ranuts 0.1.0-alpha.9 → 0.2.0-alpha.1
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 +164 -0
- package/README.md +116 -0
- package/{readme.md → README.zh-CN.md} +43 -12
- package/dist/bin/generate-api-docs.d.ts +1 -0
- package/dist/build/build.es.d.ts +2 -0
- package/dist/build/build.umd.d.ts +2 -0
- package/dist/build/build.umd.node.d.ts +2 -0
- package/dist/build/build.umd.utils.d.ts +2 -0
- package/dist/color-CRdlaDqQ.js +1 -0
- package/dist/examples/clone-deep-example.d.ts +1 -0
- package/dist/examples/is-equal-example.d.ts +1 -0
- package/dist/index.d.ts +5 -21
- package/dist/index.js +1 -2484
- package/dist/plugins/vite-plugins-banner.d.ts +2 -0
- package/dist/rolldown-runtime-I3TIJKkN.js +1 -0
- package/dist/src/node/appendFile.d.ts +7 -0
- package/dist/src/node/body.d.ts +9 -0
- package/dist/src/node/color.d.ts +7 -0
- package/dist/src/node/command.d.ts +8 -0
- package/dist/src/node/ctx2req.d.ts +5 -0
- package/dist/src/node/fileInfo.d.ts +7 -0
- package/dist/src/node/fs.d.ts +7 -0
- package/dist/src/node/get.d.ts +10 -0
- package/dist/src/node/getIPAdress.d.ts +1 -0
- package/dist/src/node/index.d.ts +25 -0
- package/dist/src/node/index.js +1 -0
- package/dist/src/node/isColorSupported.d.ts +2 -0
- package/dist/src/node/paresUrl.d.ts +19 -0
- package/dist/src/node/readDir.d.ts +6 -0
- package/dist/src/node/readFile.d.ts +9 -0
- package/dist/src/node/router.d.ts +42 -0
- package/dist/src/node/send.d.ts +7 -0
- package/dist/src/node/server.d.ts +18 -0
- package/dist/src/node/startTask.d.ts +2 -0
- package/dist/src/node/stream.d.ts +15 -0
- package/dist/src/node/taskEnd.d.ts +2 -0
- package/dist/src/node/traverse.d.ts +17 -0
- package/dist/src/node/watchFile.d.ts +8 -0
- package/dist/src/node/writeFile.d.ts +8 -0
- package/dist/src/node/ws.d.ts +8 -0
- package/dist/src/utils/audioRecorder.d.ts +16 -0
- package/dist/src/utils/behavior.d.ts +15 -0
- package/dist/src/utils/bom.d.ts +294 -0
- package/dist/src/utils/color.d.ts +71 -0
- package/dist/src/utils/compose.d.ts +10 -0
- package/dist/src/utils/console.d.ts +1 -0
- package/dist/src/utils/debounce.d.ts +7 -0
- package/dist/src/utils/device.d.ts +25 -0
- package/dist/src/utils/dom.d.ts +105 -0
- package/dist/src/utils/error.d.ts +1 -0
- package/dist/src/utils/func.d.ts +1 -0
- package/dist/src/utils/img.d.ts +16 -0
- package/dist/src/utils/index.d.ts +35 -0
- package/dist/src/utils/index.js +1 -0
- package/dist/src/utils/memoize.d.ts +7 -0
- package/dist/src/utils/mimeType.d.ts +9 -0
- package/dist/src/utils/monitor.d.ts +38 -0
- package/dist/src/utils/network.d.ts +39 -0
- package/dist/src/utils/noop.d.ts +2 -0
- package/dist/src/utils/number.d.ts +45 -0
- package/dist/src/utils/obj.d.ts +83 -0
- package/dist/src/utils/performance.d.ts +21 -0
- package/dist/src/utils/queue.d.ts +33 -0
- package/dist/src/utils/report.d.ts +8 -0
- package/dist/src/utils/request.d.ts +17 -0
- package/dist/src/utils/script.d.ts +7 -0
- package/dist/src/utils/signal.d.ts +6 -0
- package/dist/src/utils/storage.d.ts +2 -0
- package/dist/src/utils/str.d.ts +212 -0
- package/dist/src/utils/subscribe.d.ts +46 -0
- package/dist/src/utils/throttle.d.ts +15 -0
- package/dist/src/utils/time.d.ts +20 -0
- package/dist/src/utils/totp/sha/common.d.ts +151 -0
- package/dist/src/utils/totp/sha/converters.d.ts +88 -0
- package/dist/src/utils/totp/sha/custom_types.d.ts +60 -0
- package/dist/src/utils/totp/sha/primitives_32.d.ts +98 -0
- package/dist/src/utils/totp/sha/primitives_64.d.ts +116 -0
- package/dist/src/utils/totp/sha/sha.d.ts +103 -0
- package/dist/src/utils/totp/sha/sha1.d.ts +18 -0
- package/dist/src/utils/totp/sha/sha256.d.ts +20 -0
- package/dist/src/utils/totp/sha/sha3.d.ts +53 -0
- package/dist/src/utils/totp/sha/sha512.d.ts +21 -0
- package/dist/src/utils/totp/totp.d.ts +23 -0
- package/dist/src/utils/visual/application.d.ts +27 -0
- package/dist/src/utils/visual/enums.d.ts +27 -0
- package/dist/src/utils/visual/event/boundary.d.ts +22 -0
- package/dist/src/utils/visual/event/event.d.ts +14 -0
- package/dist/src/utils/visual/event/index.d.ts +6 -0
- package/dist/src/utils/visual/event/types.d.ts +32 -0
- package/dist/src/utils/visual/graphics/graphics.d.ts +81 -0
- package/dist/src/utils/visual/graphics/graphicsData.d.ts +13 -0
- package/dist/src/utils/visual/graphics/graphicsGeometry.d.ts +35 -0
- package/dist/src/utils/visual/graphics/index.d.ts +4 -0
- package/dist/src/utils/visual/index.d.ts +7 -0
- package/dist/src/utils/visual/index.js +1 -0
- package/dist/src/utils/visual/math/bezier.d.ts +2 -0
- package/dist/src/utils/visual/math/enums.d.ts +3 -0
- package/dist/src/utils/visual/math/index.d.ts +5 -0
- package/dist/src/utils/visual/math/matrix.d.ts +113 -0
- package/dist/src/utils/visual/math/transform.d.ts +29 -0
- package/dist/src/utils/visual/render/batchRenderer.d.ts +78 -0
- package/dist/src/utils/visual/render/canvasRenderer.d.ts +10 -0
- package/dist/src/utils/visual/render/index.d.ts +3 -0
- package/dist/src/utils/visual/render/render.d.ts +11 -0
- package/dist/src/utils/visual/render/utils/batch/index.d.ts +90 -0
- package/dist/src/utils/visual/render/utils/batch/index.test.d.ts +1 -0
- package/dist/src/utils/visual/render/utils/float.d.ts +63 -0
- package/dist/src/utils/visual/render/utils/index.d.ts +3 -0
- package/dist/src/utils/visual/render/utils/index.test.d.ts +1 -0
- package/dist/src/utils/visual/render/utils/verticy.d.ts +13 -0
- package/dist/src/utils/visual/render/utils/webgl/initShader.d.ts +7 -0
- package/dist/src/utils/visual/render/utils/webgl/shaders.d.ts +2 -0
- package/dist/src/utils/visual/render/utils/webgpu/shaders.d.ts +8 -0
- package/dist/src/utils/visual/render/webGPURenderer.d.ts +49 -0
- package/dist/src/utils/visual/render/webGlRenderer.d.ts +14 -0
- package/dist/src/utils/visual/shape/circle.d.ts +11 -0
- package/dist/src/utils/visual/shape/ellipse.d.ts +12 -0
- package/dist/src/utils/visual/shape/index.d.ts +7 -0
- package/dist/src/utils/visual/shape/polygon.d.ts +11 -0
- package/dist/src/utils/visual/shape/rectangle.d.ts +12 -0
- package/dist/src/utils/visual/shape/roundedRectangle.d.ts +13 -0
- package/dist/src/utils/visual/shape/shape.d.ts +6 -0
- package/dist/src/utils/visual/style/fill.d.ts +8 -0
- package/dist/src/utils/visual/style/index.d.ts +3 -0
- package/dist/src/utils/visual/style/line.d.ts +10 -0
- package/dist/src/utils/visual/types.d.ts +18 -0
- package/dist/src/utils/visual/vertex/container.d.ts +74 -0
- package/dist/src/utils/visual/vertex/point.d.ts +18 -0
- package/dist/src/utils/visual/vertex/vertex.d.ts +36 -0
- package/dist/src/vnode/chainDom.d.ts +47 -0
- package/dist/src/vnode/h.d.ts +6 -0
- package/dist/src/vnode/hooks.d.ts +23 -0
- package/dist/src/vnode/htmlDomApi.d.ts +33 -0
- package/dist/src/vnode/index.d.ts +18 -0
- package/dist/src/vnode/index.js +1 -0
- package/dist/src/vnode/init.d.ts +2 -0
- package/dist/src/vnode/is.d.ts +5 -0
- package/dist/src/vnode/modules/attributes.d.ts +8 -0
- package/dist/src/vnode/modules/class.d.ts +8 -0
- package/dist/src/vnode/modules/index.d.ts +3 -0
- package/dist/src/vnode/modules/listeners.d.ts +12 -0
- package/dist/src/vnode/modules/props.d.ts +8 -0
- package/dist/src/vnode/modules/style.d.ts +14 -0
- package/dist/src/vnode/vnode.d.ts +31 -0
- package/dist/subscribe-CINWsor3.js +1 -0
- package/dist/test/bridge.test.d.ts +1 -0
- package/dist/test/clearBr.test.d.ts +1 -0
- package/dist/test/cloneDeep.test.d.ts +1 -0
- package/dist/test/command.test.d.ts +1 -0
- package/dist/test/encodeUrl.test.d.ts +1 -0
- package/dist/test/escapeHtml.test.d.ts +1 -0
- package/dist/test/is-equal.test.d.ts +1 -0
- package/dist/test/mimeType.test.d.ts +1 -0
- package/dist/test/package-exports.test.d.ts +1 -0
- package/dist/test/server.test.d.ts +1 -0
- package/dist/test/status.test.d.ts +1 -0
- package/dist/test/totp.test.d.ts +1 -0
- package/dist/test/utils/compose.test.d.ts +1 -0
- package/dist/test/utils/mergeObj.test.d.ts +1 -0
- package/dist/test/visual/math.test.d.ts +1 -0
- package/dist/test/visual-application.test.d.ts +1 -0
- package/dist/test/visual-batch.test.d.ts +1 -0
- package/dist/test/visual-math.test.d.ts +1 -0
- package/dist/test/vnode/index.d.ts +1 -0
- package/dist/test/vnode/server.d.ts +2 -0
- package/dist/test/vnode/vnode.d.ts +1 -0
- package/dist/test/vnode.test.d.ts +1 -0
- package/dist/test/websocket.test.d.ts +1 -0
- package/dist/test/writeFile.test.d.ts +1 -0
- package/dist/umd/index.umd.cjs +1 -0
- package/dist/umd/node/node.umd.cjs +1 -0
- package/dist/umd/utils/utils.umd.cjs +1 -0
- package/dist/utils-_OxsVZmz.js +1 -0
- package/dist/vite.config.d.ts +8 -0
- package/dist/vitest.config.d.ts +2 -0
- package/docs/API.md +305 -0
- package/package.json +67 -15
- package/typings.d.ts +28 -0
- package/dist/index.umd.cjs +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./subscribe-CINWsor3.js";import{A as t,F as n,M as r,k as i}from"./color-CRdlaDqQ.js";var a=(e="")=>{if(0===e.length)return 0;if(e.endsWith("%")){const t=Number(e.replace("%",""));return t>1?t/100:t}return Number(e)},o=(e,t=0,n=1)=>Math.min(n,Math.max(t,e)),s=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 c(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)=>c(o,e,t)}}var d=(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,c=Math.min(Math.floor((o-1)/a),i.length-1),d=s.divide(Number(e),10**(c*a))?.toFixed(n);return Number(d).toFixed(r)+i[c]},u=(e,t)=>n(e).startsWith("+")||n(e).startsWith("-")?n(e):t?Number(t||0)>0?`+${n(e)}`:n(e):Number(e||0)>0?`+${n(e)}`:n(e),h=e=>"function"==typeof e,l=()=>{};function p(e){return e<10?`0${e}`:e}function m(e){let t=/* @__PURE__ */new Date;return e&&(t=new Date(e)),t.format=(e="YYYY-MM-DD HH:mm:ss")=>{const n=t.getFullYear(),r=p(t.getMonth()+1),i=p(t.getDate()),a=p(t.getHours()),o=p(t.getMinutes()),s=p(t.getSeconds());return e.replace(/Y+/gi,`${n}`).replace(/M+/g,`${r}`).replace(/D+/gi,`${i}`).replace(/H+/gi,`${a}`).replace(/m+/g,`${o}`).replace(/S+/gi,`${s}`)},t}var f=e=>{if(0===e)return"00:00";if(!e)return"";const t=Math.trunc(e/3600),n=Math.trunc(e%3600/60),r=p(Math.trunc(e-3600*t-60*n));return 0===t?`${p(n)}:${r}`:`${p(t)}:${p(n)}:${r}`},g=()=>{if("undefined"!=typeof document)return performance.now();if("undefined"!=typeof process){const[e,t]=process.hrtime();return 1e3*e+t/1e6}return Date.now()},w=/* @__PURE__ */function(e){return e.IPAD="ipad",e.ANDROID="android",e.IPhONE="iphone",e.PC="pc",e}({}),y=()=>{if("undefined"!=typeof window){const e=navigator.userAgent.toLowerCase();return/ipad|ipod/.test(e)?"ipad":/android/.test(e)?"android":/iphone/.test(e)?"iphone":"pc"}return"pc"},C="undefined"!=typeof window,b=()=>!!C&&window.navigator.userAgent.toLowerCase().includes("micromessenger"),S=()=>{if(!C)return!1;const e=window.navigator.userAgent;return!!/Android|webOS|iPhone|iPod|iPad|BlackBerry/i.test(e)},A=()=>{if(!C)return!1;const e=/iphone/i.test(window.navigator.userAgent),t=window.devicePixelRatio&&2===window.devicePixelRatio,n=window.devicePixelRatio&&3===window.devicePixelRatio,r=360===window.screen.width&&780===window.screen.height,i=375===window.screen.width&&812===window.screen.height,a=390===window.screen.width&&844===window.screen.height,o=414===window.screen.width&&896===window.screen.height,s=428===window.screen.width&&926===window.screen.height;switch(!0){case e&&n&&r:case e&&n&&i:case e&&n&&a:case e&&t&&o:case e&&n&&o:case e&&n&&s:return!0;default:return!1}},v=(e=l)=>{const t=()=>{e(),C&&window.removeEventListener("popstate",t)};C&&window.history.pushState(null,"",window.location.href),setTimeout(()=>{C&&window.addEventListener("popstate",t)},500)},O=e=>{const t=document.cookie.split("; ");for(let n=0;n<t.length;n++){const r=t[n].split("=");if(r[0]===e)return decodeURIComponent(r[1])}return""},E=(e,t)=>new Promise(function(n,r){const i=new XMLHttpRequest;i.open(t.method||"GET",e,!0),i.responseType=t.responseType||"arraybuffer",i.onload=function(){200===i.status?n({success:!0,data:i.response,message:""}):r({success:!1,data:i.status,message:`The request status is${i.status}`})},i.onerror=function(e){r({success:!1,data:e,message:""})},i.onprogress=e=>{t.onProgress&&t.onProgress(e)},i.withCredentials=t.withCredentials||!1,t.headers&&Object.keys(t.headers).forEach(function(e){t.headers?.[e]&&i.setRequestHeader(e,t.headers[e])}),i.send(t.body)}),U=e=>{const t=e.backingStorePixelRatio||e.webkitBackingStorePixelRatio||e.mozBackingStorePixelRatio||e.msBackingStorePixelRatio||e.oBackingStorePixelRatio||1;return(C&&window.devicePixelRatio||1)/t},B=async e=>{if("string"==typeof e)return e;if(e instanceof Blob)return URL.createObjectURL(e);if(e instanceof ArrayBuffer)return URL.createObjectURL(new Blob([e]));if(e instanceof Response){const t=await e.blob();return URL.createObjectURL(t)}return e},M=(e=10)=>{const t=[];let n,r=0;return new Promise(i=>{const a=()=>{const o=g(),s=o-r;0!==r&&t.push(s),r=o,t.length>e&&(i(1/(t.reduce((e,t)=>e+t)/e)),cancelAnimationFrame(n)),n=requestAnimationFrame(a)};t.length<=e&&(n=requestAnimationFrame(a))})},T=e=>{if("undefined"!=typeof window){let n="";if(e&&t(e))n=/trunk|neibu|release/.test(e)?`.${e}`:/test/.test(e)?e:(/prod/.test(e),"");else{const e=/\w(\.trunk|\.neibu|\.release|test)\./.exec(window.location.hostname);e&&(n=e[1])}return`//log.${n}`}},k=e=>{if("undefined"!=typeof window){const t={},n=e||window.location.href;return n.split("?")[1]&&n.split("?")[1].split("&").forEach(e=>{const[n,r]=e.split("=");n&&r&&(t[n]=decodeURIComponent(r))}),t}return{}},L=e=>{if("undefined"!=typeof window){const t={},n=e||window.location.href;return n.split("?")[1]&&n.split("?")[1].split("&").forEach(e=>{const[n,r]=e.split("=");n&&r&&(t[n]=decodeURIComponent(r))}),t}return{}};function F(e,t={}){let n=e;0===n.indexOf("//")&&(n=n.replace("//","https://"));const r=new URL(n);return t&&Object.keys(t).forEach(e=>{t[e]&&r.searchParams.set(e,t[e])}),r.href}var R=e=>{const t=document.createElement("img");t.src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",t.width=0,t.height=0,t.style.opacity="0",e.dataTransfer&&e.dataTransfer.setDragImage(t,0,0)};function H(e){if("undefined"!=typeof window){const t=new RegExp(`(^| )${e}(?:=([^;]*))?(;|$)`).exec(document.cookie);if(t&&t[2])return t[2]}return""}var D=()=>"undefined"!=typeof window?{width:window.innerWidth,height:window.innerHeight}:{width:0,height:0},P=()=>{if("undefined"!=typeof window)return window.navigator.connection},x=/(?:[^\x21\x25\x26-\x3B\x3D\x3F-\x5B\x5D\x5F\x7E]|%(?:[^\da-f]|[\da-f][^\da-f]|$))+/gi,I=/(^|[^\uD800-\uDBFF])[\uDC00-\uDFFF]|[\uD800-\uDBFF]([^\uDC00-\uDFFF]|$)/g;function z(e){return String(e).replace(I,"$1�$2").replace(x,encodeURI)}var j=e=>new Promise((t,n)=>{const r=new Image,i=/* @__PURE__ */(new Date).getTime();r.src=e||`https://github.com/favicon.ico?d=${i}`,r.onload=()=>{t(/* @__PURE__ */(new Date).getTime()-i)},r.onerror=e=>{n(e)}}),N=(e,...t)=>n=>new Promise((r,i)=>{setTimeout(async()=>{try{r(await e(...t))}catch(n){i(n)}},n)}),K=async e=>{const{url:t,duration:n=3e3,count:r=5}=e;let i=0,a=0;const o=[];for(let s=0;s<r;s++){const e=await N(j,t)(n);o.push(e)}return i=Math.max(...o)-Math.min(...o),a=o.reduce((e,t)=>e+t)/o.length,{ping:a,jitter:i}},_=()=>{if("undefined"!=typeof navigator)return navigator.vendor&&navigator.vendor.indexOf("Apple")>-1&&navigator.userAgent&&!navigator.userAgent.includes("CriOS")&&!navigator.userAgent.includes("FxiOS")},q=12e4,V="__ranuts_bridge__",W="default",$=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)}},Y=class{targetWindow;targetOrigin;messageHandlers;pendingRequests;channel;senderId;available;constructor(e,t="*",n=W){this.targetOrigin=t,this.channel=n,this.senderId=i(12),this.messageHandlers=/* @__PURE__ */new Map,this.pendingRequests=/* @__PURE__ */new Map,this.available="undefined"!=typeof window,this.available?(this.targetWindow=e??window,$.add(this)):this.targetWindow=void 0}post(e,t){const n={...t,__bridge:V,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(h(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 n=i(10);return new Promise((r,i)=>{const a=setTimeout(()=>{this.pendingRequests.has(n)&&(this.pendingRequests.delete(n),i(/* @__PURE__ */new Error("Request timeout")))},q),o=e=>{clearTimeout(a),i(e)};this.pendingRequests.set(n,{resolve:e=>{clearTimeout(a),r(e)},reject:o});try{this.post(this.targetWindow,{type:e,payload:t,id:n})}catch(s){this.pendingRequests.delete(n),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=()=>{$.remove(this),this.messageHandlers.clear(),this.pendingRequests.forEach(e=>{e.reject(/* @__PURE__ */new Error("Bridge destroyed"))}),this.pendingRequests.clear()}},X=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:n,channel:r})=>{const a=new Y(n,t,r);if(e||(e=i(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`))}},G=X.getInstance(),J={connect:({id:e,targetWindow:t,targetOrigin:n,channel:r})=>G.connectClient({id:e,targetWindow:t,targetOrigin:n,channel:r}),remove:e=>{e&&G.removeClient(e)},removeAll:()=>{G.removeAllClient()},broadcast:e=>G.broadcast(e),call:({id:e,type:t,payload:n})=>G.sendTo(e,t,n),broadcastToAll:e=>{if("undefined"==typeof window)return;const t={__bridge:V,channel:W,type:e.type,payload:e.payload};return window.postMessage(t,"*")}},Q={init:e=>{const t=new Map(Object.entries(e).filter(e=>h(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:V,channel:o,type:r,id:a,isResponse:!0,...t},{targetOrigin:e.origin})};try{c({payload:await s(i)})}catch(d){c({payload:d instanceof Error?d.message:String(d),isError:!0})}};window.removeEventListener("message",n),window.addEventListener("message",n);return{destroy:()=>{window.removeEventListener("message",n)}}}},Z="__ranuts_port_init__",ee=e=>{const t=/* @__PURE__ */new Map,n=/* @__PURE__ */new Map,r=r=>{const i=r.data;if(!i||"object"!=typeof i||"string"!=typeof i.type)return;const{type:a,payload:o,id:s,isResponse:c,isError:d}=i;if(c&&s){const e=n.get(s);return void(e&&(d?e.reject(new Error("string"==typeof o?o:"Bridge request failed")):e.resolve(o),n.delete(s)))}if(!t.has(a))return;const u=t.get(a);h(u)&&Promise.resolve(u(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",r),e.start(),{on:(e,n)=>{t.set(e,n)},off:e=>{t.delete(e)},send:(t,r)=>{const a=i(10);return new Promise((i,o)=>{const s=setTimeout(()=>{n.has(a)&&(n.delete(a),o(/* @__PURE__ */new Error("Request timeout")))},q),c=e=>{clearTimeout(s),o(e)};n.set(a,{resolve:e=>{clearTimeout(s),i(e)},reject:c});try{e.postMessage({type:t,payload:r,id:a})}catch(d){n.delete(a),c(d instanceof Error?d:/* @__PURE__ */new Error("Failed to post message"))}})},broadcast:t=>{try{e.postMessage({type:t.type,payload:t.payload})}catch{}},destroy:()=>{e.removeEventListener("message",r),t.clear(),n.forEach(e=>e.reject(/* @__PURE__ */new Error("Bridge destroyed"))),n.clear(),e.close()}}},te=({targetWindow:e,targetOrigin:t="*",name:n="default"})=>{const r=new MessageChannel;return e.postMessage({[Z]:!0,name:n},t,[r.port2]),ee(r.port1)},ne=({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[Z]||a.name!==t)return;const o=i.ports?.[0];o&&(window.removeEventListener("message",r),n(ee(o)))};window.addEventListener("message",r)}),re=e=>{let t,n=!1;return(...r)=>(n||(t="function"==typeof e?e(...r):e,n=!0,e=void 0),t)};function ie(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 ae=(e,t=()=>{})=>{let n="",r=0;let i=((e,t=()=>{})=>{let n="";if("[object String]"!==Object.prototype.toString.call(e))try{n=JSON.stringify(e)}catch(r){t(r)}else try{e="string"==typeof e?e.replace(/'/g,'"'):JSON.stringify(e),n=JSON.stringify(JSON.parse(e))}catch(r){t(r)}return n})(e,t);if(!i)return i;const a=[];let o=null,s=null,c=[];return i=i.replace(/([{}])/g,"\r\n$1\r\n"),i=i.replace(/([[\]])/g,"\r\n$1\r\n"),i=i.replace(/,/g,",\r\n"),i=i.replace(/\r\n\r\n/g,"\r\n"),i=i.replace(/\r\n,/g,","),c=i.split("\r\n"),c.forEach(function(e,t){const n=e.match(/"/g)&&e.match(/"/g)?.length||0;n%2&&!o&&(o=t),n%2&&o&&o!==t&&(s=t),o&&s&&(a.push({start:o,end:s}),o=null,s=null)}),a.reverse().forEach(function(e){const t=c.slice(e.start,e.end+1);c.splice(e.start,e.end+1-e.start,t.join(""))}),i=c.join("\r\n"),i=i.replace(/:\r\n\{/g,":{"),i=i.replace(/:\r\n\[/g,":["),c=i.split("\r\n"),c.forEach(function(e){let t=0,i=0,a="";for(e.endsWith("{")||e.endsWith("[")?i+=1:e.endsWith("}")||e.endsWith("]")||e.endsWith("},")||e.endsWith("],")?0!==r&&(r-=1):i=0,t=0;t<r;t++)a+=" ";n+=a+e+"\r\n",r+=i}),n.trim()},oe=(e,t)=>{const n={};return Object.keys(e).forEach(r=>{t.includes(r)||(n[r]=e[r])}),n},se=(e,t)=>{if(e&&t)for(const n in t)e[n]=t[n];return e};function ce(e,t,n,r){if(void 0!==e&&(t in e||r)){const r=n(e[t]);"function"==typeof r&&(e[t]=r)}}var de=(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:re(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:de({},t.value)})}}return Object.freeze(e)},ue=(e,t)=>{"undefined"!=typeof window&&(window[e]=t),"undefined"!=typeof global&&(global[e]=t)};function he(e){return Object.prototype.toString.call(e)}function le(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=he(e);if(i!==he(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(!le(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)&&le(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=>le(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)||!le(e[s],t[s],n))return!1;return!0}var pe=(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]=pe(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?pe(r,t):r,pe(e,t))}),n}if(e instanceof Set){const n=/* @__PURE__ */new Set;return t.set(e,n),e.forEach(e=>{n.add(pe(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]=pe(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]=pe(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}}},me={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"}},fe=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 ge(e){return e.length%2==1?"0"+e:e}var we=class extends fe{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+=ge(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(ge(e.toString(16)))}},ye=class extends fe{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)}},Ce=class e extends fe{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=me[n]||{name:"Unknown",type:"Unknown"};let o=fe;switch(a.type){case"Container":o=e;break;case"Uint":o=we;break;case"Float":o=ye}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}}},be=class extends Ce{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 ye("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 Se=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 be(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}},Ae=new e,ve=(e,t)=>{const n={value:e,compare:pe(e),subscribers:Ae,comparator:t?.equals},{subscriber:r}=t||{},i=e=>{le(n.compare,e)||(n.value=e,n.compare=pe(e),r&&n.subscribers.call(r))};return[()=>n.value,e=>{const{comparator:t}=n;if(t instanceof Function)return!t(n.value,e)&&i(e);void 0===t?n.value!==e&&i(e):t||i(e)}]},Oe=()=>{const e=document.createElement("canvas").getContext("webgl2");return e?function(e){const t=e.getExtension("WEBGL_debug_renderer_info");return t?{vendor:e.getParameter(t.UNMASKED_VENDOR_WEBGL),renderer:e.getParameter(t.UNMASKED_RENDERER_WEBGL)}:null}(e):null},Ee=()=>{const e=document.createElement("canvas"),t=e.getContext("2d"),n="BrowserLeaks,com <canvas> 1.0";return t?(t.textBaseline="top",t.font="14px 'Arial'",t.textBaseline="alphabetic",t.fillStyle="#f60",t.fillRect(125,1,62,20),t.fillStyle="#069",t.fillText(n,2,15),t.fillStyle="rgba(102, 204, 0, 0.7)",t.fillText(n,4,17),e.toDataURL()):null},Ue=()=>new Promise((e,t)=>{C||t("window is undefined");const n=new(window.OfflineAudioContext||window.webkitOfflineAudioContext)(1,44100,44100),r=n.createOscillator();r.type="triangle",r.frequency.setValueAtTime(1e4,n.currentTime);const i=n.createDynamicsCompressor();!function(e,t){if(Array.prototype.forEach&&e.forEach===Array.prototype.forEach)e.forEach(t);else if(e.length===+e.length)for(let n=0,r=e.length;n<r;n++)t(e[n],n,e);else for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&t(e[n],Number(n),e)}([["threshold",-50],["knee",40],["ratio",12],["reduction",-20],["attack",0],["release",.25]],function(e){if(i[e[0]]&&"number"!=typeof i[e[0]]){const{setValueAtTime:t}=i[e[0]];t(e[1],n.currentTime)}}),r.connect(i),i.connect(n.destination),r.start(0),n.startRendering();const a=setTimeout(function(){return n.oncomplete=()=>{},t("audioTimeout"),"audioTimeout"},100);n.oncomplete=n=>{try{clearTimeout(a);const t=n.renderedBuffer.getChannelData(0).slice(4500,5e3).reduce(function(e,t){return e+Math.abs(t)},0).toString();return r.disconnect(),i.disconnect(),e(t),t}catch(o){return void t(o)}}}),Be="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function Me(e,t,n,r){let i,a,o;const s=t||[0],c=(n=n||0)>>>3,d=-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*(d+r*(o%4));return{value:s,binLen:8*e.length+n}}function Te(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],d=(n=n||0)>>>3,u=-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)+d,o=s>>>2;c.length<=o;)c.push(0);c[o]|=a<<8*(u+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,d,u,h,l,p=0;const m=n||[0],f=(r=r||0)>>>3;if("UTF8"===t)for(h=-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(u=p+f,d=u>>>2;m.length<=d;)m.push(0);m[d]|=o[c]<<8*(h+i*(u%4)),p+=1}else for(h=-1===i?2:0,l="UTF16LE"===t&&1!==i||"UTF16LE"!==t&&1===i,s=0;s<e.length;s+=1){for(a=e.charCodeAt(s),!0===l&&(c=255&a,a=c<<8|a>>>8),u=p+f,d=u>>>2;m.length<=d;)m.push(0);m[d]|=a<<8*(h+i*(u%4)),p+=2}return{value:m,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,d,u,h=0;const l=t||[0],p=(n=n||0)>>>3,m=-1===r?3:0,f=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!==f&&f<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=Be.indexOf(c.charAt(o)),s|=i<<18-6*o;for(o=0;o<c.length-1;o+=1){for(u=h+p,d=u>>>2;l.length<=d;)l.push(0);l[d]|=(s>>>16-8*o&255)<<8*(m+r*(u%4)),h+=1}}return{value:l,binLen:8*h+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],d=(n=n||0)>>>3,u=-1===r?3:0;for(a=0;a<e.length;a+=1)i=e.charCodeAt(a),s=a+d,o=s>>>2,c.length<=o&&c.push(0),c[o]|=i<<8*(u+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 Me(new Uint8Array(e),t,n,r)}(e,t,r,n)};case"UINT8ARRAY":return function(e,t,r){return Me(e,t,r,n)};default:throw new Error("format must be HEX, TEXT, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}}function ke(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,d=-1===n?3:0;for(a=0;a<c;a+=1)o=e[a>>>2]>>>8*(d+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,d="";const u=t/8,h=-1===n?3:0;for(i=0;i<u;i+=3)for(s=i+1<u?e[i+1>>>2]:0,c=i+2<u?e[i+2>>>2]:0,o=(e[i>>>2]>>>8*(h+n*(i%4))&255)<<16|(s>>>8*(h+n*((i+1)%4))&255)<<8|c>>>8*(h+n*((i+2)%4))&255,a=0;a<4;a+=1)d+=8*i+6*a<=t?Be.charAt(o>>>6*(3-a)&63):r.b64Pad;return d}(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 Le=4294967296,Fe=[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],Re=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428],He=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],De="Chosen SHA variant is not supported",Pe="Cannot set numRounds with MAC";function xe(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 Ie(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 ze(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 Te(t.format,t.encoding||"UTF8",n)(t.value)}var je=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=Ie(t);if(this.isVariableLen){if(-1===a.outputLen)throw new Error("Output length must be specified in options");i=a.outputLen}const o=ke(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=Te(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(Pe);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=Ie(t);return ke(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 Ne(e,t){return e<<t|e>>>32-t}function Ke(e,t){return e>>>t|e<<32-t}function _e(e,t){return e>>>t}function qe(e,t,n){return e^t^n}function Ve(e,t,n){return e&t^~e&n}function We(e,t,n){return e&t^e&n^t&n}function $e(e){return Ke(e,2)^Ke(e,13)^Ke(e,22)}function Ye(e,t){const n=(65535&e)+(65535&t);return((e>>>16)+(t>>>16)+(n>>>16)&65535)<<16|65535&n}function Xe(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 Ge(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 Je(e){return Ke(e,17)^Ke(e,19)^_e(e,10)}function Qe(e){return Ke(e,7)^Ke(e,18)^_e(e,3)}function Ze(e){return Ke(e,6)^Ke(e,11)^Ke(e,25)}function et(e){return[1732584193,4023233417,2562383102,271733878,3285377520]}function tt(e,t){let n,r,i,a,o,s,c;const d=[];for(n=t[0],r=t[1],i=t[2],a=t[3],o=t[4],c=0;c<80;c+=1)d[c]=c<16?e[c]:Ne(d[c-3]^d[c-8]^d[c-14]^d[c-16],1),s=c<20?Ge(Ne(n,5),Ve(r,i,a),o,1518500249,d[c]):c<40?Ge(Ne(n,5),qe(r,i,a),o,1859775393,d[c]):c<60?Ge(Ne(n,5),We(r,i,a),o,2400959708,d[c]):Ge(Ne(n,5),qe(r,i,a),o,3395469782,d[c]),o=a,a=i,i=Ne(r,30),r=n,n=s;return t[0]=Ye(n,t[0]),t[1]=Ye(r,t[1]),t[2]=Ye(i,t[2]),t[3]=Ye(a,t[3]),t[4]=Ye(o,t[4]),t}function nt(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/Le|0,i=0;i<e.length;i+=16)r=tt(e.slice(i,i+16),r);return r}var rt=class extends je{intermediateState;variantBlockSize;bigEndianMod;outputBinLen;isVariableLen;HMACSupported;converterFunc;roundFunc;finalizeFunc;stateCloneFunc;newStateFunc;getMAC;constructor(e,t,n){if("SHA-1"!==e)throw new Error(De);super(e,t,n);const r=n||{};this.HMACSupported=!0,this.getMAC=this._getHMAC,this.bigEndianMod=-1,this.converterFunc=Te(this.inputFormat,this.utfType,this.bigEndianMod),this.roundFunc=tt,this.stateCloneFunc=function(e){return e.slice()},this.newStateFunc=et,this.finalizeFunc=nt,this.intermediateState=[1732584193,4023233417,2562383102,271733878,3285377520],this.variantBlockSize=512,this.outputBinLen=160,this.isVariableLen=!1,r.hmacKey&&this._setHMACKey(ze("hmacKey",r.hmacKey,this.bigEndianMod))}};function it(e){let t;return t="SHA-224"===e?Re.slice():He.slice(),t}function at(e,t){let n,r,i,a,o,s,c,d,u,h,l;const p=[];for(n=t[0],r=t[1],i=t[2],a=t[3],o=t[4],s=t[5],c=t[6],d=t[7],l=0;l<64;l+=1)p[l]=l<16?e[l]:Xe(Je(p[l-2]),p[l-7],Qe(p[l-15]),p[l-16]),u=Ge(d,Ze(o),Ve(o,s,c),Fe[l],p[l]),h=Ye($e(n),We(n,r,i)),d=c,c=s,s=o,o=Ye(a,u),a=i,i=r,r=n,n=Ye(u,h);return t[0]=Ye(n,t[0]),t[1]=Ye(r,t[1]),t[2]=Ye(i,t[2]),t[3]=Ye(a,t[3]),t[4]=Ye(o,t[4]),t[5]=Ye(s,t[5]),t[6]=Ye(c,t[6]),t[7]=Ye(d,t[7]),t}var ot=class extends je{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(De);super(e,t,n);const r=n||{};this.getMAC=this._getHMAC,this.HMACSupported=!0,this.bigEndianMod=-1,this.converterFunc=Te(this.inputFormat,this.utfType,this.bigEndianMod),this.roundFunc=at,this.stateCloneFunc=function(e){return e.slice()},this.newStateFunc=it,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/Le|0,a=0;a<e.length;a+=16)r=at(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=it(e),this.variantBlockSize=512,this.outputBinLen="SHA-224"===e?224:256,this.isVariableLen=!1,r.hmacKey&&this._setHMACKey(ze("hmacKey",r.hmacKey,this.bigEndianMod))}},st=class{highOrder;lowOrder;constructor(e,t){this.highOrder=e,this.lowOrder=t}};function ct(e,t){let n;return t>32?(n=64-t,new st(e.lowOrder<<t|e.highOrder>>>n,e.highOrder<<t|e.lowOrder>>>n)):0!==t?(n=32-t,new st(e.highOrder<<t|e.lowOrder>>>n,e.lowOrder<<t|e.highOrder>>>n)):e}function dt(e,t){let n;return t<32?(n=32-t,new st(e.highOrder>>>t|e.lowOrder<<n,e.lowOrder>>>t|e.highOrder<<n)):(n=64-t,new st(e.lowOrder>>>t|e.highOrder<<n,e.highOrder>>>t|e.lowOrder<<n))}function ut(e,t){return new st(e.highOrder>>>t,e.lowOrder>>>t|e.highOrder<<32-t)}function ht(e,t,n){return new st(e.highOrder&t.highOrder^~e.highOrder&n.highOrder,e.lowOrder&t.lowOrder^~e.lowOrder&n.lowOrder)}function lt(e,t,n){return new st(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 pt(e){const t=dt(e,28),n=dt(e,34),r=dt(e,39);return new st(t.highOrder^n.highOrder^r.highOrder,t.lowOrder^n.lowOrder^r.lowOrder)}function mt(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 st((65535&r)<<16|65535&n,i)}function ft(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 st((65535&a)<<16|65535&i,o)}function gt(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 st((65535&o)<<16|65535&a,s)}function wt(e,t){return new st(e.highOrder^t.highOrder,e.lowOrder^t.lowOrder)}function yt(e,t,n,r,i){return new st(e.highOrder^t.highOrder^n.highOrder^r.highOrder^i.highOrder,e.lowOrder^t.lowOrder^n.lowOrder^r.lowOrder^i.lowOrder)}function Ct(e){const t=dt(e,19),n=dt(e,61),r=ut(e,6);return new st(t.highOrder^n.highOrder^r.highOrder,t.lowOrder^n.lowOrder^r.lowOrder)}function bt(e){const t=dt(e,1),n=dt(e,8),r=ut(e,7);return new st(t.highOrder^n.highOrder^r.highOrder,t.lowOrder^n.lowOrder^r.lowOrder)}function St(e){const t=dt(e,14),n=dt(e,18),r=dt(e,41);return new st(t.highOrder^n.highOrder^r.highOrder,t.lowOrder^n.lowOrder^r.lowOrder)}var At=[new st(Fe[0],3609767458),new st(Fe[1],602891725),new st(Fe[2],3964484399),new st(Fe[3],2173295548),new st(Fe[4],4081628472),new st(Fe[5],3053834265),new st(Fe[6],2937671579),new st(Fe[7],3664609560),new st(Fe[8],2734883394),new st(Fe[9],1164996542),new st(Fe[10],1323610764),new st(Fe[11],3590304994),new st(Fe[12],4068182383),new st(Fe[13],991336113),new st(Fe[14],633803317),new st(Fe[15],3479774868),new st(Fe[16],2666613458),new st(Fe[17],944711139),new st(Fe[18],2341262773),new st(Fe[19],2007800933),new st(Fe[20],1495990901),new st(Fe[21],1856431235),new st(Fe[22],3175218132),new st(Fe[23],2198950837),new st(Fe[24],3999719339),new st(Fe[25],766784016),new st(Fe[26],2566594879),new st(Fe[27],3203337956),new st(Fe[28],1034457026),new st(Fe[29],2466948901),new st(Fe[30],3758326383),new st(Fe[31],168717936),new st(Fe[32],1188179964),new st(Fe[33],1546045734),new st(Fe[34],1522805485),new st(Fe[35],2643833823),new st(Fe[36],2343527390),new st(Fe[37],1014477480),new st(Fe[38],1206759142),new st(Fe[39],344077627),new st(Fe[40],1290863460),new st(Fe[41],3158454273),new st(Fe[42],3505952657),new st(Fe[43],106217008),new st(Fe[44],3606008344),new st(Fe[45],1432725776),new st(Fe[46],1467031594),new st(Fe[47],851169720),new st(Fe[48],3100823752),new st(Fe[49],1363258195),new st(Fe[50],3750685593),new st(Fe[51],3785050280),new st(Fe[52],3318307427),new st(Fe[53],3812723403),new st(Fe[54],2003034995),new st(Fe[55],3602036899),new st(Fe[56],1575990012),new st(Fe[57],1125592928),new st(Fe[58],2716904306),new st(Fe[59],442776044),new st(Fe[60],593698344),new st(Fe[61],3733110249),new st(Fe[62],2999351573),new st(Fe[63],3815920427),new st(3391569614,3928383900),new st(3515267271,566280711),new st(3940187606,3454069534),new st(4118630271,4000239992),new st(116418474,1914138554),new st(174292421,2731055270),new st(289380356,3203993006),new st(460393269,320620315),new st(685471733,587496836),new st(852142971,1086792851),new st(1017036298,365543100),new st(1126000580,2618297676),new st(1288033470,3409855158),new st(1501505948,4234509866),new st(1607167915,987167468),new st(1816402316,1246189591)];function vt(e){return"SHA-384"===e?[new st(3418070365,Re[0]),new st(1654270250,Re[1]),new st(2438529370,Re[2]),new st(355462360,Re[3]),new st(1731405415,Re[4]),new st(41048885895,Re[5]),new st(3675008525,Re[6]),new st(1203062813,Re[7])]:[new st(He[0],4089235720),new st(He[1],2227873595),new st(He[2],4271175723),new st(He[3],1595750129),new st(He[4],2917565137),new st(He[5],725511199),new st(He[6],4215389547),new st(He[7],327033209)]}function Ot(e,t){let n,r,i,a,o,s,c,d,u,h,l,p;const m=[];for(n=t[0],r=t[1],i=t[2],a=t[3],o=t[4],s=t[5],c=t[6],d=t[7],l=0;l<80;l+=1)l<16?(p=2*l,m[l]=new st(e[p],e[p+1])):m[l]=ft(Ct(m[l-2]),m[l-7],bt(m[l-15]),m[l-16]),u=gt(d,St(o),ht(o,s,c),At[l],m[l]),h=mt(pt(n),lt(n,r,i)),d=c,c=s,s=o,o=mt(a,u),a=i,i=r,r=n,n=mt(u,h);return t[0]=mt(n,t[0]),t[1]=mt(r,t[1]),t[2]=mt(i,t[2]),t[3]=mt(a,t[3]),t[4]=mt(o,t[4]),t[5]=mt(s,t[5]),t[6]=mt(c,t[6]),t[7]=mt(d,t[7]),t}var Et=class extends je{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(De);super(e,t,n);const r=n||{};this.getMAC=this._getHMAC,this.HMACSupported=!0,this.bigEndianMod=-1,this.converterFunc=Te(this.inputFormat,this.utfType,this.bigEndianMod),this.roundFunc=Ot,this.stateCloneFunc=function(e){return e.slice()},this.newStateFunc=vt,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/Le|0,a=0;a<e.length;a+=32)r=Ot(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=vt(e),this.variantBlockSize=1024,this.outputBinLen="SHA-384"===e?384:512,this.isVariableLen=!1,r.hmacKey&&this._setHMACKey(ze("hmacKey",r.hmacKey,this.bigEndianMod))}},Ut=[new st(0,1),new st(0,32898),new st(2147483648,32906),new st(2147483648,2147516416),new st(0,32907),new st(0,2147483649),new st(2147483648,2147516545),new st(2147483648,32777),new st(0,138),new st(0,136),new st(0,2147516425),new st(0,2147483658),new st(0,2147516555),new st(2147483648,139),new st(2147483648,32905),new st(2147483648,32771),new st(2147483648,32770),new st(2147483648,128),new st(0,32778),new st(2147483648,2147483658),new st(2147483648,2147516545),new st(2147483648,32896),new st(0,2147483649),new st(2147483648,2147516424)],Bt=[[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 Mt(e){let t;const n=[];for(t=0;t<5;t+=1)n[t]=[new st(0,0),new st(0,0),new st(0,0),new st(0,0),new st(0,0)];return n}function Tt(e){let t;const n=[];for(t=0;t<5;t+=1)n[t]=e[t].slice();return n}function kt(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]=wt(t[(r>>>1)%5][(r>>>1)/5|0],new st(e[r+1],e[r]));for(n=0;n<24;n+=1){for(a=Mt(),r=0;r<5;r+=1)o[r]=yt(t[r][0],t[r][1],t[r][2],t[r][3],t[r][4]);for(r=0;r<5;r+=1)s[r]=wt(o[(r+4)%5],ct(o[(r+1)%5],1));for(r=0;r<5;r+=1)for(i=0;i<5;i+=1)t[r][i]=wt(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]=ct(t[r][i],Bt[r][i]);for(r=0;r<5;r+=1)for(i=0;i<5;i+=1)t[r][i]=wt(a[r][i],new st(~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]=wt(t[0][0],Ut[n])}return t}function Lt(e){let t,n,r=0;const i=[0,0],a=[4294967295&e,e/Le&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 Ft(e){return xe(Lt(e.binLen),e)}function Rt(e,t){let n,r=Lt(t);r=xe(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 Ht=class extends je{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(Pe);if("CSHAKE128"===this.shaVariant||"CSHAKE256"===this.shaVariant)throw new Error("Cannot set numRounds for CSHAKE variants")}switch(this.bigEndianMod=1,this.converterFunc=Te(this.inputFormat,this.utfType,this.bigEndianMod),this.roundFunc=kt,this.stateCloneFunc=Tt,this.newStateFunc=Mt,this.intermediateState=Mt(),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(De)}this.finalizeFunc=function(e,t,n,a,o){return function(e,t,n,r,i,a,o){let s,c,d=0;const u=[],h=i>>>5,l=t>>>5;for(s=0;s<l&&t>=i;s+=h)r=kt(e.slice(s,s+h),r),t-=i;for(e=e.slice(s),t%=i;e.length<h;)e.push(0);for(s=t>>>3,e[s>>2]^=a<<s%4*8,e[h-1]^=2147483648,r=kt(e,r);32*u.length<o&&(c=r[d%5][d/5|0],u.push(c.lowOrder),!(32*u.length>=o));)u.push(c.highOrder),d+=1,0==64*d%i&&(kt(null,r),d=0);return u}(e,t,0,a,i,r,o)},a.hmacKey&&this._setHMACKey(ze("hmacKey",a.hmacKey,this.bigEndianMod))}_initializeCSHAKE(e,t){const n=function(e){const t=e||{};return{funcName:ze("funcName",t.funcName,1,{value:[],binLen:0}),customization:ze("Customization",t.customization,1,{value:[],binLen:0})}}(e||{});t&&(n.funcName=t);const r=xe(Ft(n.funcName),Ft(n.customization));if(0!==n.customization.binLen||0!==n.funcName.binLen){const e=Rt(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:ze("kmacKey",t.kmacKey,1),funcName:{value:[1128353099],binLen:32},customization:ze("Customization",t.customization,1,{value:[],binLen:0})}}(e||{});this._initializeCSHAKE(e,t.funcName);const n=Rt(Ft(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=xe({value:this.remainder.slice(),binLen:this.remainderLen},function(e){let t,n,r=0;const i=[0,0],a=[4294967295&e,e/Le&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)}},Dt=class{shaObj;constructor(e,t,n){if("SHA-1"===e)this.shaObj=new rt(e,t,n);else if("SHA-224"===e||"SHA-256"===e)this.shaObj=new ot(e,t,n);else if("SHA-384"===e||"SHA-512"===e)this.shaObj=new Et(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(De);this.shaObj=new Ht(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)}},Pt=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 Dt(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 d=Math.max(c.length-n.digits,0);c=c.substring(d,d+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}},xt=(e,t)=>{C&&localStorage.setItem(e,t)},It=e=>C&&localStorage.getItem(e)||"";function zt(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 jt=(e=l)=>{["log","info","warn","error","assert"].forEach(t=>{ce(console,t,n=>function(...r){n&&(e(t,...r),n.apply(console,r))})})},Nt=(e,t=500)=>{let n;return(...r)=>{clearTimeout(n),n=setTimeout(()=>{e.apply(void 0,r)},t)}},Kt=(e,t)=>{if("undefined"==typeof document)return;const n=e.classList;n.contains(t)||n.add(t)},_t=(e,t)=>{if("undefined"==typeof document)return;const n=e.classList;n.contains(t)&&n.remove(t)},qt=e=>{if("undefined"==typeof document)return;const t=document.createDocumentFragment();return e.forEach(e=>t.appendChild(e)),t},Vt=/["'&<>]/;function Wt(e){const t=""+e,n=Vt.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 $t=(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 d=s/t*16;e&&(d/=a),n.style.fontSize=`${d}px`;const u=window.getComputedStyle(n).fontSize.replace("px","")||0;d!==u&&(n.style.fontSize=d/Number(u)*d+"px")}y()===w.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()},Yt=["svg","path","g","circle","rect","line","polyline","polygon","ellipse","text","tspan","textPath","defs","marker","radialGradient","stop","linearGradient","clipPath","mask","pattern","image","use","symbol","foreignObject","feGaussianBlur","feColorMatrix"],Xt=class e{listener;element;constructor(e,t){this.element=this.create(e,t),this.listener=/* @__PURE__ */new Map}create=(e,t)=>Yt.includes(e)?document.createElementNS("http://www.w3.org/2000/svg",e,t):document.createElement(e,t);setAttribute=(e,t)=>(this.element.setAttribute(e,t),this);removeAttribute=e=>(this.element.removeAttribute(e),this);append=e=>(this.element.appendChild(e),this);remove=e=>(this.element.removeChild(e),this);setTextContent=e=>(this.element.textContent=e,this);setStyle=(e,t)=>(this.element.style.setProperty(e,t),this);addElementByType=(t,n)=>{t instanceof e&&n.appendChild(t.element),t instanceof HTMLElement&&n.appendChild(t)};addChild=e=>{if(Array.isArray(e)){const t=document.createDocumentFragment();e.forEach(e=>{this.addElementByType(e,t)}),this.element.appendChild(t)}else this.addElementByType(e,this.element);return this};listen=(e,t,n)=>{let r=this.listener.get(e);r||(r=/* @__PURE__ */new Map,this.listener.set(e,r));const i=r.get(t.name);return i===t&&console.warn(`${i.name} listener has been added to ${e} event, please remove it first.`),this.element.addEventListener(e,t,n),r.set(t.name,t),this};clearListener=(e,t,n)=>{this.element.removeEventListener(e,t,n);const r=this.listener.get(e);return r?r.delete(t.name):console.warn(`No ${e} event listener has been added.`),this};clearAllListener=()=>{for(const[e,t]of this.listener){for(const[n,r]of t)this.element.removeEventListener(e,r),t.delete(n);this.listener.delete(e)}return this}},Gt=(e,t)=>new Xt(e,t),Jt=(e=l)=>{"undefined"!=typeof window&&(window.addEventListener("unhandledrejection",t=>{e(t)},!0),window.addEventListener("error",t=>(e(t),!1),!0))},Qt=(e,t,n)=>new Promise((r,i)=>{C||i("window is undefined");const a=window.URL||window.webkitURL,o=new Image;o.onload=function(){let e=!1;t&&(e=o.width===t),n&&(e=o.height===n),a.revokeObjectURL(o.src),r(e)},o.src=a.createObjectURL(e)}),Zt=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)});function en(){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:d,loadEventStart:u,domInteractive:h,domContentLoadedEventEnd:l,duration:p,responseStart:m,requestStart:f,responseEnd:g,fetchStart:w,transferSize:y,encodedBodySize:C,redirectEnd:b,redirectStart:S,redirectCount:A}=e;return{dnsSearch:a-o,tcpConnect:s-c,sslConnect:s-d,request:m-f,response:g-m,parseDomTree:h-g,resource:u-l,domReady:l-w,interactive:h-w,complete:u-w,httpHead:y-C,redirect:A,redirectTime:b-S,duration:p,fp:r,fcp:i}}}var tn=({url:e="",type:t="application/json; charset=UTF-8",payload:n={}})=>{const r=e||T();return"undefined"!=typeof navigator?(({url:e="",type:t="application/json; charset=UTF-8",payload:n={}})=>{const r=e||T();if(navigator.sendBeacon&&r){const e=new Blob([JSON.stringify(n)],{type:t});return navigator.sendBeacon(r,e)}})({url:r,type:t,payload:n}):(({url:e="",payload:t={}})=>{const n=e||T();if("undefined"!=typeof document&&n){const e=new Image;e.width=1,e.height=1,e.src=`${n}?${ie(t)}`}})({url:r,payload:n})};function nn(e={}){if("undefined"!=typeof window){const{width:t,height:n}=D();return Object.assign({},{id:r(),path:window.location.href,time:Date.now(),referrer:document.referrer,ip:window.returnCitySN||{cid:"",cip:"",cname:""},userId:O("chaxus_prod"),ratio:`${t}x${n}`,userAgent:window.navigator.userAgent},e)}return{}}var rn=(e={})=>{if("undefined"!=typeof window){const{requestHook:t=l,responseHook:n=l,errorHook:r=l}=e;ce(window,"fetch",e=>(i,a)=>(t(i,a),e.apply(window,[i,a]).then(e=>(n(i,a,e),e)).catch(e=>{throw r(i,e),e})))}},an=(e={})=>{if("undefined"!=typeof window){const t=XMLHttpRequest.prototype,{requestHook:n=l,responseHook:r=l,errorHook:i=l}=e;ce(t,"open",e=>function(...t){n(t),e.apply(this,t)});ce(t,"send",e=>function(...t){this.addEventListener("loadend",function(){r(this)}),this.addEventListener("error",function(){i(this)}),e.apply(this,t)})}};function on(e,t=300){let n=0,r=null;return function(...i){const a=Date.now();a-n>=t?(null!=r&&(clearTimeout(r),r=null),n=a,e.apply(this,i)):null==r&&(r=window.setTimeout(()=>{n=Date.now(),e.apply(this,i),r=null},t-(a-n)))}}var sn=()=>{let e=0,t=null;return function(n,r=300){return function(...i){const a=Date.now();a-e>=r?(null!=t&&(clearTimeout(t),t=null),e=a,n.apply(this,i)):null==t&&(t=window.setTimeout(()=>{e=Date.now(),n.apply(this,i),t=null},r-(a-e)))}}},cn=class{constructor(){this.initialize()}reportPerformance(){const e=en(),t=nn();tn({payload:{...e,...t}})}log(e){tn({payload:e})}reportClick(){const e=on(tn),t=nn();((e=l)=>{"undefined"!=typeof document&&document.addEventListener("click",function(t){e(t)},!0)})(n=>{const{pageX:r,pageY:i,screenX:a,screenY:o,type:s}=n;e({payload:{...t,data:{pageX:r,pageY:i,screenX:a,screenY:o,type:s},type:"click"}})})}reportXhr(){const e=on(tn),t=nn();an({requestHook:(...n)=>{e({payload:{...t,data:{...n},type:"xhrRequest"}})},responseHook:(...n)=>{e({payload:{...t,data:{...n},type:"xhrResponse"}})},errorHook:(...n)=>{e({payload:{...t,data:{...n},type:"xhrError"}})}})}reportFetch(){const e=on(tn),t=nn();rn({requestHook:(...n)=>{e({payload:{...t,data:{...n},type:"fetchRequest"}})},responseHook:(...n)=>{e({payload:{...t,data:{...n},type:"fetchResponse"}})},errorHook:(...n)=>{e({payload:{...t,data:{...n},type:"fetchError"}})}})}reportError(){const e=on(tn),t=nn();Jt((...n)=>{e({payload:{...t,data:{...n},type:"error"}})})}reportConsole(){const e=on(tn),t=nn();jt((...n)=>{e({payload:{...t,data:{...n},type:"console"}})})}init=()=>{this.reportClick(),this.reportError(),this.reportFetch(),this.reportPerformance(),this.reportXhr()};initialize(){"undefined"==typeof window||window.ranlog||(window.ranlog=!0,this.init()),"undefined"==typeof process||process.ranlog||(process.ranlog=!0,this.init())}},dn=/* @__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"]]),un={message:dn,code:function(e){const t=/* @__PURE__ */new Map;for(const[n,r]of e)t.set(r.toLowerCase(),n);return t}(dn),codes:function(e){const t=[];for(const[n,r]of e)t.push(n);return t}(dn),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 hn(e){if(!un.message.has(e))throw new Error("invalid status code: "+e);return un.message.get(e)}function ln(e){if("number"==typeof e)return hn(e);if("string"!=typeof e)throw new TypeError("code must be a number or string");const t=parseInt(e,10);return!isNaN(t)&&un.codes.includes(t)?hn(t):function(e){const t=e.toLowerCase();if(un.code.has(t),!un.code.has(t))throw new Error('invalid status message: "'+e+'"');return un.code.get(t)}(e)}var pn=class{current;queue;simultaneous;executed;total;constructor({simultaneous:e,total:t}){this.current=0,this.queue=[],this.simultaneous=e,this.executed=0,this.total=t}add=e=>{if("function"!=typeof e)return;this.queue.push(()=>new Promise((t,n)=>{this.current++,e().then(t).catch(n).finally(()=>{this.current--,this.running()})}))};running=()=>new Promise((e,t)=>{if(this.current<=this.simultaneous&&this.queue.length){const n=this.queue.pop();n&&n().then(e).catch(t).finally(()=>{this.executed++})}else e({})});allSettled=()=>{let e=0;return new Promise((t,n)=>{const r=[];if(this.current<this.simultaneous&&this.queue.length){const i=this.queue.pop();e++,i&&i().then(n=>{r[e]=n,t(n)}).catch(t=>{r[e]=t,n(t)}).finally(()=>{this.executed++})}this.executed>=this.total&&t(r)})}},mn=(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{P as $,Oe as A,c as At,ie as B,jt as C,b as Ct,Pt as D,l as Dt,xt as E,m as Et,oe as F,X as G,ue as H,ae as I,Q as J,J as K,le as L,Ae as M,o as Mt,Se as N,d as Nt,Ue as O,s as Ot,pe as P,G as Q,se as R,Nt as S,S as St,It as T,f as Tt,re as U,ce as V,V as W,ne as X,Y,F as Z,Gt as _,E as _t,cn as a,O as at,_t as b,A as bt,rn as c,T as ct,en as d,D as dt,B as et,Zt as f,j as ft,Kt as g,R as gt,Xt as h,te as ht,un as i,k as it,ve as j,a as jt,Ee as k,u as kt,nn as l,U as lt,Jt as m,K as mt,pn as n,N as nt,sn as o,H as ot,Qt as p,_ as pt,W as q,ln as r,z as rt,on as s,M as st,mn as t,ee as tt,tn as u,L as ut,qt as v,v as vt,zt as w,g as wt,$t as x,C as xt,Wt as y,y as yt,de as z};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { BuildOptions, UserConfig } from 'vite';
|
|
2
|
+
export declare const umd: BuildOptions;
|
|
3
|
+
export declare const umdUtil: BuildOptions;
|
|
4
|
+
export declare const umdNode: BuildOptions;
|
|
5
|
+
export declare const es: BuildOptions;
|
|
6
|
+
export declare const viteConfig: UserConfig;
|
|
7
|
+
declare const _default: UserConfig;
|
|
8
|
+
export default _default;
|
package/docs/API.md
ADDED
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
# ranuts API (Generated)
|
|
2
|
+
|
|
3
|
+
Auto-generated by `bin/generate-api-docs.ts` (`npm run doc:api`). Per-entry-point
|
|
4
|
+
reference of every exported symbol with its signature and one-line description,
|
|
5
|
+
extracted from source + JSDoc. For orientation (which entry to import, runtime
|
|
6
|
+
constraints, conventions) read [../CLAUDE.md](../CLAUDE.md) first.
|
|
7
|
+
|
|
8
|
+
Import from the **subpath** that owns the symbol, e.g. `import { debounce } from
|
|
9
|
+
'ranuts/utils'`. The root `ranuts` barrel re-exports the utils + visual surface.
|
|
10
|
+
|
|
11
|
+
**199 exports** across 4 entry points. Generated at 2026-07-04T09:39:55.881Z.
|
|
12
|
+
|
|
13
|
+
## Entry points
|
|
14
|
+
|
|
15
|
+
- [`ranuts/utils`](#ranutsutils) — 浏览器 / 通用工具函数 · _browser + node_ · 135 exports
|
|
16
|
+
- [`ranuts/node`](#ranutsnode) — Node 服务端工具(fs / http / ws / 中间件) · _node only_ · 26 exports
|
|
17
|
+
- [`ranuts/visual`](#ranutsvisual) — 2D 渲染引擎(Canvas / WebGL / WebGPU) · _browser only_ · 12 exports
|
|
18
|
+
- [`ranuts/vnode`](#ranutsvnode) — Snabbdom 风格虚拟 DOM · _browser_ · 26 exports
|
|
19
|
+
|
|
20
|
+
## `ranuts/utils`
|
|
21
|
+
|
|
22
|
+
浏览器 / 通用工具函数 · runtime: **browser + node** · source: `src/utils/index.ts`
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
import {} from /* … */ 'ranuts/utils';
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### Functions
|
|
29
|
+
|
|
30
|
+
- `acceptPortBridge({ targetOrigin, name }?: AcceptPortBridgeOptions): Promise<PortBridge>` — 接收方:等待发起方递来的 port,握手完成后返回 bridge。
|
|
31
|
+
- `addClassToElement(element: Element, addClass: string): void` — 给指定的元素添加指定的 class
|
|
32
|
+
- `addNumSym(value: string | number, flag?: string | number): string`
|
|
33
|
+
- `appendUrl(url: string, params?: Record<string, string>): string` — 将一个对象转换成 querystring,拼接到 url 后面
|
|
34
|
+
- `audioVendor(): Promise<string>` — 音频指纹,1.生成音频信息流 (三角波),对其进行 FFT 变换,计算 SHA 值作为指纹。2.生成音频信息流(正弦波),进行动态压缩处理,计算 MD5 值。
|
|
35
|
+
- `canvasVendor(): string | null`
|
|
36
|
+
- `changeHumpToLowerCase(str: string): string`
|
|
37
|
+
- `checkEncoding(uint8Array: Uint8Array): string`
|
|
38
|
+
- `clearBr(str?: string): string` — 清除字符串中的空格、换行和 HTML 标签
|
|
39
|
+
- `clearStr(str: string, options?: ClearStrOption): string` — 去除字符串首尾的空格,encode 编码,首尾的引号
|
|
40
|
+
- `cloneDeep<T>(value: T, cloneMap?: WeakMap<object, any>): T` — 深克隆函数,支持各种复杂数据类型和循环引用
|
|
41
|
+
- `componentToHex(c: string | number): string`
|
|
42
|
+
- `compose<T>(middleware: Array<Middleware<T>>): ComposedMiddleware<T>` — 将异步函数转化为同步的方式进行执行
|
|
43
|
+
- `connection(): number | undefined` — 返回当前网络状态,当前吞吐量,是否切换网络
|
|
44
|
+
- `convertImageToBase64(file: File): Promise<convertImageToBase64Return>` — 图片转 base64
|
|
45
|
+
- `create(tagName: string, options?: ElementCreationOptions): Chain`
|
|
46
|
+
- `createData(params?: Record<string, unknown>): Record<string, unknown>`
|
|
47
|
+
- `createDocumentFragment(list: Element[]): DocumentFragment | undefined` — 创建一个 Fragment
|
|
48
|
+
- `createObjectURL(src: Blob | ArrayBuffer | Response): Promise<string>`
|
|
49
|
+
- `createPortBridge(port: MessagePort): PortBridge` — 在任意 MessagePort 上构建 bridge(Web Worker / SharedWorker 或已握手的 port)。
|
|
50
|
+
- `createSignal<T = unknown>(value: T, options?: { subscriber?: string; equals?: boolean | ((prev: T | undefined, next: T) => boolean); }): [() => T, (newValue: T…`
|
|
51
|
+
- `currentDevice(): CurrentDevice`
|
|
52
|
+
- `debounce(fn: any, ms?: number): any` — 防抖
|
|
53
|
+
- `durationHandler<T, U>(handler: (...args: T[]) => U, ...params: T[]): ((a: number) => Promise<U>)` — 间隔一定时间,执行指定的函数
|
|
54
|
+
- `encodeUrl(url: string): string` — Encode a URL to a percent-encoded form, excluding already-encoded sequences.
|
|
55
|
+
- `escapeHtml(string?: string | number | null): string`
|
|
56
|
+
- `filterObj(obj: Record<string, unknown>, list: Array<string>): Record<string, unknown>` — 过滤对象的属性,去除对象中在 list 数组里面有的属性,返回一个新对象,一般是用于去除空字符和 null
|
|
57
|
+
- `formatJson(jsonObj: string, callback?: () => void): string`
|
|
58
|
+
- `generateThrottle(): Function` — 生成节流函数
|
|
59
|
+
- `getAllQueryString(url?: string): Record<string, string>` — 将 url 上的字符串转换成对象
|
|
60
|
+
- `getCookie(objName: string): string` — 获取指定的 cookie
|
|
61
|
+
- `getCookieByName(name: string): string`
|
|
62
|
+
- `getExtensions(mimeType: string): string[]` — Get file extensions from MIME type
|
|
63
|
+
- `getFrame(n?: number): Promise<number>` — 计算每毫秒的帧率,每秒的帧率需要乘 1000
|
|
64
|
+
- `getHost(env?: string): string | undefined` — Gets the current environment configuration
|
|
65
|
+
- `getMatchingSentences(text: string, searchValue: string): string[]` — 获取文本中包含搜索关键词的完整句子,对于重复的句子只保留最长的一个
|
|
66
|
+
- `getMime(ext: string): string | undefined`
|
|
67
|
+
- `getPerformance(): BasicType | undefined`
|
|
68
|
+
- `getPixelRatio(context: CanvasRenderingContext2D & Partial<Context>): number` — 获取分辨率
|
|
69
|
+
- `getQuery(url?: string): Record<string, string>` — 将 url 上的字符串转换成对象
|
|
70
|
+
- `getRandomString(len?: number): string`
|
|
71
|
+
- `getStatus(code?: number | string): number | string | undefined` — Get the status code.
|
|
72
|
+
- `getWindow(): ClientRatio` — 跨浏览器获取可视窗口大小
|
|
73
|
+
- `handleConsole(hooks?: (...args: unknown[]) => void): void`
|
|
74
|
+
- `handleError(hooks?: (error: Error | PromiseRejectionEvent | ErrorEvent) => void): void`
|
|
75
|
+
- `handleFetchHook(options?: Partial<Options>): void` — fetch
|
|
76
|
+
- `hexToRgb(hex: string): RegExpExecArray | null | Array<number>`
|
|
77
|
+
- `hsbToRgb(h: number, s: number, v: number): number[]`
|
|
78
|
+
- `hslToRgb(h: number | string | number[], s: number | string, l: number | string): Array<number>`
|
|
79
|
+
- `hsvToHsl(h: any, s: any, b: any): number[]`
|
|
80
|
+
- `hsvToRgb(h: number, s: number, v: number): number[]`
|
|
81
|
+
- `hue2rgb(p: number, q: number, t: number): number`
|
|
82
|
+
- `imageRequest(url?: string): Promise<number>` — 图片请求
|
|
83
|
+
- `isBangDevice(): boolean`
|
|
84
|
+
- `isEqual(value: any, other: any, seen?: Map<any, any>): boolean` — 深度比较两个值是否相等
|
|
85
|
+
- `isImageSize(file: File, width?: number, height?: number): Promise<boolean>` — 校验图片尺寸
|
|
86
|
+
- `isMobile(): boolean` — 是否是移动端
|
|
87
|
+
- `isSafari(): boolean | undefined | string`
|
|
88
|
+
- `isString(obj: unknown): boolean`
|
|
89
|
+
- `isWeiXin(): boolean` — 判断是否是微信浏览器的函数
|
|
90
|
+
- `localStorageGetItem(name: string): string`
|
|
91
|
+
- `localStorageSetItem(name: string, value: string): void`
|
|
92
|
+
- `mathjs(a: number, type: string, b: number): ComputeNumberResult`
|
|
93
|
+
- `md5(str: string): string` — MD5 hash function implementation
|
|
94
|
+
- `memoize(fn: unknown): Func` — 返回缓存的函数,执行一次后,无须执行直接返回结果
|
|
95
|
+
- `merge(a: Obj, b?: Obj): Obj` — 合并对象
|
|
96
|
+
- `mergeExports(obj: Record<string, string>, exports: Record<string, string>): Record<string, string>` — 将 exports 对象拼接到 obj 上,并冻结 obj
|
|
97
|
+
- `networkSpeed(options: Options): Promise<ReturnType>` — 通过请求来测试当前网络的 ping 值
|
|
98
|
+
- `noop(): void`
|
|
99
|
+
- `openPortBridge({ targetWindow, targetOrigin, name }: OpenPortBridgeOptions): PortBridge` — 发起方:创建 MessageChannel,把一端交给目标窗口,自己持有另一端。
|
|
100
|
+
- `performanceTime(): number` — 获取当前时间戳
|
|
101
|
+
- `perToNum(str?: string): number` — 百分比转换成数字
|
|
102
|
+
- `querystring(data?: {}): string` — 对象转 url 字符串
|
|
103
|
+
- `randomColor(): Color`
|
|
104
|
+
- `randomString(len?: number): string`
|
|
105
|
+
- `range(num: number, min?: number, max?: number): number` — 限制最大和最小值
|
|
106
|
+
- `removeClassToElement(element: Element, removeClass: string): void` — 给指定的元素移除指定的 class
|
|
107
|
+
- `removeGhosting(event: DragEvent): void` — 移除拖拽事件的阴影
|
|
108
|
+
- `replaceOld(source: any, name: string, replacement: (...args: unknown[]) => unknown, isForced?: boolean): void` — 重写对象上面的某个属性
|
|
109
|
+
- `report({ url, type, payload, }: BeaconPayload): boolean | undefined | void`
|
|
110
|
+
- `requestUrlToBuffer(src: string, options: Partial<RequestUrlToArraybufferOption>): Promise<requestUrlToArraybufferReturn>` — url 转 arrayBuffer
|
|
111
|
+
- `retain(callback?: () => void): void` — 覆盖浏览器的后退事件
|
|
112
|
+
- `rgbToHex(r: string | number | Array<string | number>, g?: string | number, b?: string | number): string`
|
|
113
|
+
- `rgbToHsb(r: number, g: number, b: number): number[]`
|
|
114
|
+
- `rgbToHsl(r: number | number[], g?: number, b?: number): Array<number>`
|
|
115
|
+
- `scriptOnLoad(urls: string[], append?: HTMLElement, callback?: () => void): Promise<void>` — 动态插入 script/link 标签
|
|
116
|
+
- `setAttributeByGlobal(name: string, value: unknown): void` — 给全局对象上增加属性
|
|
117
|
+
- `setFontSize2html(designWidth?: number): void` — 根据 UI 稿宽度设置 rem
|
|
118
|
+
- `setMime(ext: string, mimeType: string): Map<string, string>`
|
|
119
|
+
- `str2Xml(xmlStr: string, format?: DOMParserSupportedType): HTMLElement | undefined` — 传入字符串和指定的格式,将字符串转成 xml
|
|
120
|
+
- `strParse(str?: string, sep?: string | RegExp, eq?: string | RegExp): Record<string, string>` — 将字符串转对象,比如
|
|
121
|
+
- `throttle<T extends (...args: any[]) => any>(func: T, delay?: number): ThrottleFunc<T>` — 节流
|
|
122
|
+
- `timeFormat(time: number): string` — 时间秒,转化成:分割的时间
|
|
123
|
+
- `timestampToTime(timestamp?: number | string): Date & { format?: Function; }` — 时间戳转日期
|
|
124
|
+
- `toString(value: string | number): string`
|
|
125
|
+
- `transformNumber(value: string, locale?: string, precision?: number, fixed?: number): string`
|
|
126
|
+
- `transformText(content: string | ArrayBuffer): TransformText | undefined`
|
|
127
|
+
- `webglVendor(): { vendor: string; renderer: string; } | null`
|
|
128
|
+
|
|
129
|
+
### Classes
|
|
130
|
+
|
|
131
|
+
- `class AudioRecorder` — 录音
|
|
132
|
+
- `class BridgeManager`
|
|
133
|
+
- `class Chain` — 链式调用的 dom 操作
|
|
134
|
+
- `class Color`
|
|
135
|
+
- `class ColorScheme`
|
|
136
|
+
- `class Hsl`
|
|
137
|
+
- `class Hsla`
|
|
138
|
+
- `class Mathjs` — 数字运算(主要用于小数点精度问题)
|
|
139
|
+
- `class Monitor`
|
|
140
|
+
- `class PostMessageBridge` — Bridge 注册事件,供 client 消费
|
|
141
|
+
- `class QuestQueue`
|
|
142
|
+
- `class Rgb`
|
|
143
|
+
- `class Rgba`
|
|
144
|
+
- `class SyncHook`
|
|
145
|
+
- `class TOTP`
|
|
146
|
+
|
|
147
|
+
### Interfaces
|
|
148
|
+
|
|
149
|
+
- `interface AcceptPortBridgeOptions`
|
|
150
|
+
- `interface BridgeManagerOptions`
|
|
151
|
+
- `interface BroadcastPayload`
|
|
152
|
+
- `interface CallToPayload`
|
|
153
|
+
- `interface MessageData`
|
|
154
|
+
- `interface MessageHandler`
|
|
155
|
+
- `interface OpenPortBridgeOptions`
|
|
156
|
+
- `interface PendingRequest`
|
|
157
|
+
- `interface PortBridge` — 基于 MessagePort 的点对点桥接(方案 B,作为新 API 提供)。
|
|
158
|
+
- `interface TransformText`
|
|
159
|
+
|
|
160
|
+
### Types
|
|
161
|
+
|
|
162
|
+
- `type CurrentDevice`
|
|
163
|
+
|
|
164
|
+
### Constants
|
|
165
|
+
|
|
166
|
+
- `const BRIDGE_MARKER: "__ranuts_bridge__"`
|
|
167
|
+
- `const bridgeManager: BridgeManager`
|
|
168
|
+
- `const Client: { connect: ({ id, targetWindow, targetOrigin, channel, }: BridgeManagerOptions) => { bridge: PostMessageBridge; id: string; }; remove: (id: strin…`
|
|
169
|
+
- `const DEFAULT_CHANNEL: "default"`
|
|
170
|
+
- `const FMT: Record<string, string[]>`
|
|
171
|
+
- `const isClient: boolean`
|
|
172
|
+
- `const MessageCodec: { encode(data: any): string; decode<T = any>(encodedStr: string): T | null; encodeFile(file: File): Promise<string>; decodeFile(encoded: st…` — 消息编解码工具
|
|
173
|
+
- `const MimeType: Map<string, string>`
|
|
174
|
+
- `const Platform: { init: <T = unknown, R = unknown>(events: Record<string, MessageHandler<T, R>>) => { destroy: () => void; }; }`
|
|
175
|
+
- `const status: { message: Map<number, string>; code: Map<string, number>; codes: number[]; redirect: { 300: boolean; 301: boolean; 302: boolean; 303: boolean; 3…`
|
|
176
|
+
- `const subscribers: SyncHook`
|
|
177
|
+
|
|
178
|
+
## `ranuts/node`
|
|
179
|
+
|
|
180
|
+
Node 服务端工具(fs / http / ws / 中间件) · runtime: **node only** · source: `src/node/index.ts`
|
|
181
|
+
|
|
182
|
+
```ts
|
|
183
|
+
import {} from /* … */ 'ranuts/node';
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
### Functions
|
|
187
|
+
|
|
188
|
+
- `appendFile(path: string, content: string): Promise<Ranuts.Identification>` — 给一个已经存在的文件追加内容
|
|
189
|
+
- `bodyMiddleware(options?: Partial<ServerBody>): MiddlewareFunction`
|
|
190
|
+
- `connect(connectMiddleware: ConnectMiddleware): MiddlewareFunction`
|
|
191
|
+
- `get({ url }: Request): Promise<Response>`
|
|
192
|
+
- `getIPAdress(): string | undefined`
|
|
193
|
+
- `default(req: Req): ParseUrl | undefined` — 解析 IncomingMessage 类型的请求 url,返回的类型永远是 ParseUrl
|
|
194
|
+
- `prompt({ message, stream, defaultResponse }: PromptOption): Promise<boolean>`
|
|
195
|
+
- `queryFileInfo(path: string): Promise<Ranuts.Identification>` — 查询一个文件的详细信息,一般用于区分文件还是目录(data.isDirectory())
|
|
196
|
+
- `readDir(options: Options): Array<string>`
|
|
197
|
+
- `readFile(path: string, format?: BufferEncoding): FilePromiseResult` — 读取一个文件,读取成功返回状态码和文件内容
|
|
198
|
+
- `readStream(option: ReadOption): ReadStream`
|
|
199
|
+
- `runCommand(command: string, args: string[]): Promise<void>`
|
|
200
|
+
- `startTask(): symbol`
|
|
201
|
+
- `staticMiddleware(option?: Partial<Option>): MiddlewareFunction`
|
|
202
|
+
- `taskEnd(symbol: symbol): number | bigint`
|
|
203
|
+
- `traverse(dir: string, callback: Caller, pre?: string): Promise<any>` — 递归遍历每一个目录,为找到的文件都执行一个函数
|
|
204
|
+
- `traverseSync(dir: string, callback: Caller, pre?: string): void` — 同步方法,递归遍历每一个目录,为找到的文件都执行一个函数
|
|
205
|
+
- `watchFile(path: string, interval?: number): Promise<Ranuts.Identification>` — 观察一个文件是否被改变,返回状态
|
|
206
|
+
- `writeFile(path: string, content: string): Promise<Ranuts.Identification>` — 根据文件路径创建文件,如果文件存在会清空再写入,如果不存在会创建
|
|
207
|
+
- `writeStream(option: WriteOption): WriteStream`
|
|
208
|
+
- `WSS(this: any, server: http.Server): void` — Create a WebSocket Server
|
|
209
|
+
|
|
210
|
+
### Classes
|
|
211
|
+
|
|
212
|
+
- `class Router`
|
|
213
|
+
- `class Server`
|
|
214
|
+
|
|
215
|
+
### Interfaces
|
|
216
|
+
|
|
217
|
+
- `interface Context`
|
|
218
|
+
|
|
219
|
+
### Constants
|
|
220
|
+
|
|
221
|
+
- `const isColorSupported: any`
|
|
222
|
+
|
|
223
|
+
### Other
|
|
224
|
+
|
|
225
|
+
- `default`
|
|
226
|
+
|
|
227
|
+
## `ranuts/visual`
|
|
228
|
+
|
|
229
|
+
2D 渲染引擎(Canvas / WebGL / WebGPU) · runtime: **browser only** · source: `src/utils/visual/index.ts`
|
|
230
|
+
|
|
231
|
+
```ts
|
|
232
|
+
import {} from /* … */ 'ranuts/visual';
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
### Classes
|
|
236
|
+
|
|
237
|
+
- `class Application`
|
|
238
|
+
- `class Container`
|
|
239
|
+
- `class Graphics`
|
|
240
|
+
|
|
241
|
+
### Interfaces
|
|
242
|
+
|
|
243
|
+
- `interface IApplicationOptions`
|
|
244
|
+
- `interface IFillStyleOptions`
|
|
245
|
+
- `interface ILineStyleOptions`
|
|
246
|
+
|
|
247
|
+
### Enums
|
|
248
|
+
|
|
249
|
+
- `enum LINE_CAP`
|
|
250
|
+
- `enum LINE_JOIN`
|
|
251
|
+
- `enum RENDERER_TYPE`
|
|
252
|
+
- `enum SHAPE_TYPE`
|
|
253
|
+
|
|
254
|
+
### Constants
|
|
255
|
+
|
|
256
|
+
- `const BYTES_PER_VERTEX: 12`
|
|
257
|
+
- `const MAX_VERTEX_COUNT: 65536`
|
|
258
|
+
|
|
259
|
+
## `ranuts/vnode`
|
|
260
|
+
|
|
261
|
+
Snabbdom 风格虚拟 DOM · runtime: **browser** · source: `src/vnode/index.ts`
|
|
262
|
+
|
|
263
|
+
```ts
|
|
264
|
+
import {} from /* … */ 'ranuts/vnode';
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
### Functions
|
|
268
|
+
|
|
269
|
+
- `addNS(data: VNodeData, children: Array<VNode | string | number> | undefined, sel: string | undefined): void`
|
|
270
|
+
- `create(tagName: string, options?: ElementCreationOptions): Chain`
|
|
271
|
+
- `h(sel: string): VNode (+3 overloads)`
|
|
272
|
+
- `init(): (oldVnode: VNode | Element, vnode: VNode) => VNode`
|
|
273
|
+
- `vnode(sel: string | undefined, data: any | undefined, children: Array<VNode | string | number> | undefined, text: string | number | undefined, elm: Element | T…`
|
|
274
|
+
|
|
275
|
+
### Classes
|
|
276
|
+
|
|
277
|
+
- `class Chain` — 链式调用的 dom 操作
|
|
278
|
+
|
|
279
|
+
### Interfaces
|
|
280
|
+
|
|
281
|
+
- `interface DOMAPI`
|
|
282
|
+
- `interface Fragment`
|
|
283
|
+
- `interface Hooks`
|
|
284
|
+
- `interface VNode`
|
|
285
|
+
- `interface VNodeData`
|
|
286
|
+
|
|
287
|
+
### Types
|
|
288
|
+
|
|
289
|
+
- `type ArrayOrElement`
|
|
290
|
+
- `type Key`
|
|
291
|
+
- `type ModuleHook`
|
|
292
|
+
- `type Modules`
|
|
293
|
+
- `type VNodeChildElement`
|
|
294
|
+
- `type VNodeChildren`
|
|
295
|
+
- `type VNodes`
|
|
296
|
+
|
|
297
|
+
### Constants
|
|
298
|
+
|
|
299
|
+
- `const attributesModule: { create: (oldVnode: VNode, vnode: VNode) => void; update: (oldVnode: VNode, vnode: VNode) => void; }`
|
|
300
|
+
- `const classModule: { create: (oldVnode: VNode, vnode: VNode) => void; update: (oldVnode: VNode, vnode: VNode) => void; }`
|
|
301
|
+
- `const eventListenersModule: { create: (oldVnode: VNode, vnode?: VNode) => void; update: (oldVnode: VNode, vnode?: VNode) => void; destroy: (oldVnode: VNode, vn…`
|
|
302
|
+
- `const htmlDomApi: DOMAPI`
|
|
303
|
+
- `const modules: Modules`
|
|
304
|
+
- `const propsModule: { create: (oldVnode: VNode, vnode: VNode) => void; update: (oldVnode: VNode, vnode: VNode) => void; }`
|
|
305
|
+
- `const styleModule: { pre: () => void; create: (oldVnode: VNode, vnode: VNode) => void; update: (oldVnode: VNode, vnode: VNode) => void; destroy: (vnode: VNode)…`
|
package/package.json
CHANGED
|
@@ -1,43 +1,95 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ranuts",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.2.0-alpha.1",
|
|
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",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"types": "dist/index.d.ts",
|
|
9
9
|
"engines": {
|
|
10
|
-
"node": ">=
|
|
10
|
+
"node": ">=23.10.0"
|
|
11
11
|
},
|
|
12
12
|
"exports": {
|
|
13
13
|
".": {
|
|
14
14
|
"types": "./dist/index.d.ts",
|
|
15
15
|
"import": "./dist/index.js",
|
|
16
|
-
"require": "./dist/index.umd.cjs"
|
|
16
|
+
"require": "./dist/umd/index.umd.cjs"
|
|
17
|
+
},
|
|
18
|
+
"./node": {
|
|
19
|
+
"types": "./dist/src/node/index.d.ts",
|
|
20
|
+
"import": "./dist/src/node/index.js",
|
|
21
|
+
"require": "./dist/umd/node/node.umd.cjs"
|
|
22
|
+
},
|
|
23
|
+
"./utils": {
|
|
24
|
+
"types": "./dist/src/utils/index.d.ts",
|
|
25
|
+
"import": "./dist/src/utils/index.js",
|
|
26
|
+
"require": "./dist/umd/utils/utils.umd.cjs"
|
|
27
|
+
},
|
|
28
|
+
"./visual": {
|
|
29
|
+
"types": "./dist/src/utils/visual/index.d.ts",
|
|
30
|
+
"import": "./dist/src/utils/visual/index.js"
|
|
31
|
+
},
|
|
32
|
+
"./vnode": {
|
|
33
|
+
"types": "./dist/src/vnode/index.d.ts",
|
|
34
|
+
"import": "./dist/src/vnode/index.js"
|
|
17
35
|
}
|
|
18
36
|
},
|
|
19
37
|
"repository": {
|
|
20
38
|
"type": "git",
|
|
21
|
-
"url": "git+https://github.com/chaxus/ran",
|
|
39
|
+
"url": "git+https://github.com/chaxus/ran.git",
|
|
22
40
|
"directory": "packages/ranuts"
|
|
23
41
|
},
|
|
24
|
-
"
|
|
25
|
-
|
|
42
|
+
"bugs": {
|
|
43
|
+
"url": "https://github.com/chaxus/ran/issues"
|
|
44
|
+
},
|
|
45
|
+
"homepage": "https://ran.chaxus.com/src/ranuts/",
|
|
46
|
+
"files": [
|
|
47
|
+
"dist",
|
|
48
|
+
"typings.d.ts",
|
|
49
|
+
"CLAUDE.md",
|
|
50
|
+
"docs/API.md"
|
|
51
|
+
],
|
|
52
|
+
"keywords": [
|
|
53
|
+
"ranuts",
|
|
54
|
+
"utils",
|
|
55
|
+
"utilities",
|
|
56
|
+
"typescript",
|
|
57
|
+
"javascript",
|
|
58
|
+
"debounce",
|
|
59
|
+
"throttle",
|
|
60
|
+
"compose",
|
|
61
|
+
"dom",
|
|
62
|
+
"bom",
|
|
63
|
+
"virtual-dom",
|
|
64
|
+
"canvas",
|
|
65
|
+
"webgl",
|
|
66
|
+
"tree-shakeable"
|
|
67
|
+
],
|
|
26
68
|
"author": "",
|
|
27
|
-
"license": "
|
|
69
|
+
"license": "MIT",
|
|
28
70
|
"devDependencies": {
|
|
29
|
-
"@babel/parser": "^
|
|
30
|
-
"@types/
|
|
31
|
-
"
|
|
71
|
+
"@babel/parser": "^8.0.4",
|
|
72
|
+
"@types/earcut": "^3.0.0",
|
|
73
|
+
"@types/node": "^26.1.1",
|
|
74
|
+
"@vitest/coverage-v8": "^4.1.10",
|
|
75
|
+
"@webgpu/types": "^0.1.71",
|
|
76
|
+
"tsx": "^4.23.0",
|
|
77
|
+
"typescript": "^6.0.3",
|
|
78
|
+
"vite": "^8.1.4",
|
|
79
|
+
"vitest": "^4.1.10"
|
|
32
80
|
},
|
|
33
81
|
"dependencies": {
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
82
|
+
"earcut": "^3.2.3",
|
|
83
|
+
"jschardet": "^3.1.4",
|
|
84
|
+
"magic-string": "^0.30.21"
|
|
37
85
|
},
|
|
38
86
|
"scripts": {
|
|
39
|
-
"build": "
|
|
87
|
+
"build": "sh ./bin/build.sh",
|
|
40
88
|
"test": "vitest run",
|
|
89
|
+
"test:coverage": "vitest run --coverage",
|
|
90
|
+
"tsc": "tsc --noEmit",
|
|
91
|
+
"dev": "vite --host",
|
|
92
|
+
"doc:api": "tsx ./bin/generate-api-docs.ts",
|
|
41
93
|
"prepublish": "npm run build"
|
|
42
94
|
}
|
|
43
95
|
}
|