-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathend_to_end_encryption-files.mjs
More file actions
2 lines (2 loc) · 498 KB
/
end_to_end_encryption-files.mjs
File metadata and controls
2 lines (2 loc) · 498 KB
1
2
(function(){"use strict";try{if(typeof document<"u"){var i=document.createElement("style");i.appendChild(document.createTextNode("/*!\n * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors\n * SPDX-License-Identifier: AGPL-3.0-or-later\n */.toastify.dialogs{min-width:200px;background:none;background-color:var(--color-main-background);color:var(--color-main-text);box-shadow:0 0 6px 0 var(--color-box-shadow);padding:0 12px;margin-top:45px;position:fixed;z-index:10100;border-radius:var(--border-radius);display:flex;align-items:center}.toastify.dialogs .toast-undo-container{display:flex;align-items:center}.toastify.dialogs .toast-undo-button,.toastify.dialogs .toast-close{position:static;overflow:hidden;box-sizing:border-box;min-width:44px;height:100%;padding:12px;white-space:nowrap;background-repeat:no-repeat;background-position:center;background-color:transparent;min-height:0}.toastify.dialogs .toast-undo-button.toast-close,.toastify.dialogs .toast-close.toast-close{text-indent:0;opacity:.4;border:none;min-height:44px;margin-left:10px;font-size:0}.toastify.dialogs .toast-undo-button.toast-close:before,.toastify.dialogs .toast-close.toast-close:before{background-image:url(\"data:image/svg+xml,%3csvg%20viewBox='0%200%2016%2016'%20height='16'%20width='16'%20xmlns='http://www.w3.org/2000/svg'%20xml:space='preserve'%20style='fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2'%3e%3cpath%20d='M6.4%2019%205%2017.6l5.6-5.6L5%206.4%206.4%205l5.6%205.6L17.6%205%2019%206.4%2013.4%2012l5.6%205.6-1.4%201.4-5.6-5.6L6.4%2019Z'%20style='fill-rule:nonzero'%20transform='matrix(.85714%200%200%20.85714%20-2.286%20-2.286)'/%3e%3c/svg%3e\");content:\" \";filter:var(--background-invert-if-dark);display:inline-block;width:16px;height:16px}.toastify.dialogs .toast-undo-button.toast-undo-button,.toastify.dialogs .toast-close.toast-undo-button{height:calc(100% - 6px);margin:3px 3px 3px 12px}.toastify.dialogs .toast-undo-button:hover,.toastify.dialogs .toast-undo-button:focus,.toastify.dialogs .toast-undo-button:active,.toastify.dialogs .toast-close:hover,.toastify.dialogs .toast-close:focus,.toastify.dialogs .toast-close:active{cursor:pointer;opacity:1}.toastify.dialogs.toastify-top{right:10px}.toastify.dialogs.toast-with-click{cursor:pointer}.toastify.dialogs.toast-error{border-left:3px solid var(--color-error)}.toastify.dialogs.toast-info{border-left:3px solid var(--color-primary)}.toastify.dialogs.toast-warning{border-left:3px solid var(--color-warning)}.toastify.dialogs.toast-success,.toastify.dialogs.toast-undo{border-left:3px solid var(--color-success)}.theme--dark .toastify.dialogs .toast-close.toast-close:before{background-image:url(\"data:image/svg+xml,%3csvg%20viewBox='0%200%2016%2016'%20height='16'%20width='16'%20xmlns='http://www.w3.org/2000/svg'%20xml:space='preserve'%20style='fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2'%3e%3cpath%20d='M6.4%2019%205%2017.6l5.6-5.6L5%206.4%206.4%205l5.6%205.6L17.6%205%2019%206.4%2013.4%2012l5.6%205.6-1.4%201.4-5.6-5.6L6.4%2019Z'%20style='fill:%23fff;fill-rule:nonzero'%20transform='matrix(.85714%200%200%20.85714%20-2.286%20-2.286)'/%3e%3c/svg%3e\")}.nc-generic-dialog .dialog__actions{justify-content:space-between;min-width:calc(100% - 12px)}/*!\n * SPDX-FileCopyrightText: 2023-2024 Nextcloud GmbH and Nextcloud contributors\n * SPDX-License-Identifier: AGPL-3.0-or-later\n */._file-picker__file-icon_19mjt_9{width:32px;height:32px;min-width:32px;min-height:32px;background-repeat:no-repeat;background-size:contain;display:flex;justify-content:center}tr.file-picker__row[data-v-15187afc]{height:var(--row-height, 50px)}tr.file-picker__row td[data-v-15187afc]{cursor:pointer;overflow:hidden;text-overflow:ellipsis;border-bottom:none}tr.file-picker__row td.row-checkbox[data-v-15187afc]{padding:0 2px}tr.file-picker__row td[data-v-15187afc]:not(.row-checkbox){padding-inline:14px 0}tr.file-picker__row td.row-size[data-v-15187afc]{text-align:end;padding-inline:0 14px}tr.file-picker__row td.row-name[data-v-15187afc]{padding-inline:2px 0}@keyframes gradient-15187afc{0%{background-position:0% 50%}50%{background-position:100% 50%}to{background-position:0% 50%}}.loading-row .row-checkbox[data-v-15187afc]{text-align:center!important}.loading-row span[data-v-15187afc]{display:inline-block;height:24px;background:linear-gradient(to right,var(--color-background-darker),var(--color-text-maxcontrast),var(--color-background-darker));background-size:600px 100%;border-radius:var(--border-radius);animation:gradient-15187afc 12s ease infinite}.loading-row .row-wrapper[data-v-15187afc]{display:inline-flex;align-items:center}.loading-row .row-checkbox span[data-v-15187afc]{width:24px}.loading-row .row-name span[data-v-15187afc]:last-of-type{margin-inline-start:6px;width:130px}.loading-row .row-size span[data-v-15187afc]{width:80px}.loading-row .row-modified span[data-v-15187afc]{width:90px}/*!\n* SPDX-FileCopyrightText: 2023-2024 Nextcloud GmbH and Nextcloud contributors\n* SPDX-License-Identifier: AGPL-3.0-or-later\n*/tr.file-picker__row[data-v-cb12dccb]{height:var(--row-height, 50px)}tr.file-picker__row td[data-v-cb12dccb]{cursor:pointer;overflow:hidden;text-overflow:ellipsis;border-bottom:none}tr.file-picker__row td.row-checkbox[data-v-cb12dccb]{padding:0 2px}tr.file-picker__row td[data-v-cb12dccb]:not(.row-checkbox){padding-inline:14px 0}tr.file-picker__row td.row-size[data-v-cb12dccb]{text-align:end;padding-inline:0 14px}tr.file-picker__row td.row-name[data-v-cb12dccb]{padding-inline:2px 0}.file-picker__row--selected[data-v-cb12dccb]{background-color:var(--color-background-dark)}.file-picker__row[data-v-cb12dccb]:hover{background-color:var(--color-background-hover)}.file-picker__name-container[data-v-cb12dccb]{display:flex;justify-content:start;align-items:center;height:100%}.file-picker__file-name[data-v-cb12dccb]{padding-inline-start:6px;min-width:0;overflow:hidden;text-overflow:ellipsis}.file-picker__file-extension[data-v-cb12dccb]{color:var(--color-text-maxcontrast);min-width:fit-content}.file-picker__header-preview[data-v-006fdbd0]{width:22px;height:32px;flex:0 0 auto}.file-picker__files[data-v-006fdbd0]{margin:2px;margin-inline-start:12px;overflow:scroll auto}.file-picker__files table[data-v-006fdbd0]{width:100%;max-height:100%;table-layout:fixed}.file-picker__files th[data-v-006fdbd0]{position:-webkit-sticky;position:sticky;z-index:1;top:0;background-color:var(--color-main-background);padding:2px}.file-picker__files th .header-wrapper[data-v-006fdbd0]{display:flex}.file-picker__files th.row-checkbox[data-v-006fdbd0]{width:44px}.file-picker__files th.row-name[data-v-006fdbd0]{width:230px}.file-picker__files th.row-size[data-v-006fdbd0]{width:100px}.file-picker__files th.row-modified[data-v-006fdbd0]{width:120px}.file-picker__files th[data-v-006fdbd0]:not(.row-size) .button-vue__wrapper{justify-content:start;flex-direction:row-reverse}.file-picker__files th[data-v-006fdbd0]:not(.row-size) .button-vue{padding-inline:16px 4px}.file-picker__files th.row-size[data-v-006fdbd0] .button-vue__wrapper{justify-content:end}.file-picker__files th[data-v-006fdbd0] .button-vue__wrapper{color:var(--color-text-maxcontrast)}.file-picker__files th[data-v-006fdbd0] .button-vue__wrapper .button-vue__text{font-weight:400}.file-picker__breadcrumbs[data-v-b357227a]{flex-grow:0!important}.file-picker__side[data-v-b42054b8]{display:flex;flex-direction:column;align-items:stretch;gap:.5rem;min-width:200px;padding:2px;margin-block-start:7px;overflow:auto}.file-picker__side[data-v-b42054b8] .button-vue__wrapper{justify-content:start}.file-picker__filter-input[data-v-b42054b8]{margin-block:7px;max-width:260px}@media (max-width: 736px){.file-picker__side[data-v-b42054b8]{flex-direction:row;min-width:unset}}@media (max-width: 512px){.file-picker__side[data-v-b42054b8]{flex-direction:row;min-width:unset}.file-picker__filter-input[data-v-b42054b8]{max-width:unset}}.file-picker__navigation{padding-inline:8px 2px}.file-picker__navigation,.file-picker__navigation *{box-sizing:border-box}.file-picker__navigation .v-select.select{min-width:220px}@media (min-width: 513px) and (max-width: 736px){.file-picker__navigation{gap:11px}}@media (max-width: 512px){.file-picker__navigation{flex-direction:column-reverse!important}}.file-picker__view[data-v-20b719ba]{height:50px;display:flex;justify-content:start;align-items:center}.file-picker__view h3[data-v-20b719ba]{font-weight:700;height:fit-content;margin:0}.file-picker__main[data-v-20b719ba]{box-sizing:border-box;width:100%;display:flex;flex-direction:column;min-height:0;flex:1;padding-inline:2px}.file-picker__main *[data-v-20b719ba]{box-sizing:border-box}[data-v-20b719ba] .file-picker{height:min(80vh,800px)!important}@media (max-width: 512px){[data-v-20b719ba] .file-picker{height:calc(100% - 16px - var(--default-clickable-area))!important}}[data-v-20b719ba] .file-picker__content{display:flex;flex-direction:column;overflow:hidden}.material-design-icon[data-v-e4fac465]{display:flex;align-self:center;justify-self:center;align-items:center;justify-content:center}.input-field[data-v-e4fac465]{--input-border-radius: var(--border-radius-element, var(--border-radius-large));--input-padding-start: var(--border-radius-large);--input-padding-end: var(--border-radius-large);position:relative;width:100%;margin-block-start:6px}.input-field--disabled[data-v-e4fac465]{opacity:.4;filter:saturate(.4)}.input-field--label-outside[data-v-e4fac465]{margin-block-start:0}.input-field--leading-icon[data-v-e4fac465]{--input-padding-start: calc(var(--default-clickable-area) - var(--default-grid-baseline))}.input-field--trailing-icon[data-v-e4fac465]{--input-padding-end: calc(var(--default-clickable-area) - var(--default-grid-baseline))}.input-field--pill[data-v-e4fac465]{--input-border-radius: var(--border-radius-pill)}.input-field__main-wrapper[data-v-e4fac465]{height:var(--default-clickable-area);position:relative}.input-field__input[data-v-e4fac465]{--input-border-width-offset: calc(var(--border-width-input-focused, 2px) - var(--border-width-input, 2px));background-color:var(--color-main-background);color:var(--color-main-text);border:var(--border-width-input, 2px) solid var(--color-border-maxcontrast);border-radius:var(--input-border-radius);cursor:pointer;-webkit-appearance:textfield!important;-moz-appearance:textfield!important;appearance:textfield!important;font-size:var(--default-font-size);text-overflow:ellipsis;height:calc(var(--default-clickable-area) - 2 * var(--input-border-width-offset))!important;width:100%;padding-inline:calc(var(--input-padding-start) + var(--input-border-width-offset)) calc(var(--input-padding-end) + var(--input-border-width-offset));padding-block:var(--input-border-width-offset)}.input-field__input[data-v-e4fac465]::placeholder{color:var(--color-text-maxcontrast)}.input-field__input[data-v-e4fac465]:active:not([disabled]),.input-field__input[data-v-e4fac465]:hover:not([disabled]),.input-field__input[data-v-e4fac465]:focus:not([disabled]){border-color:var(--color-main-text);border-width:var(--border-width-input-focused, 2px);box-shadow:0 0 0 2px var(--color-main-background)!important;--input-border-width-offset: 0px}.input-field__input:focus+.input-field__label[data-v-e4fac465],.input-field__input:hover:not(:placeholder-shown)+.input-field__label[data-v-e4fac465]{color:var(--color-main-text)}.input-field__input[data-v-e4fac465]:focus{cursor:text}.input-field__input[data-v-e4fac465]:disabled{cursor:default}.input-field__input[data-v-e4fac465]:focus-visible{box-shadow:unset!important}.input-field__input--success[data-v-e4fac465]{border-color:var(--color-success)!important}.input-field__input--success[data-v-e4fac465]:focus-visible{box-shadow:#f8fafc 0 0 0 2px,var(--color-primary-element) 0 0 0 4px,#0000000d 0 1px 2px}.input-field__input--error[data-v-e4fac465],.input-field__input[data-v-e4fac465]:invalid{border-color:var(--color-error)!important}.input-field__input--error[data-v-e4fac465]:focus-visible,.input-field__input[data-v-e4fac465]:invalid:focus-visible{box-shadow:#f8fafc 0 0 0 2px,var(--color-primary-element) 0 0 0 4px,#0000000d 0 1px 2px}.input-field:not(.input-field--label-outside) .input-field__input[data-v-e4fac465]:not(:focus)::placeholder{opacity:0}.input-field__label[data-v-e4fac465]{--input-label-font-size: var(--default-font-size);position:absolute;margin-inline:var(--input-padding-start) var(--input-padding-end);max-width:fit-content;font-size:var(--input-label-font-size);inset-block-start:calc((var(--default-clickable-area) - 1lh) / 2);inset-inline:var(--border-width-input-focused, 2px);color:var(--color-text-maxcontrast);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;pointer-events:none;transition:height var(--animation-quick),inset-block-start var(--animation-quick),font-size var(--animation-quick),color var(--animation-quick),background-color var(--animation-quick) var(--animation-slow)}.input-field__input:focus+.input-field__label[data-v-e4fac465],.input-field__input:not(:placeholder-shown)+.input-field__label[data-v-e4fac465]{--input-label-font-size: 13px;line-height:1.5;inset-block-start:calc(-1.5 * var(--input-label-font-size) / 2);font-weight:500;border-radius:var(--default-grid-baseline) var(--default-grid-baseline) 0 0;background-color:var(--color-main-background);padding-inline:var(--default-grid-baseline);margin-inline:calc(var(--input-padding-start) - var(--default-grid-baseline)) calc(var(--input-padding-end) - var(--default-grid-baseline));transition:height var(--animation-quick),inset-block-start var(--animation-quick),font-size var(--animation-quick),color var(--animation-quick)}.input-field__icon[data-v-e4fac465]{position:absolute;height:var(--default-clickable-area);width:var(--default-clickable-area);display:flex;align-items:center;justify-content:center;opacity:.7;inset-block-end:0}.input-field__icon--leading[data-v-e4fac465]{inset-inline-start:0px}.input-field__icon--trailing[data-v-e4fac465]{inset-inline-end:0px}.input-field__trailing-button[data-v-e4fac465]{--button-size: calc(var(--default-clickable-area) - 2 * var(--border-width-input-focused, 2px)) !important;--button-radius: calc(var(--input-border-radius) - var(--border-width-input-focused, 2px))}.input-field__trailing-button.button-vue[data-v-e4fac465]{position:absolute;top:var(--border-width-input-focused, 2px);inset-inline-end:var(--border-width-input-focused, 2px)}.input-field__trailing-button.button-vue[data-v-e4fac465]:focus-visible{box-shadow:none!important}.input-field__helper-text-message[data-v-e4fac465]{padding-block:4px;padding-inline:var(--border-radius-large);display:flex;align-items:center;color:var(--color-text-maxcontrast)}.input-field__helper-text-message__icon[data-v-e4fac465]{margin-inline-end:8px}.input-field__helper-text-message--error[data-v-e4fac465]{color:var(--color-error-text)}.input-field__helper-text-message--success[data-v-e4fac465]{color:var(--color-success-text)}")),document.head.appendChild(i)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();
var Jg=Object.defineProperty,qg=Object.defineProperties;var Wg=Object.getOwnPropertyDescriptors;var pd=Object.getOwnPropertySymbols;var Gg=Object.prototype.hasOwnProperty,zg=Object.prototype.propertyIsEnumerable;var gd=r=>{throw TypeError(r)};var Qh=(r,e,t)=>e in r?Jg(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,it=(r,e)=>{for(var t in e||(e={}))Gg.call(e,t)&&Qh(r,t,e[t]);if(pd)for(var t of pd(e))zg.call(e,t)&&Qh(r,t,e[t]);return r},os=(r,e)=>qg(r,Wg(e));var Ke=(r,e,t)=>Qh(r,typeof e!="symbol"?e+"":e,t),Yh=(r,e,t)=>e.has(r)||gd("Cannot "+t);var H=(r,e,t)=>(Yh(r,e,"read from private field"),t?t.call(r):e.get(r)),Et=(r,e,t)=>e.has(r)?gd("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),Be=(r,e,t,s)=>(Yh(r,e,"write to private field"),s?s.call(r,t):e.set(r,t),t),zs=(r,e,t)=>(Yh(r,e,"access private method"),t);import{p as Ge,g as It,l as Lf,a as Gm,b as Uf,U as _g,o as Xg,c as Zg,d as Bp,v as Pp,n as lc,N as Qg,G as Yg,r as ew,C as tw,t as em,e as sw,f as rw,h as aw,i as tm,j as wd,k as zm,m as nw,q as iw,s as ow,u as uw,w as No}from"./_plugin-vue2_normalizer-CRvlGwWh.chunk.mjs";import{f as Le,B as pe,s as ko,a as Nh,O as $,N as Fe,I as B,S as A,g as f,A as X,b as J,c as T,d as R,e as re,C as I,R as Z,h as Ne,P as _,i as ce,j as Je,G as ke,k as ia,u as go,l as Zl,m as kh,t as _m,n as Ql,o as lw,p as cw,q as yd,r as vd,E as Yl,U as Xm,v as Ch,w as Zm,x as Qm,y as Mc,z as Ts,T as Ym,V as hw,D as Op,F as mw,H as fw,J as dw,K as pw,X as gw,L as ww}from"./ArrowRight-CY2b9hgN-DDNQW0w5.chunk.mjs";import{u as Dp}from"./useModelMigration-EhAWvqDD-DncDLzJM.chunk.mjs";import{N as yw}from"./NcCheckboxRadioSwitch-R1y0mLbC-BF-LH75D.chunk.mjs";function tr(r,e,t){return e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function bd(r,e,t){vw(r,e),e.set(r,t)}function vw(r,e){if(e.has(r))throw new TypeError("Cannot initialize the same private elements twice on an object")}function at(r,e){var t=Tp(r,e,"get");return bw(r,t)}function bw(r,e){return e.get?e.get.call(r):e.value}function Sd(r,e,t){var s=Tp(r,e,"set");return Sw(r,s,t),t}function Tp(r,e,t){if(!e.has(r))throw new TypeError("attempted to "+t+" private field on non-instance");return e.get(r)}function Sw(r,e,t){if(e.set)e.set.call(r,t);else{if(!e.writable)throw new TypeError("attempted to set read only private field");e.value=t}}var Aw=typeof Symbol<"u"?Symbol.toStringTag:"@@toStringTag",ot=new WeakMap,Po=new WeakMap;class Wh{constructor(e){var{executor:t=()=>{},internals:s=$f(),promise:a=new Promise((n,u)=>t(n,u,i=>{s.onCancelList.push(i)}))}=e;bd(this,ot,{writable:!0,value:void 0}),bd(this,Po,{writable:!0,value:void 0}),tr(this,Aw,"CancelablePromise"),this.cancel=this.cancel.bind(this),Sd(this,ot,s),Sd(this,Po,a||new Promise((n,u)=>t(n,u,i=>{s.onCancelList.push(i)})))}then(e,t){return Fc(at(this,Po).then(mc(e,at(this,ot)),mc(t,at(this,ot))),at(this,ot))}catch(e){return Fc(at(this,Po).catch(mc(e,at(this,ot))),at(this,ot))}finally(e,t){return t&&at(this,ot).onCancelList.push(e),Fc(at(this,Po).finally(mc(()=>{if(e)return t&&(at(this,ot).onCancelList=at(this,ot).onCancelList.filter(s=>s!==e)),e()},at(this,ot))),at(this,ot))}cancel(){at(this,ot).isCanceled=!0;var e=at(this,ot).onCancelList;at(this,ot).onCancelList=[];for(var t of e)if(typeof t=="function")try{t()}catch(s){console.error(s)}}isCanceled(){return at(this,ot).isCanceled===!0}}class sr extends Wh{constructor(e){super({executor:e})}}tr(sr,"all",function(r){return fc(r,Promise.all(r))}),tr(sr,"allSettled",function(r){return fc(r,Promise.allSettled(r))}),tr(sr,"any",function(r){return fc(r,Promise.any(r))}),tr(sr,"race",function(r){return fc(r,Promise.race(r))}),tr(sr,"resolve",function(r){return Ad(Promise.resolve(r))}),tr(sr,"reject",function(r){return Ad(Promise.reject(r))}),tr(sr,"isCancelable",jf);function Ad(r){return Fc(r,$f())}function jf(r){return r instanceof sr||r instanceof Wh}function mc(r,e){if(r)return t=>{if(!e.isCanceled){var s=r(t);return jf(s)&&e.onCancelList.push(s.cancel),s}return t}}function Fc(r,e){return new Wh({internals:e,promise:r})}function fc(r,e){var t=$f();return t.onCancelList.push(()=>{for(var s of r)jf(s)&&s.cancel()}),new Wh({internals:t,promise:e})}function $f(){return{isCanceled:!1,onCancelList:[]}}var sm={},Nw={2:r=>{function e(a,n,u){a instanceof RegExp&&(a=t(a,u)),n instanceof RegExp&&(n=t(n,u));var i=s(a,n,u);return i&&{start:i[0],end:i[1],pre:u.slice(0,i[0]),body:u.slice(i[0]+a.length,i[1]),post:u.slice(i[1]+n.length)}}function t(a,n){var u=n.match(a);return u?u[0]:null}function s(a,n,u){var i,l,o,c,m,h=u.indexOf(a),p=u.indexOf(n,h+1),d=h;if(h>=0&&p>0){for(i=[],o=u.length;d>=0&&!m;)d==h?(i.push(d),h=u.indexOf(a,d+1)):i.length==1?m=[i.pop(),p]:((l=i.pop())<o&&(o=l,c=p),p=u.indexOf(n,d+1)),d=h<p&&h>=0?h:p;i.length&&(m=[o,c])}return m}r.exports=e,e.range=s},101:function(r,e,t){var s;r=t.nmd(r),function(a){var n=(r&&r.exports,typeof It=="object"&&It);n.global!==n&&n.window;var u=function(m){this.message=m};(u.prototype=new Error).name="InvalidCharacterError";var i=function(m){throw new u(m)},l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=/[\t\n\f\r ]/g,c={encode:function(m){m=String(m),/[^\0-\xFF]/.test(m)&&i("The string to be encoded contains characters outside of the Latin1 range.");for(var h,p,d,w,y=m.length%3,k="",g=-1,b=m.length-y;++g<b;)h=m.charCodeAt(g)<<16,p=m.charCodeAt(++g)<<8,d=m.charCodeAt(++g),k+=l.charAt((w=h+p+d)>>18&63)+l.charAt(w>>12&63)+l.charAt(w>>6&63)+l.charAt(63&w);return y==2?(h=m.charCodeAt(g)<<8,p=m.charCodeAt(++g),k+=l.charAt((w=h+p)>>10)+l.charAt(w>>4&63)+l.charAt(w<<2&63)+"="):y==1&&(w=m.charCodeAt(g),k+=l.charAt(w>>2)+l.charAt(w<<4&63)+"=="),k},decode:function(m){var h=(m=String(m).replace(o,"")).length;h%4==0&&(h=(m=m.replace(/==?$/,"")).length),(h%4==1||/[^+a-zA-Z0-9/]/.test(m))&&i("Invalid character: the string to be decoded is not correctly encoded.");for(var p,d,w=0,y="",k=-1;++k<h;)d=l.indexOf(m.charAt(k)),p=w%4?64*p+d:d,w++%4&&(y+=String.fromCharCode(255&p>>(-2*w&6)));return y},version:"1.0.0"};(s=function(){return c}.call(e,t,e,r))===void 0||(r.exports=s)}()},172:(r,e)=>{e.d=function(t){if(!t)return 0;for(var s=(t=t.toString()).length,a=t.length;a--;){var n=t.charCodeAt(a);56320<=n&&n<=57343&&a--,127<n&&n<=2047?s++:2047<n&&n<=65535&&(s+=2)}return s}},526:r=>{var e={utf8:{stringToBytes:function(t){return e.bin.stringToBytes(unescape(encodeURIComponent(t)))},bytesToString:function(t){return decodeURIComponent(escape(e.bin.bytesToString(t)))}},bin:{stringToBytes:function(t){for(var s=[],a=0;a<t.length;a++)s.push(255&t.charCodeAt(a));return s},bytesToString:function(t){for(var s=[],a=0;a<t.length;a++)s.push(String.fromCharCode(t[a]));return s.join("")}}};r.exports=e},298:r=>{var e,t;e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t={rotl:function(s,a){return s<<a|s>>>32-a},rotr:function(s,a){return s<<32-a|s>>>a},endian:function(s){if(s.constructor==Number)return 16711935&t.rotl(s,8)|4278255360&t.rotl(s,24);for(var a=0;a<s.length;a++)s[a]=t.endian(s[a]);return s},randomBytes:function(s){for(var a=[];s>0;s--)a.push(Math.floor(256*Math.random()));return a},bytesToWords:function(s){for(var a=[],n=0,u=0;n<s.length;n++,u+=8)a[u>>>5]|=s[n]<<24-u%32;return a},wordsToBytes:function(s){for(var a=[],n=0;n<32*s.length;n+=8)a.push(s[n>>>5]>>>24-n%32&255);return a},bytesToHex:function(s){for(var a=[],n=0;n<s.length;n++)a.push((s[n]>>>4).toString(16)),a.push((15&s[n]).toString(16));return a.join("")},hexToBytes:function(s){for(var a=[],n=0;n<s.length;n+=2)a.push(parseInt(s.substr(n,2),16));return a},bytesToBase64:function(s){for(var a=[],n=0;n<s.length;n+=3)for(var u=s[n]<<16|s[n+1]<<8|s[n+2],i=0;i<4;i++)8*n+6*i<=8*s.length?a.push(e.charAt(u>>>6*(3-i)&63)):a.push("=");return a.join("")},base64ToBytes:function(s){s=s.replace(/[^A-Z0-9+\/]/gi,"");for(var a=[],n=0,u=0;n<s.length;u=++n%4)u!=0&&a.push((e.indexOf(s.charAt(n-1))&Math.pow(2,-2*u+8)-1)<<2*u|e.indexOf(s.charAt(n))>>>6-2*u);return a}},r.exports=t},635:(r,e,t)=>{const s=t(31),a=t(338),n=t(221);r.exports={XMLParser:a,XMLValidator:s,XMLBuilder:n}},705:(r,e)=>{const t=":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",s="["+t+"]["+t+"\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*",a=new RegExp("^"+s+"$");e.isExist=function(n){return n!==void 0},e.isEmptyObject=function(n){return Object.keys(n).length===0},e.merge=function(n,u,i){if(u){const l=Object.keys(u),o=l.length;for(let c=0;c<o;c++)n[l[c]]=i==="strict"?[u[l[c]]]:u[l[c]]}},e.getValue=function(n){return e.isExist(n)?n:""},e.isName=function(n){return a.exec(n)!=null},e.getAllMatches=function(n,u){const i=[];let l=u.exec(n);for(;l;){const o=[];o.startIndex=u.lastIndex-l[0].length;const c=l.length;for(let m=0;m<c;m++)o.push(l[m]);i.push(o),l=u.exec(n)}return i},e.nameRegexp=s},31:(r,e,t)=>{const s=t(705),a={allowBooleanAttributes:!1,unpairedTags:[]};function n(g){return g===" "||g===" "||g==="\n"||g==="\r"}function u(g,b){const N=b;for(;b<g.length;b++)if(!(g[b]!="?"&&g[b]!=" ")){const S=g.substr(N,b-N);if(b>5&&S==="xml")return d("InvalidXml","XML declaration allowed only at the start of the document.",y(g,b));if(g[b]=="?"&&g[b+1]==">"){b++;break}}return b}function i(g,b){if(g.length>b+5&&g[b+1]==="-"&&g[b+2]==="-"){for(b+=3;b<g.length;b++)if(g[b]==="-"&&g[b+1]==="-"&&g[b+2]===">"){b+=2;break}}else if(g.length>b+8&&g[b+1]==="D"&&g[b+2]==="O"&&g[b+3]==="C"&&g[b+4]==="T"&&g[b+5]==="Y"&&g[b+6]==="P"&&g[b+7]==="E"){let N=1;for(b+=8;b<g.length;b++)if(g[b]==="<")N++;else if(g[b]===">"&&(N--,N===0))break}else if(g.length>b+9&&g[b+1]==="["&&g[b+2]==="C"&&g[b+3]==="D"&&g[b+4]==="A"&&g[b+5]==="T"&&g[b+6]==="A"&&g[b+7]==="["){for(b+=8;b<g.length;b++)if(g[b]==="]"&&g[b+1]==="]"&&g[b+2]===">"){b+=2;break}}return b}e.validate=function(g,b){b=Object.assign({},a,b);const N=[];let S=!1,E=!1;g[0]==="\uFEFF"&&(g=g.substr(1));for(let C=0;C<g.length;C++)if(g[C]==="<"&&g[C+1]==="?"){if(C+=2,C=u(g,C),C.err)return C}else{if(g[C]!=="<"){if(n(g[C]))continue;return d("InvalidChar","char '"+g[C]+"' is not expected.",y(g,C))}{let P=C;if(C++,g[C]==="!"){C=i(g,C);continue}{let K=!1;g[C]==="/"&&(K=!0,C++);let L="";for(;C<g.length&&g[C]!==">"&&g[C]!==" "&&g[C]!==" "&&g[C]!=="\n"&&g[C]!=="\r";C++)L+=g[C];if(L=L.trim(),L[L.length-1]==="/"&&(L=L.substring(0,L.length-1),C--),x=L,!s.isName(x)){let M;return M=L.trim().length===0?"Invalid space after '<'.":"Tag '"+L+"' is an invalid name.",d("InvalidTag",M,y(g,C))}const j=c(g,C);if(j===!1)return d("InvalidAttr","Attributes for '"+L+"' have open quote.",y(g,C));let U=j.value;if(C=j.index,U[U.length-1]==="/"){const M=C-U.length;U=U.substring(0,U.length-1);const G=h(U,b);if(G!==!0)return d(G.err.code,G.err.msg,y(g,M+G.err.line));S=!0}else if(K){if(!j.tagClosed)return d("InvalidTag","Closing tag '"+L+"' doesn't have proper closing.",y(g,C));if(U.trim().length>0)return d("InvalidTag","Closing tag '"+L+"' can't have attributes or invalid starting.",y(g,P));if(N.length===0)return d("InvalidTag","Closing tag '"+L+"' has not been opened.",y(g,P));{const M=N.pop();if(L!==M.tagName){let G=y(g,M.tagStartPos);return d("InvalidTag","Expected closing tag '"+M.tagName+"' (opened in line "+G.line+", col "+G.col+") instead of closing tag '"+L+"'.",y(g,P))}N.length==0&&(E=!0)}}else{const M=h(U,b);if(M!==!0)return d(M.err.code,M.err.msg,y(g,C-U.length+M.err.line));if(E===!0)return d("InvalidXml","Multiple possible root nodes found.",y(g,C));b.unpairedTags.indexOf(L)!==-1||N.push({tagName:L,tagStartPos:P}),S=!0}for(C++;C<g.length;C++)if(g[C]==="<"){if(g[C+1]==="!"){C++,C=i(g,C);continue}if(g[C+1]!=="?")break;if(C=u(g,++C),C.err)return C}else if(g[C]==="&"){const M=p(g,C);if(M==-1)return d("InvalidChar","char '&' is not expected.",y(g,C));C=M}else if(E===!0&&!n(g[C]))return d("InvalidXml","Extra text at the end",y(g,C));g[C]==="<"&&C--}}}var x;return S?N.length==1?d("InvalidTag","Unclosed tag '"+N[0].tagName+"'.",y(g,N[0].tagStartPos)):!(N.length>0)||d("InvalidXml","Invalid '"+JSON.stringify(N.map(C=>C.tagName),null,4).replace(/\r?\n/g,"")+"' found.",{line:1,col:1}):d("InvalidXml","Start tag expected.",1)};const l='"',o="'";function c(g,b){let N="",S="",E=!1;for(;b<g.length;b++){if(g[b]===l||g[b]===o)S===""?S=g[b]:S!==g[b]||(S="");else if(g[b]===">"&&S===""){E=!0;break}N+=g[b]}return S===""&&{value:N,index:b,tagClosed:E}}const m=new RegExp("(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['\"])(([\\s\\S])*?)\\5)?","g");function h(g,b){const N=s.getAllMatches(g,m),S={};for(let E=0;E<N.length;E++){if(N[E][1].length===0)return d("InvalidAttr","Attribute '"+N[E][2]+"' has no space in starting.",k(N[E]));if(N[E][3]!==void 0&&N[E][4]===void 0)return d("InvalidAttr","Attribute '"+N[E][2]+"' is without value.",k(N[E]));if(N[E][3]===void 0&&!b.allowBooleanAttributes)return d("InvalidAttr","boolean attribute '"+N[E][2]+"' is not allowed.",k(N[E]));const x=N[E][2];if(!w(x))return d("InvalidAttr","Attribute '"+x+"' is an invalid name.",k(N[E]));if(S.hasOwnProperty(x))return d("InvalidAttr","Attribute '"+x+"' is repeated.",k(N[E]));S[x]=1}return!0}function p(g,b){if(g[++b]===";")return-1;if(g[b]==="#")return function(S,E){let x=/\d/;for(S[E]==="x"&&(E++,x=/[\da-fA-F]/);E<S.length;E++){if(S[E]===";")return E;if(!S[E].match(x))break}return-1}(g,++b);let N=0;for(;b<g.length;b++,N++)if(!(g[b].match(/\w/)&&N<20)){if(g[b]===";")break;return-1}return b}function d(g,b,N){return{err:{code:g,msg:b,line:N.line||N,col:N.col}}}function w(g){return s.isName(g)}function y(g,b){const N=g.substring(0,b).split(/\r?\n/);return{line:N.length,col:N[N.length-1].length+1}}function k(g){return g.startIndex+g[1].length}},221:(r,e,t)=>{const s=t(87),a={attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,cdataPropName:!1,format:!1,indentBy:" ",suppressEmptyNode:!1,suppressUnpairedNode:!0,suppressBooleanAttributes:!0,tagValueProcessor:function(o,c){return c},attributeValueProcessor:function(o,c){return c},preserveOrder:!1,commentPropName:!1,unpairedTags:[],entities:[{regex:new RegExp("&","g"),val:"&"},{regex:new RegExp(">","g"),val:">"},{regex:new RegExp("<","g"),val:"<"},{regex:new RegExp("'","g"),val:"'"},{regex:new RegExp('"',"g"),val:"""}],processEntities:!0,stopNodes:[],oneListGroup:!1};function n(o){this.options=Object.assign({},a,o),this.options.ignoreAttributes||this.options.attributesGroupName?this.isAttribute=function(){return!1}:(this.attrPrefixLen=this.options.attributeNamePrefix.length,this.isAttribute=l),this.processTextOrObjNode=u,this.options.format?(this.indentate=i,this.tagEndChar=">\n",this.newLine="\n"):(this.indentate=function(){return""},this.tagEndChar=">",this.newLine="")}function u(o,c,m){const h=this.j2x(o,m+1);return o[this.options.textNodeName]!==void 0&&Object.keys(o).length===1?this.buildTextValNode(o[this.options.textNodeName],c,h.attrStr,m):this.buildObjectNode(h.val,c,h.attrStr,m)}function i(o){return this.options.indentBy.repeat(o)}function l(o){return!(!o.startsWith(this.options.attributeNamePrefix)||o===this.options.textNodeName)&&o.substr(this.attrPrefixLen)}n.prototype.build=function(o){return this.options.preserveOrder?s(o,this.options):(Array.isArray(o)&&this.options.arrayNodeName&&this.options.arrayNodeName.length>1&&(o={[this.options.arrayNodeName]:o}),this.j2x(o,0).val)},n.prototype.j2x=function(o,c){let m="",h="";for(let p in o)if(Object.prototype.hasOwnProperty.call(o,p))if(o[p]===void 0)this.isAttribute(p)&&(h+="");else if(o[p]===null)this.isAttribute(p)?h+="":p[0]==="?"?h+=this.indentate(c)+"<"+p+"?"+this.tagEndChar:h+=this.indentate(c)+"<"+p+"/"+this.tagEndChar;else if(o[p]instanceof Date)h+=this.buildTextValNode(o[p],p,"",c);else if(typeof o[p]!="object"){const d=this.isAttribute(p);if(d)m+=this.buildAttrPairStr(d,""+o[p]);else if(p===this.options.textNodeName){let w=this.options.tagValueProcessor(p,""+o[p]);h+=this.replaceEntitiesValue(w)}else h+=this.buildTextValNode(o[p],p,"",c)}else if(Array.isArray(o[p])){const d=o[p].length;let w="",y="";for(let k=0;k<d;k++){const g=o[p][k];if(g!==void 0)if(g===null)p[0]==="?"?h+=this.indentate(c)+"<"+p+"?"+this.tagEndChar:h+=this.indentate(c)+"<"+p+"/"+this.tagEndChar;else if(typeof g=="object")if(this.options.oneListGroup){const b=this.j2x(g,c+1);w+=b.val,this.options.attributesGroupName&&g.hasOwnProperty(this.options.attributesGroupName)&&(y+=b.attrStr)}else w+=this.processTextOrObjNode(g,p,c);else if(this.options.oneListGroup){let b=this.options.tagValueProcessor(p,g);b=this.replaceEntitiesValue(b),w+=b}else w+=this.buildTextValNode(g,p,"",c)}this.options.oneListGroup&&(w=this.buildObjectNode(w,p,y,c)),h+=w}else if(this.options.attributesGroupName&&p===this.options.attributesGroupName){const d=Object.keys(o[p]),w=d.length;for(let y=0;y<w;y++)m+=this.buildAttrPairStr(d[y],""+o[p][d[y]])}else h+=this.processTextOrObjNode(o[p],p,c);return{attrStr:m,val:h}},n.prototype.buildAttrPairStr=function(o,c){return c=this.options.attributeValueProcessor(o,""+c),c=this.replaceEntitiesValue(c),this.options.suppressBooleanAttributes&&c==="true"?" "+o:" "+o+'="'+c+'"'},n.prototype.buildObjectNode=function(o,c,m,h){if(o==="")return c[0]==="?"?this.indentate(h)+"<"+c+m+"?"+this.tagEndChar:this.indentate(h)+"<"+c+m+this.closeTag(c)+this.tagEndChar;{let p="</"+c+this.tagEndChar,d="";return c[0]==="?"&&(d="?",p=""),!m&&m!==""||o.indexOf("<")!==-1?this.options.commentPropName!==!1&&c===this.options.commentPropName&&d.length===0?this.indentate(h)+"<!--".concat(o,"-->")+this.newLine:this.indentate(h)+"<"+c+m+d+this.tagEndChar+o+this.indentate(h)+p:this.indentate(h)+"<"+c+m+d+">"+o+p}},n.prototype.closeTag=function(o){let c="";return this.options.unpairedTags.indexOf(o)!==-1?this.options.suppressUnpairedNode||(c="/"):c=this.options.suppressEmptyNode?"/":"></".concat(o),c},n.prototype.buildTextValNode=function(o,c,m,h){if(this.options.cdataPropName!==!1&&c===this.options.cdataPropName)return this.indentate(h)+"<![CDATA[".concat(o,"]]>")+this.newLine;if(this.options.commentPropName!==!1&&c===this.options.commentPropName)return this.indentate(h)+"<!--".concat(o,"-->")+this.newLine;if(c[0]==="?")return this.indentate(h)+"<"+c+m+"?"+this.tagEndChar;{let p=this.options.tagValueProcessor(c,o);return p=this.replaceEntitiesValue(p),p===""?this.indentate(h)+"<"+c+m+this.closeTag(c)+this.tagEndChar:this.indentate(h)+"<"+c+m+">"+p+"</"+c+this.tagEndChar}},n.prototype.replaceEntitiesValue=function(o){if(o&&o.length>0&&this.options.processEntities)for(let c=0;c<this.options.entities.length;c++){const m=this.options.entities[c];o=o.replace(m.regex,m.val)}return o},r.exports=n},87:r=>{function e(u,i,l,o){let c="",m=!1;for(let h=0;h<u.length;h++){const p=u[h],d=t(p);if(d===void 0)continue;let w="";if(w=l.length===0?d:"".concat(l,".").concat(d),d===i.textNodeName){let b=p[d];a(w,i)||(b=i.tagValueProcessor(d,b),b=n(b,i)),m&&(c+=o),c+=b,m=!1;continue}if(d===i.cdataPropName){m&&(c+=o),c+="<![CDATA[".concat(p[d][0][i.textNodeName],"]]>"),m=!1;continue}if(d===i.commentPropName){c+=o+"<!--".concat(p[d][0][i.textNodeName],"-->"),m=!0;continue}if(d[0]==="?"){const b=s(p[":@"],i),N=d==="?xml"?"":o;let S=p[d][0][i.textNodeName];S=S.length!==0?" "+S:"",c+=N+"<".concat(d).concat(S).concat(b,"?>"),m=!0;continue}let y=o;y!==""&&(y+=i.indentBy);const k=o+"<".concat(d).concat(s(p[":@"],i)),g=e(p[d],i,w,y);i.unpairedTags.indexOf(d)!==-1?i.suppressUnpairedNode?c+=k+">":c+=k+"/>":g&&g.length!==0||!i.suppressEmptyNode?g&&g.endsWith(">")?c+=k+">".concat(g).concat(o,"</").concat(d,">"):(c+=k+">",g&&o!==""&&(g.includes("/>")||g.includes("</"))?c+=o+i.indentBy+g+o:c+=g,c+="</".concat(d,">")):c+=k+"/>",m=!0}return c}function t(u){const i=Object.keys(u);for(let l=0;l<i.length;l++){const o=i[l];if(u.hasOwnProperty(o)&&o!==":@")return o}}function s(u,i){let l="";if(u&&!i.ignoreAttributes)for(let o in u){if(!u.hasOwnProperty(o))continue;let c=i.attributeValueProcessor(o,u[o]);c=n(c,i),c===!0&&i.suppressBooleanAttributes?l+=" ".concat(o.substr(i.attributeNamePrefix.length)):l+=" ".concat(o.substr(i.attributeNamePrefix.length),'="').concat(c,'"')}return l}function a(u,i){let l=(u=u.substr(0,u.length-i.textNodeName.length-1)).substr(u.lastIndexOf(".")+1);for(let o in i.stopNodes)if(i.stopNodes[o]===u||i.stopNodes[o]==="*."+l)return!0;return!1}function n(u,i){if(u&&u.length>0&&i.processEntities)for(let l=0;l<i.entities.length;l++){const o=i.entities[l];u=u.replace(o.regex,o.val)}return u}r.exports=function(u,i){let l="";return i.format&&i.indentBy.length>0&&(l="\n"),e(u,i,"",l)}},193:(r,e,t)=>{const s=t(705);function a(m,h){let p="";for(;h<m.length&&m[h]!=="'"&&m[h]!=='"';h++)p+=m[h];if(p=p.trim(),p.indexOf(" ")!==-1)throw new Error("External entites are not supported");const d=m[h++];let w="";for(;h<m.length&&m[h]!==d;h++)w+=m[h];return[p,w,h]}function n(m,h){return m[h+1]==="!"&&m[h+2]==="-"&&m[h+3]==="-"}function u(m,h){return m[h+1]==="!"&&m[h+2]==="E"&&m[h+3]==="N"&&m[h+4]==="T"&&m[h+5]==="I"&&m[h+6]==="T"&&m[h+7]==="Y"}function i(m,h){return m[h+1]==="!"&&m[h+2]==="E"&&m[h+3]==="L"&&m[h+4]==="E"&&m[h+5]==="M"&&m[h+6]==="E"&&m[h+7]==="N"&&m[h+8]==="T"}function l(m,h){return m[h+1]==="!"&&m[h+2]==="A"&&m[h+3]==="T"&&m[h+4]==="T"&&m[h+5]==="L"&&m[h+6]==="I"&&m[h+7]==="S"&&m[h+8]==="T"}function o(m,h){return m[h+1]==="!"&&m[h+2]==="N"&&m[h+3]==="O"&&m[h+4]==="T"&&m[h+5]==="A"&&m[h+6]==="T"&&m[h+7]==="I"&&m[h+8]==="O"&&m[h+9]==="N"}function c(m){if(s.isName(m))return m;throw new Error("Invalid entity name ".concat(m))}r.exports=function(m,h){const p={};if(m[h+3]!=="O"||m[h+4]!=="C"||m[h+5]!=="T"||m[h+6]!=="Y"||m[h+7]!=="P"||m[h+8]!=="E")throw new Error("Invalid Tag instead of DOCTYPE");{h+=9;let d=1,w=!1,y=!1,k="";for(;h<m.length;h++)if(m[h]!=="<"||y)if(m[h]===">"){if(y?m[h-1]==="-"&&m[h-2]==="-"&&(y=!1,d--):d--,d===0)break}else m[h]==="["?w=!0:k+=m[h];else{if(w&&u(m,h))h+=7,[entityName,val,h]=a(m,h+1),val.indexOf("&")===-1&&(p[c(entityName)]={regx:RegExp("&".concat(entityName,";"),"g"),val});else if(w&&i(m,h))h+=8;else if(w&&l(m,h))h+=8;else if(w&&o(m,h))h+=9;else{if(!n)throw new Error("Invalid DOCTYPE");y=!0}d++,k=""}if(d!==0)throw new Error("Unclosed DOCTYPE")}return{entities:p,i:h}}},63:(r,e)=>{const t={preserveOrder:!1,attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,removeNSPrefix:!1,allowBooleanAttributes:!1,parseTagValue:!0,parseAttributeValue:!1,trimValues:!0,cdataPropName:!1,numberParseOptions:{hex:!0,leadingZeros:!0,eNotation:!0},tagValueProcessor:function(s,a){return a},attributeValueProcessor:function(s,a){return a},stopNodes:[],alwaysCreateTextNode:!1,isArray:()=>!1,commentPropName:!1,unpairedTags:[],processEntities:!0,htmlEntities:!1,ignoreDeclaration:!1,ignorePiTags:!1,transformTagName:!1,transformAttributeName:!1,updateTag:function(s,a,n){return s}};e.buildOptions=function(s){return Object.assign({},t,s)},e.defaultOptions=t},299:(r,e,t)=>{const s=t(705),a=t(365),n=t(193),u=t(494);function i(S){const E=Object.keys(S);for(let x=0;x<E.length;x++){const C=E[x];this.lastEntities[C]={regex:new RegExp("&"+C+";","g"),val:S[C]}}}function l(S,E,x,C,P,K,L){if(S!==void 0&&(this.options.trimValues&&!C&&(S=S.trim()),S.length>0)){L||(S=this.replaceEntitiesValue(S));const j=this.options.tagValueProcessor(E,S,x,P,K);return j==null?S:typeof j!=typeof S||j!==S?j:this.options.trimValues||S.trim()===S?N(S,this.options.parseTagValue,this.options.numberParseOptions):S}}function o(S){if(this.options.removeNSPrefix){const E=S.split(":"),x=S.charAt(0)==="/"?"/":"";if(E[0]==="xmlns")return"";E.length===2&&(S=x+E[1])}return S}const c=new RegExp("([^\\s=]+)\\s*(=\\s*(['\"])([\\s\\S]*?)\\3)?","gm");function m(S,E,x){if(!this.options.ignoreAttributes&&typeof S=="string"){const C=s.getAllMatches(S,c),P=C.length,K={};for(let L=0;L<P;L++){const j=this.resolveNameSpace(C[L][1]);let U=C[L][4],M=this.options.attributeNamePrefix+j;if(j.length)if(this.options.transformAttributeName&&(M=this.options.transformAttributeName(M)),M==="__proto__"&&(M="#__proto__"),U!==void 0){this.options.trimValues&&(U=U.trim()),U=this.replaceEntitiesValue(U);const G=this.options.attributeValueProcessor(j,U,E);K[M]=G==null?U:typeof G!=typeof U||G!==U?G:N(U,this.options.parseAttributeValue,this.options.numberParseOptions)}else this.options.allowBooleanAttributes&&(K[M]=!0)}if(!Object.keys(K).length)return;if(this.options.attributesGroupName){const L={};return L[this.options.attributesGroupName]=K,L}return K}}const h=function(S){S=S.replace(/\r\n?/g,"\n");const E=new a("!xml");let x=E,C="",P="";for(let K=0;K<S.length;K++)if(S[K]==="<")if(S[K+1]==="/"){const L=k(S,">",K,"Closing Tag is not closed.");let j=S.substring(K+2,L).trim();if(this.options.removeNSPrefix){const G=j.indexOf(":");G!==-1&&(j=j.substr(G+1))}this.options.transformTagName&&(j=this.options.transformTagName(j)),x&&(C=this.saveTextToParentTag(C,x,P));const U=P.substring(P.lastIndexOf(".")+1);if(j&&this.options.unpairedTags.indexOf(j)!==-1)throw new Error("Unpaired tag can not be used as closing tag: </".concat(j,">"));let M=0;U&&this.options.unpairedTags.indexOf(U)!==-1?(M=P.lastIndexOf(".",P.lastIndexOf(".")-1),this.tagsNodeStack.pop()):M=P.lastIndexOf("."),P=P.substring(0,M),x=this.tagsNodeStack.pop(),C="",K=L}else if(S[K+1]==="?"){let L=g(S,K,!1,"?>");if(!L)throw new Error("Pi Tag is not closed.");if(C=this.saveTextToParentTag(C,x,P),!(this.options.ignoreDeclaration&&L.tagName==="?xml"||this.options.ignorePiTags)){const j=new a(L.tagName);j.add(this.options.textNodeName,""),L.tagName!==L.tagExp&&L.attrExpPresent&&(j[":@"]=this.buildAttributesMap(L.tagExp,P,L.tagName)),this.addChild(x,j,P)}K=L.closeIndex+1}else if(S.substr(K+1,3)==="!--"){const L=k(S,"-->",K+4,"Comment is not closed.");if(this.options.commentPropName){const j=S.substring(K+4,L-2);C=this.saveTextToParentTag(C,x,P),x.add(this.options.commentPropName,[{[this.options.textNodeName]:j}])}K=L}else if(S.substr(K+1,2)==="!D"){const L=n(S,K);this.docTypeEntities=L.entities,K=L.i}else if(S.substr(K+1,2)==="!["){const L=k(S,"]]>",K,"CDATA is not closed.")-2,j=S.substring(K+9,L);C=this.saveTextToParentTag(C,x,P);let U=this.parseTextData(j,x.tagname,P,!0,!1,!0,!0);U==null&&(U=""),this.options.cdataPropName?x.add(this.options.cdataPropName,[{[this.options.textNodeName]:j}]):x.add(this.options.textNodeName,U),K=L+2}else{let L=g(S,K,this.options.removeNSPrefix),j=L.tagName;const U=L.rawTagName;let M=L.tagExp,G=L.attrExpPresent,we=L.closeIndex;this.options.transformTagName&&(j=this.options.transformTagName(j)),x&&C&&x.tagname!=="!xml"&&(C=this.saveTextToParentTag(C,x,P,!1));const ae=x;if(ae&&this.options.unpairedTags.indexOf(ae.tagname)!==-1&&(x=this.tagsNodeStack.pop(),P=P.substring(0,P.lastIndexOf("."))),j!==E.tagname&&(P+=P?"."+j:j),this.isItStopNode(this.options.stopNodes,P,j)){let Y="";if(M.length>0&&M.lastIndexOf("/")===M.length-1)j[j.length-1]==="/"?(j=j.substr(0,j.length-1),P=P.substr(0,P.length-1),M=j):M=M.substr(0,M.length-1),K=L.closeIndex;else if(this.options.unpairedTags.indexOf(j)!==-1)K=L.closeIndex;else{const F=this.readStopNodeData(S,U,we+1);if(!F)throw new Error("Unexpected end of ".concat(U));K=F.i,Y=F.tagContent}const se=new a(j);j!==M&&G&&(se[":@"]=this.buildAttributesMap(M,P,j)),Y&&(Y=this.parseTextData(Y,j,P,!0,G,!0,!0)),P=P.substr(0,P.lastIndexOf(".")),se.add(this.options.textNodeName,Y),this.addChild(x,se,P)}else{if(M.length>0&&M.lastIndexOf("/")===M.length-1){j[j.length-1]==="/"?(j=j.substr(0,j.length-1),P=P.substr(0,P.length-1),M=j):M=M.substr(0,M.length-1),this.options.transformTagName&&(j=this.options.transformTagName(j));const Y=new a(j);j!==M&&G&&(Y[":@"]=this.buildAttributesMap(M,P,j)),this.addChild(x,Y,P),P=P.substr(0,P.lastIndexOf("."))}else{const Y=new a(j);this.tagsNodeStack.push(x),j!==M&&G&&(Y[":@"]=this.buildAttributesMap(M,P,j)),this.addChild(x,Y,P),x=Y}C="",K=we}}else C+=S[K];return E.child};function p(S,E,x){const C=this.options.updateTag(E.tagname,x,E[":@"]);C===!1||(typeof C=="string"&&(E.tagname=C),S.addChild(E))}const d=function(S){if(this.options.processEntities){for(let E in this.docTypeEntities){const x=this.docTypeEntities[E];S=S.replace(x.regx,x.val)}for(let E in this.lastEntities){const x=this.lastEntities[E];S=S.replace(x.regex,x.val)}if(this.options.htmlEntities)for(let E in this.htmlEntities){const x=this.htmlEntities[E];S=S.replace(x.regex,x.val)}S=S.replace(this.ampEntity.regex,this.ampEntity.val)}return S};function w(S,E,x,C){return S&&(C===void 0&&(C=Object.keys(E.child).length===0),(S=this.parseTextData(S,E.tagname,x,!1,!!E[":@"]&&Object.keys(E[":@"]).length!==0,C))!==void 0&&S!==""&&E.add(this.options.textNodeName,S),S=""),S}function y(S,E,x){const C="*."+x;for(const P in S){const K=S[P];if(C===K||E===K)return!0}return!1}function k(S,E,x,C){const P=S.indexOf(E,x);if(P===-1)throw new Error(C);return P+E.length-1}function g(S,E,x){const C=function(G,we){let ae,Y=arguments.length>2&&arguments[2]!==void 0?arguments[2]:">",se="";for(let F=we;F<G.length;F++){let W=G[F];if(ae)W===ae&&(ae="");else if(W==='"'||W==="'")ae=W;else if(W===Y[0]){if(!Y[1])return{data:se,index:F};if(G[F+1]===Y[1])return{data:se,index:F}}else W===" "&&(W=" ");se+=W}}(S,E+1,arguments.length>3&&arguments[3]!==void 0?arguments[3]:">");if(!C)return;let P=C.data;const K=C.index,L=P.search(/\s/);let j=P,U=!0;L!==-1&&(j=P.substring(0,L),P=P.substring(L+1).trimStart());const M=j;if(x){const G=j.indexOf(":");G!==-1&&(j=j.substr(G+1),U=j!==C.data.substr(G+1))}return{tagName:j,tagExp:P,closeIndex:K,attrExpPresent:U,rawTagName:M}}function b(S,E,x){const C=x;let P=1;for(;x<S.length;x++)if(S[x]==="<")if(S[x+1]==="/"){const K=k(S,">",x,"".concat(E," is not closed"));if(S.substring(x+2,K).trim()===E&&(P--,P===0))return{tagContent:S.substring(C,x),i:K};x=K}else if(S[x+1]==="?")x=k(S,"?>",x+1,"StopNode is not closed.");else if(S.substr(x+1,3)==="!--")x=k(S,"-->",x+3,"StopNode is not closed.");else if(S.substr(x+1,2)==="![")x=k(S,"]]>",x,"StopNode is not closed.")-2;else{const K=g(S,x,">");K&&((K&&K.tagName)===E&&K.tagExp[K.tagExp.length-1]!=="/"&&P++,x=K.closeIndex)}}function N(S,E,x){if(E&&typeof S=="string"){const C=S.trim();return C==="true"||C!=="false"&&u(S,x)}return s.isExist(S)?S:""}r.exports=class{constructor(S){this.options=S,this.currentNode=null,this.tagsNodeStack=[],this.docTypeEntities={},this.lastEntities={apos:{regex:/&(apos|#39|#x27);/g,val:"'"},gt:{regex:/&(gt|#62|#x3E);/g,val:">"},lt:{regex:/&(lt|#60|#x3C);/g,val:"<"},quot:{regex:/&(quot|#34|#x22);/g,val:'"'}},this.ampEntity={regex:/&(amp|#38|#x26);/g,val:"&"},this.htmlEntities={space:{regex:/&(nbsp|#160);/g,val:" "},cent:{regex:/&(cent|#162);/g,val:"¢"},pound:{regex:/&(pound|#163);/g,val:"£"},yen:{regex:/&(yen|#165);/g,val:"¥"},euro:{regex:/&(euro|#8364);/g,val:"€"},copyright:{regex:/&(copy|#169);/g,val:"©"},reg:{regex:/&(reg|#174);/g,val:"®"},inr:{regex:/&(inr|#8377);/g,val:"₹"},num_dec:{regex:/&#([0-9]{1,7});/g,val:(E,x)=>String.fromCharCode(Number.parseInt(x,10))},num_hex:{regex:/&#x([0-9a-fA-F]{1,6});/g,val:(E,x)=>String.fromCharCode(Number.parseInt(x,16))}},this.addExternalEntities=i,this.parseXml=h,this.parseTextData=l,this.resolveNameSpace=o,this.buildAttributesMap=m,this.isItStopNode=y,this.replaceEntitiesValue=d,this.readStopNodeData=b,this.saveTextToParentTag=w,this.addChild=p}}},338:(r,e,t)=>{const{buildOptions:s}=t(63),a=t(299),{prettify:n}=t(728),u=t(31);r.exports=class{constructor(i){this.externalEntities={},this.options=s(i)}parse(i,l){if(typeof i!="string"){if(!i.toString)throw new Error("XML data is accepted in String or Bytes[] form.");i=i.toString()}if(l){l===!0&&(l={});const m=u.validate(i,l);if(m!==!0)throw Error("".concat(m.err.msg,":").concat(m.err.line,":").concat(m.err.col))}const o=new a(this.options);o.addExternalEntities(this.externalEntities);const c=o.parseXml(i);return this.options.preserveOrder||c===void 0?c:n(c,this.options)}addEntity(i,l){if(l.indexOf("&")!==-1)throw new Error("Entity value can't have '&'");if(i.indexOf("&")!==-1||i.indexOf(";")!==-1)throw new Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '
'");if(l==="&")throw new Error("An entity with value '&' is not permitted");this.externalEntities[i]=l}}},728:(r,e)=>{function t(u,i,l){let o;const c={};for(let m=0;m<u.length;m++){const h=u[m],p=s(h);let d="";if(d=l===void 0?p:l+"."+p,p===i.textNodeName)o===void 0?o=h[p]:o+=""+h[p];else{if(p===void 0)continue;if(h[p]){let w=t(h[p],i,d);const y=n(w,i);h[":@"]?a(w,h[":@"],d,i):Object.keys(w).length!==1||w[i.textNodeName]===void 0||i.alwaysCreateTextNode?Object.keys(w).length===0&&(i.alwaysCreateTextNode?w[i.textNodeName]="":w=""):w=w[i.textNodeName],c[p]!==void 0&&c.hasOwnProperty(p)?(Array.isArray(c[p])||(c[p]=[c[p]]),c[p].push(w)):i.isArray(p,d,y)?c[p]=[w]:c[p]=w}}}return typeof o=="string"?o.length>0&&(c[i.textNodeName]=o):o!==void 0&&(c[i.textNodeName]=o),c}function s(u){const i=Object.keys(u);for(let l=0;l<i.length;l++){const o=i[l];if(o!==":@")return o}}function a(u,i,l,o){if(i){const c=Object.keys(i),m=c.length;for(let h=0;h<m;h++){const p=c[h];o.isArray(p,l+"."+p,!0,!0)?u[p]=[i[p]]:u[p]=i[p]}}}function n(u,i){const{textNodeName:l}=i,o=Object.keys(u).length;return o===0||!(o!==1||!u[l]&&typeof u[l]!="boolean"&&u[l]!==0)}e.prettify=function(u,i){return t(u,i)}},365:r=>{r.exports=class{constructor(e){this.tagname=e,this.child=[],this[":@"]={}}add(e,t){e==="__proto__"&&(e="#__proto__"),this.child.push({[e]:t})}addChild(e){e.tagname==="__proto__"&&(e.tagname="#__proto__"),e[":@"]&&Object.keys(e[":@"]).length>0?this.child.push({[e.tagname]:e.child,":@":e[":@"]}):this.child.push({[e.tagname]:e.child})}}},135:r=>{function e(t){return!!t.constructor&&typeof t.constructor.isBuffer=="function"&&t.constructor.isBuffer(t)}r.exports=function(t){return t!=null&&(e(t)||function(s){return typeof s.readFloatLE=="function"&&typeof s.slice=="function"&&e(s.slice(0,0))}(t)||!!t._isBuffer)}},542:(r,e,t)=>{(function(){var s=t(298),a=t(526).utf8,n=t(135),u=t(526).bin,i=function(l,o){l.constructor==String?l=o&&o.encoding==="binary"?u.stringToBytes(l):a.stringToBytes(l):n(l)?l=Array.prototype.slice.call(l,0):Array.isArray(l)||l.constructor===Uint8Array||(l=l.toString());for(var c=s.bytesToWords(l),m=8*l.length,h=1732584193,p=-271733879,d=-1732584194,w=271733878,y=0;y<c.length;y++)c[y]=16711935&(c[y]<<8|c[y]>>>24)|4278255360&(c[y]<<24|c[y]>>>8);c[m>>>5]|=128<<m%32,c[14+(m+64>>>9<<4)]=m;var k=i._ff,g=i._gg,b=i._hh,N=i._ii;for(y=0;y<c.length;y+=16){var S=h,E=p,x=d,C=w;h=k(h,p,d,w,c[y+0],7,-680876936),w=k(w,h,p,d,c[y+1],12,-389564586),d=k(d,w,h,p,c[y+2],17,606105819),p=k(p,d,w,h,c[y+3],22,-1044525330),h=k(h,p,d,w,c[y+4],7,-176418897),w=k(w,h,p,d,c[y+5],12,1200080426),d=k(d,w,h,p,c[y+6],17,-1473231341),p=k(p,d,w,h,c[y+7],22,-45705983),h=k(h,p,d,w,c[y+8],7,1770035416),w=k(w,h,p,d,c[y+9],12,-1958414417),d=k(d,w,h,p,c[y+10],17,-42063),p=k(p,d,w,h,c[y+11],22,-1990404162),h=k(h,p,d,w,c[y+12],7,1804603682),w=k(w,h,p,d,c[y+13],12,-40341101),d=k(d,w,h,p,c[y+14],17,-1502002290),h=g(h,p=k(p,d,w,h,c[y+15],22,1236535329),d,w,c[y+1],5,-165796510),w=g(w,h,p,d,c[y+6],9,-1069501632),d=g(d,w,h,p,c[y+11],14,643717713),p=g(p,d,w,h,c[y+0],20,-373897302),h=g(h,p,d,w,c[y+5],5,-701558691),w=g(w,h,p,d,c[y+10],9,38016083),d=g(d,w,h,p,c[y+15],14,-660478335),p=g(p,d,w,h,c[y+4],20,-405537848),h=g(h,p,d,w,c[y+9],5,568446438),w=g(w,h,p,d,c[y+14],9,-1019803690),d=g(d,w,h,p,c[y+3],14,-187363961),p=g(p,d,w,h,c[y+8],20,1163531501),h=g(h,p,d,w,c[y+13],5,-1444681467),w=g(w,h,p,d,c[y+2],9,-51403784),d=g(d,w,h,p,c[y+7],14,1735328473),h=b(h,p=g(p,d,w,h,c[y+12],20,-1926607734),d,w,c[y+5],4,-378558),w=b(w,h,p,d,c[y+8],11,-2022574463),d=b(d,w,h,p,c[y+11],16,1839030562),p=b(p,d,w,h,c[y+14],23,-35309556),h=b(h,p,d,w,c[y+1],4,-1530992060),w=b(w,h,p,d,c[y+4],11,1272893353),d=b(d,w,h,p,c[y+7],16,-155497632),p=b(p,d,w,h,c[y+10],23,-1094730640),h=b(h,p,d,w,c[y+13],4,681279174),w=b(w,h,p,d,c[y+0],11,-358537222),d=b(d,w,h,p,c[y+3],16,-722521979),p=b(p,d,w,h,c[y+6],23,76029189),h=b(h,p,d,w,c[y+9],4,-640364487),w=b(w,h,p,d,c[y+12],11,-421815835),d=b(d,w,h,p,c[y+15],16,530742520),h=N(h,p=b(p,d,w,h,c[y+2],23,-995338651),d,w,c[y+0],6,-198630844),w=N(w,h,p,d,c[y+7],10,1126891415),d=N(d,w,h,p,c[y+14],15,-1416354905),p=N(p,d,w,h,c[y+5],21,-57434055),h=N(h,p,d,w,c[y+12],6,1700485571),w=N(w,h,p,d,c[y+3],10,-1894986606),d=N(d,w,h,p,c[y+10],15,-1051523),p=N(p,d,w,h,c[y+1],21,-2054922799),h=N(h,p,d,w,c[y+8],6,1873313359),w=N(w,h,p,d,c[y+15],10,-30611744),d=N(d,w,h,p,c[y+6],15,-1560198380),p=N(p,d,w,h,c[y+13],21,1309151649),h=N(h,p,d,w,c[y+4],6,-145523070),w=N(w,h,p,d,c[y+11],10,-1120210379),d=N(d,w,h,p,c[y+2],15,718787259),p=N(p,d,w,h,c[y+9],21,-343485551),h=h+S>>>0,p=p+E>>>0,d=d+x>>>0,w=w+C>>>0}return s.endian([h,p,d,w])};i._ff=function(l,o,c,m,h,p,d){var w=l+(o&c|~o&m)+(h>>>0)+d;return(w<<p|w>>>32-p)+o},i._gg=function(l,o,c,m,h,p,d){var w=l+(o&m|c&~m)+(h>>>0)+d;return(w<<p|w>>>32-p)+o},i._hh=function(l,o,c,m,h,p,d){var w=l+(o^c^m)+(h>>>0)+d;return(w<<p|w>>>32-p)+o},i._ii=function(l,o,c,m,h,p,d){var w=l+(c^(o|~m))+(h>>>0)+d;return(w<<p|w>>>32-p)+o},i._blocksize=16,i._digestsize=16,r.exports=function(l,o){if(l==null)throw new Error("Illegal argument "+l);var c=s.wordsToBytes(i(l,o));return o&&o.asBytes?c:o&&o.asString?u.bytesToString(c):s.bytesToHex(c)}})()},285:(r,e,t)=>{var s=t(2);r.exports=function(k){return k?(k.substr(0,2)==="{}"&&(k="\\{\\}"+k.substr(2)),y(function(g){return g.split("\\\\").join(a).split("\\{").join(n).split("\\}").join(u).split("\\,").join(i).split("\\.").join(l)}(k),!0).map(c)):[]};var a="\0SLASH"+Math.random()+"\0",n="\0OPEN"+Math.random()+"\0",u="\0CLOSE"+Math.random()+"\0",i="\0COMMA"+Math.random()+"\0",l="\0PERIOD"+Math.random()+"\0";function o(k){return parseInt(k,10)==k?parseInt(k,10):k.charCodeAt(0)}function c(k){return k.split(a).join("\\").split(n).join("{").split(u).join("}").split(i).join(",").split(l).join(".")}function m(k){if(!k)return[""];var g=[],b=s("{","}",k);if(!b)return k.split(",");var N=b.pre,S=b.body,E=b.post,x=N.split(",");x[x.length-1]+="{"+S+"}";var C=m(E);return E.length&&(x[x.length-1]+=C.shift(),x.push.apply(x,C)),g.push.apply(g,x),g}function h(k){return"{"+k+"}"}function p(k){return/^-?0\d/.test(k)}function d(k,g){return k<=g}function w(k,g){return k>=g}function y(k,g){var b=[],N=s("{","}",k);if(!N)return[k];var S=N.pre,E=N.post.length?y(N.post,!1):[""];if(/\$$/.test(N.pre))for(var x=0;x<E.length;x++){var C=S+"{"+N.body+"}"+E[x];b.push(C)}else{var P,K,L=/^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(N.body),j=/^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(N.body),U=L||j,M=N.body.indexOf(",")>=0;if(!U&&!M)return N.post.match(/,.*\}/)?y(k=N.pre+"{"+N.body+u+N.post):[k];if(U)P=N.body.split(/\.\./);else if((P=m(N.body)).length===1&&(P=y(P[0],!1).map(h)).length===1)return E.map(function(_t){return N.pre+P[0]+_t});if(U){var G=o(P[0]),we=o(P[1]),ae=Math.max(P[0].length,P[1].length),Y=P.length==3?Math.abs(o(P[2])):1,se=d;we<G&&(Y*=-1,se=w);var F=P.some(p);K=[];for(var W=G;se(W,we);W+=Y){var q;if(j)(q=String.fromCharCode(W))==="\\"&&(q="");else if(q=String(W),F){var ee=ae-q.length;if(ee>0){var ie=new Array(ee+1).join("0");q=W<0?"-"+ie+q.slice(1):ie+q}}K.push(q)}}else{K=[];for(var xe=0;xe<P.length;xe++)K.push.apply(K,y(P[xe],!1))}for(xe=0;xe<K.length;xe++)for(x=0;x<E.length;x++)C=S+K[xe]+E[x],(!g||U||C)&&b.push(C)}return b}},829:r=>{function e(o){return e=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(c){return typeof c}:function(c){return c&&typeof Symbol=="function"&&c.constructor===Symbol&&c!==Symbol.prototype?"symbol":typeof c},e(o)}function t(o){var c=typeof Map=="function"?new Map:void 0;return t=function(m){if(m===null||(h=m,Function.toString.call(h).indexOf("[native code]")===-1))return m;var h;if(typeof m!="function")throw new TypeError("Super expression must either be null or a function");if(c!==void 0){if(c.has(m))return c.get(m);c.set(m,p)}function p(){return s(m,arguments,n(this).constructor)}return p.prototype=Object.create(m.prototype,{constructor:{value:p,enumerable:!1,writable:!0,configurable:!0}}),a(p,m)},t(o)}function s(o,c,m){return s=function(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(h){return!1}}()?Reflect.construct:function(h,p,d){var w=[null];w.push.apply(w,p);var y=new(Function.bind.apply(h,w));return d&&a(y,d.prototype),y},s.apply(null,arguments)}function a(o,c){return a=Object.setPrototypeOf||function(m,h){return m.__proto__=h,m},a(o,c)}function n(o){return n=Object.setPrototypeOf?Object.getPrototypeOf:function(c){return c.__proto__||Object.getPrototypeOf(c)},n(o)}var u=function(o){function c(m){var h;return function(p,d){if(!(p instanceof d))throw new TypeError("Cannot call a class as a function")}(this,c),(h=function(p,d){return!d||e(d)!=="object"&&typeof d!="function"?function(w){if(w===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return w}(p):d}(this,n(c).call(this,m))).name="ObjectPrototypeMutationError",h}return function(m,h){if(typeof h!="function"&&h!==null)throw new TypeError("Super expression must either be null or a function");m.prototype=Object.create(h&&h.prototype,{constructor:{value:m,writable:!0,configurable:!0}}),h&&a(m,h)}(c,o),c}(t(Error));function i(o,c){for(var m=arguments.length>2&&arguments[2]!==void 0?arguments[2]:function(){},h=c.split("."),p=h.length,d=function(k){var g=h[k];if(!o)return{v:void 0};if(g==="+"){if(Array.isArray(o))return{v:o.map(function(N,S){var E=h.slice(k+1);return E.length>0?i(N,E.join("."),m):m(o,S,h,k)})};var b=h.slice(0,k).join(".");throw new Error("Object at wildcard (".concat(b,") is not an array"))}o=m(o,g,h,k)},w=0;w<p;w++){var y=d(w);if(e(y)==="object")return y.v}return o}function l(o,c){return o.length===c+1}r.exports={set:function(o,c,m){if(e(o)!="object"||o===null||c===void 0)return o;if(typeof c=="number")return o[c]=m,o[c];try{return i(o,c,function(h,p,d,w){if(h===Reflect.getPrototypeOf({}))throw new u("Attempting to mutate Object.prototype");if(!h[p]){var y=Number.isInteger(Number(d[w+1])),k=d[w+1]==="+";h[p]=y||k?[]:{}}return l(d,w)&&(h[p]=m),h[p]})}catch(h){if(h instanceof u)throw h;return o}},get:function(o,c){if(e(o)!="object"||o===null||c===void 0)return o;if(typeof c=="number")return o[c];try{return i(o,c,function(m,h){return m[h]})}catch(m){return o}},has:function(o,c){var m=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(e(o)!="object"||o===null||c===void 0)return!1;if(typeof c=="number")return c in o;try{var h=!1;return i(o,c,function(p,d,w,y){if(!l(w,y))return p&&p[d];h=m.own?p.hasOwnProperty(d):d in p}),h}catch(p){return!1}},hasOwn:function(o,c,m){return this.has(o,c,m||{own:!0})},isIn:function(o,c,m){var h=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};if(e(o)!="object"||o===null||c===void 0)return!1;try{var p=!1,d=!1;return i(o,c,function(w,y,k,g){return p=p||w===m||!!w&&w[y]===m,d=l(k,g)&&e(w)==="object"&&y in w,w&&w[y]}),h.validPath?p&&d:p}catch(w){return!1}},ObjectPrototypeMutationError:u}},47:(r,e,t)=>{var s=t(410),a=function(o){return typeof o=="string"};function n(o,c){for(var m=[],h=0;h<o.length;h++){var p=o[h];p&&p!=="."&&(p===".."?m.length&&m[m.length-1]!==".."?m.pop():c&&m.push(".."):m.push(p))}return m}var u=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,i={};function l(o){return u.exec(o).slice(1)}i.resolve=function(){for(var o="",c=!1,m=arguments.length-1;m>=-1&&!c;m--){var h=m>=0?arguments[m]:Ge.cwd();if(!a(h))throw new TypeError("Arguments to path.resolve must be strings");h&&(o=h+"/"+o,c=h.charAt(0)==="/")}return(c?"/":"")+(o=n(o.split("/"),!c).join("/"))||"."},i.normalize=function(o){var c=i.isAbsolute(o),m=o.substr(-1)==="/";return(o=n(o.split("/"),!c).join("/"))||c||(o="."),o&&m&&(o+="/"),(c?"/":"")+o},i.isAbsolute=function(o){return o.charAt(0)==="/"},i.join=function(){for(var o="",c=0;c<arguments.length;c++){var m=arguments[c];if(!a(m))throw new TypeError("Arguments to path.join must be strings");m&&(o+=o?"/"+m:m)}return i.normalize(o)},i.relative=function(o,c){function m(g){for(var b=0;b<g.length&&g[b]==="";b++);for(var N=g.length-1;N>=0&&g[N]==="";N--);return b>N?[]:g.slice(b,N+1)}o=i.resolve(o).substr(1),c=i.resolve(c).substr(1);for(var h=m(o.split("/")),p=m(c.split("/")),d=Math.min(h.length,p.length),w=d,y=0;y<d;y++)if(h[y]!==p[y]){w=y;break}var k=[];for(y=w;y<h.length;y++)k.push("..");return(k=k.concat(p.slice(w))).join("/")},i._makeLong=function(o){return o},i.dirname=function(o){var c=l(o),m=c[0],h=c[1];return m||h?(h&&(h=h.substr(0,h.length-1)),m+h):"."},i.basename=function(o,c){var m=l(o)[2];return c&&m.substr(-1*c.length)===c&&(m=m.substr(0,m.length-c.length)),m},i.extname=function(o){return l(o)[3]},i.format=function(o){if(!s.isObject(o))throw new TypeError("Parameter 'pathObject' must be an object, not "+typeof o);var c=o.root||"";if(!a(c))throw new TypeError("'pathObject.root' must be a string or undefined, not "+typeof o.root);return(o.dir?o.dir+i.sep:"")+(o.base||"")},i.parse=function(o){if(!a(o))throw new TypeError("Parameter 'pathString' must be a string, not "+typeof o);var c=l(o);if(!c||c.length!==4)throw new TypeError("Invalid path '"+o+"'");return c[1]=c[1]||"",c[2]=c[2]||"",c[3]=c[3]||"",{root:c[0],dir:c[0]+c[1].slice(0,c[1].length-1),base:c[2],ext:c[3],name:c[2].slice(0,c[2].length-c[3].length)}},i.sep="/",i.delimiter=":",r.exports=i},647:(r,e)=>{var t=Object.prototype.hasOwnProperty;function s(n){try{return decodeURIComponent(n.replace(/\+/g," "))}catch(u){return null}}function a(n){try{return encodeURIComponent(n)}catch(u){return null}}e.stringify=function(n,u){u=u||"";var i,l,o=[];for(l in typeof u!="string"&&(u="?"),n)if(t.call(n,l)){if((i=n[l])||i!=null&&!isNaN(i)||(i=""),l=a(l),i=a(i),l===null||i===null)continue;o.push(l+"="+i)}return o.length?u+o.join("&"):""},e.parse=function(n){for(var u,i=/([^=?#&]+)=?([^&]*)/g,l={};u=i.exec(n);){var o=s(u[1]),c=s(u[2]);o===null||c===null||o in l||(l[o]=c)}return l}},670:r=>{r.exports=function(e,t){if(t=t.split(":")[0],!(e=+e))return!1;switch(t){case"http":case"ws":return e!==80;case"https":case"wss":return e!==443;case"ftp":return e!==21;case"gopher":return e!==70;case"file":return!1}return e!==0}},494:r=>{const e=/^[-+]?0x[a-fA-F0-9]+$/,t=/^([\-\+])?(0*)(\.[0-9]+([eE]\-?[0-9]+)?|[0-9]+(\.[0-9]+([eE]\-?[0-9]+)?)?)$/;!Number.parseInt&&window.parseInt&&(Number.parseInt=window.parseInt),!Number.parseFloat&&window.parseFloat&&(Number.parseFloat=window.parseFloat);const s={hex:!0,leadingZeros:!0,decimalPoint:".",eNotation:!0};r.exports=function(a){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(n=Object.assign({},s,n),!a||typeof a!="string")return a;let u=a.trim();if(n.skipLike!==void 0&&n.skipLike.test(u))return a;if(n.hex&&e.test(u))return Number.parseInt(u,16);{const l=t.exec(u);if(l){const o=l[1],c=l[2];let m=((i=l[3])&&i.indexOf(".")!==-1&&((i=i.replace(/0+$/,""))==="."?i="0":i[0]==="."?i="0"+i:i[i.length-1]==="."&&(i=i.substr(0,i.length-1))),i);const h=l[4]||l[6];if(!n.leadingZeros&&c.length>0&&o&&u[2]!=="."||!n.leadingZeros&&c.length>0&&!o&&u[1]!==".")return a;{const p=Number(u),d=""+p;return d.search(/[eE]/)!==-1||h?n.eNotation?p:a:u.indexOf(".")!==-1?d==="0"&&m===""||d===m||o&&d==="-"+m?p:a:c?m===d||o+m===d?p:a:u===d||u===o+d?p:a}}return a}var i}},737:(r,e,t)=>{var s=t(670),a=t(647),n=/^[\x00-\x20\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]+/,u=/[\n\r\t]/g,i=/^[A-Za-z][A-Za-z0-9+-.]*:\/\//,l=/:\d+$/,o=/^([a-z][a-z0-9.+-]*:)?(\/\/)?([\\/]+)?([\S\s]*)/i,c=/^[a-zA-Z]:/;function m(g){return(g||"").toString().replace(n,"")}var h=[["#","hash"],["?","query"],function(g,b){return w(b.protocol)?g.replace(/\\/g,"/"):g},["/","pathname"],["@","auth",1],[NaN,"host",void 0,1,1],[/:(\d*)$/,"port",void 0,1],[NaN,"hostname",void 0,1,1]],p={hash:1,query:1};function d(g){var b,N=(typeof window<"u"?window:typeof It<"u"?It:typeof self<"u"?self:{}).location||{},S={},E=typeof(g=g||N);if(g.protocol==="blob:")S=new k(unescape(g.pathname),{});else if(E==="string")for(b in S=new k(g,{}),p)delete S[b];else if(E==="object"){for(b in g)b in p||(S[b]=g[b]);S.slashes===void 0&&(S.slashes=i.test(g.href))}return S}function w(g){return g==="file:"||g==="ftp:"||g==="http:"||g==="https:"||g==="ws:"||g==="wss:"}function y(g,b){g=(g=m(g)).replace(u,""),b=b||{};var N,S=o.exec(g),E=S[1]?S[1].toLowerCase():"",x=!!S[2],C=!!S[3],P=0;return x?C?(N=S[2]+S[3]+S[4],P=S[2].length+S[3].length):(N=S[2]+S[4],P=S[2].length):C?(N=S[3]+S[4],P=S[3].length):N=S[4],E==="file:"?P>=2&&(N=N.slice(2)):w(E)?N=S[4]:E?x&&(N=N.slice(2)):P>=2&&w(b.protocol)&&(N=S[4]),{protocol:E,slashes:x||w(E),slashesCount:P,rest:N}}function k(g,b,N){if(g=(g=m(g)).replace(u,""),!(this instanceof k))return new k(g,b,N);var S,E,x,C,P,K,L=h.slice(),j=typeof b,U=this,M=0;for(j!=="object"&&j!=="string"&&(N=b,b=null),N&&typeof N!="function"&&(N=a.parse),S=!(E=y(g||"",b=d(b))).protocol&&!E.slashes,U.slashes=E.slashes||S&&b.slashes,U.protocol=E.protocol||b.protocol||"",g=E.rest,(E.protocol==="file:"&&(E.slashesCount!==2||c.test(g))||!E.slashes&&(E.protocol||E.slashesCount<2||!w(U.protocol)))&&(L[3]=[/(.*)/,"pathname"]);M<L.length;M++)typeof(C=L[M])!="function"?(x=C[0],K=C[1],x!=x?U[K]=g:typeof x=="string"?~(P=x==="@"?g.lastIndexOf(x):g.indexOf(x))&&(typeof C[2]=="number"?(U[K]=g.slice(0,P),g=g.slice(P+C[2])):(U[K]=g.slice(P),g=g.slice(0,P))):(P=x.exec(g))&&(U[K]=P[1],g=g.slice(0,P.index)),U[K]=U[K]||S&&C[3]&&b[K]||"",C[4]&&(U[K]=U[K].toLowerCase())):g=C(g,U);N&&(U.query=N(U.query)),S&&b.slashes&&U.pathname.charAt(0)!=="/"&&(U.pathname!==""||b.pathname!=="")&&(U.pathname=function(G,we){if(G==="")return we;for(var ae=(we||"/").split("/").slice(0,-1).concat(G.split("/")),Y=ae.length,se=ae[Y-1],F=!1,W=0;Y--;)ae[Y]==="."?ae.splice(Y,1):ae[Y]===".."?(ae.splice(Y,1),W++):W&&(Y===0&&(F=!0),ae.splice(Y,1),W--);return F&&ae.unshift(""),se!=="."&&se!==".."||ae.push(""),ae.join("/")}(U.pathname,b.pathname)),U.pathname.charAt(0)!=="/"&&w(U.protocol)&&(U.pathname="/"+U.pathname),s(U.port,U.protocol)||(U.host=U.hostname,U.port=""),U.username=U.password="",U.auth&&(~(P=U.auth.indexOf(":"))?(U.username=U.auth.slice(0,P),U.username=encodeURIComponent(decodeURIComponent(U.username)),U.password=U.auth.slice(P+1),U.password=encodeURIComponent(decodeURIComponent(U.password))):U.username=encodeURIComponent(decodeURIComponent(U.auth)),U.auth=U.password?U.username+":"+U.password:U.username),U.origin=U.protocol!=="file:"&&w(U.protocol)&&U.host?U.protocol+"//"+U.host:"null",U.href=U.toString()}k.prototype={set:function(g,b,N){var S=this;switch(g){case"query":typeof b=="string"&&b.length&&(b=(N||a.parse)(b)),S[g]=b;break;case"port":S[g]=b,s(b,S.protocol)?b&&(S.host=S.hostname+":"+b):(S.host=S.hostname,S[g]="");break;case"hostname":S[g]=b,S.port&&(b+=":"+S.port),S.host=b;break;case"host":S[g]=b,l.test(b)?(b=b.split(":"),S.port=b.pop(),S.hostname=b.join(":")):(S.hostname=b,S.port="");break;case"protocol":S.protocol=b.toLowerCase(),S.slashes=!N;break;case"pathname":case"hash":if(b){var E=g==="pathname"?"/":"#";S[g]=b.charAt(0)!==E?E+b:b}else S[g]=b;break;case"username":case"password":S[g]=encodeURIComponent(b);break;case"auth":var x=b.indexOf(":");~x?(S.username=b.slice(0,x),S.username=encodeURIComponent(decodeURIComponent(S.username)),S.password=b.slice(x+1),S.password=encodeURIComponent(decodeURIComponent(S.password))):S.username=encodeURIComponent(decodeURIComponent(b))}for(var C=0;C<h.length;C++){var P=h[C];P[4]&&(S[P[1]]=S[P[1]].toLowerCase())}return S.auth=S.password?S.username+":"+S.password:S.username,S.origin=S.protocol!=="file:"&&w(S.protocol)&&S.host?S.protocol+"//"+S.host:"null",S.href=S.toString(),S},toString:function(g){g&&typeof g=="function"||(g=a.stringify);var b,N=this,S=N.host,E=N.protocol;E&&E.charAt(E.length-1)!==":"&&(E+=":");var x=E+(N.protocol&&N.slashes||w(N.protocol)?"//":"");return N.username?(x+=N.username,N.password&&(x+=":"+N.password),x+="@"):N.password?(x+=":"+N.password,x+="@"):N.protocol!=="file:"&&w(N.protocol)&&!S&&N.pathname!=="/"&&(x+="@"),(S[S.length-1]===":"||l.test(N.hostname)&&!N.port)&&(S+=":"),x+=S+N.pathname,(b=typeof N.query=="object"?g(N.query):N.query)&&(x+=b.charAt(0)!=="?"?"?"+b:b),N.hash&&(x+=N.hash),x}},k.extractProtocol=y,k.location=d,k.trimLeft=m,k.qs=a,r.exports=k},410:()=>{},388:()=>{},805:()=>{},345:()=>{},800:()=>{}},Nd={};function de(r){var e=Nd[r];if(e!==void 0)return e.exports;var t=Nd[r]={id:r,loaded:!1,exports:{}};return Nw[r].call(t.exports,t,t.exports,de),t.loaded=!0,t.exports}de.n=r=>{var e=r&&r.__esModule?()=>r.default:()=>r;return de.d(e,{a:e}),e},de.d=(r,e)=>{for(var t in e)de.o(e,t)&&!de.o(r,t)&&Object.defineProperty(r,t,{enumerable:!0,get:e[t]})},de.o=(r,e)=>Object.prototype.hasOwnProperty.call(r,e),de.nmd=r=>(r.paths=[],r.children||(r.children=[]),r);var zt={};de.d(zt,{hT:()=>bt,O4:()=>Js,Kd:()=>Ow,YK:()=>Dw,UU:()=>$y,Gu:()=>jp,ky:()=>_p,h4:()=>cc,ch:()=>Gh,hq:()=>Tn,i5:()=>Xp});var kw=de(737),Cw=de.n(kw);function rm(r){if(!ef(r))throw new Error("Parameter was not an error")}function ef(r){return!!r&&typeof r=="object"&&(e=r,Object.prototype.toString.call(e)==="[object Error]")||r instanceof Error;var e}class Nt extends Error{constructor(e,t){const s=[...arguments],{options:a,shortMessage:n}=function(i){let l,o="";if(i.length===0)l={};else if(ef(i[0]))l={cause:i[0]},o=i.slice(1).join(" ")||"";else if(i[0]&&typeof i[0]=="object")l=Object.assign({},i[0]),o=i.slice(1).join(" ")||"";else{if(typeof i[0]!="string")throw new Error("Invalid arguments passed to Layerr");l={},o=o=i.join(" ")||""}return{options:l,shortMessage:o}}(s);let u=n;if(a.cause&&(u="".concat(u,": ").concat(a.cause.message)),super(u),this.message=u,a.name&&typeof a.name=="string"?this.name=a.name:this.name="Layerr",a.cause&&Object.defineProperty(this,"_cause",{value:a.cause}),Object.defineProperty(this,"_info",{value:{}}),a.info&&typeof a.info=="object"&&Object.assign(this._info,a.info),Error.captureStackTrace){const i=a.constructorOpt||this.constructor;Error.captureStackTrace(this,i)}}static cause(e){return rm(e),e._cause&&ef(e._cause)?e._cause:null}static fullStack(e){var s;rm(e);const t=Nt.cause(e);return t?"".concat(e.stack,"\ncaused by: ").concat(Nt.fullStack(t)):(s=e.stack)!=null?s:""}static info(e){rm(e);const t={},s=Nt.cause(e);return s&&Object.assign(t,Nt.info(s)),e._info&&Object.assign(t,e._info),t}toString(){let e=this.name||this.constructor.name||this.constructor.prototype.name;return this.message&&(e="".concat(e,": ").concat(this.message)),e}}var Ew=de(47),Eh=de.n(Ew);const kd="__PATH_SEPARATOR_POSIX__",Cd="__PATH_SEPARATOR_WINDOWS__";function Ce(r){try{const e=r.replace(/\//g,kd).replace(/\\\\/g,Cd);return encodeURIComponent(e).split(Cd).join("\\\\").split(kd).join("/")}catch(e){throw new Nt(e,"Failed encoding path")}}function Ed(r){return r.startsWith("/")?r:"/"+r}function ec(r){let e=r;return e[0]!=="/"&&(e="/"+e),/^.+\/$/.test(e)&&(e=e.substr(0,e.length-1)),e}function xw(r){let e=new(Cw())(r).pathname;return e.length<=0&&(e="/"),ec(e)}function Ee(){for(var r=arguments.length,e=new Array(r),t=0;t<r;t++)e[t]=arguments[t];return function(){return function(s){var a=[];if(s.length===0)return"";if(typeof s[0]!="string")throw new TypeError("Url must be a string. Received "+s[0]);if(s[0].match(/^[^/:]+:\/*$/)&&s.length>1){var n=s.shift();s[0]=n+s[0]}s[0].match(/^file:\/\/\//)?s[0]=s[0].replace(/^([^/:]+):\/*/,"$1:///"):s[0]=s[0].replace(/^([^/:]+):\/*/,"$1://");for(var u=0;u<s.length;u++){var i=s[u];if(typeof i!="string")throw new TypeError("Url must be a string. Received "+i);i!==""&&(u>0&&(i=i.replace(/^[\/]+/,"")),i=u<s.length-1?i.replace(/[\/]+$/,""):i.replace(/[\/]+$/,"/"),a.push(i))}var l=a.join("/"),o=(l=l.replace(/\/(\?|&|#[^!])/g,"$1")).split("?");return o.shift()+(o.length>0?"?":"")+o.join("&")}(typeof arguments[0]=="object"?arguments[0]:[].slice.call(arguments))}(e.reduce((s,a,n)=>((n===0||a!=="/"||a==="/"&&s[s.length-1]!=="/")&&s.push(a),s),[]))}var Iw=de(542),Oo=de.n(Iw);const Vw="abcdef0123456789";function xd(r,e){const t=r.url.replace("//",""),s=t.indexOf("/")==-1?"/":t.slice(t.indexOf("/")),a=r.method?r.method.toUpperCase():"GET",n=!!/(^|,)\s*auth\s*($|,)/.test(e.qop)&&"auth",u="00000000".concat(e.nc).slice(-8),i=function(h,p,d,w,y,k,g){const b=g||Oo()("".concat(p,":").concat(d,":").concat(w));return h&&h.toLowerCase()==="md5-sess"?Oo()("".concat(b,":").concat(y,":").concat(k)):b}(e.algorithm,e.username,e.realm,e.password,e.nonce,e.cnonce,e.ha1),l=Oo()("".concat(a,":").concat(s)),o=n?Oo()("".concat(i,":").concat(e.nonce,":").concat(u,":").concat(e.cnonce,":").concat(n,":").concat(l)):Oo()("".concat(i,":").concat(e.nonce,":").concat(l)),c={username:e.username,realm:e.realm,nonce:e.nonce,uri:s,qop:n,response:o,nc:u,cnonce:e.cnonce,algorithm:e.algorithm,opaque:e.opaque},m=[];for(const h in c)c[h]&&(h==="qop"||h==="nc"||h==="algorithm"?m.push("".concat(h,"=").concat(c[h])):m.push("".concat(h,'="').concat(c[h],'"')));return"Digest ".concat(m.join(", "))}function Rp(r){return(r.headers&&r.headers.get("www-authenticate")||"").split(/\s/)[0].toLowerCase()==="digest"}var Bw=de(101),Lp=de.n(Bw);function Id(r){return Lp().decode(r)}function Vd(r,e){var t;return"Basic ".concat((t="".concat(r,":").concat(e),Lp().encode(t)))}const xh=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope?self:typeof window<"u"?window:globalThis,Pw=xh.fetch.bind(xh),Ow=xh.Request,Dw=xh.Response;let bt=function(r){return r.Auto="auto",r.Digest="digest",r.None="none",r.Password="password",r.Token="token",r}({}),Js=function(r){return r.DataTypeNoLength="data-type-no-length",r.InvalidAuthType="invalid-auth-type",r.InvalidOutputFormat="invalid-output-format",r.LinkUnsupportedAuthType="link-unsupported-auth",r.InvalidUpdateRange="invalid-update-range",r.NotSupported="not-supported",r}({});function Up(r,e,t,s,a){switch(r.authType){case bt.Auto:e&&t&&(r.headers.Authorization=Vd(e,t));break;case bt.Digest:r.digest=function(u,i,l){return{username:u,password:i,ha1:l,nc:0,algorithm:"md5",hasDigestAuth:!1}}(e,t,a);break;case bt.None:break;case bt.Password:r.headers.Authorization=Vd(e,t);break;case bt.Token:r.headers.Authorization="".concat((n=s).token_type," ").concat(n.access_token);break;default:throw new Nt({info:{code:Js.InvalidAuthType}},"Invalid auth type: ".concat(r.authType))}var n}de(345),de(800);const Bd="@@HOTPATCHER",Tw=()=>{};function am(r){return{original:r,methods:[r],final:!1}}class Rw{constructor(){this._configuration={registry:{},getEmptyAction:"null"},this.__type__=Bd}get configuration(){return this._configuration}get getEmptyAction(){return this.configuration.getEmptyAction}set getEmptyAction(e){this.configuration.getEmptyAction=e}control(e){let t=arguments.length>1&&arguments[1]!==void 0&&arguments[1];if(!e||e.__type__!==Bd)throw new Error("Failed taking control of target HotPatcher instance: Invalid type or object");return Object.keys(e.configuration.registry).forEach(s=>{this.configuration.registry.hasOwnProperty(s)?t&&(this.configuration.registry[s]=Object.assign({},e.configuration.registry[s])):this.configuration.registry[s]=Object.assign({},e.configuration.registry[s])}),e._configuration=this.configuration,this}execute(e){const t=this.get(e)||Tw;for(var s=arguments.length,a=new Array(s>1?s-1:0),n=1;n<s;n++)a[n-1]=arguments[n];return t(...a)}get(e){const t=this.configuration.registry[e];if(!t)switch(this.getEmptyAction){case"null":return null;case"throw":throw new Error("Failed handling method request: No method provided for override: ".concat(e));default:throw new Error("Failed handling request which resulted in an empty method: Invalid empty-action specified: ".concat(this.getEmptyAction))}return function(){for(var s=arguments.length,a=new Array(s),n=0;n<s;n++)a[n]=arguments[n];if(a.length===0)throw new Error("Failed creating sequence: No functions provided");return function(){for(var u=arguments.length,i=new Array(u),l=0;l<u;l++)i[l]=arguments[l];let o=i;const c=this;for(;a.length>0;)o=[a.shift().apply(c,o)];return o[0]}}(...t.methods)}isPatched(e){return!!this.configuration.registry[e]}patch(e,t){let s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const{chain:a=!1}=s;if(this.configuration.registry[e]&&this.configuration.registry[e].final)throw new Error("Failed patching '".concat(e,"': Method marked as being final"));if(typeof t!="function")throw new Error("Failed patching '".concat(e,"': Provided method is not a function"));if(a)this.configuration.registry[e]?this.configuration.registry[e].methods.push(t):this.configuration.registry[e]=am(t);else if(this.isPatched(e)){const{original:n}=this.configuration.registry[e];this.configuration.registry[e]=Object.assign(am(t),{original:n})}else this.configuration.registry[e]=am(t);return this}patchInline(e,t){this.isPatched(e)||this.patch(e,t);for(var s=arguments.length,a=new Array(s>2?s-2:0),n=2;n<s;n++)a[n-2]=arguments[n];return this.execute(e,...a)}plugin(e){for(var t=arguments.length,s=new Array(t>1?t-1:0),a=1;a<t;a++)s[a-1]=arguments[a];return s.forEach(n=>{this.patch(e,n,{chain:!0})}),this}restore(e){if(!this.isPatched(e))throw new Error("Failed restoring method: No method present for key: ".concat(e));if(typeof this.configuration.registry[e].original!="function")throw new Error("Failed restoring method: Original method not found or of invalid type for key: ".concat(e));return this.configuration.registry[e].methods=[this.configuration.registry[e].original],this}setFinal(e){if(!this.configuration.registry.hasOwnProperty(e))throw new Error("Failed marking '".concat(e,"' as final: No method found for key"));return this.configuration.registry[e].final=!0,this}}let nm=null;function jp(){return nm||(nm=new Rw),nm}function Ih(r){return function(e){if(typeof e!="object"||e===null||Object.prototype.toString.call(e)!="[object Object]")return!1;if(Object.getPrototypeOf(e)===null)return!0;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}(r)?Object.assign({},r):Object.setPrototypeOf(Object.assign({},r),Object.getPrototypeOf(r))}function Pd(){for(var r=arguments.length,e=new Array(r),t=0;t<r;t++)e[t]=arguments[t];let s=null,a=[...e];for(;a.length>0;){const n=a.shift();s=s?$p(s,n):Ih(n)}return s}function $p(r,e){const t=Ih(r);return Object.keys(e).forEach(s=>{t.hasOwnProperty(s)?Array.isArray(e[s])?t[s]=Array.isArray(t[s])?[...t[s],...e[s]]:[...e[s]]:typeof e[s]=="object"&&e[s]?t[s]=typeof t[s]=="object"&&t[s]?$p(t[s],e[s]):Ih(e[s]):t[s]=e[s]:t[s]=e[s]}),t}function Lw(r){const e={};for(const t of r.keys())e[t]=r.get(t);return e}function tf(){for(var r=arguments.length,e=new Array(r),t=0;t<r;t++)e[t]=arguments[t];if(e.length===0)return{};const s={};return e.reduce((a,n)=>(Object.keys(n).forEach(u=>{const i=u.toLowerCase();s.hasOwnProperty(i)?a[s[i]]=n[u]:(s[i]=u,a[u]=n[u])}),a),{})}de(805);const Uw=typeof ArrayBuffer=="function",{toString:jw}=Object.prototype;function Kp(r){return Uw&&(r instanceof ArrayBuffer||jw.call(r)==="[object ArrayBuffer]")}function Hp(r){return r!=null&&r.constructor!=null&&typeof r.constructor.isBuffer=="function"&&r.constructor.isBuffer(r)}function Kf(r){return function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];try{return Promise.resolve(r.apply(this,e))}catch(s){return Promise.reject(s)}}}function sf(r,e,t){return r&&r.then||(r=Promise.resolve(r)),e?r.then(e):r}const Mp=Kf(function(r){const e=r._digest;return delete r._digest,e.hasDigestAuth&&(r=Pd(r,{headers:{Authorization:xd(r,e)}})),sf(Vh(r),function(t){let s=!1;return a=function(u){return s?u:t},(n=function(){if(t.status==401)return e.hasDigestAuth=function(u,i){if(!Rp(u))return!1;const l=/([a-z0-9_-]+)=(?:"([^"]+)"|([a-z0-9_-]+))/gi;for(;;){const o=u.headers&&u.headers.get("www-authenticate")||"",c=l.exec(o);if(!c)break;i[c[1]]=c[2]||c[3]}return i.nc+=1,i.cnonce=function(){let o="";for(let c=0;c<32;++c)o="".concat(o).concat(Vw[Math.floor(16*Math.random())]);return o}(),!0}(t,e),function(){if(e.hasDigestAuth)return sf(Vh(r=Pd(r,{headers:{Authorization:xd(r,e)}})),function(u){return u.status==401?e.hasDigestAuth=!1:e.nc++,s=!0,u})}();e.nc++}())&&n.then?n.then(a):a(n);var a,n})}),$w=Kf(function(r,e){return sf(Vh(r),function(t){return t.ok?(e.authType=bt.Password,t):t.status==401&&Rp(t)?(e.authType=bt.Digest,Up(e,e.username,e.password,void 0,void 0),r._digest=e.digest,Mp(r)):t})}),Xe=Kf(function(r,e){return e.authType===bt.Auto?$w(r,e):r._digest?Mp(r):Vh(r)});function Ze(r,e,t){const s=Ih(r);return s.headers=tf(e.headers,s.headers||{},t.headers||{}),t.data!==void 0&&(s.data=t.data),t.signal&&(s.signal=t.signal),e.httpAgent&&(s.httpAgent=e.httpAgent),e.httpsAgent&&(s.httpsAgent=e.httpsAgent),e.digest&&(s._digest=e.digest),typeof e.withCredentials=="boolean"&&(s.withCredentials=e.withCredentials),s}function Vh(r){const e=jp();return e.patchInline("request",t=>e.patchInline("fetch",Pw,t.url,function(s){let a={};const n={method:s.method};if(s.headers&&(a=tf(a,s.headers)),s.data!==void 0){const[u,i]=function(l){if(typeof l=="string")return[l,{}];if(Hp(l))return[l,{}];if(Kp(l))return[l,{}];if(l&&typeof l=="object")return[JSON.stringify(l),{"content-type":"application/json"}];throw new Error("Unable to convert request body: Unexpected body type: "+typeof l)}(s.data);n.body=u,a=tf(a,i)}return s.signal&&(n.signal=s.signal),s.withCredentials&&(n.credentials="include"),n.headers=a,n}(t)),r)}var Kw=de(285);const Bh=r=>{if(typeof r!="string")throw new TypeError("invalid pattern");if(r.length>65536)throw new TypeError("pattern is too long")},Hw={"[:alnum:]":["\\p{L}\\p{Nl}\\p{Nd}",!0],"[:alpha:]":["\\p{L}\\p{Nl}",!0],"[:ascii:]":["\\x00-\\x7f",!1],"[:blank:]":["\\p{Zs}\\t",!0],"[:cntrl:]":["\\p{Cc}",!0],"[:digit:]":["\\p{Nd}",!0],"[:graph:]":["\\p{Z}\\p{C}",!0,!0],"[:lower:]":["\\p{Ll}",!0],"[:print:]":["\\p{C}",!0],"[:punct:]":["\\p{P}",!0],"[:space:]":["\\p{Z}\\t\\r\\n\\v\\f",!0],"[:upper:]":["\\p{Lu}",!0],"[:word:]":["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}",!0],"[:xdigit:]":["A-Fa-f0-9",!1]},Do=r=>r.replace(/[[\]\\-]/g,"\\$&"),Od=r=>r.join(""),Mw=(r,e)=>{const t=e;if(r.charAt(t)!=="[")throw new Error("not in a brace expression");const s=[],a=[];let n=t+1,u=!1,i=!1,l=!1,o=!1,c=t,m="";e:for(;n<r.length;){const w=r.charAt(n);if(w!=="!"&&w!=="^"||n!==t+1){if(w==="]"&&u&&!l){c=n+1;break}if(u=!0,w!=="\\"||l){if(w==="["&&!l){for(const[y,[k,g,b]]of Object.entries(Hw))if(r.startsWith(y,n)){if(m)return["$.",!1,r.length-t,!0];n+=y.length,b?a.push(k):s.push(k),i=i||g;continue e}}l=!1,m?(w>m?s.push(Do(m)+"-"+Do(w)):w===m&&s.push(Do(w)),m="",n++):r.startsWith("-]",n+1)?(s.push(Do(w+"-")),n+=2):r.startsWith("-",n+1)?(m=w,n+=2):(s.push(Do(w)),n++)}else l=!0,n++}else o=!0,n++}if(c<n)return["",!1,0,!1];if(!s.length&&!a.length)return["$.",!1,r.length-t,!0];if(a.length===0&&s.length===1&&/^\\?.$/.test(s[0])&&!o)return[(h=s[0].length===2?s[0].slice(-1):s[0],h.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")),!1,c-t,!1];var h;const p="["+(o?"^":"")+Od(s)+"]",d="["+(o?"":"^")+Od(a)+"]";return[s.length&&a.length?"("+p+"|"+d+")":s.length?p:d,i,c-t,!0]},Xo=function(r){let{windowsPathsNoEscape:e=!1}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return e?r.replace(/\[([^\/\\])\]/g,"$1"):r.replace(/((?!\\).|^)\[([^\/\\])\]/g,"$1$2").replace(/\\([^\/])/g,"$1")},Fw=new Set(["!","?","+","*","@"]),Dd=r=>Fw.has(r),im="(?!\\.)",Jw=new Set(["[","."]),qw=new Set(["..","."]),Ww=new Set("().*{}+?[]^$\\!"),Hf="[^/]",Td=Hf+"*?",Rd=Hf+"+?";var We,et,Os,be,He,Wr,Sn,Gr,hs,An,uc,Dn,Fp,na,Jc,rf,Jp;const pt=class pt{constructor(e,t){Et(this,Dn);Ke(this,"type");Et(this,We);Et(this,et);Et(this,Os,!1);Et(this,be,[]);Et(this,He);Et(this,Wr);Et(this,Sn);Et(this,Gr,!1);Et(this,hs);Et(this,An);Et(this,uc,!1);let s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};this.type=e,e&&Be(this,et,!0),Be(this,He,t),Be(this,We,H(this,He)?H(H(this,He),We):this),Be(this,hs,H(this,We)===this?s:H(H(this,We),hs)),Be(this,Sn,H(this,We)===this?[]:H(H(this,We),Sn)),e!=="!"||H(H(this,We),Gr)||H(this,Sn).push(this),Be(this,Wr,H(this,He)?H(H(this,He),be).length:0)}get hasMagic(){if(H(this,et)!==void 0)return H(this,et);for(const e of H(this,be))if(typeof e!="string"&&(e.type||e.hasMagic))return Be(this,et,!0);return H(this,et)}toString(){return H(this,An)!==void 0?H(this,An):this.type?Be(this,An,this.type+"("+H(this,be).map(e=>String(e)).join("|")+")"):Be(this,An,H(this,be).map(e=>String(e)).join(""))}push(){for(var e=arguments.length,t=new Array(e),s=0;s<e;s++)t[s]=arguments[s];for(const a of t)if(a!==""){if(typeof a!="string"&&!(a instanceof pt&&H(a,He)===this))throw new Error("invalid part: "+a);H(this,be).push(a)}}toJSON(){var t;const e=this.type===null?H(this,be).slice().map(s=>typeof s=="string"?s:s.toJSON()):[this.type,...H(this,be).map(s=>s.toJSON())];return this.isStart()&&!this.type&&e.unshift([]),this.isEnd()&&(this===H(this,We)||H(H(this,We),Gr)&&((t=H(this,He))==null?void 0:t.type)==="!")&&e.push({}),e}isStart(){var t;if(H(this,We)===this)return!0;if(!((t=H(this,He))!=null&&t.isStart()))return!1;if(H(this,Wr)===0)return!0;const e=H(this,He);for(let s=0;s<H(this,Wr);s++){const a=H(e,be)[s];if(!(a instanceof pt&&a.type==="!"))return!1}return!0}isEnd(){var t,s,a;if(H(this,We)===this||((t=H(this,He))==null?void 0:t.type)==="!")return!0;if(!((s=H(this,He))!=null&&s.isEnd()))return!1;if(!this.type)return(a=H(this,He))==null?void 0:a.isEnd();const e=H(this,He)?H(H(this,He),be).length:0;return H(this,Wr)===e-1}copyIn(e){typeof e=="string"?this.push(e):this.push(e.clone(this))}clone(e){const t=new pt(this.type,e);for(const s of H(this,be))t.copyIn(s);return t}static fromGlob(e){var a;let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const s=new pt(null,void 0,t);return zs(a=pt,na,Jc).call(a,e,s,0,t),s}toMMPattern(){if(this!==H(this,We))return H(this,We).toMMPattern();const e=this.toString(),[t,s,a,n]=this.toRegExpSource();if(!(a||H(this,et)||H(this,hs).nocase&&!H(this,hs).nocaseMagicOnly&&e.toUpperCase()!==e.toLowerCase()))return s;const u=(H(this,hs).nocase?"i":"")+(n?"u":"");return Object.assign(new RegExp("^".concat(t,"$"),u),{_src:t,_glob:e})}get options(){return H(this,hs)}toRegExpSource(e){var l;const t=e!=null?e:!!H(this,hs).dot;if(H(this,We)===this&&zs(this,Dn,Fp).call(this),!this.type){const o=this.isStart()&&this.isEnd(),c=H(this,be).map(p=>{var g;const[d,w,y,k]=typeof p=="string"?zs(g=pt,na,Jp).call(g,p,H(this,et),o):p.toRegExpSource(e);return Be(this,et,H(this,et)||y),Be(this,Os,H(this,Os)||k),d}).join("");let m="";if(this.isStart()&&typeof H(this,be)[0]=="string"&&(H(this,be).length!==1||!qw.has(H(this,be)[0]))){const p=Jw,d=t&&p.has(c.charAt(0))||c.startsWith("\\.")&&p.has(c.charAt(2))||c.startsWith("\\.\\.")&&p.has(c.charAt(4)),w=!t&&!e&&p.has(c.charAt(0));m=d?"(?!(?:^|/)\\.\\.?(?:$|/))":w?im:""}let h="";return this.isEnd()&&H(H(this,We),Gr)&&((l=H(this,He))==null?void 0:l.type)==="!"&&(h="(?:$|\\/)"),[m+c+h,Xo(c),Be(this,et,!!H(this,et)),H(this,Os)]}const s=this.type==="*"||this.type==="+",a=this.type==="!"?"(?:(?!(?:":"(?:";let n=zs(this,Dn,rf).call(this,t);if(this.isStart()&&this.isEnd()&&!n&&this.type!=="!"){const o=this.toString();return Be(this,be,[o]),this.type=null,Be(this,et,void 0),[o,Xo(this.toString()),!1,!1]}let u=!s||e||t?"":zs(this,Dn,rf).call(this,!0);u===n&&(u=""),u&&(n="(?:".concat(n,")(?:").concat(u,")*?"));let i="";return i=this.type==="!"&&H(this,uc)?(this.isStart()&&!t?im:"")+Rd:a+n+(this.type==="!"?"))"+(!this.isStart()||t||e?"":im)+Td+")":this.type==="@"?")":this.type==="?"?")?":this.type==="+"&&u?")":this.type==="*"&&u?")?":")".concat(this.type)),[i,Xo(n),Be(this,et,!!H(this,et)),H(this,Os)]}};We=new WeakMap,et=new WeakMap,Os=new WeakMap,be=new WeakMap,He=new WeakMap,Wr=new WeakMap,Sn=new WeakMap,Gr=new WeakMap,hs=new WeakMap,An=new WeakMap,uc=new WeakMap,Dn=new WeakSet,Fp=function(){if(this!==H(this,We))throw new Error("should only call on root");if(H(this,Gr))return this;let e;for(this.toString(),Be(this,Gr,!0);e=H(this,Sn).pop();){if(e.type!=="!")continue;let t=e,s=H(t,He);for(;s;){for(let a=H(t,Wr)+1;!s.type&&a<H(s,be).length;a++)for(const n of H(e,be)){if(typeof n=="string")throw new Error("string part in extglob AST??");n.copyIn(H(s,be)[a])}t=s,s=H(t,He)}}return this},na=new WeakSet,Jc=function(e,t,s,a){var p,d;let n=!1,u=!1,i=-1,l=!1;if(t.type===null){let w=s,y="";for(;w<e.length;){const k=e.charAt(w++);if(n||k==="\\")n=!n,y+=k;else if(u)w===i+1?k!=="^"&&k!=="!"||(l=!0):k!=="]"||w===i+2&&l||(u=!1),y+=k;else if(k!=="[")if(a.noext||!Dd(k)||e.charAt(w)!=="(")y+=k;else{t.push(y),y="";const g=new pt(k,t);w=zs(p=pt,na,Jc).call(p,e,g,w,a),t.push(g)}else u=!0,i=w,l=!1,y+=k}return t.push(y),w}let o=s+1,c=new pt(null,t);const m=[];let h="";for(;o<e.length;){const w=e.charAt(o++);if(n||w==="\\")n=!n,h+=w;else if(u)o===i+1?w!=="^"&&w!=="!"||(l=!0):w!=="]"||o===i+2&&l||(u=!1),h+=w;else if(w!=="[")if(Dd(w)&&e.charAt(o)==="("){c.push(h),h="";const y=new pt(w,c);c.push(y),o=zs(d=pt,na,Jc).call(d,e,y,o,a)}else if(w!=="|"){if(w===")")return h===""&&H(t,be).length===0&&Be(t,uc,!0),c.push(h),h="",t.push(...m,c),o;h+=w}else c.push(h),h="",m.push(c),c=new pt(null,t);else u=!0,i=o,l=!1,h+=w}return t.type=null,Be(t,et,void 0),Be(t,be,[e.substring(s-1)]),o},rf=function(e){return H(this,be).map(t=>{if(typeof t=="string")throw new Error("string type in extglob ast??");const[s,a,n,u]=t.toRegExpSource(e);return Be(this,Os,H(this,Os)||u),s}).filter(t=>!(this.isStart()&&this.isEnd()&&!t)).join("|")},Jp=function(e,t){let s=arguments.length>2&&arguments[2]!==void 0&&arguments[2],a=!1,n="",u=!1;for(let i=0;i<e.length;i++){const l=e.charAt(i);if(a)a=!1,n+=(Ww.has(l)?"\\":"")+l;else if(l!=="\\"){if(l==="["){const[o,c,m,h]=Mw(e,i);if(m){n+=o,u=u||c,i+=m-1,t=t||h;continue}}l!=="*"?l!=="?"?n+=l.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"):(n+=Hf,t=!0):(n+=s&&e==="*"?Rd:Td,t=!0)}else i===e.length-1?n+="\\\\":a=!0}return[n,Xo(e),!!t,u]},Et(pt,na);let Ph=pt;const ft=function(r,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return Bh(e),!(!t.nocomment&&e.charAt(0)==="#")&&new Oh(e,t).match(r)},Gw=/^\*+([^+@!?\*\[\(]*)$/,zw=r=>e=>!e.startsWith(".")&&e.endsWith(r),_w=r=>e=>e.endsWith(r),Xw=r=>(r=r.toLowerCase(),e=>!e.startsWith(".")&&e.toLowerCase().endsWith(r)),Zw=r=>(r=r.toLowerCase(),e=>e.toLowerCase().endsWith(r)),Qw=/^\*+\.\*+$/,Yw=r=>!r.startsWith(".")&&r.includes("."),ey=r=>r!=="."&&r!==".."&&r.includes("."),ty=/^\.\*+$/,sy=r=>r!=="."&&r!==".."&&r.startsWith("."),ry=/^\*+$/,ay=r=>r.length!==0&&!r.startsWith("."),ny=r=>r.length!==0&&r!=="."&&r!=="..",iy=/^\?+([^+@!?\*\[\(]*)?$/,oy=r=>{let[e,t=""]=r;const s=qp([e]);return t?(t=t.toLowerCase(),a=>s(a)&&a.toLowerCase().endsWith(t)):s},uy=r=>{let[e,t=""]=r;const s=Wp([e]);return t?(t=t.toLowerCase(),a=>s(a)&&a.toLowerCase().endsWith(t)):s},ly=r=>{let[e,t=""]=r;const s=Wp([e]);return t?a=>s(a)&&a.endsWith(t):s},cy=r=>{let[e,t=""]=r;const s=qp([e]);return t?a=>s(a)&&a.endsWith(t):s},qp=r=>{let[e]=r;const t=e.length;return s=>s.length===t&&!s.startsWith(".")},Wp=r=>{let[e]=r;const t=e.length;return s=>s.length===t&&s!=="."&&s!==".."},Gp=typeof Ge=="object"&&Ge?typeof sm=="object"&&sm&&sm.__MINIMATCH_TESTING_PLATFORM__||Ge.platform:"posix";ft.sep=Gp==="win32"?"\\":"/";const Kt=Symbol("globstar **");ft.GLOBSTAR=Kt,ft.filter=function(r){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return t=>ft(t,r,e)};const jt=function(r){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return Object.assign({},r,e)};ft.defaults=r=>{if(!r||typeof r!="object"||!Object.keys(r).length)return ft;const e=ft;return Object.assign(function(t,s){return e(t,s,jt(r,arguments.length>2&&arguments[2]!==void 0?arguments[2]:{}))},{Minimatch:class extends e.Minimatch{constructor(t){super(t,jt(r,arguments.length>1&&arguments[1]!==void 0?arguments[1]:{}))}static defaults(t){return e.defaults(jt(r,t)).Minimatch}},AST:class extends e.AST{constructor(t,s){super(t,s,jt(r,arguments.length>2&&arguments[2]!==void 0?arguments[2]:{}))}static fromGlob(t){let s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return e.AST.fromGlob(t,jt(r,s))}},unescape:function(t){let s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return e.unescape(t,jt(r,s))},escape:function(t){let s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return e.escape(t,jt(r,s))},filter:function(t){let s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return e.filter(t,jt(r,s))},defaults:t=>e.defaults(jt(r,t)),makeRe:function(t){let s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return e.makeRe(t,jt(r,s))},braceExpand:function(t){let s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return e.braceExpand(t,jt(r,s))},match:function(t,s){let a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return e.match(t,s,jt(r,a))},sep:e.sep,GLOBSTAR:Kt})};const zp=function(r){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return Bh(r),e.nobrace||!/\{(?:(?!\{).)*\}/.test(r)?[r]:Kw(r)};ft.braceExpand=zp,ft.makeRe=function(r){return new Oh(r,arguments.length>1&&arguments[1]!==void 0?arguments[1]:{}).makeRe()},ft.match=function(r,e){const t=new Oh(e,arguments.length>2&&arguments[2]!==void 0?arguments[2]:{});return r=r.filter(s=>t.match(s)),t.options.nonull&&!r.length&&r.push(e),r};const Ld=/[?*]|[+@!]\(.*?\)|\[|\]/;class Oh{constructor(e){Ke(this,"options");Ke(this,"set");Ke(this,"pattern");Ke(this,"windowsPathsNoEscape");Ke(this,"nonegate");Ke(this,"negate");Ke(this,"comment");Ke(this,"empty");Ke(this,"preserveMultipleSlashes");Ke(this,"partial");Ke(this,"globSet");Ke(this,"globParts");Ke(this,"nocase");Ke(this,"isWindows");Ke(this,"platform");Ke(this,"windowsNoMagicRoot");Ke(this,"regexp");let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};Bh(e),t=t||{},this.options=t,this.pattern=e,this.platform=t.platform||Gp,this.isWindows=this.platform==="win32",this.windowsPathsNoEscape=!!t.windowsPathsNoEscape||t.allowWindowsEscape===!1,this.windowsPathsNoEscape&&(this.pattern=this.pattern.replace(/\\/g,"/")),this.preserveMultipleSlashes=!!t.preserveMultipleSlashes,this.regexp=null,this.negate=!1,this.nonegate=!!t.nonegate,this.comment=!1,this.empty=!1,this.partial=!!t.partial,this.nocase=!!this.options.nocase,this.windowsNoMagicRoot=t.windowsNoMagicRoot!==void 0?t.windowsNoMagicRoot:!(!this.isWindows||!this.nocase),this.globSet=[],this.globParts=[],this.set=[],this.make()}hasMagic(){if(this.options.magicalBraces&&this.set.length>1)return!0;for(const e of this.set)for(const t of e)if(typeof t!="string")return!0;return!1}debug(){}make(){const e=this.pattern,t=this.options;if(!t.nocomment&&e.charAt(0)==="#")return void(this.comment=!0);if(!e)return void(this.empty=!0);this.parseNegate(),this.globSet=[...new Set(this.braceExpand())],t.debug&&(this.debug=function(){return console.error(...arguments)}),this.debug(this.pattern,this.globSet);const s=this.globSet.map(n=>this.slashSplit(n));this.globParts=this.preprocess(s),this.debug(this.pattern,this.globParts);let a=this.globParts.map((n,u,i)=>{if(this.isWindows&&this.windowsNoMagicRoot){const l=!(n[0]!==""||n[1]!==""||n[2]!=="?"&&Ld.test(n[2])||Ld.test(n[3])),o=/^[a-z]:/i.test(n[0]);if(l)return[...n.slice(0,4),...n.slice(4).map(c=>this.parse(c))];if(o)return[n[0],...n.slice(1).map(c=>this.parse(c))]}return n.map(l=>this.parse(l))});if(this.debug(this.pattern,a),this.set=a.filter(n=>n.indexOf(!1)===-1),this.isWindows)for(let n=0;n<this.set.length;n++){const u=this.set[n];u[0]===""&&u[1]===""&&this.globParts[n][2]==="?"&&typeof u[3]=="string"&&/^[a-z]:$/i.test(u[3])&&(u[2]="?")}this.debug(this.pattern,this.set)}preprocess(e){if(this.options.noglobstar)for(let s=0;s<e.length;s++)for(let a=0;a<e[s].length;a++)e[s][a]==="**"&&(e[s][a]="*");const{optimizationLevel:t=1}=this.options;return t>=2?(e=this.firstPhasePreProcess(e),e=this.secondPhasePreProcess(e)):e=t>=1?this.levelOneOptimize(e):this.adjascentGlobstarOptimize(e),e}adjascentGlobstarOptimize(e){return e.map(t=>{let s=-1;for(;(s=t.indexOf("**",s+1))!==-1;){let a=s;for(;t[a+1]==="**";)a++;a!==s&&t.splice(s,a-s)}return t})}levelOneOptimize(e){return e.map(t=>(t=t.reduce((s,a)=>{const n=s[s.length-1];return a==="**"&&n==="**"?s:a===".."&&n&&n!==".."&&n!=="."&&n!=="**"?(s.pop(),s):(s.push(a),s)},[])).length===0?[""]:t)}levelTwoFileOptimize(e){Array.isArray(e)||(e=this.slashSplit(e));let t=!1;do{if(t=!1,!this.preserveMultipleSlashes){for(let a=1;a<e.length-1;a++){const n=e[a];a===1&&n===""&&e[0]===""||n!=="."&&n!==""||(t=!0,e.splice(a,1),a--)}e[0]!=="."||e.length!==2||e[1]!=="."&&e[1]!==""||(t=!0,e.pop())}let s=0;for(;(s=e.indexOf("..",s+1))!==-1;){const a=e[s-1];a&&a!=="."&&a!==".."&&a!=="**"&&(t=!0,e.splice(s-1,2),s-=2)}}while(t);return e.length===0?[""]:e}firstPhasePreProcess(e){let t=!1;do{t=!1;for(let s of e){let a=-1;for(;(a=s.indexOf("**",a+1))!==-1;){let u=a;for(;s[u+1]==="**";)u++;u>a&&s.splice(a+1,u-a);let i=s[a+1];const l=s[a+2],o=s[a+3];if(i!==".."||!l||l==="."||l===".."||!o||o==="."||o==="..")continue;t=!0,s.splice(a,1);const c=s.slice(0);c[a]="**",e.push(c),a--}if(!this.preserveMultipleSlashes){for(let u=1;u<s.length-1;u++){const i=s[u];u===1&&i===""&&s[0]===""||i!=="."&&i!==""||(t=!0,s.splice(u,1),u--)}s[0]!=="."||s.length!==2||s[1]!=="."&&s[1]!==""||(t=!0,s.pop())}let n=0;for(;(n=s.indexOf("..",n+1))!==-1;){const u=s[n-1];if(u&&u!=="."&&u!==".."&&u!=="**"){t=!0;const i=n===1&&s[n+1]==="**"?["."]:[];s.splice(n-1,2,...i),s.length===0&&s.push(""),n-=2}}}}while(t);return e}secondPhasePreProcess(e){for(let t=0;t<e.length-1;t++)for(let s=t+1;s<e.length;s++){const a=this.partsMatch(e[t],e[s],!this.preserveMultipleSlashes);if(a){e[t]=[],e[s]=a;break}}return e.filter(t=>t.length)}partsMatch(e,t){let s=arguments.length>2&&arguments[2]!==void 0&&arguments[2],a=0,n=0,u=[],i="";for(;a<e.length&&n<t.length;)if(e[a]===t[n])u.push(i==="b"?t[n]:e[a]),a++,n++;else if(s&&e[a]==="**"&&t[n]===e[a+1])u.push(e[a]),a++;else if(s&&t[n]==="**"&&e[a]===t[n+1])u.push(t[n]),n++;else if(e[a]!=="*"||!t[n]||!this.options.dot&&t[n].startsWith(".")||t[n]==="**"){if(t[n]!=="*"||!e[a]||!this.options.dot&&e[a].startsWith(".")||e[a]==="**"||i==="a")return!1;i="b",u.push(t[n]),a++,n++}else{if(i==="b")return!1;i="a",u.push(e[a]),a++,n++}return e.length===t.length&&u}parseNegate(){if(this.nonegate)return;const e=this.pattern;let t=!1,s=0;for(let a=0;a<e.length&&e.charAt(a)==="!";a++)t=!t,s++;s&&(this.pattern=e.slice(s)),this.negate=t}matchOne(e,t){let s=arguments.length>2&&arguments[2]!==void 0&&arguments[2];const a=this.options;if(this.isWindows){const w=typeof e[0]=="string"&&/^[a-z]:$/i.test(e[0]),y=!w&&e[0]===""&&e[1]===""&&e[2]==="?"&&/^[a-z]:$/i.test(e[3]),k=typeof t[0]=="string"&&/^[a-z]:$/i.test(t[0]),g=y?3:w?0:void 0,b=!k&&t[0]===""&&t[1]===""&&t[2]==="?"&&typeof t[3]=="string"&&/^[a-z]:$/i.test(t[3])?3:k?0:void 0;if(typeof g=="number"&&typeof b=="number"){const[N,S]=[e[g],t[b]];N.toLowerCase()===S.toLowerCase()&&(t[b]=N,b>g?t=t.slice(b):g>b&&(e=e.slice(g)))}}const{optimizationLevel:n=1}=this.options;n>=2&&(e=this.levelTwoFileOptimize(e)),this.debug("matchOne",this,{file:e,pattern:t}),this.debug("matchOne",e.length,t.length);for(var u=0,i=0,l=e.length,o=t.length;u<l&&i<o;u++,i++){this.debug("matchOne loop");var c=t[i],m=e[u];if(this.debug(t,c,m),c===!1)return!1;if(c===Kt){this.debug("GLOBSTAR",[t,c,m]);var h=u,p=i+1;if(p===o){for(this.debug("** at the end");u<l;u++)if(e[u]==="."||e[u]===".."||!a.dot&&e[u].charAt(0)===".")return!1;return!0}for(;h<l;){var d=e[h];if(this.debug("\nglobstar while",e,h,t,p,d),this.matchOne(e.slice(h),t.slice(p),s))return this.debug("globstar found match!",h,l,d),!0;if(d==="."||d===".."||!a.dot&&d.charAt(0)==="."){this.debug("dot detected!",e,h,t,p);break}this.debug("globstar swallow a segment, and continue"),h++}return!(!s||(this.debug("\n>>> no match, partial?",e,h,t,p),h!==l))}let w;if(typeof c=="string"?(w=m===c,this.debug("string match",c,m,w)):(w=c.test(m),this.debug("pattern match",c,m,w)),!w)return!1}if(u===l&&i===o)return!0;if(u===l)return s;if(i===o)return u===l-1&&e[u]==="";throw new Error("wtf?")}braceExpand(){return zp(this.pattern,this.options)}parse(e){Bh(e);const t=this.options;if(e==="**")return Kt;if(e==="")return"";let s,a=null;(s=e.match(ry))?a=t.dot?ny:ay:(s=e.match(Gw))?a=(t.nocase?t.dot?Zw:Xw:t.dot?_w:zw)(s[1]):(s=e.match(iy))?a=(t.nocase?t.dot?uy:oy:t.dot?ly:cy)(s):(s=e.match(Qw))?a=t.dot?ey:Yw:(s=e.match(ty))&&(a=sy);const n=Ph.fromGlob(e,this.options).toMMPattern();return a&&typeof n=="object"&&Reflect.defineProperty(n,"test",{value:a}),n}makeRe(){if(this.regexp||this.regexp===!1)return this.regexp;const e=this.set;if(!e.length)return this.regexp=!1,this.regexp;const t=this.options,s=t.noglobstar?"[^/]*?":t.dot?"(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?":"(?:(?!(?:\\/|^)\\.).)*?",a=new Set(t.nocase?["i"]:[]);let n=e.map(l=>{const o=l.map(c=>{if(c instanceof RegExp)for(const m of c.flags.split(""))a.add(m);return typeof c=="string"?c.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"):c===Kt?Kt:c._src});return o.forEach((c,m)=>{const h=o[m+1],p=o[m-1];c===Kt&&p!==Kt&&(p===void 0?h!==void 0&&h!==Kt?o[m+1]="(?:\\/|"+s+"\\/)?"+h:o[m]=s:h===void 0?o[m-1]=p+"(?:\\/|"+s+")?":h!==Kt&&(o[m-1]=p+"(?:\\/|\\/"+s+"\\/)"+h,o[m+1]=Kt))}),o.filter(c=>c!==Kt).join("/")}).join("|");const[u,i]=e.length>1?["(?:",")"]:["",""];n="^"+u+n+i+"$",this.negate&&(n="^(?!"+n+").+$");try{this.regexp=new RegExp(n,[...a].join(""))}catch(l){this.regexp=!1}return this.regexp}slashSplit(e){return this.preserveMultipleSlashes?e.split("/"):this.isWindows&&/^\/\/[^\/]+/.test(e)?["",...e.split(/\/+/)]:e.split(/\/+/)}match(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.partial;if(this.debug("match",e,this.pattern),this.comment)return!1;if(this.empty)return e==="";if(e==="/"&&t)return!0;const s=this.options;this.isWindows&&(e=e.split("\\").join("/"));const a=this.slashSplit(e);this.debug(this.pattern,"split",a);const n=this.set;this.debug(this.pattern,"set",n);let u=a[a.length-1];if(!u)for(let i=a.length-2;!u&&i>=0;i--)u=a[i];for(let i=0;i<n.length;i++){const l=n[i];let o=a;if(s.matchBase&&l.length===1&&(o=[u]),this.matchOne(o,l,t))return!!s.flipNegate||!this.negate}return!s.flipNegate&&this.negate}static defaults(e){return ft.defaults(e).Minimatch}}function Mf(r){const e=new Error("".concat(arguments.length>1&&arguments[1]!==void 0?arguments[1]:"","Invalid response: ").concat(r.status," ").concat(r.statusText));return e.status=r.status,e.response=r,e}function Qe(r,e){const{status:t}=e;if(t===401&&r.digest)return e;if(t>=400)throw Mf(e);return e}function Tn(r,e){return arguments.length>2&&arguments[2]!==void 0&&arguments[2]?{data:e,headers:r.headers?Lw(r.headers):{},status:r.status,statusText:r.statusText}:e}ft.AST=Ph,ft.Minimatch=Oh,ft.escape=function(r){let{windowsPathsNoEscape:e=!1}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return e?r.replace(/[?*()[\]]/g,"[$&]"):r.replace(/[?*()[\]\\]/g,"\\$&")},ft.unescape=Xo;const hy=(Ud=function(r,e,t){let s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};const a=Ze({url:Ee(r.remoteURL,Ce(e)),method:"COPY",headers:{Destination:Ee(r.remoteURL,Ce(t)),Overwrite:s.overwrite===!1?"F":"T",Depth:s.shallow?"0":"infinity"}},r,s);return u=function(i){Qe(r,i)},(n=Xe(a,r))&&n.then||(n=Promise.resolve(n)),u?n.then(u):n;var n,u},function(){for(var r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];try{return Promise.resolve(Ud.apply(this,r))}catch(t){return Promise.reject(t)}});var Ud,Ff=de(635),my=de(829),Ps=de.n(my),ho=function(r){return r.Array="array",r.Object="object",r.Original="original",r}(ho||{});function dc(r,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:ho.Original;const s=Ps().get(r,e);return t==="array"&&Array.isArray(s)===!1?[s]:t==="object"&&Array.isArray(s)?s[0]:s}function cc(r){return new Promise(e=>{e(function(t){const{multistatus:s}=t;if(s==="")return{multistatus:{response:[]}};if(!s)throw new Error("Invalid response: No root multistatus found");const a={multistatus:Array.isArray(s)?s[0]:s};return Ps().set(a,"multistatus.response",dc(a,"multistatus.response",ho.Array)),Ps().set(a,"multistatus.response",Ps().get(a,"multistatus.response").map(n=>function(u){const i=Object.assign({},u);return i.status?Ps().set(i,"status",dc(i,"status",ho.Object)):(Ps().set(i,"propstat",dc(i,"propstat",ho.Object)),Ps().set(i,"propstat.prop",dc(i,"propstat.prop",ho.Object))),i}(n))),a}(new Ff.XMLParser({removeNSPrefix:!0,numberParseOptions:{hex:!0,leadingZeros:!1}}).parse(r)))})}function Gh(r,e){let t=arguments.length>2&&arguments[2]!==void 0&&arguments[2];const{getlastmodified:s=null,getcontentlength:a="0",resourcetype:n=null,getcontenttype:u=null,getetag:i=null}=r,l=n&&typeof n=="object"&&n.collection!==void 0?"directory":"file",o={filename:e,basename:Eh().basename(e),lastmod:s,size:parseInt(a,10),type:l,etag:typeof i=="string"?i.replace(/"/g,""):null};return l==="file"&&(o.mime=u&&typeof u=="string"?u.split(";")[0]:""),t&&(r.displayname!==void 0&&(r.displayname=String(r.displayname)),o.props=r),o}function _p(r,e){let t=arguments.length>2&&arguments[2]!==void 0&&arguments[2],s=null;try{r.multistatus.response[0].propstat&&(s=r.multistatus.response[0])}catch(c){}if(!s)throw new Error("Failed getting item stat: bad response");const{propstat:{prop:a,status:n}}=s,[u,i,l]=n.split(" ",3),o=parseInt(i,10);if(o>=400){const c=new Error("Invalid response: ".concat(o," ").concat(l));throw c.status=o,c}return Gh(a,ec(e),t)}function Xp(r){switch(String(r)){case"-3":return"unlimited";case"-2":case"-1":return"unknown";default:return parseInt(String(r),10)}}function om(r,e,t){return r&&r.then||(r=Promise.resolve(r)),e?r.then(e):r}const Jf=function(r){return function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];try{return Promise.resolve(r.apply(this,e))}catch(s){return Promise.reject(s)}}}(function(r,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const{details:s=!1}=t,a=Ze({url:Ee(r.remoteURL,Ce(e)),method:"PROPFIND",headers:{Accept:"text/plain,application/xml",Depth:"0"}},r,t);return om(Xe(a,r),function(n){return Qe(r,n),om(n.text(),function(u){return om(cc(u),function(i){const l=_p(i,e,s);return Tn(n,l,s)})})})});function Zp(r,e,t){return r&&r.then||(r=Promise.resolve(r)),e?r.then(e):r}const fy=Qp(function(r,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const s=function(n){if(!n||n==="/")return[];let u=n;const i=[];do i.push(u),u=Eh().dirname(u);while(u&&u!=="/");return i}(ec(e));s.sort((n,u)=>n.length>u.length?1:u.length>n.length?-1:0);let a=!1;return function(n,u,i){if(typeof n[$d]=="function"){let w=function(y){try{for(;!(l=m.next()).done;)if((y=u(l.value))&&y.then){if(!Kd(y))return void y.then(w,c||(c=St.bind(null,o=new mo,2)));y=y.v}o?St(o,1,y):o=y}catch(k){St(o||(o=new mo),2,k)}};var l,o,c,m=n[$d]();if(w(),m.return){var h=function(y){try{l.done||m.return()}catch(k){}return y};if(o&&o.then)return o.then(h,function(y){throw h(y)});h()}return o}if(!("length"in n))throw new TypeError("Object is not iterable");for(var p=[],d=0;d<n.length;d++)p.push(n[d]);return function(w,y,k){var g,b,N=-1;return function S(E){try{for(;++N<w.length&&(!k||!k());)if((E=y(N))&&E.then){if(!Kd(E))return void E.then(S,b||(b=St.bind(null,g=new mo,2)));E=E.v}g?St(g,1,E):g=E}catch(x){St(g||(g=new mo),2,x)}}(),g}(p,function(w){return u(p[w])},i)}(s,function(n){return u=function(){return function(l,o){try{var c=Zp(Jf(r,n),function(m){if(m.type!=="directory")throw new Error("Path includes a file: ".concat(e))})}catch(m){return o(m)}return c&&c.then?c.then(void 0,o):c}(0,function(l){const o=l;return function(){if(o.status===404)return a=!0,jd(af(r,n,os(it({},t),{recursive:!1})));throw l}()})},(i=function(){if(a)return jd(af(r,n,os(it({},t),{recursive:!1})))}())&&i.then?i.then(u):u();var u,i},function(){return!1})});function Qp(r){return function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];try{return Promise.resolve(r.apply(this,e))}catch(s){return Promise.reject(s)}}}function dy(){}function jd(r,e){return r&&r.then?r.then(dy):Promise.resolve()}const $d=typeof Symbol<"u"?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";function St(r,e,t){if(!r.s){if(t instanceof mo){if(!t.s)return void(t.o=St.bind(null,r,e));1&e&&(e=t.s),t=t.v}if(t&&t.then)return void t.then(St.bind(null,r,e),St.bind(null,r,2));r.s=e,r.v=t;const s=r.o;s&&s(r)}}const mo=function(){function r(){}return r.prototype.then=function(e,t){const s=new r,a=this.s;if(a){const n=1&a?e:t;if(n){try{St(s,1,n(this.v))}catch(u){St(s,2,u)}return s}return this}return this.o=function(n){try{const u=n.v;1&n.s?St(s,1,e?e(u):u):t?St(s,1,t(u)):St(s,2,u)}catch(u){St(s,2,u)}},s},r}();function Kd(r){return r instanceof mo&&1&r.s}const af=Qp(function(r,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(t.recursive===!0)return fy(r,e,t);const s=Ze({url:Ee(r.remoteURL,(a=Ce(e),a.endsWith("/")?a:a+"/")),method:"MKCOL"},r,t);var a;return Zp(Xe(s,r),function(n){Qe(r,n)})});var py=de(388),Hd=de.n(py);const gy=function(r){return function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];try{return Promise.resolve(r.apply(this,e))}catch(s){return Promise.reject(s)}}}(function(r,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const s={};if(typeof t.range=="object"&&typeof t.range.start=="number"){let i="bytes=".concat(t.range.start,"-");typeof t.range.end=="number"&&(i="".concat(i).concat(t.range.end)),s.Range=i}const a=Ze({url:Ee(r.remoteURL,Ce(e)),method:"GET",headers:s},r,t);return u=function(i){if(Qe(r,i),s.Range&&i.status!==206){const l=new Error("Invalid response code for partial request: ".concat(i.status));throw l.status=i.status,l}return t.callback&&setTimeout(()=>{t.callback(i)},0),i.body},(n=Xe(a,r))&&n.then||(n=Promise.resolve(n)),u?n.then(u):n;var n,u}),wy=()=>{},yy=function(r){return function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];try{return Promise.resolve(r.apply(this,e))}catch(s){return Promise.reject(s)}}}(function(r,e,t){t.url||(t.url=Ee(r.remoteURL,Ce(e)));const s=Ze(t,r,{});return n=function(u){return Qe(r,u),u},(a=Xe(s,r))&&a.then||(a=Promise.resolve(a)),n?a.then(n):a;var a,n}),vy=function(r){return function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];try{return Promise.resolve(r.apply(this,e))}catch(s){return Promise.reject(s)}}}(function(r,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const s=Ze({url:Ee(r.remoteURL,Ce(e)),method:"DELETE"},r,t);return n=function(u){Qe(r,u)},(a=Xe(s,r))&&a.then||(a=Promise.resolve(a)),n?a.then(n):a;var a,n}),by=function(r){return function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];try{return Promise.resolve(r.apply(this,e))}catch(s){return Promise.reject(s)}}}(function(r,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return function(s,a){try{var n=(u=Jf(r,e,t),i=function(){return!0},l?i?i(u):u:(u&&u.then||(u=Promise.resolve(u)),i?u.then(i):u))}catch(o){return a(o)}var u,i,l;return n&&n.then?n.then(void 0,a):n}(0,function(s){if(s.status===404)return!1;throw s})});function um(r,e,t){return r&&r.then||(r=Promise.resolve(r)),e?r.then(e):r}const Sy=function(r){return function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];try{return Promise.resolve(r.apply(this,e))}catch(s){return Promise.reject(s)}}}(function(r,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const s=Ze({url:Ee(r.remoteURL,Ce(e),"/"),method:"PROPFIND",headers:{Accept:"text/plain,application/xml",Depth:t.deep?"infinity":"1"}},r,t);return um(Xe(s,r),function(a){return Qe(r,a),um(a.text(),function(n){if(!n)throw new Error("Failed parsing directory contents: Empty response");return um(cc(n),function(u){const i=Ed(e);let l=function(o,c,m){let h=arguments.length>3&&arguments[3]!==void 0&&arguments[3],p=arguments.length>4&&arguments[4]!==void 0&&arguments[4];const d=Eh().join(c,"/"),{multistatus:{response:w}}=o,y=w.map(k=>{const g=function(N){try{return N.replace(/^https?:\/\/[^\/]+/,"")}catch(S){throw new Nt(S,"Failed normalising HREF")}}(k.href),{propstat:{prop:b}}=k;return Gh(b,d==="/"?decodeURIComponent(ec(g)):ec(Eh().relative(decodeURIComponent(d),decodeURIComponent(g))),h)});return p?y:y.filter(k=>k.basename&&(k.type==="file"||k.filename!==m.replace(/\/$/,"")))}(u,Ed(r.remoteBasePath||r.remotePath),i,t.details,t.includeSelf);return t.glob&&(l=function(o,c){return o.filter(m=>ft(m.filename,c,{matchBase:!0}))}(l,t.glob)),Tn(a,l,t.details)})})})});function qf(r){return function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];try{return Promise.resolve(r.apply(this,e))}catch(s){return Promise.reject(s)}}}const Ay=qf(function(r,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const s=Ze({url:Ee(r.remoteURL,Ce(e)),method:"GET",headers:{Accept:"text/plain"},transformResponse:[Cy]},r,t);return Dh(Xe(s,r),function(a){return Qe(r,a),Dh(a.text(),function(n){return Tn(a,n,t.details)})})});function Dh(r,e,t){return r&&r.then||(r=Promise.resolve(r)),e?r.then(e):r}const Ny=qf(function(r,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const s=Ze({url:Ee(r.remoteURL,Ce(e)),method:"GET"},r,t);return Dh(Xe(s,r),function(a){let n;return Qe(r,a),function(u,i){var l=u();return l&&l.then?l.then(i):i()}(function(){return Dh(a.arrayBuffer(),function(u){n=u})},function(){return Tn(a,n,t.details)})})}),ky=qf(function(r,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const{format:s="binary"}=t;if(s!=="binary"&&s!=="text")throw new Nt({info:{code:Js.InvalidOutputFormat}},"Invalid output format: ".concat(s));return s==="text"?Ay(r,e,t):Ny(r,e,t)}),Cy=r=>r;function Ey(r){return new Ff.XMLBuilder({attributeNamePrefix:"@_",format:!0,ignoreAttributes:!1,suppressEmptyNode:!0}).build(Yp({lockinfo:{"@_xmlns:d":"DAV:",lockscope:{exclusive:{}},locktype:{write:{}},owner:{href:r}}},"d"))}function Yp(r,e){const t=it({},r);for(const s in t)t.hasOwnProperty(s)&&(t[s]&&typeof t[s]=="object"&&s.indexOf(":")===-1?(t["".concat(e,":").concat(s)]=Yp(t[s],e),delete t[s]):/^@_/.test(s)===!1&&(t["".concat(e,":").concat(s)]=t[s],delete t[s]));return t}function nf(r,e,t){return r&&r.then||(r=Promise.resolve(r)),e?r.then(e):r}function eg(r){return function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];try{return Promise.resolve(r.apply(this,e))}catch(s){return Promise.reject(s)}}}const xy=eg(function(r,e,t){let s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};const a=Ze({url:Ee(r.remoteURL,Ce(e)),method:"UNLOCK",headers:{"Lock-Token":t}},r,s);return nf(Xe(a,r),function(n){if(Qe(r,n),n.status!==204&&n.status!==200)throw Mf(n)})}),Iy=eg(function(r,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const{refreshToken:s,timeout:a=Vy}=t,n={Accept:"text/plain,application/xml",Timeout:a};s&&(n.If=s);const u=Ze({url:Ee(r.remoteURL,Ce(e)),method:"LOCK",headers:n,data:Ey(r.contactHref)},r,t);return nf(Xe(u,r),function(i){return Qe(r,i),nf(i.text(),function(l){const o=(h=l,new Ff.XMLParser({removeNSPrefix:!0,parseAttributeValue:!0,parseTagValue:!0}).parse(h)),c=Ps().get(o,"prop.lockdiscovery.activelock.locktoken.href"),m=Ps().get(o,"prop.lockdiscovery.activelock.timeout");var h;if(!c)throw Mf(i,"No lock token received: ");return{token:c,serverTimeout:m}})})}),Vy="Infinite, Second-4100000000";function lm(r,e,t){return r&&r.then||(r=Promise.resolve(r)),e?r.then(e):r}const By=function(r){return function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];try{return Promise.resolve(r.apply(this,e))}catch(s){return Promise.reject(s)}}}(function(r){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const t=e.path||"/",s=Ze({url:Ee(r.remoteURL,t),method:"PROPFIND",headers:{Accept:"text/plain,application/xml",Depth:"0"}},r,e);return lm(Xe(s,r),function(a){return Qe(r,a),lm(a.text(),function(n){return lm(cc(n),function(u){const i=function(l){try{const[o]=l.multistatus.response,{propstat:{prop:{"quota-used-bytes":c,"quota-available-bytes":m}}}=o;return c!==void 0&&m!==void 0?{used:parseInt(String(c),10),available:Xp(m)}:null}catch(o){}return null}(u);return Tn(a,i,e.details)})})})});function cm(r,e,t){return r&&r.then||(r=Promise.resolve(r)),e?r.then(e):r}const Py=function(r){return function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];try{return Promise.resolve(r.apply(this,e))}catch(s){return Promise.reject(s)}}}(function(r,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const{details:s=!1}=t,a=Ze({url:Ee(r.remoteURL,Ce(e)),method:"SEARCH",headers:{Accept:"text/plain,application/xml","Content-Type":r.headers["Content-Type"]||"application/xml; charset=utf-8"}},r,t);return cm(Xe(a,r),function(n){return Qe(r,n),cm(n.text(),function(u){return cm(cc(u),function(i){const l=function(o,c,m){const h={truncated:!1,results:[]};return h.truncated=o.multistatus.response.some(p=>{var d,w;return((w=(p.status||((d=p.propstat)==null?void 0:d.status)).split(" ",3))==null?void 0:w[1])==="507"&&p.href.replace(/\/$/,"").endsWith(Ce(c).replace(/\/$/,""))}),o.multistatus.response.forEach(p=>{if(p.propstat===void 0)return;const d=p.href.split("/").map(decodeURIComponent).join("/");h.results.push(Gh(p.propstat.prop,d,m))}),h}(i,e,s);return Tn(n,l,s)})})})}),Oy=function(r){return function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];try{return Promise.resolve(r.apply(this,e))}catch(s){return Promise.reject(s)}}}(function(r,e,t){let s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};const a=Ze({url:Ee(r.remoteURL,Ce(e)),method:"MOVE",headers:{Destination:Ee(r.remoteURL,Ce(t)),Overwrite:s.overwrite===!1?"F":"T"}},r,s);return u=function(i){Qe(r,i)},(n=Xe(a,r))&&n.then||(n=Promise.resolve(n)),u?n.then(u):n;var n,u});var Dy=de(172);const Ty=function(r){return function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];try{return Promise.resolve(r.apply(this,e))}catch(s){return Promise.reject(s)}}}(function(r,e,t){let s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};const{contentLength:a=!0,overwrite:n=!0}=s,u={"Content-Type":"application/octet-stream"};a===!1||(u["Content-Length"]=typeof a=="number"?"".concat(a):"".concat(function(c){if(Kp(c))return c.byteLength;if(Hp(c))return c.length;if(typeof c=="string")return(0,Dy.d)(c);throw new Nt({info:{code:Js.DataTypeNoLength}},"Cannot calculate data length: Invalid type")}(t))),n||(u["If-None-Match"]="*");const i=Ze({url:Ee(r.remoteURL,Ce(e)),method:"PUT",headers:u,data:t},r,s);return o=function(c){try{Qe(r,c)}catch(m){const h=m;if(h.status!==412||n)throw h;return!1}return!0},(l=Xe(i,r))&&l.then||(l=Promise.resolve(l)),o?l.then(o):l;var l,o}),tg=function(r){return function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];try{return Promise.resolve(r.apply(this,e))}catch(s){return Promise.reject(s)}}}(function(r,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const s=Ze({url:Ee(r.remoteURL,Ce(e)),method:"OPTIONS"},r,t);return n=function(u){var i,l;try{Qe(r,u)}catch(o){throw o}return{compliance:((i=u.headers.get("DAV"))!=null?i:"").split(",").map(o=>o.trim()),server:(l=u.headers.get("Server"))!=null?l:""}},(a=Xe(s,r))&&a.then||(a=Promise.resolve(a)),n?a.then(n):a;var a,n});function Gl(r,e,t){return r&&r.then||(r=Promise.resolve(r)),e?r.then(e):r}const Ry=Wf(function(r,e,t,s,a){let n=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{};if(t>s||t<0)throw new Nt({info:{code:Js.InvalidUpdateRange}},"Invalid update range ".concat(t," for partial update"));const u={"Content-Type":"application/octet-stream","Content-Length":""+(s-t+1),"Content-Range":"bytes ".concat(t,"-").concat(s,"/*")},i=Ze({url:Ee(r.remoteURL,Ce(e)),method:"PUT",headers:u,data:a},r,n);return Gl(Xe(i,r),function(l){Qe(r,l)})});function Md(r,e){var t=r();return t&&t.then?t.then(e):e(t)}const Ly=Wf(function(r,e,t,s,a){let n=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{};if(t>s||t<0)throw new Nt({info:{code:Js.InvalidUpdateRange}},"Invalid update range ".concat(t," for partial update"));const u={"Content-Type":"application/x-sabredav-partialupdate","Content-Length":""+(s-t+1),"X-Update-Range":"bytes=".concat(t,"-").concat(s)},i=Ze({url:Ee(r.remoteURL,Ce(e)),method:"PATCH",headers:u,data:a},r,n);return Gl(Xe(i,r),function(l){Qe(r,l)})});function Wf(r){return function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];try{return Promise.resolve(r.apply(this,e))}catch(s){return Promise.reject(s)}}}const Uy=Wf(function(r,e,t,s,a){let n=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{};return Gl(tg(r,e,n),function(u){let i=!1;return Md(function(){if(u.compliance.includes("sabredav-partialupdate"))return Gl(Ly(r,e,t,s,a,n),function(l){return i=!0,l})},function(l){let o=!1;return i?l:Md(function(){if(u.server.includes("Apache")&&u.compliance.includes("<http://apache.org/dav/propset/fs/1>"))return Gl(Ry(r,e,t,s,a,n),function(c){return o=!0,c})},function(c){if(o)return c;throw new Nt({info:{code:Js.NotSupported}},"Not supported")})})})}),jy="https://github.com/perry-mitchell/webdav-client/blob/master/LOCK_CONTACT.md";function $y(r){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const{authType:t=null,remoteBasePath:s,contactHref:a=jy,ha1:n,headers:u={},httpAgent:i,httpsAgent:l,password:o,token:c,username:m,withCredentials:h}=e;let p=t;p||(p=m||o?bt.Password:bt.None);const d={authType:p,remoteBasePath:s,contactHref:a,ha1:n,headers:Object.assign({},u),httpAgent:i,httpsAgent:l,password:o,remotePath:xw(r),remoteURL:r,token:c,username:m,withCredentials:h};return Up(d,m,o,c,n),{copyFile:(w,y,k)=>hy(d,w,y,k),createDirectory:(w,y)=>af(d,w,y),createReadStream:(w,y)=>function(k,g){let b=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const N=new(Hd()).PassThrough;return gy(k,g,b).then(S=>{S.pipe(N)}).catch(S=>{N.emit("error",S)}),N}(d,w,y),createWriteStream:(w,y,k)=>function(g,b){let N=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},S=arguments.length>3&&arguments[3]!==void 0?arguments[3]:wy;const E=new(Hd()).PassThrough,x={};N.overwrite===!1&&(x["If-None-Match"]="*");const C=Ze({url:Ee(g.remoteURL,Ce(b)),method:"PUT",headers:x,data:E,maxRedirects:0},g,N);return Xe(C,g).then(P=>Qe(g,P)).then(P=>{setTimeout(()=>{S(P)},0)}).catch(P=>{E.emit("error",P)}),E}(d,w,y,k),customRequest:(w,y)=>yy(d,w,y),deleteFile:(w,y)=>vy(d,w,y),exists:(w,y)=>by(d,w,y),getDirectoryContents:(w,y)=>Sy(d,w,y),getFileContents:(w,y)=>ky(d,w,y),getFileDownloadLink:w=>function(y,k){let g=Ee(y.remoteURL,Ce(k));const b=/^https:/i.test(g)?"https":"http";switch(y.authType){case bt.None:break;case bt.Password:{const N=Id(y.headers.Authorization.replace(/^Basic /i,"").trim());g=g.replace(/^https?:\/\//,"".concat(b,"://").concat(N,"@"));break}default:throw new Nt({info:{code:Js.LinkUnsupportedAuthType}},"Unsupported auth type for file link: ".concat(y.authType))}return g}(d,w),getFileUploadLink:w=>function(y,k){let g="".concat(Ee(y.remoteURL,Ce(k)),"?Content-Type=application/octet-stream");const b=/^https:/i.test(g)?"https":"http";switch(y.authType){case bt.None:break;case bt.Password:{const N=Id(y.headers.Authorization.replace(/^Basic /i,"").trim());g=g.replace(/^https?:\/\//,"".concat(b,"://").concat(N,"@"));break}default:throw new Nt({info:{code:Js.LinkUnsupportedAuthType}},"Unsupported auth type for file link: ".concat(y.authType))}return g}(d,w),getHeaders:()=>Object.assign({},d.headers),getQuota:w=>By(d,w),lock:(w,y)=>Iy(d,w,y),moveFile:(w,y,k)=>Oy(d,w,y,k),putFileContents:(w,y,k)=>Ty(d,w,y,k),partialUpdateFileContents:(w,y,k,g,b)=>Uy(d,w,y,k,g,b),getDAVCompliance:w=>tg(d,w),search:(w,y)=>Py(d,w,y),setHeaders:w=>{d.headers=Object.assign({},w)},stat:(w,y)=>Jf(d,w,y),unlock:(w,y,k)=>xy(d,w,y,k)}}zt.hT,zt.O4,zt.Kd,zt.YK;var Ky=zt.UU,Hy=zt.Gu,My=zt.ky,Fy=zt.h4;zt.ch,zt.hq,zt.i5;function sg(){var r;return(r=Lf("files_sharing","isPublic",null))!=null?r:document.querySelector('input#isPublic[type="hidden"][name="isPublic"][value="1"]')!==null}function Jy(){var r,e,t;return(t=(e=Lf("files_sharing","sharingToken",null))!=null?e:(r=document.querySelector('input#sharingToken[type="hidden"]'))==null?void 0:r.value)!=null?t:null}const wo=Gm().setApp("@nextcloud/files").detectUser().build();var rg=(r=>(r[r.NONE=0]="NONE",r[r.CREATE=4]="CREATE",r[r.READ=1]="READ",r[r.UPDATE=2]="UPDATE",r[r.DELETE=8]="DELETE",r[r.SHARE=16]="SHARE",r[r.ALL=31]="ALL",r))(rg||{}),ag=(r=>(r.Folder="folder",r.File="file",r))(ag||{});const ng=["d:getcontentlength","d:getcontenttype","d:getetag","d:getlastmodified","d:creationdate","d:displayname","d:quota-available-bytes","d:resourcetype","nc:has-preview","nc:is-encrypted","nc:mount-type","oc:comments-unread","oc:favorite","oc:fileid","oc:owner-display-name","oc:owner-id","oc:permissions","oc:size"],ig={d:"DAV:",nc:"http://nextcloud.org/ns",oc:"http://owncloud.org/ns",ocs:"http://open-collaboration-services.org/ns"},hm=function(r,e={nc:"http://nextcloud.org/ns"}){typeof window._nc_dav_properties>"u"&&(window._nc_dav_properties=[...ng],window._nc_dav_namespaces=it({},ig));const t=it(it({},window._nc_dav_namespaces),e);if(window._nc_dav_properties.find(a=>a===r))return wo.warn("".concat(r," already registered"),{prop:r}),!1;if(r.startsWith("<")||r.split(":").length!==2)return wo.error("".concat(r," is not valid. See example: 'oc:fileid'"),{prop:r}),!1;const s=r.split(":")[0];return t[s]?(window._nc_dav_properties.push(r),window._nc_dav_namespaces=t,!0):(wo.error("".concat(r," namespace unknown"),{prop:r,namespaces:t}),!1)},qy=function(){return typeof window._nc_dav_properties>"u"&&(window._nc_dav_properties=[...ng]),window._nc_dav_properties.map(r=>"<".concat(r," />")).join(" ")},Wy=function(){return typeof window._nc_dav_namespaces>"u"&&(window._nc_dav_namespaces=it({},ig)),Object.keys(window._nc_dav_namespaces).map(r=>{var e;return"xmlns:".concat(r,'="').concat((e=window._nc_dav_namespaces)==null?void 0:e[r],'"')}).join(" ")},Gy=function(){return'<?xml version="1.0"?>\n <d:propfind '.concat(Wy(),">\n <d:prop>\n ").concat(qy(),"\n </d:prop>\n </d:propfind>")};function zy(){var r;return sg()?"/files/".concat(Jy()):"/files/".concat((r=Uf())==null?void 0:r.uid)}zy();function _y(){const r=_g("dav");return sg()?r.replace("remote.php","public.php"):r}const Xy=_y(),Zy=function(r=Xy,e={}){const t=Ky(r,{headers:e});function s(a){t.setHeaders(os(it({},e),{"X-Requested-With":"XMLHttpRequest",requesttoken:a!=null?a:""}))}return Xg(s),s(Zg()),Hy().patch("fetch",(a,n)=>{const u=n.headers;return u!=null&&u.method&&(n.method=u.method,delete u.method),fetch(a,n)}),t};var mm={},Gf=(r=>(r.DEFAULT="default",r.HIDDEN="hidden",r))(Gf||{});class Qy{constructor(e){Ke(this,"_action");this.validateAction(e),this._action=e}get id(){return this._action.id}get displayName(){return this._action.displayName}get title(){return this._action.title}get iconSvgInline(){return this._action.iconSvgInline}get enabled(){return this._action.enabled}get exec(){return this._action.exec}get execBatch(){return this._action.execBatch}get order(){return this._action.order}get parent(){return this._action.parent}get default(){return this._action.default}get destructive(){return this._action.destructive}get inline(){return this._action.inline}get renderInline(){return this._action.renderInline}validateAction(e){if(!e.id||typeof e.id!="string")throw new Error("Invalid id");if(!e.displayName||typeof e.displayName!="function")throw new Error("Invalid displayName function");if("title"in e&&typeof e.title!="function")throw new Error("Invalid title function");if(!e.iconSvgInline||typeof e.iconSvgInline!="function")throw new Error("Invalid iconSvgInline function");if(!e.exec||typeof e.exec!="function")throw new Error("Invalid exec function");if("enabled"in e&&typeof e.enabled!="function")throw new Error("Invalid enabled function");if("execBatch"in e&&typeof e.execBatch!="function")throw new Error("Invalid execBatch function");if("order"in e&&typeof e.order!="number")throw new Error("Invalid order");if(e.destructive!==void 0&&typeof e.destructive!="boolean")throw new Error("Invalid destructive flag");if("parent"in e&&typeof e.parent!="string")throw new Error("Invalid parent");if(e.default&&!Object.values(Gf).includes(e.default))throw new Error("Invalid default");if("inline"in e&&typeof e.inline!="function")throw new Error("Invalid inline function");if("renderInline"in e&&typeof e.renderInline!="function")throw new Error("Invalid renderInline function")}}const Yy=function(r){if(typeof window._nc_fileactions>"u"&&(window._nc_fileactions=[],wo.debug("FileActions initialized")),window._nc_fileactions.find(e=>e.id===r.id)){wo.error("FileAction ".concat(r.id," already registered"),{action:r});return}window._nc_fileactions.push(r)},ev=function(){return typeof window._nc_fileactions>"u"&&(window._nc_fileactions=[],wo.debug("FileActions initialized")),window._nc_fileactions};var tv={};(function(r){const e=":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",t=e+"\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040",s="["+e+"]["+t+"]*",a=new RegExp("^"+s+"$"),n=function(i,l){const o=[];let c=l.exec(i);for(;c;){const m=[];m.startIndex=l.lastIndex-c[0].length;const h=c.length;for(let p=0;p<h;p++)m.push(c[p]);o.push(m),c=l.exec(i)}return o},u=function(i){const l=a.exec(i);return!(l===null||typeof l>"u")};r.isExist=function(i){return typeof i<"u"},r.isEmptyObject=function(i){return Object.keys(i).length===0},r.merge=function(i,l,o){if(l){const c=Object.keys(l),m=c.length;for(let h=0;h<m;h++)o==="strict"?i[c[h]]=[l[c[h]]]:i[c[h]]=l[c[h]]}},r.getValue=function(i){return r.isExist(i)?i:""},r.isName=u,r.getAllMatches=n,r.nameRegexp=s})(tv),!Number.parseInt&&window.parseInt&&(Number.parseInt=window.parseInt),!Number.parseFloat&&window.parseFloat&&(Number.parseFloat=window.parseFloat);const sv=typeof Ge=="object"&&mm&&mm.NODE_DEBUG&&/\bsemver\b/i.test(mm.NODE_DEBUG)?(...r)=>console.error("SEMVER",...r):()=>{};var rv=sv;const av="2.0.0",og=256,nv=Number.MAX_SAFE_INTEGER||9007199254740991,iv=16,ov=og-6,uv=["major","premajor","minor","preminor","patch","prepatch","prerelease"];var lv={MAX_LENGTH:og,MAX_SAFE_COMPONENT_LENGTH:iv,MAX_SAFE_BUILD_LENGTH:ov,MAX_SAFE_INTEGER:nv,RELEASE_TYPES:uv,SEMVER_SPEC_VERSION:av,FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2},Fd={exports:{}};(function(r,e){const{MAX_SAFE_COMPONENT_LENGTH:t,MAX_SAFE_BUILD_LENGTH:s,MAX_LENGTH:a}=lv,n=rv;e=r.exports={};const u=e.re=[],i=e.safeRe=[],l=e.src=[],o=e.t={};let c=0;const m="[a-zA-Z0-9-]",h=[["\\s",1],["\\d",a],[m,s]],p=w=>{for(const[y,k]of h)w=w.split("".concat(y,"*")).join("".concat(y,"{0,").concat(k,"}")).split("".concat(y,"+")).join("".concat(y,"{1,").concat(k,"}"));return w},d=(w,y,k)=>{const g=p(y),b=c++;n(w,b,y),o[w]=b,l[b]=y,u[b]=new RegExp(y,k?"g":void 0),i[b]=new RegExp(g,k?"g":void 0)};d("NUMERICIDENTIFIER","0|[1-9]\\d*"),d("NUMERICIDENTIFIERLOOSE","\\d+"),d("NONNUMERICIDENTIFIER","\\d*[a-zA-Z-]".concat(m,"*")),d("MAINVERSION","(".concat(l[o.NUMERICIDENTIFIER],")\\.(").concat(l[o.NUMERICIDENTIFIER],")\\.(").concat(l[o.NUMERICIDENTIFIER],")")),d("MAINVERSIONLOOSE","(".concat(l[o.NUMERICIDENTIFIERLOOSE],")\\.(").concat(l[o.NUMERICIDENTIFIERLOOSE],")\\.(").concat(l[o.NUMERICIDENTIFIERLOOSE],")")),d("PRERELEASEIDENTIFIER","(?:".concat(l[o.NUMERICIDENTIFIER],"|").concat(l[o.NONNUMERICIDENTIFIER],")")),d("PRERELEASEIDENTIFIERLOOSE","(?:".concat(l[o.NUMERICIDENTIFIERLOOSE],"|").concat(l[o.NONNUMERICIDENTIFIER],")")),d("PRERELEASE","(?:-(".concat(l[o.PRERELEASEIDENTIFIER],"(?:\\.").concat(l[o.PRERELEASEIDENTIFIER],")*))")),d("PRERELEASELOOSE","(?:-?(".concat(l[o.PRERELEASEIDENTIFIERLOOSE],"(?:\\.").concat(l[o.PRERELEASEIDENTIFIERLOOSE],")*))")),d("BUILDIDENTIFIER","".concat(m,"+")),d("BUILD","(?:\\+(".concat(l[o.BUILDIDENTIFIER],"(?:\\.").concat(l[o.BUILDIDENTIFIER],")*))")),d("FULLPLAIN","v?".concat(l[o.MAINVERSION]).concat(l[o.PRERELEASE],"?").concat(l[o.BUILD],"?")),d("FULL","^".concat(l[o.FULLPLAIN],"$")),d("LOOSEPLAIN","[v=\\s]*".concat(l[o.MAINVERSIONLOOSE]).concat(l[o.PRERELEASELOOSE],"?").concat(l[o.BUILD],"?")),d("LOOSE","^".concat(l[o.LOOSEPLAIN],"$")),d("GTLT","((?:<|>)?=?)"),d("XRANGEIDENTIFIERLOOSE","".concat(l[o.NUMERICIDENTIFIERLOOSE],"|x|X|\\*")),d("XRANGEIDENTIFIER","".concat(l[o.NUMERICIDENTIFIER],"|x|X|\\*")),d("XRANGEPLAIN","[v=\\s]*(".concat(l[o.XRANGEIDENTIFIER],")(?:\\.(").concat(l[o.XRANGEIDENTIFIER],")(?:\\.(").concat(l[o.XRANGEIDENTIFIER],")(?:").concat(l[o.PRERELEASE],")?").concat(l[o.BUILD],"?)?)?")),d("XRANGEPLAINLOOSE","[v=\\s]*(".concat(l[o.XRANGEIDENTIFIERLOOSE],")(?:\\.(").concat(l[o.XRANGEIDENTIFIERLOOSE],")(?:\\.(").concat(l[o.XRANGEIDENTIFIERLOOSE],")(?:").concat(l[o.PRERELEASELOOSE],")?").concat(l[o.BUILD],"?)?)?")),d("XRANGE","^".concat(l[o.GTLT],"\\s*").concat(l[o.XRANGEPLAIN],"$")),d("XRANGELOOSE","^".concat(l[o.GTLT],"\\s*").concat(l[o.XRANGEPLAINLOOSE],"$")),d("COERCEPLAIN","(^|[^\\d])(\\d{1,".concat(t,"})(?:\\.(\\d{1,").concat(t,"}))?(?:\\.(\\d{1,").concat(t,"}))?")),d("COERCE","".concat(l[o.COERCEPLAIN],"(?:$|[^\\d])")),d("COERCEFULL",l[o.COERCEPLAIN]+"(?:".concat(l[o.PRERELEASE],")?(?:").concat(l[o.BUILD],")?(?:$|[^\\d])")),d("COERCERTL",l[o.COERCE],!0),d("COERCERTLFULL",l[o.COERCEFULL],!0),d("LONETILDE","(?:~>?)"),d("TILDETRIM","(\\s*)".concat(l[o.LONETILDE],"\\s+"),!0),e.tildeTrimReplace="$1~",d("TILDE","^".concat(l[o.LONETILDE]).concat(l[o.XRANGEPLAIN],"$")),d("TILDELOOSE","^".concat(l[o.LONETILDE]).concat(l[o.XRANGEPLAINLOOSE],"$")),d("LONECARET","(?:\\^)"),d("CARETTRIM","(\\s*)".concat(l[o.LONECARET],"\\s+"),!0),e.caretTrimReplace="$1^",d("CARET","^".concat(l[o.LONECARET]).concat(l[o.XRANGEPLAIN],"$")),d("CARETLOOSE","^".concat(l[o.LONECARET]).concat(l[o.XRANGEPLAINLOOSE],"$")),d("COMPARATORLOOSE","^".concat(l[o.GTLT],"\\s*(").concat(l[o.LOOSEPLAIN],")$|^$")),d("COMPARATOR","^".concat(l[o.GTLT],"\\s*(").concat(l[o.FULLPLAIN],")$|^$")),d("COMPARATORTRIM","(\\s*)".concat(l[o.GTLT],"\\s*(").concat(l[o.LOOSEPLAIN],"|").concat(l[o.XRANGEPLAIN],")"),!0),e.comparatorTrimReplace="$1$2$3",d("HYPHENRANGE","^\\s*(".concat(l[o.XRANGEPLAIN],")\\s+-\\s+(").concat(l[o.XRANGEPLAIN],")\\s*$")),d("HYPHENRANGELOOSE","^\\s*(".concat(l[o.XRANGEPLAINLOOSE],")\\s+-\\s+(").concat(l[o.XRANGEPLAINLOOSE],")\\s*$")),d("STAR","(<|>)?=?\\s*\\*"),d("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$"),d("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")})(Fd,Fd.exports);var zf={},zh={};(function(r){const e=":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",t=e+"\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040",s="["+e+"]["+t+"]*",a=new RegExp("^"+s+"$"),n=function(i,l){const o=[];let c=l.exec(i);for(;c;){const m=[];m.startIndex=l.lastIndex-c[0].length;const h=c.length;for(let p=0;p<h;p++)m.push(c[p]);o.push(m),c=l.exec(i)}return o},u=function(i){const l=a.exec(i);return!(l===null||typeof l>"u")};r.isExist=function(i){return typeof i<"u"},r.isEmptyObject=function(i){return Object.keys(i).length===0},r.merge=function(i,l,o){if(l){const c=Object.keys(l),m=c.length;for(let h=0;h<m;h++)o==="strict"?i[c[h]]=[l[c[h]]]:i[c[h]]=l[c[h]]}},r.getValue=function(i){return r.isExist(i)?i:""},r.isName=u,r.getAllMatches=n,r.nameRegexp=s})(zh);const _f=zh,cv={allowBooleanAttributes:!1,unpairedTags:[]};zf.validate=function(r,e){e=Object.assign({},cv,e);const t=[];let s=!1,a=!1;r[0]==="\uFEFF"&&(r=r.substr(1));for(let n=0;n<r.length;n++)if(r[n]==="<"&&r[n+1]==="?"){if(n+=2,n=qd(r,n),n.err)return n}else if(r[n]==="<"){let u=n;if(n++,r[n]==="!"){n=Wd(r,n);continue}else{let i=!1;r[n]==="/"&&(i=!0,n++);let l="";for(;n<r.length&&r[n]!==">"&&r[n]!==" "&&r[n]!==" "&&r[n]!=="\n"&&r[n]!=="\r";n++)l+=r[n];if(l=l.trim(),l[l.length-1]==="/"&&(l=l.substring(0,l.length-1),n--),!yv(l)){let m;return l.trim().length===0?m="Invalid space after '<'.":m="Tag '"+l+"' is an invalid name.",Pe("InvalidTag",m,dt(r,n))}const o=fv(r,n);if(o===!1)return Pe("InvalidAttr","Attributes for '"+l+"' have open quote.",dt(r,n));let c=o.value;if(n=o.index,c[c.length-1]==="/"){const m=n-c.length;c=c.substring(0,c.length-1);const h=Gd(c,e);if(h===!0)s=!0;else return Pe(h.err.code,h.err.msg,dt(r,m+h.err.line))}else if(i)if(o.tagClosed){if(c.trim().length>0)return Pe("InvalidTag","Closing tag '"+l+"' can't have attributes or invalid starting.",dt(r,u));if(t.length===0)return Pe("InvalidTag","Closing tag '"+l+"' has not been opened.",dt(r,u));{const m=t.pop();if(l!==m.tagName){let h=dt(r,m.tagStartPos);return Pe("InvalidTag","Expected closing tag '"+m.tagName+"' (opened in line "+h.line+", col "+h.col+") instead of closing tag '"+l+"'.",dt(r,u))}t.length==0&&(a=!0)}}else return Pe("InvalidTag","Closing tag '"+l+"' doesn't have proper closing.",dt(r,n));else{const m=Gd(c,e);if(m!==!0)return Pe(m.err.code,m.err.msg,dt(r,n-c.length+m.err.line));if(a===!0)return Pe("InvalidXml","Multiple possible root nodes found.",dt(r,n));e.unpairedTags.indexOf(l)!==-1||t.push({tagName:l,tagStartPos:u}),s=!0}for(n++;n<r.length;n++)if(r[n]==="<")if(r[n+1]==="!"){n++,n=Wd(r,n);continue}else if(r[n+1]==="?"){if(n=qd(r,++n),n.err)return n}else break;else if(r[n]==="&"){const m=gv(r,n);if(m==-1)return Pe("InvalidChar","char '&' is not expected.",dt(r,n));n=m}else if(a===!0&&!Jd(r[n]))return Pe("InvalidXml","Extra text at the end",dt(r,n));r[n]==="<"&&n--}}else{if(Jd(r[n]))continue;return Pe("InvalidChar","char '"+r[n]+"' is not expected.",dt(r,n))}if(s){if(t.length==1)return Pe("InvalidTag","Unclosed tag '"+t[0].tagName+"'.",dt(r,t[0].tagStartPos));if(t.length>0)return Pe("InvalidXml","Invalid '"+JSON.stringify(t.map(n=>n.tagName),null,4).replace(/\r?\n/g,"")+"' found.",{line:1,col:1})}else return Pe("InvalidXml","Start tag expected.",1);return!0};function Jd(r){return r===" "||r===" "||r==="\n"||r==="\r"}function qd(r,e){const t=e;for(;e<r.length;e++)if(r[e]=="?"||r[e]==" "){const s=r.substr(t,e-t);if(e>5&&s==="xml")return Pe("InvalidXml","XML declaration allowed only at the start of the document.",dt(r,e));if(r[e]=="?"&&r[e+1]==">"){e++;break}else continue}return e}function Wd(r,e){if(r.length>e+5&&r[e+1]==="-"&&r[e+2]==="-"){for(e+=3;e<r.length;e++)if(r[e]==="-"&&r[e+1]==="-"&&r[e+2]===">"){e+=2;break}}else if(r.length>e+8&&r[e+1]==="D"&&r[e+2]==="O"&&r[e+3]==="C"&&r[e+4]==="T"&&r[e+5]==="Y"&&r[e+6]==="P"&&r[e+7]==="E"){let t=1;for(e+=8;e<r.length;e++)if(r[e]==="<")t++;else if(r[e]===">"&&(t--,t===0))break}else if(r.length>e+9&&r[e+1]==="["&&r[e+2]==="C"&&r[e+3]==="D"&&r[e+4]==="A"&&r[e+5]==="T"&&r[e+6]==="A"&&r[e+7]==="["){for(e+=8;e<r.length;e++)if(r[e]==="]"&&r[e+1]==="]"&&r[e+2]===">"){e+=2;break}}return e}const hv='"',mv="'";function fv(r,e){let t="",s="",a=!1;for(;e<r.length;e++){if(r[e]===hv||r[e]===mv)s===""?s=r[e]:s!==r[e]||(s="");else if(r[e]===">"&&s===""){a=!0;break}t+=r[e]}return s!==""?!1:{value:t,index:e,tagClosed:a}}const dv=new RegExp("(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['\"])(([\\s\\S])*?)\\5)?","g");function Gd(r,e){const t=_f.getAllMatches(r,dv),s={};for(let a=0;a<t.length;a++){if(t[a][1].length===0)return Pe("InvalidAttr","Attribute '"+t[a][2]+"' has no space in starting.",To(t[a]));if(t[a][3]!==void 0&&t[a][4]===void 0)return Pe("InvalidAttr","Attribute '"+t[a][2]+"' is without value.",To(t[a]));if(t[a][3]===void 0&&!e.allowBooleanAttributes)return Pe("InvalidAttr","boolean attribute '"+t[a][2]+"' is not allowed.",To(t[a]));const n=t[a][2];if(!wv(n))return Pe("InvalidAttr","Attribute '"+n+"' is an invalid name.",To(t[a]));if(!s.hasOwnProperty(n))s[n]=1;else return Pe("InvalidAttr","Attribute '"+n+"' is repeated.",To(t[a]))}return!0}function pv(r,e){let t=/\d/;for(r[e]==="x"&&(e++,t=/[\da-fA-F]/);e<r.length;e++){if(r[e]===";")return e;if(!r[e].match(t))break}return-1}function gv(r,e){if(e++,r[e]===";")return-1;if(r[e]==="#")return e++,pv(r,e);let t=0;for(;e<r.length;e++,t++)if(!(r[e].match(/\w/)&&t<20)){if(r[e]===";")break;return-1}return e}function Pe(r,e,t){return{err:{code:r,msg:e,line:t.line||t,col:t.col}}}function wv(r){return _f.isName(r)}function yv(r){return _f.isName(r)}function dt(r,e){const t=r.substring(0,e).split(/\r?\n/);return{line:t.length,col:t[t.length-1].length+1}}function To(r){return r.startIndex+r[1].length}var of={};const ug={preserveOrder:!1,attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,removeNSPrefix:!1,allowBooleanAttributes:!1,parseTagValue:!0,parseAttributeValue:!1,trimValues:!0,cdataPropName:!1,numberParseOptions:{hex:!0,leadingZeros:!0,eNotation:!0},tagValueProcessor:function(r,e){return e},attributeValueProcessor:function(r,e){return e},stopNodes:[],alwaysCreateTextNode:!1,isArray:()=>!1,commentPropName:!1,unpairedTags:[],processEntities:!0,htmlEntities:!1,ignoreDeclaration:!1,ignorePiTags:!1,transformTagName:!1,transformAttributeName:!1,updateTag:function(r,e,t){return r}},vv=function(r){return Object.assign({},ug,r)};of.buildOptions=vv,of.defaultOptions=ug;class bv{constructor(e){this.tagname=e,this.child=[],this[":@"]={}}add(e,t){e==="__proto__"&&(e="#__proto__"),this.child.push({[e]:t})}addChild(e){e.tagname==="__proto__"&&(e.tagname="#__proto__"),e[":@"]&&Object.keys(e[":@"]).length>0?this.child.push({[e.tagname]:e.child,":@":e[":@"]}):this.child.push({[e.tagname]:e.child})}}var Sv=bv;const Av=zh;function Nv(r,e){const t={};if(r[e+3]==="O"&&r[e+4]==="C"&&r[e+5]==="T"&&r[e+6]==="Y"&&r[e+7]==="P"&&r[e+8]==="E"){e=e+9;let s=1,a=!1,n=!1,u="";for(;e<r.length;e++)if(r[e]==="<"&&!n){if(a&&Ev(r,e))e+=7,[entityName,val,e]=kv(r,e+1),val.indexOf("&")===-1&&(t[Bv(entityName)]={regx:RegExp("&".concat(entityName,";"),"g"),val});else if(a&&xv(r,e))e+=8;else if(a&&Iv(r,e))e+=8;else if(a&&Vv(r,e))e+=9;else if(Cv)n=!0;else throw new Error("Invalid DOCTYPE");s++,u=""}else if(r[e]===">"){if(n?r[e-1]==="-"&&r[e-2]==="-"&&(n=!1,s--):s--,s===0)break}else r[e]==="["?a=!0:u+=r[e];if(s!==0)throw new Error("Unclosed DOCTYPE")}else throw new Error("Invalid Tag instead of DOCTYPE");return{entities:t,i:e}}function kv(r,e){let t="";for(;e<r.length&&r[e]!=="'"&&r[e]!=='"';e++)t+=r[e];if(t=t.trim(),t.indexOf(" ")!==-1)throw new Error("External entites are not supported");const s=r[e++];let a="";for(;e<r.length&&r[e]!==s;e++)a+=r[e];return[t,a,e]}function Cv(r,e){return r[e+1]==="!"&&r[e+2]==="-"&&r[e+3]==="-"}function Ev(r,e){return r[e+1]==="!"&&r[e+2]==="E"&&r[e+3]==="N"&&r[e+4]==="T"&&r[e+5]==="I"&&r[e+6]==="T"&&r[e+7]==="Y"}function xv(r,e){return r[e+1]==="!"&&r[e+2]==="E"&&r[e+3]==="L"&&r[e+4]==="E"&&r[e+5]==="M"&&r[e+6]==="E"&&r[e+7]==="N"&&r[e+8]==="T"}function Iv(r,e){return r[e+1]==="!"&&r[e+2]==="A"&&r[e+3]==="T"&&r[e+4]==="T"&&r[e+5]==="L"&&r[e+6]==="I"&&r[e+7]==="S"&&r[e+8]==="T"}function Vv(r,e){return r[e+1]==="!"&&r[e+2]==="N"&&r[e+3]==="O"&&r[e+4]==="T"&&r[e+5]==="A"&&r[e+6]==="T"&&r[e+7]==="I"&&r[e+8]==="O"&&r[e+9]==="N"}function Bv(r){if(Av.isName(r))return r;throw new Error("Invalid entity name ".concat(r))}var Pv=Nv;const Ov=/^[-+]?0x[a-fA-F0-9]+$/,Dv=/^([\-\+])?(0*)(\.[0-9]+([eE]\-?[0-9]+)?|[0-9]+(\.[0-9]+([eE]\-?[0-9]+)?)?)$/;!Number.parseInt&&window.parseInt&&(Number.parseInt=window.parseInt),!Number.parseFloat&&window.parseFloat&&(Number.parseFloat=window.parseFloat);const Tv={hex:!0,leadingZeros:!0,decimalPoint:".",eNotation:!0};function Rv(r,e={}){if(e=Object.assign({},Tv,e),!r||typeof r!="string")return r;let t=r.trim();if(e.skipLike!==void 0&&e.skipLike.test(t))return r;if(e.hex&&Ov.test(t))return Number.parseInt(t,16);{const s=Dv.exec(t);if(s){const a=s[1],n=s[2];let u=Lv(s[3]);const i=s[4]||s[6];if(!e.leadingZeros&&n.length>0&&a&&t[2]!=="."||!e.leadingZeros&&n.length>0&&!a&&t[1]!==".")return r;{const l=Number(t),o=""+l;return o.search(/[eE]/)!==-1||i?e.eNotation?l:r:t.indexOf(".")!==-1?o==="0"&&u===""||o===u||a&&o==="-"+u?l:r:n?u===o||a+u===o?l:r:t===o||t===a+o?l:r}}else return r}}function Lv(r){return r&&r.indexOf(".")!==-1&&(r=r.replace(/0+$/,""),r==="."?r="0":r[0]==="."?r="0"+r:r[r.length-1]==="."&&(r=r.substr(0,r.length-1))),r}var Uv=Rv;function jv(r){return typeof r=="function"?r:Array.isArray(r)?e=>{for(const t of r)if(typeof t=="string"&&e===t||t instanceof RegExp&&t.test(e))return!0}:()=>!1}var lg=jv;const cg=zh,Ro=Sv,$v=Pv,Kv=Uv,Hv=lg;let Mv=class{constructor(r){this.options=r,this.currentNode=null,this.tagsNodeStack=[],this.docTypeEntities={},this.lastEntities={apos:{regex:/&(apos|#39|#x27);/g,val:"'"},gt:{regex:/&(gt|#62|#x3E);/g,val:">"},lt:{regex:/&(lt|#60|#x3C);/g,val:"<"},quot:{regex:/&(quot|#34|#x22);/g,val:'"'}},this.ampEntity={regex:/&(amp|#38|#x26);/g,val:"&"},this.htmlEntities={space:{regex:/&(nbsp|#160);/g,val:" "},cent:{regex:/&(cent|#162);/g,val:"¢"},pound:{regex:/&(pound|#163);/g,val:"£"},yen:{regex:/&(yen|#165);/g,val:"¥"},euro:{regex:/&(euro|#8364);/g,val:"€"},copyright:{regex:/&(copy|#169);/g,val:"©"},reg:{regex:/&(reg|#174);/g,val:"®"},inr:{regex:/&(inr|#8377);/g,val:"₹"},num_dec:{regex:/&#([0-9]{1,7});/g,val:(e,t)=>String.fromCharCode(Number.parseInt(t,10))},num_hex:{regex:/&#x([0-9a-fA-F]{1,6});/g,val:(e,t)=>String.fromCharCode(Number.parseInt(t,16))}},this.addExternalEntities=Fv,this.parseXml=zv,this.parseTextData=Jv,this.resolveNameSpace=qv,this.buildAttributesMap=Gv,this.isItStopNode=Qv,this.replaceEntitiesValue=Xv,this.readStopNodeData=eb,this.saveTextToParentTag=Zv,this.addChild=_v,this.ignoreAttributesFn=Hv(this.options.ignoreAttributes)}};function Fv(r){const e=Object.keys(r);for(let t=0;t<e.length;t++){const s=e[t];this.lastEntities[s]={regex:new RegExp("&"+s+";","g"),val:r[s]}}}function Jv(r,e,t,s,a,n,u){if(r!==void 0&&(this.options.trimValues&&!s&&(r=r.trim()),r.length>0)){u||(r=this.replaceEntitiesValue(r));const i=this.options.tagValueProcessor(e,r,t,a,n);return i==null?r:typeof i!=typeof r||i!==r?i:this.options.trimValues?lf(r,this.options.parseTagValue,this.options.numberParseOptions):r.trim()===r?lf(r,this.options.parseTagValue,this.options.numberParseOptions):r}}function qv(r){if(this.options.removeNSPrefix){const e=r.split(":"),t=r.charAt(0)==="/"?"/":"";if(e[0]==="xmlns")return"";e.length===2&&(r=t+e[1])}return r}const Wv=new RegExp("([^\\s=]+)\\s*(=\\s*(['\"])([\\s\\S]*?)\\3)?","gm");function Gv(r,e,t){if(this.options.ignoreAttributes!==!0&&typeof r=="string"){const s=cg.getAllMatches(r,Wv),a=s.length,n={};for(let u=0;u<a;u++){const i=this.resolveNameSpace(s[u][1]);if(this.ignoreAttributesFn(i,e))continue;let l=s[u][4],o=this.options.attributeNamePrefix+i;if(i.length)if(this.options.transformAttributeName&&(o=this.options.transformAttributeName(o)),o==="__proto__"&&(o="#__proto__"),l!==void 0){this.options.trimValues&&(l=l.trim()),l=this.replaceEntitiesValue(l);const c=this.options.attributeValueProcessor(i,l,e);c==null?n[o]=l:typeof c!=typeof l||c!==l?n[o]=c:n[o]=lf(l,this.options.parseAttributeValue,this.options.numberParseOptions)}else this.options.allowBooleanAttributes&&(n[o]=!0)}if(!Object.keys(n).length)return;if(this.options.attributesGroupName){const u={};return u[this.options.attributesGroupName]=n,u}return n}}const zv=function(r){r=r.replace(/\r\n?/g,"\n");const e=new Ro("!xml");let t=e,s="",a="";for(let n=0;n<r.length;n++)if(r[n]==="<")if(r[n+1]==="/"){const u=wn(r,">",n,"Closing Tag is not closed.");let i=r.substring(n+2,u).trim();if(this.options.removeNSPrefix){const c=i.indexOf(":");c!==-1&&(i=i.substr(c+1))}this.options.transformTagName&&(i=this.options.transformTagName(i)),t&&(s=this.saveTextToParentTag(s,t,a));const l=a.substring(a.lastIndexOf(".")+1);if(i&&this.options.unpairedTags.indexOf(i)!==-1)throw new Error("Unpaired tag can not be used as closing tag: </".concat(i,">"));let o=0;l&&this.options.unpairedTags.indexOf(l)!==-1?(o=a.lastIndexOf(".",a.lastIndexOf(".")-1),this.tagsNodeStack.pop()):o=a.lastIndexOf("."),a=a.substring(0,o),t=this.tagsNodeStack.pop(),s="",n=u}else if(r[n+1]==="?"){let u=uf(r,n,!1,"?>");if(!u)throw new Error("Pi Tag is not closed.");if(s=this.saveTextToParentTag(s,t,a),!(this.options.ignoreDeclaration&&u.tagName==="?xml"||this.options.ignorePiTags)){const i=new Ro(u.tagName);i.add(this.options.textNodeName,""),u.tagName!==u.tagExp&&u.attrExpPresent&&(i[":@"]=this.buildAttributesMap(u.tagExp,a,u.tagName)),this.addChild(t,i,a)}n=u.closeIndex+1}else if(r.substr(n+1,3)==="!--"){const u=wn(r,"-->",n+4,"Comment is not closed.");if(this.options.commentPropName){const i=r.substring(n+4,u-2);s=this.saveTextToParentTag(s,t,a),t.add(this.options.commentPropName,[{[this.options.textNodeName]:i}])}n=u}else if(r.substr(n+1,2)==="!D"){const u=$v(r,n);this.docTypeEntities=u.entities,n=u.i}else if(r.substr(n+1,2)==="!["){const u=wn(r,"]]>",n,"CDATA is not closed.")-2,i=r.substring(n+9,u);s=this.saveTextToParentTag(s,t,a);let l=this.parseTextData(i,t.tagname,a,!0,!1,!0,!0);l==null&&(l=""),this.options.cdataPropName?t.add(this.options.cdataPropName,[{[this.options.textNodeName]:i}]):t.add(this.options.textNodeName,l),n=u+2}else{let u=uf(r,n,this.options.removeNSPrefix),i=u.tagName;const l=u.rawTagName;let o=u.tagExp,c=u.attrExpPresent,m=u.closeIndex;this.options.transformTagName&&(i=this.options.transformTagName(i)),t&&s&&t.tagname!=="!xml"&&(s=this.saveTextToParentTag(s,t,a,!1));const h=t;if(h&&this.options.unpairedTags.indexOf(h.tagname)!==-1&&(t=this.tagsNodeStack.pop(),a=a.substring(0,a.lastIndexOf("."))),i!==e.tagname&&(a+=a?"."+i:i),this.isItStopNode(this.options.stopNodes,a,i)){let p="";if(o.length>0&&o.lastIndexOf("/")===o.length-1)i[i.length-1]==="/"?(i=i.substr(0,i.length-1),a=a.substr(0,a.length-1),o=i):o=o.substr(0,o.length-1),n=u.closeIndex;else if(this.options.unpairedTags.indexOf(i)!==-1)n=u.closeIndex;else{const w=this.readStopNodeData(r,l,m+1);if(!w)throw new Error("Unexpected end of ".concat(l));n=w.i,p=w.tagContent}const d=new Ro(i);i!==o&&c&&(d[":@"]=this.buildAttributesMap(o,a,i)),p&&(p=this.parseTextData(p,i,a,!0,c,!0,!0)),a=a.substr(0,a.lastIndexOf(".")),d.add(this.options.textNodeName,p),this.addChild(t,d,a)}else{if(o.length>0&&o.lastIndexOf("/")===o.length-1){i[i.length-1]==="/"?(i=i.substr(0,i.length-1),a=a.substr(0,a.length-1),o=i):o=o.substr(0,o.length-1),this.options.transformTagName&&(i=this.options.transformTagName(i));const p=new Ro(i);i!==o&&c&&(p[":@"]=this.buildAttributesMap(o,a,i)),this.addChild(t,p,a),a=a.substr(0,a.lastIndexOf("."))}else{const p=new Ro(i);this.tagsNodeStack.push(t),i!==o&&c&&(p[":@"]=this.buildAttributesMap(o,a,i)),this.addChild(t,p,a),t=p}s="",n=m}}else s+=r[n];return e.child};function _v(r,e,t){const s=this.options.updateTag(e.tagname,t,e[":@"]);s===!1||(typeof s=="string"&&(e.tagname=s),r.addChild(e))}const Xv=function(r){if(this.options.processEntities){for(let e in this.docTypeEntities){const t=this.docTypeEntities[e];r=r.replace(t.regx,t.val)}for(let e in this.lastEntities){const t=this.lastEntities[e];r=r.replace(t.regex,t.val)}if(this.options.htmlEntities)for(let e in this.htmlEntities){const t=this.htmlEntities[e];r=r.replace(t.regex,t.val)}r=r.replace(this.ampEntity.regex,this.ampEntity.val)}return r};function Zv(r,e,t,s){return r&&(s===void 0&&(s=Object.keys(e.child).length===0),r=this.parseTextData(r,e.tagname,t,!1,e[":@"]?Object.keys(e[":@"]).length!==0:!1,s),r!==void 0&&r!==""&&e.add(this.options.textNodeName,r),r=""),r}function Qv(r,e,t){const s="*."+t;for(const a in r){const n=r[a];if(s===n||e===n)return!0}return!1}function Yv(r,e,t=">"){let s,a="";for(let n=e;n<r.length;n++){let u=r[n];if(s)u===s&&(s="");else if(u==='"'||u==="'")s=u;else if(u===t[0])if(t[1]){if(r[n+1]===t[1])return{data:a,index:n}}else return{data:a,index:n};else u===" "&&(u=" ");a+=u}}function wn(r,e,t,s){const a=r.indexOf(e,t);if(a===-1)throw new Error(s);return a+e.length-1}function uf(r,e,t,s=">"){const a=Yv(r,e+1,s);if(!a)return;let n=a.data;const u=a.index,i=n.search(/\s/);let l=n,o=!0;i!==-1&&(l=n.substring(0,i),n=n.substring(i+1).trimStart());const c=l;if(t){const m=l.indexOf(":");m!==-1&&(l=l.substr(m+1),o=l!==a.data.substr(m+1))}return{tagName:l,tagExp:n,closeIndex:u,attrExpPresent:o,rawTagName:c}}function eb(r,e,t){const s=t;let a=1;for(;t<r.length;t++)if(r[t]==="<")if(r[t+1]==="/"){const n=wn(r,">",t,"".concat(e," is not closed"));if(r.substring(t+2,n).trim()===e&&(a--,a===0))return{tagContent:r.substring(s,t),i:n};t=n}else if(r[t+1]==="?")t=wn(r,"?>",t+1,"StopNode is not closed.");else if(r.substr(t+1,3)==="!--")t=wn(r,"-->",t+3,"StopNode is not closed.");else if(r.substr(t+1,2)==="![")t=wn(r,"]]>",t,"StopNode is not closed.")-2;else{const n=uf(r,t,">");n&&((n&&n.tagName)===e&&n.tagExp[n.tagExp.length-1]!=="/"&&a++,t=n.closeIndex)}}function lf(r,e,t){if(e&&typeof r=="string"){const s=r.trim();return s==="true"?!0:s==="false"?!1:Kv(r,t)}else return cg.isExist(r)?r:""}var tb=Mv,hg={};function sb(r,e){return mg(r,e)}function mg(r,e,t){let s;const a={};for(let n=0;n<r.length;n++){const u=r[n],i=rb(u);let l="";if(t===void 0?l=i:l=t+"."+i,i===e.textNodeName)s===void 0?s=u[i]:s+=""+u[i];else{if(i===void 0)continue;if(u[i]){let o=mg(u[i],e,l);const c=nb(o,e);u[":@"]?ab(o,u[":@"],l,e):Object.keys(o).length===1&&o[e.textNodeName]!==void 0&&!e.alwaysCreateTextNode?o=o[e.textNodeName]:Object.keys(o).length===0&&(e.alwaysCreateTextNode?o[e.textNodeName]="":o=""),a[i]!==void 0&&a.hasOwnProperty(i)?(Array.isArray(a[i])||(a[i]=[a[i]]),a[i].push(o)):e.isArray(i,l,c)?a[i]=[o]:a[i]=o}}}return typeof s=="string"?s.length>0&&(a[e.textNodeName]=s):s!==void 0&&(a[e.textNodeName]=s),a}function rb(r){const e=Object.keys(r);for(let t=0;t<e.length;t++){const s=e[t];if(s!==":@")return s}}function ab(r,e,t,s){if(e){const a=Object.keys(e),n=a.length;for(let u=0;u<n;u++){const i=a[u];s.isArray(i,t+"."+i,!0,!0)?r[i]=[e[i]]:r[i]=e[i]}}}function nb(r,e){const{textNodeName:t}=e,s=Object.keys(r).length;return!!(s===0||s===1&&(r[t]||typeof r[t]=="boolean"||r[t]===0))}hg.prettify=sb;const{buildOptions:ib}=of,ob=tb,{prettify:ub}=hg,lb=zf;let cb=class{constructor(r){this.externalEntities={},this.options=ib(r)}parse(r,e){if(typeof r!="string")if(r.toString)r=r.toString();else throw new Error("XML data is accepted in String or Bytes[] form.");if(e){e===!0&&(e={});const a=lb.validate(r,e);if(a!==!0)throw Error("".concat(a.err.msg,":").concat(a.err.line,":").concat(a.err.col))}const t=new ob(this.options);t.addExternalEntities(this.externalEntities);const s=t.parseXml(r);return this.options.preserveOrder||s===void 0?s:ub(s,this.options)}addEntity(r,e){if(e.indexOf("&")!==-1)throw new Error("Entity value can't have '&'");if(r.indexOf("&")!==-1||r.indexOf(";")!==-1)throw new Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '
'");if(e==="&")throw new Error("An entity with value '&' is not permitted");this.externalEntities[r]=e}};var hb=cb;const mb="\n";function fb(r,e){let t="";return e.format&&e.indentBy.length>0&&(t=mb),fg(r,e,"",t)}function fg(r,e,t,s){let a="",n=!1;for(let u=0;u<r.length;u++){const i=r[u],l=db(i);if(l===void 0)continue;let o="";if(t.length===0?o=l:o="".concat(t,".").concat(l),l===e.textNodeName){let d=i[l];pb(o,e)||(d=e.tagValueProcessor(l,d),d=dg(d,e)),n&&(a+=s),a+=d,n=!1;continue}else if(l===e.cdataPropName){n&&(a+=s),a+="<![CDATA[".concat(i[l][0][e.textNodeName],"]]>"),n=!1;continue}else if(l===e.commentPropName){a+=s+"<!--".concat(i[l][0][e.textNodeName],"-->"),n=!0;continue}else if(l[0]==="?"){const d=zd(i[":@"],e),w=l==="?xml"?"":s;let y=i[l][0][e.textNodeName];y=y.length!==0?" "+y:"",a+=w+"<".concat(l).concat(y).concat(d,"?>"),n=!0;continue}let c=s;c!==""&&(c+=e.indentBy);const m=zd(i[":@"],e),h=s+"<".concat(l).concat(m),p=fg(i[l],e,o,c);e.unpairedTags.indexOf(l)!==-1?e.suppressUnpairedNode?a+=h+">":a+=h+"/>":(!p||p.length===0)&&e.suppressEmptyNode?a+=h+"/>":p&&p.endsWith(">")?a+=h+">".concat(p).concat(s,"</").concat(l,">"):(a+=h+">",p&&s!==""&&(p.includes("/>")||p.includes("</"))?a+=s+e.indentBy+p+s:a+=p,a+="</".concat(l,">")),n=!0}return a}function db(r){const e=Object.keys(r);for(let t=0;t<e.length;t++){const s=e[t];if(r.hasOwnProperty(s)&&s!==":@")return s}}function zd(r,e){let t="";if(r&&!e.ignoreAttributes)for(let s in r){if(!r.hasOwnProperty(s))continue;let a=e.attributeValueProcessor(s,r[s]);a=dg(a,e),a===!0&&e.suppressBooleanAttributes?t+=" ".concat(s.substr(e.attributeNamePrefix.length)):t+=" ".concat(s.substr(e.attributeNamePrefix.length),'="').concat(a,'"')}return t}function pb(r,e){r=r.substr(0,r.length-e.textNodeName.length-1);let t=r.substr(r.lastIndexOf(".")+1);for(let s in e.stopNodes)if(e.stopNodes[s]===r||e.stopNodes[s]==="*."+t)return!0;return!1}function dg(r,e){if(r&&r.length>0&&e.processEntities)for(let t=0;t<e.entities.length;t++){const s=e.entities[t];r=r.replace(s.regex,s.val)}return r}var gb=fb;const wb=gb,yb=lg,vb={attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,cdataPropName:!1,format:!1,indentBy:" ",suppressEmptyNode:!1,suppressUnpairedNode:!0,suppressBooleanAttributes:!0,tagValueProcessor:function(r,e){return e},attributeValueProcessor:function(r,e){return e},preserveOrder:!1,commentPropName:!1,unpairedTags:[],entities:[{regex:new RegExp("&","g"),val:"&"},{regex:new RegExp(">","g"),val:">"},{regex:new RegExp("<","g"),val:"<"},{regex:new RegExp("'","g"),val:"'"},{regex:new RegExp('"',"g"),val:"""}],processEntities:!0,stopNodes:[],oneListGroup:!1};function zr(r){this.options=Object.assign({},vb,r),this.options.ignoreAttributes===!0||this.options.attributesGroupName?this.isAttribute=function(){return!1}:(this.ignoreAttributesFn=yb(this.options.ignoreAttributes),this.attrPrefixLen=this.options.attributeNamePrefix.length,this.isAttribute=Ab),this.processTextOrObjNode=bb,this.options.format?(this.indentate=Sb,this.tagEndChar=">\n",this.newLine="\n"):(this.indentate=function(){return""},this.tagEndChar=">",this.newLine="")}zr.prototype.build=function(r){return this.options.preserveOrder?wb(r,this.options):(Array.isArray(r)&&this.options.arrayNodeName&&this.options.arrayNodeName.length>1&&(r={[this.options.arrayNodeName]:r}),this.j2x(r,0,[]).val)},zr.prototype.j2x=function(r,e,t){let s="",a="";const n=t.join(".");for(let u in r)if(Object.prototype.hasOwnProperty.call(r,u))if(typeof r[u]>"u")this.isAttribute(u)&&(a+="");else if(r[u]===null)this.isAttribute(u)?a+="":u[0]==="?"?a+=this.indentate(e)+"<"+u+"?"+this.tagEndChar:a+=this.indentate(e)+"<"+u+"/"+this.tagEndChar;else if(r[u]instanceof Date)a+=this.buildTextValNode(r[u],u,"",e);else if(typeof r[u]!="object"){const i=this.isAttribute(u);if(i&&!this.ignoreAttributesFn(i,n))s+=this.buildAttrPairStr(i,""+r[u]);else if(!i)if(u===this.options.textNodeName){let l=this.options.tagValueProcessor(u,""+r[u]);a+=this.replaceEntitiesValue(l)}else a+=this.buildTextValNode(r[u],u,"",e)}else if(Array.isArray(r[u])){const i=r[u].length;let l="",o="";for(let c=0;c<i;c++){const m=r[u][c];if(!(typeof m>"u"))if(m===null)u[0]==="?"?a+=this.indentate(e)+"<"+u+"?"+this.tagEndChar:a+=this.indentate(e)+"<"+u+"/"+this.tagEndChar;else if(typeof m=="object")if(this.options.oneListGroup){const h=this.j2x(m,e+1,t.concat(u));l+=h.val,this.options.attributesGroupName&&m.hasOwnProperty(this.options.attributesGroupName)&&(o+=h.attrStr)}else l+=this.processTextOrObjNode(m,u,e,t);else if(this.options.oneListGroup){let h=this.options.tagValueProcessor(u,m);h=this.replaceEntitiesValue(h),l+=h}else l+=this.buildTextValNode(m,u,"",e)}this.options.oneListGroup&&(l=this.buildObjectNode(l,u,o,e)),a+=l}else if(this.options.attributesGroupName&&u===this.options.attributesGroupName){const i=Object.keys(r[u]),l=i.length;for(let o=0;o<l;o++)s+=this.buildAttrPairStr(i[o],""+r[u][i[o]])}else a+=this.processTextOrObjNode(r[u],u,e,t);return{attrStr:s,val:a}},zr.prototype.buildAttrPairStr=function(r,e){return e=this.options.attributeValueProcessor(r,""+e),e=this.replaceEntitiesValue(e),this.options.suppressBooleanAttributes&&e==="true"?" "+r:" "+r+'="'+e+'"'};function bb(r,e,t,s){const a=this.j2x(r,t+1,s.concat(e));return r[this.options.textNodeName]!==void 0&&Object.keys(r).length===1?this.buildTextValNode(r[this.options.textNodeName],e,a.attrStr,t):this.buildObjectNode(a.val,e,a.attrStr,t)}zr.prototype.buildObjectNode=function(r,e,t,s){if(r==="")return e[0]==="?"?this.indentate(s)+"<"+e+t+"?"+this.tagEndChar:this.indentate(s)+"<"+e+t+this.closeTag(e)+this.tagEndChar;{let a="</"+e+this.tagEndChar,n="";return e[0]==="?"&&(n="?",a=""),(t||t==="")&&r.indexOf("<")===-1?this.indentate(s)+"<"+e+t+n+">"+r+a:this.options.commentPropName!==!1&&e===this.options.commentPropName&&n.length===0?this.indentate(s)+"<!--".concat(r,"-->")+this.newLine:this.indentate(s)+"<"+e+t+n+this.tagEndChar+r+this.indentate(s)+a}},zr.prototype.closeTag=function(r){let e="";return this.options.unpairedTags.indexOf(r)!==-1?this.options.suppressUnpairedNode||(e="/"):this.options.suppressEmptyNode?e="/":e="></".concat(r),e},zr.prototype.buildTextValNode=function(r,e,t,s){if(this.options.cdataPropName!==!1&&e===this.options.cdataPropName)return this.indentate(s)+"<![CDATA[".concat(r,"]]>")+this.newLine;if(this.options.commentPropName!==!1&&e===this.options.commentPropName)return this.indentate(s)+"<!--".concat(r,"-->")+this.newLine;if(e[0]==="?")return this.indentate(s)+"<"+e+t+"?"+this.tagEndChar;{let a=this.options.tagValueProcessor(e,r);return a=this.replaceEntitiesValue(a),a===""?this.indentate(s)+"<"+e+t+this.closeTag(e)+this.tagEndChar:this.indentate(s)+"<"+e+t+">"+a+"</"+e+this.tagEndChar}},zr.prototype.replaceEntitiesValue=function(r){if(r&&r.length>0&&this.options.processEntities)for(let e=0;e<this.options.entities.length;e++){const t=this.options.entities[e];r=r.replace(t.regex,t.val)}return r};function Sb(r){return this.options.indentBy.repeat(r)}function Ab(r){return r.startsWith(this.options.attributeNamePrefix)&&r!==this.options.textNodeName?r.substr(this.attrPrefixLen):!1}var Nb=zr;const kb=zf,Cb=hb,Eb=Nb;var xb={XMLParser:Cb,XMLValidator:kb,XMLBuilder:Eb};function qc(r){return r.users!==void 0}const Ib=r=>r===null?Gm().setApp("end_to_end_encryption").build():Gm().setApp("end_to_end_encryption").setUid(r.uid).build(),_e=Ib(Uf());class Ae{constructor(e={}){if("view"in e)this.fromUint8Array(e.view);else if("buffer"in e)this.fromArrayBuffer(e.buffer);else if("string"in e)this.fromString(e.string);else if("hexstring"in e)this.fromHexString(e.hexstring);else if("length"in e&&e.length>0){if(this.length=e.length,e.stub)for(let t=0;t<this._view.length;t++)this._view[t]=e.stub}else this.length=0}set buffer(e){this._buffer=e,this._view=new Uint8Array(this._buffer)}get buffer(){return this._buffer}set view(e){this._buffer=new ArrayBuffer(e.length),this._view=new Uint8Array(this._buffer),this._view.set(e)}get view(){return this._view}get length(){return this.view.byteLength}set length(e){this._buffer=new ArrayBuffer(e),this._view=new Uint8Array(this._buffer)}clear(){this._buffer=new ArrayBuffer(0),this._view=new Uint8Array(this._buffer)}fromArrayBuffer(e){this._buffer=e,this._view=new Uint8Array(this._buffer)}fromUint8Array(e){this.fromArrayBuffer(new Uint8Array(e).buffer)}fromString(e){const t=e.length;this.length=t;for(let s=0;s<t;s++)this.view[s]=e.charCodeAt(s)}toString(e=0,t=this.view.length-e){let s="";(e>=this.view.length||e<0)&&(e=0),(t>=this.view.length||t<0)&&(t=this.view.length-e);for(let a=e;a<e+t;a++)s+=String.fromCharCode(this.view[a]);return s}fromHexString(e){const t=e.length;this.buffer=new ArrayBuffer(t>>1),this.view=new Uint8Array(this.buffer);const s=new Map;s.set("0",0),s.set("1",1),s.set("2",2),s.set("3",3),s.set("4",4),s.set("5",5),s.set("6",6),s.set("7",7),s.set("8",8),s.set("9",9),s.set("A",10),s.set("a",10),s.set("B",11),s.set("b",11),s.set("C",12),s.set("c",12),s.set("D",13),s.set("d",13),s.set("E",14),s.set("e",14),s.set("F",15),s.set("f",15);let a=0,n=0;for(let u=0;u<t;u++)u%2?(n|=s.get(e.charAt(u)),this.view[a]=n,a++):n=s.get(e.charAt(u))<<4}toHexString(e=0,t=this.view.length-e){let s="";(e>=this.view.length||e<0)&&(e=0),(t>=this.view.length||t<0)&&(t=this.view.length-e);for(let a=e;a<e+t;a++){const n=this.view[a].toString(16).toUpperCase();s=s+(n.length==1?"0":"")+n}return s}copy(e=0,t=this.length-e){if(!e&&!this.length)return new Ae;if(e<0||e>this.length-1)throw new Error("Wrong start position: ".concat(e));return new Ae({buffer:this._buffer.slice(e,e+t)})}slice(e=0,t=this.length){if(!e&&!this.length)return new Ae;if(e<0||e>this.length-1)throw new Error("Wrong start position: ".concat(e));return new Ae({buffer:this._buffer.slice(e,t)})}realloc(e){const t=new ArrayBuffer(e),s=new Uint8Array(t);e>this._view.length?s.set(this._view):s.set(new Uint8Array(this._buffer,0,e)),this._buffer=t,this._view=new Uint8Array(this._buffer)}append(e){const t=this.length,s=e.length,a=e._view.subarray();this.realloc(t+s),this._view.set(a,t)}insert(e,t=0,s=this.length-t){return t>this.length-1?!1:(s>this.length-t&&(s=this.length-t),s>e.length&&(s=e.length),s==e.length?this._view.set(e._view,t):this._view.set(e._view.subarray(0,s),t),!0)}isEqual(e){if(this.length!=e.length)return!1;for(let t=0;t<e.length;t++)if(this.view[t]!=e.view[t])return!1;return!0}isEqualView(e){if(e.length!=this.view.length)return!1;for(let t=0;t<e.length;t++)if(this.view[t]!=e[t])return!1;return!0}findPattern(e,t,s,a){const{start:n,length:u,backward:i}=this.prepareFindParameters(t,s,a),l=e.length;if(l>u)return-1;const o=[];for(let c=0;c<l;c++)o.push(e.view[c]);for(let c=0;c<=u-l;c++){let m=!0;const h=i?n-l-c:n+c;for(let p=0;p<l;p++)if(this.view[p+h]!=o[p]){m=!1;break}if(m)return i?n-l-c:n+l+c}return-1}findFirstIn(e,t,s,a){const{start:n,length:u,backward:i}=this.prepareFindParameters(t,s,a),l={id:-1,position:i?0:n+u,length:0};for(let o=0;o<e.length;o++){const c=this.findPattern(e[o],n,u,i);if(c!=-1){let m=!1;const h=e[o].length;i?c-h>=l.position-l.length&&(m=!0):c-h<=l.position-l.length&&(m=!0),m&&(l.position=c,l.id=o,l.length=h)}}return l}findAllIn(e,t,s){let{start:a,length:n}=this.prepareFindParameters(t,s);const u=[];let i={id:-1,position:a};do{const l=i.position;if(i=this.findFirstIn(e,i.position,n),i.id==-1)break;n-=i.position-l,u.push({id:i.id,position:i.position})}while(!0);return u}findAllPatternIn(e,t,s){const{start:a,length:n}=this.prepareFindParameters(t,s),u=[],i=e.length;if(i>n)return-1;const l=Array.from(e.view);for(let o=0;o<=n-i;o++){let c=!0;const m=a+o;for(let h=0;h<i;h++)if(this.view[h+m]!=l[h]){c=!1;break}c&&(u.push(a+i+o),o+=i-1)}return u}findFirstNotIn(e,t,s,a){let{start:n,length:u,backward:i}=this.prepareFindParameters(t,s,a);const l={left:{id:-1,position:n},right:{id:-1,position:0},value:new Ae};let o=u;for(;o>0;){if(l.right=this.findFirstIn(e,i?n-u+o:n+u-o,o,i),l.right.id==-1){u=o,i?n-=u:n=l.left.position,l.value=new Ae({buffer:this._buffer.slice(n,n+u)});break}if(l.right.position!=(i?l.left.position-e[l.right.id].length:l.left.position+e[l.right.id].length)){i?(n=l.right.position+e[l.right.id].length,u=l.left.position-l.right.position-e[l.right.id].length):(n=l.left.position,u=l.right.position-l.left.position-e[l.right.id].length),l.value=new Ae({buffer:this._buffer.slice(n,n+u)});break}l.left=l.right,o-=e[l.right.id].length}if(i){const c=l.right;l.right=l.left,l.left=c}return l}findAllNotIn(e,t,s){let{start:a,length:n}=this.prepareFindParameters(t,s);const u=[];let i={left:{id:-1,position:a},right:{id:-1,position:a},value:new Ae};do{const l=i.right.position;i=this.findFirstNotIn(e,i.right.position,n),n-=i.right.position-l,u.push({left:{id:i.left.id,position:i.left.position},right:{id:i.right.id,position:i.right.position},value:i.value})}while(i.right.id!=-1);return u}findFirstSequence(e,t,s,a){let{start:n,length:u,backward:i}=this.prepareFindParameters(t,s,a);const l=this.skipNotPatterns(e,n,u,i);if(l==-1)return{position:-1,value:new Ae};const o=this.skipPatterns(e,l,u-(i?n-l:l-n),i);i?(n=o,u=l-o):(n=l,u=o-l);const c=new Ae({buffer:this._buffer.slice(n,n+u)});return{position:o,value:c}}findAllSequences(e,t,s){let{start:a,length:n}=this.prepareFindParameters(t,s);const u=[];let i={position:a,value:new Ae};do{const l=i.position;i=this.findFirstSequence(e,i.position,n),i.position!=-1&&(n-=i.position-l,u.push({position:i.position,value:i.value}))}while(i.position!=-1);return u}findPairedPatterns(e,t,s,a){const n=[];if(e.isEqual(t))return n;const{start:u,length:i}=this.prepareFindParameters(s,a);let l=0;const o=this.findAllPatternIn(e,u,i);if(!Array.isArray(o)||o.length==0)return n;const c=this.findAllPatternIn(t,u,i);if(!Array.isArray(c)||c.length==0)return n;for(;l<o.length&&c.length!=0;){if(o[0]==c[0]){n.push({left:o[0],right:c[0]}),o.splice(0,1),c.splice(0,1);continue}if(o[l]>c[0])break;for(;o[l]<c[0]&&(l++,!(l>=o.length)););n.push({left:o[l-1],right:c[0]}),o.splice(l-1,1),c.splice(0,1),l=0}return n.sort((m,h)=>m.left-h.left),n}findPairedArrays(e,t,s,a){const{start:n,length:u}=this.prepareFindParameters(s,a),i=[];let l=0;const o=this.findAllIn(e,n,u);if(o.length==0)return i;const c=this.findAllIn(t,n,u);if(c.length==0)return i;for(;l<o.length&&c.length!=0;){if(o[0].position==c[0].position){i.push({left:o[0],right:c[0]}),o.splice(0,1),c.splice(0,1);continue}if(o[l].position>c[0].position)break;for(;o[l].position<c[0].position&&(l++,!(l>=o.length)););i.push({left:o[l-1],right:c[0]}),o.splice(l-1,1),c.splice(0,1),l=0}return i.sort((m,h)=>m.left.position-h.left.position),i}replacePattern(e,t,s,a,n=null){let u=[],i;const l={status:-1,searchPatternPositions:[],replacePatternPositions:[]},{start:o,length:c}=this.prepareFindParameters(s,a);if(n==null){if(u=this.findAllIn([e],o,c),u.length==0)return l}else u=n;l.searchPatternPositions.push(...Array.from(u,d=>d.position));const m=e.length-t.length,h=new ArrayBuffer(this.view.length-u.length*m),p=new Uint8Array(h);for(p.set(new Uint8Array(this.buffer,0,o)),i=0;i<u.length;i++){const d=i==0?o:u[i-1].position;p.set(new Uint8Array(this.buffer,d,u[i].position-e.length-d),d-i*m),p.set(t.view,u[i].position-e.length-i*m),l.replacePatternPositions.push(u[i].position-e.length-i*m)}return i--,p.set(new Uint8Array(this.buffer,u[i].position,this.length-u[i].position),u[i].position-e.length+t.length-i*m),this.buffer=h,this.view=new Uint8Array(this.buffer),l.status=1,l}skipPatterns(e,t,s,a){const{start:n,length:u,backward:i}=this.prepareFindParameters(t,s,a);let l=n;for(let o=0;o<e.length;o++){const c=e[o].length,m=i?l-c:l;let h=!0;for(let p=0;p<c;p++)if(this.view[p+m]!=e[o].view[p]){h=!1;break}if(h){if(o=-1,i){if(l-=c,l<=0)return l}else if(l+=c,l>=n+u)return l}}return l}skipNotPatterns(e,t,s,a){const{start:n,length:u,backward:i}=this.prepareFindParameters(t,s,a);let l=-1;for(let o=0;o<u;o++){for(let c=0;c<e.length;c++){const m=e[c].length,h=i?n-o-m:n+o;let p=!0;for(let d=0;d<m;d++)if(this.view[d+h]!=e[c].view[d]){p=!1;break}if(p){l=i?n-o:n+o;break}}if(l!=-1)break}return l}prepareFindParameters(e=null,t=null,s=!1){return e===null&&(e=s?this.length:0),e>this.length&&(e=this.length),s?(t===null&&(t=e),t>e&&(t=e)):(t===null&&(t=this.length-e),t>this.length-e&&(t=this.length-e)),{start:e,length:t,backward:s}}}const Vb=16777216;class ta{constructor(e={}){this._stream=new Ae,this._length=0,this._start=0,this.backward=!1,this.appendBlock=0,this.prevLength=0,this.prevStart=0,"view"in e?this.stream=new Ae({view:e.view}):"buffer"in e?this.stream=new Ae({buffer:e.buffer}):"string"in e?this.stream=new Ae({string:e.string}):"hexstring"in e?this.stream=new Ae({hexstring:e.hexstring}):"stream"in e?this.stream=e.stream.slice():this.stream=new Ae,"backward"in e&&e.backward&&(this.backward=e.backward,this._start=this.stream.length),"length"in e&&e.length>0&&(this._length=e.length),"start"in e&&e.start&&e.start>0&&(this._start=e.start),"appendBlock"in e&&e.appendBlock&&e.appendBlock>0&&(this.appendBlock=e.appendBlock)}set stream(e){this._stream=e,this.prevLength=this._length,this._length=e.length,this.prevStart=this._start,this._start=0}get stream(){return this._stream}set length(e){this.prevLength=this._length,this._length=e}get length(){return this.appendBlock?this.start:this._length}set start(e){e>this.stream.length||(this.prevStart=this._start,this.prevLength=this._length,this._length-=this.backward?this._start-e:e-this._start,this._start=e)}get start(){return this._start}get buffer(){return this._stream.buffer.slice(0,this._length)}resetPosition(){this._start=this.prevStart,this._length=this.prevLength}findPattern(e,t=null){(t==null||t>this.length)&&(t=this.length);const s=this.stream.findPattern(e,this.start,this.length,this.backward);if(s==-1)return s;if(this.backward){if(s<this.start-e.length-t)return-1}else if(s>this.start+e.length+t)return-1;return this.start=s,s}findFirstIn(e,t=null){(t==null||t>this.length)&&(t=this.length);const s=this.stream.findFirstIn(e,this.start,this.length,this.backward);if(s.id==-1)return s;if(this.backward){if(s.position<this.start-e[s.id].length-t)return{id:-1,position:this.backward?0:this.start+this.length}}else if(s.position>this.start+e[s.id].length+t)return{id:-1,position:this.backward?0:this.start+this.length};return this.start=s.position,s}findAllIn(e){const t=this.backward?this.start-this.length:this.start;return this.stream.findAllIn(e,t,this.length)}findFirstNotIn(e,t=null){(t==null||t>this._length)&&(t=this._length);const s=this._stream.findFirstNotIn(e,this._start,this._length,this.backward);if(s.left.id==-1&&s.right.id==-1)return s;if(this.backward){if(s.right.id!=-1&&s.right.position<this._start-e[s.right.id].length-t)return{left:{id:-1,position:this._start},right:{id:-1,position:0},value:new Ae}}else if(s.left.id!=-1&&s.left.position>this._start+e[s.left.id].length+t)return{left:{id:-1,position:this._start},right:{id:-1,position:0},value:new Ae};return this.backward?s.left.id==-1?this.start=0:this.start=s.left.position:s.right.id==-1?this.start=this._start+this._length:this.start=s.right.position,s}findAllNotIn(e){const t=this.backward?this._start-this._length:this._start;return this._stream.findAllNotIn(e,t,this._length)}findFirstSequence(e,t=null,s=null){(t==null||t>this._length)&&(t=this._length),(s==null||s>t)&&(s=t);const a=this._stream.findFirstSequence(e,this._start,t,this.backward);if(a.value.length==0)return a;if(this.backward){if(a.position<this._start-a.value.length-s)return{position:-1,value:new Ae}}else if(a.position>this._start+a.value.length+s)return{position:-1,value:new Ae};return this.start=a.position,a}findAllSequences(e){const t=this.backward?this.start-this.length:this.start;return this.stream.findAllSequences(e,t,this.length)}findPairedPatterns(e,t,s=null){(s==null||s>this.length)&&(s=this.length);const a=this.backward?this.start-this.length:this.start,n=this.stream.findPairedPatterns(e,t,a,this.length);if(n.length){if(this.backward){if(n[0].right<this.start-t.length-s)return[]}else if(n[0].left>this.start+e.length+s)return[]}return n}findPairedArrays(e,t,s=null){(s==null||s>this.length)&&(s=this.length);const a=this.backward?this.start-this.length:this.start,n=this.stream.findPairedArrays(e,t,a,this.length);if(n.length){if(this.backward){if(n[0].right.position<this.start-t[n[0].right.id].length-s)return[]}else if(n[0].left.position>this.start+e[n[0].left.id].length+s)return[]}return n}replacePattern(e,t){const s=this.backward?this.start-this.length:this.start;return this.stream.replacePattern(e,t,s,this.length)}skipPatterns(e){const t=this.stream.skipPatterns(e,this.start,this.length,this.backward);return this.start=t,t}skipNotPatterns(e){const t=this.stream.skipNotPatterns(e,this.start,this.length,this.backward);return t==-1?-1:(this.start=t,t)}append(e){this.beforeAppend(e.length),this._stream.view.set(e.view,this._start),this._length+=e.length*2,this.start=this._start+e.length,this.prevLength-=e.length*2}appendView(e){this.beforeAppend(e.length),this._stream.view.set(e,this._start),this._length+=e.length*2,this.start=this._start+e.length,this.prevLength-=e.length*2}appendChar(e){this.beforeAppend(1),this._stream.view[this._start]=e,this._length+=2,this.start=this._start+1,this.prevLength-=2}appendUint16(e){this.beforeAppend(2);const t=new Uint16Array([e]),s=new Uint8Array(t.buffer);this.stream.view[this._start]=s[1],this._stream.view[this._start+1]=s[0],this._length+=4,this.start=this._start+2,this.prevLength-=4}appendUint24(e){this.beforeAppend(3);const t=new Uint32Array([e]),s=new Uint8Array(t.buffer);this._stream.view[this._start]=s[2],this._stream.view[this._start+1]=s[1],this._stream.view[this._start+2]=s[0],this._length+=6,this.start=this._start+3,this.prevLength-=6}appendUint32(e){this.beforeAppend(4);const t=new Uint32Array([e]),s=new Uint8Array(t.buffer);this._stream.view[this._start]=s[3],this._stream.view[this._start+1]=s[2],this._stream.view[this._start+2]=s[1],this._stream.view[this._start+3]=s[0],this._length+=8,this.start=this._start+4,this.prevLength-=8}appendInt16(e){this.beforeAppend(2);const t=new Int16Array([e]),s=new Uint8Array(t.buffer);this._stream.view[this._start]=s[1],this._stream.view[this._start+1]=s[0],this._length+=4,this.start=this._start+2,this.prevLength-=4}appendInt32(e){this.beforeAppend(4);const t=new Int32Array([e]),s=new Uint8Array(t.buffer);this._stream.view[this._start]=s[3],this._stream.view[this._start+1]=s[2],this._stream.view[this._start+2]=s[1],this._stream.view[this._start+3]=s[0],this._length+=8,this.start=this._start+4,this.prevLength-=8}getBlock(e,t=!0){if(this._length<=0)return new Uint8Array(0);this._length<e&&(e=this._length);let s;if(this.backward){const a=this._stream.view.subarray(this._length-e,this._length);s=new Uint8Array(e);for(let n=0;n<e;n++)s[e-1-n]=a[n]}else s=this._stream.view.subarray(this._start,this._start+e);return t&&(this.start+=this.backward?-1*e:e),s}getUint16(e=!0){const t=this.getBlock(2,e);return t.length<2?0:t[0]<<8|t[1]}getInt16(e=!0){const t=this.getUint16(e),s=32768;return t&s?-(s-(t^s)):t}getUint24(e=!0){const t=this.getBlock(4,e);return t.length<3?0:t[0]<<16|t[1]<<8|t[2]}getUint32(e=!0){const t=this.getBlock(4,e);return t.length<4?0:t[0]*Vb+(t[1]<<16)+(t[2]<<8)+t[3]}getInt32(e=!0){const t=this.getUint32(e),s=2147483648;return t&s?-(s-(t^s)):t}beforeAppend(e){this._start+e>this._stream.length&&(e>this.appendBlock&&(this.appendBlock=e+ta.APPEND_BLOCK),this._stream.realloc(this._stream.length+this.appendBlock))}}ta.APPEND_BLOCK=1e3;function Bb(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function pg(r,...e){if(!Bb(r))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(r.length))throw new Error("Uint8Array expected of length "+e+", got length="+r.length)}function _d(r,e=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(e&&r.finished)throw new Error("Hash#digest() has already been called")}function Pb(r,e){pg(r);const t=e.outputLen;if(r.length<t)throw new Error("digestInto() expects output buffer of length at least "+t)}const fm=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),us=(r,e)=>r<<32-e|r>>>e,dm=(r,e)=>r<<e|r>>>32-e>>>0;function Ob(r){if(typeof r!="string")throw new Error("utf8ToBytes expected string, got "+typeof r);return new Uint8Array(new TextEncoder().encode(r))}function gg(r){return typeof r=="string"&&(r=Ob(r)),pg(r),r}class Db{clone(){return this._cloneInto()}}function _h(r){const e=s=>r().update(gg(s)).digest(),t=r();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>r(),e}function Tb(r,e,t,s){if(typeof r.setBigUint64=="function")return r.setBigUint64(e,t,s);const a=BigInt(32),n=BigInt(4294967295),u=Number(t>>a&n),i=Number(t&n),l=s?4:0,o=s?0:4;r.setUint32(e+l,u,s),r.setUint32(e+o,i,s)}const wg=(r,e,t)=>r&e^~r&t,yg=(r,e,t)=>r&e^r&t^e&t;class Xf extends Db{constructor(e,t,s,a){super(),this.blockLen=e,this.outputLen=t,this.padOffset=s,this.isLE=a,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=fm(this.buffer)}update(e){_d(this);const{view:t,buffer:s,blockLen:a}=this;e=gg(e);const n=e.length;for(let u=0;u<n;){const i=Math.min(a-this.pos,n-u);if(i===a){const l=fm(e);for(;a<=n-u;u+=a)this.process(l,u);continue}s.set(e.subarray(u,u+i),this.pos),this.pos+=i,u+=i,this.pos===a&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){_d(this),Pb(e,this),this.finished=!0;const{buffer:t,view:s,blockLen:a,isLE:n}=this;let{pos:u}=this;t[u++]=128,this.buffer.subarray(u).fill(0),this.padOffset>a-u&&(this.process(s,0),u=0);for(let m=u;m<a;m++)t[m]=0;Tb(s,a-8,BigInt(this.length*8),n),this.process(s,0);const i=fm(e),l=this.outputLen;if(l%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const o=l/4,c=this.get();if(o>c.length)throw new Error("_sha2: outputLen bigger than state");for(let m=0;m<o;m++)i.setUint32(4*m,c[m],n)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const s=e.slice(0,t);return this.destroy(),s}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:s,length:a,finished:n,destroyed:u,pos:i}=this;return e.length=a,e.pos=i,e.finished=n,e.destroyed=u,a%t&&e.buffer.set(s),e}}const Lo=new Uint32Array([1732584193,4023233417,2562383102,271733878,3285377520]),_s=new Uint32Array(80);let Rb=class extends Xf{constructor(){super(64,20,8,!1),this.A=Lo[0]|0,this.B=Lo[1]|0,this.C=Lo[2]|0,this.D=Lo[3]|0,this.E=Lo[4]|0}get(){const{A:r,B:e,C:t,D:s,E:a}=this;return[r,e,t,s,a]}set(r,e,t,s,a){this.A=r|0,this.B=e|0,this.C=t|0,this.D=s|0,this.E=a|0}process(r,e){for(let i=0;i<16;i++,e+=4)_s[i]=r.getUint32(e,!1);for(let i=16;i<80;i++)_s[i]=dm(_s[i-3]^_s[i-8]^_s[i-14]^_s[i-16],1);let{A:t,B:s,C:a,D:n,E:u}=this;for(let i=0;i<80;i++){let l,o;i<20?(l=wg(s,a,n),o=1518500249):i<40?(l=s^a^n,o=1859775393):i<60?(l=yg(s,a,n),o=2400959708):(l=s^a^n,o=3395469782);const c=dm(t,5)+l+u+o+_s[i]|0;u=n,n=a,a=dm(s,30),s=t,t=c}t=t+this.A|0,s=s+this.B|0,a=a+this.C|0,n=n+this.D|0,u=u+this.E|0,this.set(t,s,a,n,u)}roundClean(){_s.fill(0)}destroy(){this.set(0,0,0,0,0),this.buffer.fill(0)}};const Lb=_h(()=>new Rb),Ub=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Xs=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Zs=new Uint32Array(64);let jb=class extends Xf{constructor(){super(64,32,8,!1),this.A=Xs[0]|0,this.B=Xs[1]|0,this.C=Xs[2]|0,this.D=Xs[3]|0,this.E=Xs[4]|0,this.F=Xs[5]|0,this.G=Xs[6]|0,this.H=Xs[7]|0}get(){const{A:r,B:e,C:t,D:s,E:a,F:n,G:u,H:i}=this;return[r,e,t,s,a,n,u,i]}set(r,e,t,s,a,n,u,i){this.A=r|0,this.B=e|0,this.C=t|0,this.D=s|0,this.E=a|0,this.F=n|0,this.G=u|0,this.H=i|0}process(r,e){for(let c=0;c<16;c++,e+=4)Zs[c]=r.getUint32(e,!1);for(let c=16;c<64;c++){const m=Zs[c-15],h=Zs[c-2],p=us(m,7)^us(m,18)^m>>>3,d=us(h,17)^us(h,19)^h>>>10;Zs[c]=d+Zs[c-7]+p+Zs[c-16]|0}let{A:t,B:s,C:a,D:n,E:u,F:i,G:l,H:o}=this;for(let c=0;c<64;c++){const m=us(u,6)^us(u,11)^us(u,25),h=o+m+wg(u,i,l)+Ub[c]+Zs[c]|0,p=(us(t,2)^us(t,13)^us(t,22))+yg(t,s,a)|0;o=l,l=i,i=u,u=n+h|0,n=a,a=s,s=t,t=h+p|0}t=t+this.A|0,s=s+this.B|0,a=a+this.C|0,n=n+this.D|0,u=u+this.E|0,i=i+this.F|0,l=l+this.G|0,o=o+this.H|0,this.set(t,s,a,n,u,i,l,o)}roundClean(){Zs.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};const $b=_h(()=>new jb),pc=BigInt(2**32-1),cf=BigInt(32);function vg(r,e=!1){return e?{h:Number(r&pc),l:Number(r>>cf&pc)}:{h:Number(r>>cf&pc)|0,l:Number(r&pc)|0}}function Kb(r,e=!1){let t=new Uint32Array(r.length),s=new Uint32Array(r.length);for(let a=0;a<r.length;a++){const{h:n,l:u}=vg(r[a],e);[t[a],s[a]]=[n,u]}return[t,s]}const Hb=(r,e)=>BigInt(r>>>0)<<cf|BigInt(e>>>0),Mb=(r,e,t)=>r>>>t,Fb=(r,e,t)=>r<<32-t|e>>>t,Jb=(r,e,t)=>r>>>t|e<<32-t,qb=(r,e,t)=>r<<32-t|e>>>t,Wb=(r,e,t)=>r<<64-t|e>>>t-32,Gb=(r,e,t)=>r>>>t-32|e<<64-t,zb=(r,e)=>e,_b=(r,e)=>r,Xb=(r,e,t)=>r<<t|e>>>32-t,Zb=(r,e,t)=>e<<t|r>>>32-t,Qb=(r,e,t)=>e<<t-32|r>>>64-t,Yb=(r,e,t)=>r<<t-32|e>>>64-t;function e0(r,e,t,s){const a=(e>>>0)+(s>>>0);return{h:r+t+(a/2**32|0)|0,l:a|0}}const t0=(r,e,t)=>(r>>>0)+(e>>>0)+(t>>>0),s0=(r,e,t,s)=>e+t+s+(r/2**32|0)|0,r0=(r,e,t,s)=>(r>>>0)+(e>>>0)+(t>>>0)+(s>>>0),a0=(r,e,t,s,a)=>e+t+s+a+(r/2**32|0)|0,n0=(r,e,t,s,a)=>(r>>>0)+(e>>>0)+(t>>>0)+(s>>>0)+(a>>>0),i0=(r,e,t,s,a,n)=>e+t+s+a+n+(r/2**32|0)|0,te={fromBig:vg,split:Kb,toBig:Hb,shrSH:Mb,shrSL:Fb,rotrSH:Jb,rotrSL:qb,rotrBH:Wb,rotrBL:Gb,rotr32H:zb,rotr32L:_b,rotlSH:Xb,rotlSL:Zb,rotlBH:Qb,rotlBL:Yb,add:e0,add3L:t0,add3H:s0,add4L:r0,add4H:a0,add5H:i0,add5L:n0},[o0,u0]=te.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(r=>BigInt(r))),Qs=new Uint32Array(80),Ys=new Uint32Array(80);let bg=class extends Xf{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:r,Al:e,Bh:t,Bl:s,Ch:a,Cl:n,Dh:u,Dl:i,Eh:l,El:o,Fh:c,Fl:m,Gh:h,Gl:p,Hh:d,Hl:w}=this;return[r,e,t,s,a,n,u,i,l,o,c,m,h,p,d,w]}set(r,e,t,s,a,n,u,i,l,o,c,m,h,p,d,w){this.Ah=r|0,this.Al=e|0,this.Bh=t|0,this.Bl=s|0,this.Ch=a|0,this.Cl=n|0,this.Dh=u|0,this.Dl=i|0,this.Eh=l|0,this.El=o|0,this.Fh=c|0,this.Fl=m|0,this.Gh=h|0,this.Gl=p|0,this.Hh=d|0,this.Hl=w|0}process(r,e){for(let g=0;g<16;g++,e+=4)Qs[g]=r.getUint32(e),Ys[g]=r.getUint32(e+=4);for(let g=16;g<80;g++){const b=Qs[g-15]|0,N=Ys[g-15]|0,S=te.rotrSH(b,N,1)^te.rotrSH(b,N,8)^te.shrSH(b,N,7),E=te.rotrSL(b,N,1)^te.rotrSL(b,N,8)^te.shrSL(b,N,7),x=Qs[g-2]|0,C=Ys[g-2]|0,P=te.rotrSH(x,C,19)^te.rotrBH(x,C,61)^te.shrSH(x,C,6),K=te.rotrSL(x,C,19)^te.rotrBL(x,C,61)^te.shrSL(x,C,6),L=te.add4L(E,K,Ys[g-7],Ys[g-16]),j=te.add4H(L,S,P,Qs[g-7],Qs[g-16]);Qs[g]=j|0,Ys[g]=L|0}let{Ah:t,Al:s,Bh:a,Bl:n,Ch:u,Cl:i,Dh:l,Dl:o,Eh:c,El:m,Fh:h,Fl:p,Gh:d,Gl:w,Hh:y,Hl:k}=this;for(let g=0;g<80;g++){const b=te.rotrSH(c,m,14)^te.rotrSH(c,m,18)^te.rotrBH(c,m,41),N=te.rotrSL(c,m,14)^te.rotrSL(c,m,18)^te.rotrBL(c,m,41),S=c&h^~c&d,E=m&p^~m&w,x=te.add5L(k,N,E,u0[g],Ys[g]),C=te.add5H(x,y,b,S,o0[g],Qs[g]),P=x|0,K=te.rotrSH(t,s,28)^te.rotrBH(t,s,34)^te.rotrBH(t,s,39),L=te.rotrSL(t,s,28)^te.rotrBL(t,s,34)^te.rotrBL(t,s,39),j=t&a^t&u^a&u,U=s&n^s&i^n&i;y=d|0,k=w|0,d=h|0,w=p|0,h=c|0,p=m|0,{h:c,l:m}=te.add(l|0,o|0,C|0,P|0),l=u|0,o=i|0,u=a|0,i=n|0,a=t|0,n=s|0;const M=te.add3L(P,L,U);t=te.add3H(M,C,K,j),s=M|0}({h:t,l:s}=te.add(this.Ah|0,this.Al|0,t|0,s|0)),{h:a,l:n}=te.add(this.Bh|0,this.Bl|0,a|0,n|0),{h:u,l:i}=te.add(this.Ch|0,this.Cl|0,u|0,i|0),{h:l,l:o}=te.add(this.Dh|0,this.Dl|0,l|0,o|0),{h:c,l:m}=te.add(this.Eh|0,this.El|0,c|0,m|0),{h,l:p}=te.add(this.Fh|0,this.Fl|0,h|0,p|0),{h:d,l:w}=te.add(this.Gh|0,this.Gl|0,d|0,w|0),{h:y,l:k}=te.add(this.Hh|0,this.Hl|0,y|0,k|0),this.set(t,s,a,n,u,i,l,o,c,m,h,p,d,w,y,k)}roundClean(){Qs.fill(0),Ys.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},l0=class extends bg{constructor(){super(),this.Ah=-876896931,this.Al=-1056596264,this.Bh=1654270250,this.Bl=914150663,this.Ch=-1856437926,this.Cl=812702999,this.Dh=355462360,this.Dl=-150054599,this.Eh=1731405415,this.El=-4191439,this.Fh=-1900787065,this.Fl=1750603025,this.Gh=-619958771,this.Gl=1694076839,this.Hh=1203062813,this.Hl=-1090891868,this.outputLen=48}};const c0=_h(()=>new bg),h0=_h(()=>new l0),Ue=new ArrayBuffer(0),v="";class he extends TypeError{constructor(){super(...arguments),this.name=he.NAME}static isType(e,t){if(typeof t=="string"){if(t==="Array"&&Array.isArray(e)||t==="ArrayBuffer"&&e instanceof ArrayBuffer||t==="ArrayBufferView"&&ArrayBuffer.isView(e)||typeof e===t)return!0}else if(e instanceof t)return!0;return!1}static assert(e,t,...s){for(const n of s)if(this.isType(e,n))return;const a=s.map(n=>n instanceof Function&&"name"in n?n.name:"".concat(n));throw new he("Parameter '".concat(t,"' is not of type ").concat(a.length>1?"(".concat(a.join(" or "),")"):a[0]))}}he.NAME="ArgumentError";class ne extends TypeError{static assert(...e){let t=null,s,a;typeof e[0]=="string"?(t=e[0],s=e[1],a=e.slice(2)):(s=e[0],a=e.slice(1)),he.assert(s,"parameters","object");for(const n of a)if(s[n]==null)throw new ne(n,t)}static assertEmpty(e,t,s){if(e==null)throw new ne(t,s)}constructor(e,t=null,s){super(),this.name=ne.NAME,this.field=e,t&&(this.target=t),s?this.message=s:this.message="Absent mandatory parameter '".concat(e,"' ").concat(t?" in '".concat(t,"'"):v)}}ne.NAME="ParameterError";class O extends Error{static assertSchema(e,t){if(!e.verified)throw new Error("Object's schema was not verified against input data for ".concat(t))}static assert(e,t){if(e.offset===-1)throw new O("Error during parsing of ASN.1 data. Data is not correct for '".concat(t,"'."))}constructor(e){super(e),this.name="AsnError"}}class D{static blockName(){return this.CLASS_NAME}static fromBER(e){const t=Le(e);O.assert(t,this.name);try{return new this({schema:t.result})}catch(s){throw new O("Cannot create '".concat(this.CLASS_NAME,"' from ASN.1 object"))}}static defaultValues(e){throw new Error("Invalid member name for ".concat(this.CLASS_NAME," class: ").concat(e))}static schema(e={}){throw new Error("Method '".concat(this.CLASS_NAME,".schema' should be overridden"))}get className(){return this.constructor.CLASS_NAME}toString(e="hex"){let t;try{t=this.toSchema()}catch(s){t=this.toSchema(!0)}return ce.ToString(t.toBER(),e)}}D.CLASS_NAME="PkiObject";function Hr(r){let e=!1,t=v;const s=r.trim();for(let a=0;a<s.length;a++)s.charCodeAt(a)===32?e===!1&&(e=!0):(e&&(t+=" ",e=!1),t+=s[a]);return t.toLowerCase()}const Uo="type",pm="value";class _r extends D{constructor(e={}){super(),this.type=f(e,Uo,_r.defaultValues(Uo)),this.value=f(e,pm,_r.defaultValues(pm)),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case Uo:return v;case pm:return{};default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||v,value:[new J({name:t.type||v}),new X({name:t.value||v})]})}fromSchema(e){T(e,[Uo,"typeValue"]);const t=R(e,e,_r.schema({names:{type:Uo,value:"typeValue"}}));O.assertSchema(t,this.className),this.type=t.result.type.valueBlock.toString(),this.value=t.result.typeValue}toSchema(){return new A({value:[new J({value:this.type}),this.value]})}toJSON(){const e={type:this.type};return Object.keys(this.value).length!==0?e.value=this.value.toJSON():e.value=this.value,e}isEqual(e){const t=[Ch.blockName(),Zm.blockName(),Qm.blockName(),Mc.blockName(),Ts.blockName(),Ym.blockName(),hw.blockName(),Op.blockName(),mw.blockName(),fw.blockName(),dw.blockName(),pw.blockName()];if(e instanceof ArrayBuffer)return pe.isEqual(this.value.valueBeforeDecodeView,e);if(e.constructor.blockName()===_r.blockName()){if(this.type!==e.type)return!1;const s=[!1,!1],a=this.value.constructor.blockName();for(const n of t)a===n&&(s[0]=!0),e.value.constructor.blockName()===n&&(s[1]=!0);if(s[0]!==s[1])return!1;if(s[0]&&s[1]){const n=Hr(this.value.valueBlock.value),u=Hr(e.value.valueBlock.value);if(n.localeCompare(u)!==0)return!1}else if(!pe.isEqual(this.value.valueBeforeDecodeView,e.value.valueBeforeDecodeView))return!1;return!0}return!1}}_r.CLASS_NAME="AttributeTypeAndValue";const la="typesAndValues",gc="valueBeforeDecode",Xd="RDN";class me extends D{constructor(e={}){super(),this.typesAndValues=f(e,la,me.defaultValues(la)),this.valueBeforeDecode=f(e,gc,me.defaultValues(gc)),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case la:return[];case gc:return Ue;default:return super.defaultValues(e)}}static compareWithDefault(e,t){switch(e){case la:return t.length===0;case gc:return t.byteLength===0;default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||v,value:[new Z({name:t.repeatedSequence||v,value:new Je({value:[new Z({name:t.repeatedSet||v,value:_r.schema(t.typeAndValue||{})})]})})]})}fromSchema(e){T(e,[Xd,la]);const t=R(e,e,me.schema({names:{blockName:Xd,repeatedSet:la}}));O.assertSchema(t,this.className),la in t.result&&(this.typesAndValues=Array.from(t.result.typesAndValues,s=>new _r({schema:s}))),this.valueBeforeDecode=t.result.RDN.valueBeforeDecodeView.slice().buffer}toSchema(){if(this.valueBeforeDecode.byteLength===0)return new A({value:[new Je({value:Array.from(this.typesAndValues,t=>t.toSchema())})]});const e=Le(this.valueBeforeDecode);if(O.assert(e,"RelativeDistinguishedNames"),!(e.result instanceof A))throw new Error("ASN.1 result should be SEQUENCE");return e.result}toJSON(){return{typesAndValues:Array.from(this.typesAndValues,e=>e.toJSON())}}isEqual(e){if(e instanceof me){if(this.typesAndValues.length!==e.typesAndValues.length)return!1;for(const[t,s]of this.typesAndValues.entries())if(s.isEqual(e.typesAndValues[t])===!1)return!1;return!0}return e instanceof ArrayBuffer?Zl(this.valueBeforeDecode,e):!1}}me.CLASS_NAME="RelativeDistinguishedNames";const Zo="type",Qo="value";function m0(r={},e=!1){const t=f(r,"names",{});return new A({optional:e,value:[new I({optional:!0,idBlock:{tagClass:2,tagNumber:1},name:t.country_name||v,value:[new Ne({value:[new Mc,new Ts]})]}),new I({optional:!0,idBlock:{tagClass:2,tagNumber:2},name:t.administration_domain_name||v,value:[new Ne({value:[new Mc,new Ts]})]}),new _({optional:!0,idBlock:{tagClass:3,tagNumber:0},name:t.network_address||v,isHexOnly:!0}),new _({optional:!0,idBlock:{tagClass:3,tagNumber:1},name:t.terminal_identifier||v,isHexOnly:!0}),new I({optional:!0,idBlock:{tagClass:3,tagNumber:2},name:t.private_domain_name||v,value:[new Ne({value:[new Mc,new Ts]})]}),new _({optional:!0,idBlock:{tagClass:3,tagNumber:3},name:t.organization_name||v,isHexOnly:!0}),new _({optional:!0,name:t.numeric_user_identifier||v,idBlock:{tagClass:3,tagNumber:4},isHexOnly:!0}),new I({optional:!0,name:t.personal_name||v,idBlock:{tagClass:3,tagNumber:5},value:[new _({idBlock:{tagClass:3,tagNumber:0},isHexOnly:!0}),new _({optional:!0,idBlock:{tagClass:3,tagNumber:1},isHexOnly:!0}),new _({optional:!0,idBlock:{tagClass:3,tagNumber:2},isHexOnly:!0}),new _({optional:!0,idBlock:{tagClass:3,tagNumber:3},isHexOnly:!0})]}),new I({optional:!0,name:t.organizational_unit_names||v,idBlock:{tagClass:3,tagNumber:6},value:[new Z({value:new Ts})]})]})}function f0(r=!1){return new A({optional:r,value:[new Ts,new Ts]})}function d0(r=!1){return new Je({optional:r,value:[new _({optional:!0,idBlock:{tagClass:3,tagNumber:0},isHexOnly:!0}),new I({optional:!0,idBlock:{tagClass:3,tagNumber:1},value:[new X]})]})}class ue extends D{constructor(e={}){super(),this.type=f(e,Zo,ue.defaultValues(Zo)),this.value=f(e,Qo,ue.defaultValues(Qo)),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case Zo:return 9;case Qo:return{};default:return super.defaultValues(e)}}static compareWithDefault(e,t){switch(e){case Zo:return t===ue.defaultValues(e);case Qo:return Object.keys(t).length===0;default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new Ne({value:[new I({idBlock:{tagClass:3,tagNumber:0},name:t.blockName||v,value:[new J,new I({idBlock:{tagClass:3,tagNumber:0},value:[new X]})]}),new _({name:t.blockName||v,idBlock:{tagClass:3,tagNumber:1}}),new _({name:t.blockName||v,idBlock:{tagClass:3,tagNumber:2}}),new I({idBlock:{tagClass:3,tagNumber:3},name:t.blockName||v,value:[m0(t.builtInStandardAttributes||{},!1),f0(!0),d0(!0)]}),new I({idBlock:{tagClass:3,tagNumber:4},name:t.blockName||v,value:[me.schema(t.directoryName||{})]}),new I({idBlock:{tagClass:3,tagNumber:5},name:t.blockName||v,value:[new I({optional:!0,idBlock:{tagClass:3,tagNumber:0},value:[new Ne({value:[new Ym,new Ts,new Qm,new Ch,new Zm]})]}),new I({idBlock:{tagClass:3,tagNumber:1},value:[new Ne({value:[new Ym,new Ts,new Qm,new Ch,new Zm]})]})]}),new _({name:t.blockName||v,idBlock:{tagClass:3,tagNumber:6}}),new _({name:t.blockName||v,idBlock:{tagClass:3,tagNumber:7}}),new _({name:t.blockName||v,idBlock:{tagClass:3,tagNumber:8}})]})}fromSchema(e){T(e,["blockName","otherName","rfc822Name","dNSName","x400Address","directoryName","ediPartyName","uniformResourceIdentifier","iPAddress","registeredID"]);const t=R(e,e,ue.schema({names:{blockName:"blockName",otherName:"otherName",rfc822Name:"rfc822Name",dNSName:"dNSName",x400Address:"x400Address",directoryName:{names:{blockName:"directoryName"}},ediPartyName:"ediPartyName",uniformResourceIdentifier:"uniformResourceIdentifier",iPAddress:"iPAddress",registeredID:"registeredID"}}));switch(O.assertSchema(t,this.className),this.type=t.result.blockName.idBlock.tagNumber,this.type){case 0:this.value=t.result.blockName;break;case 1:case 2:case 6:{const s=t.result.blockName;s.idBlock.tagClass=1,s.idBlock.tagNumber=22;const a=s.toBER(!1),n=Le(a);O.assert(n,"GeneralName value"),this.value=n.result.valueBlock.value}break;case 3:this.value=t.result.blockName;break;case 4:this.value=new me({schema:t.result.directoryName});break;case 5:this.value=t.result.ediPartyName;break;case 7:this.value=new $({valueHex:t.result.blockName.valueBlock.valueHex});break;case 8:{const s=t.result.blockName;s.idBlock.tagClass=1,s.idBlock.tagNumber=6;const a=s.toBER(!1),n=Le(a);O.assert(n,"GeneralName registeredID"),this.value=n.result.valueBlock.toString()}break}}toSchema(){switch(this.type){case 0:case 3:case 5:return new I({idBlock:{tagClass:3,tagNumber:this.type},value:[this.value]});case 1:case 2:case 6:{const e=new Op({value:this.value});return e.idBlock.tagClass=3,e.idBlock.tagNumber=this.type,e}case 4:return new I({idBlock:{tagClass:3,tagNumber:4},value:[this.value.toSchema()]});case 7:{const e=this.value;return e.idBlock.tagClass=3,e.idBlock.tagNumber=this.type,e}case 8:{const e=new J({value:this.value});return e.idBlock.tagClass=3,e.idBlock.tagNumber=this.type,e}default:return ue.schema()}}toJSON(){const e={type:this.type,value:v};if(typeof this.value=="string")e.value=this.value;else try{e.value=this.value.toJSON()}catch(t){}return e}}ue.CLASS_NAME="GeneralName";const Yo="accessMethod",eu="accessLocation",p0=[Yo,eu];class Nn extends D{constructor(e={}){super(),this.accessMethod=f(e,Yo,Nn.defaultValues(Yo)),this.accessLocation=f(e,eu,Nn.defaultValues(eu)),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case Yo:return v;case eu:return new ue;default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||v,value:[new J({name:t.accessMethod||v}),ue.schema(t.accessLocation||{})]})}fromSchema(e){T(e,p0);const t=R(e,e,Nn.schema({names:{accessMethod:Yo,accessLocation:{names:{blockName:eu}}}}));O.assertSchema(t,this.className),this.accessMethod=t.result.accessMethod.valueBlock.toString(),this.accessLocation=new ue({schema:t.result.accessLocation})}toSchema(){return new A({value:[new J({value:this.accessMethod}),this.accessLocation.toSchema()]})}toJSON(){return{accessMethod:this.accessMethod,accessLocation:this.accessLocation.toJSON()}}}Nn.CLASS_NAME="AccessDescription";const rr="seconds",ar="millis",nr="micros";class Dt extends D{constructor(e={}){super(),rr in e&&(this.seconds=f(e,rr,Dt.defaultValues(rr))),ar in e&&(this.millis=f(e,ar,Dt.defaultValues(ar))),nr in e&&(this.micros=f(e,nr,Dt.defaultValues(nr))),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case rr:case ar:case nr:return 0;default:return super.defaultValues(e)}}static compareWithDefault(e,t){switch(e){case rr:case ar:case nr:return t===Dt.defaultValues(e);default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||v,optional:!0,value:[new B({optional:!0,name:t.seconds||v}),new _({name:t.millis||v,optional:!0,idBlock:{tagClass:3,tagNumber:0}}),new _({name:t.micros||v,optional:!0,idBlock:{tagClass:3,tagNumber:1}})]})}fromSchema(e){T(e,[rr,ar,nr]);const t=R(e,e,Dt.schema({names:{seconds:rr,millis:ar,micros:nr}}));if(O.assertSchema(t,this.className),"seconds"in t.result&&(this.seconds=t.result.seconds.valueBlock.valueDec),"millis"in t.result){const s=new B({valueHex:t.result.millis.valueBlock.valueHex});this.millis=s.valueBlock.valueDec}if("micros"in t.result){const s=new B({valueHex:t.result.micros.valueBlock.valueHex});this.micros=s.valueBlock.valueDec}}toSchema(){const e=[];if(this.seconds!==void 0&&e.push(new B({value:this.seconds})),this.millis!==void 0){const t=new B({value:this.millis});e.push(new _({idBlock:{tagClass:3,tagNumber:0},valueHex:t.valueBlock.valueHexView}))}if(this.micros!==void 0){const t=new B({value:this.micros});e.push(new _({idBlock:{tagClass:3,tagNumber:1},valueHex:t.valueBlock.valueHexView}))}return new A({value:e})}toJSON(){const e={};return this.seconds!==void 0&&(e.seconds=this.seconds),this.millis!==void 0&&(e.millis=this.millis),this.micros!==void 0&&(e.micros=this.micros),e}}Dt.CLASS_NAME="Accuracy";const wc="algorithmId",jo="algorithmParams",Sg="algorithm",hf="params",g0=[Sg,hf];class V extends D{constructor(e={}){super(),this.algorithmId=f(e,wc,V.defaultValues(wc)),jo in e&&(this.algorithmParams=f(e,jo,V.defaultValues(jo))),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case wc:return v;case jo:return new X;default:return super.defaultValues(e)}}static compareWithDefault(e,t){switch(e){case wc:return t===v;case jo:return t instanceof X;default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||v,optional:t.optional||!1,value:[new J({name:t.algorithmIdentifier||v}),new X({name:t.algorithmParams||v,optional:!0})]})}fromSchema(e){T(e,g0);const t=R(e,e,V.schema({names:{algorithmIdentifier:Sg,algorithmParams:hf}}));O.assertSchema(t,this.className),this.algorithmId=t.result.algorithm.valueBlock.toString(),hf in t.result&&(this.algorithmParams=t.result.params)}toSchema(){const e=[];return e.push(new J({value:this.algorithmId})),this.algorithmParams&&!(this.algorithmParams instanceof X)&&e.push(this.algorithmParams),new A({value:e})}toJSON(){const e={algorithmId:this.algorithmId};return this.algorithmParams&&!(this.algorithmParams instanceof X)&&(e.algorithmParams=this.algorithmParams.toJSON()),e}isEqual(e){return!(e instanceof V)||this.algorithmId!==e.algorithmId?!1:this.algorithmParams?e.algorithmParams?JSON.stringify(this.algorithmParams)===JSON.stringify(e.algorithmParams):!1:!e.algorithmParams}}V.CLASS_NAME="AlgorithmIdentifier";const qn="altNames",w0=[qn];class Co extends D{constructor(e={}){super(),this.altNames=f(e,qn,Co.defaultValues(qn)),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case qn:return[];default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||v,value:[new Z({name:t.altNames||v,value:ue.schema()})]})}fromSchema(e){T(e,w0);const t=R(e,e,Co.schema({names:{altNames:qn}}));O.assertSchema(t,this.className),qn in t.result&&(this.altNames=Array.from(t.result.altNames,s=>new ue({schema:s})))}toSchema(){return new A({value:Array.from(this.altNames,e=>e.toSchema())})}toJSON(){return{altNames:Array.from(this.altNames,e=>e.toJSON())}}}Co.CLASS_NAME="AltName";const Wn="type",Gn="values",y0=[Wn,Gn];class ge extends D{constructor(e={}){super(),this.type=f(e,Wn,ge.defaultValues(Wn)),this.values=f(e,Gn,ge.defaultValues(Gn)),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case Wn:return v;case Gn:return[];default:return super.defaultValues(e)}}static compareWithDefault(e,t){switch(e){case Wn:return t===v;case Gn:return t.length===0;default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||v,value:[new J({name:t.type||v}),new Je({name:t.setName||v,value:[new Z({name:t.values||v,value:new X})]})]})}fromSchema(e){T(e,y0);const t=R(e,e,ge.schema({names:{type:Wn,values:Gn}}));O.assertSchema(t,this.className),this.type=t.result.type.valueBlock.toString(),this.values=t.result.values}toSchema(){return new A({value:[new J({value:this.type}),new Je({value:this.values})]})}toJSON(){return{type:this.type,values:Array.from(this.values,e=>e.toJSON())}}}ge.CLASS_NAME="Attribute";const tu="notBeforeTime",su="notAfterTime",v0=[tu,su];class as extends D{constructor(e={}){super(),this.notBeforeTime=f(e,tu,as.defaultValues(tu)),this.notAfterTime=f(e,su,as.defaultValues(su)),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case tu:case su:return new Date(0,0,0);default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||v,value:[new ke({name:t.notBeforeTime||v}),new ke({name:t.notAfterTime||v})]})}fromSchema(e){T(e,v0);const t=R(e,e,as.schema({names:{notBeforeTime:tu,notAfterTime:su}}));O.assertSchema(t,this.className),this.notBeforeTime=t.result.notBeforeTime.toDate(),this.notAfterTime=t.result.notAfterTime.toDate()}toSchema(){return new A({value:[new ke({valueDate:this.notBeforeTime}),new ke({valueDate:this.notAfterTime})]})}toJSON(){return{notBeforeTime:this.notBeforeTime,notAfterTime:this.notAfterTime}}}as.CLASS_NAME="AttCertValidityPeriod";const $o="names",Zd="generalNames";class qe extends D{constructor(e={}){super(),this.names=f(e,$o,qe.defaultValues($o)),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case"names":return[];default:return super.defaultValues(e)}}static schema(e={},t=!1){const s=f(e,$o,{});return new A({optional:t,name:s.blockName||v,value:[new Z({name:s.generalNames||v,value:ue.schema()})]})}fromSchema(e){T(e,[$o,Zd]);const t=R(e,e,qe.schema({names:{blockName:$o,generalNames:Zd}}));O.assertSchema(t,this.className),this.names=Array.from(t.result.generalNames,s=>new ue({schema:s}))}toSchema(){return new A({value:Array.from(this.names,e=>e.toSchema())})}toJSON(){return{names:Array.from(this.names,e=>e.toJSON())}}}qe.CLASS_NAME="GeneralNames";const b0="2.5.29.9",S0="2.5.29.14",A0="2.5.29.15",N0="2.5.29.16",Ag="2.5.29.17",Ng="2.5.29.18",Zf="2.5.29.19",k0="2.5.29.20",C0="2.5.29.27",E0="2.5.29.21",x0="2.5.29.24",kg="2.5.29.28",Cg="2.5.29.29",Eg="2.5.29.30",xg="2.5.29.31",Qf="2.5.29.46",Ig="2.5.29.32",$t="2.5.29.32.0",I0="1.3.6.1.4.1.311.21.10",Vg="2.5.29.33",Yf="2.5.29.35",Bg="2.5.29.36",V0="2.5.29.37",B0="2.5.29.54",ed="1.3.6.1.5.5.7.1.1",P0="1.3.6.1.5.5.7.1.11",O0="1.3.6.1.4.1.11129.2.4.2",D0="1.3.6.1.4.1.311.21.7",T0="1.3.6.1.4.1.311.21.1",R0="1.3.6.1.5.5.7.1.3",td="1.2.840.113549.1.7.1",Pg="1.2.840.113549.1.7.2",Og="1.2.840.113549.1.7.3",Dg="1.2.840.113549.1.7.6",L0="1.2.840.113549.1.9.16.1.4",Qd="1.2.840.113549.1.9.22.1",U0="1.2.840.113549.1.9.22.2",Yd="1.2.840.113549.1.9.22.3",ep="1.2.840.113549.1.9.23.1",j0="1.3.6.1.5.5.7",$0="".concat(j0,".48"),Wc="".concat($0,".1.1"),da="keyIdentifier",pa="authorityCertIssuer",ga="authorityCertSerialNumber",K0=[da,pa,ga];class Xr extends D{constructor(e={}){super(),da in e&&(this.keyIdentifier=f(e,da,Xr.defaultValues(da))),pa in e&&(this.authorityCertIssuer=f(e,pa,Xr.defaultValues(pa))),ga in e&&(this.authorityCertSerialNumber=f(e,ga,Xr.defaultValues(ga))),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case da:return new $;case pa:return[];case ga:return new B;default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||v,value:[new _({name:t.keyIdentifier||v,optional:!0,idBlock:{tagClass:3,tagNumber:0}}),new I({optional:!0,idBlock:{tagClass:3,tagNumber:1},value:[new Z({name:t.authorityCertIssuer||v,value:ue.schema()})]}),new _({name:t.authorityCertSerialNumber||v,optional:!0,idBlock:{tagClass:3,tagNumber:2}})]})}fromSchema(e){T(e,K0);const t=R(e,e,Xr.schema({names:{keyIdentifier:da,authorityCertIssuer:pa,authorityCertSerialNumber:ga}}));O.assertSchema(t,this.className),da in t.result&&(this.keyIdentifier=new $({valueHex:t.result.keyIdentifier.valueBlock.valueHex})),pa in t.result&&(this.authorityCertIssuer=Array.from(t.result.authorityCertIssuer,s=>new ue({schema:s}))),ga in t.result&&(this.authorityCertSerialNumber=new B({valueHex:t.result.authorityCertSerialNumber.valueBlock.valueHex}))}toSchema(){const e=[];return this.keyIdentifier&&e.push(new _({idBlock:{tagClass:3,tagNumber:0},valueHex:this.keyIdentifier.valueBlock.valueHexView})),this.authorityCertIssuer&&e.push(new I({idBlock:{tagClass:3,tagNumber:1},value:Array.from(this.authorityCertIssuer,t=>t.toSchema())})),this.authorityCertSerialNumber&&e.push(new _({idBlock:{tagClass:3,tagNumber:2},valueHex:this.authorityCertSerialNumber.valueBlock.valueHexView})),new A({value:e})}toJSON(){const e={};return this.keyIdentifier&&(e.keyIdentifier=this.keyIdentifier.toJSON()),this.authorityCertIssuer&&(e.authorityCertIssuer=Array.from(this.authorityCertIssuer,t=>t.toJSON())),this.authorityCertSerialNumber&&(e.authorityCertSerialNumber=this.authorityCertSerialNumber.toJSON()),e}}Xr.CLASS_NAME="AuthorityKeyIdentifier";const ca="pathLenConstraint",ha="cA";class kn extends D{constructor(e={}){super(),this.cA=f(e,ha,!1),ca in e&&(this.pathLenConstraint=f(e,ca,0)),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case ha:return!1;default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||v,value:[new ia({optional:!0,name:t.cA||v}),new B({optional:!0,name:t.pathLenConstraint||v})]})}fromSchema(e){T(e,[ha,ca]);const t=R(e,e,kn.schema({names:{cA:ha,pathLenConstraint:ca}}));O.assertSchema(t,this.className),ha in t.result&&(this.cA=t.result.cA.valueBlock.value),ca in t.result&&(t.result.pathLenConstraint.valueBlock.isHexOnly?this.pathLenConstraint=t.result.pathLenConstraint:this.pathLenConstraint=t.result.pathLenConstraint.valueBlock.valueDec)}toSchema(){const e=[];return this.cA!==kn.defaultValues(ha)&&e.push(new ia({value:this.cA})),ca in this&&(this.pathLenConstraint instanceof B?e.push(this.pathLenConstraint):e.push(new B({value:this.pathLenConstraint}))),new A({value:e})}toJSON(){const e={};return this.cA!==kn.defaultValues(ha)&&(e.cA=this.cA),ca in this&&(this.pathLenConstraint instanceof B?e.pathLenConstraint=this.pathLenConstraint.toJSON():e.pathLenConstraint=this.pathLenConstraint),e}}kn.CLASS_NAME="BasicConstraints";const gm="certificateIndex",wm="keyIndex";class tc extends D{constructor(e={}){super(),this.certificateIndex=f(e,gm,tc.defaultValues(gm)),this.keyIndex=f(e,wm,tc.defaultValues(wm)),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case gm:case wm:return 0;default:return super.defaultValues(e)}}static schema(){return new B}fromSchema(e){if(e.constructor.blockName()!==B.blockName())throw new Error("Object's schema was not verified against input data for CAVersion");let t=e.valueBlock.valueHex.slice(0);const s=new Uint8Array(t);switch(!0){case t.byteLength<4:{const m=new ArrayBuffer(4);new Uint8Array(m).set(s,4-t.byteLength),t=m.slice(0)}break;case t.byteLength>4:{const m=new ArrayBuffer(4);new Uint8Array(m).set(s.slice(0,4)),t=m.slice(0)}break}const a=t.slice(0,2),n=new Uint8Array(a);let u=n[0];n[0]=n[1],n[1]=u;const i=new Uint16Array(a);this.keyIndex=i[0];const l=t.slice(2),o=new Uint8Array(l);u=o[0],o[0]=o[1],o[1]=u;const c=new Uint16Array(l);this.certificateIndex=c[0]}toSchema(){const e=new ArrayBuffer(2),t=new Uint16Array(e);t[0]=this.certificateIndex;const s=new Uint8Array(e);let a=s[0];s[0]=s[1],s[1]=a;const n=new ArrayBuffer(2),u=new Uint16Array(n);u[0]=this.keyIndex;const i=new Uint8Array(n);return a=i[0],i[0]=i[1],i[1]=a,new B({valueHex:go(n,e)})}toJSON(){return{certificateIndex:this.certificateIndex,keyIndex:this.keyIndex}}}tc.CLASS_NAME="CAVersion";const ru="policyQualifierId",au="qualifier",H0=[ru,au];class Cn extends D{constructor(e={}){super(),this.policyQualifierId=f(e,ru,Cn.defaultValues(ru)),this.qualifier=f(e,au,Cn.defaultValues(au)),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case ru:return v;case au:return new X;default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||v,value:[new J({name:t.policyQualifierId||v}),new X({name:t.qualifier||v})]})}fromSchema(e){T(e,H0);const t=R(e,e,Cn.schema({names:{policyQualifierId:ru,qualifier:au}}));O.assertSchema(t,this.className),this.policyQualifierId=t.result.policyQualifierId.valueBlock.toString(),this.qualifier=t.result.qualifier}toSchema(){return new A({value:[new J({value:this.policyQualifierId}),this.qualifier]})}toJSON(){return{policyQualifierId:this.policyQualifierId,qualifier:this.qualifier.toJSON()}}}Cn.CLASS_NAME="PolicyQualifierInfo";const nu="policyIdentifier",wa="policyQualifiers",M0=[nu,wa];class En extends D{constructor(e={}){super(),this.policyIdentifier=f(e,nu,En.defaultValues(nu)),wa in e&&(this.policyQualifiers=f(e,wa,En.defaultValues(wa))),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case nu:return v;case wa:return[];default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||v,value:[new J({name:t.policyIdentifier||v}),new A({optional:!0,value:[new Z({name:t.policyQualifiers||v,value:Cn.schema()})]})]})}fromSchema(e){T(e,M0);const t=R(e,e,En.schema({names:{policyIdentifier:nu,policyQualifiers:wa}}));O.assertSchema(t,this.className),this.policyIdentifier=t.result.policyIdentifier.valueBlock.toString(),wa in t.result&&(this.policyQualifiers=Array.from(t.result.policyQualifiers,s=>new Cn({schema:s})))}toSchema(){const e=[];return e.push(new J({value:this.policyIdentifier})),this.policyQualifiers&&e.push(new A({value:Array.from(this.policyQualifiers,t=>t.toSchema())})),new A({value:e})}toJSON(){const e={policyIdentifier:this.policyIdentifier};return this.policyQualifiers&&(e.policyQualifiers=Array.from(this.policyQualifiers,t=>t.toJSON())),e}}En.CLASS_NAME="PolicyInformation";const iu="certificatePolicies",F0=[iu];class Eo extends D{constructor(e={}){super(),this.certificatePolicies=f(e,iu,Eo.defaultValues(iu)),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case iu:return[];default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||v,value:[new Z({name:t.certificatePolicies||v,value:En.schema()})]})}fromSchema(e){T(e,F0);const t=R(e,e,Eo.schema({names:{certificatePolicies:iu}}));O.assertSchema(t,this.className),this.certificatePolicies=Array.from(t.result.certificatePolicies,s=>new En({schema:s}))}toSchema(){return new A({value:Array.from(this.certificatePolicies,e=>e.toSchema())})}toJSON(){return{certificatePolicies:Array.from(this.certificatePolicies,e=>e.toJSON())}}}Eo.CLASS_NAME="CertificatePolicies";const ou="templateID",vs="templateMajorVersion",bs="templateMinorVersion",J0=[ou,vs,bs];class fo extends D{constructor(e={}){super(),this.templateID=f(e,ou,fo.defaultValues(ou)),vs in e&&(this.templateMajorVersion=f(e,vs,fo.defaultValues(vs))),bs in e&&(this.templateMinorVersion=f(e,bs,fo.defaultValues(bs))),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case ou:return v;case vs:case bs:return 0;default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||v,value:[new J({name:t.templateID||v}),new B({name:t.templateMajorVersion||v,optional:!0}),new B({name:t.templateMinorVersion||v,optional:!0})]})}fromSchema(e){T(e,J0);const t=R(e,e,fo.schema({names:{templateID:ou,templateMajorVersion:vs,templateMinorVersion:bs}}));O.assertSchema(t,this.className),this.templateID=t.result.templateID.valueBlock.toString(),vs in t.result&&(this.templateMajorVersion=t.result.templateMajorVersion.valueBlock.valueDec),bs in t.result&&(this.templateMinorVersion=t.result.templateMinorVersion.valueBlock.valueDec)}toSchema(){const e=[];return e.push(new J({value:this.templateID})),vs in this&&e.push(new B({value:this.templateMajorVersion})),bs in this&&e.push(new B({value:this.templateMinorVersion})),new A({value:e})}toJSON(){const e={templateID:this.templateID};return vs in this&&(e.templateMajorVersion=this.templateMajorVersion),bs in this&&(e.templateMinorVersion=this.templateMinorVersion),e}}const ya="distributionPoint",Tg="distributionPointNames",va="reasons",ba="cRLIssuer",Rg="cRLIssuerNames",q0=[ya,Tg,va,ba,Rg];class Zr extends D{constructor(e={}){super(),ya in e&&(this.distributionPoint=f(e,ya,Zr.defaultValues(ya))),va in e&&(this.reasons=f(e,va,Zr.defaultValues(va))),ba in e&&(this.cRLIssuer=f(e,ba,Zr.defaultValues(ba))),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case ya:return[];case va:return new re;case ba:return[];default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||v,value:[new I({optional:!0,idBlock:{tagClass:3,tagNumber:0},value:[new Ne({value:[new I({name:t.distributionPoint||v,optional:!0,idBlock:{tagClass:3,tagNumber:0},value:[new Z({name:t.distributionPointNames||v,value:ue.schema()})]}),new I({name:t.distributionPoint||v,optional:!0,idBlock:{tagClass:3,tagNumber:1},value:me.schema().valueBlock.value})]})]}),new _({name:t.reasons||v,optional:!0,idBlock:{tagClass:3,tagNumber:1}}),new I({name:t.cRLIssuer||v,optional:!0,idBlock:{tagClass:3,tagNumber:2},value:[new Z({name:t.cRLIssuerNames||v,value:ue.schema()})]})]})}fromSchema(e){T(e,q0);const t=R(e,e,Zr.schema({names:{distributionPoint:ya,distributionPointNames:Tg,reasons:va,cRLIssuer:ba,cRLIssuerNames:Rg}}));O.assertSchema(t,this.className),ya in t.result&&(t.result.distributionPoint.idBlock.tagNumber===0&&(this.distributionPoint=Array.from(t.result.distributionPointNames,s=>new ue({schema:s}))),t.result.distributionPoint.idBlock.tagNumber===1&&(this.distributionPoint=new me({schema:new A({value:t.result.distributionPoint.valueBlock.value})}))),va in t.result&&(this.reasons=new re({valueHex:t.result.reasons.valueBlock.valueHex})),ba in t.result&&(this.cRLIssuer=Array.from(t.result.cRLIssuerNames,s=>new ue({schema:s})))}toSchema(){const e=[];if(this.distributionPoint){let t;this.distributionPoint instanceof Array?t=new I({idBlock:{tagClass:3,tagNumber:0},value:Array.from(this.distributionPoint,s=>s.toSchema())}):t=new I({idBlock:{tagClass:3,tagNumber:1},value:[this.distributionPoint.toSchema()]}),e.push(new I({idBlock:{tagClass:3,tagNumber:0},value:[t]}))}return this.reasons&&e.push(new _({idBlock:{tagClass:3,tagNumber:1},valueHex:this.reasons.valueBlock.valueHexView})),this.cRLIssuer&&e.push(new I({idBlock:{tagClass:3,tagNumber:2},value:Array.from(this.cRLIssuer,t=>t.toSchema())})),new A({value:e})}toJSON(){const e={};return this.distributionPoint&&(this.distributionPoint instanceof Array?e.distributionPoint=Array.from(this.distributionPoint,t=>t.toJSON()):e.distributionPoint=this.distributionPoint.toJSON()),this.reasons&&(e.reasons=this.reasons.toJSON()),this.cRLIssuer&&(e.cRLIssuer=Array.from(this.cRLIssuer,t=>t.toJSON())),e}}Zr.CLASS_NAME="DistributionPoint";const uu="distributionPoints",W0=[uu];class xo extends D{constructor(e={}){super(),this.distributionPoints=f(e,uu,xo.defaultValues(uu)),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case uu:return[];default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||v,value:[new Z({name:t.distributionPoints||v,value:Zr.schema()})]})}fromSchema(e){T(e,W0);const t=R(e,e,xo.schema({names:{distributionPoints:uu}}));O.assertSchema(t,this.className),this.distributionPoints=Array.from(t.result.distributionPoints,s=>new Zr({schema:s}))}toSchema(){return new A({value:Array.from(this.distributionPoints,e=>e.toSchema())})}toJSON(){return{distributionPoints:Array.from(this.distributionPoints,e=>e.toJSON())}}}xo.CLASS_NAME="CRLDistributionPoints";const lu="keyPurposes",G0=[lu];class sc extends D{constructor(e={}){super(),this.keyPurposes=f(e,lu,sc.defaultValues(lu)),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case lu:return[];default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||v,value:[new Z({name:t.keyPurposes||v,value:new J})]})}fromSchema(e){T(e,G0);const t=R(e,e,sc.schema({names:{keyPurposes:lu}}));O.assertSchema(t,this.className),this.keyPurposes=Array.from(t.result.keyPurposes,s=>s.valueBlock.toString())}toSchema(){return new A({value:Array.from(this.keyPurposes,e=>new J({value:e}))})}toJSON(){return{keyPurposes:Array.from(this.keyPurposes)}}}sc.CLASS_NAME="ExtKeyUsage";const Ko="accessDescriptions";class Io extends D{constructor(e={}){super(),this.accessDescriptions=f(e,Ko,Io.defaultValues(Ko)),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case Ko:return[];default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||v,value:[new Z({name:t.accessDescriptions||v,value:Nn.schema()})]})}fromSchema(e){T(e,[Ko]);const t=R(e,e,Io.schema({names:{accessDescriptions:Ko}}));O.assertSchema(t,this.className),this.accessDescriptions=Array.from(t.result.accessDescriptions,s=>new Nn({schema:s}))}toSchema(){return new A({value:Array.from(this.accessDescriptions,e=>e.toSchema())})}toJSON(){return{accessDescriptions:Array.from(this.accessDescriptions,e=>e.toJSON())}}}Io.CLASS_NAME="InfoAccess";const Sa="distributionPoint",Lg="distributionPointNames",ir="onlyContainsUserCerts",or="onlyContainsCACerts",ur="onlySomeReasons",lr="indirectCRL",cr="onlyContainsAttributeCerts",z0=[Sa,Lg,ir,or,ur,lr,cr];class Ye extends D{constructor(e={}){super(),Sa in e&&(this.distributionPoint=f(e,Sa,Ye.defaultValues(Sa))),this.onlyContainsUserCerts=f(e,ir,Ye.defaultValues(ir)),this.onlyContainsCACerts=f(e,or,Ye.defaultValues(or)),ur in e&&(this.onlySomeReasons=f(e,ur,Ye.defaultValues(ur))),this.indirectCRL=f(e,lr,Ye.defaultValues(lr)),this.onlyContainsAttributeCerts=f(e,cr,Ye.defaultValues(cr)),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case Sa:return[];case ir:return!1;case or:return!1;case ur:return 0;case lr:return!1;case cr:return!1;default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||v,value:[new I({optional:!0,idBlock:{tagClass:3,tagNumber:0},value:[new Ne({value:[new I({name:t.distributionPoint||v,idBlock:{tagClass:3,tagNumber:0},value:[new Z({name:t.distributionPointNames||v,value:ue.schema()})]}),new I({name:t.distributionPoint||v,idBlock:{tagClass:3,tagNumber:1},value:me.schema().valueBlock.value})]})]}),new _({name:t.onlyContainsUserCerts||v,optional:!0,idBlock:{tagClass:3,tagNumber:1}}),new _({name:t.onlyContainsCACerts||v,optional:!0,idBlock:{tagClass:3,tagNumber:2}}),new _({name:t.onlySomeReasons||v,optional:!0,idBlock:{tagClass:3,tagNumber:3}}),new _({name:t.indirectCRL||v,optional:!0,idBlock:{tagClass:3,tagNumber:4}}),new _({name:t.onlyContainsAttributeCerts||v,optional:!0,idBlock:{tagClass:3,tagNumber:5}})]})}fromSchema(e){T(e,z0);const t=R(e,e,Ye.schema({names:{distributionPoint:Sa,distributionPointNames:Lg,onlyContainsUserCerts:ir,onlyContainsCACerts:or,onlySomeReasons:ur,indirectCRL:lr,onlyContainsAttributeCerts:cr}}));if(O.assertSchema(t,this.className),Sa in t.result)switch(!0){case t.result.distributionPoint.idBlock.tagNumber===0:this.distributionPoint=Array.from(t.result.distributionPointNames,s=>new ue({schema:s}));break;case t.result.distributionPoint.idBlock.tagNumber===1:this.distributionPoint=new me({schema:new A({value:t.result.distributionPoint.valueBlock.value})});break;default:throw new Error("Unknown tagNumber for distributionPoint: {$asn1.result.distributionPoint.idBlock.tagNumber}")}if(ir in t.result){const s=new Uint8Array(t.result.onlyContainsUserCerts.valueBlock.valueHex);this.onlyContainsUserCerts=s[0]!==0}if(or in t.result){const s=new Uint8Array(t.result.onlyContainsCACerts.valueBlock.valueHex);this.onlyContainsCACerts=s[0]!==0}if(ur in t.result){const s=new Uint8Array(t.result.onlySomeReasons.valueBlock.valueHex);this.onlySomeReasons=s[0]}if(lr in t.result){const s=new Uint8Array(t.result.indirectCRL.valueBlock.valueHex);this.indirectCRL=s[0]!==0}if(cr in t.result){const s=new Uint8Array(t.result.onlyContainsAttributeCerts.valueBlock.valueHex);this.onlyContainsAttributeCerts=s[0]!==0}}toSchema(){const e=[];if(this.distributionPoint){let t;this.distributionPoint instanceof Array?t=new I({idBlock:{tagClass:3,tagNumber:0},value:Array.from(this.distributionPoint,s=>s.toSchema())}):(t=this.distributionPoint.toSchema(),t.idBlock.tagClass=3,t.idBlock.tagNumber=1),e.push(new I({idBlock:{tagClass:3,tagNumber:0},value:[t]}))}if(this.onlyContainsUserCerts!==Ye.defaultValues(ir)&&e.push(new _({idBlock:{tagClass:3,tagNumber:1},valueHex:new Uint8Array([255]).buffer})),this.onlyContainsCACerts!==Ye.defaultValues(or)&&e.push(new _({idBlock:{tagClass:3,tagNumber:2},valueHex:new Uint8Array([255]).buffer})),this.onlySomeReasons!==void 0){const t=new ArrayBuffer(1),s=new Uint8Array(t);s[0]=this.onlySomeReasons,e.push(new _({idBlock:{tagClass:3,tagNumber:3},valueHex:t}))}return this.indirectCRL!==Ye.defaultValues(lr)&&e.push(new _({idBlock:{tagClass:3,tagNumber:4},valueHex:new Uint8Array([255]).buffer})),this.onlyContainsAttributeCerts!==Ye.defaultValues(cr)&&e.push(new _({idBlock:{tagClass:3,tagNumber:5},valueHex:new Uint8Array([255]).buffer})),new A({value:e})}toJSON(){const e={};return this.distributionPoint&&(this.distributionPoint instanceof Array?e.distributionPoint=Array.from(this.distributionPoint,t=>t.toJSON()):e.distributionPoint=this.distributionPoint.toJSON()),this.onlyContainsUserCerts!==Ye.defaultValues(ir)&&(e.onlyContainsUserCerts=this.onlyContainsUserCerts),this.onlyContainsCACerts!==Ye.defaultValues(or)&&(e.onlyContainsCACerts=this.onlyContainsCACerts),ur in this&&(e.onlySomeReasons=this.onlySomeReasons),this.indirectCRL!==Ye.defaultValues(lr)&&(e.indirectCRL=this.indirectCRL),this.onlyContainsAttributeCerts!==Ye.defaultValues(cr)&&(e.onlyContainsAttributeCerts=this.onlyContainsAttributeCerts),e}}Ye.CLASS_NAME="IssuingDistributionPoint";const cu="base",zn="minimum",hr="maximum",_0=[cu,zn,hr];class fs extends D{constructor(e={}){super(),this.base=f(e,cu,fs.defaultValues(cu)),this.minimum=f(e,zn,fs.defaultValues(zn)),hr in e&&(this.maximum=f(e,hr,fs.defaultValues(hr))),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case cu:return new ue;case zn:return 0;case hr:return 0;default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||v,value:[ue.schema(t.base||{}),new I({optional:!0,idBlock:{tagClass:3,tagNumber:0},value:[new B({name:t.minimum||v})]}),new I({optional:!0,idBlock:{tagClass:3,tagNumber:1},value:[new B({name:t.maximum||v})]})]})}fromSchema(e){T(e,_0);const t=R(e,e,fs.schema({names:{base:{names:{blockName:cu}},minimum:zn,maximum:hr}}));O.assertSchema(t,this.className),this.base=new ue({schema:t.result.base}),zn in t.result&&(t.result.minimum.valueBlock.isHexOnly?this.minimum=t.result.minimum:this.minimum=t.result.minimum.valueBlock.valueDec),hr in t.result&&(t.result.maximum.valueBlock.isHexOnly?this.maximum=t.result.maximum:this.maximum=t.result.maximum.valueBlock.valueDec)}toSchema(){const e=[];if(e.push(this.base.toSchema()),this.minimum!==0){let t=0;this.minimum instanceof B?t=this.minimum:t=new B({value:this.minimum}),e.push(new I({optional:!0,idBlock:{tagClass:3,tagNumber:0},value:[t]}))}if(hr in this){let t=0;this.maximum instanceof B?t=this.maximum:t=new B({value:this.maximum}),e.push(new I({optional:!0,idBlock:{tagClass:3,tagNumber:1},value:[t]}))}return new A({value:e})}toJSON(){const e={base:this.base.toJSON()};return this.minimum!==0&&(typeof this.minimum=="number"?e.minimum=this.minimum:e.minimum=this.minimum.toJSON()),this.maximum!==void 0&&(typeof this.maximum=="number"?e.maximum=this.maximum:e.maximum=this.maximum.toJSON()),e}}fs.CLASS_NAME="GeneralSubtree";const Aa="permittedSubtrees",Na="excludedSubtrees",X0=[Aa,Na];class yo extends D{constructor(e={}){super(),Aa in e&&(this.permittedSubtrees=f(e,Aa,yo.defaultValues(Aa))),Na in e&&(this.excludedSubtrees=f(e,Na,yo.defaultValues(Na))),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case Aa:case Na:return[];default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||v,value:[new I({optional:!0,idBlock:{tagClass:3,tagNumber:0},value:[new Z({name:t.permittedSubtrees||v,value:fs.schema()})]}),new I({optional:!0,idBlock:{tagClass:3,tagNumber:1},value:[new Z({name:t.excludedSubtrees||v,value:fs.schema()})]})]})}fromSchema(e){T(e,X0);const t=R(e,e,yo.schema({names:{permittedSubtrees:Aa,excludedSubtrees:Na}}));O.assertSchema(t,this.className),Aa in t.result&&(this.permittedSubtrees=Array.from(t.result.permittedSubtrees,s=>new fs({schema:s}))),Na in t.result&&(this.excludedSubtrees=Array.from(t.result.excludedSubtrees,s=>new fs({schema:s})))}toSchema(){const e=[];return this.permittedSubtrees&&e.push(new I({idBlock:{tagClass:3,tagNumber:0},value:Array.from(this.permittedSubtrees,t=>t.toSchema())})),this.excludedSubtrees&&e.push(new I({idBlock:{tagClass:3,tagNumber:1},value:Array.from(this.excludedSubtrees,t=>t.toSchema())})),new A({value:e})}toJSON(){const e={};return this.permittedSubtrees&&(e.permittedSubtrees=Array.from(this.permittedSubtrees,t=>t.toJSON())),this.excludedSubtrees&&(e.excludedSubtrees=Array.from(this.excludedSubtrees,t=>t.toJSON())),e}}yo.CLASS_NAME="NameConstraints";const Ss="requireExplicitPolicy",As="inhibitPolicyMapping",Z0=[Ss,As];class vo extends D{constructor(e={}){super(),Ss in e&&(this.requireExplicitPolicy=f(e,Ss,vo.defaultValues(Ss))),As in e&&(this.inhibitPolicyMapping=f(e,As,vo.defaultValues(As))),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case Ss:return 0;case As:return 0;default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||v,value:[new _({name:t.requireExplicitPolicy||v,optional:!0,idBlock:{tagClass:3,tagNumber:0}}),new _({name:t.inhibitPolicyMapping||v,optional:!0,idBlock:{tagClass:3,tagNumber:1}})]})}fromSchema(e){T(e,Z0);const t=R(e,e,vo.schema({names:{requireExplicitPolicy:Ss,inhibitPolicyMapping:As}}));if(O.assertSchema(t,this.className),Ss in t.result){const s=t.result.requireExplicitPolicy;s.idBlock.tagClass=1,s.idBlock.tagNumber=2;const a=s.toBER(!1),n=Le(a);O.assert(n,"Integer"),this.requireExplicitPolicy=n.result.valueBlock.valueDec}if(As in t.result){const s=t.result.inhibitPolicyMapping;s.idBlock.tagClass=1,s.idBlock.tagNumber=2;const a=s.toBER(!1),n=Le(a);O.assert(n,"Integer"),this.inhibitPolicyMapping=n.result.valueBlock.valueDec}}toSchema(){const e=[];if(Ss in this){const t=new B({value:this.requireExplicitPolicy});t.idBlock.tagClass=3,t.idBlock.tagNumber=0,e.push(t)}if(As in this){const t=new B({value:this.inhibitPolicyMapping});t.idBlock.tagClass=3,t.idBlock.tagNumber=1,e.push(t)}return new A({value:e})}toJSON(){const e={};return Ss in this&&(e.requireExplicitPolicy=this.requireExplicitPolicy),As in this&&(e.inhibitPolicyMapping=this.inhibitPolicyMapping),e}}vo.CLASS_NAME="PolicyConstraints";const hu="issuerDomainPolicy",mu="subjectDomainPolicy",Q0=[hu,mu];class xn extends D{constructor(e={}){super(),this.issuerDomainPolicy=f(e,hu,xn.defaultValues(hu)),this.subjectDomainPolicy=f(e,mu,xn.defaultValues(mu)),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case hu:return v;case mu:return v;default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||v,value:[new J({name:t.issuerDomainPolicy||v}),new J({name:t.subjectDomainPolicy||v})]})}fromSchema(e){T(e,Q0);const t=R(e,e,xn.schema({names:{issuerDomainPolicy:hu,subjectDomainPolicy:mu}}));O.assertSchema(t,this.className),this.issuerDomainPolicy=t.result.issuerDomainPolicy.valueBlock.toString(),this.subjectDomainPolicy=t.result.subjectDomainPolicy.valueBlock.toString()}toSchema(){return new A({value:[new J({value:this.issuerDomainPolicy}),new J({value:this.subjectDomainPolicy})]})}toJSON(){return{issuerDomainPolicy:this.issuerDomainPolicy,subjectDomainPolicy:this.subjectDomainPolicy}}}xn.CLASS_NAME="PolicyMapping";const fu="mappings",Y0=[fu];class rc extends D{constructor(e={}){super(),this.mappings=f(e,fu,rc.defaultValues(fu)),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case fu:return[];default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||v,value:[new Z({name:t.mappings||v,value:xn.schema()})]})}fromSchema(e){T(e,Y0);const t=R(e,e,rc.schema({names:{mappings:fu}}));O.assertSchema(t,this.className),this.mappings=Array.from(t.result.mappings,s=>new xn({schema:s}))}toSchema(){return new A({value:Array.from(this.mappings,e=>e.toSchema())})}toJSON(){return{mappings:Array.from(this.mappings,e=>e.toJSON())}}}rc.CLASS_NAME="PolicyMappings";const mr="notBefore",fr="notAfter",e1=[mr,fr];class bo extends D{constructor(e={}){super(),mr in e&&(this.notBefore=f(e,mr,bo.defaultValues(mr))),fr in e&&(this.notAfter=f(e,fr,bo.defaultValues(fr))),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case mr:return new Date;case fr:return new Date;default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||v,value:[new _({name:t.notBefore||v,optional:!0,idBlock:{tagClass:3,tagNumber:0}}),new _({name:t.notAfter||v,optional:!0,idBlock:{tagClass:3,tagNumber:1}})]})}fromSchema(e){T(e,e1);const t=R(e,e,bo.schema({names:{notBefore:mr,notAfter:fr}}));if(O.assertSchema(t,this.className),mr in t.result){const s=new ke;s.fromBuffer(t.result.notBefore.valueBlock.valueHex),this.notBefore=s.toDate()}if(fr in t.result){const s=new ke({valueHex:t.result.notAfter.valueBlock.valueHex});s.fromBuffer(t.result.notAfter.valueBlock.valueHex),this.notAfter=s.toDate()}}toSchema(){const e=[];return mr in this&&e.push(new _({idBlock:{tagClass:3,tagNumber:0},valueHex:new ke({valueDate:this.notBefore}).valueBlock.valueHexView})),fr in this&&e.push(new _({idBlock:{tagClass:3,tagNumber:1},valueHex:new ke({valueDate:this.notAfter}).valueBlock.valueHexView})),new A({value:e})}toJSON(){const e={};return this.notBefore&&(e.notBefore=this.notBefore),this.notAfter&&(e.notAfter=this.notAfter),e}}bo.CLASS_NAME="PrivateKeyUsagePeriod";const _n="id",Ns="type",Xn="values",t1=[_n,Ns],s1=[Xn];class In extends D{constructor(e={}){super(),this.id=f(e,_n,In.defaultValues(_n)),Ns in e&&(this.type=f(e,Ns,In.defaultValues(Ns))),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case _n:return v;case Ns:return new Fe;default:return super.defaultValues(e)}}static compareWithDefault(e,t){switch(e){case _n:return t===v;case Ns:return t instanceof Fe;default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||v,value:[new J({name:t.id||v}),new X({name:t.type||v,optional:!0})]})}fromSchema(e){T(e,t1);const t=R(e,e,In.schema({names:{id:_n,type:Ns}}));O.assertSchema(t,this.className),this.id=t.result.id.valueBlock.toString(),Ns in t.result&&(this.type=t.result.type)}toSchema(){const e=[new J({value:this.id})];return Ns in this&&e.push(this.type),new A({value:e})}toJSON(){const e={id:this.id};return this.type&&(e.type=this.type.toJSON()),e}}In.CLASS_NAME="QCStatement";class ac extends D{constructor(e={}){super(),this.values=f(e,Xn,ac.defaultValues(Xn)),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case Xn:return[];default:return super.defaultValues(e)}}static compareWithDefault(e,t){switch(e){case Xn:return t.length===0;default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||v,value:[new Z({name:t.values||v,value:In.schema(t.value||{})})]})}fromSchema(e){T(e,s1);const t=R(e,e,ac.schema({names:{values:Xn}}));O.assertSchema(t,this.className),this.values=Array.from(t.result.values,s=>new In({schema:s}))}toSchema(){return new A({value:Array.from(this.values,e=>e.toSchema())})}toJSON(){return{values:Array.from(this.values,e=>e.toJSON())}}}ac.CLASS_NAME="QCStatements";var ma;class sa{static register(e,t,s){this.namedCurves[e.toLowerCase()]=this.namedCurves[t]={name:e,id:t,size:s}}static find(e){return this.namedCurves[e.toLowerCase()]||null}}ma=sa,sa.namedCurves={},ma.register("P-256","1.2.840.10045.3.1.7",32),ma.register("P-384","1.3.132.0.34",48),ma.register("P-521","1.3.132.0.35",66),ma.register("brainpoolP256r1","1.3.36.3.3.2.8.1.1.7",32),ma.register("brainpoolP384r1","1.3.36.3.3.2.8.1.1.11",48),ma.register("brainpoolP512r1","1.3.36.3.3.2.8.1.1.13",64);const yc="x",vc="y",bc="namedCurve";class At extends D{constructor(e={}){super(),this.x=f(e,yc,At.defaultValues(yc)),this.y=f(e,vc,At.defaultValues(vc)),this.namedCurve=f(e,bc,At.defaultValues(bc)),e.json&&this.fromJSON(e.json),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case yc:case vc:return Ue;case bc:return v;default:return super.defaultValues(e)}}static compareWithDefault(e,t){switch(e){case yc:case vc:return t instanceof ArrayBuffer&&Zl(t,At.defaultValues(e));case bc:return typeof t=="string"&&t===At.defaultValues(e);default:return super.defaultValues(e)}}static schema(){return new kh}fromSchema(e){const t=pe.toUint8Array(e);if(t[0]!==4)throw new Error("Object's schema was not verified against input data for ECPublicKey");const s=sa.find(this.namedCurve);if(!s)throw new Error("Incorrect curve OID: ".concat(this.namedCurve));const a=s.size;if(t.byteLength!==a*2+1)throw new Error("Object's schema was not verified against input data for ECPublicKey");this.namedCurve=s.name,this.x=t.slice(1,a+1).buffer,this.y=t.slice(1+a,a*2+1).buffer}toSchema(){return new kh({data:go(new Uint8Array([4]).buffer,this.x,this.y)})}toJSON(){const e=sa.find(this.namedCurve);return{crv:e?e.name:this.namedCurve,x:_m(Nh(this.x),!0,!0,!1),y:_m(Nh(this.y),!0,!0,!1)}}fromJSON(e){ne.assert("json",e,"crv","x","y");let t=0;const s=sa.find(e.crv);s&&(this.namedCurve=s.id,t=s.size);const a=ko(Ql(e.x,!0));if(a.byteLength<t){this.x=new ArrayBuffer(t);const u=new Uint8Array(this.x),i=new Uint8Array(a);u.set(i,1)}else this.x=a.slice(0,t);const n=ko(Ql(e.y,!0));if(n.byteLength<t){this.y=new ArrayBuffer(t);const u=new Uint8Array(this.y),i=new Uint8Array(n);u.set(i,1)}else this.y=n.slice(0,t)}}At.CLASS_NAME="ECPublicKey";const du="modulus",pu="publicExponent",r1=[du,pu];class Vn extends D{constructor(e={}){super(),this.modulus=f(e,du,Vn.defaultValues(du)),this.publicExponent=f(e,pu,Vn.defaultValues(pu)),e.json&&this.fromJSON(e.json),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case du:return new B;case pu:return new B;default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||v,value:[new B({name:t.modulus||v}),new B({name:t.publicExponent||v})]})}fromSchema(e){T(e,r1);const t=R(e,e,Vn.schema({names:{modulus:du,publicExponent:pu}}));O.assertSchema(t,this.className),this.modulus=t.result.modulus.convertFromDER(256),this.publicExponent=t.result.publicExponent}toSchema(){return new A({value:[this.modulus.convertToDER(),this.publicExponent]})}toJSON(){return{n:ce.ToBase64Url(this.modulus.valueBlock.valueHexView),e:ce.ToBase64Url(this.publicExponent.valueBlock.valueHexView)}}fromJSON(e){ne.assert("json",e,"n","e");const t=ko(Ql(e.n,!0));this.modulus=new B({valueHex:t.slice(0,Math.pow(2,lw(t.byteLength)))}),this.publicExponent=new B({valueHex:ko(Ql(e.e,!0)).slice(0,3)})}}Vn.CLASS_NAME="RSAPublicKey";const gu="algorithm",wu="subjectPublicKey",a1=[gu,wu];class Ct extends D{get parsedKey(){if(this._parsedKey===void 0){switch(this.algorithm.algorithmId){case"1.2.840.10045.2.1":if("algorithmParams"in this.algorithm&&this.algorithm.algorithmParams.constructor.blockName()===J.blockName())try{this._parsedKey=new At({namedCurve:this.algorithm.algorithmParams.valueBlock.toString(),schema:this.subjectPublicKey.valueBlock.valueHexView})}catch(e){}break;case"1.2.840.113549.1.1.1":{const e=Le(this.subjectPublicKey.valueBlock.valueHexView);if(e.offset!==-1)try{this._parsedKey=new Vn({schema:e.result})}catch(t){}}break}this._parsedKey||(this._parsedKey=null)}return this._parsedKey||void 0}set parsedKey(e){this._parsedKey=e}constructor(e={}){super(),this.algorithm=f(e,gu,Ct.defaultValues(gu)),this.subjectPublicKey=f(e,wu,Ct.defaultValues(wu));const t=f(e,"parsedKey",null);t&&(this.parsedKey=t),e.json&&this.fromJSON(e.json),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case gu:return new V;case wu:return new re;default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||v,value:[V.schema(t.algorithm||{}),new re({name:t.subjectPublicKey||v})]})}fromSchema(e){T(e,a1);const t=R(e,e,Ct.schema({names:{algorithm:{names:{blockName:gu}},subjectPublicKey:wu}}));O.assertSchema(t,this.className),this.algorithm=new V({schema:t.result.algorithm}),this.subjectPublicKey=t.result.subjectPublicKey}toSchema(){return new A({value:[this.algorithm.toSchema(),this.subjectPublicKey]})}toJSON(){if(!this.parsedKey)return{algorithm:this.algorithm.toJSON(),subjectPublicKey:this.subjectPublicKey.toJSON()};const e={};switch(this.algorithm.algorithmId){case"1.2.840.10045.2.1":e.kty="EC";break;case"1.2.840.113549.1.1.1":e.kty="RSA";break}const t=this.parsedKey.toJSON();return Object.assign(e,t),e}fromJSON(e){if("kty"in e){switch(e.kty.toUpperCase()){case"EC":this.parsedKey=new At({json:e}),this.algorithm=new V({algorithmId:"1.2.840.10045.2.1",algorithmParams:new J({value:this.parsedKey.namedCurve})});break;case"RSA":this.parsedKey=new Vn({json:e}),this.algorithm=new V({algorithmId:"1.2.840.113549.1.1.1",algorithmParams:new Fe});break;default:throw new Error('Invalid value for "kty" parameter: '.concat(e.kty))}this.subjectPublicKey=new re({valueHex:this.parsedKey.toSchema().toBER(!1)})}}async importKey(e,t=Q(!0)){try{if(!e)throw new Error("Need to provide publicKey input parameter");const s=await t.exportKey("spki",e),a=Le(s);try{this.fromSchema(a.result)}catch(n){throw new Error("Error during initializing object from schema")}}catch(s){const a=s instanceof Error?s.message:"".concat(s);throw new Error("Error during exporting public key: ".concat(a))}}}Ct.CLASS_NAME="PublicKeyInfo";const Zn="version",Qn="privateKey",Xt="namedCurve",dr="publicKey",n1=[Zn,Qn,Xt,dr];class Ht extends D{constructor(e={}){super(),this.version=f(e,Zn,Ht.defaultValues(Zn)),this.privateKey=f(e,Qn,Ht.defaultValues(Qn)),Xt in e&&(this.namedCurve=f(e,Xt,Ht.defaultValues(Xt))),dr in e&&(this.publicKey=f(e,dr,Ht.defaultValues(dr))),e.json&&this.fromJSON(e.json),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case Zn:return 1;case Qn:return new $;case Xt:return v;case dr:return new At;default:return super.defaultValues(e)}}static compareWithDefault(e,t){switch(e){case Zn:return t===Ht.defaultValues(e);case Qn:return t.isEqual(Ht.defaultValues(e));case Xt:return t===v;case dr:return At.compareWithDefault(Xt,t.namedCurve)&&At.compareWithDefault("x",t.x)&&At.compareWithDefault("y",t.y);default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||v,value:[new B({name:t.version||v}),new $({name:t.privateKey||v}),new I({optional:!0,idBlock:{tagClass:3,tagNumber:0},value:[new J({name:t.namedCurve||v})]}),new I({optional:!0,idBlock:{tagClass:3,tagNumber:1},value:[new re({name:t.publicKey||v})]})]})}fromSchema(e){T(e,n1);const t=R(e,e,Ht.schema({names:{version:Zn,privateKey:Qn,namedCurve:Xt,publicKey:dr}}));if(O.assertSchema(t,this.className),this.version=t.result.version.valueBlock.valueDec,this.privateKey=t.result.privateKey,Xt in t.result&&(this.namedCurve=t.result.namedCurve.valueBlock.toString()),dr in t.result){const s={schema:t.result.publicKey.valueBlock.valueHex};Xt in this&&(s.namedCurve=this.namedCurve),this.publicKey=new At(s)}}toSchema(){const e=[new B({value:this.version}),this.privateKey];return this.namedCurve&&e.push(new I({idBlock:{tagClass:3,tagNumber:0},value:[new J({value:this.namedCurve})]})),this.publicKey&&e.push(new I({idBlock:{tagClass:3,tagNumber:1},value:[new re({valueHex:this.publicKey.toSchema().toBER(!1)})]})),new A({value:e})}toJSON(){if(!this.namedCurve||Ht.compareWithDefault(Xt,this.namedCurve))throw new Error('Not enough information for making JSON: absent "namedCurve" value');const e=sa.find(this.namedCurve),t={crv:e?e.name:this.namedCurve,d:ce.ToBase64Url(this.privateKey.valueBlock.valueHexView)};if(this.publicKey){const s=this.publicKey.toJSON();t.x=s.x,t.y=s.y}return t}fromJSON(e){ne.assert("json",e,"crv","d");let t=0;const s=sa.find(e.crv);s&&(this.namedCurve=s.id,t=s.size);const a=ce.FromBase64Url(e.d);if(a.byteLength<t){const n=new ArrayBuffer(t),u=new Uint8Array(n),i=new Uint8Array(a);u.set(i,1),this.privateKey=new $({valueHex:n})}else this.privateKey=new $({valueHex:a.slice(0,t)});e.x&&e.y&&(this.publicKey=new At({json:e}))}}Ht.CLASS_NAME="ECPrivateKey";const yu="prime",vu="exponent",bu="coefficient",i1=[yu,vu,bu];class Rs extends D{constructor(e={}){super(),this.prime=f(e,yu,Rs.defaultValues(yu)),this.exponent=f(e,vu,Rs.defaultValues(vu)),this.coefficient=f(e,bu,Rs.defaultValues(bu)),e.json&&this.fromJSON(e.json),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case yu:return new B;case vu:return new B;case bu:return new B;default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||v,value:[new B({name:t.prime||v}),new B({name:t.exponent||v}),new B({name:t.coefficient||v})]})}fromSchema(e){T(e,i1);const t=R(e,e,Rs.schema({names:{prime:yu,exponent:vu,coefficient:bu}}));O.assertSchema(t,this.className),this.prime=t.result.prime.convertFromDER(),this.exponent=t.result.exponent.convertFromDER(),this.coefficient=t.result.coefficient.convertFromDER()}toSchema(){return new A({value:[this.prime.convertToDER(),this.exponent.convertToDER(),this.coefficient.convertToDER()]})}toJSON(){return{r:ce.ToBase64Url(this.prime.valueBlock.valueHexView),d:ce.ToBase64Url(this.exponent.valueBlock.valueHexView),t:ce.ToBase64Url(this.coefficient.valueBlock.valueHexView)}}fromJSON(e){ne.assert("json",e,"r","d","r"),this.prime=new B({valueHex:ce.FromBase64Url(e.r)}),this.exponent=new B({valueHex:ce.FromBase64Url(e.d)}),this.coefficient=new B({valueHex:ce.FromBase64Url(e.t)})}}Rs.CLASS_NAME="OtherPrimeInfo";const Su="version",Au="modulus",Nu="publicExponent",ku="privateExponent",Cu="prime1",Eu="prime2",xu="exponent1",Iu="exponent2",Vu="coefficient",ka="otherPrimeInfos",o1=[Su,Au,Nu,ku,Cu,Eu,xu,Iu,Vu,ka];class gt extends D{constructor(e={}){super(),this.version=f(e,Su,gt.defaultValues(Su)),this.modulus=f(e,Au,gt.defaultValues(Au)),this.publicExponent=f(e,Nu,gt.defaultValues(Nu)),this.privateExponent=f(e,ku,gt.defaultValues(ku)),this.prime1=f(e,Cu,gt.defaultValues(Cu)),this.prime2=f(e,Eu,gt.defaultValues(Eu)),this.exponent1=f(e,xu,gt.defaultValues(xu)),this.exponent2=f(e,Iu,gt.defaultValues(Iu)),this.coefficient=f(e,Vu,gt.defaultValues(Vu)),ka in e&&(this.otherPrimeInfos=f(e,ka,gt.defaultValues(ka))),e.json&&this.fromJSON(e.json),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case Su:return 0;case Au:return new B;case Nu:return new B;case ku:return new B;case Cu:return new B;case Eu:return new B;case xu:return new B;case Iu:return new B;case Vu:return new B;case ka:return[];default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||v,value:[new B({name:t.version||v}),new B({name:t.modulus||v}),new B({name:t.publicExponent||v}),new B({name:t.privateExponent||v}),new B({name:t.prime1||v}),new B({name:t.prime2||v}),new B({name:t.exponent1||v}),new B({name:t.exponent2||v}),new B({name:t.coefficient||v}),new A({optional:!0,value:[new Z({name:t.otherPrimeInfosName||v,value:Rs.schema(t.otherPrimeInfo||{})})]})]})}fromSchema(e){T(e,o1);const t=R(e,e,gt.schema({names:{version:Su,modulus:Au,publicExponent:Nu,privateExponent:ku,prime1:Cu,prime2:Eu,exponent1:xu,exponent2:Iu,coefficient:Vu,otherPrimeInfo:{names:{blockName:ka}}}}));O.assertSchema(t,this.className),this.version=t.result.version.valueBlock.valueDec,this.modulus=t.result.modulus.convertFromDER(256),this.publicExponent=t.result.publicExponent,this.privateExponent=t.result.privateExponent.convertFromDER(256),this.prime1=t.result.prime1.convertFromDER(128),this.prime2=t.result.prime2.convertFromDER(128),this.exponent1=t.result.exponent1.convertFromDER(128),this.exponent2=t.result.exponent2.convertFromDER(128),this.coefficient=t.result.coefficient.convertFromDER(128),ka in t.result&&(this.otherPrimeInfos=Array.from(t.result.otherPrimeInfos,s=>new Rs({schema:s})))}toSchema(){const e=[];return e.push(new B({value:this.version})),e.push(this.modulus.convertToDER()),e.push(this.publicExponent),e.push(this.privateExponent.convertToDER()),e.push(this.prime1.convertToDER()),e.push(this.prime2.convertToDER()),e.push(this.exponent1.convertToDER()),e.push(this.exponent2.convertToDER()),e.push(this.coefficient.convertToDER()),this.otherPrimeInfos&&e.push(new A({value:Array.from(this.otherPrimeInfos,t=>t.toSchema())})),new A({value:e})}toJSON(){const e={n:ce.ToBase64Url(this.modulus.valueBlock.valueHexView),e:ce.ToBase64Url(this.publicExponent.valueBlock.valueHexView),d:ce.ToBase64Url(this.privateExponent.valueBlock.valueHexView),p:ce.ToBase64Url(this.prime1.valueBlock.valueHexView),q:ce.ToBase64Url(this.prime2.valueBlock.valueHexView),dp:ce.ToBase64Url(this.exponent1.valueBlock.valueHexView),dq:ce.ToBase64Url(this.exponent2.valueBlock.valueHexView),qi:ce.ToBase64Url(this.coefficient.valueBlock.valueHexView)};return this.otherPrimeInfos&&(e.oth=Array.from(this.otherPrimeInfos,t=>t.toJSON())),e}fromJSON(e){ne.assert("json",e,"n","e","d","p","q","dp","dq","qi"),this.modulus=new B({valueHex:ce.FromBase64Url(e.n)}),this.publicExponent=new B({valueHex:ce.FromBase64Url(e.e)}),this.privateExponent=new B({valueHex:ce.FromBase64Url(e.d)}),this.prime1=new B({valueHex:ce.FromBase64Url(e.p)}),this.prime2=new B({valueHex:ce.FromBase64Url(e.q)}),this.exponent1=new B({valueHex:ce.FromBase64Url(e.dp)}),this.exponent2=new B({valueHex:ce.FromBase64Url(e.dq)}),this.coefficient=new B({valueHex:ce.FromBase64Url(e.qi)}),e.oth&&(this.otherPrimeInfos=Array.from(e.oth,t=>new Rs({json:t})))}}gt.CLASS_NAME="RSAPrivateKey";const Bu="version",Pu="privateKeyAlgorithm",Ou="privateKey",Ca="attributes",Sc="parsedKey",u1=[Bu,Pu,Ou,Ca];class Ft extends D{constructor(e={}){super(),this.version=f(e,Bu,Ft.defaultValues(Bu)),this.privateKeyAlgorithm=f(e,Pu,Ft.defaultValues(Pu)),this.privateKey=f(e,Ou,Ft.defaultValues(Ou)),Ca in e&&(this.attributes=f(e,Ca,Ft.defaultValues(Ca))),Sc in e&&(this.parsedKey=f(e,Sc,Ft.defaultValues(Sc))),e.json&&this.fromJSON(e.json),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case Bu:return 0;case Pu:return new V;case Ou:return new $;case Ca:return[];case Sc:return{};default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||v,value:[new B({name:t.version||v}),V.schema(t.privateKeyAlgorithm||{}),new $({name:t.privateKey||v}),new I({optional:!0,idBlock:{tagClass:3,tagNumber:0},value:[new Z({name:t.attributes||v,value:ge.schema()})]})]})}fromSchema(e){T(e,u1);const t=R(e,e,Ft.schema({names:{version:Bu,privateKeyAlgorithm:{names:{blockName:Pu}},privateKey:Ou,attributes:Ca}}));switch(O.assertSchema(t,this.className),this.version=t.result.version.valueBlock.valueDec,this.privateKeyAlgorithm=new V({schema:t.result.privateKeyAlgorithm}),this.privateKey=t.result.privateKey,Ca in t.result&&(this.attributes=Array.from(t.result.attributes,s=>new ge({schema:s}))),this.privateKeyAlgorithm.algorithmId){case"1.2.840.113549.1.1.1":{const s=Le(this.privateKey.valueBlock.valueHexView);s.offset!==-1&&(this.parsedKey=new gt({schema:s.result}))}break;case"1.2.840.10045.2.1":if("algorithmParams"in this.privateKeyAlgorithm&&this.privateKeyAlgorithm.algorithmParams instanceof J){const s=Le(this.privateKey.valueBlock.valueHexView);s.offset!==-1&&(this.parsedKey=new Ht({namedCurve:this.privateKeyAlgorithm.algorithmParams.valueBlock.toString(),schema:s.result}))}break}}toSchema(){const e=[new B({value:this.version}),this.privateKeyAlgorithm.toSchema(),this.privateKey];return this.attributes&&e.push(new I({optional:!0,idBlock:{tagClass:3,tagNumber:0},value:Array.from(this.attributes,t=>t.toSchema())})),new A({value:e})}toJSON(){if(!this.parsedKey){const s={version:this.version,privateKeyAlgorithm:this.privateKeyAlgorithm.toJSON(),privateKey:this.privateKey.toJSON()};return this.attributes&&(s.attributes=Array.from(this.attributes,a=>a.toJSON())),s}const e={};switch(this.privateKeyAlgorithm.algorithmId){case"1.2.840.10045.2.1":e.kty="EC";break;case"1.2.840.113549.1.1.1":e.kty="RSA";break}const t=this.parsedKey.toJSON();return Object.assign(e,t),e}fromJSON(e){if("kty"in e){switch(e.kty.toUpperCase()){case"EC":this.parsedKey=new Ht({json:e}),this.privateKeyAlgorithm=new V({algorithmId:"1.2.840.10045.2.1",algorithmParams:new J({value:this.parsedKey.namedCurve})});break;case"RSA":this.parsedKey=new gt({json:e}),this.privateKeyAlgorithm=new V({algorithmId:"1.2.840.113549.1.1.1",algorithmParams:new Fe});break;default:throw new Error('Invalid value for "kty" parameter: '.concat(e.kty))}this.privateKey=new $({valueHex:this.parsedKey.toSchema().toBER(!1)})}}}Ft.CLASS_NAME="PrivateKeyInfo";const Yn="contentType",ei="contentEncryptionAlgorithm",Ea="encryptedContent",l1=[Yn,ei,Ea],tp=1024;class Oe extends D{constructor(e={}){if(super(),this.contentType=f(e,Yn,Oe.defaultValues(Yn)),this.contentEncryptionAlgorithm=f(e,ei,Oe.defaultValues(ei)),Ea in e&&e.encryptedContent&&(this.encryptedContent=e.encryptedContent,this.encryptedContent.idBlock.tagClass===1&&this.encryptedContent.idBlock.tagNumber===4&&this.encryptedContent.idBlock.isConstructed===!1&&!e.disableSplit)){const t=new $({idBlock:{isConstructed:!0},isConstructed:!0});let s=0;const a=this.encryptedContent.valueBlock.valueHexView.slice().buffer;let n=a.byteLength;for(;n>0;){const u=new Uint8Array(a,s,s+tp>a.byteLength?a.byteLength-s:tp),i=new ArrayBuffer(u.length),l=new Uint8Array(i);for(let o=0;o<l.length;o++)l[o]=u[o];t.valueBlock.value.push(new $({valueHex:i})),n-=u.length,s+=u.length}this.encryptedContent=t}e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case Yn:return v;case ei:return new V;case Ea:return new $;default:return super.defaultValues(e)}}static compareWithDefault(e,t){switch(e){case Yn:return t===v;case ei:return t.algorithmId===v&&!("algorithmParams"in t);case Ea:return t.isEqual(Oe.defaultValues(Ea));default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||v,value:[new J({name:t.contentType||v}),V.schema(t.contentEncryptionAlgorithm||{}),new Ne({value:[new I({name:t.encryptedContent||v,idBlock:{tagClass:3,tagNumber:0},value:[new Z({value:new $})]}),new _({name:t.encryptedContent||v,idBlock:{tagClass:3,tagNumber:0}})]})]})}fromSchema(e){T(e,l1);const t=R(e,e,Oe.schema({names:{contentType:Yn,contentEncryptionAlgorithm:{names:{blockName:ei}},encryptedContent:Ea}}));O.assertSchema(t,this.className),this.contentType=t.result.contentType.valueBlock.toString(),this.contentEncryptionAlgorithm=new V({schema:t.result.contentEncryptionAlgorithm}),Ea in t.result&&(this.encryptedContent=t.result.encryptedContent,this.encryptedContent.idBlock.tagClass=1,this.encryptedContent.idBlock.tagNumber=4)}toSchema(){const e={isIndefiniteForm:!1},t=[];if(t.push(new J({value:this.contentType})),t.push(this.contentEncryptionAlgorithm.toSchema()),this.encryptedContent){e.isIndefiniteForm=this.encryptedContent.idBlock.isConstructed;const s=this.encryptedContent;s.idBlock.tagClass=3,s.idBlock.tagNumber=0,s.lenBlock.isIndefiniteForm=this.encryptedContent.idBlock.isConstructed,t.push(s)}return new A({lenBlock:e,value:t})}toJSON(){const e={contentType:this.contentType,contentEncryptionAlgorithm:this.contentEncryptionAlgorithm.toJSON()};return this.encryptedContent&&(e.encryptedContent=this.encryptedContent.toJSON()),e}getEncryptedContent(){if(!this.encryptedContent)throw new Error("Parameter 'encryptedContent' is undefined");return $.prototype.getValue.call(this.encryptedContent)}}Oe.CLASS_NAME="EncryptedContentInfo";const pr="hashAlgorithm",gr="maskGenAlgorithm",wr="saltLength",yr="trailerField",c1=[pr,gr,wr,yr];class tt extends D{constructor(e={}){super(),this.hashAlgorithm=f(e,pr,tt.defaultValues(pr)),this.maskGenAlgorithm=f(e,gr,tt.defaultValues(gr)),this.saltLength=f(e,wr,tt.defaultValues(wr)),this.trailerField=f(e,yr,tt.defaultValues(yr)),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case pr:return new V({algorithmId:"1.3.14.3.2.26",algorithmParams:new Fe});case gr:return new V({algorithmId:"1.2.840.113549.1.1.8",algorithmParams:new V({algorithmId:"1.3.14.3.2.26",algorithmParams:new Fe}).toSchema()});case wr:return 20;case yr:return 1;default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||v,value:[new I({idBlock:{tagClass:3,tagNumber:0},optional:!0,value:[V.schema(t.hashAlgorithm||{})]}),new I({idBlock:{tagClass:3,tagNumber:1},optional:!0,value:[V.schema(t.maskGenAlgorithm||{})]}),new I({idBlock:{tagClass:3,tagNumber:2},optional:!0,value:[new B({name:t.saltLength||v})]}),new I({idBlock:{tagClass:3,tagNumber:3},optional:!0,value:[new B({name:t.trailerField||v})]})]})}fromSchema(e){T(e,c1);const t=R(e,e,tt.schema({names:{hashAlgorithm:{names:{blockName:pr}},maskGenAlgorithm:{names:{blockName:gr}},saltLength:wr,trailerField:yr}}));O.assertSchema(t,this.className),pr in t.result&&(this.hashAlgorithm=new V({schema:t.result.hashAlgorithm})),gr in t.result&&(this.maskGenAlgorithm=new V({schema:t.result.maskGenAlgorithm})),wr in t.result&&(this.saltLength=t.result.saltLength.valueBlock.valueDec),yr in t.result&&(this.trailerField=t.result.trailerField.valueBlock.valueDec)}toSchema(){const e=[];return this.hashAlgorithm.isEqual(tt.defaultValues(pr))||e.push(new I({idBlock:{tagClass:3,tagNumber:0},value:[this.hashAlgorithm.toSchema()]})),this.maskGenAlgorithm.isEqual(tt.defaultValues(gr))||e.push(new I({idBlock:{tagClass:3,tagNumber:1},value:[this.maskGenAlgorithm.toSchema()]})),this.saltLength!==tt.defaultValues(wr)&&e.push(new I({idBlock:{tagClass:3,tagNumber:2},value:[new B({value:this.saltLength})]})),this.trailerField!==tt.defaultValues(yr)&&e.push(new I({idBlock:{tagClass:3,tagNumber:3},value:[new B({value:this.trailerField})]})),new A({value:e})}toJSON(){const e={};return this.hashAlgorithm.isEqual(tt.defaultValues(pr))||(e.hashAlgorithm=this.hashAlgorithm.toJSON()),this.maskGenAlgorithm.isEqual(tt.defaultValues(gr))||(e.maskGenAlgorithm=this.maskGenAlgorithm.toJSON()),this.saltLength!==tt.defaultValues(wr)&&(e.saltLength=this.saltLength),this.trailerField!==tt.defaultValues(yr)&&(e.trailerField=this.trailerField),e}}tt.CLASS_NAME="RSASSAPSSParams";const ti="salt",Du="iterationCount",Zt="keyLength",ks="prf",h1=[ti,Du,Zt,ks];class mt extends D{constructor(e={}){super(),this.salt=f(e,ti,mt.defaultValues(ti)),this.iterationCount=f(e,Du,mt.defaultValues(Du)),Zt in e&&(this.keyLength=f(e,Zt,mt.defaultValues(Zt))),ks in e&&(this.prf=f(e,ks,mt.defaultValues(ks))),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case ti:return{};case Du:return-1;case Zt:return 0;case ks:return new V({algorithmId:"1.3.14.3.2.26",algorithmParams:new Fe});default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||v,value:[new Ne({value:[new $({name:t.saltPrimitive||v}),V.schema(t.saltConstructed||{})]}),new B({name:t.iterationCount||v}),new B({name:t.keyLength||v,optional:!0}),V.schema(t.prf||{names:{optional:!0}})]})}fromSchema(e){T(e,h1);const t=R(e,e,mt.schema({names:{saltPrimitive:ti,saltConstructed:{names:{blockName:ti}},iterationCount:Du,keyLength:Zt,prf:{names:{blockName:ks,optional:!0}}}}));O.assertSchema(t,this.className),this.salt=t.result.salt,this.iterationCount=t.result.iterationCount.valueBlock.valueDec,Zt in t.result&&(this.keyLength=t.result.keyLength.valueBlock.valueDec),ks in t.result&&(this.prf=new V({schema:t.result.prf}))}toSchema(){const e=[];return e.push(this.salt),e.push(new B({value:this.iterationCount})),Zt in this&&mt.defaultValues(Zt)!==this.keyLength&&e.push(new B({value:this.keyLength})),this.prf&&mt.defaultValues(ks).isEqual(this.prf)===!1&&e.push(this.prf.toSchema()),new A({value:e})}toJSON(){const e={salt:this.salt.toJSON(),iterationCount:this.iterationCount};return Zt in this&&mt.defaultValues(Zt)!==this.keyLength&&(e.keyLength=this.keyLength),this.prf&&mt.defaultValues(ks).isEqual(this.prf)===!1&&(e.prf=this.prf.toJSON()),e}}mt.CLASS_NAME="PBKDF2Params";const Tu="keyDerivationFunc",Ru="encryptionScheme",m1=[Tu,Ru];class Bn extends D{constructor(e={}){super(),this.keyDerivationFunc=f(e,Tu,Bn.defaultValues(Tu)),this.encryptionScheme=f(e,Ru,Bn.defaultValues(Ru)),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case Tu:return new V;case Ru:return new V;default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||v,value:[V.schema(t.keyDerivationFunc||{}),V.schema(t.encryptionScheme||{})]})}fromSchema(e){T(e,m1);const t=R(e,e,Bn.schema({names:{keyDerivationFunc:{names:{blockName:Tu}},encryptionScheme:{names:{blockName:Ru}}}}));O.assertSchema(t,this.className),this.keyDerivationFunc=new V({schema:t.result.keyDerivationFunc}),this.encryptionScheme=new V({schema:t.result.encryptionScheme})}toSchema(){return new A({value:[this.keyDerivationFunc.toSchema(),this.encryptionScheme.toSchema()]})}toJSON(){return{keyDerivationFunc:this.keyDerivationFunc.toJSON(),encryptionScheme:this.encryptionScheme.toJSON()}}}Bn.CLASS_NAME="PBES2Params";class f1{constructor(e){this.crypto=e.crypto,this.subtle="webkitSubtle"in e.crypto?e.crypto.webkitSubtle:e.crypto.subtle,this.name=f(e,"name",v)}async encrypt(...e){return this.subtle.encrypt(...e)}async decrypt(...e){return this.subtle.decrypt(...e)}sign(...e){return this.subtle.sign(...e)}async verify(...e){return this.subtle.verify(...e)}async digest(...e){return this.subtle.digest(...e)}async generateKey(...e){return this.subtle.generateKey(...e)}async deriveKey(...e){return this.subtle.deriveKey(...e)}async deriveBits(...e){return this.subtle.deriveBits(...e)}async wrapKey(...e){return this.subtle.wrapKey(...e)}async unwrapKey(...e){return this.subtle.unwrapKey(...e)}exportKey(...e){return this.subtle.exportKey(...e)}importKey(...e){return this.subtle.importKey(...e)}getRandomValues(e){return this.crypto.getRandomValues(e)}}async function sp(r,e,t,s,a){let n,u,i;switch(r.toUpperCase()){case"SHA-1":n=20,u=64,i=Lb;break;case"SHA-256":n=32,u=64,i=$b;break;case"SHA-384":n=48,u=128,i=h0;break;case"SHA-512":n=64,u=128,i=c0;break;default:throw new Error("Unsupported hashing algorithm")}const l=new Uint8Array(t);let o=new TextDecoder().decode(t);new TextEncoder().encode(o).some((b,N)=>b!==l[N])&&(o=String.fromCharCode(...l));const c=new Uint8Array(o.length*2+2),m=new DataView(c.buffer);for(let b=0;b<o.length;b++)m.setUint16(b*2,o.charCodeAt(b),!1);m.setUint16(o.length*2,0,!1);const h=new Uint8Array(u).fill(3),p=new Uint8Array(s),d=new Uint8Array(u*Math.ceil(p.length/u)).map((b,N)=>p[N%p.length]),w=new Uint8Array(u*Math.ceil(c.length/u)).map((b,N)=>c[N%c.length]);let y=new Uint8Array(d.length+w.length);y.set(d),y.set(w,d.length);const k=Math.ceil((e>>3)/n),g=[];for(let b=0;b<k;b++){let N=new Uint8Array(h.length+y.length);N.set(h),N.set(y,h.length);for(let C=0;C<a;C++)N=i(N);const S=new Uint8Array(u).map((C,P)=>N[P%N.length]),E=Math.ceil(p.length/u)+Math.ceil(c.length/u),x=[];for(let C=0;C<E;C++){const P=Array.from(y.slice(C*u,(C+1)*u));let K=511;for(let L=S.length-1;L>=0;L--)K>>=8,K+=S[L]+(P[L]||0),P[L]=K&255;x.push(...P)}y=new Uint8Array(x),g.push(...N)}return new Uint8Array(g.slice(0,e>>3)).buffer}function Ug(r){const e=typeof r=="string"?{name:r}:r;return"hash"in e?os(it({},e),{hash:Ug(e.hash)}):e}class nc extends f1{async importKey(e,t,s,a,n){var u,i,l,o,c,m;let h={};const p=Ug(s);switch(e.toLowerCase()){case"raw":return this.subtle.importKey("raw",t,s,a,n);case"spki":{const d=Le(pe.toArrayBuffer(t));O.assert(d,"keyData");const w=new Ct;try{w.fromSchema(d.result)}catch(y){throw new he("Incorrect keyData")}switch(p.name.toUpperCase()){case"RSA-PSS":{if(!p.hash)throw new ne("hash","algorithm.hash","Incorrect hash algorithm: Hash algorithm is missed");switch(p.hash.name.toUpperCase()){case"SHA-1":h.alg="PS1";break;case"SHA-256":h.alg="PS256";break;case"SHA-384":h.alg="PS384";break;case"SHA-512":h.alg="PS512";break;default:throw new Error("Incorrect hash algorithm: ".concat(p.hash.name.toUpperCase()))}}case"RSASSA-PKCS1-V1_5":{if(n=["verify"],h.kty="RSA",h.ext=a,h.key_ops=n,w.algorithm.algorithmId!=="1.2.840.113549.1.1.1")throw new Error("Incorrect public key algorithm: ".concat(w.algorithm.algorithmId));if(!h.alg){if(!p.hash)throw new ne("hash","algorithm.hash","Incorrect hash algorithm: Hash algorithm is missed");switch(p.hash.name.toUpperCase()){case"SHA-1":h.alg="RS1";break;case"SHA-256":h.alg="RS256";break;case"SHA-384":h.alg="RS384";break;case"SHA-512":h.alg="RS512";break;default:throw new Error("Incorrect hash algorithm: ".concat(p.hash.name.toUpperCase()))}}const y=w.toJSON();Object.assign(h,y)}break;case"ECDSA":n=["verify"];case"ECDH":{if(h={kty:"EC",ext:a,key_ops:n},w.algorithm.algorithmId!=="1.2.840.10045.2.1")throw new Error("Incorrect public key algorithm: ".concat(w.algorithm.algorithmId));const y=w.toJSON();Object.assign(h,y)}break;case"RSA-OAEP":{if(h.kty="RSA",h.ext=a,h.key_ops=n,this.name.toLowerCase()==="safari")h.alg="RSA-OAEP";else{if(!p.hash)throw new ne("hash","algorithm.hash","Incorrect hash algorithm: Hash algorithm is missed");switch(p.hash.name.toUpperCase()){case"SHA-1":h.alg="RSA-OAEP";break;case"SHA-256":h.alg="RSA-OAEP-256";break;case"SHA-384":h.alg="RSA-OAEP-384";break;case"SHA-512":h.alg="RSA-OAEP-512";break;default:throw new Error("Incorrect hash algorithm: ".concat(p.hash.name.toUpperCase()))}}const y=w.toJSON();Object.assign(h,y)}break;case"RSAES-PKCS1-V1_5":{h.kty="RSA",h.ext=a,h.key_ops=n,h.alg="PS1";const y=w.toJSON();Object.assign(h,y)}break;default:throw new Error("Incorrect algorithm name: ".concat(p.name.toUpperCase()))}}break;case"pkcs8":{const d=new Ft,w=Le(pe.toArrayBuffer(t));O.assert(w,"keyData");try{d.fromSchema(w.result)}catch(y){throw new Error("Incorrect keyData")}if(!d.parsedKey)throw new Error("Incorrect keyData");switch(p.name.toUpperCase()){case"RSA-PSS":switch((u=p.hash)===null||u===void 0?void 0:u.name.toUpperCase()){case"SHA-1":h.alg="PS1";break;case"SHA-256":h.alg="PS256";break;case"SHA-384":h.alg="PS384";break;case"SHA-512":h.alg="PS512";break;default:throw new Error("Incorrect hash algorithm: ".concat((i=p.hash)===null||i===void 0?void 0:i.name.toUpperCase()))}case"RSASSA-PKCS1-V1_5":{if(n=["sign"],h.kty="RSA",h.ext=a,h.key_ops=n,d.privateKeyAlgorithm.algorithmId!=="1.2.840.113549.1.1.1")throw new Error("Incorrect private key algorithm: ".concat(d.privateKeyAlgorithm.algorithmId));if(!("alg"in h))switch((l=p.hash)===null||l===void 0?void 0:l.name.toUpperCase()){case"SHA-1":h.alg="RS1";break;case"SHA-256":h.alg="RS256";break;case"SHA-384":h.alg="RS384";break;case"SHA-512":h.alg="RS512";break;default:throw new Error("Incorrect hash algorithm: ".concat((o=p.hash)===null||o===void 0?void 0:o.name.toUpperCase()))}const y=d.toJSON();Object.assign(h,y)}break;case"ECDSA":n=["sign"];case"ECDH":{if(h={kty:"EC",ext:a,key_ops:n},d.privateKeyAlgorithm.algorithmId!=="1.2.840.10045.2.1")throw new Error("Incorrect algorithm: ".concat(d.privateKeyAlgorithm.algorithmId));const y=d.toJSON();Object.assign(h,y)}break;case"RSA-OAEP":{if(h.kty="RSA",h.ext=a,h.key_ops=n,this.name.toLowerCase()==="safari")h.alg="RSA-OAEP";else switch((c=p.hash)===null||c===void 0?void 0:c.name.toUpperCase()){case"SHA-1":h.alg="RSA-OAEP";break;case"SHA-256":h.alg="RSA-OAEP-256";break;case"SHA-384":h.alg="RSA-OAEP-384";break;case"SHA-512":h.alg="RSA-OAEP-512";break;default:throw new Error("Incorrect hash algorithm: ".concat((m=p.hash)===null||m===void 0?void 0:m.name.toUpperCase()))}const y=d.toJSON();Object.assign(h,y)}break;case"RSAES-PKCS1-V1_5":{n=["decrypt"],h.kty="RSA",h.ext=a,h.key_ops=n,h.alg="PS1";const y=d.toJSON();Object.assign(h,y)}break;default:throw new Error("Incorrect algorithm name: ".concat(p.name.toUpperCase()))}}break;case"jwk":h=t;break;default:throw new Error("Incorrect format: ".concat(e))}if(this.name.toLowerCase()==="safari")try{return this.subtle.importKey("jwk",ko(JSON.stringify(h)),s,a,n)}catch(d){return this.subtle.importKey("jwk",h,s,a,n)}return this.subtle.importKey("jwk",h,s,a,n)}async exportKey(e,t){let s=await this.subtle.exportKey("jwk",t);switch(this.name.toLowerCase()==="safari"&&s instanceof ArrayBuffer&&(s=JSON.parse(Nh(s))),e.toLowerCase()){case"raw":return this.subtle.exportKey("raw",t);case"spki":{const a=new Ct;try{a.fromJSON(s)}catch(n){throw new Error("Incorrect key data")}return a.toSchema().toBER(!1)}case"pkcs8":{const a=new Ft;try{a.fromJSON(s)}catch(n){throw new Error("Incorrect key data")}return a.toSchema().toBER(!1)}case"jwk":return s;default:throw new Error("Incorrect format: ".concat(e))}}async convert(e,t,s,a,n,u){if(e.toLowerCase()===t.toLowerCase())return s;const i=await this.importKey(e,s,a,n,u);return this.exportKey(t,i)}getAlgorithmByOID(e,t=!1,s){switch(e){case"1.2.840.113549.1.1.1":return{name:"RSAES-PKCS1-v1_5"};case"1.2.840.113549.1.1.5":return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-1"}};case"1.2.840.113549.1.1.11":return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}};case"1.2.840.113549.1.1.12":return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-384"}};case"1.2.840.113549.1.1.13":return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-512"}};case"1.2.840.113549.1.1.10":return{name:"RSA-PSS"};case"1.2.840.113549.1.1.7":return{name:"RSA-OAEP"};case"1.2.840.10045.2.1":case"1.2.840.10045.4.1":return{name:"ECDSA",hash:{name:"SHA-1"}};case"1.2.840.10045.4.3.2":return{name:"ECDSA",hash:{name:"SHA-256"}};case"1.2.840.10045.4.3.3":return{name:"ECDSA",hash:{name:"SHA-384"}};case"1.2.840.10045.4.3.4":return{name:"ECDSA",hash:{name:"SHA-512"}};case"1.3.133.16.840.63.0.2":return{name:"ECDH",kdf:"SHA-1"};case"1.3.132.1.11.1":return{name:"ECDH",kdf:"SHA-256"};case"1.3.132.1.11.2":return{name:"ECDH",kdf:"SHA-384"};case"1.3.132.1.11.3":return{name:"ECDH",kdf:"SHA-512"};case"2.16.840.1.101.3.4.1.2":return{name:"AES-CBC",length:128};case"2.16.840.1.101.3.4.1.22":return{name:"AES-CBC",length:192};case"2.16.840.1.101.3.4.1.42":return{name:"AES-CBC",length:256};case"2.16.840.1.101.3.4.1.6":return{name:"AES-GCM",length:128};case"2.16.840.1.101.3.4.1.26":return{name:"AES-GCM",length:192};case"2.16.840.1.101.3.4.1.46":return{name:"AES-GCM",length:256};case"2.16.840.1.101.3.4.1.4":return{name:"AES-CFB",length:128};case"2.16.840.1.101.3.4.1.24":return{name:"AES-CFB",length:192};case"2.16.840.1.101.3.4.1.44":return{name:"AES-CFB",length:256};case"2.16.840.1.101.3.4.1.5":return{name:"AES-KW",length:128};case"2.16.840.1.101.3.4.1.25":return{name:"AES-KW",length:192};case"2.16.840.1.101.3.4.1.45":return{name:"AES-KW",length:256};case"1.2.840.113549.2.7":return{name:"HMAC",hash:{name:"SHA-1"}};case"1.2.840.113549.2.9":return{name:"HMAC",hash:{name:"SHA-256"}};case"1.2.840.113549.2.10":return{name:"HMAC",hash:{name:"SHA-384"}};case"1.2.840.113549.2.11":return{name:"HMAC",hash:{name:"SHA-512"}};case"1.2.840.113549.1.9.16.3.5":return{name:"DH"};case"1.3.14.3.2.26":return{name:"SHA-1"};case"2.16.840.1.101.3.4.2.1":return{name:"SHA-256"};case"2.16.840.1.101.3.4.2.2":return{name:"SHA-384"};case"2.16.840.1.101.3.4.2.3":return{name:"SHA-512"};case"1.2.840.113549.1.5.12":return{name:"PBKDF2"};case"1.2.840.10045.3.1.7":return{name:"P-256"};case"1.3.132.0.34":return{name:"P-384"};case"1.3.132.0.35":return{name:"P-521"}}if(t)throw new Error("Unsupported algorithm identifier ".concat(s?"for ".concat(s," "):v,": ").concat(e));return{}}getOIDByAlgorithm(e,t=!1,s){let a=v;switch(e.name.toUpperCase()){case"RSAES-PKCS1-V1_5":a="1.2.840.113549.1.1.1";break;case"RSASSA-PKCS1-V1_5":switch(e.hash.name.toUpperCase()){case"SHA-1":a="1.2.840.113549.1.1.5";break;case"SHA-256":a="1.2.840.113549.1.1.11";break;case"SHA-384":a="1.2.840.113549.1.1.12";break;case"SHA-512":a="1.2.840.113549.1.1.13";break}break;case"RSA-PSS":a="1.2.840.113549.1.1.10";break;case"RSA-OAEP":a="1.2.840.113549.1.1.7";break;case"ECDSA":switch(e.hash.name.toUpperCase()){case"SHA-1":a="1.2.840.10045.4.1";break;case"SHA-256":a="1.2.840.10045.4.3.2";break;case"SHA-384":a="1.2.840.10045.4.3.3";break;case"SHA-512":a="1.2.840.10045.4.3.4";break}break;case"ECDH":switch(e.kdf.toUpperCase()){case"SHA-1":a="1.3.133.16.840.63.0.2";break;case"SHA-256":a="1.3.132.1.11.1";break;case"SHA-384":a="1.3.132.1.11.2";break;case"SHA-512":a="1.3.132.1.11.3";break}break;case"AES-CTR":break;case"AES-CBC":switch(e.length){case 128:a="2.16.840.1.101.3.4.1.2";break;case 192:a="2.16.840.1.101.3.4.1.22";break;case 256:a="2.16.840.1.101.3.4.1.42";break}break;case"AES-CMAC":break;case"AES-GCM":switch(e.length){case 128:a="2.16.840.1.101.3.4.1.6";break;case 192:a="2.16.840.1.101.3.4.1.26";break;case 256:a="2.16.840.1.101.3.4.1.46";break}break;case"AES-CFB":switch(e.length){case 128:a="2.16.840.1.101.3.4.1.4";break;case 192:a="2.16.840.1.101.3.4.1.24";break;case 256:a="2.16.840.1.101.3.4.1.44";break}break;case"AES-KW":switch(e.length){case 128:a="2.16.840.1.101.3.4.1.5";break;case 192:a="2.16.840.1.101.3.4.1.25";break;case 256:a="2.16.840.1.101.3.4.1.45";break}break;case"HMAC":switch(e.hash.name.toUpperCase()){case"SHA-1":a="1.2.840.113549.2.7";break;case"SHA-256":a="1.2.840.113549.2.9";break;case"SHA-384":a="1.2.840.113549.2.10";break;case"SHA-512":a="1.2.840.113549.2.11";break}break;case"DH":a="1.2.840.113549.1.9.16.3.5";break;case"SHA-1":a="1.3.14.3.2.26";break;case"SHA-256":a="2.16.840.1.101.3.4.2.1";break;case"SHA-384":a="2.16.840.1.101.3.4.2.2";break;case"SHA-512":a="2.16.840.1.101.3.4.2.3";break;case"CONCAT":break;case"HKDF":break;case"PBKDF2":a="1.2.840.113549.1.5.12";break;case"P-256":a="1.2.840.10045.3.1.7";break;case"P-384":a="1.3.132.0.34";break;case"P-521":a="1.3.132.0.35";break}if(!a&&t)throw new Error("Unsupported algorithm ".concat(s?"for ".concat(s," "):v,": ").concat(e.name));return a}getAlgorithmParameters(e,t){let s={algorithm:{},usages:[]};switch(e.toUpperCase()){case"RSAES-PKCS1-V1_5":case"RSASSA-PKCS1-V1_5":switch(t.toLowerCase()){case"generatekey":s={algorithm:{name:"RSASSA-PKCS1-v1_5",modulusLength:2048,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},usages:["sign","verify"]};break;case"verify":case"sign":case"importkey":s={algorithm:{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},usages:["verify"]};break;case"exportkey":default:return{algorithm:{name:"RSASSA-PKCS1-v1_5"},usages:[]}}break;case"RSA-PSS":switch(t.toLowerCase()){case"sign":case"verify":s={algorithm:{name:"RSA-PSS",hash:{name:"SHA-1"},saltLength:20},usages:["sign","verify"]};break;case"generatekey":s={algorithm:{name:"RSA-PSS",modulusLength:2048,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-1"}},usages:["sign","verify"]};break;case"importkey":s={algorithm:{name:"RSA-PSS",hash:{name:"SHA-1"}},usages:["verify"]};break;case"exportkey":default:return{algorithm:{name:"RSA-PSS"},usages:[]}}break;case"RSA-OAEP":switch(t.toLowerCase()){case"encrypt":case"decrypt":s={algorithm:{name:"RSA-OAEP"},usages:["encrypt","decrypt"]};break;case"generatekey":s={algorithm:{name:"RSA-OAEP",modulusLength:2048,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},usages:["encrypt","decrypt","wrapKey","unwrapKey"]};break;case"importkey":s={algorithm:{name:"RSA-OAEP",hash:{name:"SHA-256"}},usages:["encrypt"]};break;case"exportkey":default:return{algorithm:{name:"RSA-OAEP"},usages:[]}}break;case"ECDSA":switch(t.toLowerCase()){case"generatekey":s={algorithm:{name:"ECDSA",namedCurve:"P-256"},usages:["sign","verify"]};break;case"importkey":s={algorithm:{name:"ECDSA",namedCurve:"P-256"},usages:["verify"]};break;case"verify":case"sign":s={algorithm:{name:"ECDSA",hash:{name:"SHA-256"}},usages:["sign"]};break;default:return{algorithm:{name:"ECDSA"},usages:[]}}break;case"ECDH":switch(t.toLowerCase()){case"exportkey":case"importkey":case"generatekey":s={algorithm:{name:"ECDH",namedCurve:"P-256"},usages:["deriveKey","deriveBits"]};break;case"derivekey":case"derivebits":s={algorithm:{name:"ECDH",namedCurve:"P-256",public:[]},usages:["encrypt","decrypt"]};break;default:return{algorithm:{name:"ECDH"},usages:[]}}break;case"AES-CTR":switch(t.toLowerCase()){case"importkey":case"exportkey":case"generatekey":s={algorithm:{name:"AES-CTR",length:256},usages:["encrypt","decrypt","wrapKey","unwrapKey"]};break;case"decrypt":case"encrypt":s={algorithm:{name:"AES-CTR",counter:new Uint8Array(16),length:10},usages:["encrypt","decrypt","wrapKey","unwrapKey"]};break;default:return{algorithm:{name:"AES-CTR"},usages:[]}}break;case"AES-CBC":switch(t.toLowerCase()){case"importkey":case"exportkey":case"generatekey":s={algorithm:{name:"AES-CBC",length:256},usages:["encrypt","decrypt","wrapKey","unwrapKey"]};break;case"decrypt":case"encrypt":s={algorithm:{name:"AES-CBC",iv:this.getRandomValues(new Uint8Array(16))},usages:["encrypt","decrypt","wrapKey","unwrapKey"]};break;default:return{algorithm:{name:"AES-CBC"},usages:[]}}break;case"AES-GCM":switch(t.toLowerCase()){case"importkey":case"exportkey":case"generatekey":s={algorithm:{name:"AES-GCM",length:256},usages:["encrypt","decrypt","wrapKey","unwrapKey"]};break;case"decrypt":case"encrypt":s={algorithm:{name:"AES-GCM",iv:this.getRandomValues(new Uint8Array(16))},usages:["encrypt","decrypt","wrapKey","unwrapKey"]};break;default:return{algorithm:{name:"AES-GCM"},usages:[]}}break;case"AES-KW":switch(t.toLowerCase()){case"importkey":case"exportkey":case"generatekey":case"wrapkey":case"unwrapkey":s={algorithm:{name:"AES-KW",length:256},usages:["wrapKey","unwrapKey"]};break;default:return{algorithm:{name:"AES-KW"},usages:[]}}break;case"HMAC":switch(t.toLowerCase()){case"sign":case"verify":s={algorithm:{name:"HMAC"},usages:["sign","verify"]};break;case"importkey":case"exportkey":case"generatekey":s={algorithm:{name:"HMAC",length:32,hash:{name:"SHA-256"}},usages:["sign","verify"]};break;default:return{algorithm:{name:"HMAC"},usages:[]}}break;case"HKDF":switch(t.toLowerCase()){case"derivekey":s={algorithm:{name:"HKDF",hash:"SHA-256",salt:new Uint8Array([]),info:new Uint8Array([])},usages:["encrypt","decrypt"]};break;default:return{algorithm:{name:"HKDF"},usages:[]}}break;case"PBKDF2":switch(t.toLowerCase()){case"derivekey":s={algorithm:{name:"PBKDF2",hash:{name:"SHA-256"},salt:new Uint8Array([]),iterations:1e4},usages:["encrypt","decrypt"]};break;default:return{algorithm:{name:"PBKDF2"},usages:[]}}break}return s}getHashAlgorithm(e){let t=v;switch(e.algorithmId){case"1.2.840.10045.4.1":case"1.2.840.113549.1.1.5":t="SHA-1";break;case"1.2.840.10045.4.3.2":case"1.2.840.113549.1.1.11":t="SHA-256";break;case"1.2.840.10045.4.3.3":case"1.2.840.113549.1.1.12":t="SHA-384";break;case"1.2.840.10045.4.3.4":case"1.2.840.113549.1.1.13":t="SHA-512";break;case"1.2.840.113549.1.1.10":try{const s=new tt({schema:e.algorithmParams});if(s.hashAlgorithm){const a=this.getAlgorithmByOID(s.hashAlgorithm.algorithmId);if("name"in a)t=a.name;else return v}else t="SHA-1"}catch(s){}break}return t}async encryptEncryptedContentInfo(e){ne.assert(e,"password","contentEncryptionAlgorithm","hmacHashAlgorithm","iterationCount","contentToEncrypt","contentToEncrypt","contentType");const t=this.getOIDByAlgorithm(e.contentEncryptionAlgorithm,!0,"contentEncryptionAlgorithm"),s=this.getOIDByAlgorithm({name:"PBKDF2"},!0,"PBKDF2"),a=this.getOIDByAlgorithm({name:"HMAC",hash:{name:e.hmacHashAlgorithm}},!0,"hmacHashAlgorithm"),n=new ArrayBuffer(16),u=new Uint8Array(n);this.getRandomValues(u);const i=new ArrayBuffer(64),l=new Uint8Array(i);this.getRandomValues(l);const o=new Uint8Array(e.contentToEncrypt),c=new mt({salt:new $({valueHex:i}),iterationCount:e.iterationCount,prf:new V({algorithmId:a,algorithmParams:new Fe})}),m=new Uint8Array(e.password),h=await this.importKey("raw",m,"PBKDF2",!1,["deriveKey"]),p=await this.deriveKey({name:"PBKDF2",hash:{name:e.hmacHashAlgorithm},salt:l,iterations:e.iterationCount},h,e.contentEncryptionAlgorithm,!1,["encrypt"]),d=await this.encrypt({name:e.contentEncryptionAlgorithm.name,iv:u},p,o),w=new Bn({keyDerivationFunc:new V({algorithmId:s,algorithmParams:c.toSchema()}),encryptionScheme:new V({algorithmId:t,algorithmParams:new $({valueHex:n})})});return new Oe({contentType:e.contentType,contentEncryptionAlgorithm:new V({algorithmId:"1.2.840.113549.1.5.13",algorithmParams:w.toSchema()}),encryptedContent:new $({valueHex:d})})}async decryptEncryptedContentInfo(e){if(ne.assert(e,"password","encryptedContentInfo"),e.encryptedContentInfo.contentEncryptionAlgorithm.algorithmId!=="1.2.840.113549.1.5.13")throw new Error('Unknown "contentEncryptionAlgorithm": '.concat(e.encryptedContentInfo.contentEncryptionAlgorithm.algorithmId));let t;try{t=new Bn({schema:e.encryptedContentInfo.contentEncryptionAlgorithm.algorithmParams})}catch(d){throw new Error('Incorrectly encoded "pbes2Parameters"')}let s;try{s=new mt({schema:t.keyDerivationFunc.algorithmParams})}catch(d){throw new Error('Incorrectly encoded "pbkdf2Params"')}const a=this.getAlgorithmByOID(t.encryptionScheme.algorithmId,!0),n=t.encryptionScheme.algorithmParams.valueBlock.valueHex,u=new Uint8Array(n),i=s.salt.valueBlock.valueHex,l=new Uint8Array(i),o=s.iterationCount;let c="SHA-1";s.prf&&(c=this.getAlgorithmByOID(s.prf.algorithmId,!0).hash.name);const m=await this.importKey("raw",e.password,"PBKDF2",!1,["deriveKey"]),h=await this.deriveKey({name:"PBKDF2",hash:{name:c},salt:l,iterations:o},m,a,!1,["decrypt"]),p=e.encryptedContentInfo.getEncryptedContent();return this.decrypt({name:a.name,iv:u},h,p)}async stampDataWithPassword(e){if(!(e instanceof Object))throw new Error('Parameters must have type "Object"');ne.assert(e,"password","hashAlgorithm","iterationCount","salt","contentToStamp");let t;switch(e.hashAlgorithm.toLowerCase()){case"sha-1":t=160;break;case"sha-256":t=256;break;case"sha-384":t=384;break;case"sha-512":t=512;break;default:throw new Error('Incorrect "parameters.hashAlgorithm" parameter: '.concat(e.hashAlgorithm))}const s={name:"HMAC",length:t,hash:{name:e.hashAlgorithm}},a=await sp(e.hashAlgorithm,t,e.password,e.salt,e.iterationCount),n=await this.importKey("raw",new Uint8Array(a),s,!1,["sign"]);return this.sign(s,n,new Uint8Array(e.contentToStamp))}async verifyDataStampedWithPassword(e){ne.assert(e,"password","hashAlgorithm","salt","iterationCount","contentToVerify","signatureToVerify");let t=0;switch(e.hashAlgorithm.toLowerCase()){case"sha-1":t=160;break;case"sha-256":t=256;break;case"sha-384":t=384;break;case"sha-512":t=512;break;default:throw new Error('Incorrect "parameters.hashAlgorithm" parameter: '.concat(e.hashAlgorithm))}const s={name:"HMAC",length:t,hash:{name:e.hashAlgorithm}},a=await sp(e.hashAlgorithm,t,e.password,e.salt,e.iterationCount),n=await this.importKey("raw",new Uint8Array(a),s,!1,["verify"]);return this.verify(s,n,new Uint8Array(e.signatureToVerify),new Uint8Array(e.contentToVerify))}async getSignatureParameters(e,t="SHA-1"){this.getOIDByAlgorithm({name:t},!0,"hashAlgorithm");const s=new V,a=this.getAlgorithmParameters(e.algorithm.name,"sign");if(!Object.keys(a.algorithm).length)throw new Error("Parameter 'algorithm' is empty");const n=a.algorithm;switch("hash"in e.algorithm&&e.algorithm.hash&&e.algorithm.hash.name?n.hash.name=e.algorithm.hash.name:n.hash.name=t,e.algorithm.name.toUpperCase()){case"RSASSA-PKCS1-V1_5":case"ECDSA":s.algorithmId=this.getOIDByAlgorithm(n,!0);break;case"RSA-PSS":{switch(n.hash.name.toUpperCase()){case"SHA-256":n.saltLength=32;break;case"SHA-384":n.saltLength=48;break;case"SHA-512":n.saltLength=64;break}const u={};if(n.hash.name.toUpperCase()!=="SHA-1"){const l=this.getOIDByAlgorithm({name:n.hash.name},!0,"hashAlgorithm");u.hashAlgorithm=new V({algorithmId:l,algorithmParams:new Fe}),u.maskGenAlgorithm=new V({algorithmId:"1.2.840.113549.1.1.8",algorithmParams:u.hashAlgorithm.toSchema()})}n.saltLength!==20&&(u.saltLength=n.saltLength);const i=new tt(u);s.algorithmId="1.2.840.113549.1.1.10",s.algorithmParams=i.toSchema()}break;default:throw new Error("Unsupported signature algorithm: ".concat(e.algorithm.name))}return{signatureAlgorithm:s,parameters:a}}async signWithPrivateKey(e,t,s){const a=await this.sign(s.algorithm,t,e);return s.algorithm.name==="ECDSA"?p1(a):a}fillPublicKeyParameters(e,t){const s={},a=this.getHashAlgorithm(t);if(a===v)throw new Error("Unsupported signature algorithm: ".concat(t.algorithmId));let n;t.algorithmId==="1.2.840.113549.1.1.10"?n=t.algorithmId:n=e.algorithm.algorithmId;const u=this.getAlgorithmByOID(n,!0);if(s.algorithm=this.getAlgorithmParameters(u.name,"importKey"),"hash"in s.algorithm.algorithm&&(s.algorithm.algorithm.hash.name=a),u.name==="ECDSA"){const i=e.algorithm;if(!i.algorithmParams)throw new Error("Algorithm parameters for ECDSA public key are missed");const l=i.algorithmParams;if("idBlock"in i.algorithmParams&&!(l.idBlock.tagClass===1&&l.idBlock.tagNumber===6))throw new Error("Incorrect type for ECDSA public key parameters");const o=this.getAlgorithmByOID(l.valueBlock.toString(),!0);s.algorithm.algorithm.namedCurve=o.name}return s}async getPublicKey(e,t,s){s||(s=this.fillPublicKeyParameters(e,t));const a=e.toSchema().toBER(!1);return this.importKey("spki",a,s.algorithm.algorithm,!0,s.algorithm.usages)}async verifyWithPublicKey(e,t,s,a,n){let u;if(n){const o={};let c;a.algorithmId==="1.2.840.113549.1.1.10"?c=a.algorithmId:c=s.algorithm.algorithmId;const m=this.getAlgorithmByOID(c,!0);if(o.algorithm=this.getAlgorithmParameters(m.name,"importKey"),"hash"in o.algorithm.algorithm&&(o.algorithm.algorithm.hash.name=n),m.name==="ECDSA"){let h=!1;if("algorithmParams"in s.algorithm&&"idBlock"in s.algorithm.algorithmParams&&s.algorithm.algorithmParams.idBlock.tagClass===1&&s.algorithm.algorithmParams.idBlock.tagNumber===6&&(h=!0),h===!1)throw new Error("Incorrect type for ECDSA public key parameters");const p=this.getAlgorithmByOID(s.algorithm.algorithmParams.valueBlock.toString(),!0);o.algorithm.algorithm.namedCurve=p.name}u=await this.getPublicKey(s,null,o)}else{if(n=this.getHashAlgorithm(a),!n)throw new Error("Unsupported signature algorithm: ".concat(a.algorithmId));u=await this.getPublicKey(s,a)}const i=this.getAlgorithmParameters(u.algorithm.name,"verify");"hash"in i.algorithm&&(i.algorithm.hash.name=n);let l=t.valueBlock.valueHexView;if(u.algorithm.name==="ECDSA"){const o=sa.find(u.algorithm.namedCurve);if(!o)throw new Error("Unsupported named curve in use");const c=Le(l);O.assert(c,"Signature value"),l=g1(c.result,o.size)}if(u.algorithm.name==="RSA-PSS"){const o=new tt({schema:a.algorithmParams});"saltLength"in o?i.algorithm.saltLength=o.saltLength:i.algorithm.saltLength=20;let c="SHA-1";"hashAlgorithm"in o&&(c=this.getAlgorithmByOID(o.hashAlgorithm.algorithmId,!0).name),i.algorithm.hash.name=c}return this.verify(i.algorithm,u,l,e)}}let jg={name:"none",crypto:null};function rp(r){return!!(r&&typeof r=="object"&&"crypto"in r)}function ap(r,...e){let t=null;if(e.length<2)e.length?t=e[0]:t=typeof self<"u"&&self.crypto?new nc({name:"browser",crypto:self.crypto}):null;else{const s=e[0],a=e[1];rp(a)?t=a:rp(s)?t=s:"subtle"in s&&"getRandomValues"in s&&(t=new nc({crypto:s}))}if(typeof Ge<"u"&&"pid"in Ge&&typeof It<"u"&&typeof window>"u"){if(typeof It[Ge.pid]>"u")It[Ge.pid]={};else if(typeof It[Ge.pid]!="object")throw new Error("Name global.".concat(Ge.pid," already exists and it is not an object"));if(typeof It[Ge.pid].pkijs>"u")It[Ge.pid].pkijs={};else if(typeof It[Ge.pid].pkijs!="object")throw new Error("Name global.".concat(Ge.pid,".pkijs already exists and it is not an object"));It[Ge.pid].pkijs.engine={name:r,crypto:t}}else jg={name:r,crypto:t}}function d1(){if(typeof Ge<"u"&&"pid"in Ge&&typeof It<"u"&&typeof window>"u"){let r;try{r=It[Ge.pid].pkijs.engine}catch(e){throw new Error("Please call 'setEngine' before call to 'getEngine'")}return r}return jg}function Q(r=!1){const e=d1();if(!e.crypto&&r)throw new Error("Unable to create WebCrypto object");return e.crypto}function p1(r){if(r.byteLength%2!==0)return Ue;const e=r.byteLength/2,t=new ArrayBuffer(e);new Uint8Array(t).set(new Uint8Array(r,0,e));const s=new B({valueHex:t}),a=new ArrayBuffer(e);new Uint8Array(a).set(new Uint8Array(r,e,e));const n=new B({valueHex:a});return new A({value:[s.convertToDER(),n.convertToDER()]}).toBER(!1)}function g1(r,e){if(!(r instanceof A&&r.valueBlock.value.length===2&&r.valueBlock.value[0]instanceof B&&r.valueBlock.value[1]instanceof B))return Ue;const t=r.valueBlock.value[0].convertFromDER().valueBlock.valueHexView,s=r.valueBlock.value[1].convertFromDER().valueBlock.valueHexView,a=new Uint8Array(e*2);return a.set(t,e-t.byteLength),a.set(s,2*e-s.byteLength),a.buffer}async function w1(r,e,t,s,a){switch(r.toUpperCase()){case"SHA-1":case"SHA-256":case"SHA-384":case"SHA-512":break;default:throw new he("Unknown hash function: ".concat(r))}if(he.assert(e,"zBuffer","ArrayBuffer"),e.byteLength===0)throw new he("'zBuffer' has zero length, error");if(he.assert(s,"SharedInfo","ArrayBuffer"),t>255)throw new he("Please set 'Counter' argument to value less or equal to 255");const n=new ArrayBuffer(4),u=new Uint8Array(n);u[0]=0,u[1]=0,u[2]=0,u[3]=t;let i=Ue;i=go(i,e),i=go(i,n),i=go(i,s);const l=await a.digest({name:r},i);return{counter:t,result:l}}async function np(r,e,t,s,a=Q(!0)){let n=0,u=1;switch(r.toUpperCase()){case"SHA-1":n=160;break;case"SHA-256":n=256;break;case"SHA-384":n=384;break;case"SHA-512":n=512;break;default:throw new he("Unknown hash function: ".concat(r))}if(he.assert(e,"Zbuffer","ArrayBuffer"),e.byteLength===0)throw new he("'Zbuffer' has zero length, error");he.assert(s,"SharedInfo","ArrayBuffer");const i=t/n;Math.floor(i)>0&&(u=Math.floor(i),i-u>0&&u++);const l=[];for(let h=1;h<=u;h++)l.push(await w1(r,e,h,s,a));let o=Ue,c=1,m=!0;for(;m;){m=!1;for(const h of l)if(h.counter===c){o=go(o,h.result),m=!0;break}c++}if(t>>=3,o.byteLength>t){const h=new ArrayBuffer(t),p=new Uint8Array(h),d=new Uint8Array(o);for(let w=0;w<t;w++)p[w]=d[w];return h}return o}const ym="version",vm="logID",bm="extensions",Sm="timestamp",Am="hashAlgorithm",Nm="signatureAlgorithm",km="signature",ip="none",op="md5",up="sha1",lp="sha224",cp="sha256",hp="sha384",mp="sha512",fp="anonymous",dp="rsa",pp="dsa",gp="ecdsa";class cs extends D{constructor(e={}){super(),this.version=f(e,ym,cs.defaultValues(ym)),this.logID=f(e,vm,cs.defaultValues(vm)),this.timestamp=f(e,Sm,cs.defaultValues(Sm)),this.extensions=f(e,bm,cs.defaultValues(bm)),this.hashAlgorithm=f(e,Am,cs.defaultValues(Am)),this.signatureAlgorithm=f(e,Nm,cs.defaultValues(Nm)),this.signature=f(e,km,cs.defaultValues(km)),"stream"in e&&e.stream&&this.fromStream(e.stream),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case ym:return 0;case vm:case bm:return Ue;case Sm:return new Date(0);case Am:case Nm:return v;case km:return new X;default:return super.defaultValues(e)}}fromSchema(e){if(!(e instanceof kh))throw new Error("Object's schema was not verified against input data for SignedCertificateTimestamp");const t=new ta({stream:new Ae({buffer:e.data})});this.fromStream(t)}fromStream(e){const t=e.getUint16();if(this.version=e.getBlock(1)[0],this.version===0){this.logID=new Uint8Array(e.getBlock(32)).buffer.slice(0),this.timestamp=new Date(cw(new Uint8Array(e.getBlock(8)),8));const s=e.getUint16();switch(this.extensions=new Uint8Array(e.getBlock(s)).buffer.slice(0),e.getBlock(1)[0]){case 0:this.hashAlgorithm=ip;break;case 1:this.hashAlgorithm=op;break;case 2:this.hashAlgorithm=up;break;case 3:this.hashAlgorithm=lp;break;case 4:this.hashAlgorithm=cp;break;case 5:this.hashAlgorithm=hp;break;case 6:this.hashAlgorithm=mp;break;default:throw new Error("Object's stream was not correct for SignedCertificateTimestamp")}switch(e.getBlock(1)[0]){case 0:this.signatureAlgorithm=fp;break;case 1:this.signatureAlgorithm=dp;break;case 2:this.signatureAlgorithm=pp;break;case 3:this.signatureAlgorithm=gp;break;default:throw new Error("Object's stream was not correct for SignedCertificateTimestamp")}const a=e.getUint16(),n=new Uint8Array(e.getBlock(a)).buffer.slice(0),u=Le(n);if(O.assert(u,"SignedCertificateTimestamp"),this.signature=u.result,t!==47+s+a)throw new Error("Object's stream was not correct for SignedCertificateTimestamp")}}toSchema(){const e=this.toStream();return new kh({data:e.stream.buffer})}toStream(){const e=new ta;e.appendUint16(47+this.extensions.byteLength+this.signature.valueBeforeDecodeView.byteLength),e.appendChar(this.version),e.appendView(new Uint8Array(this.logID));const t=new ArrayBuffer(8),s=new Uint8Array(t),a=yd(this.timestamp.valueOf(),8);s.set(new Uint8Array(a),8-a.byteLength),e.appendView(s),e.appendUint16(this.extensions.byteLength),this.extensions.byteLength&&e.appendView(new Uint8Array(this.extensions));let n;switch(this.hashAlgorithm.toLowerCase()){case ip:n=0;break;case op:n=1;break;case up:n=2;break;case lp:n=3;break;case cp:n=4;break;case hp:n=5;break;case mp:n=6;break;default:throw new Error("Incorrect data for hashAlgorithm: ".concat(this.hashAlgorithm))}e.appendChar(n);let u;switch(this.signatureAlgorithm.toLowerCase()){case fp:u=0;break;case dp:u=1;break;case pp:u=2;break;case gp:u=3;break;default:throw new Error("Incorrect data for signatureAlgorithm: ".concat(this.signatureAlgorithm))}e.appendChar(u);const i=this.signature.toBER(!1);return e.appendUint16(i.byteLength),e.appendView(new Uint8Array(i)),e}toJSON(){return{version:this.version,logID:vd(this.logID),timestamp:this.timestamp,extensions:vd(this.extensions),hashAlgorithm:this.hashAlgorithm,signatureAlgorithm:this.signatureAlgorithm,signature:this.signature.toJSON()}}async verify(e,t,s=0,a=Q(!0)){const n=_m(Nh(this.logID));let u=null;const i=new ta;for(const p of e)if(p.log_id===n){u=p.key;break}if(!u)throw new Error("Public key not found for CT with logId: ".concat(n));const l=ko(Ql(u)),o=Ct.fromBER(l);i.appendChar(0),i.appendChar(0);const c=new ArrayBuffer(8),m=new Uint8Array(c),h=yd(this.timestamp.valueOf(),8);return m.set(new Uint8Array(h),8-h.byteLength),i.appendView(m),i.appendUint16(s),s===0&&i.appendUint24(t.byteLength),i.appendView(new Uint8Array(t)),i.appendUint16(this.extensions.byteLength),this.extensions.byteLength!==0&&i.appendView(new Uint8Array(this.extensions)),a.verifyWithPublicKey(i.buffer.slice(0,i.length),new $({valueHex:this.signature.toBER(!1)}),o,{algorithmId:v},"SHA-256")}}cs.CLASS_NAME="SignedCertificateTimestamp";const Ac="timestamps";class Xh extends D{constructor(e={}){super(),this.timestamps=f(e,Ac,Xh.defaultValues(Ac)),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case Ac:return[];default:return super.defaultValues(e)}}static compareWithDefault(e,t){switch(e){case Ac:return t.length===0;default:return super.defaultValues(e)}}static schema(e={}){var t;const s=f(e,"names",{});return(t=s.optional)!==null&&t!==void 0||(s.optional=!1),new $({name:s.blockName||"SignedCertificateTimestampList",optional:s.optional})}fromSchema(e){if(!(e instanceof $))throw new Error("Object's schema was not verified against input data for SignedCertificateTimestampList");const t=new ta({stream:new Ae({buffer:e.valueBlock.valueHex})});if(t.getUint16()!==t.length)throw new Error("Object's schema was not verified against input data for SignedCertificateTimestampList");for(;t.length;)this.timestamps.push(new cs({stream:t}))}toSchema(){const e=new ta;let t=0;const s=[];for(const a of this.timestamps){const n=a.toStream();s.push(n),t+=n.stream.buffer.byteLength}e.appendUint16(t);for(const a of s)e.appendView(a.stream.view);return new $({valueHex:e.stream.buffer.slice(0)})}toJSON(){return{timestamps:Array.from(this.timestamps,e=>e.toJSON())}}}Xh.CLASS_NAME="SignedCertificateTimestampList";const Lu="attributes",y1=[Lu];class ic extends D{constructor(e={}){super(),this.attributes=f(e,Lu,ic.defaultValues(Lu)),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case Lu:return[];default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||v,value:[new Z({name:t.attributes||v,value:ge.schema()})]})}fromSchema(e){T(e,y1);const t=R(e,e,ic.schema({names:{attributes:Lu}}));O.assertSchema(t,this.className),this.attributes=Array.from(t.result.attributes,s=>new ge({schema:s}))}toSchema(){return new A({value:Array.from(this.attributes,e=>e.toSchema())})}toJSON(){return{attributes:Array.from(this.attributes,e=>e.toJSON())}}}ic.CLASS_NAME="SubjectDirectoryAttributes";class ve{static getItems(){return this.types||(this.types={},ve.register(Ag,"SubjectAltName",Co),ve.register(Ng,"IssuerAltName",Co),ve.register(Yf,"AuthorityKeyIdentifier",Xr),ve.register(Zf,"BasicConstraints",kn),ve.register(T0,"MicrosoftCaVersion",tc),ve.register(Ig,"CertificatePolicies",Eo),ve.register(I0,"CertificatePoliciesMicrosoft",Eo),ve.register(D0,"MicrosoftCertTemplateV2",fo),ve.register(xg,"CRLDistributionPoints",xo),ve.register(Qf,"FreshestCRL",xo),ve.register(V0,"ExtKeyUsage",sc),ve.register(Cg,"CertificateIssuer",qe),ve.register(ed,"AuthorityInfoAccess",Io),ve.register(P0,"SubjectInfoAccess",Io),ve.register(kg,"IssuingDistributionPoint",Ye),ve.register(Eg,"NameConstraints",yo),ve.register(Bg,"PolicyConstraints",vo),ve.register(Vg,"PolicyMappings",rc),ve.register(N0,"PrivateKeyUsagePeriod",bo),ve.register(R0,"QCStatements",ac),ve.register(O0,"SignedCertificateTimestampList",Xh),ve.register(b0,"SubjectDirectoryAttributes",ic)),this.types}static fromBER(e,t){const s=Le(t);if(s.offset===-1)return null;const a=this.find(e);if(a)try{return new a.type({schema:s.result})}catch(n){const u=new a.type;return u.parsingError="Incorrectly formatted value of extension ".concat(a.name," (").concat(e,")"),u}return s.result}static find(e){return this.getItems()[e]||null}static register(e,t,s){this.getItems()[e]={name:t,type:s}}}const Uu="extnID",vr="critical",ju="extnValue",Nc="parsedValue",v1=[Uu,vr,ju];class De extends D{get parsedValue(){if(this._parsedValue===void 0){const e=ve.fromBER(this.extnID,this.extnValue.valueBlock.valueHexView);this._parsedValue=e}return this._parsedValue||void 0}set parsedValue(e){this._parsedValue=e}constructor(e={}){super(),this.extnID=f(e,Uu,De.defaultValues(Uu)),this.critical=f(e,vr,De.defaultValues(vr)),ju in e?this.extnValue=new $({valueHex:e.extnValue}):this.extnValue=De.defaultValues(ju),Nc in e&&(this.parsedValue=f(e,Nc,De.defaultValues(Nc))),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case Uu:return v;case vr:return!1;case ju:return new $;case Nc:return{};default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||v,value:[new J({name:t.extnID||v}),new ia({name:t.critical||v,optional:!0}),new $({name:t.extnValue||v})]})}fromSchema(e){T(e,v1);const t=R(e,e,De.schema({names:{extnID:Uu,critical:vr,extnValue:ju}}));O.assertSchema(t,this.className),this.extnID=t.result.extnID.valueBlock.toString(),vr in t.result&&(this.critical=t.result.critical.valueBlock.value),this.extnValue=t.result.extnValue}toSchema(){const e=[];return e.push(new J({value:this.extnID})),this.critical!==De.defaultValues(vr)&&e.push(new ia({value:this.critical})),e.push(this.extnValue),new A({value:e})}toJSON(){const e={extnID:this.extnID,extnValue:this.extnValue.toJSON()};return this.critical!==De.defaultValues(vr)&&(e.critical=this.critical),this.parsedValue&&this.parsedValue.toJSON&&(e.parsedValue=this.parsedValue.toJSON()),e}}De.CLASS_NAME="Extension";const $u="extensions",b1=[$u];class je extends D{constructor(e={}){super(),this.extensions=f(e,$u,je.defaultValues($u)),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case $u:return[];default:return super.defaultValues(e)}}static schema(e={},t=!1){const s=f(e,"names",{});return new A({optional:t,name:s.blockName||v,value:[new Z({name:s.extensions||v,value:De.schema(s.extension||{})})]})}fromSchema(e){T(e,b1);const t=R(e,e,je.schema({names:{extensions:$u}}));O.assertSchema(t,this.className),this.extensions=Array.from(t.result.extensions,s=>new De({schema:s}))}toSchema(){return new A({value:Array.from(this.extensions,e=>e.toSchema())})}toJSON(){return{extensions:this.extensions.map(e=>e.toJSON())}}}je.CLASS_NAME="Extensions";const Ku="issuer",Hu="serialNumber",xa="issuerUID",S1=[Ku,Hu,xa];class kt extends D{constructor(e={}){super(),this.issuer=f(e,Ku,kt.defaultValues(Ku)),this.serialNumber=f(e,Hu,kt.defaultValues(Hu)),xa in e&&(this.issuerUID=f(e,xa,kt.defaultValues(xa))),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case Ku:return new qe;case Hu:return new B;case xa:return new re;default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||v,value:[qe.schema(t.issuer||{}),new B({name:t.serialNumber||v}),new re({optional:!0,name:t.issuerUID||v})]})}fromSchema(e){T(e,S1);const t=R(e,e,kt.schema({names:{issuer:{names:{blockName:Ku}},serialNumber:Hu,issuerUID:xa}}));O.assertSchema(t,this.className),this.issuer=new qe({schema:t.result.issuer}),this.serialNumber=t.result.serialNumber,xa in t.result&&(this.issuerUID=t.result.issuerUID)}toSchema(){const e=new A({value:[this.issuer.toSchema(),this.serialNumber]});return this.issuerUID&&e.valueBlock.value.push(this.issuerUID),e}toJSON(){const e={issuer:this.issuer.toJSON(),serialNumber:this.serialNumber.toJSON()};return this.issuerUID&&(e.issuerUID=this.issuerUID.toJSON()),e}}kt.CLASS_NAME="IssuerSerial";const Mu="version",Ia="baseCertificateID",Va="subjectName",Fu="issuer",Ju="signature",qu="serialNumber",Wu="attrCertValidityPeriod",Gu="attributes",Ba="issuerUniqueID",Pa="extensions",A1=[Mu,Ia,Va,Fu,Ju,qu,Wu,Gu,Ba,Pa];class ct extends D{constructor(e={}){super(),this.version=f(e,Mu,ct.defaultValues(Mu)),Ia in e&&(this.baseCertificateID=f(e,Ia,ct.defaultValues(Ia))),Va in e&&(this.subjectName=f(e,Va,ct.defaultValues(Va))),this.issuer=f(e,Fu,ct.defaultValues(Fu)),this.signature=f(e,Ju,ct.defaultValues(Ju)),this.serialNumber=f(e,qu,ct.defaultValues(qu)),this.attrCertValidityPeriod=f(e,Wu,ct.defaultValues(Wu)),this.attributes=f(e,Gu,ct.defaultValues(Gu)),Ba in e&&(this.issuerUniqueID=f(e,Ba,ct.defaultValues(Ba))),Pa in e&&(this.extensions=f(e,Pa,ct.defaultValues(Pa))),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case Mu:return 0;case Ia:return new kt;case Va:return new qe;case Fu:return new qe;case Ju:return new V;case qu:return new B;case Wu:return new as;case Gu:return[];case Ba:return new re;case Pa:return new je;default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||v,value:[new B({name:t.version||v}),new Ne({value:[new I({name:t.baseCertificateID||v,idBlock:{tagClass:3,tagNumber:0},value:kt.schema().valueBlock.value}),new I({name:t.subjectName||v,idBlock:{tagClass:3,tagNumber:1},value:qe.schema().valueBlock.value})]}),qe.schema({names:{blockName:t.issuer||v}}),V.schema(t.signature||{}),new B({name:t.serialNumber||v}),as.schema(t.attrCertValidityPeriod||{}),new A({name:t.attributes||v,value:[new Z({value:ge.schema()})]}),new re({optional:!0,name:t.issuerUniqueID||v}),je.schema(t.extensions||{},!0)]})}fromSchema(e){T(e,A1);const t=R(e,e,ct.schema({names:{version:Mu,baseCertificateID:Ia,subjectName:Va,issuer:Fu,signature:{names:{blockName:Ju}},serialNumber:qu,attrCertValidityPeriod:{names:{blockName:Wu}},attributes:Gu,issuerUniqueID:Ba,extensions:{names:{blockName:Pa}}}}));O.assertSchema(t,this.className),this.version=t.result.version.valueBlock.valueDec,Ia in t.result&&(this.baseCertificateID=new kt({schema:new A({value:t.result.baseCertificateID.valueBlock.value})})),Va in t.result&&(this.subjectName=new qe({schema:new A({value:t.result.subjectName.valueBlock.value})})),this.issuer=t.result.issuer,this.signature=new V({schema:t.result.signature}),this.serialNumber=t.result.serialNumber,this.attrCertValidityPeriod=new as({schema:t.result.attrCertValidityPeriod}),this.attributes=Array.from(t.result.attributes.valueBlock.value,s=>new ge({schema:s})),Ba in t.result&&(this.issuerUniqueID=t.result.issuerUniqueID),Pa in t.result&&(this.extensions=new je({schema:t.result.extensions}))}toSchema(){const e=new A({value:[new B({value:this.version})]});return this.baseCertificateID&&e.valueBlock.value.push(new I({idBlock:{tagClass:3,tagNumber:0},value:this.baseCertificateID.toSchema().valueBlock.value})),this.subjectName&&e.valueBlock.value.push(new I({idBlock:{tagClass:3,tagNumber:1},value:this.subjectName.toSchema().valueBlock.value})),e.valueBlock.value.push(this.issuer.toSchema()),e.valueBlock.value.push(this.signature.toSchema()),e.valueBlock.value.push(this.serialNumber),e.valueBlock.value.push(this.attrCertValidityPeriod.toSchema()),e.valueBlock.value.push(new A({value:Array.from(this.attributes,t=>t.toSchema())})),this.issuerUniqueID&&e.valueBlock.value.push(this.issuerUniqueID),this.extensions&&e.valueBlock.value.push(this.extensions.toSchema()),e}toJSON(){const e={version:this.version};return this.baseCertificateID&&(e.baseCertificateID=this.baseCertificateID.toJSON()),this.subjectName&&(e.subjectName=this.subjectName.toJSON()),e.issuer=this.issuer.toJSON(),e.signature=this.signature.toJSON(),e.serialNumber=this.serialNumber.toJSON(),e.attrCertValidityPeriod=this.attrCertValidityPeriod.toJSON(),e.attributes=Array.from(this.attributes,t=>t.toJSON()),this.issuerUniqueID&&(e.issuerUniqueID=this.issuerUniqueID.toJSON()),this.extensions&&(e.extensions=this.extensions.toJSON()),e}}ct.CLASS_NAME="AttributeCertificateInfoV1";const zu="acinfo",_u="signatureAlgorithm",Xu="signatureValue",N1=[zu,Xu,_u];class Ls extends D{constructor(e={}){super(),this.acinfo=f(e,zu,Ls.defaultValues(zu)),this.signatureAlgorithm=f(e,_u,Ls.defaultValues(_u)),this.signatureValue=f(e,Xu,Ls.defaultValues(Xu)),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case zu:return new ct;case _u:return new V;case Xu:return new re;default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||v,value:[ct.schema(t.acinfo||{}),V.schema(t.signatureAlgorithm||{}),new re({name:t.signatureValue||v})]})}fromSchema(e){T(e,N1);const t=R(e,e,Ls.schema({names:{acinfo:{names:{blockName:zu}},signatureAlgorithm:{names:{blockName:_u}},signatureValue:Xu}}));O.assertSchema(t,this.className),this.acinfo=new ct({schema:t.result.acinfo}),this.signatureAlgorithm=new V({schema:t.result.signatureAlgorithm}),this.signatureValue=t.result.signatureValue}toSchema(){return new A({value:[this.acinfo.toSchema(),this.signatureAlgorithm.toSchema(),this.signatureValue]})}toJSON(){return{acinfo:this.acinfo.toJSON(),signatureAlgorithm:this.signatureAlgorithm.toJSON(),signatureValue:this.signatureValue.toJSON()}}}Ls.CLASS_NAME="AttributeCertificateV1";const Zu="digestedObjectType",Oa="otherObjectTypeID",Qu="digestAlgorithm",Yu="objectDigest",k1=[Zu,Oa,Qu,Yu];class Rt extends D{constructor(e={}){super(),this.digestedObjectType=f(e,Zu,Rt.defaultValues(Zu)),Oa in e&&(this.otherObjectTypeID=f(e,Oa,Rt.defaultValues(Oa))),this.digestAlgorithm=f(e,Qu,Rt.defaultValues(Qu)),this.objectDigest=f(e,Yu,Rt.defaultValues(Yu)),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case Zu:return new Yl;case Oa:return new J;case Qu:return new V;case Yu:return new re;default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||v,value:[new Yl({name:t.digestedObjectType||v}),new J({optional:!0,name:t.otherObjectTypeID||v}),V.schema(t.digestAlgorithm||{}),new re({name:t.objectDigest||v})]})}fromSchema(e){T(e,k1);const t=R(e,e,Rt.schema({names:{digestedObjectType:Zu,otherObjectTypeID:Oa,digestAlgorithm:{names:{blockName:Qu}},objectDigest:Yu}}));O.assertSchema(t,this.className),this.digestedObjectType=t.result.digestedObjectType,Oa in t.result&&(this.otherObjectTypeID=t.result.otherObjectTypeID),this.digestAlgorithm=new V({schema:t.result.digestAlgorithm}),this.objectDigest=t.result.objectDigest}toSchema(){const e=new A({value:[this.digestedObjectType]});return this.otherObjectTypeID&&e.valueBlock.value.push(this.otherObjectTypeID),e.valueBlock.value.push(this.digestAlgorithm.toSchema()),e.valueBlock.value.push(this.objectDigest),e}toJSON(){const e={digestedObjectType:this.digestedObjectType.toJSON(),digestAlgorithm:this.digestAlgorithm.toJSON(),objectDigest:this.objectDigest.toJSON()};return this.otherObjectTypeID&&(e.otherObjectTypeID=this.otherObjectTypeID.toJSON()),e}}Rt.CLASS_NAME="ObjectDigestInfo";const Da="issuerName",Ta="baseCertificateID",Ra="objectDigestInfo",C1=[Da,Ta,Ra];class Qr extends D{constructor(e={}){super(),Da in e&&(this.issuerName=f(e,Da,Qr.defaultValues(Da))),Ta in e&&(this.baseCertificateID=f(e,Ta,Qr.defaultValues(Ta))),Ra in e&&(this.objectDigestInfo=f(e,Ra,Qr.defaultValues(Ra))),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case Da:return new qe;case Ta:return new kt;case Ra:return new Rt;default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||v,value:[qe.schema({names:{blockName:t.issuerName}},!0),new I({optional:!0,name:t.baseCertificateID||v,idBlock:{tagClass:3,tagNumber:0},value:kt.schema().valueBlock.value}),new I({optional:!0,name:t.objectDigestInfo||v,idBlock:{tagClass:3,tagNumber:1},value:Rt.schema().valueBlock.value})]})}fromSchema(e){T(e,C1);const t=R(e,e,Qr.schema({names:{issuerName:Da,baseCertificateID:Ta,objectDigestInfo:Ra}}));O.assertSchema(t,this.className),Da in t.result&&(this.issuerName=new qe({schema:t.result.issuerName})),Ta in t.result&&(this.baseCertificateID=new kt({schema:new A({value:t.result.baseCertificateID.valueBlock.value})})),Ra in t.result&&(this.objectDigestInfo=new Rt({schema:new A({value:t.result.objectDigestInfo.valueBlock.value})}))}toSchema(){const e=new A;return this.issuerName&&e.valueBlock.value.push(this.issuerName.toSchema()),this.baseCertificateID&&e.valueBlock.value.push(new I({idBlock:{tagClass:3,tagNumber:0},value:this.baseCertificateID.toSchema().valueBlock.value})),this.objectDigestInfo&&e.valueBlock.value.push(new I({idBlock:{tagClass:3,tagNumber:1},value:this.objectDigestInfo.toSchema().valueBlock.value})),e}toJSON(){const e={};return this.issuerName&&(e.issuerName=this.issuerName.toJSON()),this.baseCertificateID&&(e.baseCertificateID=this.baseCertificateID.toJSON()),this.objectDigestInfo&&(e.objectDigestInfo=this.objectDigestInfo.toJSON()),e}}Qr.CLASS_NAME="V2Form";const La="baseCertificateID",Ua="entityName",ja="objectDigestInfo",E1=[La,Ua,ja];class Us extends D{constructor(e={}){super(),La in e&&(this.baseCertificateID=f(e,La,Us.defaultValues(La))),Ua in e&&(this.entityName=f(e,Ua,Us.defaultValues(Ua))),ja in e&&(this.objectDigestInfo=f(e,ja,Us.defaultValues(ja))),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case La:return new kt;case Ua:return new qe;case ja:return new Rt;default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||v,value:[new I({optional:!0,name:t.baseCertificateID||v,idBlock:{tagClass:3,tagNumber:0},value:kt.schema().valueBlock.value}),new I({optional:!0,name:t.entityName||v,idBlock:{tagClass:3,tagNumber:1},value:qe.schema().valueBlock.value}),new I({optional:!0,name:t.objectDigestInfo||v,idBlock:{tagClass:3,tagNumber:2},value:Rt.schema().valueBlock.value})]})}fromSchema(e){T(e,E1);const t=R(e,e,Us.schema({names:{baseCertificateID:La,entityName:Ua,objectDigestInfo:ja}}));O.assertSchema(t,this.className),La in t.result&&(this.baseCertificateID=new kt({schema:new A({value:t.result.baseCertificateID.valueBlock.value})})),Ua in t.result&&(this.entityName=new qe({schema:new A({value:t.result.entityName.valueBlock.value})})),ja in t.result&&(this.objectDigestInfo=new Rt({schema:new A({value:t.result.objectDigestInfo.valueBlock.value})}))}toSchema(){const e=new A;return this.baseCertificateID&&e.valueBlock.value.push(new I({idBlock:{tagClass:3,tagNumber:0},value:this.baseCertificateID.toSchema().valueBlock.value})),this.entityName&&e.valueBlock.value.push(new I({idBlock:{tagClass:3,tagNumber:1},value:this.entityName.toSchema().valueBlock.value})),this.objectDigestInfo&&e.valueBlock.value.push(new I({idBlock:{tagClass:3,tagNumber:2},value:this.objectDigestInfo.toSchema().valueBlock.value})),e}toJSON(){const e={};return this.baseCertificateID&&(e.baseCertificateID=this.baseCertificateID.toJSON()),this.entityName&&(e.entityName=this.entityName.toJSON()),this.objectDigestInfo&&(e.objectDigestInfo=this.objectDigestInfo.toJSON()),e}}Us.CLASS_NAME="Holder";const el="version",tl="holder",sl="issuer",rl="signature",al="serialNumber",nl="attrCertValidityPeriod",il="attributes",$a="issuerUniqueID",Ka="extensions",x1=[el,tl,sl,rl,al,nl,il,$a,Ka];class wt extends D{constructor(e={}){super(),this.version=f(e,el,wt.defaultValues(el)),this.holder=f(e,tl,wt.defaultValues(tl)),this.issuer=f(e,sl,wt.defaultValues(sl)),this.signature=f(e,rl,wt.defaultValues(rl)),this.serialNumber=f(e,al,wt.defaultValues(al)),this.attrCertValidityPeriod=f(e,nl,wt.defaultValues(nl)),this.attributes=f(e,il,wt.defaultValues(il)),$a in e&&(this.issuerUniqueID=f(e,$a,wt.defaultValues($a))),Ka in e&&(this.extensions=f(e,Ka,wt.defaultValues(Ka))),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case el:return 1;case tl:return new Us;case sl:return{};case rl:return new V;case al:return new B;case nl:return new as;case il:return[];case $a:return new re;case Ka:return new je;default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||v,value:[new B({name:t.version||v}),Us.schema(t.holder||{}),new Ne({value:[qe.schema({names:{blockName:t.issuer||v}}),new I({name:t.issuer||v,idBlock:{tagClass:3,tagNumber:0},value:Qr.schema().valueBlock.value})]}),V.schema(t.signature||{}),new B({name:t.serialNumber||v}),as.schema(t.attrCertValidityPeriod||{}),new A({name:t.attributes||v,value:[new Z({value:ge.schema()})]}),new re({optional:!0,name:t.issuerUniqueID||v}),je.schema(t.extensions||{},!0)]})}fromSchema(e){T(e,x1);const t=R(e,e,wt.schema({names:{version:el,holder:{names:{blockName:tl}},issuer:sl,signature:{names:{blockName:rl}},serialNumber:al,attrCertValidityPeriod:{names:{blockName:nl}},attributes:il,issuerUniqueID:$a,extensions:{names:{blockName:Ka}}}}));switch(O.assertSchema(t,this.className),this.version=t.result.version.valueBlock.valueDec,this.holder=new Us({schema:t.result.holder}),t.result.issuer.idBlock.tagClass){case 3:this.issuer=new Qr({schema:new A({value:t.result.issuer.valueBlock.value})});break;case 1:default:throw new Error("Incorrect value for 'issuer' in AttributeCertificateInfoV2")}this.signature=new V({schema:t.result.signature}),this.serialNumber=t.result.serialNumber,this.attrCertValidityPeriod=new as({schema:t.result.attrCertValidityPeriod}),this.attributes=Array.from(t.result.attributes.valueBlock.value,s=>new ge({schema:s})),$a in t.result&&(this.issuerUniqueID=t.result.issuerUniqueID),Ka in t.result&&(this.extensions=new je({schema:t.result.extensions}))}toSchema(){const e=new A({value:[new B({value:this.version}),this.holder.toSchema(),new I({idBlock:{tagClass:3,tagNumber:0},value:this.issuer.toSchema().valueBlock.value}),this.signature.toSchema(),this.serialNumber,this.attrCertValidityPeriod.toSchema(),new A({value:Array.from(this.attributes,t=>t.toSchema())})]});return this.issuerUniqueID&&e.valueBlock.value.push(this.issuerUniqueID),this.extensions&&e.valueBlock.value.push(this.extensions.toSchema()),e}toJSON(){const e={version:this.version,holder:this.holder.toJSON(),issuer:this.issuer.toJSON(),signature:this.signature.toJSON(),serialNumber:this.serialNumber.toJSON(),attrCertValidityPeriod:this.attrCertValidityPeriod.toJSON(),attributes:Array.from(this.attributes,t=>t.toJSON())};return this.issuerUniqueID&&(e.issuerUniqueID=this.issuerUniqueID.toJSON()),this.extensions&&(e.extensions=this.extensions.toJSON()),e}}wt.CLASS_NAME="AttributeCertificateInfoV2";const ol="acinfo",ul="signatureAlgorithm",ll="signatureValue",I1=[ol,ul,ll];class Lt extends D{constructor(e={}){super(),this.acinfo=f(e,ol,Lt.defaultValues(ol)),this.signatureAlgorithm=f(e,ul,Lt.defaultValues(ul)),this.signatureValue=f(e,ll,Lt.defaultValues(ll)),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case ol:return new wt;case ul:return new V;case ll:return new re;default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||v,value:[wt.schema(t.acinfo||{}),V.schema(t.signatureAlgorithm||{}),new re({name:t.signatureValue||v})]})}fromSchema(e){T(e,I1);const t=R(e,e,Lt.schema({names:{acinfo:{names:{blockName:ol}},signatureAlgorithm:{names:{blockName:ul}},signatureValue:ll}}));O.assertSchema(t,this.className),this.acinfo=new wt({schema:t.result.acinfo}),this.signatureAlgorithm=new V({schema:t.result.signatureAlgorithm}),this.signatureValue=t.result.signatureValue}toSchema(){return new A({value:[this.acinfo.toSchema(),this.signatureAlgorithm.toSchema(),this.signatureValue]})}toJSON(){return{acinfo:this.acinfo.toJSON(),signatureAlgorithm:this.signatureAlgorithm.toJSON(),signatureValue:this.signatureValue.toJSON()}}}Lt.CLASS_NAME="AttributeCertificateV2";const Ha="contentType",si="content",V1=[Ha,si];class fe extends D{constructor(e={}){super(),this.contentType=f(e,Ha,fe.defaultValues(Ha)),this.content=f(e,si,fe.defaultValues(si)),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case Ha:return v;case si:return new X;default:return super.defaultValues(e)}}static compareWithDefault(e,t){switch(e){case Ha:return typeof t=="string"&&t===this.defaultValues(Ha);case si:return t instanceof X;default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return"optional"in t||(t.optional=!1),new A({name:t.blockName||"ContentInfo",optional:t.optional,value:[new J({name:t.contentType||Ha}),new I({idBlock:{tagClass:3,tagNumber:0},value:[new X({name:t.content||si})]})]})}fromSchema(e){T(e,V1);const t=R(e,e,fe.schema());O.assertSchema(t,this.className),this.contentType=t.result.contentType.valueBlock.toString(),this.content=t.result.content}toSchema(){return new A({value:[new J({value:this.contentType}),new I({idBlock:{tagClass:3,tagNumber:0},value:[this.content]})]})}toJSON(){const e={contentType:this.contentType};return this.content instanceof X||(e.content=this.content.toJSON()),e}}fe.CLASS_NAME="ContentInfo",fe.DATA=td,fe.SIGNED_DATA=Pg,fe.ENVELOPED_DATA=Og,fe.ENCRYPTED_DATA=Dg;const Cm="type",Em="value",mf="utcTimeName",ff="generalTimeName",B1=[mf,ff];var wp;(function(r){r[r.UTCTime=0]="UTCTime",r[r.GeneralizedTime=1]="GeneralizedTime",r[r.empty=2]="empty"})(wp||(wp={}));class Re extends D{constructor(e={}){super(),this.type=f(e,Cm,Re.defaultValues(Cm)),this.value=f(e,Em,Re.defaultValues(Em)),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case Cm:return 0;case Em:return new Date(0,0,0);default:return super.defaultValues(e)}}static schema(e={},t=!1){const s=f(e,"names",{});return new Ne({optional:t,value:[new Xm({name:s.utcTimeName||v}),new ke({name:s.generalTimeName||v})]})}fromSchema(e){T(e,B1);const t=R(e,e,Re.schema({names:{utcTimeName:mf,generalTimeName:ff}}));O.assertSchema(t,this.className),mf in t.result&&(this.type=0,this.value=t.result.utcTimeName.toDate()),ff in t.result&&(this.type=1,this.value=t.result.generalTimeName.toDate())}toSchema(){return this.type===0?new Xm({valueDate:this.value}):this.type===1?new ke({valueDate:this.value}):{}}toJSON(){return{type:this.type,value:this.value}}}Re.CLASS_NAME="Time";const xm="tbs",br="version",Gc="serialNumber",zc="signature",_c="issuer",Xc="notBefore",Zc="notAfter",Qc="subject",Yc="subjectPublicKeyInfo",cl="issuerUniqueID",hl="subjectUniqueID",ml="extensions",fl="signatureAlgorithm",dl="signatureValue",Ut="tbsCertificate",Th="".concat(Ut,".").concat(br),sd="".concat(Ut,".").concat(Gc),rd="".concat(Ut,".").concat(zc),ad="".concat(Ut,".").concat(_c),Rh="".concat(Ut,".").concat(Xc),Lh="".concat(Ut,".").concat(Zc),nd="".concat(Ut,".").concat(Qc),id="".concat(Ut,".").concat(Yc),Uh="".concat(Ut,".").concat(cl),jh="".concat(Ut,".").concat(hl),zl="".concat(Ut,".").concat(ml),P1=[Ut,Th,sd,rd,ad,Rh,Lh,nd,id,Uh,jh,zl,fl,dl];function O1(r={}){const e=f(r,"names",{});return new A({name:e.blockName||Ut,value:[new I({optional:!0,idBlock:{tagClass:3,tagNumber:0},value:[new B({name:e.tbsCertificateVersion||Th})]}),new B({name:e.tbsCertificateSerialNumber||sd}),V.schema(e.signature||{names:{blockName:rd}}),me.schema(e.issuer||{names:{blockName:ad}}),new A({name:e.tbsCertificateValidity||"tbsCertificate.validity",value:[Re.schema(e.notBefore||{names:{utcTimeName:Rh,generalTimeName:Rh}}),Re.schema(e.notAfter||{names:{utcTimeName:Lh,generalTimeName:Lh}})]}),me.schema(e.subject||{names:{blockName:nd}}),Ct.schema(e.subjectPublicKeyInfo||{names:{blockName:id}}),new _({name:e.tbsCertificateIssuerUniqueID||Uh,optional:!0,idBlock:{tagClass:3,tagNumber:1}}),new _({name:e.tbsCertificateSubjectUniqueID||jh,optional:!0,idBlock:{tagClass:3,tagNumber:2}}),new I({optional:!0,idBlock:{tagClass:3,tagNumber:3},value:[je.schema(e.extensions||{names:{blockName:zl}})]})]})}class oe extends D{get tbs(){return pe.toArrayBuffer(this.tbsView)}set tbs(e){this.tbsView=new Uint8Array(e)}constructor(e={}){super(),this.tbsView=new Uint8Array(f(e,xm,oe.defaultValues(xm))),this.version=f(e,br,oe.defaultValues(br)),this.serialNumber=f(e,Gc,oe.defaultValues(Gc)),this.signature=f(e,zc,oe.defaultValues(zc)),this.issuer=f(e,_c,oe.defaultValues(_c)),this.notBefore=f(e,Xc,oe.defaultValues(Xc)),this.notAfter=f(e,Zc,oe.defaultValues(Zc)),this.subject=f(e,Qc,oe.defaultValues(Qc)),this.subjectPublicKeyInfo=f(e,Yc,oe.defaultValues(Yc)),cl in e&&(this.issuerUniqueID=f(e,cl,oe.defaultValues(cl))),hl in e&&(this.subjectUniqueID=f(e,hl,oe.defaultValues(hl))),ml in e&&(this.extensions=f(e,ml,oe.defaultValues(ml))),this.signatureAlgorithm=f(e,fl,oe.defaultValues(fl)),this.signatureValue=f(e,dl,oe.defaultValues(dl)),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case xm:return Ue;case br:return 0;case Gc:return new B;case zc:return new V;case _c:return new me;case Xc:return new Re;case Zc:return new Re;case Qc:return new me;case Yc:return new Ct;case cl:return Ue;case hl:return Ue;case ml:return[];case fl:return new V;case dl:return new re;default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||v,value:[O1(t.tbsCertificate),V.schema(t.signatureAlgorithm||{names:{blockName:fl}}),new re({name:t.signatureValue||dl})]})}fromSchema(e){T(e,P1);const t=R(e,e,oe.schema({names:{tbsCertificate:{names:{extensions:{names:{extensions:zl}}}}}}));O.assertSchema(t,this.className),this.tbsView=t.result.tbsCertificate.valueBeforeDecodeView,Th in t.result&&(this.version=t.result[Th].valueBlock.valueDec),this.serialNumber=t.result[sd],this.signature=new V({schema:t.result[rd]}),this.issuer=new me({schema:t.result[ad]}),this.notBefore=new Re({schema:t.result[Rh]}),this.notAfter=new Re({schema:t.result[Lh]}),this.subject=new me({schema:t.result[nd]}),this.subjectPublicKeyInfo=new Ct({schema:t.result[id]}),Uh in t.result&&(this.issuerUniqueID=t.result[Uh].valueBlock.valueHex),jh in t.result&&(this.subjectUniqueID=t.result[jh].valueBlock.valueHex),zl in t.result&&(this.extensions=Array.from(t.result[zl],s=>new De({schema:s}))),this.signatureAlgorithm=new V({schema:t.result.signatureAlgorithm}),this.signatureValue=t.result.signatureValue}encodeTBS(){const e=[];return br in this&&this.version!==oe.defaultValues(br)&&e.push(new I({optional:!0,idBlock:{tagClass:3,tagNumber:0},value:[new B({value:this.version})]})),e.push(this.serialNumber),e.push(this.signature.toSchema()),e.push(this.issuer.toSchema()),e.push(new A({value:[this.notBefore.toSchema(),this.notAfter.toSchema()]})),e.push(this.subject.toSchema()),e.push(this.subjectPublicKeyInfo.toSchema()),this.issuerUniqueID&&e.push(new _({optional:!0,idBlock:{tagClass:3,tagNumber:1},valueHex:this.issuerUniqueID})),this.subjectUniqueID&&e.push(new _({optional:!0,idBlock:{tagClass:3,tagNumber:2},valueHex:this.subjectUniqueID})),this.extensions&&e.push(new I({optional:!0,idBlock:{tagClass:3,tagNumber:3},value:[new A({value:Array.from(this.extensions,t=>t.toSchema())})]})),new A({value:e})}toSchema(e=!1){let t;if(e===!1){if(!this.tbsView.byteLength)return oe.schema().value[0];const s=Le(this.tbsView);O.assert(s,"TBS Certificate"),t=s.result}else t=this.encodeTBS();return new A({value:[t,this.signatureAlgorithm.toSchema(),this.signatureValue]})}toJSON(){const e={tbs:ce.ToHex(this.tbsView),version:this.version,serialNumber:this.serialNumber.toJSON(),signature:this.signature.toJSON(),issuer:this.issuer.toJSON(),notBefore:this.notBefore.toJSON(),notAfter:this.notAfter.toJSON(),subject:this.subject.toJSON(),subjectPublicKeyInfo:this.subjectPublicKeyInfo.toJSON(),signatureAlgorithm:this.signatureAlgorithm.toJSON(),signatureValue:this.signatureValue.toJSON()};return br in this&&this.version!==oe.defaultValues(br)&&(e.version=this.version),this.issuerUniqueID&&(e.issuerUniqueID=ce.ToHex(this.issuerUniqueID)),this.subjectUniqueID&&(e.subjectUniqueID=ce.ToHex(this.subjectUniqueID)),this.extensions&&(e.extensions=Array.from(this.extensions,t=>t.toJSON())),e}async getPublicKey(e,t=Q(!0)){return t.getPublicKey(this.subjectPublicKeyInfo,this.signatureAlgorithm,e)}async getKeyHash(e="SHA-1",t=Q(!0)){return t.digest({name:e},this.subjectPublicKeyInfo.subjectPublicKey.valueBlock.valueHexView)}async sign(e,t="SHA-1",s=Q(!0)){if(!e)throw new Error("Need to provide a private key for signing");const a=await s.getSignatureParameters(e,t),n=a.parameters;this.signature=a.signatureAlgorithm,this.signatureAlgorithm=a.signatureAlgorithm,this.tbsView=new Uint8Array(this.encodeTBS().toBER());const u=await s.signWithPrivateKey(this.tbsView,e,n);this.signatureValue=new re({valueHex:u})}async verify(e,t=Q(!0)){let s;if(e?s=e.subjectPublicKeyInfo:this.issuer.isEqual(this.subject)&&(s=this.subjectPublicKeyInfo),!(s instanceof Ct))throw new Error("Please provide issuer certificate as a parameter");return t.verifyWithPublicKey(this.tbsView,this.signatureValue,s,this.signatureAlgorithm)}}oe.CLASS_NAME="Certificate";function $g(r,e=null){if(e&&r.issuer.isEqual(e.issuer)&&r.serialNumber.isEqual(e.serialNumber))return null;let t=!1;if(r.extensions){for(const s of r.extensions)if(s.extnID===Zf&&s.parsedValue instanceof kn&&s.parsedValue.cA){t=!0;break}}return t?r:null}const ri="certId",ai="certValue",jn="parsedValue",D1=[ri,ai];class yn extends D{constructor(e={}){super(),this.certId=f(e,ri,yn.defaultValues(ri)),this.certValue=f(e,ai,yn.defaultValues(ai)),jn in e&&(this.parsedValue=f(e,jn,yn.defaultValues(jn))),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case ri:return v;case ai:return new X;case jn:return{};default:return super.defaultValues(e)}}static compareWithDefault(e,t){switch(e){case ri:return t===v;case ai:return t instanceof X;case jn:return t instanceof Object&&Object.keys(t).length===0;default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||v,value:[new J({name:t.id||"id"}),new I({idBlock:{tagClass:3,tagNumber:0},value:[new X({name:t.value||"value"})]})]})}fromSchema(e){T(e,D1);const t=R(e,e,yn.schema({names:{id:ri,value:ai}}));O.assertSchema(t,this.className),this.certId=t.result.certId.valueBlock.toString(),this.certValue=t.result.certValue;const s=this.certValue.valueBlock.valueHexView;switch(this.certId){case Qd:try{this.parsedValue=oe.fromBER(s)}catch(a){Lt.fromBER(s)}break;case Yd:this.parsedValue=Lt.fromBER(s);break;case U0:default:throw new Error("Incorrect CERT_ID value in CertBag: ".concat(this.certId))}}toSchema(){return jn in this&&("acinfo"in this.parsedValue?this.certId=Yd:this.certId=Qd,this.certValue=new $({valueHex:this.parsedValue.toSchema().toBER(!1)})),new A({value:[new J({value:this.certId}),new I({idBlock:{tagClass:3,tagNumber:0},value:["toSchema"in this.certValue?this.certValue.toSchema():this.certValue]})]})}toJSON(){return{certId:this.certId,certValue:this.certValue.toJSON()}}}yn.CLASS_NAME="CertBag";const pl="userCertificate",ni="revocationDate",Ma="crlEntryExtensions",T1=[pl,ni,Ma];class vn extends D{constructor(e={}){super(),this.userCertificate=f(e,pl,vn.defaultValues(pl)),this.revocationDate=f(e,ni,vn.defaultValues(ni)),Ma in e&&(this.crlEntryExtensions=f(e,Ma,vn.defaultValues(Ma))),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case pl:return new B;case ni:return new Re;case Ma:return new je;default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||v,value:[new B({name:t.userCertificate||pl}),Re.schema({names:{utcTimeName:t.revocationDate||ni,generalTimeName:t.revocationDate||ni}}),je.schema({names:{blockName:t.crlEntryExtensions||Ma}},!0)]})}fromSchema(e){T(e,T1);const t=R(e,e,vn.schema());O.assertSchema(t,this.className),this.userCertificate=t.result.userCertificate,this.revocationDate=new Re({schema:t.result.revocationDate}),Ma in t.result&&(this.crlEntryExtensions=new je({schema:t.result.crlEntryExtensions}))}toSchema(){const e=[this.userCertificate,this.revocationDate.toSchema()];return this.crlEntryExtensions&&e.push(this.crlEntryExtensions.toSchema()),new A({value:e})}toJSON(){const e={userCertificate:this.userCertificate.toJSON(),revocationDate:this.revocationDate.toJSON()};return this.crlEntryExtensions&&(e.crlEntryExtensions=this.crlEntryExtensions.toJSON()),e}}vn.CLASS_NAME="RevokedCertificate";const Im="tbs",Ho="version",Vm="signature",Bm="issuer",Pm="thisUpdate",kc="nextUpdate",Cc="revokedCertificates",Ec="crlExtensions",gl="signatureAlgorithm",wl="signatureValue",qs="tbsCertList",$h="".concat(qs,".version"),od="".concat(qs,".signature"),ud="".concat(qs,".issuer"),Kh="".concat(qs,".thisUpdate"),oc="".concat(qs,".nextUpdate"),Hh="".concat(qs,".revokedCertificates"),Mh="".concat(qs,".extensions"),R1=[qs,$h,od,ud,Kh,oc,Hh,Mh,gl,wl];function L1(r={}){const e=f(r,"names",{});return new A({name:e.blockName||qs,value:[new B({optional:!0,name:e.tbsCertListVersion||$h,value:2}),V.schema(e.signature||{names:{blockName:od}}),me.schema(e.issuer||{names:{blockName:ud}}),Re.schema(e.tbsCertListThisUpdate||{names:{utcTimeName:Kh,generalTimeName:Kh}}),Re.schema(e.tbsCertListNextUpdate||{names:{utcTimeName:oc,generalTimeName:oc}},!0),new A({optional:!0,value:[new Z({name:e.tbsCertListRevokedCertificates||Hh,value:new A({value:[new B,Re.schema(),je.schema({},!0)]})})]}),new I({optional:!0,idBlock:{tagClass:3,tagNumber:0},value:[je.schema(e.crlExtensions||{names:{blockName:Mh}})]})]})}const U1=[Yf,Ng,k0,C0,kg,Qf,ed,E0,x0,Cg];class Me extends D{get tbs(){return pe.toArrayBuffer(this.tbsView)}set tbs(e){this.tbsView=new Uint8Array(e)}constructor(e={}){super(),this.tbsView=new Uint8Array(f(e,Im,Me.defaultValues(Im))),this.version=f(e,Ho,Me.defaultValues(Ho)),this.signature=f(e,Vm,Me.defaultValues(Vm)),this.issuer=f(e,Bm,Me.defaultValues(Bm)),this.thisUpdate=f(e,Pm,Me.defaultValues(Pm)),kc in e&&(this.nextUpdate=f(e,kc,Me.defaultValues(kc))),Cc in e&&(this.revokedCertificates=f(e,Cc,Me.defaultValues(Cc))),Ec in e&&(this.crlExtensions=f(e,Ec,Me.defaultValues(Ec))),this.signatureAlgorithm=f(e,gl,Me.defaultValues(gl)),this.signatureValue=f(e,wl,Me.defaultValues(wl)),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case Im:return Ue;case Ho:return 0;case Vm:return new V;case Bm:return new me;case Pm:return new Re;case kc:return new Re;case Cc:return[];case Ec:return new je;case gl:return new V;case wl:return new re;default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||"CertificateList",value:[L1(e),V.schema(t.signatureAlgorithm||{names:{blockName:gl}}),new re({name:t.signatureValue||wl})]})}fromSchema(e){T(e,R1);const t=R(e,e,Me.schema());O.assertSchema(t,this.className),this.tbsView=t.result.tbsCertList.valueBeforeDecodeView,$h in t.result&&(this.version=t.result[$h].valueBlock.valueDec),this.signature=new V({schema:t.result[od]}),this.issuer=new me({schema:t.result[ud]}),this.thisUpdate=new Re({schema:t.result[Kh]}),oc in t.result&&(this.nextUpdate=new Re({schema:t.result[oc]})),Hh in t.result&&(this.revokedCertificates=Array.from(t.result[Hh],s=>new vn({schema:s}))),Mh in t.result&&(this.crlExtensions=new je({schema:t.result[Mh]})),this.signatureAlgorithm=new V({schema:t.result.signatureAlgorithm}),this.signatureValue=t.result.signatureValue}encodeTBS(){const e=[];return this.version!==Me.defaultValues(Ho)&&e.push(new B({value:this.version})),e.push(this.signature.toSchema()),e.push(this.issuer.toSchema()),e.push(this.thisUpdate.toSchema()),this.nextUpdate&&e.push(this.nextUpdate.toSchema()),this.revokedCertificates&&e.push(new A({value:Array.from(this.revokedCertificates,t=>t.toSchema())})),this.crlExtensions&&e.push(new I({optional:!0,idBlock:{tagClass:3,tagNumber:0},value:[this.crlExtensions.toSchema()]})),new A({value:e})}toSchema(e=!1){let t;if(e)t=this.encodeTBS();else{if(!this.tbsView.byteLength)return Me.schema();const s=Le(this.tbsView);O.assert(s,"TBS Certificate Revocation List"),t=s.result}return new A({value:[t,this.signatureAlgorithm.toSchema(),this.signatureValue]})}toJSON(){const e={tbs:ce.ToHex(this.tbsView),version:this.version,signature:this.signature.toJSON(),issuer:this.issuer.toJSON(),thisUpdate:this.thisUpdate.toJSON(),signatureAlgorithm:this.signatureAlgorithm.toJSON(),signatureValue:this.signatureValue.toJSON()};return this.version!==Me.defaultValues(Ho)&&(e.version=this.version),this.nextUpdate&&(e.nextUpdate=this.nextUpdate.toJSON()),this.revokedCertificates&&(e.revokedCertificates=Array.from(this.revokedCertificates,t=>t.toJSON())),this.crlExtensions&&(e.crlExtensions=this.crlExtensions.toJSON()),e}isCertificateRevoked(e){if(!this.issuer.isEqual(e.issuer)||!this.revokedCertificates)return!1;for(const t of this.revokedCertificates)if(t.userCertificate.isEqual(e.serialNumber))return!0;return!1}async sign(e,t="SHA-1",s=Q(!0)){if(!e)throw new Error("Need to provide a private key for signing");const a=await s.getSignatureParameters(e,t),{parameters:n}=a;this.signature=a.signatureAlgorithm,this.signatureAlgorithm=a.signatureAlgorithm,this.tbsView=new Uint8Array(this.encodeTBS().toBER());const u=await s.signWithPrivateKey(this.tbsView,e,n);this.signatureValue=new re({valueHex:u})}async verify(e={},t=Q(!0)){let s;if(e.issuerCertificate&&(s=e.issuerCertificate.subjectPublicKeyInfo,!this.issuer.isEqual(e.issuerCertificate.subject)))return!1;if(e.publicKeyInfo&&(s=e.publicKeyInfo),!s)throw new Error("Issuer's certificate must be provided as an input parameter");if(this.crlExtensions){for(const a of this.crlExtensions.extensions)if(a.critical&&!U1.includes(a.extnID))return!1}return t.verifyWithPublicKey(this.tbsView,this.signatureValue,s,this.signatureAlgorithm)}}Me.CLASS_NAME="CertificateRevocationList";const ii="crlId",oi="crlValue",Mo="parsedValue",j1=[ii,oi];class bn extends D{constructor(e={}){super(),this.crlId=f(e,ii,bn.defaultValues(ii)),this.crlValue=f(e,oi,bn.defaultValues(oi)),Mo in e&&(this.parsedValue=f(e,Mo,bn.defaultValues(Mo))),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case ii:return v;case oi:return new X;case Mo:return{};default:return super.defaultValues(e)}}static compareWithDefault(e,t){switch(e){case ii:return t===v;case oi:return t instanceof X;case Mo:return t instanceof Object&&Object.keys(t).length===0;default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||v,value:[new J({name:t.id||"id"}),new I({idBlock:{tagClass:3,tagNumber:0},value:[new X({name:t.value||"value"})]})]})}fromSchema(e){T(e,j1);const t=R(e,e,bn.schema({names:{id:ii,value:oi}}));switch(O.assertSchema(t,this.className),this.crlId=t.result.crlId.valueBlock.toString(),this.crlValue=t.result.crlValue,this.crlId){case ep:this.parsedValue=Me.fromBER(this.certValue.valueBlock.valueHex);break;default:throw new Error("Incorrect CRL_ID value in CRLBag: ".concat(this.crlId))}}toSchema(){return this.parsedValue&&(this.crlId=ep,this.crlValue=new $({valueHex:this.parsedValue.toSchema().toBER(!1)})),new A({value:[new J({value:this.crlId}),new I({idBlock:{tagClass:3,tagNumber:0},value:[this.crlValue.toSchema()]})]})}toJSON(){return{crlId:this.crlId,crlValue:this.crlValue.toJSON()}}}bn.CLASS_NAME="CRLBag";const ui="version",li="encryptedContentInfo",Sr="unprotectedAttrs",$1=[ui,li,Sr];class ds extends D{constructor(e={}){super(),this.version=f(e,ui,ds.defaultValues(ui)),this.encryptedContentInfo=f(e,li,ds.defaultValues(li)),Sr in e&&(this.unprotectedAttrs=f(e,Sr,ds.defaultValues(Sr))),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case ui:return 0;case li:return new Oe;case Sr:return[];default:return super.defaultValues(e)}}static compareWithDefault(e,t){switch(e){case ui:return t===0;case li:return Oe.compareWithDefault("contentType",t.contentType)&&Oe.compareWithDefault("contentEncryptionAlgorithm",t.contentEncryptionAlgorithm)&&Oe.compareWithDefault("encryptedContent",t.encryptedContent);case Sr:return t.length===0;default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||v,value:[new B({name:t.version||v}),Oe.schema(t.encryptedContentInfo||{}),new I({optional:!0,idBlock:{tagClass:3,tagNumber:1},value:[new Z({name:t.unprotectedAttrs||v,value:ge.schema()})]})]})}fromSchema(e){T(e,$1);const t=R(e,e,ds.schema({names:{version:ui,encryptedContentInfo:{names:{blockName:li}},unprotectedAttrs:Sr}}));O.assertSchema(t,this.className),this.version=t.result.version.valueBlock.valueDec,this.encryptedContentInfo=new Oe({schema:t.result.encryptedContentInfo}),Sr in t.result&&(this.unprotectedAttrs=Array.from(t.result.unprotectedAttrs,s=>new ge({schema:s})))}toSchema(){const e=[];return e.push(new B({value:this.version})),e.push(this.encryptedContentInfo.toSchema()),this.unprotectedAttrs&&e.push(new I({optional:!0,idBlock:{tagClass:3,tagNumber:1},value:Array.from(this.unprotectedAttrs,t=>t.toSchema())})),new A({value:e})}toJSON(){const e={version:this.version,encryptedContentInfo:this.encryptedContentInfo.toJSON()};return this.unprotectedAttrs&&(e.unprotectedAttrs=Array.from(this.unprotectedAttrs,t=>t.toJSON())),e}async encrypt(e,t=Q(!0)){he.assert(e,"parameters","object");const s=os(it({},e),{contentType:"1.2.840.113549.1.7.1"});this.encryptedContentInfo=await t.encryptEncryptedContentInfo(s)}async decrypt(e,t=Q(!0)){he.assert(e,"parameters","object");const s=os(it({},e),{encryptedContentInfo:this.encryptedContentInfo});return t.decryptEncryptedContentInfo(s)}}ds.CLASS_NAME="EncryptedData";const Fa="encryptionAlgorithm",Ar="encryptedData",Fo="parsedValue",K1=[Fa,Ar];class Jr extends D{constructor(e={}){super(),this.encryptionAlgorithm=f(e,Fa,Jr.defaultValues(Fa)),this.encryptedData=f(e,Ar,Jr.defaultValues(Ar)),Fo in e&&(this.parsedValue=f(e,Fo,Jr.defaultValues(Fo))),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case Fa:return new V;case Ar:return new $;case Fo:return{};default:return super.defaultValues(e)}}static compareWithDefault(e,t){switch(e){case Fa:return V.compareWithDefault("algorithmId",t.algorithmId)&&!("algorithmParams"in t);case Ar:return t.isEqual(Jr.defaultValues(e));case Fo:return t instanceof Object&&Object.keys(t).length===0;default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||v,value:[V.schema(t.encryptionAlgorithm||{names:{blockName:Fa}}),new Ne({value:[new $({name:t.encryptedData||Ar}),new $({idBlock:{isConstructed:!0},name:t.encryptedData||Ar})]})]})}fromSchema(e){T(e,K1);const t=R(e,e,Jr.schema({names:{encryptionAlgorithm:{names:{blockName:Fa}},encryptedData:Ar}}));O.assertSchema(t,this.className),this.encryptionAlgorithm=new V({schema:t.result.encryptionAlgorithm}),this.encryptedData=t.result.encryptedData}toSchema(){return new A({value:[this.encryptionAlgorithm.toSchema(),this.encryptedData]})}toJSON(){return{encryptionAlgorithm:this.encryptionAlgorithm.toJSON(),encryptedData:this.encryptedData.toJSON()}}async parseInternalValues(e,t=Q(!0)){const s=await new ds({encryptedContentInfo:new Oe({contentEncryptionAlgorithm:this.encryptionAlgorithm,encryptedContent:this.encryptedData})}).decrypt(e,t);this.parsedValue=Ft.fromBER(s)}async makeInternalValues(e,t=Q(!0)){if(!this.parsedValue)throw new Error('Please initialize "parsedValue" first');const s=new ds,a=os(it({},e),{contentToEncrypt:this.parsedValue.toSchema().toBER(!1)});if(await s.encrypt(a,t),!s.encryptedContentInfo.encryptedContent)throw new Error("The filed `encryptedContent` in EncryptedContentInfo is empty");this.encryptionAlgorithm=s.encryptedContentInfo.contentEncryptionAlgorithm,this.encryptedData=s.encryptedContentInfo.encryptedContent}}Jr.CLASS_NAME="PKCS8ShroudedKeyBag";const ci="secretTypeId",hi="secretValue",H1=[ci,hi];class So extends D{constructor(e={}){super(),this.secretTypeId=f(e,ci,So.defaultValues(ci)),this.secretValue=f(e,hi,So.defaultValues(hi)),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case ci:return v;case hi:return new X;default:return super.defaultValues(e)}}static compareWithDefault(e,t){switch(e){case ci:return t===v;case hi:return t instanceof X;default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||v,value:[new J({name:t.id||"id"}),new I({idBlock:{tagClass:3,tagNumber:0},value:[new X({name:t.value||"value"})]})]})}fromSchema(e){T(e,H1);const t=R(e,e,So.schema({names:{id:ci,value:hi}}));O.assertSchema(t,this.className),this.secretTypeId=t.result.secretTypeId.valueBlock.toString(),this.secretValue=t.result.secretValue}toSchema(){return new A({value:[new J({value:this.secretTypeId}),new I({idBlock:{tagClass:3,tagNumber:0},value:[this.secretValue.toSchema()]})]})}toJSON(){return{secretTypeId:this.secretTypeId,secretValue:this.secretValue.toJSON()}}}So.CLASS_NAME="SecretBag";class Mr{static getItems(){return this.items||(this.items={},Mr.register("1.2.840.113549.1.12.10.1.1",Ft),Mr.register("1.2.840.113549.1.12.10.1.2",Jr),Mr.register("1.2.840.113549.1.12.10.1.3",yn),Mr.register("1.2.840.113549.1.12.10.1.4",bn),Mr.register("1.2.840.113549.1.12.10.1.5",So),Mr.register("1.2.840.113549.1.12.10.1.6",js)),this.items}static register(e,t){this.getItems()[e]=t}static find(e){return this.getItems()[e]||null}}const Ja="bagId",qa="bagValue",Cs="bagAttributes",M1=[Ja,qa,Cs];class Yr extends D{constructor(e={}){super(),this.bagId=f(e,Ja,Yr.defaultValues(Ja)),this.bagValue=f(e,qa,Yr.defaultValues(qa)),Cs in e&&(this.bagAttributes=f(e,Cs,Yr.defaultValues(Cs))),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case Ja:return v;case qa:return new X;case Cs:return[];default:return super.defaultValues(e)}}static compareWithDefault(e,t){switch(e){case Ja:return t===v;case qa:return t instanceof X;case Cs:return t.length===0;default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||v,value:[new J({name:t.bagId||Ja}),new I({idBlock:{tagClass:3,tagNumber:0},value:[new X({name:t.bagValue||qa})]}),new Je({optional:!0,value:[new Z({name:t.bagAttributes||Cs,value:ge.schema()})]})]})}fromSchema(e){T(e,M1);const t=R(e,e,Yr.schema({names:{bagId:Ja,bagValue:qa,bagAttributes:Cs}}));O.assertSchema(t,this.className),this.bagId=t.result.bagId.valueBlock.toString();const s=Mr.find(this.bagId);if(!s)throw new Error("Invalid BAG_ID for SafeBag: ".concat(this.bagId));this.bagValue=new s({schema:t.result.bagValue}),Cs in t.result&&(this.bagAttributes=Array.from(t.result.bagAttributes,a=>new ge({schema:a})))}toSchema(){const e=[new J({value:this.bagId}),new I({idBlock:{tagClass:3,tagNumber:0},value:[this.bagValue.toSchema()]})];return this.bagAttributes&&e.push(new Je({value:Array.from(this.bagAttributes,t=>t.toSchema())})),new A({value:e})}toJSON(){const e={bagId:this.bagId,bagValue:this.bagValue.toJSON()};return this.bagAttributes&&(e.bagAttributes=Array.from(this.bagAttributes,t=>t.toJSON())),e}}Yr.CLASS_NAME="SafeBag";const $n="safeBags";class js extends D{constructor(e={}){super(),this.safeBags=f(e,$n,js.defaultValues($n)),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case $n:return[];default:return super.defaultValues(e)}}static compareWithDefault(e,t){switch(e){case $n:return t.length===0;default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||v,value:[new Z({name:t.safeBags||v,value:Yr.schema()})]})}fromSchema(e){T(e,[$n]);const t=R(e,e,js.schema({names:{safeBags:$n}}));O.assertSchema(t,this.className),this.safeBags=Array.from(t.result.safeBags,s=>new Yr({schema:s}))}toSchema(){return new A({value:Array.from(this.safeBags,e=>e.toSchema())})}toJSON(){return{safeBags:Array.from(this.safeBags,e=>e.toJSON())}}}js.CLASS_NAME="SafeContents";const yl="otherCertFormat",vl="otherCert",F1=[yl,vl];class ra extends D{constructor(e={}){super(),this.otherCertFormat=f(e,yl,ra.defaultValues(yl)),this.otherCert=f(e,vl,ra.defaultValues(vl)),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case yl:return v;case vl:return new X;default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||v,value:[new J({name:t.otherCertFormat||yl}),new X({name:t.otherCert||vl})]})}fromSchema(e){T(e,F1);const t=R(e,e,ra.schema());O.assertSchema(t,this.className),this.otherCertFormat=t.result.otherCertFormat.valueBlock.toString(),this.otherCert=t.result.otherCert}toSchema(){return new A({value:[new J({value:this.otherCertFormat}),this.otherCert]})}toJSON(){const e={otherCertFormat:this.otherCertFormat};return this.otherCert instanceof X||(e.otherCert=this.otherCert.toJSON()),e}}const bl="certificates",J1=[bl];class ps extends D{constructor(e={}){super(),this.certificates=f(e,bl,ps.defaultValues(bl)),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case bl:return[];default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new Je({name:t.blockName||v,value:[new Z({name:t.certificates||bl,value:new Ne({value:[oe.schema(),new I({idBlock:{tagClass:3,tagNumber:0},value:[new X]}),new I({idBlock:{tagClass:3,tagNumber:1},value:[new A]}),new I({idBlock:{tagClass:3,tagNumber:2},value:Lt.schema().valueBlock.value}),new I({idBlock:{tagClass:3,tagNumber:3},value:ra.schema().valueBlock.value})]})})]})}fromSchema(e){T(e,J1);const t=R(e,e,ps.schema());O.assertSchema(t,this.className),this.certificates=Array.from(t.result.certificates||[],s=>{const a=s.idBlock.tagNumber;if(s.idBlock.tagClass===1)return new oe({schema:s});const n=new A({value:s.valueBlock.value});switch(a){case 1:return n.valueBlock.value[0].valueBlock.value[0].valueBlock.valueDec===1?new Lt({schema:n}):new Ls({schema:n});case 2:return new Lt({schema:n});case 3:return new ra({schema:n})}return s})}toSchema(){return new Je({value:Array.from(this.certificates,e=>{switch(!0){case e instanceof oe:return e.toSchema();case e instanceof Ls:return new I({idBlock:{tagClass:3,tagNumber:1},value:e.toSchema().valueBlock.value});case e instanceof Lt:return new I({idBlock:{tagClass:3,tagNumber:2},value:e.toSchema().valueBlock.value});case e instanceof ra:return new I({idBlock:{tagClass:3,tagNumber:3},value:e.toSchema().valueBlock.value})}return e.toSchema()})})}toJSON(){return{certificates:Array.from(this.certificates,e=>e.toJSON())}}}ps.CLASS_NAME="CertificateSet";const Sl="otherRevInfoFormat",Al="otherRevInfo",q1=[Sl,Al];class Hs extends D{constructor(e={}){super(),this.otherRevInfoFormat=f(e,Sl,Hs.defaultValues(Sl)),this.otherRevInfo=f(e,Al,Hs.defaultValues(Al)),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case Sl:return v;case Al:return new X;default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||v,value:[new J({name:t.otherRevInfoFormat||Sl}),new X({name:t.otherRevInfo||Al})]})}fromSchema(e){T(e,q1);const t=R(e,e,Hs.schema());O.assertSchema(t,this.className),this.otherRevInfoFormat=t.result.otherRevInfoFormat.valueBlock.toString(),this.otherRevInfo=t.result.otherRevInfo}toSchema(){return new A({value:[new J({value:this.otherRevInfoFormat}),this.otherRevInfo]})}toJSON(){const e={otherRevInfoFormat:this.otherRevInfoFormat};return this.otherRevInfo instanceof X||(e.otherRevInfo=this.otherRevInfo.toJSON()),e}}Hs.CLASS_NAME="OtherRevocationInfoFormat";const Nl="crls",Om="otherRevocationInfos",W1=[Nl];class Ms extends D{constructor(e={}){super(),this.crls=f(e,Nl,Ms.defaultValues(Nl)),this.otherRevocationInfos=f(e,Om,Ms.defaultValues(Om)),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case Nl:return[];case Om:return[];default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new Je({name:t.blockName||v,value:[new Z({name:t.crls||v,value:new Ne({value:[Me.schema(),new I({idBlock:{tagClass:3,tagNumber:1},value:[new J,new X]})]})})]})}fromSchema(e){T(e,W1);const t=R(e,e,Ms.schema({names:{crls:Nl}}));if(O.assertSchema(t,this.className),t.result.crls)for(const s of t.result.crls)s.idBlock.tagClass===1?this.crls.push(new Me({schema:s})):this.otherRevocationInfos.push(new Hs({schema:s}))}toSchema(){const e=[];return e.push(...Array.from(this.crls,t=>t.toSchema())),e.push(...Array.from(this.otherRevocationInfos,t=>{const s=t.toSchema();return s.idBlock.tagClass=3,s.idBlock.tagNumber=1,s})),new Je({value:e})}toJSON(){return{crls:Array.from(this.crls,e=>e.toJSON()),otherRevocationInfos:Array.from(this.otherRevocationInfos,e=>e.toJSON())}}}Ms.CLASS_NAME="RevocationInfoChoices";const kl="certs",Wa="crls",G1=[kl,Wa];class Pn extends D{constructor(e={}){super(),this.crls=f(e,Wa,Pn.defaultValues(Wa)),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case kl:return new ps;case Wa:return new Ms;default:return super.defaultValues(e)}}static compareWithDefault(e,t){switch(e){case kl:return t.certificates.length===0;case Wa:return t.crls.length===0&&t.otherRevocationInfos.length===0;default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||v,value:[new I({name:t.certs||v,optional:!0,idBlock:{tagClass:3,tagNumber:0},value:ps.schema().valueBlock.value}),new I({name:t.crls||v,optional:!0,idBlock:{tagClass:3,tagNumber:1},value:Ms.schema().valueBlock.value})]})}fromSchema(e){T(e,G1);const t=R(e,e,Pn.schema({names:{certs:kl,crls:Wa}}));O.assertSchema(t,this.className),kl in t.result&&(this.certs=new ps({schema:new Je({value:t.result.certs.valueBlock.value})})),Wa in t.result&&(this.crls=new Ms({schema:new Je({value:t.result.crls.valueBlock.value})}))}toSchema(){const e=[];return this.certs&&e.push(new I({idBlock:{tagClass:3,tagNumber:0},value:this.certs.toSchema().valueBlock.value})),this.crls&&e.push(new I({idBlock:{tagClass:3,tagNumber:1},value:this.crls.toSchema().valueBlock.value})),new A({value:e})}toJSON(){const e={};return this.certs&&(e.certs=this.certs.toJSON()),this.crls&&(e.crls=this.crls.toJSON()),e}}Pn.CLASS_NAME="OriginatorInfo";const Cl="issuer",El="serialNumber",z1=[Cl,El];class $e extends D{constructor(e={}){super(),this.issuer=f(e,Cl,$e.defaultValues(Cl)),this.serialNumber=f(e,El,$e.defaultValues(El)),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case Cl:return new me;case El:return new B;default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||v,value:[me.schema(t.issuer||{}),new B({name:t.serialNumber||v})]})}fromSchema(e){T(e,z1);const t=R(e,e,$e.schema({names:{issuer:{names:{blockName:Cl}},serialNumber:El}}));O.assertSchema(t,this.className),this.issuer=new me({schema:t.result.issuer}),this.serialNumber=t.result.serialNumber}toSchema(){return new A({value:[this.issuer.toSchema(),this.serialNumber]})}toJSON(){return{issuer:this.issuer.toJSON(),serialNumber:this.serialNumber.toJSON()}}}$e.CLASS_NAME="IssuerAndSerialNumber";const xc="variant",Jo="value",_1=["blockName"];class Ao extends D{constructor(e={}){super(),this.variant=f(e,xc,Ao.defaultValues(xc)),Jo in e&&(this.value=f(e,Jo,Ao.defaultValues(Jo))),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case xc:return-1;case Jo:return{};default:return super.defaultValues(e)}}static compareWithDefault(e,t){switch(e){case xc:return t===-1;case Jo:return Object.keys(t).length===0;default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new Ne({value:[$e.schema({names:{blockName:t.blockName||v}}),new _({name:t.blockName||v,idBlock:{tagClass:3,tagNumber:0}})]})}fromSchema(e){T(e,_1);const t=R(e,e,Ao.schema({names:{blockName:"blockName"}}));O.assertSchema(t,this.className),t.result.blockName.idBlock.tagClass===1?(this.variant=1,this.value=new $e({schema:t.result.blockName})):(this.variant=2,this.value=new $({valueHex:t.result.blockName.valueBlock.valueHex}))}toSchema(){switch(this.variant){case 1:if(!(this.value instanceof $e))throw new Error("Incorrect type of RecipientIdentifier.value. It should be IssuerAndSerialNumber.");return this.value.toSchema();case 2:if(!(this.value instanceof $))throw new Error("Incorrect type of RecipientIdentifier.value. It should be ASN.1 OctetString.");return new _({idBlock:{tagClass:3,tagNumber:0},valueHex:this.value.valueBlock.valueHexView});default:return new X}}toJSON(){const e={variant:this.variant};return(this.variant===1||this.variant===2)&&this.value&&(e.value=this.value.toJSON()),e}}Ao.CLASS_NAME="RecipientIdentifier";const Ga="version",mi="rid",fi="keyEncryptionAlgorithm",di="encryptedKey",Ic="recipientCertificate",X1=[Ga,mi,fi,di];class Pt extends D{constructor(e={}){super(),this.version=f(e,Ga,Pt.defaultValues(Ga)),this.rid=f(e,mi,Pt.defaultValues(mi)),this.keyEncryptionAlgorithm=f(e,fi,Pt.defaultValues(fi)),this.encryptedKey=f(e,di,Pt.defaultValues(di)),this.recipientCertificate=f(e,Ic,Pt.defaultValues(Ic)),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case Ga:return-1;case mi:return{};case fi:return new V;case di:return new $;case Ic:return new oe;default:return super.defaultValues(e)}}static compareWithDefault(e,t){switch(e){case Ga:return t===Pt.defaultValues(Ga);case mi:return Object.keys(t).length===0;case fi:case di:return t.isEqual(Pt.defaultValues(e));case Ic:return!1;default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||v,value:[new B({name:t.version||v}),Ao.schema(t.rid||{}),V.schema(t.keyEncryptionAlgorithm||{}),new $({name:t.encryptedKey||v})]})}fromSchema(e){T(e,X1);const t=R(e,e,Pt.schema({names:{version:Ga,rid:{names:{blockName:mi}},keyEncryptionAlgorithm:{names:{blockName:fi}},encryptedKey:di}}));O.assertSchema(t,this.className),this.version=t.result.version.valueBlock.valueDec,t.result.rid.idBlock.tagClass===3?this.rid=new $({valueHex:t.result.rid.valueBlock.valueHex}):this.rid=new $e({schema:t.result.rid}),this.keyEncryptionAlgorithm=new V({schema:t.result.keyEncryptionAlgorithm}),this.encryptedKey=t.result.encryptedKey}toSchema(){const e=[];return this.rid instanceof $e?(this.version=0,e.push(new B({value:this.version})),e.push(this.rid.toSchema())):(this.version=2,e.push(new B({value:this.version})),e.push(new _({idBlock:{tagClass:3,tagNumber:0},valueHex:this.rid.valueBlock.valueHexView}))),e.push(this.keyEncryptionAlgorithm.toSchema()),e.push(this.encryptedKey),new A({value:e})}toJSON(){return{version:this.version,rid:this.rid.toJSON(),keyEncryptionAlgorithm:this.keyEncryptionAlgorithm.toJSON(),encryptedKey:this.encryptedKey.toJSON()}}}Pt.CLASS_NAME="KeyTransRecipientInfo";const pi="algorithm",gi="publicKey",Z1=[pi,gi];class $s extends D{constructor(e={}){super(),this.algorithm=f(e,pi,$s.defaultValues(pi)),this.publicKey=f(e,gi,$s.defaultValues(gi)),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case pi:return new V;case gi:return new re;default:return super.defaultValues(e)}}static compareWithDefault(e,t){switch(e){case pi:case gi:return t.isEqual($s.defaultValues(e));default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||v,value:[V.schema(t.algorithm||{}),new re({name:t.publicKey||v})]})}fromSchema(e){T(e,Z1);const t=R(e,e,$s.schema({names:{algorithm:{names:{blockName:pi}},publicKey:gi}}));O.assertSchema(t,this.className),this.algorithm=new V({schema:t.result.algorithm}),this.publicKey=t.result.publicKey}toSchema(){return new A({value:[this.algorithm.toSchema(),this.publicKey]})}toJSON(){return{algorithm:this.algorithm.toJSON(),publicKey:this.publicKey.toJSON()}}}$s.CLASS_NAME="OriginatorPublicKey";const Vc="variant",qo="value",Q1=["blockName"];class Fs extends D{constructor(e={}){super(),this.variant=f(e,Vc,Fs.defaultValues(Vc)),qo in e&&(this.value=f(e,qo,Fs.defaultValues(qo))),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case Vc:return-1;case qo:return{};default:return super.defaultValues(e)}}static compareWithDefault(e,t){switch(e){case Vc:return t===-1;case qo:return Object.keys(t).length===0;default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new Ne({value:[$e.schema({names:{blockName:t.blockName||v}}),new _({idBlock:{tagClass:3,tagNumber:0},name:t.blockName||v}),new I({idBlock:{tagClass:3,tagNumber:1},name:t.blockName||v,value:$s.schema().valueBlock.value})]})}fromSchema(e){T(e,Q1);const t=R(e,e,Fs.schema({names:{blockName:"blockName"}}));O.assertSchema(t,this.className),t.result.blockName.idBlock.tagClass===1?(this.variant=1,this.value=new $e({schema:t.result.blockName})):t.result.blockName.idBlock.tagNumber===0?(t.result.blockName.idBlock.tagClass=1,t.result.blockName.idBlock.tagNumber=4,this.variant=2,this.value=t.result.blockName):(this.variant=3,this.value=new $s({schema:new A({value:t.result.blockName.valueBlock.value})}))}toSchema(){switch(this.variant){case 1:return this.value.toSchema();case 2:return this.value.idBlock.tagClass=3,this.value.idBlock.tagNumber=0,this.value;case 3:{const e=this.value.toSchema();return e.idBlock.tagClass=3,e.idBlock.tagNumber=1,e}default:return new X}}toJSON(){const e={variant:this.variant};return(this.variant===1||this.variant===2||this.variant===3)&&(e.value=this.value.toJSON()),e}}Fs.CLASS_NAME="OriginatorIdentifierOrKey";const wi="keyAttrId",ls="keyAttr",Y1=[wi,ls];class ns extends D{constructor(e={}){super(),this.keyAttrId=f(e,wi,ns.defaultValues(wi)),ls in e&&(this.keyAttr=f(e,ls,ns.defaultValues(ls))),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case wi:return v;case ls:return{};default:return super.defaultValues(e)}}static compareWithDefault(e,t){switch(e){case wi:return typeof t=="string"&&t===v;case ls:return Object.keys(t).length===0;default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({optional:t.optional||!0,name:t.blockName||v,value:[new J({name:t.keyAttrId||v}),new X({optional:!0,name:t.keyAttr||v})]})}fromSchema(e){T(e,Y1);const t=R(e,e,ns.schema({names:{keyAttrId:wi,keyAttr:ls}}));O.assertSchema(t,this.className),this.keyAttrId=t.result.keyAttrId.valueBlock.toString(),ls in t.result&&(this.keyAttr=t.result.keyAttr)}toSchema(){const e=[];return e.push(new J({value:this.keyAttrId})),ls in this&&e.push(this.keyAttr),new A({value:e})}toJSON(){const e={keyAttrId:this.keyAttrId};return ls in this&&(e.keyAttr=this.keyAttr.toJSON()),e}}ns.CLASS_NAME="OtherKeyAttribute";const za="subjectKeyIdentifier",Nr="date",kr="other",eS=[za,Nr,kr];class ms extends D{constructor(e={}){super(),this.subjectKeyIdentifier=f(e,za,ms.defaultValues(za)),Nr in e&&(this.date=f(e,Nr,ms.defaultValues(Nr))),kr in e&&(this.other=f(e,kr,ms.defaultValues(kr))),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case za:return new $;case Nr:return new ke;case kr:return new ns;default:return super.defaultValues(e)}}static compareWithDefault(e,t){switch(e){case za:return t.isEqual(ms.defaultValues(za));case Nr:return t.year===0&&t.month===0&&t.day===0&&t.hour===0&&t.minute===0&&t.second===0&&t.millisecond===0;case kr:return t.keyAttrId===v&&!("keyAttr"in t);default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||v,value:[new $({name:t.subjectKeyIdentifier||v}),new ke({optional:!0,name:t.date||v}),ns.schema(t.other||{})]})}fromSchema(e){T(e,eS);const t=R(e,e,ms.schema({names:{subjectKeyIdentifier:za,date:Nr,other:{names:{blockName:kr}}}}));O.assertSchema(t,this.className),this.subjectKeyIdentifier=t.result.subjectKeyIdentifier,Nr in t.result&&(this.date=t.result.date),kr in t.result&&(this.other=new ns({schema:t.result.other}))}toSchema(){const e=[];return e.push(this.subjectKeyIdentifier),this.date&&e.push(this.date),this.other&&e.push(this.other.toSchema()),new A({value:e})}toJSON(){const e={subjectKeyIdentifier:this.subjectKeyIdentifier.toJSON()};return this.date&&(e.date=this.date.toJSON()),this.other&&(e.other=this.other.toJSON()),e}}ms.CLASS_NAME="RecipientKeyIdentifier";const Bc="variant",Pc="value",tS=["blockName"];class gs extends D{constructor(e={}){super(),this.variant=f(e,Bc,gs.defaultValues(Bc)),this.value=f(e,Pc,gs.defaultValues(Pc)),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case Bc:return-1;case Pc:return{};default:return super.defaultValues(e)}}static compareWithDefault(e,t){switch(e){case Bc:return t===-1;case Pc:return Object.keys(t).length===0;default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new Ne({value:[$e.schema(t.issuerAndSerialNumber||{names:{blockName:t.blockName||v}}),new I({name:t.blockName||v,idBlock:{tagClass:3,tagNumber:0},value:ms.schema(t.rKeyId||{names:{blockName:t.blockName||v}}).valueBlock.value})]})}fromSchema(e){T(e,tS);const t=R(e,e,gs.schema({names:{blockName:"blockName"}}));O.assertSchema(t,this.className),t.result.blockName.idBlock.tagClass===1?(this.variant=1,this.value=new $e({schema:t.result.blockName})):(this.variant=2,this.value=new ms({schema:new A({value:t.result.blockName.valueBlock.value})}))}toSchema(){switch(this.variant){case 1:return this.value.toSchema();case 2:return new I({idBlock:{tagClass:3,tagNumber:0},value:this.value.toSchema().valueBlock.value});default:return new X}}toJSON(){const e={variant:this.variant};return(this.variant===1||this.variant===2)&&(e.value=this.value.toJSON()),e}}gs.CLASS_NAME="KeyAgreeRecipientIdentifier";const yi="rid",_a="encryptedKey",sS=[yi,_a];class Ks extends D{constructor(e={}){super(),this.rid=f(e,yi,Ks.defaultValues(yi)),this.encryptedKey=f(e,_a,Ks.defaultValues(_a)),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case yi:return new gs;case _a:return new $;default:return super.defaultValues(e)}}static compareWithDefault(e,t){switch(e){case yi:return t.variant===-1&&!("value"in t);case _a:return t.isEqual(Ks.defaultValues(_a));default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||v,value:[gs.schema(t.rid||{}),new $({name:t.encryptedKey||v})]})}fromSchema(e){T(e,sS);const t=R(e,e,Ks.schema({names:{rid:{names:{blockName:yi}},encryptedKey:_a}}));O.assertSchema(t,this.className),this.rid=new gs({schema:t.result.rid}),this.encryptedKey=t.result.encryptedKey}toSchema(){return new A({value:[this.rid.toSchema(),this.encryptedKey]})}toJSON(){return{rid:this.rid.toJSON(),encryptedKey:this.encryptedKey.toJSON()}}}Ks.CLASS_NAME="RecipientEncryptedKey";const Oc="encryptedKeys",Kg="RecipientEncryptedKeys",rS=[Kg];class aa extends D{constructor(e={}){super(),this.encryptedKeys=f(e,Oc,aa.defaultValues(Oc)),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case Oc:return[];default:return super.defaultValues(e)}}static compareWithDefault(e,t){switch(e){case Oc:return t.length===0;default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||v,value:[new Z({name:t.RecipientEncryptedKeys||v,value:Ks.schema()})]})}fromSchema(e){T(e,rS);const t=R(e,e,aa.schema({names:{RecipientEncryptedKeys:Kg}}));O.assertSchema(t,this.className),this.encryptedKeys=Array.from(t.result.RecipientEncryptedKeys,s=>new Ks({schema:s}))}toSchema(){return new A({value:Array.from(this.encryptedKeys,e=>e.toSchema())})}toJSON(){return{encryptedKeys:Array.from(this.encryptedKeys,e=>e.toJSON())}}}aa.CLASS_NAME="RecipientEncryptedKeys";const vi="version",bi="originator",Es="ukm",Si="keyEncryptionAlgorithm",Ai="recipientEncryptedKeys",Dc="recipientCertificate",Tc="recipientPublicKey",aS=[vi,bi,Es,Si,Ai];class xt extends D{constructor(e={}){super(),this.version=f(e,vi,xt.defaultValues(vi)),this.originator=f(e,bi,xt.defaultValues(bi)),Es in e&&(this.ukm=f(e,Es,xt.defaultValues(Es))),this.keyEncryptionAlgorithm=f(e,Si,xt.defaultValues(Si)),this.recipientEncryptedKeys=f(e,Ai,xt.defaultValues(Ai)),this.recipientCertificate=f(e,Dc,xt.defaultValues(Dc)),this.recipientPublicKey=f(e,Tc,xt.defaultValues(Tc)),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case vi:return 0;case bi:return new Fs;case Es:return new $;case Si:return new V;case Ai:return new aa;case Dc:return new oe;case Tc:return null;default:return super.defaultValues(e)}}static compareWithDefault(e,t){switch(e){case vi:return t===0;case bi:return t.variant===-1&&!("value"in t);case Es:return t.isEqual(xt.defaultValues(Es));case Si:return t.algorithmId===v&&!("algorithmParams"in t);case Ai:return t.encryptedKeys.length===0;case Dc:return!1;case Tc:return!1;default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||v,value:[new B({name:t.version||v}),new I({idBlock:{tagClass:3,tagNumber:0},value:[Fs.schema(t.originator||{})]}),new I({optional:!0,idBlock:{tagClass:3,tagNumber:1},value:[new $({name:t.ukm||v})]}),V.schema(t.keyEncryptionAlgorithm||{}),aa.schema(t.recipientEncryptedKeys||{})]})}fromSchema(e){T(e,aS);const t=R(e,e,xt.schema({names:{version:vi,originator:{names:{blockName:bi}},ukm:Es,keyEncryptionAlgorithm:{names:{blockName:Si}},recipientEncryptedKeys:{names:{blockName:Ai}}}}));O.assertSchema(t,this.className),this.version=t.result.version.valueBlock.valueDec,this.originator=new Fs({schema:t.result.originator}),Es in t.result&&(this.ukm=t.result.ukm),this.keyEncryptionAlgorithm=new V({schema:t.result.keyEncryptionAlgorithm}),this.recipientEncryptedKeys=new aa({schema:t.result.recipientEncryptedKeys})}toSchema(){const e=[];return e.push(new B({value:this.version})),e.push(new I({idBlock:{tagClass:3,tagNumber:0},value:[this.originator.toSchema()]})),this.ukm&&e.push(new I({optional:!0,idBlock:{tagClass:3,tagNumber:1},value:[this.ukm]})),e.push(this.keyEncryptionAlgorithm.toSchema()),e.push(this.recipientEncryptedKeys.toSchema()),new A({value:e})}toJSON(){const e={version:this.version,originator:this.originator.toJSON(),keyEncryptionAlgorithm:this.keyEncryptionAlgorithm.toJSON(),recipientEncryptedKeys:this.recipientEncryptedKeys.toJSON()};return this.ukm&&(e.ukm=this.ukm.toJSON()),e}}xt.CLASS_NAME="KeyAgreeRecipientInfo";const Xa="keyIdentifier",Cr="date",Er="other",nS=[Xa,Cr,Er];class ss extends D{constructor(e={}){super(),this.keyIdentifier=f(e,Xa,ss.defaultValues(Xa)),Cr in e&&(this.date=f(e,Cr,ss.defaultValues(Cr))),Er in e&&(this.other=f(e,Er,ss.defaultValues(Er))),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case Xa:return new $;case Cr:return new ke;case Er:return new ns;default:return super.defaultValues(e)}}static compareWithDefault(e,t){switch(e){case Xa:return t.isEqual(ss.defaultValues(Xa));case Cr:return t.year===0&&t.month===0&&t.day===0&&t.hour===0&&t.minute===0&&t.second===0&&t.millisecond===0;case Er:return t.compareWithDefault("keyAttrId",t.keyAttrId)&&!("keyAttr"in t);default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||v,value:[new $({name:t.keyIdentifier||v}),new ke({optional:!0,name:t.date||v}),ns.schema(t.other||{})]})}fromSchema(e){T(e,nS);const t=R(e,e,ss.schema({names:{keyIdentifier:Xa,date:Cr,other:{names:{blockName:Er}}}}));O.assertSchema(t,this.className),this.keyIdentifier=t.result.keyIdentifier,Cr in t.result&&(this.date=t.result.date),Er in t.result&&(this.other=new ns({schema:t.result.other}))}toSchema(){const e=[];return e.push(this.keyIdentifier),this.date&&e.push(this.date),this.other&&e.push(this.other.toSchema()),new A({value:e})}toJSON(){const e={keyIdentifier:this.keyIdentifier.toJSON()};return this.date&&(e.date=this.date),this.other&&(e.other=this.other.toJSON()),e}}ss.CLASS_NAME="KEKIdentifier";const Ni="version",ki="kekid",Ci="keyEncryptionAlgorithm",Za="encryptedKey",Rc="preDefinedKEK",iS=[Ni,ki,Ci,Za];class Ot extends D{constructor(e={}){super(),this.version=f(e,Ni,Ot.defaultValues(Ni)),this.kekid=f(e,ki,Ot.defaultValues(ki)),this.keyEncryptionAlgorithm=f(e,Ci,Ot.defaultValues(Ci)),this.encryptedKey=f(e,Za,Ot.defaultValues(Za)),this.preDefinedKEK=f(e,Rc,Ot.defaultValues(Rc)),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case Ni:return 0;case ki:return new ss;case Ci:return new V;case Za:return new $;case Rc:return Ue;default:return super.defaultValues(e)}}static compareWithDefault(e,t){switch(e){case"KEKRecipientInfo":return t===Ot.defaultValues(Ni);case ki:return t.compareWithDefault("keyIdentifier",t.keyIdentifier)&&!("date"in t)&&!("other"in t);case Ci:return t.algorithmId===v&&!("algorithmParams"in t);case Za:return t.isEqual(Ot.defaultValues(Za));case Rc:return t.byteLength===0;default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||v,value:[new B({name:t.version||v}),ss.schema(t.kekid||{}),V.schema(t.keyEncryptionAlgorithm||{}),new $({name:t.encryptedKey||v})]})}fromSchema(e){T(e,iS);const t=R(e,e,Ot.schema({names:{version:Ni,kekid:{names:{blockName:ki}},keyEncryptionAlgorithm:{names:{blockName:Ci}},encryptedKey:Za}}));O.assertSchema(t,this.className),this.version=t.result.version.valueBlock.valueDec,this.kekid=new ss({schema:t.result.kekid}),this.keyEncryptionAlgorithm=new V({schema:t.result.keyEncryptionAlgorithm}),this.encryptedKey=t.result.encryptedKey}toSchema(){return new A({value:[new B({value:this.version}),this.kekid.toSchema(),this.keyEncryptionAlgorithm.toSchema(),this.encryptedKey]})}toJSON(){return{version:this.version,kekid:this.kekid.toJSON(),keyEncryptionAlgorithm:this.keyEncryptionAlgorithm.toJSON(),encryptedKey:this.encryptedKey.toJSON()}}}Ot.CLASS_NAME="KEKRecipientInfo";const Ei="version",xr="keyDerivationAlgorithm",xi="keyEncryptionAlgorithm",Qa="encryptedKey",Lc="password",oS=[Ei,xr,xi,Qa];class Mt extends D{constructor(e={}){super(),this.version=f(e,Ei,Mt.defaultValues(Ei)),xr in e&&(this.keyDerivationAlgorithm=f(e,xr,Mt.defaultValues(xr))),this.keyEncryptionAlgorithm=f(e,xi,Mt.defaultValues(xi)),this.encryptedKey=f(e,Qa,Mt.defaultValues(Qa)),this.password=f(e,Lc,Mt.defaultValues(Lc)),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case Ei:return-1;case xr:return new V;case xi:return new V;case Qa:return new $;case Lc:return Ue;default:return super.defaultValues(e)}}static compareWithDefault(e,t){switch(e){case Ei:return t===-1;case xr:case xi:return t.algorithmId===v&&!("algorithmParams"in t);case Qa:return t.isEqual(Mt.defaultValues(Qa));case Lc:return t.byteLength===0;default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||v,value:[new B({name:t.version||v}),new I({name:t.keyDerivationAlgorithm||v,optional:!0,idBlock:{tagClass:3,tagNumber:0},value:V.schema().valueBlock.value}),V.schema(t.keyEncryptionAlgorithm||{}),new $({name:t.encryptedKey||v})]})}fromSchema(e){T(e,oS);const t=R(e,e,Mt.schema({names:{version:Ei,keyDerivationAlgorithm:xr,keyEncryptionAlgorithm:{names:{blockName:xi}},encryptedKey:Qa}}));O.assertSchema(t,this.className),this.version=t.result.version.valueBlock.valueDec,xr in t.result&&(this.keyDerivationAlgorithm=new V({schema:new A({value:t.result.keyDerivationAlgorithm.valueBlock.value})})),this.keyEncryptionAlgorithm=new V({schema:t.result.keyEncryptionAlgorithm}),this.encryptedKey=t.result.encryptedKey}toSchema(){const e=[];return e.push(new B({value:this.version})),this.keyDerivationAlgorithm&&e.push(new I({idBlock:{tagClass:3,tagNumber:0},value:this.keyDerivationAlgorithm.toSchema().valueBlock.value})),e.push(this.keyEncryptionAlgorithm.toSchema()),e.push(this.encryptedKey),new A({value:e})}toJSON(){const e={version:this.version,keyEncryptionAlgorithm:this.keyEncryptionAlgorithm.toJSON(),encryptedKey:this.encryptedKey.toJSON()};return this.keyDerivationAlgorithm&&(e.keyDerivationAlgorithm=this.keyDerivationAlgorithm.toJSON()),e}}Mt.CLASS_NAME="PasswordRecipientInfo";const Ii="oriType",Ya="oriValue",uS=[Ii,Ya];class ea extends D{constructor(e={}){super(),this.oriType=f(e,Ii,ea.defaultValues(Ii)),this.oriValue=f(e,Ya,ea.defaultValues(Ya)),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case Ii:return v;case Ya:return{};default:return super.defaultValues(e)}}static compareWithDefault(e,t){switch(e){case Ii:return t===v;case Ya:return Object.keys(t).length===0;default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||v,value:[new J({name:t.oriType||v}),new X({name:t.oriValue||v})]})}fromSchema(e){T(e,uS);const t=R(e,e,ea.schema({names:{oriType:Ii,oriValue:Ya}}));O.assertSchema(t,this.className),this.oriType=t.result.oriType.valueBlock.toString(),this.oriValue=t.result.oriValue}toSchema(){return new A({value:[new J({value:this.oriType}),this.oriValue]})}toJSON(){const e={oriType:this.oriType};return ea.compareWithDefault(Ya,this.oriValue)||(e.oriValue=this.oriValue.toJSON()),e}}ea.CLASS_NAME="OtherRecipientInfo";const Uc="variant",Wo="value",lS=["blockName"];class Jt extends D{constructor(e={}){super(),this.variant=f(e,Uc,Jt.defaultValues(Uc)),Wo in e&&(this.value=f(e,Wo,Jt.defaultValues(Wo))),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case Uc:return-1;case Wo:return{};default:return super.defaultValues(e)}}static compareWithDefault(e,t){switch(e){case Uc:return t===Jt.defaultValues(e);case Wo:return Object.keys(t).length===0;default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new Ne({value:[Pt.schema({names:{blockName:t.blockName||v}}),new I({name:t.blockName||v,idBlock:{tagClass:3,tagNumber:1},value:xt.schema().valueBlock.value}),new I({name:t.blockName||v,idBlock:{tagClass:3,tagNumber:2},value:Ot.schema().valueBlock.value}),new I({name:t.blockName||v,idBlock:{tagClass:3,tagNumber:3},value:Mt.schema().valueBlock.value}),new I({name:t.blockName||v,idBlock:{tagClass:3,tagNumber:4},value:ea.schema().valueBlock.value})]})}fromSchema(e){T(e,lS);const t=R(e,e,Jt.schema({names:{blockName:"blockName"}}));if(O.assertSchema(t,this.className),t.result.blockName.idBlock.tagClass===1)this.variant=1,this.value=new Pt({schema:t.result.blockName});else{const s=new A({value:t.result.blockName.valueBlock.value});switch(t.result.blockName.idBlock.tagNumber){case 1:this.variant=2,this.value=new xt({schema:s});break;case 2:this.variant=3,this.value=new Ot({schema:s});break;case 3:this.variant=4,this.value=new Mt({schema:s});break;case 4:this.variant=5,this.value=new ea({schema:s});break;default:throw new Error("Incorrect structure of RecipientInfo block")}}}toSchema(){ne.assertEmpty(this.value,"value","RecipientInfo");const e=this.value.toSchema();switch(this.variant){case 1:return e;case 2:case 3:case 4:return e.idBlock.tagClass=3,e.idBlock.tagNumber=this.variant-1,e;default:return new X}}toJSON(){const e={variant:this.variant};return this.value&&this.variant>=1&&this.variant<=4&&(e.value=this.value.toJSON()),e}}Jt.CLASS_NAME="RecipientInfo";const Ir="hashAlgorithm",Vr="maskGenAlgorithm",Br="pSourceAlgorithm",cS=[Ir,Vr,Br];class yt extends D{constructor(e={}){super(),this.hashAlgorithm=f(e,Ir,yt.defaultValues(Ir)),this.maskGenAlgorithm=f(e,Vr,yt.defaultValues(Vr)),this.pSourceAlgorithm=f(e,Br,yt.defaultValues(Br)),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case Ir:return new V({algorithmId:"1.3.14.3.2.26",algorithmParams:new Fe});case Vr:return new V({algorithmId:"1.2.840.113549.1.1.8",algorithmParams:new V({algorithmId:"1.3.14.3.2.26",algorithmParams:new Fe}).toSchema()});case Br:return new V({algorithmId:"1.2.840.113549.1.1.9",algorithmParams:new $({valueHex:new Uint8Array([218,57,163,238,94,107,75,13,50,85,191,239,149,96,24,144,175,216,7,9]).buffer})});default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||v,value:[new I({idBlock:{tagClass:3,tagNumber:0},optional:!0,value:[V.schema(t.hashAlgorithm||{})]}),new I({idBlock:{tagClass:3,tagNumber:1},optional:!0,value:[V.schema(t.maskGenAlgorithm||{})]}),new I({idBlock:{tagClass:3,tagNumber:2},optional:!0,value:[V.schema(t.pSourceAlgorithm||{})]})]})}fromSchema(e){T(e,cS);const t=R(e,e,yt.schema({names:{hashAlgorithm:{names:{blockName:Ir}},maskGenAlgorithm:{names:{blockName:Vr}},pSourceAlgorithm:{names:{blockName:Br}}}}));O.assertSchema(t,this.className),Ir in t.result&&(this.hashAlgorithm=new V({schema:t.result.hashAlgorithm})),Vr in t.result&&(this.maskGenAlgorithm=new V({schema:t.result.maskGenAlgorithm})),Br in t.result&&(this.pSourceAlgorithm=new V({schema:t.result.pSourceAlgorithm}))}toSchema(){const e=[];return this.hashAlgorithm.isEqual(yt.defaultValues(Ir))||e.push(new I({idBlock:{tagClass:3,tagNumber:0},value:[this.hashAlgorithm.toSchema()]})),this.maskGenAlgorithm.isEqual(yt.defaultValues(Vr))||e.push(new I({idBlock:{tagClass:3,tagNumber:1},value:[this.maskGenAlgorithm.toSchema()]})),this.pSourceAlgorithm.isEqual(yt.defaultValues(Br))||e.push(new I({idBlock:{tagClass:3,tagNumber:2},value:[this.pSourceAlgorithm.toSchema()]})),new A({value:e})}toJSON(){const e={};return this.hashAlgorithm.isEqual(yt.defaultValues(Ir))||(e.hashAlgorithm=this.hashAlgorithm.toJSON()),this.maskGenAlgorithm.isEqual(yt.defaultValues(Vr))||(e.maskGenAlgorithm=this.maskGenAlgorithm.toJSON()),this.pSourceAlgorithm.isEqual(yt.defaultValues(Br))||(e.pSourceAlgorithm=this.pSourceAlgorithm.toJSON()),e}}yt.CLASS_NAME="RSAESOAEPParams";const Vi="keyInfo",Pr="entityUInfo",Bi="suppPubInfo",hS=[Vi,Pr,Bi];class Ds extends D{constructor(e={}){super(),this.keyInfo=f(e,Vi,Ds.defaultValues(Vi)),Pr in e&&(this.entityUInfo=f(e,Pr,Ds.defaultValues(Pr))),this.suppPubInfo=f(e,Bi,Ds.defaultValues(Bi)),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case Vi:return new V;case Pr:return new $;case Bi:return new $;default:return super.defaultValues(e)}}static compareWithDefault(e,t){switch(e){case Vi:case Pr:case Bi:return t.isEqual(Ds.defaultValues(e));default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||v,value:[V.schema(t.keyInfo||{}),new I({name:t.entityUInfo||v,idBlock:{tagClass:3,tagNumber:0},optional:!0,value:[new $]}),new I({name:t.suppPubInfo||v,idBlock:{tagClass:3,tagNumber:2},value:[new $]})]})}fromSchema(e){T(e,hS);const t=R(e,e,Ds.schema({names:{keyInfo:{names:{blockName:Vi}},entityUInfo:Pr,suppPubInfo:Bi}}));O.assertSchema(t,this.className),this.keyInfo=new V({schema:t.result.keyInfo}),Pr in t.result&&(this.entityUInfo=t.result.entityUInfo.valueBlock.value[0]),this.suppPubInfo=t.result.suppPubInfo.valueBlock.value[0]}toSchema(){const e=[];return e.push(this.keyInfo.toSchema()),this.entityUInfo&&e.push(new I({idBlock:{tagClass:3,tagNumber:0},value:[this.entityUInfo]})),e.push(new I({idBlock:{tagClass:3,tagNumber:2},value:[this.suppPubInfo]})),new A({value:e})}toJSON(){const e={keyInfo:this.keyInfo.toJSON(),suppPubInfo:this.suppPubInfo.toJSON()};return this.entityUInfo&&(e.entityUInfo=this.entityUInfo.toJSON()),e}}Ds.CLASS_NAME="ECCCMSSharedInfo";const Pi="version",Or="originatorInfo",Oi="recipientInfos",Di="encryptedContentInfo",Dr="unprotectedAttrs",mS=[Pi,Or,Oi,Di,Dr],yp={kdfAlgorithm:"SHA-512",kekEncryptionLength:256},fS={"P-256":256,"P-384":384,"P-521":528};class es extends D{constructor(e={}){super(),this.version=f(e,Pi,es.defaultValues(Pi)),Or in e&&(this.originatorInfo=f(e,Or,es.defaultValues(Or))),this.recipientInfos=f(e,Oi,es.defaultValues(Oi)),this.encryptedContentInfo=f(e,Di,es.defaultValues(Di)),Dr in e&&(this.unprotectedAttrs=f(e,Dr,es.defaultValues(Dr))),this.policy={disableSplit:!!e.disableSplit},e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case Pi:return 0;case Or:return new Pn;case Oi:return[];case Di:return new Oe;case Dr:return[];default:return super.defaultValues(e)}}static compareWithDefault(e,t){switch(e){case Pi:return t===es.defaultValues(e);case Or:return t.certs.certificates.length===0&&t.crls.crls.length===0;case Oi:case Dr:return t.length===0;case Di:return Oe.compareWithDefault("contentType",t.contentType)&&Oe.compareWithDefault("contentEncryptionAlgorithm",t.contentEncryptionAlgorithm)&&Oe.compareWithDefault("encryptedContent",t.encryptedContent);default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||v,value:[new B({name:t.version||v}),new I({name:t.originatorInfo||v,optional:!0,idBlock:{tagClass:3,tagNumber:0},value:Pn.schema().valueBlock.value}),new Je({value:[new Z({name:t.recipientInfos||v,value:Jt.schema()})]}),Oe.schema(t.encryptedContentInfo||{}),new I({optional:!0,idBlock:{tagClass:3,tagNumber:1},value:[new Z({name:t.unprotectedAttrs||v,value:ge.schema()})]})]})}fromSchema(e){T(e,mS);const t=R(e,e,es.schema({names:{version:Pi,originatorInfo:Or,recipientInfos:Oi,encryptedContentInfo:{names:{blockName:Di}},unprotectedAttrs:Dr}}));O.assertSchema(t,this.className),this.version=t.result.version.valueBlock.valueDec,Or in t.result&&(this.originatorInfo=new Pn({schema:new A({value:t.result.originatorInfo.valueBlock.value})})),this.recipientInfos=Array.from(t.result.recipientInfos,s=>new Jt({schema:s})),this.encryptedContentInfo=new Oe({schema:t.result.encryptedContentInfo}),Dr in t.result&&(this.unprotectedAttrs=Array.from(t.result.unprotectedAttrs,s=>new ge({schema:s})))}toSchema(){const e=[];return e.push(new B({value:this.version})),this.originatorInfo&&e.push(new I({optional:!0,idBlock:{tagClass:3,tagNumber:0},value:this.originatorInfo.toSchema().valueBlock.value})),e.push(new Je({value:Array.from(this.recipientInfos,t=>t.toSchema())})),e.push(this.encryptedContentInfo.toSchema()),this.unprotectedAttrs&&e.push(new I({optional:!0,idBlock:{tagClass:3,tagNumber:1},value:Array.from(this.unprotectedAttrs,t=>t.toSchema())})),new A({value:e})}toJSON(){const e={version:this.version,recipientInfos:Array.from(this.recipientInfos,t=>t.toJSON()),encryptedContentInfo:this.encryptedContentInfo.toJSON()};return this.originatorInfo&&(e.originatorInfo=this.originatorInfo.toJSON()),this.unprotectedAttrs&&(e.unprotectedAttrs=Array.from(this.unprotectedAttrs,t=>t.toJSON())),e}addRecipientByCertificate(e,t,s,a=Q(!0)){const n=Object.assign({useOAEP:!0,oaepHashAlgorithm:"SHA-512"},yp,t||{});if(e.subjectPublicKeyInfo.algorithm.algorithmId.indexOf("1.2.840.113549")!==-1)s=1;else if(e.subjectPublicKeyInfo.algorithm.algorithmId.indexOf("1.2.840.10045")!==-1)s=2;else throw new Error("Unknown type of certificate's public key: ".concat(e.subjectPublicKeyInfo.algorithm.algorithmId));switch(s){case 1:{let u,i;if(n.useOAEP===!0){u=a.getOIDByAlgorithm({name:"RSA-OAEP"},!0,"keyEncryptionAlgorithm");const o=a.getOIDByAlgorithm({name:n.oaepHashAlgorithm},!0,"RSAES-OAEP-params"),c=new V({algorithmId:o,algorithmParams:new Fe});i=new yt({hashAlgorithm:c,maskGenAlgorithm:new V({algorithmId:"1.2.840.113549.1.1.8",algorithmParams:c.toSchema()})}).toSchema()}else{if(u=a.getOIDByAlgorithm({name:"RSAES-PKCS1-v1_5"}),u===v)throw new Error("Can not find OID for RSAES-PKCS1-v1_5");i=new Fe}const l=new Pt({version:0,rid:new $e({issuer:e.issuer,serialNumber:e.serialNumber}),keyEncryptionAlgorithm:new V({algorithmId:u,algorithmParams:i}),recipientCertificate:e});this.recipientInfos.push(new Jt({variant:1,value:l}))}break;case 2:{const u=new gs({variant:1,value:new $e({issuer:e.issuer,serialNumber:e.serialNumber})});this._addKeyAgreeRecipientInfo(u,n,{recipientCertificate:e},a)}break;default:throw new Error('Unknown "variant" value: '.concat(s))}return!0}addRecipientByPreDefinedData(e,t={},s,a=Q(!0)){if(he.assert(e,"preDefinedData","ArrayBuffer"),!e.byteLength)throw new Error("Pre-defined data could have zero length");if(!t.keyIdentifier){const n=new ArrayBuffer(16),u=new Uint8Array(n);a.getRandomValues(u),t.keyIdentifier=n}switch(t.hmacHashAlgorithm||(t.hmacHashAlgorithm="SHA-512"),t.iterationCount===void 0&&(t.iterationCount=2048),t.keyEncryptionAlgorithm||(t.keyEncryptionAlgorithm={name:"AES-KW",length:256}),t.keyEncryptionAlgorithmParams||(t.keyEncryptionAlgorithmParams=new Fe),s){case 1:{const n=a.getOIDByAlgorithm(t.keyEncryptionAlgorithm,!0,"keyEncryptionAlgorithm"),u=new Ot({version:4,kekid:new ss({keyIdentifier:new $({valueHex:t.keyIdentifier})}),keyEncryptionAlgorithm:new V({algorithmId:n,algorithmParams:t.keyEncryptionAlgorithmParams}),preDefinedKEK:e});this.recipientInfos.push(new Jt({variant:3,value:u}))}break;case 2:{const n=a.getOIDByAlgorithm({name:"PBKDF2"},!0,"keyDerivationAlgorithm"),u=new ArrayBuffer(64),i=new Uint8Array(u);a.getRandomValues(i);const l=a.getOIDByAlgorithm({name:"HMAC",hash:{name:t.hmacHashAlgorithm}},!0,"hmacHashAlgorithm"),o=new mt({salt:new $({valueHex:u}),iterationCount:t.iterationCount,prf:new V({algorithmId:l,algorithmParams:new Fe})}),c=a.getOIDByAlgorithm(t.keyEncryptionAlgorithm,!0,"keyEncryptionAlgorithm"),m=new Mt({version:0,keyDerivationAlgorithm:new V({algorithmId:n,algorithmParams:o.toSchema()}),keyEncryptionAlgorithm:new V({algorithmId:c,algorithmParams:t.keyEncryptionAlgorithmParams}),password:e});this.recipientInfos.push(new Jt({variant:4,value:m}))}break;default:throw new Error('Unknown value for "variant": '.concat(s))}}addRecipientByKeyIdentifier(e,t,s,a=Q(!0)){const n=Object.assign({},yp,s||{}),u=new gs({variant:2,value:new ms({subjectKeyIdentifier:new $({valueHex:t})})});this._addKeyAgreeRecipientInfo(u,n,{recipientPublicKey:e},a)}_addKeyAgreeRecipientInfo(e,t,s,a=Q(!0)){const n=new Ks({rid:e}),u=a.getOIDByAlgorithm({name:"AES-KW",length:t.kekEncryptionLength},!0,"keyEncryptionAlgorithm"),i=new V({algorithmId:u}),l=a.getOIDByAlgorithm({name:"ECDH",kdf:t.kdfAlgorithm},!0,"KeyAgreeRecipientInfo"),o=new ArrayBuffer(64),c=new Uint8Array(o);a.getRandomValues(c);const m={version:3,ukm:new $({valueHex:o}),keyEncryptionAlgorithm:new V({algorithmId:l,algorithmParams:i.toSchema()}),recipientEncryptedKeys:new aa({encryptedKeys:[n]})},h=new xt(Object.assign(m,s));this.recipientInfos.push(new Jt({variant:2,value:h}))}async encrypt(e,t,s=Q(!0)){const a=new ArrayBuffer(16),n=new Uint8Array(a);s.getRandomValues(n);const u=new Uint8Array(t),i=s.getOIDByAlgorithm(e,!0,"contentEncryptionAlgorithm"),l=await s.generateKey(e,!0,["encrypt"]),o=await s.encrypt({name:e.name,iv:n},l,u),c=await s.exportKey("raw",l);this.version=2,this.encryptedContentInfo=new Oe({disableSplit:this.policy.disableSplit,contentType:"1.2.840.113549.1.7.1",contentEncryptionAlgorithm:new V({algorithmId:i,algorithmParams:new $({valueHex:a})}),encryptedContent:new $({valueHex:o})});const m=async y=>{const k=this.recipientInfos[y].value;let g,b;if(k.recipientPublicKey)g=k.recipientPublicKey.algorithm.namedCurve,b=k.recipientPublicKey;else if(k.recipientCertificate){const se=k.recipientCertificate.subjectPublicKeyInfo.algorithm.algorithmParams;if(se.constructor.blockName()!==J.blockName())throw new Error('Incorrect "recipientCertificate" for index '.concat(y));switch(se.valueBlock.toString()){case"1.2.840.10045.3.1.7":g="P-256";break;case"1.3.132.0.34":g="P-384";break;case"1.3.132.0.35":g="P-521";break;default:throw new Error("Incorrect curve OID for index ".concat(y))}b=await k.recipientCertificate.getPublicKey({algorithm:{algorithm:{name:"ECDH",namedCurve:g},usages:[]}},s)}else throw new Error("Unsupported RecipientInfo");const N=fS[g],S=await s.generateKey({name:"ECDH",namedCurve:g},!0,["deriveBits"]),E=await s.exportKey("spki",S.publicKey),x=await s.deriveBits({name:"ECDH",public:b},S.privateKey,N),C=new V({schema:k.keyEncryptionAlgorithm.algorithmParams}),P=s.getAlgorithmByOID(C.algorithmId,!0,"aesKWAlgorithm");let K=P.length;const L=new ArrayBuffer(4),j=new Uint8Array(L);for(let se=3;se>=0;se--)j[se]=K,K>>=8;const U=new Ds({keyInfo:new V({algorithmId:C.algorithmId}),entityUInfo:k.ukm,suppPubInfo:new $({valueHex:L})}).toSchema().toBER(!1),M=s.getAlgorithmByOID(k.keyEncryptionAlgorithm.algorithmId,!0,"ecdhAlgorithm"),G=await np(M.kdf,x,P.length,U,s),we=await s.importKey("raw",G,{name:"AES-KW"},!0,["wrapKey"]),ae=await s.wrapKey("raw",l,we,{name:"AES-KW"}),Y=new Fs;return Y.variant=3,Y.value=$s.fromBER(E),k.originator=Y,k.recipientEncryptedKeys.encryptedKeys[0].encryptedKey=new $({valueHex:ae}),{ecdhPrivateKey:S.privateKey}},h=async y=>{const k=this.recipientInfos[y].value,g=s.getAlgorithmByOID(k.keyEncryptionAlgorithm.algorithmId,!0,"keyEncryptionAlgorithm");if(g.name==="RSA-OAEP"){const b=k.keyEncryptionAlgorithm.algorithmParams,N=new yt({schema:b});if(g.hash=s.getAlgorithmByOID(N.hashAlgorithm.algorithmId),!("name"in g.hash))throw new Error("Incorrect OID for hash algorithm: ".concat(N.hashAlgorithm.algorithmId))}try{const b=await k.recipientCertificate.getPublicKey({algorithm:{algorithm:g,usages:["encrypt","wrapKey"]}},s),N=await s.encrypt(b.algorithm,b,c);k.encryptedKey=new $({valueHex:N})}catch(b){}},p=async y=>{const k=this.recipientInfos[y].value,g=s.getAlgorithmByOID(k.keyEncryptionAlgorithm.algorithmId,!0,"kekAlgorithm"),b=await s.importKey("raw",new Uint8Array(k.preDefinedKEK),g,!0,["wrapKey"]),N=await s.wrapKey("raw",l,b,g);k.encryptedKey=new $({valueHex:N})},d=async y=>{const k=this.recipientInfos[y].value;let g;if(!k.keyDerivationAlgorithm)throw new Error('Please append encoded "keyDerivationAlgorithm"');if(!k.keyDerivationAlgorithm.algorithmParams)throw new Error('Incorrectly encoded "keyDerivationAlgorithm"');try{g=new mt({schema:k.keyDerivationAlgorithm.algorithmParams})}catch(L){throw new Error('Incorrectly encoded "keyDerivationAlgorithm"')}const b=new Uint8Array(k.password),N=await s.importKey("raw",b,"PBKDF2",!1,["deriveKey"]),S=s.getAlgorithmByOID(k.keyEncryptionAlgorithm.algorithmId,!0,"kekAlgorithm");let E="SHA-1";g.prf&&(E=s.getAlgorithmByOID(g.prf.algorithmId,!0,"prfAlgorithm").hash.name);const x=new Uint8Array(g.salt.valueBlock.valueHex),C=g.iterationCount,P=await s.deriveKey({name:"PBKDF2",hash:{name:E},salt:x,iterations:C},N,S,!0,["wrapKey"]),K=await s.wrapKey("raw",l,P,S);k.encryptedKey=new $({valueHex:K})},w=[];for(let y=0;y<this.recipientInfos.length;y++)switch(this.recipientInfos[y].variant){case 1:w.push(await h(y));break;case 2:w.push(await m(y));break;case 3:w.push(await p(y));break;case 4:w.push(await d(y));break;default:throw new Error("Unknown recipient type in array with index ".concat(y))}return w}async decrypt(e,t,s=Q(!0)){const a=t||{};if(e+1>this.recipientInfos.length)throw new Error('Maximum value for "index" is: '.concat(this.recipientInfos.length-1));const n=async w=>{const y=this.recipientInfos[w].value;let k,g,b;const N=y.originator;if(a.recipientCertificate){const G=a.recipientCertificate.subjectPublicKeyInfo.algorithm.algorithmParams;if(G.constructor.blockName()!==J.blockName())throw new Error('Incorrect "recipientCertificate" for index '.concat(w));k=G.valueBlock.toString()}else if(N.value.algorithm.algorithmParams){const G=N.value.algorithm.algorithmParams;if(G.constructor.blockName()!==J.blockName())throw new Error("Incorrect originator for index ".concat(w));k=G.valueBlock.toString()}else throw new Error('Parameter "recipientCertificate" is mandatory for "KeyAgreeRecipientInfo" if algorithm params are missing from originator');if(!a.recipientPrivateKey)throw new Error('Parameter "recipientPrivateKey" is mandatory for "KeyAgreeRecipientInfo"');switch(k){case"1.2.840.10045.3.1.7":g="P-256",b=256;break;case"1.3.132.0.34":g="P-384",b=384;break;case"1.3.132.0.35":g="P-521",b=528;break;default:throw new Error("Incorrect curve OID for index ".concat(w))}let S,E=s;pe.isBufferSource(a.recipientPrivateKey)?S=await s.importKey("pkcs8",a.recipientPrivateKey,{name:"ECDH",namedCurve:g},!0,["deriveBits"]):(S=a.recipientPrivateKey,"crypto"in a&&a.crypto&&(E=a.crypto.subtle)),"algorithmParams"in N.value.algorithm||(N.value.algorithm.algorithmParams=new J({value:k}));const x=N.value.toSchema().toBER(!1),C=await s.importKey("spki",x,{name:"ECDH",namedCurve:g},!0,[]),P=await E.deriveBits({name:"ECDH",public:C},S,b);async function K(G){G=G||!1;const we=new V({schema:y.keyEncryptionAlgorithm.algorithmParams}),ae=s.getAlgorithmByOID(we.algorithmId,!0,"kwAlgorithm");let Y=ae.length;const se=new ArrayBuffer(4),F=new Uint8Array(se);for(let ie=3;ie>=0;ie--)F[ie]=Y,Y>>=8;const W={algorithmId:we.algorithmId};G&&(W.algorithmParams=new Fe);const q=new Ds({keyInfo:new V(W),entityUInfo:y.ukm,suppPubInfo:new $({valueHex:se})}).toSchema().toBER(!1),ee=s.getAlgorithmByOID(y.keyEncryptionAlgorithm.algorithmId,!0,"ecdhAlgorithm");if(!ee.name)throw new Error("Incorrect OID for key encryption algorithm: ".concat(y.keyEncryptionAlgorithm.algorithmId));return np(ee.kdf,P,ae.length,q,s)}const L=await K(),j=async G=>s.importKey("raw",G,{name:"AES-KW"},!0,["unwrapKey"]),U=await j(L),M=async G=>{const we=this.encryptedContentInfo.contentEncryptionAlgorithm.algorithmId,ae=s.getAlgorithmByOID(we,!0,"contentEncryptionAlgorithm");return s.unwrapKey("raw",y.recipientEncryptedKeys.encryptedKeys[0].encryptedKey.valueBlock.valueHexView,G,{name:"AES-KW"},ae,!0,["decrypt"])};try{return await M(U)}catch(G){const we=await K(!0),ae=await j(we);return M(ae)}},u=async w=>{const y=this.recipientInfos[w].value;if(!a.recipientPrivateKey)throw new Error('Parameter "recipientPrivateKey" is mandatory for "KeyTransRecipientInfo"');const k=s.getAlgorithmByOID(y.keyEncryptionAlgorithm.algorithmId,!0,"keyEncryptionAlgorithm");if(k.name==="RSA-OAEP"){const x=y.keyEncryptionAlgorithm.algorithmParams,C=new yt({schema:x});if(k.hash=s.getAlgorithmByOID(C.hashAlgorithm.algorithmId),!("name"in k.hash))throw new Error("Incorrect OID for hash algorithm: ".concat(C.hashAlgorithm.algorithmId))}let g,b=s;pe.isBufferSource(a.recipientPrivateKey)?g=await s.importKey("pkcs8",a.recipientPrivateKey,k,!0,["decrypt"]):(g=a.recipientPrivateKey,"crypto"in a&&a.crypto&&(b=a.crypto.subtle));const N=await b.decrypt(g.algorithm,g,y.encryptedKey.valueBlock.valueHexView),S=this.encryptedContentInfo.contentEncryptionAlgorithm.algorithmId,E=s.getAlgorithmByOID(S,!0,"contentEncryptionAlgorithm");if(!("name"in E))throw new Error('Incorrect "contentEncryptionAlgorithm": '.concat(S));return s.importKey("raw",N,E,!0,["decrypt"])},i=async w=>{const y=this.recipientInfos[w].value;if(!a.preDefinedData)throw new Error('Parameter "preDefinedData" is mandatory for "KEKRecipientInfo"');const k=s.getAlgorithmByOID(y.keyEncryptionAlgorithm.algorithmId,!0,"kekAlgorithm"),g=await s.importKey("raw",a.preDefinedData,k,!0,["unwrapKey"]),b=this.encryptedContentInfo.contentEncryptionAlgorithm.algorithmId,N=s.getAlgorithmByOID(b,!0,"contentEncryptionAlgorithm");if(!N.name)throw new Error('Incorrect "contentEncryptionAlgorithm": '.concat(b));return s.unwrapKey("raw",y.encryptedKey.valueBlock.valueHexView,g,k,N,!0,["decrypt"])},l=async w=>{const y=this.recipientInfos[w].value;let k;if(!a.preDefinedData)throw new Error('Parameter "preDefinedData" is mandatory for "KEKRecipientInfo"');if(!y.keyDerivationAlgorithm)throw new Error('Please append encoded "keyDerivationAlgorithm"');if(!y.keyDerivationAlgorithm.algorithmParams)throw new Error('Incorrectly encoded "keyDerivationAlgorithm"');try{k=new mt({schema:y.keyDerivationAlgorithm.algorithmParams})}catch(K){throw new Error('Incorrectly encoded "keyDerivationAlgorithm"')}const g=await s.importKey("raw",a.preDefinedData,"PBKDF2",!1,["deriveKey"]),b=s.getAlgorithmByOID(y.keyEncryptionAlgorithm.algorithmId,!0,"keyEncryptionAlgorithm"),N=k.prf?s.getAlgorithmByOID(k.prf.algorithmId,!0,"prfAlgorithm").hash.name:"SHA-1",S=new Uint8Array(k.salt.valueBlock.valueHex),E=k.iterationCount,x=await s.deriveKey({name:"PBKDF2",hash:{name:N},salt:S,iterations:E},g,b,!0,["unwrapKey"]),C=this.encryptedContentInfo.contentEncryptionAlgorithm.algorithmId,P=s.getAlgorithmByOID(C,!0,"contentEncryptionAlgorithm");return s.unwrapKey("raw",y.encryptedKey.valueBlock.valueHexView,x,b,P,!0,["decrypt"])};let o;switch(this.recipientInfos[e].variant){case 1:o=await u(e);break;case 2:o=await n(e);break;case 3:o=await i(e);break;case 4:o=await l(e);break;default:throw new Error("Unknown recipient type in array with index ".concat(e))}const c=this.encryptedContentInfo.contentEncryptionAlgorithm.algorithmId,m=s.getAlgorithmByOID(c,!0,"contentEncryptionAlgorithm"),h=this.encryptedContentInfo.contentEncryptionAlgorithm.algorithmParams.valueBlock.valueHex,p=new Uint8Array(h);if(!this.encryptedContentInfo.encryptedContent)throw new Error("Required property `encryptedContent` is empty");const d=this.encryptedContentInfo.getEncryptedContent();return s.decrypt({name:m.name,iv:p},o,d)}}es.CLASS_NAME="EnvelopedData";const Kn="safeContents",Go="parsedValue",vp="contentInfos";class On extends D{constructor(e={}){super(),this.safeContents=f(e,Kn,On.defaultValues(Kn)),Go in e&&(this.parsedValue=f(e,Go,On.defaultValues(Go))),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case Kn:return[];case Go:return{};default:return super.defaultValues(e)}}static compareWithDefault(e,t){switch(e){case Kn:return t.length===0;case Go:return t instanceof Object&&Object.keys(t).length===0;default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||v,value:[new Z({name:t.contentInfos||v,value:fe.schema()})]})}fromSchema(e){T(e,[vp]);const t=R(e,e,On.schema({names:{contentInfos:vp}}));O.assertSchema(t,this.className),this.safeContents=Array.from(t.result.contentInfos,s=>new fe({schema:s}))}toSchema(){return new A({value:Array.from(this.safeContents,e=>e.toSchema())})}toJSON(){return{safeContents:Array.from(this.safeContents,e=>e.toJSON())}}async parseInternalValues(e,t=Q(!0)){if(ne.assert(e,Kn),he.assert(e.safeContents,Kn,"Array"),e.safeContents.length!==this.safeContents.length)throw new he('Length of "parameters.safeContents" must be equal to "this.safeContents.length"');this.parsedValue={safeContents:[]};for(const[s,a]of this.safeContents.entries()){const n=e.safeContents[s],u="parameters.safeContents[".concat(s,"]");switch(a.contentType){case td:{he.assert(a.content,"this.safeContents[j].content",$);const i=a.content.getValue();this.parsedValue.safeContents.push({privacyMode:0,value:js.fromBER(i)})}break;case Og:{const i=new es({schema:a.content});ne.assert(u,n,"recipientCertificate","recipientKey");const l=n,o=l.recipientCertificate,c=l.recipientKey,m=await i.decrypt(0,{recipientCertificate:o,recipientPrivateKey:c},t);this.parsedValue.safeContents.push({privacyMode:2,value:js.fromBER(m)})}break;case Dg:{const i=new ds({schema:a.content});ne.assert(u,n,"password");const l=n.password,o=await i.decrypt({password:l},t);this.parsedValue.safeContents.push({privacyMode:1,value:js.fromBER(o)})}break;default:throw new Error('Unknown "contentType" for AuthenticatedSafe: " '.concat(a.contentType))}}}async makeInternalValues(e,t=Q(!0)){if(!this.parsedValue)throw new Error('Please run "parseValues" first or add "parsedValue" manually');if(he.assert(this.parsedValue,"this.parsedValue","object"),he.assert(this.parsedValue.safeContents,"this.parsedValue.safeContents","Array"),he.assert(e,"parameters","object"),ne.assert(e,"safeContents"),he.assert(e.safeContents,"parameters.safeContents","Array"),e.safeContents.length!==this.parsedValue.safeContents.length)throw new he('Length of "parameters.safeContents" must be equal to "this.parsedValue.safeContents"');this.safeContents=[];for(const[s,a]of this.parsedValue.safeContents.entries())switch(ne.assert("content",a,"privacyMode","value"),he.assert(a.value,"content.value",js),a.privacyMode){case 0:{const n=a.value.toSchema().toBER(!1);this.safeContents.push(new fe({contentType:"1.2.840.113549.1.7.1",content:new $({valueHex:n})}))}break;case 1:{const n=new ds,u=e.safeContents[s];u.contentToEncrypt=a.value.toSchema().toBER(!1),await n.encrypt(u,t),this.safeContents.push(new fe({contentType:"1.2.840.113549.1.7.6",content:n.toSchema()}))}break;case 2:{const n=new es,u=a.value.toSchema().toBER(!1),i=e.safeContents[s];switch(ne.assert("parameters.safeContents[".concat(s,"]"),i,"encryptingCertificate","encryptionAlgorithm"),!0){case i.encryptionAlgorithm.name.toLowerCase()==="aes-cbc":case i.encryptionAlgorithm.name.toLowerCase()==="aes-gcm":break;default:throw new Error('Incorrect parameter "encryptionAlgorithm" in "parameters.safeContents[i]": '.concat(i.encryptionAlgorithm))}switch(!0){case i.encryptionAlgorithm.length===128:case i.encryptionAlgorithm.length===192:case i.encryptionAlgorithm.length===256:break;default:throw new Error('Incorrect parameter "encryptionAlgorithm.length" in "parameters.safeContents[i]": '.concat(i.encryptionAlgorithm.length))}const l=i.encryptionAlgorithm;n.addRecipientByCertificate(i.encryptingCertificate,{},void 0,t),await n.encrypt(l,u,t),this.safeContents.push(new fe({contentType:"1.2.840.113549.1.7.3",content:n.toSchema()}))}break;default:throw new Error('Incorrect value for "content.privacyMode": '.concat(a.privacyMode))}return this}}On.CLASS_NAME="AuthenticatedSafe";const en="hashAlgorithm",Ti="issuerNameHash",Ri="issuerKeyHash",tn="serialNumber",dS=[en,Ti,Ri,tn];class Te extends D{static async create(e,t,s=Q(!0)){const a=new Te;return await a.createForCertificate(e,t,s),a}constructor(e={}){super(),this.hashAlgorithm=f(e,en,Te.defaultValues(en)),this.issuerNameHash=f(e,Ti,Te.defaultValues(Ti)),this.issuerKeyHash=f(e,Ri,Te.defaultValues(Ri)),this.serialNumber=f(e,tn,Te.defaultValues(tn)),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case en:return new V;case Ti:case Ri:return new $;case tn:return new B;default:return super.defaultValues(e)}}static compareWithDefault(e,t){switch(e){case en:return t.algorithmId===v&&!("algorithmParams"in t);case Ti:case Ri:case tn:return t.isEqual(Te.defaultValues(tn));default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||v,value:[V.schema(t.hashAlgorithmObject||{names:{blockName:t.hashAlgorithm||v}}),new $({name:t.issuerNameHash||v}),new $({name:t.issuerKeyHash||v}),new B({name:t.serialNumber||v})]})}fromSchema(e){T(e,dS);const t=R(e,e,Te.schema({names:{hashAlgorithm:en,issuerNameHash:Ti,issuerKeyHash:Ri,serialNumber:tn}}));O.assertSchema(t,this.className),this.hashAlgorithm=new V({schema:t.result.hashAlgorithm}),this.issuerNameHash=t.result.issuerNameHash,this.issuerKeyHash=t.result.issuerKeyHash,this.serialNumber=t.result.serialNumber}toSchema(){return new A({value:[this.hashAlgorithm.toSchema(),this.issuerNameHash,this.issuerKeyHash,this.serialNumber]})}toJSON(){return{hashAlgorithm:this.hashAlgorithm.toJSON(),issuerNameHash:this.issuerNameHash.toJSON(),issuerKeyHash:this.issuerKeyHash.toJSON(),serialNumber:this.serialNumber.toJSON()}}isEqual(e){return!(this.hashAlgorithm.algorithmId!==e.hashAlgorithm.algorithmId||!pe.isEqual(this.issuerNameHash.valueBlock.valueHexView,e.issuerNameHash.valueBlock.valueHexView)||!pe.isEqual(this.issuerKeyHash.valueBlock.valueHexView,e.issuerKeyHash.valueBlock.valueHexView)||!this.serialNumber.isEqual(e.serialNumber))}async createForCertificate(e,t,s=Q(!0)){ne.assert(t,en,"issuerCertificate");const a=s.getOIDByAlgorithm({name:t.hashAlgorithm},!0,"hashAlgorithm");this.hashAlgorithm=new V({algorithmId:a,algorithmParams:new Fe});const n=t.issuerCertificate;this.serialNumber=e.serialNumber;const u=await s.digest({name:t.hashAlgorithm},n.subject.toSchema().toBER(!1));this.issuerNameHash=new $({valueHex:u});const i=n.subjectPublicKeyInfo.subjectPublicKey.valueBlock.valueHexView,l=await s.digest({name:t.hashAlgorithm},i);this.issuerKeyHash=new $({valueHex:l})}}Te.CLASS_NAME="CertID";const Li="certID",Ui="certStatus",ji="thisUpdate",Tr="nextUpdate",sn="singleExtensions",pS=[Li,Ui,ji,Tr,sn];class ts extends D{constructor(e={}){super(),this.certID=f(e,Li,ts.defaultValues(Li)),this.certStatus=f(e,Ui,ts.defaultValues(Ui)),this.thisUpdate=f(e,ji,ts.defaultValues(ji)),Tr in e&&(this.nextUpdate=f(e,Tr,ts.defaultValues(Tr))),sn in e&&(this.singleExtensions=f(e,sn,ts.defaultValues(sn))),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case Li:return new Te;case Ui:return{};case ji:case Tr:return new Date(0,0,0);case sn:return[];default:return super.defaultValues(e)}}static compareWithDefault(e,t){switch(e){case Li:return Te.compareWithDefault("hashAlgorithm",t.hashAlgorithm)&&Te.compareWithDefault("issuerNameHash",t.issuerNameHash)&&Te.compareWithDefault("issuerKeyHash",t.issuerKeyHash)&&Te.compareWithDefault("serialNumber",t.serialNumber);case Ui:return Object.keys(t).length===0;case ji:case Tr:return t===ts.defaultValues(e);default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||v,value:[Te.schema(t.certID||{}),new Ne({value:[new _({name:t.certStatus||v,idBlock:{tagClass:3,tagNumber:0}}),new I({name:t.certStatus||v,idBlock:{tagClass:3,tagNumber:1},value:[new ke,new I({optional:!0,idBlock:{tagClass:3,tagNumber:0},value:[new Yl]})]}),new _({name:t.certStatus||v,idBlock:{tagClass:3,tagNumber:2},lenBlock:{length:1}})]}),new ke({name:t.thisUpdate||v}),new I({optional:!0,idBlock:{tagClass:3,tagNumber:0},value:[new ke({name:t.nextUpdate||v})]}),new I({optional:!0,idBlock:{tagClass:3,tagNumber:1},value:[je.schema(t.singleExtensions||{})]})]})}fromSchema(e){T(e,pS);const t=R(e,e,ts.schema({names:{certID:{names:{blockName:Li}},certStatus:Ui,thisUpdate:ji,nextUpdate:Tr,singleExtensions:{names:{blockName:sn}}}}));O.assertSchema(t,this.className),this.certID=new Te({schema:t.result.certID}),this.certStatus=t.result.certStatus,this.thisUpdate=t.result.thisUpdate.toDate(),Tr in t.result&&(this.nextUpdate=t.result.nextUpdate.toDate()),sn in t.result&&(this.singleExtensions=Array.from(t.result.singleExtensions.valueBlock.value,s=>new De({schema:s})))}toSchema(){const e=[];return e.push(this.certID.toSchema()),e.push(this.certStatus),e.push(new ke({valueDate:this.thisUpdate})),this.nextUpdate&&e.push(new I({idBlock:{tagClass:3,tagNumber:0},value:[new ke({valueDate:this.nextUpdate})]})),this.singleExtensions&&e.push(new A({value:Array.from(this.singleExtensions,t=>t.toSchema())})),new A({value:e})}toJSON(){const e={certID:this.certID.toJSON(),certStatus:this.certStatus.toJSON(),thisUpdate:this.thisUpdate};return this.nextUpdate&&(e.nextUpdate=this.nextUpdate),this.singleExtensions&&(e.singleExtensions=Array.from(this.singleExtensions,t=>t.toJSON())),e}}ts.CLASS_NAME="SingleResponse";const jc="tbs",rn="version",xl="responderID",Il="producedAt",Vl="responses",$i="responseExtensions",Rn="ResponseData",eh="".concat(Rn,".").concat(rn),Ki="".concat(Rn,".").concat(xl),df="".concat(Rn,".").concat(Il),pf="".concat(Rn,".").concat(Vl),th="".concat(Rn,".").concat($i),gS=[Rn,eh,Ki,df,pf,th];class ze extends D{get tbs(){return pe.toArrayBuffer(this.tbsView)}set tbs(e){this.tbsView=new Uint8Array(e)}constructor(e={}){super(),this.tbsView=new Uint8Array(f(e,jc,ze.defaultValues(jc))),rn in e&&(this.version=f(e,rn,ze.defaultValues(rn))),this.responderID=f(e,xl,ze.defaultValues(xl)),this.producedAt=f(e,Il,ze.defaultValues(Il)),this.responses=f(e,Vl,ze.defaultValues(Vl)),$i in e&&(this.responseExtensions=f(e,$i,ze.defaultValues($i))),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case rn:return 0;case jc:return Ue;case xl:return{};case Il:return new Date(0,0,0);case Vl:case $i:return[];default:return super.defaultValues(e)}}static compareWithDefault(e,t){switch(e){case jc:return t.byteLength===0;case xl:return Object.keys(t).length===0;case Il:return t===ze.defaultValues(e);case Vl:case $i:return t.length===0;default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||Rn,value:[new I({optional:!0,idBlock:{tagClass:3,tagNumber:0},value:[new B({name:t.version||eh})]}),new Ne({value:[new I({name:t.responderID||Ki,idBlock:{tagClass:3,tagNumber:1},value:[me.schema(t.ResponseDataByName||{names:{blockName:"ResponseData.byName"}})]}),new I({name:t.responderID||Ki,idBlock:{tagClass:3,tagNumber:2},value:[new $({name:t.ResponseDataByKey||"ResponseData.byKey"})]})]}),new ke({name:t.producedAt||df}),new A({value:[new Z({name:pf,value:ts.schema(t.response||{})})]}),new I({optional:!0,idBlock:{tagClass:3,tagNumber:1},value:[je.schema(t.extensions||{names:{blockName:th}})]})]})}fromSchema(e){T(e,gS);const t=R(e,e,ze.schema());O.assertSchema(t,this.className),this.tbsView=t.result.ResponseData.valueBeforeDecodeView,eh in t.result&&(this.version=t.result[eh].valueBlock.valueDec),t.result[Ki].idBlock.tagNumber===1?this.responderID=new me({schema:t.result[Ki].valueBlock.value[0]}):this.responderID=t.result[Ki].valueBlock.value[0],this.producedAt=t.result[df].toDate(),this.responses=Array.from(t.result[pf],s=>new ts({schema:s})),th in t.result&&(this.responseExtensions=Array.from(t.result[th].valueBlock.value,s=>new De({schema:s})))}toSchema(e=!1){let t;if(e===!1){if(!this.tbsView.byteLength)return ze.schema();const s=Le(this.tbsView);O.assert(s,"TBS Response Data"),t=s.result}else{const s=[];rn in this&&s.push(new I({idBlock:{tagClass:3,tagNumber:0},value:[new B({value:this.version})]})),this.responderID instanceof me?s.push(new I({idBlock:{tagClass:3,tagNumber:1},value:[this.responderID.toSchema()]})):s.push(new I({idBlock:{tagClass:3,tagNumber:2},value:[this.responderID]})),s.push(new ke({valueDate:this.producedAt})),s.push(new A({value:Array.from(this.responses,a=>a.toSchema())})),this.responseExtensions&&s.push(new I({idBlock:{tagClass:3,tagNumber:1},value:[new A({value:Array.from(this.responseExtensions,a=>a.toSchema())})]})),t=new A({value:s})}return t}toJSON(){const e={};return rn in this&&(e.version=this.version),this.responderID&&(e.responderID=this.responderID),this.producedAt&&(e.producedAt=this.producedAt),this.responses&&(e.responses=Array.from(this.responses,t=>t.toJSON())),this.responseExtensions&&(e.responseExtensions=Array.from(this.responseExtensions,t=>t.toJSON())),e}}ze.CLASS_NAME="ResponseData";const Dm="trustedCerts",Tm="certs",Rm="crls",Lm="ocsps",Um="checkDate",jm="findOrigin",$m="findIssuer";var dn;(function(r){r[r.unknown=-1]="unknown",r[r.success=0]="success",r[r.noRevocation=11]="noRevocation",r[r.noPath=60]="noPath",r[r.noValidPath=97]="noValidPath"})(dn||(dn={}));class qr extends Error{constructor(e,t){super(t),this.name=qr.NAME,this.code=e,this.message=t}}qr.NAME="ChainValidationError";function wS(r,e){for(let t=0;t<e.length;t++)if(pe.isEqual(r.tbsView,e[t].tbsView))return!0;return!1}class Zh{constructor(e={}){this.trustedCerts=f(e,Dm,this.defaultValues(Dm)),this.certs=f(e,Tm,this.defaultValues(Tm)),this.crls=f(e,Rm,this.defaultValues(Rm)),this.ocsps=f(e,Lm,this.defaultValues(Lm)),this.checkDate=f(e,Um,this.defaultValues(Um)),this.findOrigin=f(e,jm,this.defaultValues(jm)),this.findIssuer=f(e,$m,this.defaultValues($m))}static defaultFindOrigin(e,t){e.tbsView.byteLength===0&&(e.tbsView=new Uint8Array(e.encodeTBS().toBER()));for(const s of t.certs)if(s.tbsView.byteLength===0&&(s.tbsView=new Uint8Array(s.encodeTBS().toBER())),pe.isEqual(e.tbsView,s.tbsView))return"Intermediate Certificates";for(const s of t.trustedCerts)if(s.tbsView.byteLength===0&&(s.tbsView=new Uint8Array(s.encodeTBS().toBER())),pe.isEqual(e.tbsView,s.tbsView))return"Trusted Certificates";return"Unknown"}async defaultFindIssuer(e,t,s=Q(!0)){const a=[];let n=null,u=null,i=null;if(e.subject.isEqual(e.issuer))try{if(await e.verify(void 0,s))return[e]}catch(o){}if(e.extensions){for(const o of e.extensions)if(o.extnID===Yf&&o.parsedValue instanceof Xr){o.parsedValue.keyIdentifier?n=o.parsedValue.keyIdentifier:(o.parsedValue.authorityCertIssuer&&(u=o.parsedValue.authorityCertIssuer),o.parsedValue.authorityCertSerialNumber&&(i=o.parsedValue.authorityCertSerialNumber));break}}function l(o){if(n!==null&&o.extensions){let m=!1;for(const h of o.extensions)if(h.extnID===S0&&h.parsedValue){m=!0,pe.isEqual(h.parsedValue.valueBlock.valueHex,n.valueBlock.valueHexView)&&a.push(o);break}if(m)return}let c=!1;i!==null&&(c=o.serialNumber.isEqual(i)),u!==null?o.subject.isEqual(u)&&c&&a.push(o):e.issuer.isEqual(o.subject)&&a.push(o)}for(const o of t.trustedCerts)l(o);for(const o of t.certs)l(o);for(let o=a.length-1;o>=0;o--)try{await e.verify(a[o],s)===!1&&a.splice(o,1)}catch(c){a.splice(o,1)}return a}defaultValues(e){switch(e){case Dm:return[];case Tm:return[];case Rm:return[];case Lm:return[];case Um:return new Date;case jm:return Zh.defaultFindOrigin;case $m:return this.defaultFindIssuer;default:throw new Error("Invalid member name for CertificateChainValidationEngine class: ".concat(e))}}async sort(e=!1,t=Q(!0)){const s=[],a=async(d,w)=>{const y=[];function k(b){let N=!0;for(let S=0;S<b.length;S++){for(let E=0;E<b.length;E++)if(E!==S&&b[S]===b[E]){N=!1;break}if(!N)break}return N}if(wS(d,this.trustedCerts))return[[d]];const g=await this.findIssuer(d,this,w);if(g.length===0)throw new Error("No valid certificate paths found");for(let b=0;b<g.length;b++){if(pe.isEqual(g[b].tbsView,d.tbsView)){y.push([g[b]]);continue}const N=await a(g[b],w);for(let S=0;S<N.length;S++){const E=N[S].slice();E.splice(0,0,g[b]),k(E)?y.push(E):y.push(N[S])}}return y},n=async d=>{const w=[],y=[],k=[];if(w.push(...s.filter(g=>d.issuer.isEqual(g.subject))),w.length===0)return{status:1,statusMessage:"No certificate's issuers"};if(y.push(...this.crls.filter(g=>g.issuer.isEqual(d.issuer))),y.length===0)return{status:2,statusMessage:"No CRLs for specific certificate issuer"};for(let g=0;g<y.length;g++){const b=y[g];if(!(b.nextUpdate&&b.nextUpdate.value<this.checkDate))for(let N=0;N<w.length;N++)try{if(await y[g].verify({issuerCertificate:w[N]},t)){k.push({crl:y[g],certificate:w[N]});break}}catch(S){}}return k.length?{status:0,statusMessage:v,result:k}:{status:3,statusMessage:"No valid CRLs found"}},u=async(d,w)=>{const y=t.getAlgorithmByOID(d.signatureAlgorithm.algorithmId);if(!y.name||!y.hash)return 1;for(let k=0;k<this.ocsps.length;k++){const g=await this.ocsps[k].getCertificateStatus(d,w,t);if(g.isForCertificate)return g.status===0?0:1}return 2};async function i(d,w=!1){let y=!1,k=!1,g=!1,b=!1;if(d.extensions){for(let N=0;N<d.extensions.length;N++){const S=d.extensions[N];if(S.critical&&!S.parsedValue)return{result:!1,resultCode:6,resultMessage:"Unable to parse critical certificate extension: ".concat(S.extnID)};if(S.extnID===A0){g=!0;const E=new Uint8Array(S.parsedValue.valueBlock.valueHex);(E[0]&4)===4&&(k=!0),(E[0]&2)===2&&(b=!0)}S.extnID===Zf&&"cA"in S.parsedValue&&S.parsedValue.cA===!0&&(y=!0)}if(k===!0&&y===!1)return{result:!1,resultCode:3,resultMessage:'Unable to build certificate chain - using "keyCertSign" flag set without BasicConstraints'};if(g===!0&&y===!0&&k===!1)return{result:!1,resultCode:4,resultMessage:'Unable to build certificate chain - "keyCertSign" flag was not set'};if(y===!0&&g===!0&&w&&b===!1)return{result:!1,resultCode:5,resultMessage:'Unable to build certificate chain - intermediate certificate must have "cRLSign" key usage flag'}}return y===!1?{result:!1,resultCode:7,resultMessage:"Unable to build certificate chain - more than one possible end-user certificate"}:{result:!0,resultCode:0,resultMessage:v}}const l=async(d,w)=>{for(let y=0;y<d.length;y++)if(d[y].notBefore.value>w||d[y].notAfter.value<w)return{result:!1,resultCode:8,resultMessage:"The certificate is either not yet valid or expired"};if(d.length<2)return{result:!1,resultCode:9,resultMessage:"Too short certificate path"};for(let y=d.length-2;y>=0;y--)if(d[y].issuer.isEqual(d[y].subject)===!1&&d[y].issuer.isEqual(d[y+1].subject)===!1)return{result:!1,resultCode:10,resultMessage:"Incorrect name chaining"};if(this.crls.length!==0||this.ocsps.length!==0)for(let y=0;y<d.length-1;y++){let k=2,g={status:0,statusMessage:v};if(this.ocsps.length!==0)switch(k=await u(d[y],d[y+1]),k){case 0:continue;case 1:return{result:!1,resultCode:12,resultMessage:"One of certificates was revoked via OCSP response"}}if(this.crls.length!==0){if(g=await n(d[y]),g.status===0&&g.result)for(let b=0;b<g.result.length;b++){if(g.result[b].crl.isCertificateRevoked(d[y]))return{result:!1,resultCode:12,resultMessage:"One of certificates had been revoked"};if((await i(g.result[b].certificate,!0)).result===!1)return{result:!1,resultCode:13,resultMessage:"CRL issuer certificate is not a CA certificate or does not have crlSign flag"}}else if(e===!1)throw new qr(dn.noRevocation,"No revocation values found for one of certificates: ".concat(g.statusMessage))}else if(k===2)return{result:!1,resultCode:11,resultMessage:"No revocation values found for one of certificates"};if(k===2&&g.status===2&&e){const b=d[y+1];let N=!1;if(b.extensions)for(const S of b.extensions)switch(S.extnID){case xg:case Qf:case ed:N=!0;break}if(N)throw new qr(dn.noRevocation,"No revocation values found for one of certificates: ".concat(g.statusMessage))}}for(const[y,k]of d.entries())if(y&&!(await i(k)).result)return{result:!1,resultCode:14,resultMessage:"One of intermediate certificates is not a CA certificate"};return{result:!0}};s.push(...this.trustedCerts),s.push(...this.certs);for(let d=0;d<s.length;d++)for(let w=0;w<s.length;w++)if(d!==w&&pe.isEqual(s[d].tbsView,s[w].tbsView)){s.splice(w,1),d=0;break}const o=s[s.length-1];let c;const m=[o];if(c=await a(o,t),c.length===0)throw new qr(dn.noPath,"Unable to find certificate path");for(let d=c.length-1;d>=0;d--){let w=!1;for(let y=0;y<c[d].length;y++){const k=c[d][y];for(let g=0;g<this.trustedCerts.length;g++)if(pe.isEqual(k.tbsView,this.trustedCerts[g].tbsView)){w=!0;break}if(w)break}w||c.splice(d,1)}if(c.length===0)throw new qr(dn.noValidPath,"No valid certificate paths found");let h=c[0].length,p=0;for(let d=0;d<c.length;d++)c[d].length<h&&(h=c[d].length,p=d);for(let d=0;d<c[p].length;d++)m.push(c[p][d]);if(c=await l(m,this.checkDate),c.result===!1)throw c;return m}async verify(e={},t=Q(!0)){function s(l,o){const c=Hr(l),m=Hr(o),h=c.split("."),p=m.split("."),d=h.length,w=p.length;if(d===0||w===0||d<w)return!1;for(let y=0;y<d;y++)if(h[y].length===0)return!1;for(let y=0;y<w;y++)if(p[y].length===0){if(y===0){if(w===1)return!1;continue}return!1}for(let y=0;y<w;y++)if(p[w-1-y].length!==0&&h[d-1-y].localeCompare(p[w-1-y])!==0)return!1;return!0}function a(l,o){const c=Hr(l),m=Hr(o),h=c.split("@"),p=m.split("@");if(h.length===0||p.length===0||h.length<p.length)return!1;if(p.length===1){if(s(h[1],p[0])){const d=h[1].split("."),w=p[0].split(".");return w[0].length===0?!0:d.length===w.length}return!1}return c.localeCompare(m)===0}function n(l,o){let c=Hr(l);const m=Hr(o),h=c.split("/");if(m.split("/").length>1)return!1;if(h.length>1){for(let p=0;p<h.length;p++)if(h[p].length>0&&h[p].charAt(h[p].length-1)!==":"){c=h[p].split(":")[0];break}}if(s(c,m)){const p=c.split("."),d=m.split(".");return d[0].length===0?!0:p.length===d.length}return!1}function u(l,o){const c=l.valueBlock.valueHexView,m=o.valueBlock.valueHexView;if(c.length===4&&m.length===8){for(let h=0;h<4;h++)if((c[h]^m[h])&m[h+4])return!1;return!0}if(c.length===16&&m.length===32){for(let h=0;h<16;h++)if((c[h]^m[h])&m[h+16])return!1;return!0}return!1}function i(l,o){if(l.typesAndValues.length===0||o.typesAndValues.length===0)return!0;if(l.typesAndValues.length<o.typesAndValues.length)return!1;let c=!0,m=0;for(let h=0;h<o.typesAndValues.length;h++){let p=!1;for(let d=m;d<l.typesAndValues.length;d++)if(p=l.typesAndValues[d].isEqual(o.typesAndValues[h]),l.typesAndValues[d].type===o.typesAndValues[h].type&&(c=c&&p),p===!0)if(m===0||m===d){m=d+1;break}else return!1;if(p===!1)return!1}return m===0?!1:c}try{if(this.certs.length===0)throw new Error("Empty certificate array");const l=e.passedWhenNotRevValues||!1,o=e.initialPolicySet||[$t],c=e.initialExplicitPolicy||!1,m=e.initialPolicyMappingInhibit||!1,h=e.initialInhibitPolicy||!1,p=e.initialPermittedSubtreesSet||[],d=e.initialExcludedSubtreesSet||[],w=e.initialRequiredNameForms||[];let y=c,k=m,g=h;const b=[!1,!1,!1];let N=0,S=0,E=0,x=p,C=d;const P=w;let K=1;this.certs=await this.sort(l,t);const L=[];L.push($t);const j=[],U=new Array(this.certs.length-1);for(let F=0;F<this.certs.length-1;F++)U[F]=!0;j.push(U);const M=new Array(this.certs.length-1),G=new Array(this.certs.length-1);let we=y?this.certs.length-1:-1;for(let F=this.certs.length-2;F>=0;F--,K++){const W=this.certs[F];if(W.extensions){for(let q=0;q<W.extensions.length;q++){const ee=W.extensions[q];if(ee.extnID===Ig){G[F]=ee.parsedValue;for(let ie=0;ie<L.length;ie++)if(L[ie]===$t){delete j[ie][F];break}for(let ie=0;ie<ee.parsedValue.certificatePolicies.length;ie++){let xe=-1;const _t=ee.parsedValue.certificatePolicies[ie].policyIdentifier;for(let Ie=0;Ie<L.length;Ie++)if(_t===L[Ie]){xe=Ie;break}if(xe===-1){L.push(_t);const Ie=new Array(this.certs.length-1);Ie[F]=!0,j.push(Ie)}else j[xe][F]=!0}}if(ee.extnID===Vg){if(k)return{result:!1,resultCode:98,resultMessage:"Policy mapping prohibited"};M[F]=ee.parsedValue}ee.extnID===Bg&&y===!1&&(ee.parsedValue.requireExplicitPolicy===0?(y=!0,we=F):b[0]===!1?(b[0]=!0,N=ee.parsedValue.requireExplicitPolicy):N=N>ee.parsedValue.requireExplicitPolicy?ee.parsedValue.requireExplicitPolicy:N,ee.parsedValue.inhibitPolicyMapping===0?k=!0:b[1]===!1?(b[1]=!0,S=ee.parsedValue.inhibitPolicyMapping+1):S=S>ee.parsedValue.inhibitPolicyMapping+1?ee.parsedValue.inhibitPolicyMapping+1:S),ee.extnID===B0&&g===!1&&(ee.parsedValue.valueBlock.valueDec===0?g=!0:b[2]===!1?(b[2]=!0,E=ee.parsedValue.valueBlock.valueDec):E=E>ee.parsedValue.valueBlock.valueDec?ee.parsedValue.valueBlock.valueDec:E)}if(g===!0){let q=-1;for(let ee=0;ee<L.length;ee++)if(L[ee]===$t){q=ee;break}q!==-1&&delete j[0][F]}y===!1&&b[0]===!0&&(N--,N===0&&(y=!0,we=F,b[0]=!1)),k===!1&&b[1]===!0&&(S--,S===0&&(k=!0,b[1]=!1)),g===!1&&b[2]===!0&&(E--,E===0&&(g=!0,b[2]=!1))}}for(let F=0;F<this.certs.length-1;F++)if(F<this.certs.length-2&&typeof M[F+1]<"u")for(let W=0;W<M[F+1].mappings.length;W++){if(M[F+1].mappings[W].issuerDomainPolicy===$t||M[F+1].mappings[W].subjectDomainPolicy===$t)return{result:!1,resultCode:99,resultMessage:'The "anyPolicy" should not be a part of policy mapping scheme'};let q=-1,ee=-1;for(let ie=0;ie<L.length;ie++)L[ie]===M[F+1].mappings[W].issuerDomainPolicy&&(q=ie),L[ie]===M[F+1].mappings[W].subjectDomainPolicy&&(ee=ie);typeof j[q][F]<"u"&&delete j[q][F];for(let ie=0;ie<G[F].certificatePolicies.length;ie++)if(M[F+1].mappings[W].subjectDomainPolicy===G[F].certificatePolicies[ie].policyIdentifier&&q!==-1&&ee!==-1)for(let xe=0;xe<=F;xe++)typeof j[ee][xe]<"u"&&(j[q][xe]=!0,delete j[ee][xe])}for(let F=0;F<L.length;F++)if(L[F]===$t)for(let W=0;W<we;W++)delete j[F][W];const ae=[];for(let F=0;F<j.length;F++){let W=!0;for(let q=0;q<this.certs.length-1;q++){let ee=!1;if(q<we&&L[F]===$t&&L.length>1){W=!1;break}if(typeof j[F][q]>"u"){if(q>=we){for(let ie=0;ie<L.length;ie++)if(L[ie]===$t){j[ie][q]===!0&&(ee=!0);break}}if(!ee){W=!1;break}}}W===!0&&ae.push(L[F])}let Y=[];if(o.length===1&&o[0]===$t&&y===!1)Y=o;else if(ae.length===1&&ae[0]===$t)Y=o;else for(let F=0;F<ae.length;F++)for(let W=0;W<o.length;W++)if(o[W]===ae[F]||o[W]===$t){Y.push(ae[F]);break}const se={result:Y.length>0,resultCode:0,resultMessage:Y.length>0?v:'Zero "userConstrPolicies" array, no intersections with "authConstrPolicies"',authConstrPolicies:ae,userConstrPolicies:Y,explicitPolicyIndicator:y,policyMappings:M,certificatePath:this.certs};if(Y.length===0||se.result===!1)return se;K=1;for(let F=this.certs.length-2;F>=0;F--,K++){const W=this.certs[F];let q=[],ee=[],ie=[];if(W.extensions)for(let le=0;le<W.extensions.length;le++){const z=W.extensions[le];z.extnID===Eg&&("permittedSubtrees"in z.parsedValue&&(ee=ee.concat(z.parsedValue.permittedSubtrees)),"excludedSubtrees"in z.parsedValue&&(ie=ie.concat(z.parsedValue.excludedSubtrees))),z.extnID===Ag&&(q=q.concat(z.parsedValue.altNames))}let xe=P.length<=0;for(let le=0;le<P.length;le++)switch(P[le].base.type){case 4:{if(P[le].base.value.typesAndValues.length!==W.subject.typesAndValues.length)continue;xe=!0;for(let z=0;z<W.subject.typesAndValues.length;z++)if(W.subject.typesAndValues[z].type!==P[le].base.value.typesAndValues[z].type){xe=!1;break}if(xe===!0)break}break;default:}if(xe===!1)throw se.result=!1,se.resultCode=21,se.resultMessage="No necessary name form found",se;const _t=[[],[],[],[],[]];for(let le=0;le<x.length;le++)switch(x[le].base.type){case 1:_t[0].push(x[le]);break;case 2:_t[1].push(x[le]);break;case 4:_t[2].push(x[le]);break;case 6:_t[3].push(x[le]);break;case 7:_t[4].push(x[le]);break;default:}for(let le=0;le<5;le++){let z=!1,ua=!1;const Ws=_t[le];for(let Gs=0;Gs<Ws.length;Gs++){switch(le){case 0:if(q.length>0)for(let ye=0;ye<q.length;ye++)q[ye].type===1&&(ua=!0,z=z||a(q[ye].value,Ws[Gs].base.value));else for(let ye=0;ye<W.subject.typesAndValues.length;ye++)(W.subject.typesAndValues[ye].type==="1.2.840.113549.1.9.1"||W.subject.typesAndValues[ye].type==="0.9.2342.19200300.100.1.3")&&(ua=!0,z=z||a(W.subject.typesAndValues[ye].value.valueBlock.value,Ws[Gs].base.value));break;case 1:if(q.length>0)for(let ye=0;ye<q.length;ye++)q[ye].type===2&&(ua=!0,z=z||s(q[ye].value,Ws[Gs].base.value));break;case 2:ua=!0,z=i(W.subject,Ws[Gs].base.value);break;case 3:if(q.length>0)for(let ye=0;ye<q.length;ye++)q[ye].type===6&&(ua=!0,z=z||n(q[ye].value,Ws[Gs].base.value));break;case 4:if(q.length>0)for(let ye=0;ye<q.length;ye++)q[ye].type===7&&(ua=!0,z=z||u(q[ye].value,Ws[Gs].base.value));break;default:}if(z)break}if(z===!1&&Ws.length>0&&ua)throw se.result=!1,se.resultCode=41,se.resultMessage='Failed to meet "permitted sub-trees" name constraint',se}let Ie=!1;for(let le=0;le<C.length;le++){switch(C[le].base.type){case 1:if(q.length>=0)for(let z=0;z<q.length;z++)q[z].type===1&&(Ie=Ie||a(q[z].value,C[le].base.value));else for(let z=0;z<W.subject.typesAndValues.length;z++)(W.subject.typesAndValues[z].type==="1.2.840.113549.1.9.1"||W.subject.typesAndValues[z].type==="0.9.2342.19200300.100.1.3")&&(Ie=Ie||a(W.subject.typesAndValues[z].value.valueBlock.value,C[le].base.value));break;case 2:if(q.length>0)for(let z=0;z<q.length;z++)q[z].type===2&&(Ie=Ie||s(q[z].value,C[le].base.value));break;case 4:Ie=Ie||i(W.subject,C[le].base.value);break;case 6:if(q.length>0)for(let z=0;z<q.length;z++)q[z].type===6&&(Ie=Ie||n(q[z].value,C[le].base.value));break;case 7:if(q.length>0)for(let z=0;z<q.length;z++)q[z].type===7&&(Ie=Ie||u(q[z].value,C[le].base.value));break;default:}if(Ie)break}if(Ie===!0)throw se.result=!1,se.resultCode=42,se.resultMessage='Failed to meet "excluded sub-trees" name constraint',se;x=x.concat(ee),C=C.concat(ie)}return se}catch(l){return l instanceof Error?l instanceof qr?{result:!1,resultCode:l.code,resultMessage:l.message,error:l}:{result:!1,resultCode:dn.unknown,resultMessage:l.message,error:l}:l&&typeof l=="object"&&"resultMessage"in l?l:{result:!1,resultCode:-1,resultMessage:"".concat(l)}}}}const sh="tbsResponseData",Bl="signatureAlgorithm",Pl="signature",Hi="certs",hc="BasicOCSPResponse",gf="".concat(hc,".").concat(sh),wf="".concat(hc,".").concat(Bl),yf="".concat(hc,".").concat(Pl),rh="".concat(hc,".").concat(Hi),yS=[gf,wf,yf,rh];class qt extends D{constructor(e={}){super(),this.tbsResponseData=f(e,sh,qt.defaultValues(sh)),this.signatureAlgorithm=f(e,Bl,qt.defaultValues(Bl)),this.signature=f(e,Pl,qt.defaultValues(Pl)),Hi in e&&(this.certs=f(e,Hi,qt.defaultValues(Hi))),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case sh:return new ze;case Bl:return new V;case Pl:return new re;case Hi:return[];default:return super.defaultValues(e)}}static compareWithDefault(e,t){switch(e){case"type":{let s=ze.compareWithDefault("tbs",t.tbs)&&ze.compareWithDefault("responderID",t.responderID)&&ze.compareWithDefault("producedAt",t.producedAt)&&ze.compareWithDefault("responses",t.responses);return"responseExtensions"in t&&(s=s&&ze.compareWithDefault("responseExtensions",t.responseExtensions)),s}case Bl:return t.algorithmId===v&&!("algorithmParams"in t);case Pl:return t.isEqual(qt.defaultValues(e));case Hi:return t.length===0;default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||hc,value:[ze.schema(t.tbsResponseData||{names:{blockName:gf}}),V.schema(t.signatureAlgorithm||{names:{blockName:wf}}),new re({name:t.signature||yf}),new I({optional:!0,idBlock:{tagClass:3,tagNumber:0},value:[new A({value:[new Z({name:rh,value:oe.schema(t.certs||{})})]})]})]})}fromSchema(e){T(e,yS);const t=R(e,e,qt.schema());O.assertSchema(t,this.className),this.tbsResponseData=new ze({schema:t.result[gf]}),this.signatureAlgorithm=new V({schema:t.result[wf]}),this.signature=t.result[yf],rh in t.result&&(this.certs=Array.from(t.result[rh],s=>new oe({schema:s})))}toSchema(){const e=[];return e.push(this.tbsResponseData.toSchema()),e.push(this.signatureAlgorithm.toSchema()),e.push(this.signature),this.certs&&e.push(new I({idBlock:{tagClass:3,tagNumber:0},value:[new A({value:Array.from(this.certs,t=>t.toSchema())})]})),new A({value:e})}toJSON(){const e={tbsResponseData:this.tbsResponseData.toJSON(),signatureAlgorithm:this.signatureAlgorithm.toJSON(),signature:this.signature.toJSON()};return this.certs&&(e.certs=Array.from(this.certs,t=>t.toJSON())),e}async getCertificateStatus(e,t,s=Q(!0)){const a={isForCertificate:!1,status:2},n={},u=[];for(const i of this.tbsResponseData.responses){const l=s.getAlgorithmByOID(i.certID.hashAlgorithm.algorithmId,!0,"CertID.hashAlgorithm");if(!n[l.name]){n[l.name]=1;const o=new Te;u.push(o),await o.createForCertificate(e,{hashAlgorithm:l.name,issuerCertificate:t},s)}}for(const i of this.tbsResponseData.responses)for(const l of u)if(i.certID.isEqual(l)){a.isForCertificate=!0;try{switch(i.certStatus.idBlock.isConstructed){case!0:i.certStatus.idBlock.tagNumber===1&&(a.status=1);break;case!1:switch(i.certStatus.idBlock.tagNumber){case 0:a.status=0;break;case 2:a.status=2;break;default:}break;default:}}catch(o){}return a}return a}async sign(e,t="SHA-1",s=Q(!0)){if(!e)throw new Error("Need to provide a private key for signing");const a=await s.getSignatureParameters(e,t),n=a.parameters.algorithm;if(!("name"in n))throw new Error("Empty algorithm");this.signatureAlgorithm=a.signatureAlgorithm,this.tbsResponseData.tbsView=new Uint8Array(this.tbsResponseData.toSchema(!0).toBER());const u=await s.signWithPrivateKey(this.tbsResponseData.tbsView,e,{algorithm:n});this.signature=new re({valueHex:u})}async verify(e={},t=Q(!0)){let s=null,a=-1;const n=e.trustedCerts||[];if(!this.certs)throw new Error("No certificates attached to the BasicOCSPResponse");switch(!0){case this.tbsResponseData.responderID instanceof me:for(const[i,l]of this.certs.entries())if(l.subject.isEqual(this.tbsResponseData.responderID)){a=i;break}break;case this.tbsResponseData.responderID instanceof $:for(const[i,l]of this.certs.entries()){const o=await t.digest({name:"sha-1"},l.subjectPublicKeyInfo.subjectPublicKey.valueBlock.valueHexView);if(Zl(o,this.tbsResponseData.responderID.valueBlock.valueHex)){a=i;break}}break;default:throw new Error("Wrong value for responderID")}if(a===-1)throw new Error("Correct certificate was not found in OCSP response");s=this.certs[a];const u=[s];for(const i of this.certs){const l=await $g(i,s);l&&u.push(l)}if(!(await new Zh({certs:u,trustedCerts:n}).verify({},t)).result)throw new Error("Validation of signer's certificate failed");return t.verifyWithPublicKey(this.tbsResponseData.tbsView,this.signature,this.certs[a].subjectPublicKeyInfo,this.signatureAlgorithm)}}qt.CLASS_NAME="BasicOCSPResponse";const Km="tbs",Hm="version",Mm="subject",Fm="subjectPublicKeyInfo",Hn="attributes",Ol="signatureAlgorithm",Dl="signatureValue",Vo="CertificationRequestInfo",ld="".concat(Vo,".version"),cd="".concat(Vo,".subject"),hd="".concat(Vo,".subjectPublicKeyInfo"),Fh="".concat(Vo,".attributes"),vS=[Vo,ld,cd,hd,Fh,Ol,Dl];function bS(r={}){const e=f(r,"names",{});return new A({name:e.CertificationRequestInfo||Vo,value:[new B({name:e.CertificationRequestInfoVersion||ld}),me.schema(e.subject||{names:{blockName:cd}}),Ct.schema({names:{blockName:hd}}),new I({optional:!0,idBlock:{tagClass:3,tagNumber:0},value:[new Z({optional:!0,name:e.CertificationRequestInfoAttributes||Fh,value:ge.schema(e.attributes||{})})]})]})}class Yt extends D{get tbs(){return pe.toArrayBuffer(this.tbsView)}set tbs(e){this.tbsView=new Uint8Array(e)}constructor(e={}){super(),this.tbsView=new Uint8Array(f(e,Km,Yt.defaultValues(Km))),this.version=f(e,Hm,Yt.defaultValues(Hm)),this.subject=f(e,Mm,Yt.defaultValues(Mm)),this.subjectPublicKeyInfo=f(e,Fm,Yt.defaultValues(Fm)),Hn in e&&(this.attributes=f(e,Hn,Yt.defaultValues(Hn))),this.signatureAlgorithm=f(e,Ol,Yt.defaultValues(Ol)),this.signatureValue=f(e,Dl,Yt.defaultValues(Dl)),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case Km:return Ue;case Hm:return 0;case Mm:return new me;case Fm:return new Ct;case Hn:return[];case Ol:return new V;case Dl:return new re;default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({value:[bS(t.certificationRequestInfo||{}),new A({name:t.signatureAlgorithm||Ol,value:[new J,new X({optional:!0})]}),new re({name:t.signatureValue||Dl})]})}fromSchema(e){T(e,vS);const t=R(e,e,Yt.schema());O.assertSchema(t,this.className),this.tbsView=t.result.CertificationRequestInfo.valueBeforeDecodeView,this.version=t.result[ld].valueBlock.valueDec,this.subject=new me({schema:t.result[cd]}),this.subjectPublicKeyInfo=new Ct({schema:t.result[hd]}),Fh in t.result&&(this.attributes=Array.from(t.result[Fh],s=>new ge({schema:s}))),this.signatureAlgorithm=new V({schema:t.result.signatureAlgorithm}),this.signatureValue=t.result.signatureValue}encodeTBS(){const e=[new B({value:this.version}),this.subject.toSchema(),this.subjectPublicKeyInfo.toSchema()];return Hn in this&&e.push(new I({idBlock:{tagClass:3,tagNumber:0},value:Array.from(this.attributes||[],t=>t.toSchema())})),new A({value:e})}toSchema(e=!1){let t;if(e===!1){if(this.tbsView.byteLength===0)return Yt.schema();const s=Le(this.tbsView);O.assert(s,"PKCS#10 Certificate Request"),t=s.result}else t=this.encodeTBS();return new A({value:[t,this.signatureAlgorithm.toSchema(),this.signatureValue]})}toJSON(){const e={tbs:ce.ToHex(this.tbsView),version:this.version,subject:this.subject.toJSON(),subjectPublicKeyInfo:this.subjectPublicKeyInfo.toJSON(),signatureAlgorithm:this.signatureAlgorithm.toJSON(),signatureValue:this.signatureValue.toJSON()};return Hn in this&&(e.attributes=Array.from(this.attributes||[],t=>t.toJSON())),e}async sign(e,t="SHA-1",s=Q(!0)){if(!e)throw new Error("Need to provide a private key for signing");const a=await s.getSignatureParameters(e,t),n=a.parameters;this.signatureAlgorithm=a.signatureAlgorithm,this.tbsView=new Uint8Array(this.encodeTBS().toBER());const u=await s.signWithPrivateKey(this.tbsView,e,n);this.signatureValue=new re({valueHex:u})}async verify(e=Q(!0)){return e.verifyWithPublicKey(this.tbsView,this.signatureValue,this.subjectPublicKeyInfo,this.signatureAlgorithm)}async getPublicKey(e,t=Q(!0)){return t.getPublicKey(this.subjectPublicKeyInfo,this.signatureAlgorithm,e)}}Yt.CLASS_NAME="CertificationRequest";const an="digestAlgorithm",nn="digest",SS=[an,nn];class Gt extends D{constructor(e={}){super(),this.digestAlgorithm=f(e,an,Gt.defaultValues(an)),this.digest=f(e,nn,Gt.defaultValues(nn)),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case an:return new V;case nn:return new $;default:return super.defaultValues(e)}}static compareWithDefault(e,t){switch(e){case an:return V.compareWithDefault("algorithmId",t.algorithmId)&&!("algorithmParams"in t);case nn:return t.isEqual(Gt.defaultValues(e));default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||v,value:[V.schema(t.digestAlgorithm||{names:{blockName:an}}),new $({name:t.digest||nn})]})}fromSchema(e){T(e,SS);const t=R(e,e,Gt.schema({names:{digestAlgorithm:{names:{blockName:an}},digest:nn}}));O.assertSchema(t,this.className),this.digestAlgorithm=new V({schema:t.result.digestAlgorithm}),this.digest=t.result.digest}toSchema(){return new A({value:[this.digestAlgorithm.toSchema(),this.digest]})}toJSON(){return{digestAlgorithm:this.digestAlgorithm.toJSON(),digest:this.digest.toJSON()}}}Gt.CLASS_NAME="DigestInfo";const Mi="eContentType",Qt="eContent",AS=[Mi,Qt];class Vt extends D{constructor(e={}){if(super(),this.eContentType=f(e,Mi,Vt.defaultValues(Mi)),Qt in e&&(this.eContent=f(e,Qt,Vt.defaultValues(Qt)),this.eContent.idBlock.tagClass===1&&this.eContent.idBlock.tagNumber===4&&this.eContent.idBlock.isConstructed===!1)){const t=new $({idBlock:{isConstructed:!0},isConstructed:!0});let s=0;const a=this.eContent.valueBlock.valueHexView.slice().buffer;let n=a.byteLength;for(;n>0;){const u=new Uint8Array(a,s,s+65536>a.byteLength?a.byteLength-s:65536),i=new ArrayBuffer(u.length),l=new Uint8Array(i);for(let o=0;o<l.length;o++)l[o]=u[o];t.valueBlock.value.push(new $({valueHex:i})),n-=u.length,s+=u.length}this.eContent=t}e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case Mi:return v;case Qt:return new $;default:return super.defaultValues(e)}}static compareWithDefault(e,t){switch(e){case Mi:return t===v;case Qt:return t.idBlock.tagClass===1&&t.idBlock.tagNumber===4?t.isEqual(Vt.defaultValues(Qt)):!1;default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||v,value:[new J({name:t.eContentType||v}),new I({optional:!0,idBlock:{tagClass:3,tagNumber:0},value:[new X({name:t.eContent||v})]})]})}fromSchema(e){T(e,AS);const t=R(e,e,Vt.schema({names:{eContentType:Mi,eContent:Qt}}));O.assertSchema(t,this.className),this.eContentType=t.result.eContentType.valueBlock.toString(),Qt in t.result&&(this.eContent=t.result.eContent)}toSchema(){const e=[];return e.push(new J({value:this.eContentType})),this.eContent&&Vt.compareWithDefault(Qt,this.eContent)===!1&&e.push(new I({optional:!0,idBlock:{tagClass:3,tagNumber:0},value:[this.eContent]})),new A({value:e})}toJSON(){const e={eContentType:this.eContentType};return this.eContent&&Vt.compareWithDefault(Qt,this.eContent)===!1&&(e.eContent=this.eContent.toJSON()),e}}Vt.CLASS_NAME="EncapsulatedContentInfo";const on="mac",un="macSalt",xs="iterations",NS=[on,un,xs];class vt extends D{constructor(e={}){super(),this.mac=f(e,on,vt.defaultValues(on)),this.macSalt=f(e,un,vt.defaultValues(un)),xs in e&&(this.iterations=f(e,xs,vt.defaultValues(xs))),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case on:return new Gt;case un:return new $;case xs:return 1;default:return super.defaultValues(e)}}static compareWithDefault(e,t){switch(e){case on:return Gt.compareWithDefault("digestAlgorithm",t.digestAlgorithm)&&Gt.compareWithDefault("digest",t.digest);case un:return t.isEqual(vt.defaultValues(e));case xs:return t===vt.defaultValues(e);default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||v,optional:t.optional||!0,value:[Gt.schema(t.mac||{names:{blockName:on}}),new $({name:t.macSalt||un}),new B({optional:!0,name:t.iterations||xs})]})}fromSchema(e){T(e,NS);const t=R(e,e,vt.schema({names:{mac:{names:{blockName:on}},macSalt:un,iterations:xs}}));O.assertSchema(t,this.className),this.mac=new Gt({schema:t.result.mac}),this.macSalt=t.result.macSalt,xs in t.result&&(this.iterations=t.result.iterations.valueBlock.valueDec)}toSchema(){const e=[this.mac.toSchema(),this.macSalt];return this.iterations!==void 0&&e.push(new B({value:this.iterations})),new A({value:e})}toJSON(){const e={mac:this.mac.toJSON(),macSalt:this.macSalt.toJSON()};return this.iterations!==void 0&&(e.iterations=this.iterations),e}}vt.CLASS_NAME="MacData";const pn="hashAlgorithm",gn="hashedMessage",kS=[pn,gn];class nt extends D{static async create(e,t,s=Q(!0)){const a=s.getOIDByAlgorithm({name:e},!0,"hashAlgorithm"),n=await s.digest(e,t);return new nt({hashAlgorithm:new V({algorithmId:a,algorithmParams:new Fe}),hashedMessage:new $({valueHex:n})})}constructor(e={}){super(),this.hashAlgorithm=f(e,pn,nt.defaultValues(pn)),this.hashedMessage=f(e,gn,nt.defaultValues(gn)),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case pn:return new V;case gn:return new $;default:return super.defaultValues(e)}}static compareWithDefault(e,t){switch(e){case pn:return t.algorithmId===v&&!("algorithmParams"in t);case gn:return t.isEqual(nt.defaultValues(e))===0;default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||v,value:[V.schema(t.hashAlgorithm||{}),new $({name:t.hashedMessage||v})]})}fromSchema(e){T(e,kS);const t=R(e,e,nt.schema({names:{hashAlgorithm:{names:{blockName:pn}},hashedMessage:gn}}));O.assertSchema(t,this.className),this.hashAlgorithm=new V({schema:t.result.hashAlgorithm}),this.hashedMessage=t.result.hashedMessage}toSchema(){return new A({value:[this.hashAlgorithm.toSchema(),this.hashedMessage]})}toJSON(){return{hashAlgorithm:this.hashAlgorithm.toJSON(),hashedMessage:this.hashedMessage.toJSON()}}}nt.CLASS_NAME="MessageImprint";const Fi="reqCert",Rr="singleRequestExtensions",CS=[Fi,Rr];let Jh=class Tl extends D{constructor(e={}){super(),this.reqCert=f(e,Fi,Tl.defaultValues(Fi)),Rr in e&&(this.singleRequestExtensions=f(e,Rr,Tl.defaultValues(Rr))),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case Fi:return new Te;case Rr:return[];default:return super.defaultValues(e)}}static compareWithDefault(e,t){switch(e){case Fi:return t.isEqual(Tl.defaultValues(e));case Rr:return t.length===0;default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||v,value:[Te.schema(t.reqCert||{}),new I({optional:!0,idBlock:{tagClass:3,tagNumber:0},value:[De.schema(t.extensions||{names:{blockName:t.singleRequestExtensions||v}})]})]})}fromSchema(e){T(e,CS);const t=R(e,e,Tl.schema({names:{reqCert:{names:{blockName:Fi}},extensions:{names:{blockName:Rr}}}}));O.assertSchema(t,this.className),this.reqCert=new Te({schema:t.result.reqCert}),Rr in t.result&&(this.singleRequestExtensions=Array.from(t.result.singleRequestExtensions.valueBlock.value,s=>new De({schema:s})))}toSchema(){const e=[];return e.push(this.reqCert.toSchema()),this.singleRequestExtensions&&e.push(new I({optional:!0,idBlock:{tagClass:3,tagNumber:0},value:[new A({value:Array.from(this.singleRequestExtensions,t=>t.toSchema())})]})),new A({value:e})}toJSON(){const e={reqCert:this.reqCert.toJSON()};return this.singleRequestExtensions&&(e.singleRequestExtensions=Array.from(this.singleRequestExtensions,t=>t.toJSON())),e}};Jh.CLASS_NAME="Request";const $c="tbs",Ji="version",qi="requestorName",Kc="requestList",Wi="requestExtensions",Bo="TBSRequest",ah="".concat(Bo,".").concat(Ji),nh="".concat(Bo,".").concat(qi),vf="".concat(Bo,".requests"),ih="".concat(Bo,".").concat(Wi),ES=[Bo,ah,nh,vf,ih];class rt extends D{get tbs(){return pe.toArrayBuffer(this.tbsView)}set tbs(e){this.tbsView=new Uint8Array(e)}constructor(e={}){super(),this.tbsView=new Uint8Array(f(e,$c,rt.defaultValues($c))),Ji in e&&(this.version=f(e,Ji,rt.defaultValues(Ji))),qi in e&&(this.requestorName=f(e,qi,rt.defaultValues(qi))),this.requestList=f(e,Kc,rt.defaultValues(Kc)),Wi in e&&(this.requestExtensions=f(e,Wi,rt.defaultValues(Wi))),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case $c:return Ue;case Ji:return 0;case qi:return new ue;case Kc:case Wi:return[];default:return super.defaultValues(e)}}static compareWithDefault(e,t){switch(e){case $c:return t.byteLength===0;case Ji:return t===rt.defaultValues(e);case qi:return t.type===ue.defaultValues("type")&&Object.keys(t.value).length===0;case Kc:case Wi:return t.length===0;default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||Bo,value:[new I({optional:!0,idBlock:{tagClass:3,tagNumber:0},value:[new B({name:t.TBSRequestVersion||ah})]}),new I({optional:!0,idBlock:{tagClass:3,tagNumber:1},value:[ue.schema(t.requestorName||{names:{blockName:nh}})]}),new A({name:t.requestList||"TBSRequest.requestList",value:[new Z({name:t.requests||vf,value:Jh.schema(t.requestNames||{})})]}),new I({optional:!0,idBlock:{tagClass:3,tagNumber:2},value:[je.schema(t.extensions||{names:{blockName:t.requestExtensions||ih}})]})]})}fromSchema(e){T(e,ES);const t=R(e,e,rt.schema());O.assertSchema(t,this.className),this.tbsView=t.result.TBSRequest.valueBeforeDecodeView,ah in t.result&&(this.version=t.result[ah].valueBlock.valueDec),nh in t.result&&(this.requestorName=new ue({schema:t.result[nh]})),this.requestList=Array.from(t.result[vf],s=>new Jh({schema:s})),ih in t.result&&(this.requestExtensions=Array.from(t.result[ih].valueBlock.value,s=>new De({schema:s})))}toSchema(e=!1){let t;if(e===!1){if(this.tbsView.byteLength===0)return rt.schema();const s=Le(this.tbsView);if(O.assert(s,"TBS Request"),!(s.result instanceof A))throw new Error("ASN.1 result should be SEQUENCE");t=s.result}else{const s=[];this.version!==void 0&&s.push(new I({idBlock:{tagClass:3,tagNumber:0},value:[new B({value:this.version})]})),this.requestorName&&s.push(new I({idBlock:{tagClass:3,tagNumber:1},value:[this.requestorName.toSchema()]})),s.push(new A({value:Array.from(this.requestList,a=>a.toSchema())})),this.requestExtensions&&s.push(new I({idBlock:{tagClass:3,tagNumber:2},value:[new A({value:Array.from(this.requestExtensions,a=>a.toSchema())})]})),t=new A({value:s})}return t}toJSON(){const e={};return this.version!=null&&(e.version=this.version),this.requestorName&&(e.requestorName=this.requestorName.toJSON()),e.requestList=Array.from(this.requestList,t=>t.toJSON()),this.requestExtensions&&(e.requestExtensions=Array.from(this.requestExtensions,t=>t.toJSON())),e}}rt.CLASS_NAME="TBSRequest";const Mn="signatureAlgorithm",Fn="signature",er="certs";class Tt extends D{constructor(e={}){super(),this.signatureAlgorithm=f(e,Mn,Tt.defaultValues(Mn)),this.signature=f(e,Fn,Tt.defaultValues(Fn)),er in e&&(this.certs=f(e,er,Tt.defaultValues(er))),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case Mn:return new V;case Fn:return new re;case er:return[];default:return super.defaultValues(e)}}static compareWithDefault(e,t){switch(e){case Mn:return t.algorithmId===v&&!("algorithmParams"in t);case Fn:return t.isEqual(Tt.defaultValues(e));case er:return t.length===0;default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||v,value:[V.schema(t.signatureAlgorithm||{}),new re({name:t.signature||v}),new I({optional:!0,idBlock:{tagClass:3,tagNumber:0},value:[new A({value:[new Z({name:t.certs||v,value:oe.schema({})})]})]})]})}fromSchema(e){T(e,[Mn,Fn,er]);const t=R(e,e,Tt.schema({names:{signatureAlgorithm:{names:{blockName:Mn}},signature:Fn,certs:er}}));O.assertSchema(t,this.className),this.signatureAlgorithm=new V({schema:t.result.signatureAlgorithm}),this.signature=t.result.signature,er in t.result&&(this.certs=Array.from(t.result.certs,s=>new oe({schema:s})))}toSchema(){const e=[];return e.push(this.signatureAlgorithm.toSchema()),e.push(this.signature),this.certs&&e.push(new I({optional:!0,idBlock:{tagClass:3,tagNumber:0},value:[new A({value:Array.from(this.certs,t=>t.toSchema())})]})),new A({value:e})}toJSON(){const e={signatureAlgorithm:this.signatureAlgorithm.toJSON(),signature:this.signature.toJSON()};return this.certs&&(e.certs=Array.from(this.certs,t=>t.toJSON())),e}}Tt.CLASS_NAME="Signature";const Gi="tbsRequest",Lr="optionalSignature",xS=[Gi,Lr];class _l extends D{constructor(e={}){super(),this.tbsRequest=f(e,Gi,_l.defaultValues(Gi)),Lr in e&&(this.optionalSignature=f(e,Lr,_l.defaultValues(Lr))),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case Gi:return new rt;case Lr:return new Tt;default:return super.defaultValues(e)}}static compareWithDefault(e,t){switch(e){case Gi:return rt.compareWithDefault("tbs",t.tbs)&&rt.compareWithDefault("version",t.version)&&rt.compareWithDefault("requestorName",t.requestorName)&&rt.compareWithDefault("requestList",t.requestList)&&rt.compareWithDefault("requestExtensions",t.requestExtensions);case Lr:return Tt.compareWithDefault("signatureAlgorithm",t.signatureAlgorithm)&&Tt.compareWithDefault("signature",t.signature)&&Tt.compareWithDefault("certs",t.certs);default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||"OCSPRequest",value:[rt.schema(t.tbsRequest||{names:{blockName:Gi}}),new I({optional:!0,idBlock:{tagClass:3,tagNumber:0},value:[Tt.schema(t.optionalSignature||{names:{blockName:Lr}})]})]})}fromSchema(e){T(e,xS);const t=R(e,e,_l.schema());O.assertSchema(t,this.className),this.tbsRequest=new rt({schema:t.result.tbsRequest}),Lr in t.result&&(this.optionalSignature=new Tt({schema:t.result.optionalSignature}))}toSchema(e=!1){const t=[];return t.push(this.tbsRequest.toSchema(e)),this.optionalSignature&&t.push(new I({optional:!0,idBlock:{tagClass:3,tagNumber:0},value:[this.optionalSignature.toSchema()]})),new A({value:t})}toJSON(){const e={tbsRequest:this.tbsRequest.toJSON()};return this.optionalSignature&&(e.optionalSignature=this.optionalSignature.toJSON()),e}async createForCertificate(e,t,s=Q(!0)){const a=new Te;await a.createForCertificate(e,t,s),this.tbsRequest.requestList.push(new Jh({reqCert:a}))}async sign(e,t="SHA-1",s=Q(!0)){if(ne.assertEmpty(e,"privateKey","OCSPRequest.sign method"),!this.optionalSignature)throw new Error('Need to create "optionalSignature" field before signing');const a=await s.getSignatureParameters(e,t),n=a.parameters;this.optionalSignature.signatureAlgorithm=a.signatureAlgorithm;const u=this.tbsRequest.toSchema(!0).toBER(!1),i=await s.signWithPrivateKey(u,e,n);this.optionalSignature.signature=new re({valueHex:i})}verify(){}}_l.CLASS_NAME="OCSPRequest";const zi="responseType",_i="response",IS=[zi,_i];class rs extends D{constructor(e={}){super(),this.responseType=f(e,zi,rs.defaultValues(zi)),this.response=f(e,_i,rs.defaultValues(_i)),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case zi:return v;case _i:return new $;default:return super.defaultValues(e)}}static compareWithDefault(e,t){switch(e){case zi:return t===v;case _i:return t.isEqual(rs.defaultValues(e));default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||v,value:[new J({name:t.responseType||v}),new $({name:t.response||v})]})}fromSchema(e){T(e,IS);const t=R(e,e,rs.schema({names:{responseType:zi,response:_i}}));O.assertSchema(t,this.className),this.responseType=t.result.responseType.valueBlock.toString(),this.response=t.result.response}toSchema(){return new A({value:[new J({value:this.responseType}),this.response]})}toJSON(){return{responseType:this.responseType,response:this.response.toJSON()}}}rs.CLASS_NAME="ResponseBytes";const Jn="responseStatus",ys="responseBytes";class po extends D{constructor(e={}){super(),this.responseStatus=f(e,Jn,po.defaultValues(Jn)),ys in e&&(this.responseBytes=f(e,ys,po.defaultValues(ys))),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case Jn:return new Yl;case ys:return new rs;default:return super.defaultValues(e)}}static compareWithDefault(e,t){switch(e){case Jn:return t.isEqual(po.defaultValues(e));case ys:return rs.compareWithDefault("responseType",t.responseType)&&rs.compareWithDefault("response",t.response);default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||"OCSPResponse",value:[new Yl({name:t.responseStatus||Jn}),new I({optional:!0,idBlock:{tagClass:3,tagNumber:0},value:[rs.schema(t.responseBytes||{names:{blockName:ys}})]})]})}fromSchema(e){T(e,[Jn,ys]);const t=R(e,e,po.schema());O.assertSchema(t,this.className),this.responseStatus=t.result.responseStatus,ys in t.result&&(this.responseBytes=new rs({schema:t.result.responseBytes}))}toSchema(){const e=[];return e.push(this.responseStatus),this.responseBytes&&e.push(new I({idBlock:{tagClass:3,tagNumber:0},value:[this.responseBytes.toSchema()]})),new A({value:e})}toJSON(){const e={responseStatus:this.responseStatus.toJSON()};return this.responseBytes&&(e.responseBytes=this.responseBytes.toJSON()),e}async getCertificateStatus(e,t,s=Q(!0)){let a;const n={isForCertificate:!1,status:2};if(!this.responseBytes||this.responseBytes.responseType!==Wc)return n;try{const u=Le(this.responseBytes.response.valueBlock.valueHexView);O.assert(u,"Basic OCSP response"),a=new qt({schema:u.result})}catch(u){return n}return a.getCertificateStatus(e,t,s)}async sign(e,t,s=Q(!0)){var a;if(this.responseBytes&&this.responseBytes.responseType===Wc)return qt.fromBER(this.responseBytes.response.valueBlock.valueHexView).sign(e,t,s);throw new Error("Unknown ResponseBytes type: ".concat(((a=this.responseBytes)===null||a===void 0?void 0:a.responseType)||"Unknown"))}async verify(e=null,t=Q(!0)){var s;if(!(ys in this))throw new Error("Empty ResponseBytes field");if(this.responseBytes&&this.responseBytes.responseType===Wc){const a=qt.fromBER(this.responseBytes.response.valueBlock.valueHexView);return e!==null&&(a.certs||(a.certs=[]),a.certs.push(e)),a.verify({},t)}throw new Error("Unknown ResponseBytes type: ".concat(((s=this.responseBytes)===null||s===void 0?void 0:s.responseType)||"Unknown"))}}po.CLASS_NAME="OCSPResponse";const fa="type",Is="attributes",Hc="encodedValue",VS=[Is];class Se extends D{constructor(e={}){super(),this.type=f(e,fa,Se.defaultValues(fa)),this.attributes=f(e,Is,Se.defaultValues(Is)),this.encodedValue=f(e,Hc,Se.defaultValues(Hc)),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case fa:return-1;case Is:return[];case Hc:return Ue;default:return super.defaultValues(e)}}static compareWithDefault(e,t){switch(e){case fa:return t===Se.defaultValues(fa);case Is:return t.length===0;case Hc:return t.byteLength===0;default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new I({name:t.blockName||v,optional:!0,idBlock:{tagClass:3,tagNumber:t.tagNumber||0},value:[new Z({name:t.attributes||v,value:ge.schema()})]})}fromSchema(e){T(e,VS);const t=R(e,e,Se.schema({names:{tagNumber:this.type,attributes:Is}}));O.assertSchema(t,this.className),this.type=t.result.idBlock.tagNumber,this.encodedValue=pe.toArrayBuffer(t.result.valueBeforeDecodeView);const s=new Uint8Array(this.encodedValue);if(s[0]=49,!(Is in t.result)){if(this.type===0)throw new Error("Wrong structure of SignedUnsignedAttributes");return}this.attributes=Array.from(t.result.attributes,a=>new ge({schema:a}))}toSchema(){if(Se.compareWithDefault(fa,this.type)||Se.compareWithDefault(Is,this.attributes))throw new Error('Incorrectly initialized "SignedAndUnsignedAttributes" class');return new I({optional:!0,idBlock:{tagClass:3,tagNumber:this.type},value:Array.from(this.attributes,e=>e.toSchema())})}toJSON(){if(Se.compareWithDefault(fa,this.type)||Se.compareWithDefault(Is,this.attributes))throw new Error('Incorrectly initialized "SignedAndUnsignedAttributes" class');return{type:this.type,attributes:Array.from(this.attributes,e=>e.toJSON())}}}Se.CLASS_NAME="SignedAndUnsignedAttributes";const Xi="version",ln="sid",Zi="digestAlgorithm",Ur="signedAttrs",Qi="signatureAlgorithm",Rl="signature",jr="unsignedAttrs",oa="SignerInfo",bf="".concat(oa,".").concat(Xi),Ll="".concat(oa,".").concat(ln),Sf="".concat(oa,".").concat(Zi),oh="".concat(oa,".").concat(Ur),Af="".concat(oa,".").concat(Qi),Nf="".concat(oa,".").concat(Rl),uh="".concat(oa,".").concat(jr),BS=[bf,Ll,Sf,oh,Af,Nf,uh];class Ve extends D{constructor(e={}){super(),this.version=f(e,Xi,Ve.defaultValues(Xi)),this.sid=f(e,ln,Ve.defaultValues(ln)),this.digestAlgorithm=f(e,Zi,Ve.defaultValues(Zi)),Ur in e&&(this.signedAttrs=f(e,Ur,Ve.defaultValues(Ur))),this.signatureAlgorithm=f(e,Qi,Ve.defaultValues(Qi)),this.signature=f(e,Rl,Ve.defaultValues(Rl)),jr in e&&(this.unsignedAttrs=f(e,jr,Ve.defaultValues(jr))),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case Xi:return 0;case ln:return new X;case Zi:return new V;case Ur:return new Se({type:0});case Qi:return new V;case Rl:return new $;case jr:return new Se({type:1});default:return super.defaultValues(e)}}static compareWithDefault(e,t){switch(e){case Xi:return Ve.defaultValues(Xi)===t;case ln:return t instanceof X;case Zi:return t instanceof V?t.isEqual(Ve.defaultValues(Zi)):!1;case Ur:return Se.compareWithDefault("type",t.type)&&Se.compareWithDefault("attributes",t.attributes)&&Se.compareWithDefault("encodedValue",t.encodedValue);case Qi:return t instanceof V?t.isEqual(Ve.defaultValues(Qi)):!1;case Rl:case jr:return Se.compareWithDefault("type",t.type)&&Se.compareWithDefault("attributes",t.attributes)&&Se.compareWithDefault("encodedValue",t.encodedValue);default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:oa,value:[new B({name:t.version||bf}),new Ne({value:[$e.schema(t.sidSchema||{names:{blockName:Ll}}),new Ne({value:[new I({optional:!0,name:t.sid||Ll,idBlock:{tagClass:3,tagNumber:0},value:[new $]}),new _({optional:!0,name:t.sid||Ll,idBlock:{tagClass:3,tagNumber:0}})]})]}),V.schema(t.digestAlgorithm||{names:{blockName:Sf}}),Se.schema(t.signedAttrs||{names:{blockName:oh,tagNumber:0}}),V.schema(t.signatureAlgorithm||{names:{blockName:Af}}),new $({name:t.signature||Nf}),Se.schema(t.unsignedAttrs||{names:{blockName:uh,tagNumber:1}})]})}fromSchema(e){T(e,BS);const t=R(e,e,Ve.schema());O.assertSchema(t,this.className),this.version=t.result[bf].valueBlock.valueDec;const s=t.result[Ll];s.idBlock.tagClass===1?this.sid=new $e({schema:s}):this.sid=s,this.digestAlgorithm=new V({schema:t.result[Sf]}),oh in t.result&&(this.signedAttrs=new Se({type:0,schema:t.result[oh]})),this.signatureAlgorithm=new V({schema:t.result[Af]}),this.signature=t.result[Nf],uh in t.result&&(this.unsignedAttrs=new Se({type:1,schema:t.result[uh]}))}toSchema(){if(Ve.compareWithDefault(ln,this.sid))throw new Error('Incorrectly initialized "SignerInfo" class');const e=[];return e.push(new B({value:this.version})),this.sid instanceof $e?e.push(this.sid.toSchema()):e.push(this.sid),e.push(this.digestAlgorithm.toSchema()),this.signedAttrs&&Ve.compareWithDefault(Ur,this.signedAttrs)===!1&&e.push(this.signedAttrs.toSchema()),e.push(this.signatureAlgorithm.toSchema()),e.push(this.signature),this.unsignedAttrs&&Ve.compareWithDefault(jr,this.unsignedAttrs)===!1&&e.push(this.unsignedAttrs.toSchema()),new A({value:e})}toJSON(){if(Ve.compareWithDefault(ln,this.sid))throw new Error('Incorrectly initialized "SignerInfo" class');const e={version:this.version,digestAlgorithm:this.digestAlgorithm.toJSON(),signatureAlgorithm:this.signatureAlgorithm.toJSON(),signature:this.signature.toJSON()};return this.sid instanceof X||(e.sid=this.sid.toJSON()),this.signedAttrs&&Ve.compareWithDefault(Ur,this.signedAttrs)===!1&&(e.signedAttrs=this.signedAttrs.toJSON()),this.unsignedAttrs&&Ve.compareWithDefault(jr,this.unsignedAttrs)===!1&&(e.unsignedAttrs=this.unsignedAttrs.toJSON()),e}}Ve.CLASS_NAME="SignerInfo";const Ul="version",jl="policy",$l="messageImprint",Kl="serialNumber",Hl="genTime",cn="ordering",hn="nonce",Yi="accuracy",eo="tsa",to="extensions",is="TSTInfo",kf="".concat(is,".").concat(Ul),Cf="".concat(is,".").concat(jl),Ef="".concat(is,".").concat($l),xf="".concat(is,".").concat(Kl),If="".concat(is,".").concat(Hl),lh="".concat(is,".").concat(Yi),ch="".concat(is,".").concat(cn),hh="".concat(is,".").concat(hn),mh="".concat(is,".").concat(eo),fh="".concat(is,".").concat(to),PS=[kf,Cf,Ef,xf,If,lh,ch,hh,mh,fh];class lt extends D{constructor(e={}){super(),this.version=f(e,Ul,lt.defaultValues(Ul)),this.policy=f(e,jl,lt.defaultValues(jl)),this.messageImprint=f(e,$l,lt.defaultValues($l)),this.serialNumber=f(e,Kl,lt.defaultValues(Kl)),this.genTime=f(e,Hl,lt.defaultValues(Hl)),Yi in e&&(this.accuracy=f(e,Yi,lt.defaultValues(Yi))),cn in e&&(this.ordering=f(e,cn,lt.defaultValues(cn))),hn in e&&(this.nonce=f(e,hn,lt.defaultValues(hn))),eo in e&&(this.tsa=f(e,eo,lt.defaultValues(eo))),to in e&&(this.extensions=f(e,to,lt.defaultValues(to))),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case Ul:return 0;case jl:return v;case $l:return new nt;case Kl:return new B;case Hl:return new Date(0,0,0);case Yi:return new Dt;case cn:return!1;case hn:return new B;case eo:return new ue;case to:return[];default:return super.defaultValues(e)}}static compareWithDefault(e,t){switch(e){case Ul:case jl:case Hl:case cn:return t===lt.defaultValues(cn);case $l:return nt.compareWithDefault(pn,t.hashAlgorithm)&&nt.compareWithDefault(gn,t.hashedMessage);case Kl:case hn:return t.isEqual(lt.defaultValues(hn));case Yi:return Dt.compareWithDefault(rr,t.seconds)&&Dt.compareWithDefault(ar,t.millis)&&Dt.compareWithDefault(nr,t.micros);case eo:return ue.compareWithDefault(Zo,t.type)&&ue.compareWithDefault(Qo,t.value);case to:return t.length===0;default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||is,value:[new B({name:t.version||kf}),new J({name:t.policy||Cf}),nt.schema(t.messageImprint||{names:{blockName:Ef}}),new B({name:t.serialNumber||xf}),new ke({name:t.genTime||If}),Dt.schema(t.accuracy||{names:{blockName:lh}}),new ia({name:t.ordering||ch,optional:!0}),new B({name:t.nonce||hh,optional:!0}),new I({optional:!0,idBlock:{tagClass:3,tagNumber:0},value:[ue.schema(t.tsa||{names:{blockName:mh}})]}),new I({optional:!0,idBlock:{tagClass:3,tagNumber:1},value:[new Z({name:t.extensions||fh,value:De.schema(t.extension||{})})]})]})}fromSchema(e){T(e,PS);const t=R(e,e,lt.schema());O.assertSchema(t,this.className),this.version=t.result[kf].valueBlock.valueDec,this.policy=t.result[Cf].valueBlock.toString(),this.messageImprint=new nt({schema:t.result[Ef]}),this.serialNumber=t.result[xf],this.genTime=t.result[If].toDate(),lh in t.result&&(this.accuracy=new Dt({schema:t.result[lh]})),ch in t.result&&(this.ordering=t.result[ch].valueBlock.value),hh in t.result&&(this.nonce=t.result[hh]),mh in t.result&&(this.tsa=new ue({schema:t.result[mh]})),fh in t.result&&(this.extensions=Array.from(t.result[fh],s=>new De({schema:s})))}toSchema(){const e=[];return e.push(new B({value:this.version})),e.push(new J({value:this.policy})),e.push(this.messageImprint.toSchema()),e.push(this.serialNumber),e.push(new ke({valueDate:this.genTime})),this.accuracy&&e.push(this.accuracy.toSchema()),this.ordering!==void 0&&e.push(new ia({value:this.ordering})),this.nonce&&e.push(this.nonce),this.tsa&&e.push(new I({optional:!0,idBlock:{tagClass:3,tagNumber:0},value:[this.tsa.toSchema()]})),this.extensions&&e.push(new I({optional:!0,idBlock:{tagClass:3,tagNumber:1},value:Array.from(this.extensions,t=>t.toSchema())})),new A({value:e})}toJSON(){const e={version:this.version,policy:this.policy,messageImprint:this.messageImprint.toJSON(),serialNumber:this.serialNumber.toJSON(),genTime:this.genTime};return this.accuracy&&(e.accuracy=this.accuracy.toJSON()),this.ordering!==void 0&&(e.ordering=this.ordering),this.nonce&&(e.nonce=this.nonce.toJSON()),this.tsa&&(e.tsa=this.tsa.toJSON()),this.extensions&&(e.extensions=Array.from(this.extensions,t=>t.toJSON())),e}async verify(e,t=Q(!0)){if(!e.data)throw new Error('"data" is a mandatory attribute for TST_INFO verification');const s=e.data;if(e.notBefore&&this.genTime<e.notBefore)throw new Error("Generation time for TSTInfo object is less than notBefore value");if(e.notAfter&&this.genTime>e.notAfter)throw new Error("Generation time for TSTInfo object is more than notAfter value");const a=t.getAlgorithmByOID(this.messageImprint.hashAlgorithm.algorithmId,!0,"MessageImprint.hashAlgorithm"),n=await t.digest(a.name,new Uint8Array(s));return pe.isEqual(n,this.messageImprint.hashedMessage.valueBlock.valueHexView)}}lt.CLASS_NAME="TSTInfo";const so="version",Ml="digestAlgorithms",Fl="encapContentInfo",ro="certificates",ao="crls",Jl="signerInfos",zo="ocsps",Ln="SignedData",Vf="".concat(Ln,".").concat(so),dh="".concat(Ln,".").concat(Ml),Bf="".concat(Ln,".").concat(Fl),ph="".concat(Ln,".").concat(ro),gh="".concat(Ln,".").concat(ao),wh="".concat(Ln,".").concat(Jl),OS=[Vf,dh,Bf,ph,gh,wh];class ut extends Error{constructor({message:e,code:t=0,date:s=new Date,signatureVerified:a=null,signerCertificate:n=null,signerCertificateVerified:u=null,timestampSerial:i=null,certificatePath:l=[]}){super(e),this.name="SignedDataVerifyError",this.date=s,this.code=t,this.timestampSerial=i,this.signatureVerified=a,this.signerCertificate=n,this.signerCertificateVerified=u,this.certificatePath=l}}class st extends D{constructor(e={}){super(),this.version=f(e,so,st.defaultValues(so)),this.digestAlgorithms=f(e,Ml,st.defaultValues(Ml)),this.encapContentInfo=f(e,Fl,st.defaultValues(Fl)),ro in e&&(this.certificates=f(e,ro,st.defaultValues(ro))),ao in e&&(this.crls=f(e,ao,st.defaultValues(ao))),zo in e&&(this.ocsps=f(e,zo,st.defaultValues(zo))),this.signerInfos=f(e,Jl,st.defaultValues(Jl)),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case so:return 0;case Ml:return[];case Fl:return new Vt;case ro:return[];case ao:return[];case zo:return[];case Jl:return[];default:return super.defaultValues(e)}}static compareWithDefault(e,t){switch(e){case so:return t===st.defaultValues(so);case Fl:return Vt.compareWithDefault("eContentType",t.eContentType)&&Vt.compareWithDefault("eContent",t.eContent);case Ml:case ro:case ao:case zo:case Jl:return t.length===0;default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return t.optional===void 0&&(t.optional=!1),new A({name:t.blockName||Ln,optional:t.optional,value:[new B({name:t.version||Vf}),new Je({value:[new Z({name:t.digestAlgorithms||dh,value:V.schema()})]}),Vt.schema(t.encapContentInfo||{names:{blockName:Bf}}),new I({name:t.certificates||ph,optional:!0,idBlock:{tagClass:3,tagNumber:0},value:ps.schema().valueBlock.value}),new I({optional:!0,idBlock:{tagClass:3,tagNumber:1},value:Ms.schema(t.crls||{names:{crls:gh}}).valueBlock.value}),new Je({value:[new Z({name:t.signerInfos||wh,value:Ve.schema()})]})]})}fromSchema(e){T(e,OS);const t=R(e,e,st.schema());if(O.assertSchema(t,this.className),this.version=t.result[Vf].valueBlock.valueDec,dh in t.result&&(this.digestAlgorithms=Array.from(t.result[dh],s=>new V({schema:s}))),this.encapContentInfo=new Vt({schema:t.result[Bf]}),ph in t.result){const s=new ps({schema:new Je({value:t.result[ph].valueBlock.value})});this.certificates=s.certificates.slice(0)}gh in t.result&&(this.crls=Array.from(t.result[gh],s=>s.idBlock.tagClass===1?new Me({schema:s}):(s.idBlock.tagClass=1,s.idBlock.tagNumber=16,new Hs({schema:s})))),wh in t.result&&(this.signerInfos=Array.from(t.result[wh],s=>new Ve({schema:s})))}toSchema(e=!1){const t=[];if(this.certificates&&this.certificates.length&&this.certificates.some(s=>s instanceof ra)||this.crls&&this.crls.length&&this.crls.some(s=>s instanceof Hs)?this.version=5:this.certificates&&this.certificates.length&&this.certificates.some(s=>s instanceof Lt)?this.version=4:this.certificates&&this.certificates.length&&this.certificates.some(s=>s instanceof Ls)||this.signerInfos.some(s=>s.version===3)||this.encapContentInfo.eContentType!==st.ID_DATA?this.version=3:this.version=1,t.push(new B({value:this.version})),t.push(new Je({value:Array.from(this.digestAlgorithms,s=>s.toSchema())})),t.push(this.encapContentInfo.toSchema()),this.certificates){const s=new ps({certificates:this.certificates}).toSchema();t.push(new I({idBlock:{tagClass:3,tagNumber:0},value:s.valueBlock.value}))}return this.crls&&t.push(new I({idBlock:{tagClass:3,tagNumber:1},value:Array.from(this.crls,s=>{if(s instanceof Hs){const a=s.toSchema();return a.idBlock.tagClass=3,a.idBlock.tagNumber=1,a}return s.toSchema(e)})})),t.push(new Je({value:Array.from(this.signerInfos,s=>s.toSchema())})),new A({value:t})}toJSON(){const e={version:this.version,digestAlgorithms:Array.from(this.digestAlgorithms,t=>t.toJSON()),encapContentInfo:this.encapContentInfo.toJSON(),signerInfos:Array.from(this.signerInfos,t=>t.toJSON())};return this.certificates&&(e.certificates=Array.from(this.certificates,t=>t.toJSON())),this.crls&&(e.crls=Array.from(this.crls,t=>t.toJSON())),e}async verify({signer:e=-1,data:t=Ue,trustedCerts:s=[],checkDate:a=new Date,checkChain:n=!1,passedWhenNotRevValues:u=!1,extendedMode:i=!1,findOrigin:l=null,findIssuer:o=null}={},c=Q(!0)){let m=null,h=null;try{let p=Ue,d=v,w=[];const y=this.signerInfos[e];if(!y)throw new ut({date:a,code:1,message:"Unable to get signer by supplied index"});if(!this.certificates)throw new ut({date:a,code:2,message:"No certificates attached to this signed data"});if(y.sid instanceof $e){for(const N of this.certificates)if(N instanceof oe&&N.issuer.isEqual(y.sid.issuer)&&N.serialNumber.isEqual(y.sid.serialNumber)){m=N;break}}else{const N=y.sid,S=N.idBlock.isConstructed?N.valueBlock.value[0].valueBlock.valueHex:N.valueBlock.valueHex;for(const E of this.certificates){if(!(E instanceof oe))continue;const x=await c.digest({name:"sha-1"},E.subjectPublicKeyInfo.subjectPublicKey.valueBlock.valueHexView);if(Zl(x,S)){m=E;break}}}if(!m)throw new ut({date:a,code:3,message:"Unable to find signer certificate"});if(this.encapContentInfo.eContentType===L0){if(!this.encapContentInfo.eContent)throw new ut({date:a,code:15,message:"Error during verification: TSTInfo eContent is empty",signatureVerified:null,signerCertificate:m,timestampSerial:h,signerCertificateVerified:!0});let N;try{N=lt.fromBER(this.encapContentInfo.eContent.valueBlock.valueHexView)}catch(S){throw new ut({date:a,code:15,message:"Error during verification: TSTInfo wrong ASN.1 schema ",signatureVerified:null,signerCertificate:m,timestampSerial:h,signerCertificateVerified:!0})}if(a=N.genTime,h=N.serialNumber.valueBlock.valueHexView.slice(),t.byteLength===0)throw new ut({date:a,code:4,message:"Missed detached data input array"});if(!await N.verify({data:t},c))throw new ut({date:a,code:15,message:"Error during verification: TSTInfo verification is failed",signatureVerified:!1,signerCertificate:m,timestampSerial:h,signerCertificateVerified:!0})}if(n){const N=this.certificates.filter(C=>C instanceof oe&&!!$g(C,m)),S={checkDate:a,certs:N,trustedCerts:s};o&&(S.findIssuer=o),l&&(S.findOrigin=l);const E=new Zh(S);if(E.certs.push(m),this.crls)for(const C of this.crls)"thisUpdate"in C?E.crls.push(C):C.otherRevInfoFormat===Wc&&E.ocsps.push(new qt({schema:C.otherRevInfo}));this.ocsps&&E.ocsps.push(...this.ocsps);const x=await E.verify({passedWhenNotRevValues:u},c).catch(C=>{throw new ut({date:a,code:5,message:"Validation of signer's certificate failed with error: ".concat(C instanceof Object?C.resultMessage:C),signerCertificate:m,signerCertificateVerified:!1})});if(x.certificatePath&&(w=x.certificatePath),!x.result)throw new ut({date:a,code:5,message:"Validation of signer's certificate failed: ".concat(x.resultMessage),signerCertificate:m,signerCertificateVerified:!1})}const k=c.getAlgorithmByOID(y.digestAlgorithm.algorithmId);if(!("name"in k))throw new ut({date:a,code:7,message:"Unsupported signature algorithm: ".concat(y.digestAlgorithm.algorithmId),signerCertificate:m,signerCertificateVerified:!0});d=k.name;const g=this.encapContentInfo.eContent;if(g)g.idBlock.tagClass===1&&g.idBlock.tagNumber===4?t=g.getValue():t=g.valueBlock.valueBeforeDecodeView;else if(t.byteLength===0)throw new ut({date:a,code:8,message:"Missed detached data input array",signerCertificate:m,signerCertificateVerified:!0});if(y.signedAttrs){let N=!1,S=!1;for(const E of y.signedAttrs.attributes)if(E.type==="1.2.840.113549.1.9.3"&&(N=!0),E.type==="1.2.840.113549.1.9.4"&&(S=!0,p=E.values[0].valueBlock.valueHex),N&&S)break;if(N===!1)throw new ut({date:a,code:9,message:'Attribute "content-type" is a mandatory attribute for "signed attributes"',signerCertificate:m,signerCertificateVerified:!0});if(S===!1)throw new ut({date:a,code:10,message:'Attribute "message-digest" is a mandatory attribute for "signed attributes"',signatureVerified:null,signerCertificate:m,signerCertificateVerified:!0})}if(y.signedAttrs){const N=await c.digest(d,new Uint8Array(t));if(!Zl(N,p))throw new ut({date:a,code:15,message:"Error during verification: Message digest doesn't match",signatureVerified:null,signerCertificate:m,timestampSerial:h,signerCertificateVerified:!0});t=y.signedAttrs.encodedValue}const b=y.signatureAlgorithm.algorithmId==="1.2.840.113549.1.1.1"?await c.verifyWithPublicKey(t,y.signature,m.subjectPublicKeyInfo,y.signatureAlgorithm,d):await c.verifyWithPublicKey(t,y.signature,m.subjectPublicKeyInfo,y.signatureAlgorithm);return i?{date:a,code:14,message:v,signatureVerified:b,signerCertificate:m,timestampSerial:h,signerCertificateVerified:!0,certificatePath:w}:b}catch(p){throw p instanceof ut?p:new ut({date:a,code:15,message:"Error during verification: ".concat(p instanceof Error?p.message:p),signatureVerified:null,signerCertificate:m,timestampSerial:h,signerCertificateVerified:!0})}}async sign(e,t,s="SHA-1",a=Ue,n=Q(!0)){var u;if(!e)throw new Error("Need to provide a private key for signing");const i=this.signerInfos[t];if(!i)throw new RangeError("SignerInfo index is out of range");!(!((u=i.signedAttrs)===null||u===void 0)&&u.attributes.length)&&"hash"in e.algorithm&&"hash"in e.algorithm&&e.algorithm.hash&&(s=e.algorithm.hash.name);const l=n.getOIDByAlgorithm({name:s},!0,"hashAlgorithm");this.digestAlgorithms.filter(h=>h.algorithmId===l).length===0&&this.digestAlgorithms.push(new V({algorithmId:l,algorithmParams:new Fe})),i.digestAlgorithm=new V({algorithmId:l,algorithmParams:new Fe});const o=await n.getSignatureParameters(e,s),c=o.parameters;if(i.signatureAlgorithm=o.signatureAlgorithm,i.signedAttrs)if(i.signedAttrs.encodedValue.byteLength!==0)a=i.signedAttrs.encodedValue;else{a=i.signedAttrs.toSchema().toBER();const h=pe.toUint8Array(a);h[0]=49}else{const h=this.encapContentInfo.eContent;if(h)h.idBlock.tagClass===1&&h.idBlock.tagNumber===4?a=h.getValue():a=h.valueBlock.valueBeforeDecodeView;else if(a.byteLength===0)throw new Error("Missed detached data input array")}const m=await n.signWithPrivateKey(a,e,c);i.signature=new $({valueHex:m})}}st.CLASS_NAME="SignedData",st.ID_DATA=td;const mn="version",fn="authSafe",Vs="macData",_o="parsedValue",DS=[mn,fn,Vs];class Fr extends D{constructor(e={}){super(),this.version=f(e,mn,Fr.defaultValues(mn)),this.authSafe=f(e,fn,Fr.defaultValues(fn)),Vs in e&&(this.macData=f(e,Vs,Fr.defaultValues(Vs))),_o in e&&(this.parsedValue=f(e,_o,Fr.defaultValues(_o))),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case mn:return 3;case fn:return new fe;case Vs:return new vt;case _o:return{};default:return super.defaultValues(e)}}static compareWithDefault(e,t){switch(e){case mn:return t===Fr.defaultValues(e);case fn:return fe.compareWithDefault("contentType",t.contentType)&&fe.compareWithDefault("content",t.content);case Vs:return vt.compareWithDefault("mac",t.mac)&&vt.compareWithDefault("macSalt",t.macSalt)&&vt.compareWithDefault("iterations",t.iterations);case _o:return t instanceof Object&&Object.keys(t).length===0;default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||v,value:[new B({name:t.version||mn}),fe.schema(t.authSafe||{names:{blockName:fn}}),vt.schema(t.macData||{names:{blockName:Vs,optional:!0}})]})}fromSchema(e){T(e,DS);const t=R(e,e,Fr.schema({names:{version:mn,authSafe:{names:{blockName:fn}},macData:{names:{blockName:Vs}}}}));O.assertSchema(t,this.className),this.version=t.result.version.valueBlock.valueDec,this.authSafe=new fe({schema:t.result.authSafe}),Vs in t.result&&(this.macData=new vt({schema:t.result.macData}))}toSchema(){const e=[new B({value:this.version}),this.authSafe.toSchema()];return this.macData&&e.push(this.macData.toSchema()),new A({value:e})}toJSON(){const e={version:this.version,authSafe:this.authSafe.toJSON()};return this.macData&&(e.macData=this.macData.toJSON()),e}async makeInternalValues(e={},t=Q(!0)){if(he.assert(e,"parameters","object"),!this.parsedValue)throw new Error('Please call "parseValues" function first in order to make "parsedValue" data');switch(ne.assertEmpty(this.parsedValue.integrityMode,"integrityMode","parsedValue"),ne.assertEmpty(this.parsedValue.authenticatedSafe,"authenticatedSafe","parsedValue"),this.parsedValue.integrityMode){case 0:{if(!("iterations"in e))throw new ne("iterations");ne.assertEmpty(e.pbkdf2HashAlgorithm,"pbkdf2HashAlgorithm"),ne.assertEmpty(e.hmacHashAlgorithm,"hmacHashAlgorithm"),ne.assertEmpty(e.password,"password");const s=new ArrayBuffer(64),a=new Uint8Array(s);t.getRandomValues(a);const n=this.parsedValue.authenticatedSafe.toSchema().toBER(!1);this.authSafe=new fe({contentType:fe.DATA,content:new $({valueHex:n})});const u=await t.stampDataWithPassword({password:e.password,hashAlgorithm:e.hmacHashAlgorithm,salt:s,iterationCount:e.iterations,contentToStamp:n});this.macData=new vt({mac:new Gt({digestAlgorithm:new V({algorithmId:t.getOIDByAlgorithm({name:e.hmacHashAlgorithm},!0,"hmacHashAlgorithm")}),digest:new $({valueHex:u})}),macSalt:new $({valueHex:s}),iterations:e.iterations})}break;case 1:{if(!("signingCertificate"in e))throw new ne("signingCertificate");ne.assertEmpty(e.privateKey,"privateKey"),ne.assertEmpty(e.hashAlgorithm,"hashAlgorithm");const s=this.parsedValue.authenticatedSafe.toSchema().toBER(!1),a=new st({version:1,encapContentInfo:new Vt({eContentType:"1.2.840.113549.1.7.1",eContent:new $({valueHex:s})}),certificates:[e.signingCertificate]}),n=await t.digest({name:e.hashAlgorithm},new Uint8Array(s)),u=[];u.push(new ge({type:"1.2.840.113549.1.9.3",values:[new J({value:"1.2.840.113549.1.7.1"})]})),u.push(new ge({type:"1.2.840.113549.1.9.5",values:[new Xm({valueDate:new Date})]})),u.push(new ge({type:"1.2.840.113549.1.9.4",values:[new $({valueHex:n})]})),a.signerInfos.push(new Ve({version:1,sid:new $e({issuer:e.signingCertificate.issuer,serialNumber:e.signingCertificate.serialNumber}),signedAttrs:new Se({type:0,attributes:u})})),await a.sign(e.privateKey,0,e.hashAlgorithm,void 0,t),this.authSafe=new fe({contentType:"1.2.840.113549.1.7.2",content:a.toSchema(!0)})}break;default:throw new Error('Parameter "integrityMode" has unknown value: '.concat(this.parsedValue.integrityMode))}}async parseInternalValues(e,t=Q(!0)){switch(he.assert(e,"parameters","object"),e.checkIntegrity===void 0&&(e.checkIntegrity=!0),this.parsedValue={},this.authSafe.contentType){case fe.DATA:{ne.assertEmpty(e.password,"password"),this.parsedValue.integrityMode=0,he.assert(this.authSafe.content,"authSafe.content",$);const s=this.authSafe.content.getValue();if(this.parsedValue.authenticatedSafe=On.fromBER(s),e.checkIntegrity){if(!this.macData)throw new Error('Absent "macData" value, can not check PKCS#12 data integrity');const a=t.getAlgorithmByOID(this.macData.mac.digestAlgorithm.algorithmId,!0,"digestAlgorithm");if(!await t.verifyDataStampedWithPassword({password:e.password,hashAlgorithm:a.name,salt:pe.toArrayBuffer(this.macData.macSalt.valueBlock.valueHexView),iterationCount:this.macData.iterations||1,contentToVerify:s,signatureToVerify:pe.toArrayBuffer(this.macData.mac.digest.valueBlock.valueHexView)}))throw new Error("Integrity for the PKCS#12 data is broken!")}}break;case fe.SIGNED_DATA:{this.parsedValue.integrityMode=1;const s=new st({schema:this.authSafe.content}),a=s.encapContentInfo.eContent;ne.assert(a,"eContent","cmsSigned.encapContentInfo"),he.assert(a,"eContent",$);const n=a.getValue();if(this.parsedValue.authenticatedSafe=On.fromBER(n),!await s.verify({signer:0,checkChain:!1},t))throw new Error("Integrity for the PKCS#12 data is broken!")}break;default:throw new Error('Incorrect value for "this.authSafe.contentType": '.concat(this.authSafe.contentType))}}}Fr.CLASS_NAME="PFX";const no="status",$r="statusStrings",Kr="failInfo",TS=[no,$r,Kr];var bp;(function(r){r[r.granted=0]="granted",r[r.grantedWithMods=1]="grantedWithMods",r[r.rejection=2]="rejection",r[r.waiting=3]="waiting",r[r.revocationWarning=4]="revocationWarning",r[r.revocationNotification=5]="revocationNotification"})(bp||(bp={}));class Wt extends D{constructor(e={}){super(),this.status=f(e,no,Wt.defaultValues(no)),$r in e&&(this.statusStrings=f(e,$r,Wt.defaultValues($r))),Kr in e&&(this.failInfo=f(e,Kr,Wt.defaultValues(Kr))),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case no:return 2;case $r:return[];case Kr:return new re;default:return super.defaultValues(e)}}static compareWithDefault(e,t){switch(e){case no:return t===Wt.defaultValues(e);case $r:return t.length===0;case Kr:return t.isEqual(Wt.defaultValues(e));default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||v,value:[new B({name:t.status||v}),new A({optional:!0,value:[new Z({name:t.statusStrings||v,value:new Ch})]}),new re({name:t.failInfo||v,optional:!0})]})}fromSchema(e){T(e,TS);const t=R(e,e,Wt.schema({names:{status:no,statusStrings:$r,failInfo:Kr}}));O.assertSchema(t,this.className);const s=t.result.status;if(s.valueBlock.isHexOnly===!0||s.valueBlock.valueDec<0||s.valueBlock.valueDec>5)throw new Error('PKIStatusInfo "status" has invalid value');this.status=s.valueBlock.valueDec,$r in t.result&&(this.statusStrings=t.result.statusStrings),Kr in t.result&&(this.failInfo=t.result.failInfo)}toSchema(){const e=[];return e.push(new B({value:this.status})),this.statusStrings&&e.push(new A({optional:!0,value:this.statusStrings})),this.failInfo&&e.push(this.failInfo),new A({value:e})}toJSON(){const e={status:this.status};return this.statusStrings&&(e.statusStrings=Array.from(this.statusStrings,t=>t.toJSON())),this.failInfo&&(e.failInfo=this.failInfo.toJSON()),e}}Wt.CLASS_NAME="PKIStatusInfo";const ql="version",Wl="messageImprint",io="reqPolicy",oo="nonce",Bs="certReq",uo="extensions",Un="TimeStampReq",Pf="".concat(Un,".").concat(ql),Of="".concat(Un,".").concat(Wl),yh="".concat(Un,".").concat(io),vh="".concat(Un,".").concat(oo),bh="".concat(Un,".").concat(Bs),Sh="".concat(Un,".").concat(uo),RS=[Pf,Of,yh,vh,bh,Sh];class Bt extends D{constructor(e={}){super(),this.version=f(e,ql,Bt.defaultValues(ql)),this.messageImprint=f(e,Wl,Bt.defaultValues(Wl)),io in e&&(this.reqPolicy=f(e,io,Bt.defaultValues(io))),oo in e&&(this.nonce=f(e,oo,Bt.defaultValues(oo))),Bs in e&&(this.certReq=f(e,Bs,Bt.defaultValues(Bs))),uo in e&&(this.extensions=f(e,uo,Bt.defaultValues(uo))),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case ql:return 0;case Wl:return new nt;case io:return v;case oo:return new B;case Bs:return!1;case uo:return[];default:return super.defaultValues(e)}}static compareWithDefault(e,t){switch(e){case ql:case io:case Bs:return t===Bt.defaultValues(e);case Wl:return nt.compareWithDefault("hashAlgorithm",t.hashAlgorithm)&&nt.compareWithDefault("hashedMessage",t.hashedMessage);case oo:return t.isEqual(Bt.defaultValues(e));case uo:return t.length===0;default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||Un,value:[new B({name:t.version||Pf}),nt.schema(t.messageImprint||{names:{blockName:Of}}),new J({name:t.reqPolicy||yh,optional:!0}),new B({name:t.nonce||vh,optional:!0}),new ia({name:t.certReq||bh,optional:!0}),new I({optional:!0,idBlock:{tagClass:3,tagNumber:0},value:[new Z({name:t.extensions||Sh,value:De.schema()})]})]})}fromSchema(e){T(e,RS);const t=R(e,e,Bt.schema());O.assertSchema(t,this.className),this.version=t.result[Pf].valueBlock.valueDec,this.messageImprint=new nt({schema:t.result[Of]}),yh in t.result&&(this.reqPolicy=t.result[yh].valueBlock.toString()),vh in t.result&&(this.nonce=t.result[vh]),bh in t.result&&(this.certReq=t.result[bh].valueBlock.value),Sh in t.result&&(this.extensions=Array.from(t.result[Sh],s=>new De({schema:s})))}toSchema(){const e=[];return e.push(new B({value:this.version})),e.push(this.messageImprint.toSchema()),this.reqPolicy&&e.push(new J({value:this.reqPolicy})),this.nonce&&e.push(this.nonce),Bs in this&&Bt.compareWithDefault(Bs,this.certReq)===!1&&e.push(new ia({value:this.certReq})),this.extensions&&e.push(new I({idBlock:{tagClass:3,tagNumber:0},value:Array.from(this.extensions,t=>t.toSchema())})),new A({value:e})}toJSON(){const e={version:this.version,messageImprint:this.messageImprint.toJSON()};return this.reqPolicy!==void 0&&(e.reqPolicy=this.reqPolicy),this.nonce!==void 0&&(e.nonce=this.nonce.toJSON()),this.certReq!==void 0&&Bt.compareWithDefault(Bs,this.certReq)===!1&&(e.certReq=this.certReq),this.extensions&&(e.extensions=Array.from(this.extensions,t=>t.toJSON())),e}}Bt.CLASS_NAME="TimeStampReq";const lo="status",co="timeStampToken",md="TimeStampResp",Df="".concat(md,".").concat(lo),Ah="".concat(md,".").concat(co),LS=[Df,Ah];class Xl extends D{constructor(e={}){super(),this.status=f(e,lo,Xl.defaultValues(lo)),co in e&&(this.timeStampToken=f(e,co,Xl.defaultValues(co))),e.schema&&this.fromSchema(e.schema)}static defaultValues(e){switch(e){case lo:return new Wt;case co:return new fe;default:return super.defaultValues(e)}}static compareWithDefault(e,t){switch(e){case lo:return Wt.compareWithDefault(lo,t.status)&&!("statusStrings"in t)&&!("failInfo"in t);case co:return t.contentType===v&&t.content instanceof X;default:return super.defaultValues(e)}}static schema(e={}){const t=f(e,"names",{});return new A({name:t.blockName||md,value:[Wt.schema(t.status||{names:{blockName:Df}}),fe.schema(t.timeStampToken||{names:{blockName:Ah,optional:!0}})]})}fromSchema(e){T(e,LS);const t=R(e,e,Xl.schema());O.assertSchema(t,this.className),this.status=new Wt({schema:t.result[Df]}),Ah in t.result&&(this.timeStampToken=new fe({schema:t.result[Ah]}))}toSchema(){const e=[];return e.push(this.status.toSchema()),this.timeStampToken&&e.push(this.timeStampToken.toSchema()),new A({value:e})}toJSON(){const e={status:this.status.toJSON()};return this.timeStampToken&&(e.timeStampToken=this.timeStampToken.toJSON()),e}async sign(e,t,s=Q(!0)){return this.assertContentType(),new st({schema:this.timeStampToken.content}).sign(e,0,t,void 0,s)}async verify(e={signer:0,trustedCerts:[],data:Ue},t=Q(!0)){return this.assertContentType(),new st({schema:this.timeStampToken.content}).verify(e,t)}assertContentType(){if(!this.timeStampToken)throw new Error("timeStampToken is absent in TSP response");if(this.timeStampToken.contentType!==Pg)throw new Error("Wrong format of timeStampToken: ".concat(this.timeStampToken.contentType))}}Xl.CLASS_NAME="TimeStampResp";function US(){if(typeof self<"u"){if("crypto"in self){let r="webcrypto";"webkitSubtle"in self.crypto&&(r="safari"),ap(r,new nc({name:r,crypto}))}}else if(typeof crypto<"u"&&"webcrypto"in crypto){const r="NodeJS ^15",e=crypto.webcrypto;ap(r,new nc({name:r,crypto:e}))}}US();function jS(r){return String.fromCharCode(...r)}function Hg(r){return Uint8Array.from(r,e=>e.charCodeAt(0))}function $S(r){return Array.from(r).map(e=>e.toString(16).padStart(2,"0")).join("")}function ws(r){return Hg(atob(r))}function fd(r){const e=r.replace(/-----BEGIN ((PRIVATE KEY)|(PUBLIC KEY)|(CERTIFICATE))-----/,"").replace(/-----END ((PRIVATE KEY)|(PUBLIC KEY)|(CERTIFICATE))-----/,"").replace(/\n/g,"");return ws(e)}var KS=Object.defineProperty,HS=Object.defineProperties,MS=Object.getOwnPropertyDescriptors,Sp=Object.getOwnPropertySymbols,FS=Object.prototype.hasOwnProperty,JS=Object.prototype.propertyIsEnumerable,Ap=(r,e,t)=>e in r?KS(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Tf=(r,e)=>{for(var t in e||(e={}))FS.call(e,t)&&Ap(r,t,e[t]);if(Sp)for(var t of Sp(e))JS.call(e,t)&&Ap(r,t,e[t]);return r},Np=(r,e)=>HS(r,MS(e));async function dd(r,e,t={}){return await self.crypto.subtle.decrypt(Tf({name:"AES-GCM"},t),e,r)}async function qS(r,e){return await self.crypto.subtle.decrypt({name:"RSA-OAEP"},e,r)}async function Mg(r){return await self.crypto.subtle.importKey("raw",r,{name:"AES-GCM",length:128},!0,["decrypt","encrypt"])}async function WS(r){return await self.crypto.subtle.importKey("spki",r,{name:"RSASSA-PKCS1-v1_5",hash:"SHA-256"},!0,["verify"])}async function GS(r){return await self.crypto.subtle.importKey("pkcs8",r,{name:"RSA-OAEP",hash:"SHA-256"},!0,["decrypt"])}async function zS(r){return new Uint8Array(await self.crypto.subtle.exportKey("raw",r))}async function _S(r){const e=await self.crypto.subtle.digest("SHA-256",r);return $S(new Uint8Array(e))}async function XS(r,e){return new gw(r).verify({publicKey:e},ZS())}function ZS(){return Np(Tf({},self.crypto),{subtle:Np(Tf({},self.crypto.subtle),{async verify(r,e,t,s){return self.crypto.subtle.verify(r,e,new Uint8Array(t),new Uint8Array(s))}})})}async function QS(r,e,t){const s=fe.fromBER(e),a=new st({schema:s.content}),n=a.signerInfos[0].sid.issuer.typesAndValues.find(({type:l})=>l==="2.5.4.3").value.valueBlock.value,u=t.find(({userId:l})=>l===n);if(u===void 0)throw new Error("Signer not found in the users array");const i=oe.fromBER(fd(u.certificate));return await a.verify({signer:0,trustedCerts:[i],data:r,checkChain:!0},eA())}class YS extends nc{verify(e,t,s,a){return super.verify(e,t,s,new Uint8Array(a))}}function eA(){return new YS({crypto:self.crypto})}var tA=Object.defineProperty,kp=Object.getOwnPropertySymbols,sA=Object.prototype.hasOwnProperty,rA=Object.prototype.propertyIsEnumerable,Cp=(r,e,t)=>e in r?tA(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,aA=(r,e)=>{for(var t in e||(e={}))sA.call(e,t)&&Cp(r,t,e[t]);if(kp)for(var t of kp(e))rA.call(e,t)&&Cp(r,t,e[t]);return r};async function nA(r,e){_e.debug("Decrypting private key",{privateKeyInfo:r,mnemonic:e});const t=await Promise.all([await Jm(e,r.salt,{hash:"SHA-256",iterations:6e5}),await Jm(e,r.salt,{hash:"SHA-1",iterations:1024}),await Jm(e,r.salt,{hash:"SHA-1",iterations:6e5})]);for(const s of t)try{const a=await dd(r.encryptedPrivateKey,s,{iv:r.iv,tagLength:128}),n=atob(jS(new Uint8Array(a)));return GS(fd(n))}catch(a){}throw new Error("Failed to decrypt private key")}async function Jm(r,e,t){const s=await crypto.subtle.importKey("raw",new TextEncoder().encode(r.replaceAll(" ","")),{name:"PBKDF2"},!1,["deriveKey"]);return await crypto.subtle.deriveKey(aA({name:"PBKDF2",salt:e},t),s,{name:"AES-GCM",length:256},!0,["decrypt","encrypt"])}const qm="apps/end_to_end_encryption/api/v2",Fg={PrivateKey:qm+"/private-key",Metadata:qm+"/meta-data/{fileId}",ServerKey:qm+"/server-key"};async function iA(){const r=(await Bp.get(Pp(Fg.PrivateKey),{headers:{"X-E2EE-SUPPORTED":"true"}})).data.ocs.data["private-key"],[e,t,s]=r.split("|");return{encryptedPrivateKey:ws(e),iv:ws(t),salt:ws(s)}}async function oA(){const r=await Bp.get(Pp(Fg.ServerKey),{headers:{"X-E2EE-SUPPORTED":"true"}});return await WS(fd(r.data.ocs.data["public-key"]))}const uA={name:"AlertCircleOutlineIcon",emits:["click"],props:{title:{type:String},fillColor:{type:String,default:"currentColor"},size:{type:Number,default:24}}};var lA=function(){var r=this,e=r._self._c;return e("span",r._b({staticClass:"material-design-icon alert-circle-outline-icon",attrs:{"aria-hidden":r.title?null:"true","aria-label":r.title,role:"img"},on:{click:function(t){return r.$emit("click",t)}}},"span",r.$attrs,!1),[e("svg",{staticClass:"material-design-icon__svg",attrs:{fill:r.fillColor,width:r.size,height:r.size,viewBox:"0 0 24 24"}},[e("path",{attrs:{d:"M11,15H13V17H11V15M11,7H13V13H11V7M12,2C6.47,2 2,6.5 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2M12,20A8,8 0 0,1 4,12A8,8 0 0,1 12,4A8,8 0 0,1 20,12A8,8 0 0,1 12,20Z"}},[r.title?e("title",[r._v(r._s(r.title))]):r._e()])])])},cA=[],hA=lc(uA,lA,cA,!1,null,null);const mA=hA.exports,fA={name:"CheckIcon",emits:["click"],props:{title:{type:String},fillColor:{type:String,default:"currentColor"},size:{type:Number,default:24}}};var dA=function(){var r=this,e=r._self._c;return e("span",r._b({staticClass:"material-design-icon check-icon",attrs:{"aria-hidden":r.title?null:"true","aria-label":r.title,role:"img"},on:{click:function(t){return r.$emit("click",t)}}},"span",r.$attrs,!1),[e("svg",{staticClass:"material-design-icon__svg",attrs:{fill:r.fillColor,width:r.size,height:r.size,viewBox:"0 0 24 24"}},[e("path",{attrs:{d:"M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"}},[r.title?e("title",[r._v(r._s(r.title))]):r._e()])])])},pA=[],gA=lc(fA,dA,pA,!1,null,null);const wA=gA.exports,yA={name:"NcInputField",components:{NcButton:Qg,AlertCircle:mA,Check:wA},inheritAttrs:!1,model:{prop:"modelValue",event:"update:modelValue"},props:{value:{type:[String,Number],default:void 0},modelValue:{type:[String,Number],default:void 0},type:{type:String,default:"text",validator:r=>["text","password","email","tel","url","search","number"].includes(r)},label:{type:String,default:void 0},labelOutside:{type:Boolean,default:!1},placeholder:{type:String,default:void 0},showTrailingButton:{type:Boolean,default:!1},trailingButtonLabel:{type:String,default:""},success:{type:Boolean,default:!1},error:{type:Boolean,default:!1},helperText:{type:String,default:""},disabled:{type:Boolean,default:!1},pill:{type:Boolean,default:!1},inputClass:{type:[Object,String],default:""}},emits:["update:value","update:modelValue","update:model-value","trailing-button-click"],setup(){return{model:Dp("value","update:value",!0)}},computed:{computedId(){return this.$attrs.id&&this.$attrs.id!==""?this.$attrs.id:this.inputName},inputName(){return"input"+Yg()},hasLeadingIcon(){return this.$slots.default},hasTrailingIcon(){return this.success},hasPlaceholder(){return this.placeholder!==""&&this.placeholder!==void 0},computedPlaceholder(){return this.hasPlaceholder?this.placeholder:this.label},isValidLabel(){const r=this.label||this.labelOutside;return r||console.warn("You need to add a label to the NcInputField component. Either use the prop label or use an external one, as per the example in the documentation."),r},ariaDescribedby(){const r=[];return this.helperText.length>0&&r.push("".concat(this.inputName,"-helper-text")),this.$attrs["aria-describedby"]&&r.push(this.$attrs["aria-describedby"]),r.join(" ")||null}},methods:{focus(){this.$refs.input.focus()},select(){this.$refs.input.select()},handleInput(r){const e=this.type==="number"&&typeof this.model=="number"?parseFloat(r.target.value,10):r.target.value;this.model=e},handleTrailingButtonClick(r){this.$emit("trailing-button-click",r)}}};var vA=function(){var t;var r=this,e=r._self._c;return e("div",{staticClass:"input-field",class:{"input-field--disabled":r.disabled,"input-field--label-outside":r.labelOutside||!r.isValidLabel,"input-field--leading-icon":r.hasLeadingIcon,"input-field--trailing-icon":r.showTrailingButton||r.hasTrailingIcon,"input-field--pill":r.pill}},[e("div",{staticClass:"input-field__main-wrapper"},[e("input",r._g(r._b({ref:"input",staticClass:"input-field__input",class:[r.inputClass,{"input-field__input--success":r.success,"input-field__input--error":r.error}],attrs:{id:r.computedId,type:r.type,disabled:r.disabled,placeholder:r.computedPlaceholder,"aria-describedby":r.ariaDescribedby,"aria-live":"polite"},domProps:{value:(t=r.model)==null?void 0:t.toString()},on:{input:r.handleInput}},"input",r.$attrs,!1),r.$listeners)),!r.labelOutside&&r.isValidLabel?e("label",{staticClass:"input-field__label",attrs:{for:r.computedId}},[r._v(" "+r._s(r.label)+" ")]):r._e(),e("div",{directives:[{name:"show",rawName:"v-show",value:r.hasLeadingIcon,expression:"hasLeadingIcon"}],staticClass:"input-field__icon input-field__icon--leading"},[r._t("default")],2),r.showTrailingButton?e("NcButton",{staticClass:"input-field__trailing-button",attrs:{type:"tertiary-no-background","aria-label":r.trailingButtonLabel,disabled:r.disabled},on:{click:r.handleTrailingButtonClick},scopedSlots:r._u([{key:"icon",fn:function(){return[r._t("trailing-button-icon")]},proxy:!0}],null,!0)}):r.success||r.error?e("div",{staticClass:"input-field__icon input-field__icon--trailing"},[r.success?e("Check",{staticStyle:{color:"var(--color-success-text)"},attrs:{size:20}}):r.error?e("AlertCircle",{staticStyle:{color:"var(--color-error-text)"},attrs:{size:20}}):r._e()],1):r._e()],1),r.helperText.length>0?e("p",{staticClass:"input-field__helper-text-message",class:{"input-field__helper-text-message--error":r.error,"input-field__helper-text-message--success":r.success},attrs:{id:"".concat(r.inputName,"-helper-text")}},[r.success?e("Check",{staticClass:"input-field__helper-text-message__icon",attrs:{size:18}}):r.error?e("AlertCircle",{staticClass:"input-field__helper-text-message__icon",attrs:{size:18}}):r._e(),r._v(" "+r._s(r.helperText)+" ")],1):r._e()])},bA=[],SA=lc(yA,vA,bA,!1,null,"e4fac465");const Rf=SA.exports,AA={name:"UndoVariantIcon",emits:["click"],props:{title:{type:String},fillColor:{type:String,default:"currentColor"},size:{type:Number,default:24}}};var NA=function(){var r=this,e=r._self._c;return e("span",r._b({staticClass:"material-design-icon undo-variant-icon",attrs:{"aria-hidden":r.title?null:"true","aria-label":r.title,role:"img"},on:{click:function(t){return r.$emit("click",t)}}},"span",r.$attrs,!1),[e("svg",{staticClass:"material-design-icon__svg",attrs:{fill:r.fillColor,width:r.size,height:r.size,viewBox:"0 0 24 24"}},[e("path",{attrs:{d:"M13.5,7A6.5,6.5 0 0,1 20,13.5A6.5,6.5 0 0,1 13.5,20H10V18H13.5C16,18 18,16 18,13.5C18,11 16,9 13.5,9H7.83L10.91,12.09L9.5,13.5L4,8L9.5,2.5L10.92,3.91L7.83,7H13.5M6,18H8V20H6V18Z"}},[r.title?e("title",[r._v(r._s(r.title))]):r._e()])])])},kA=[],CA=lc(AA,NA,kA,!1,null,null);const EA=CA.exports;ew(rw,sw);const xA=new Set(Object.keys(Rf.props)),IA={name:"NcTextField",components:{NcInputField:Rf,Close:tw,ArrowRight:ww,Undo:EA},inheritAttrs:!1,model:{prop:"modelValue",event:"update:modelValue"},props:os(it({" ":{}},Rf.props),{trailingButtonLabel:{type:String,default:""},trailingButtonIcon:{type:String,default:"close",validator:r=>["close","arrowRight","undo"].includes(r)}}),emits:["update:value","update:modelValue","update:model-value"],setup(){return{model:Dp("value","update:value")}},computed:{propsAndAttrsToForward(){const r={undo:em("Undo changes"),close:em("Clear text"),arrowRight:em("Save changes")};return os(it(it({},this.$attrs),Object.fromEntries(Object.entries(this.$props).filter(([e])=>xA.has(e)))),{trailingButtonLabel:this.trailingButtonLabel||r[this.trailingButtonIcon]})}},methods:{focus(){this.$refs.inputField.focus()},select(){this.$refs.inputField.select()}}};var VA=function(){var r=this,e=r._self._c;return e("NcInputField",r._g(r._b({ref:"inputField",scopedSlots:r._u([r.type!=="search"?{key:"trailing-button-icon",fn:function(){return[r.trailingButtonIcon==="close"?e("Close",{attrs:{size:20}}):r.trailingButtonIcon==="arrowRight"?e("ArrowRight",{attrs:{size:20}}):r.trailingButtonIcon==="undo"?e("Undo",{attrs:{size:20}}):r._e()]},proxy:!0}:null],null,!0)},"NcInputField",r.propsAndAttrsToForward,!1),r.$listeners),[r._t("default")],2)},BA=[],PA=lc(IA,VA,BA,!1,null,null);const OA=PA.exports,DA=aw({__name:"MnemonicPromptDialog",emits:["close"],setup(r,{emit:e}){const t=tm(),s=tm(""),a=tm(!1),n=wd(()=>a.value===!0&&s.value.trim().split(/\s+/g).length===12);function u(){e("close",s.value)}const i=wd(()=>[{label:zm("end_to_en_encryption","Submit"),nativeType:"submit",type:"primary",disabled:!n.value,callback:u}]);return{__sfc:!0,emit:e,dialogRef:t,mnemonic:s,confirmToggle:a,isFormValid:n,submit:u,buttons:i,t:zm,NcDialog:nw,NcTextField:OA,NcNoteCard:iw,NcCheckboxRadioSwitch:yw}}});var TA=function(){var r=this,e=r._self._c,t=r._self._setupProxy;return e(t.NcDialog,{ref:"dialogRef",attrs:{name:t.t("end_to_end_encryption","Enter your 12 words mnemonic"),buttons:t.buttons,"is-form":!0},on:{submit:t.submit}},[e(t.NcNoteCard,{attrs:{type:"warning","show-alert":!0,heading:t.t("end_to_end_encryption","Decrypting your files in the browser can weaken security")}},[r._v(" "+r._s(t.t("end_to_end_encryption","The server could serve malicious source code to extract the secret that protects your files."))+" "),e(t.NcCheckboxRadioSwitch,{attrs:{required:!0,"data-cy-e2ee-mnemonic-prompt":"i_understand_the_risks",type:"switch"},model:{value:t.confirmToggle,callback:function(s){t.confirmToggle=s},expression:"confirmToggle"}},[r._v(" "+r._s(t.t("end_to_end_encryption","I understand the risks"))+" ")])],1),e(t.NcTextField,{attrs:{value:t.mnemonic,required:"true",pattern:"^(\\w+\\s+){11}\\w+$",label:t.t("end_to_end_encryption","Mnemonic"),autofocus:!0},on:{"update:value":function(s){t.mnemonic=s}}})],1)},RA=[],LA=ow(DA,TA,RA,!1,null,null);const UA=LA.exports;async function jA(){const r=Promise.withResolvers();return uw(UA,void 0,e=>{e!==void 0?r.resolve(e):r.reject()}),r.promise}async function $A(r,e){_e.debug("Decrypting metadata info",{metadata:r});const[t,s]=r.metadata.ciphertext.split("|"),a=await dd(ws(t),e,{iv:ws(s)}),n=JSON.parse(await MA(a));return KA(n,r),await HA(n,e),n}function KA(r,e){var t,s;if(((t=r.keyChecksums)==null?void 0:t.length)!==((s=e.users)==null?void 0:s.length))throw new Error("Key checksums length does not match users length")}async function HA(r,e){if(r.keyChecksums===void 0)return;const t=await zS(e),s=await _S(t);if(!r.keyChecksums.includes(s))throw new Error("Key checksum is not in keyChecksums")}async function MA(r){const e=new ReadableStream({start(t){t.enqueue(new Uint8Array(r)),t.close()}}).pipeThrough(new DecompressionStream("gzip"));return await new Response(e).text()}async function FA(r,e,t){var s;_e.debug("Getting metadata private key",{metadata:r,userId:e});const a=(s=r.users)==null?void 0:s.find(i=>i.userId===e);if(!a)throw new Error("User not found in metadata");const n=ws(a.encryptedMetadataKey),u=await qS(n,t);return await Mg(new Uint8Array(u))}async function Ep(r,e,t){const s=JSON.stringify(r,(n,u)=>{if(n!=="filedrop")return u}),a=await QS(Hg(btoa(s)),ws(e),t.users);if(!a)throw new Error("Metadata signature verification failed");return a}async function JA(r,e){const t=r.users.map(async({userId:s,certificate:a})=>{const n=await XS(a,e);if(!n)throw new Error("Certificate verification failed for user ".concat(s));return n});return await Promise.all(t)}const qA=Zy(),ht={_userPrivateKey:void 0,_serverPublicKey:void 0,_metadataCache:{},async getUserPrivateKey(){var r;return(r=this._userPrivateKey)!=null||(this._userPrivateKey=await nA(await iA(),await jA())),this._userPrivateKey},async getServerPublicKey(){var r;return(r=this._serverPublicKey)!=null||(this._serverPublicKey=await oA()),this._serverPublicKey},async getMetadata(r){if(this._metadataCache[r])return _e.debug("Found metadata in cache",{path:r,state:ht}),this._metadataCache[r];if(_e.debug("Fetching PROPFIND for metadata",{path:r,state:ht}),await qA.stat(decodeURI(r).replace("remote.php/dav/",""),{details:!0,data:Gy()}),this._metadataCache[r])return _e.debug("Found metadata in cache after PROPFIND",{path:r,state:ht}),this._metadataCache[r];throw new Error("Could not find metadata for ".concat(r))},async setMetadata(r,e,t){const s=JSON.parse(e);qc(s)?(await Ep(s,t,s),await JA(s,await this.getServerPublicKey())):await Ep(s,t,await this.getRootMetadata(No.dirname(r))),this._metadataCache[r]=s,_e.debug("Added metadata in cache",{path:r,state:ht})},async getMetadataInfo(r){const e=await this.getMetadata(r),t=await this.getRootMetadata(r),s=Uf();if(s===null)throw new Error("No user logged in");return $A(e,await FA(t,s.uid,await ht.getUserPrivateKey()))},async getRootMetadata(r){const e=Object.entries(ht._metadataCache).filter(([t])=>r.startsWith(t)).map(([,t])=>t).find(t=>qc(t));if(e)return _e.debug("Found root metadata in cache",{path:r,state:ht}),e;for(_e.debug("Looking for root metadata",{path:r,state:ht});r!=="/";){const t=await ht.getMetadata(r);if(qc(t))return _e.debug("Fetched root metadata",{path:r,state:ht}),t;r=No.dirname(r)}throw new Error("Found no root metadata for ".concat(r))}};var WA=Object.defineProperty,GA=Object.defineProperties,zA=Object.getOwnPropertyDescriptors,xp=Object.getOwnPropertySymbols,_A=Object.prototype.hasOwnProperty,XA=Object.prototype.propertyIsEnumerable,Ip=(r,e,t)=>e in r?WA(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,ZA=(r,e)=>{for(var t in e||(e={}))_A.call(e,t)&&Ip(r,t,e[t]);if(xp)for(var t of xp(e))XA.call(e,t)&&Ip(r,t,e[t]);return r},QA=(r,e)=>GA(r,zA(e));let qh;function YA(){qh=window.fetch,_e.debug("Setting up WebDAV decryption proxy"),window.fetch=async(r,e={})=>{let t=new Request(r,e);if(!(t.url.includes("/remote.php/dav/files/")&&(t.method==="GET"||t.method==="PROPFIND")))return qh(t);_e.debug("Proxying ".concat(t.method," ").concat(t.url),{request:t});const s=new Headers(t.headers);switch(s.set("X-E2EE-SUPPORTED","true"),t=new Request(t,{headers:s}),t.method){case"PROPFIND":return tN(t);case"GET":default:return eN(t)}}}async function eN(r){const e=new URL(r.url).pathname,t=qh(r);try{const s=await ht.getMetadataInfo(No.dirname(e)),a=s.files[No.basename(r.url)];if(a===void 0)throw _e.debug("Could not find file in metadata",{path:e,metadataInfo:s}),new Error("Could not find file in metadata");return await sN(await t,a)}catch(s){return await t}}async function tN(r){var e;_e.debug("Fetching raw PROPFIND",{request:r});const t=await qh(r),s=new URL(r.url).pathname,a=await t.text(),n=await Fy(a),u=My(n,s,!0);if(((e=u.props)==null?void 0:e["e2ee-is-encrypted"])!==1)return _e.debug("Node is not e2ee",{xml:n}),new Response(a,t);if(u.type==="directory"){const i=u.props["e2ee-metadata"],l=u.props["e2ee-metadata-signature"];i!==void 0&&l!==void 0&&await ht.setMetadata(s,i,l);const o=await ht.getMetadata(s),c=await ht.getMetadataInfo(s);if(qc(o))Wm(n,s,c);else{const m=await ht.getMetadataInfo(No.dirname(s));Wm(n,s,c,m)}}else if(u.type==="file"){const i=await ht.getMetadataInfo(No.dirname(s));if(i===void 0)return _e.debug("Cannot find metadata for parent folder",{path:s}),new Response(a,t);Wm(n,s,void 0,i)}return new Response(new xb.XMLBuilder().build(n),t)}function Wm(r,e,t,s){_e.debug("Updating PROPFIND info",{path:e,decryptedMetadata:t,decryptedParentMetadata:s,xml:r}),r.multistatus.response.forEach(a=>{if(a.propstat===void 0)return;const n=a.href===e?s:t;if(n===void 0)return;const u=a.propstat.prop.displayname;let i=u;n.files[u]?(i=n.files[u].filename,a.propstat.prop.getcontenttype=n.files[u].mimetype):n.folders[u]&&(i=n.folders[u],a.propstat.prop.getcontenttype="httpd/unix-directory"),a.propstat.prop.displayname=i,a.propstat.prop.permissions=a.propstat.prop.permissions.replace(/(R)|(D)|(N)|(V)|(W)|(CK)/g,"")})}async function sN(r,e){_e.debug("Decrypting encrypted file",{response:r,fileEncryptionInfo:e});const t=await dd(new Uint8Array(await r.arrayBuffer()),await Mg(ws(e.key)),{iv:ws(e.nonce)}),s=new Headers(r.headers);return s.set("Content-Type",e.mimetype),new Response(t,QA(ZA({},r),{headers:s}))}const rN='<svg xmlns="http://www.w3.org/2000/svg" id="mdi-arrow-down" viewBox="0 0 24 24"><path d="M11,4H13V16L18.5,10.5L19.92,11.92L12,19.84L4.08,11.92L5.5,10.5L11,16V4Z" /></svg>';function aN(r){if(!(r.permissions&rg.READ))return!1;if(r.attributes["share-attributes"]){const e=JSON.parse(r.attributes["share-attributes"]||"[]").find(({scope:t,key:s})=>t==="permissions"&&s==="download");if(e!==void 0)return e.value===!0}return!0}async function nN([r]){const e=await(await fetch(r.encodedSource)).arrayBuffer(),t=new Blob([e],{type:r.mime}),s=document.createElement("a");s.href=window.URL.createObjectURL(t),s.download=r.displayname,s.click()}const iN=new Qy({id:"download_unencrypted",default:Gf.DEFAULT,displayName:()=>zm("files","Download unencrypted"),iconSvgInline:()=>rN,enabled(r){return r.length!==1||r.some(e=>e.attributes["e2ee-is-encrypted"]!==1)||r.some(e=>!e.isDavRessource)||r.some(e=>e.type!==ag.File)?!1:r.every(aN)},async exec(r){return nN([r]),null},order:30}),oN=Lf("end_to_end_encryption","userConfig",{e2eeInBrowserEnabled:!1});oN.e2eeInBrowserEnabled&&(YA(),hm("nc:e2ee-is-encrypted",{nc:"http://nextcloud.org/ns"}),hm("nc:e2ee-metadata",{nc:"http://nextcloud.org/ns"}),hm("nc:e2ee-metadata-signature",{nc:"http://nextcloud.org/ns"}),Yy(iN),Vp("download"),Vp("move-copy"));function Vp(r){_e.debug("Inhibiting ".concat(r," actions for e2ee files"));const e=ev().find(s=>s.id===r),t=e._action.enabled;e._action.enabled=(s,a)=>s.some(n=>n.attributes["e2ee-is-encrypted"]===1)?!1:t(s,a)}