ranuts 0.4.0-alpha.4 → 0.4.0-alpha.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +1 -0
- package/README.md +5 -1
- package/README.zh-CN.md +17 -1
- package/dist/index.js +1 -1
- package/dist/src/utils/binary.d.ts +107 -0
- package/dist/src/utils/index.d.ts +2 -1
- package/dist/src/utils/index.js +1 -1
- package/dist/test/binary.test.d.ts +1 -0
- package/dist/umd/index.umd.cjs +1 -1
- package/dist/umd/utils/utils.umd.cjs +1 -1
- package/dist/{utils-CYrYCt5o.js → utils-BSvtPyGl.js} +1 -1
- package/docs/API.md +11 -2
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e,t}from"./enums-BAgbyGdH.js";import{Q as n,at as r,et as i,it as a,tt as s}from"./color-DPV7TsVU.js";import{A as o,O as c,_ as u,x as d}from"./i18n-Bq-f7htr.js";var l=(e="")=>{if(0===e.length)return 0;if(e.endsWith("%")){const t=Number(e.replace("%",""));return t>1?t/100:t}return Number(e)},h=(e,t=0,n=1)=>Math.min(n,Math.max(t,e)),p=class e{getDecimalLength=e=>{const[t,n]=e.toString().split(".");return n?n.length:0};amend=(e,t=15)=>parseFloat(Number(e).toPrecision(t));power=(e,t)=>Math.pow(10,Math.max(this.getDecimalLength(e),this.getDecimalLength(t)));static handleMethod=(t,n)=>{const{power:r,amend:i}=new e,a=r(t,n),s=i(t*a),o=i(n*a);return e=>{switch(e){case"+":return(s+o)/a;case"-":return(s-o)/a;case"*":return s*o/(a*a);case"/":return s/o}}};static add=(e,t)=>this.handleMethod(e,t)("+");static divide=(e,t)=>this.handleMethod(e,t)("/");static multiply=(e,t)=>this.handleMethod(e,t)("*");static subtract=(e,t)=>this.handleMethod(e,t)("-")};function f(e,t,n){function r(e){const[t,n]=e.toString().split(".");return n?n.length:0}const i=(e,t=15)=>parseFloat(Number(e).toPrecision(t)),a=Math.pow(10,Math.max(r(e),r(n)));let s=0;switch(e=i(e*a),n=i(n*a),t){case"+":s=(e+n)/a;break;case"-":s=(e-n)/a;break;case"*":s=e*n/(a*a);break;case"/":s=e/n}return s=i(s),{result:s,next:(e,t)=>f(s,e,t)}}var m=(e,t="zh-CN",n=2,r=2)=>{let i=["","K","M","B","T"],a=3;if("zh-CN"===t&&(i=[""," 万"," 亿"," 万亿"],a=4),"zh-HK"===t&&(i=[""," 萬"," 億"," 萬億"],a=4),!/^[+-]?\d+(?:\.\d+)?$/.test(e))return"--";const s=parseInt(e).toString().length,o=Math.min(Math.floor((s-1)/a),i.length-1),c=p.divide(Number(e),10**(o*a))?.toFixed(n);return Number(c).toFixed(r)+i[o]},g=(e,t)=>r(e).startsWith("+")||r(e).startsWith("-")?r(e):t?Number(t||0)>0?`+${r(e)}`:r(e):Number(e||0)>0?`+${r(e)}`:r(e),y={"零":0,"〇":0,"一":1,"二":2,"两":2,"三":3,"四":4,"五":5,"六":6,"七":7,"八":8,"九":9},w={"十":10,"百":100,"千":1e3},b=e=>{const t=a(e.trim());if(/^\d+$/.test(t))return Number.parseInt(t,10);if(0===t.length)return null;let n=0,r=0,i=0;for(const a of t)if(void 0!==y[a])i=y[a];else if(void 0!==w[a])r+=(i||("十"===a?1:0))*w[a],i=0;else{if("万"!==a&&"萬"!==a)return null;n=1e4*(n+r+i),r=0,i=0}return n+r+i},S={I:1,V:5,X:10,L:50,C:100,D:500,M:1e3},C=e=>{const t=e.trim().toUpperCase();if(!/^[IVXLCDM]+$/.test(t))return null;let n=0;for(let r=0;r<t.length;r++){const e=S[t[r]],i=S[t[r+1]];i&&e<i?n-=e:n+=e}return n},v={one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12,thirteen:13,fourteen:14,fifteen:15,sixteen:16,seventeen:17,eighteen:18,nineteen:19,twenty:20},U=e=>{const t=e.trim().toLowerCase();return/^\d+$/.test(t)?Number.parseInt(t,10):void 0!==v[t]?v[t]:C(t)},E=(e,t,n)=>Math.min(n,Math.max(t,e)),O=(e,t,n)=>e+(t-e)*n,A=(e,t,n)=>e===t?0:(n-e)/(t-e),M=(e,t,n,r,i)=>r+(e-t)*(i-r)/(n-t),k=(e,t,n,r,i)=>E(M(e,t,n,r,i),Math.min(r,i),Math.max(r,i)),T=(e,t,n)=>e===t?n<e?0:1:E((n-e)/(t-e),0,1),B=(e,t,n)=>{const r=T(e,t,n);return r*r*(3-2*r)},L=()=>{if("undefined"==typeof window)return;const e=window;return e.SpeechRecognition??e.webkitSpeechRecognition},F=()=>void 0!==L(),P=(e={})=>{const{lang:t,continuous:n=!0,interimResults:r=!0,onResult:i,onError:a,onStart:s,onEnd:o}=e;let c=null;const u=()=>{c=null,o?.()},d={get supported(){return void 0!==L()},get active(){return null!==c},start(){const e=L();if(e&&!c)try{const o=new e;o.lang="function"==typeof t?t():t??"",o.continuous=n,o.interimResults=r,o.maxAlternatives=1;let d="",l=0;o.onresult=e=>{const t=e.results,n=Math.min(e.resultIndex??0,t.length);for(n<l&&(l=0,d="");l<n;l++)d+=t[l]?.[0]?.transcript??"";let r="",a=!0;for(let i=l;i<t.length;i++){const e=t[i];r+=e?.[0]?.transcript??"",!1===e?.isFinal&&(a=!1)}i?.(d+r,a)},o.onerror=e=>{return a?.({kind:(t=e.error,"not-allowed"===t||"service-not-allowed"===t?"denied":"no-speech"===t?"noSpeech":"aborted"===t?"aborted":"failed"),detail:e.error});var t},o.onstart=()=>s?.(),o.onend=u,c=o,o.start()}catch(d){c=null,a?.({kind:"failed",detail:d instanceof Error?d.message:String(d)}),o?.()}},stop(){c?.stop()},abort(){c?.abort()},toggle(){c?d.stop():d.start()}};return d},R=e=>"function"==typeof e,H=12e4,D="__ranuts_bridge__",I="default",x=new class{bridges=/* @__PURE__ */new Set;attachedWindow=null;handleMessage=e=>{for(const t of Array.from(this.bridges))t.receive(e)};add(e){this.bridges.add(e),"undefined"!=typeof window&&this.attachedWindow!==window&&(window.addEventListener("message",this.handleMessage),this.attachedWindow=window)}remove(e){this.bridges.delete(e),0===this.bridges.size&&this.attachedWindow&&(this.attachedWindow.removeEventListener("message",this.handleMessage),this.attachedWindow=null)}},j=class{targetWindow;targetOrigin;messageHandlers;pendingRequests;channel;senderId;available;constructor(e,t="*",r=I){this.targetOrigin=t,this.channel=r,this.senderId=n(12),this.messageHandlers=/* @__PURE__ */new Map,this.pendingRequests=/* @__PURE__ */new Map,this.available="undefined"!=typeof window,this.available?(this.targetWindow=e??window,x.add(this)):this.targetWindow=void 0}post(e,t){const n={...t,__bridge:D,channel:this.channel,senderId:this.senderId};e.postMessage(n,this.targetOrigin)}receive=e=>{if(!this.available)return;if("*"!==this.targetOrigin&&e.origin!==this.targetOrigin)return;if(e.source&&e.source!==this.targetWindow)return;const t=e.data;if(!t||"object"!=typeof t||"__ranuts_bridge__"!==t.__bridge)return;if((t.channel??"default")!==this.channel)return;const{type:n,payload:r,id:i,isResponse:a,isError:s,senderId:o}=t;if(a&&i){const e=this.pendingRequests.get(i);return void(e&&(s?e.reject(new Error("string"==typeof r?r:"Bridge request failed")):e.resolve(r),this.pendingRequests.delete(i)))}if(o&&o===this.senderId)return;if("string"!=typeof n||!this.messageHandlers.has(n))return;const c=this.messageHandlers.get(n);if(R(c)){const t=e.source??this.targetWindow;Promise.resolve(c(r)).then(e=>{i&&this.post(t,{type:n,payload:e,id:i,isResponse:!0})}).catch(e=>{i&&this.post(t,{type:n,payload:e instanceof Error?e.message:String(e),id:i,isResponse:!0,isError:!0})})}};on=(e,t)=>{this.messageHandlers.set(e,t)};off=e=>{this.messageHandlers.delete(e)};send=async(e,t)=>{if(!this.available)return Promise.reject(/* @__PURE__ */new Error("PostMessageBridge is unavailable outside a browser environment"));const r=n(10);return new Promise((n,i)=>{const a=setTimeout(()=>{this.pendingRequests.has(r)&&(this.pendingRequests.delete(r),i(/* @__PURE__ */new Error("Request timeout")))},H),s=e=>{clearTimeout(a),i(e)};this.pendingRequests.set(r,{resolve:e=>{clearTimeout(a),n(e)},reject:s});try{this.post(this.targetWindow,{type:e,payload:t,id:r})}catch(o){this.pendingRequests.delete(r),s(o instanceof Error?o:/* @__PURE__ */new Error("Failed to post message"))}})};broadcast=e=>{if(this.available)try{this.post(this.targetWindow,{type:e.type,payload:e.payload})}catch{}};destroy=()=>{x.remove(this),this.messageHandlers.clear(),this.pendingRequests.forEach(e=>{e.reject(/* @__PURE__ */new Error("Bridge destroyed"))}),this.pendingRequests.clear()}},N=class e{static instance;bridges=/* @__PURE__ */new Map;constructor(){}static getInstance(){return e.instance||(e.instance=new e),e.instance}connectClient=({id:e,targetOrigin:t,targetWindow:r,channel:i})=>{const a=new j(r,t,i);if(e||(e=n(10)),this.bridges.has(e))throw new Error(`Bridge ${e} already exists`);return this.bridges.set(e,a),{bridge:a,id:e}};getClient=e=>this.bridges.get(e);removeClient=e=>{const t=this.bridges.get(e);t&&(t.destroy(),this.bridges.delete(e))};removeAllClient=()=>{this.bridges.forEach(e=>{e.destroy()}),this.bridges.clear()};broadcast=e=>{this.bridges.forEach(t=>{t.broadcast(e)})};sendTo=(e,t,n)=>{const r=this.getClient(e);return r?r.send(t,n):Promise.reject(/* @__PURE__ */new Error(`Bridge ${e} not found`))}},z=N.getInstance(),K={connect:({id:e,targetWindow:t,targetOrigin:n,channel:r})=>z.connectClient({id:e,targetWindow:t,targetOrigin:n,channel:r}),remove:e=>{e&&z.removeClient(e)},removeAll:()=>{z.removeAllClient()},broadcast:e=>z.broadcast(e),call:({id:e,type:t,payload:n})=>z.sendTo(e,t,n),broadcastToAll:e=>{if("undefined"==typeof window)return;const t={__bridge:D,channel:I,type:e.type,payload:e.payload};return window.postMessage(t,"*")}},W={init:e=>{const t=new Map(Object.entries(e).filter(e=>R(e[1]))),n=async e=>{const n=e.data;if(!n||"object"!=typeof n||"__ranuts_bridge__"!==n.__bridge)return;const{type:r,payload:i,id:a}=n,s=n.channel??"default";if("string"!=typeof r||!t.has(r))return;const o=t.get(r);if(!o)return;const c=t=>{a&&e.source?.postMessage({__bridge:D,channel:s,type:r,id:a,isResponse:!0,...t},{targetOrigin:e.origin})};try{c({payload:await o(i)})}catch(u){c({payload:u instanceof Error?u.message:String(u),isError:!0})}};window.removeEventListener("message",n),window.addEventListener("message",n);return{destroy:()=>{window.removeEventListener("message",n)}}}},_="__ranuts_port_init__",q=e=>{const t=/* @__PURE__ */new Map,r=/* @__PURE__ */new Map,i=n=>{const i=n.data;if(!i||"object"!=typeof i||"string"!=typeof i.type)return;const{type:a,payload:s,id:o,isResponse:c,isError:u}=i;if(c&&o){const e=r.get(o);return void(e&&(u?e.reject(new Error("string"==typeof s?s:"Bridge request failed")):e.resolve(s),r.delete(o)))}if(!t.has(a))return;const d=t.get(a);R(d)&&Promise.resolve(d(s)).then(t=>{o&&e.postMessage({type:a,payload:t,id:o,isResponse:!0})}).catch(t=>{o&&e.postMessage({type:a,payload:t instanceof Error?t.message:String(t),id:o,isResponse:!0,isError:!0})})};return e.addEventListener("message",i),e.start(),{on:(e,n)=>{t.set(e,n)},off:e=>{t.delete(e)},send:(t,i)=>{const a=n(10);return new Promise((n,s)=>{const o=setTimeout(()=>{r.has(a)&&(r.delete(a),s(/* @__PURE__ */new Error("Request timeout")))},H),c=e=>{clearTimeout(o),s(e)};r.set(a,{resolve:e=>{clearTimeout(o),n(e)},reject:c});try{e.postMessage({type:t,payload:i,id:a})}catch(u){r.delete(a),c(u instanceof Error?u:/* @__PURE__ */new Error("Failed to post message"))}})},broadcast:t=>{try{e.postMessage({type:t.type,payload:t.payload})}catch{}},destroy:()=>{e.removeEventListener("message",i),t.clear(),r.forEach(e=>e.reject(/* @__PURE__ */new Error("Bridge destroyed"))),r.clear(),e.close()}}},V=({targetWindow:e,targetOrigin:t="*",name:n="default"})=>{const r=new MessageChannel;return e.postMessage({[_]:!0,name:n},t,[r.port2]),q(r.port1)},$=({targetOrigin:e="*",name:t="default"}={})=>"undefined"==typeof window?Promise.reject(/* @__PURE__ */new Error("acceptPortBridge is unavailable outside a browser environment")):new Promise(n=>{const r=i=>{if("*"!==e&&i.origin!==e)return;const a=i.data;if(!a||"object"!=typeof a||!0!==a[_]||a.name!==t)return;const s=i.ports?.[0];s&&(window.removeEventListener("message",r),n(q(s)))};window.addEventListener("message",r)}),X=e=>{let t,n=!1,r=e;return(...e)=>(n||(t="function"==typeof r?r(...e):r,n=!0,r=void 0),t)},Y=X,G=e=>{let t=null;const n=()=>(t??=e().catch(e=>{throw t=null,e}),t);return n.reset=()=>{t=null},Object.defineProperty(n,"started",{get:()=>null!==t}),n},J=()=>{};function Q(e={}){if("object"!=typeof e)throw new TypeError("param must be object");return Object.entries(e).reduce((e,[t,n])=>(void 0===n||null==n||e.append(decodeURIComponent(t),decodeURIComponent(n)),e),new URLSearchParams).toString()}var Z=(e,t=J,n=4)=>{try{const t="string"==typeof e?JSON.parse(e.replace(/'/g,'"')):e;return JSON.stringify(t,null,n)??""}catch(r){return t(r),""}},ee=(e,t)=>{const n={};return Object.keys(e).forEach(r=>{t.includes(r)||(n[r]=e[r])}),n},te=(e,t)=>{if(e&&t)for(const n in t)e[n]=t[n];return e};function ne(e,t,n,r){if(void 0===e)return J;if(!(t in e)&&!r)return J;const i=t in e,a=e[t],s=n(a);if("function"!=typeof s)return J;e[t]=s;let o=!1;return()=>{o||(o=!0,e[t]===s&&(i?e[t]=a:delete e[t]))}}var re=(e,t)=>{const n=Object.getOwnPropertyDescriptors(t);for(const r of Object.keys(n)){const t=n[r];if(t.get){const n=t.get;Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:X(n)})}else{if("object"!=typeof t.value)throw new Error("Exposed values must be either a getter or an nested object");Object.defineProperty(e,r,{configurable:!1,enumerable:!0,writable:!1,value:re({},t.value)})}}return Object.freeze(e)};function ie(e){return Object.prototype.toString.call(e)}function ae(e,t,n=/* @__PURE__ */new Map){if(e===t)return!0;if(null==e||null==t)return e===t;if(e!=e&&t!=t)return!0;const r=typeof e;if(r!==typeof t)return!1;if("object"!==r)return e===t;const i=ie(e);if(i!==ie(t))return!1;if(n.has(e))return n.get(e)===t;if(n.set(e,t),"[object Array]"===i){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!ae(e[r],t[r],n))return!1;return!0}if("[object Date]"===i)return+e===+t;if("[object RegExp]"===i)return e.toString()===t.toString();if("[object Map]"===i){if(e.size!==t.size)return!1;let r=!0;return e.forEach((e,i)=>{r&&(t.has(i)&&ae(e,t.get(i),n)||(r=!1))}),r}if("[object Set]"===i){if(e.size!==t.size)return!1;const r=Array.from(e),i=Array.from(t);return r.every(e=>i.some(t=>ae(e,t,n)))}const a=Object.keys(e),s=Object.keys(t);if(a.length!==s.length)return!1;for(const o of a)if(!Object.prototype.hasOwnProperty.call(t,o)||!ae(e[o],t[o],n))return!1;return!0}var se=(e,t=/* @__PURE__ */new WeakMap)=>{if(null===e||"object"!=typeof e)return e;if(t.has(e))return t.get(e);if(e instanceof Date)return new Date(e.getTime());if(e instanceof RegExp)return new RegExp(e.source,e.flags);if(Array.isArray(e)){const n=[];t.set(e,n);for(let r=0;r<e.length;r++)n[r]=se(e[r],t);return n}if(e instanceof Map){const n=/* @__PURE__ */new Map;return t.set(e,n),e.forEach((e,r)=>{n.set("object"==typeof r&&null!==r?se(r,t):r,se(e,t))}),n}if(e instanceof Set){const n=/* @__PURE__ */new Set;return t.set(e,n),e.forEach(e=>{n.add(se(e,t))}),n}if("object"==typeof e&&e.constructor===Object){const n={};return t.set(e,n),[...Object.getOwnPropertyNames(e),...Object.getOwnPropertySymbols(e)].forEach(r=>{n[r]=se(e[r],t)}),n}try{const n=new(0,Object.getPrototypeOf(e).constructor);t.set(e,n);for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=se(e[r],t));return n}catch{return console.warn(`Unable to deeply clone object of type ${Object.prototype.toString.call(e)}. Fallback to shallow copy.`),{...e}}},oe={172351395:{name:"EBML",type:"Container"},646:{name:"EBMLVersion",type:"Uint"},759:{name:"EBMLReadVersion",type:"Uint"},754:{name:"EBMLMaxIDLength",type:"Uint"},755:{name:"EBMLMaxSizeLength",type:"Uint"},642:{name:"DocType",type:"String"},647:{name:"DocTypeVersion",type:"Uint"},645:{name:"DocTypeReadVersion",type:"Uint"},108:{name:"Void",type:"Binary"},63:{name:"CRC-32",type:"Binary"},190023271:{name:"SignatureSlot",type:"Container"},16010:{name:"SignatureAlgo",type:"Uint"},16026:{name:"SignatureHash",type:"Uint"},16037:{name:"SignaturePublicKey",type:"Binary"},16053:{name:"Signature",type:"Binary"},15963:{name:"SignatureElements",type:"Container"},15995:{name:"SignatureElementList",type:"Container"},9522:{name:"SignedElement",type:"Binary"},139690087:{name:"Segment",type:"Container"},21863284:{name:"SeekHead",type:"Container"},3515:{name:"Seek",type:"Container"},5035:{name:"SeekID",type:"Binary"},5036:{name:"SeekPosition",type:"Uint"},88713574:{name:"Info",type:"Container"},13220:{name:"SegmentUID",type:"Binary"},13188:{name:"SegmentFilename",type:"String"},1882403:{name:"PrevUID",type:"Binary"},1868715:{name:"PrevFilename",type:"String"},2013475:{name:"NextUID",type:"Binary"},1999803:{name:"NextFilename",type:"String"},1092:{name:"SegmentFamily",type:"Binary"},10532:{name:"ChapterTranslate",type:"Container"},10748:{name:"ChapterTranslateEditionUID",type:"Uint"},10687:{name:"ChapterTranslateCodec",type:"Uint"},10661:{name:"ChapterTranslateID",type:"Binary"},710577:{name:"TimecodeScale",type:"Uint"},1161:{name:"Duration",type:"Float"},1121:{name:"DateUTC",type:"Date"},15273:{name:"Title",type:"String"},3456:{name:"MuxingApp",type:"String"},5953:{name:"WritingApp",type:"String"},103:{name:"Timecode",type:"Uint"},6228:{name:"SilentTracks",type:"Container"},6359:{name:"SilentTrackNumber",type:"Uint"},39:{name:"Position",type:"Uint"},43:{name:"PrevSize",type:"Uint"},35:{name:"SimpleBlock",type:"Binary"},32:{name:"BlockGroup",type:"Container"},33:{name:"Block",type:"Binary"},34:{name:"BlockVirtual",type:"Binary"},13729:{name:"BlockAdditions",type:"Container"},38:{name:"BlockMore",type:"Container"},110:{name:"BlockAddID",type:"Uint"},37:{name:"BlockAdditional",type:"Binary"},27:{name:"BlockDuration",type:"Uint"},122:{name:"ReferencePriority",type:"Uint"},123:{name:"ReferenceBlock",type:"Int"},125:{name:"ReferenceVirtual",type:"Int"},36:{name:"CodecState",type:"Binary"},13730:{name:"DiscardPadding",type:"Int"},14:{name:"Slices",type:"Container"},104:{name:"TimeSlice",type:"Container"},76:{name:"LaceNumber",type:"Uint"},77:{name:"FrameNumber",type:"Uint"},75:{name:"BlockAdditionID",type:"Uint"},78:{name:"Delay",type:"Uint"},79:{name:"SliceDuration",type:"Uint"},72:{name:"ReferenceFrame",type:"Container"},73:{name:"ReferenceOffset",type:"Uint"},74:{name:"ReferenceTimeCode",type:"Uint"},47:{name:"EncryptedBlock",type:"Binary"},106212971:{name:"Tracks",type:"Container"},46:{name:"TrackEntry",type:"Container"},87:{name:"TrackNumber",type:"Uint"},13253:{name:"TrackUID",type:"Uint"},3:{name:"TrackType",type:"Uint"},57:{name:"FlagEnabled",type:"Uint"},8:{name:"FlagDefault",type:"Uint"},5546:{name:"FlagForced",type:"Uint"},28:{name:"FlagLacing",type:"Uint"},11751:{name:"MinCache",type:"Uint"},11768:{name:"MaxCache",type:"Uint"},254851:{name:"DefaultDuration",type:"Uint"},216698:{name:"DefaultDecodedFieldDuration",type:"Uint"},209231:{name:"TrackTimecodeScale",type:"Float"},4991:{name:"TrackOffset",type:"Int"},5614:{name:"MaxBlockAdditionID",type:"Uint"},4974:{name:"Name",type:"String"},177564:{name:"Language",type:"String"},6:{name:"CodecID",type:"String"},9122:{name:"CodecPrivate",type:"Binary"},362120:{name:"CodecName",type:"String"},13382:{name:"AttachmentLink",type:"Uint"},1742487:{name:"CodecSettings",type:"String"},1785920:{name:"CodecInfoURL",type:"String"},438848:{name:"CodecDownloadURL",type:"String"},42:{name:"CodecDecodeAll",type:"Uint"},12203:{name:"TrackOverlay",type:"Uint"},5802:{name:"CodecDelay",type:"Uint"},5819:{name:"SeekPreRoll",type:"Uint"},9764:{name:"TrackTranslate",type:"Container"},9980:{name:"TrackTranslateEditionUID",type:"Uint"},9919:{name:"TrackTranslateCodec",type:"Uint"},9893:{name:"TrackTranslateTrackID",type:"Binary"},96:{name:"Video",type:"Container"},26:{name:"FlagInterlaced",type:"Uint"},5048:{name:"StereoMode",type:"Uint"},5056:{name:"AlphaMode",type:"Uint"},5049:{name:"OldStereoMode",type:"Uint"},48:{name:"PixelWidth",type:"Uint"},58:{name:"PixelHeight",type:"Uint"},5290:{name:"PixelCropBottom",type:"Uint"},5307:{name:"PixelCropTop",type:"Uint"},5324:{name:"PixelCropLeft",type:"Uint"},5341:{name:"PixelCropRight",type:"Uint"},5296:{name:"DisplayWidth",type:"Uint"},5306:{name:"DisplayHeight",type:"Uint"},5298:{name:"DisplayUnit",type:"Uint"},5299:{name:"AspectRatioType",type:"Uint"},963876:{name:"ColourSpace",type:"Binary"},1029411:{name:"GammaValue",type:"Float"},230371:{name:"FrameRate",type:"Float"},97:{name:"Audio",type:"Container"},53:{name:"SamplingFrequency",type:"Float"},14517:{name:"OutputSamplingFrequency",type:"Float"},31:{name:"Channels",type:"Uint"},15739:{name:"ChannelPositions",type:"Binary"},8804:{name:"BitDepth",type:"Uint"},98:{name:"TrackOperation",type:"Container"},99:{name:"TrackCombinePlanes",type:"Container"},100:{name:"TrackPlane",type:"Container"},101:{name:"TrackPlaneUID",type:"Uint"},102:{name:"TrackPlaneType",type:"Uint"},105:{name:"TrackJoinBlocks",type:"Container"},109:{name:"TrackJoinUID",type:"Uint"},64:{name:"TrickTrackUID",type:"Uint"},65:{name:"TrickTrackSegmentUID",type:"Binary"},70:{name:"TrickTrackFlag",type:"Uint"},71:{name:"TrickMasterTrackUID",type:"Uint"},68:{name:"TrickMasterTrackSegmentUID",type:"Binary"},11648:{name:"ContentEncodings",type:"Container"},8768:{name:"ContentEncoding",type:"Container"},4145:{name:"ContentEncodingOrder",type:"Uint"},4146:{name:"ContentEncodingScope",type:"Uint"},4147:{name:"ContentEncodingType",type:"Uint"},4148:{name:"ContentCompression",type:"Container"},596:{name:"ContentCompAlgo",type:"Uint"},597:{name:"ContentCompSettings",type:"Binary"},4149:{name:"ContentEncryption",type:"Container"},2017:{name:"ContentEncAlgo",type:"Uint"},2018:{name:"ContentEncKeyID",type:"Binary"},2019:{name:"ContentSignature",type:"Binary"},2020:{name:"ContentSigKeyID",type:"Binary"},2021:{name:"ContentSigAlgo",type:"Uint"},2022:{name:"ContentSigHashAlgo",type:"Uint"},206814059:{name:"Cues",type:"Container"},59:{name:"CuePoint",type:"Container"},51:{name:"CueTime",type:"Uint"},55:{name:"CueTrackPositions",type:"Container"},119:{name:"CueTrack",type:"Uint"},113:{name:"CueClusterPosition",type:"Uint"},112:{name:"CueRelativePosition",type:"Uint"},50:{name:"CueDuration",type:"Uint"},4984:{name:"CueBlockNumber",type:"Uint"},106:{name:"CueCodecState",type:"Uint"},91:{name:"CueReference",type:"Container"},22:{name:"CueRefTime",type:"Uint"},23:{name:"CueRefCluster",type:"Uint"},4959:{name:"CueRefNumber",type:"Uint"},107:{name:"CueRefCodecState",type:"Uint"},155296873:{name:"Attachments",type:"Container"},8615:{name:"AttachedFile",type:"Container"},1662:{name:"FileDescription",type:"String"},1646:{name:"FileName",type:"String"},1632:{name:"FileMimeType",type:"String"},1628:{name:"FileData",type:"Binary"},1710:{name:"FileUID",type:"Uint"},1653:{name:"FileReferral",type:"Binary"},1633:{name:"FileUsedStartTime",type:"Uint"},1634:{name:"FileUsedEndTime",type:"Uint"},4433776:{name:"Chapters",type:"Container"},1465:{name:"EditionEntry",type:"Container"},1468:{name:"EditionUID",type:"Uint"},1469:{name:"EditionFlagHidden",type:"Uint"},1499:{name:"EditionFlagDefault",type:"Uint"},1501:{name:"EditionFlagOrdered",type:"Uint"},54:{name:"ChapterAtom",type:"Container"},13252:{name:"ChapterUID",type:"Uint"},5716:{name:"ChapterStringUID",type:"String"},17:{name:"ChapterTimeStart",type:"Uint"},18:{name:"ChapterTimeEnd",type:"Uint"},24:{name:"ChapterFlagHidden",type:"Uint"},1432:{name:"ChapterFlagEnabled",type:"Uint"},11879:{name:"ChapterSegmentUID",type:"Binary"},11964:{name:"ChapterSegmentEditionUID",type:"Uint"},9155:{name:"ChapterPhysicalEquiv",type:"Uint"},15:{name:"ChapterTrack",type:"Container"},9:{name:"ChapterTrackNumber",type:"Uint"},0:{name:"ChapterDisplay",type:"Container"},5:{name:"ChapString",type:"String"},892:{name:"ChapLanguage",type:"String"},894:{name:"ChapCountry",type:"String"},10564:{name:"ChapProcess",type:"Container"},10581:{name:"ChapProcessCodecID",type:"Uint"},1293:{name:"ChapProcessPrivate",type:"Binary"},10513:{name:"ChapProcessCommand",type:"Container"},10530:{name:"ChapProcessTime",type:"Uint"},10547:{name:"ChapProcessData",type:"Binary"},39109479:{name:"Tags",type:"Container"},13171:{name:"Tag",type:"Container"},9152:{name:"Targets",type:"Container"},10442:{name:"TargetTypeValue",type:"Uint"},9162:{name:"TargetType",type:"String"},9157:{name:"TagTrackUID",type:"Uint"},9161:{name:"TagEditionUID",type:"Uint"},9156:{name:"TagChapterUID",type:"Uint"},9158:{name:"TagAttachmentUID",type:"Uint"},10184:{name:"SimpleTag",type:"Container"},1443:{name:"TagName",type:"String"},1146:{name:"TagLanguage",type:"String"},1156:{name:"TagDefault",type:"Uint"},1159:{name:"TagString",type:"String"},1157:{name:"TagBinary",type:"Binary"}},ce=class{name;type;source;data;constructor(e="Unknown",t="Unknown"){this.name=e,this.type=t}updateBySource(){}setSource(e){this.source=e,this.updateBySource()}updateByData(){}setData(e){this.data=e,this.updateByData()}};function ue(e){return e.length%2==1?"0"+e:e}var de=class extends ce{constructor(e,t){super(e,t||"Uint")}updateBySource(){this.data="";for(let e=0;e<this.source.length;e++){const t=this.source[e].toString(16);this.data+=ue(t)}}updateByData(){const e=this.data.length/2;this.source=new Uint8Array(e);for(let t=0;t<e;t++){const e=this.data.substr(2*t,2);this.source[t]=parseInt(e,16)}}getValue(){return parseInt(this.data,16)}setValue(e){this.setData(ue(e.toString(16)))}},le=class extends ce{constructor(e,t){super(e,t||"Float")}getFloatArrayType(){return this.source&&4===this.source.length?Float32Array:Float64Array}updateBySource(){const e=this.source.reverse(),t=new(this.getFloatArrayType())(e.buffer);this.data=t[0]}updateByData(){const e=new(this.getFloatArrayType())([this.data]),t=new Uint8Array(e.buffer);this.source=t.reverse()}getValue(){return this.data}setValue(e){this.setData(e)}},he=class e extends ce{offset=0;data=[];constructor(e,t){super(e,t||"Container")}readByte(){return this.source[this.offset++]}readUint(){const e=this.readByte(),t=8-e.toString(2).length;let n=e-(1<<7-t);for(let r=0;r<t;r++)n*=256,n+=this.readByte();return n}updateBySource(){let t;for(this.data=[],this.offset=0;this.offset<this.source.length;this.offset=t){const n=this.readUint(),r=this.readUint();t=Math.min(this.offset+r,this.source.length);const i=this.source.slice(this.offset,t),a=oe[n]||{name:"Unknown",type:"Unknown"};let s=ce;switch(a.type){case"Container":s=e;break;case"Uint":s=de;break;case"Float":s=le}const o=new s(a.name,a.type);o.setSource(i),this.data.push({id:n,idHex:n.toString(16),data:o})}}writeUint(e,t=!1){let n=1,r=128;for(;e>=r&&n<8;)n++,r*=128;if(!t){let t=r+e;for(let e=n-1;e>=0;e--){const n=t%256;this.source[this.offset+e]=n,t=(t-n)/256}}this.offset+=n}writeSections(e=!1){this.offset=0;for(let t=0;t<this.data.length;t++){const n=this.data[t],r=n.data.source,i=r.length;this.writeUint(n.id,e),this.writeUint(i,e),e||this.source.set(r,this.offset),this.offset+=i}return this.offset}updateByData(){const e=this.writeSections(!0);this.source=new Uint8Array(e),this.writeSections()}getSectionById(e){for(let t=0;t<this.data.length;t++){const n=this.data[t];if(n.id===e)return n.data}}},pe=class extends he{constructor(e){super("File","File"),this.setSource(e)}fixDuration(e){const t=this.getSectionById(139690087);if(!t)return!1;const n=t.getSectionById(88713574);if(!n)return!1;const r=n.getSectionById(710577);if(!r)return!1;let i=n.getSectionById(1161);if(i){if(!(i.getValue()<=0))return!1;i.setValue(e)}else i=new le("Duration","Float"),i.setValue(e),n.data.push({id:1161,data:i});return r.setValue(1e6),n.updateByData(),t.updateByData(),this.updateByData(),!0}toBlob(e="video/webm"){return new Blob([this.source.buffer],{type:e})}};var fe=class{startTime;chunks;mediaRecorder;blob;constructor(){this.startTime=Date.now(),this.chunks=[],navigator.mediaDevices.getUserMedia({audio:!0}).then(e=>{this.init(e)}).catch(e=>{})}init(e){const t=function(){const e=["audio/webm","audio/mp4","audio/ogg","audio/wav","audio/aac"];for(let t=0;t<e.length;t++)if(MediaRecorder.isTypeSupported(e[t]))return e[t]}();this.mediaRecorder=new MediaRecorder(e,{mimeType:t}),this.mediaRecorder?.addEventListener("dataavailable",async e=>{if(e.data.size>0&&this.chunks.push(e.data),"inactive"===this.mediaRecorder?.state){const e=Date.now()-this.startTime;this.blob=new Blob(this.chunks,{type:t}),"audio/webm"===t&&(this.blob=await((e,t,n="video/webm")=>new Promise((r,i)=>{try{const a=new FileReader;a.addEventListener("loadend",()=>{try{const i=a.result,s=new pe(new Uint8Array(i));s.fixDuration(t)?r(s.toBlob(n)):r(e)}catch(s){i(s)}}),a.addEventListener("error",()=>i()),a.readAsArrayBuffer(e)}catch(a){i(a)}}))(this.blob,e,this.blob.type)),this.chunks=[]}}),this.mediaRecorder?.start()}start(){return"paused"===this.mediaRecorder?.state&&this.mediaRecorder.resume(),this.mediaRecorder}pause(){return"recording"===this.mediaRecorder?.state&&this.mediaRecorder.pause(),this.mediaRecorder}stop(){return this.mediaRecorder?.stop(),this.blob}},me=new e,ge=(e,t={})=>{const{subscriber:n,equals:r}=t;let i=e;return[()=>i,e=>{var t,a;(t=i,a=e,!1!==r&&("function"==typeof r?r(t,a):Object.is(t,a)))||(i=e,n&&me.call(n))}]},ye="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function we(e,t,n,r){let i,a,s;const o=t||[0],c=(n=n||0)>>>3,u=-1===r?3:0;for(i=0;i<e.length;i+=1)s=i+c,a=s>>>2,o.length<=a&&o.push(0),o[a]|=e[i]<<8*(u+r*(s%4));return{value:o,binLen:8*e.length+n}}function be(e,t,n){switch(t){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw new Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(e){case"HEX":return function(e,t,r){return function(e,t,n,r){let i,a,s,o;if(0!=e.length%2)throw new Error("String of HEX type must be in byte increments");const c=t||[0],u=(n=n||0)>>>3,d=-1===r?3:0;for(i=0;i<e.length;i+=2){if(a=parseInt(e.substr(i,2),16),isNaN(a))throw new Error("String of HEX type contains invalid characters");for(o=(i>>>1)+u,s=o>>>2;c.length<=s;)c.push(0);c[s]|=a<<8*(d+r*(o%4))}return{value:c,binLen:4*e.length+n}}(e,t,r,n)};case"TEXT":return function(e,r,i){return function(e,t,n,r,i){let a,s,o,c,u,d,l,h,p=0;const f=n||[0],m=(r=r||0)>>>3;if("UTF8"===t)for(l=-1===i?3:0,o=0;o<e.length;o+=1)for(a=e.charCodeAt(o),s=[],128>a?s.push(a):2048>a?(s.push(192|a>>>6),s.push(128|63&a)):55296>a||57344<=a?s.push(224|a>>>12,128|a>>>6&63,128|63&a):(o+=1,a=65536+((1023&a)<<10|1023&e.charCodeAt(o)),s.push(240|a>>>18,128|a>>>12&63,128|a>>>6&63,128|63&a)),c=0;c<s.length;c+=1){for(d=p+m,u=d>>>2;f.length<=u;)f.push(0);f[u]|=s[c]<<8*(l+i*(d%4)),p+=1}else for(l=-1===i?2:0,h="UTF16LE"===t&&1!==i||"UTF16LE"!==t&&1===i,o=0;o<e.length;o+=1){for(a=e.charCodeAt(o),!0===h&&(c=255&a,a=c<<8|a>>>8),d=p+m,u=d>>>2;f.length<=u;)f.push(0);f[u]|=a<<8*(l+i*(d%4)),p+=2}return{value:f,binLen:8*p+r}}(e,t,r,i,n)};case"B64":return function(e,t,r){return function(e,t,n,r){let i,a,s,o,c,u,d,l=0;const h=t||[0],p=(n=n||0)>>>3,f=-1===r?3:0,m=e.indexOf("=");if(-1===e.search(/^[a-z\d=+/]+$/i))throw new Error("Invalid character in base-64 string");if(e=e.replace(/=/g,""),-1!==m&&m<e.length)throw new Error("Invalid '=' found in base-64 string");for(a=0;a<e.length;a+=4){for(c=e.substr(a,4),o=0,s=0;s<c.length;s+=1)i=ye.indexOf(c.charAt(s)),o|=i<<18-6*s;for(s=0;s<c.length-1;s+=1){for(d=l+p,u=d>>>2;h.length<=u;)h.push(0);h[u]|=(o>>>16-8*s&255)<<8*(f+r*(d%4)),l+=1}}return{value:h,binLen:8*l+n}}(e,t,r,n)};case"BYTES":return function(e,t,r){return function(e,t,n,r){let i,a,s,o;const c=t||[0],u=(n=n||0)>>>3,d=-1===r?3:0;for(a=0;a<e.length;a+=1)i=e.charCodeAt(a),o=a+u,s=o>>>2,c.length<=s&&c.push(0),c[s]|=i<<8*(d+r*(o%4));return{value:c,binLen:8*e.length+n}}(e,t,r,n)};case"ARRAYBUFFER":return function(e,t,r){return function(e,t,n,r){return we(new Uint8Array(e),t,n,r)}(e,t,r,n)};case"UINT8ARRAY":return function(e,t,r){return we(e,t,r,n)};default:throw new Error("format must be HEX, TEXT, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}}function Se(e,t,n,r){switch(e){case"HEX":return function(e){return function(e,t,n,r){const i="0123456789abcdef";let a,s,o="";const c=t/8,u=-1===n?3:0;for(a=0;a<c;a+=1)s=e[a>>>2]>>>8*(u+n*(a%4)),o+=i.charAt(s>>>4&15)+i.charAt(15&s);return r.outputUpper?o.toUpperCase():o}(e,t,n,r)};case"B64":return function(e){return function(e,t,n,r){let i,a,s,o,c,u="";const d=t/8,l=-1===n?3:0;for(i=0;i<d;i+=3)for(o=i+1<d?e[i+1>>>2]:0,c=i+2<d?e[i+2>>>2]:0,s=(e[i>>>2]>>>8*(l+n*(i%4))&255)<<16|(o>>>8*(l+n*((i+1)%4))&255)<<8|c>>>8*(l+n*((i+2)%4))&255,a=0;a<4;a+=1)u+=8*i+6*a<=t?ye.charAt(s>>>6*(3-a)&63):r.b64Pad;return u}(e,t,n,r)};case"BYTES":return function(e){return function(e,t,n){let r,i,a="";const s=t/8,o=-1===n?3:0;for(r=0;r<s;r+=1)i=e[r>>>2]>>>8*(o+n*(r%4))&255,a+=String.fromCharCode(i);return a}(e,t,n)};case"ARRAYBUFFER":return function(e){return function(e,t,n){let r;const i=t/8,a=new ArrayBuffer(i),s=new Uint8Array(a),o=-1===n?3:0;for(r=0;r<i;r+=1)s[r]=e[r>>>2]>>>8*(o+n*(r%4))&255;return a}(e,t,n)};case"UINT8ARRAY":return function(e){return function(e,t,n){let r;const i=t/8,a=-1===n?3:0,s=new Uint8Array(i);for(r=0;r<i;r+=1)s[r]=e[r>>>2]>>>8*(a+n*(r%4))&255;return s}(e,t,n)};default:throw new Error("format must be HEX, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}}var Ce=4294967296,ve=[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],Ue=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428],Ee=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],Oe="Chosen SHA variant is not supported",Ae="Cannot set numRounds with MAC";function Me(e,t){let n,r;const i=e.binLen>>>3,a=t.binLen>>>3,s=i<<3,o=4-i<<3;if(i%4!=0){for(n=0;n<a;n+=4)r=i+n>>>2,e.value[r]|=t.value[n>>>2]<<s,e.value.push(0),e.value[r+1]|=t.value[n>>>2]>>>o;return(e.value.length<<2)-4>=a+i&&e.value.pop(),{value:e.value,binLen:e.binLen+t.binLen}}return{value:e.value.concat(t.value),binLen:e.binLen+t.binLen}}function ke(e){const t={outputUpper:!1,b64Pad:"=",outputLen:-1},n=e||{},r="Output length must be a multiple of 8";if(t.outputUpper=n.outputUpper||!1,n.b64Pad&&(t.b64Pad=n.b64Pad),n.outputLen){if(n.outputLen%8!=0)throw new Error(r);t.outputLen=n.outputLen}else if(n.shakeLen){if(n.shakeLen%8!=0)throw new Error(r);t.outputLen=n.shakeLen}if("boolean"!=typeof t.outputUpper)throw new Error("Invalid outputUpper formatting option");if("string"!=typeof t.b64Pad)throw new Error("Invalid b64Pad formatting option");return t}function Te(e,t,n,r){const i=e+" must include a value and format";if(!t){if(!r)throw new Error(i);return r}if(void 0===t.value||!t.format)throw new Error(i);return be(t.format,t.encoding||"UTF8",n)(t.value)}var Be=class{shaVariant;inputFormat;utfType;numRounds;keyWithIPad;keyWithOPad;remainder;remainderLen;updateCalled;processedLen;macKeySet;constructor(e,t,n){const r=n||{};if(this.inputFormat=t,this.utfType=r.encoding||"UTF8",this.numRounds=r.numRounds||1,isNaN(this.numRounds)||this.numRounds!==parseInt(this.numRounds,10)||1>this.numRounds)throw new Error("numRounds must a integer >= 1");this.shaVariant=e,this.remainder=[],this.remainderLen=0,this.updateCalled=!1,this.processedLen=0,this.macKeySet=!1,this.keyWithIPad=[],this.keyWithOPad=[]}update(e){let t,n=0;const r=this.variantBlockSize>>>5,i=this.converterFunc(e,this.remainder,this.remainderLen),a=i.binLen,s=i.value,o=a>>>5;for(t=0;t<o;t+=r)n+this.variantBlockSize<=a&&(this.intermediateState=this.roundFunc(s.slice(t,t+r),this.intermediateState),n+=this.variantBlockSize);return this.processedLen+=n,this.remainder=s.slice(n>>>5),this.remainderLen=a%this.variantBlockSize,this.updateCalled=!0,this}getHash(e,t){let n,r,i=this.outputBinLen;const a=ke(t);if(this.isVariableLen){if(-1===a.outputLen)throw new Error("Output length must be specified in options");i=a.outputLen}const s=Se(e,i,this.bigEndianMod,a);if(this.macKeySet&&this.getMAC)return s(this.getMAC(a));for(r=this.finalizeFunc(this.remainder.slice(),this.remainderLen,this.processedLen,this.stateCloneFunc(this.intermediateState),i),n=1;n<this.numRounds;n+=1)this.isVariableLen&&i%32!=0&&(r[r.length-1]&=16777215>>>24-i%32),r=this.finalizeFunc(r,i,0,this.newStateFunc(this.shaVariant),i);return s(r)}setHMACKey(e,t,n){if(!this.HMACSupported)throw new Error("Variant does not support HMAC");if(this.updateCalled)throw new Error("Cannot set MAC key after calling update");const r=be(t,(n||{}).encoding||"UTF8",this.bigEndianMod);this._setHMACKey(r(e))}_setHMACKey(e){const t=this.variantBlockSize>>>3,n=t/4-1;let r;if(1!==this.numRounds)throw new Error(Ae);if(this.macKeySet)throw new Error("MAC key already set");for(t<e.binLen/8&&(e.value=this.finalizeFunc(e.value,e.binLen,0,this.newStateFunc(this.shaVariant),this.outputBinLen));e.value.length<=n;)e.value.push(0);for(r=0;r<=n;r+=1)this.keyWithIPad[r]=909522486^e.value[r],this.keyWithOPad[r]=1549556828^e.value[r];this.intermediateState=this.roundFunc(this.keyWithIPad,this.intermediateState),this.processedLen=this.variantBlockSize,this.macKeySet=!0}getHMAC(e,t){const n=ke(t);return Se(e,this.outputBinLen,this.bigEndianMod,n)(this._getHMAC())}_getHMAC(){let e;if(!this.macKeySet)throw new Error("Cannot call getHMAC without first setting MAC key");const t=this.finalizeFunc(this.remainder.slice(),this.remainderLen,this.processedLen,this.stateCloneFunc(this.intermediateState),this.outputBinLen);return e=this.roundFunc(this.keyWithOPad,this.newStateFunc(this.shaVariant)),e=this.finalizeFunc(t,this.outputBinLen,this.variantBlockSize,e,this.outputBinLen),e}};function Le(e,t){return e<<t|e>>>32-t}function Fe(e,t){return e>>>t|e<<32-t}function Pe(e,t){return e>>>t}function Re(e,t,n){return e^t^n}function He(e,t,n){return e&t^~e&n}function De(e,t,n){return e&t^e&n^t&n}function Ie(e){return Fe(e,2)^Fe(e,13)^Fe(e,22)}function xe(e,t){const n=(65535&e)+(65535&t);return((e>>>16)+(t>>>16)+(n>>>16)&65535)<<16|65535&n}function je(e,t,n,r){const i=(65535&e)+(65535&t)+(65535&n)+(65535&r);return((e>>>16)+(t>>>16)+(n>>>16)+(r>>>16)+(i>>>16)&65535)<<16|65535&i}function Ne(e,t,n,r,i){const a=(65535&e)+(65535&t)+(65535&n)+(65535&r)+(65535&i);return((e>>>16)+(t>>>16)+(n>>>16)+(r>>>16)+(i>>>16)+(a>>>16)&65535)<<16|65535&a}function ze(e){return Fe(e,17)^Fe(e,19)^Pe(e,10)}function Ke(e){return Fe(e,7)^Fe(e,18)^Pe(e,3)}function We(e){return Fe(e,6)^Fe(e,11)^Fe(e,25)}function _e(e){return[1732584193,4023233417,2562383102,271733878,3285377520]}function qe(e,t){let n,r,i,a,s,o,c;const u=[];for(n=t[0],r=t[1],i=t[2],a=t[3],s=t[4],c=0;c<80;c+=1)u[c]=c<16?e[c]:Le(u[c-3]^u[c-8]^u[c-14]^u[c-16],1),o=c<20?Ne(Le(n,5),He(r,i,a),s,1518500249,u[c]):c<40?Ne(Le(n,5),Re(r,i,a),s,1859775393,u[c]):c<60?Ne(Le(n,5),De(r,i,a),s,2400959708,u[c]):Ne(Le(n,5),Re(r,i,a),s,3395469782,u[c]),s=a,a=i,i=Le(r,30),r=n,n=o;return t[0]=xe(n,t[0]),t[1]=xe(r,t[1]),t[2]=xe(i,t[2]),t[3]=xe(a,t[3]),t[4]=xe(s,t[4]),t}function Ve(e,t,n,r){let i;const a=15+(t+65>>>9<<4),s=t+n;for(;e.length<=a;)e.push(0);for(e[t>>>5]|=128<<24-t%32,e[a]=4294967295&s,e[a-1]=s/Ce|0,i=0;i<e.length;i+=16)r=qe(e.slice(i,i+16),r);return r}var $e=class extends Be{intermediateState;variantBlockSize;bigEndianMod;outputBinLen;isVariableLen;HMACSupported;converterFunc;roundFunc;finalizeFunc;stateCloneFunc;newStateFunc;getMAC;constructor(e,t,n){if("SHA-1"!==e)throw new Error(Oe);super(e,t,n);const r=n||{};this.HMACSupported=!0,this.getMAC=this._getHMAC,this.bigEndianMod=-1,this.converterFunc=be(this.inputFormat,this.utfType,this.bigEndianMod),this.roundFunc=qe,this.stateCloneFunc=function(e){return e.slice()},this.newStateFunc=_e,this.finalizeFunc=Ve,this.intermediateState=[1732584193,4023233417,2562383102,271733878,3285377520],this.variantBlockSize=512,this.outputBinLen=160,this.isVariableLen=!1,r.hmacKey&&this._setHMACKey(Te("hmacKey",r.hmacKey,this.bigEndianMod))}};function Xe(e){let t;return t="SHA-224"===e?Ue.slice():Ee.slice(),t}function Ye(e,t){let n,r,i,a,s,o,c,u,d,l,h;const p=[];for(n=t[0],r=t[1],i=t[2],a=t[3],s=t[4],o=t[5],c=t[6],u=t[7],h=0;h<64;h+=1)p[h]=h<16?e[h]:je(ze(p[h-2]),p[h-7],Ke(p[h-15]),p[h-16]),d=Ne(u,We(s),He(s,o,c),ve[h],p[h]),l=xe(Ie(n),De(n,r,i)),u=c,c=o,o=s,s=xe(a,d),a=i,i=r,r=n,n=xe(d,l);return t[0]=xe(n,t[0]),t[1]=xe(r,t[1]),t[2]=xe(i,t[2]),t[3]=xe(a,t[3]),t[4]=xe(s,t[4]),t[5]=xe(o,t[5]),t[6]=xe(c,t[6]),t[7]=xe(u,t[7]),t}var Ge=class extends Be{intermediateState;variantBlockSize;bigEndianMod;outputBinLen;isVariableLen;HMACSupported;converterFunc;roundFunc;finalizeFunc;stateCloneFunc;newStateFunc;getMAC;constructor(e,t,n){if("SHA-224"!==e&&"SHA-256"!==e)throw new Error(Oe);super(e,t,n);const r=n||{};this.getMAC=this._getHMAC,this.HMACSupported=!0,this.bigEndianMod=-1,this.converterFunc=be(this.inputFormat,this.utfType,this.bigEndianMod),this.roundFunc=Ye,this.stateCloneFunc=function(e){return e.slice()},this.newStateFunc=Xe,this.finalizeFunc=function(t,n,r,i){return function(e,t,n,r,i){let a,s;const o=15+(t+65>>>9<<4),c=t+n;for(;e.length<=o;)e.push(0);for(e[t>>>5]|=128<<24-t%32,e[o]=4294967295&c,e[o-1]=c/Ce|0,a=0;a<e.length;a+=16)r=Ye(e.slice(a,a+16),r);return s="SHA-224"===i?[r[0],r[1],r[2],r[3],r[4],r[5],r[6]]:r,s}(t,n,r,i,e)},this.intermediateState=Xe(e),this.variantBlockSize=512,this.outputBinLen="SHA-224"===e?224:256,this.isVariableLen=!1,r.hmacKey&&this._setHMACKey(Te("hmacKey",r.hmacKey,this.bigEndianMod))}},Je=class{highOrder;lowOrder;constructor(e,t){this.highOrder=e,this.lowOrder=t}};function Qe(e,t){let n;return t>32?(n=64-t,new Je(e.lowOrder<<t|e.highOrder>>>n,e.highOrder<<t|e.lowOrder>>>n)):0!==t?(n=32-t,new Je(e.highOrder<<t|e.lowOrder>>>n,e.lowOrder<<t|e.highOrder>>>n)):e}function Ze(e,t){let n;return t<32?(n=32-t,new Je(e.highOrder>>>t|e.lowOrder<<n,e.lowOrder>>>t|e.highOrder<<n)):(n=64-t,new Je(e.lowOrder>>>t|e.highOrder<<n,e.highOrder>>>t|e.lowOrder<<n))}function et(e,t){return new Je(e.highOrder>>>t,e.lowOrder>>>t|e.highOrder<<32-t)}function tt(e,t,n){return new Je(e.highOrder&t.highOrder^~e.highOrder&n.highOrder,e.lowOrder&t.lowOrder^~e.lowOrder&n.lowOrder)}function nt(e,t,n){return new Je(e.highOrder&t.highOrder^e.highOrder&n.highOrder^t.highOrder&n.highOrder,e.lowOrder&t.lowOrder^e.lowOrder&n.lowOrder^t.lowOrder&n.lowOrder)}function rt(e){const t=Ze(e,28),n=Ze(e,34),r=Ze(e,39);return new Je(t.highOrder^n.highOrder^r.highOrder,t.lowOrder^n.lowOrder^r.lowOrder)}function it(e,t){let n,r;n=(65535&e.lowOrder)+(65535&t.lowOrder),r=(e.lowOrder>>>16)+(t.lowOrder>>>16)+(n>>>16);const i=(65535&r)<<16|65535&n;n=(65535&e.highOrder)+(65535&t.highOrder)+(r>>>16),r=(e.highOrder>>>16)+(t.highOrder>>>16)+(n>>>16);return new Je((65535&r)<<16|65535&n,i)}function at(e,t,n,r){let i,a;i=(65535&e.lowOrder)+(65535&t.lowOrder)+(65535&n.lowOrder)+(65535&r.lowOrder),a=(e.lowOrder>>>16)+(t.lowOrder>>>16)+(n.lowOrder>>>16)+(r.lowOrder>>>16)+(i>>>16);const s=(65535&a)<<16|65535&i;i=(65535&e.highOrder)+(65535&t.highOrder)+(65535&n.highOrder)+(65535&r.highOrder)+(a>>>16),a=(e.highOrder>>>16)+(t.highOrder>>>16)+(n.highOrder>>>16)+(r.highOrder>>>16)+(i>>>16);return new Je((65535&a)<<16|65535&i,s)}function st(e,t,n,r,i){let a,s;a=(65535&e.lowOrder)+(65535&t.lowOrder)+(65535&n.lowOrder)+(65535&r.lowOrder)+(65535&i.lowOrder),s=(e.lowOrder>>>16)+(t.lowOrder>>>16)+(n.lowOrder>>>16)+(r.lowOrder>>>16)+(i.lowOrder>>>16)+(a>>>16);const o=(65535&s)<<16|65535&a;a=(65535&e.highOrder)+(65535&t.highOrder)+(65535&n.highOrder)+(65535&r.highOrder)+(65535&i.highOrder)+(s>>>16),s=(e.highOrder>>>16)+(t.highOrder>>>16)+(n.highOrder>>>16)+(r.highOrder>>>16)+(i.highOrder>>>16)+(a>>>16);return new Je((65535&s)<<16|65535&a,o)}function ot(e,t){return new Je(e.highOrder^t.highOrder,e.lowOrder^t.lowOrder)}function ct(e,t,n,r,i){return new Je(e.highOrder^t.highOrder^n.highOrder^r.highOrder^i.highOrder,e.lowOrder^t.lowOrder^n.lowOrder^r.lowOrder^i.lowOrder)}function ut(e){const t=Ze(e,19),n=Ze(e,61),r=et(e,6);return new Je(t.highOrder^n.highOrder^r.highOrder,t.lowOrder^n.lowOrder^r.lowOrder)}function dt(e){const t=Ze(e,1),n=Ze(e,8),r=et(e,7);return new Je(t.highOrder^n.highOrder^r.highOrder,t.lowOrder^n.lowOrder^r.lowOrder)}function lt(e){const t=Ze(e,14),n=Ze(e,18),r=Ze(e,41);return new Je(t.highOrder^n.highOrder^r.highOrder,t.lowOrder^n.lowOrder^r.lowOrder)}var ht=[new Je(ve[0],3609767458),new Je(ve[1],602891725),new Je(ve[2],3964484399),new Je(ve[3],2173295548),new Je(ve[4],4081628472),new Je(ve[5],3053834265),new Je(ve[6],2937671579),new Je(ve[7],3664609560),new Je(ve[8],2734883394),new Je(ve[9],1164996542),new Je(ve[10],1323610764),new Je(ve[11],3590304994),new Je(ve[12],4068182383),new Je(ve[13],991336113),new Je(ve[14],633803317),new Je(ve[15],3479774868),new Je(ve[16],2666613458),new Je(ve[17],944711139),new Je(ve[18],2341262773),new Je(ve[19],2007800933),new Je(ve[20],1495990901),new Je(ve[21],1856431235),new Je(ve[22],3175218132),new Je(ve[23],2198950837),new Je(ve[24],3999719339),new Je(ve[25],766784016),new Je(ve[26],2566594879),new Je(ve[27],3203337956),new Je(ve[28],1034457026),new Je(ve[29],2466948901),new Je(ve[30],3758326383),new Je(ve[31],168717936),new Je(ve[32],1188179964),new Je(ve[33],1546045734),new Je(ve[34],1522805485),new Je(ve[35],2643833823),new Je(ve[36],2343527390),new Je(ve[37],1014477480),new Je(ve[38],1206759142),new Je(ve[39],344077627),new Je(ve[40],1290863460),new Je(ve[41],3158454273),new Je(ve[42],3505952657),new Je(ve[43],106217008),new Je(ve[44],3606008344),new Je(ve[45],1432725776),new Je(ve[46],1467031594),new Je(ve[47],851169720),new Je(ve[48],3100823752),new Je(ve[49],1363258195),new Je(ve[50],3750685593),new Je(ve[51],3785050280),new Je(ve[52],3318307427),new Je(ve[53],3812723403),new Je(ve[54],2003034995),new Je(ve[55],3602036899),new Je(ve[56],1575990012),new Je(ve[57],1125592928),new Je(ve[58],2716904306),new Je(ve[59],442776044),new Je(ve[60],593698344),new Je(ve[61],3733110249),new Je(ve[62],2999351573),new Je(ve[63],3815920427),new Je(3391569614,3928383900),new Je(3515267271,566280711),new Je(3940187606,3454069534),new Je(4118630271,4000239992),new Je(116418474,1914138554),new Je(174292421,2731055270),new Je(289380356,3203993006),new Je(460393269,320620315),new Je(685471733,587496836),new Je(852142971,1086792851),new Je(1017036298,365543100),new Je(1126000580,2618297676),new Je(1288033470,3409855158),new Je(1501505948,4234509866),new Je(1607167915,987167468),new Je(1816402316,1246189591)];function pt(e){return"SHA-384"===e?[new Je(3418070365,Ue[0]),new Je(1654270250,Ue[1]),new Je(2438529370,Ue[2]),new Je(355462360,Ue[3]),new Je(1731405415,Ue[4]),new Je(41048885895,Ue[5]),new Je(3675008525,Ue[6]),new Je(1203062813,Ue[7])]:[new Je(Ee[0],4089235720),new Je(Ee[1],2227873595),new Je(Ee[2],4271175723),new Je(Ee[3],1595750129),new Je(Ee[4],2917565137),new Je(Ee[5],725511199),new Je(Ee[6],4215389547),new Je(Ee[7],327033209)]}function ft(e,t){let n,r,i,a,s,o,c,u,d,l,h,p;const f=[];for(n=t[0],r=t[1],i=t[2],a=t[3],s=t[4],o=t[5],c=t[6],u=t[7],h=0;h<80;h+=1)h<16?(p=2*h,f[h]=new Je(e[p],e[p+1])):f[h]=at(ut(f[h-2]),f[h-7],dt(f[h-15]),f[h-16]),d=st(u,lt(s),tt(s,o,c),ht[h],f[h]),l=it(rt(n),nt(n,r,i)),u=c,c=o,o=s,s=it(a,d),a=i,i=r,r=n,n=it(d,l);return t[0]=it(n,t[0]),t[1]=it(r,t[1]),t[2]=it(i,t[2]),t[3]=it(a,t[3]),t[4]=it(s,t[4]),t[5]=it(o,t[5]),t[6]=it(c,t[6]),t[7]=it(u,t[7]),t}var mt=class extends Be{intermediateState;variantBlockSize;bigEndianMod;outputBinLen;isVariableLen;HMACSupported;converterFunc;roundFunc;finalizeFunc;stateCloneFunc;newStateFunc;getMAC;constructor(e,t,n){if("SHA-384"!==e&&"SHA-512"!==e)throw new Error(Oe);super(e,t,n);const r=n||{};this.getMAC=this._getHMAC,this.HMACSupported=!0,this.bigEndianMod=-1,this.converterFunc=be(this.inputFormat,this.utfType,this.bigEndianMod),this.roundFunc=ft,this.stateCloneFunc=function(e){return e.slice()},this.newStateFunc=pt,this.finalizeFunc=function(t,n,r,i){return function(e,t,n,r,i){let a,s;const o=31+(t+129>>>10<<5),c=t+n;for(;e.length<=o;)e.push(0);for(e[t>>>5]|=128<<24-t%32,e[o]=4294967295&c,e[o-1]=c/Ce|0,a=0;a<e.length;a+=32)r=ft(e.slice(a,a+32),r);return s="SHA-384"===i?[r[0].highOrder,r[0].lowOrder,r[1].highOrder,r[1].lowOrder,r[2].highOrder,r[2].lowOrder,r[3].highOrder,r[3].lowOrder,r[4].highOrder,r[4].lowOrder,r[5].highOrder,r[5].lowOrder]:[r[0].highOrder,r[0].lowOrder,r[1].highOrder,r[1].lowOrder,r[2].highOrder,r[2].lowOrder,r[3].highOrder,r[3].lowOrder,r[4].highOrder,r[4].lowOrder,r[5].highOrder,r[5].lowOrder,r[6].highOrder,r[6].lowOrder,r[7].highOrder,r[7].lowOrder],s}(t,n,r,i,e)},this.intermediateState=pt(e),this.variantBlockSize=1024,this.outputBinLen="SHA-384"===e?384:512,this.isVariableLen=!1,r.hmacKey&&this._setHMACKey(Te("hmacKey",r.hmacKey,this.bigEndianMod))}},gt=[new Je(0,1),new Je(0,32898),new Je(2147483648,32906),new Je(2147483648,2147516416),new Je(0,32907),new Je(0,2147483649),new Je(2147483648,2147516545),new Je(2147483648,32777),new Je(0,138),new Je(0,136),new Je(0,2147516425),new Je(0,2147483658),new Je(0,2147516555),new Je(2147483648,139),new Je(2147483648,32905),new Je(2147483648,32771),new Je(2147483648,32770),new Je(2147483648,128),new Je(0,32778),new Je(2147483648,2147483658),new Je(2147483648,2147516545),new Je(2147483648,32896),new Je(0,2147483649),new Je(2147483648,2147516424)],yt=[[0,36,3,41,18],[1,44,10,45,2],[62,6,43,15,61],[28,55,25,21,56],[27,20,39,8,14]];function wt(e){let t;const n=[];for(t=0;t<5;t+=1)n[t]=[new Je(0,0),new Je(0,0),new Je(0,0),new Je(0,0),new Je(0,0)];return n}function bt(e){let t;const n=[];for(t=0;t<5;t+=1)n[t]=e[t].slice();return n}function St(e,t){let n,r,i,a;const s=[],o=[];if(null!=e)for(r=0;r<e.length;r+=2)t[(r>>>1)%5][(r>>>1)/5|0]=ot(t[(r>>>1)%5][(r>>>1)/5|0],new Je(e[r+1],e[r]));for(n=0;n<24;n+=1){for(a=wt(),r=0;r<5;r+=1)s[r]=ct(t[r][0],t[r][1],t[r][2],t[r][3],t[r][4]);for(r=0;r<5;r+=1)o[r]=ot(s[(r+4)%5],Qe(s[(r+1)%5],1));for(r=0;r<5;r+=1)for(i=0;i<5;i+=1)t[r][i]=ot(t[r][i],o[r]);for(r=0;r<5;r+=1)for(i=0;i<5;i+=1)a[i][(2*r+3*i)%5]=Qe(t[r][i],yt[r][i]);for(r=0;r<5;r+=1)for(i=0;i<5;i+=1)t[r][i]=ot(a[r][i],new Je(~a[(r+1)%5][i].highOrder&a[(r+2)%5][i].highOrder,~a[(r+1)%5][i].lowOrder&a[(r+2)%5][i].lowOrder));t[0][0]=ot(t[0][0],gt[n])}return t}function Ct(e){let t,n,r=0;const i=[0,0],a=[4294967295&e,e/Ce&2097151];for(t=6;t>=0;t--)n=a[t>>2]>>>8*t&255,0===n&&0===r||(i[r+1>>2]|=n<<8*(r+1),r+=1);return r=0!==r?r:1,i[0]|=r,{value:r+1>4?i:[i[0]],binLen:8+8*r}}function vt(e){return Me(Ct(e.binLen),e)}function Ut(e,t){let n,r=Ct(t);r=Me(r,e);const i=t>>>2,a=(i-r.value.length%i)%i;for(n=0;n<a;n++)r.value.push(0);return r.value}var Et=class extends Be{intermediateState;variantBlockSize;bigEndianMod;outputBinLen;isVariableLen;HMACSupported;converterFunc;roundFunc;finalizeFunc;stateCloneFunc;newStateFunc;getMAC;constructor(e,t,n){let r=6,i=0;super(e,t,n);const a=n||{};if(1!==this.numRounds){if(a.kmacKey||a.hmacKey)throw new Error(Ae);if("CSHAKE128"===this.shaVariant||"CSHAKE256"===this.shaVariant)throw new Error("Cannot set numRounds for CSHAKE variants")}switch(this.bigEndianMod=1,this.converterFunc=be(this.inputFormat,this.utfType,this.bigEndianMod),this.roundFunc=St,this.stateCloneFunc=bt,this.newStateFunc=wt,this.intermediateState=wt(),this.isVariableLen=!1,e){case"SHA3-224":this.variantBlockSize=i=1152,this.outputBinLen=224,this.HMACSupported=!0,this.getMAC=this._getHMAC;break;case"SHA3-256":this.variantBlockSize=i=1088,this.outputBinLen=256,this.HMACSupported=!0,this.getMAC=this._getHMAC;break;case"SHA3-384":this.variantBlockSize=i=832,this.outputBinLen=384,this.HMACSupported=!0,this.getMAC=this._getHMAC;break;case"SHA3-512":this.variantBlockSize=i=576,this.outputBinLen=512,this.HMACSupported=!0,this.getMAC=this._getHMAC;break;case"SHAKE128":r=31,this.variantBlockSize=i=1344,this.outputBinLen=-1,this.isVariableLen=!0,this.HMACSupported=!1,this.getMAC=null;break;case"SHAKE256":r=31,this.variantBlockSize=i=1088,this.outputBinLen=-1,this.isVariableLen=!0,this.HMACSupported=!1,this.getMAC=null;break;case"KMAC128":r=4,this.variantBlockSize=i=1344,this._initializeKMAC(n),this.outputBinLen=-1,this.isVariableLen=!0,this.HMACSupported=!1,this.getMAC=this._getKMAC;break;case"KMAC256":r=4,this.variantBlockSize=i=1088,this._initializeKMAC(n),this.outputBinLen=-1,this.isVariableLen=!0,this.HMACSupported=!1,this.getMAC=this._getKMAC;break;case"CSHAKE128":this.variantBlockSize=i=1344,r=this._initializeCSHAKE(n),this.outputBinLen=-1,this.isVariableLen=!0,this.HMACSupported=!1,this.getMAC=null;break;case"CSHAKE256":this.variantBlockSize=i=1088,r=this._initializeCSHAKE(n),this.outputBinLen=-1,this.isVariableLen=!0,this.HMACSupported=!1,this.getMAC=null;break;default:throw new Error(Oe)}this.finalizeFunc=function(e,t,n,a,s){return function(e,t,n,r,i,a,s){let o,c,u=0;const d=[],l=i>>>5,h=t>>>5;for(o=0;o<h&&t>=i;o+=l)r=St(e.slice(o,o+l),r),t-=i;for(e=e.slice(o),t%=i;e.length<l;)e.push(0);for(o=t>>>3,e[o>>2]^=a<<o%4*8,e[l-1]^=2147483648,r=St(e,r);32*d.length<s&&(c=r[u%5][u/5|0],d.push(c.lowOrder),!(32*d.length>=s));)d.push(c.highOrder),u+=1,0==64*u%i&&(St(null,r),u=0);return d}(e,t,0,a,i,r,s)},a.hmacKey&&this._setHMACKey(Te("hmacKey",a.hmacKey,this.bigEndianMod))}_initializeCSHAKE(e,t){const n=function(e){const t=e||{};return{funcName:Te("funcName",t.funcName,1,{value:[],binLen:0}),customization:Te("Customization",t.customization,1,{value:[],binLen:0})}}(e||{});t&&(n.funcName=t);const r=Me(vt(n.funcName),vt(n.customization));if(0!==n.customization.binLen||0!==n.funcName.binLen){const e=Ut(r,this.variantBlockSize>>>3);for(let t=0;t<e.length;t+=this.variantBlockSize>>>5)this.intermediateState=this.roundFunc(e.slice(t,t+(this.variantBlockSize>>>5)),this.intermediateState),this.processedLen+=this.variantBlockSize;return 4}return 31}_initializeKMAC(e){const t=function(e){const t=e||{};return{kmacKey:Te("kmacKey",t.kmacKey,1),funcName:{value:[1128353099],binLen:32},customization:Te("Customization",t.customization,1,{value:[],binLen:0})}}(e||{});this._initializeCSHAKE(e,t.funcName);const n=Ut(vt(t.kmacKey),this.variantBlockSize>>>3);for(let r=0;r<n.length;r+=this.variantBlockSize>>>5)this.intermediateState=this.roundFunc(n.slice(r,r+(this.variantBlockSize>>>5)),this.intermediateState),this.processedLen+=this.variantBlockSize;this.macKeySet=!0}_getKMAC(e){const t=Me({value:this.remainder.slice(),binLen:this.remainderLen},function(e){let t,n,r=0;const i=[0,0],a=[4294967295&e,e/Ce&2097151];for(t=6;t>=0;t--)n=a[t>>2]>>>8*t&255,0===n&&0===r||(i[r>>2]|=n<<8*r,r+=1);return r=0!==r?r:1,i[r>>2]|=r<<8*r,{value:r+1>4?i:[i[0]],binLen:8+8*r}}(e.outputLen));return this.finalizeFunc(t.value,t.binLen,this.processedLen,this.stateCloneFunc(this.intermediateState),e.outputLen)}},Ot=class{shaObj;constructor(e,t,n){if("SHA-1"===e)this.shaObj=new $e(e,t,n);else if("SHA-224"===e||"SHA-256"===e)this.shaObj=new Ge(e,t,n);else if("SHA-384"===e||"SHA-512"===e)this.shaObj=new mt(e,t,n);else{if("SHA3-224"!==e&&"SHA3-256"!==e&&"SHA3-384"!==e&&"SHA3-512"!==e&&"SHAKE128"!==e&&"SHAKE256"!==e&&"CSHAKE128"!==e&&"CSHAKE256"!==e&&"KMAC128"!==e&&"KMAC256"!==e)throw new Error(Oe);this.shaObj=new Et(e,t,n)}}update(e){return this.shaObj.update(e),this}getHash(e,t){return this.shaObj.getHash(e,t)}setHMACKey(e,t,n){this.shaObj.setHMACKey(e,t,n)}getHMAC(e,t){return this.shaObj.getHMAC(e,t)}},At=class{static generate(e,t){const n={digits:6,algorithm:"SHA-1",period:30,timestamp:Date.now(),...t},r=Math.floor(n.timestamp/1e3),i=this.leftpad(this.dec2hex(Math.floor(r/n.period)),16,"0"),a=new Ot(n.algorithm,"HEX");a.setHMACKey(this.base32tohex(e),"HEX"),a.update(i);const s=a.getHMAC("HEX"),o=this.hex2dec(s.substring(s.length-1));let c=(this.hex2dec(s.slice(2*o,2*o+8))&this.hex2dec("7fffffff"))+"";const u=Math.max(c.length-n.digits,0);c=c.substring(u,u+n.digits);return{otp:c,expires:Math.ceil((n.timestamp+1)/(1e3*n.period))*n.period*1e3}}static hex2dec(e){return parseInt(e,16)}static dec2hex(e){return(e<15.5?"0":"")+Math.round(e).toString(16)}static base32tohex(e){let t="",n="";const r=e.endsWith("=")?e.slice(0,e.lastIndexOf("=")):e;for(let i=0;i<r.length;i++){const n="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567".indexOf(e.charAt(i).toUpperCase());if(-1===n)throw new Error("Invalid base32 character in key");t+=this.leftpad(n.toString(2),5,"0")}for(let i=0;i+8<=t.length;i+=8){const e=t.slice(i,i+8);n+=this.leftpad(parseInt(e,2).toString(16),2,"0")}return n}static leftpad(e,t,n){return t+1>=e.length&&(e=Array(t+1-e.length).join(n)+e),e}};function Mt(e){if(!Array.isArray(e))throw new TypeError("Middleware stack must be an array!");for(const t of e)if("function"!=typeof t)throw new TypeError("Middleware must be composed of functions!");return function(t,n){let r=-1;return function i(a){if(a<=r)return Promise.reject(/* @__PURE__ */new Error("next() called multiple times"));r=a;let s=e[a];a===e.length&&n&&(s=n);if(!s)return Promise.resolve();try{return Promise.resolve(s(t,i.bind(null,a+1)))}catch(o){return Promise.reject(o)}}(0)}}var kt=["log","info","warn","error","assert"],Tt=(e=J)=>{if("undefined"==typeof console)return J;const t=kt.map(t=>ne(console,t,n=>{if("function"!=typeof n)return;const r=n;return function(...n){e(t,...n),r.apply(console,n)}}));return()=>t.forEach(e=>e())},Bt=(e,t=500)=>{let n,r=null,i=null;const a=()=>{if(r=null,!i)return;const t=i,a=n;i=null,n=void 0,e.apply(a,t)},s=function(...e){n=this,i=e,null!==r&&clearTimeout(r),r=setTimeout(a,t)};return s.cancel=()=>{null!==r&&clearTimeout(r),r=null,i=null,n=void 0},s.flush=()=>{null!==r&&(clearTimeout(r),a())},s.pending=()=>null!==r,s},Lt=(e,t)=>{if("undefined"==typeof document)return;const n=e.classList;n.contains(t)||n.add(t)},Ft=(e,t)=>{if("undefined"==typeof document)return;const n=e.classList;n.contains(t)&&n.remove(t)},Pt=e=>{if("undefined"==typeof document)return;const t=document.createDocumentFragment();return e.forEach(e=>t.appendChild(e)),t},Rt=/["'&<>]/;function Ht(e){const t=""+e,n=Rt.exec(t);if(!n)return t;let r,i="",a=0,s=0;for(a=n.index;a<t.length;a++){switch(t.charCodeAt(a)){case 34:r=""";break;case 38:r="&";break;case 39:r="'";break;case 60:r="<";break;case 62:r=">";break;default:continue}s!==a&&(i+=t.substring(s,a)),s=a+1,i+=r}return s!==a?i+t.substring(s,a):i}var Dt=(e=375)=>{let t=e;const{documentElement:n}=document,r=window.matchMedia("(orientation: portrait)");let i,a=667/375;function s(){const e=!r.matches;let i=window.screen.width,s=window.screen.height;i<s&&([i,s]=[s,i]);let o=n.clientWidth,c=s;o/c>=a?(o=c*a,n.classList.remove("adjustHeight"),n.classList.add("adjustWidth")):(c=o/a,n.classList.remove("adjustWidth"),n.classList.add("adjustHeight"));let u=o/t*16;e&&(u/=a),n.style.fontSize=`${u}px`;const d=window.getComputedStyle(n).fontSize.replace("px","")||0;u!==d&&(n.style.fontSize=u/Number(d)*u+"px")}o()===c.IPAD&&(a=1024/768,t=768),window.addEventListener("resize",function(){clearTimeout(i),i=setTimeout(s,300)},!1),window.addEventListener("pageshow",function(e){e.persisted&&(clearTimeout(i),i=setTimeout(s,300))},!1),window.addEventListener("orientationchange",function(){s()},!1),s()},It=e=>{const t=e.style.height,n=e=>{const t=parseFloat(e);return Number.isFinite(t)?t:0},r=()=>{e.style.height="auto";const t=getComputedStyle(e),r="border-box"===t.boxSizing?n(t.borderTopWidth)+n(t.borderBottomWidth):-(n(t.paddingTop)+n(t.paddingBottom));e.style.height=`${e.scrollHeight+r}px`};return e.addEventListener("input",r),r(),()=>{e.removeEventListener("input",r),e.style.height=t}},xt=(e=J)=>{if("undefined"==typeof window)return J;const t=t=>e(t),n=t=>e(t);return window.addEventListener("unhandledrejection",t,!0),window.addEventListener("error",n,!0),()=>{window.removeEventListener("unhandledrejection",t,!0),window.removeEventListener("error",n,!0)}},jt=class{ac;constructor(){this.ac=new AbortController}get signal(){return this.ac.signal}on(e,t,n,r){return e.addEventListener(t,n,{...r,signal:this.ac.signal}),this}delegate(e,t,n,r,i){return e.addEventListener(n,n=>{const i=n.target?.closest(t);i&&e.contains(i)&&r(n,i)},{...i,signal:this.ac.signal}),this}abort(){this.ac.abort(),this.ac=new AbortController}};function Nt(e={}){const{windowMs:t=300,maxDistancePx:n=60}=e;let r=-1/0,i=0,a=0;const s=()=>{r=-1/0,i=0,a=0};return{check:(e,o,c=Date.now())=>c-r<t&&Math.hypot(e-i,o-a)<n?(s(),!0):(r=c,i=e,a=o,!1),reset:s}}var zt={easeIn:function(e,t,n,r){return e>=r&&(e=r),n*(e/=r)*e+t},easeOut:function(e,t,n,r){return e>=r&&(e=r),-n*(e/=r)*(e-2)+t}},Kt={easeIn:function(e,t,n,r){return e>=r&&(e=r),n*(e/=r)*e*e+t},easeOut:function(e,t,n,r){return e>=r&&(e=r),n*((e=e/r-1)*e*e+1)+t}},Wt={easeIn:function(e,t,n,r){return e>=r&&(e=r),n*(e/=r)*e*e*e+t},easeOut:function(e,t,n,r){return e>=r&&(e=r),-n*((e=e/r-1)*e*e*e-1)+t}},_t={easeIn:function(e,t,n,r){return e>=r&&(e=r),n*(e/=r)*e*e*e*e+t},easeOut:function(e,t,n,r){return e>=r&&(e=r),n*((e=e/r-1)*e*e*e*e+1)+t}},qt={easeIn:function(e,t,n,r){return e>=r&&(e=r),-n*Math.cos(e/r*(Math.PI/2))+n+t},easeOut:function(e,t,n,r){return e>=r&&(e=r),n*Math.sin(e/r*(Math.PI/2))+t}},Vt={easeIn:function(e,t,n,r){return e>=r&&(e=r),0===e?t:n*Math.pow(2,10*(e/r-1))+t},easeOut:function(e,t,n,r){return e>=r&&(e=r),e===r?t+n:n*(1-Math.pow(2,-10*e/r))+t}},$t={easeIn:function(e,t,n,r){return e>=r&&(e=r),-n*(Math.sqrt(1-(e/=r)*e)-1)+t},easeOut:function(e,t,n,r){return e>=r&&(e=r),n*Math.sqrt(1-(e=e/r-1)*e)+t}},Xt=e=>t*e,Yt=(e,t)=>[+(Math.cos(e)*t).toFixed(8),+(Math.sin(e)*t).toFixed(8)],Gt=(e,t)=>{const n=-e/t;return[n,-n*e+t]},Jt=(e,t,n,r,i)=>{e.beginPath();const a=Xt(90/Math.PI/t*i),s=n+a,o=r-a;e.arc(0,0,t,s,o,!1),e.lineTo(...Yt((n+r)/2,i/2/Math.abs(Math.sin((n-r)/2)))),e.closePath()},Qt=(e,...[t,n,r,i,a])=>{const s=Math.min(r,i),o=Math.PI;a>s/2&&(a=s/2),e.beginPath(),e.moveTo(t+a,n),e.lineTo(t+a,n),e.lineTo(t+r-a,n),e.arc(t+r-a,n+a,a,-o/2,0),e.lineTo(t+r,n+i-a),e.arc(t+r-a,n+i-a,a,0,o/2),e.lineTo(t+a,n+i),e.arc(t+a,n+i-a,a,o/2,o),e.lineTo(t,n+a),e.arc(t+a,n+a,a,o,-o/2),e.closePath()},Zt=(e,t,n,r,i,a)=>{const s=/linear-gradient\((.+)\)/.exec(a)[1].split(",").map(e=>e.trim());let o=s.shift(),c=[0,0,0,0];if(o.includes("deg")){const e=Number(o.slice(0,-3))%360;o=`${e}`;const a=e=>Math.tan(e/180*Math.PI);e>=0&&e<45?c=[t,n+i,t+r,n+i-r*a(e-0)]:e>=45&&e<90?c=[t,n+i,t+r-i*a(e-45),n]:e>=90&&e<135?c=[t+r,n+i,t+r-i*a(e-90),n]:e>=135&&e<180?c=[t+r,n+i,t,n+r*a(e-135)]:e>=180&&e<225?c=[t+r,n,t,n+r*a(e-180)]:e>=225&&e<270?c=[t+r,n,t+i*a(e-225),n+i]:e>=270&&e<315?c=[t,n,t+i*a(e-270),n+i]:e>=315&&e<360&&(c=[t,n,t+r,n+i-r*a(e-315)])}else o.includes("top")?c=[t,n+i,t,n]:o.includes("bottom")?c=[t,n,t,n+i]:o.includes("left")?c=[t+r,n,t,n]:o.includes("right")&&(c=[t,n,t+r,n]);const u=e.createLinearGradient(...c.map(e=>e|0));return s.reduce((e,t,n)=>{const r=t.split(" ");return 1===r.length?e.addColorStop(n,r[0]):2===r.length&&e.addColorStop(Number(r[1]),r[0]),e},u)},en=e=>new Promise((t,n)=>{const r=new Image;r.onload=()=>t(r),r.onerror=e=>n(e),r.src=e}),tn=(e,t)=>{const n=document.createElement("canvas"),r=n.getContext("2d"),{width:i,height:a}=e;return n.width=i,n.height=a,Qt(r,0,0,i,a,t),r.clip(),r.drawImage(e,0,0,i,a),n},nn=(e,t)=>{const n=document.createElement("canvas"),r=n.getContext("2d"),{width:i,height:a}=e;if(n.width=i,n.height=a,"string"==typeof r.filter)r.filter=`opacity(${100*t}%)`,r.drawImage(e,0,0,i,a);else{r.drawImage(e,0,0,i,a);const n=r.getImageData(0,0,i,a),{data:s}=n,o=s.length;for(let e=0;e<o;e+=4){const n=s[e+3];0!==n&&(s[e+3]=n*t)}r.putImageData(n,0,0)}return n},rn=(e,t)=>{t=t||e/3;const n=Math.ceil(e),r=t*t,i=2*r,a=1/(2*Math.PI*r),s=[];let o=0;for(let c=-n;c<=n;c++)for(let e=-n;e<=n;e++){const t=a*Math.exp(-(c*c+e*e)/i);s.push(t),o+=t}for(let c=0;c<s.length;c++)s[c]/=o;return s},an=(e,t,n)=>new Promise((r,i)=>{if("undefined"==typeof window)return void i(/* @__PURE__ */new Error("isImageSize is browser-only: window is undefined"));const a=window.URL||window.webkitURL,s=new Image,o=a.createObjectURL(e),c=()=>a.revokeObjectURL(o);s.onload=()=>{c();const e=void 0===t||s.width===t,i=void 0===n||s.height===n;r(e&&i)},s.onerror=()=>{c(),i(/* @__PURE__ */new Error("failed to decode image"))},s.src=o}),sn=e=>new Promise((t,n)=>{const r=new FileReader;r.onload=function(){t({success:!0,data:r.result,message:""})},r.onerror=e=>{n({success:!1,data:e,message:""})},r.readAsDataURL(e)}),on=/* @__PURE__ */new Map,cn=/* @__PURE__ */new Map,un="data-adopted-style",dn="data-adopted-sheet",ln=(e,t,n)=>{if("undefined"==typeof CSSStyleSheet)return!1;try{if(!n.has(t)){const e=new CSSStyleSheet;e.replaceSync(t),n.set(t,e)}const r=n.get(t);return e.adoptedStyleSheets.includes(r)||(e.adoptedStyleSheets=[...e.adoptedStyleSheets,r]),!0}catch{return!1}},hn=(e,t,n=un)=>{if("undefined"!=typeof document&&t&&!ln(e,t,on)&&!e.querySelector(`style[${n}]`)){const r=document.createElement("style");r.setAttribute(n,""),r.textContent=t,e.appendChild(r)}},pn=(e,t,n=dn)=>{if("undefined"!=typeof document&&t&&!ln(e,t,cn)&&!Array.from(e.querySelectorAll(`style[${n}]`)).some(e=>e.textContent===t)){const r=document.createElement("style");r.setAttribute(n,""),r.textContent=t,e.appendChild(r)}},fn=e=>({status:"success",code:0,data:e,error:!1}),mn=(e,t=null)=>({status:"error",code:1,data:t,error:!0,message:e}),gn=class{database;version;dbName;stores;upgrade;constructor({dbName:e,version:t,stores:n,upgrade:r}){this.dbName=e,this.version=t||1,this.stores=n||[],this.upgrade=r}openDataBase=()=>new Promise((e,t)=>{if("undefined"==typeof indexedDB)return void t(mn("indexedDB is not available"));const n=indexedDB.open(this.dbName,this.version);n.onsuccess=()=>{this.database=n.result,this.version=this.database.version,this.database.onversionchange=()=>{this.database?.close(),this.database=void 0},e(fn({db:this.database}))},n.onerror=()=>{if(n.error&&"VersionError"===n.error.name){const[,r]=(n.error.message||"").match(/\d+/g)||[];if(Number(r)>this.version)return this.version=Number(r),void this.refreshDatabase().then(e,t)}t(mn("open database error",n.error))},n.onupgradeneeded=e=>{const t=n.result;this.database=t,this.version=t.version;for(const r of this.stores){const e=t.objectStoreNames.contains(r.name)?n.transaction?.objectStore(r.name):t.createObjectStore(r.name,r.options);for(const t of r.indexes||[])e&&!e.indexNames.contains(t.name)&&e.createIndex(t.name,t.keyPath,t.options)}this.upgrade?.(t,e,n.transaction)}});closeDataBase=()=>{this.database?.close(),this.database=void 0};refreshDatabase=()=>(this.closeDataBase(),this.openDataBase());deleteDatabase=({dbName:e}={})=>new Promise((t,n)=>{const r=indexedDB.deleteDatabase(e??this.dbName);r.onsuccess=()=>t(fn(null)),r.onerror=()=>n(mn("delete database error",r.error))});getObjectStore=(e,t="readonly")=>{if(this.database)return this.database.transaction([e],t).objectStore(e)};run=(e,t,n,r,i)=>new Promise((a,s)=>{let o;try{const r=this.database?.transaction(e,t).objectStore(e);o=r&&n(r)}catch(u){return void s(mn(`${r} error`,u))}if(!o)return void s(mn(`${r} error`));const c=o;c.onsuccess=()=>a(fn(i(c))),c.onerror=()=>s(mn(`${r} error`,c.error))});add=({storeName:e,data:t})=>this.run(e,"readwrite",e=>e.add(t),"add",()=>t);update=({storeName:e,data:t})=>this.run(e,"readwrite",e=>e.put(t),"update",()=>null);readByKey=({storeName:e,key:t})=>this.run(e,"readonly",e=>e.get(t),"read",e=>e.result);readAll=({storeName:e,query:t,count:n})=>this.run(e,"readonly",e=>e.getAll(t,n),"read all",e=>e.result);count=({storeName:e,query:t})=>this.run(e,"readonly",e=>e.count(t),"count",e=>e.result);readByCursor=({storeName:e,keyRange:t,direction:n})=>new Promise((r,i)=>{const a=(this.database?.transaction(e,"readonly").objectStore(e))?.openCursor(t,n),s=[];a?(a.onsuccess=()=>{const e=a.result;e?(s.push(e.value),e.continue()):r(fn(s))},a.onerror=()=>i(mn("read cursor error",a.error))):i(mn("read cursor error"))});delete=({storeName:e,key:t})=>this.run(e,"readwrite",e=>e.delete(t),"delete",()=>null);clear=({storeName:e})=>this.run(e,"readwrite",e=>e.clear(),"clear",()=>null);collection=e=>{const t=(e,t)=>e.then(e=>e.data??t).catch(()=>t),n=e=>e.then(()=>!0).catch(()=>!1);return{name:e,get:t=>this.readByKey({storeName:e,key:t}).then(e=>e.data??null).catch(()=>null),all:()=>t(this.readByCursor({storeName:e}),[]),count:()=>t(this.count({storeName:e}),0),add:t=>n(this.add({storeName:e,data:t})),put:t=>n(this.update({storeName:e,data:t})),remove:t=>n(this.delete({storeName:e,key:t})),clear:()=>n(this.clear({storeName:e}))}}},yn=({dbName:e,storeName:t="files",key:n="pending"})=>{const r=()=>new Promise(n=>{if("undefined"==typeof indexedDB)return void n(null);let r;try{r=indexedDB.open(e,1)}catch{return void n(null)}r.onupgradeneeded=()=>{r.result.objectStoreNames.contains(t)||r.result.createObjectStore(t)},r.onerror=()=>n(null),r.onblocked=()=>n(null),r.onsuccess=()=>n(r.result)});return{put:async e=>{const i=await r();return!!i&&new Promise(r=>{try{const a=i.transaction(t,"readwrite");a.objectStore(t).put(e,n),a.oncomplete=()=>{i.close(),r(!0)},a.onerror=a.onabort=()=>{i.close(),r(!1)}}catch{i.close(),r(!1)}})},take:async()=>{const e=await r();return e?new Promise(r=>{try{const i=e.transaction(t,"readwrite"),a=i.objectStore(t),s=a.get(n);let o=null;s.onsuccess=()=>{o=s.result??null,null!==o&&a.delete(n)},i.oncomplete=()=>{e.close(),r(o)},i.onerror=i.onabort=()=>{e.close(),r(null)}}catch{e.close(),r(null)}}):null}}},wn=e=>{const t=Array.from({length:e.length});let n=0;for(let r=0;r<e.length;r++)t[r]=n,n+=e[r]||0;return t},bn=(e,t)=>{if(0===e.length)return 0;let n=0,r=e.length-1,i=0;for(;n<=r;){const a=n+r>>1;e[a]<=t?(i=a,n=a+1):r=a-1}return i},Sn=(e,t,n)=>{const r=t+e.length,i=n.map(e=>({value:e.value,s:Math.max(e.start,t)-t,e:Math.min(e.end,r)-t})).filter(e=>e.e>e.s).sort((e,t)=>e.s-t.s||e.e-t.e),a=[],s=(n,r,i)=>{a.push({text:e.slice(n,r),start:t+n,end:t+r,value:i})};let o=0;for(const c of i){let e=c.s;if(e<o){if(c.e<=o)continue;e=o}e>o&&s(o,e,null),s(e,c.e,c.value),o=c.e}return o<e.length&&s(o,e.length,null),0===a.length&&s(0,e.length,null),a},Cn=(()=>{const e=/* @__PURE__ */new Uint8Array(128);for(let t=0;t<78;t++)e["abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-.,!?;:'\"()[]{}".charCodeAt(t)]=1;return e})(),vn=e=>e<128&&1===Cn[e],Un={pages:[],charsPerLine:0,linesPerPage:0,charsPerPage:0},En=(e,t,n,r={})=>{const i=e.replace(/(?:\r\n|\r|\n)+/g,"\n")||"",a=i.length,s=r.minBox??30,{charWidth:o,lineHeight:c}=n,u=n.narrowRatio??.5625;if(t.width<s||t.height<s||o<=0||c<=0)return{...Un,total:a};const d=Math.floor(t.width/o),l=Math.floor(t.height/c),h=d*l;if(d<=0||l<=0)return{...Un,total:a};const p=e=>{let t=e,n=e;for(;t<a;){const e=i.charCodeAt(t);if(vn(e))t++;else{if(32===e){n=t,t++;break}t++}}return n},f=e=>{let t=e,n=e;for(;t>0;){const e=i.charCodeAt(t-1);if(vn(e))n=t-1,t--;else{if(32===e)break;t--}}return n},m=[];let g=0;for(;a>g;){let e=0,t=0;const n=g;let r=h;for(;e<l&&t<h&&g<a;){const n=i.charCodeAt(g);if(10===n||13===n){e++,t=0,g++,r--;continue}const a=vn(n);if(t>=d){if(a){const n=f(g);if(p(g)-n>d){e++,t=0;continue}}e++,t=0}else g++,t+=a?u:1,r--}if(g<a&&vn(i.charCodeAt(g))){const e=f(g);p(g)-e>r&&e>n&&(g=e)}if(g===n)break;m.push({text:i.slice(n,g),start:n,end:g,index:m.length})}return{pages:m,total:a,charsPerLine:d,linesPerPage:l,charsPerPage:h}},On=e=>{const t=e.search(/[?#]/);return-1===t?[e,""]:[e.slice(0,t),e.slice(t)]},An=e=>{const t=e.locales.length>0?e.locales:[{code:"en"}],n=(e=>{const t=e.trim().replace(/\/+$/,"");return t?t.startsWith("/")?t:`/${t}`:""})(e.base??""),r=e.defaultLocale??(t.find(e=>!e.prefix)??t[0]).code,i=t.filter(e=>e.prefix).sort((e,t)=>t.prefix.length-e.prefix.length),a=e=>{const t=e||"/";return n?t===n?"/":t.startsWith(`${n}/`)?t.slice(n.length):t.startsWith("/")?t:`/${t}`:t.startsWith("/")?t:`/${t}`},s=e=>{const t=e.split("/").filter(Boolean)[0],n=t?i.find(e=>e.prefix===t):void 0;if(!n)return{code:r,rest:e};const a=e.slice(n.prefix.length+1)||"/";return{code:n.code,rest:a.startsWith("/")?a:`/${a}`}},o=(e,i=r)=>{const[o,c]=On(e),{rest:u}=s(a(o)),{prefix:d}=(e=>t.find(t=>t.code===e)??{code:r})(i);return`${n}${d?`/${d}${u}`:u}${c}`||"/"};return{base:n,defaultLocale:r,localeFromPath:e=>s(a(On(e)[0])).code,stripLocale:e=>{const[t,r]=On(e);return`${n}${s(a(t)).rest}${r}`},href:o,hrefForLocale:(e,t)=>o(e,t),alternates:e=>t.map(t=>({code:t.code,href:o(e,t.code)}))}},Mn=e=>{const{anchor:t,floating:n,offset:r=0,padding:i=8}=e,a=e.boundary??{top:0,left:0,width:"undefined"!=typeof window?window.innerWidth:1/0,height:"undefined"!=typeof window?window.innerHeight:1/0};let s=e.placement;const o="top"===s||"bottom"===s,c=t.width>0&&t.height>0&&n.width>0&&n.height>0;if(c&&o){const e=a.top+a.height-(t.top+t.height),i=t.top-a.top;"bottom"===s&&e<n.height+r&&i>e?s="top":"top"===s&&i<n.height+r&&e>i&&(s="bottom")}else if(c){const e=a.left+a.width-(t.left+t.width),i=t.left-a.left;"right"===s&&e<n.width+r&&i>e?s="left":"left"===s&&i<n.width+r&&e>i&&(s="right")}let u,d;if("bottom"===s?(u=t.top+t.height+r,d=t.left):"top"===s?(u=t.top-n.height-r,d=t.left):"right"===s?(u=t.top,d=t.left+t.width+r):(u=t.top,d=t.left-n.width-r),c&&o){const e=a.left+i,t=a.left+a.width-n.width-i;t>=e&&(d=Math.min(Math.max(d,e),t))}else if(c){const e=a.top+i,t=a.top+a.height-n.height-i;t>=e&&(u=Math.min(Math.max(u,e),t))}return{top:u,left:d,placement:s}},kn=(e,t,n)=>new Promise((r,i)=>{if("undefined"==typeof FileReader)return void i(/* @__PURE__ */new Error("FileReader is not available"));const a=new FileReader;a.onload=()=>r(a.result),a.onerror=()=>i(a.error??/* @__PURE__ */new Error("read file error")),a.onabort=()=>i(/* @__PURE__ */new Error("read file aborted")),"arrayBuffer"===t?a.readAsArrayBuffer(e):"text"===t?a.readAsText(e,n):"dataURL"===t?a.readAsDataURL(e):a.readAsBinaryString(e)}),Tn=e=>kn(e,"arrayBuffer"),Bn=async e=>new Uint8Array(await Tn(e)),Ln=(e,t)=>kn(e,"text",t),Fn=e=>kn(e,"dataURL"),Pn=class{worker=null;nextOperationId=1;pending=/* @__PURE__ */new Map;options;constructor(e){this.options=e}get active(){return null!==this.worker}get pendingCount(){return this.pending.size}send=(e,t,n)=>{const r=this.nextOperationId++;return new Promise((i,a)=>{const s={resolve:i,reject:a,onProgress:t};this.options.timeout&&(s.timer=setTimeout(()=>{this.pending.delete(r),a(/* @__PURE__ */new Error(`worker request timed out after ${this.options.timeout}ms`))},this.options.timeout)),this.pending.set(r,s);try{this.getWorker().postMessage({...e,operationId:r},n??[])}catch(o){this.settle(r),a(o instanceof Error?o:new Error(String(o)))}})};dispose=()=>{this.worker?.terminate(),this.worker=null,this.rejectAll(/* @__PURE__ */new Error("worker disposed"))};getWorker=()=>(this.worker||(this.worker=this.options.create(),this.worker.onmessage=e=>this.handleMessage(e.data),this.worker.onerror=e=>this.rejectAll(new Error(e.message||"worker crashed"))),this.worker);settle=e=>{const t=this.pending.get(e);return t?.timer&&clearTimeout(t.timer),this.pending.delete(e),t};handleMessage=e=>{const t=this.pending.get(e.operationId);if(!t)return;const{isProgress:n,getProgress:r,isError:i,getErrorMessage:a}=this.options;if(n?n(e):"progress"===e.type){const n=r?r(e):e.progress;return void t.onProgress?.(n)}if(this.settle(e.operationId),i?i(e):"error"===e.type){const n=a?a(e):e.message;t.reject(new Error(n||"worker error"))}else t.resolve(e)};rejectAll=e=>{for(const[t,n]of this.pending)n.timer&&clearTimeout(n.timer),n.reject(e),this.pending.delete(t)}},Rn=(e,t={})=>{const n=t.scope??globalThis;if(!n||"function"!=typeof n.addEventListener)return()=>{};const r=t.resultType??"result",i=t=>{const i=t.data;if(!i||"number"!=typeof i.operationId)return;const{operationId:a}=i,s=e=>n.postMessage({...e,operationId:a}),o={progress:e=>s({type:"progress",progress:e})};Promise.resolve().then(()=>e(i,o)).then(e=>s("object"==typeof e&&null!==e?e:{type:r,result:e}),e=>s({type:"error",message:e instanceof Error?e.message:String(e)}))};return n.addEventListener("message",i),()=>n.removeEventListener("message",i)},Hn=()=>"undefined"!=typeof window,Dn=(e,t={})=>{const{timeout:n=8e3,fallbackDelay:r=2500}=t;if(!Hn())return()=>{};const i=window.requestIdleCallback;if(i){const t=i(e,{timeout:n});return()=>window.cancelIdleCallback?.(t)}const a=setTimeout(e,r);return()=>clearTimeout(a)},In=(e={})=>{const{optOutKey:t,slowTypes:n=["slow-2g","2g"]}=e;if(!Hn())return!1;if(t)try{if(localStorage.getItem(t))return!1}catch{}const r=navigator.connection;return!r?.saveData&&(!r?.effectiveType||!n.includes(r.effectiveType))},xn=async e=>{if("undefined"==typeof caches)return!1;try{return Boolean(await caches.match(e))}catch{return!1}},jn=async e=>{try{if(await xn(e))return;await fetch(e,{cache:"force-cache"})}catch{}},Nn=async(e,t={})=>{if(!(0===e.length||t.serviceWorkerMessage&&((e,t)=>{try{const n="undefined"!=typeof navigator&&"serviceWorker"in navigator?navigator.serviceWorker.controller:null;return!!n&&(n.postMessage({type:t,urls:e}),!0)}catch{return!1}})(e,t.serviceWorkerMessage)))for(const n of e)await jn(n)},zn=(e,t={})=>In(t)?Dn(()=>{Nn(e,t)},t):()=>{},Kn=()=>{let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}},Wn=class extends Error{constructor(e){super(e),this.name="TimeoutError"}},_n=(e,t,n={})=>{const{message:r=`operation timed out after ${t}ms`,onTimeout:i}=n;return new Promise((n,a)=>{const s=setTimeout(()=>{i?.(),a(new Wn(r))},t);e.then(e=>{clearTimeout(s),n(e)},e=>{clearTimeout(s),a(e)})})},qn=(e,t,n,r)=>new Promise((i,a)=>{const s=setTimeout(()=>{r?.(),i(n)},t);e.then(e=>{clearTimeout(s),i(e)},e=>{clearTimeout(s),a(e)})}),Vn=e=>new Promise(t=>setTimeout(t,e)),$n=()=>{let e=0;return{start:()=>++e,isCurrent:t=>t===e}},Xn=67324752,Yn=33639248,Gn=101010256,Jn=30,Qn=46,Zn=0,er=8,tr=(e,t)=>e[t]|e[t+1]<<8,nr=(e,t)=>(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0,rr=/* @__PURE__ */(()=>{const e=/* @__PURE__ */new Uint32Array(256);for(let t=0;t<256;t++){let n=t;for(let e=0;e<8;e++)n=1&n?3988292384^n>>>1:n>>>1;e[t]=n}return e})(),ir=e=>{let t=4294967295;for(let n=0;n<e.length;n++)t=(rr[255&(t^e[n])]??0)^t>>>8;return(4294967295^t)>>>0},ar=async e=>{if("undefined"==typeof DecompressionStream)throw new Error("DecompressionStream is not available in this runtime");const t=new DecompressionStream("deflate-raw"),n=t.writable.getWriter(),r=t.readable.getReader();n.write(e),n.close();const i=[];for(;;){const{done:e,value:t}=await r.read();if(e)break;t&&i.push(t)}return sr(i)},sr=e=>{let t=0;for(const i of e)t+=i.length;const n=new Uint8Array(t);let r=0;for(const i of e)n.set(i,r),r+=i.length;return n},or=e=>{const t=(e=>{const t=Math.max(0,e.length-65558);for(let n=e.length-22;n>=t;n--)if(nr(e,n)===Gn)return n;return-1})(e);if(-1===t)return[];const n=tr(e,t+10),r=[];let i=nr(e,t+16);for(let a=0;a<n&&!(i+Qn>e.length)&&nr(e,i)===Yn;a++){const t=tr(e,i+10),n=tr(e,i+12),a=tr(e,i+14),s=nr(e,i+16),o=nr(e,i+20),c=nr(e,i+24),u=tr(e,i+28),d=tr(e,i+30),l=tr(e,i+32),h=nr(e,i+42),p=e.slice(i+Qn,i+Qn+u),f=new TextDecoder("utf-8",{fatal:!1}).decode(p),m=h+Jn<=e.length,g=m?tr(e,h+26):0,y=m?tr(e,h+28):0,w=i;i+=Qn+u+d+l,r.push({name:f,compression:t,crc:s,compressedSize:o,uncompressedSize:c,modTime:n,modDate:a,directory:f.endsWith("/"),dataStart:h+Jn+g+y,nameBytes:p,localOffset:h,centralStart:w,centralEnd:i})}return r},cr=(e,t)=>or(e).some(e=>e.name===t),ur=async(e,t)=>{const n="string"==typeof t?or(e).find(e=>e.name===t):t;if(!n||n.directory)return null;if(n.dataStart+n.compressedSize>e.length)return null;const r=e.slice(n.dataStart,n.dataStart+n.compressedSize);if(0===n.compression)return r;if(8!==n.compression)return null;try{return await ar(r)}catch{return null}},dr=(e,t,n,r=0,i=0)=>{const a=new Uint8Array(Jn+e.length),s=new DataView(a.buffer);return s.setUint32(0,Xn,!0),s.setUint16(4,20,!0),s.setUint16(6,0,!0),s.setUint16(8,0,!0),s.setUint16(10,r,!0),s.setUint16(12,i,!0),s.setUint32(14,n,!0),s.setUint32(18,t,!0),s.setUint32(22,t,!0),s.setUint16(26,e.length,!0),a.set(e,Jn),a},lr=(e,t,n,r,i=0,a=0)=>{const s=new Uint8Array(Qn+e.length),o=new DataView(s.buffer);return o.setUint32(0,Yn,!0),o.setUint16(4,20,!0),o.setUint16(6,20,!0),o.setUint16(8,0,!0),o.setUint16(10,0,!0),o.setUint16(12,i,!0),o.setUint16(14,a,!0),o.setUint32(16,n,!0),o.setUint32(20,t,!0),o.setUint32(24,t,!0),o.setUint16(28,e.length,!0),o.setUint32(42,r,!0),s.set(e,Qn),s},hr=e=>"string"==typeof e?(new TextEncoder).encode(e):e,pr=async(e,t={})=>{const{filter:n,transform:r,inject:i}=t,a=or(e);if(0===a.length)return e;const s=/* @__PURE__ */new Map;if(r)for(const g of a)if(!g.directory&&(!n||n(g)))try{const t=await ur(e,g);if(!t)continue;const n=await r(t,g);if(null==n)continue;const i=hr(n);if(i.length===t.length&&i.every((e,n)=>e===t[n]))continue;s.set(g,i)}catch{}const o=(i??[]).map(({name:e,data:t})=>({nameBytes:(new TextEncoder).encode(e),data:hr(t)}));if(0===s.size&&0===o.length)return e;const c=[],u=[];let d=0;for(const g of a){u.push(d);const t=s.get(g);if(t){const e=dr(g.nameBytes,t.length,ir(t),g.modTime,g.modDate);c.push(e,t),d+=e.length+t.length;continue}const n=new Uint8Array(Jn+g.nameBytes.length),r=new DataView(n.buffer);r.setUint32(0,Xn,!0),r.setUint16(4,20,!0),r.setUint16(6,0,!0),r.setUint16(8,g.compression,!0),r.setUint16(10,g.modTime,!0),r.setUint16(12,g.modDate,!0),r.setUint32(14,g.crc,!0),r.setUint32(18,g.compressedSize,!0),r.setUint32(22,g.uncompressedSize,!0),r.setUint16(26,g.nameBytes.length,!0),n.set(g.nameBytes,Jn);const i=e.slice(g.dataStart,g.dataStart+g.compressedSize);c.push(n,i),d+=n.length+i.length}const l=[];for(const g of o){l.push(d);const e=dr(g.nameBytes,g.data.length,ir(g.data));c.push(e,g.data),d+=e.length+g.data.length}const h=d;for(let g=0;g<a.length;g++){const t=a[g],n=s.get(t);if(n){const e=lr(t.nameBytes,n.length,ir(n),u[g],t.modTime,t.modDate);c.push(e),d+=e.length;continue}const r=new Uint8Array(e.slice(t.centralStart,t.centralEnd)),i=new DataView(r.buffer);i.setUint16(8,-9&tr(r,8),!0),i.setUint32(42,u[g],!0),c.push(r),d+=r.length}for(let g=0;g<o.length;g++){const e=o[g],t=lr(e.nameBytes,e.data.length,ir(e.data),l[g]);c.push(t),d+=t.length}const p=a.length+o.length,f=new Uint8Array(22),m=new DataView(f.buffer);return m.setUint32(0,Gn,!0),m.setUint16(8,p,!0),m.setUint16(10,p,!0),m.setUint32(12,d-h,!0),m.setUint32(16,h,!0),c.push(f),sr(c)},fr=e=>{const t=[],n=[];let r=0;for(const o of e){const e=(new TextEncoder).encode(o.name),i=hr(o.data),a=ir(i),s=dr(e,i.length,a);n.push(lr(e,i.length,a,r)),t.push(s,i),r+=s.length+i.length}const i=r;for(const o of n)t.push(o),r+=o.length;const a=new Uint8Array(22),s=new DataView(a.buffer);return s.setUint32(0,Gn,!0),s.setUint16(8,e.length,!0),s.setUint16(10,e.length,!0),s.setUint32(12,r-i,!0),s.setUint32(16,i,!0),t.push(a),sr(t)};function mr(){if("undefined"!=typeof window){const[e]=performance.getEntriesByType("navigation"),[t={},n={}]=performance.getEntriesByType("paint"),{startTime:r}=t,{startTime:i}=n,{domainLookupEnd:a,domainLookupStart:s,connectEnd:o,connectStart:c,secureConnectionStart:u,loadEventStart:d,domInteractive:l,domContentLoadedEventEnd:h,duration:p,responseStart:f,requestStart:m,responseEnd:g,fetchStart:y,transferSize:w,encodedBodySize:b,redirectEnd:S,redirectStart:C,redirectCount:v}=e;return{dnsSearch:a-s,tcpConnect:o-c,sslConnect:o-u,request:f-m,response:g-f,parseDomTree:l-g,resource:d-h,domReady:h-y,interactive:l-y,complete:d-y,httpHead:w-b,redirect:v,redirectTime:S-C,duration:p,fp:r,fcp:i}}}var gr={},yr=e=>{"string"==typeof e?gr.url=e:Object.assign(gr,e)},wr=()=>gr.url??"",br=({url:e,type:t="application/json; charset=UTF-8",payload:n={}})=>{const r=e||wr();return!!r&&((({url:e="",type:t="application/json; charset=UTF-8",payload:n={}})=>{if("undefined"==typeof navigator||!navigator.sendBeacon||!e)return!1;const r=new Blob([JSON.stringify(n)],{type:t});return navigator.sendBeacon(e,r)})({url:r,type:t,payload:n})||(({url:e="",payload:t={}})=>{if("undefined"==typeof document||!e)return!1;const n=new Image;return n.width=1,n.height=1,n.src=`${e}?${Q(t)}`,!0})({url:r,payload:n}))};function Sr(e={}){if("undefined"==typeof window)return{};const{width:t,height:n}=d();return{id:s(),path:window.location.href,time:Date.now(),referrer:document.referrer,ratio:`${t}x${n}`,userAgent:window.navigator.userAgent,...gr.userIdCookie?{userId:u(gr.userIdCookie)}:{},...e}}var Cr=(e={})=>{if("undefined"==typeof window)return J;const{requestHook:t=J,responseHook:n=J,errorHook:r=J}=e;return ne(window,"fetch",e=>{if("function"!=typeof e)return;const i=e;return(e,a)=>(t(e,a),i.apply(window,[e,a]).then(t=>(n(e,a,t),t)).catch(t=>{throw r(e,t),t}))})},vr=(e={})=>{if("undefined"==typeof window||"undefined"==typeof XMLHttpRequest)return J;const t=XMLHttpRequest.prototype,{requestHook:n=J,responseHook:r=J,errorHook:i=J}=e,a=ne(t,"open",e=>{if("function"!=typeof e)return;const t=e;return function(...e){n(e),t.apply(this,e)}}),s=ne(t,"send",e=>{if("function"!=typeof e)return;const t=e;return function(...e){this.addEventListener("loadend",()=>r(this),{once:!0}),this.addEventListener("error",()=>i(this),{once:!0}),t.apply(this,e)}});return()=>{s(),a()}};function Ur(e,t=300){let n,r=0,i=null,a=null;const s=()=>{if(i=null,!a)return;const t=a,s=n;a=null,n=void 0,r=Date.now(),e.apply(s,t)},o=function(...e){const o=t-(Date.now()-r);n=this,a=e,o<=0?(null!==i&&(clearTimeout(i),i=null),s()):null===i&&(i=setTimeout(s,o))};return o.cancel=()=>{null!==i&&clearTimeout(i),i=null,a=null,n=void 0},o.pending=()=>null!==i,o}var Er={click:!0,error:!0,fetch:!0,xhr:!0,performance:!0,console:!1},Or=class{options;teardown=[];send=J;constructor(e){this.options=e,yr({url:e.url,userIdCookie:e.userIdCookie}),this.send=Ur(e=>br(e),e.throttleMs??300)}get running(){return this.teardown.length>0}start=()=>{if(this.running)return this.stop;const e={...Er,...this.options.channels};return e.performance&&this.reportPerformance(),e.click&&this.teardown.push(this.reportClick()),e.error&&this.teardown.push(this.reportError()),e.fetch&&this.teardown.push(this.reportFetch()),e.xhr&&this.teardown.push(this.reportXhr()),e.console&&this.teardown.push(this.reportConsole()),this.stop};stop=()=>{const e=this.teardown.splice(0,this.teardown.length);for(const t of e)t()};event=(e,t)=>({payload:{...Sr(),data:t,type:e}});log=e=>{this.send({payload:{...Sr(),...e}})};reportPerformance=()=>{br({payload:{...mr(),...Sr(),type:"performance"}})};reportClick=()=>((e=J)=>{if("undefined"==typeof document)return J;const t=t=>e(t);return document.addEventListener("click",t,!0),()=>document.removeEventListener("click",t,!0)})(e=>{const{pageX:t,pageY:n,screenX:r,screenY:i,type:a}=e;this.send(this.event("click",{pageX:t,pageY:n,screenX:r,screenY:i,type:a}))});reportError=()=>xt((...e)=>this.send(this.event("error",{...e})));reportFetch=()=>Cr({requestHook:(...e)=>this.send(this.event("fetchRequest",{...e})),responseHook:(...e)=>this.send(this.event("fetchResponse",{...e})),errorHook:(...e)=>this.send(this.event("fetchError",{...e}))});reportXhr=()=>vr({requestHook:(...e)=>this.send(this.event("xhrRequest",{...e})),responseHook:(...e)=>this.send(this.event("xhrResponse",{...e})),errorHook:(...e)=>this.send(this.event("xhrError",{...e}))});reportConsole=()=>Tt((...e)=>this.send(this.event("console",{...e})))},Ar=/* @__PURE__ */new Map([[100,"Continue"],[101,"Switching Protocols"],[102,"Processing"],[103,"Early Hints"],[200,"OK"],[201,"Created"],[202,"Accepted"],[203,"Non-Authoritative Information"],[204,"No Content"],[205,"Reset Content"],[206,"Partial Content"],[207,"Multi-Status"],[208,"Already Reported"],[226,"IM Used"],[300,"Multiple Choices"],[301,"Moved Permanently"],[302,"Found"],[303,"See Other"],[304,"Not Modified"],[305,"Use Proxy"],[307,"Temporary Redirect"],[308,"Permanent Redirect"],[400,"Bad Request"],[401,"Unauthorized"],[402,"Payment Required"],[403,"Forbidden"],[404,"Not Found"],[405,"Method Not Allowed"],[406,"Not Acceptable"],[407,"Proxy Authentication Required"],[408,"Request Timeout"],[409,"Conflict"],[410,"Gone"],[411,"Length Required"],[412,"Precondition Failed"],[413,"Payload Too Large"],[414,"URI Too Long"],[415,"Unsupported Media Type"],[416,"Range Not Satisfiable"],[417,"Expectation Failed"],[418,"I'm a Teapot"],[421,"Misdirected Request"],[422,"Unprocessable Entity"],[423,"Locked"],[424,"Failed Dependency"],[425,"Too Early"],[426,"Upgrade Required"],[428,"Precondition Required"],[429,"Too Many Requests"],[431,"Request Header Fields Too Large"],[451,"Unavailable For Legal Reasons"],[500,"Internal Server Error"],[501,"Not Implemented"],[502,"Bad Gateway"],[503,"Service Unavailable"],[504,"Gateway Timeout"],[505,"HTTP Version Not Supported"],[506,"Variant Also Negotiates"],[507,"Insufficient Storage"],[508,"Loop Detected"],[509,"Bandwidth Limit Exceeded"],[510,"Not Extended"],[511,"Network Authentication Required"]]),Mr={message:Ar,code:function(e){const t=/* @__PURE__ */new Map;for(const[n,r]of e)t.set(r.toLowerCase(),n);return t}(Ar),codes:function(e){const t=[];for(const[n,r]of e)t.push(n);return t}(Ar),redirect:{300:!0,301:!0,302:!0,303:!0,305:!0,307:!0,308:!0},empty:{204:!0,205:!0,304:!0},retry:{502:!0,503:!0,504:!0}};function kr(e){if(!Mr.message.has(e))throw new Error("invalid status code: "+e);return Mr.message.get(e)}function Tr(e){if("number"==typeof e)return kr(e);if("string"!=typeof e)throw new TypeError("code must be a number or string");const t=parseInt(e,10);return!isNaN(t)&&Mr.codes.includes(t)?kr(t):function(e){const t=e.toLowerCase();if(Mr.code.has(t),!Mr.code.has(t))throw new Error('invalid status message: "'+e+'"');return Mr.code.get(t)}(e)}var Br=class{running=0;executed=0;simultaneous;queue=[];idleWaiters=[];constructor({simultaneous:e=1}={}){this.simultaneous=Math.max(1,e)}get pending(){return this.queue.length}get idle(){return 0===this.queue.length&&0===this.running}add=e=>"function"!=typeof e?Promise.reject(/* @__PURE__ */new TypeError("QuestQueue.add expects a function")):new Promise((t,n)=>{this.queue.push({task:e,resolve:t,reject:n}),this.next()});allSettled=e=>Promise.allSettled(e.map(e=>this.add(e)));onIdle=()=>this.idle?Promise.resolve():new Promise(e=>this.idleWaiters.push(e));clear=()=>{const e=this.queue.splice(0,this.queue.length);for(const t of e)t.reject(/* @__PURE__ */new Error("QuestQueue cleared"));this.settleIdle()};next=()=>{for(;this.running<this.simultaneous&&this.queue.length>0;){const e=this.queue.shift();this.running++,Promise.resolve().then(e.task).then(e.resolve,e.reject).finally(()=>{this.running--,this.executed++,this.settleIdle(),this.next()})}};settleIdle=()=>{if(!this.idle)return;const e=this.idleWaiters.splice(0,this.idleWaiters.length);for(const t of e)t()}},Lr=/* @__PURE__ */new Set,Fr=({type:e,content:t})=>new Promise((n,r)=>{const a=i(`${e}:${t}`);if(Lr.has(a))return void n({success:!0});const s=document.createElement("script");if(s.onload=function(){Lr.add(a),n({success:!0})},s.onerror=function(e){r({success:!1,error:e})},"content"===e)return s.textContent=t,document.body.append(s),Lr.add(a),void n({success:!0});s.src=t,document.body.append(s)}),Pr=(e,t,n)=>{const r=(e=Array.isArray(e)?e:[e]).map(e=>{let n;if(e.toLowerCase().endsWith(".css")){const t=document.createElement("link");t.type="text/css",t.rel="stylesheet",t.href=e,n=t}else n=document.createElement("script"),n.type="text/javascript",n.src=e;const r=document.getElementsByTagName("body")[0];return(t||r).appendChild(n),new Promise(e=>{n.onload=()=>{e()}})});return new Promise(e=>{Promise.all(r).then(()=>{n&&n(),e()})})};export{hn as $,$ as $t,xn as A,Mt as At,Ln as B,re as Bt,cr as C,It as Ct,Vn as D,Dt,Kn as E,Ft as Et,Dn as F,se as Ft,wn as G,X as Gt,Mn as H,ne as Ht,Pn as I,ee as It,gn as J,N as Jt,bn as K,G as Kt,Rn as L,Z as Lt,jn as M,ge as Mt,Nn as N,me as Nt,_n as O,Bt as Ot,zn as P,fe as Pt,pn as Q,j as Qt,Tn as R,ae as Rt,pr as S,Lt as St,$n as T,Ht as Tt,An as U,J as Ut,Bn as V,Q as Vt,En as W,Y as Wt,dn as X,I as Xt,yn as Y,K as Yt,un as Z,W as Zt,ir as _,h as _n,_t,Mr as a,p as an,nn as at,or as b,m as bn,Nt as bt,Cr as c,k as cn,Yt as ct,wr as d,T as dn,Qt as dt,z as en,sn as et,br as f,f as fn,$t as ft,Zn as g,l as gn,Wt as gt,er as h,C as hn,zt as ht,Tr as i,F as in,an as it,In as j,At as jt,qn as k,Tt as kt,vr as l,A as ln,Zt as lt,mr as m,U as mn,Vt as mt,Pr as n,V as nn,en as nt,Or as o,g as on,Jt as ot,yr as p,b as pn,Kt as pt,Sn as q,D as qt,Br as r,P as rn,rn as rt,Ur as s,E as sn,Xt as st,Fr as t,q as tn,tn as tt,Sr as u,O as un,Gt as ut,fr as v,M as vn,qt as vt,Wn as w,Pt as wt,ur as x,xt,ar as y,B as yn,jt as yt,Fn as z,te as zt};
|
|
1
|
+
import{i as e,t}from"./enums-BAgbyGdH.js";import{Q as n,at as r,et as i,it as a,tt as o}from"./color-DPV7TsVU.js";import{A as s,O as c,_ as u,x as d}from"./i18n-Bq-f7htr.js";var l=(e="")=>{if(0===e.length)return 0;if(e.endsWith("%")){const t=Number(e.replace("%",""));return t>1?t/100:t}return Number(e)},h=(e,t=0,n=1)=>Math.min(n,Math.max(t,e)),p=class e{getDecimalLength=e=>{const[t,n]=e.toString().split(".");return n?n.length:0};amend=(e,t=15)=>parseFloat(Number(e).toPrecision(t));power=(e,t)=>Math.pow(10,Math.max(this.getDecimalLength(e),this.getDecimalLength(t)));static handleMethod=(t,n)=>{const{power:r,amend:i}=new e,a=r(t,n),o=i(t*a),s=i(n*a);return e=>{switch(e){case"+":return(o+s)/a;case"-":return(o-s)/a;case"*":return o*s/(a*a);case"/":return o/s}}};static add=(e,t)=>this.handleMethod(e,t)("+");static divide=(e,t)=>this.handleMethod(e,t)("/");static multiply=(e,t)=>this.handleMethod(e,t)("*");static subtract=(e,t)=>this.handleMethod(e,t)("-")};function f(e,t,n){function r(e){const[t,n]=e.toString().split(".");return n?n.length:0}const i=(e,t=15)=>parseFloat(Number(e).toPrecision(t)),a=Math.pow(10,Math.max(r(e),r(n)));let o=0;switch(e=i(e*a),n=i(n*a),t){case"+":o=(e+n)/a;break;case"-":o=(e-n)/a;break;case"*":o=e*n/(a*a);break;case"/":o=e/n}return o=i(o),{result:o,next:(e,t)=>f(o,e,t)}}var m=(e,t="zh-CN",n=2,r=2)=>{let i=["","K","M","B","T"],a=3;if("zh-CN"===t&&(i=[""," 万"," 亿"," 万亿"],a=4),"zh-HK"===t&&(i=[""," 萬"," 億"," 萬億"],a=4),!/^[+-]?\d+(?:\.\d+)?$/.test(e))return"--";const o=parseInt(e).toString().length,s=Math.min(Math.floor((o-1)/a),i.length-1),c=p.divide(Number(e),10**(s*a))?.toFixed(n);return Number(c).toFixed(r)+i[s]},g=(e,t)=>r(e).startsWith("+")||r(e).startsWith("-")?r(e):t?Number(t||0)>0?`+${r(e)}`:r(e):Number(e||0)>0?`+${r(e)}`:r(e),y={"零":0,"〇":0,"一":1,"二":2,"两":2,"三":3,"四":4,"五":5,"六":6,"七":7,"八":8,"九":9},w={"十":10,"百":100,"千":1e3},b=e=>{const t=a(e.trim());if(/^\d+$/.test(t))return Number.parseInt(t,10);if(0===t.length)return null;let n=0,r=0,i=0;for(const a of t)if(void 0!==y[a])i=y[a];else if(void 0!==w[a])r+=(i||("十"===a?1:0))*w[a],i=0;else{if("万"!==a&&"萬"!==a)return null;n=1e4*(n+r+i),r=0,i=0}return n+r+i},S={I:1,V:5,X:10,L:50,C:100,D:500,M:1e3},C=e=>{const t=e.trim().toUpperCase();if(!/^[IVXLCDM]+$/.test(t))return null;let n=0;for(let r=0;r<t.length;r++){const e=S[t[r]],i=S[t[r+1]];i&&e<i?n-=e:n+=e}return n},v={one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12,thirteen:13,fourteen:14,fifteen:15,sixteen:16,seventeen:17,eighteen:18,nineteen:19,twenty:20},U=e=>{const t=e.trim().toLowerCase();return/^\d+$/.test(t)?Number.parseInt(t,10):void 0!==v[t]?v[t]:C(t)},E=(e,t,n)=>Math.min(n,Math.max(t,e)),O=(e,t,n)=>e+(t-e)*n,A=(e,t,n)=>e===t?0:(n-e)/(t-e),M=(e,t,n,r,i)=>r+(e-t)*(i-r)/(n-t),k=(e,t,n,r,i)=>E(M(e,t,n,r,i),Math.min(r,i),Math.max(r,i)),T=(e,t,n)=>e===t?n<e?0:1:E((n-e)/(t-e),0,1),B=(e,t,n)=>{const r=T(e,t,n);return r*r*(3-2*r)},L=()=>{if("undefined"==typeof window)return;const e=window;return e.SpeechRecognition??e.webkitSpeechRecognition},F=()=>void 0!==L(),R=(e={})=>{const{lang:t,continuous:n=!0,interimResults:r=!0,onResult:i,onError:a,onStart:o,onEnd:s}=e;let c=null;const u=()=>{c=null,s?.()},d={get supported(){return void 0!==L()},get active(){return null!==c},start(){const e=L();if(e&&!c)try{const s=new e;s.lang="function"==typeof t?t():t??"",s.continuous=n,s.interimResults=r,s.maxAlternatives=1;let d="",l=0;s.onresult=e=>{const t=e.results,n=Math.min(e.resultIndex??0,t.length);for(n<l&&(l=0,d="");l<n;l++)d+=t[l]?.[0]?.transcript??"";let r="",a=!0;for(let i=l;i<t.length;i++){const e=t[i];r+=e?.[0]?.transcript??"",!1===e?.isFinal&&(a=!1)}i?.(d+r,a)},s.onerror=e=>{return a?.({kind:(t=e.error,"not-allowed"===t||"service-not-allowed"===t?"denied":"no-speech"===t?"noSpeech":"aborted"===t?"aborted":"failed"),detail:e.error});var t},s.onstart=()=>o?.(),s.onend=u,c=s,s.start()}catch(d){c=null,a?.({kind:"failed",detail:d instanceof Error?d.message:String(d)}),s?.()}},stop(){c?.stop()},abort(){c?.abort()},toggle(){c?d.stop():d.start()}};return d},P=e=>"function"==typeof e,D=12e4,x="__ranuts_bridge__",H="default",I=new class{bridges=/* @__PURE__ */new Set;attachedWindow=null;handleMessage=e=>{for(const t of Array.from(this.bridges))t.receive(e)};add(e){this.bridges.add(e),"undefined"!=typeof window&&this.attachedWindow!==window&&(window.addEventListener("message",this.handleMessage),this.attachedWindow=window)}remove(e){this.bridges.delete(e),0===this.bridges.size&&this.attachedWindow&&(this.attachedWindow.removeEventListener("message",this.handleMessage),this.attachedWindow=null)}},j=class{targetWindow;targetOrigin;messageHandlers;pendingRequests;channel;senderId;available;constructor(e,t="*",r=H){this.targetOrigin=t,this.channel=r,this.senderId=n(12),this.messageHandlers=/* @__PURE__ */new Map,this.pendingRequests=/* @__PURE__ */new Map,this.available="undefined"!=typeof window,this.available?(this.targetWindow=e??window,I.add(this)):this.targetWindow=void 0}post(e,t){const n={...t,__bridge:x,channel:this.channel,senderId:this.senderId};e.postMessage(n,this.targetOrigin)}receive=e=>{if(!this.available)return;if("*"!==this.targetOrigin&&e.origin!==this.targetOrigin)return;if(e.source&&e.source!==this.targetWindow)return;const t=e.data;if(!t||"object"!=typeof t||"__ranuts_bridge__"!==t.__bridge)return;if((t.channel??"default")!==this.channel)return;const{type:n,payload:r,id:i,isResponse:a,isError:o,senderId:s}=t;if(a&&i){const e=this.pendingRequests.get(i);return void(e&&(o?e.reject(new Error("string"==typeof r?r:"Bridge request failed")):e.resolve(r),this.pendingRequests.delete(i)))}if(s&&s===this.senderId)return;if("string"!=typeof n||!this.messageHandlers.has(n))return;const c=this.messageHandlers.get(n);if(P(c)){const t=e.source??this.targetWindow;Promise.resolve(c(r)).then(e=>{i&&this.post(t,{type:n,payload:e,id:i,isResponse:!0})}).catch(e=>{i&&this.post(t,{type:n,payload:e instanceof Error?e.message:String(e),id:i,isResponse:!0,isError:!0})})}};on=(e,t)=>{this.messageHandlers.set(e,t)};off=e=>{this.messageHandlers.delete(e)};send=async(e,t)=>{if(!this.available)return Promise.reject(/* @__PURE__ */new Error("PostMessageBridge is unavailable outside a browser environment"));const r=n(10);return new Promise((n,i)=>{const a=setTimeout(()=>{this.pendingRequests.has(r)&&(this.pendingRequests.delete(r),i(/* @__PURE__ */new Error("Request timeout")))},D),o=e=>{clearTimeout(a),i(e)};this.pendingRequests.set(r,{resolve:e=>{clearTimeout(a),n(e)},reject:o});try{this.post(this.targetWindow,{type:e,payload:t,id:r})}catch(s){this.pendingRequests.delete(r),o(s instanceof Error?s:/* @__PURE__ */new Error("Failed to post message"))}})};broadcast=e=>{if(this.available)try{this.post(this.targetWindow,{type:e.type,payload:e.payload})}catch{}};destroy=()=>{I.remove(this),this.messageHandlers.clear(),this.pendingRequests.forEach(e=>{e.reject(/* @__PURE__ */new Error("Bridge destroyed"))}),this.pendingRequests.clear()}},N=class e{static instance;bridges=/* @__PURE__ */new Map;constructor(){}static getInstance(){return e.instance||(e.instance=new e),e.instance}connectClient=({id:e,targetOrigin:t,targetWindow:r,channel:i})=>{const a=new j(r,t,i);if(e||(e=n(10)),this.bridges.has(e))throw new Error(`Bridge ${e} already exists`);return this.bridges.set(e,a),{bridge:a,id:e}};getClient=e=>this.bridges.get(e);removeClient=e=>{const t=this.bridges.get(e);t&&(t.destroy(),this.bridges.delete(e))};removeAllClient=()=>{this.bridges.forEach(e=>{e.destroy()}),this.bridges.clear()};broadcast=e=>{this.bridges.forEach(t=>{t.broadcast(e)})};sendTo=(e,t,n)=>{const r=this.getClient(e);return r?r.send(t,n):Promise.reject(/* @__PURE__ */new Error(`Bridge ${e} not found`))}},z=N.getInstance(),K={connect:({id:e,targetWindow:t,targetOrigin:n,channel:r})=>z.connectClient({id:e,targetWindow:t,targetOrigin:n,channel:r}),remove:e=>{e&&z.removeClient(e)},removeAll:()=>{z.removeAllClient()},broadcast:e=>z.broadcast(e),call:({id:e,type:t,payload:n})=>z.sendTo(e,t,n),broadcastToAll:e=>{if("undefined"==typeof window)return;const t={__bridge:x,channel:H,type:e.type,payload:e.payload};return window.postMessage(t,"*")}},W={init:e=>{const t=new Map(Object.entries(e).filter(e=>P(e[1]))),n=async e=>{const n=e.data;if(!n||"object"!=typeof n||"__ranuts_bridge__"!==n.__bridge)return;const{type:r,payload:i,id:a}=n,o=n.channel??"default";if("string"!=typeof r||!t.has(r))return;const s=t.get(r);if(!s)return;const c=t=>{a&&e.source?.postMessage({__bridge:x,channel:o,type:r,id:a,isResponse:!0,...t},{targetOrigin:e.origin})};try{c({payload:await s(i)})}catch(u){c({payload:u instanceof Error?u.message:String(u),isError:!0})}};window.removeEventListener("message",n),window.addEventListener("message",n);return{destroy:()=>{window.removeEventListener("message",n)}}}},_="__ranuts_port_init__",q=e=>{const t=/* @__PURE__ */new Map,r=/* @__PURE__ */new Map,i=n=>{const i=n.data;if(!i||"object"!=typeof i||"string"!=typeof i.type)return;const{type:a,payload:o,id:s,isResponse:c,isError:u}=i;if(c&&s){const e=r.get(s);return void(e&&(u?e.reject(new Error("string"==typeof o?o:"Bridge request failed")):e.resolve(o),r.delete(s)))}if(!t.has(a))return;const d=t.get(a);P(d)&&Promise.resolve(d(o)).then(t=>{s&&e.postMessage({type:a,payload:t,id:s,isResponse:!0})}).catch(t=>{s&&e.postMessage({type:a,payload:t instanceof Error?t.message:String(t),id:s,isResponse:!0,isError:!0})})};return e.addEventListener("message",i),e.start(),{on:(e,n)=>{t.set(e,n)},off:e=>{t.delete(e)},send:(t,i)=>{const a=n(10);return new Promise((n,o)=>{const s=setTimeout(()=>{r.has(a)&&(r.delete(a),o(/* @__PURE__ */new Error("Request timeout")))},D),c=e=>{clearTimeout(s),o(e)};r.set(a,{resolve:e=>{clearTimeout(s),n(e)},reject:c});try{e.postMessage({type:t,payload:i,id:a})}catch(u){r.delete(a),c(u instanceof Error?u:/* @__PURE__ */new Error("Failed to post message"))}})},broadcast:t=>{try{e.postMessage({type:t.type,payload:t.payload})}catch{}},destroy:()=>{e.removeEventListener("message",i),t.clear(),r.forEach(e=>e.reject(/* @__PURE__ */new Error("Bridge destroyed"))),r.clear(),e.close()}}},V=({targetWindow:e,targetOrigin:t="*",name:n="default"})=>{const r=new MessageChannel;return e.postMessage({[_]:!0,name:n},t,[r.port2]),q(r.port1)},$=({targetOrigin:e="*",name:t="default"}={})=>"undefined"==typeof window?Promise.reject(/* @__PURE__ */new Error("acceptPortBridge is unavailable outside a browser environment")):new Promise(n=>{const r=i=>{if("*"!==e&&i.origin!==e)return;const a=i.data;if(!a||"object"!=typeof a||!0!==a[_]||a.name!==t)return;const o=i.ports?.[0];o&&(window.removeEventListener("message",r),n(q(o)))};window.addEventListener("message",r)}),X=e=>{let t,n=!1,r=e;return(...e)=>(n||(t="function"==typeof r?r(...e):r,n=!0,r=void 0),t)},Y=X,G=e=>{let t=null;const n=()=>(t??=e().catch(e=>{throw t=null,e}),t);return n.reset=()=>{t=null},Object.defineProperty(n,"started",{get:()=>null!==t}),n},J=()=>{};function Q(e={}){if("object"!=typeof e)throw new TypeError("param must be object");return Object.entries(e).reduce((e,[t,n])=>(void 0===n||null==n||e.append(decodeURIComponent(t),decodeURIComponent(n)),e),new URLSearchParams).toString()}var Z=(e,t=J,n=4)=>{try{const t="string"==typeof e?JSON.parse(e.replace(/'/g,'"')):e;return JSON.stringify(t,null,n)??""}catch(r){return t(r),""}},ee=(e,t)=>{const n={};return Object.keys(e).forEach(r=>{t.includes(r)||(n[r]=e[r])}),n},te=(e,t)=>{if(e&&t)for(const n in t)e[n]=t[n];return e};function ne(e,t,n,r){if(void 0===e)return J;if(!(t in e)&&!r)return J;const i=t in e,a=e[t],o=n(a);if("function"!=typeof o)return J;e[t]=o;let s=!1;return()=>{s||(s=!0,e[t]===o&&(i?e[t]=a:delete e[t]))}}var re=(e,t)=>{const n=Object.getOwnPropertyDescriptors(t);for(const r of Object.keys(n)){const t=n[r];if(t.get){const n=t.get;Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:X(n)})}else{if("object"!=typeof t.value)throw new Error("Exposed values must be either a getter or an nested object");Object.defineProperty(e,r,{configurable:!1,enumerable:!0,writable:!1,value:re({},t.value)})}}return Object.freeze(e)};function ie(e){return Object.prototype.toString.call(e)}function ae(e,t,n=/* @__PURE__ */new Map){if(e===t)return!0;if(null==e||null==t)return e===t;if(e!=e&&t!=t)return!0;const r=typeof e;if(r!==typeof t)return!1;if("object"!==r)return e===t;const i=ie(e);if(i!==ie(t))return!1;if(n.has(e))return n.get(e)===t;if(n.set(e,t),"[object Array]"===i){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!ae(e[r],t[r],n))return!1;return!0}if("[object Date]"===i)return+e===+t;if("[object RegExp]"===i)return e.toString()===t.toString();if("[object Map]"===i){if(e.size!==t.size)return!1;let r=!0;return e.forEach((e,i)=>{r&&(t.has(i)&&ae(e,t.get(i),n)||(r=!1))}),r}if("[object Set]"===i){if(e.size!==t.size)return!1;const r=Array.from(e),i=Array.from(t);return r.every(e=>i.some(t=>ae(e,t,n)))}const a=Object.keys(e),o=Object.keys(t);if(a.length!==o.length)return!1;for(const s of a)if(!Object.prototype.hasOwnProperty.call(t,s)||!ae(e[s],t[s],n))return!1;return!0}var oe=(e,t=/* @__PURE__ */new WeakMap)=>{if(null===e||"object"!=typeof e)return e;if(t.has(e))return t.get(e);if(e instanceof Date)return new Date(e.getTime());if(e instanceof RegExp)return new RegExp(e.source,e.flags);if(Array.isArray(e)){const n=[];t.set(e,n);for(let r=0;r<e.length;r++)n[r]=oe(e[r],t);return n}if(e instanceof Map){const n=/* @__PURE__ */new Map;return t.set(e,n),e.forEach((e,r)=>{n.set("object"==typeof r&&null!==r?oe(r,t):r,oe(e,t))}),n}if(e instanceof Set){const n=/* @__PURE__ */new Set;return t.set(e,n),e.forEach(e=>{n.add(oe(e,t))}),n}if("object"==typeof e&&e.constructor===Object){const n={};return t.set(e,n),[...Object.getOwnPropertyNames(e),...Object.getOwnPropertySymbols(e)].forEach(r=>{n[r]=oe(e[r],t)}),n}try{const n=new(0,Object.getPrototypeOf(e).constructor);t.set(e,n);for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=oe(e[r],t));return n}catch{return console.warn(`Unable to deeply clone object of type ${Object.prototype.toString.call(e)}. Fallback to shallow copy.`),{...e}}},se={172351395:{name:"EBML",type:"Container"},646:{name:"EBMLVersion",type:"Uint"},759:{name:"EBMLReadVersion",type:"Uint"},754:{name:"EBMLMaxIDLength",type:"Uint"},755:{name:"EBMLMaxSizeLength",type:"Uint"},642:{name:"DocType",type:"String"},647:{name:"DocTypeVersion",type:"Uint"},645:{name:"DocTypeReadVersion",type:"Uint"},108:{name:"Void",type:"Binary"},63:{name:"CRC-32",type:"Binary"},190023271:{name:"SignatureSlot",type:"Container"},16010:{name:"SignatureAlgo",type:"Uint"},16026:{name:"SignatureHash",type:"Uint"},16037:{name:"SignaturePublicKey",type:"Binary"},16053:{name:"Signature",type:"Binary"},15963:{name:"SignatureElements",type:"Container"},15995:{name:"SignatureElementList",type:"Container"},9522:{name:"SignedElement",type:"Binary"},139690087:{name:"Segment",type:"Container"},21863284:{name:"SeekHead",type:"Container"},3515:{name:"Seek",type:"Container"},5035:{name:"SeekID",type:"Binary"},5036:{name:"SeekPosition",type:"Uint"},88713574:{name:"Info",type:"Container"},13220:{name:"SegmentUID",type:"Binary"},13188:{name:"SegmentFilename",type:"String"},1882403:{name:"PrevUID",type:"Binary"},1868715:{name:"PrevFilename",type:"String"},2013475:{name:"NextUID",type:"Binary"},1999803:{name:"NextFilename",type:"String"},1092:{name:"SegmentFamily",type:"Binary"},10532:{name:"ChapterTranslate",type:"Container"},10748:{name:"ChapterTranslateEditionUID",type:"Uint"},10687:{name:"ChapterTranslateCodec",type:"Uint"},10661:{name:"ChapterTranslateID",type:"Binary"},710577:{name:"TimecodeScale",type:"Uint"},1161:{name:"Duration",type:"Float"},1121:{name:"DateUTC",type:"Date"},15273:{name:"Title",type:"String"},3456:{name:"MuxingApp",type:"String"},5953:{name:"WritingApp",type:"String"},103:{name:"Timecode",type:"Uint"},6228:{name:"SilentTracks",type:"Container"},6359:{name:"SilentTrackNumber",type:"Uint"},39:{name:"Position",type:"Uint"},43:{name:"PrevSize",type:"Uint"},35:{name:"SimpleBlock",type:"Binary"},32:{name:"BlockGroup",type:"Container"},33:{name:"Block",type:"Binary"},34:{name:"BlockVirtual",type:"Binary"},13729:{name:"BlockAdditions",type:"Container"},38:{name:"BlockMore",type:"Container"},110:{name:"BlockAddID",type:"Uint"},37:{name:"BlockAdditional",type:"Binary"},27:{name:"BlockDuration",type:"Uint"},122:{name:"ReferencePriority",type:"Uint"},123:{name:"ReferenceBlock",type:"Int"},125:{name:"ReferenceVirtual",type:"Int"},36:{name:"CodecState",type:"Binary"},13730:{name:"DiscardPadding",type:"Int"},14:{name:"Slices",type:"Container"},104:{name:"TimeSlice",type:"Container"},76:{name:"LaceNumber",type:"Uint"},77:{name:"FrameNumber",type:"Uint"},75:{name:"BlockAdditionID",type:"Uint"},78:{name:"Delay",type:"Uint"},79:{name:"SliceDuration",type:"Uint"},72:{name:"ReferenceFrame",type:"Container"},73:{name:"ReferenceOffset",type:"Uint"},74:{name:"ReferenceTimeCode",type:"Uint"},47:{name:"EncryptedBlock",type:"Binary"},106212971:{name:"Tracks",type:"Container"},46:{name:"TrackEntry",type:"Container"},87:{name:"TrackNumber",type:"Uint"},13253:{name:"TrackUID",type:"Uint"},3:{name:"TrackType",type:"Uint"},57:{name:"FlagEnabled",type:"Uint"},8:{name:"FlagDefault",type:"Uint"},5546:{name:"FlagForced",type:"Uint"},28:{name:"FlagLacing",type:"Uint"},11751:{name:"MinCache",type:"Uint"},11768:{name:"MaxCache",type:"Uint"},254851:{name:"DefaultDuration",type:"Uint"},216698:{name:"DefaultDecodedFieldDuration",type:"Uint"},209231:{name:"TrackTimecodeScale",type:"Float"},4991:{name:"TrackOffset",type:"Int"},5614:{name:"MaxBlockAdditionID",type:"Uint"},4974:{name:"Name",type:"String"},177564:{name:"Language",type:"String"},6:{name:"CodecID",type:"String"},9122:{name:"CodecPrivate",type:"Binary"},362120:{name:"CodecName",type:"String"},13382:{name:"AttachmentLink",type:"Uint"},1742487:{name:"CodecSettings",type:"String"},1785920:{name:"CodecInfoURL",type:"String"},438848:{name:"CodecDownloadURL",type:"String"},42:{name:"CodecDecodeAll",type:"Uint"},12203:{name:"TrackOverlay",type:"Uint"},5802:{name:"CodecDelay",type:"Uint"},5819:{name:"SeekPreRoll",type:"Uint"},9764:{name:"TrackTranslate",type:"Container"},9980:{name:"TrackTranslateEditionUID",type:"Uint"},9919:{name:"TrackTranslateCodec",type:"Uint"},9893:{name:"TrackTranslateTrackID",type:"Binary"},96:{name:"Video",type:"Container"},26:{name:"FlagInterlaced",type:"Uint"},5048:{name:"StereoMode",type:"Uint"},5056:{name:"AlphaMode",type:"Uint"},5049:{name:"OldStereoMode",type:"Uint"},48:{name:"PixelWidth",type:"Uint"},58:{name:"PixelHeight",type:"Uint"},5290:{name:"PixelCropBottom",type:"Uint"},5307:{name:"PixelCropTop",type:"Uint"},5324:{name:"PixelCropLeft",type:"Uint"},5341:{name:"PixelCropRight",type:"Uint"},5296:{name:"DisplayWidth",type:"Uint"},5306:{name:"DisplayHeight",type:"Uint"},5298:{name:"DisplayUnit",type:"Uint"},5299:{name:"AspectRatioType",type:"Uint"},963876:{name:"ColourSpace",type:"Binary"},1029411:{name:"GammaValue",type:"Float"},230371:{name:"FrameRate",type:"Float"},97:{name:"Audio",type:"Container"},53:{name:"SamplingFrequency",type:"Float"},14517:{name:"OutputSamplingFrequency",type:"Float"},31:{name:"Channels",type:"Uint"},15739:{name:"ChannelPositions",type:"Binary"},8804:{name:"BitDepth",type:"Uint"},98:{name:"TrackOperation",type:"Container"},99:{name:"TrackCombinePlanes",type:"Container"},100:{name:"TrackPlane",type:"Container"},101:{name:"TrackPlaneUID",type:"Uint"},102:{name:"TrackPlaneType",type:"Uint"},105:{name:"TrackJoinBlocks",type:"Container"},109:{name:"TrackJoinUID",type:"Uint"},64:{name:"TrickTrackUID",type:"Uint"},65:{name:"TrickTrackSegmentUID",type:"Binary"},70:{name:"TrickTrackFlag",type:"Uint"},71:{name:"TrickMasterTrackUID",type:"Uint"},68:{name:"TrickMasterTrackSegmentUID",type:"Binary"},11648:{name:"ContentEncodings",type:"Container"},8768:{name:"ContentEncoding",type:"Container"},4145:{name:"ContentEncodingOrder",type:"Uint"},4146:{name:"ContentEncodingScope",type:"Uint"},4147:{name:"ContentEncodingType",type:"Uint"},4148:{name:"ContentCompression",type:"Container"},596:{name:"ContentCompAlgo",type:"Uint"},597:{name:"ContentCompSettings",type:"Binary"},4149:{name:"ContentEncryption",type:"Container"},2017:{name:"ContentEncAlgo",type:"Uint"},2018:{name:"ContentEncKeyID",type:"Binary"},2019:{name:"ContentSignature",type:"Binary"},2020:{name:"ContentSigKeyID",type:"Binary"},2021:{name:"ContentSigAlgo",type:"Uint"},2022:{name:"ContentSigHashAlgo",type:"Uint"},206814059:{name:"Cues",type:"Container"},59:{name:"CuePoint",type:"Container"},51:{name:"CueTime",type:"Uint"},55:{name:"CueTrackPositions",type:"Container"},119:{name:"CueTrack",type:"Uint"},113:{name:"CueClusterPosition",type:"Uint"},112:{name:"CueRelativePosition",type:"Uint"},50:{name:"CueDuration",type:"Uint"},4984:{name:"CueBlockNumber",type:"Uint"},106:{name:"CueCodecState",type:"Uint"},91:{name:"CueReference",type:"Container"},22:{name:"CueRefTime",type:"Uint"},23:{name:"CueRefCluster",type:"Uint"},4959:{name:"CueRefNumber",type:"Uint"},107:{name:"CueRefCodecState",type:"Uint"},155296873:{name:"Attachments",type:"Container"},8615:{name:"AttachedFile",type:"Container"},1662:{name:"FileDescription",type:"String"},1646:{name:"FileName",type:"String"},1632:{name:"FileMimeType",type:"String"},1628:{name:"FileData",type:"Binary"},1710:{name:"FileUID",type:"Uint"},1653:{name:"FileReferral",type:"Binary"},1633:{name:"FileUsedStartTime",type:"Uint"},1634:{name:"FileUsedEndTime",type:"Uint"},4433776:{name:"Chapters",type:"Container"},1465:{name:"EditionEntry",type:"Container"},1468:{name:"EditionUID",type:"Uint"},1469:{name:"EditionFlagHidden",type:"Uint"},1499:{name:"EditionFlagDefault",type:"Uint"},1501:{name:"EditionFlagOrdered",type:"Uint"},54:{name:"ChapterAtom",type:"Container"},13252:{name:"ChapterUID",type:"Uint"},5716:{name:"ChapterStringUID",type:"String"},17:{name:"ChapterTimeStart",type:"Uint"},18:{name:"ChapterTimeEnd",type:"Uint"},24:{name:"ChapterFlagHidden",type:"Uint"},1432:{name:"ChapterFlagEnabled",type:"Uint"},11879:{name:"ChapterSegmentUID",type:"Binary"},11964:{name:"ChapterSegmentEditionUID",type:"Uint"},9155:{name:"ChapterPhysicalEquiv",type:"Uint"},15:{name:"ChapterTrack",type:"Container"},9:{name:"ChapterTrackNumber",type:"Uint"},0:{name:"ChapterDisplay",type:"Container"},5:{name:"ChapString",type:"String"},892:{name:"ChapLanguage",type:"String"},894:{name:"ChapCountry",type:"String"},10564:{name:"ChapProcess",type:"Container"},10581:{name:"ChapProcessCodecID",type:"Uint"},1293:{name:"ChapProcessPrivate",type:"Binary"},10513:{name:"ChapProcessCommand",type:"Container"},10530:{name:"ChapProcessTime",type:"Uint"},10547:{name:"ChapProcessData",type:"Binary"},39109479:{name:"Tags",type:"Container"},13171:{name:"Tag",type:"Container"},9152:{name:"Targets",type:"Container"},10442:{name:"TargetTypeValue",type:"Uint"},9162:{name:"TargetType",type:"String"},9157:{name:"TagTrackUID",type:"Uint"},9161:{name:"TagEditionUID",type:"Uint"},9156:{name:"TagChapterUID",type:"Uint"},9158:{name:"TagAttachmentUID",type:"Uint"},10184:{name:"SimpleTag",type:"Container"},1443:{name:"TagName",type:"String"},1146:{name:"TagLanguage",type:"String"},1156:{name:"TagDefault",type:"Uint"},1159:{name:"TagString",type:"String"},1157:{name:"TagBinary",type:"Binary"}},ce=class{name;type;source;data;constructor(e="Unknown",t="Unknown"){this.name=e,this.type=t}updateBySource(){}setSource(e){this.source=e,this.updateBySource()}updateByData(){}setData(e){this.data=e,this.updateByData()}};function ue(e){return e.length%2==1?"0"+e:e}var de=class extends ce{constructor(e,t){super(e,t||"Uint")}updateBySource(){this.data="";for(let e=0;e<this.source.length;e++){const t=this.source[e].toString(16);this.data+=ue(t)}}updateByData(){const e=this.data.length/2;this.source=new Uint8Array(e);for(let t=0;t<e;t++){const e=this.data.substr(2*t,2);this.source[t]=parseInt(e,16)}}getValue(){return parseInt(this.data,16)}setValue(e){this.setData(ue(e.toString(16)))}},le=class extends ce{constructor(e,t){super(e,t||"Float")}getFloatArrayType(){return this.source&&4===this.source.length?Float32Array:Float64Array}updateBySource(){const e=this.source.reverse(),t=new(this.getFloatArrayType())(e.buffer);this.data=t[0]}updateByData(){const e=new(this.getFloatArrayType())([this.data]),t=new Uint8Array(e.buffer);this.source=t.reverse()}getValue(){return this.data}setValue(e){this.setData(e)}},he=class e extends ce{offset=0;data=[];constructor(e,t){super(e,t||"Container")}readByte(){return this.source[this.offset++]}readUint(){const e=this.readByte(),t=8-e.toString(2).length;let n=e-(1<<7-t);for(let r=0;r<t;r++)n*=256,n+=this.readByte();return n}updateBySource(){let t;for(this.data=[],this.offset=0;this.offset<this.source.length;this.offset=t){const n=this.readUint(),r=this.readUint();t=Math.min(this.offset+r,this.source.length);const i=this.source.slice(this.offset,t),a=se[n]||{name:"Unknown",type:"Unknown"};let o=ce;switch(a.type){case"Container":o=e;break;case"Uint":o=de;break;case"Float":o=le}const s=new o(a.name,a.type);s.setSource(i),this.data.push({id:n,idHex:n.toString(16),data:s})}}writeUint(e,t=!1){let n=1,r=128;for(;e>=r&&n<8;)n++,r*=128;if(!t){let t=r+e;for(let e=n-1;e>=0;e--){const n=t%256;this.source[this.offset+e]=n,t=(t-n)/256}}this.offset+=n}writeSections(e=!1){this.offset=0;for(let t=0;t<this.data.length;t++){const n=this.data[t],r=n.data.source,i=r.length;this.writeUint(n.id,e),this.writeUint(i,e),e||this.source.set(r,this.offset),this.offset+=i}return this.offset}updateByData(){const e=this.writeSections(!0);this.source=new Uint8Array(e),this.writeSections()}getSectionById(e){for(let t=0;t<this.data.length;t++){const n=this.data[t];if(n.id===e)return n.data}}},pe=class extends he{constructor(e){super("File","File"),this.setSource(e)}fixDuration(e){const t=this.getSectionById(139690087);if(!t)return!1;const n=t.getSectionById(88713574);if(!n)return!1;const r=n.getSectionById(710577);if(!r)return!1;let i=n.getSectionById(1161);if(i){if(!(i.getValue()<=0))return!1;i.setValue(e)}else i=new le("Duration","Float"),i.setValue(e),n.data.push({id:1161,data:i});return r.setValue(1e6),n.updateByData(),t.updateByData(),this.updateByData(),!0}toBlob(e="video/webm"){return new Blob([this.source.buffer],{type:e})}};var fe=class{startTime;chunks;mediaRecorder;blob;constructor(){this.startTime=Date.now(),this.chunks=[],navigator.mediaDevices.getUserMedia({audio:!0}).then(e=>{this.init(e)}).catch(e=>{})}init(e){const t=function(){const e=["audio/webm","audio/mp4","audio/ogg","audio/wav","audio/aac"];for(let t=0;t<e.length;t++)if(MediaRecorder.isTypeSupported(e[t]))return e[t]}();this.mediaRecorder=new MediaRecorder(e,{mimeType:t}),this.mediaRecorder?.addEventListener("dataavailable",async e=>{if(e.data.size>0&&this.chunks.push(e.data),"inactive"===this.mediaRecorder?.state){const e=Date.now()-this.startTime;this.blob=new Blob(this.chunks,{type:t}),"audio/webm"===t&&(this.blob=await((e,t,n="video/webm")=>new Promise((r,i)=>{try{const a=new FileReader;a.addEventListener("loadend",()=>{try{const i=a.result,o=new pe(new Uint8Array(i));o.fixDuration(t)?r(o.toBlob(n)):r(e)}catch(o){i(o)}}),a.addEventListener("error",()=>i()),a.readAsArrayBuffer(e)}catch(a){i(a)}}))(this.blob,e,this.blob.type)),this.chunks=[]}}),this.mediaRecorder?.start()}start(){return"paused"===this.mediaRecorder?.state&&this.mediaRecorder.resume(),this.mediaRecorder}pause(){return"recording"===this.mediaRecorder?.state&&this.mediaRecorder.pause(),this.mediaRecorder}stop(){return this.mediaRecorder?.stop(),this.blob}},me=new e,ge=(e,t={})=>{const{subscriber:n,equals:r}=t;let i=e;return[()=>i,e=>{var t,a;(t=i,a=e,!1!==r&&("function"==typeof r?r(t,a):Object.is(t,a)))||(i=e,n&&me.call(n))}]},ye="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function we(e,t,n,r){let i,a,o;const s=t||[0],c=(n=n||0)>>>3,u=-1===r?3:0;for(i=0;i<e.length;i+=1)o=i+c,a=o>>>2,s.length<=a&&s.push(0),s[a]|=e[i]<<8*(u+r*(o%4));return{value:s,binLen:8*e.length+n}}function be(e,t,n){switch(t){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw new Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(e){case"HEX":return function(e,t,r){return function(e,t,n,r){let i,a,o,s;if(0!=e.length%2)throw new Error("String of HEX type must be in byte increments");const c=t||[0],u=(n=n||0)>>>3,d=-1===r?3:0;for(i=0;i<e.length;i+=2){if(a=parseInt(e.substr(i,2),16),isNaN(a))throw new Error("String of HEX type contains invalid characters");for(s=(i>>>1)+u,o=s>>>2;c.length<=o;)c.push(0);c[o]|=a<<8*(d+r*(s%4))}return{value:c,binLen:4*e.length+n}}(e,t,r,n)};case"TEXT":return function(e,r,i){return function(e,t,n,r,i){let a,o,s,c,u,d,l,h,p=0;const f=n||[0],m=(r=r||0)>>>3;if("UTF8"===t)for(l=-1===i?3:0,s=0;s<e.length;s+=1)for(a=e.charCodeAt(s),o=[],128>a?o.push(a):2048>a?(o.push(192|a>>>6),o.push(128|63&a)):55296>a||57344<=a?o.push(224|a>>>12,128|a>>>6&63,128|63&a):(s+=1,a=65536+((1023&a)<<10|1023&e.charCodeAt(s)),o.push(240|a>>>18,128|a>>>12&63,128|a>>>6&63,128|63&a)),c=0;c<o.length;c+=1){for(d=p+m,u=d>>>2;f.length<=u;)f.push(0);f[u]|=o[c]<<8*(l+i*(d%4)),p+=1}else for(l=-1===i?2:0,h="UTF16LE"===t&&1!==i||"UTF16LE"!==t&&1===i,s=0;s<e.length;s+=1){for(a=e.charCodeAt(s),!0===h&&(c=255&a,a=c<<8|a>>>8),d=p+m,u=d>>>2;f.length<=u;)f.push(0);f[u]|=a<<8*(l+i*(d%4)),p+=2}return{value:f,binLen:8*p+r}}(e,t,r,i,n)};case"B64":return function(e,t,r){return function(e,t,n,r){let i,a,o,s,c,u,d,l=0;const h=t||[0],p=(n=n||0)>>>3,f=-1===r?3:0,m=e.indexOf("=");if(-1===e.search(/^[a-z\d=+/]+$/i))throw new Error("Invalid character in base-64 string");if(e=e.replace(/=/g,""),-1!==m&&m<e.length)throw new Error("Invalid '=' found in base-64 string");for(a=0;a<e.length;a+=4){for(c=e.substr(a,4),s=0,o=0;o<c.length;o+=1)i=ye.indexOf(c.charAt(o)),s|=i<<18-6*o;for(o=0;o<c.length-1;o+=1){for(d=l+p,u=d>>>2;h.length<=u;)h.push(0);h[u]|=(s>>>16-8*o&255)<<8*(f+r*(d%4)),l+=1}}return{value:h,binLen:8*l+n}}(e,t,r,n)};case"BYTES":return function(e,t,r){return function(e,t,n,r){let i,a,o,s;const c=t||[0],u=(n=n||0)>>>3,d=-1===r?3:0;for(a=0;a<e.length;a+=1)i=e.charCodeAt(a),s=a+u,o=s>>>2,c.length<=o&&c.push(0),c[o]|=i<<8*(d+r*(s%4));return{value:c,binLen:8*e.length+n}}(e,t,r,n)};case"ARRAYBUFFER":return function(e,t,r){return function(e,t,n,r){return we(new Uint8Array(e),t,n,r)}(e,t,r,n)};case"UINT8ARRAY":return function(e,t,r){return we(e,t,r,n)};default:throw new Error("format must be HEX, TEXT, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}}function Se(e,t,n,r){switch(e){case"HEX":return function(e){return function(e,t,n,r){const i="0123456789abcdef";let a,o,s="";const c=t/8,u=-1===n?3:0;for(a=0;a<c;a+=1)o=e[a>>>2]>>>8*(u+n*(a%4)),s+=i.charAt(o>>>4&15)+i.charAt(15&o);return r.outputUpper?s.toUpperCase():s}(e,t,n,r)};case"B64":return function(e){return function(e,t,n,r){let i,a,o,s,c,u="";const d=t/8,l=-1===n?3:0;for(i=0;i<d;i+=3)for(s=i+1<d?e[i+1>>>2]:0,c=i+2<d?e[i+2>>>2]:0,o=(e[i>>>2]>>>8*(l+n*(i%4))&255)<<16|(s>>>8*(l+n*((i+1)%4))&255)<<8|c>>>8*(l+n*((i+2)%4))&255,a=0;a<4;a+=1)u+=8*i+6*a<=t?ye.charAt(o>>>6*(3-a)&63):r.b64Pad;return u}(e,t,n,r)};case"BYTES":return function(e){return function(e,t,n){let r,i,a="";const o=t/8,s=-1===n?3:0;for(r=0;r<o;r+=1)i=e[r>>>2]>>>8*(s+n*(r%4))&255,a+=String.fromCharCode(i);return a}(e,t,n)};case"ARRAYBUFFER":return function(e){return function(e,t,n){let r;const i=t/8,a=new ArrayBuffer(i),o=new Uint8Array(a),s=-1===n?3:0;for(r=0;r<i;r+=1)o[r]=e[r>>>2]>>>8*(s+n*(r%4))&255;return a}(e,t,n)};case"UINT8ARRAY":return function(e){return function(e,t,n){let r;const i=t/8,a=-1===n?3:0,o=new Uint8Array(i);for(r=0;r<i;r+=1)o[r]=e[r>>>2]>>>8*(a+n*(r%4))&255;return o}(e,t,n)};default:throw new Error("format must be HEX, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}}var Ce=4294967296,ve=[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],Ue=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428],Ee=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],Oe="Chosen SHA variant is not supported",Ae="Cannot set numRounds with MAC";function Me(e,t){let n,r;const i=e.binLen>>>3,a=t.binLen>>>3,o=i<<3,s=4-i<<3;if(i%4!=0){for(n=0;n<a;n+=4)r=i+n>>>2,e.value[r]|=t.value[n>>>2]<<o,e.value.push(0),e.value[r+1]|=t.value[n>>>2]>>>s;return(e.value.length<<2)-4>=a+i&&e.value.pop(),{value:e.value,binLen:e.binLen+t.binLen}}return{value:e.value.concat(t.value),binLen:e.binLen+t.binLen}}function ke(e){const t={outputUpper:!1,b64Pad:"=",outputLen:-1},n=e||{},r="Output length must be a multiple of 8";if(t.outputUpper=n.outputUpper||!1,n.b64Pad&&(t.b64Pad=n.b64Pad),n.outputLen){if(n.outputLen%8!=0)throw new Error(r);t.outputLen=n.outputLen}else if(n.shakeLen){if(n.shakeLen%8!=0)throw new Error(r);t.outputLen=n.shakeLen}if("boolean"!=typeof t.outputUpper)throw new Error("Invalid outputUpper formatting option");if("string"!=typeof t.b64Pad)throw new Error("Invalid b64Pad formatting option");return t}function Te(e,t,n,r){const i=e+" must include a value and format";if(!t){if(!r)throw new Error(i);return r}if(void 0===t.value||!t.format)throw new Error(i);return be(t.format,t.encoding||"UTF8",n)(t.value)}var Be=class{shaVariant;inputFormat;utfType;numRounds;keyWithIPad;keyWithOPad;remainder;remainderLen;updateCalled;processedLen;macKeySet;constructor(e,t,n){const r=n||{};if(this.inputFormat=t,this.utfType=r.encoding||"UTF8",this.numRounds=r.numRounds||1,isNaN(this.numRounds)||this.numRounds!==parseInt(this.numRounds,10)||1>this.numRounds)throw new Error("numRounds must a integer >= 1");this.shaVariant=e,this.remainder=[],this.remainderLen=0,this.updateCalled=!1,this.processedLen=0,this.macKeySet=!1,this.keyWithIPad=[],this.keyWithOPad=[]}update(e){let t,n=0;const r=this.variantBlockSize>>>5,i=this.converterFunc(e,this.remainder,this.remainderLen),a=i.binLen,o=i.value,s=a>>>5;for(t=0;t<s;t+=r)n+this.variantBlockSize<=a&&(this.intermediateState=this.roundFunc(o.slice(t,t+r),this.intermediateState),n+=this.variantBlockSize);return this.processedLen+=n,this.remainder=o.slice(n>>>5),this.remainderLen=a%this.variantBlockSize,this.updateCalled=!0,this}getHash(e,t){let n,r,i=this.outputBinLen;const a=ke(t);if(this.isVariableLen){if(-1===a.outputLen)throw new Error("Output length must be specified in options");i=a.outputLen}const o=Se(e,i,this.bigEndianMod,a);if(this.macKeySet&&this.getMAC)return o(this.getMAC(a));for(r=this.finalizeFunc(this.remainder.slice(),this.remainderLen,this.processedLen,this.stateCloneFunc(this.intermediateState),i),n=1;n<this.numRounds;n+=1)this.isVariableLen&&i%32!=0&&(r[r.length-1]&=16777215>>>24-i%32),r=this.finalizeFunc(r,i,0,this.newStateFunc(this.shaVariant),i);return o(r)}setHMACKey(e,t,n){if(!this.HMACSupported)throw new Error("Variant does not support HMAC");if(this.updateCalled)throw new Error("Cannot set MAC key after calling update");const r=be(t,(n||{}).encoding||"UTF8",this.bigEndianMod);this._setHMACKey(r(e))}_setHMACKey(e){const t=this.variantBlockSize>>>3,n=t/4-1;let r;if(1!==this.numRounds)throw new Error(Ae);if(this.macKeySet)throw new Error("MAC key already set");for(t<e.binLen/8&&(e.value=this.finalizeFunc(e.value,e.binLen,0,this.newStateFunc(this.shaVariant),this.outputBinLen));e.value.length<=n;)e.value.push(0);for(r=0;r<=n;r+=1)this.keyWithIPad[r]=909522486^e.value[r],this.keyWithOPad[r]=1549556828^e.value[r];this.intermediateState=this.roundFunc(this.keyWithIPad,this.intermediateState),this.processedLen=this.variantBlockSize,this.macKeySet=!0}getHMAC(e,t){const n=ke(t);return Se(e,this.outputBinLen,this.bigEndianMod,n)(this._getHMAC())}_getHMAC(){let e;if(!this.macKeySet)throw new Error("Cannot call getHMAC without first setting MAC key");const t=this.finalizeFunc(this.remainder.slice(),this.remainderLen,this.processedLen,this.stateCloneFunc(this.intermediateState),this.outputBinLen);return e=this.roundFunc(this.keyWithOPad,this.newStateFunc(this.shaVariant)),e=this.finalizeFunc(t,this.outputBinLen,this.variantBlockSize,e,this.outputBinLen),e}};function Le(e,t){return e<<t|e>>>32-t}function Fe(e,t){return e>>>t|e<<32-t}function Re(e,t){return e>>>t}function Pe(e,t,n){return e^t^n}function De(e,t,n){return e&t^~e&n}function xe(e,t,n){return e&t^e&n^t&n}function He(e){return Fe(e,2)^Fe(e,13)^Fe(e,22)}function Ie(e,t){const n=(65535&e)+(65535&t);return((e>>>16)+(t>>>16)+(n>>>16)&65535)<<16|65535&n}function je(e,t,n,r){const i=(65535&e)+(65535&t)+(65535&n)+(65535&r);return((e>>>16)+(t>>>16)+(n>>>16)+(r>>>16)+(i>>>16)&65535)<<16|65535&i}function Ne(e,t,n,r,i){const a=(65535&e)+(65535&t)+(65535&n)+(65535&r)+(65535&i);return((e>>>16)+(t>>>16)+(n>>>16)+(r>>>16)+(i>>>16)+(a>>>16)&65535)<<16|65535&a}function ze(e){return Fe(e,17)^Fe(e,19)^Re(e,10)}function Ke(e){return Fe(e,7)^Fe(e,18)^Re(e,3)}function We(e){return Fe(e,6)^Fe(e,11)^Fe(e,25)}function _e(e){return[1732584193,4023233417,2562383102,271733878,3285377520]}function qe(e,t){let n,r,i,a,o,s,c;const u=[];for(n=t[0],r=t[1],i=t[2],a=t[3],o=t[4],c=0;c<80;c+=1)u[c]=c<16?e[c]:Le(u[c-3]^u[c-8]^u[c-14]^u[c-16],1),s=c<20?Ne(Le(n,5),De(r,i,a),o,1518500249,u[c]):c<40?Ne(Le(n,5),Pe(r,i,a),o,1859775393,u[c]):c<60?Ne(Le(n,5),xe(r,i,a),o,2400959708,u[c]):Ne(Le(n,5),Pe(r,i,a),o,3395469782,u[c]),o=a,a=i,i=Le(r,30),r=n,n=s;return t[0]=Ie(n,t[0]),t[1]=Ie(r,t[1]),t[2]=Ie(i,t[2]),t[3]=Ie(a,t[3]),t[4]=Ie(o,t[4]),t}function Ve(e,t,n,r){let i;const a=15+(t+65>>>9<<4),o=t+n;for(;e.length<=a;)e.push(0);for(e[t>>>5]|=128<<24-t%32,e[a]=4294967295&o,e[a-1]=o/Ce|0,i=0;i<e.length;i+=16)r=qe(e.slice(i,i+16),r);return r}var $e=class extends Be{intermediateState;variantBlockSize;bigEndianMod;outputBinLen;isVariableLen;HMACSupported;converterFunc;roundFunc;finalizeFunc;stateCloneFunc;newStateFunc;getMAC;constructor(e,t,n){if("SHA-1"!==e)throw new Error(Oe);super(e,t,n);const r=n||{};this.HMACSupported=!0,this.getMAC=this._getHMAC,this.bigEndianMod=-1,this.converterFunc=be(this.inputFormat,this.utfType,this.bigEndianMod),this.roundFunc=qe,this.stateCloneFunc=function(e){return e.slice()},this.newStateFunc=_e,this.finalizeFunc=Ve,this.intermediateState=[1732584193,4023233417,2562383102,271733878,3285377520],this.variantBlockSize=512,this.outputBinLen=160,this.isVariableLen=!1,r.hmacKey&&this._setHMACKey(Te("hmacKey",r.hmacKey,this.bigEndianMod))}};function Xe(e){let t;return t="SHA-224"===e?Ue.slice():Ee.slice(),t}function Ye(e,t){let n,r,i,a,o,s,c,u,d,l,h;const p=[];for(n=t[0],r=t[1],i=t[2],a=t[3],o=t[4],s=t[5],c=t[6],u=t[7],h=0;h<64;h+=1)p[h]=h<16?e[h]:je(ze(p[h-2]),p[h-7],Ke(p[h-15]),p[h-16]),d=Ne(u,We(o),De(o,s,c),ve[h],p[h]),l=Ie(He(n),xe(n,r,i)),u=c,c=s,s=o,o=Ie(a,d),a=i,i=r,r=n,n=Ie(d,l);return t[0]=Ie(n,t[0]),t[1]=Ie(r,t[1]),t[2]=Ie(i,t[2]),t[3]=Ie(a,t[3]),t[4]=Ie(o,t[4]),t[5]=Ie(s,t[5]),t[6]=Ie(c,t[6]),t[7]=Ie(u,t[7]),t}var Ge=class extends Be{intermediateState;variantBlockSize;bigEndianMod;outputBinLen;isVariableLen;HMACSupported;converterFunc;roundFunc;finalizeFunc;stateCloneFunc;newStateFunc;getMAC;constructor(e,t,n){if("SHA-224"!==e&&"SHA-256"!==e)throw new Error(Oe);super(e,t,n);const r=n||{};this.getMAC=this._getHMAC,this.HMACSupported=!0,this.bigEndianMod=-1,this.converterFunc=be(this.inputFormat,this.utfType,this.bigEndianMod),this.roundFunc=Ye,this.stateCloneFunc=function(e){return e.slice()},this.newStateFunc=Xe,this.finalizeFunc=function(t,n,r,i){return function(e,t,n,r,i){let a,o;const s=15+(t+65>>>9<<4),c=t+n;for(;e.length<=s;)e.push(0);for(e[t>>>5]|=128<<24-t%32,e[s]=4294967295&c,e[s-1]=c/Ce|0,a=0;a<e.length;a+=16)r=Ye(e.slice(a,a+16),r);return o="SHA-224"===i?[r[0],r[1],r[2],r[3],r[4],r[5],r[6]]:r,o}(t,n,r,i,e)},this.intermediateState=Xe(e),this.variantBlockSize=512,this.outputBinLen="SHA-224"===e?224:256,this.isVariableLen=!1,r.hmacKey&&this._setHMACKey(Te("hmacKey",r.hmacKey,this.bigEndianMod))}},Je=class{highOrder;lowOrder;constructor(e,t){this.highOrder=e,this.lowOrder=t}};function Qe(e,t){let n;return t>32?(n=64-t,new Je(e.lowOrder<<t|e.highOrder>>>n,e.highOrder<<t|e.lowOrder>>>n)):0!==t?(n=32-t,new Je(e.highOrder<<t|e.lowOrder>>>n,e.lowOrder<<t|e.highOrder>>>n)):e}function Ze(e,t){let n;return t<32?(n=32-t,new Je(e.highOrder>>>t|e.lowOrder<<n,e.lowOrder>>>t|e.highOrder<<n)):(n=64-t,new Je(e.lowOrder>>>t|e.highOrder<<n,e.highOrder>>>t|e.lowOrder<<n))}function et(e,t){return new Je(e.highOrder>>>t,e.lowOrder>>>t|e.highOrder<<32-t)}function tt(e,t,n){return new Je(e.highOrder&t.highOrder^~e.highOrder&n.highOrder,e.lowOrder&t.lowOrder^~e.lowOrder&n.lowOrder)}function nt(e,t,n){return new Je(e.highOrder&t.highOrder^e.highOrder&n.highOrder^t.highOrder&n.highOrder,e.lowOrder&t.lowOrder^e.lowOrder&n.lowOrder^t.lowOrder&n.lowOrder)}function rt(e){const t=Ze(e,28),n=Ze(e,34),r=Ze(e,39);return new Je(t.highOrder^n.highOrder^r.highOrder,t.lowOrder^n.lowOrder^r.lowOrder)}function it(e,t){let n,r;n=(65535&e.lowOrder)+(65535&t.lowOrder),r=(e.lowOrder>>>16)+(t.lowOrder>>>16)+(n>>>16);const i=(65535&r)<<16|65535&n;n=(65535&e.highOrder)+(65535&t.highOrder)+(r>>>16),r=(e.highOrder>>>16)+(t.highOrder>>>16)+(n>>>16);return new Je((65535&r)<<16|65535&n,i)}function at(e,t,n,r){let i,a;i=(65535&e.lowOrder)+(65535&t.lowOrder)+(65535&n.lowOrder)+(65535&r.lowOrder),a=(e.lowOrder>>>16)+(t.lowOrder>>>16)+(n.lowOrder>>>16)+(r.lowOrder>>>16)+(i>>>16);const o=(65535&a)<<16|65535&i;i=(65535&e.highOrder)+(65535&t.highOrder)+(65535&n.highOrder)+(65535&r.highOrder)+(a>>>16),a=(e.highOrder>>>16)+(t.highOrder>>>16)+(n.highOrder>>>16)+(r.highOrder>>>16)+(i>>>16);return new Je((65535&a)<<16|65535&i,o)}function ot(e,t,n,r,i){let a,o;a=(65535&e.lowOrder)+(65535&t.lowOrder)+(65535&n.lowOrder)+(65535&r.lowOrder)+(65535&i.lowOrder),o=(e.lowOrder>>>16)+(t.lowOrder>>>16)+(n.lowOrder>>>16)+(r.lowOrder>>>16)+(i.lowOrder>>>16)+(a>>>16);const s=(65535&o)<<16|65535&a;a=(65535&e.highOrder)+(65535&t.highOrder)+(65535&n.highOrder)+(65535&r.highOrder)+(65535&i.highOrder)+(o>>>16),o=(e.highOrder>>>16)+(t.highOrder>>>16)+(n.highOrder>>>16)+(r.highOrder>>>16)+(i.highOrder>>>16)+(a>>>16);return new Je((65535&o)<<16|65535&a,s)}function st(e,t){return new Je(e.highOrder^t.highOrder,e.lowOrder^t.lowOrder)}function ct(e,t,n,r,i){return new Je(e.highOrder^t.highOrder^n.highOrder^r.highOrder^i.highOrder,e.lowOrder^t.lowOrder^n.lowOrder^r.lowOrder^i.lowOrder)}function ut(e){const t=Ze(e,19),n=Ze(e,61),r=et(e,6);return new Je(t.highOrder^n.highOrder^r.highOrder,t.lowOrder^n.lowOrder^r.lowOrder)}function dt(e){const t=Ze(e,1),n=Ze(e,8),r=et(e,7);return new Je(t.highOrder^n.highOrder^r.highOrder,t.lowOrder^n.lowOrder^r.lowOrder)}function lt(e){const t=Ze(e,14),n=Ze(e,18),r=Ze(e,41);return new Je(t.highOrder^n.highOrder^r.highOrder,t.lowOrder^n.lowOrder^r.lowOrder)}var ht=[new Je(ve[0],3609767458),new Je(ve[1],602891725),new Je(ve[2],3964484399),new Je(ve[3],2173295548),new Je(ve[4],4081628472),new Je(ve[5],3053834265),new Je(ve[6],2937671579),new Je(ve[7],3664609560),new Je(ve[8],2734883394),new Je(ve[9],1164996542),new Je(ve[10],1323610764),new Je(ve[11],3590304994),new Je(ve[12],4068182383),new Je(ve[13],991336113),new Je(ve[14],633803317),new Je(ve[15],3479774868),new Je(ve[16],2666613458),new Je(ve[17],944711139),new Je(ve[18],2341262773),new Je(ve[19],2007800933),new Je(ve[20],1495990901),new Je(ve[21],1856431235),new Je(ve[22],3175218132),new Je(ve[23],2198950837),new Je(ve[24],3999719339),new Je(ve[25],766784016),new Je(ve[26],2566594879),new Je(ve[27],3203337956),new Je(ve[28],1034457026),new Je(ve[29],2466948901),new Je(ve[30],3758326383),new Je(ve[31],168717936),new Je(ve[32],1188179964),new Je(ve[33],1546045734),new Je(ve[34],1522805485),new Je(ve[35],2643833823),new Je(ve[36],2343527390),new Je(ve[37],1014477480),new Je(ve[38],1206759142),new Je(ve[39],344077627),new Je(ve[40],1290863460),new Je(ve[41],3158454273),new Je(ve[42],3505952657),new Je(ve[43],106217008),new Je(ve[44],3606008344),new Je(ve[45],1432725776),new Je(ve[46],1467031594),new Je(ve[47],851169720),new Je(ve[48],3100823752),new Je(ve[49],1363258195),new Je(ve[50],3750685593),new Je(ve[51],3785050280),new Je(ve[52],3318307427),new Je(ve[53],3812723403),new Je(ve[54],2003034995),new Je(ve[55],3602036899),new Je(ve[56],1575990012),new Je(ve[57],1125592928),new Je(ve[58],2716904306),new Je(ve[59],442776044),new Je(ve[60],593698344),new Je(ve[61],3733110249),new Je(ve[62],2999351573),new Je(ve[63],3815920427),new Je(3391569614,3928383900),new Je(3515267271,566280711),new Je(3940187606,3454069534),new Je(4118630271,4000239992),new Je(116418474,1914138554),new Je(174292421,2731055270),new Je(289380356,3203993006),new Je(460393269,320620315),new Je(685471733,587496836),new Je(852142971,1086792851),new Je(1017036298,365543100),new Je(1126000580,2618297676),new Je(1288033470,3409855158),new Je(1501505948,4234509866),new Je(1607167915,987167468),new Je(1816402316,1246189591)];function pt(e){return"SHA-384"===e?[new Je(3418070365,Ue[0]),new Je(1654270250,Ue[1]),new Je(2438529370,Ue[2]),new Je(355462360,Ue[3]),new Je(1731405415,Ue[4]),new Je(41048885895,Ue[5]),new Je(3675008525,Ue[6]),new Je(1203062813,Ue[7])]:[new Je(Ee[0],4089235720),new Je(Ee[1],2227873595),new Je(Ee[2],4271175723),new Je(Ee[3],1595750129),new Je(Ee[4],2917565137),new Je(Ee[5],725511199),new Je(Ee[6],4215389547),new Je(Ee[7],327033209)]}function ft(e,t){let n,r,i,a,o,s,c,u,d,l,h,p;const f=[];for(n=t[0],r=t[1],i=t[2],a=t[3],o=t[4],s=t[5],c=t[6],u=t[7],h=0;h<80;h+=1)h<16?(p=2*h,f[h]=new Je(e[p],e[p+1])):f[h]=at(ut(f[h-2]),f[h-7],dt(f[h-15]),f[h-16]),d=ot(u,lt(o),tt(o,s,c),ht[h],f[h]),l=it(rt(n),nt(n,r,i)),u=c,c=s,s=o,o=it(a,d),a=i,i=r,r=n,n=it(d,l);return t[0]=it(n,t[0]),t[1]=it(r,t[1]),t[2]=it(i,t[2]),t[3]=it(a,t[3]),t[4]=it(o,t[4]),t[5]=it(s,t[5]),t[6]=it(c,t[6]),t[7]=it(u,t[7]),t}var mt=class extends Be{intermediateState;variantBlockSize;bigEndianMod;outputBinLen;isVariableLen;HMACSupported;converterFunc;roundFunc;finalizeFunc;stateCloneFunc;newStateFunc;getMAC;constructor(e,t,n){if("SHA-384"!==e&&"SHA-512"!==e)throw new Error(Oe);super(e,t,n);const r=n||{};this.getMAC=this._getHMAC,this.HMACSupported=!0,this.bigEndianMod=-1,this.converterFunc=be(this.inputFormat,this.utfType,this.bigEndianMod),this.roundFunc=ft,this.stateCloneFunc=function(e){return e.slice()},this.newStateFunc=pt,this.finalizeFunc=function(t,n,r,i){return function(e,t,n,r,i){let a,o;const s=31+(t+129>>>10<<5),c=t+n;for(;e.length<=s;)e.push(0);for(e[t>>>5]|=128<<24-t%32,e[s]=4294967295&c,e[s-1]=c/Ce|0,a=0;a<e.length;a+=32)r=ft(e.slice(a,a+32),r);return o="SHA-384"===i?[r[0].highOrder,r[0].lowOrder,r[1].highOrder,r[1].lowOrder,r[2].highOrder,r[2].lowOrder,r[3].highOrder,r[3].lowOrder,r[4].highOrder,r[4].lowOrder,r[5].highOrder,r[5].lowOrder]:[r[0].highOrder,r[0].lowOrder,r[1].highOrder,r[1].lowOrder,r[2].highOrder,r[2].lowOrder,r[3].highOrder,r[3].lowOrder,r[4].highOrder,r[4].lowOrder,r[5].highOrder,r[5].lowOrder,r[6].highOrder,r[6].lowOrder,r[7].highOrder,r[7].lowOrder],o}(t,n,r,i,e)},this.intermediateState=pt(e),this.variantBlockSize=1024,this.outputBinLen="SHA-384"===e?384:512,this.isVariableLen=!1,r.hmacKey&&this._setHMACKey(Te("hmacKey",r.hmacKey,this.bigEndianMod))}},gt=[new Je(0,1),new Je(0,32898),new Je(2147483648,32906),new Je(2147483648,2147516416),new Je(0,32907),new Je(0,2147483649),new Je(2147483648,2147516545),new Je(2147483648,32777),new Je(0,138),new Je(0,136),new Je(0,2147516425),new Je(0,2147483658),new Je(0,2147516555),new Je(2147483648,139),new Je(2147483648,32905),new Je(2147483648,32771),new Je(2147483648,32770),new Je(2147483648,128),new Je(0,32778),new Je(2147483648,2147483658),new Je(2147483648,2147516545),new Je(2147483648,32896),new Je(0,2147483649),new Je(2147483648,2147516424)],yt=[[0,36,3,41,18],[1,44,10,45,2],[62,6,43,15,61],[28,55,25,21,56],[27,20,39,8,14]];function wt(e){let t;const n=[];for(t=0;t<5;t+=1)n[t]=[new Je(0,0),new Je(0,0),new Je(0,0),new Je(0,0),new Je(0,0)];return n}function bt(e){let t;const n=[];for(t=0;t<5;t+=1)n[t]=e[t].slice();return n}function St(e,t){let n,r,i,a;const o=[],s=[];if(null!=e)for(r=0;r<e.length;r+=2)t[(r>>>1)%5][(r>>>1)/5|0]=st(t[(r>>>1)%5][(r>>>1)/5|0],new Je(e[r+1],e[r]));for(n=0;n<24;n+=1){for(a=wt(),r=0;r<5;r+=1)o[r]=ct(t[r][0],t[r][1],t[r][2],t[r][3],t[r][4]);for(r=0;r<5;r+=1)s[r]=st(o[(r+4)%5],Qe(o[(r+1)%5],1));for(r=0;r<5;r+=1)for(i=0;i<5;i+=1)t[r][i]=st(t[r][i],s[r]);for(r=0;r<5;r+=1)for(i=0;i<5;i+=1)a[i][(2*r+3*i)%5]=Qe(t[r][i],yt[r][i]);for(r=0;r<5;r+=1)for(i=0;i<5;i+=1)t[r][i]=st(a[r][i],new Je(~a[(r+1)%5][i].highOrder&a[(r+2)%5][i].highOrder,~a[(r+1)%5][i].lowOrder&a[(r+2)%5][i].lowOrder));t[0][0]=st(t[0][0],gt[n])}return t}function Ct(e){let t,n,r=0;const i=[0,0],a=[4294967295&e,e/Ce&2097151];for(t=6;t>=0;t--)n=a[t>>2]>>>8*t&255,0===n&&0===r||(i[r+1>>2]|=n<<8*(r+1),r+=1);return r=0!==r?r:1,i[0]|=r,{value:r+1>4?i:[i[0]],binLen:8+8*r}}function vt(e){return Me(Ct(e.binLen),e)}function Ut(e,t){let n,r=Ct(t);r=Me(r,e);const i=t>>>2,a=(i-r.value.length%i)%i;for(n=0;n<a;n++)r.value.push(0);return r.value}var Et=class extends Be{intermediateState;variantBlockSize;bigEndianMod;outputBinLen;isVariableLen;HMACSupported;converterFunc;roundFunc;finalizeFunc;stateCloneFunc;newStateFunc;getMAC;constructor(e,t,n){let r=6,i=0;super(e,t,n);const a=n||{};if(1!==this.numRounds){if(a.kmacKey||a.hmacKey)throw new Error(Ae);if("CSHAKE128"===this.shaVariant||"CSHAKE256"===this.shaVariant)throw new Error("Cannot set numRounds for CSHAKE variants")}switch(this.bigEndianMod=1,this.converterFunc=be(this.inputFormat,this.utfType,this.bigEndianMod),this.roundFunc=St,this.stateCloneFunc=bt,this.newStateFunc=wt,this.intermediateState=wt(),this.isVariableLen=!1,e){case"SHA3-224":this.variantBlockSize=i=1152,this.outputBinLen=224,this.HMACSupported=!0,this.getMAC=this._getHMAC;break;case"SHA3-256":this.variantBlockSize=i=1088,this.outputBinLen=256,this.HMACSupported=!0,this.getMAC=this._getHMAC;break;case"SHA3-384":this.variantBlockSize=i=832,this.outputBinLen=384,this.HMACSupported=!0,this.getMAC=this._getHMAC;break;case"SHA3-512":this.variantBlockSize=i=576,this.outputBinLen=512,this.HMACSupported=!0,this.getMAC=this._getHMAC;break;case"SHAKE128":r=31,this.variantBlockSize=i=1344,this.outputBinLen=-1,this.isVariableLen=!0,this.HMACSupported=!1,this.getMAC=null;break;case"SHAKE256":r=31,this.variantBlockSize=i=1088,this.outputBinLen=-1,this.isVariableLen=!0,this.HMACSupported=!1,this.getMAC=null;break;case"KMAC128":r=4,this.variantBlockSize=i=1344,this._initializeKMAC(n),this.outputBinLen=-1,this.isVariableLen=!0,this.HMACSupported=!1,this.getMAC=this._getKMAC;break;case"KMAC256":r=4,this.variantBlockSize=i=1088,this._initializeKMAC(n),this.outputBinLen=-1,this.isVariableLen=!0,this.HMACSupported=!1,this.getMAC=this._getKMAC;break;case"CSHAKE128":this.variantBlockSize=i=1344,r=this._initializeCSHAKE(n),this.outputBinLen=-1,this.isVariableLen=!0,this.HMACSupported=!1,this.getMAC=null;break;case"CSHAKE256":this.variantBlockSize=i=1088,r=this._initializeCSHAKE(n),this.outputBinLen=-1,this.isVariableLen=!0,this.HMACSupported=!1,this.getMAC=null;break;default:throw new Error(Oe)}this.finalizeFunc=function(e,t,n,a,o){return function(e,t,n,r,i,a,o){let s,c,u=0;const d=[],l=i>>>5,h=t>>>5;for(s=0;s<h&&t>=i;s+=l)r=St(e.slice(s,s+l),r),t-=i;for(e=e.slice(s),t%=i;e.length<l;)e.push(0);for(s=t>>>3,e[s>>2]^=a<<s%4*8,e[l-1]^=2147483648,r=St(e,r);32*d.length<o&&(c=r[u%5][u/5|0],d.push(c.lowOrder),!(32*d.length>=o));)d.push(c.highOrder),u+=1,0==64*u%i&&(St(null,r),u=0);return d}(e,t,0,a,i,r,o)},a.hmacKey&&this._setHMACKey(Te("hmacKey",a.hmacKey,this.bigEndianMod))}_initializeCSHAKE(e,t){const n=function(e){const t=e||{};return{funcName:Te("funcName",t.funcName,1,{value:[],binLen:0}),customization:Te("Customization",t.customization,1,{value:[],binLen:0})}}(e||{});t&&(n.funcName=t);const r=Me(vt(n.funcName),vt(n.customization));if(0!==n.customization.binLen||0!==n.funcName.binLen){const e=Ut(r,this.variantBlockSize>>>3);for(let t=0;t<e.length;t+=this.variantBlockSize>>>5)this.intermediateState=this.roundFunc(e.slice(t,t+(this.variantBlockSize>>>5)),this.intermediateState),this.processedLen+=this.variantBlockSize;return 4}return 31}_initializeKMAC(e){const t=function(e){const t=e||{};return{kmacKey:Te("kmacKey",t.kmacKey,1),funcName:{value:[1128353099],binLen:32},customization:Te("Customization",t.customization,1,{value:[],binLen:0})}}(e||{});this._initializeCSHAKE(e,t.funcName);const n=Ut(vt(t.kmacKey),this.variantBlockSize>>>3);for(let r=0;r<n.length;r+=this.variantBlockSize>>>5)this.intermediateState=this.roundFunc(n.slice(r,r+(this.variantBlockSize>>>5)),this.intermediateState),this.processedLen+=this.variantBlockSize;this.macKeySet=!0}_getKMAC(e){const t=Me({value:this.remainder.slice(),binLen:this.remainderLen},function(e){let t,n,r=0;const i=[0,0],a=[4294967295&e,e/Ce&2097151];for(t=6;t>=0;t--)n=a[t>>2]>>>8*t&255,0===n&&0===r||(i[r>>2]|=n<<8*r,r+=1);return r=0!==r?r:1,i[r>>2]|=r<<8*r,{value:r+1>4?i:[i[0]],binLen:8+8*r}}(e.outputLen));return this.finalizeFunc(t.value,t.binLen,this.processedLen,this.stateCloneFunc(this.intermediateState),e.outputLen)}},Ot=class{shaObj;constructor(e,t,n){if("SHA-1"===e)this.shaObj=new $e(e,t,n);else if("SHA-224"===e||"SHA-256"===e)this.shaObj=new Ge(e,t,n);else if("SHA-384"===e||"SHA-512"===e)this.shaObj=new mt(e,t,n);else{if("SHA3-224"!==e&&"SHA3-256"!==e&&"SHA3-384"!==e&&"SHA3-512"!==e&&"SHAKE128"!==e&&"SHAKE256"!==e&&"CSHAKE128"!==e&&"CSHAKE256"!==e&&"KMAC128"!==e&&"KMAC256"!==e)throw new Error(Oe);this.shaObj=new Et(e,t,n)}}update(e){return this.shaObj.update(e),this}getHash(e,t){return this.shaObj.getHash(e,t)}setHMACKey(e,t,n){this.shaObj.setHMACKey(e,t,n)}getHMAC(e,t){return this.shaObj.getHMAC(e,t)}},At=class{static generate(e,t){const n={digits:6,algorithm:"SHA-1",period:30,timestamp:Date.now(),...t},r=Math.floor(n.timestamp/1e3),i=this.leftpad(this.dec2hex(Math.floor(r/n.period)),16,"0"),a=new Ot(n.algorithm,"HEX");a.setHMACKey(this.base32tohex(e),"HEX"),a.update(i);const o=a.getHMAC("HEX"),s=this.hex2dec(o.substring(o.length-1));let c=(this.hex2dec(o.slice(2*s,2*s+8))&this.hex2dec("7fffffff"))+"";const u=Math.max(c.length-n.digits,0);c=c.substring(u,u+n.digits);return{otp:c,expires:Math.ceil((n.timestamp+1)/(1e3*n.period))*n.period*1e3}}static hex2dec(e){return parseInt(e,16)}static dec2hex(e){return(e<15.5?"0":"")+Math.round(e).toString(16)}static base32tohex(e){let t="",n="";const r=e.endsWith("=")?e.slice(0,e.lastIndexOf("=")):e;for(let i=0;i<r.length;i++){const n="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567".indexOf(e.charAt(i).toUpperCase());if(-1===n)throw new Error("Invalid base32 character in key");t+=this.leftpad(n.toString(2),5,"0")}for(let i=0;i+8<=t.length;i+=8){const e=t.slice(i,i+8);n+=this.leftpad(parseInt(e,2).toString(16),2,"0")}return n}static leftpad(e,t,n){return t+1>=e.length&&(e=Array(t+1-e.length).join(n)+e),e}};function Mt(e){if(!Array.isArray(e))throw new TypeError("Middleware stack must be an array!");for(const t of e)if("function"!=typeof t)throw new TypeError("Middleware must be composed of functions!");return function(t,n){let r=-1;return function i(a){if(a<=r)return Promise.reject(/* @__PURE__ */new Error("next() called multiple times"));r=a;let o=e[a];a===e.length&&n&&(o=n);if(!o)return Promise.resolve();try{return Promise.resolve(o(t,i.bind(null,a+1)))}catch(s){return Promise.reject(s)}}(0)}}var kt=["log","info","warn","error","assert"],Tt=(e=J)=>{if("undefined"==typeof console)return J;const t=kt.map(t=>ne(console,t,n=>{if("function"!=typeof n)return;const r=n;return function(...n){e(t,...n),r.apply(console,n)}}));return()=>t.forEach(e=>e())},Bt=(e,t=500)=>{let n,r=null,i=null;const a=()=>{if(r=null,!i)return;const t=i,a=n;i=null,n=void 0,e.apply(a,t)},o=function(...e){n=this,i=e,null!==r&&clearTimeout(r),r=setTimeout(a,t)};return o.cancel=()=>{null!==r&&clearTimeout(r),r=null,i=null,n=void 0},o.flush=()=>{null!==r&&(clearTimeout(r),a())},o.pending=()=>null!==r,o},Lt=(e,t)=>{if("undefined"==typeof document)return;const n=e.classList;n.contains(t)||n.add(t)},Ft=(e,t)=>{if("undefined"==typeof document)return;const n=e.classList;n.contains(t)&&n.remove(t)},Rt=e=>{if("undefined"==typeof document)return;const t=document.createDocumentFragment();return e.forEach(e=>t.appendChild(e)),t},Pt=/["'&<>]/;function Dt(e){const t=""+e,n=Pt.exec(t);if(!n)return t;let r,i="",a=0,o=0;for(a=n.index;a<t.length;a++){switch(t.charCodeAt(a)){case 34:r=""";break;case 38:r="&";break;case 39:r="'";break;case 60:r="<";break;case 62:r=">";break;default:continue}o!==a&&(i+=t.substring(o,a)),o=a+1,i+=r}return o!==a?i+t.substring(o,a):i}var xt=(e=375)=>{let t=e;const{documentElement:n}=document,r=window.matchMedia("(orientation: portrait)");let i,a=667/375;function o(){const e=!r.matches;let i=window.screen.width,o=window.screen.height;i<o&&([i,o]=[o,i]);let s=n.clientWidth,c=o;s/c>=a?(s=c*a,n.classList.remove("adjustHeight"),n.classList.add("adjustWidth")):(c=s/a,n.classList.remove("adjustWidth"),n.classList.add("adjustHeight"));let u=s/t*16;e&&(u/=a),n.style.fontSize=`${u}px`;const d=window.getComputedStyle(n).fontSize.replace("px","")||0;u!==d&&(n.style.fontSize=u/Number(d)*u+"px")}s()===c.IPAD&&(a=1024/768,t=768),window.addEventListener("resize",function(){clearTimeout(i),i=setTimeout(o,300)},!1),window.addEventListener("pageshow",function(e){e.persisted&&(clearTimeout(i),i=setTimeout(o,300))},!1),window.addEventListener("orientationchange",function(){o()},!1),o()},Ht=e=>{const t=e.style.height,n=e=>{const t=parseFloat(e);return Number.isFinite(t)?t:0},r=()=>{e.style.height="auto";const t=getComputedStyle(e),r="border-box"===t.boxSizing?n(t.borderTopWidth)+n(t.borderBottomWidth):-(n(t.paddingTop)+n(t.paddingBottom));e.style.height=`${e.scrollHeight+r}px`};return e.addEventListener("input",r),r(),()=>{e.removeEventListener("input",r),e.style.height=t}},It=(e=J)=>{if("undefined"==typeof window)return J;const t=t=>e(t),n=t=>e(t);return window.addEventListener("unhandledrejection",t,!0),window.addEventListener("error",n,!0),()=>{window.removeEventListener("unhandledrejection",t,!0),window.removeEventListener("error",n,!0)}},jt=class{ac;constructor(){this.ac=new AbortController}get signal(){return this.ac.signal}on(e,t,n,r){return e.addEventListener(t,n,{...r,signal:this.ac.signal}),this}delegate(e,t,n,r,i){return e.addEventListener(n,n=>{const i=n.target?.closest(t);i&&e.contains(i)&&r(n,i)},{...i,signal:this.ac.signal}),this}abort(){this.ac.abort(),this.ac=new AbortController}};function Nt(e={}){const{windowMs:t=300,maxDistancePx:n=60}=e;let r=-1/0,i=0,a=0;const o=()=>{r=-1/0,i=0,a=0};return{check:(e,s,c=Date.now())=>c-r<t&&Math.hypot(e-i,s-a)<n?(o(),!0):(r=c,i=e,a=s,!1),reset:o}}var zt={easeIn:function(e,t,n,r){return e>=r&&(e=r),n*(e/=r)*e+t},easeOut:function(e,t,n,r){return e>=r&&(e=r),-n*(e/=r)*(e-2)+t}},Kt={easeIn:function(e,t,n,r){return e>=r&&(e=r),n*(e/=r)*e*e+t},easeOut:function(e,t,n,r){return e>=r&&(e=r),n*((e=e/r-1)*e*e+1)+t}},Wt={easeIn:function(e,t,n,r){return e>=r&&(e=r),n*(e/=r)*e*e*e+t},easeOut:function(e,t,n,r){return e>=r&&(e=r),-n*((e=e/r-1)*e*e*e-1)+t}},_t={easeIn:function(e,t,n,r){return e>=r&&(e=r),n*(e/=r)*e*e*e*e+t},easeOut:function(e,t,n,r){return e>=r&&(e=r),n*((e=e/r-1)*e*e*e*e+1)+t}},qt={easeIn:function(e,t,n,r){return e>=r&&(e=r),-n*Math.cos(e/r*(Math.PI/2))+n+t},easeOut:function(e,t,n,r){return e>=r&&(e=r),n*Math.sin(e/r*(Math.PI/2))+t}},Vt={easeIn:function(e,t,n,r){return e>=r&&(e=r),0===e?t:n*Math.pow(2,10*(e/r-1))+t},easeOut:function(e,t,n,r){return e>=r&&(e=r),e===r?t+n:n*(1-Math.pow(2,-10*e/r))+t}},$t={easeIn:function(e,t,n,r){return e>=r&&(e=r),-n*(Math.sqrt(1-(e/=r)*e)-1)+t},easeOut:function(e,t,n,r){return e>=r&&(e=r),n*Math.sqrt(1-(e=e/r-1)*e)+t}},Xt=e=>t*e,Yt=(e,t)=>[+(Math.cos(e)*t).toFixed(8),+(Math.sin(e)*t).toFixed(8)],Gt=(e,t)=>{const n=-e/t;return[n,-n*e+t]},Jt=(e,t,n,r,i)=>{e.beginPath();const a=Xt(90/Math.PI/t*i),o=n+a,s=r-a;e.arc(0,0,t,o,s,!1),e.lineTo(...Yt((n+r)/2,i/2/Math.abs(Math.sin((n-r)/2)))),e.closePath()},Qt=(e,...[t,n,r,i,a])=>{const o=Math.min(r,i),s=Math.PI;a>o/2&&(a=o/2),e.beginPath(),e.moveTo(t+a,n),e.lineTo(t+a,n),e.lineTo(t+r-a,n),e.arc(t+r-a,n+a,a,-s/2,0),e.lineTo(t+r,n+i-a),e.arc(t+r-a,n+i-a,a,0,s/2),e.lineTo(t+a,n+i),e.arc(t+a,n+i-a,a,s/2,s),e.lineTo(t,n+a),e.arc(t+a,n+a,a,s,-s/2),e.closePath()},Zt=(e,t,n,r,i,a)=>{const o=/linear-gradient\((.+)\)/.exec(a)[1].split(",").map(e=>e.trim());let s=o.shift(),c=[0,0,0,0];if(s.includes("deg")){const e=Number(s.slice(0,-3))%360;s=`${e}`;const a=e=>Math.tan(e/180*Math.PI);e>=0&&e<45?c=[t,n+i,t+r,n+i-r*a(e-0)]:e>=45&&e<90?c=[t,n+i,t+r-i*a(e-45),n]:e>=90&&e<135?c=[t+r,n+i,t+r-i*a(e-90),n]:e>=135&&e<180?c=[t+r,n+i,t,n+r*a(e-135)]:e>=180&&e<225?c=[t+r,n,t,n+r*a(e-180)]:e>=225&&e<270?c=[t+r,n,t+i*a(e-225),n+i]:e>=270&&e<315?c=[t,n,t+i*a(e-270),n+i]:e>=315&&e<360&&(c=[t,n,t+r,n+i-r*a(e-315)])}else s.includes("top")?c=[t,n+i,t,n]:s.includes("bottom")?c=[t,n,t,n+i]:s.includes("left")?c=[t+r,n,t,n]:s.includes("right")&&(c=[t,n,t+r,n]);const u=e.createLinearGradient(...c.map(e=>e|0));return o.reduce((e,t,n)=>{const r=t.split(" ");return 1===r.length?e.addColorStop(n,r[0]):2===r.length&&e.addColorStop(Number(r[1]),r[0]),e},u)},en=e=>new Promise((t,n)=>{const r=new Image;r.onload=()=>t(r),r.onerror=e=>n(e),r.src=e}),tn=(e,t)=>{const n=document.createElement("canvas"),r=n.getContext("2d"),{width:i,height:a}=e;return n.width=i,n.height=a,Qt(r,0,0,i,a,t),r.clip(),r.drawImage(e,0,0,i,a),n},nn=(e,t)=>{const n=document.createElement("canvas"),r=n.getContext("2d"),{width:i,height:a}=e;if(n.width=i,n.height=a,"string"==typeof r.filter)r.filter=`opacity(${100*t}%)`,r.drawImage(e,0,0,i,a);else{r.drawImage(e,0,0,i,a);const n=r.getImageData(0,0,i,a),{data:o}=n,s=o.length;for(let e=0;e<s;e+=4){const n=o[e+3];0!==n&&(o[e+3]=n*t)}r.putImageData(n,0,0)}return n},rn=(e,t)=>{t=t||e/3;const n=Math.ceil(e),r=t*t,i=2*r,a=1/(2*Math.PI*r),o=[];let s=0;for(let c=-n;c<=n;c++)for(let e=-n;e<=n;e++){const t=a*Math.exp(-(c*c+e*e)/i);o.push(t),s+=t}for(let c=0;c<o.length;c++)o[c]/=s;return o},an=(e,t,n)=>new Promise((r,i)=>{if("undefined"==typeof window)return void i(/* @__PURE__ */new Error("isImageSize is browser-only: window is undefined"));const a=window.URL||window.webkitURL,o=new Image,s=a.createObjectURL(e),c=()=>a.revokeObjectURL(s);o.onload=()=>{c();const e=void 0===t||o.width===t,i=void 0===n||o.height===n;r(e&&i)},o.onerror=()=>{c(),i(/* @__PURE__ */new Error("failed to decode image"))},o.src=s}),on=e=>new Promise((t,n)=>{const r=new FileReader;r.onload=function(){t({success:!0,data:r.result,message:""})},r.onerror=e=>{n({success:!1,data:e,message:""})},r.readAsDataURL(e)}),sn=/* @__PURE__ */new Map,cn=/* @__PURE__ */new Map,un="data-adopted-style",dn="data-adopted-sheet",ln=(e,t,n)=>{if("undefined"==typeof CSSStyleSheet)return!1;try{if(!n.has(t)){const e=new CSSStyleSheet;e.replaceSync(t),n.set(t,e)}const r=n.get(t);return e.adoptedStyleSheets.includes(r)||(e.adoptedStyleSheets=[...e.adoptedStyleSheets,r]),!0}catch{return!1}},hn=(e,t,n=un)=>{if("undefined"!=typeof document&&t&&!ln(e,t,sn)&&!e.querySelector(`style[${n}]`)){const r=document.createElement("style");r.setAttribute(n,""),r.textContent=t,e.appendChild(r)}},pn=(e,t,n=dn)=>{if("undefined"!=typeof document&&t&&!ln(e,t,cn)&&!Array.from(e.querySelectorAll(`style[${n}]`)).some(e=>e.textContent===t)){const r=document.createElement("style");r.setAttribute(n,""),r.textContent=t,e.appendChild(r)}},fn=e=>({status:"success",code:0,data:e,error:!1}),mn=(e,t=null)=>({status:"error",code:1,data:t,error:!0,message:e}),gn=class{database;version;dbName;stores;upgrade;constructor({dbName:e,version:t,stores:n,upgrade:r}){this.dbName=e,this.version=t||1,this.stores=n||[],this.upgrade=r}openDataBase=()=>new Promise((e,t)=>{if("undefined"==typeof indexedDB)return void t(mn("indexedDB is not available"));const n=indexedDB.open(this.dbName,this.version);n.onsuccess=()=>{this.database=n.result,this.version=this.database.version,this.database.onversionchange=()=>{this.database?.close(),this.database=void 0},e(fn({db:this.database}))},n.onerror=()=>{if(n.error&&"VersionError"===n.error.name){const[,r]=(n.error.message||"").match(/\d+/g)||[];if(Number(r)>this.version)return this.version=Number(r),void this.refreshDatabase().then(e,t)}t(mn("open database error",n.error))},n.onupgradeneeded=e=>{const t=n.result;this.database=t,this.version=t.version;for(const r of this.stores){const e=t.objectStoreNames.contains(r.name)?n.transaction?.objectStore(r.name):t.createObjectStore(r.name,r.options);for(const t of r.indexes||[])e&&!e.indexNames.contains(t.name)&&e.createIndex(t.name,t.keyPath,t.options)}this.upgrade?.(t,e,n.transaction)}});closeDataBase=()=>{this.database?.close(),this.database=void 0};refreshDatabase=()=>(this.closeDataBase(),this.openDataBase());deleteDatabase=({dbName:e}={})=>new Promise((t,n)=>{const r=indexedDB.deleteDatabase(e??this.dbName);r.onsuccess=()=>t(fn(null)),r.onerror=()=>n(mn("delete database error",r.error))});getObjectStore=(e,t="readonly")=>{if(this.database)return this.database.transaction([e],t).objectStore(e)};run=(e,t,n,r,i)=>new Promise((a,o)=>{let s;try{const r=this.database?.transaction(e,t).objectStore(e);s=r&&n(r)}catch(u){return void o(mn(`${r} error`,u))}if(!s)return void o(mn(`${r} error`));const c=s;c.onsuccess=()=>a(fn(i(c))),c.onerror=()=>o(mn(`${r} error`,c.error))});add=({storeName:e,data:t})=>this.run(e,"readwrite",e=>e.add(t),"add",()=>t);update=({storeName:e,data:t})=>this.run(e,"readwrite",e=>e.put(t),"update",()=>null);readByKey=({storeName:e,key:t})=>this.run(e,"readonly",e=>e.get(t),"read",e=>e.result);readAll=({storeName:e,query:t,count:n})=>this.run(e,"readonly",e=>e.getAll(t,n),"read all",e=>e.result);count=({storeName:e,query:t})=>this.run(e,"readonly",e=>e.count(t),"count",e=>e.result);readByCursor=({storeName:e,keyRange:t,direction:n})=>new Promise((r,i)=>{const a=(this.database?.transaction(e,"readonly").objectStore(e))?.openCursor(t,n),o=[];a?(a.onsuccess=()=>{const e=a.result;e?(o.push(e.value),e.continue()):r(fn(o))},a.onerror=()=>i(mn("read cursor error",a.error))):i(mn("read cursor error"))});delete=({storeName:e,key:t})=>this.run(e,"readwrite",e=>e.delete(t),"delete",()=>null);clear=({storeName:e})=>this.run(e,"readwrite",e=>e.clear(),"clear",()=>null);collection=e=>{const t=(e,t)=>e.then(e=>e.data??t).catch(()=>t),n=e=>e.then(()=>!0).catch(()=>!1);return{name:e,get:t=>this.readByKey({storeName:e,key:t}).then(e=>e.data??null).catch(()=>null),all:()=>t(this.readByCursor({storeName:e}),[]),count:()=>t(this.count({storeName:e}),0),add:t=>n(this.add({storeName:e,data:t})),put:t=>n(this.update({storeName:e,data:t})),remove:t=>n(this.delete({storeName:e,key:t})),clear:()=>n(this.clear({storeName:e}))}}},yn=({dbName:e,storeName:t="files",key:n="pending"})=>{const r=()=>new Promise(n=>{if("undefined"==typeof indexedDB)return void n(null);let r;try{r=indexedDB.open(e,1)}catch{return void n(null)}r.onupgradeneeded=()=>{r.result.objectStoreNames.contains(t)||r.result.createObjectStore(t)},r.onerror=()=>n(null),r.onblocked=()=>n(null),r.onsuccess=()=>n(r.result)});return{put:async e=>{const i=await r();return!!i&&new Promise(r=>{try{const a=i.transaction(t,"readwrite");a.objectStore(t).put(e,n),a.oncomplete=()=>{i.close(),r(!0)},a.onerror=a.onabort=()=>{i.close(),r(!1)}}catch{i.close(),r(!1)}})},take:async()=>{const e=await r();return e?new Promise(r=>{try{const i=e.transaction(t,"readwrite"),a=i.objectStore(t),o=a.get(n);let s=null;o.onsuccess=()=>{s=o.result??null,null!==s&&a.delete(n)},i.oncomplete=()=>{e.close(),r(s)},i.onerror=i.onabort=()=>{e.close(),r(null)}}catch{e.close(),r(null)}}):null}}},wn=e=>{const t=Array.from({length:e.length});let n=0;for(let r=0;r<e.length;r++)t[r]=n,n+=e[r]||0;return t},bn=(e,t)=>{if(0===e.length)return 0;let n=0,r=e.length-1,i=0;for(;n<=r;){const a=n+r>>1;e[a]<=t?(i=a,n=a+1):r=a-1}return i},Sn=(e,t,n)=>{const r=t+e.length,i=n.map(e=>({value:e.value,s:Math.max(e.start,t)-t,e:Math.min(e.end,r)-t})).filter(e=>e.e>e.s).sort((e,t)=>e.s-t.s||e.e-t.e),a=[],o=(n,r,i)=>{a.push({text:e.slice(n,r),start:t+n,end:t+r,value:i})};let s=0;for(const c of i){let e=c.s;if(e<s){if(c.e<=s)continue;e=s}e>s&&o(s,e,null),o(e,c.e,c.value),s=c.e}return s<e.length&&o(s,e.length,null),0===a.length&&o(0,e.length,null),a},Cn=(()=>{const e=/* @__PURE__ */new Uint8Array(128);for(let t=0;t<78;t++)e["abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-.,!?;:'\"()[]{}".charCodeAt(t)]=1;return e})(),vn=e=>e<128&&1===Cn[e],Un={pages:[],charsPerLine:0,linesPerPage:0,charsPerPage:0},En=(e,t,n,r={})=>{const i=e.replace(/(?:\r\n|\r|\n)+/g,"\n")||"",a=i.length,o=r.minBox??30,{charWidth:s,lineHeight:c}=n,u=n.narrowRatio??.5625;if(t.width<o||t.height<o||s<=0||c<=0)return{...Un,total:a};const d=Math.floor(t.width/s),l=Math.floor(t.height/c),h=d*l;if(d<=0||l<=0)return{...Un,total:a};const p=e=>{let t=e,n=e;for(;t<a;){const e=i.charCodeAt(t);if(vn(e))t++;else{if(32===e){n=t,t++;break}t++}}return n},f=e=>{let t=e,n=e;for(;t>0;){const e=i.charCodeAt(t-1);if(vn(e))n=t-1,t--;else{if(32===e)break;t--}}return n},m=[];let g=0;for(;a>g;){let e=0,t=0;const n=g;let r=h;for(;e<l&&t<h&&g<a;){const n=i.charCodeAt(g);if(10===n||13===n){e++,t=0,g++,r--;continue}const a=vn(n);if(t>=d){if(a){const n=f(g);if(p(g)-n>d){e++,t=0;continue}}e++,t=0}else g++,t+=a?u:1,r--}if(g<a&&vn(i.charCodeAt(g))){const e=f(g);p(g)-e>r&&e>n&&(g=e)}if(g===n)break;m.push({text:i.slice(n,g),start:n,end:g,index:m.length})}return{pages:m,total:a,charsPerLine:d,linesPerPage:l,charsPerPage:h}},On=e=>{const t=e.search(/[?#]/);return-1===t?[e,""]:[e.slice(0,t),e.slice(t)]},An=e=>{const t=e.locales.length>0?e.locales:[{code:"en"}],n=(e=>{const t=e.trim().replace(/\/+$/,"");return t?t.startsWith("/")?t:`/${t}`:""})(e.base??""),r=e.defaultLocale??(t.find(e=>!e.prefix)??t[0]).code,i=t.filter(e=>e.prefix).sort((e,t)=>t.prefix.length-e.prefix.length),a=e=>{const t=e||"/";return n?t===n?"/":t.startsWith(`${n}/`)?t.slice(n.length):t.startsWith("/")?t:`/${t}`:t.startsWith("/")?t:`/${t}`},o=e=>{const t=e.split("/").filter(Boolean)[0],n=t?i.find(e=>e.prefix===t):void 0;if(!n)return{code:r,rest:e};const a=e.slice(n.prefix.length+1)||"/";return{code:n.code,rest:a.startsWith("/")?a:`/${a}`}},s=(e,i=r)=>{const[s,c]=On(e),{rest:u}=o(a(s)),{prefix:d}=(e=>t.find(t=>t.code===e)??{code:r})(i);return`${n}${d?`/${d}${u}`:u}${c}`||"/"};return{base:n,defaultLocale:r,localeFromPath:e=>o(a(On(e)[0])).code,stripLocale:e=>{const[t,r]=On(e);return`${n}${o(a(t)).rest}${r}`},href:s,hrefForLocale:(e,t)=>s(e,t),alternates:e=>t.map(t=>({code:t.code,href:s(e,t.code)}))}},Mn=e=>{const{anchor:t,floating:n,offset:r=0,padding:i=8}=e,a=e.boundary??{top:0,left:0,width:"undefined"!=typeof window?window.innerWidth:1/0,height:"undefined"!=typeof window?window.innerHeight:1/0};let o=e.placement;const s="top"===o||"bottom"===o,c=t.width>0&&t.height>0&&n.width>0&&n.height>0;if(c&&s){const e=a.top+a.height-(t.top+t.height),i=t.top-a.top;"bottom"===o&&e<n.height+r&&i>e?o="top":"top"===o&&i<n.height+r&&e>i&&(o="bottom")}else if(c){const e=a.left+a.width-(t.left+t.width),i=t.left-a.left;"right"===o&&e<n.width+r&&i>e?o="left":"left"===o&&i<n.width+r&&e>i&&(o="right")}let u,d;if("bottom"===o?(u=t.top+t.height+r,d=t.left):"top"===o?(u=t.top-n.height-r,d=t.left):"right"===o?(u=t.top,d=t.left+t.width+r):(u=t.top,d=t.left-n.width-r),c&&s){const e=a.left+i,t=a.left+a.width-n.width-i;t>=e&&(d=Math.min(Math.max(d,e),t))}else if(c){const e=a.top+i,t=a.top+a.height-n.height-i;t>=e&&(u=Math.min(Math.max(u,e),t))}return{top:u,left:d,placement:o}},kn=(e,t,n)=>new Promise((r,i)=>{if("undefined"==typeof FileReader)return void i(/* @__PURE__ */new Error("FileReader is not available"));const a=new FileReader;a.onload=()=>r(a.result),a.onerror=()=>i(a.error??/* @__PURE__ */new Error("read file error")),a.onabort=()=>i(/* @__PURE__ */new Error("read file aborted")),"arrayBuffer"===t?a.readAsArrayBuffer(e):"text"===t?a.readAsText(e,n):"dataURL"===t?a.readAsDataURL(e):a.readAsBinaryString(e)}),Tn=e=>kn(e,"arrayBuffer"),Bn=async e=>new Uint8Array(await Tn(e)),Ln=(e,t)=>kn(e,"text",t),Fn=e=>kn(e,"dataURL"),Rn=e=>{const t=e instanceof Uint8Array?e:new Uint8Array(e);let n="";for(let r=0;r<t.length;r+=32768)n+=String.fromCharCode.apply(null,Array.from(t.subarray(r,r+32768)));return btoa(n)},Pn=e=>{const t=e.startsWith("data:")?e.slice(e.indexOf(",")+1):e,n=atob(t),r=new Uint8Array(n.length);for(let i=0;i<n.length;i++)r[i]=n.charCodeAt(i);return r},Dn=e=>e.length>=2&&31===e[0]&&139===e[1],xn=e=>e.length>=4&&80===e[0]&&75===e[1]&&3===e[2]&&4===e[3],Hn=e=>{if(e.length<8||xn(e))return!1;const t=239===e[0]&&187===e[1]&&191===e[2]?3:0,n=new TextDecoder("latin1").decode(e.subarray(t,t+2048)).replace(/^\s+/,"");return/^<(!doctype\s+html|html|head|body|table|meta|\?xml[^>]*>\s*<html)/i.test(n)},In=async e=>{if(!Dn(e))return e;if("undefined"==typeof DecompressionStream)throw new Error("DecompressionStream is not available in this runtime");const t=new Response(e).body.pipeThrough(new DecompressionStream("gzip"));return new Uint8Array(await new Response(t).arrayBuffer())},jn=async(e,t)=>{const n=await fetch(e,t);if(!n.ok)throw new Error(`Failed to fetch '${String(e)}' (${n.status} ${n.statusText})`);return In(new Uint8Array(await n.arrayBuffer()))},Nn=(e,t=["utf-8","gb18030","latin1"])=>{if(e.length>=3&&239===e[0]&&187===e[1]&&191===e[2])return new TextDecoder("utf-8").decode(e.subarray(3));for(let n=0;n<t.length;n++){const r=n===t.length-1;try{return new TextDecoder(t[n],{fatal:!r}).decode(e)}catch{}}return new TextDecoder("latin1").decode(e)},zn=async(e,t,n={})=>{const r=e instanceof Blob?e:new Blob([e],{type:n.mimeType}),i=globalThis.showSaveFilePicker;if("function"==typeof i){const e=t.includes(".")?`.${t.split(".").pop()}`:"";try{const a=await(await i({suggestedName:t,types:[{description:n.description||"File",accept:{[n.mimeType||r.type||"application/octet-stream"]:e?[e]:[]}}]})).createWritable();return await a.write(r),await a.close(),!0}catch(s){if("AbortError"===s?.name)return!1;throw s}}const a=URL.createObjectURL(r),o=document.createElement("a");return o.href=a,o.download=t,o.style.display="none",document.body.appendChild(o),o.click(),setTimeout(()=>{o.remove(),URL.revokeObjectURL(a)},100),!0},Kn=class{worker=null;nextOperationId=1;pending=/* @__PURE__ */new Map;options;constructor(e){this.options=e}get active(){return null!==this.worker}get pendingCount(){return this.pending.size}send=(e,t,n)=>{const r=this.nextOperationId++;return new Promise((i,a)=>{const o={resolve:i,reject:a,onProgress:t};this.options.timeout&&(o.timer=setTimeout(()=>{this.pending.delete(r),a(/* @__PURE__ */new Error(`worker request timed out after ${this.options.timeout}ms`))},this.options.timeout)),this.pending.set(r,o);try{this.getWorker().postMessage({...e,operationId:r},n??[])}catch(s){this.settle(r),a(s instanceof Error?s:new Error(String(s)))}})};dispose=()=>{this.worker?.terminate(),this.worker=null,this.rejectAll(/* @__PURE__ */new Error("worker disposed"))};getWorker=()=>(this.worker||(this.worker=this.options.create(),this.worker.onmessage=e=>this.handleMessage(e.data),this.worker.onerror=e=>this.rejectAll(new Error(e.message||"worker crashed"))),this.worker);settle=e=>{const t=this.pending.get(e);return t?.timer&&clearTimeout(t.timer),this.pending.delete(e),t};handleMessage=e=>{const t=this.pending.get(e.operationId);if(!t)return;const{isProgress:n,getProgress:r,isError:i,getErrorMessage:a}=this.options;if(n?n(e):"progress"===e.type){const n=r?r(e):e.progress;return void t.onProgress?.(n)}if(this.settle(e.operationId),i?i(e):"error"===e.type){const n=a?a(e):e.message;t.reject(new Error(n||"worker error"))}else t.resolve(e)};rejectAll=e=>{for(const[t,n]of this.pending)n.timer&&clearTimeout(n.timer),n.reject(e),this.pending.delete(t)}},Wn=(e,t={})=>{const n=t.scope??globalThis;if(!n||"function"!=typeof n.addEventListener)return()=>{};const r=t.resultType??"result",i=t=>{const i=t.data;if(!i||"number"!=typeof i.operationId)return;const{operationId:a}=i,o=e=>n.postMessage({...e,operationId:a}),s={progress:e=>o({type:"progress",progress:e})};Promise.resolve().then(()=>e(i,s)).then(e=>o("object"==typeof e&&null!==e?e:{type:r,result:e}),e=>o({type:"error",message:e instanceof Error?e.message:String(e)}))};return n.addEventListener("message",i),()=>n.removeEventListener("message",i)},_n=()=>"undefined"!=typeof window,qn=(e,t={})=>{const{timeout:n=8e3,fallbackDelay:r=2500}=t;if(!_n())return()=>{};const i=window.requestIdleCallback;if(i){const t=i(e,{timeout:n});return()=>window.cancelIdleCallback?.(t)}const a=setTimeout(e,r);return()=>clearTimeout(a)},Vn=(e={})=>{const{optOutKey:t,slowTypes:n=["slow-2g","2g"]}=e;if(!_n())return!1;if(t)try{if(localStorage.getItem(t))return!1}catch{}const r=navigator.connection;return!r?.saveData&&(!r?.effectiveType||!n.includes(r.effectiveType))},$n=async e=>{if("undefined"==typeof caches)return!1;try{return Boolean(await caches.match(e))}catch{return!1}},Xn=async e=>{try{if(await $n(e))return;await fetch(e,{cache:"force-cache"})}catch{}},Yn=async(e,t={})=>{if(!(0===e.length||t.serviceWorkerMessage&&((e,t)=>{try{const n="undefined"!=typeof navigator&&"serviceWorker"in navigator?navigator.serviceWorker.controller:null;return!!n&&(n.postMessage({type:t,urls:e}),!0)}catch{return!1}})(e,t.serviceWorkerMessage)))for(const n of e)await Xn(n)},Gn=(e,t={})=>Vn(t)?qn(()=>{Yn(e,t)},t):()=>{},Jn=()=>{let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}},Qn=class extends Error{constructor(e){super(e),this.name="TimeoutError"}},Zn=(e,t,n={})=>{const{message:r=`operation timed out after ${t}ms`,onTimeout:i}=n;return new Promise((n,a)=>{const o=setTimeout(()=>{i?.(),a(new Qn(r))},t);e.then(e=>{clearTimeout(o),n(e)},e=>{clearTimeout(o),a(e)})})},er=(e,t,n,r)=>new Promise((i,a)=>{const o=setTimeout(()=>{r?.(),i(n)},t);e.then(e=>{clearTimeout(o),i(e)},e=>{clearTimeout(o),a(e)})}),tr=e=>new Promise(t=>setTimeout(t,e)),nr=()=>{let e=0;return{start:()=>++e,isCurrent:t=>t===e}},rr=67324752,ir=33639248,ar=101010256,or=30,sr=46,cr=0,ur=8,dr=(e,t)=>e[t]|e[t+1]<<8,lr=(e,t)=>(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0,hr=/* @__PURE__ */(()=>{const e=/* @__PURE__ */new Uint32Array(256);for(let t=0;t<256;t++){let n=t;for(let e=0;e<8;e++)n=1&n?3988292384^n>>>1:n>>>1;e[t]=n}return e})(),pr=e=>{let t=4294967295;for(let n=0;n<e.length;n++)t=(hr[255&(t^e[n])]??0)^t>>>8;return(4294967295^t)>>>0},fr=async e=>{if("undefined"==typeof DecompressionStream)throw new Error("DecompressionStream is not available in this runtime");const t=new DecompressionStream("deflate-raw"),n=t.writable.getWriter(),r=t.readable.getReader();n.write(e),n.close();const i=[];for(;;){const{done:e,value:t}=await r.read();if(e)break;t&&i.push(t)}return mr(i)},mr=e=>{let t=0;for(const i of e)t+=i.length;const n=new Uint8Array(t);let r=0;for(const i of e)n.set(i,r),r+=i.length;return n},gr=e=>{const t=(e=>{const t=Math.max(0,e.length-65558);for(let n=e.length-22;n>=t;n--)if(lr(e,n)===ar)return n;return-1})(e);if(-1===t)return[];const n=dr(e,t+10),r=[];let i=lr(e,t+16);for(let a=0;a<n&&!(i+sr>e.length)&&lr(e,i)===ir;a++){const t=dr(e,i+10),n=dr(e,i+12),a=dr(e,i+14),o=lr(e,i+16),s=lr(e,i+20),c=lr(e,i+24),u=dr(e,i+28),d=dr(e,i+30),l=dr(e,i+32),h=lr(e,i+42),p=e.slice(i+sr,i+sr+u),f=new TextDecoder("utf-8",{fatal:!1}).decode(p),m=h+or<=e.length,g=m?dr(e,h+26):0,y=m?dr(e,h+28):0,w=i;i+=sr+u+d+l,r.push({name:f,compression:t,crc:o,compressedSize:s,uncompressedSize:c,modTime:n,modDate:a,directory:f.endsWith("/"),dataStart:h+or+g+y,nameBytes:p,localOffset:h,centralStart:w,centralEnd:i})}return r},yr=(e,t)=>gr(e).some(e=>e.name===t),wr=async(e,t)=>{const n="string"==typeof t?gr(e).find(e=>e.name===t):t;if(!n||n.directory)return null;if(n.dataStart+n.compressedSize>e.length)return null;const r=e.slice(n.dataStart,n.dataStart+n.compressedSize);if(0===n.compression)return r;if(8!==n.compression)return null;try{return await fr(r)}catch{return null}},br=(e,t,n,r=0,i=0)=>{const a=new Uint8Array(or+e.length),o=new DataView(a.buffer);return o.setUint32(0,rr,!0),o.setUint16(4,20,!0),o.setUint16(6,0,!0),o.setUint16(8,0,!0),o.setUint16(10,r,!0),o.setUint16(12,i,!0),o.setUint32(14,n,!0),o.setUint32(18,t,!0),o.setUint32(22,t,!0),o.setUint16(26,e.length,!0),a.set(e,or),a},Sr=(e,t,n,r,i=0,a=0)=>{const o=new Uint8Array(sr+e.length),s=new DataView(o.buffer);return s.setUint32(0,ir,!0),s.setUint16(4,20,!0),s.setUint16(6,20,!0),s.setUint16(8,0,!0),s.setUint16(10,0,!0),s.setUint16(12,i,!0),s.setUint16(14,a,!0),s.setUint32(16,n,!0),s.setUint32(20,t,!0),s.setUint32(24,t,!0),s.setUint16(28,e.length,!0),s.setUint32(42,r,!0),o.set(e,sr),o},Cr=e=>"string"==typeof e?(new TextEncoder).encode(e):e,vr=async(e,t={})=>{const{filter:n,transform:r,inject:i}=t,a=gr(e);if(0===a.length)return e;const o=/* @__PURE__ */new Map;if(r)for(const g of a)if(!g.directory&&(!n||n(g)))try{const t=await wr(e,g);if(!t)continue;const n=await r(t,g);if(null==n)continue;const i=Cr(n);if(i.length===t.length&&i.every((e,n)=>e===t[n]))continue;o.set(g,i)}catch{}const s=(i??[]).map(({name:e,data:t})=>({nameBytes:(new TextEncoder).encode(e),data:Cr(t)}));if(0===o.size&&0===s.length)return e;const c=[],u=[];let d=0;for(const g of a){u.push(d);const t=o.get(g);if(t){const e=br(g.nameBytes,t.length,pr(t),g.modTime,g.modDate);c.push(e,t),d+=e.length+t.length;continue}const n=new Uint8Array(or+g.nameBytes.length),r=new DataView(n.buffer);r.setUint32(0,rr,!0),r.setUint16(4,20,!0),r.setUint16(6,0,!0),r.setUint16(8,g.compression,!0),r.setUint16(10,g.modTime,!0),r.setUint16(12,g.modDate,!0),r.setUint32(14,g.crc,!0),r.setUint32(18,g.compressedSize,!0),r.setUint32(22,g.uncompressedSize,!0),r.setUint16(26,g.nameBytes.length,!0),n.set(g.nameBytes,or);const i=e.slice(g.dataStart,g.dataStart+g.compressedSize);c.push(n,i),d+=n.length+i.length}const l=[];for(const g of s){l.push(d);const e=br(g.nameBytes,g.data.length,pr(g.data));c.push(e,g.data),d+=e.length+g.data.length}const h=d;for(let g=0;g<a.length;g++){const t=a[g],n=o.get(t);if(n){const e=Sr(t.nameBytes,n.length,pr(n),u[g],t.modTime,t.modDate);c.push(e),d+=e.length;continue}const r=new Uint8Array(e.slice(t.centralStart,t.centralEnd)),i=new DataView(r.buffer);i.setUint16(8,-9&dr(r,8),!0),i.setUint32(42,u[g],!0),c.push(r),d+=r.length}for(let g=0;g<s.length;g++){const e=s[g],t=Sr(e.nameBytes,e.data.length,pr(e.data),l[g]);c.push(t),d+=t.length}const p=a.length+s.length,f=new Uint8Array(22),m=new DataView(f.buffer);return m.setUint32(0,ar,!0),m.setUint16(8,p,!0),m.setUint16(10,p,!0),m.setUint32(12,d-h,!0),m.setUint32(16,h,!0),c.push(f),mr(c)},Ur=e=>{const t=[],n=[];let r=0;for(const s of e){const e=(new TextEncoder).encode(s.name),i=Cr(s.data),a=pr(i),o=br(e,i.length,a);n.push(Sr(e,i.length,a,r)),t.push(o,i),r+=o.length+i.length}const i=r;for(const s of n)t.push(s),r+=s.length;const a=new Uint8Array(22),o=new DataView(a.buffer);return o.setUint32(0,ar,!0),o.setUint16(8,e.length,!0),o.setUint16(10,e.length,!0),o.setUint32(12,r-i,!0),o.setUint32(16,i,!0),t.push(a),mr(t)};function Er(){if("undefined"!=typeof window){const[e]=performance.getEntriesByType("navigation"),[t={},n={}]=performance.getEntriesByType("paint"),{startTime:r}=t,{startTime:i}=n,{domainLookupEnd:a,domainLookupStart:o,connectEnd:s,connectStart:c,secureConnectionStart:u,loadEventStart:d,domInteractive:l,domContentLoadedEventEnd:h,duration:p,responseStart:f,requestStart:m,responseEnd:g,fetchStart:y,transferSize:w,encodedBodySize:b,redirectEnd:S,redirectStart:C,redirectCount:v}=e;return{dnsSearch:a-o,tcpConnect:s-c,sslConnect:s-u,request:f-m,response:g-f,parseDomTree:l-g,resource:d-h,domReady:h-y,interactive:l-y,complete:d-y,httpHead:w-b,redirect:v,redirectTime:S-C,duration:p,fp:r,fcp:i}}}var Or={},Ar=e=>{"string"==typeof e?Or.url=e:Object.assign(Or,e)},Mr=()=>Or.url??"",kr=({url:e,type:t="application/json; charset=UTF-8",payload:n={}})=>{const r=e||Mr();return!!r&&((({url:e="",type:t="application/json; charset=UTF-8",payload:n={}})=>{if("undefined"==typeof navigator||!navigator.sendBeacon||!e)return!1;const r=new Blob([JSON.stringify(n)],{type:t});return navigator.sendBeacon(e,r)})({url:r,type:t,payload:n})||(({url:e="",payload:t={}})=>{if("undefined"==typeof document||!e)return!1;const n=new Image;return n.width=1,n.height=1,n.src=`${e}?${Q(t)}`,!0})({url:r,payload:n}))};function Tr(e={}){if("undefined"==typeof window)return{};const{width:t,height:n}=d();return{id:o(),path:window.location.href,time:Date.now(),referrer:document.referrer,ratio:`${t}x${n}`,userAgent:window.navigator.userAgent,...Or.userIdCookie?{userId:u(Or.userIdCookie)}:{},...e}}var Br=(e={})=>{if("undefined"==typeof window)return J;const{requestHook:t=J,responseHook:n=J,errorHook:r=J}=e;return ne(window,"fetch",e=>{if("function"!=typeof e)return;const i=e;return(e,a)=>(t(e,a),i.apply(window,[e,a]).then(t=>(n(e,a,t),t)).catch(t=>{throw r(e,t),t}))})},Lr=(e={})=>{if("undefined"==typeof window||"undefined"==typeof XMLHttpRequest)return J;const t=XMLHttpRequest.prototype,{requestHook:n=J,responseHook:r=J,errorHook:i=J}=e,a=ne(t,"open",e=>{if("function"!=typeof e)return;const t=e;return function(...e){n(e),t.apply(this,e)}}),o=ne(t,"send",e=>{if("function"!=typeof e)return;const t=e;return function(...e){this.addEventListener("loadend",()=>r(this),{once:!0}),this.addEventListener("error",()=>i(this),{once:!0}),t.apply(this,e)}});return()=>{o(),a()}};function Fr(e,t=300){let n,r=0,i=null,a=null;const o=()=>{if(i=null,!a)return;const t=a,o=n;a=null,n=void 0,r=Date.now(),e.apply(o,t)},s=function(...e){const s=t-(Date.now()-r);n=this,a=e,s<=0?(null!==i&&(clearTimeout(i),i=null),o()):null===i&&(i=setTimeout(o,s))};return s.cancel=()=>{null!==i&&clearTimeout(i),i=null,a=null,n=void 0},s.pending=()=>null!==i,s}var Rr={click:!0,error:!0,fetch:!0,xhr:!0,performance:!0,console:!1},Pr=class{options;teardown=[];send=J;constructor(e){this.options=e,Ar({url:e.url,userIdCookie:e.userIdCookie}),this.send=Fr(e=>kr(e),e.throttleMs??300)}get running(){return this.teardown.length>0}start=()=>{if(this.running)return this.stop;const e={...Rr,...this.options.channels};return e.performance&&this.reportPerformance(),e.click&&this.teardown.push(this.reportClick()),e.error&&this.teardown.push(this.reportError()),e.fetch&&this.teardown.push(this.reportFetch()),e.xhr&&this.teardown.push(this.reportXhr()),e.console&&this.teardown.push(this.reportConsole()),this.stop};stop=()=>{const e=this.teardown.splice(0,this.teardown.length);for(const t of e)t()};event=(e,t)=>({payload:{...Tr(),data:t,type:e}});log=e=>{this.send({payload:{...Tr(),...e}})};reportPerformance=()=>{kr({payload:{...Er(),...Tr(),type:"performance"}})};reportClick=()=>((e=J)=>{if("undefined"==typeof document)return J;const t=t=>e(t);return document.addEventListener("click",t,!0),()=>document.removeEventListener("click",t,!0)})(e=>{const{pageX:t,pageY:n,screenX:r,screenY:i,type:a}=e;this.send(this.event("click",{pageX:t,pageY:n,screenX:r,screenY:i,type:a}))});reportError=()=>It((...e)=>this.send(this.event("error",{...e})));reportFetch=()=>Br({requestHook:(...e)=>this.send(this.event("fetchRequest",{...e})),responseHook:(...e)=>this.send(this.event("fetchResponse",{...e})),errorHook:(...e)=>this.send(this.event("fetchError",{...e}))});reportXhr=()=>Lr({requestHook:(...e)=>this.send(this.event("xhrRequest",{...e})),responseHook:(...e)=>this.send(this.event("xhrResponse",{...e})),errorHook:(...e)=>this.send(this.event("xhrError",{...e}))});reportConsole=()=>Tt((...e)=>this.send(this.event("console",{...e})))},Dr=/* @__PURE__ */new Map([[100,"Continue"],[101,"Switching Protocols"],[102,"Processing"],[103,"Early Hints"],[200,"OK"],[201,"Created"],[202,"Accepted"],[203,"Non-Authoritative Information"],[204,"No Content"],[205,"Reset Content"],[206,"Partial Content"],[207,"Multi-Status"],[208,"Already Reported"],[226,"IM Used"],[300,"Multiple Choices"],[301,"Moved Permanently"],[302,"Found"],[303,"See Other"],[304,"Not Modified"],[305,"Use Proxy"],[307,"Temporary Redirect"],[308,"Permanent Redirect"],[400,"Bad Request"],[401,"Unauthorized"],[402,"Payment Required"],[403,"Forbidden"],[404,"Not Found"],[405,"Method Not Allowed"],[406,"Not Acceptable"],[407,"Proxy Authentication Required"],[408,"Request Timeout"],[409,"Conflict"],[410,"Gone"],[411,"Length Required"],[412,"Precondition Failed"],[413,"Payload Too Large"],[414,"URI Too Long"],[415,"Unsupported Media Type"],[416,"Range Not Satisfiable"],[417,"Expectation Failed"],[418,"I'm a Teapot"],[421,"Misdirected Request"],[422,"Unprocessable Entity"],[423,"Locked"],[424,"Failed Dependency"],[425,"Too Early"],[426,"Upgrade Required"],[428,"Precondition Required"],[429,"Too Many Requests"],[431,"Request Header Fields Too Large"],[451,"Unavailable For Legal Reasons"],[500,"Internal Server Error"],[501,"Not Implemented"],[502,"Bad Gateway"],[503,"Service Unavailable"],[504,"Gateway Timeout"],[505,"HTTP Version Not Supported"],[506,"Variant Also Negotiates"],[507,"Insufficient Storage"],[508,"Loop Detected"],[509,"Bandwidth Limit Exceeded"],[510,"Not Extended"],[511,"Network Authentication Required"]]),xr={message:Dr,code:function(e){const t=/* @__PURE__ */new Map;for(const[n,r]of e)t.set(r.toLowerCase(),n);return t}(Dr),codes:function(e){const t=[];for(const[n,r]of e)t.push(n);return t}(Dr),redirect:{300:!0,301:!0,302:!0,303:!0,305:!0,307:!0,308:!0},empty:{204:!0,205:!0,304:!0},retry:{502:!0,503:!0,504:!0}};function Hr(e){if(!xr.message.has(e))throw new Error("invalid status code: "+e);return xr.message.get(e)}function Ir(e){if("number"==typeof e)return Hr(e);if("string"!=typeof e)throw new TypeError("code must be a number or string");const t=parseInt(e,10);return!isNaN(t)&&xr.codes.includes(t)?Hr(t):function(e){const t=e.toLowerCase();if(xr.code.has(t),!xr.code.has(t))throw new Error('invalid status message: "'+e+'"');return xr.code.get(t)}(e)}var jr=class{running=0;executed=0;simultaneous;queue=[];idleWaiters=[];constructor({simultaneous:e=1}={}){this.simultaneous=Math.max(1,e)}get pending(){return this.queue.length}get idle(){return 0===this.queue.length&&0===this.running}add=e=>"function"!=typeof e?Promise.reject(/* @__PURE__ */new TypeError("QuestQueue.add expects a function")):new Promise((t,n)=>{this.queue.push({task:e,resolve:t,reject:n}),this.next()});allSettled=e=>Promise.allSettled(e.map(e=>this.add(e)));onIdle=()=>this.idle?Promise.resolve():new Promise(e=>this.idleWaiters.push(e));clear=()=>{const e=this.queue.splice(0,this.queue.length);for(const t of e)t.reject(/* @__PURE__ */new Error("QuestQueue cleared"));this.settleIdle()};next=()=>{for(;this.running<this.simultaneous&&this.queue.length>0;){const e=this.queue.shift();this.running++,Promise.resolve().then(e.task).then(e.resolve,e.reject).finally(()=>{this.running--,this.executed++,this.settleIdle(),this.next()})}};settleIdle=()=>{if(!this.idle)return;const e=this.idleWaiters.splice(0,this.idleWaiters.length);for(const t of e)t()}},Nr=/* @__PURE__ */new Set,zr=({type:e,content:t})=>new Promise((n,r)=>{const a=i(`${e}:${t}`);if(Nr.has(a))return void n({success:!0});const o=document.createElement("script");if(o.onload=function(){Nr.add(a),n({success:!0})},o.onerror=function(e){r({success:!1,error:e})},"content"===e)return o.textContent=t,document.body.append(o),Nr.add(a),void n({success:!0});o.src=t,document.body.append(o)}),Kr=(e,t,n)=>{const r=(e=Array.isArray(e)?e:[e]).map(e=>{let n;if(e.toLowerCase().endsWith(".css")){const t=document.createElement("link");t.type="text/css",t.rel="stylesheet",t.href=e,n=t}else n=document.createElement("script"),n.type="text/javascript",n.src=e;const r=document.getElementsByTagName("body")[0];return(t||r).appendChild(n),new Promise(e=>{n.onload=()=>{e()}})});return new Promise(e=>{Promise.all(r).then(()=>{n&&n(),e()})})};export{En as $,Y as $t,$n as A,It as At,Nn as B,At as Bt,yr as C,U as Cn,Vt as Ct,tr as D,M as Dn,qt as Dt,Jn as E,h as En,_t as Et,qn as F,Ft,xn as G,ee as Gt,In as H,me as Ht,Kn as I,xt as It,Fn as J,te as Jt,zn as K,Z as Kt,Wn as L,Bt as Lt,Xn as M,Ht as Mt,Yn as N,Rt as Nt,Zn as O,B as On,jt as Ot,Gn as P,Dt as Pt,An as Q,J as Qt,Pn as R,Tt as Rt,vr as S,b as Sn,Kt as St,nr as T,l as Tn,Wt as Tt,Dn as U,fe as Ut,jn as V,ge as Vt,Hn as W,oe as Wt,Bn as X,Q as Xt,Ln as Y,re as Yt,Mn as Z,ne as Zt,pr as _,k as _n,Yt as _t,xr as a,H as an,dn as at,gr as b,T as bn,Qt as bt,Br as c,$ as cn,hn as ct,Mr as d,V as dn,en as dt,X as en,wn as et,kr as f,R as fn,rn as ft,cr as g,E as gn,Xt as gt,ur as h,g as hn,Jt as ht,Ir as i,K as in,yn as it,Vn as j,Lt as jt,er as k,m as kn,Nt as kt,Lr as l,z as ln,on as lt,Er as m,p as mn,nn as mt,Kr as n,x as nn,Sn as nt,Pr as o,W as on,un as ot,Ar as p,F as pn,an as pt,Tn as q,ae as qt,jr as r,N as rn,gn as rt,Fr as s,j as sn,pn as st,zr as t,G as tn,bn as tt,Tr as u,q as un,tn as ut,Ur as v,A as vn,Zt as vt,Qn as w,C as wn,zt as wt,wr as x,f as xn,$t as xt,fr as y,O as yn,Gt as yt,Rn as z,Mt as zt};
|
package/docs/API.md
CHANGED
|
@@ -8,11 +8,11 @@ constraints, conventions) read [../CLAUDE.md](../CLAUDE.md) first.
|
|
|
8
8
|
Import from the **subpath** that owns the symbol, e.g. `import { debounce } from
|
|
9
9
|
'ranuts/utils'`. The root `ranuts` barrel re-exports the utils + visual surface.
|
|
10
10
|
|
|
11
|
-
**
|
|
11
|
+
**402 exports** across 6 entry points. Generated at 2026-08-17T14:42:17.466Z.
|
|
12
12
|
|
|
13
13
|
## Entry points
|
|
14
14
|
|
|
15
|
-
- [`ranuts/utils`](#ranuts-utils) — Browser and general-purpose utilities · _browser + node_ ·
|
|
15
|
+
- [`ranuts/utils`](#ranuts-utils) — Browser and general-purpose utilities · _browser + node_ · 316 exports
|
|
16
16
|
- [`ranuts/sw`](#ranuts-sw) — Service Worker caching strategies and the precache protocol · _service worker only_ · 9 exports
|
|
17
17
|
- [`ranuts/node`](#ranuts-node) — Node server utilities (fs / http / ws / middleware) · _node only_ · 26 exports
|
|
18
18
|
- [`ranuts/visual`](#ranuts-visual) — 2D rendering engine (Canvas / WebGL / WebGPU) · _browser only_ · 16 exports
|
|
@@ -37,11 +37,13 @@ import { /* … */ } from 'ranuts/utils';
|
|
|
37
37
|
- `appendUrl(url: string, params?: Record<string, string>) => string` — Turn an object into a query string and append it to a URL
|
|
38
38
|
- `arrayBufferToString(buffer: ArrayBuffer | Uint8Array) => string` — Decode bytes into a string using the sniffed encoding. Required when reading
|
|
39
39
|
- `autosizeTextarea(element: HTMLTextAreaElement) => (() => void)` — Make a `<textarea>` grow and shrink with its content, so a long message is
|
|
40
|
+
- `base64ToBytes(base64: string) => Uint8Array<ArrayBuffer>` — Decode base64 into bytes. Accepts a bare payload or a full
|
|
40
41
|
- `blendMultiply(base: RGB, blend: RGB) => RGB` — Multiply blend of two colours (channel-wise `base * blend`). Channels in 0..1.
|
|
41
42
|
- `blendOverlay(base: RGB, blend: RGB) => RGB` — Overlay blend of two colours (multiply in shadows, screen in highlights). Channels in 0..1.
|
|
42
43
|
- `blendScreen(base: RGB, blend: RGB) => RGB` — Screen blend of two colours (channel-wise `1 - (1 - base)(1 - blend)`). Channels in 0..1.
|
|
43
44
|
- `brightnessContrast(color: RGB, brightness: number, contrast: number) => RGB` — Adjust brightness and contrast of a colour: `(c - 0.5) * contrast + 0.5 + brightness` per channel. Channels in 0..1.
|
|
44
45
|
- `buildOffsets(lengths: readonly number[]) => number[]` — The global start offset of every chunk in the concatenated coordinate
|
|
46
|
+
- `bytesToBase64(data: Uint8Array | ArrayBuffer) => string` — Encode bytes as base64 without blowing the call stack.
|
|
45
47
|
- `checkEncoding(uint8Array: Uint8Array) => string`
|
|
46
48
|
- `clamp(value: number, min: number, max: number) => number` — Clamp `value` into the inclusive range `[min, max]`.
|
|
47
49
|
- `clearBr(str?: string) => string` — Strip whitespace, line breaks and HTML tags out of a string
|
|
@@ -71,6 +73,7 @@ import { /* … */ } from 'ranuts/utils';
|
|
|
71
73
|
- `currentDevice() => CurrentDevice`
|
|
72
74
|
- `cutRound(img: ImgSource, radius: number) => ImgSource` — Round an image's corners, returning an offscreen canvas.
|
|
73
75
|
- `debounce<T extends (...args: any[]) => any>(fn: T, ms?: number) => Debounced<T>` — Debounce — on a burst of calls, run only the last one, **`ms` milliseconds
|
|
76
|
+
- `decodeTextBytes(bytes: Uint8Array, encodings?: string[]) => string` — Decode text bytes, trying encodings in order until one holds.
|
|
74
77
|
- `deferred<T = void>() => Deferred<T>` — A promise plus its `resolve` / `reject`, for the case where the thing that
|
|
75
78
|
- `delay(ms: number) => Promise<void>` — Resolve after `ms` milliseconds. Uses the bare `setTimeout`, so it works in
|
|
76
79
|
- `detectLanguage(text: string, sampleSize?: number) => TextLanguage` — Decide a text's primary language from the ratio of CJK to Latin characters.
|
|
@@ -78,6 +81,7 @@ import { /* … */ } from 'ranuts/utils';
|
|
|
78
81
|
- `encodeUrl(url: string) => string` — Encode a URL to a percent-encoded form, excluding already-encoded sequences.
|
|
79
82
|
- `escapeHtml(string?: string | number | null) => string`
|
|
80
83
|
- `fanShapedByArc(ctx: CanvasRenderingContext2D, maxRadius: number, start: number, end: number, gutter: number) => void` — Trace a pie slice with arc(), including the gutter between slices.
|
|
84
|
+
- `fetchMaybeGzip(input: RequestInfo | URL, init?: RequestInit) => Promise<Uint8Array>` — Fetch a resource that may be delivered gzipped or already
|
|
81
85
|
- `filterObj(obj: Record<string, unknown>, list: Array<string>) => Record<string, unknown>` — Return a new object without the properties whose values appear in `list` — typically used to drop empty strings and nulls
|
|
82
86
|
- `fit(value: number, a1: number, a2: number, b1: number, b2: number) => number` — Remap `value` from `[a1, a2]` onto `[b1, b2]` and clamp to the output range — the shader `fit`.
|
|
83
87
|
- `formatDate(value?: DateInput, pattern?: string) => string` — Format a date with a token pattern. Accepts a timestamp, a date string, a
|
|
@@ -103,6 +107,7 @@ import { /* … */ } from 'ranuts/utils';
|
|
|
103
107
|
- `getStatus(code?: number | string) => number | string | undefined` — Get the status code.
|
|
104
108
|
- `getTangentByPointer(x: number, y: number) => Array<number>` — The tangent line at a point on a circle
|
|
105
109
|
- `getWindow() => ClientRatio` — Get the viewport size across browsers
|
|
110
|
+
- `gunzipMaybe(bytes: Uint8Array) => Promise<Uint8Array>` — Decompress bytes if — and only if — they are still gzipped.
|
|
106
111
|
- `handleConsole(hooks?: (...args: unknown[]) => void) => (() => void)` — Tap into `console` so every call also reaches your hook, while still printing
|
|
107
112
|
- `handleError(hooks?: (error: ErrorPayload) => void) => (() => void)` — Listen for uncaught errors and unhandled promise rejections, in the capture
|
|
108
113
|
- `handleFetchHook(options?: Partial<Options>) => (() => void)` — Instrument `window.fetch` so every request, response and failure reaches your
|
|
@@ -124,6 +129,8 @@ import { /* … */ } from 'ranuts/utils';
|
|
|
124
129
|
- `inflateRaw(data: Uint8Array) => Promise<Uint8Array>` — Decompress raw DEFLATE bytes (no zlib or gzip wrapper) — the form ZIP
|
|
125
130
|
- `inverseLerp(a: number, b: number, value: number) => number` — Inverse of `lerp` — where `value` sits between `a` and `b`, as 0..1. Returns 0 when `a === b`. Not clamped.
|
|
126
131
|
- `isEqual(value: any, other: any, seen?: Map<any, any>) => boolean` — Deep-compare two values.
|
|
132
|
+
- `isGzip(bytes: Uint8Array) => boolean` — Whether the bytes start with the gzip magic number (1f 8b).
|
|
133
|
+
- `isHtmlDocument(bytes: Uint8Array) => boolean` — Whether the bytes are an HTML document rather than the binary
|
|
127
134
|
- `isImageSize(file: File, width?: number, height?: number) => Promise<boolean>` — Check an image's dimensions against a given width / height. When both are
|
|
128
135
|
- `isInIframe() => boolean` — Whether this page is running inside an iframe. Returns false under SSR.
|
|
129
136
|
- `isMobile() => boolean` — Whether this is a mobile device
|
|
@@ -132,6 +139,7 @@ import { /* … */ } from 'ranuts/utils';
|
|
|
132
139
|
- `isString(obj: unknown) => boolean`
|
|
133
140
|
- `isUrlCached(url: string) => Promise<boolean>` — Whether a URL is already in CacheStorage. When probing a group of files,
|
|
134
141
|
- `isWeiXin() => boolean` — Whether this is the WeChat in-app browser
|
|
142
|
+
- `isZipContainer(bytes: Uint8Array) => boolean` — Whether the bytes are a ZIP container (PK\x03\x04) — which is
|
|
135
143
|
- `lerp(a: number, b: number, t: number) => number` — Linear interpolation from `a` to `b` by `t` (t=0 → a, t=1 → b). Not clamped.
|
|
136
144
|
- `linearstep(edge0: number, edge1: number, x: number) => number` — Linear ramp — 0 below `edge0`, 1 above `edge1`, a straight line between (the shader `linearstep`, no smoothing).
|
|
137
145
|
- `linearToSrgb(c: number) => number` — Convert one linear-light channel (0..1) to sRGB.
|
|
@@ -191,6 +199,7 @@ import { /* … */ } from 'ranuts/utils';
|
|
|
191
199
|
- `rgbToHsv(r: number, g: number, b: number) => number[]` — Alias of `rgbToHsb` — HSV and HSB are two names for the same colour space.
|
|
192
200
|
- `roundRectByArc(ctx: CanvasRenderingContext2D, ...[x, y, w, h, r]: number[]) => void` — Trace a rounded rectangle with arc(). A corner radius larger than half the
|
|
193
201
|
- `saturation(color: RGB, amount: number) => RGB` — Adjust saturation by mixing toward the colour's luminance. `amount` 0 = greyscale, 1 = unchanged, >1 = more saturated. Channels in 0..1.
|
|
202
|
+
- `saveFileToDisk(data: Blob | Uint8Array, fileName: string, options?: SaveFileOptions) => Promise<boolean>` — Save bytes to disk: a real "Save as" dialog through the File
|
|
194
203
|
- `scriptOnLoad(urls: string[], append?: HTMLElement, callback?: () => void) => Promise<void>` — Insert script/link tags dynamically
|
|
195
204
|
- `segmentByRanges<T>(text: string, chunkStart: number, ranges: readonly OffsetRange<T>[]) => Segment<T>[]` — Split one chunk of text into a sequence of plain / matched spans according
|
|
196
205
|
- `serveWorker<Req extends WorkerRequestBase, Res extends object = object, Progress = unknown>(handler: (request: Req, context: WorkerHandlerContext<Progress>) =>…` — Serve requests inside a Web Worker, mirroring {@link WorkerClient} on the
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ranuts",
|
|
3
|
-
"version": "0.4.0-alpha.
|
|
3
|
+
"version": "0.4.0-alpha.5",
|
|
4
4
|
"description": "Tree-shakeable TypeScript utility library: DOM/BOM helpers, string/object/number/color utils, debounce/throttle/compose, a 2D rendering engine and a virtual DOM.",
|
|
5
5
|
"main": "dist/index.umd.cjs",
|
|
6
6
|
"module": "dist/index.js",
|