@wener/utils 1.1.10 → 1.1.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- System.register([],function(u,ye){"use strict";return{execute:function(){u({arrayFromAsync:me,arrayOfMaybeArray:ge,camelCase:G,classOf:B,clearAsyncInterval:ve,copy:Ke,createChildLogger:Ve,createLazyPromise:we,createLogger:M,createNoopLogger:Z,createRandom:ht,createTranslate:Fe,createULID:de,deepEqual:v,download:Ye,firstOfMaybeArray:R,formatBytes:Ne,get:S,getFileFromDataTransfer:Xe,hex:st,isBuffer:O,isClass:Ue,isDefined:$e,isEmptyObject:Ce,isModule:Le,isPlainObject:W,isPromise:N,isTransferable:ze,isULID:ct,isUUID:Pe,lastOfMaybeArray:he,loadScripts:te,loadStyles:Qe,maybeFunction:xe,memoize:Se,objectOfMaybeArray:pe,parseBoolean:Te,parseModuleId:De,parseObjectPath:x,parseTimestamp:Me,parseULID:ut,pascalCase:Re,renderTemplate:H,set:be,setAsyncInterval:Ae,sha1:rt,sha256:nt,sha384:ot,sha512:at,shallowClone:Ee,shallowEqual:Oe,timeout:Be});function pe(e,t=null,r=R){return Object.fromEntries(t===null?Object.entries(e).map(([n,o])=>[n,r(o)]):t.map(n=>[n,r(n)]))}function R(e){return Array.isArray(e)?e[0]:e}function he(e){return Array.isArray(e)?e[e.length-1]:e}function ge(e){return Array.isArray(e)?e:e==null?[]:[e]}async function me(e){const t=[];for await(const r of e)t.push(r);return t}function x(e){if(typeof e!="string")return Array.isArray(e)?e:[e];const t=e.split(".");if(!e.includes("["))return t;const r=[];for(const n of t)if(!n.endsWith("]"))r.push(n);else{const o=n.split("[");for(let a of o)a.endsWith("]")&&(a=a.slice(0,-1)),r.push(a)}return r}function S(e,t,r){const n=x(t);let o=e;for(const a of n)o=o?o[a]:void 0;return o===void 0?r:o}function be(e,t,r,n=!0){const o=x(t);let a=0;const i=o.length;let s=e,c,l;for(;a<i&&(l=o[a++],!(l==="__proto__"||l==="constructor"||l==="prototype"));)s=s[l]=a===i?n?P(s[l],r):r:typeof(c=s[l])==typeof o?c:o[a]*0!==0||~(""+o[a]).indexOf(".")?{}:[]}function P(e,t){let r;if(typeof e=="object"&&typeof t=="object"){if(Array.isArray(e)&&Array.isArray(t))for(r=0;r<t.length;r++)e[r]=P(e[r],t[r]);else for(r in t){if(r==="__proto__"||r==="constructor"||r==="prototype")break;e[r]=P(e[r],t[r])}return e}return t}function N(e){return e&&(e instanceof Promise||e.then&&e.catch)}function we(e){const t={resolve(n){throw new Error("pending resolve")},reject(n){throw new Error("pending reject")}},r=Object.assign(new Promise((n,o)=>{t.reject=o,t.resolve=n}),{resolve(n){t.resolve(n)},reject(n){t.resolve(n)}});if(e){const n=t.resolve;let o=!0;t.resolve=s=>{o=!1,n(s)};const a=r.then.bind(r);r.then=(...s)=>{if(o){o=!1;try{const c=e(t.resolve,t.reject);N(c)?c.then(t.resolve,t.reject):c!==void 0&&t.resolve(c)}catch(c){t.reject(c)}}return a(...s)};const i=t;return i.then=r.then,i.catch=r.catch.bind(r),r.finally&&(i.finally=r.finally),Object.defineProperty(i,Symbol.species,{get(){return Promise}}),i}return r}function Ae(e,t,r=t){let n;const o=async()=>{await e(),n=setTimeout(o,t)};return n=setTimeout(o,r),()=>n}function ve(e){clearTimeout(e==null?void 0:e())}const gt=u("sleep",e=>new Promise(t=>setTimeout(t,e)));function Be(e,t){const r=new F;let n;return Promise.race([e,new Promise((o,a)=>{n=setTimeout(()=>a(r),t)})]).then(o=>(clearTimeout(n),o),o=>{throw clearTimeout(n),o})}class F extends Error{constructor(){super("TimeoutError")}}u("TimeoutError",F);function Oe(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;const r=Object.keys(e);if(r.length!==Object.keys(t).length)return!1;for(let n=0;n<r.length;n++)if(!Object.prototype.hasOwnProperty.call(t,r[n])||!Object.is(e[r[n]],t[r[n]]))return!1;return!0}const z=Object.prototype.hasOwnProperty,je=typeof Element<"u";function q(e,t,r){for(r of e.keys())if(v(r,t))return r}function v(e,t){let r,n,o;if(e===t)return!0;if(e&&t&&(r=e.constructor)===t.constructor){if(r===Date)return e.getTime()===t.getTime();if(r===RegExp)return e.toString()===t.toString();if(r===Array){if((n=e.length)===t.length)for(;n--&&v(e[n],t[n]););return n===-1}if(r===Set){if(e.size!==t.size)return!1;for(n of e)if(o=n,o&&typeof o=="object"&&(o=q(t,o),!o)||!t.has(o))return!1;return!0}if(r===Map){if(e.size!==t.size)return!1;for(n of e)if(o=n[0],o&&typeof o=="object"&&(o=q(t,o),!o)||!v(n[1],t.get(o)))return!1;return!0}if(r===ArrayBuffer)e=new Uint8Array(e),t=new Uint8Array(t);else if(r===DataView){if((n=e.byteLength)===t.byteLength)for(;n--&&e.getInt8(n)===t.getInt8(n););return n===-1}if(ArrayBuffer.isView(e)){if((n=e.byteLength)===t.byteLength)for(;n--&&e[n]===t[n];);return n===-1}if(je&&e instanceof Element)return!1;if(!r||typeof e=="object"){n=0;for(r in e)if(!((r==="_owner"||r==="__v"||r==="__o")&&e.$$typeof)&&(z.call(e,r)&&++n&&!z.call(t,r)||!(r in t)||!v(e[r],t[r])))return!1;return Object.keys(t).length===n}}return e!==e&&t!==t}function B(e){return Object.prototype.toString.call(e).slice(8,-1)}function Ee(e){return e&&(Array.isArray(e)?e.slice():typeof e=="object"?Object.assign({},e):e)}function Ue(e){return typeof e=="function"&&/^class\s/.test(Function.prototype.toString.call(e))}function $e(e){return e!=null}function W(e){return B(e)!=="Object"?!1:e.constructor===Object&&Object.getPrototypeOf(e)===Object.prototype}function Ce(e){return W(e)&&Object.keys(e).length===0}function Te(e,t=!1){if(typeof e=="boolean")return e;if(typeof e=="string")switch(e.toLowerCase()){case"f":case"false":case"0":return!1;case"1":case"t":case"true":return!0}else if(typeof e=="number")switch(e){case 0:return!1;case 1:return!0}if(!t)return Boolean(e)}function xe(e,...t){return e instanceof Function?e(...t):e}function Se(e,{resolver:t=(...r)=>JSON.stringify(r)}={}){if(typeof e!="function")throw new Error("`callback` should be a function");if(t!==void 0&&typeof t!="function")throw new Error("`resolver` should be a function");const r={},n=function(){const o=Array.prototype.slice.call(arguments),a=t.apply(this,o);return a in r||(r[a]=e.apply(this,o)),r[a]};return n.cache=r,n}function Pe(e){return/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(e)}function Me(e){if(e){if(e instanceof Date)return e;if(typeof e=="string"&&/^[0-9.]+$/.test(e)){let t=parseFloat(e);return Math.floor(t).toString().length<=11&&(t*=1e3),new Date(t)}else if(typeof e=="string"){const t=new Date(e);if(!isNaN(+t))return t}throw new Error(`parseTimestamp: invalid "${e}"`)}}const ke=/^(?<n>(?:@(?<org>[a-z0-9-~][a-z0-9-._~]*)\/)?(?<pkg>[a-z0-9-~][a-z0-9-._~]*))(?:@(?<v>[-a-z0-9><=_.^~]+))?(?<p>\/[^\r\n]*)?$/;function De(e){var t;const r=(t=e.match(ke))==null?void 0:t.groups;if(!r)return;const{n,v:o,p:a,org:i,pkg:s}=r,c=Boolean(i),l=/^\d+\.\d+\.\d+/.test(o)?o:void 0,A=o||"latest",$={id:`${n}@${A}`,name:n,range:A,scoped:c,pkg:s,org:i,versioned:Boolean(o)};return l&&($.version=l),a&&($.path=a),$.scoped||delete $.org,$}function Le(e){return e&&e[Symbol.toStringTag]==="Module"}function M(e=({level:r,values:n,...o})=>{var a;({values:n,...o}=_e(o,n)),(a=console[r])==null||a.call(console,...n,o)},t={}){return{trace:(...r)=>e({...t,level:"trace",values:r}),debug:(...r)=>e({...t,level:"debug",values:r}),info:(...r)=>e({...t,level:"info",values:r}),warn:(...r)=>e({...t,level:"warn",values:r}),error:(...r)=>e({...t,level:"error",values:r}),child:r=>M(e,{...t,...r})}}function _e(e,t){return t[0]&&typeof t[0]=="object"?{...e,...t[0],values:t.slice(1)}:{...e,values:t}}function Z(){const e=(...t)=>{};return{trace:e,debug:e,info:e,warn:e,error:e,child:()=>Z()}}function Ve(e,t){return e.child?e.child(t):M(r=>{const{level:n,values:o,...a}=r;Object.keys(a).length?e[n](a,...o):e[n](...o)},t)}function Ie(e){let t=!1,r=!1,n=!1;for(let o=0;o<e.length;o++){const a=e[o];t&&/[a-zA-Z]/.test(a)&&a.toUpperCase()===a?(e=e.slice(0,o)+"-"+e.slice(o),t=!1,n=r,r=!0,o++):r&&n&&/[a-zA-Z]/.test(a)&&a.toLowerCase()===a?(e=e.slice(0,o-1)+"-"+e.slice(o-1),n=r,r=!1,t=!0):(t=a.toLowerCase()===a&&a.toUpperCase()!==a,n=r,r=a.toUpperCase()===a&&a.toLowerCase()!==a)}return e}function Re(e){return G(e,{pascalCase:!0})}function G(e,t={pascalCase:!1}){if(!(typeof e=="string"||Array.isArray(e)))throw new TypeError("Expected the input to be `string | string[]`");const r=n=>t.pascalCase?n.charAt(0).toUpperCase()+n.slice(1):n;return Array.isArray(e)?e=e.map(n=>n.trim()).filter(n=>n.length).join("-"):e=e.trim(),e.length===0?"":e.length===1?t.pascalCase?e.toUpperCase():e.toLowerCase():(e!==e.toLowerCase()&&(e=Ie(e)),e=e.replace(/^[_.\- ]+/,"").toLowerCase().replace(/[_.\- ]+(\w|$)/g,(n,o)=>o.toUpperCase()).replace(/\d+(\w|$)/g,n=>n.toUpperCase()),r(e))}function H(e,t,r="js"){let n;return t?typeof t=="function"?n=t:n=o=>S(t,o):n=()=>"",typeof r=="string"&&(r=J[r]||J.js),e.replace(r,(o,a)=>n(a.trim()))}const J={js:/\${(.*?)}/g,common:/{{(.*?)}}/g};function Ne(e,t=!1,r=1){const n=t?1e3:1024;if(Math.abs(e)<n)return`${e} B`;const o=t?["kB","MB","GB","TB","PB","EB","ZB","YB"]:["KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"];let a=-1;const i=10**r;do e/=n,++a;while(Math.round(Math.abs(e)*i)/i>=n&&a<o.length-1);return e.toFixed(r)+" "+o[a]}function Fe(e){let t="";const r=e||{},n=o=>{if(Array.isArray(o))return o;const a=o.split(/[_-]/);return a.length>1?[o,a[0]]:[o]};return{locale(o){return t=o||t},dict:(o,a)=>{if(a){r[o]=Object.assign(r[o]||{},a);return}return r[o]},t(o,a,i){let s;for(const c of n(i||t))if(s=S(r[c],o,""),s)break;return typeof s=="function"?s(a):typeof s=="string"?H(s,a,"common"):s}}}function O(e){var t,r;return(r=(t=e==null?void 0:e.constructor)==null?void 0:t.isBuffer)==null?void 0:r.call(t,e)}function ze(e){return K||=qe(),K.some(t=>e instanceof t)}let K;function qe(){const e=globalThis.window||globalThis||global;return[e.ArrayBuffer,e.MessagePort,e.ReadableStream,e.WritableStream,e.TransformStream,e.AudioData,e.ImageBitmap,e.VideoFrame,e.OffscreenCanvas,e.RTCDataChannel].filter(Boolean)}const m="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",j=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let e=0;e<m.length;e++)j[m.charCodeAt(e)]=e;function We(e){const t=new Uint8Array(e),r=t.length;let n="";for(let o=0;o<r;o+=3)n+=m[t[o]>>2],n+=m[(t[o]&3)<<4|t[o+1]>>4],n+=m[(t[o+1]&15)<<2|t[o+2]>>6],n+=m[t[o+2]&63];return r%3===2?n=n.substring(0,n.length-1)+"=":r%3===1&&(n=n.substring(0,n.length-2)+"=="),n}function Ze(e){const t=e.length;let r=e.length*.75,n,o=0,a,i,s,c;e[e.length-1]==="="&&(r--,e[e.length-2]==="="&&r--);const l=new ArrayBuffer(r),A=new Uint8Array(l);for(n=0;n<t;n+=4)a=j[e.charCodeAt(n)],i=j[e.charCodeAt(n+1)],s=j[e.charCodeAt(n+2)],c=j[e.charCodeAt(n+3)],A[o++]=a<<2|i>>4,A[o++]=(i&15)<<4|s>>2,A[o++]=(s&3)<<6|c&63;return l}var Y=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},k=(e,t,r)=>(Y(e,t,"read from private field"),r?r.call(e):t.get(e)),Q=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},X=(e,t,r,n)=>(Y(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r),C,E;const d=class{static isNativeBufferAvailable(){var t,r;return k(this,E)??X(this,E,!((r=(t=globalThis.Buffer)==null?void 0:t.isPollyfill)!=null&&r.call(t)))}static isNativeBufferAllowed(){return k(this,C)&&k(this,E)}static setNativeBufferAllowed(t){X(this,C,t)}};let f=u("ArrayBuffers",d);C=new WeakMap,E=new WeakMap,Q(f,C,!0),Q(f,E,void 0),f.isArrayBuffer=e=>e instanceof ArrayBuffer,f.slice=(e,t,r)=>O(e)?Uint8Array.prototype.slice.call(e,t,r):e.slice(t,r),f.asView=(e,t,r,n)=>t instanceof e&&(r??0)===0&&n===void 0?t:ArrayBuffer.isView(t)||O(t)?d.isNativeBufferAllowed()&&e===Buffer?Buffer.from(t.buffer,r,n):new e(t.buffer,t.byteOffset+(r??0),n??t.byteLength):new e(t,r,n),f.toString=(e,t="utf8")=>{if(typeof e=="string")switch(t){case"base64":return btoa(e);case"utf-8":case"utf8":return e;default:throw new Error(`[ArrayBuffers.toString] Unsupported encoding for string: ${t}`)}if(d.isNativeBufferAllowed())return Buffer.from(d.asView(Uint8Array,e)).toString(t);switch(t){case"hex":return[...d.asView(Uint8Array,e)].map(r=>Ge[r]).join("");case"base64":return We(d.asView(Uint8Array,e));case"utf8":case"utf-8":return new TextDecoder().decode(e);case"ascii":{const r=d.asView(Uint8Array,e);return String.fromCharCode(...r.map(n=>n&127))}case"latin1":case"binary":{const r=d.asView(Uint8Array,e);return String.fromCharCode(...r)}case"ucs2":case"ucs-2":case"utf16le":{const r=d.asView(Uint8Array,e);let n="";for(let o=0;o<r.length-1;o+=2)n+=String.fromCharCode(r[o]+r[o+1]*256);return n}default:throw new Error(`[ArrayBuffers.toString] Unknown encoding: ${t}`)}},f.toJSON=(e,t)=>JSON.parse(d.toString(e),t),f.alloc=(e,t,r)=>t!==void 0?typeof t=="number"?new Uint8Array(e).fill(t):d.asView(Uint8Array,d.from(t,r)).slice(0,e):new ArrayBuffer(e),f.from=(e,t="utf8")=>{if(!e)return new ArrayBuffer(0);if(typeof e=="string"){if(d.isNativeBufferAllowed())return Buffer.from(e,t);switch(t){case"utf-8":case"utf8":return new TextEncoder().encode(e).buffer;case"base64":return Ze(e.replace(/[^0-9a-zA-Z=+/_]/g,""));default:throw new Error(`[ArrayBuffers.from] Unknown encoding: ${t}`)}}if(e instanceof ArrayBuffer)return e;if(ArrayBuffer.isView(e)||O(e)){if(e.byteOffset!==0)throw new Error("ArrayBuffers.from do not support view with offset");return e.buffer}if(Array.isArray(e))return new Uint8Array(e);const r=B(e);throw new TypeError(`ArrayBuffers.from unsupported type ${r}`)},f.isEncoding=e=>{switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":return!0;default:return!1}},f.concat=(e,t,r=0)=>{const n=e.reduce((a,i)=>a+i.byteLength,0),o=t?new Uint8Array(t):new Uint8Array(n);for(const a of e){if(!(a!=null&&a.byteLength))continue;let i;if(a instanceof ArrayBuffer)i=new Uint8Array(a);else if(ArrayBuffer.isView(a))i=new Uint8Array(a.buffer,a.byteOffset,a.byteLength);else throw new Error(`ArrayBuffers.concat unsupported type ${B(a)}`);o.set(i,r),r+=a.byteLength}return o.buffer};const Ge=function(){const e="0123456789abcdef",t=new Array(256);for(let r=0;r<16;++r){const n=r*16;for(let o=0;o<16;++o)t[n+o]=e[r]+e[o]}return t}(),D=class extends Uint8Array{static get isPolyfill(){return!0}static isBuffer(e){return e instanceof D||O(e)}static from(e,t){return new D(f.from(e,t))}toString(e){return f.toString(this,e)}};let He=u("Buffer",D);He.isEncoding=f.isEncoding;let L;function Je(){let e;function t(){return navigator.userAgent.match(/ipad|iphone/i)}function r(a){e=document.createElement("textArea"),e.value=a,document.body.appendChild(e)}function n(){let a,i;if(t()){if(a=document.createRange(),a.selectNodeContents(e),i=window.getSelection(),i===null){console.error("no selection");return}i.removeAllRanges(),i.addRange(a),e.setSelectionRange(0,999999)}else e.select()}function o(){document.execCommand("copy"),document.body.removeChild(e)}L=a=>{r(a),n(),o()}}function Ke(e){var t,r;return(r=(t=window.navigator)==null?void 0:t.clipboard)!=null&&r.writeText?window.navigator.clipboard.writeText(e):(L||Je(),L(e))}function Ye(e,t,{type:r="application/octet-stream",raw:n=!1}={}){const o=document.createElement("a");let a=()=>null;try{if(o.download=e,typeof t=="string"&&/^(https?:|data:)/.test(t)&&!n?o.href=t:typeof t=="string"&&(t=new TextEncoder().encode(t)),t instanceof Uint8Array&&(t=new Blob([t],{type:r})),t instanceof File||t instanceof Blob||t instanceof MediaSource)o.href=URL.createObjectURL(t),a=()=>URL.revokeObjectURL(o.href);else throw console.error("invalid download data",t),new Error(`can not download ${Object.getPrototypeOf(t)}`);o.click()}finally{a()}}function ee(e,t,r,n){e.onload=()=>t(e),e.onerror=a=>{e.remove(),r(a)};const{attributes:o={}}=n||{};Object.entries(o).forEach(([a,i])=>e.setAttribute(a,i)),document.head.appendChild(e)}function te(e,t){if(Array.isArray(e))return Promise.resolve().then(async()=>{const n=[];for(const o of e)n.push(await te(o));return n});const r=document.querySelector(`script[src="${e}"]`);return r?Promise.resolve(r):new Promise((n,o)=>{const a=document.createElement("script");a.src=e,ee(a,n,o,t)})}function Qe(e,t){const r=document.querySelector(`link[href="${e}"]`);return r?Promise.resolve(r):new Promise((n,o)=>{const a=document.createElement("link");a.rel="stylesheet",a.href=e,ee(a,n,o,t)})}function Xe(e){var t;if(!e)return{};const r=e.items??[];if(r.length>=2&&r[0].kind==="string"&&r[1].kind==="file"){const n=e.getData("text"),o=r[1].getAsFile()??((t=e.files)==null?void 0:t.item(0));return o?{file:o,name:n}:(console.error(`no file ${n}`,r[1]),{})}else if(r[0].kind==="file"){const n=r[0].getAsFile();return n?{file:n,name:n.name}:(console.error("no file",r[0]),{})}else console.debug("file item not match",Array.from(r).map(n=>({type:n.type,kind:n.kind})));return{}}const mt=u("getGlobalThis",()=>{if(typeof globalThis<"u")return globalThis;if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global;throw new Error("Unable to locate global `this`")}),bt=u("structuredClone",globalThis.structuredClone||b);function re(e,t,r){typeof r.value=="object"&&(r.value=b(r.value)),!r.enumerable||r.get||r.set||!r.configurable||!r.writable||t==="__proto__"?Object.defineProperty(e,t,r):e[t]=r.value}function b(e){if(typeof e!="object")return e;let t=0,r,n,o;const a=B(e);switch(a){case"Array":o=Array(e.length);break;case"Object":o=Object.create(e.__proto__||null);break;case"Set":o=new Set,e.forEach(function(i){o.add(b(i))});break;case"Map":o=new Map,e.forEach(function(i,s){o.set(b(s),b(i))});break;case"Date":o=new Date(+e);break;case"RegExp":o=new RegExp(e.source,e.flags);break;case"DataView":o=new e.constructor(b(e.buffer));break;case"ArrayBuffer":o=e.slice(0);break;default:a.endsWith("Array")&&(o=new e.constructor(e))}if(o){for(n=Object.getOwnPropertySymbols(e);t<n.length;t++)re(o,n[t],Object.getOwnPropertyDescriptor(e,n[t]));for(t=0,n=Object.getOwnPropertyNames(e);t<n.length;t++)Object.hasOwnProperty.call(o,r=n[t])&&o[r]===e[r]||re(o,r,Object.getOwnPropertyDescriptor(e,r))}return o||e}var ne,oe;const wt=u("randomUUID",((oe=(ne=globalThis.crypto)==null?void 0:ne.randomUUID)==null?void 0:oe.bind(globalThis.crypto))||et);function et(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}var ae,ie,se,ce;let y;if(typeof window>"u")try{typeof require>"u"?ye.import("node:crypto").then(e=>y=e.default):y=require("node:crypto")}catch{}let le=u("getRandomValues",((ie=(ae=globalThis.crypto)==null?void 0:ae.getRandomValues)==null?void 0:ie.bind(globalThis.crypto))||((ce=(se=globalThis.msCrypto)==null?void 0:se.getRandomValues)==null?void 0:ce.bind(globalThis.msCrypto))||tt);function tt(e){var t,r,n;if((t=y==null?void 0:y.webcrypto)!=null&&t.getRandomValues)return u("getRandomValues",le=(n=(r=y==null?void 0:y.webcrypto)==null?void 0:r.getRandomValues)==null?void 0:n.bind(y==null?void 0:y.webcrypto)),y.webcrypto.getRandomValues(e);if(y!=null&&y.randomBytes){if(!(e instanceof Uint8Array))throw new TypeError("expected Uint8Array");if(e.length>65536){const a=new Error;throw a.code=22,a.message=`Failed to execute 'getRandomValues' on 'Crypto': The ArrayBufferView's byte length (${e.length}) exceeds the number of bytes of entropy available via this API (65536).`,a.name="QuotaExceededError",a}const o=y.randomBytes(e.length);return e.set(o),e}throw new Error("[getRandomValues]: No secure random number generator available.")}function rt(e){return T("SHA-1",e)}function nt(e){return T("SHA-256",e)}function ot(e){return T("SHA-384",e)}function at(e){return T("SHA-512",e)}function T(e,t){return crypto.subtle.digest(e,it(t))}function it(e){return typeof e=="string"?new TextEncoder().encode(e):e}function st(e){return Array.from(new Uint8Array(e)).map(t=>t.toString(16).padStart(2,"0")).join("")}function p(e){const t=new Error(e);return t.source="ulid",t}const h="0123456789ABCDEFGHJKMNPQRSTVWXYZ",g=h.length,_=Math.pow(2,48)-1,w=10,V=16;function ct(e){return(e==null?void 0:e.length)===26&&/^[0-9A-HJKMNP-TV-Z]{26}$/i.test(e)}function fe(e,t,r){return t>e.length-1?e:e.substr(0,t)+r+e.substr(t+1)}function lt(e){let t,r=e.length,n,o;const a=g-1;for(;!t&&r-->=0;){if(n=e[r],o=h.indexOf(n),o===-1)throw p("incorrectly encoded string");if(o===a){e=fe(e,r,h[0]);continue}t=fe(e,r,h[o+1])}if(typeof t=="string")return t;throw p("cannot increment this string")}function ft(e){let t=Math.floor(e()*g);return t===g&&(t=g-1),h.charAt(t)}function I(e,t){if(isNaN(e))throw new Error(`${e} must be a number`);if(e>_)throw p(`cannot encode time greater than ${_}`);if(e<0)throw p("time must be positive");if(!Number.isInteger(e))throw p("time must be an integer");let r,n="";for(;t>0;t--)r=e%g,n=h.charAt(r)+n,e=(e-r)/g;return n}function ue(e,t){let r="";for(;e>0;e--)r=ft(t)+r;return r}function ut(e){if(e.length!==w+V)throw p("malformed ulid");const t=e.substr(0,w).split("").reverse().reduce((r,n,o)=>{const a=h.indexOf(n);if(a===-1)throw p("invalid character found: "+n);return r+=a*Math.pow(g,o)},0);if(t>_)throw p("malformed ulid, timestamp too large");return{timestamp:t,random:e.substring(w)}}function dt(){return()=>{const e=new Uint8Array(1);return le(e),e[0]/255}}function de({monotonic:e=!0,random:t=dt(),now:r=Date.now}={}){if(!e)return function(a){return a||=r(),I(a,w)+ue(V,t)};let n=0,o;return function(a){if(a||=r(),a<=n&&o){const s=o=lt(o);return I(n,w)+s}n=a;const i=o=ue(V,t);return I(a,w)+i}}let yt=u("ulid",(...e)=>U?U(...e):(U=de(),u("ulid",yt=U),U(...e))),U;class pt{static decode(t){const r=t.match(/^-----BEGIN (?<type>[^\r\n-]+)-----$\r?\n(?<headers>(^[^:\r\n]+:[^\n\r]+\r?\n)+\r?\n)?(?<data>[a-zA-Z0-9/_=\n\r+]+?)^-----END \1-----$\r?\n?/ms);if(!(r!=null&&r.groups))throw new Error("Invalid PEM data");const{type:n,headers:o="",data:a}=r.groups,i=o.split(`
1
+ System.register([],function(u,de){"use strict";return{execute:function(){u({arrayFromAsync:me,arrayOfMaybeArray:ge,camelCase:G,classOf:v,clearAsyncInterval:ve,copy:Ke,createChildLogger:Ve,createLazyPromise:we,createLogger:P,createNoopLogger:Z,createRandom:gt,createTranslate:Fe,createULID:ye,deepEqual:A,download:Ye,firstOfMaybeArray:R,formatBytes:Ne,get:x,getFileFromDataTransfer:Xe,hex:ct,isBuffer:B,isClass:Ce,isDefined:Ue,isEmptyObject:$e,isModule:Le,isPlainObject:W,isPromise:N,isTransferable:ze,isULID:lt,isUUID:Pe,lastOfMaybeArray:he,loadScripts:te,loadStyles:Qe,maybeFunction:xe,memoize:Se,objectOfMaybeArray:pe,parseBoolean:Te,parseModuleId:De,parseObjectPath:T,parseTimestamp:Me,parseULID:yt,pascalCase:Re,renderTemplate:H,set:be,setAsyncInterval:Ae,sha1:nt,sha256:ot,sha384:at,sha512:it,shallowClone:Ee,shallowEqual:Oe,timeout:Be});function pe(e,t=null,r=R){return Object.fromEntries(t===null?Object.entries(e).map(([n,o])=>[n,r(o)]):t.map(n=>[n,r(n)]))}function R(e){return Array.isArray(e)?e[0]:e}function he(e){return Array.isArray(e)?e[e.length-1]:e}function ge(e){return Array.isArray(e)?e:e==null?[]:[e]}async function me(e){const t=[];for await(const r of e)t.push(r);return t}function T(e){if(typeof e!="string")return Array.isArray(e)?e:[e];const t=e.split(".");if(!e.includes("["))return t;const r=[];for(const n of t)if(!n.endsWith("]"))r.push(n);else{const o=n.split("[");for(let a of o)a.endsWith("]")&&(a=a.slice(0,-1)),r.push(a)}return r}function x(e,t,r){const n=T(t);let o=e;for(const a of n)o=o?o[a]:void 0;return o===void 0?r:o}function be(e,t,r,n=!0){const o=T(t);let a=0;const i=o.length;let s=e,c,l;for(;a<i&&(l=o[a++],!(l==="__proto__"||l==="constructor"||l==="prototype"));)s=s[l]=a===i?n?S(s[l],r):r:typeof(c=s[l])==typeof o?c:o[a]*0!==0||~(""+o[a]).indexOf(".")?{}:[]}function S(e,t){let r;if(typeof e=="object"&&typeof t=="object"){if(Array.isArray(e)&&Array.isArray(t))for(r=0;r<t.length;r++)e[r]=S(e[r],t[r]);else for(r in t){if(r==="__proto__"||r==="constructor"||r==="prototype")break;e[r]=S(e[r],t[r])}return e}return t}function N(e){return e&&(e instanceof Promise||e.then&&e.catch)}function we(e){const t={resolve(n){throw new Error("pending resolve")},reject(n){throw new Error("pending reject")}},r=Object.assign(new Promise((n,o)=>{t.reject=o,t.resolve=n}),{resolve(n){t.resolve(n)},reject(n){t.resolve(n)}});if(e){const n=t.resolve;let o=!0;t.resolve=s=>{o=!1,n(s)};const a=r.then.bind(r);r.then=(...s)=>{if(o){o=!1;try{const c=e(t.resolve,t.reject);N(c)?c.then(t.resolve,t.reject):c!==void 0&&t.resolve(c)}catch(c){t.reject(c)}}return a(...s)};const i=t;return i.then=r.then,i.catch=r.catch.bind(r),r.finally&&(i.finally=r.finally),Object.defineProperty(i,Symbol.species,{get(){return Promise}}),i}return r}function Ae(e,t,r=t){let n;const o=async()=>{await e(),n=setTimeout(o,t)};return n=setTimeout(o,r),()=>n}function ve(e){clearTimeout(e==null?void 0:e())}const mt=u("sleep",e=>new Promise(t=>setTimeout(t,e)));function Be(e,t){const r=new F;let n;return Promise.race([e,new Promise((o,a)=>{n=setTimeout(()=>a(r),t)})]).then(o=>(clearTimeout(n),o),o=>{throw clearTimeout(n),o})}class F extends Error{constructor(){super("TimeoutError")}}u("TimeoutError",F);function Oe(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;const r=Object.keys(e);if(r.length!==Object.keys(t).length)return!1;for(let n=0;n<r.length;n++)if(!Object.prototype.hasOwnProperty.call(t,r[n])||!Object.is(e[r[n]],t[r[n]]))return!1;return!0}const z=Object.prototype.hasOwnProperty,je=typeof Element<"u";function q(e,t,r){for(r of e.keys())if(A(r,t))return r}function A(e,t){let r,n,o;if(e===t)return!0;if(e&&t&&(r=e.constructor)===t.constructor){if(r===Date)return e.getTime()===t.getTime();if(r===RegExp)return e.toString()===t.toString();if(r===Array){if((n=e.length)===t.length)for(;n--&&A(e[n],t[n]););return n===-1}if(r===Set){if(e.size!==t.size)return!1;for(n of e)if(o=n,o&&typeof o=="object"&&(o=q(t,o),!o)||!t.has(o))return!1;return!0}if(r===Map){if(e.size!==t.size)return!1;for(n of e)if(o=n[0],o&&typeof o=="object"&&(o=q(t,o),!o)||!A(n[1],t.get(o)))return!1;return!0}if(r===ArrayBuffer)e=new Uint8Array(e),t=new Uint8Array(t);else if(r===DataView){if((n=e.byteLength)===t.byteLength)for(;n--&&e.getInt8(n)===t.getInt8(n););return n===-1}if(ArrayBuffer.isView(e)){if((n=e.byteLength)===t.byteLength)for(;n--&&e[n]===t[n];);return n===-1}if(je&&e instanceof Element)return!1;if(!r||typeof e=="object"){n=0;for(r in e)if(!((r==="_owner"||r==="__v"||r==="__o")&&e.$$typeof)&&(z.call(e,r)&&++n&&!z.call(t,r)||!(r in t)||!A(e[r],t[r])))return!1;return Object.keys(t).length===n}}return e!==e&&t!==t}function v(e){return Object.prototype.toString.call(e).slice(8,-1)}function Ee(e){return e&&(Array.isArray(e)?e.slice():typeof e=="object"?Object.assign({},e):e)}function Ce(e){return typeof e=="function"&&/^class\s/.test(Function.prototype.toString.call(e))}function Ue(e){return e!=null}function W(e){return v(e)!=="Object"?!1:e.constructor===Object&&Object.getPrototypeOf(e)===Object.prototype}function $e(e){return W(e)&&Object.keys(e).length===0}function Te(e,t=!1){if(typeof e=="boolean")return e;if(typeof e=="string")switch(e.toLowerCase()){case"f":case"false":case"0":return!1;case"1":case"t":case"true":return!0}else if(typeof e=="number")switch(e){case 0:return!1;case 1:return!0}if(!t)return Boolean(e)}function xe(e,...t){return e instanceof Function?e(...t):e}function Se(e,{resolver:t=(...r)=>JSON.stringify(r)}={}){if(typeof e!="function")throw new Error("`callback` should be a function");if(t!==void 0&&typeof t!="function")throw new Error("`resolver` should be a function");const r={},n=function(){const o=Array.prototype.slice.call(arguments),a=t.apply(this,o);return a in r||(r[a]=e.apply(this,o)),r[a]};return n.cache=r,n}function Pe(e){return/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(e)}function Me(e){if(e){if(e instanceof Date)return e;if(typeof e=="string"&&/^[0-9.]+$/.test(e)){let t=parseFloat(e);return Math.floor(t).toString().length<=11&&(t*=1e3),new Date(t)}else if(typeof e=="string"){const t=new Date(e);if(!isNaN(+t))return t}throw new Error(`parseTimestamp: invalid "${e}"`)}}const ke=/^(?<n>(?:@(?<org>[a-z0-9-~][a-z0-9-._~]*)\/)?(?<pkg>[a-z0-9-~][a-z0-9-._~]*))(?:@(?<v>[-a-z0-9><=_.^~]+))?(?<p>\/[^\r\n]*)?$/;function De(e){var t;const r=(t=e.match(ke))==null?void 0:t.groups;if(!r)return;const{n,v:o,p:a,org:i,pkg:s}=r,c=Boolean(i),l=/^\d+\.\d+\.\d+/.test(o)?o:void 0,w=o||"latest",C={id:`${n}@${w}`,name:n,range:w,scoped:c,pkg:s,org:i,versioned:Boolean(o)};return l&&(C.version=l),a&&(C.path=a),C.scoped||delete C.org,C}function Le(e){return e&&e[Symbol.toStringTag]==="Module"}function P(e=({level:r,values:n,...o})=>{var a;({values:n,...o}=_e(o,n)),(a=console[r])==null||a.call(console,...n,o)},t={}){return{trace:(...r)=>e({...t,level:"trace",values:r}),debug:(...r)=>e({...t,level:"debug",values:r}),info:(...r)=>e({...t,level:"info",values:r}),warn:(...r)=>e({...t,level:"warn",values:r}),error:(...r)=>e({...t,level:"error",values:r}),child:r=>P(e,{...t,...r})}}function _e(e,t){return t[0]&&typeof t[0]=="object"?{...e,...t[0],values:t.slice(1)}:{...e,values:t}}function Z(){const e=(...t)=>{};return{trace:e,debug:e,info:e,warn:e,error:e,child:()=>Z()}}function Ve(e,t){return e.child?e.child(t):P(r=>{const{level:n,values:o,...a}=r;Object.keys(a).length?e[n](a,...o):e[n](...o)},t)}function Ie(e){let t=!1,r=!1,n=!1;for(let o=0;o<e.length;o++){const a=e[o];t&&/[a-zA-Z]/.test(a)&&a.toUpperCase()===a?(e=e.slice(0,o)+"-"+e.slice(o),t=!1,n=r,r=!0,o++):r&&n&&/[a-zA-Z]/.test(a)&&a.toLowerCase()===a?(e=e.slice(0,o-1)+"-"+e.slice(o-1),n=r,r=!1,t=!0):(t=a.toLowerCase()===a&&a.toUpperCase()!==a,n=r,r=a.toUpperCase()===a&&a.toLowerCase()!==a)}return e}function Re(e){return G(e,{pascalCase:!0})}function G(e,t={pascalCase:!1}){if(!(typeof e=="string"||Array.isArray(e)))throw new TypeError("Expected the input to be `string | string[]`");const r=n=>t.pascalCase?n.charAt(0).toUpperCase()+n.slice(1):n;return Array.isArray(e)?e=e.map(n=>n.trim()).filter(n=>n.length).join("-"):e=e.trim(),e.length===0?"":e.length===1?t.pascalCase?e.toUpperCase():e.toLowerCase():(e!==e.toLowerCase()&&(e=Ie(e)),e=e.replace(/^[_.\- ]+/,"").toLowerCase().replace(/[_.\- ]+(\w|$)/g,(n,o)=>o.toUpperCase()).replace(/\d+(\w|$)/g,n=>n.toUpperCase()),r(e))}function H(e,t,r="js"){let n;return t?typeof t=="function"?n=t:n=o=>x(t,o):n=()=>"",typeof r=="string"&&(r=J[r]||J.js),e.replace(r,(o,a)=>n(a.trim()))}const J={js:/\${(.*?)}/g,common:/{{(.*?)}}/g};function Ne(e,t=!1,r=1){const n=t?1e3:1024;if(Math.abs(e)<n)return`${e} B`;const o=t?["kB","MB","GB","TB","PB","EB","ZB","YB"]:["KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"];let a=-1;const i=10**r;do e/=n,++a;while(Math.round(Math.abs(e)*i)/i>=n&&a<o.length-1);return e.toFixed(r)+" "+o[a]}function Fe(e){let t="";const r=e||{},n=o=>{if(Array.isArray(o))return o;const a=o.split(/[_-]/);return a.length>1?[o,a[0]]:[o]};return{locale(o){return t=o||t},dict:(o,a)=>{if(a){r[o]=Object.assign(r[o]||{},a);return}return r[o]},t(o,a,i){let s;for(const c of n(i||t))if(s=x(r[c],o,""),s)break;return typeof s=="function"?s(a):typeof s=="string"?H(s,a,"common"):s}}}function B(e){var t,r;return(r=(t=e==null?void 0:e.constructor)==null?void 0:t.isBuffer)==null?void 0:r.call(t,e)}function ze(e){return K||=qe(),K.some(t=>e instanceof t)}let K;function qe(){const e=globalThis.window||globalThis||global;return[e.ArrayBuffer,e.MessagePort,e.ReadableStream,e.WritableStream,e.TransformStream,e.AudioData,e.ImageBitmap,e.VideoFrame,e.OffscreenCanvas,e.RTCDataChannel].filter(Boolean)}const g="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",O=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let e=0;e<g.length;e++)O[g.charCodeAt(e)]=e;function We(e){const t=new Uint8Array(e),r=t.length;let n="";for(let o=0;o<r;o+=3)n+=g[t[o]>>2],n+=g[(t[o]&3)<<4|t[o+1]>>4],n+=g[(t[o+1]&15)<<2|t[o+2]>>6],n+=g[t[o+2]&63];return r%3===2?n=n.substring(0,n.length-1)+"=":r%3===1&&(n=n.substring(0,n.length-2)+"=="),n}function Ze(e){const t=e.length;let r=e.length*.75,n,o=0,a,i,s,c;e[e.length-1]==="="&&(r--,e[e.length-2]==="="&&r--);const l=new ArrayBuffer(r),w=new Uint8Array(l);for(n=0;n<t;n+=4)a=O[e.charCodeAt(n)],i=O[e.charCodeAt(n+1)],s=O[e.charCodeAt(n+2)],c=O[e.charCodeAt(n+3)],w[o++]=a<<2|i>>4,w[o++]=(i&15)<<4|s>>2,w[o++]=(s&3)<<6|c&63;return l}var Y=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},M=(e,t,r)=>(Y(e,t,"read from private field"),r?r.call(e):t.get(e)),Q=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},X=(e,t,r,n)=>(Y(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r),U,j;const y=class{static isNativeBufferAvailable(){var t,r;return M(this,j)??X(this,j,!((r=(t=globalThis.Buffer)==null?void 0:t.isPollyfill)!=null&&r.call(t)))}static isNativeBufferAllowed(){return M(this,U)&&M(this,j)}static setNativeBufferAllowed(t){X(this,U,t)}};let f=u("ArrayBuffers",y);U=new WeakMap,j=new WeakMap,Q(f,U,!0),Q(f,j,void 0),f.isArrayBuffer=e=>e instanceof ArrayBuffer,f.slice=(e,t,r)=>B(e)?Uint8Array.prototype.slice.call(e,t,r):e.slice(t,r),f.asView=(e,t,r,n)=>t instanceof e&&(r??0)===0&&n===void 0?t:ArrayBuffer.isView(t)||B(t)?y.isNativeBufferAllowed()&&e===Buffer?Buffer.from(t.buffer,r,n):new e(t.buffer,t.byteOffset+(r??0),n??t.byteLength):new e(t,r,n),f.toString=(e,t="utf8")=>{if(typeof e=="string")switch(t){case"base64":return btoa(e);case"utf-8":case"utf8":return e;default:throw new Error(`[ArrayBuffers.toString] Unsupported encoding for string: ${t}`)}if(y.isNativeBufferAllowed())return Buffer.from(y.asView(Uint8Array,e)).toString(t);switch(t){case"hex":return[...y.asView(Uint8Array,e)].map(r=>Ge[r]).join("");case"base64":return We(y.asView(Uint8Array,e));case"utf8":case"utf-8":return new TextDecoder().decode(e);case"ascii":{const r=y.asView(Uint8Array,e);return String.fromCharCode(...r.map(n=>n&127))}case"latin1":case"binary":{const r=y.asView(Uint8Array,e);return String.fromCharCode(...r)}case"ucs2":case"ucs-2":case"utf16le":{const r=y.asView(Uint8Array,e);let n="";for(let o=0;o<r.length-1;o+=2)n+=String.fromCharCode(r[o]+r[o+1]*256);return n}default:throw new Error(`[ArrayBuffers.toString] Unknown encoding: ${t}`)}},f.toJSON=(e,t)=>JSON.parse(y.toString(e),t),f.alloc=(e,t,r)=>t!==void 0?typeof t=="number"?new Uint8Array(e).fill(t):y.asView(Uint8Array,y.from(t,r)).slice(0,e):new ArrayBuffer(e),f.from=(e,t="utf8")=>{if(!e)return new ArrayBuffer(0);if(typeof e=="string"){if(y.isNativeBufferAllowed())return Buffer.from(e,t);switch(t){case"utf-8":case"utf8":return new TextEncoder().encode(e).buffer;case"base64":return Ze(e.replace(/[^0-9a-zA-Z=+/_]/g,""));default:throw new Error(`[ArrayBuffers.from] Unknown encoding: ${t}`)}}if(e instanceof ArrayBuffer)return e;if(ArrayBuffer.isView(e)||B(e)){if(e.byteOffset!==0)throw new Error("ArrayBuffers.from do not support view with offset");return e.buffer}if(Array.isArray(e))return new Uint8Array(e);const r=v(e);throw new TypeError(`ArrayBuffers.from unsupported type ${r}`)},f.isEncoding=e=>{switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":return!0;default:return!1}},f.concat=(e,t,r=0)=>{const n=e.reduce((a,i)=>a+i.byteLength,0),o=t?new Uint8Array(t):new Uint8Array(n);for(const a of e){if(!(a!=null&&a.byteLength))continue;let i;if(a instanceof ArrayBuffer)i=new Uint8Array(a);else if(ArrayBuffer.isView(a))i=new Uint8Array(a.buffer,a.byteOffset,a.byteLength);else throw new Error(`ArrayBuffers.concat unsupported type ${v(a)}`);o.set(i,r),r+=a.byteLength}return o.buffer};const Ge=function(){const e="0123456789abcdef",t=new Array(256);for(let r=0;r<16;++r){const n=r*16;for(let o=0;o<16;++o)t[n+o]=e[r]+e[o]}return t}(),k=class extends Uint8Array{static get isPolyfill(){return!0}static isBuffer(e){return e instanceof k||B(e)}static from(e,t){return new k(f.from(e,t))}toString(e){return f.toString(this,e)}};let He=u("Buffer",k);He.isEncoding=f.isEncoding;let D;function Je(){let e;function t(){return navigator.userAgent.match(/ipad|iphone/i)}function r(a){e=document.createElement("textArea"),e.value=a,document.body.appendChild(e)}function n(){let a,i;if(t()){if(a=document.createRange(),a.selectNodeContents(e),i=window.getSelection(),i===null){console.error("no selection");return}i.removeAllRanges(),i.addRange(a),e.setSelectionRange(0,999999)}else e.select()}function o(){document.execCommand("copy"),document.body.removeChild(e)}D=a=>{r(a),n(),o()}}function Ke(e){var t,r;return(r=(t=window.navigator)==null?void 0:t.clipboard)!=null&&r.writeText?window.navigator.clipboard.writeText(e):(D||Je(),D(e))}function Ye(e,t,{type:r="application/octet-stream",raw:n=!1}={}){const o=document.createElement("a");let a=()=>null;try{if(o.download=e,typeof t=="string"&&/^(https?:|data:)/.test(t)&&!n?o.href=t:typeof t=="string"&&(t=new TextEncoder().encode(t)),t instanceof Uint8Array&&(t=new Blob([t],{type:r})),t instanceof File||t instanceof Blob||t instanceof MediaSource)o.href=URL.createObjectURL(t),a=()=>URL.revokeObjectURL(o.href);else throw console.error("invalid download data",t),new Error(`can not download ${Object.getPrototypeOf(t)}`);o.click()}finally{a()}}function ee(e,t,r,n){e.onload=()=>t(e),e.onerror=a=>{e.remove(),r(a)};const{attributes:o={}}=n||{};Object.entries(o).forEach(([a,i])=>e.setAttribute(a,i)),document.head.appendChild(e)}function te(e,t){if(Array.isArray(e))return Promise.resolve().then(async()=>{const n=[];for(const o of e)n.push(await te(o));return n});const r=document.querySelector(`script[src="${e}"]`);return r?Promise.resolve(r):new Promise((n,o)=>{const a=document.createElement("script");a.src=e,ee(a,n,o,t)})}function Qe(e,t){const r=document.querySelector(`link[href="${e}"]`);return r?Promise.resolve(r):new Promise((n,o)=>{const a=document.createElement("link");a.rel="stylesheet",a.href=e,ee(a,n,o,t)})}function Xe(e){var t;if(!e)return{};const r=e.items??[];if(r.length>=2&&r[0].kind==="string"&&r[1].kind==="file"){const n=e.getData("text"),o=r[1].getAsFile()??((t=e.files)==null?void 0:t.item(0));return o?{file:o,name:n}:(console.error(`no file ${n}`,r[1]),{})}else if(r[0].kind==="file"){const n=r[0].getAsFile();return n?{file:n,name:n.name}:(console.error("no file",r[0]),{})}else console.debug("file item not match",Array.from(r).map(n=>({type:n.type,kind:n.kind})));return{}}const bt=u("getGlobalThis",()=>{if(typeof globalThis<"u")return globalThis;if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global;throw new Error("Unable to locate global `this`")}),wt=u("structuredClone",globalThis.structuredClone||m);function re(e,t,r){typeof r.value=="object"&&(r.value=m(r.value)),!r.enumerable||r.get||r.set||!r.configurable||!r.writable||t==="__proto__"?Object.defineProperty(e,t,r):e[t]=r.value}function m(e){if(typeof e!="object")return e;let t=0,r,n,o;const a=v(e);switch(a){case"Array":o=Array(e.length);break;case"Object":o=Object.create(e.__proto__||null);break;case"Set":o=new Set,e.forEach(function(i){o.add(m(i))});break;case"Map":o=new Map,e.forEach(function(i,s){o.set(m(s),m(i))});break;case"Date":o=new Date(+e);break;case"RegExp":o=new RegExp(e.source,e.flags);break;case"DataView":o=new e.constructor(m(e.buffer));break;case"ArrayBuffer":o=e.slice(0);break;default:a.endsWith("Array")&&(o=new e.constructor(e))}if(o){for(n=Object.getOwnPropertySymbols(e);t<n.length;t++)re(o,n[t],Object.getOwnPropertyDescriptor(e,n[t]));for(t=0,n=Object.getOwnPropertyNames(e);t<n.length;t++)Object.hasOwnProperty.call(o,r=n[t])&&o[r]===e[r]||re(o,r,Object.getOwnPropertyDescriptor(e,r))}return o||e}var ne,oe;const At=u("randomUUID",((oe=(ne=globalThis.crypto)==null?void 0:ne.randomUUID)==null?void 0:oe.bind(globalThis.crypto))||et);function et(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}let L;if(typeof window>"u")try{typeof require>"u"?de.import("crypto").then(e=>L=e.default):L=require("crypto")}catch{}function tt(){return L}var ae,ie,se,ce;let le=u("getRandomValues",((ie=(ae=globalThis.crypto)==null?void 0:ae.getRandomValues)==null?void 0:ie.bind(globalThis.crypto))||((ce=(se=globalThis.msCrypto)==null?void 0:se.getRandomValues)==null?void 0:ce.bind(globalThis.msCrypto))||rt);function rt(e){var t,r,n;const o=tt();if((t=o==null?void 0:o.webcrypto)!=null&&t.getRandomValues)return u("getRandomValues",le=(n=(r=o==null?void 0:o.webcrypto)==null?void 0:r.getRandomValues)==null?void 0:n.bind(o==null?void 0:o.webcrypto)),o.webcrypto.getRandomValues(e);if(o!=null&&o.randomBytes){if(!(e instanceof Uint8Array))throw new TypeError("expected Uint8Array");if(e.length>65536){const i=new Error;throw i.code=22,i.message=`Failed to execute 'getRandomValues' on 'Crypto': The ArrayBufferView's byte length (${e.length}) exceeds the number of bytes of entropy available via this API (65536).`,i.name="QuotaExceededError",i}const a=o.randomBytes(e.length);return e.set(a),e}throw new Error("[getRandomValues]: No secure random number generator available.")}function nt(e){return $("SHA-1",e)}function ot(e){return $("SHA-256",e)}function at(e){return $("SHA-384",e)}function it(e){return $("SHA-512",e)}function $(e,t){return crypto.subtle.digest(e,st(t))}function st(e){return typeof e=="string"?new TextEncoder().encode(e):e}function ct(e){return Array.from(new Uint8Array(e)).map(t=>t.toString(16).padStart(2,"0")).join("")}function d(e){const t=new Error(e);return t.source="ulid",t}const p="0123456789ABCDEFGHJKMNPQRSTVWXYZ",h=p.length,_=Math.pow(2,48)-1,b=10,V=16;function lt(e){return(e==null?void 0:e.length)===26&&/^[0-9A-HJKMNP-TV-Z]{26}$/i.test(e)}function fe(e,t,r){return t>e.length-1?e:e.substr(0,t)+r+e.substr(t+1)}function ft(e){let t,r=e.length,n,o;const a=h-1;for(;!t&&r-->=0;){if(n=e[r],o=p.indexOf(n),o===-1)throw d("incorrectly encoded string");if(o===a){e=fe(e,r,p[0]);continue}t=fe(e,r,p[o+1])}if(typeof t=="string")return t;throw d("cannot increment this string")}function ut(e){let t=Math.floor(e()*h);return t===h&&(t=h-1),p.charAt(t)}function I(e,t){if(isNaN(e))throw new Error(`${e} must be a number`);if(e>_)throw d(`cannot encode time greater than ${_}`);if(e<0)throw d("time must be positive");if(!Number.isInteger(e))throw d("time must be an integer");let r,n="";for(;t>0;t--)r=e%h,n=p.charAt(r)+n,e=(e-r)/h;return n}function ue(e,t){let r="";for(;e>0;e--)r=ut(t)+r;return r}function yt(e){if(e.length!==b+V)throw d("malformed ulid");const t=e.substr(0,b).split("").reverse().reduce((r,n,o)=>{const a=p.indexOf(n);if(a===-1)throw d("invalid character found: "+n);return r+=a*Math.pow(h,o)},0);if(t>_)throw d("malformed ulid, timestamp too large");return{timestamp:t,random:e.substring(b)}}function dt(){return()=>{const e=new Uint8Array(1);return le(e),e[0]/255}}function ye({monotonic:e=!0,random:t=dt(),now:r=Date.now}={}){if(!e)return function(a){return a||=r(),I(a,b)+ue(V,t)};let n=0,o;return function(a){if(a||=r(),a<=n&&o){const s=o=ft(o);return I(n,b)+s}n=a;const i=o=ue(V,t);return I(a,b)+i}}let pt=u("ulid",(...e)=>E?E(...e):(E=ye(),u("ulid",pt=E),E(...e))),E;class ht{static decode(t){const r=t.match(/^-----BEGIN (?<type>[^\r\n-]+)-----$\r?\n(?<headers>(^[^:\r\n]+:[^\n\r]+\r?\n)+\r?\n)?(?<data>[a-zA-Z0-9/_=\n\r+]+?)^-----END \1-----$\r?\n?/ms);if(!(r!=null&&r.groups))throw new Error("Invalid PEM data");const{type:n,headers:o="",data:a}=r.groups,i=o.split(`
2
2
  `).filter(s=>s.trim()).map(s=>{const[c,...l]=s.split(":");return[c.trim(),l.join(":").trim()]}).reduce((s,[c,l])=>({...s,[c]:l}),{});return{block:{type:n,header:i,bytes:f.from(a.replace(/[\r\n]/g,""),"base64")},head:t.slice(0,r.index||0),tail:t.slice((r.index||0)+r[0].length)}}static encode(t){var r;const{type:n,header:o,bytes:a}=t,i=Object.entries(o||{}).map(([s,c])=>`${s}: ${c}`).join(`
3
3
  `);return`-----BEGIN ${n}-----
4
4
  ${i}${i.length?`
@@ -6,5 +6,5 @@ ${i}${i.length?`
6
6
  `:""}${((r=f.toString(a,"base64").match(/.{1,64}/g))==null?void 0:r.join(`
7
7
  `))||""}
8
8
  -----END ${n}-----
9
- `}}u("PEM",pt);function ht(e={}){let t=typeof e.seed=="string"?0:e.seed??0;if(typeof e.seed=="string"){let r=0;for(let n=0;n<e.seed.length;n++)r+=e.seed.charCodeAt(n);t=r}return()=>{const r=Math.sin(t++)*1e4;return r-Math.floor(r)}}}}});
9
+ `}}u("PEM",ht);function gt(e={}){let t=typeof e.seed=="string"?0:e.seed??0;if(typeof e.seed=="string"){let r=0;for(let n=0;n<e.seed.length;n++)r+=e.seed.charCodeAt(n);t=r}return()=>{const r=Math.sin(t++)*1e4;return r-Math.floor(r)}}}}});
10
10
  //# sourceMappingURL=index.js.map