nhanh-pure-function
Version:
1,468 lines • 220 kB
JavaScript
(function(){"use strict";try{if(typeof document<"u"){var a=document.createElement("style");a.appendChild(document.createTextNode(".no-select{-webkit-user-select:none;-ms-user-select:none;user-select:none}._nhanh_canvas{cursor:initial}._nhanh_canvas:active{cursor:pointer}._nhanh_canvas._nhanh_canvas_draggable{cursor:grab}._nhanh_canvas._nhanh_canvas_draggable:active{cursor:grabbing}._nhanh_canvas_hover_overlay{cursor:pointer!important}._nhanh_canvas_hover_overlay:active{cursor:grabbing!important}._nhanh_canvas_hover_overlay_draggable{cursor:pointer!important}._nhanh_canvas_hover_overlay_draggable:active{cursor:move!important}._nhanh_canvas_hover_overlay_draggable_ew{cursor:pointer!important}._nhanh_canvas_hover_overlay_draggable_ew:active{cursor:e-resize!important;cursor:ew-resize!important}._nhanh_canvas_hover_overlay_draggable_ns{cursor:pointer!important}._nhanh_canvas_hover_overlay_draggable_ns:active{cursor:n-resize!important;cursor:ns-resize!important}")),document.head.appendChild(a)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();
var ze = Object.defineProperty;
var ge = (r) => {
throw TypeError(r);
};
var qe = (r, n, t) => n in r ? ze(r, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[n] = t;
var f = (r, n, t) => qe(r, typeof n != "symbol" ? n + "" : n, t), ye = (r, n, t) => n.has(r) || ge("Cannot " + t);
var P = (r, n, t) => (ye(r, n, "read from private field"), t ? t.call(r) : n.get(r)), N = (r, n, t) => n.has(r) ? ge("Cannot add the same private member more than once") : n instanceof WeakSet ? n.add(r) : n.set(r, t), D = (r, n, t, e) => (ye(r, n, "write to private field"), e ? e.call(r, t) : n.set(r, t), t);
const We = {
".mp3": "audio/mpeg",
".mp4": "video/mp4",
".m4a": "audio/mp4",
".aac": "audio/aac",
".ogg": "audio/ogg",
".wav": "audio/wav",
".flac": "audio/flac",
".opus": "audio/opus",
".webm": "video/webm",
".avi": "video/x-msvideo",
".mov": "video/quicktime",
".wmv": "video/x-ms-wmv",
".png": "image/png",
".jpg": "image/jpeg",
".jpeg": "image/jpeg",
".gif": "image/gif",
".bmp": "image/bmp",
".tiff": "image/tiff",
".ico": "image/vnd.microsoft.icon",
".svg": "image/svg+xml",
".webp": "image/webp",
".heif": "image/heif",
".heic": "image/heic",
".json": "application/json",
".xml": "application/xml",
".html": "text/html",
".htm": "text/html",
".css": "text/css",
".js": "application/javascript",
".ts": "application/typescript",
".csv": "text/csv",
".tsv": "text/tab-separated-values",
".txt": "text/plain",
".md": "text/markdown",
".rtf": "application/rtf",
".pdf": "application/pdf",
".zip": "application/zip",
".rar": "application/x-rar-compressed",
".tar": "application/x-tar",
".gz": "application/gzip",
".7z": "application/x-7z-compressed",
".exe": "application/x-msdownload",
".apk": "application/vnd.android.package-archive",
".doc": "application/msword",
".docx": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
".xls": "application/vnd.ms-excel",
".xlsx": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
".ppt": "application/vnd.ms-powerpoint",
".pptx": "application/vnd.openxmlformats-officedocument.presentationml.presentation",
".odt": "application/vnd.oasis.opendocument.text",
".ods": "application/vnd.oasis.opendocument.spreadsheet",
".odp": "application/vnd.oasis.opendocument.presentation",
".jsonld": "application/ld+json",
".yaml": "application/x-yaml",
".yml": "application/x-yaml",
".woff": "font/woff",
".woff2": "font/woff2",
".ttf": "font/ttf",
".otf": "font/otf",
".eot": "application/vnd.ms-fontobject",
".map": "application/json"
}, ee = {
image: [
".jpg",
".jpeg",
".png",
".gif",
".bmp",
".webp",
".tiff",
".svg",
".heif",
".heic",
".ico",
".raw",
".jfif",
".avif",
".png8",
".indd",
".eps",
".ai"
],
ppt: [".ppt", ".pptx", ".odp"],
word: [".doc", ".docx", ".odt", ".rtf"],
excel: [".xls", ".xlsx", ".ods", ".csv", ".tsv"],
pdf: [".pdf"],
text: [
".txt",
".csv",
".md",
".json",
".yaml",
".yml",
".log",
".ini",
".rtf"
],
audio: [
".mp3",
".wav",
".ogg",
".flac",
".aac",
".wma",
".m4a",
".alac",
".ape",
".opus",
".amr",
".ra",
".mid",
".midi",
".aiff",
".pcm",
".au",
".wavpack",
".spx"
],
video: [
".mp4",
".avi",
".mkv",
".mov",
".wmv",
".flv",
".webm",
".mpg",
".mpeg",
".3gp",
".vob",
".ogv",
".m4v",
".ts",
".rm",
".rmvb",
".m2ts",
".divx",
".xvid",
".swf",
".f4v"
],
archive: [
".zip",
".rar",
".tar",
".gz",
".bz2",
".xz",
".7z",
".tar.gz",
".tar.bz2",
".tar.xz",
".tar.lz",
".tar.lzma",
".cab",
".iso",
".dmg",
".tgz",
".apk",
".gz2",
".tar.zst"
],
code: [
".js",
".ts",
".py",
".java",
".cpp",
".c",
".html",
".css",
".scss",
".less",
".sass",
".php",
".rb",
".go",
".swift",
".rs",
".kt",
".scala",
".lua",
".pl",
".m",
".h",
".xml",
".json",
".yaml",
".yml",
".toml",
".vue",
".ejs",
".handlebars",
".jinja",
".dart"
],
font: [
".woff",
".woff2",
".ttf",
".otf",
".eot",
".svg",
".ttc",
".fnt",
".fon",
".otc"
],
database: [
".sql",
".sqlite",
".db",
".mdb",
".accdb",
".jsonld",
".xml",
".csv"
],
markup: [".html", ".htm", ".xhtml", ".xml", ".json", ".yaml", ".yml"],
configuration: [
".ini",
".conf",
".cfg",
".env",
".properties",
".json",
".toml"
],
logs: [".log", ".err", ".trace", ".out"],
script: [
".bash",
".sh",
".zsh",
".bat",
".ps1",
".vbs",
".cmd",
".sed",
".awk",
".php"
]
}, ve = [
"",
"万",
"亿",
"兆",
"京",
"垓",
"秭",
"穰",
"沟",
"涧",
"正",
"载",
"极"
], Ps = ["_self", "_blank", "_parent", "_top"], Se = {
// 北美标准尺寸 (毫米)
Letter: { width: 215.9, height: 279.4 },
// 8.5 × 11 英寸
Legal: { width: 215.9, height: 355.6 },
// 8.5 × 14 英寸
Tabloid: { width: 279.4, height: 431.8 },
// 11 × 17 英寸
Ledger: { width: 431.8, height: 279.4 },
// 17 × 11 英寸
Executive: { width: 184.2, height: 266.7 },
// 7.25 × 10.5 英寸
// 其他常见尺寸
Folio: { width: 215.9, height: 330.2 },
// 8.5 × 13 英寸
Quarto: { width: 215, height: 275 },
// 8.46 × 10.83 英寸
"Government-Letter": { width: 203.2, height: 266.7 },
// 8 × 10.5 英寸
// ISO A系列 (毫米)
A0: { width: 841, height: 1189 },
A1: { width: 594, height: 841 },
A2: { width: 420, height: 594 },
A3: { width: 297, height: 420 },
A4: { width: 210, height: 297 },
A5: { width: 148, height: 210 },
A6: { width: 105, height: 148 },
A7: { width: 74, height: 105 },
A8: { width: 52, height: 74 },
A9: { width: 37, height: 52 },
A10: { width: 26, height: 37 },
// ISO B系列 (毫米)
B0: { width: 1e3, height: 1414 },
B1: { width: 707, height: 1e3 },
B2: { width: 500, height: 707 },
B3: { width: 353, height: 500 },
B4: { width: 250, height: 353 },
B5: { width: 176, height: 250 },
B6: { width: 125, height: 176 },
B7: { width: 88, height: 125 },
B8: { width: 62, height: 88 },
B9: { width: 44, height: 62 },
B10: { width: 31, height: 44 },
// ISO C系列 (信封尺寸,毫米)
C0: { width: 917, height: 1297 },
C1: { width: 648, height: 917 },
C2: { width: 458, height: 648 },
C3: { width: 324, height: 458 },
C4: { width: 229, height: 324 },
C5: { width: 162, height: 229 },
C6: { width: 114, height: 162 },
C7: { width: 81, height: 114 },
C8: { width: 57, height: 81 }
}, xs = Object.keys(Se).map(
(r) => ({ value: r, label: r })
);
function Gt(r, n = 500) {
let t, e = !0;
function i(s) {
if (!e) return;
t || (t = s);
let o = Math.min((s - t) / n, 1);
r(o), s - t < n && requestAnimationFrame(i);
}
return requestAnimationFrame(i), () => e = !1;
}
function bs(r, n, t, e, i = 2) {
let s = r, o = !1, a = 1, l = r, c = n, h = t;
const u = () => {
const C = (c - l) / h;
return Number(C.toFixed(i));
};
let d = u();
const m = (C) => Math.min(Math.max(C, l), c), g = (C) => Number(C.toFixed(i)), p = (C, _, E) => {
const A = [];
return C >= _ && A.push("最小值必须小于最大值"), E <= 0 ? A.push("分段数必须为正数") : u() == 0 && A.push("数值精度过低,致使动画步长为 0"), A;
}, v = (C, _, E) => {
const A = p(C, _, E);
return A.length > 0 ? (console.error(`参数更新失败: ${A.join("; ")}`), !1) : (l = C, c = _, h = E, d = u(), s = m(s), !0);
}, w = () => {
o && (a = s >= c ? -1 : s <= l ? 1 : a, s = m(s + d * a), e(g(s)), requestAnimationFrame(w));
};
return {
/** 启动/继续动画 */
play(C = s) {
if (s = m(C), p(l, c, h).length)
return console.error("配置参数错误", this.getParams());
o || (o = !0, w());
},
/** 暂停动画 */
pause() {
o = !1;
},
/** 获取当前值 */
getCurrent: () => g(s),
/** 是否正在运行 */
isPlaying: () => o,
/** 更新参数(不中断动画) */
updateParams: v,
/** 获取当前参数 */
getParams: () => ({ min: l, max: c, steps: h, precision: i, stepSize: d })
};
}
function Cs(r, n, t, e, i = 2) {
if (t <= 0) return console.error("动画步数 必须为正数");
const s = (u) => Number(u.toFixed(i)), o = n - r, a = s(Math.abs(o) / t);
if (a === 0) return console.error("数值精度过低,致使动画步长为 0");
const l = Math.sign(o);
let c = r;
const h = () => {
c = s(c + a * l), (l > 0 ? c < n : c > n) ? (e(c), requestAnimationFrame(h)) : e(n);
};
h();
}
function _s(r, n = "image/png") {
try {
let t, e = n;
if (r instanceof File)
return URL.createObjectURL(r);
if (typeof r == "string") {
let s = r;
const o = s.match(/^data:([^;]*)(;base64)?,(.*)$/i);
if (o) {
if (!o[2])
return console.error("无效的数据 URL:缺少 base64 编码声明");
if (e = o[1] || e, s = o[3], !s)
return console.error("数据 URL 包含空有效负载");
}
s = s.replace(/[^A-Za-z0-9+/=]/g, "");
const a = atob(s);
t = new Uint8Array(a.length);
for (let l = 0; l < a.length; l++)
t[l] = a.charCodeAt(l);
} else if (r instanceof ArrayBuffer)
t = new Uint8Array(r);
else if (r instanceof Uint8Array)
t = r;
else
return console.error(
"不支持的数据类型。应为 Base64 字符串、ArrayBuffer 或 Uint8Array"
);
const i = new Blob([t], { type: e });
return URL.createObjectURL(i);
} catch (t) {
return console.error(
"数据到 ImageURL 的转换失败:",
t.message,
t.stack || "没有可用的堆栈跟踪"
), null;
}
}
function Ss(r) {
return r.charAt(0).toUpperCase() + r.slice(1);
}
function Es(r, n, t = 2) {
return !Number.isFinite(r) || !Number.isFinite(n) || !Number.isFinite(t) ? (console.error("所有参数必须是有限的数字"), "") : n === 0 ? (console.error("分母不能为零"), "") : t < 0 ? (console.error("小数位数不能为负数"), "") : (r / n * 100).toFixed(t) + "%";
}
function se(r) {
const t = r.toString().split("."), e = t[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",");
return t.length > 1 ? e + "." + t[1] : e;
}
function Ds(r, n) {
const t = {
join: !0,
suffix: "",
decimalPlaces: 2
}, { join: e, suffix: i, decimalPlaces: s } = {
...t,
...n || {}
}, o = Number(r);
if (isNaN(o)) return e ? `0${i}` : [0, i];
const a = Math.abs(o), l = o >= 0, c = Math.max(0, Math.floor(Math.log10(a) / 4)), h = Math.pow(1e4, c), u = a / h, d = (l ? 1 : -1) * parseFloat(u.toFixed(Math.max(0, s)));
return e ? `${d}${ve[c]}${i}` : [d, ve[c] + i];
}
function Vs(r) {
const n = ["B", "KB", "MB", "GB", "TB", "PB"];
let t = 0;
for (; r > 1024; )
r /= 1024, t++;
return `${Math.round(r * 100) / 100} ${n[t]}`;
}
function Rs(r, n = "YYYY-MM-DD hh:mm:ss", t = !0) {
const e = new Date(r);
if (isNaN(e.getTime()))
return console.error("Invalid date"), "";
const i = {
YYYY: (s) => s.getFullYear(),
MM: (s) => s.getMonth() + 1,
// Adjust for 0-based month
DD: (s) => s.getDate(),
hh: (s) => s.getHours(),
mm: (s) => s.getMinutes(),
ss: (s) => s.getSeconds(),
ms: (s) => s.getMilliseconds()
};
return n.replace(/YYYY|MM|DD|hh|mm|ss|ms/g, (s) => {
const o = i[s](e);
return t ? String(o).padStart(2, "0") : String(o);
});
}
function ne(r, n = "file") {
if (!r || (r = String(r).trim(), r === "")) return n;
const t = r.split("/");
return t[t.length - 1].split("?")[0];
}
function ks(r, n) {
return r = r.replace(/([^a-zA-Z][a-z])/g, (t) => t.toUpperCase()), n ? r.replace(/[^a-zA-Z]+/g, "") : r;
}
function Ms(r, n, t = ",") {
const e = new RegExp(
`(^|${t})${n}(${t}|$)`,
"g"
);
return r.replace(e, function(i, s, o) {
return s === o ? t : "";
});
}
function Os(r, n = !0) {
const t = {
"\b": "\\b",
" ": "\\t",
"\n": "\\n",
"\v": "\\v",
"\f": "\\f",
"\r": "\\r",
" ": "\\s"
}, e = Object.fromEntries(
Object.entries(t).map(([i, s]) => [s, i])
);
return n ? r.replace(
/[\b\t\n\v\f\r ]/g,
(i) => t[i]
) : r.replace(/\\[btnvfrs]/g, (i) => e[i] || i);
}
const Nt = [
["年", 365 * 24 * 60 * 60 * 1e3],
["月", 30 * 24 * 60 * 60 * 1e3],
["周", 7 * 24 * 60 * 60 * 1e3],
["天", 24 * 60 * 60 * 1e3],
["时", 60 * 60 * 1e3],
["分", 60 * 1e3],
["秒", 1e3],
["毫秒", 1]
];
function As(r, n) {
if (!Number.isInteger(r) || r < 0) return "0毫秒";
const t = n ? Nt.findIndex(([i]) => i === n) : 0, e = t === -1 ? 0 : t;
for (let i = e; i < Nt.length; i++) {
const [s, o] = Nt[i];
if (r >= o) {
const a = o === 1 ? r : Math.round(r / o * 10) / 10;
let l = Number.isInteger(a) ? a : a.toFixed(1).replace(/\.0$/, "");
return s === Nt[e][0] && (l = se(Number(l))), `${l}${s}`;
}
}
return "0毫秒";
}
function Ns(r, n) {
if (n < 1)
return console.error("分割大小必须大于0"), [];
const t = [];
for (let e = 0; e < r.length; e += n) {
const i = r.slice(e, e + n);
t.push(i);
}
return t;
}
function me(r, n = 2) {
if (Array.isArray(r) && r.length >= n) {
for (let e = 0; e < r.length; e++)
if (typeof r[e] != "number" || !Number.isFinite(r[e])) return !1;
} else return !1;
return !0;
}
function Yt(r, n = 1, t = 2) {
if (Array.isArray(r) && r.length >= n) {
for (let i = 0; i < r.length; i++)
if (!me(r[i], t)) return !1;
} else return !1;
return !0;
}
function Is(r, n, t) {
return Math.abs(r - n) <= t;
}
function Hs(r, n) {
let t = !1;
const { x: e, y: i } = r, s = n.length;
for (let o = 0, a = s - 1; o < s; a = o++) {
const l = n[o].x, c = n[o].y, h = n[a].x, u = n[a].y;
c > i != u > i && e < (h - l) * (i - c) / (u - c) + l && (t = !t);
}
return t;
}
function Ls(r, n, t, e) {
const i = Math.min(r[0], n[0]), s = Math.max(r[0], n[0]), o = Math.min(r[1], n[1]), a = Math.max(r[1], n[1]), l = [
[i, o],
// 左上
[s, o],
// 右上
[s, a],
// 右下
[i, a]
// 左下
], c = e[1] - t[1], h = t[0] - e[0], u = e[0] * t[1] - t[0] * e[1];
if (c === 0 && h === 0) {
const [p, v] = t;
return p >= i && p <= s && v >= o && v <= a;
}
const d = 1e-10;
let m = !1, g = !1;
for (const [p, v] of l) {
const w = c * p + h * v + u;
if (Math.abs(w) < d || (w > d ? m = !0 : g = !0, m && g))
return !0;
}
return m && g;
}
function re(r) {
return Object.prototype.toString.call(r).slice(8, -1).toLowerCase();
}
function Ts(r) {
return [
"https:",
// HTTPS协议,用于安全地浏览网页
"wss:",
// WebSocket Secure协议,用于安全的WebSocket通信
"ftps:",
// FTP Secure协议,用于安全的文件传输
"sftp:",
// SSH File Transfer Protocol,通过SSH安全地传输文件
"smpts:",
// Secure SMTP协议,用于安全地发送邮件
"smtp+tls:",
// SMTP协议结合STARTTLS扩展,用于升级到安全连接
"imap+tls:",
// IMAP协议结合STARTTLS扩展,用于安全地访问邮件
"pop3+tls:",
// POP3协议结合STARTTLS扩展,用于安全地接收邮件
"rdp:",
// Remote Desktop Protocol,用于安全的远程桌面连接
"vpn:"
// VPN协议,用于创建安全的网络连接
].some((t) => r.startsWith(t));
}
function Fs(r) {
return new Promise((n, t) => {
if (typeof r != "string" || r.trim() === "" || !r.includes("://")) {
t(new Error("Invalid URL: Must be a non-empty string"));
return;
}
try {
new XMLHttpRequest().open("HEAD", r, !0);
} catch (s) {
t(new Error(`Invalid URL format: ${s.message}`));
return;
}
const e = new XMLHttpRequest();
e.open("HEAD", r, !0);
const i = (s) => {
t(new Error(`Request failed: ${s.type}`));
};
e.onreadystatechange = function() {
e.readyState === XMLHttpRequest.DONE && (e.status === 0 ? t(new Error("Network error or CORS blocked")) : e.status >= 200 && e.status < 300 ? n(!0) : t(new Error(`HTTP Error: ${e.status}`)));
}, e.onerror = i, e.onabort = i, e.ontimeout = i;
try {
e.send();
} catch (s) {
t(new Error(`Request send failed: ${s.message}`));
}
});
}
const tt = class tt {
constructor() {
if (new.target === tt)
throw new Error("请直接使用静态方法,而不是实例化此类");
}
static check(n, t) {
if (!n || typeof n != "string")
return console.error("Invalid URL provided"), t ? !1 : "unknown";
const e = ne(n).toLowerCase();
if (t) {
if (!ee.hasOwnProperty(t))
return console.error(`Unknown file type: ${t}`), "unknown";
const i = ee[t];
return tt._checkExtension(e, i);
}
return tt._detectFileType(e);
}
/**
* 静态方法,用于解析地址信息
* 该方法接受一个URL字符串,将其解析为一个包含地址详情的对象数组
* 主要用于批量处理以逗号分隔的URL列表,为每个URL生成相应的名称和类型
*
* @param {string} url - 以逗号分隔的URL字符串,每个URL代表一个资源的位置
* @returns {Array} - 包含每个URL及其相关信息(名称和类型)的对象数组
*/
static parseAddresses(n) {
return !n || typeof n != "string" ? (console.error("Invalid URL provided"), []) : n.split(",").map((t) => {
const e = ne(t), i = this.check(t);
return { url: t, name: e, type: i };
});
}
/**
* 检查 MIME 类型是否与指定的模式匹配
* @param {string} type - 要检查的 MIME 类型(如 "image/png")
* @param {string} [accept] - 可接受的 MIME 类型模式(如 "image/*, text/plain")
* @returns {boolean} - 如果类型匹配,则返回 true,否则返回 false
*/
static matchesMimeType(n, t) {
if (!t) return !0;
if (typeof n != "string" || typeof t != "string") return !1;
const e = tt._normalizeType(n), i = t.split(",").map((a) => tt._normalizeType(a.trim())), [s, o = "*"] = e.split("/");
return i.some((a) => {
const [l, c = "*"] = a.split("/");
return (l === "*" || s === "*" || l === s) && (c === "*" || o === "*" || c === o);
});
}
/**
* 类型标准化函数
* 该函数旨在将文件类型或MIME类型字符串转换为标准格式
* 主要处理三种情况:带扩展名的字符串、简写格式的类型以及已标准格式的类型
*
* @param {string} type - 文件类型或MIME类型字符串
* @returns {string} 标准化的MIME类型字符串,如果无法识别则返回原始输入
*/
static _normalizeType(n) {
return n.startsWith(".") && !n.includes("/") ? We[n.toLowerCase()] || n : n.includes("/") ? n : `${n}/*`;
}
/**
* 检查URL是否具有任何指定的文件扩展名
* @param {string} url - 文件的URL
* @param {string[]} validExtensions - 有效文件扩展名的数组
* @returns {boolean} - 如果URL具有任何指定的文件扩展名,则返回true,否则返回false
*/
static _checkExtension(n, t) {
return t.some((e) => n.endsWith(e));
}
/**
* 检测文件URL的类型
* @param {string} url - 文件的URL
* @returns {string} - 如果URL与任何已知类型匹配,则返回文件类型,否则返回"unknown"
*/
static _detectFileType(n) {
for (const [t, e] of tt.cachedEntries)
if (e.some((i) => n.endsWith(i)))
return t;
return "unknown";
}
};
// 缓存文件扩展名的条目,以提高性能
f(tt, "cachedEntries", Object.entries(ee));
let we = tt;
const je = /\w*(?:\[\d+\])+|\w+/g, Ee = /^\w*(?:\[\d+\])+$/, De = /\w+|(\[\d+\])/g, Ve = /\[(\d+)\]/;
function Re(r) {
return r ? r.match(je) || [] : [];
}
function Bs(r, n = 3e3) {
if (typeof r != "function")
return console.error("非函数:", r);
const t = window.requestIdleCallback, e = function(i) {
i.timeRemaining() <= 0 && !i.didTimeout ? t(e, { timeout: n }) : r();
};
t ? t(e, { timeout: n }) : requestAnimationFrame(() => r());
}
function $e(r, n) {
const t = Date.now();
return new Promise((e, i) => {
const s = () => {
const o = Date.now() - t;
if (o >= n) return i(o);
if (r()) return e(o);
requestAnimationFrame(s);
};
s();
});
}
function gt(r, n, t = [], e = Date.now()) {
if (e < Date.now() - 50) {
console.error("_MergeObjects 合并异常:疑似死循环");
return;
}
const i = re(r), s = re(n);
if (i != s) return n;
if (i == "object" || i == "array") {
if (t.some(([o, a]) => o == r && a == n)) return r;
if (t.push([r, n]), i == "object") {
for (const o in n)
if (Object.prototype.hasOwnProperty.call(n, o)) {
const a = n[o], l = r[o], c = gt(
l,
a,
t,
e
);
r[o] = c;
}
return r;
} else if (i == "array")
return n.forEach((o, a) => {
const l = o, c = r[a], h = gt(
c,
l,
t,
e
);
r[a] = h;
}), r;
} else return n;
}
function oe(r = "") {
return r + "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(n) {
const t = Math.random() * 16 | 0;
return (n === "x" ? t : t & 3 | 8).toString(16);
});
}
function ke(r, n) {
let t;
return function(...e) {
clearTimeout(t), t = setTimeout(() => {
r(...e), t = void 0;
}, n);
};
}
function Us(r, n) {
let t = -1 / 0;
return function(...e) {
const i = performance.now();
if (i - t > n) {
t = i;
try {
r(...e);
} catch (s) {
console.error("Throttled function execution failed:", s);
}
}
};
}
function Xs(r, n) {
if (!r || !n) return r;
const t = Re(n);
return t.length ? t.reduce((e, i, s) => {
const o = s === t.length - 1;
if (Ee.test(i)) {
const a = i.match(De) || [];
return a.reduce((l, c, h) => {
if (/^\w+$/.test(c))
return l[c] || (h < a.length - 1 ? [] : {});
const u = c.match(Ve), d = u ? parseInt(u[1], 10) : 0, m = h === a.length - 1;
return m && o ? l[d] : l[d] || (m ? {} : []);
}, e);
}
return o ? e[i] : e[i] || {};
}, r) : r;
}
function Gs(r, n, t, e) {
if (!r || !n) return t;
const i = Re(n);
return i.length ? i.reduce((s, o, a) => {
const l = a === i.length - 1;
if (Ee.test(o)) {
const c = o.match(De) || [];
return c.reduce((h, u, d) => {
const m = d === c.length - 1;
if (/^\w+$/.test(u))
return h.hasOwnProperty(u) || (h[u] = []), h[u];
const g = u.match(Ve), p = g ? parseInt(g[1], 10) : 0, v = m && l;
return h.hasOwnProperty(p) ? v && !e && (h[p] = t) : h[p] = v ? t : m ? {} : [], h[p];
}, s);
}
return l ? ((!e || !s.hasOwnProperty(o)) && (s[o] = t), s[o]) : (s.hasOwnProperty(o) || (s[o] = {}), s[o]);
}, r) : t;
}
function Ys(r) {
return r.map((n, t) => r.slice(t).concat(r.slice(0, t)));
}
function Ze(r) {
const n = window.structuredClone, t = (e, i = /* @__PURE__ */ new WeakMap()) => {
const s = e;
if (s === null || typeof s != "object")
return s;
if (i.has(s))
return i.get(s);
switch (re(s)) {
case "array": {
const a = [];
i.set(s, a);
for (const l of s)
a.push(t(l, i));
return a;
}
case "object": {
if (s === null) return s;
const a = {};
i.set(s, a);
for (const l in s)
Object.prototype.hasOwnProperty.call(s, l) && (a[l] = t(s[l], i));
return a;
}
case "date": {
const a = new Date(s.getTime());
return i.set(s, a), a;
}
case "regexp": {
const a = s, l = new RegExp(a.source, a.flags);
return l.lastIndex = a.lastIndex, i.set(s, l), l;
}
case "map": {
const a = /* @__PURE__ */ new Map();
return i.set(s, a), s.forEach((l, c) => {
a.set(
t(c, i),
t(l, i)
);
}), a;
}
case "set": {
const a = /* @__PURE__ */ new Set();
return i.set(s, a), s.forEach((l) => {
a.add(t(l, i));
}), a;
}
// 处理其他可克隆对象类型
case "arraybuffer":
case "dataview":
case "int8array":
case "uint8array":
case "uint8clampedarray":
case "int16array":
case "uint16array":
case "int32array":
case "uint32array":
case "float32array":
case "float64array":
case "bigint64array":
case "biguint64array": {
const a = s, l = a.constructor, c = a.buffer.slice(
a.byteOffset,
a.byteOffset + a.byteLength
), h = new l(
c,
a.byteOffset,
a.byteLength / a.BYTES_PER_ELEMENT
);
return i.set(s, h), h;
}
// 处理特殊对象类型
case "error": {
const a = s, l = new a.constructor(a.message);
return l.stack = a.stack, l.name = a.name, i.set(s, l), l;
}
// 处理不可克隆对象(直接返回原值)
case "function":
case "promise":
case "weakmap":
case "weakset":
case "file":
default:
return s;
}
};
try {
return n ? n(r) : t(r);
} catch (e) {
return console.warn("structuredClone error:", e), n && t(r);
}
}
function Qe(r, n, t = 30) {
if (typeof r != "function")
return console.error("第一个参数必须是一个函数。");
if (!Array.isArray(n))
return console.error("第二个参数必须是一个数组。");
let e = [], i = 0;
const s = (o, a) => {
for (const [l, c] of a)
if (o >= l)
return c;
return "black";
};
return function(...o) {
const a = performance.now(), l = r(...o), c = performance.now() - a;
e.push(c), e.length > t && e.shift(), i = e.reduce((d, m) => d + m, 0) / e.length || 0;
const h = s(c, n), u = s(i, n);
return console.log(
`%c单次耗时:${c.toFixed(2)}ms
%c平均耗时(${e.length}次):${i.toFixed(2)}ms`,
`color: ${h}; padding: 2px 0;`,
`color: ${u}; padding: 2px 0;`
), l;
};
}
function zs(r) {
const n = Date.now();
let t = performance.now();
for (; Date.now() - n < r; ) {
t = Math.sin(t) * 1e6, (t > 1e6 || t < -1e6) && (t = 0);
try {
const e = t.toString().substring(0, 8);
history.replaceState(null, "", `#${e}`);
} catch {
}
}
return Date.now() - n;
}
function qs(r, n = 10) {
let t = 0, e = n;
function i() {
if (e > 0)
e--, requestAnimationFrame(i);
else {
const o = (Date.now() - t) / n, a = 1e3 / o;
r(Number(a.toFixed(2)), Number(o.toFixed(2)));
}
}
requestAnimationFrame(() => {
t = Date.now(), i();
});
}
function Ws(r) {
const n = () => Promise.resolve(), t = (a) => (console.error(a), Promise.reject(a));
function e() {
return navigator.clipboard.writeText(r).then(n).catch(t);
}
function i() {
const a = document.createElement("div");
a.innerText = r, document.body.appendChild(a);
const l = document.createRange();
l.selectNodeContents(a);
const c = window.getSelection();
let h = !1;
return c && (c.removeAllRanges(), c.addRange(l), h = document.execCommand("copy")), document.body.removeChild(a), h ? Promise.resolve() : Promise.reject();
}
function s() {
const a = document.createElement("textarea");
a.value = r, document.body.appendChild(a), a.select(), a.setSelectionRange(0, r.length);
let l = !1;
return document.activeElement === a && (l = document.execCommand("Copy", !0)), document.body.removeChild(a), l ? Promise.resolve() : Promise.reject();
}
function o() {
return i().then(n).catch(() => {
s().then(n).catch(() => t("复制方式尽皆失效"));
});
}
return navigator.clipboard ? e().catch(o) : o();
}
function js(r, n) {
const t = Se[r];
if (!t) return console.error(`未知纸张类型: ${r}`);
const { width: e, height: i } = t, s = (g) => g / 25.4, a = typeof window < "u" ? window.devicePixelRatio * 96 : 300, l = (g) => Math.round(s(g) * a), c = l(e), h = l(i), u = l(n), d = Math.max(0, c - 2 * u), m = Math.max(0, h - 2 * u);
return {
/** 内容宽度(像素) */
contentWidth: d,
/** 内容高度(像素) */
contentHeight: m,
/** 边距(像素) */
paddingPx: u,
/** 纸张宽度(像素) */
paperWidthPx: c,
/** 纸张高度(像素) */
paperHeightPx: h
};
}
class It {
constructor() {
}
/** 初始化标签页管理器 */
static init(n) {
if (!n) return console.error("标签页名称不能为空");
this.initFinish || (this.setupEventListeners(), this.initFinish = !0), window.name = n;
}
/** 设置事件监听器 */
static setupEventListeners() {
this.channel.addEventListener(
"message",
(n) => {
this.handleChannelMessage(n);
}
);
}
/** 处理BroadcastChannel消息 */
static handleChannelMessage(n) {
const { type: t, responseKey: e, name: i } = n.data;
if (t === "response") {
const s = this.pendingQueries.get(e);
s == null || s.forEach((o) => o(i));
} else if (t === "query") {
if (this.pendingQueries.has(e) || i != "*" && i != window.name) return;
const s = {
type: "response",
responseKey: e,
name: window.name
};
this.channel.postMessage(s);
}
}
/**
* 获取已经打开的指定名称的标签页
* @param name 标签页名称
*/
static getWindow(n) {
if (!this.initFinish) {
const o = "请先初始化标签页管理器";
return console.error(o), Promise.reject(o);
}
const t = oe();
let e = !1;
const i = this.pendingQueries.get(t) || [];
i.push(() => e = !0), this.pendingQueries.set(t, i);
const s = {
type: "query",
responseKey: t,
name: n
};
return this.channel.postMessage(s), $e(() => e, this.timeout).finally(
() => this.pendingQueries.delete(t)
);
}
/** 打开标签页 */
static openWindow(n, t, e = "_blank", i) {
var s;
if (!this.initFinish) {
const o = "请先初始化标签页管理器";
return console.error(o), Promise.reject(o);
}
return (s = this.getWindow(n)) == null ? void 0 : s.then(() => window.open("javascript:;", n)).catch(() => {
const o = window.open(t, e, i);
return o || console.error("无法打开标签页"), o;
});
}
/** 获取所有已经打开的标签页 */
static getAllWindows() {
if (!this.initFinish) {
const s = "请先初始化标签页管理器";
return console.error(s), Promise.reject(s);
}
const n = oe(), t = [], e = this.pendingQueries.get(n) || [];
e.push((s) => t.push(s)), this.pendingQueries.set(n, e);
const i = {
type: "query",
responseKey: n,
name: "*"
};
return this.channel.postMessage(i), new Promise((s) => {
setTimeout(() => {
this.pendingQueries.delete(n), s(t);
}, this.timeout);
});
}
}
/** 初始化完成标志 */
f(It, "initFinish", !1), /** 频道 */
f(It, "channel", new BroadcastChannel("nhanh-pure-function")), /** 等待回执消息时间上限(上限) */
f(It, "timeout", 150), /**
* 待处理查询
* @param key 回执消息key
* @param callback 匹配标签页的回调函数
*/
f(It, "pendingQueries", /* @__PURE__ */ new Map());
/*!
* decimal.js v10.5.0
* An arbitrary-precision Decimal type for JavaScript.
* https://github.com/MikeMcl/decimal.js
* Copyright (c) 2025 Michael Mclaughlin <M8ch88l@gmail.com>
* MIT Licence
*/
var ae = 9e15, ht = 1e9, le = "0123456789abcdef", zt = "2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058", qt = "3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789", ce = {
// These values must be integers within the stated ranges (inclusive).
// Most of these values can be changed at run-time using the `Decimal.config` method.
// The maximum number of significant digits of the result of a calculation or base conversion.
// E.g. `Decimal.config({ precision: 20 });`
precision: 20,
// 1 to MAX_DIGITS
// The rounding mode used when rounding to `precision`.
//
// ROUND_UP 0 Away from zero.
// ROUND_DOWN 1 Towards zero.
// ROUND_CEIL 2 Towards +Infinity.
// ROUND_FLOOR 3 Towards -Infinity.
// ROUND_HALF_UP 4 Towards nearest neighbour. If equidistant, up.
// ROUND_HALF_DOWN 5 Towards nearest neighbour. If equidistant, down.
// ROUND_HALF_EVEN 6 Towards nearest neighbour. If equidistant, towards even neighbour.
// ROUND_HALF_CEIL 7 Towards nearest neighbour. If equidistant, towards +Infinity.
// ROUND_HALF_FLOOR 8 Towards nearest neighbour. If equidistant, towards -Infinity.
//
// E.g.
// `Decimal.rounding = 4;`
// `Decimal.rounding = Decimal.ROUND_HALF_UP;`
rounding: 4,
// 0 to 8
// The modulo mode used when calculating the modulus: a mod n.
// The quotient (q = a / n) is calculated according to the corresponding rounding mode.
// The remainder (r) is calculated as: r = a - n * q.
//
// UP 0 The remainder is positive if the dividend is negative, else is negative.
// DOWN 1 The remainder has the same sign as the dividend (JavaScript %).
// FLOOR 3 The remainder has the same sign as the divisor (Python %).
// HALF_EVEN 6 The IEEE 754 remainder function.
// EUCLID 9 Euclidian division. q = sign(n) * floor(a / abs(n)). Always positive.
//
// Truncated division (1), floored division (3), the IEEE 754 remainder (6), and Euclidian
// division (9) are commonly used for the modulus operation. The other rounding modes can also
// be used, but they may not give useful results.
modulo: 1,
// 0 to 9
// The exponent value at and beneath which `toString` returns exponential notation.
// JavaScript numbers: -7
toExpNeg: -7,
// 0 to -EXP_LIMIT
// The exponent value at and above which `toString` returns exponential notation.
// JavaScript numbers: 21
toExpPos: 21,
// 0 to EXP_LIMIT
// The minimum exponent value, beneath which underflow to zero occurs.
// JavaScript numbers: -324 (5e-324)
minE: -9e15,
// -1 to -EXP_LIMIT
// The maximum exponent value, above which overflow to Infinity occurs.
// JavaScript numbers: 308 (1.7976931348623157e+308)
maxE: ae,
// 1 to EXP_LIMIT
// Whether to use cryptographically-secure random number generation, if available.
crypto: !1
// true/false
}, Me, nt, S = !0, Zt = "[DecimalError] ", ct = Zt + "Invalid argument: ", Oe = Zt + "Precision limit exceeded", Ae = Zt + "crypto unavailable", Ne = "[object Decimal]", T = Math.floor, I = Math.pow, Je = /^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i, Ke = /^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i, ti = /^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i, Ie = /^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i, j = 1e7, b = 7, ei = 9007199254740991, ii = zt.length - 1, he = qt.length - 1, y = { toStringTag: Ne };
y.absoluteValue = y.abs = function() {
var r = new this.constructor(this);
return r.s < 0 && (r.s = 1), x(r);
};
y.ceil = function() {
return x(new this.constructor(this), this.e + 1, 2);
};
y.clampedTo = y.clamp = function(r, n) {
var t, e = this, i = e.constructor;
if (r = new i(r), n = new i(n), !r.s || !n.s) return new i(NaN);
if (r.gt(n)) throw Error(ct + n);
return t = e.cmp(r), t < 0 ? r : e.cmp(n) > 0 ? n : new i(e);
};
y.comparedTo = y.cmp = function(r) {
var n, t, e, i, s = this, o = s.d, a = (r = new s.constructor(r)).d, l = s.s, c = r.s;
if (!o || !a)
return !l || !c ? NaN : l !== c ? l : o === a ? 0 : !o ^ l < 0 ? 1 : -1;
if (!o[0] || !a[0]) return o[0] ? l : a[0] ? -c : 0;
if (l !== c) return l;
if (s.e !== r.e) return s.e > r.e ^ l < 0 ? 1 : -1;
for (e = o.length, i = a.length, n = 0, t = e < i ? e : i; n < t; ++n)
if (o[n] !== a[n]) return o[n] > a[n] ^ l < 0 ? 1 : -1;
return e === i ? 0 : e > i ^ l < 0 ? 1 : -1;
};
y.cosine = y.cos = function() {
var r, n, t = this, e = t.constructor;
return t.d ? t.d[0] ? (r = e.precision, n = e.rounding, e.precision = r + Math.max(t.e, t.sd()) + b, e.rounding = 1, t = si(e, Be(e, t)), e.precision = r, e.rounding = n, x(nt == 2 || nt == 3 ? t.neg() : t, r, n, !0)) : new e(1) : new e(NaN);
};
y.cubeRoot = y.cbrt = function() {
var r, n, t, e, i, s, o, a, l, c, h = this, u = h.constructor;
if (!h.isFinite() || h.isZero()) return new u(h);
for (S = !1, s = h.s * I(h.s * h, 1 / 3), !s || Math.abs(s) == 1 / 0 ? (t = H(h.d), r = h.e, (s = (r - t.length + 1) % 3) && (t += s == 1 || s == -2 ? "0" : "00"), s = I(t, 1 / 3), r = T((r + 1) / 3) - (r % 3 == (r < 0 ? -1 : 2)), s == 1 / 0 ? t = "5e" + r : (t = s.toExponential(), t = t.slice(0, t.indexOf("e") + 1) + r), e = new u(t), e.s = h.s) : e = new u(s.toString()), o = (r = u.precision) + 3; ; )
if (a = e, l = a.times(a).times(a), c = l.plus(h), e = k(c.plus(h).times(a), c.plus(l), o + 2, 1), H(a.d).slice(0, o) === (t = H(e.d)).slice(0, o))
if (t = t.slice(o - 3, o + 1), t == "9999" || !i && t == "4999") {
if (!i && (x(a, r + 1, 0), a.times(a).times(a).eq(h))) {
e = a;
break;
}
o += 4, i = 1;
} else {
(!+t || !+t.slice(1) && t.charAt(0) == "5") && (x(e, r + 1, 1), n = !e.times(e).times(e).eq(h));
break;
}
return S = !0, x(e, r, u.rounding, n);
};
y.decimalPlaces = y.dp = function() {
var r, n = this.d, t = NaN;
if (n) {
if (r = n.length - 1, t = (r - T(this.e / b)) * b, r = n[r], r) for (; r % 10 == 0; r /= 10) t--;
t < 0 && (t = 0);
}
return t;
};
y.dividedBy = y.div = function(r) {
return k(this, new this.constructor(r));
};
y.dividedToIntegerBy = y.divToInt = function(r) {
var n = this, t = n.constructor;
return x(k(n, new t(r), 0, 1, 1), t.precision, t.rounding);
};
y.equals = y.eq = function(r) {
return this.cmp(r) === 0;
};
y.floor = function() {
return x(new this.constructor(this), this.e + 1, 3);
};
y.greaterThan = y.gt = function(r) {
return this.cmp(r) > 0;
};
y.greaterThanOrEqualTo = y.gte = function(r) {
var n = this.cmp(r);
return n == 1 || n === 0;
};
y.hyperbolicCosine = y.cosh = function() {
var r, n, t, e, i, s = this, o = s.constructor, a = new o(1);
if (!s.isFinite()) return new o(s.s ? 1 / 0 : NaN);
if (s.isZero()) return a;
t = o.precision, e = o.rounding, o.precision = t + Math.max(s.e, s.sd()) + 4, o.rounding = 1, i = s.d.length, i < 32 ? (r = Math.ceil(i / 3), n = (1 / Jt(4, r)).toString()) : (r = 16, n = "2.3283064365386962890625e-10"), s = Et(o, 1, s.times(n), new o(1), !0);
for (var l, c = r, h = new o(8); c--; )
l = s.times(s), s = a.minus(l.times(h.minus(l.times(h))));
return x(s, o.precision = t, o.rounding = e, !0);
};
y.hyperbolicSine = y.sinh = function() {
var r, n, t, e, i = this, s = i.constructor;
if (!i.isFinite() || i.isZero()) return new s(i);
if (n = s.precision, t = s.rounding, s.precision = n + Math.max(i.e, i.sd()) + 4, s.rounding = 1, e = i.d.length, e < 3)
i = Et(s, 2, i, i, !0);
else {
r = 1.4 * Math.sqrt(e), r = r > 16 ? 16 : r | 0, i = i.times(1 / Jt(5, r)), i = Et(s, 2, i, i, !0);
for (var o, a = new s(5), l = new s(16), c = new s(20); r--; )
o = i.times(i), i = i.times(a.plus(o.times(l.times(o).plus(c))));
}
return s.precision = n, s.rounding = t, x(i, n, t, !0);
};
y.hyperbolicTangent = y.tanh = function() {
var r, n, t = this, e = t.constructor;
return t.isFinite() ? t.isZero() ? new e(t) : (r = e.precision, n = e.rounding, e.precision = r + 7, e.rounding = 1, k(t.sinh(), t.cosh(), e.precision = r, e.rounding = n)) : new e(t.s);
};
y.inverseCosine = y.acos = function() {
var r = this, n = r.constructor, t = r.abs().cmp(1), e = n.precision, i = n.rounding;
return t !== -1 ? t === 0 ? r.isNeg() ? J(n, e, i) : new n(0) : new n(NaN) : r.isZero() ? J(n, e + 4, i).times(0.5) : (n.precision = e + 6, n.rounding = 1, r = new n(1).minus(r).div(r.plus(1)).sqrt().atan(), n.precision = e, n.rounding = i, r.times(2));
};
y.inverseHyperbolicCosine = y.acosh = function() {
var r, n, t = this, e = t.constructor;
return t.lte(1) ? new e(t.eq(1) ? 0 : NaN) : t.isFinite() ? (r = e.precision, n = e.rounding, e.precision = r + Math.max(Math.abs(t.e), t.sd()) + 4, e.rounding = 1, S = !1, t = t.times(t).minus(1).sqrt().plus(t), S = !0, e.precision = r, e.rounding = n, t.ln()) : new e(t);
};
y.inverseHyperbolicSine = y.asinh = function() {
var r, n, t = this, e = t.constructor;
return !t.isFinite() || t.isZero() ? new e(t) : (r = e.precision, n = e.rounding, e.precision = r + 2 * Math.max(Math.abs(t.e), t.sd()) + 6, e.rounding = 1, S = !1, t = t.times(t).plus(1).sqrt().plus(t), S = !0, e.precision = r, e.rounding = n, t.ln());
};
y.inverseHyperbolicTangent = y.atanh = function() {
var r, n, t, e, i = this, s = i.constructor;
return i.isFinite() ? i.e >= 0 ? new s(i.abs().eq(1) ? i.s / 0 : i.isZero() ? i : NaN) : (r = s.precision, n = s.rounding, e = i.sd(), Math.max(e, r) < 2 * -i.e - 1 ? x(new s(i), r, n, !0) : (s.precision = t = e - i.e, i = k(i.plus(1), new s(1).minus(i), t + r, 1), s.precision = r + 4, s.rounding = 1, i = i.ln(), s.precision = r, s.rounding = n, i.times(0.5))) : new s(NaN);
};
y.inverseSine = y.asin = function() {
var r, n, t, e, i = this, s = i.constructor;
return i.isZero() ? new s(i) : (n = i.abs().cmp(1), t = s.precision, e = s.rounding, n !== -1 ? n === 0 ? (r = J(s, t + 4, e).times(0.5), r.s = i.s, r) : new s(NaN) : (s.precision = t + 6, s.rounding = 1, i = i.div(new s(1).minus(i.times(i)).sqrt().plus(1)).atan(), s.precision = t, s.rounding = e, i.times(2)));
};
y.inverseTangent = y.atan = function() {
var r, n, t, e, i, s, o, a, l, c = this, h = c.constructor, u = h.precision, d = h.rounding;
if (c.isFinite()) {
if (c.isZero())
return new h(c);
if (c.abs().eq(1) && u + 4 <= he)
return o = J(h, u + 4, d).times(0.25), o.s = c.s, o;
} else {
if (!c.s) return new h(NaN);
if (u + 4 <= he)
return o = J(h, u + 4, d).times(0.5), o.s = c.s, o;
}
for (h.precision = a = u + 10, h.rounding = 1, t = Math.min(28, a / b + 2 | 0), r = t; r; --r) c = c.div(c.times(c).plus(1).sqrt().plus(1));
for (S = !1, n = Math.ceil(a / b), e = 1, l = c.times(c), o = new h(c), i = c; r !== -1; )
if (i = i.times(l), s = o.minus(i.div(e += 2)), i = i.times(l), o = s.plus(i.div(e += 2)), o.d[n] !== void 0) for (r = n; o.d[r] === s.d[r] && r--; ) ;
return t && (o = o.times(2 << t - 1)), S = !0, x(o, h.precision = u, h.rounding = d, !0);
};
y.isFinite = function() {
return !!this.d;
};
y.isInteger = y.isInt = function() {
return !!this.d && T(this.e / b) > this.d.length - 2;
};
y.isNaN = function() {
return !this.s;
};
y.isNegative = y.isNeg = function() {
return this.s < 0;
};
y.isPositive = y.isPos = function() {
return this.s > 0;
};
y.isZero = function() {
return !!this.d && this.d[0] === 0;
};
y.lessThan = y.lt = function(r) {
return this.cmp(r) < 0;
};
y.lessThanOrEqualTo = y.lte = function(r) {
return this.cmp(r) < 1;
};
y.logarithm = y.log = function(r) {
var n, t, e, i, s, o, a, l, c = this, h = c.constructor, u = h.precision, d = h.rounding, m = 5;
if (r == null)
r = new h(10), n = !0;
else {
if (r = new h(r), t = r.d, r.s < 0 || !t || !t[0] || r.eq(1)) return new h(NaN);
n = r.eq(10);
}
if (t = c.d, c.s < 0 || !t || !t[0] || c.eq(1))
return new h(t && !t[0] ? -1 / 0 : c.s != 1 ? NaN : t ? 0 : 1 / 0);
if (n)
if (t.length > 1)
s = !0;
else {
for (i = t[0]; i % 10 === 0; ) i /= 10;
s = i !== 1;
}
if (S = !1, a = u + m, o = at(c, a), e = n ? Wt(h, a + 10) : at(r, a), l = k(o, e, a, 1), Rt(l.d, i = u, d))
do
if (a += 10, o = at(c, a), e = n ? Wt(h, a + 10) : at(r, a), l = k(o, e, a, 1), !s) {
+H(l.d).slice(i + 1, i + 15) + 1 == 1e14 && (l = x(l, u + 1, 0));
break;
}
while (Rt(l.d, i += 10, d));
return S = !0, x(l, u, d);
};
y.minus = y.sub = function(r) {
var n, t, e, i, s, o, a, l, c, h, u, d, m = this, g = m.constructor;
if (r = new g(r), !m.d || !r.d)
return !m.s || !r.s ? r = new g(NaN) : m.d ? r.s = -r.s : r = new g(r.d || m.s !== r.s ? m : NaN), r;
if (m.s != r.s)
return r.s = -r.s, m.plus(r);
if (c = m.d, d = r.d, a = g.precision, l = g.rounding, !c[0] || !d[0]) {
if (d[0]) r.s = -r.s;
else if (c[0]) r = new g(m);
else return new g(l === 3 ? -0 : 0);
return S ? x(r, a, l) : r;
}
if (t = T(r.e / b), h = T(m.e / b), c = c.slice(), s = h - t, s) {
for (u = s < 0, u ? (n = c, s = -s, o = d.length) : (n = d, t = h, o = c.length), e = Math.max(Math.ceil(a / b), o) + 2, s > e && (s = e, n.length = 1), n.reverse(), e = s; e--; ) n.push(0);
n.reverse();
} else {
for (e = c.length, o = d.length, u = e < o, u && (o = e), e = 0; e < o; e++)
if (c[e] != d[e]) {
u = c[e] < d[e];
break;
}
s = 0;
}
for (u && (n = c, c = d, d = n, r.s = -r.s), o = c.length, e = d.length - o; e > 0; --e) c[o++] = 0;
for (e = d.length; e > s; ) {
if (c[--e] < d[e]) {
for (i = e; i && c[--i] === 0; ) c[i] = j - 1;
--c[i], c[e] += j;
}
c[e] -= d[e];
}
for (; c[--o] === 0; ) c.pop();
for (; c[0] === 0; c.shift()) --t;
return c[0] ? (r.d = c, r.e = Qt(c, t), S ? x(r, a, l) : r) : new g(l === 3 ? -0 : 0);
};
y.modulo = y.mod = function(r) {
var n, t = this, e = t.constructor;
return r = new e(r), !t.d || !r.s || r.d && !r.d[0] ? new e(NaN) : !r.d || t.d && !t.d[0] ? x(new e(t), e.precision, e.rounding) : (S = !1, e.modulo == 9 ? (n = k(t, r.abs(), 0, 3, 1), n.s *= r.s) : n = k(t, r, 0, e.modulo, 1), n = n.times(r), S = !0, t.minus(n));
};
y.naturalExponential = y.exp = function() {
return ue(this);
};
y.naturalLogarithm = y.ln = function() {
return at(this);
};
y.negated = y.neg = function() {
var r = new this.constructor(this);
return r.s = -r.s, x(r);
};
y.plus = y.add = function(r) {
var n, t, e, i, s, o, a, l, c, h, u = this, d = u.constructor;
if (r = new d(r), !u.d || !r.d)
return !u.s || !r.s ? r = new d(NaN) : u.d || (r = new d(r.d || u.s === r.s ? u : NaN)), r;
if (u.s != r.s)
return r.s = -r.s, u.minus(r);
if (c = u.d, h = r.d, a = d.precision, l = d.rounding, !c[0] || !h[0])
return h[0] || (r = new d(u)), S ? x(r, a, l) : r;
if (s = T(u.e / b), e = T(r.e / b), c = c.slice(), i = s - e, i) {
for (i < 0 ? (t = c, i = -i, o = h.length) : (t = h, e = s, o = c.length), s = Math.ceil(a / b), o = s > o ? s + 1 : o + 1, i > o && (i = o, t.length = 1), t.reverse(); i--; ) t.push(0);
t.reverse();
}
for (o = c.length, i = h.length, o - i < 0 && (i = o, t = h, h = c, c = t), n = 0; i; )
n = (c[--i] = c[i] + h[i] + n) / j | 0, c[i] %= j;
for (n && (c.unshift(n), ++e), o = c.length; c[--o] == 0; ) c.pop();
return r.d = c, r.e = Qt(c, e), S ? x(r, a, l) : r;
};
y.precision = y.sd = function(r) {
var n, t = this;
if (r !== void 0 && r !== !!r && r !== 1 && r !== 0) throw Error(ct + r);
return t.d ? (n = He(t.d), r && t.e + 1 > n && (n = t.e + 1)) : n = NaN, n;
};
y.round = function() {
var r = this, n = r.constructor;
return x(new n(r), r.e + 1, n.rounding);
};
y.sine = y.sin = function() {
var r, n, t = this, e = t.constructor;
return t.isFinite() ? t.isZero() ? new e(t) : (r = e.precision, n = e.rounding, e.precision = r + Math.max(t.e, t.sd()) + b, e.rounding = 1, t = ri(e, Be(e, t)), e.precision = r, e.rounding = n, x(nt > 2 ? t.neg() : t, r, n, !0)) : new e(NaN);
};
y.squareRoot = y.sqrt = function() {
var r, n, t, e, i, s, o = this, a = o.d, l = o.e, c = o.s, h = o.constructor;
if (c !== 1 || !a || !a[0])
return new h(!c || c < 0 && (!a || a[0]) ? NaN : a ? o : 1 / 0);
for (S = !1, c = Math.sqrt(+o), c == 0 || c == 1 / 0 ? (n = H(a), (n.length + l) % 2 == 0 && (n += "0"), c = Math.sqrt(n), l = T((l + 1) / 2) - (l < 0 || l % 2), c == 1 / 0 ? n = "5e" + l : (n = c.toExponential(), n = n.slice(0, n.indexOf("e") + 1) + l), e = new h(n)) : e = new h(c.toString()), t = (l = h.precision) + 3; ; )
if (s = e, e = s.plus(k(o, s, t + 2, 1)).times(0.5), H(s.d).slice(0, t) === (n = H(e.d)).slice(0, t))
if (n = n.slice(t - 3, t + 1), n == "9999" || !i && n == "4999") {
if (!i && (x(s, l + 1, 0), s.times(s).eq(o))) {
e = s;
break;
}
t += 4, i = 1;
} else {
(!+n || !+n.slice(1) && n.charAt(0) == "5") && (x(e, l + 1, 1), r = !e.times(e).eq(o));
break;
}
return