nhanh-pure-function 3.0.6 → 4.0.0
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/LICENSE +1 -1
- package/README.md +20 -6
- package/dist/Canvas/{LayerGroup → Axis/LayerGroup}/index.d.ts +2 -2
- package/dist/Canvas/{LayerGroup → Axis/LayerGroup}/layer.d.ts +9 -6
- package/dist/Canvas/Axis/OverlayCreator/index.d.ts +52 -0
- package/dist/Canvas/{OverlayGroup → Axis/OverlayGroup}/index.d.ts +2 -2
- package/dist/Canvas/{OverlayGroup → Axis/OverlayGroup}/public/overlay.d.ts +4 -4
- package/dist/Canvas/{core → Axis/core}/axis.d.ts +1 -1
- package/dist/Canvas/{core → Axis/core}/basedata.d.ts +1 -1
- package/dist/Canvas/{core → Axis/core}/quikmethod.d.ts +1 -1
- package/dist/Canvas/{core → Axis/core}/style.d.ts +1 -1
- package/dist/Canvas/{index.d.ts → Axis/index.d.ts} +11 -8
- package/dist/Canvas/{index.types.d.ts → Axis/index.types.d.ts} +3 -1
- package/dist/Canvas/{public → Axis/public}/basedata.d.ts +5 -5
- package/dist/Canvas/Axis/public/viewFit.d.ts +28 -0
- package/dist/Canvas/TimeAxis/index.d.ts +165 -0
- package/dist/index.cjs.js +3 -3
- package/dist/index.d.ts +2 -1
- package/dist/index.es.js +2382 -1857
- package/package.json +5 -5
- /package/dist/Canvas/{OverlayGroup → Axis/OverlayGroup}/arc.d.ts +0 -0
- /package/dist/Canvas/{OverlayGroup → Axis/OverlayGroup}/arcTo.d.ts +0 -0
- /package/dist/Canvas/{OverlayGroup → Axis/OverlayGroup}/bezierCurve.d.ts +0 -0
- /package/dist/Canvas/{OverlayGroup → Axis/OverlayGroup}/custom.d.ts +0 -0
- /package/dist/Canvas/{OverlayGroup → Axis/OverlayGroup}/ellipse.d.ts +0 -0
- /package/dist/Canvas/{OverlayGroup → Axis/OverlayGroup}/line.d.ts +0 -0
- /package/dist/Canvas/{OverlayGroup → Axis/OverlayGroup}/point.d.ts +0 -0
- /package/dist/Canvas/{OverlayGroup → Axis/OverlayGroup}/polygon.d.ts +0 -0
- /package/dist/Canvas/{OverlayGroup → Axis/OverlayGroup}/public/geometricBoundary.d.ts +0 -0
- /package/dist/Canvas/{OverlayGroup → Axis/OverlayGroup}/text.d.ts +0 -0
- /package/dist/Canvas/{common.type.d.ts → Axis/common.type.d.ts} +0 -0
- /package/dist/Canvas/{core → Axis/core}/draw.d.ts +0 -0
- /package/dist/Canvas/{core → Axis/core}/event.d.ts +0 -0
- /package/dist/Canvas/{public → Axis/public}/eventController.d.ts +0 -0
- /package/dist/Canvas/{public → Axis/public}/eventControllerBasedata.d.ts +0 -0
- /package/dist/Canvas/{public → Axis/public}/tools.d.ts +0 -0
package/dist/index.cjs.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
(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)}})();
|
|
2
|
-
"use strict";var Ke=Object.defineProperty;var _e=r=>{throw TypeError(r)};var ti=(r,n,t)=>n in r?Ke(r,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[n]=t;var f=(r,n,t)=>ti(r,typeof n!="symbol"?n+"":n,t),Ce=(r,n,t)=>n.has(r)||_e("Cannot "+t);var P=(r,n,t)=>(Ce(r,n,"read from private field"),t?t.call(r):n.get(r)),A=(r,n,t)=>n.has(r)?_e("Cannot add the same private member more than once"):n instanceof WeakSet?n.add(r):n.set(r,t),D=(r,n,t,e)=>(Ce(r,n,"write to private field"),e?e.call(r,t):n.set(r,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Re={".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"},Ft={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"]},le=["","万","亿","兆","京","垓","秭","穰","沟","涧","正","载","极"],ei=["_self","_blank","_parent","_top"],ve={Letter:{width:215.9,height:279.4},Legal:{width:215.9,height:355.6},Tabloid:{width:279.4,height:431.8},Ledger:{width:431.8,height:279.4},Executive:{width:184.2,height:266.7},Folio:{width:215.9,height:330.2},Quarto:{width:215,height:275},"Government-Letter":{width:203.2,height:266.7},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},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},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}},ii=Object.keys(ve).map(r=>({value:r,label:r}));function kt(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 si(r,n,t,e,i=2){let s=r,o=!1,a=1,l=r,c=n,h=t;const u=()=>{const _=(c-l)/h;return Number(_.toFixed(i))};let d=u();const m=_=>Math.min(Math.max(_,l),c),g=_=>Number(_.toFixed(i)),p=(_,C,E)=>{const N=[];return _>=C&&N.push("最小值必须小于最大值"),E<=0?N.push("分段数必须为正数"):u()==0&&N.push("数值精度过低,致使动画步长为 0"),N},v=(_,C,E)=>{const N=p(_,C,E);return N.length>0?(console.error(`参数更新失败: ${N.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(_=s){if(s=m(_),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 ni(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 ri(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 oi(r){return r.charAt(0).toUpperCase()+r.slice(1)}function ai(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 Wt(r){const t=r.toString().split("."),e=t[0].replace(/\B(?=(\d{3})+(?!\d))/g,",");return t.length>1?e+"."+t[1]:e}function li(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}${le[c]}${i}`:[d,le[c]+i]}function ci(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 hi(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,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 jt(r,n="file"){if(!r||(r=String(r).trim(),r===""))return n;const t=r.split("/");return t[t.length-1].split("?")[0]}function ui(r,n){return r=r.replace(/([^a-zA-Z][a-z])/g,t=>t.toUpperCase()),n?r.replace(/[^a-zA-Z]+/g,""):r}function di(r,n,t=","){const e=new RegExp(`(^|${t})${n}(${t}|$)`,"g");return r.replace(e,function(i,s,o){return s===o?t:""})}function fi(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 Lt=[["年",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 mi(r,n){if(!Number.isFinite(r)||r<0)return"0毫秒";r=Math.round(r);const t=n?Lt.findIndex(([i])=>i===n):0,e=t===-1?0:t;for(let i=e;i<Lt.length;i++){const[s,o]=Lt[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===Lt[e][0]&&(l=Wt(Number(l))),`${l}${s}`}}return"0毫秒"}function pi(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 ee(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 Mt(r,n=1,t=2){if(Array.isArray(r)&&r.length>=n){for(let i=0;i<r.length;i++)if(!ee(r[i],t))return!1}else return!1;return!0}function gi(r,n,t){return Math.abs(r-n)<=t}function yi(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 vi(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 qt(r){return Object.prototype.toString.call(r).slice(8,-1).toLowerCase()}function wi(r){return["https:","wss:","ftps:","sftp:","smpts:","smtp+tls:","imap+tls:","pop3+tls:","rdp:","vpn:"].some(t=>r.startsWith(t))}function Pi(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=jt(n).toLowerCase();if(t){if(!Ft.hasOwnProperty(t))return console.error(`Unknown file type: ${t}`),"unknown";const i=Ft[t];return tt._checkExtension(e,i)}return tt._detectFileType(e)}static parseAddresses(n){return!n||typeof n!="string"?(console.error("Invalid URL provided"),[]):n.split(",").map(t=>{const e=jt(t),i=this.check(t);return{url:t,name:e,type:i}})}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)})}static _normalizeType(n){return n.startsWith(".")&&!n.includes("/")?Re[n.toLowerCase()]||n:n.includes("/")?n:`${n}/*`}static _checkExtension(n,t){return t.some(e=>n.endsWith(e))}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(Ft));let ce=tt;const xi=/\w*(?:\[\d+\])+|\w+/g,ke=/^\w*(?:\[\d+\])+$/,Me=/\w+|(\[\d+\])/g,Oe=/\[(\d+)\]/;function Ne(r){return r?r.match(xi)||[]:[]}function bi(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(i)};t?t(e,{timeout:n}):requestAnimationFrame(()=>r())}function Ae(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 ct(r,n,t=[],e=Date.now()){if(e<Date.now()-50){console.error("_MergeObjects 合并异常:疑似死循环");return}const i=qt(r),s=qt(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=ct(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=ct(c,l,t,e);r[a]=h}),r}else return n}function $t(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 we(r,n){let t;return function(...e){clearTimeout(t),t=setTimeout(()=>{r(...e),t=void 0},n)}}function _i(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 Ci(r,n){if(!r||!n)return r;const t=Ne(n);return t.length?t.reduce((e,i,s)=>{const o=s===t.length-1;if(ke.test(i)){const a=i.match(Me)||[];return a.reduce((l,c,h)=>{if(/^\w+$/.test(c))return l[c]||(h<a.length-1?[]:{});const u=c.match(Oe),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 Si(r,n,t,e){if(!r||!n)return t;const i=Ne(n);return i.length?i.reduce((s,o,a)=>{const l=a===i.length-1;if(ke.test(o)){const c=o.match(Me)||[];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(Oe),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 Ei(r){return r.map((n,t)=>r.slice(t).concat(r.slice(0,t)))}function Ie(r){const n=window.structuredClone,t=(e,i=new WeakMap)=>{const s=e;if(s===null||typeof s!="object")return s;if(i.has(s))return i.get(s);switch(qt(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=new Map;return i.set(s,a),s.forEach((l,c)=>{a.set(t(c,i),t(l,i))}),a}case"set":{const a=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 He(r,n){const t=[[11,"#d03050"],[8,"#f0a020"],[5,"#2080f0"],[2,"#18a058"]],{level:e=t,maxHistory:i=30,prefix:s=""}=n||{};if(e.sort((h,u)=>u[0]-h[0]),typeof r!="function")return console.error("第一个参数必须是一个函数。");if(!Array.isArray(e))return console.error("第二个参数必须是一个数组。");let o=[],a=0;const l=(h,u)=>{for(const[d,m]of u)if(h>=d)return m;return"black"};return(...h)=>{const u=performance.now(),d=r(...h),m=performance.now()-u;o.push(m),o.length>i&&o.shift(),a=o.reduce((v,w)=>v+w,0)/o.length||0;const g=l(m,e),p=l(a,e);return console.log(`%c${s?s+" - ":""}单次耗时:${m.toFixed(2)}ms
|
|
3
|
-
%c平均耗时(${o.length}次):${a.toFixed(2)}ms`,`color: ${
|
|
2
|
+
"use strict";var ei=Object.defineProperty;var be=r=>{throw TypeError(r)};var ii=(r,s,t)=>s in r?ei(r,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[s]=t;var d=(r,s,t)=>ii(r,typeof s!="symbol"?s+"":s,t),_e=(r,s,t)=>s.has(r)||be("Cannot "+t);var x=(r,s,t)=>(_e(r,s,"read from private field"),t?t.call(r):s.get(r)),I=(r,s,t)=>s.has(r)?be("Cannot add the same private member more than once"):s instanceof WeakSet?s.add(r):s.set(r,t),E=(r,s,t,e)=>(_e(r,s,"write to private field"),e?e.call(r,t):s.set(r,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Ve={".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"},Ft={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"]},le=["","万","亿","兆","京","垓","秭","穰","沟","涧","正","载","极"],si=["_self","_blank","_parent","_top"],ye={Letter:{width:215.9,height:279.4},Legal:{width:215.9,height:355.6},Tabloid:{width:279.4,height:431.8},Ledger:{width:431.8,height:279.4},Executive:{width:184.2,height:266.7},Folio:{width:215.9,height:330.2},Quarto:{width:215,height:275},"Government-Letter":{width:203.2,height:266.7},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},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},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}},ni=Object.keys(ye).map(r=>({value:r,label:r}));function Rt(r,s=500){let t,e=!0;function i(n){if(!e)return;t||(t=n);let o=Math.min((n-t)/s,1);r(o),n-t<s&&requestAnimationFrame(i)}return requestAnimationFrame(i),()=>e=!1}function ri(r,s,t,e,i=2){let n=r,o=!1,a=1,l=r,c=s,h=t;const u=()=>{const C=(c-l)/h;return Number(C.toFixed(i))};let f=u();const m=C=>Math.min(Math.max(C,l),c),p=C=>Number(C.toFixed(i)),g=(C,b,M)=>{const A=[];return C>=b&&A.push("最小值必须小于最大值"),M<=0?A.push("分段数必须为正数"):u()==0&&A.push("数值精度过低,致使动画步长为 0"),A},y=(C,b,M)=>{const A=g(C,b,M);return A.length>0?(console.error(`参数更新失败: ${A.join("; ")}`),!1):(l=C,c=b,h=M,f=u(),n=m(n),!0)},w=()=>{o&&(a=n>=c?-1:n<=l?1:a,n=m(n+f*a),e(p(n)),requestAnimationFrame(w))};return{play(C=n){if(n=m(C),g(l,c,h).length)return console.error("配置参数错误",this.getParams());o||(o=!0,w())},pause(){o=!1},getCurrent:()=>p(n),isPlaying:()=>o,updateParams:y,getParams:()=>({min:l,max:c,steps:h,precision:i,stepSize:f})}}function Re(r,s,t,e,i=2){if(t<=0)return console.error("动画步数 必须为正数");const n=u=>Number(u.toFixed(i)),o=s-r,a=n(Math.abs(o)/t);if(a===0)return console.error("数值精度过低,致使动画步长为 0");const l=Math.sign(o);let c=r;const h=()=>{c=n(c+a*l),(l>0?c<s:c>s)?(e(c),requestAnimationFrame(h)):e(s)};h()}function oi(r,s="image/png"){try{let t,e=s;if(r instanceof File)return URL.createObjectURL(r);if(typeof r=="string"){let n=r;const o=n.match(/^data:([^;]*)(;base64)?,(.*)$/i);if(o){if(!o[2])return console.error("无效的数据 URL:缺少 base64 编码声明");if(e=o[1]||e,n=o[3],!n)return console.error("数据 URL 包含空有效负载")}n=n.replace(/[^A-Za-z0-9+/=]/g,"");const a=atob(n);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 ai(r){return r.charAt(0).toUpperCase()+r.slice(1)}function li(r,s,t=2){return!Number.isFinite(r)||!Number.isFinite(s)||!Number.isFinite(t)?(console.error("所有参数必须是有限的数字"),""):s===0?(console.error("分母不能为零"),""):t<0?(console.error("小数位数不能为负数"),""):(r/s*100).toFixed(t)+"%"}function Wt(r){const t=r.toString().split("."),e=t[0].replace(/\B(?=(\d{3})+(?!\d))/g,",");return t.length>1?e+"."+t[1]:e}function ci(r,s){const t={join:!0,suffix:"",decimalPlaces:2},{join:e,suffix:i,decimalPlaces:n}={...t,...s||{}},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,f=(l?1:-1)*parseFloat(u.toFixed(Math.max(0,n)));return e?`${f}${le[c]}${i}`:[f,le[c]+i]}function hi(r){const s=["B","KB","MB","GB","TB","PB"];let t=0;for(;r>1024;)r/=1024,t++;return`${Math.round(r*100)/100} ${s[t]}`}function ke(r,s="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:n=>n.getFullYear(),MM:n=>n.getMonth()+1,DD:n=>n.getDate(),hh:n=>n.getHours(),mm:n=>n.getMinutes(),ss:n=>n.getSeconds(),ms:n=>n.getMilliseconds()};return s.replace(/YYYY|MM|DD|hh|mm|ss|ms/g,n=>{const o=i[n](e);return t?String(o).padStart(2,"0"):String(o)})}function jt(r,s="file"){if(!r||(r=String(r).trim(),r===""))return s;const t=r.split("/");return t[t.length-1].split("?")[0]}function ui(r,s){return r=r.replace(/([^a-zA-Z][a-z])/g,t=>t.toUpperCase()),s?r.replace(/[^a-zA-Z]+/g,""):r}function di(r,s,t=","){const e=new RegExp(`(^|${t})${s}(${t}|$)`,"g");return r.replace(e,function(i,n,o){return n===o?t:""})}function fi(r,s=!0){const t={"\b":"\\b"," ":"\\t","\n":"\\n","\v":"\\v","\f":"\\f","\r":"\\r"," ":"\\s"},e=Object.fromEntries(Object.entries(t).map(([i,n])=>[n,i]));return s?r.replace(/[\b\t\n\v\f\r ]/g,i=>t[i]):r.replace(/\\[btnvfrs]/g,i=>e[i]||i)}const Lt=[["年",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 mi(r,s){if(!Number.isFinite(r)||r<0)return"0毫秒";r=Math.round(r);const t=s?Lt.findIndex(([i])=>i===s):0,e=t===-1?0:t;for(let i=e;i<Lt.length;i++){const[n,o]=Lt[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 n===Lt[e][0]&&(l=Wt(Number(l))),`${l}${n}`}}return"0毫秒"}function gi(r,s){if(s<1)return console.error("分割大小必须大于0"),[];const t=[];for(let e=0;e<r.length;e+=s){const i=r.slice(e,e+s);t.push(i)}return t}function ee(r,s=2){if(Array.isArray(r)&&r.length>=s){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 kt(r,s=1,t=2){if(Array.isArray(r)&&r.length>=s){for(let i=0;i<r.length;i++)if(!ee(r[i],t))return!1}else return!1;return!0}function pi(r,s,t){return Math.abs(r-s)<=t}function vi(r,s){let t=!1;const{x:e,y:i}=r,n=s.length;for(let o=0,a=n-1;o<n;a=o++){const l=s[o].x,c=s[o].y,h=s[a].x,u=s[a].y;c>i!=u>i&&e<(h-l)*(i-c)/(u-c)+l&&(t=!t)}return t}function yi(r,s,t,e){const i=Math.min(r[0],s[0]),n=Math.max(r[0],s[0]),o=Math.min(r[1],s[1]),a=Math.max(r[1],s[1]),l=[[i,o],[n,o],[n,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[g,y]=t;return g>=i&&g<=n&&y>=o&&y<=a}const f=1e-10;let m=!1,p=!1;for(const[g,y]of l){const w=c*g+h*y+u;if(Math.abs(w)<f||(w>f?m=!0:p=!0,m&&p))return!0}return m&&p}function qt(r){return Object.prototype.toString.call(r).slice(8,-1).toLowerCase()}function wi(r){return["https:","wss:","ftps:","sftp:","smpts:","smtp+tls:","imap+tls:","pop3+tls:","rdp:","vpn:"].some(t=>r.startsWith(t))}function xi(r){return new Promise((s,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(n){t(new Error(`Invalid URL format: ${n.message}`));return}const e=new XMLHttpRequest;e.open("HEAD",r,!0);const i=n=>{t(new Error(`Request failed: ${n.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?s(!0):t(new Error(`HTTP Error: ${e.status}`)))},e.onerror=i,e.onabort=i,e.ontimeout=i;try{e.send()}catch(n){t(new Error(`Request send failed: ${n.message}`))}})}const tt=class tt{constructor(){if(new.target===tt)throw new Error("请直接使用静态方法,而不是实例化此类")}static check(s,t){if(!s||typeof s!="string")return console.error("Invalid URL provided"),t?!1:"unknown";const e=jt(s).toLowerCase();if(t){if(!Ft.hasOwnProperty(t))return console.error(`Unknown file type: ${t}`),"unknown";const i=Ft[t];return tt._checkExtension(e,i)}return tt._detectFileType(e)}static parseAddresses(s){return!s||typeof s!="string"?(console.error("Invalid URL provided"),[]):s.split(",").map(t=>{const e=jt(t),i=this.check(t);return{url:t,name:e,type:i}})}static matchesMimeType(s,t){if(!t)return!0;if(typeof s!="string"||typeof t!="string")return!1;const e=tt._normalizeType(s),i=t.split(",").map(a=>tt._normalizeType(a.trim())),[n,o="*"]=e.split("/");return i.some(a=>{const[l,c="*"]=a.split("/");return(l==="*"||n==="*"||l===n)&&(c==="*"||o==="*"||c===o)})}static _normalizeType(s){return s.startsWith(".")&&!s.includes("/")?Ve[s.toLowerCase()]||s:s.includes("/")?s:`${s}/*`}static _checkExtension(s,t){return t.some(e=>s.endsWith(e))}static _detectFileType(s){for(const[t,e]of tt.cachedEntries)if(e.some(i=>s.endsWith(i)))return t;return"unknown"}};d(tt,"cachedEntries",Object.entries(Ft));let ce=tt;const Pi=/\w*(?:\[\d+\])+|\w+/g,Oe=/^\w*(?:\[\d+\])+$/,Ae=/\w+|(\[\d+\])/g,Ie=/\[(\d+)\]/;function Te(r){return r?r.match(Pi)||[]:[]}function Ci(r,s=3e3){if(typeof r!="function")return console.error("非函数:",r);const t=window.requestIdleCallback,e=function(i){i.timeRemaining()<=0&&!i.didTimeout?t(e,{timeout:s}):r(i)};t?t(e,{timeout:s}):requestAnimationFrame(()=>r())}function Ne(r,s){const t=Date.now();return new Promise((e,i)=>{const n=()=>{const o=Date.now()-t;if(o>=s)return i(o);if(r())return e(o);requestAnimationFrame(n)};n()})}function ct(r,s,t=[],e=Date.now()){if(e<Date.now()-50){console.error("_MergeObjects 合并异常:疑似死循环");return}const i=qt(r),n=qt(s);if(i!=n)return s;if(i=="object"||i=="array"){if(t.some(([o,a])=>o==r&&a==s))return r;if(t.push([r,s]),i=="object"){for(const o in s)if(Object.prototype.hasOwnProperty.call(s,o)){const a=s[o],l=r[o],c=ct(l,a,t,e);r[o]=c}return r}else if(i=="array")return s.forEach((o,a)=>{const l=o,c=r[a],h=ct(c,l,t,e);r[a]=h}),r}else return s}function $t(r=""){return r+"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(s){const t=Math.random()*16|0;return(s==="x"?t:t&3|8).toString(16)})}function we(r,s){let t;return function(...e){clearTimeout(t),t=setTimeout(()=>{r(...e),t=void 0},s)}}function bi(r,s){let t=-1/0;return function(...e){const i=performance.now();if(i-t>s){t=i;try{r(...e)}catch(n){console.error("Throttled function execution failed:",n)}}}}function _i(r,s){if(!r||!s)return r;const t=Te(s);return t.length?t.reduce((e,i,n)=>{const o=n===t.length-1;if(Oe.test(i)){const a=i.match(Ae)||[];return a.reduce((l,c,h)=>{if(/^\w+$/.test(c))return l[c]||(h<a.length-1?[]:{});const u=c.match(Ie),f=u?parseInt(u[1],10):0,m=h===a.length-1;return m&&o?l[f]:l[f]||(m?{}:[])},e)}return o?e[i]:e[i]||{}},r):r}function Si(r,s,t,e){if(!r||!s)return t;const i=Te(s);return i.length?i.reduce((n,o,a)=>{const l=a===i.length-1;if(Oe.test(o)){const c=o.match(Ae)||[];return c.reduce((h,u,f)=>{const m=f===c.length-1;if(/^\w+$/.test(u))return h.hasOwnProperty(u)||(h[u]=[]),h[u];const p=u.match(Ie),g=p?parseInt(p[1],10):0,y=m&&l;return h.hasOwnProperty(g)?y&&!e&&(h[g]=t):h[g]=y?t:m?{}:[],h[g]},n)}return l?((!e||!n.hasOwnProperty(o))&&(n[o]=t),n[o]):(n.hasOwnProperty(o)||(n[o]={}),n[o])},r):t}function Mi(r){return r.map((s,t)=>r.slice(t).concat(r.slice(0,t)))}function Le(r){const s=window.structuredClone,t=(e,i=new WeakMap)=>{const n=e;if(n===null||typeof n!="object")return n;if(i.has(n))return i.get(n);switch(qt(n)){case"array":{const a=[];i.set(n,a);for(const l of n)a.push(t(l,i));return a}case"object":{if(n===null)return n;const a={};i.set(n,a);for(const l in n)Object.prototype.hasOwnProperty.call(n,l)&&(a[l]=t(n[l],i));return a}case"date":{const a=new Date(n.getTime());return i.set(n,a),a}case"regexp":{const a=n,l=new RegExp(a.source,a.flags);return l.lastIndex=a.lastIndex,i.set(n,l),l}case"map":{const a=new Map;return i.set(n,a),n.forEach((l,c)=>{a.set(t(c,i),t(l,i))}),a}case"set":{const a=new Set;return i.set(n,a),n.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=n,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(n,h),h}case"error":{const a=n,l=new a.constructor(a.message);return l.stack=a.stack,l.name=a.name,i.set(n,l),l}case"function":case"promise":case"weakmap":case"weakset":case"file":default:return n}};try{return s?s(r):t(r)}catch(e){return console.warn("structuredClone error:",e),s&&t(r)}}function He(r,s){const t=[[11,"#d03050"],[8,"#f0a020"],[5,"#2080f0"],[2,"#18a058"]],{level:e=t,maxHistory:i=30,prefix:n=""}=s||{};if(e.sort((h,u)=>u[0]-h[0]),typeof r!="function")return console.error("第一个参数必须是一个函数。");if(!Array.isArray(e))return console.error("第二个参数必须是一个数组。");let o=[],a=0;const l=(h,u)=>{for(const[f,m]of u)if(h>=f)return m;return"black"};return(...h)=>{const u=performance.now(),f=r(...h),m=performance.now()-u;o.push(m),o.length>i&&o.shift(),a=o.reduce((y,w)=>y+w,0)/o.length||0;const p=l(m,e),g=l(a,e);return console.log(`%c${n?n+" - ":""}单次耗时:${m.toFixed(2)}ms
|
|
3
|
+
%c平均耗时(${o.length}次):${a.toFixed(2)}ms`,`color: ${p}; padding: 2px 0;`,`color: ${g}; padding: 2px 0;`),f}}function Ei(r){const s=Date.now();let t=performance.now();for(;Date.now()-s<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()-s}function Di(r,s=10){let t=0,e=s;function i(){if(e>0)e--,requestAnimationFrame(i);else{const o=(Date.now()-t)/s,a=1e3/o;r(Number(a.toFixed(2)),Number(o.toFixed(2)))}}requestAnimationFrame(()=>{t=Date.now(),i()})}function Vi(r){const s=()=>Promise.resolve(),t=a=>(console.error(a),Promise.reject(a));function e(){return navigator.clipboard.writeText(r).then(s).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 n(){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(s).catch(()=>{n().then(s).catch(()=>t("复制方式尽皆失效"))})}return navigator.clipboard?e().catch(o):o()}function Ri(r,s){const t=ye[r];if(!t)return console.error(`未知纸张类型: ${r}`);const{width:e,height:i}=t,n=p=>p/25.4,a=typeof window<"u"?window.devicePixelRatio*96:300,l=p=>Math.round(n(p)*a),c=l(e),h=l(i),u=l(s),f=Math.max(0,c-2*u),m=Math.max(0,h-2*u);return{contentWidth:f,contentHeight:m,paddingPx:u,paperWidthPx:c,paperHeightPx:h}}class Dt{constructor(){}static init(s){if(!s)return console.error("标签页名称不能为空");this.initFinish||(this.setupEventListeners(),this.initFinish=!0),window.name=s}static setupEventListeners(){this.channel.addEventListener("message",s=>{this.handleChannelMessage(s)})}static handleChannelMessage(s){const{type:t,responseKey:e,name:i}=s.data;if(t==="response"){const n=this.pendingQueries.get(e);n==null||n.forEach(o=>o(i))}else if(t==="query"){if(this.pendingQueries.has(e)||i!="*"&&i!=window.name)return;const n={type:"response",responseKey:e,name:window.name};this.channel.postMessage(n)}}static getWindow(s){if(!this.initFinish){const o="请先初始化标签页管理器";return console.error(o),Promise.reject(o)}const t=$t();let e=!1;const i=this.pendingQueries.get(t)||[];i.push(()=>e=!0),this.pendingQueries.set(t,i);const n={type:"query",responseKey:t,name:s};return this.channel.postMessage(n),Ne(()=>e,this.timeout).finally(()=>this.pendingQueries.delete(t))}static openWindow(s,t,e="_blank",i){var n;if(!this.initFinish){const o="请先初始化标签页管理器";return console.error(o),Promise.reject(o)}return(n=this.getWindow(s))==null?void 0:n.then(()=>window.open("javascript:;",s)).catch(()=>{const o=window.open(t,e,i);return o||console.error("无法打开标签页"),o})}static getAllWindows(){if(!this.initFinish){const n="请先初始化标签页管理器";return console.error(n),Promise.reject(n)}const s=$t(),t=[],e=this.pendingQueries.get(s)||[];e.push(n=>t.push(n)),this.pendingQueries.set(s,e);const i={type:"query",responseKey:s,name:"*"};return this.channel.postMessage(i),new Promise(n=>{setTimeout(()=>{this.pendingQueries.delete(s),n(t)},this.timeout)})}}d(Dt,"initFinish",!1),d(Dt,"channel",new BroadcastChannel("nhanh-pure-function")),d(Dt,"timeout",150),d(Dt,"pendingQueries",new Map);/*!
|
|
4
4
|
* decimal.js v10.5.0
|
|
5
5
|
* An arbitrary-precision Decimal type for JavaScript.
|
|
6
6
|
* https://github.com/MikeMcl/decimal.js
|
|
7
7
|
* Copyright (c) 2025 Michael Mclaughlin <M8ch88l@gmail.com>
|
|
8
8
|
* MIT Licence
|
|
9
|
-
*/var he=9e15,ut=1e9,ue="0123456789abcdef",Zt="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",Qt="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",de={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-9e15,maxE:he,crypto:!1},Le,nt,S=!0,ie="[DecimalError] ",ht=ie+"Invalid argument: ",Te=ie+"Precision limit exceeded",Fe=ie+"crypto unavailable",Be="[object Decimal]",T=Math.floor,I=Math.pow,Mi=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,Oi=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,Ni=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,Ue=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,$=1e7,b=7,Ai=9007199254740991,Ii=Zt.length-1,fe=Qt.length-1,y={toStringTag:Be};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(ht+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=Hi(e,We(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/ne(4,r)).toString()):(r=16,n="2.3283064365386962890625e-10"),s=Dt(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=Dt(s,2,i,i,!0);else{r=1.4*Math.sqrt(e),r=r>16?16:r|0,i=i.times(1/ne(5,r)),i=Dt(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(.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(.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(.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<=fe)return o=J(h,u+4,d).times(.25),o.s=c.s,o}else{if(!c.s)return new h(NaN);if(u+4<=fe)return o=J(h,u+4,d).times(.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?Jt(h,a+10):at(r,a),l=k(o,e,a,1),Ot(l.d,i=u,d))do if(a+=10,o=at(c,a),e=n?Jt(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(Ot(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]=$-1;--c[i],c[e]+=$}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=se(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 me(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)/$|0,c[i]%=$;for(n&&(c.unshift(n),++e),o=c.length;c[--o]==0;)c.pop();return r.d=c,r.e=se(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(ht+r);return t.d?(n=Ge(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=Ti(e,We(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(.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 S=!0,x(e,l,h.rounding,r)};y.tangent=y.tan=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+10,e.rounding=1,t=t.sin(),t.s=1,t=k(t,new e(1).minus(t.times(t)).sqrt(),r+10,0),e.precision=r,e.rounding=n,x(nt==2||nt==4?t.neg():t,r,n,!0)):new e(NaN)};y.times=y.mul=function(r){var n,t,e,i,s,o,a,l,c,h=this,u=h.constructor,d=h.d,m=(r=new u(r)).d;if(r.s*=h.s,!d||!d[0]||!m||!m[0])return new u(!r.s||d&&!d[0]&&!m||m&&!m[0]&&!d?NaN:!d||!m?r.s/0:r.s*0);for(t=T(h.e/b)+T(r.e/b),l=d.length,c=m.length,l<c&&(s=d,d=m,m=s,o=l,l=c,c=o),s=[],o=l+c,e=o;e--;)s.push(0);for(e=c;--e>=0;){for(n=0,i=l+e;i>e;)a=s[i]+m[e]*d[i-e-1]+n,s[i--]=a%$|0,n=a/$|0;s[i]=(s[i]+n)%$|0}for(;!s[--o];)s.pop();return n?++t:s.shift(),r.d=s,r.e=se(s,t),S?x(r,u.precision,u.rounding):r};y.toBinary=function(r,n){return Pe(this,2,r,n)};y.toDecimalPlaces=y.toDP=function(r,n){var t=this,e=t.constructor;return t=new e(t),r===void 0?t:(U(r,0,ut),n===void 0?n=e.rounding:U(n,0,8),x(t,r+t.e+1,n))};y.toExponential=function(r,n){var t,e=this,i=e.constructor;return r===void 0?t=K(e,!0):(U(r,0,ut),n===void 0?n=i.rounding:U(n,0,8),e=x(new i(e),r+1,n),t=K(e,!0,r+1)),e.isNeg()&&!e.isZero()?"-"+t:t};y.toFixed=function(r,n){var t,e,i=this,s=i.constructor;return r===void 0?t=K(i):(U(r,0,ut),n===void 0?n=s.rounding:U(n,0,8),e=x(new s(i),r+i.e+1,n),t=K(e,!1,r+e.e+1)),i.isNeg()&&!i.isZero()?"-"+t:t};y.toFraction=function(r){var n,t,e,i,s,o,a,l,c,h,u,d,m=this,g=m.d,p=m.constructor;if(!g)return new p(m);if(c=t=new p(1),e=l=new p(0),n=new p(e),s=n.e=Ge(g)-m.e-1,o=s%b,n.d[0]=I(10,o<0?b+o:o),r==null)r=s>0?n:c;else{if(a=new p(r),!a.isInt()||a.lt(c))throw Error(ht+a);r=a.gt(n)?s>0?n:c:a}for(S=!1,a=new p(H(g)),h=p.precision,p.precision=s=g.length*b*2;u=k(a,n,0,1,1),i=t.plus(u.times(e)),i.cmp(r)!=1;)t=e,e=i,i=c,c=l.plus(u.times(i)),l=i,i=n,n=a.minus(u.times(i)),a=i;return i=k(r.minus(t),e,0,1,1),l=l.plus(i.times(c)),t=t.plus(i.times(e)),l.s=c.s=m.s,d=k(c,e,s,1).minus(m).abs().cmp(k(l,t,s,1).minus(m).abs())<1?[c,e]:[l,t],p.precision=h,S=!0,d};y.toHexadecimal=y.toHex=function(r,n){return Pe(this,16,r,n)};y.toNearest=function(r,n){var t=this,e=t.constructor;if(t=new e(t),r==null){if(!t.d)return t;r=new e(1),n=e.rounding}else{if(r=new e(r),n===void 0?n=e.rounding:U(n,0,8),!t.d)return r.s?t:r;if(!r.d)return r.s&&(r.s=t.s),r}return r.d[0]?(S=!1,t=k(t,r,0,n,1).times(r),S=!0,x(t)):(r.s=t.s,t=r),t};y.toNumber=function(){return+this};y.toOctal=function(r,n){return Pe(this,8,r,n)};y.toPower=y.pow=function(r){var n,t,e,i,s,o,a=this,l=a.constructor,c=+(r=new l(r));if(!a.d||!r.d||!a.d[0]||!r.d[0])return new l(I(+a,c));if(a=new l(a),a.eq(1))return a;if(e=l.precision,s=l.rounding,r.eq(1))return x(a,e,s);if(n=T(r.e/b),n>=r.d.length-1&&(t=c<0?-c:c)<=Ai)return i=Xe(l,a,t,e),r.s<0?new l(1).div(i):x(i,e,s);if(o=a.s,o<0){if(n<r.d.length-1)return new l(NaN);if(r.d[n]&1||(o=1),a.e==0&&a.d[0]==1&&a.d.length==1)return a.s=o,a}return t=I(+a,c),n=t==0||!isFinite(t)?T(c*(Math.log("0."+H(a.d))/Math.LN10+a.e+1)):new l(t+"").e,n>l.maxE+1||n<l.minE-1?new l(n>0?o/0:0):(S=!1,l.rounding=a.s=1,t=Math.min(12,(n+"").length),i=me(r.times(at(a,e+t)),e),i.d&&(i=x(i,e+5,1),Ot(i.d,e,s)&&(n=e+10,i=x(me(r.times(at(a,n+t)),n),n+5,1),+H(i.d).slice(e+1,e+15)+1==1e14&&(i=x(i,e+1,0)))),i.s=o,S=!0,l.rounding=s,x(i,e,s))};y.toPrecision=function(r,n){var t,e=this,i=e.constructor;return r===void 0?t=K(e,e.e<=i.toExpNeg||e.e>=i.toExpPos):(U(r,1,ut),n===void 0?n=i.rounding:U(n,0,8),e=x(new i(e),r,n),t=K(e,r<=e.e||e.e<=i.toExpNeg,r)),e.isNeg()&&!e.isZero()?"-"+t:t};y.toSignificantDigits=y.toSD=function(r,n){var t=this,e=t.constructor;return r===void 0?(r=e.precision,n=e.rounding):(U(r,1,ut),n===void 0?n=e.rounding:U(n,0,8)),x(new e(t),r,n)};y.toString=function(){var r=this,n=r.constructor,t=K(r,r.e<=n.toExpNeg||r.e>=n.toExpPos);return r.isNeg()&&!r.isZero()?"-"+t:t};y.truncated=y.trunc=function(){return x(new this.constructor(this),this.e+1,1)};y.valueOf=y.toJSON=function(){var r=this,n=r.constructor,t=K(r,r.e<=n.toExpNeg||r.e>=n.toExpPos);return r.isNeg()?"-"+t:t};function H(r){var n,t,e,i=r.length-1,s="",o=r[0];if(i>0){for(s+=o,n=1;n<i;n++)e=r[n]+"",t=b-e.length,t&&(s+=ot(t)),s+=e;o=r[n],e=o+"",t=b-e.length,t&&(s+=ot(t))}else if(o===0)return"0";for(;o%10===0;)o/=10;return s+o}function U(r,n,t){if(r!==~~r||r<n||r>t)throw Error(ht+r)}function Ot(r,n,t,e){var i,s,o,a;for(s=r[0];s>=10;s/=10)--n;return--n<0?(n+=b,i=0):(i=Math.ceil((n+1)/b),n%=b),s=I(10,b-n),a=r[i]%s|0,e==null?n<3?(n==0?a=a/100|0:n==1&&(a=a/10|0),o=t<4&&a==99999||t>3&&a==49999||a==5e4||a==0):o=(t<4&&a+1==s||t>3&&a+1==s/2)&&(r[i+1]/s/100|0)==I(10,n-2)-1||(a==s/2||a==0)&&(r[i+1]/s/100|0)==0:n<4?(n==0?a=a/1e3|0:n==1?a=a/100|0:n==2&&(a=a/10|0),o=(e||t<4)&&a==9999||!e&&t>3&&a==4999):o=((e||t<4)&&a+1==s||!e&&t>3&&a+1==s/2)&&(r[i+1]/s/1e3|0)==I(10,n-3)-1,o}function Bt(r,n,t){for(var e,i=[0],s,o=0,a=r.length;o<a;){for(s=i.length;s--;)i[s]*=n;for(i[0]+=ue.indexOf(r.charAt(o++)),e=0;e<i.length;e++)i[e]>t-1&&(i[e+1]===void 0&&(i[e+1]=0),i[e+1]+=i[e]/t|0,i[e]%=t)}return i.reverse()}function Hi(r,n){var t,e,i;if(n.isZero())return n;e=n.d.length,e<32?(t=Math.ceil(e/3),i=(1/ne(4,t)).toString()):(t=16,i="2.3283064365386962890625e-10"),r.precision+=t,n=Dt(r,1,n.times(i),new r(1));for(var s=t;s--;){var o=n.times(n);n=o.times(o).minus(o).times(8).plus(1)}return r.precision-=t,n}var k=function(){function r(e,i,s){var o,a=0,l=e.length;for(e=e.slice();l--;)o=e[l]*i+a,e[l]=o%s|0,a=o/s|0;return a&&e.unshift(a),e}function n(e,i,s,o){var a,l;if(s!=o)l=s>o?1:-1;else for(a=l=0;a<s;a++)if(e[a]!=i[a]){l=e[a]>i[a]?1:-1;break}return l}function t(e,i,s,o){for(var a=0;s--;)e[s]-=a,a=e[s]<i[s]?1:0,e[s]=a*o+e[s]-i[s];for(;!e[0]&&e.length>1;)e.shift()}return function(e,i,s,o,a,l){var c,h,u,d,m,g,p,v,w,_,C,E,N,G,At,dt,rt,vt,X,It,Ht=e.constructor,oe=e.s==i.s?1:-1,L=e.d,M=i.d;if(!L||!L[0]||!M||!M[0])return new Ht(!e.s||!i.s||(L?M&&L[0]==M[0]:!M)?NaN:L&&L[0]==0||!M?oe*0:oe/0);for(l?(m=1,h=e.e-i.e):(l=$,m=b,h=T(e.e/m)-T(i.e/m)),X=M.length,rt=L.length,w=new Ht(oe),_=w.d=[],u=0;M[u]==(L[u]||0);u++);if(M[u]>(L[u]||0)&&h--,s==null?(G=s=Ht.precision,o=Ht.rounding):a?G=s+(e.e-i.e)+1:G=s,G<0)_.push(1),g=!0;else{if(G=G/m+2|0,u=0,X==1){for(d=0,M=M[0],G++;(u<rt||d)&&G--;u++)At=d*l+(L[u]||0),_[u]=At/M|0,d=At%M|0;g=d||u<rt}else{for(d=l/(M[0]+1)|0,d>1&&(M=r(M,d,l),L=r(L,d,l),X=M.length,rt=L.length),dt=X,C=L.slice(0,X),E=C.length;E<X;)C[E++]=0;It=M.slice(),It.unshift(0),vt=M[0],M[1]>=l/2&&++vt;do d=0,c=n(M,C,X,E),c<0?(N=C[0],X!=E&&(N=N*l+(C[1]||0)),d=N/vt|0,d>1?(d>=l&&(d=l-1),p=r(M,d,l),v=p.length,E=C.length,c=n(p,C,v,E),c==1&&(d--,t(p,X<v?It:M,v,l))):(d==0&&(c=d=1),p=M.slice()),v=p.length,v<E&&p.unshift(0),t(C,p,E,l),c==-1&&(E=C.length,c=n(M,C,X,E),c<1&&(d++,t(C,X<E?It:M,E,l))),E=C.length):c===0&&(d++,C=[0]),_[u++]=d,c&&C[0]?C[E++]=L[dt]||0:(C=[L[dt]],E=1);while((dt++<rt||C[0]!==void 0)&&G--);g=C[0]!==void 0}_[0]||_.shift()}if(m==1)w.e=h,Le=g;else{for(u=1,d=_[0];d>=10;d/=10)u++;w.e=u+h*m-1,x(w,a?s+w.e+1:s,o,g)}return w}}();function x(r,n,t,e){var i,s,o,a,l,c,h,u,d,m=r.constructor;t:if(n!=null){if(u=r.d,!u)return r;for(i=1,a=u[0];a>=10;a/=10)i++;if(s=n-i,s<0)s+=b,o=n,h=u[d=0],l=h/I(10,i-o-1)%10|0;else if(d=Math.ceil((s+1)/b),a=u.length,d>=a)if(e){for(;a++<=d;)u.push(0);h=l=0,i=1,s%=b,o=s-b+1}else break t;else{for(h=a=u[d],i=1;a>=10;a/=10)i++;s%=b,o=s-b+i,l=o<0?0:h/I(10,i-o-1)%10|0}if(e=e||n<0||u[d+1]!==void 0||(o<0?h:h%I(10,i-o-1)),c=t<4?(l||e)&&(t==0||t==(r.s<0?3:2)):l>5||l==5&&(t==4||e||t==6&&(s>0?o>0?h/I(10,i-o):0:u[d-1])%10&1||t==(r.s<0?8:7)),n<1||!u[0])return u.length=0,c?(n-=r.e+1,u[0]=I(10,(b-n%b)%b),r.e=-n||0):u[0]=r.e=0,r;if(s==0?(u.length=d,a=1,d--):(u.length=d+1,a=I(10,b-s),u[d]=o>0?(h/I(10,i-o)%I(10,o)|0)*a:0),c)for(;;)if(d==0){for(s=1,o=u[0];o>=10;o/=10)s++;for(o=u[0]+=a,a=1;o>=10;o/=10)a++;s!=a&&(r.e++,u[0]==$&&(u[0]=1));break}else{if(u[d]+=a,u[d]!=$)break;u[d--]=0,a=1}for(s=u.length;u[--s]===0;)u.pop()}return S&&(r.e>m.maxE?(r.d=null,r.e=NaN):r.e<m.minE&&(r.e=0,r.d=[0])),r}function K(r,n,t){if(!r.isFinite())return ze(r);var e,i=r.e,s=H(r.d),o=s.length;return n?(t&&(e=t-o)>0?s=s.charAt(0)+"."+s.slice(1)+ot(e):o>1&&(s=s.charAt(0)+"."+s.slice(1)),s=s+(r.e<0?"e":"e+")+r.e):i<0?(s="0."+ot(-i-1)+s,t&&(e=t-o)>0&&(s+=ot(e))):i>=o?(s+=ot(i+1-o),t&&(e=t-i-1)>0&&(s=s+"."+ot(e))):((e=i+1)<o&&(s=s.slice(0,e)+"."+s.slice(e)),t&&(e=t-o)>0&&(i+1===o&&(s+="."),s+=ot(e))),s}function se(r,n){var t=r[0];for(n*=b;t>=10;t/=10)n++;return n}function Jt(r,n,t){if(n>Ii)throw S=!0,t&&(r.precision=t),Error(Te);return x(new r(Zt),n,1,!0)}function J(r,n,t){if(n>fe)throw Error(Te);return x(new r(Qt),n,t,!0)}function Ge(r){var n=r.length-1,t=n*b+1;if(n=r[n],n){for(;n%10==0;n/=10)t--;for(n=r[0];n>=10;n/=10)t++}return t}function ot(r){for(var n="";r--;)n+="0";return n}function Xe(r,n,t,e){var i,s=new r(1),o=Math.ceil(e/b+4);for(S=!1;;){if(t%2&&(s=s.times(n),Ee(s.d,o)&&(i=!0)),t=T(t/2),t===0){t=s.d.length-1,i&&s.d[t]===0&&++s.d[t];break}n=n.times(n),Ee(n.d,o)}return S=!0,s}function Se(r){return r.d[r.d.length-1]&1}function Ye(r,n,t){for(var e,i,s=new r(n[0]),o=0;++o<n.length;){if(i=new r(n[o]),!i.s){s=i;break}e=s.cmp(i),(e===t||e===0&&s.s===t)&&(s=i)}return s}function me(r,n){var t,e,i,s,o,a,l,c=0,h=0,u=0,d=r.constructor,m=d.rounding,g=d.precision;if(!r.d||!r.d[0]||r.e>17)return new d(r.d?r.d[0]?r.s<0?0:1/0:1:r.s?r.s<0?0:r:NaN);for(n==null?(S=!1,l=g):l=n,a=new d(.03125);r.e>-2;)r=r.times(a),u+=5;for(e=Math.log(I(2,u))/Math.LN10*2+5|0,l+=e,t=s=o=new d(1),d.precision=l;;){if(s=x(s.times(r),l,1),t=t.times(++h),a=o.plus(k(s,t,l,1)),H(a.d).slice(0,l)===H(o.d).slice(0,l)){for(i=u;i--;)o=x(o.times(o),l,1);if(n==null)if(c<3&&Ot(o.d,l-e,m,c))d.precision=l+=10,t=s=a=new d(1),h=0,c++;else return x(o,d.precision=g,m,S=!0);else return d.precision=g,o}o=a}}function at(r,n){var t,e,i,s,o,a,l,c,h,u,d,m=1,g=10,p=r,v=p.d,w=p.constructor,_=w.rounding,C=w.precision;if(p.s<0||!v||!v[0]||!p.e&&v[0]==1&&v.length==1)return new w(v&&!v[0]?-1/0:p.s!=1?NaN:v?0:p);if(n==null?(S=!1,h=C):h=n,w.precision=h+=g,t=H(v),e=t.charAt(0),Math.abs(s=p.e)<15e14){for(;e<7&&e!=1||e==1&&t.charAt(1)>3;)p=p.times(r),t=H(p.d),e=t.charAt(0),m++;s=p.e,e>1?(p=new w("0."+t),s++):p=new w(e+"."+t.slice(1))}else return c=Jt(w,h+2,C).times(s+""),p=at(new w(e+"."+t.slice(1)),h-g).plus(c),w.precision=C,n==null?x(p,C,_,S=!0):p;for(u=p,l=o=p=k(p.minus(1),p.plus(1),h,1),d=x(p.times(p),h,1),i=3;;){if(o=x(o.times(d),h,1),c=l.plus(k(o,new w(i),h,1)),H(c.d).slice(0,h)===H(l.d).slice(0,h))if(l=l.times(2),s!==0&&(l=l.plus(Jt(w,h+2,C).times(s+""))),l=k(l,new w(m),h,1),n==null)if(Ot(l.d,h-g,_,a))w.precision=h+=g,c=o=p=k(u.minus(1),u.plus(1),h,1),d=x(p.times(p),h,1),i=a=1;else return x(l,w.precision=C,_,S=!0);else return w.precision=C,l;l=c,i+=2}}function ze(r){return String(r.s*r.s/0)}function Ut(r,n){var t,e,i;for((t=n.indexOf("."))>-1&&(n=n.replace(".","")),(e=n.search(/e/i))>0?(t<0&&(t=e),t+=+n.slice(e+1),n=n.substring(0,e)):t<0&&(t=n.length),e=0;n.charCodeAt(e)===48;e++);for(i=n.length;n.charCodeAt(i-1)===48;--i);if(n=n.slice(e,i),n){if(i-=e,r.e=t=t-e-1,r.d=[],e=(t+1)%b,t<0&&(e+=b),e<i){for(e&&r.d.push(+n.slice(0,e)),i-=b;e<i;)r.d.push(+n.slice(e,e+=b));n=n.slice(e),e=b-n.length}else e-=i;for(;e--;)n+="0";r.d.push(+n),S&&(r.e>r.constructor.maxE?(r.d=null,r.e=NaN):r.e<r.constructor.minE&&(r.e=0,r.d=[0]))}else r.e=0,r.d=[0];return r}function Li(r,n){var t,e,i,s,o,a,l,c,h;if(n.indexOf("_")>-1){if(n=n.replace(/(\d)_(?=\d)/g,"$1"),Ue.test(n))return Ut(r,n)}else if(n==="Infinity"||n==="NaN")return+n||(r.s=NaN),r.e=NaN,r.d=null,r;if(Oi.test(n))t=16,n=n.toLowerCase();else if(Mi.test(n))t=2;else if(Ni.test(n))t=8;else throw Error(ht+n);for(s=n.search(/p/i),s>0?(l=+n.slice(s+1),n=n.substring(2,s)):n=n.slice(2),s=n.indexOf("."),o=s>=0,e=r.constructor,o&&(n=n.replace(".",""),a=n.length,s=a-s,i=Xe(e,new e(t),s,s*2)),c=Bt(n,t,$),h=c.length-1,s=h;c[s]===0;--s)c.pop();return s<0?new e(r.s*0):(r.e=se(c,h),r.d=c,S=!1,o&&(r=k(r,i,a*4)),l&&(r=r.times(Math.abs(l)<54?I(2,l):V.pow(2,l))),S=!0,r)}function Ti(r,n){var t,e=n.d.length;if(e<3)return n.isZero()?n:Dt(r,2,n,n);t=1.4*Math.sqrt(e),t=t>16?16:t|0,n=n.times(1/ne(5,t)),n=Dt(r,2,n,n);for(var i,s=new r(5),o=new r(16),a=new r(20);t--;)i=n.times(n),n=n.times(s.plus(i.times(o.times(i).minus(a))));return n}function Dt(r,n,t,e,i){var s,o,a,l,c=r.precision,h=Math.ceil(c/b);for(S=!1,l=t.times(t),a=new r(e);;){if(o=k(a.times(l),new r(n++*n++),c,1),a=i?e.plus(o):e.minus(o),e=k(o.times(l),new r(n++*n++),c,1),o=a.plus(e),o.d[h]!==void 0){for(s=h;o.d[s]===a.d[s]&&s--;);if(s==-1)break}s=a,a=e,e=o,o=s}return S=!0,o.d.length=h+1,o}function ne(r,n){for(var t=r;--n;)t*=r;return t}function We(r,n){var t,e=n.s<0,i=J(r,r.precision,1),s=i.times(.5);if(n=n.abs(),n.lte(s))return nt=e?4:1,n;if(t=n.divToInt(i),t.isZero())nt=e?3:2;else{if(n=n.minus(t.times(i)),n.lte(s))return nt=Se(t)?e?2:3:e?4:1,n;nt=Se(t)?e?1:4:e?3:2}return n.minus(i).abs()}function Pe(r,n,t,e){var i,s,o,a,l,c,h,u,d,m=r.constructor,g=t!==void 0;if(g?(U(t,1,ut),e===void 0?e=m.rounding:U(e,0,8)):(t=m.precision,e=m.rounding),!r.isFinite())h=ze(r);else{for(h=K(r),o=h.indexOf("."),g?(i=2,n==16?t=t*4-3:n==8&&(t=t*3-2)):i=n,o>=0&&(h=h.replace(".",""),d=new m(1),d.e=h.length-o,d.d=Bt(K(d),10,i),d.e=d.d.length),u=Bt(h,10,i),s=l=u.length;u[--l]==0;)u.pop();if(!u[0])h=g?"0p+0":"0";else{if(o<0?s--:(r=new m(r),r.d=u,r.e=s,r=k(r,d,t,e,0,i),u=r.d,s=r.e,c=Le),o=u[t],a=i/2,c=c||u[t+1]!==void 0,c=e<4?(o!==void 0||c)&&(e===0||e===(r.s<0?3:2)):o>a||o===a&&(e===4||c||e===6&&u[t-1]&1||e===(r.s<0?8:7)),u.length=t,c)for(;++u[--t]>i-1;)u[t]=0,t||(++s,u.unshift(1));for(l=u.length;!u[l-1];--l);for(o=0,h="";o<l;o++)h+=ue.charAt(u[o]);if(g){if(l>1)if(n==16||n==8){for(o=n==16?4:3,--l;l%o;l++)h+="0";for(u=Bt(h,i,n),l=u.length;!u[l-1];--l);for(o=1,h="1.";o<l;o++)h+=ue.charAt(u[o])}else h=h.charAt(0)+"."+h.slice(1);h=h+(s<0?"p":"p+")+s}else if(s<0){for(;++s;)h="0"+h;h="0."+h}else if(++s>l)for(s-=l;s--;)h+="0";else s<l&&(h=h.slice(0,s)+"."+h.slice(s))}h=(n==16?"0x":n==2?"0b":n==8?"0o":"")+h}return r.s<0?"-"+h:h}function Ee(r,n){if(r.length>n)return r.length=n,!0}function Fi(r){return new this(r).abs()}function Bi(r){return new this(r).acos()}function Ui(r){return new this(r).acosh()}function Gi(r,n){return new this(r).plus(n)}function Xi(r){return new this(r).asin()}function Yi(r){return new this(r).asinh()}function zi(r){return new this(r).atan()}function Wi(r){return new this(r).atanh()}function ji(r,n){r=new this(r),n=new this(n);var t,e=this.precision,i=this.rounding,s=e+4;return!r.s||!n.s?t=new this(NaN):!r.d&&!n.d?(t=J(this,s,1).times(n.s>0?.25:.75),t.s=r.s):!n.d||r.isZero()?(t=n.s<0?J(this,e,i):new this(0),t.s=r.s):!r.d||n.isZero()?(t=J(this,s,1).times(.5),t.s=r.s):n.s<0?(this.precision=s,this.rounding=1,t=this.atan(k(r,n,s,1)),n=J(this,s,1),this.precision=e,this.rounding=i,t=r.s<0?t.minus(n):t.plus(n)):t=this.atan(k(r,n,s,1)),t}function qi(r){return new this(r).cbrt()}function $i(r){return x(r=new this(r),r.e+1,2)}function Zi(r,n,t){return new this(r).clamp(n,t)}function Qi(r){if(!r||typeof r!="object")throw Error(ie+"Object expected");var n,t,e,i=r.defaults===!0,s=["precision",1,ut,"rounding",0,8,"toExpNeg",-9e15,0,"toExpPos",0,he,"maxE",0,he,"minE",-9e15,0,"modulo",0,9];for(n=0;n<s.length;n+=3)if(t=s[n],i&&(this[t]=de[t]),(e=r[t])!==void 0)if(T(e)===e&&e>=s[n+1]&&e<=s[n+2])this[t]=e;else throw Error(ht+t+": "+e);if(t="crypto",i&&(this[t]=de[t]),(e=r[t])!==void 0)if(e===!0||e===!1||e===0||e===1)if(e)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[t]=!0;else throw Error(Fe);else this[t]=!1;else throw Error(ht+t+": "+e);return this}function Ji(r){return new this(r).cos()}function Ki(r){return new this(r).cosh()}function je(r){var n,t,e;function i(s){var o,a,l,c=this;if(!(c instanceof i))return new i(s);if(c.constructor=i,De(s)){c.s=s.s,S?!s.d||s.e>i.maxE?(c.e=NaN,c.d=null):s.e<i.minE?(c.e=0,c.d=[0]):(c.e=s.e,c.d=s.d.slice()):(c.e=s.e,c.d=s.d?s.d.slice():s.d);return}if(l=typeof s,l==="number"){if(s===0){c.s=1/s<0?-1:1,c.e=0,c.d=[0];return}if(s<0?(s=-s,c.s=-1):c.s=1,s===~~s&&s<1e7){for(o=0,a=s;a>=10;a/=10)o++;S?o>i.maxE?(c.e=NaN,c.d=null):o<i.minE?(c.e=0,c.d=[0]):(c.e=o,c.d=[s]):(c.e=o,c.d=[s]);return}if(s*0!==0){s||(c.s=NaN),c.e=NaN,c.d=null;return}return Ut(c,s.toString())}if(l==="string")return(a=s.charCodeAt(0))===45?(s=s.slice(1),c.s=-1):(a===43&&(s=s.slice(1)),c.s=1),Ue.test(s)?Ut(c,s):Li(c,s);if(l==="bigint")return s<0?(s=-s,c.s=-1):c.s=1,Ut(c,s.toString());throw Error(ht+s)}if(i.prototype=y,i.ROUND_UP=0,i.ROUND_DOWN=1,i.ROUND_CEIL=2,i.ROUND_FLOOR=3,i.ROUND_HALF_UP=4,i.ROUND_HALF_DOWN=5,i.ROUND_HALF_EVEN=6,i.ROUND_HALF_CEIL=7,i.ROUND_HALF_FLOOR=8,i.EUCLID=9,i.config=i.set=Qi,i.clone=je,i.isDecimal=De,i.abs=Fi,i.acos=Bi,i.acosh=Ui,i.add=Gi,i.asin=Xi,i.asinh=Yi,i.atan=zi,i.atanh=Wi,i.atan2=ji,i.cbrt=qi,i.ceil=$i,i.clamp=Zi,i.cos=Ji,i.cosh=Ki,i.div=ts,i.exp=es,i.floor=is,i.hypot=ss,i.ln=ns,i.log=rs,i.log10=as,i.log2=os,i.max=ls,i.min=cs,i.mod=hs,i.mul=us,i.pow=ds,i.random=fs,i.round=ms,i.sign=ps,i.sin=gs,i.sinh=ys,i.sqrt=vs,i.sub=ws,i.sum=Ps,i.tan=xs,i.tanh=bs,i.trunc=_s,r===void 0&&(r={}),r&&r.defaults!==!0)for(e=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],n=0;n<e.length;)r.hasOwnProperty(t=e[n++])||(r[t]=this[t]);return i.config(r),i}function ts(r,n){return new this(r).div(n)}function es(r){return new this(r).exp()}function is(r){return x(r=new this(r),r.e+1,3)}function ss(){var r,n,t=new this(0);for(S=!1,r=0;r<arguments.length;)if(n=new this(arguments[r++]),n.d)t.d&&(t=t.plus(n.times(n)));else{if(n.s)return S=!0,new this(1/0);t=n}return S=!0,t.sqrt()}function De(r){return r instanceof V||r&&r.toStringTag===Be||!1}function ns(r){return new this(r).ln()}function rs(r,n){return new this(r).log(n)}function os(r){return new this(r).log(2)}function as(r){return new this(r).log(10)}function ls(){return Ye(this,arguments,-1)}function cs(){return Ye(this,arguments,1)}function hs(r,n){return new this(r).mod(n)}function us(r,n){return new this(r).mul(n)}function ds(r,n){return new this(r).pow(n)}function fs(r){var n,t,e,i,s=0,o=new this(1),a=[];if(r===void 0?r=this.precision:U(r,1,ut),e=Math.ceil(r/b),this.crypto)if(crypto.getRandomValues)for(n=crypto.getRandomValues(new Uint32Array(e));s<e;)i=n[s],i>=429e7?n[s]=crypto.getRandomValues(new Uint32Array(1))[0]:a[s++]=i%1e7;else if(crypto.randomBytes){for(n=crypto.randomBytes(e*=4);s<e;)i=n[s]+(n[s+1]<<8)+(n[s+2]<<16)+((n[s+3]&127)<<24),i>=214e7?crypto.randomBytes(4).copy(n,s):(a.push(i%1e7),s+=4);s=e/4}else throw Error(Fe);else for(;s<e;)a[s++]=Math.random()*1e7|0;for(e=a[--s],r%=b,e&&r&&(i=I(10,b-r),a[s]=(e/i|0)*i);a[s]===0;s--)a.pop();if(s<0)t=0,a=[0];else{for(t=-1;a[0]===0;t-=b)a.shift();for(e=1,i=a[0];i>=10;i/=10)e++;e<b&&(t-=b-e)}return o.e=t,o.d=a,o}function ms(r){return x(r=new this(r),r.e+1,this.rounding)}function ps(r){return r=new this(r),r.d?r.d[0]?r.s:0*r.s:r.s||NaN}function gs(r){return new this(r).sin()}function ys(r){return new this(r).sinh()}function vs(r){return new this(r).sqrt()}function ws(r,n){return new this(r).sub(n)}function Ps(){var r=0,n=arguments,t=new this(n[r]);for(S=!1;t.s&&++r<n.length;)t=t.plus(n[r]);return S=!0,x(t,this.precision,this.rounding)}function xs(r){return new this(r).tan()}function bs(r){return new this(r).tanh()}function _s(r){return x(r=new this(r),r.e+1,1)}y[Symbol.for("nodejs.util.inspect.custom")]=y.toString;y[Symbol.toStringTag]="Decimal";var V=y.constructor=je(de);Zt=new V(Zt);Qt=new V(Qt);class Cs{constructor(){f(this,"parent");f(this,"name","");f(this,"extData");f(this,"mainCanvas");f(this,"_isRecalculate",!1);f(this,"notifyReload")}get isRecalculate(){return(this.parent?this.parent.isRecalculate:!1)||this._isRecalculate}set isRecalculate(n){this._isRecalculate=n}equalsMainCanvas(n){return this.mainCanvas===n}setMainCanvas(n){this.mainCanvas=n}}class Ss extends Cs{constructor(){super(...arguments);f(this,"_isVisible",!0);f(this,"inheritOpacity",!0);f(this,"_opacity");f(this,"_scaleRange")}get isVisible(){return this._isVisible}set isVisible(t){var e;t!=this.isVisible&&(this._isVisible=t,(e=this.notifyReload)==null||e.call(this,!0))}get opacity(){var t;return this.inheritOpacity?this._opacity??((t=this.parent)==null?void 0:t.opacity):this._opacity}set opacity(t){var e;this._opacity!=t&&(t===void 0||t>=0&&t<=1?(this._opacity=t,(e=this.notifyReload)==null||e.call(this,!1)):console.warn("Opacity value should be between 0 and 1."))}get scaleRange(){return this._scaleRange}set scaleRange(t){var e;t!=this.scaleRange&&(this._scaleRange=t,this.isVisible&&((e=this.notifyReload)==null||e.call(this)))}shouldRender(){var e;if(!this.isVisible||this.opacity===0)return!1;const t=(e=this.mainCanvas)==null?void 0:e.scale;if(this.scaleRange&&t){const i=Math.min(...this.scaleRange),s=Math.max(...this.scaleRange);return t>=i&&t<=s}return!0}}let Es=class extends Ss{constructor(n){super(),n.name=n.name||$t("default-name-"),Object.assign(this,{...n})}};class Ds extends Es{constructor(t){super(t);f(this,"_isInteractive",!0);f(this,"_isHoverable",!0);f(this,"_isDownable",!0);f(this,"_isContextmenuable",!0);f(this,"_isClickable",!0);f(this,"_isDoubleClickable",!0);f(this,"_isDraggable",!0);f(this,"_isWheelable",!0);Object.assign(this,{...t})}get isInteractive(){return this.getPropValue("isInteractive",this._isInteractive,!1)}set isInteractive(t){this._isInteractive=t}get isHoverable(){return this.getPropValue("isHoverable",this._isHoverable)}set isHoverable(t){this._isHoverable=t}get isDownable(){return this.getPropValue("isDownable",this._isDownable)}set isDownable(t){this._isDownable=t}get isContextmenuable(){return this.getPropValue("isContextmenuable",this._isContextmenuable)}set isContextmenuable(t){this._isContextmenuable=t}get isClickable(){return this.getPropValue("isClickable",this._isClickable)}set isClickable(t){this._isClickable=t}get isDoubleClickable(){return this.getPropValue("isDoubleClickable",this._isDoubleClickable)}set isDoubleClickable(t){this._isDoubleClickable=t}get isDraggable(){return this.getPropValue("isDraggable",this._isDraggable)}set isDraggable(t){this._isDraggable=t}get isWheelable(){return this.getPropValue("isWheelable",this._isWheelable)}set isWheelable(t){this._isWheelable=t}getPropValue(t,e,i=!0){return(this.parent?this.parent[t]:!0)&&e&&(i?this.isInteractive:!0)}}class Vs{constructor(n){f(this,"propagationStopped",!1);this.data=n}stopPropagation(){this.propagationStopped=!0}get canPropagate(){return!this.propagationStopped}}class Nt extends Ds{constructor(){super(...arguments);f(this,"listeners",{wheel:new Set,hover:new Set,down:new Set,contextmenu:new Set,click:new Set,doubleClick:new Set,dragg:new Set});f(this,"sharedControllers",{});f(this,"_eventDate",{});f(this,"_clearEventDate",!1);f(this,"_isHover",!1);f(this,"notifyHover",(t,e)=>this.checkEventDate("hover",t)&&this.trigger("hover",{state:t,oldState:this.isHover},e,"isHoverable"));f(this,"_isDown",!1);f(this,"notifyDown",(t,e)=>this.checkEventDate("down",t)&&this.trigger("down",{state:t,oldState:this.isDown},e,"isDownable"));f(this,"_isContextmenu",!1);f(this,"notifyContextmenu",(t,e)=>this.checkEventDate("contextmenu",t)&&this.trigger("contextmenu",{state:t,oldState:this.isContextmenu},e,"isContextmenuable"));f(this,"_isClick",!1);f(this,"clickTimestamp",0);f(this,"doubleClickInterval",300);f(this,"notifyClick",(t,e)=>{if(!this.checkEventDate("click",t))return;let i=!1;t?(i=Date.now()-this.clickTimestamp<this.doubleClickInterval,this.clickTimestamp=i?0:Date.now()):(this._isDblClick=!1,this.clickTimestamp=0),i?this.notifyDoubleClick(i,e):this.trigger("click",{state:t,oldState:this.isClick},e,"isClickable")});f(this,"_isDblClick",!1);f(this,"notifyDoubleClick",(t,e)=>this.checkEventDate("doubleClick",t)&&this.trigger("doubleClick",{state:t,oldState:this.isDblClick},e,"isDoubleClickable"));f(this,"notifyDragg",(t,e)=>this.checkEventDate("dragg",t)&&this.trigger("dragg",t,e,"isDraggable"));f(this,"notifyWheel",(t,e)=>this.checkEventDate("wheel",t)&&this.trigger("wheel",t,e,"isWheelable"))}addEventListener(t,e){this.listeners[t].add(e)}removeEventListener(t,e){this.listeners[t].delete(e)}registerControllers(t,e){this.sharedControllers[t]=e}hasController(t,e){var i;return(i=this.sharedControllers[t])==null?void 0:i.includes(e)}trigger(t,e,i,s){var c,h;if(!this[s])return;this.updateStates(t,e);const o=new Vs(e);this.listeners[t].forEach(u=>u(o,i));const a="notify"+(t.charAt(0).toUpperCase()+t.slice(1)),l=["notifyDragg","notifyWheel"].includes(a)?e:e.state;o.canPropagate&&((c=this.parent)==null||c[a](l,i)),(h=this.sharedControllers[t])==null||h.forEach(u=>u!==this&&u[a](l,i))}updateStates(t,e){const i=e;switch(t){case"hover":this._isHover=i.state;break;case"down":this._isDown=i.state;break;case"contextmenu":this._isContextmenu=i.state;break;case"click":this._isClick=i.state;break;case"doubleClick":this._isDblClick=i.state;break}}checkEventDate(t,e){const i=this._eventDate[t],s=JSON.stringify(e);return i==s?!1:(this._eventDate[t]=s,this._clearEventDate||(this._clearEventDate=!0,Promise.resolve().then(()=>{this._clearEventDate=!1,this._eventDate={}})),!0)}get isHover(){return this.isHoverable&&this._isHover}get isDown(){return this.isDraggable&&this._isDown}get isContextmenu(){return this.isClickable&&this._isContextmenu}get isClick(){return this.isClickable&&this._isClick}get isDblClick(){return this.isDoubleClickable&&this._isDblClick}}class Rs extends Nt{constructor(t){super(t);f(this,"canvas");f(this,"ctx");f(this,"_rectValueIsUpdated",!1);f(this,"_rect");f(this,"offset",{x:0,y:0});f(this,"center",{x:0,y:0});f(this,"defaultCenter",{top:void 0,bottom:void 0,left:void 0,right:void 0});f(this,"accuracy",5);f(this,"scale",1);f(this,"defaultScale",1);f(this,"percentage",1);f(this,"axisConfig",{count:2,min:100,size:100,x:1,y:1});f(this,"cycle",10);f(this,"delta",.02);f(this,"_redrawInNextRenderFrame",!1);f(this,"isAuto",!1);f(this,"isRendering",!1);f(this,"drawAxis");f(this,"layerGroups",new Map);f(this,"isScaleUpdated",!1);f(this,"nowGridCount");const{id:e,axisConfig:i,defaultCenter:s,offset:o,defaultScale:a}=t,l=document.getElementById(e);if(l instanceof HTMLCanvasElement)if(l.getContext){this.canvas=l,this.ctx=l.getContext("2d");const{clientWidth:c,clientHeight:h}=l;[l.width,l.height]=[c,h]}else throw new Error("canvas-unsupported code here");else throw new Error("canvas is not HTMLCanvasElement");i&&this.setAxis(i),o&&(this.offset.x=o.x||0,this.offset.y=o.y||0),s&&this.setDefaultCenter(s),a&&(this.updateCenter(),this.setScale("center",a-1),this.defaultScale=a)}get rect(){return this._rectValueIsUpdated&&this._rect?this._rect:(this._rectValueIsUpdated=!0,Promise.resolve().then(()=>this._rectValueIsUpdated=!1),this._rect=this.canvas.getBoundingClientRect(),this._rect)}get redrawInNextRenderFrame(){return this._redrawInNextRenderFrame}set redrawInNextRenderFrame(t){this._redrawInNextRenderFrame=t}setNotifyReload(t){this.notifyReload=t}getDefaultCenterLocation(){const{canvas:t,rect:e,defaultCenter:i}=this;if(!t)return console.error("canvas is not HTMLCanvasElement");const{width:s,height:o}=e,{top:a,bottom:l,left:c,right:h}=i,u={vertical:(p,v)=>{if([0,"0","0%"].includes(p))return 0;if(!(p==1/0||p==-1/0))return typeof p=="number"?p:["top","left"].includes(p)?0:["bottom","right"].includes(p)?v:["middle","center"].includes(p)?v/2:/^(-?\d+)%$/.test(p)?(p=p.match(/^(-?\d+)%$/)[1],v*Number(p)/100):Number(p)||void 0},reverse:(p,v)=>{if([0,"0","0%"].includes(p))return v;if(p==1/0||p==-1/0)return;if(typeof p=="number")return v-p;const w=u.vertical(p,v);return w?v-w:void 0}},d=(p,v,w)=>{if(p!==void 0){const _=u.vertical(p,w);if(_!==void 0)return _}if(v!==void 0){const _=u.reverse(v,w);if(_!==void 0)return _}return w/2},m=d(a,l,o);return{x:d(c,h,s),y:m}}updateCenter(){const t=this.getDefaultCenterLocation();if(!t)return;const{x:e,y:i}=t;this.center={x:Math.floor(e+this.offset.x),y:Math.floor(i+this.offset.y)}}updateSize(){const{scale:t,axisConfig:e}=this;e.size=this.getGridSize(t),this.percentage=this.getAxisPointByValue(e.count,0).x/e.min}setScale(t,e){const{canvas:i,isWheelable:s,axisConfig:o,rect:a}=this;if(!s||!i)return console.error("canvas is not HTMLCanvasElement");let l,c;t==="center"?(l=a.left+a.width/2,c=a.top+a.height/2):[l,c]=[t.clientX,t.clientY];const h=this.getMousePositionOnAxis({clientX:l,clientY:c}),u=this.getAxisValueByPoint(h.x,h.y);this.scale=new V(this.scale).add(e).toNumber(),this.isScaleUpdated=!0,this.updateSize();const d=this.getAxisPointByValue(u.xV,u.yV);this.offset.x-=(d.x-h.x)*o.x,this.offset.y-=(d.y-h.y)*o.y,this.offset.x=Number(this.offset.x.toFixed(0)),this.offset.y=Number(this.offset.y.toFixed(0))}setAxis(t){const e={...this.axisConfig,...t},i=Object.fromEntries(Object.entries(e).map(([p,v])=>[p,Number(v)])),{x:s,y:o,count:a,min:l,size:c}=i,h=[1,-1].includes(s),u=[1,-1].includes(o),d=a>0,m=l>0,g=c>=l&&c<=l*2;if(!h||!u||!d||!m){console.warn("Invalid axis configuration:",{x:s,y:o,count:a,min:l});return}g||(i.size=l),this.axisConfig=i}setDefaultCenter(t){Object.assign(this.defaultCenter,t),this.updateCenter()}getGridSize(t){const{cycle:e,delta:i,axisConfig:s}=this;let o=new V(t).sub(1).abs().mod(e*i).div(i).toNumber();return o=t<1&&o!=0?e-o:o,Number(((o/e+1)*s.min).toFixed(0))}getGridCount(t){const{axisConfig:e,cycle:i,delta:s}=this,o=e.count,a=i*s;if(t===1)return o;if(t>1){const l=new V(t).sub(1).div(a).floor();return new V(o).div(new V(2).pow(l)).toNumber()}else{const l=new V(1).sub(t).div(a).ceil();return new V(o).mul(new V(2).pow(l)).toNumber()}}get getNowGridCount(){const{scale:t,nowGridCount:e,isRendering:i}=this;return e&&i?e:(this.nowGridCount=this.getGridCount(t),i&&Promise.resolve().then(()=>this.nowGridCount=void 0),this.nowGridCount)}getMousePositionOnAxis(t){const{canvas:e,center:i,rect:s,axisConfig:o}=this;if(!e)return console.error("canvas is not HTMLCanvasElement");const{clientX:a,clientY:l}=t,{left:c,top:h}=s,u=(a-c-i.x)*o.x,d=(l-h-i.y)*o.y;return{x:u,y:d}}getAxisValueByPoint(t,e,i){const{axisConfig:s}=this;if(i)return{xV:t/s.min*s.count,yV:e/s.min*s.count};const o=this.getNowGridCount,a=new V(t).div(s.size).mul(o).toFixed(8),l=new V(e).div(s.size).mul(o).toFixed(8);return{xV:Number(a),yV:Number(l)}}getAxisPointByValue(t,e,i){const{axisConfig:s}=this;if(i)return{x:t/s.count*s.min,y:e/s.count*s.min};const o=this.getNowGridCount,a=new V(t).div(o).mul(s.size).toFixed(3),l=new V(e).div(o).mul(s.size).toFixed(3);return{x:Number(a),y:Number(l)}}getMaxMinValue(t){t=t||this.rect;const{left:e,top:i,right:s,bottom:o}=t,{axisConfig:a}=this,{x:l,y:c}=this.getMousePositionOnAxis({clientX:a.x==1?e:s,clientY:a.y==1?i:o}),{xV:h,yV:u}=this.getAxisValueByPoint(l,c),{x:d,y:m}=this.getMousePositionOnAxis({clientX:a.x==1?s:e,clientY:a.y==1?o:i}),{xV:g,yV:p}=this.getAxisValueByPoint(d,m);return{minXV:h,maxXV:g,minYV:u,maxYV:p}}transformPosition(t){const{center:e,percentage:i,axisConfig:s}=this,o=i*s.x,a=i*s.y,l=c=>[e.x+c[0]*o,e.y+c[1]*a];return Array.isArray(t[0])?t.map(c=>l(c)):l(t)}}class ks extends Rs{constructor(t){super(t);f(this,"theme","light");f(this,"isThemeUpdated",!1);f(this,"style",{light:{background:"#fff",text:{color:"#222",secondary:"#909399",stroke:"#fff",size:12,family:"monospace",bold:!0},grid:{axis:"#222",grid:"#666",innerGrid:"#e5e5e5"},point:{radius:5,fill:"#d03050",width:14,stroke:"#d0305080"},line:{stroke:{color:"#f0a020",color_hover:"#f2c97d",width:4,dash:!1,dashGap:[5,10],dashOffset:0,cap:"round",join:"round"},point:{radius:5,stroke:"#f0a02080",width:14,fill:"#f0a020"}},arc:{fill:"#f0a02030",fill_hover:"#f2c97d60",stroke:{color:"#f0a020",color_hover:"#f2c97d",width:4,dash:!1,dashGap:[5,10],dashOffset:0,cap:"round",join:"round"},point:{radius:5,stroke:"#f0a02080",width:14,fill:"#f0a020"}},arcTo:{stroke:{color:"#f0a020",color_hover:"#f2c97d",width:4,dash:!1,dashGap:[5,10],dashOffset:0,cap:"round",join:"round"},point:{radius:5,stroke:"#f0a02080",width:14,fill:"#f0a020"}},polygon:{fill:"#18a05830",fill_hover:"#03693360",stroke:{color:"#18a058",color_hover:"#036933",width:1,dash:!1,dashGap:[5,10],dashOffset:0,cap:"round",join:"round"},point:{radius:5,stroke:"#03693380",width:14,fill:"#036933"}}},dark:{background:"#000",text:{color:"#aeaeae",secondary:"#8c8c8c",stroke:"#000",size:12,family:"monospace",bold:!0},grid:{axis:"#aeaeae",grid:"#666",innerGrid:"#454545"},point:{radius:5,fill:"#e88080",width:14,stroke:"#e8808070"},line:{stroke:{color:"#f2c97d",color_hover:"#f0a020",width:4,dash:!1,dashGap:[5,10],dashOffset:0,cap:"round",join:"round"},point:{radius:5,stroke:"#f2c97d80",width:14,fill:"#f2c97d"}},arc:{fill:"#f2c97d30",fill_hover:"#f0a02060",stroke:{color:"#f2c97d",color_hover:"#f0a020",width:4,dash:!1,dashGap:[5,10],dashOffset:0,cap:"round",join:"round"},point:{radius:5,stroke:"#f2c97d80",width:14,fill:"#f2c97d"}},arcTo:{stroke:{color:"#f2c97d",color_hover:"#f0a020",width:4,dash:!1,dashGap:[5,10],dashOffset:0,cap:"round",join:"round"},point:{radius:5,stroke:"#f2c97d80",width:14,fill:"#f2c97d"}},polygon:{fill:"#63e2b730",fill_hover:"#7efbd160",stroke:{color:"#63e2b7",color_hover:"#63e2b7",width:1,dash:!1,dashGap:[5,10],dashOffset:0,cap:"round",join:"round"},point:{radius:5,stroke:"#7efbd180",width:14,fill:"#7efbd1"}}}});const{theme:e}=t;e&&this.setTheme(e),this.initStyle(),this.clearScreen()}initStyle(){const{canvas:t,ctx:e,theme:i}=this;t.classList.add("_nhanh_canvas");const s=this.style[i];e.font=`${s.text.bold?"bold":""} ${s.text.size}px ${s.text.family}`}clearScreen(t=!0){const{ctx:e,theme:i,rect:s}=this,{width:o,height:a}=s;e.clearRect(0,0,o,a),t&&this.style[i].background&&(e.fillStyle=this.style[i].background,e.fillRect(0,0,o,a))}setStyle(t){for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e)){const i=Ie(this.style[e]||this.style[this.theme]);ct(i,t[e]),this.style[e]=i}this.initStyle()}setTheme(t){t in this.style&&(this.theme=t,this.isThemeUpdated=!0)}}class R extends Nt{constructor(t){t={...t},t.isDraggable=t.isDraggable??!1;const{mainCanvas:e,notifyReload:i}=t;delete t.mainCanvas,delete t.notifyReload;super(t);f(this,"_style");f(this,"_position");f(this,"_value");f(this,"_zIndex",0);f(this,"_dynamicPosition");f(this,"_offset",{x:0,y:0});f(this,"path");f(this,"publicToPrivateKeyMap",{offset:"_offset",position:"_position",value:"_value",dynamicPosition:"_dynamicPosition",zIndex:"_zIndex",style:"_style"});f(this,"redrawOnIsHoverChange",!0);f(this,"defaultHover",(t,e)=>{var i;this.redrawOnIsHoverChange&&((i=this.notifyReload)==null||i.call(this))});f(this,"_valueScope");f(this,"styleRadius",{value:0,radius:0});f(this,"offsetValue",{xV:0,yV:0});f(this,"fixedExtraScope",{topV:0,bottomV:0,leftV:0,rightV:0});f(this,"extraScope",{top:0,bottom:0,left:0,right:0,topV:0,bottomV:0,leftV:0,rightV:0});this.setNotifyReload(i),this.mainCanvas=e,["redrawOnIsHoverChange"].forEach(o=>{o in t&&(this[o]=t[o])});const s={};["offset","style","zIndex","position","dynamicPosition","value"].forEach(o=>{o in t&&(s[o]=t[o])}),this.internalUpdate(s),this.addEventListener("hover",this.defaultHover)}get style(){return this._style}set style(t){var e;this._style=t,this.mainCanvas&&(this.updateValueScope(),(e=this.notifyReload)==null||e.call(this))}get position(){return this._position}set position(t){var e;this._position=t,this._value=void 0,this.updateBaseData(),(e=this.notifyReload)==null||e.call(this)}get value(){return this._value}set value(t){var e;this._value=t,this._position=void 0,this.updateBaseData(),(e=this.notifyReload)==null||e.call(this)}get zIndex(){return this._zIndex}set zIndex(t){var e;this._zIndex!=t&&(this._zIndex=t,(e=this.notifyReload)==null||e.call(this))}get dynamicPosition(){return this._dynamicPosition}set dynamicPosition(t){this._dynamicPosition=t}get offset(){return this._offset}set offset(t){var e;this._offset=t,this.calculateOffsetValue(),(e=this.notifyReload)==null||e.call(this)}get finalDynamicPosition(){var i;const{x:t,y:e}=this.offset;return(i=this.dynamicPosition)==null?void 0:i.map((s,o)=>typeof s=="number"?o==0?s+t:s+e:[s[0]+t,s[1]+e])}internalUpdate(t,e){Object.keys(t).forEach(i=>{const s=this.publicToPrivateKeyMap[i];s&&(this[s]=t[i])}),e&&this.updateValueScope()}setMainCanvas(t){super.setMainCanvas(t),t&&this.updateBaseData()}setNotifyReload(t){this.notifyReload=t?e=>{var i;e&&(this.isRecalculate=!0),(e||this.isNeedRender||(i=this.mainCanvas)!=null&&i.currentDrawOverlays.includes(this))&&t()}:void 0}get valueScope(){return this._valueScope}set valueScope(t){this._valueScope=t}initValueScope(){const t=this.value;if(Array.isArray(t[0])){let e=1/0,i=-1/0,s=1/0,o=-1/0;t.forEach(([a,l])=>{e=Math.min(e,a),i=Math.max(i,a),s=Math.min(s,l),o=Math.max(o,l)}),this.valueScope={minX:e,maxX:i,minY:s,maxY:o}}else{const[e,i]=t;this.valueScope={minX:e,maxX:e,minY:i,maxY:i}}this.calculateStyleRadiusValue(!1),this.calculateOffsetValue(!1),this.setFixedExtraScope(!0),this.setExtraScope(!0)}calculateStyleRadiusValue(t=!0){if(!(!this.mainCanvas||!this.valueScope))if(t){const{radius:e,value:i}=this.styleRadius;if(e==0)return;const s=this.mainCanvas.getAxisValueByPoint(e,0).xV,o=s-i;this.valueScope.minX-=o,this.valueScope.maxX+=o,this.valueScope.minY-=o,this.valueScope.maxY+=o,this.styleRadius={radius:e,value:s}}else{const{stroke:e,point:i}=this.computedValueScopeStyles,s=i?i.radius+Math.max(0,i.width/2):0,o=e?Math.max(0,e.width/2):0,a=Math.max(s,o);if(a==0)return this.styleRadius={radius:0,value:0};const l=this.mainCanvas.getAxisValueByPoint(a,0).xV;this.valueScope.minX-=l,this.valueScope.maxX+=l,this.valueScope.minY-=l,this.valueScope.maxY+=l,this.styleRadius={radius:a,value:l}}}calculateOffsetValue(t=!0){const{mainCanvas:e,valueScope:i,offset:s,offsetValue:o}=this;if(!(!e||!i))if(t){const{x:a,y:l}=e.axisConfig;let{xV:c,yV:h}=e.getAxisValueByPoint(s.x,s.y);c*=a,h*=l;const u=c-o.xV,d=h-o.yV;i.minX+=u,i.maxX+=u,i.minY+=d,i.maxY+=d,this.offsetValue={xV:c,yV:h}}else{if(this.offsetValue={xV:0,yV:0},s.x==0&&s.y==0)return;this.calculateOffsetValue()}}setFixedExtraScope(t){if(t===!0)this.fixedExtraScope={topV:0,bottomV:0,leftV:0,rightV:0};else{const e=t||{topV:0,bottomV:0,leftV:0,rightV:0};if(this.valueScope){const{leftV:i,rightV:s,topV:o,bottomV:a}=e;this.valueScope.minX-=i-this.fixedExtraScope.leftV,this.valueScope.maxX+=s-this.fixedExtraScope.rightV,this.valueScope.minY-=o-this.fixedExtraScope.topV,this.valueScope.maxY+=a-this.fixedExtraScope.bottomV,this.fixedExtraScope=e}}}setExtraScope(t){const{valueScope:e,mainCanvas:i,extraScope:s}=this;if(!(!e||!i))if(t===!0)this.extraScope={top:0,bottom:0,left:0,right:0,topV:0,bottomV:0,leftV:0,rightV:0};else if(t){const{left:o,right:a,top:l,bottom:c}=t,{xV:h,yV:u}=i.getAxisValueByPoint(l,c),{xV:d,yV:m}=i.getAxisValueByPoint(o,a);e.minX-=d-s.leftV,e.maxX+=m-s.rightV,e.minY-=h-s.topV,e.maxY+=u-s.bottomV,this.extraScope={...t,topV:h,bottomV:u,leftV:d,rightV:m}}else this.setExtraScope(this.extraScope)}get isWithinRange(){const{mainCanvas:t,valueScope:e}=this;if(!t)return!1;const{isScaleUpdated:i,maxMinValue:s}=t;return i&&(this.calculateStyleRadiusValue(),this.calculateOffsetValue(),this.setExtraScope()),e?!(s.maxXV<e.minX||s.minXV>e.maxX||s.maxYV<e.minY||s.minYV>e.maxY):!0}get isNeedRender(){return!!(this.mainCanvas&&this.shouldRender()&&this.dynamicPosition&&this.isWithinRange)}calculateOffset(t,e){const{percentage:i,axisConfig:s}=this.mainCanvas,o=s.count/s.min/i,a={value:t*o*s.x,position:t/i*s.x,dynamicPosition:t},l={value:e*o*s.y,position:e/i*s.y,dynamicPosition:e};return{x:a,y:l}}handleValuePosition(t,e){let{value:i,position:s,mainCanvas:o}=this;if(!o)return!1;const a=t==="array1D"?ee:Mt,[l,c]=[a(i)&&(!e||i.length>=e),a(s)&&(!e||s.length>=e)],h={value:i,position:s,dynamicPosition:[]};if(!l&&!c)return this.internalUpdate({dynamicPosition:void 0}),!1;if(l){const u=i;if(t==="array1D"){const d=o.getAxisPointByValue(u[0],u[1],!0);h.position=[d.x,d.y]}else{h.position=[];for(let d=0;d<u.length;d++){const m=u[d],g=o.getAxisPointByValue(m[0],m[1],!0);h.position.push([g.x,g.y])}}}else{const u=s;if(t==="array1D"){const d=o.getAxisValueByPoint(u[0],u[1],!0);h.value=[d.xV,d.yV]}else{h.value=[];for(let d=0;d<u.length;d++){const m=u[d],g=o.getAxisValueByPoint(m[0],m[1],!0);h.value.push([g.xV,g.yV])}}}return h.dynamicPosition=o.transformPosition(h.position),this.internalUpdate(h,!0),!0}isPointInAnywhere(t,e){return this.isPointInPath(t,e)||this.isPointInStroke(t,e)}setGlobalAlpha(t){var i;const e=this.opacity??((i=this.parent)==null?void 0:i.opacity);e!==void 0&&(t.globalAlpha=e)}setBaseLineStyle(t,e){const{width:i,dash:s,dashGap:o,dashOffset:a,color:l,color_hover:c,cap:h,join:u}=e;return t.setLineDash(s?o:[]),t.lineDashOffset=a,t.lineCap=h,t.lineJoin=u,t.lineWidth=i,t.strokeStyle=this.isHover?c:l,e}get cursorStyle(){return this.isInteractive?this.isDraggable?"_nhanh_canvas_hover_overlay_draggable":"_nhanh_canvas_hover_overlay":void 0}}f(R,"ctx",document.createElement("canvas").getContext("2d"));class Gt extends R{constructor(t){super(t);f(this,"_draw");this.redrawOnIsHoverChange=!1;const{draw:e}=t;Object.assign(this,{draw:e})}updateValueScope(){this.initValueScope()}isPointInPath(t,e){return!1}isPointInStroke(t,e){return!1}updateBaseData(){if(!this.mainCanvas)return;this.internalUpdate({dynamicPosition:void 0});let t=this.value,e=this.position;t?e=this.convertValuesToPositions(t):t=this.convertPositionsToValues(e),this.updateDataProperties(t,e)}convertValuesToPositions(t){const e=[];let i;return t.forEach(s=>{if(i===void 0){const o=this.mainCanvas.getAxisPointByValue(s[0],s[1],!0);e.push([o.x,o.y]),s[0]!=0?i=new V(o.x).div(s[0]).toNumber():s[1]!=0&&(i=new V(o.y).div(s[1]).toNumber())}else e.push([new V(i).mul(s[0]).toNumber(),new V(i).mul(s[1]).toNumber()])}),e}convertPositionsToValues(t){const e=[];let i;return t.forEach((s,o)=>{if(i===void 0){const a=this.mainCanvas.getAxisValueByPoint(s[0],s[1],!0);e.push([a.xV,a.yV]),s[0]!=0?i=new V(a.xV).div(s[0]).toNumber():s[1]!=0&&(i=new V(a.yV).div(s[1]).toNumber())}else e.push([new V(i).mul(s[0]).toNumber(),new V(i).mul(s[1]).toNumber()])}),e}updateDataProperties(t,e){this.internalUpdate({value:t,position:e,dynamicPosition:this.mainCanvas.transformPosition(e)})}setOverlayStyles(t){}get computedValueScopeStyles(){return{}}get draw(){return t=>{var e;this.setGlobalAlpha(t),(e=this._draw)==null||e.call(this,t)}}set draw(t){this._draw=t}getDraw(){if(this.isNeedRender){const{mainCanvas:t,position:e}=this;return this.isRecalculate&&this.internalUpdate({dynamicPosition:t.transformPosition(e)}),[this.draw,this]}}}class O{static add(n,t){return new V(n).add(t).toNumber()}static sub(n,t){return new V(n).sub(t).toNumber()}static mul(n,t){return new V(n).mul(t).toNumber()}static div(n,t){return new V(n).div(t).toNumber()}}class Xt extends R{constructor(t){super(t);f(this,"textOffset",{x:0,y:0});f(this,"_text");f(this,"defaultDragg",(t,e)=>{var l;const{offsetX:i,offsetY:s}=t.data,{x:o,y:a}=this.calculateOffset(i,s);this.internalUpdate({value:[O.add(this.value[0],o.value),O.add(this.value[1],a.value)],position:[O.add(this.position[0],o.position),O.add(this.position[1],a.position)],dynamicPosition:[O.add(this.dynamicPosition[0],o.dynamicPosition),O.add(this.dynamicPosition[1],a.dynamicPosition)]},!0),(l=this.notifyReload)==null||l.call(this)});const{text:e}=t;Object.assign(this,{text:e}),this.addEventListener("dragg",this.defaultDragg)}get text(){return this._text}set text(t){var e;this._text!=t&&(this._text=t,this.updateBaseData(),(e=this.notifyReload)==null||e.call(this))}updateValueScope(){this.initValueScope();const t=this.textOffset;this.setExtraScope({top:t.y,bottom:t.y,left:t.x,right:t.x})}isPointInPath(t,e){return this.path?R.ctx.isPointInPath(this.path,t,e):!1}isPointInStroke(t,e){return!1}updateBaseData(){if(!this.mainCanvas)return;if(!this.text||this.text.length==0)return this.internalUpdate({dynamicPosition:void 0});const t=R.ctx;this.setOverlayStyles(t);const e=t.measureText(this.text);this.textOffset={x:e.width/2,y:e.actualBoundingBoxAscent/2},this.handleValuePosition("array1D")}setOverlayStyles(t){var o;const e=this.mainCanvas,i=e.style[e.theme].text;let s={};return typeof this.style=="string"?s=((o=e.style[this.style])==null?void 0:o.text)||i:typeof this.style=="object"?s=Object.assign({},i,this.style):s=i,t.font=`${s.bold?"bold":""} ${s.size}px ${s.family}`,t.lineWidth=2,t.strokeStyle=s.stroke,t.fillStyle=s[this.isHover?"secondary":"color"],s}get computedValueScopeStyles(){return{}}draw(t){const{text:e,textOffset:i,finalDynamicPosition:s}=this;if(!this.mainCanvas||!e)return;this.setGlobalAlpha(t),this.setOverlayStyles(t);const o=s[0]-i.x,a=s[1]+i.y;t.strokeText(e,o,a),t.fillText(e,o,a),this.path=new Path2D,this.path.rect(o,s[1]-i.y,i.x*2,i.y*2)}getDraw(){if(this.isNeedRender){if(this.isRecalculate){const{position:t,mainCanvas:e}=this;this.internalUpdate({dynamicPosition:e.transformPosition(t)})}return[this.draw,this]}}}class lt extends R{constructor(t){super(t);f(this,"angle",2*Math.PI);f(this,"defaultDragg",(t,e)=>{var l;const{offsetX:i,offsetY:s}=t.data,{x:o,y:a}=this.calculateOffset(i,s);this.internalUpdate({value:[O.add(this.value[0],o.value),O.add(this.value[1],a.value)],position:[O.add(this.position[0],o.position),O.add(this.position[1],a.position)],dynamicPosition:[O.add(this.dynamicPosition[0],o.dynamicPosition),O.add(this.dynamicPosition[1],a.dynamicPosition)]},!0),(l=this.notifyReload)==null||l.call(this)});f(this,"fillProgress");f(this,"defaultHover",(t,e)=>{const i=t.data.state,s=300,o=this.setOverlayStyles().width;this.fillProgress?this.cancelAndRestartAnimation(i,o,s-100):i&&this.startNewHoverAnimation(o,s)});this.addEventListener("hover",this.defaultHover),this.addEventListener("dragg",this.defaultDragg)}updateValueScope(){this.initValueScope()}cancelAndRestartAnimation(t,e,i){this.fillProgress.scheduleCallback();let s=0;this.fillProgress.scheduleCallback=kt(o=>{!this.fillProgress||!o||(this.fillProgress.progress+=(o-s)*(t?1:-1),s=o,this.fillProgress.progress=Math.min(1,Math.max(0,this.fillProgress.progress)),this.updateLineWidthOffset(e),(this.fillProgress.progress===1||this.fillProgress.progress===0)&&(this.fillProgress.scheduleCallback(),this.fillProgress.progress===0&&(this.fillProgress=void 0)))},i)}startNewHoverAnimation(t,e){this.fillProgress={lineWidthOffset:0,progress:0,scheduleCallback:kt(i=>{this.fillProgress&&(this.fillProgress.progress=i,this.updateLineWidthOffset(t))},e)}}updateLineWidthOffset(t){var i;if(!this.fillProgress)return;const e=Math.ceil(t*this.fillProgress.progress);e!==this.fillProgress.lineWidthOffset&&(this.fillProgress.lineWidthOffset=e,(i=this.notifyReload)==null||i.call(this))}isPointInPath(t,e){return this.path?R.ctx.isPointInPath(this.path,t,e):!1}isPointInStroke(t,e){var i;if(this.path&&this.mainCanvas){const{width:s}=this.setOverlayStyles(R.ctx);return((i=this.fillProgress)==null?void 0:i.lineWidthOffset)==s?!1:R.ctx.isPointInStroke(this.path,t,e)}return!1}updateBaseData(){this.handleValuePosition("array1D")}setOverlayStyles(t){var c,h;const e=this.mainCanvas,i=e.style[e.theme].point;let s={};typeof this.style=="string"?s=((c=e.style[this.style])==null?void 0:c.point)||i:typeof this.style=="object"?s=Object.assign({},i,this.style):s=i;const{width:o,stroke:a,fill:l}=s;if(t){t.setLineDash([]);const u=((h=this.fillProgress)==null?void 0:h.lineWidthOffset)||0;t.lineWidth=o-u,t.strokeStyle=a,t.fillStyle=l}return{...s}}get computedValueScopeStyles(){return{point:this.setOverlayStyles()}}draw(t){var h;const{finalDynamicPosition:e,mainCanvas:i}=this;if(!i)return;this.setGlobalAlpha(t);const{radius:s,width:o}=this.setOverlayStyles(t),a=((h=this.fillProgress)==null?void 0:h.lineWidthOffset)||0,[l,c]=e;t.beginPath(),this.path=new Path2D,this.path.arc(l,c,s+a/2,0,this.angle),o!=a&&t.stroke(this.path),t.fill(this.path)}getDraw(){if(this.isNeedRender){const{mainCanvas:t,position:e}=this;return this.isRecalculate&&this.internalUpdate({dynamicPosition:t.transformPosition(e)}),[this.draw,this]}}}class qe extends R{constructor(t){super(t);f(this,"handlePoints",[]);f(this,"isShowHandlePoint",!1);f(this,"_isHandlePointsVisible",!0);f(this,"canCreateOrDeleteHandlePoint",!0);f(this,"lockedCanCreateOrDeleteHandlePoint",!1);f(this,"defaultClick",(t,e)=>{var o;if(!this.isHandlePointsVisible)return;const{state:i,oldState:s}=t.data;i!=s&&!this.isInfinite&&((o=this.notifyReload)==null||o.call(this))});f(this,"defaultDoubleClick",(t,e)=>{if(e){if(!this.isHandlePointsVisible)return;const{offsetX:i,offsetY:s}=e,{state:o}=t.data;if(this.lockedCanCreateOrDeleteHandlePoint)this.resetHandlePointLock();else if(o&&this.isHandlePointsVisible&&this.canCreateOrDeleteHandlePoint&&this.isDraggable){const l=this.handlePoints.findIndex(c=>c.isHover);l===-1?this.tryCreateNewHandlePoint(i,s):this.tryDeleteHandlePoint(l)}}});f(this,"defaultDragg",(t,e)=>{var s;if(!this.mainCanvas)return;const i=()=>{const{offsetX:o,offsetY:a}=t.data,{x:l,y:c}=this.calculateOffset(o,a);this.value.forEach((h,u)=>{this.value[u]=[O.add(this.value[u][0],l.value),O.add(this.value[u][1],c.value)],this.position[u]=[O.add(this.position[u][0],l.position),O.add(this.position[u][1],c.position)],this.dynamicPosition[u]=[O.add(this.dynamicPosition[u][0],l.dynamicPosition),O.add(this.dynamicPosition[u][1],c.dynamicPosition)]}),this.handlePoints.forEach((h,u)=>{h.internalUpdate({value:this.value[u],position:this.position[u],dynamicPosition:this.dynamicPosition[u]})}),this.lockedCanCreateOrDeleteHandlePoint=!0};if(this.isHandlePointsVisible){const o=this.handlePoints.findIndex(a=>a.isHover);if(o!=-1){const a=this.handlePoints[o];a.notifyDragg(t.data,e),this.value[o]=a.value,this.position[o]=a.position,this.dynamicPosition[o]=a.dynamicPosition}else i()}else i();(s=this.notifyReload)==null||s.call(this),this.updateValueScope()});["isHandlePointsVisible","canCreateOrDeleteHandlePoint"].forEach(e=>{e in t&&(this[e]=t[e])}),this.addEventListener("click",this.defaultClick),this.addEventListener("doubleClick",this.defaultDoubleClick),this.addEventListener("dragg",this.defaultDragg)}get isHandlePointsVisible(){return this._isHandlePointsVisible}set isHandlePointsVisible(t){var e;this._isHandlePointsVisible!==t&&(this._isHandlePointsVisible=t,this.isShowHandlePoint!=t&&((e=this.notifyReload)==null||e.call(this)),this.updateHandlePoints())}get offset(){return super.offset}set offset(t){super.offset=t;let{isHandlePointsVisible:e,handlePoints:i}=this;e&&i.forEach(s=>s.internalUpdate({offset:t}))}tryCreateNewHandlePoint(t,e){var c;if(!this.isPointInStroke(t,e))return;const i=this.getExtendedDynamicPositions(),s=Ms([t,e],i);if(s===-1)return;const[o,a]=this.getAdjacentIndices(s),l=this.createNewHandlePoint(o,a);this.insertHandlePoint(s,l),this.lockHandlePointCreationTemporarily(),(c=this.notifyReload)==null||c.call(this)}tryDeleteHandlePoint(t){var e;!this.isDblClick||!this.canDeleteHandlePoint||(this.deleteHandlePoint(t),(e=this.notifyReload)==null||e.call(this))}getExtendedDynamicPositions(){return this.isClosed?[...this.dynamicPosition,this.dynamicPosition[0]]:this.dynamicPosition}getAdjacentIndices(t){const e=t-1,i=this.isClosed&&t===this.dynamicPosition.length?0:t;return[e,i]}createNewHandlePoint(t,e){const i=ae(this.value[t],this.value[e]),s=ae(this.position[t],this.position[e]),o=ae(this.dynamicPosition[t],this.dynamicPosition[e]);return new lt({value:i,position:s,dynamicPosition:o,isDraggable:!0,mainCanvas:this.mainCanvas,notifyReload:()=>{var a;return(a=this.notifyReload)==null?void 0:a.call(this)}})}insertHandlePoint(t,e){this.handlePoints.splice(t,0,e),this.value.splice(t,0,e.value),this.position.splice(t,0,e.position),this.dynamicPosition.splice(t,0,e.dynamicPosition)}deleteHandlePoint(t){this.handlePoints.splice(t,1),this.value.splice(t,1),this.position.splice(t,1),this.dynamicPosition.splice(t,1)}lockHandlePointCreationTemporarily(){this.lockedCanCreateOrDeleteHandlePoint=!0,setTimeout(()=>{this.lockedCanCreateOrDeleteHandlePoint=!1},300)}resetHandlePointLock(){this.lockedCanCreateOrDeleteHandlePoint=!1}get canDeleteHandlePoint(){return this.handlePoints.length>this.minNeededHandlePoints}updateHandlePoints(){let{value:t,position:e,dynamicPosition:i,offset:s,isHandlePointsVisible:o}=this;!i||!o||(t==null||t.forEach((a,l)=>{if(!this.handlePoints[l]){const c=new lt({value:[0,0],mainCanvas:this.mainCanvas,isDraggable:!0,offset:s,notifyReload:()=>{var h;return(h=this.notifyReload)==null?void 0:h.call(this)}});this.handlePoints.push(c)}this.handlePoints[l].internalUpdate({value:t[l],position:e[l],dynamicPosition:i[l]},!0)}),this.handlePoints.length=t.length)}updateHandlePointsPosition(){this.isHandlePointsVisible&&this.handlePoints.forEach((t,e)=>{t.internalUpdate({dynamicPosition:this.dynamicPosition[e]})})}}function Ms(r,n,t=10){if(n.length===0)return 0;if(n.length===1)return 1;let e=1/0,i=-1;for(let s=0;s<n.length-1;s++){const o=Je(r,n[s],n[s+1]);if(o<t)return s+1;o<e&&(e=o,i=s+1)}return i}function ae(r,n){const{x:t,y:e}=be(...r,...n);return[t,e]}class Yt extends qe{constructor(t){super(t);f(this,"_isInfinite");f(this,"isClosed",!1);f(this,"minNeededHandlePoints",2);const{isInfinite:e}=t;Object.assign(this,{isInfinite:e}),e&&(this.canCreateOrDeleteHandlePoint=!1)}get isInfinite(){return this._isInfinite}set isInfinite(t){var e;this._isInfinite!=t&&(this._isInfinite=t,this.canCreateOrDeleteHandlePoint=!t,(e=this.notifyReload)==null||e.call(this))}updateValueScope(){this.initValueScope()}isPointInPath(t,e){return!1}isPointInStroke(t,e){return this.path&&this.mainCanvas?(this.setOverlayStyles(R.ctx),this.isDraggable&&(R.ctx.lineWidth=Math.max(R.ctx.lineWidth,20)),R.ctx.isPointInStroke(this.path,t,e)):!1}isPointInAnywhere(t,e){return(s=>{if(!s)return!1;let o=!1;return[...this.handlePoints].sort((l,c)=>(l.isHover?0:1)-(c.isHover?0:1)).forEach(l=>{o?l.isHover&&l.notifyHover(!1):(o=l.isPointInAnywhere(t,e),o!=l.isHover&&l.notifyHover(o))}),o})((this.isClick||!!this.isInfinite)&&this.isShowHandlePoint)||super.isPointInAnywhere(t,e)}get isWithinRange(){if(this.isInfinite){this.isRecalculate&&this.updateDynamicPosition();const{width:t,height:e}=this.mainCanvas.rect;return Os([0,0],[t,e],this.finalDynamicPosition[0],this.finalDynamicPosition[1])}return super.isWithinRange}updateBaseData(){this.handleValuePosition("array2D",2)&&this.updateHandlePoints()}updateDynamicPosition(){const{mainCanvas:t,position:e}=this,i=t.transformPosition(e);this.internalUpdate({dynamicPosition:i}),this.updateHandlePointsPosition()}setOverlayStyles(t){var o;const e=this.mainCanvas,i=e.style[e.theme].line;let s={};return typeof this.style=="string"?s=((o=e.style[this.style])==null?void 0:o.line)||i:typeof this.style=="object"?s=ct(JSON.parse(JSON.stringify(i)),this.style):s=i,t&&this.setBaseLineStyle(t,s.stroke),s}get computedValueScopeStyles(){return this.setOverlayStyles()}drawLine(t,e){const{mainCanvas:i,isInfinite:s,isClick:o}=this;if(e=e||this.finalDynamicPosition,!i)return;this.setGlobalAlpha(t);const a=this.setOverlayStyles(t);t.beginPath(),this.path=new Path2D,e.forEach((l,c)=>{this.path[c==0?"moveTo":"lineTo"](l[0],l[1])}),t.stroke(this.path),this.isShowHandlePoint=(s||o)&&this.isHandlePointsVisible,this.isShowHandlePoint&&this.handlePoints.forEach(l=>{var c;l.style=a.point,(c=l.getDraw())==null||c[0].call(l,t)})}drawisInfiniteStraightLine(t){const{mainCanvas:e,finalDynamicPosition:i}=this;if(!e)return;this.setGlobalAlpha(t);const{rect:s}=e,[o,a]=i,l=[a[0]-o[0],a[1]-o[1]];if(l[0]===0&&l[1]===0)return console.error("重合点无法确定方向");const c=Ve(o,[-l[0],-l[1]],s.width,s.height),h=Ve(a,l,s.width,s.height);this.drawLine(t,[c,h])}getDraw(){if(this.isNeedRender){const{isRecalculate:t,isInfinite:e}=this;return t&&this.updateDynamicPosition(),e?[this.drawisInfiniteStraightLine,this]:[this.drawLine,this]}}}function Ve(r,n,t,e){const[i,s]=r,[o,a]=n;let l=1/0;if(o!==0){const c=o>0?(t-i)/o:-i/o;c>0&&(l=Math.min(l,c))}if(a!==0){const c=a>0?(e-s)/a:-s/a;c>0&&(l=Math.min(l,c))}return l===1/0?r:[i+o*l,s+a*l]}function Os(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}class zt extends qe{constructor(t){super(t);f(this,"_isRect",!1);f(this,"dynamicBorderRadius");f(this,"_borderRadius");f(this,"_borderRadiusType","position");f(this,"isClosed",!0);f(this,"minNeededHandlePoints",3);["isRect","borderRadius","borderRadiusType"].forEach(e=>{e in t&&(this[e]=t[e])}),t.isRect&&(this.canCreateOrDeleteHandlePoint=!1)}get isRect(){return this._isRect}set isRect(t){var e;this._isRect!=t&&(this._isRect=t,this.canCreateOrDeleteHandlePoint=!t,this.updateBaseData(),(e=this.notifyReload)==null||e.call(this))}get borderRadius(){return this._borderRadius}set borderRadius(t){var e;this._borderRadius!=t&&(this._borderRadius=t,this.updateDynamicRadius(),(e=this.notifyReload)==null||e.call(this))}get borderRadiusType(){return this._borderRadiusType}set borderRadiusType(t){var e;this._borderRadiusType!=t&&(this._borderRadiusType=t,this.updateDynamicRadius(),(e=this.notifyReload)==null||e.call(this))}updateValueScope(){this.initValueScope()}isPointInPath(t,e){return this.path?R.ctx.isPointInPath(this.path,t,e):!1}isPointInStroke(t,e){return this.path&&this.mainCanvas?(this.setOverlayStyles(R.ctx),this.isDraggable&&(R.ctx.lineWidth=Math.max(R.ctx.lineWidth,20)),R.ctx.isPointInStroke(this.path,t,e)):!1}isPointInAnywhere(t,e){return(s=>{if(!s)return!1;let o=!1;return[...this.handlePoints].sort((l,c)=>(l.isHover?0:1)-(c.isHover?0:1)).forEach(l=>{o?l.isHover&&l.notifyHover(!1):(o=l.isPointInAnywhere(t,e),o!=l.isHover&&l.notifyHover(o))}),o})(this.isClick&&this.isShowHandlePoint)||super.isPointInAnywhere(t,e)}updateDynamicRadius(){const{mainCanvas:t,borderRadius:e}=this;if(!t||!e){this.dynamicBorderRadius=void 0;return}if(typeof e=="number"){this.dynamicBorderRadius=this.handleSingleRadius(e);return}this.dynamicBorderRadius=e.map(i=>this.handleSingleRadius(i,!0))}handleSingleRadius(t,e){const{mainCanvas:i,borderRadiusType:s}=this;if(t<=0)return e?0:void 0;switch(s){case"position":return t*i.percentage;default:return i.getAxisPointByValue(t,0).x}}updateBaseData(){if(!this.mainCanvas)return;let{value:t,position:e,isRect:i}=this;const s=i?2:3;i&&(Array.isArray(t)&&(t.length=2),Array.isArray(e)&&(e.length=2)),this.handleValuePosition("array2D",s)&&(this.updateHandlePoints(),this.updateDynamicRadius())}setOverlayStyles(t){var c;const e=this.isHover,i=this.mainCanvas,s=i.style[i.theme].polygon;let o={};typeof this.style=="string"?o=((c=i.style[this.style])==null?void 0:c.polygon)||s:typeof this.style=="object"?o=ct(JSON.parse(JSON.stringify(s)),this.style):o=s;const{fill:a,fill_hover:l}=o;return t&&(this.setBaseLineStyle(t,o.stroke),t.fillStyle=e?l:a),o}get computedValueScopeStyles(){return this.setOverlayStyles()}drawRect(t){this.setGlobalAlpha(t);const[[e,i],[s,o]]=this.finalDynamicPosition,a=Math.abs(s-e),l=Math.abs(o-i),c=Math.min(e,s),h=Math.min(i,o),u=this.setOverlayStyles(t);t.beginPath(),this.path=new Path2D,this.dynamicBorderRadius?this.path.roundRect(c,h,a,l,this.dynamicBorderRadius):this.path.rect(c,h,a,l),t.stroke(this.path),t.fill(this.path),this.isShowHandlePoint=this.isClick&&this.isHandlePointsVisible,this.isShowHandlePoint&&this.handlePoints.forEach(d=>{var m;d.internalUpdate({style:u.point}),(m=d.getDraw())==null||m[0].call(d,t)})}drawPolygon(t){this.setGlobalAlpha(t);const e=this.finalDynamicPosition,i=this.setOverlayStyles(t);t.beginPath(),this.path=new Path2D,e.forEach((s,o)=>{this.path[o==0?"moveTo":"lineTo"](s[0],s[1])}),this.path.closePath(),t.stroke(this.path),t.fill(this.path),this.isShowHandlePoint=this.isClick&&this.isHandlePointsVisible,this.isShowHandlePoint&&this.handlePoints.forEach(s=>{var o;s.internalUpdate({style:i.point}),(o=s.getDraw())==null||o[0].call(s,t)})}getDraw(){if(this.isNeedRender){const{mainCanvas:t,position:e}=this;if(this.isRecalculate){this.updateDynamicRadius();const i=t.transformPosition(e);this.internalUpdate({dynamicPosition:i}),this.updateHandlePointsPosition()}return this.isRect?[this.drawRect,this]:[this.drawPolygon,this]}}}class pe extends R{constructor(t){super(t);f(this,"_isFill",!1);f(this,"_isClosed",!1);f(this,"_isClosedThroughCenter",!1);f(this,"_radiusValue",0);f(this,"_radiusPosition",0);f(this,"_startAngle",0);f(this,"_endAngle",0);f(this,"_counterclockwise",!1);f(this,"isShowHandlePoint",!1);f(this,"_isHandlePointsVisible",!0);f(this,"defaultClick",(t,e)=>{var o;if(!this.isHandlePointsVisible)return;const{state:i,oldState:s}=t.data;i!=s&&((o=this.notifyReload)==null||o.call(this))});f(this,"defaultDragg",(t,e)=>{if(!this.mainCanvas)return;const i=()=>{var h;const{offsetX:s,offsetY:o}=t.data,{x:a,y:l}=this.calculateOffset(s,o);this.handlePointsArr.concat(this).forEach(u=>{u.internalUpdate({value:[O.add(u.value[0],a.value),O.add(u.value[1],l.value)],position:[O.add(u.position[0],a.position),O.add(u.position[1],l.position)],dynamicPosition:[O.add(u.dynamicPosition[0],a.dynamicPosition),O.add(u.dynamicPosition[1],l.dynamicPosition)]},!0)}),(h=this.notifyReload)==null||h.call(this)};if(this.isHandlePointsVisible){const{start:s,end:o,radius:a}=this.handlePoints,l=this.handlePointsArr.find(c=>c.isHover);if(l){const c=t.data.offsetX;if(l==s)this.startAngle=(this.startAngle+-c/180*Math.PI)%(Math.PI*2);else if(l==o)this.endAngle=(this.endAngle+-c/180*Math.PI)%(Math.PI*2);else if(l==a){const h=c/2/this.mainCanvas.percentage;this.radiusPosition+h>0&&(this.radiusPosition+=h)}}else i()}else i()});f(this,"handlePoints",{start:void 0,end:void 0,radius:void 0});["isFill","isClosed","isClosedThroughCenter","radiusValue","radiusPosition","startAngle","endAngle","counterclockwise","isHandlePointsVisible"].forEach(e=>{e in t&&(this["_"+e]=t[e])}),this.addEventListener("click",this.defaultClick),this.addEventListener("dragg",this.defaultDragg)}get isFill(){return this._isFill}set isFill(t){var e;this._isFill!=t&&(this._isFill=t,(e=this.notifyReload)==null||e.call(this))}get isClosed(){return this._isClosed}set isClosed(t){var e;this._isClosed!=t&&(this._isClosed=t,(e=this.notifyReload)==null||e.call(this))}get isClosedThroughCenter(){return this._isClosedThroughCenter}set isClosedThroughCenter(t){var e;this._isClosedThroughCenter!=t&&(this._isClosedThroughCenter=t,(e=this.notifyReload)==null||e.call(this))}get radiusValue(){return this._radiusValue}set radiusValue(t){this._radiusValue!=t&&(this._radiusValue=t,this._radiusPosition=0,this.updateBaseData())}get radiusPosition(){return this._radiusPosition}set radiusPosition(t){this._radiusPosition!=t&&(this._radiusPosition=t,this._radiusValue=0,this.updateBaseData())}get startAngle(){return this._startAngle}set startAngle(t){var e;this._startAngle!=t&&(this._startAngle=t,this.updateHandlePoints(),(e=this.notifyReload)==null||e.call(this))}get endAngle(){return this._endAngle}set endAngle(t){var e;this._endAngle!=t&&(this._endAngle=t,this.updateHandlePoints(),(e=this.notifyReload)==null||e.call(this))}get counterclockwise(){return this._counterclockwise}set counterclockwise(t){var e;this._counterclockwise!=t&&(this._counterclockwise=t,(e=this.notifyReload)==null||e.call(this))}get isHandlePointsVisible(){return this._isHandlePointsVisible}set isHandlePointsVisible(t){var e;this._isHandlePointsVisible!==t&&(this._isHandlePointsVisible=t,this.isShowHandlePoint!=t&&((e=this.notifyReload)==null||e.call(this)),this.updateHandlePoints())}get offset(){return super.offset}set offset(t){super.offset=t;let{isHandlePointsVisible:e,handlePointsArr:i}=this;e&&i.forEach(s=>s.internalUpdate({offset:t}))}updateValueScope(){const{mainCanvas:t,radiusValue:e}=this;t&&(this.initValueScope(),this.setFixedExtraScope({topV:e,bottomV:e,leftV:e,rightV:e*2}))}isPointInPath(t,e){return this.isFill&&this.path?R.ctx.isPointInPath(this.path,t,e):!1}isPointInStroke(t,e){return this.path&&this.mainCanvas?(this.setOverlayStyles(R.ctx),this.isDraggable&&(R.ctx.lineWidth=Math.max(R.ctx.lineWidth,20)),R.ctx.isPointInStroke(this.path,t,e)):!1}isPointInAnywhere(t,e){return(s=>{if(!s)return!1;let o=!1;return this.handlePointsArr.forEach(a=>{o?a.isHover&&a.notifyHover(!1):(o=a.isPointInAnywhere(t,e),o!=a.isHover&&a.notifyHover(o))}),o})(this.isClick&&this.isShowHandlePoint)||super.isPointInAnywhere(t,e)}get cursorStyle(){const t=this.handlePointsArr.some(e=>e==null?void 0:e.isHover);return this.isInteractive?this.isDraggable?"_nhanh_canvas_hover_overlay_draggable"+(t?"_ew":""):"_nhanh_canvas_hover_overlay":void 0}setOverlayStyles(t){var c;const e=this.isHover,i=this.mainCanvas,s=i.style[i.theme].arc;let o={};typeof this.style=="string"?o=((c=i.style[this.style])==null?void 0:c.arc)||s:typeof this.style=="object"?o=ct(JSON.parse(JSON.stringify(s)),this.style):o=s;const{fill:a,fill_hover:l}=o;return t&&(this.setBaseLineStyle(t,o.stroke),t.fillStyle=e?l:a),o}get computedValueScopeStyles(){return this.setOverlayStyles()}get handlePointsArr(){const t=this.handlePoints.radius;return Object.values(this.handlePoints).filter(Boolean).sort((e,i)=>(e.isHover||e==t?0:1)-(i.isHover||i==t?0:1))}updateHandlePoints(){let{mainCanvas:t,value:e,radiusValue:i,startAngle:s,endAngle:o,dynamicPosition:a,isHandlePointsVisible:l,offset:c}=this;if(!t||!a||!l)return;const[h,u]=Ns(...e,i,s,o,t.axisConfig.x,t.axisConfig.y),d=w=>new lt({name:w,offset:c,value:[0,0],isDraggable:!0,mainCanvas:this.mainCanvas,notifyReload:()=>{var _;return(_=this.notifyReload)==null?void 0:_.call(this)}}),m=this.handlePoints.start||d("start"),g=this.handlePoints.end||d("end"),p=this.handlePoints.radius||d("radius");m.value=h,g.value=u;const v=e[0]+i*2*t.axisConfig.x;p.value=[v,e[1]],this.handlePoints={start:m,end:g,radius:p}}updateBaseData(){this.mainCanvas&&(this.radiusValue?this._radiusPosition=this.mainCanvas.getAxisPointByValue(this.radiusValue,0,!0).x:this._radiusValue=this.mainCanvas.getAxisValueByPoint(this.radiusPosition,0,!0).xV,this.handleValuePosition("array1D")&&this.updateHandlePoints())}drawGuideLine(t,e,i,s){this.setBaseLineStyle(t,{...s.stroke,dash:!s.stroke.dash});const{radiusPosition:o,startAngle:a,endAngle:l,counterclockwise:c,mainCanvas:h}=this;t.beginPath(),t.arc(e,i,o*h.percentage,l,a,c),t.stroke(),t.beginPath(),t.moveTo(e,i);const u=this.handlePoints.radius.finalDynamicPosition;t.lineTo(u[0],u[1]),t.stroke(),!(this.isClosed&&this.isClosedThroughCenter)&&(t.fillStyle=t.strokeStyle,t.beginPath(),t.arc(e,i,s.point.radius,0,Math.PI*2),t.fill())}draw(t){const{finalDynamicPosition:e,mainCanvas:i,startAngle:s,endAngle:o,counterclockwise:a,isFill:l,isClosed:c,isClosedThroughCenter:h,radiusPosition:u}=this;if(!i||u<=0)return;this.setGlobalAlpha(t);const d=this.setOverlayStyles(t),[m,g]=e;t.beginPath(),this.path=new Path2D,this.path.arc(m,g,u*i.percentage,s,o,a),c&&(this.path.lineTo(m,g),h&&this.path.closePath()),t.stroke(this.path),l&&t.fill(this.path),this.isShowHandlePoint=this.isClick&&this.isHandlePointsVisible,this.isShowHandlePoint&&(this.drawGuideLine(t,m,g,d),this.handlePointsArr.forEach(p=>{var v;p.internalUpdate({style:d.point}),(v=p.getDraw())==null||v[0].call(p,t)}))}getDraw(){if(this.isNeedRender){if(this.isRecalculate){const{position:t,mainCanvas:e}=this,i=this.dynamicPosition,s=e.transformPosition(t);if(this.internalUpdate({dynamicPosition:s}),this.isHandlePointsVisible)if(e!=null&&e.isScaleUpdated)this.updateHandlePoints();else{const o=s[0]-i[0],a=s[1]-i[1];this.handlePointsArr.forEach(l=>{const c=l.dynamicPosition[0]+o,h=l.dynamicPosition[1]+a;l.internalUpdate({dynamicPosition:[c,h]})})}}return[this.draw,this]}}}function Ns(r,n,t,e,i,s=1,o=1){const a=r+t*Math.cos(e)*s,l=n+t*Math.sin(e)*o,c=r+t*Math.cos(i)*s,h=n+t*Math.sin(i)*o;return[[a,l],[c,h]]}class ge extends R{constructor(t){super(t);f(this,"handlePoints");f(this,"isShowHandlePoint",!1);f(this,"_isHandlePointsVisible",!0);f(this,"_radiusValue",0);f(this,"_radiusPosition",0);f(this,"defaultClick",(t,e)=>{var o;if(!this.isHandlePointsVisible)return;const{state:i,oldState:s}=t.data;i!=s&&((o=this.notifyReload)==null||o.call(this))});f(this,"defaultDragg",(t,e)=>{this.mainCanvas});["isHandlePointsVisible"].forEach(e=>{e in t&&(this["_"+e]=t[e])}),this.addEventListener("click",this.defaultClick),this.addEventListener("dragg",this.defaultDragg)}get handlePointsArr(){if(this.handlePoints){const{radius:t,other:e}=this.handlePoints;return[t,...e].filter(Boolean).sort((i,s)=>(i.isHover||i==t?0:1)-(s.isHover||s==t?0:1))}return[]}get isHandlePointsVisible(){return this._isHandlePointsVisible}set isHandlePointsVisible(t){var e;this._isHandlePointsVisible!==t&&(this._isHandlePointsVisible=t,this.isShowHandlePoint!=t&&((e=this.notifyReload)==null||e.call(this)))}get radiusValue(){return this._radiusValue}set radiusValue(t){this._radiusValue!=t&&(this._radiusValue=t,this.updateBaseData())}get radiusPosition(){return this._radiusPosition}set radiusPosition(t){this._radiusPosition!=t&&(this._radiusPosition=t,this.updateBaseData())}updateValueScope(){this.initValueScope()}isPointInPath(t,e){return!1}isPointInStroke(t,e){return this.path&&this.mainCanvas?(this.setOverlayStyles(R.ctx),this.isDraggable&&(R.ctx.lineWidth=Math.max(R.ctx.lineWidth,20)),R.ctx.isPointInStroke(this.path,t,e)):!1}isPointInAnywhere(t,e){return(s=>{if(!s)return!1;let o=!1;return this.handlePointsArr.forEach(a=>{o?a.isHover&&a.notifyHover(!1):(o=a.isPointInAnywhere(t,e),o!=a.isHover&&a.notifyHover(o))}),o})(this.isClick&&this.isShowHandlePoint)||super.isPointInAnywhere(t,e)}get cursorStyle(){var e;const t=(e=this.handlePoints)==null?void 0:e.radius.isHover;return this.isDraggable?"_nhanh_canvas_hover_overlay_draggable"+(t?"_ns":""):"_nhanh_canvas_hover_overlay"}setOverlayStyles(t){var o;const e=this.mainCanvas,i=e.style[e.theme].arcTo;let s={};return typeof this.style=="string"?s=((o=e.style[this.style])==null?void 0:o.arcTo)||i:typeof this.style=="object"?s=ct(JSON.parse(JSON.stringify(i)),this.style):s=i,t&&this.setBaseLineStyle(t,s.stroke),s}get computedValueScopeStyles(){return this.setOverlayStyles()}updateHandlePoints(){var c,h;let{value:t,position:e,dynamicPosition:i,isHandlePointsVisible:s}=this;if(!i||!s)return;const o=()=>new lt({value:[0,0],mainCanvas:this.mainCanvas,isDraggable:!0,notifyReload:()=>{var u;return(u=this.notifyReload)==null?void 0:u.call(this)}}),a=((c=this.handlePoints)==null?void 0:c.other)||[];t==null||t.forEach((u,d)=>{a[d]||a.push(o()),a[d].internalUpdate({value:t[d],position:e[d],dynamicPosition:i[d]},!0)}),a.length=t.length;const l=((h=this.handlePoints)==null?void 0:h.radius)||o();this.handlePoints={radius:l,other:a}}updateBaseData(){if(!this.mainCanvas)return;let{value:t,position:e}=this;const[i,s]=[Mt(t)&&t.length>1,Mt(e)&&e.length>1];if(!i&&!s)return this.handlePoints=void 0,this.internalUpdate({dynamicPosition:void 0});if(i){e=[];for(let a=0;a<t.length;a++){const l=t[a],c=this.mainCanvas.getAxisPointByValue(l[0],l[1],!0);e.push([c.x,c.y])}}else{t=[];for(let a=0;a<e.length;a++){const l=e[a],c=this.mainCanvas.getAxisValueByPoint(l[0],l[1],!0);t.push([c.xV,c.yV])}}const o=this.mainCanvas.transformPosition(e);this.internalUpdate({value:t,position:e,dynamicPosition:o}),this.updateHandlePoints()}draw(t){const{dynamicPosition:e,mainCanvas:i,radiusValue:s}=this}getDraw(){if(this.isNeedRender){if(this.isRecalculate){const{position:t,mainCanvas:e}=this,i=this.dynamicPosition,s=e.transformPosition(t);if(this.internalUpdate({dynamicPosition:s}),this.isHandlePointsVisible)if(e!=null&&e.isScaleUpdated)this.updateHandlePoints();else{const o=s[0][0]-i[0][0],a=s[0][1]-i[0][1];this.handlePointsArr.forEach(l=>{const c=l.dynamicPosition[0]+o,h=l.dynamicPosition[1]+a;l.internalUpdate({dynamicPosition:[c,h]})})}}return[this.draw,this]}}}class As extends ks{constructor(t){super(t);f(this,"resizeObserver");f(this,"currentDrawOverlays",[]);f(this,"rely","");f(this,"maxMinValue",{minXV:0,maxXV:0,minYV:0,maxYV:0});f(this,"measureRedrawPerformance",He(()=>{this.isRendering=!0,this.redraw(),this.redrawInNextRenderFrame=!1,this.isRendering=!1},{level:[[1,"#F56C6C"],[.5,"#E6A23C"],[0,"#67C23A"]]}));this.canvas&&(this.resizeObserver=new ResizeObserver(we(()=>{[this.canvas.width,this.canvas.height]=[this.rect.width,this.rect.height],this.redrawOnce()},200)),this.resizeObserver.observe(this.canvas)),this.updateRely(),this.isRecalculate=!1}updateRely(){const{center:t,scale:e,rect:i,axisConfig:s}=this,o=[t.x,t.y,e,JSON.stringify(s),i.width,i.height].join();this.isRecalculate=this.rely!==o,this.rely=o}redraw(){var s,o;if(!this.canvas)return console.warn("canvas is not HTMLCanvasElement");if(this.canvas.clientWidth==0||this.canvas.clientHeight==0)return console.warn("The image argument is a canvas element with a width or height of 0.");if(!this.shouldRender())return this.clearScreen(!1);this.ctx.globalAlpha=this.opacity??1,this.updateCenter(),this.updateRely(),this.maxMinValue=this.getMaxMinValue(),this.clearScreen();const t=[];let e=[];const i=(s=this.drawAxis)==null?void 0:s.drawAxisAndGrid();i&&e.push([0,i,[]]),this.layerGroups.forEach(a=>e.push(...a.fetchCanvas())),e.sort((a,l)=>a[0]-l[0]),e.forEach(([,a,l],c)=>{this.ctx.drawImage(a,0,0),l.forEach(([[h,u],d])=>{t.push([[h+c,u],d])})}),t.sort(([[a,l],c],[[h,u],d])=>{if(a!==h)return h-a;if(l!==u)return u-l;const m=g=>g instanceof Gt?5:g instanceof Xt?4:g instanceof lt?3:g instanceof Yt||g instanceof pe||g instanceof ge?2:g instanceof zt?1:0;return m(d)-m(c)}),this.currentDrawOverlays=t.map(([,a])=>a),this.isRecalculate=!1,this.isThemeUpdated=!1,this.isScaleUpdated=!1,(o=this.notifyReload)==null||o.call(this)}redrawOnce(){this.redrawInNextRenderFrame||(this.redrawInNextRenderFrame=!0,Promise.resolve().then(()=>{this.isRendering=!0,this.redraw(),this.redrawInNextRenderFrame=!1,this.isRendering=!1}))}findOverlayByPoint(t){const{offsetX:e,offsetY:i,clientX:s,clientY:o}=t,{x:a,y:l}=this.axisConfig,c=this.getMousePositionOnAxis({clientX:s-10*a,clientY:o-10*l}),h=this.getMousePositionOnAxis({clientX:s+10*a,clientY:o+10*l}),u=this.getAxisValueByPoint(c.x,c.y),d=this.getAxisValueByPoint(h.x,h.y);return[...this.currentDrawOverlays].sort((m,g)=>(m.isDraggable&&m.isClick?0:1)-(g.isDraggable&&g.isClick?0:1)).find(m=>{const g=m.valueScope;return g&&(g.maxX<u.xV||g.minX>d.xV||g.maxY<u.yV||g.minY>d.yV)?!1:m.isPointInAnywhere(e,i)})}destroy(){var t;(t=this.resizeObserver)==null||t.disconnect()}}class Is extends As{constructor(t){super(t);f(this,"mouseInCanvas",!1);f(this,"mouseIsDown",!1);f(this,"mouseLastPosition",{x:0,y:0});f(this,"unBind");f(this,"lastClickedOverlay");f(this,"lockNotifyClick",!1);f(this,"lastContextmenuOverlay");f(this,"defaultContextmenu",(t,e)=>{const i=this.lastClickedOverlay;i!=null&&i.isDraggable&&i.notifyClick(!1,e)});f(this,"lastPressedKey",{key:"",keyupTime:0,doubleClick:!1});f(this,"defaultWheel",(t,e)=>{this.setScale(e,t.data),this.redrawOnce()});f(this,"lastDownOverlay");f(this,"defaultDown",(t,e)=>{(e==null?void 0:e.button)==0&&(this.mouseIsDown=!0)});f(this,"lastHoverOverlay");f(this,"lastCursorStyle");f(this,"oldClientX",[]);f(this,"oldClientY",[]);this.initEvent(),this.addEventListener("contextmenu",this.defaultContextmenu),this.addEventListener("down",this.defaultDown),this.addEventListener("wheel",this.defaultWheel)}initEvent(){const{canvas:t}=this;if(!t)return console.error("canvas is not HTMLCanvasElement");const e=[{type:"click",handler:this.click.bind(this)},{type:"contextmenu",handler:this.contextmenu.bind(this)},{type:"mouseenter",handler:this.mouseenter.bind(this)},{type:"mouseleave",handler:this.mouseleave.bind(this)},{type:"keydown",handler:this.keydown.bind(this),target:window},{type:"keyup",handler:this.keyup.bind(this),target:window},{type:"wheel",handler:this.wheel.bind(this)},{type:"mousedown",handler:this.mousedown.bind(this)},{type:"mouseup",handler:this.mouseup.bind(this),target:window},{type:"mousemove",handler:this.mousemove.bind(this),target:window},{type:"touchend",handler:this.touchend.bind(this)},{type:"touchmove",handler:this.touchmove.bind(this)}];e.forEach(({type:i,handler:s,target:o=t})=>{o.addEventListener(i,s)}),this.unBind=()=>{e.forEach(({type:i,handler:s,target:o=t})=>{o.removeEventListener(i,s)})}}click(t){var i;if(!this.isClickable)return;if(this.lockNotifyClick)return this.lockNotifyClick=!1;const e=this.findOverlayByPoint(t);this.lastClickedOverlay!=e&&((i=this.lastClickedOverlay)==null||i.notifyClick(!1,t)),e==null||e.notifyClick(!0,t),this.lastClickedOverlay=e,this.notifyClick(!0,t)}contextmenu(t){var i;if(!this.isContextmenuable)return;t.preventDefault();const e=this.findOverlayByPoint(t);this.lastContextmenuOverlay!=e&&((i=this.lastContextmenuOverlay)==null||i.notifyContextmenu(!1,t)),e==null||e.notifyContextmenu(!0,t),this.lastContextmenuOverlay=e,this.notifyContextmenu(!0,t)}mouseenter(t){this.mouseInCanvas=!0}mouseleave(t){this.mouseInCanvas=!1}getStep(t){const{lastPressedKey:e}=this;return e.doubleClick?4:e.key===t&&Date.now()-e.keyupTime<300?(e.doubleClick=!0,4):1}keydown(t){const{mouseInCanvas:e,offset:i,delta:s,axisConfig:o}=this,a=t.key;if(!e||!this.isDraggable||this.isAuto)return;const l=this.getStep(a),c=this.lastClickedOverlay,u=(c==null?void 0:c.isDraggable)&&this.currentDrawOverlays.includes(c)&&(Mt(c.value)?"Matrix":ee(c.value)?"Single":!1),d=(v,w)=>{if(!u)return i.x+=v*l,i.y+=w*l,!0;const _=this.getAxisValueByPoint(l,0).xV,[C,E]=[_*o.x,_*o.y];if(u==="Single"){const N=c.value;N[0]+=v*C,N[1]+=w*E}else c.value.forEach(N=>{N[0]+=v*C,N[1]+=w*E});return c.value=[...c.value],!0},m=v=>(this.setScale("center",v*s),!0),p={ArrowUp:()=>d(0,-1),ArrowDown:()=>d(0,1),ArrowLeft:()=>d(-1,0),ArrowRight:()=>d(1,0),"+":()=>m(1),"-":()=>m(-1)}[a];p!=null&&p()&&(this.redrawOnce(),t.preventDefault())}keyup(t){const{mouseInCanvas:e,lastPressedKey:i}=this;if(e){const s=t.key;i.key=s,i.keyupTime=Date.now(),i.doubleClick=!1}}wheel(t){if(!this.isWheelable)return;t.preventDefault();const{delta:e,isAuto:i}=this;if(i)return;const s=t.deltaY<0?e:-e,o=this.findOverlayByPoint(t);o==null||o.notifyWheel(s,t),this.notifyWheel(s,t)}mousedown(t){var o;if(!this.isDownable)return;const{clientX:e,clientY:i}=t;this.mouseLastPosition={x:e,y:i};const s=this.findOverlayByPoint(t);this.lastDownOverlay!=s&&((o=this.lastDownOverlay)==null||o.notifyDown(!1,t),s==null||s.notifyDown(!0,t)),this.lastDownOverlay=s,this.notifyDown(!0,t)}mouseup(t){this.mouseIsDown=!1,this.lastDownOverlay=void 0}mousemove(t){this.isAuto||(this.canvas.classList.toggle("_nhanh_canvas_draggable",this.isDraggable),this.mouseIsDown?this.handleDragMove(t):this.handleHover(t))}handleDragMove(t){if(!this.isDraggable)return;const{clientX:e,clientY:i}=t,s={x:e,y:i};if(JSON.stringify(s)==JSON.stringify(this.mouseLastPosition))return;const{lastDownOverlay:o}=this;o!=null&&o.isDraggable?this.notifyDraggOverlays(t):this.handleCanvasPan(t),this.mouseLastPosition=s,this.lockNotifyClick=!0}notifyDraggOverlays(t){const e=this.lastDownOverlay,{mouseLastPosition:i}=this,{clientX:s,clientY:o}=t;e.notifyDragg({offsetX:s-i.x,offsetY:o-i.y},t)}handleCanvasPan(t){const{clientX:e,clientY:i}=t,{offset:s,mouseLastPosition:o}=this,a=e-o.x,l=i-o.y;s.x+=a,s.y+=l,this.redrawOnce(),this.notifyDragg({offsetX:a,offsetY:l},t)}handleHover(t){if(!this.isHoverable||t.target!=this.canvas)return;const e=this.findOverlayByPoint(t);this.updateHoverState(e,t),this.notifyHover(!0,t)}updateHoverState(t,e){if(this.lastHoverOverlay===t){const s=t==null?void 0:t.cursorStyle;s!==this.lastCursorStyle&&(this.lastCursorStyle&&this.canvas.classList.remove(this.lastCursorStyle),s&&this.canvas.classList.add(s),this.lastCursorStyle=s);return}this.lastHoverOverlay&&t&&t.hasController("hover",this.lastHoverOverlay)||(this.clearHoverState(e),this.applyHoverState(t,e)),this.lastHoverOverlay=t}clearHoverState(t){this.lastHoverOverlay&&(this.lastHoverOverlay.notifyHover(!1,t),this.lastHoverOverlay.cursorStyle&&this.canvas.classList.remove(this.lastHoverOverlay.cursorStyle))}applyHoverState(t,e){t&&(t.notifyHover(!0,e),this.lastCursorStyle=t.cursorStyle,this.lastCursorStyle&&this.canvas.classList.add(this.lastCursorStyle))}touchend(t){this.oldClientX=this.oldClientY=[]}touchmove(t){if(!this.isDraggable)return;const e=t.touches;t.preventDefault();const{oldClientX:i,oldClientY:s,offset:o,delta:a,isAuto:l,isDraggable:c}=this;if(c&&!l){if(e.length===1){const{clientX:h,clientY:u}=e[0];i.length&&(o.x+=h-i[0],o.y+=u-s[0],this.redrawOnce()),this.oldClientX=[h],this.oldClientY=[u]}else if(e.length===2){const{clientX:h,clientY:u}=e[0],{clientX:d,clientY:m}=e[1];if(i.length==2){const g=ye(i[0],s[0],i[1],s[1]),p=ye(h,u,d,m),{x:v,y:w}=be(h,u,d,m);this.setScale({clientX:v,clientY:w},p>g?a:-a),this.redrawOnce()}this.oldClientX=[h,d],this.oldClientY=[u,m]}}}destroy(){var t;super.destroy(),(t=this.unBind)==null||t.call(this)}}class et extends Nt{constructor(t){super(t);f(this,"overlays",new Set);this.setNotifyReload(t.notifyReload)}setMainCanvas(t){var e;super.setMainCanvas(t),this.overlays.forEach(i=>{i.setMainCanvas(t),i.parent=this}),t&&this.overlays.size&&((e=this.notifyReload)==null||e.call(this))}setNotifyReload(t){this.notifyReload=t?e=>{e&&(this.isRecalculate=!0),(e||this.shouldRender()&&this.overlays.size)&&t()}:void 0,this.overlays.forEach(e=>e.setNotifyReload(this.notifyReload))}addOverlays(t){var e;[t].flat().forEach(i=>{i.setNotifyReload(this.notifyReload),i.setMainCanvas(this.mainCanvas),i.parent=this,this.overlays.add(i)}),(e=this.notifyReload)==null||e.call(this)}hasOverlay(t){return this.overlays.has(t)}removeOverlays(t){var e;[t].flat().forEach(i=>{this.overlays.delete(i),i.setNotifyReload(),i.setMainCanvas(),i.parent=void 0}),(e=this.notifyReload)==null||e.call(this)}clearOverlays(){var t;(t=this.notifyReload)==null||t.call(this),this.overlays.forEach(e=>{e.setNotifyReload(),e.setMainCanvas(),e.parent=void 0}),this.overlays.clear()}getOverlaysDrawingMethod(){const t=[];return this.shouldRender()&&this.overlays.size&&Array.from(this.overlays.values()).sort((e,i)=>e.zIndex-i.zIndex).forEach(e=>{if(e.equalsMainCanvas(this.mainCanvas)){const i=e.getDraw();i&&t.push([Number(e.zIndex)||0,i])}else this.overlays.delete(e)}),t}}class it extends Nt{constructor(t){super(t);f(this,"zIndex",4);f(this,"canvas",document.createElement("canvas"));f(this,"ctx",this.canvas.getContext("2d"));f(this,"isReload",!1);f(this,"groups",new Map);f(this,"currentDrawOverlays",[]);this.setNotifyReload(t.notifyReload)}setMainCanvas(t){super.setMainCanvas(t),this.canvas.width=(t==null?void 0:t.rect.width)||0,this.canvas.height=(t==null?void 0:t.rect.height)||0,this.groups.forEach(e=>{e.setMainCanvas(t),e.parent=this})}setNotifyReload(t){this.notifyReload=t?e=>{e&&(this.isRecalculate=!0),(e||this.shouldRender()&&this.groups.size)&&t()}:void 0,this.groups.forEach(e=>this.setGroupNotifyReload(e))}setGroupNotifyReload(t){t.setNotifyReload(this.notifyReload?()=>{var e;(e=this.notifyReload)==null||e.call(this),this.isReload=!0}:void 0)}getGroup(t){return this.groups.get(t)}addGroup(t){[t].flat().forEach(e=>{e instanceof et&&(this.setGroupNotifyReload(e),e.setMainCanvas(this.mainCanvas),e.parent=this,this.groups.set(e.name,e))})}removeGroup(t){var i;let e=!1;[t].flat().forEach(s=>{s instanceof et&&(this.groups.delete(s.name),s.setNotifyReload(),s.setMainCanvas(),s.parent=void 0,e=!0)}),e&&((i=this.notifyReload)==null||i.call(this))}clearGroup(){var t;this.groups.size&&(this.groups.forEach(e=>{e.setNotifyReload(),e.setMainCanvas(),e.parent=void 0}),this.groups.clear(),(t=this.notifyReload)==null||t.call(this))}setzIndex(t){var e;t!=this.zIndex&&(this.zIndex=t,(e=this.notifyReload)==null||e.call(this,!1))}getCanvas(){if(!this.mainCanvas)return;const{rect:t,isThemeUpdated:e}=this.mainCanvas,i=this.shouldRender(),s=this.groups.size;if(i&&s){if(this.isReload||this.isRecalculate||e){this.currentDrawOverlays=[],this.isReload=!1,this.canvas.width=t.width||0,this.canvas.height=t.height||0;const o=[];this.groups.forEach(a=>{a.equalsMainCanvas(this.mainCanvas)?o.push(...a.getOverlaysDrawingMethod()):this.groups.delete(a.name)}),o.sort((a,l)=>a[0]-l[0]),o.forEach(([a,[l,c]])=>{l.call(c,this.ctx),this.currentDrawOverlays.push([[Number(this.zIndex)||0,a],c])})}return[Number(this.zIndex)||0,this.canvas,this.currentDrawOverlays]}}}class Rt extends Nt{constructor(t){super(t);f(this,"layers",new Map);f(this,"defaultContextmenu",(t,e)=>t.stopPropagation());f(this,"defaultClick",(t,e)=>t.stopPropagation());f(this,"defaultDoubleClick",(t,e)=>t.stopPropagation());f(this,"defaultHover",(t,e)=>t.stopPropagation());f(this,"defaultDragg",(t,e)=>t.stopPropagation());f(this,"defaultDown",(t,e)=>t.stopPropagation());this.inheritOpacity=!1,this.setNotifyReload(t.notifyReload),this.addEventListener("contextmenu",this.defaultContextmenu),this.addEventListener("click",this.defaultClick),this.addEventListener("doubleClick",this.defaultDoubleClick),this.addEventListener("hover",this.defaultHover),this.addEventListener("dragg",this.defaultDragg),this.addEventListener("down",this.defaultDown)}setMainCanvas(t){super.setMainCanvas(t),this.layers.forEach(e=>{e.setMainCanvas(t),e.parent=this})}setNotifyReload(t){this.notifyReload=t?e=>{e&&(this.isRecalculate=!0),(e||this.shouldRender()&&this.layers.size)&&t()}:void 0,this.layers.forEach(e=>e.setNotifyReload(this.notifyReload))}getLayer(t){return this.layers.get(t)}addLayer(t){[t].flat().forEach(e=>{e instanceof it&&(e.setNotifyReload(this.notifyReload),e.setMainCanvas(this.mainCanvas),e.parent=this,this.layers.set(e.name,e))})}removeLayer(t){var i;let e=!1;[t].flat().forEach(s=>{s instanceof it&&(this.layers.delete(s.name),s.setNotifyReload(),s.setMainCanvas(),s.parent=void 0,e=!0)}),e&&((i=this.notifyReload)==null||i.call(this))}clearLayers(){var t;this.layers.size&&(this.layers.forEach(e=>{e.setNotifyReload(),e.setMainCanvas(),e.parent=void 0}),this.layers.clear(),(t=this.notifyReload)==null||t.call(this))}fetchCanvas(){if(this.shouldRender()&&this.layers.size){const t=[];return this.layers.forEach(e=>{if(e.equalsMainCanvas(this.mainCanvas)){const i=e.getCanvas();i&&t.push(i)}else this.layers.delete(e.name)}),t}return[]}}class Hs extends Is{getDefaultOverlayGroup(){var a,l,c,h,u;const n=this.layerGroups.get("默认图层群组");if(!n)return;const t=(a=n.getLayer("点位图层"))==null?void 0:a.getGroup("点位覆盖物群组"),e=(l=n.getLayer("线段图层"))==null?void 0:l.getGroup("线段覆盖物群组"),i=(c=n.getLayer("多边形图层"))==null?void 0:c.getGroup("多边形覆盖物群组"),s=(h=n.getLayer("文字图层"))==null?void 0:h.getGroup("文字覆盖物群组"),o=(u=n.getLayer("自定义绘制图层"))==null?void 0:u.getGroup("自定义绘制覆盖物群组");return{overlays_text:s,overlays_point:t,overlays_line:e,overlays_polygon:i,overlays_custom:o}}getAllOverlays(n){const t=[],e=n!==void 0?Array.isArray(n)?[...n]:[n]:Array.from(this.layerGroups.values());for(;e.length>0;){const i=e.pop();if(i instanceof Rt){if(!i.isVisible)continue;e.push(...i.layers.values())}else if(i instanceof it){if(!i.isVisible)continue;e.push(...i.groups.values())}else if(i instanceof et){if(!i.isVisible)continue;e.push(...i.overlays.values())}else i.isVisible&&t.push(i)}return t}}class Ls extends Hs{zoom(n){const{canvas:t,rect:e}=this;if(!t||!e)return console.error("canvas is not HTMLCanvasElement");this.setScale("center",n),this.redrawOnce()}zoomIn(){this.zoom(this.delta)}zoomOut(){this.zoom(-this.delta)}setStyle(n){super.setStyle(n),this.redrawOnce()}setTheme(n){super.setTheme(n),this.redrawOnce()}setAxis(n){super.setAxis(n),this.redrawOnce()}setDefaultCenter(n){super.setDefaultCenter(n),this.redrawOnce()}}class Ts extends Ls{setFitView(n=void 0,t=!1,e=[60,60,60,60],i){const s=this.getAllOverlays(n);if(s.length===0)return;const{minX:o,maxX:a,minY:l,maxY:c}=this.calculateBoundingBox(s),h=a-o,u=c-l,d=this.calculateOptimalScale(h,u,e,i),m=this.calculateOffsetDifference(o,a,l,c,e);d==this.scale&&m.x==0&&m.y==0||(t?this.applyTransformImmediately(d,m):this.animateTransform(d,m))}calculateBoundingBox(n){let t=1/0,e=-1/0,i=1/0,s=-1/0;for(const o of n){const a=o.valueScope;t=Math.min(t,a.minX),e=Math.max(e,a.maxX),i=Math.min(i,a.minY),s=Math.max(s,a.maxY)}return{minX:t,maxX:e,minY:i,maxY:s}}calculateOptimalScale(n,t,e,i){const{cycle:s,delta:o,axisConfig:a,rect:l}=this,{width:c,height:h}=l,u=Math.max(0,c-e[1]-e[3])||c,d=Math.max(0,h-e[0]-e[2])||h;if(u<=0||d<=0)return console.warn("无效的可视区域尺寸,边距设置可能不合理"),this.scale;const m=n/u,g=t/d,p=Math.max(m,g),v=a.count,w=v/a.min,_=s*o;let C;if(p>w){const E=Math.ceil(p/w);C=1-((v*E/p-a.min)/a.min+(E-2))*_}else{const E=(dt,rt,vt)=>dt<rt?vt-1:E(dt/2,rt,vt+1),N=E(w,p,0),G=Math.pow(2,N);C=1+((v/G/p-a.min)/a.min+N)*_}return i!==void 0&&(C=Math.min(i,C)),C=new V(C).div(o).round().mul(o).toNumber(),C}calculateOffsetDifference(n,t,e,i,s){const{width:o,height:a}=this.rect,{axisConfig:l,center:c}=this,h=(t+n)/2,u=(i+e)/2,d=this.getAxisPointByValue(h,u),m=this.getAxisValueByPoint((o/2-c.x)*l.x,(a/2-c.y)*l.y),g=this.getAxisPointByValue(m.xV,m.yV);return{x:Math.round(-(d.x+(s[3]-s[1])-g.x)*l.x),y:Math.round(-(d.y+(s[0]-s[2])-g.y)*l.y)}}applyTransformImmediately(n,t){this.offset={x:this.offset.x+t.x,y:this.offset.y+t.y},this.scale=n,this.updateSize(),this.redrawOnce()}animateTransform(n,t){const e=this.scale,i={...this.offset},s=300;this.isAuto=!0;const o=()=>this.isAuto=!1;(c=>this.animateOffset(i,t,s,c||o))(c=>this.animateScale(e,n,s,c||o))}animateScale(n,t,e,i){const s=t-n;let o=0;kt(a=>{!this.isAuto||!this.canvas||!this.isInteractive||(this.setScale("center",(a-o)*s),o=a,this.redrawOnce(),a===1&&i())},e)}animateOffset(n,t,e,i){kt(s=>{!this.isAuto||!this.canvas||!this.isInteractive||(this.offset={x:Number((n.x+t.x*s).toFixed(0)),y:Number((n.y+t.y*s).toFixed(0))},this.redrawOnce(),s===1&&i())},e)}returnToOrigin(){if(!this.isInteractive||this.scale==this.defaultScale&&this.offset.x==0&&this.offset.y==0)return;const{rect:n,axisConfig:t}=this,e=this.getDefaultCenterLocation(),i=(n.width/2-e.x)*t.x,s=(n.height/2-e.y)*t.y,o=this.getAxisValueByPoint(i,s,!0),a=this.getMousePositionOnAxis({clientX:n.x+n.width/2,clientY:n.y+n.height/2}),l=this.getAxisValueByPoint(a.x,a.y),c=t.size/this.getNowGridCount,h=Math.round((l.xV-o.xV)*t.x*c),u=Math.round((l.yV-o.yV)*t.y*c);h==0&&u==0||this.animateTransform(this.defaultScale,{x:h,y:u})}}class Fs extends Ts{toggleAxis(n){this.drawAxis.toggleAxis(n),this.redrawOnce()}togglePoint(n){const{overlays_point:t}=this.getDefaultOverlayGroup()||{};return t?(t.isVisible=n??!t.isVisible,this.redrawOnce(),t.isVisible):!1}toggleLine(n){const{overlays_line:t}=this.getDefaultOverlayGroup()||{};return t?(t.isVisible=n??!t.isVisible,this.redrawOnce(),t.isVisible):!1}togglePolygon(n){const{overlays_polygon:t}=this.getDefaultOverlayGroup()||{};return t?(t.isVisible=n??!t.isVisible,this.redrawOnce(),t.isVisible):!1}toggleLock(n){return this.isInteractive=n??!this.isInteractive,this.isInteractive}}class Bs extends Fs{static clearPathRegion(n,t){const{width:e,height:i}=n.canvas;n.save(),n.beginPath(),n.clip(t),n.clearRect(0,0,e,i),n.restore()}}class Us extends Bs{}class Gs{constructor(n){f(this,"canvas");f(this,"axis_canvas",document.createElement("canvas"));f(this,"ctx",this.axis_canvas.getContext("2d"));f(this,"isReload",!0);f(this,"show",{all:!0,grid:{main:!0,secondary:!0},axis:!0,axisText:!0});this.canvas=n,this.initAxisCanvas()}initAxisCanvas(){const{canvas:n,axis_canvas:t}=this;n&&(t.width=n.rect.width||0,t.height=n.rect.height||0)}toggleAxis(n){const t=(()=>{if(typeof n=="object"){const{all:e=!0,axis:i=!0,axisText:s=!0}=n,o=Object.assign({main:!0,secondary:!0},n.grid);return{all:e,grid:o,axis:i,axisText:s}}return typeof n=="boolean"?{all:!0,grid:{main:n,secondary:n},axis:n,axisText:n}:!this.show.all})();typeof t=="boolean"?this.show.all=t:this.show=t,this.isReload=!0}drawAxisAndGrid(){if(!(!this.canvas||!this.show.all))return(this.canvas.isRecalculate||this.isReload||this.canvas.isThemeUpdated)&&(this.isReload=!1,this.initAxisCanvas(),(this.show.grid.main||this.show.grid.secondary)&&this.drawGrid(),this.show.axis&&this.drawAxis(),this.show.axisText&&this.drawAxisText()),this.axis_canvas}color(){const{theme:n,style:t}=this.canvas;return(t[n]||t.light).grid}drawGrid(){const{canvas:n,ctx:t}=this,{rect:e,center:i,axisConfig:s}=n,{width:o,height:a}=e,l=this.color(),c=s.size,h=c/5;t.lineWidth=1;const u=(m,g)=>{const p=i.x%m>0?i.x%m:m+i.x%m;t.strokeStyle=g,t.beginPath();for(let v=0;v*m+p<=o;v++)t.moveTo(v*m+p,0),t.lineTo(v*m+p,a);t.stroke()},d=(m,g)=>{const p=i.y%m>0?i.y%m:m+i.y%m;t.strokeStyle=g,t.beginPath();for(let v=0;v*m+p<=a;v++)t.moveTo(0,v*m+p),t.lineTo(o,v*m+p);t.stroke()};this.show.grid.secondary&&(u(h,l.innerGrid),d(h,l.innerGrid)),this.show.grid.main&&(u(c,l.grid),d(c,l.grid))}drawAxis(){const{canvas:n,ctx:t}=this,{rect:e,center:i}=n,{width:s,height:o}=e,a=this.color();t.lineWidth=2,t.strokeStyle=a.axis;const l=()=>{i.y>=0&&i.y<=o&&(t.beginPath(),t.moveTo(0,i.y),t.lineTo(s,i.y),t.stroke())},c=()=>{i.x>=0&&i.x<=s&&(t.beginPath(),t.moveTo(i.x,0),t.lineTo(i.x,o),t.stroke())};l(),c()}drawText(n,t,e,i){const{canvas:s,ctx:o}=this,{theme:a}=s,l=this.canvas.style[a].text;o.font=`${l.bold?"bold":""} ${l.size}px ${l.family}`,o.strokeStyle=l.stroke,![n,t,e].includes(void 0)&&o.strokeText(n,t,e),o.fillStyle=l[i?"secondary":"color"],![n,t,e].includes(void 0)&&o.fillText(n,t,e)}drawAxisText(){const{canvas:n,ctx:t}=this,{rect:e,center:i,axisConfig:s,style:o,theme:a}=n,{width:l,height:c}=e;this.drawText();const h=p=>Math.ceil(t.measureText(p).width),u=4,d=o[a].text.size;{const p=h("0"),v=i.x<u||i.x>l+p+u,w=i.y<-(u+d)||i.y>c+d+u;!v&&!w&&this.drawText("0",i.x-p-u,i.y+d+u)}const m=n.getNowGridCount,g=s.size;{let p=i.y+d+u;p=Math.max(Math.min(p,c-u),u+d);const v=i.y>c||i.y<0;let w=i.x>0?i.x%g:i.x<0?g+i.x%g:0,_=n.getAxisValueByPoint((w-i.x)*s.x,0).xV;for(;w<=l;){const C=Wt(_),E=h(C);_!==0&&this.drawText(C,w-E/2,p,v),w+=g,_=new V(m).mul(s.x).add(_).toNumber()}}{const p=i.x>l||i.x<0;let v=i.y>0?i.y%g:i.y<0?g+i.y%g:0,w=n.getAxisValueByPoint(0,(v-i.y)*s.y).yV;for(;v<=c;){const _=Wt(w),C=h(_);let E=i.x-C-u;E=Math.max(Math.min(E,l-C-u),u),w!=0&&this.drawText(_,E,v+d/2,p),v+=g,w=new V(m).mul(s.y).add(w).toNumber()}}}}function Tt(r){return[r].flat(1/0)}class Y extends Us{constructor(n){super(n),this.drawAxis=new Gs(this),"axisShow"in n&&this.toggleAxis(n.axisShow),this.initLayerGroups(),this.updateCenter()}initLayerGroups(){const n=new it({name:"多边形图层"});n.addGroup(new et({name:"多边形覆盖物群组"})),n.setzIndex(1);const t=new it({name:"线段图层"});t.addGroup(new et({name:"线段覆盖物群组"})),t.setzIndex(2);const e=new it({name:"点位图层"});e.addGroup(new et({name:"点位覆盖物群组"})),e.setzIndex(3);const i=new it({name:"文字图层"});i.addGroup(new et({name:"文字覆盖物群组"})),i.setzIndex(4);const s=new it({name:"自定义绘制图层"});s.addGroup(new et({name:"自定义绘制覆盖物群组"})),s.setzIndex(5);const o=new Rt({name:"默认图层群组"});o.addLayer([i,e,t,n,s]),this.setLayerGroup(o)}gteLayerGroups(n="默认图层群组"){return this.layerGroups.get(n)}setLayerGroup(n){n instanceof Rt&&(this.layerGroups.set(n.name,n),n.setNotifyReload(()=>this.redrawOnce()),n.setMainCanvas(this),n.parent=this)}removeLayerGroup(n){n instanceof Rt&&(this.layerGroups.delete(n.name),n.setNotifyReload(),n.setMainCanvas(),n.parent=void 0,this.redrawOnce())}addLayer(n){const t=this.layerGroups.get("默认图层群组");t&&t.addLayer(Tt(n))}removeLayer(n){const t=this.layerGroups.get("默认图层群组");t&&t.removeLayer(Tt(n))}addOverlay(n){const{overlays_text:t,overlays_point:e,overlays_line:i,overlays_polygon:s,overlays_custom:o}=this.getDefaultOverlayGroup()||{};Tt(n).forEach(a=>{a instanceof Xt?t==null||t.addOverlays(a):a instanceof lt?e==null||e.addOverlays(a):a instanceof Yt||a instanceof pe||a instanceof ge?i==null||i.addOverlays(a):a instanceof zt?s==null||s.addOverlays(a):a instanceof Gt&&(o==null||o.addOverlays(a))})}removeOverlay(n){const{overlays_text:t,overlays_point:e,overlays_line:i,overlays_polygon:s,overlays_custom:o}=this.getDefaultOverlayGroup()||{};Tt(n).forEach(a=>{a instanceof Xt?t==null||t.removeOverlays(a):a instanceof lt?e==null||e.removeOverlays(a):a instanceof Yt?i==null||i.removeOverlays(a):a instanceof zt?s==null||s.removeOverlays(a):a instanceof Gt&&(o==null||o.addOverlays(a))})}destroy(){super.destroy()}}f(Y,"LayerGroup",Rt),f(Y,"Layer",it),f(Y,"OverlayGroup",et),f(Y,"Text",Xt),f(Y,"Point",lt),f(Y,"Line",Yt),f(Y,"Polygon",zt),f(Y,"Custom",Gt),f(Y,"Arc",pe),f(Y,"ArcTo",ge);function Xs(r){const n=we(r,100);let t=0,e=0;return function(i){const s=i.target;if(!s||!(s instanceof Element))return;const{scrollTop:o,scrollHeight:a,clientHeight:l,scrollLeft:c,scrollWidth:h,clientWidth:u}=s;function d(){if(t==o)return;const g=t>o;if(t=o,g)return;a-o-l<=1&&n("vertical")}function m(){if(e==c)return;const g=e>c;if(e=c,g)return;h-c-u<=1&&n("horizontal")}d(),m()}}function Ys(r,n,t){const{isClickAllowed:e,uiLibrary:i=["naiveUI","ElementPlus","Element"]}=t||{},s=function(l){const c=[];for(const h in l)Object.hasOwnProperty.call(l,h)&&i.includes(h)&&c.push(...l[h]);return c}({naiveUI:[".v-binder-follower-container",".n-image-preview-container",".n-modal-container"],ElementPlus:[".el-popper"],Element:[".el-popper"]});function o(){n(),document.removeEventListener("mousedown",a)}function a(l){if(e){const u=e(l);if(u)return;if(u===!1)return o()}const c=l.target;if(!(c instanceof Element)||!c.isConnected)return;r.concat(s).some(u=>!!(c!=null&&c.closest(u)))||o()}requestAnimationFrame(()=>document.addEventListener("mousedown",a))}var z,ft,mt,Pt,xt,Z,Q,st,bt;class zs{constructor(){A(this,z);A(this,ft,!1);A(this,mt,{});A(this,Pt,0);A(this,xt,0);A(this,Z,0);A(this,Q,0);A(this,st);A(this,bt)}init(n,t){D(this,z,n),D(this,st,t==null?void 0:t.limit),D(this,bt,t==null?void 0:t.dragDom),D(this,mt,{mousedown:this.mousedown.bind(this),mousemove:this.mousemove.bind(this),mouseup:this.mouseup.bind(this)}),this.bindOrUnbindEvent("bind")}finish(){this.bindOrUnbindEvent("unbind")}bindOrUnbindEvent(n){const t=n==="bind"?"addEventListener":"removeEventListener";if(!P(this,z))return console.error("No DOM");P(this,z)[t]("mousedown",P(this,mt).mousedown),document[t]("mousemove",P(this,mt).mousemove),document[t]("mouseup",P(this,mt).mouseup)}alterLocation(){if(!P(this,z))return console.error("No DOM");P(this,st)&&(D(this,Z,Math.min(P(this,Z),P(this,st).max.top)),D(this,Z,Math.max(P(this,Z),P(this,st).min.top)),D(this,Q,Math.min(P(this,Q),P(this,st).max.left)),D(this,Q,Math.max(P(this,Q),P(this,st).min.left))),P(this,z).style.setProperty("--top",P(this,Z)+"px"),P(this,z).style.setProperty("--left",P(this,Q)+"px")}mousedown(n){if(!P(this,z))return console.error("No DOM");if(P(this,bt)&&n.target!=P(this,bt))return;document.body.classList.add("no-select"),D(this,ft,!0);const t=P(this,z).getBoundingClientRect(),{pageX:e,pageY:i}=n;D(this,Pt,e),D(this,xt,i),D(this,Z,t.y),D(this,Q,t.x)}mousemove(n){const{pageX:t,pageY:e}=n;P(this,ft)&&(D(this,Z,P(this,Z)+(e-P(this,xt))),D(this,Q,P(this,Q)+(t-P(this,Pt))),D(this,Pt,t),D(this,xt,e),this.alterLocation())}mouseup(){P(this,ft)&&(D(this,ft,!1),document.body.classList.remove("no-select"))}}z=new WeakMap,ft=new WeakMap,mt=new WeakMap,Pt=new WeakMap,xt=new WeakMap,Z=new WeakMap,Q=new WeakMap,st=new WeakMap,bt=new WeakMap;var W,pt,gt,_t,Ct,j,q,B,St,Et;class Ws{constructor(){A(this,W);A(this,pt,!1);A(this,gt,{});A(this,_t,0);A(this,Ct,0);A(this,j,0);A(this,q,0);A(this,B);A(this,St);A(this,Et)}init(n,t={}){D(this,W,n),D(this,B,t.limit),D(this,St,t.update_move),D(this,Et,t.update_up),D(this,gt,{mousedown:this.mousedown.bind(this),mousemove:this.mousemove.bind(this),mouseup:this.mouseup.bind(this)}),this.bindOrUnbindEvent("bind")}finish(){this.bindOrUnbindEvent("unbind")}bindOrUnbindEvent(n){const t=n==="bind"?"addEventListener":"removeEventListener";if(!P(this,W))return console.error("No DOM");P(this,W)[t]("mousedown",P(this,gt).mousedown),document[t]("mousemove",P(this,gt).mousemove),document[t]("mouseup",P(this,gt).mouseup)}updateValue(){const n={top:P(this,j),left:P(this,q),percentage:{top:0,left:0}};if(P(this,B)){const t=e=>P(this,B)?(n[e]-P(this,B).min[e])/(P(this,B).max[e]-P(this,B).min[e]):0;n.percentage={top:t("top")||0,left:t("left")||0}}return n}alterLocation(){if(!P(this,W))return console.error("No DOM");P(this,B)&&(D(this,j,Math.min(P(this,j),P(this,B).max.top)),D(this,j,Math.max(P(this,j),P(this,B).min.top)),D(this,q,Math.min(P(this,q),P(this,B).max.left)),D(this,q,Math.max(P(this,q),P(this,B).min.left))),P(this,St)&&P(this,St).call(this,this.updateValue()),P(this,W).style.setProperty("--top",P(this,j)+"px"),P(this,W).style.setProperty("--left",P(this,q)+"px")}mousedown(n){if(!P(this,W))return console.error("No DOM");document.body.classList.add("no-select"),D(this,pt,!0);const t=P(this,W).getBoundingClientRect();D(this,Ct,t.y),D(this,_t,t.x);const{pageX:e,pageY:i}=n;D(this,j,i-P(this,Ct)),D(this,q,e-P(this,_t)),this.alterLocation()}mousemove(n){const{pageX:t,pageY:e}=n;P(this,pt)&&(D(this,j,e-P(this,Ct)),D(this,q,t-P(this,_t)),this.alterLocation())}mouseup(){P(this,pt)&&(D(this,pt,!1),document.body.classList.remove("no-select"),P(this,Et)&&P(this,Et).call(this,this.updateValue()))}}W=new WeakMap,pt=new WeakMap,gt=new WeakMap,_t=new WeakMap,Ct=new WeakMap,j=new WeakMap,q=new WeakMap,B=new WeakMap,St=new WeakMap,Et=new WeakMap;function re(r){if(typeof r=="string"){const n=document.querySelector(r);if(n)return n;console.error(`Element "${r}" not found`)}else return r||document.documentElement}function $e(r){const n=re(r);return n?n.requestFullscreen?n.requestFullscreen():n.mozRequestFullScreen?n.mozRequestFullScreen():n.webkitRequestFullscreen?n.webkitRequestFullscreen():n.msRequestFullscreen?n.msRequestFullscreen():Promise.reject("No Fullscreen API"):Promise.reject("No Element")}function Ze(){const r=document;return document.exitFullscreen?document.exitFullscreen():r.mozCancelFullScreen?r.mozCancelFullScreen():r.webkitExitFullscreen?r.webkitExitFullscreen():r.msExitFullscreen?r.msExitFullscreen():Promise.reject("No ExitFullscreen API")}function xe(r){const n=re(r),t=document,e=document.fullscreenElement||t.webkitFullscreenElement||t.mozFullScreenElement||t.msFullscreenElement;return n==e||!r&&window.innerWidth==screen.width&&window.innerHeight==screen.height}function js(r){if(r=re(r),!!r)return function(){xe(r)?Ze():$e(r)}}function qs(r,n){const t=re(n);if(!t)return;const e=()=>{r(xe(t))};return document.addEventListener("fullscreenchange",e),document.addEventListener("webkitfullscreenchange",e),document.addEventListener("mozfullscreenchange",e),document.addEventListener("MSFullscreenChange",e),e(),()=>{document.removeEventListener("fullscreenchange",e),document.removeEventListener("webkitfullscreenchange",e),document.removeEventListener("mozfullscreenchange",e),document.removeEventListener("MSFullscreenChange",e)}}function $s(r,n){if(typeof r=="number")return r;if(/px/.test(r))return Number(r.replace(/px/,""))||0;const t=document.createElement("div");t.style.width=r,n=n||document.body,n.appendChild(t);const e=t.getBoundingClientRect().width;return n.removeChild(t),e}function Zs(r,n){if(!r)return;let t,e;if(typeof n=="string"){const s=document.querySelector(n);if(!s)return;const o=s.getBoundingClientRect();t=o.width,e=o.height}else if(Array.isArray(n))t=n[0],e=n[1];else{const s=n.getBoundingClientRect();t=s.width,e=s.height}const i=t/e;return i>r?[r*e,e]:i<r?[t,t/r]:[t,e]}function Qs(r,n=5e3){return new Promise((t,e)=>{const i=new Image;i.src=r;const s=setTimeout(()=>{e(new Error("图片加载超时")),i.onload=null,i.onerror=null},n);i.onload=()=>{clearTimeout(s);const o=i.naturalWidth,a=i.naturalHeight,l=o/a;t([i,l])},i.onerror=()=>{clearTimeout(s),e(new Error("图片加载失败"))},i.crossOrigin="Anonymous"})}function Js(r){const t=document.getElementById(r).querySelectorAll("img"),e=t.length,i=[];let s=0;return e===0?Promise.resolve({allLoaded:!0,loaded:0,failed:0,total:0,errors:[]}):new Promise(o=>{const a=()=>{s===e&&o({allLoaded:i.length===0,loaded:e-i.length,failed:i.length,total:e,errors:i})};t.forEach(l=>{if(l.complete){l.naturalWidth===0&&i.push(l),s++,a();return}l.addEventListener("load",()=>{s++,a()},{once:!0}),l.addEventListener("error",()=>{i.push(l),s++,a()},{once:!0})})})}function Ks(r){return new Promise((n,t)=>{fetch(r).then(e=>n(e.text())).catch(e=>{console.error("Error fetching :",e),t(e)})})}function Qe(r){const{href:n,fileName:t,onProgress:e,timeout:i=3e4,autoDownload:s=!0}=r;let o,a=!1,l=null,c;const h=t||jt(n,"downloaded_file");c=decodeURIComponent(h);const u=()=>{if(!l)return;const p=URL.createObjectURL(l),v=document.createElement("a");v.href=p,v.download=c,v.click(),URL.revokeObjectURL(p)};return{promise:new Promise((p,v)=>{try{o=new XMLHttpRequest,o.open("GET",n),o.responseType="blob",o.timeout=i,o.ontimeout=()=>{a||v(new Error(`请求超时(已超过${i/1e3}秒)`))},o.addEventListener("progress",w=>{if(w.lengthComputable&&!a){const _=w.loaded/w.total*100;e==null||e(Number(_.toFixed(2)))}}),o.addEventListener("load",()=>{a||(o.status>=200&&o.status<300?(l=o.response,s&&u(),p(o.response)):v(new Error(`下载失败,状态码: ${o.status}`)))}),o.addEventListener("error",()=>{a||v(new Error("网络错误,下载失败"))}),o.addEventListener("abort",()=>{a||(a=!0,v(new Error("下载已被中止")))}),o.send()}catch(w){a||v(w)}}),abort:()=>!a&&o.abort(),download:()=>{!a&&l&&u()}}}function tn(r,n,t){if(!t){let s=n.replace(/^[^.]+./,"");s=s==n?"text/plain":"application/"+s,t={type:s}}const e=new Blob(r,t),i=URL.createObjectURL(e);Qe({href:i,fileName:n})}const en=Math.PI/2,Kt=Math.PI/180,te=6378137,sn=85.05112878;function nn(r,n){const t=Math.max(Math.min(r,180),-180),e=Math.max(Math.min(n,sn),-85.05112878),i=t*Kt*te,s=e*Kt,o=Math.log(Math.tan(Math.PI/4+s/2))*te;return[i,o]}function rn(r,n){const t=r/te/Kt,e=(2*Math.atan(Math.exp(n/te))-en)/Kt;return[t,e]}function Je(r,n,t){const[e,i]=r,[s,o]=n,[a,l]=t,c=(a-s)**2+(l-o)**2;if(c===0)return Math.sqrt((e-s)**2+(i-o)**2);let h=((e-s)*(a-s)+(i-o)*(l-o))/c;return h=Math.max(0,Math.min(1,h)),Math.sqrt((e-(s+h*(a-s)))**2+(i-(o+h*(l-o)))**2)}function on(r,n,t,e,i,s=1,o=1){const a=r+t*Math.cos(e)*s,l=n+t*Math.sin(e)*o,c=r+t*Math.cos(i)*s,h=n+t*Math.sin(i)*o;return[[a,l],[c,h]]}function ye(r,n,t,e){return Math.hypot(Math.abs(t-r),Math.abs(e-n))}function be(r,n,t,e){const i=(r+t)/2,s=(n+e)/2;return{x:i,y:s}}function an(r,n,t,e){const[i,s]=r,[o,a]=n;let l=1/0;if(o!==0){const c=o>0?(t-i)/o:-i/o;c>0&&(l=Math.min(l,c))}if(a!==0){const c=a>0?(e-s)/a:-s/a;c>0&&(l=Math.min(l,c))}return l===1/0?r:[i+o*l,s+a*l]}const ln=new Set(["sin","cos","tan","asin","acos","atan","atan2"]),cn=new Proxy(Math,{get(r,n){return ln.has(n)?function(...t){const e=t.map(i=>i/180*Math.PI);return r[n](...e)}:r[n]},set(){throw new Error("DegreeMath 是只读的,不能修改属性")},deleteProperty(){throw new Error("DegreeMath 是只读的,不能删除属性")}});class wt{constructor(n,t){f(this,"resolve");f(this,"reject");this.resolve=n,this.reject=t}run(n){var t,e;return n instanceof Promise?n.then(i=>{var s;return(s=this.resolve)==null||s.call(this),i}).catch(i=>{var s;return(s=this.reject)==null||s.call(this),Promise.reject(i)}):n?(t=this.resolve)==null||t.call(this):(e=this.reject)==null||e.call(this),n}}class hn extends wt{constructor(n){super(),this.resolve=n}warning(...n){const t=()=>{var e,i;return(i=(e=yt.tips).warning)==null?void 0:i.call(e,...n)};return new wt(this.resolve,t)}error(...n){const t=()=>{var e,i;return(i=(e=yt.tips).error)==null?void 0:i.call(e,...n)};return new wt(this.resolve,t)}}class un extends wt{constructor(n){super(),this.reject=n}info(...n){const t=()=>{var e,i;return(i=(e=yt.tips).info)==null?void 0:i.call(e,...n)};return new wt(t,this.reject)}success(...n){const t=()=>{var e,i;return(i=(e=yt.tips).success)==null?void 0:i.call(e,...n)};return new wt(t,this.reject)}}const F=class F{constructor(){if(new.target===F)throw new Error("请直接使用静态方法,而不是实例化此类")}static register(n,t){if(typeof t!="function")return console.error("TipHandler must be a function");F.tips[n]=t}static resolveTip(n){return function(...t){const e=()=>{var i,s;return(s=(i=F.tips)[n])==null?void 0:s.call(i,...t)};return new hn(e)}}static rejectTip(n){return function(...t){const e=()=>{var i,s;return(s=(i=F.tips)[n])==null?void 0:s.call(i,...t)};return new un(e)}}};f(F,"tips",{info:void 0,success:void 0,warning:void 0,error:void 0}),f(F,"info",F.resolveTip("info")),f(F,"success",F.resolveTip("success")),f(F,"warning",F.rejectTip("warning")),f(F,"error",F.rejectTip("error"));let yt=F;exports.EXTENSION_TO_MIME=Re;exports.FILE_EXTENSIONS=Ft;exports.PAPER_SIZE_DEFINITIONS=ve;exports.PAPER_SIZE_OPTIONS=ii;exports.UNIT_LABELS=le;exports.WINDOW_TARGET=ei;exports._Animate_CreateOscillator=si;exports._Animate_NumericTransition=ni;exports._Animate_Schedule=kt;exports._Blob_ConvertDataToImageUrl=ri;exports._Browser_CalculatePrintableArea=ki;exports._Browser_CopyToClipboard=Ri;exports._Browser_GetFrameRate=Vi;exports._Browser_SameOriginTabManager=Vt;exports._Canvas=Y;exports._Element_CalculateCanvasSize=Zs;exports._Element_CheckImagesLoaded=Js;exports._Element_CloseOnOutsideClick=Ys;exports._Element_Drag=zs;exports._Element_EnterFullscreen=$e;exports._Element_ExitFullscreen=Ze;exports._Element_Fullscreen=js;exports._Element_FullscreenObserver=qs;exports._Element_GetOtherSizeInPixels=$s;exports._Element_IsFullscreen=xe;exports._Element_LoadImage=Qs;exports._Element_LocalDrag=Ws;exports._Element_ScrollEndListener=Xs;exports._File_CreateAndDownload=tn;exports._File_Download=Qe;exports._File_Read=Ks;exports._Format_CamelCase=ui;exports._Format_CapitalizeFirstLetter=oi;exports._Format_ChunkArray=pi;exports._Format_ExcludeSubstring=di;exports._Format_FileSize=ci;exports._Format_HrefName=jt;exports._Format_MillisecondToReadable=mi;exports._Format_NumberWithCommas=Wt;exports._Format_NumberWithUnit=li;exports._Format_Percentage=ai;exports._Format_Timestamp=hi;exports._Format_ToggleInvisibleChars=fi;exports._Math_CalculateDistance2D=ye;exports._Math_Degree=cn;exports._Math_GetArcPoints=on;exports._Math_GetBoundaryIntersection=an;exports._Math_GetMidpoint=be;exports._Math_LngLatToPlane=nn;exports._Math_PlaneToLngLat=rn;exports._Math_PointToLineDistance=Je;exports._Tip=yt;exports._Utility_Clone=Ie;exports._Utility_Debounce=we;exports._Utility_ExecuteWhenIdle=bi;exports._Utility_GenerateUUID=$t;exports._Utility_GetTargetByPath=Ci;exports._Utility_MergeObjects=ct;exports._Utility_RotateList=Ei;exports._Utility_SetTargetByPath=Si;exports._Utility_Sleep=Di;exports._Utility_Throttle=_i;exports._Utility_TimeConsumption=He;exports._Utility_WaitForCondition=Ae;exports._Valid_CheckConnectionWithXHR=Pi;exports._Valid_DataType=qt;exports._Valid_DoesInfiniteLineIntersectRectangle=vi;exports._Valid_FileTypeChecker=ce;exports._Valid_Is2DNumberArray=Mt;exports._Valid_IsInMargin=gi;exports._Valid_IsNumberArray=ee;exports._Valid_IsPointInPolygon=yi;exports._Valid_IsSecureContext=wi;
|
|
9
|
+
*/var he=9e15,ut=1e9,ue="0123456789abcdef",Zt="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",Qt="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",de={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-9e15,maxE:he,crypto:!1},Fe,nt,S=!0,ie="[DecimalError] ",ht=ie+"Invalid argument: ",Be=ie+"Precision limit exceeded",Ue=ie+"crypto unavailable",Ge="[object Decimal]",F=Math.floor,N=Math.pow,ki=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,Oi=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,Ai=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,Xe=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,$=1e7,_=7,Ii=9007199254740991,Ti=Zt.length-1,fe=Qt.length-1,v={toStringTag:Ge};v.absoluteValue=v.abs=function(){var r=new this.constructor(this);return r.s<0&&(r.s=1),P(r)};v.ceil=function(){return P(new this.constructor(this),this.e+1,2)};v.clampedTo=v.clamp=function(r,s){var t,e=this,i=e.constructor;if(r=new i(r),s=new i(s),!r.s||!s.s)return new i(NaN);if(r.gt(s))throw Error(ht+s);return t=e.cmp(r),t<0?r:e.cmp(s)>0?s:new i(e)};v.comparedTo=v.cmp=function(r){var s,t,e,i,n=this,o=n.d,a=(r=new n.constructor(r)).d,l=n.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(n.e!==r.e)return n.e>r.e^l<0?1:-1;for(e=o.length,i=a.length,s=0,t=e<i?e:i;s<t;++s)if(o[s]!==a[s])return o[s]>a[s]^l<0?1:-1;return e===i?0:e>i^l<0?1:-1};v.cosine=v.cos=function(){var r,s,t=this,e=t.constructor;return t.d?t.d[0]?(r=e.precision,s=e.rounding,e.precision=r+Math.max(t.e,t.sd())+_,e.rounding=1,t=Ni(e,qe(e,t)),e.precision=r,e.rounding=s,P(nt==2||nt==3?t.neg():t,r,s,!0)):new e(1):new e(NaN)};v.cubeRoot=v.cbrt=function(){var r,s,t,e,i,n,o,a,l,c,h=this,u=h.constructor;if(!h.isFinite()||h.isZero())return new u(h);for(S=!1,n=h.s*N(h.s*h,1/3),!n||Math.abs(n)==1/0?(t=L(h.d),r=h.e,(n=(r-t.length+1)%3)&&(t+=n==1||n==-2?"0":"00"),n=N(t,1/3),r=F((r+1)/3)-(r%3==(r<0?-1:2)),n==1/0?t="5e"+r:(t=n.toExponential(),t=t.slice(0,t.indexOf("e")+1)+r),e=new u(t),e.s=h.s):e=new u(n.toString()),o=(r=u.precision)+3;;)if(a=e,l=a.times(a).times(a),c=l.plus(h),e=R(c.plus(h).times(a),c.plus(l),o+2,1),L(a.d).slice(0,o)===(t=L(e.d)).slice(0,o))if(t=t.slice(o-3,o+1),t=="9999"||!i&&t=="4999"){if(!i&&(P(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")&&(P(e,r+1,1),s=!e.times(e).times(e).eq(h));break}return S=!0,P(e,r,u.rounding,s)};v.decimalPlaces=v.dp=function(){var r,s=this.d,t=NaN;if(s){if(r=s.length-1,t=(r-F(this.e/_))*_,r=s[r],r)for(;r%10==0;r/=10)t--;t<0&&(t=0)}return t};v.dividedBy=v.div=function(r){return R(this,new this.constructor(r))};v.dividedToIntegerBy=v.divToInt=function(r){var s=this,t=s.constructor;return P(R(s,new t(r),0,1,1),t.precision,t.rounding)};v.equals=v.eq=function(r){return this.cmp(r)===0};v.floor=function(){return P(new this.constructor(this),this.e+1,3)};v.greaterThan=v.gt=function(r){return this.cmp(r)>0};v.greaterThanOrEqualTo=v.gte=function(r){var s=this.cmp(r);return s==1||s===0};v.hyperbolicCosine=v.cosh=function(){var r,s,t,e,i,n=this,o=n.constructor,a=new o(1);if(!n.isFinite())return new o(n.s?1/0:NaN);if(n.isZero())return a;t=o.precision,e=o.rounding,o.precision=t+Math.max(n.e,n.sd())+4,o.rounding=1,i=n.d.length,i<32?(r=Math.ceil(i/3),s=(1/ne(4,r)).toString()):(r=16,s="2.3283064365386962890625e-10"),n=Et(o,1,n.times(s),new o(1),!0);for(var l,c=r,h=new o(8);c--;)l=n.times(n),n=a.minus(l.times(h.minus(l.times(h))));return P(n,o.precision=t,o.rounding=e,!0)};v.hyperbolicSine=v.sinh=function(){var r,s,t,e,i=this,n=i.constructor;if(!i.isFinite()||i.isZero())return new n(i);if(s=n.precision,t=n.rounding,n.precision=s+Math.max(i.e,i.sd())+4,n.rounding=1,e=i.d.length,e<3)i=Et(n,2,i,i,!0);else{r=1.4*Math.sqrt(e),r=r>16?16:r|0,i=i.times(1/ne(5,r)),i=Et(n,2,i,i,!0);for(var o,a=new n(5),l=new n(16),c=new n(20);r--;)o=i.times(i),i=i.times(a.plus(o.times(l.times(o).plus(c))))}return n.precision=s,n.rounding=t,P(i,s,t,!0)};v.hyperbolicTangent=v.tanh=function(){var r,s,t=this,e=t.constructor;return t.isFinite()?t.isZero()?new e(t):(r=e.precision,s=e.rounding,e.precision=r+7,e.rounding=1,R(t.sinh(),t.cosh(),e.precision=r,e.rounding=s)):new e(t.s)};v.inverseCosine=v.acos=function(){var r=this,s=r.constructor,t=r.abs().cmp(1),e=s.precision,i=s.rounding;return t!==-1?t===0?r.isNeg()?J(s,e,i):new s(0):new s(NaN):r.isZero()?J(s,e+4,i).times(.5):(s.precision=e+6,s.rounding=1,r=new s(1).minus(r).div(r.plus(1)).sqrt().atan(),s.precision=e,s.rounding=i,r.times(2))};v.inverseHyperbolicCosine=v.acosh=function(){var r,s,t=this,e=t.constructor;return t.lte(1)?new e(t.eq(1)?0:NaN):t.isFinite()?(r=e.precision,s=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=s,t.ln()):new e(t)};v.inverseHyperbolicSine=v.asinh=function(){var r,s,t=this,e=t.constructor;return!t.isFinite()||t.isZero()?new e(t):(r=e.precision,s=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=s,t.ln())};v.inverseHyperbolicTangent=v.atanh=function(){var r,s,t,e,i=this,n=i.constructor;return i.isFinite()?i.e>=0?new n(i.abs().eq(1)?i.s/0:i.isZero()?i:NaN):(r=n.precision,s=n.rounding,e=i.sd(),Math.max(e,r)<2*-i.e-1?P(new n(i),r,s,!0):(n.precision=t=e-i.e,i=R(i.plus(1),new n(1).minus(i),t+r,1),n.precision=r+4,n.rounding=1,i=i.ln(),n.precision=r,n.rounding=s,i.times(.5))):new n(NaN)};v.inverseSine=v.asin=function(){var r,s,t,e,i=this,n=i.constructor;return i.isZero()?new n(i):(s=i.abs().cmp(1),t=n.precision,e=n.rounding,s!==-1?s===0?(r=J(n,t+4,e).times(.5),r.s=i.s,r):new n(NaN):(n.precision=t+6,n.rounding=1,i=i.div(new n(1).minus(i.times(i)).sqrt().plus(1)).atan(),n.precision=t,n.rounding=e,i.times(2)))};v.inverseTangent=v.atan=function(){var r,s,t,e,i,n,o,a,l,c=this,h=c.constructor,u=h.precision,f=h.rounding;if(c.isFinite()){if(c.isZero())return new h(c);if(c.abs().eq(1)&&u+4<=fe)return o=J(h,u+4,f).times(.25),o.s=c.s,o}else{if(!c.s)return new h(NaN);if(u+4<=fe)return o=J(h,u+4,f).times(.5),o.s=c.s,o}for(h.precision=a=u+10,h.rounding=1,t=Math.min(28,a/_+2|0),r=t;r;--r)c=c.div(c.times(c).plus(1).sqrt().plus(1));for(S=!1,s=Math.ceil(a/_),e=1,l=c.times(c),o=new h(c),i=c;r!==-1;)if(i=i.times(l),n=o.minus(i.div(e+=2)),i=i.times(l),o=n.plus(i.div(e+=2)),o.d[s]!==void 0)for(r=s;o.d[r]===n.d[r]&&r--;);return t&&(o=o.times(2<<t-1)),S=!0,P(o,h.precision=u,h.rounding=f,!0)};v.isFinite=function(){return!!this.d};v.isInteger=v.isInt=function(){return!!this.d&&F(this.e/_)>this.d.length-2};v.isNaN=function(){return!this.s};v.isNegative=v.isNeg=function(){return this.s<0};v.isPositive=v.isPos=function(){return this.s>0};v.isZero=function(){return!!this.d&&this.d[0]===0};v.lessThan=v.lt=function(r){return this.cmp(r)<0};v.lessThanOrEqualTo=v.lte=function(r){return this.cmp(r)<1};v.logarithm=v.log=function(r){var s,t,e,i,n,o,a,l,c=this,h=c.constructor,u=h.precision,f=h.rounding,m=5;if(r==null)r=new h(10),s=!0;else{if(r=new h(r),t=r.d,r.s<0||!t||!t[0]||r.eq(1))return new h(NaN);s=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(s)if(t.length>1)n=!0;else{for(i=t[0];i%10===0;)i/=10;n=i!==1}if(S=!1,a=u+m,o=at(c,a),e=s?Jt(h,a+10):at(r,a),l=R(o,e,a,1),Ot(l.d,i=u,f))do if(a+=10,o=at(c,a),e=s?Jt(h,a+10):at(r,a),l=R(o,e,a,1),!n){+L(l.d).slice(i+1,i+15)+1==1e14&&(l=P(l,u+1,0));break}while(Ot(l.d,i+=10,f));return S=!0,P(l,u,f)};v.minus=v.sub=function(r){var s,t,e,i,n,o,a,l,c,h,u,f,m=this,p=m.constructor;if(r=new p(r),!m.d||!r.d)return!m.s||!r.s?r=new p(NaN):m.d?r.s=-r.s:r=new p(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,f=r.d,a=p.precision,l=p.rounding,!c[0]||!f[0]){if(f[0])r.s=-r.s;else if(c[0])r=new p(m);else return new p(l===3?-0:0);return S?P(r,a,l):r}if(t=F(r.e/_),h=F(m.e/_),c=c.slice(),n=h-t,n){for(u=n<0,u?(s=c,n=-n,o=f.length):(s=f,t=h,o=c.length),e=Math.max(Math.ceil(a/_),o)+2,n>e&&(n=e,s.length=1),s.reverse(),e=n;e--;)s.push(0);s.reverse()}else{for(e=c.length,o=f.length,u=e<o,u&&(o=e),e=0;e<o;e++)if(c[e]!=f[e]){u=c[e]<f[e];break}n=0}for(u&&(s=c,c=f,f=s,r.s=-r.s),o=c.length,e=f.length-o;e>0;--e)c[o++]=0;for(e=f.length;e>n;){if(c[--e]<f[e]){for(i=e;i&&c[--i]===0;)c[i]=$-1;--c[i],c[e]+=$}c[e]-=f[e]}for(;c[--o]===0;)c.pop();for(;c[0]===0;c.shift())--t;return c[0]?(r.d=c,r.e=se(c,t),S?P(r,a,l):r):new p(l===3?-0:0)};v.modulo=v.mod=function(r){var s,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]?P(new e(t),e.precision,e.rounding):(S=!1,e.modulo==9?(s=R(t,r.abs(),0,3,1),s.s*=r.s):s=R(t,r,0,e.modulo,1),s=s.times(r),S=!0,t.minus(s))};v.naturalExponential=v.exp=function(){return me(this)};v.naturalLogarithm=v.ln=function(){return at(this)};v.negated=v.neg=function(){var r=new this.constructor(this);return r.s=-r.s,P(r)};v.plus=v.add=function(r){var s,t,e,i,n,o,a,l,c,h,u=this,f=u.constructor;if(r=new f(r),!u.d||!r.d)return!u.s||!r.s?r=new f(NaN):u.d||(r=new f(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=f.precision,l=f.rounding,!c[0]||!h[0])return h[0]||(r=new f(u)),S?P(r,a,l):r;if(n=F(u.e/_),e=F(r.e/_),c=c.slice(),i=n-e,i){for(i<0?(t=c,i=-i,o=h.length):(t=h,e=n,o=c.length),n=Math.ceil(a/_),o=n>o?n+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),s=0;i;)s=(c[--i]=c[i]+h[i]+s)/$|0,c[i]%=$;for(s&&(c.unshift(s),++e),o=c.length;c[--o]==0;)c.pop();return r.d=c,r.e=se(c,e),S?P(r,a,l):r};v.precision=v.sd=function(r){var s,t=this;if(r!==void 0&&r!==!!r&&r!==1&&r!==0)throw Error(ht+r);return t.d?(s=ze(t.d),r&&t.e+1>s&&(s=t.e+1)):s=NaN,s};v.round=function(){var r=this,s=r.constructor;return P(new s(r),r.e+1,s.rounding)};v.sine=v.sin=function(){var r,s,t=this,e=t.constructor;return t.isFinite()?t.isZero()?new e(t):(r=e.precision,s=e.rounding,e.precision=r+Math.max(t.e,t.sd())+_,e.rounding=1,t=Hi(e,qe(e,t)),e.precision=r,e.rounding=s,P(nt>2?t.neg():t,r,s,!0)):new e(NaN)};v.squareRoot=v.sqrt=function(){var r,s,t,e,i,n,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?(s=L(a),(s.length+l)%2==0&&(s+="0"),c=Math.sqrt(s),l=F((l+1)/2)-(l<0||l%2),c==1/0?s="5e"+l:(s=c.toExponential(),s=s.slice(0,s.indexOf("e")+1)+l),e=new h(s)):e=new h(c.toString()),t=(l=h.precision)+3;;)if(n=e,e=n.plus(R(o,n,t+2,1)).times(.5),L(n.d).slice(0,t)===(s=L(e.d)).slice(0,t))if(s=s.slice(t-3,t+1),s=="9999"||!i&&s=="4999"){if(!i&&(P(n,l+1,0),n.times(n).eq(o))){e=n;break}t+=4,i=1}else{(!+s||!+s.slice(1)&&s.charAt(0)=="5")&&(P(e,l+1,1),r=!e.times(e).eq(o));break}return S=!0,P(e,l,h.rounding,r)};v.tangent=v.tan=function(){var r,s,t=this,e=t.constructor;return t.isFinite()?t.isZero()?new e(t):(r=e.precision,s=e.rounding,e.precision=r+10,e.rounding=1,t=t.sin(),t.s=1,t=R(t,new e(1).minus(t.times(t)).sqrt(),r+10,0),e.precision=r,e.rounding=s,P(nt==2||nt==4?t.neg():t,r,s,!0)):new e(NaN)};v.times=v.mul=function(r){var s,t,e,i,n,o,a,l,c,h=this,u=h.constructor,f=h.d,m=(r=new u(r)).d;if(r.s*=h.s,!f||!f[0]||!m||!m[0])return new u(!r.s||f&&!f[0]&&!m||m&&!m[0]&&!f?NaN:!f||!m?r.s/0:r.s*0);for(t=F(h.e/_)+F(r.e/_),l=f.length,c=m.length,l<c&&(n=f,f=m,m=n,o=l,l=c,c=o),n=[],o=l+c,e=o;e--;)n.push(0);for(e=c;--e>=0;){for(s=0,i=l+e;i>e;)a=n[i]+m[e]*f[i-e-1]+s,n[i--]=a%$|0,s=a/$|0;n[i]=(n[i]+s)%$|0}for(;!n[--o];)n.pop();return s?++t:n.shift(),r.d=n,r.e=se(n,t),S?P(r,u.precision,u.rounding):r};v.toBinary=function(r,s){return xe(this,2,r,s)};v.toDecimalPlaces=v.toDP=function(r,s){var t=this,e=t.constructor;return t=new e(t),r===void 0?t:(G(r,0,ut),s===void 0?s=e.rounding:G(s,0,8),P(t,r+t.e+1,s))};v.toExponential=function(r,s){var t,e=this,i=e.constructor;return r===void 0?t=K(e,!0):(G(r,0,ut),s===void 0?s=i.rounding:G(s,0,8),e=P(new i(e),r+1,s),t=K(e,!0,r+1)),e.isNeg()&&!e.isZero()?"-"+t:t};v.toFixed=function(r,s){var t,e,i=this,n=i.constructor;return r===void 0?t=K(i):(G(r,0,ut),s===void 0?s=n.rounding:G(s,0,8),e=P(new n(i),r+i.e+1,s),t=K(e,!1,r+e.e+1)),i.isNeg()&&!i.isZero()?"-"+t:t};v.toFraction=function(r){var s,t,e,i,n,o,a,l,c,h,u,f,m=this,p=m.d,g=m.constructor;if(!p)return new g(m);if(c=t=new g(1),e=l=new g(0),s=new g(e),n=s.e=ze(p)-m.e-1,o=n%_,s.d[0]=N(10,o<0?_+o:o),r==null)r=n>0?s:c;else{if(a=new g(r),!a.isInt()||a.lt(c))throw Error(ht+a);r=a.gt(s)?n>0?s:c:a}for(S=!1,a=new g(L(p)),h=g.precision,g.precision=n=p.length*_*2;u=R(a,s,0,1,1),i=t.plus(u.times(e)),i.cmp(r)!=1;)t=e,e=i,i=c,c=l.plus(u.times(i)),l=i,i=s,s=a.minus(u.times(i)),a=i;return i=R(r.minus(t),e,0,1,1),l=l.plus(i.times(c)),t=t.plus(i.times(e)),l.s=c.s=m.s,f=R(c,e,n,1).minus(m).abs().cmp(R(l,t,n,1).minus(m).abs())<1?[c,e]:[l,t],g.precision=h,S=!0,f};v.toHexadecimal=v.toHex=function(r,s){return xe(this,16,r,s)};v.toNearest=function(r,s){var t=this,e=t.constructor;if(t=new e(t),r==null){if(!t.d)return t;r=new e(1),s=e.rounding}else{if(r=new e(r),s===void 0?s=e.rounding:G(s,0,8),!t.d)return r.s?t:r;if(!r.d)return r.s&&(r.s=t.s),r}return r.d[0]?(S=!1,t=R(t,r,0,s,1).times(r),S=!0,P(t)):(r.s=t.s,t=r),t};v.toNumber=function(){return+this};v.toOctal=function(r,s){return xe(this,8,r,s)};v.toPower=v.pow=function(r){var s,t,e,i,n,o,a=this,l=a.constructor,c=+(r=new l(r));if(!a.d||!r.d||!a.d[0]||!r.d[0])return new l(N(+a,c));if(a=new l(a),a.eq(1))return a;if(e=l.precision,n=l.rounding,r.eq(1))return P(a,e,n);if(s=F(r.e/_),s>=r.d.length-1&&(t=c<0?-c:c)<=Ii)return i=Ye(l,a,t,e),r.s<0?new l(1).div(i):P(i,e,n);if(o=a.s,o<0){if(s<r.d.length-1)return new l(NaN);if(r.d[s]&1||(o=1),a.e==0&&a.d[0]==1&&a.d.length==1)return a.s=o,a}return t=N(+a,c),s=t==0||!isFinite(t)?F(c*(Math.log("0."+L(a.d))/Math.LN10+a.e+1)):new l(t+"").e,s>l.maxE+1||s<l.minE-1?new l(s>0?o/0:0):(S=!1,l.rounding=a.s=1,t=Math.min(12,(s+"").length),i=me(r.times(at(a,e+t)),e),i.d&&(i=P(i,e+5,1),Ot(i.d,e,n)&&(s=e+10,i=P(me(r.times(at(a,s+t)),s),s+5,1),+L(i.d).slice(e+1,e+15)+1==1e14&&(i=P(i,e+1,0)))),i.s=o,S=!0,l.rounding=n,P(i,e,n))};v.toPrecision=function(r,s){var t,e=this,i=e.constructor;return r===void 0?t=K(e,e.e<=i.toExpNeg||e.e>=i.toExpPos):(G(r,1,ut),s===void 0?s=i.rounding:G(s,0,8),e=P(new i(e),r,s),t=K(e,r<=e.e||e.e<=i.toExpNeg,r)),e.isNeg()&&!e.isZero()?"-"+t:t};v.toSignificantDigits=v.toSD=function(r,s){var t=this,e=t.constructor;return r===void 0?(r=e.precision,s=e.rounding):(G(r,1,ut),s===void 0?s=e.rounding:G(s,0,8)),P(new e(t),r,s)};v.toString=function(){var r=this,s=r.constructor,t=K(r,r.e<=s.toExpNeg||r.e>=s.toExpPos);return r.isNeg()&&!r.isZero()?"-"+t:t};v.truncated=v.trunc=function(){return P(new this.constructor(this),this.e+1,1)};v.valueOf=v.toJSON=function(){var r=this,s=r.constructor,t=K(r,r.e<=s.toExpNeg||r.e>=s.toExpPos);return r.isNeg()?"-"+t:t};function L(r){var s,t,e,i=r.length-1,n="",o=r[0];if(i>0){for(n+=o,s=1;s<i;s++)e=r[s]+"",t=_-e.length,t&&(n+=ot(t)),n+=e;o=r[s],e=o+"",t=_-e.length,t&&(n+=ot(t))}else if(o===0)return"0";for(;o%10===0;)o/=10;return n+o}function G(r,s,t){if(r!==~~r||r<s||r>t)throw Error(ht+r)}function Ot(r,s,t,e){var i,n,o,a;for(n=r[0];n>=10;n/=10)--s;return--s<0?(s+=_,i=0):(i=Math.ceil((s+1)/_),s%=_),n=N(10,_-s),a=r[i]%n|0,e==null?s<3?(s==0?a=a/100|0:s==1&&(a=a/10|0),o=t<4&&a==99999||t>3&&a==49999||a==5e4||a==0):o=(t<4&&a+1==n||t>3&&a+1==n/2)&&(r[i+1]/n/100|0)==N(10,s-2)-1||(a==n/2||a==0)&&(r[i+1]/n/100|0)==0:s<4?(s==0?a=a/1e3|0:s==1?a=a/100|0:s==2&&(a=a/10|0),o=(e||t<4)&&a==9999||!e&&t>3&&a==4999):o=((e||t<4)&&a+1==n||!e&&t>3&&a+1==n/2)&&(r[i+1]/n/1e3|0)==N(10,s-3)-1,o}function Bt(r,s,t){for(var e,i=[0],n,o=0,a=r.length;o<a;){for(n=i.length;n--;)i[n]*=s;for(i[0]+=ue.indexOf(r.charAt(o++)),e=0;e<i.length;e++)i[e]>t-1&&(i[e+1]===void 0&&(i[e+1]=0),i[e+1]+=i[e]/t|0,i[e]%=t)}return i.reverse()}function Ni(r,s){var t,e,i;if(s.isZero())return s;e=s.d.length,e<32?(t=Math.ceil(e/3),i=(1/ne(4,t)).toString()):(t=16,i="2.3283064365386962890625e-10"),r.precision+=t,s=Et(r,1,s.times(i),new r(1));for(var n=t;n--;){var o=s.times(s);s=o.times(o).minus(o).times(8).plus(1)}return r.precision-=t,s}var R=function(){function r(e,i,n){var o,a=0,l=e.length;for(e=e.slice();l--;)o=e[l]*i+a,e[l]=o%n|0,a=o/n|0;return a&&e.unshift(a),e}function s(e,i,n,o){var a,l;if(n!=o)l=n>o?1:-1;else for(a=l=0;a<n;a++)if(e[a]!=i[a]){l=e[a]>i[a]?1:-1;break}return l}function t(e,i,n,o){for(var a=0;n--;)e[n]-=a,a=e[n]<i[n]?1:0,e[n]=a*o+e[n]-i[n];for(;!e[0]&&e.length>1;)e.shift()}return function(e,i,n,o,a,l){var c,h,u,f,m,p,g,y,w,C,b,M,A,X,It,dt,rt,yt,z,Tt,Nt=e.constructor,oe=e.s==i.s?1:-1,H=e.d,k=i.d;if(!H||!H[0]||!k||!k[0])return new Nt(!e.s||!i.s||(H?k&&H[0]==k[0]:!k)?NaN:H&&H[0]==0||!k?oe*0:oe/0);for(l?(m=1,h=e.e-i.e):(l=$,m=_,h=F(e.e/m)-F(i.e/m)),z=k.length,rt=H.length,w=new Nt(oe),C=w.d=[],u=0;k[u]==(H[u]||0);u++);if(k[u]>(H[u]||0)&&h--,n==null?(X=n=Nt.precision,o=Nt.rounding):a?X=n+(e.e-i.e)+1:X=n,X<0)C.push(1),p=!0;else{if(X=X/m+2|0,u=0,z==1){for(f=0,k=k[0],X++;(u<rt||f)&&X--;u++)It=f*l+(H[u]||0),C[u]=It/k|0,f=It%k|0;p=f||u<rt}else{for(f=l/(k[0]+1)|0,f>1&&(k=r(k,f,l),H=r(H,f,l),z=k.length,rt=H.length),dt=z,b=H.slice(0,z),M=b.length;M<z;)b[M++]=0;Tt=k.slice(),Tt.unshift(0),yt=k[0],k[1]>=l/2&&++yt;do f=0,c=s(k,b,z,M),c<0?(A=b[0],z!=M&&(A=A*l+(b[1]||0)),f=A/yt|0,f>1?(f>=l&&(f=l-1),g=r(k,f,l),y=g.length,M=b.length,c=s(g,b,y,M),c==1&&(f--,t(g,z<y?Tt:k,y,l))):(f==0&&(c=f=1),g=k.slice()),y=g.length,y<M&&g.unshift(0),t(b,g,M,l),c==-1&&(M=b.length,c=s(k,b,z,M),c<1&&(f++,t(b,z<M?Tt:k,M,l))),M=b.length):c===0&&(f++,b=[0]),C[u++]=f,c&&b[0]?b[M++]=H[dt]||0:(b=[H[dt]],M=1);while((dt++<rt||b[0]!==void 0)&&X--);p=b[0]!==void 0}C[0]||C.shift()}if(m==1)w.e=h,Fe=p;else{for(u=1,f=C[0];f>=10;f/=10)u++;w.e=u+h*m-1,P(w,a?n+w.e+1:n,o,p)}return w}}();function P(r,s,t,e){var i,n,o,a,l,c,h,u,f,m=r.constructor;t:if(s!=null){if(u=r.d,!u)return r;for(i=1,a=u[0];a>=10;a/=10)i++;if(n=s-i,n<0)n+=_,o=s,h=u[f=0],l=h/N(10,i-o-1)%10|0;else if(f=Math.ceil((n+1)/_),a=u.length,f>=a)if(e){for(;a++<=f;)u.push(0);h=l=0,i=1,n%=_,o=n-_+1}else break t;else{for(h=a=u[f],i=1;a>=10;a/=10)i++;n%=_,o=n-_+i,l=o<0?0:h/N(10,i-o-1)%10|0}if(e=e||s<0||u[f+1]!==void 0||(o<0?h:h%N(10,i-o-1)),c=t<4?(l||e)&&(t==0||t==(r.s<0?3:2)):l>5||l==5&&(t==4||e||t==6&&(n>0?o>0?h/N(10,i-o):0:u[f-1])%10&1||t==(r.s<0?8:7)),s<1||!u[0])return u.length=0,c?(s-=r.e+1,u[0]=N(10,(_-s%_)%_),r.e=-s||0):u[0]=r.e=0,r;if(n==0?(u.length=f,a=1,f--):(u.length=f+1,a=N(10,_-n),u[f]=o>0?(h/N(10,i-o)%N(10,o)|0)*a:0),c)for(;;)if(f==0){for(n=1,o=u[0];o>=10;o/=10)n++;for(o=u[0]+=a,a=1;o>=10;o/=10)a++;n!=a&&(r.e++,u[0]==$&&(u[0]=1));break}else{if(u[f]+=a,u[f]!=$)break;u[f--]=0,a=1}for(n=u.length;u[--n]===0;)u.pop()}return S&&(r.e>m.maxE?(r.d=null,r.e=NaN):r.e<m.minE&&(r.e=0,r.d=[0])),r}function K(r,s,t){if(!r.isFinite())return je(r);var e,i=r.e,n=L(r.d),o=n.length;return s?(t&&(e=t-o)>0?n=n.charAt(0)+"."+n.slice(1)+ot(e):o>1&&(n=n.charAt(0)+"."+n.slice(1)),n=n+(r.e<0?"e":"e+")+r.e):i<0?(n="0."+ot(-i-1)+n,t&&(e=t-o)>0&&(n+=ot(e))):i>=o?(n+=ot(i+1-o),t&&(e=t-i-1)>0&&(n=n+"."+ot(e))):((e=i+1)<o&&(n=n.slice(0,e)+"."+n.slice(e)),t&&(e=t-o)>0&&(i+1===o&&(n+="."),n+=ot(e))),n}function se(r,s){var t=r[0];for(s*=_;t>=10;t/=10)s++;return s}function Jt(r,s,t){if(s>Ti)throw S=!0,t&&(r.precision=t),Error(Be);return P(new r(Zt),s,1,!0)}function J(r,s,t){if(s>fe)throw Error(Be);return P(new r(Qt),s,t,!0)}function ze(r){var s=r.length-1,t=s*_+1;if(s=r[s],s){for(;s%10==0;s/=10)t--;for(s=r[0];s>=10;s/=10)t++}return t}function ot(r){for(var s="";r--;)s+="0";return s}function Ye(r,s,t,e){var i,n=new r(1),o=Math.ceil(e/_+4);for(S=!1;;){if(t%2&&(n=n.times(s),Me(n.d,o)&&(i=!0)),t=F(t/2),t===0){t=n.d.length-1,i&&n.d[t]===0&&++n.d[t];break}s=s.times(s),Me(s.d,o)}return S=!0,n}function Se(r){return r.d[r.d.length-1]&1}function We(r,s,t){for(var e,i,n=new r(s[0]),o=0;++o<s.length;){if(i=new r(s[o]),!i.s){n=i;break}e=n.cmp(i),(e===t||e===0&&n.s===t)&&(n=i)}return n}function me(r,s){var t,e,i,n,o,a,l,c=0,h=0,u=0,f=r.constructor,m=f.rounding,p=f.precision;if(!r.d||!r.d[0]||r.e>17)return new f(r.d?r.d[0]?r.s<0?0:1/0:1:r.s?r.s<0?0:r:NaN);for(s==null?(S=!1,l=p):l=s,a=new f(.03125);r.e>-2;)r=r.times(a),u+=5;for(e=Math.log(N(2,u))/Math.LN10*2+5|0,l+=e,t=n=o=new f(1),f.precision=l;;){if(n=P(n.times(r),l,1),t=t.times(++h),a=o.plus(R(n,t,l,1)),L(a.d).slice(0,l)===L(o.d).slice(0,l)){for(i=u;i--;)o=P(o.times(o),l,1);if(s==null)if(c<3&&Ot(o.d,l-e,m,c))f.precision=l+=10,t=n=a=new f(1),h=0,c++;else return P(o,f.precision=p,m,S=!0);else return f.precision=p,o}o=a}}function at(r,s){var t,e,i,n,o,a,l,c,h,u,f,m=1,p=10,g=r,y=g.d,w=g.constructor,C=w.rounding,b=w.precision;if(g.s<0||!y||!y[0]||!g.e&&y[0]==1&&y.length==1)return new w(y&&!y[0]?-1/0:g.s!=1?NaN:y?0:g);if(s==null?(S=!1,h=b):h=s,w.precision=h+=p,t=L(y),e=t.charAt(0),Math.abs(n=g.e)<15e14){for(;e<7&&e!=1||e==1&&t.charAt(1)>3;)g=g.times(r),t=L(g.d),e=t.charAt(0),m++;n=g.e,e>1?(g=new w("0."+t),n++):g=new w(e+"."+t.slice(1))}else return c=Jt(w,h+2,b).times(n+""),g=at(new w(e+"."+t.slice(1)),h-p).plus(c),w.precision=b,s==null?P(g,b,C,S=!0):g;for(u=g,l=o=g=R(g.minus(1),g.plus(1),h,1),f=P(g.times(g),h,1),i=3;;){if(o=P(o.times(f),h,1),c=l.plus(R(o,new w(i),h,1)),L(c.d).slice(0,h)===L(l.d).slice(0,h))if(l=l.times(2),n!==0&&(l=l.plus(Jt(w,h+2,b).times(n+""))),l=R(l,new w(m),h,1),s==null)if(Ot(l.d,h-p,C,a))w.precision=h+=p,c=o=g=R(u.minus(1),u.plus(1),h,1),f=P(g.times(g),h,1),i=a=1;else return P(l,w.precision=b,C,S=!0);else return w.precision=b,l;l=c,i+=2}}function je(r){return String(r.s*r.s/0)}function Ut(r,s){var t,e,i;for((t=s.indexOf("."))>-1&&(s=s.replace(".","")),(e=s.search(/e/i))>0?(t<0&&(t=e),t+=+s.slice(e+1),s=s.substring(0,e)):t<0&&(t=s.length),e=0;s.charCodeAt(e)===48;e++);for(i=s.length;s.charCodeAt(i-1)===48;--i);if(s=s.slice(e,i),s){if(i-=e,r.e=t=t-e-1,r.d=[],e=(t+1)%_,t<0&&(e+=_),e<i){for(e&&r.d.push(+s.slice(0,e)),i-=_;e<i;)r.d.push(+s.slice(e,e+=_));s=s.slice(e),e=_-s.length}else e-=i;for(;e--;)s+="0";r.d.push(+s),S&&(r.e>r.constructor.maxE?(r.d=null,r.e=NaN):r.e<r.constructor.minE&&(r.e=0,r.d=[0]))}else r.e=0,r.d=[0];return r}function Li(r,s){var t,e,i,n,o,a,l,c,h;if(s.indexOf("_")>-1){if(s=s.replace(/(\d)_(?=\d)/g,"$1"),Xe.test(s))return Ut(r,s)}else if(s==="Infinity"||s==="NaN")return+s||(r.s=NaN),r.e=NaN,r.d=null,r;if(Oi.test(s))t=16,s=s.toLowerCase();else if(ki.test(s))t=2;else if(Ai.test(s))t=8;else throw Error(ht+s);for(n=s.search(/p/i),n>0?(l=+s.slice(n+1),s=s.substring(2,n)):s=s.slice(2),n=s.indexOf("."),o=n>=0,e=r.constructor,o&&(s=s.replace(".",""),a=s.length,n=a-n,i=Ye(e,new e(t),n,n*2)),c=Bt(s,t,$),h=c.length-1,n=h;c[n]===0;--n)c.pop();return n<0?new e(r.s*0):(r.e=se(c,h),r.d=c,S=!1,o&&(r=R(r,i,a*4)),l&&(r=r.times(Math.abs(l)<54?N(2,l):D.pow(2,l))),S=!0,r)}function Hi(r,s){var t,e=s.d.length;if(e<3)return s.isZero()?s:Et(r,2,s,s);t=1.4*Math.sqrt(e),t=t>16?16:t|0,s=s.times(1/ne(5,t)),s=Et(r,2,s,s);for(var i,n=new r(5),o=new r(16),a=new r(20);t--;)i=s.times(s),s=s.times(n.plus(i.times(o.times(i).minus(a))));return s}function Et(r,s,t,e,i){var n,o,a,l,c=r.precision,h=Math.ceil(c/_);for(S=!1,l=t.times(t),a=new r(e);;){if(o=R(a.times(l),new r(s++*s++),c,1),a=i?e.plus(o):e.minus(o),e=R(o.times(l),new r(s++*s++),c,1),o=a.plus(e),o.d[h]!==void 0){for(n=h;o.d[n]===a.d[n]&&n--;);if(n==-1)break}n=a,a=e,e=o,o=n}return S=!0,o.d.length=h+1,o}function ne(r,s){for(var t=r;--s;)t*=r;return t}function qe(r,s){var t,e=s.s<0,i=J(r,r.precision,1),n=i.times(.5);if(s=s.abs(),s.lte(n))return nt=e?4:1,s;if(t=s.divToInt(i),t.isZero())nt=e?3:2;else{if(s=s.minus(t.times(i)),s.lte(n))return nt=Se(t)?e?2:3:e?4:1,s;nt=Se(t)?e?1:4:e?3:2}return s.minus(i).abs()}function xe(r,s,t,e){var i,n,o,a,l,c,h,u,f,m=r.constructor,p=t!==void 0;if(p?(G(t,1,ut),e===void 0?e=m.rounding:G(e,0,8)):(t=m.precision,e=m.rounding),!r.isFinite())h=je(r);else{for(h=K(r),o=h.indexOf("."),p?(i=2,s==16?t=t*4-3:s==8&&(t=t*3-2)):i=s,o>=0&&(h=h.replace(".",""),f=new m(1),f.e=h.length-o,f.d=Bt(K(f),10,i),f.e=f.d.length),u=Bt(h,10,i),n=l=u.length;u[--l]==0;)u.pop();if(!u[0])h=p?"0p+0":"0";else{if(o<0?n--:(r=new m(r),r.d=u,r.e=n,r=R(r,f,t,e,0,i),u=r.d,n=r.e,c=Fe),o=u[t],a=i/2,c=c||u[t+1]!==void 0,c=e<4?(o!==void 0||c)&&(e===0||e===(r.s<0?3:2)):o>a||o===a&&(e===4||c||e===6&&u[t-1]&1||e===(r.s<0?8:7)),u.length=t,c)for(;++u[--t]>i-1;)u[t]=0,t||(++n,u.unshift(1));for(l=u.length;!u[l-1];--l);for(o=0,h="";o<l;o++)h+=ue.charAt(u[o]);if(p){if(l>1)if(s==16||s==8){for(o=s==16?4:3,--l;l%o;l++)h+="0";for(u=Bt(h,i,s),l=u.length;!u[l-1];--l);for(o=1,h="1.";o<l;o++)h+=ue.charAt(u[o])}else h=h.charAt(0)+"."+h.slice(1);h=h+(n<0?"p":"p+")+n}else if(n<0){for(;++n;)h="0"+h;h="0."+h}else if(++n>l)for(n-=l;n--;)h+="0";else n<l&&(h=h.slice(0,n)+"."+h.slice(n))}h=(s==16?"0x":s==2?"0b":s==8?"0o":"")+h}return r.s<0?"-"+h:h}function Me(r,s){if(r.length>s)return r.length=s,!0}function Fi(r){return new this(r).abs()}function Bi(r){return new this(r).acos()}function Ui(r){return new this(r).acosh()}function Gi(r,s){return new this(r).plus(s)}function Xi(r){return new this(r).asin()}function zi(r){return new this(r).asinh()}function Yi(r){return new this(r).atan()}function Wi(r){return new this(r).atanh()}function ji(r,s){r=new this(r),s=new this(s);var t,e=this.precision,i=this.rounding,n=e+4;return!r.s||!s.s?t=new this(NaN):!r.d&&!s.d?(t=J(this,n,1).times(s.s>0?.25:.75),t.s=r.s):!s.d||r.isZero()?(t=s.s<0?J(this,e,i):new this(0),t.s=r.s):!r.d||s.isZero()?(t=J(this,n,1).times(.5),t.s=r.s):s.s<0?(this.precision=n,this.rounding=1,t=this.atan(R(r,s,n,1)),s=J(this,n,1),this.precision=e,this.rounding=i,t=r.s<0?t.minus(s):t.plus(s)):t=this.atan(R(r,s,n,1)),t}function qi(r){return new this(r).cbrt()}function $i(r){return P(r=new this(r),r.e+1,2)}function Zi(r,s,t){return new this(r).clamp(s,t)}function Qi(r){if(!r||typeof r!="object")throw Error(ie+"Object expected");var s,t,e,i=r.defaults===!0,n=["precision",1,ut,"rounding",0,8,"toExpNeg",-9e15,0,"toExpPos",0,he,"maxE",0,he,"minE",-9e15,0,"modulo",0,9];for(s=0;s<n.length;s+=3)if(t=n[s],i&&(this[t]=de[t]),(e=r[t])!==void 0)if(F(e)===e&&e>=n[s+1]&&e<=n[s+2])this[t]=e;else throw Error(ht+t+": "+e);if(t="crypto",i&&(this[t]=de[t]),(e=r[t])!==void 0)if(e===!0||e===!1||e===0||e===1)if(e)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[t]=!0;else throw Error(Ue);else this[t]=!1;else throw Error(ht+t+": "+e);return this}function Ji(r){return new this(r).cos()}function Ki(r){return new this(r).cosh()}function $e(r){var s,t,e;function i(n){var o,a,l,c=this;if(!(c instanceof i))return new i(n);if(c.constructor=i,Ee(n)){c.s=n.s,S?!n.d||n.e>i.maxE?(c.e=NaN,c.d=null):n.e<i.minE?(c.e=0,c.d=[0]):(c.e=n.e,c.d=n.d.slice()):(c.e=n.e,c.d=n.d?n.d.slice():n.d);return}if(l=typeof n,l==="number"){if(n===0){c.s=1/n<0?-1:1,c.e=0,c.d=[0];return}if(n<0?(n=-n,c.s=-1):c.s=1,n===~~n&&n<1e7){for(o=0,a=n;a>=10;a/=10)o++;S?o>i.maxE?(c.e=NaN,c.d=null):o<i.minE?(c.e=0,c.d=[0]):(c.e=o,c.d=[n]):(c.e=o,c.d=[n]);return}if(n*0!==0){n||(c.s=NaN),c.e=NaN,c.d=null;return}return Ut(c,n.toString())}if(l==="string")return(a=n.charCodeAt(0))===45?(n=n.slice(1),c.s=-1):(a===43&&(n=n.slice(1)),c.s=1),Xe.test(n)?Ut(c,n):Li(c,n);if(l==="bigint")return n<0?(n=-n,c.s=-1):c.s=1,Ut(c,n.toString());throw Error(ht+n)}if(i.prototype=v,i.ROUND_UP=0,i.ROUND_DOWN=1,i.ROUND_CEIL=2,i.ROUND_FLOOR=3,i.ROUND_HALF_UP=4,i.ROUND_HALF_DOWN=5,i.ROUND_HALF_EVEN=6,i.ROUND_HALF_CEIL=7,i.ROUND_HALF_FLOOR=8,i.EUCLID=9,i.config=i.set=Qi,i.clone=$e,i.isDecimal=Ee,i.abs=Fi,i.acos=Bi,i.acosh=Ui,i.add=Gi,i.asin=Xi,i.asinh=zi,i.atan=Yi,i.atanh=Wi,i.atan2=ji,i.cbrt=qi,i.ceil=$i,i.clamp=Zi,i.cos=Ji,i.cosh=Ki,i.div=ts,i.exp=es,i.floor=is,i.hypot=ss,i.ln=ns,i.log=rs,i.log10=as,i.log2=os,i.max=ls,i.min=cs,i.mod=hs,i.mul=us,i.pow=ds,i.random=fs,i.round=ms,i.sign=gs,i.sin=ps,i.sinh=vs,i.sqrt=ys,i.sub=ws,i.sum=xs,i.tan=Ps,i.tanh=Cs,i.trunc=bs,r===void 0&&(r={}),r&&r.defaults!==!0)for(e=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],s=0;s<e.length;)r.hasOwnProperty(t=e[s++])||(r[t]=this[t]);return i.config(r),i}function ts(r,s){return new this(r).div(s)}function es(r){return new this(r).exp()}function is(r){return P(r=new this(r),r.e+1,3)}function ss(){var r,s,t=new this(0);for(S=!1,r=0;r<arguments.length;)if(s=new this(arguments[r++]),s.d)t.d&&(t=t.plus(s.times(s)));else{if(s.s)return S=!0,new this(1/0);t=s}return S=!0,t.sqrt()}function Ee(r){return r instanceof D||r&&r.toStringTag===Ge||!1}function ns(r){return new this(r).ln()}function rs(r,s){return new this(r).log(s)}function os(r){return new this(r).log(2)}function as(r){return new this(r).log(10)}function ls(){return We(this,arguments,-1)}function cs(){return We(this,arguments,1)}function hs(r,s){return new this(r).mod(s)}function us(r,s){return new this(r).mul(s)}function ds(r,s){return new this(r).pow(s)}function fs(r){var s,t,e,i,n=0,o=new this(1),a=[];if(r===void 0?r=this.precision:G(r,1,ut),e=Math.ceil(r/_),this.crypto)if(crypto.getRandomValues)for(s=crypto.getRandomValues(new Uint32Array(e));n<e;)i=s[n],i>=429e7?s[n]=crypto.getRandomValues(new Uint32Array(1))[0]:a[n++]=i%1e7;else if(crypto.randomBytes){for(s=crypto.randomBytes(e*=4);n<e;)i=s[n]+(s[n+1]<<8)+(s[n+2]<<16)+((s[n+3]&127)<<24),i>=214e7?crypto.randomBytes(4).copy(s,n):(a.push(i%1e7),n+=4);n=e/4}else throw Error(Ue);else for(;n<e;)a[n++]=Math.random()*1e7|0;for(e=a[--n],r%=_,e&&r&&(i=N(10,_-r),a[n]=(e/i|0)*i);a[n]===0;n--)a.pop();if(n<0)t=0,a=[0];else{for(t=-1;a[0]===0;t-=_)a.shift();for(e=1,i=a[0];i>=10;i/=10)e++;e<_&&(t-=_-e)}return o.e=t,o.d=a,o}function ms(r){return P(r=new this(r),r.e+1,this.rounding)}function gs(r){return r=new this(r),r.d?r.d[0]?r.s:0*r.s:r.s||NaN}function ps(r){return new this(r).sin()}function vs(r){return new this(r).sinh()}function ys(r){return new this(r).sqrt()}function ws(r,s){return new this(r).sub(s)}function xs(){var r=0,s=arguments,t=new this(s[r]);for(S=!1;t.s&&++r<s.length;)t=t.plus(s[r]);return S=!0,P(t,this.precision,this.rounding)}function Ps(r){return new this(r).tan()}function Cs(r){return new this(r).tanh()}function bs(r){return P(r=new this(r),r.e+1,1)}v[Symbol.for("nodejs.util.inspect.custom")]=v.toString;v[Symbol.toStringTag]="Decimal";var D=v.constructor=$e(de);Zt=new D(Zt);Qt=new D(Qt);class _s{constructor(){d(this,"parent");d(this,"name","");d(this,"extData");d(this,"mainCanvas");d(this,"_isRecalculate",!1);d(this,"notifyReload")}get isRecalculate(){return(this.parent?this.parent.isRecalculate:!1)||this._isRecalculate}set isRecalculate(s){this._isRecalculate=s}equalsMainCanvas(s){return this.mainCanvas===s}setMainCanvas(s){this.mainCanvas=s}}class Ss extends _s{constructor(){super(...arguments);d(this,"_isVisible",!0);d(this,"inheritOpacity",!0);d(this,"_opacity");d(this,"_scaleRange")}get isVisible(){return this._isVisible}set isVisible(t){var e;t!=this.isVisible&&(this._isVisible=t,(e=this.notifyReload)==null||e.call(this,!0))}get opacity(){var t;return this.inheritOpacity?this._opacity??((t=this.parent)==null?void 0:t.opacity):this._opacity}set opacity(t){var e;this._opacity!=t&&(t===void 0||t>=0&&t<=1?(this._opacity=t,(e=this.notifyReload)==null||e.call(this,!1)):console.warn("Opacity value should be between 0 and 1."))}get scaleRange(){return this._scaleRange}set scaleRange(t){var e;t!=this.scaleRange&&(this._scaleRange=t,this.isVisible&&((e=this.notifyReload)==null||e.call(this)))}shouldRender(){var e;if(!this.isVisible||this.opacity===0)return!1;const t=(e=this.mainCanvas)==null?void 0:e.scale;if(this.scaleRange&&t){const i=Math.min(...this.scaleRange),n=Math.max(...this.scaleRange);return t>=i&&t<=n}return!0}}let Ms=class extends Ss{constructor(s){super(),s.name=s.name||$t("default-name-"),Object.assign(this,{...s})}};class Es extends Ms{constructor(t){super(t);d(this,"_isInteractive",!0);d(this,"_isHoverable",!0);d(this,"_isDownable",!0);d(this,"_isContextmenuable",!0);d(this,"_isClickable",!0);d(this,"_isDoubleClickable",!0);d(this,"_isDraggable",!0);d(this,"_isWheelable",!0);Object.assign(this,{...t})}get isInteractive(){return this.getPropValue("isInteractive",this._isInteractive,!1)}set isInteractive(t){this._isInteractive=t}get isHoverable(){return this.getPropValue("isHoverable",this._isHoverable)}set isHoverable(t){this._isHoverable=t}get isDownable(){return this.getPropValue("isDownable",this._isDownable)}set isDownable(t){this._isDownable=t}get isContextmenuable(){return this.getPropValue("isContextmenuable",this._isContextmenuable)}set isContextmenuable(t){this._isContextmenuable=t}get isClickable(){return this.getPropValue("isClickable",this._isClickable)}set isClickable(t){this._isClickable=t}get isDoubleClickable(){return this.getPropValue("isDoubleClickable",this._isDoubleClickable)}set isDoubleClickable(t){this._isDoubleClickable=t}get isDraggable(){return this.getPropValue("isDraggable",this._isDraggable)}set isDraggable(t){this._isDraggable=t}get isWheelable(){return this.getPropValue("isWheelable",this._isWheelable)}set isWheelable(t){this._isWheelable=t}getPropValue(t,e,i=!0){return(this.parent?this.parent[t]:!0)&&e&&(i?this.isInteractive:!0)}}class Ds{constructor(s){d(this,"propagationStopped",!1);this.data=s}stopPropagation(){this.propagationStopped=!0}get canPropagate(){return!this.propagationStopped}}class At extends Es{constructor(){super(...arguments);d(this,"listeners",{wheel:new Set,hover:new Set,down:new Set,contextmenu:new Set,click:new Set,doubleClick:new Set,dragg:new Set});d(this,"sharedControllers",{});d(this,"_eventDate",{});d(this,"_clearEventDate",!1);d(this,"_isHover",!1);d(this,"notifyHover",(t,e)=>this.checkEventDate("hover",t)&&this.trigger("hover",{state:t,oldState:this.isHover},e,"isHoverable"));d(this,"_isDown",!1);d(this,"notifyDown",(t,e)=>this.checkEventDate("down",t)&&this.trigger("down",{state:t,oldState:this.isDown},e,"isDownable"));d(this,"_isContextmenu",!1);d(this,"notifyContextmenu",(t,e)=>this.checkEventDate("contextmenu",t)&&this.trigger("contextmenu",{state:t,oldState:this.isContextmenu},e,"isContextmenuable"));d(this,"_isClick",!1);d(this,"clickTimestamp",0);d(this,"doubleClickInterval",300);d(this,"notifyClick",(t,e)=>{if(!this.checkEventDate("click",t))return;let i=!1;t?(i=Date.now()-this.clickTimestamp<this.doubleClickInterval,this.clickTimestamp=i?0:Date.now()):(this._isDblClick=!1,this.clickTimestamp=0),i?this.notifyDoubleClick(i,e):this.trigger("click",{state:t,oldState:this.isClick},e,"isClickable")});d(this,"_isDblClick",!1);d(this,"notifyDoubleClick",(t,e)=>this.checkEventDate("doubleClick",t)&&this.trigger("doubleClick",{state:t,oldState:this.isDblClick},e,"isDoubleClickable"));d(this,"notifyDragg",(t,e)=>this.checkEventDate("dragg",t)&&this.trigger("dragg",t,e,"isDraggable"));d(this,"notifyWheel",(t,e)=>this.checkEventDate("wheel",t)&&this.trigger("wheel",t,e,"isWheelable"))}addEventListener(t,e){this.listeners[t].add(e)}removeEventListener(t,e){this.listeners[t].delete(e)}registerControllers(t,e){this.sharedControllers[t]=e}hasController(t,e){var i;return(i=this.sharedControllers[t])==null?void 0:i.includes(e)}trigger(t,e,i,n){var c,h;if(!this[n])return;this.updateStates(t,e);const o=new Ds(e);this.listeners[t].forEach(u=>u(o,i));const a="notify"+(t.charAt(0).toUpperCase()+t.slice(1)),l=["notifyDragg","notifyWheel"].includes(a)?e:e.state;o.canPropagate&&((c=this.parent)==null||c[a](l,i)),(h=this.sharedControllers[t])==null||h.forEach(u=>u!==this&&u[a](l,i))}updateStates(t,e){const i=e;switch(t){case"hover":this._isHover=i.state;break;case"down":this._isDown=i.state;break;case"contextmenu":this._isContextmenu=i.state;break;case"click":this._isClick=i.state;break;case"doubleClick":this._isDblClick=i.state;break}}checkEventDate(t,e){const i=this._eventDate[t],n=JSON.stringify(e);return i==n?!1:(this._eventDate[t]=n,this._clearEventDate||(this._clearEventDate=!0,Promise.resolve().then(()=>{this._clearEventDate=!1,this._eventDate={}})),!0)}get isHover(){return this.isHoverable&&this._isHover}get isDown(){return this.isDraggable&&this._isDown}get isContextmenu(){return this.isClickable&&this._isContextmenu}get isClick(){return this.isClickable&&this._isClick}get isDblClick(){return this.isDoubleClickable&&this._isDblClick}}class Vs extends At{constructor(t){super(t);d(this,"canvas");d(this,"ctx");d(this,"_rectValueIsUpdated",!1);d(this,"_rect");d(this,"offset",{x:0,y:0});d(this,"center",{x:0,y:0});d(this,"defaultCenter",{top:void 0,bottom:void 0,left:void 0,right:void 0});d(this,"accuracy",5);d(this,"scale",1);d(this,"defaultScale",1);d(this,"percentage",1);d(this,"axisConfig",{count:2,min:100,size:100,x:1,y:1});d(this,"cycle",10);d(this,"delta",.02);d(this,"_redrawInNextRenderFrame",!1);d(this,"isAuto",!1);d(this,"isRendering",!1);d(this,"drawAxis");d(this,"layerGroups",new Map);d(this,"isScaleUpdated",!1);d(this,"nowGridCount");const{id:e,axisConfig:i,defaultCenter:n,offset:o,defaultScale:a}=t,l=document.getElementById(e);if(l instanceof HTMLCanvasElement)if(l.getContext){this.canvas=l,this.ctx=l.getContext("2d");const{clientWidth:c,clientHeight:h}=l;[l.width,l.height]=[c,h]}else throw new Error("canvas-unsupported code here");else throw new Error("canvas is not HTMLCanvasElement");i&&this.setAxis(i),o&&(this.offset.x=o.x||0,this.offset.y=o.y||0),n&&this.setDefaultCenter(n),a&&(this.updateCenter(),this.setScale("center",a-1),this.defaultScale=a)}get rect(){return this._rectValueIsUpdated&&this._rect?this._rect:(this._rectValueIsUpdated=!0,Promise.resolve().then(()=>this._rectValueIsUpdated=!1),this._rect=this.canvas.getBoundingClientRect(),this._rect)}get redrawInNextRenderFrame(){return this._redrawInNextRenderFrame}set redrawInNextRenderFrame(t){this._redrawInNextRenderFrame=t}setNotifyReload(t){this.notifyReload=t}getDefaultCenterLocation(){const{canvas:t,rect:e,defaultCenter:i}=this;if(!t)return console.error("canvas is not HTMLCanvasElement");const{width:n,height:o}=e,{top:a,bottom:l,left:c,right:h}=i,u={vertical:(g,y)=>{if([0,"0","0%"].includes(g))return 0;if(!(g==1/0||g==-1/0))return typeof g=="number"?g:["top","left"].includes(g)?0:["bottom","right"].includes(g)?y:["middle","center"].includes(g)?y/2:/^(-?\d+)%$/.test(g)?(g=g.match(/^(-?\d+)%$/)[1],y*Number(g)/100):Number(g)||void 0},reverse:(g,y)=>{if([0,"0","0%"].includes(g))return y;if(g==1/0||g==-1/0)return;if(typeof g=="number")return y-g;const w=u.vertical(g,y);return w?y-w:void 0}},f=(g,y,w)=>{if(g!==void 0){const C=u.vertical(g,w);if(C!==void 0)return C}if(y!==void 0){const C=u.reverse(y,w);if(C!==void 0)return C}return w/2},m=f(a,l,o);return{x:f(c,h,n),y:m}}updateCenter(){const t=this.getDefaultCenterLocation();if(!t)return;const{x:e,y:i}=t;this.center={x:Math.floor(e+this.offset.x),y:Math.floor(i+this.offset.y)}}updateSize(){const{scale:t,axisConfig:e}=this;e.size=this.getGridSize(t),this.percentage=this.getAxisPointByValue(e.count,0).x/e.min}setScale(t,e){const{canvas:i,isWheelable:n,axisConfig:o,rect:a}=this;if(!n||!i)return console.error("canvas is not HTMLCanvasElement");let l,c;t==="center"?(l=a.left+a.width/2,c=a.top+a.height/2):[l,c]=[t.clientX,t.clientY];const h=this.getMousePositionOnAxis({clientX:l,clientY:c}),u=this.getAxisValueByPoint(h.x,h.y);this.scale=new D(this.scale).add(e).toNumber(),this.isScaleUpdated=!0,this.updateSize();const f=this.getAxisPointByValue(u.xV,u.yV);this.offset.x-=(f.x-h.x)*o.x,this.offset.y-=(f.y-h.y)*o.y,this.offset.x=Number(this.offset.x.toFixed(0)),this.offset.y=Number(this.offset.y.toFixed(0))}setAxis(t){const e={...this.axisConfig,...t},i=Object.fromEntries(Object.entries(e).map(([g,y])=>[g,Number(y)])),{x:n,y:o,count:a,min:l,size:c}=i,h=[1,-1].includes(n),u=[1,-1].includes(o),f=a>0,m=l>0,p=c>=l&&c<=l*2;if(!h||!u||!f||!m){console.warn("Invalid axis configuration:",{x:n,y:o,count:a,min:l});return}p||(i.size=l),this.axisConfig=i}setDefaultCenter(t){Object.assign(this.defaultCenter,t),this.updateCenter()}getGridSize(t){const{cycle:e,delta:i,axisConfig:n}=this;let o=new D(t).sub(1).abs().mod(e*i).div(i).toNumber();return o=t<1&&o!=0?e-o:o,Number(((o/e+1)*n.min).toFixed(0))}getGridCount(t){const{axisConfig:e,cycle:i,delta:n}=this,o=e.count,a=i*n;if(t===1)return o;if(t>1){const l=new D(t).sub(1).div(a).floor();return new D(o).div(new D(2).pow(l)).toNumber()}else{const l=new D(1).sub(t).div(a).ceil();return new D(o).mul(new D(2).pow(l)).toNumber()}}get getNowGridCount(){const{scale:t,nowGridCount:e,isRendering:i}=this;return e&&i?e:(this.nowGridCount=this.getGridCount(t),i&&Promise.resolve().then(()=>this.nowGridCount=void 0),this.nowGridCount)}getMousePositionOnAxis(t){const{canvas:e,center:i,rect:n,axisConfig:o}=this;if(!e)return console.error("canvas is not HTMLCanvasElement");const{clientX:a,clientY:l}=t,{left:c,top:h}=n,u=(a-c-i.x)*o.x,f=(l-h-i.y)*o.y;return{x:u,y:f}}getAxisValueByPoint(t,e,i){const{axisConfig:n}=this;if(i)return{xV:t/n.min*n.count,yV:e/n.min*n.count};const o=this.getNowGridCount,a=new D(t).div(n.size).mul(o).toFixed(8),l=new D(e).div(n.size).mul(o).toFixed(8);return{xV:Number(a),yV:Number(l)}}getAxisPointByValue(t,e,i){const{axisConfig:n}=this;if(i)return{x:t/n.count*n.min,y:e/n.count*n.min};const o=this.getNowGridCount,a=new D(t).div(o).mul(n.size).toFixed(3),l=new D(e).div(o).mul(n.size).toFixed(3);return{x:Number(a),y:Number(l)}}getMaxMinValue(t){t=t||this.rect;const{left:e,top:i,right:n,bottom:o}=t,{axisConfig:a}=this,{x:l,y:c}=this.getMousePositionOnAxis({clientX:a.x==1?e:n,clientY:a.y==1?i:o}),{xV:h,yV:u}=this.getAxisValueByPoint(l,c),{x:f,y:m}=this.getMousePositionOnAxis({clientX:a.x==1?n:e,clientY:a.y==1?o:i}),{xV:p,yV:g}=this.getAxisValueByPoint(f,m);return{minXV:h,maxXV:p,minYV:u,maxYV:g}}transformPosition(t){const{center:e,percentage:i,axisConfig:n}=this,o=i*n.x,a=i*n.y,l=c=>[e.x+c[0]*o,e.y+c[1]*a];return Array.isArray(t[0])?t.map(c=>l(c)):l(t)}}class Rs extends Vs{constructor(t){super(t);d(this,"theme","light");d(this,"isThemeUpdated",!1);d(this,"style",{light:{background:"#fff",text:{color:"#222",secondary:"#909399",stroke:"#fff",size:12,family:"monospace",bold:!0},grid:{axis:"#222",grid:"#666",innerGrid:"#e5e5e5"},point:{radius:5,fill:"#d03050",width:14,stroke:"#d0305080"},line:{stroke:{color:"#f0a020",color_hover:"#f2c97d",width:4,dash:!1,dashGap:[5,10],dashOffset:0,cap:"round",join:"round"},point:{radius:5,stroke:"#f0a02080",width:14,fill:"#f0a020"}},arc:{fill:"#f0a02030",fill_hover:"#f2c97d60",stroke:{color:"#f0a020",color_hover:"#f2c97d",width:4,dash:!1,dashGap:[5,10],dashOffset:0,cap:"round",join:"round"},point:{radius:5,stroke:"#f0a02080",width:14,fill:"#f0a020"}},arcTo:{stroke:{color:"#f0a020",color_hover:"#f2c97d",width:4,dash:!1,dashGap:[5,10],dashOffset:0,cap:"round",join:"round"},point:{radius:5,stroke:"#f0a02080",width:14,fill:"#f0a020"}},polygon:{fill:"#18a05830",fill_hover:"#03693360",stroke:{color:"#18a058",color_hover:"#036933",width:1,dash:!1,dashGap:[5,10],dashOffset:0,cap:"round",join:"round"},point:{radius:5,stroke:"#03693380",width:14,fill:"#036933"}}},dark:{background:"#000",text:{color:"#aeaeae",secondary:"#8c8c8c",stroke:"#000",size:12,family:"monospace",bold:!0},grid:{axis:"#aeaeae",grid:"#666",innerGrid:"#454545"},point:{radius:5,fill:"#e88080",width:14,stroke:"#e8808070"},line:{stroke:{color:"#f2c97d",color_hover:"#f0a020",width:4,dash:!1,dashGap:[5,10],dashOffset:0,cap:"round",join:"round"},point:{radius:5,stroke:"#f2c97d80",width:14,fill:"#f2c97d"}},arc:{fill:"#f2c97d30",fill_hover:"#f0a02060",stroke:{color:"#f2c97d",color_hover:"#f0a020",width:4,dash:!1,dashGap:[5,10],dashOffset:0,cap:"round",join:"round"},point:{radius:5,stroke:"#f2c97d80",width:14,fill:"#f2c97d"}},arcTo:{stroke:{color:"#f2c97d",color_hover:"#f0a020",width:4,dash:!1,dashGap:[5,10],dashOffset:0,cap:"round",join:"round"},point:{radius:5,stroke:"#f2c97d80",width:14,fill:"#f2c97d"}},polygon:{fill:"#63e2b730",fill_hover:"#7efbd160",stroke:{color:"#63e2b7",color_hover:"#63e2b7",width:1,dash:!1,dashGap:[5,10],dashOffset:0,cap:"round",join:"round"},point:{radius:5,stroke:"#7efbd180",width:14,fill:"#7efbd1"}}}});const{theme:e}=t;e&&this.setTheme(e),this.initStyle(),this.clearScreen()}initStyle(){const{canvas:t,ctx:e,theme:i}=this;t.classList.add("_nhanh_canvas");const n=this.style[i];e.font=`${n.text.bold?"bold":""} ${n.text.size}px ${n.text.family}`}clearScreen(t=!0){const{ctx:e,theme:i,rect:n}=this,{width:o,height:a}=n;e.clearRect(0,0,o,a),t&&this.style[i].background&&(e.fillStyle=this.style[i].background,e.fillRect(0,0,o,a))}setStyle(t){for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e)){const i=Le(this.style[e]||this.style[this.theme]);ct(i,t[e]),this.style[e]=i}this.initStyle()}setTheme(t){t in this.style&&(this.theme=t,this.isThemeUpdated=!0)}}class V extends At{constructor(t){t={...t},t.isDraggable=t.isDraggable??!1;const{mainCanvas:e,notifyReload:i}=t;delete t.mainCanvas,delete t.notifyReload;super(t);d(this,"_style");d(this,"_position");d(this,"_value");d(this,"_zIndex",0);d(this,"_dynamicPosition");d(this,"_offset",{x:0,y:0});d(this,"path");d(this,"publicToPrivateKeyMap",{offset:"_offset",position:"_position",value:"_value",dynamicPosition:"_dynamicPosition",zIndex:"_zIndex",style:"_style"});d(this,"redrawOnIsHoverChange",!0);d(this,"defaultHover",(t,e)=>{var i;this.redrawOnIsHoverChange&&((i=this.notifyReload)==null||i.call(this))});d(this,"_valueScope");d(this,"styleRadius",{value:0,radius:0});d(this,"offsetValue",{xV:0,yV:0});d(this,"fixedExtraScope",{topV:0,bottomV:0,leftV:0,rightV:0});d(this,"extraScope",{top:0,bottom:0,left:0,right:0,topV:0,bottomV:0,leftV:0,rightV:0});this.setNotifyReload(i),this.mainCanvas=e,["redrawOnIsHoverChange"].forEach(o=>{o in t&&(this[o]=t[o])});const n={};["offset","style","zIndex","position","dynamicPosition","value"].forEach(o=>{o in t&&(n[o]=t[o])}),this.internalUpdate(n),this.addEventListener("hover",this.defaultHover)}get style(){return this._style}set style(t){var e;this._style=t,this.mainCanvas&&(this.updateValueScope(),(e=this.notifyReload)==null||e.call(this))}get position(){return this._position}set position(t){var e;this._position=t,this._value=void 0,this.updateBaseData(),(e=this.notifyReload)==null||e.call(this)}get value(){return this._value}set value(t){var e;this._value=t,this._position=void 0,this.updateBaseData(),(e=this.notifyReload)==null||e.call(this)}get zIndex(){return this._zIndex}set zIndex(t){var e;this._zIndex!=t&&(this._zIndex=t,(e=this.notifyReload)==null||e.call(this))}get dynamicPosition(){return this._dynamicPosition}set dynamicPosition(t){this._dynamicPosition=t}get offset(){return this._offset}set offset(t){var e;this._offset=t,this.calculateOffsetValue(),(e=this.notifyReload)==null||e.call(this)}get finalDynamicPosition(){var i;const{x:t,y:e}=this.offset;return(i=this.dynamicPosition)==null?void 0:i.map((n,o)=>typeof n=="number"?o==0?n+t:n+e:[n[0]+t,n[1]+e])}internalUpdate(t,e){Object.keys(t).forEach(i=>{const n=this.publicToPrivateKeyMap[i];n&&(this[n]=t[i])}),e&&this.updateValueScope()}setMainCanvas(t){super.setMainCanvas(t),t&&this.updateBaseData()}setNotifyReload(t){this.notifyReload=t?e=>{var i;e&&(this.isRecalculate=!0),(e||this.isNeedRender||(i=this.mainCanvas)!=null&&i.currentDrawOverlays.includes(this))&&t()}:void 0}get valueScope(){return this._valueScope}set valueScope(t){this._valueScope=t}initValueScope(){const t=this.value;if(Array.isArray(t[0])){let e=1/0,i=-1/0,n=1/0,o=-1/0;t.forEach(([a,l])=>{e=Math.min(e,a),i=Math.max(i,a),n=Math.min(n,l),o=Math.max(o,l)}),this.valueScope={minX:e,maxX:i,minY:n,maxY:o}}else{const[e,i]=t;this.valueScope={minX:e,maxX:e,minY:i,maxY:i}}this.calculateStyleRadiusValue(!1),this.calculateOffsetValue(!1),this.setFixedExtraScope(!0),this.setExtraScope(!0)}calculateStyleRadiusValue(t=!0){if(!(!this.mainCanvas||!this.valueScope))if(t){const{radius:e,value:i}=this.styleRadius;if(e==0)return;const n=this.mainCanvas.getAxisValueByPoint(e,0).xV,o=n-i;this.valueScope.minX-=o,this.valueScope.maxX+=o,this.valueScope.minY-=o,this.valueScope.maxY+=o,this.styleRadius={radius:e,value:n}}else{const{stroke:e,point:i}=this.computedValueScopeStyles,n=i?i.radius+Math.max(0,i.width/2):0,o=e?Math.max(0,e.width/2):0,a=Math.max(n,o);if(a==0)return this.styleRadius={radius:0,value:0};const l=this.mainCanvas.getAxisValueByPoint(a,0).xV;this.valueScope.minX-=l,this.valueScope.maxX+=l,this.valueScope.minY-=l,this.valueScope.maxY+=l,this.styleRadius={radius:a,value:l}}}calculateOffsetValue(t=!0){const{mainCanvas:e,valueScope:i,offset:n,offsetValue:o}=this;if(!(!e||!i))if(t){const{x:a,y:l}=e.axisConfig;let{xV:c,yV:h}=e.getAxisValueByPoint(n.x,n.y);c*=a,h*=l;const u=c-o.xV,f=h-o.yV;i.minX+=u,i.maxX+=u,i.minY+=f,i.maxY+=f,this.offsetValue={xV:c,yV:h}}else{if(this.offsetValue={xV:0,yV:0},n.x==0&&n.y==0)return;this.calculateOffsetValue()}}setFixedExtraScope(t){if(t===!0)this.fixedExtraScope={topV:0,bottomV:0,leftV:0,rightV:0};else{const e=t||{topV:0,bottomV:0,leftV:0,rightV:0};if(this.valueScope){const{leftV:i,rightV:n,topV:o,bottomV:a}=e;this.valueScope.minX-=i-this.fixedExtraScope.leftV,this.valueScope.maxX+=n-this.fixedExtraScope.rightV,this.valueScope.minY-=o-this.fixedExtraScope.topV,this.valueScope.maxY+=a-this.fixedExtraScope.bottomV,this.fixedExtraScope=e}}}setExtraScope(t){const{valueScope:e,mainCanvas:i,extraScope:n}=this;if(!(!e||!i))if(t===!0)this.extraScope={top:0,bottom:0,left:0,right:0,topV:0,bottomV:0,leftV:0,rightV:0};else if(t){const{left:o,right:a,top:l,bottom:c}=t,{xV:h,yV:u}=i.getAxisValueByPoint(l,c),{xV:f,yV:m}=i.getAxisValueByPoint(o,a);e.minX-=f-n.leftV,e.maxX+=m-n.rightV,e.minY-=h-n.topV,e.maxY+=u-n.bottomV,this.extraScope={...t,topV:h,bottomV:u,leftV:f,rightV:m}}else this.setExtraScope(this.extraScope)}get isWithinRange(){const{mainCanvas:t,valueScope:e}=this;if(!t)return!1;const{isScaleUpdated:i,maxMinValue:n}=t;return i&&(this.calculateStyleRadiusValue(),this.calculateOffsetValue(),this.setExtraScope()),e?!(n.maxXV<e.minX||n.minXV>e.maxX||n.maxYV<e.minY||n.minYV>e.maxY):!0}get isNeedRender(){return!!(this.mainCanvas&&this.shouldRender()&&this.dynamicPosition&&this.isWithinRange)}calculateOffset(t,e){const{percentage:i,axisConfig:n}=this.mainCanvas,o=n.count/n.min/i,a={value:t*o*n.x,position:t/i*n.x,dynamicPosition:t},l={value:e*o*n.y,position:e/i*n.y,dynamicPosition:e};return{x:a,y:l}}handleValuePosition(t,e){let{value:i,position:n,mainCanvas:o}=this;if(!o)return!1;const a=t==="array1D"?ee:kt,[l,c]=[a(i)&&(!e||i.length>=e),a(n)&&(!e||n.length>=e)],h={value:i,position:n,dynamicPosition:[]};if(!l&&!c)return this.internalUpdate({dynamicPosition:void 0}),!1;if(l){const u=i;if(t==="array1D"){const f=o.getAxisPointByValue(u[0],u[1],!0);h.position=[f.x,f.y]}else{h.position=[];for(let f=0;f<u.length;f++){const m=u[f],p=o.getAxisPointByValue(m[0],m[1],!0);h.position.push([p.x,p.y])}}}else{const u=n;if(t==="array1D"){const f=o.getAxisValueByPoint(u[0],u[1],!0);h.value=[f.xV,f.yV]}else{h.value=[];for(let f=0;f<u.length;f++){const m=u[f],p=o.getAxisValueByPoint(m[0],m[1],!0);h.value.push([p.xV,p.yV])}}}return h.dynamicPosition=o.transformPosition(h.position),this.internalUpdate(h,!0),!0}isPointInAnywhere(t,e){return this.isPointInPath(t,e)||this.isPointInStroke(t,e)}setGlobalAlpha(t){var i;const e=this.opacity??((i=this.parent)==null?void 0:i.opacity);e!==void 0&&(t.globalAlpha=e)}setBaseLineStyle(t,e){const{width:i,dash:n,dashGap:o,dashOffset:a,color:l,color_hover:c,cap:h,join:u}=e;return t.setLineDash(n?o:[]),t.lineDashOffset=a,t.lineCap=h,t.lineJoin=u,t.lineWidth=i,t.strokeStyle=this.isHover?c:l,e}get cursorStyle(){return this.isInteractive?this.isDraggable?"_nhanh_canvas_hover_overlay_draggable":"_nhanh_canvas_hover_overlay":void 0}}d(V,"ctx",document.createElement("canvas").getContext("2d"));class Gt extends V{constructor(t){super(t);d(this,"_draw");this.redrawOnIsHoverChange=!1;const{draw:e}=t;Object.assign(this,{draw:e})}updateValueScope(){this.initValueScope()}isPointInPath(t,e){return!1}isPointInStroke(t,e){return!1}updateBaseData(){if(!this.mainCanvas)return;this.internalUpdate({dynamicPosition:[]});let t=this.value,e=this.position;t?e=this.convertValuesToPositions(t):e&&(t=this.convertPositionsToValues(e)),t&&e&&this.updateDataProperties(t,e)}convertValuesToPositions(t){const e=[];let i;return t.forEach(n=>{if(i===void 0){const o=this.mainCanvas.getAxisPointByValue(n[0],n[1],!0);e.push([o.x,o.y]),n[0]!=0?i=new D(o.x).div(n[0]).toNumber():n[1]!=0&&(i=new D(o.y).div(n[1]).toNumber())}else e.push([new D(i).mul(n[0]).toNumber(),new D(i).mul(n[1]).toNumber()])}),e}convertPositionsToValues(t){const e=[];let i;return t.forEach((n,o)=>{if(i===void 0){const a=this.mainCanvas.getAxisValueByPoint(n[0],n[1],!0);e.push([a.xV,a.yV]),n[0]!=0?i=new D(a.xV).div(n[0]).toNumber():n[1]!=0&&(i=new D(a.yV).div(n[1]).toNumber())}else e.push([new D(i).mul(n[0]).toNumber(),new D(i).mul(n[1]).toNumber()])}),e}updateDataProperties(t,e){this.internalUpdate({value:t,position:e,dynamicPosition:this.mainCanvas.transformPosition(e)})}setOverlayStyles(t){}get computedValueScopeStyles(){return{}}get draw(){return t=>{var e;this.setGlobalAlpha(t),(e=this._draw)==null||e.call(this,t)}}set draw(t){this._draw=t}getDraw(){if(this.isNeedRender){const{mainCanvas:t,position:e}=this;return this.isRecalculate&&e&&this.internalUpdate({dynamicPosition:t.transformPosition(e)}),[this.draw,this]}}}class O{static add(s,t){return new D(s).add(t).toNumber()}static sub(s,t){return new D(s).sub(t).toNumber()}static mul(s,t){return new D(s).mul(t).toNumber()}static div(s,t){return new D(s).div(t).toNumber()}}class Xt extends V{constructor(t){super(t);d(this,"textOffset",{x:0,y:0});d(this,"_text");d(this,"defaultDragg",(t,e)=>{var l;const{offsetX:i,offsetY:n}=t.data,{x:o,y:a}=this.calculateOffset(i,n);this.internalUpdate({value:[O.add(this.value[0],o.value),O.add(this.value[1],a.value)],position:[O.add(this.position[0],o.position),O.add(this.position[1],a.position)],dynamicPosition:[O.add(this.dynamicPosition[0],o.dynamicPosition),O.add(this.dynamicPosition[1],a.dynamicPosition)]},!0),(l=this.notifyReload)==null||l.call(this)});const{text:e}=t;Object.assign(this,{text:e}),this.addEventListener("dragg",this.defaultDragg)}get text(){return this._text}set text(t){var e;this._text!=t&&(this._text=t,this.updateBaseData(),(e=this.notifyReload)==null||e.call(this))}updateValueScope(){this.initValueScope();const t=this.textOffset;this.setExtraScope({top:t.y,bottom:t.y,left:t.x,right:t.x})}isPointInPath(t,e){return this.path?V.ctx.isPointInPath(this.path,t,e):!1}isPointInStroke(t,e){return!1}updateBaseData(){if(!this.mainCanvas)return;if(!this.text||this.text.length==0)return this.internalUpdate({dynamicPosition:void 0});const t=V.ctx;this.setOverlayStyles(t);const e=t.measureText(this.text);this.textOffset={x:e.width/2,y:e.actualBoundingBoxAscent/2},this.handleValuePosition("array1D")}setOverlayStyles(t){var o;const e=this.mainCanvas,i=e.style[e.theme].text;let n={};return typeof this.style=="string"?n=((o=e.style[this.style])==null?void 0:o.text)||i:typeof this.style=="object"?n=Object.assign({},i,this.style):n=i,t.font=`${n.bold?"bold":""} ${n.size}px ${n.family}`,t.lineWidth=2,t.strokeStyle=n.stroke,t.fillStyle=n[this.isHover?"secondary":"color"],n}get computedValueScopeStyles(){return{}}draw(t){const{text:e,textOffset:i,finalDynamicPosition:n}=this;if(!this.mainCanvas||!e)return;this.setGlobalAlpha(t),this.setOverlayStyles(t);const o=n[0]-i.x,a=n[1]+i.y;t.strokeText(e,o,a),t.fillText(e,o,a),this.path=new Path2D,this.path.rect(o,n[1]-i.y,i.x*2,i.y*2)}getDraw(){if(this.isNeedRender){if(this.isRecalculate){const{position:t,mainCanvas:e}=this;this.internalUpdate({dynamicPosition:e.transformPosition(t)})}return[this.draw,this]}}}class lt extends V{constructor(t){super(t);d(this,"angle",2*Math.PI);d(this,"defaultDragg",(t,e)=>{var l;const{offsetX:i,offsetY:n}=t.data,{x:o,y:a}=this.calculateOffset(i,n);this.internalUpdate({value:[O.add(this.value[0],o.value),O.add(this.value[1],a.value)],position:[O.add(this.position[0],o.position),O.add(this.position[1],a.position)],dynamicPosition:[O.add(this.dynamicPosition[0],o.dynamicPosition),O.add(this.dynamicPosition[1],a.dynamicPosition)]},!0),(l=this.notifyReload)==null||l.call(this)});d(this,"fillProgress");d(this,"defaultHover",(t,e)=>{const i=t.data.state,n=300,o=this.setOverlayStyles().width;this.fillProgress?this.cancelAndRestartAnimation(i,o,n-100):i&&this.startNewHoverAnimation(o,n)});this.addEventListener("hover",this.defaultHover),this.addEventListener("dragg",this.defaultDragg)}updateValueScope(){this.initValueScope()}cancelAndRestartAnimation(t,e,i){this.fillProgress.scheduleCallback();let n=0;this.fillProgress.scheduleCallback=Rt(o=>{!this.fillProgress||!o||(this.fillProgress.progress+=(o-n)*(t?1:-1),n=o,this.fillProgress.progress=Math.min(1,Math.max(0,this.fillProgress.progress)),this.updateLineWidthOffset(e),(this.fillProgress.progress===1||this.fillProgress.progress===0)&&(this.fillProgress.scheduleCallback(),this.fillProgress.progress===0&&(this.fillProgress=void 0)))},i)}startNewHoverAnimation(t,e){this.fillProgress={lineWidthOffset:0,progress:0,scheduleCallback:Rt(i=>{this.fillProgress&&(this.fillProgress.progress=i,this.updateLineWidthOffset(t))},e)}}updateLineWidthOffset(t){var i;if(!this.fillProgress)return;const e=Math.ceil(t*this.fillProgress.progress);e!==this.fillProgress.lineWidthOffset&&(this.fillProgress.lineWidthOffset=e,(i=this.notifyReload)==null||i.call(this))}isPointInPath(t,e){return this.path?V.ctx.isPointInPath(this.path,t,e):!1}isPointInStroke(t,e){var i;if(this.path&&this.mainCanvas){const{width:n}=this.setOverlayStyles(V.ctx);return((i=this.fillProgress)==null?void 0:i.lineWidthOffset)==n?!1:V.ctx.isPointInStroke(this.path,t,e)}return!1}updateBaseData(){this.handleValuePosition("array1D")}setOverlayStyles(t){var c,h;const e=this.mainCanvas,i=e.style[e.theme].point;let n={};typeof this.style=="string"?n=((c=e.style[this.style])==null?void 0:c.point)||i:typeof this.style=="object"?n=Object.assign({},i,this.style):n=i;const{width:o,stroke:a,fill:l}=n;if(t){t.setLineDash([]);const u=((h=this.fillProgress)==null?void 0:h.lineWidthOffset)||0;t.lineWidth=o-u,t.strokeStyle=a,t.fillStyle=l}return{...n}}get computedValueScopeStyles(){return{point:this.setOverlayStyles()}}draw(t){var h;const{finalDynamicPosition:e,mainCanvas:i}=this;if(!i)return;this.setGlobalAlpha(t);const{radius:n,width:o}=this.setOverlayStyles(t),a=((h=this.fillProgress)==null?void 0:h.lineWidthOffset)||0,[l,c]=e;t.beginPath(),this.path=new Path2D,this.path.arc(l,c,n+a/2,0,this.angle),o!=a&&t.stroke(this.path),t.fill(this.path)}getDraw(){if(this.isNeedRender){const{mainCanvas:t,position:e}=this;return this.isRecalculate&&this.internalUpdate({dynamicPosition:t.transformPosition(e)}),[this.draw,this]}}}class Ze extends V{constructor(t){super(t);d(this,"handlePoints",[]);d(this,"isShowHandlePoint",!1);d(this,"_isHandlePointsVisible",!0);d(this,"canCreateOrDeleteHandlePoint",!0);d(this,"lockedCanCreateOrDeleteHandlePoint",!1);d(this,"defaultClick",(t,e)=>{var o;if(!this.isHandlePointsVisible)return;const{state:i,oldState:n}=t.data;i!=n&&!this.isInfinite&&((o=this.notifyReload)==null||o.call(this))});d(this,"defaultDoubleClick",(t,e)=>{if(e){if(!this.isHandlePointsVisible)return;const{offsetX:i,offsetY:n}=e,{state:o}=t.data;if(this.lockedCanCreateOrDeleteHandlePoint)this.resetHandlePointLock();else if(o&&this.isHandlePointsVisible&&this.canCreateOrDeleteHandlePoint&&this.isDraggable){const l=this.handlePoints.findIndex(c=>c.isHover);l===-1?this.tryCreateNewHandlePoint(i,n):this.tryDeleteHandlePoint(l)}}});d(this,"defaultDragg",(t,e)=>{var n;if(!this.mainCanvas)return;const i=()=>{const{offsetX:o,offsetY:a}=t.data,{x:l,y:c}=this.calculateOffset(o,a);this.value.forEach((h,u)=>{this.value[u]=[O.add(this.value[u][0],l.value),O.add(this.value[u][1],c.value)],this.position[u]=[O.add(this.position[u][0],l.position),O.add(this.position[u][1],c.position)],this.dynamicPosition[u]=[O.add(this.dynamicPosition[u][0],l.dynamicPosition),O.add(this.dynamicPosition[u][1],c.dynamicPosition)]}),this.handlePoints.forEach((h,u)=>{h.internalUpdate({value:this.value[u],position:this.position[u],dynamicPosition:this.dynamicPosition[u]})}),this.lockedCanCreateOrDeleteHandlePoint=!0};if(this.isHandlePointsVisible){const o=this.handlePoints.findIndex(a=>a.isHover);if(o!=-1){const a=this.handlePoints[o];a.notifyDragg(t.data,e),this.value[o]=a.value,this.position[o]=a.position,this.dynamicPosition[o]=a.dynamicPosition}else i()}else i();(n=this.notifyReload)==null||n.call(this),this.updateValueScope()});["isHandlePointsVisible","canCreateOrDeleteHandlePoint"].forEach(e=>{e in t&&(this[e]=t[e])}),this.addEventListener("click",this.defaultClick),this.addEventListener("doubleClick",this.defaultDoubleClick),this.addEventListener("dragg",this.defaultDragg)}get isHandlePointsVisible(){return this._isHandlePointsVisible}set isHandlePointsVisible(t){var e;this._isHandlePointsVisible!==t&&(this._isHandlePointsVisible=t,this.isShowHandlePoint!=t&&((e=this.notifyReload)==null||e.call(this)),this.updateHandlePoints())}get offset(){return super.offset}set offset(t){super.offset=t;let{isHandlePointsVisible:e,handlePoints:i}=this;e&&i.forEach(n=>n.internalUpdate({offset:t}))}tryCreateNewHandlePoint(t,e){var c;if(!this.isPointInStroke(t,e))return;const i=this.getExtendedDynamicPositions(),n=ks([t,e],i);if(n===-1)return;const[o,a]=this.getAdjacentIndices(n),l=this.createNewHandlePoint(o,a);this.insertHandlePoint(n,l),this.lockHandlePointCreationTemporarily(),(c=this.notifyReload)==null||c.call(this)}tryDeleteHandlePoint(t){var e;!this.isDblClick||!this.canDeleteHandlePoint||(this.deleteHandlePoint(t),(e=this.notifyReload)==null||e.call(this))}getExtendedDynamicPositions(){return this.isClosed?[...this.dynamicPosition,this.dynamicPosition[0]]:this.dynamicPosition}getAdjacentIndices(t){const e=t-1,i=this.isClosed&&t===this.dynamicPosition.length?0:t;return[e,i]}createNewHandlePoint(t,e){const i=ae(this.value[t],this.value[e]),n=ae(this.position[t],this.position[e]),o=ae(this.dynamicPosition[t],this.dynamicPosition[e]);return new lt({value:i,position:n,dynamicPosition:o,isDraggable:!0,mainCanvas:this.mainCanvas,notifyReload:()=>{var a;return(a=this.notifyReload)==null?void 0:a.call(this)}})}insertHandlePoint(t,e){this.handlePoints.splice(t,0,e),this.value.splice(t,0,e.value),this.position.splice(t,0,e.position),this.dynamicPosition.splice(t,0,e.dynamicPosition)}deleteHandlePoint(t){this.handlePoints.splice(t,1),this.value.splice(t,1),this.position.splice(t,1),this.dynamicPosition.splice(t,1)}lockHandlePointCreationTemporarily(){this.lockedCanCreateOrDeleteHandlePoint=!0,setTimeout(()=>{this.lockedCanCreateOrDeleteHandlePoint=!1},300)}resetHandlePointLock(){this.lockedCanCreateOrDeleteHandlePoint=!1}get canDeleteHandlePoint(){return this.handlePoints.length>this.minNeededHandlePoints}updateHandlePoints(){let{value:t,position:e,dynamicPosition:i,offset:n,isHandlePointsVisible:o}=this;!i||!o||(t==null||t.forEach((a,l)=>{if(!this.handlePoints[l]){const c=new lt({value:[0,0],mainCanvas:this.mainCanvas,isDraggable:!0,offset:n,notifyReload:()=>{var h;return(h=this.notifyReload)==null?void 0:h.call(this)}});this.handlePoints.push(c)}this.handlePoints[l].internalUpdate({value:t[l],position:e[l],dynamicPosition:i[l]},!0)}),this.handlePoints.length=t.length)}updateHandlePointsPosition(){this.isHandlePointsVisible&&this.handlePoints.forEach((t,e)=>{t.internalUpdate({dynamicPosition:this.dynamicPosition[e]})})}}function ks(r,s,t=10){if(s.length===0)return 0;if(s.length===1)return 1;let e=1/0,i=-1;for(let n=0;n<s.length-1;n++){const o=ti(r,s[n],s[n+1]);if(o<t)return n+1;o<e&&(e=o,i=n+1)}return i}function ae(r,s){const{x:t,y:e}=Ce(...r,...s);return[t,e]}class zt extends Ze{constructor(t){super(t);d(this,"_isInfinite");d(this,"isClosed",!1);d(this,"minNeededHandlePoints",2);const{isInfinite:e}=t;Object.assign(this,{isInfinite:e}),e&&(this.canCreateOrDeleteHandlePoint=!1)}get isInfinite(){return this._isInfinite}set isInfinite(t){var e;this._isInfinite!=t&&(this._isInfinite=t,this.canCreateOrDeleteHandlePoint=!t,(e=this.notifyReload)==null||e.call(this))}updateValueScope(){this.initValueScope()}isPointInPath(t,e){return!1}isPointInStroke(t,e){return this.path&&this.mainCanvas?(this.setOverlayStyles(V.ctx),this.isDraggable&&(V.ctx.lineWidth=Math.max(V.ctx.lineWidth,20)),V.ctx.isPointInStroke(this.path,t,e)):!1}isPointInAnywhere(t,e){return(n=>{if(!n)return!1;let o=!1;return[...this.handlePoints].sort((l,c)=>(l.isHover?0:1)-(c.isHover?0:1)).forEach(l=>{o?l.isHover&&l.notifyHover(!1):(o=l.isPointInAnywhere(t,e),o!=l.isHover&&l.notifyHover(o))}),o})((this.isClick||!!this.isInfinite)&&this.isShowHandlePoint)||super.isPointInAnywhere(t,e)}get isWithinRange(){if(this.isInfinite){this.isRecalculate&&this.updateDynamicPosition();const{width:t,height:e}=this.mainCanvas.rect;return Os([0,0],[t,e],this.finalDynamicPosition[0],this.finalDynamicPosition[1])}return super.isWithinRange}updateBaseData(){this.handleValuePosition("array2D",2)&&this.updateHandlePoints()}updateDynamicPosition(){const{mainCanvas:t,position:e}=this,i=t.transformPosition(e);this.internalUpdate({dynamicPosition:i}),this.updateHandlePointsPosition()}setOverlayStyles(t){var o;const e=this.mainCanvas,i=e.style[e.theme].line;let n={};return typeof this.style=="string"?n=((o=e.style[this.style])==null?void 0:o.line)||i:typeof this.style=="object"?n=ct(JSON.parse(JSON.stringify(i)),this.style):n=i,t&&this.setBaseLineStyle(t,n.stroke),n}get computedValueScopeStyles(){return this.setOverlayStyles()}drawLine(t,e){const{mainCanvas:i,isInfinite:n,isClick:o}=this;if(e=e||this.finalDynamicPosition,!i)return;this.setGlobalAlpha(t);const a=this.setOverlayStyles(t);t.beginPath(),this.path=new Path2D,e.forEach((l,c)=>{this.path[c==0?"moveTo":"lineTo"](l[0],l[1])}),t.stroke(this.path),this.isShowHandlePoint=(n||o)&&this.isHandlePointsVisible,this.isShowHandlePoint&&this.handlePoints.forEach(l=>{var c;l.style=a.point,(c=l.getDraw())==null||c[0].call(l,t)})}drawisInfiniteStraightLine(t){const{mainCanvas:e,finalDynamicPosition:i}=this;if(!e)return;this.setGlobalAlpha(t);const{rect:n}=e,[o,a]=i,l=[a[0]-o[0],a[1]-o[1]];if(l[0]===0&&l[1]===0)return console.error("重合点无法确定方向");const c=De(o,[-l[0],-l[1]],n.width,n.height),h=De(a,l,n.width,n.height);this.drawLine(t,[c,h])}getDraw(){if(this.isNeedRender){const{isRecalculate:t,isInfinite:e}=this;return t&&this.updateDynamicPosition(),e?[this.drawisInfiniteStraightLine,this]:[this.drawLine,this]}}}function De(r,s,t,e){const[i,n]=r,[o,a]=s;let l=1/0;if(o!==0){const c=o>0?(t-i)/o:-i/o;c>0&&(l=Math.min(l,c))}if(a!==0){const c=a>0?(e-n)/a:-n/a;c>0&&(l=Math.min(l,c))}return l===1/0?r:[i+o*l,n+a*l]}function Os(r,s,t,e){const i=Math.min(r[0],s[0]),n=Math.max(r[0],s[0]),o=Math.min(r[1],s[1]),a=Math.max(r[1],s[1]),l=[[i,o],[n,o],[n,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[g,y]=t;return g>=i&&g<=n&&y>=o&&y<=a}const f=1e-10;let m=!1,p=!1;for(const[g,y]of l){const w=c*g+h*y+u;if(Math.abs(w)<f||(w>f?m=!0:p=!0,m&&p))return!0}return m&&p}class Yt extends Ze{constructor(t){super(t);d(this,"_isRect",!1);d(this,"dynamicBorderRadius");d(this,"_borderRadius");d(this,"_borderRadiusType","position");d(this,"isClosed",!0);d(this,"minNeededHandlePoints",3);["isRect","borderRadius","borderRadiusType"].forEach(e=>{e in t&&(this[e]=t[e])}),t.isRect&&(this.canCreateOrDeleteHandlePoint=!1)}get isRect(){return this._isRect}set isRect(t){var e;this._isRect!=t&&(this._isRect=t,this.canCreateOrDeleteHandlePoint=!t,this.updateBaseData(),(e=this.notifyReload)==null||e.call(this))}get borderRadius(){return this._borderRadius}set borderRadius(t){var e;this._borderRadius!=t&&(this._borderRadius=t,this.updateDynamicRadius(),(e=this.notifyReload)==null||e.call(this))}get borderRadiusType(){return this._borderRadiusType}set borderRadiusType(t){var e;this._borderRadiusType!=t&&(this._borderRadiusType=t,this.updateDynamicRadius(),(e=this.notifyReload)==null||e.call(this))}updateValueScope(){this.initValueScope()}isPointInPath(t,e){return this.path?V.ctx.isPointInPath(this.path,t,e):!1}isPointInStroke(t,e){return this.path&&this.mainCanvas?(this.setOverlayStyles(V.ctx),this.isDraggable&&(V.ctx.lineWidth=Math.max(V.ctx.lineWidth,20)),V.ctx.isPointInStroke(this.path,t,e)):!1}isPointInAnywhere(t,e){return(n=>{if(!n)return!1;let o=!1;return[...this.handlePoints].sort((l,c)=>(l.isHover?0:1)-(c.isHover?0:1)).forEach(l=>{o?l.isHover&&l.notifyHover(!1):(o=l.isPointInAnywhere(t,e),o!=l.isHover&&l.notifyHover(o))}),o})(this.isClick&&this.isShowHandlePoint)||super.isPointInAnywhere(t,e)}updateDynamicRadius(){const{mainCanvas:t,borderRadius:e}=this;if(!t||!e){this.dynamicBorderRadius=void 0;return}if(typeof e=="number"){this.dynamicBorderRadius=this.handleSingleRadius(e);return}this.dynamicBorderRadius=e.map(i=>this.handleSingleRadius(i,!0))}handleSingleRadius(t,e){const{mainCanvas:i,borderRadiusType:n}=this;if(t<=0)return e?0:void 0;switch(n){case"position":return t*i.percentage;default:return i.getAxisPointByValue(t,0).x}}updateBaseData(){if(!this.mainCanvas)return;let{value:t,position:e,isRect:i}=this;const n=i?2:3;i&&(Array.isArray(t)&&(t.length=2),Array.isArray(e)&&(e.length=2)),this.handleValuePosition("array2D",n)&&(this.updateHandlePoints(),this.updateDynamicRadius())}setOverlayStyles(t){var c;const e=this.isHover,i=this.mainCanvas,n=i.style[i.theme].polygon;let o={};typeof this.style=="string"?o=((c=i.style[this.style])==null?void 0:c.polygon)||n:typeof this.style=="object"?o=ct(JSON.parse(JSON.stringify(n)),this.style):o=n;const{fill:a,fill_hover:l}=o;return t&&(this.setBaseLineStyle(t,o.stroke),t.fillStyle=e?l:a),o}get computedValueScopeStyles(){return this.setOverlayStyles()}drawRect(t){this.setGlobalAlpha(t);const[[e,i],[n,o]]=this.finalDynamicPosition,a=Math.abs(n-e),l=Math.abs(o-i),c=Math.min(e,n),h=Math.min(i,o),u=this.setOverlayStyles(t);t.beginPath(),this.path=new Path2D,this.dynamicBorderRadius?this.path.roundRect(c,h,a,l,this.dynamicBorderRadius):this.path.rect(c,h,a,l),t.stroke(this.path),t.fill(this.path),this.isShowHandlePoint=this.isClick&&this.isHandlePointsVisible,this.isShowHandlePoint&&this.handlePoints.forEach(f=>{var m;f.internalUpdate({style:u.point}),(m=f.getDraw())==null||m[0].call(f,t)})}drawPolygon(t){this.setGlobalAlpha(t);const e=this.finalDynamicPosition,i=this.setOverlayStyles(t);t.beginPath(),this.path=new Path2D,e.forEach((n,o)=>{this.path[o==0?"moveTo":"lineTo"](n[0],n[1])}),this.path.closePath(),t.stroke(this.path),t.fill(this.path),this.isShowHandlePoint=this.isClick&&this.isHandlePointsVisible,this.isShowHandlePoint&&this.handlePoints.forEach(n=>{var o;n.internalUpdate({style:i.point}),(o=n.getDraw())==null||o[0].call(n,t)})}getDraw(){if(this.isNeedRender){const{mainCanvas:t,position:e}=this;if(this.isRecalculate){this.updateDynamicRadius();const i=t.transformPosition(e);this.internalUpdate({dynamicPosition:i}),this.updateHandlePointsPosition()}return this.isRect?[this.drawRect,this]:[this.drawPolygon,this]}}}class ge extends V{constructor(t){super(t);d(this,"_isFill",!1);d(this,"_isClosed",!1);d(this,"_isClosedThroughCenter",!1);d(this,"_radiusValue",0);d(this,"_radiusPosition",0);d(this,"_startAngle",0);d(this,"_endAngle",0);d(this,"_counterclockwise",!1);d(this,"isShowHandlePoint",!1);d(this,"_isHandlePointsVisible",!0);d(this,"defaultClick",(t,e)=>{var o;if(!this.isHandlePointsVisible)return;const{state:i,oldState:n}=t.data;i!=n&&((o=this.notifyReload)==null||o.call(this))});d(this,"defaultDragg",(t,e)=>{if(!this.mainCanvas)return;const i=()=>{var h;const{offsetX:n,offsetY:o}=t.data,{x:a,y:l}=this.calculateOffset(n,o);this.handlePointsArr.concat(this).forEach(u=>{u.internalUpdate({value:[O.add(u.value[0],a.value),O.add(u.value[1],l.value)],position:[O.add(u.position[0],a.position),O.add(u.position[1],l.position)],dynamicPosition:[O.add(u.dynamicPosition[0],a.dynamicPosition),O.add(u.dynamicPosition[1],l.dynamicPosition)]},!0)}),(h=this.notifyReload)==null||h.call(this)};if(this.isHandlePointsVisible){const{start:n,end:o,radius:a}=this.handlePoints,l=this.handlePointsArr.find(c=>c.isHover);if(l){const c=t.data.offsetX;if(l==n)this.startAngle=(this.startAngle+-c/180*Math.PI)%(Math.PI*2);else if(l==o)this.endAngle=(this.endAngle+-c/180*Math.PI)%(Math.PI*2);else if(l==a){const h=c/2/this.mainCanvas.percentage;this.radiusPosition+h>0&&(this.radiusPosition+=h)}}else i()}else i()});d(this,"handlePoints",{start:void 0,end:void 0,radius:void 0});["isFill","isClosed","isClosedThroughCenter","radiusValue","radiusPosition","startAngle","endAngle","counterclockwise","isHandlePointsVisible"].forEach(e=>{e in t&&(this["_"+e]=t[e])}),this.addEventListener("click",this.defaultClick),this.addEventListener("dragg",this.defaultDragg)}get isFill(){return this._isFill}set isFill(t){var e;this._isFill!=t&&(this._isFill=t,(e=this.notifyReload)==null||e.call(this))}get isClosed(){return this._isClosed}set isClosed(t){var e;this._isClosed!=t&&(this._isClosed=t,(e=this.notifyReload)==null||e.call(this))}get isClosedThroughCenter(){return this._isClosedThroughCenter}set isClosedThroughCenter(t){var e;this._isClosedThroughCenter!=t&&(this._isClosedThroughCenter=t,(e=this.notifyReload)==null||e.call(this))}get radiusValue(){return this._radiusValue}set radiusValue(t){this._radiusValue!=t&&(this._radiusValue=t,this._radiusPosition=0,this.updateBaseData())}get radiusPosition(){return this._radiusPosition}set radiusPosition(t){this._radiusPosition!=t&&(this._radiusPosition=t,this._radiusValue=0,this.updateBaseData())}get startAngle(){return this._startAngle}set startAngle(t){var e;this._startAngle!=t&&(this._startAngle=t,this.updateHandlePoints(),(e=this.notifyReload)==null||e.call(this))}get endAngle(){return this._endAngle}set endAngle(t){var e;this._endAngle!=t&&(this._endAngle=t,this.updateHandlePoints(),(e=this.notifyReload)==null||e.call(this))}get counterclockwise(){return this._counterclockwise}set counterclockwise(t){var e;this._counterclockwise!=t&&(this._counterclockwise=t,(e=this.notifyReload)==null||e.call(this))}get isHandlePointsVisible(){return this._isHandlePointsVisible}set isHandlePointsVisible(t){var e;this._isHandlePointsVisible!==t&&(this._isHandlePointsVisible=t,this.isShowHandlePoint!=t&&((e=this.notifyReload)==null||e.call(this)),this.updateHandlePoints())}get offset(){return super.offset}set offset(t){super.offset=t;let{isHandlePointsVisible:e,handlePointsArr:i}=this;e&&i.forEach(n=>n.internalUpdate({offset:t}))}updateValueScope(){const{mainCanvas:t,radiusValue:e}=this;t&&(this.initValueScope(),this.setFixedExtraScope({topV:e,bottomV:e,leftV:e,rightV:e*2}))}isPointInPath(t,e){return this.isFill&&this.path?V.ctx.isPointInPath(this.path,t,e):!1}isPointInStroke(t,e){return this.path&&this.mainCanvas?(this.setOverlayStyles(V.ctx),this.isDraggable&&(V.ctx.lineWidth=Math.max(V.ctx.lineWidth,20)),V.ctx.isPointInStroke(this.path,t,e)):!1}isPointInAnywhere(t,e){return(n=>{if(!n)return!1;let o=!1;return this.handlePointsArr.forEach(a=>{o?a.isHover&&a.notifyHover(!1):(o=a.isPointInAnywhere(t,e),o!=a.isHover&&a.notifyHover(o))}),o})(this.isClick&&this.isShowHandlePoint)||super.isPointInAnywhere(t,e)}get cursorStyle(){const t=this.handlePointsArr.some(e=>e==null?void 0:e.isHover);return this.isInteractive?this.isDraggable?"_nhanh_canvas_hover_overlay_draggable"+(t?"_ew":""):"_nhanh_canvas_hover_overlay":void 0}setOverlayStyles(t){var c;const e=this.isHover,i=this.mainCanvas,n=i.style[i.theme].arc;let o={};typeof this.style=="string"?o=((c=i.style[this.style])==null?void 0:c.arc)||n:typeof this.style=="object"?o=ct(JSON.parse(JSON.stringify(n)),this.style):o=n;const{fill:a,fill_hover:l}=o;return t&&(this.setBaseLineStyle(t,o.stroke),t.fillStyle=e?l:a),o}get computedValueScopeStyles(){return this.setOverlayStyles()}get handlePointsArr(){const t=this.handlePoints.radius;return Object.values(this.handlePoints).filter(Boolean).sort((e,i)=>(e.isHover||e==t?0:1)-(i.isHover||i==t?0:1))}updateHandlePoints(){let{mainCanvas:t,value:e,radiusValue:i,startAngle:n,endAngle:o,dynamicPosition:a,isHandlePointsVisible:l,offset:c}=this;if(!t||!a||!l)return;const[h,u]=As(...e,i,n,o,t.axisConfig.x,t.axisConfig.y),f=w=>new lt({name:w,offset:c,value:[0,0],isDraggable:!0,mainCanvas:this.mainCanvas,notifyReload:()=>{var C;return(C=this.notifyReload)==null?void 0:C.call(this)}}),m=this.handlePoints.start||f("start"),p=this.handlePoints.end||f("end"),g=this.handlePoints.radius||f("radius");m.value=h,p.value=u;const y=e[0]+i*2*t.axisConfig.x;g.value=[y,e[1]],this.handlePoints={start:m,end:p,radius:g}}updateBaseData(){this.mainCanvas&&(this.radiusValue?this._radiusPosition=this.mainCanvas.getAxisPointByValue(this.radiusValue,0,!0).x:this._radiusValue=this.mainCanvas.getAxisValueByPoint(this.radiusPosition,0,!0).xV,this.handleValuePosition("array1D")&&this.updateHandlePoints())}drawGuideLine(t,e,i,n){this.setBaseLineStyle(t,{...n.stroke,dash:!n.stroke.dash});const{radiusPosition:o,startAngle:a,endAngle:l,counterclockwise:c,mainCanvas:h}=this;t.beginPath(),t.arc(e,i,o*h.percentage,l,a,c),t.stroke(),t.beginPath(),t.moveTo(e,i);const u=this.handlePoints.radius.finalDynamicPosition;t.lineTo(u[0],u[1]),t.stroke(),!(this.isClosed&&this.isClosedThroughCenter)&&(t.fillStyle=t.strokeStyle,t.beginPath(),t.arc(e,i,n.point.radius,0,Math.PI*2),t.fill())}draw(t){const{finalDynamicPosition:e,mainCanvas:i,startAngle:n,endAngle:o,counterclockwise:a,isFill:l,isClosed:c,isClosedThroughCenter:h,radiusPosition:u}=this;if(!i||u<=0)return;this.setGlobalAlpha(t);const f=this.setOverlayStyles(t),[m,p]=e;t.beginPath(),this.path=new Path2D,this.path.arc(m,p,u*i.percentage,n,o,a),c&&(this.path.lineTo(m,p),h&&this.path.closePath()),t.stroke(this.path),l&&t.fill(this.path),this.isShowHandlePoint=this.isClick&&this.isHandlePointsVisible,this.isShowHandlePoint&&(this.drawGuideLine(t,m,p,f),this.handlePointsArr.forEach(g=>{var y;g.internalUpdate({style:f.point}),(y=g.getDraw())==null||y[0].call(g,t)}))}getDraw(){if(this.isNeedRender){if(this.isRecalculate){const{position:t,mainCanvas:e}=this,i=this.dynamicPosition,n=e.transformPosition(t);if(this.internalUpdate({dynamicPosition:n}),this.isHandlePointsVisible)if(e!=null&&e.isScaleUpdated)this.updateHandlePoints();else{const o=n[0]-i[0],a=n[1]-i[1];this.handlePointsArr.forEach(l=>{const c=l.dynamicPosition[0]+o,h=l.dynamicPosition[1]+a;l.internalUpdate({dynamicPosition:[c,h]})})}}return[this.draw,this]}}}function As(r,s,t,e,i,n=1,o=1){const a=r+t*Math.cos(e)*n,l=s+t*Math.sin(e)*o,c=r+t*Math.cos(i)*n,h=s+t*Math.sin(i)*o;return[[a,l],[c,h]]}class pe extends V{constructor(t){super(t);d(this,"handlePoints");d(this,"isShowHandlePoint",!1);d(this,"_isHandlePointsVisible",!0);d(this,"_radiusValue",0);d(this,"_radiusPosition",0);d(this,"defaultClick",(t,e)=>{var o;if(!this.isHandlePointsVisible)return;const{state:i,oldState:n}=t.data;i!=n&&((o=this.notifyReload)==null||o.call(this))});d(this,"defaultDragg",(t,e)=>{this.mainCanvas});["isHandlePointsVisible"].forEach(e=>{e in t&&(this["_"+e]=t[e])}),this.addEventListener("click",this.defaultClick),this.addEventListener("dragg",this.defaultDragg)}get handlePointsArr(){if(this.handlePoints){const{radius:t,other:e}=this.handlePoints;return[t,...e].filter(Boolean).sort((i,n)=>(i.isHover||i==t?0:1)-(n.isHover||n==t?0:1))}return[]}get isHandlePointsVisible(){return this._isHandlePointsVisible}set isHandlePointsVisible(t){var e;this._isHandlePointsVisible!==t&&(this._isHandlePointsVisible=t,this.isShowHandlePoint!=t&&((e=this.notifyReload)==null||e.call(this)))}get radiusValue(){return this._radiusValue}set radiusValue(t){this._radiusValue!=t&&(this._radiusValue=t,this.updateBaseData())}get radiusPosition(){return this._radiusPosition}set radiusPosition(t){this._radiusPosition!=t&&(this._radiusPosition=t,this.updateBaseData())}updateValueScope(){this.initValueScope()}isPointInPath(t,e){return!1}isPointInStroke(t,e){return this.path&&this.mainCanvas?(this.setOverlayStyles(V.ctx),this.isDraggable&&(V.ctx.lineWidth=Math.max(V.ctx.lineWidth,20)),V.ctx.isPointInStroke(this.path,t,e)):!1}isPointInAnywhere(t,e){return(n=>{if(!n)return!1;let o=!1;return this.handlePointsArr.forEach(a=>{o?a.isHover&&a.notifyHover(!1):(o=a.isPointInAnywhere(t,e),o!=a.isHover&&a.notifyHover(o))}),o})(this.isClick&&this.isShowHandlePoint)||super.isPointInAnywhere(t,e)}get cursorStyle(){var e;const t=(e=this.handlePoints)==null?void 0:e.radius.isHover;return this.isDraggable?"_nhanh_canvas_hover_overlay_draggable"+(t?"_ns":""):"_nhanh_canvas_hover_overlay"}setOverlayStyles(t){var o;const e=this.mainCanvas,i=e.style[e.theme].arcTo;let n={};return typeof this.style=="string"?n=((o=e.style[this.style])==null?void 0:o.arcTo)||i:typeof this.style=="object"?n=ct(JSON.parse(JSON.stringify(i)),this.style):n=i,t&&this.setBaseLineStyle(t,n.stroke),n}get computedValueScopeStyles(){return this.setOverlayStyles()}updateHandlePoints(){var c,h;let{value:t,position:e,dynamicPosition:i,isHandlePointsVisible:n}=this;if(!i||!n)return;const o=()=>new lt({value:[0,0],mainCanvas:this.mainCanvas,isDraggable:!0,notifyReload:()=>{var u;return(u=this.notifyReload)==null?void 0:u.call(this)}}),a=((c=this.handlePoints)==null?void 0:c.other)||[];t==null||t.forEach((u,f)=>{a[f]||a.push(o()),a[f].internalUpdate({value:t[f],position:e[f],dynamicPosition:i[f]},!0)}),a.length=t.length;const l=((h=this.handlePoints)==null?void 0:h.radius)||o();this.handlePoints={radius:l,other:a}}updateBaseData(){if(!this.mainCanvas)return;let{value:t,position:e}=this;const[i,n]=[kt(t)&&t.length>1,kt(e)&&e.length>1];if(!i&&!n)return this.handlePoints=void 0,this.internalUpdate({dynamicPosition:void 0});if(i){e=[];for(let a=0;a<t.length;a++){const l=t[a],c=this.mainCanvas.getAxisPointByValue(l[0],l[1],!0);e.push([c.x,c.y])}}else{t=[];for(let a=0;a<e.length;a++){const l=e[a],c=this.mainCanvas.getAxisValueByPoint(l[0],l[1],!0);t.push([c.xV,c.yV])}}const o=this.mainCanvas.transformPosition(e);this.internalUpdate({value:t,position:e,dynamicPosition:o}),this.updateHandlePoints()}draw(t){const{dynamicPosition:e,mainCanvas:i,radiusValue:n}=this}getDraw(){if(this.isNeedRender){if(this.isRecalculate){const{position:t,mainCanvas:e}=this,i=this.dynamicPosition,n=e.transformPosition(t);if(this.internalUpdate({dynamicPosition:n}),this.isHandlePointsVisible)if(e!=null&&e.isScaleUpdated)this.updateHandlePoints();else{const o=n[0][0]-i[0][0],a=n[0][1]-i[0][1];this.handlePointsArr.forEach(l=>{const c=l.dynamicPosition[0]+o,h=l.dynamicPosition[1]+a;l.internalUpdate({dynamicPosition:[c,h]})})}}return[this.draw,this]}}}class Is extends Rs{constructor(t){super(t);d(this,"resizeObserver");d(this,"currentDrawOverlays",[]);d(this,"rely","");d(this,"maxMinValue",{minXV:0,maxXV:0,minYV:0,maxYV:0});d(this,"measureRedrawPerformance",He(()=>{this.isRendering=!0,this.redraw(),this.redrawInNextRenderFrame=!1,this.isRendering=!1},{level:[[1,"#F56C6C"],[.5,"#E6A23C"],[0,"#67C23A"]]}));this.canvas&&(this.resizeObserver=new ResizeObserver(we(()=>{[this.canvas.width,this.canvas.height]=[this.rect.width,this.rect.height],this.redrawOnce()},200)),this.resizeObserver.observe(this.canvas)),this.updateRely(),this.isRecalculate=!1}updateRely(){const{center:t,scale:e,rect:i,axisConfig:n}=this,o=[t.x,t.y,e,JSON.stringify(n),i.width,i.height].join();this.isRecalculate=this.rely!==o,this.rely=o}redraw(){var n,o;if(!this.canvas)return console.warn("canvas is not HTMLCanvasElement");if(this.canvas.clientWidth==0||this.canvas.clientHeight==0)return console.warn("The image argument is a canvas element with a width or height of 0.");if(!this.shouldRender())return this.clearScreen(!1);this.ctx.globalAlpha=this.opacity??1,this.updateCenter(),this.updateRely(),this.maxMinValue=this.getMaxMinValue(),this.clearScreen();const t=[];let e=[];const i=(n=this.drawAxis)==null?void 0:n.drawAxisAndGrid();i&&e.push([0,i,[]]),this.layerGroups.forEach(a=>e.push(...a.fetchCanvas())),e.sort((a,l)=>a[0]-l[0]),e.forEach(([,a,l],c)=>{this.ctx.drawImage(a,0,0),l.forEach(([[h,u],f])=>{t.push([[h+c,u],f])})}),t.sort(([[a,l],c],[[h,u],f])=>{if(a!==h)return h-a;if(l!==u)return u-l;const m=p=>p instanceof Gt?5:p instanceof Xt?4:p instanceof lt?3:p instanceof zt||p instanceof ge||p instanceof pe?2:p instanceof Yt?1:0;return m(f)-m(c)}),this.currentDrawOverlays=t.map(([,a])=>a),this.isRecalculate=!1,this.isThemeUpdated=!1,this.isScaleUpdated=!1,(o=this.notifyReload)==null||o.call(this)}redrawOnce(){this.redrawInNextRenderFrame||(this.redrawInNextRenderFrame=!0,Promise.resolve().then(()=>{this.isRendering=!0,this.redraw(),this.redrawInNextRenderFrame=!1,this.isRendering=!1}))}findOverlayByPoint(t){const{offsetX:e,offsetY:i,clientX:n,clientY:o}=t,{x:a,y:l}=this.axisConfig,c=this.getMousePositionOnAxis({clientX:n-10*a,clientY:o-10*l}),h=this.getMousePositionOnAxis({clientX:n+10*a,clientY:o+10*l}),u=this.getAxisValueByPoint(c.x,c.y),f=this.getAxisValueByPoint(h.x,h.y);return[...this.currentDrawOverlays].sort((m,p)=>(m.isDraggable&&m.isClick?0:1)-(p.isDraggable&&p.isClick?0:1)).find(m=>{const p=m.valueScope;return p&&(p.maxX<u.xV||p.minX>f.xV||p.maxY<u.yV||p.minY>f.yV)?!1:m.isPointInAnywhere(e,i)})}destroy(){var t;(t=this.resizeObserver)==null||t.disconnect()}}class Ts extends Is{constructor(t){super(t);d(this,"mouseInCanvas",!1);d(this,"mouseIsDown",!1);d(this,"mouseLastPosition",{x:0,y:0});d(this,"unBind");d(this,"lastClickedOverlay");d(this,"lockNotifyClick",!1);d(this,"lastContextmenuOverlay");d(this,"defaultContextmenu",(t,e)=>{const i=this.lastClickedOverlay;i!=null&&i.isDraggable&&i.notifyClick(!1,e)});d(this,"lastPressedKey",{key:"",keyupTime:0,doubleClick:!1});d(this,"defaultWheel",(t,e)=>{this.setScale(e,t.data),this.redrawOnce()});d(this,"lastDownOverlay");d(this,"defaultDown",(t,e)=>{(e==null?void 0:e.button)==0&&(this.mouseIsDown=!0)});d(this,"lastHoverOverlay");d(this,"lastCursorStyle");d(this,"oldClientX",[]);d(this,"oldClientY",[]);this.initEvent(),this.addEventListener("contextmenu",this.defaultContextmenu),this.addEventListener("down",this.defaultDown),this.addEventListener("wheel",this.defaultWheel)}initEvent(){const{canvas:t}=this;if(!t)return console.error("canvas is not HTMLCanvasElement");const e=[{type:"click",handler:this.click.bind(this)},{type:"contextmenu",handler:this.contextmenu.bind(this)},{type:"mouseenter",handler:this.mouseenter.bind(this)},{type:"mouseleave",handler:this.mouseleave.bind(this)},{type:"keydown",handler:this.keydown.bind(this),target:window},{type:"keyup",handler:this.keyup.bind(this),target:window},{type:"wheel",handler:this.wheel.bind(this)},{type:"mousedown",handler:this.mousedown.bind(this)},{type:"mouseup",handler:this.mouseup.bind(this),target:window},{type:"mousemove",handler:this.mousemove.bind(this),target:window},{type:"touchend",handler:this.touchend.bind(this)},{type:"touchmove",handler:this.touchmove.bind(this)}];e.forEach(({type:i,handler:n,target:o=t})=>{o.addEventListener(i,n)}),this.unBind=()=>{e.forEach(({type:i,handler:n,target:o=t})=>{o.removeEventListener(i,n)})}}click(t){var i;if(!this.isClickable)return;if(this.lockNotifyClick)return this.lockNotifyClick=!1;const e=this.findOverlayByPoint(t);this.lastClickedOverlay!=e&&((i=this.lastClickedOverlay)==null||i.notifyClick(!1,t)),e==null||e.notifyClick(!0,t),this.lastClickedOverlay=e,this.notifyClick(!0,t)}contextmenu(t){var i;if(!this.isContextmenuable)return;t.preventDefault();const e=this.findOverlayByPoint(t);this.lastContextmenuOverlay!=e&&((i=this.lastContextmenuOverlay)==null||i.notifyContextmenu(!1,t)),e==null||e.notifyContextmenu(!0,t),this.lastContextmenuOverlay=e,this.notifyContextmenu(!0,t)}mouseenter(t){this.mouseInCanvas=!0}mouseleave(t){this.mouseInCanvas=!1}getStep(t){const{lastPressedKey:e}=this;return e.doubleClick?4:e.key===t&&Date.now()-e.keyupTime<300?(e.doubleClick=!0,4):1}keydown(t){const{mouseInCanvas:e,offset:i,delta:n,axisConfig:o}=this,a=t.key;if(!e||!this.isDraggable||this.isAuto)return;const l=this.getStep(a),c=this.lastClickedOverlay,u=(c==null?void 0:c.isDraggable)&&this.currentDrawOverlays.includes(c)&&(kt(c.value)?"Matrix":ee(c.value)?"Single":!1),f=(y,w)=>{if(!u)return i.x+=y*l,i.y+=w*l,!0;const C=this.getAxisValueByPoint(l,0).xV,[b,M]=[C*o.x,C*o.y];if(u==="Single"){const A=c.value;A[0]+=y*b,A[1]+=w*M}else c.value.forEach(A=>{A[0]+=y*b,A[1]+=w*M});return c.value=[...c.value],!0},m=y=>(this.setScale("center",y*n),!0),g={ArrowUp:()=>f(0,-1),ArrowDown:()=>f(0,1),ArrowLeft:()=>f(-1,0),ArrowRight:()=>f(1,0),"+":()=>m(1),"-":()=>m(-1)}[a];g!=null&&g()&&(this.redrawOnce(),t.preventDefault())}keyup(t){const{mouseInCanvas:e,lastPressedKey:i}=this;if(e){const n=t.key;i.key=n,i.keyupTime=Date.now(),i.doubleClick=!1}}wheel(t){if(!this.isWheelable)return;t.preventDefault();const{delta:e,isAuto:i}=this;if(i)return;const n=t.deltaY<0?e:-e,o=this.findOverlayByPoint(t);o==null||o.notifyWheel(n,t),this.notifyWheel(n,t)}mousedown(t){var o;if(!this.isDownable)return;const{clientX:e,clientY:i}=t;this.mouseLastPosition={x:e,y:i};const n=this.findOverlayByPoint(t);this.lastDownOverlay!=n&&((o=this.lastDownOverlay)==null||o.notifyDown(!1,t),n==null||n.notifyDown(!0,t)),this.lastDownOverlay=n,this.notifyDown(!0,t)}mouseup(t){this.mouseIsDown=!1,this.lastDownOverlay=void 0}mousemove(t){this.isAuto||(this.canvas.classList.toggle("_nhanh_canvas_draggable",this.isDraggable),this.mouseIsDown?this.handleDragMove(t):this.handleHover(t))}handleDragMove(t){if(!this.isDraggable)return;const{clientX:e,clientY:i}=t,n={x:e,y:i};if(JSON.stringify(n)==JSON.stringify(this.mouseLastPosition))return;const{lastDownOverlay:o}=this;o!=null&&o.isDraggable?this.notifyDraggOverlays(t):this.handleCanvasPan(t),this.mouseLastPosition=n,this.lockNotifyClick=!0}notifyDraggOverlays(t){const e=this.lastDownOverlay,{mouseLastPosition:i}=this,{clientX:n,clientY:o}=t;e.notifyDragg({offsetX:n-i.x,offsetY:o-i.y},t)}handleCanvasPan(t){const{clientX:e,clientY:i}=t,{offset:n,mouseLastPosition:o}=this,a=e-o.x,l=i-o.y;n.x+=a,n.y+=l,this.redrawOnce(),this.notifyDragg({offsetX:a,offsetY:l},t)}handleHover(t){if(!this.isHoverable||t.target!=this.canvas)return;const e=this.findOverlayByPoint(t);this.updateHoverState(e,t),this.notifyHover(!0,t)}updateHoverState(t,e){if(this.lastHoverOverlay===t){const n=t==null?void 0:t.cursorStyle;n!==this.lastCursorStyle&&(this.lastCursorStyle&&this.canvas.classList.remove(this.lastCursorStyle),n&&this.canvas.classList.add(n),this.lastCursorStyle=n);return}this.lastHoverOverlay&&t&&t.hasController("hover",this.lastHoverOverlay)||(this.clearHoverState(e),this.applyHoverState(t,e)),this.lastHoverOverlay=t}clearHoverState(t){this.lastHoverOverlay&&(this.lastHoverOverlay.notifyHover(!1,t),this.lastHoverOverlay.cursorStyle&&this.canvas.classList.remove(this.lastHoverOverlay.cursorStyle))}applyHoverState(t,e){t&&(t.notifyHover(!0,e),this.lastCursorStyle=t.cursorStyle,this.lastCursorStyle&&this.canvas.classList.add(this.lastCursorStyle))}touchend(t){this.oldClientX=this.oldClientY=[]}touchmove(t){if(!this.isDraggable)return;const e=t.touches;t.preventDefault();const{oldClientX:i,oldClientY:n,offset:o,delta:a,isAuto:l,isDraggable:c}=this;if(c&&!l){if(e.length===1){const{clientX:h,clientY:u}=e[0];i.length&&(o.x+=h-i[0],o.y+=u-n[0],this.redrawOnce()),this.oldClientX=[h],this.oldClientY=[u]}else if(e.length===2){const{clientX:h,clientY:u}=e[0],{clientX:f,clientY:m}=e[1];if(i.length==2){const p=ve(i[0],n[0],i[1],n[1]),g=ve(h,u,f,m),{x:y,y:w}=Ce(h,u,f,m);this.setScale({clientX:y,clientY:w},g>p?a:-a),this.redrawOnce()}this.oldClientX=[h,f],this.oldClientY=[u,m]}}}destroy(){var t;super.destroy(),(t=this.unBind)==null||t.call(this)}}class et extends At{constructor(t){super(t);d(this,"overlays",new Set);this.setNotifyReload(t.notifyReload)}setMainCanvas(t){var e;super.setMainCanvas(t),this.overlays.forEach(i=>{i.setMainCanvas(t),i.parent=this}),t&&this.overlays.size&&((e=this.notifyReload)==null||e.call(this))}setNotifyReload(t){this.notifyReload=t?e=>{e&&(this.isRecalculate=!0),(e||this.shouldRender()&&this.overlays.size)&&t()}:void 0,this.overlays.forEach(e=>e.setNotifyReload(this.notifyReload))}addOverlays(t){var e;[t].flat().forEach(i=>{i.setNotifyReload(this.notifyReload),i.setMainCanvas(this.mainCanvas),i.parent=this,this.overlays.add(i)}),(e=this.notifyReload)==null||e.call(this)}hasOverlay(t){return this.overlays.has(t)}removeOverlays(t){var e;[t].flat().forEach(i=>{this.overlays.delete(i),i.setNotifyReload(),i.setMainCanvas(),i.parent=void 0}),(e=this.notifyReload)==null||e.call(this)}clearOverlays(){var t;(t=this.notifyReload)==null||t.call(this),this.overlays.forEach(e=>{e.setNotifyReload(),e.setMainCanvas(),e.parent=void 0}),this.overlays.clear()}getOverlaysDrawingMethod(){const t=[];return this.shouldRender()&&this.overlays.size&&Array.from(this.overlays.values()).sort((e,i)=>e.zIndex-i.zIndex).forEach(e=>{if(e.equalsMainCanvas(this.mainCanvas)){const i=e.getDraw();i&&t.push([Number(e.zIndex)||0,i])}else this.overlays.delete(e)}),t}}class it extends At{constructor(t){super(t);d(this,"_zIndex",4);d(this,"canvas",document.createElement("canvas"));d(this,"ctx",this.canvas.getContext("2d"));d(this,"isReload",!1);d(this,"groups",new Map);d(this,"currentDrawOverlays",[]);this.setNotifyReload(t.notifyReload),typeof t.zIndex=="number"&&(this.zIndex=t.zIndex)}get zIndex(){return this._zIndex}set zIndex(t){var e;this._zIndex!=t&&(this._zIndex=t,(e=this.notifyReload)==null||e.call(this))}setMainCanvas(t){super.setMainCanvas(t),this.canvas.width=(t==null?void 0:t.rect.width)||0,this.canvas.height=(t==null?void 0:t.rect.height)||0,this.groups.forEach(e=>{e.setMainCanvas(t),e.parent=this})}setNotifyReload(t){this.notifyReload=t?e=>{e&&(this.isRecalculate=!0),(e||this.shouldRender()&&this.groups.size)&&t()}:void 0,this.groups.forEach(e=>this.setGroupNotifyReload(e))}setGroupNotifyReload(t){t.setNotifyReload(this.notifyReload?()=>{var e;(e=this.notifyReload)==null||e.call(this),this.isReload=!0}:void 0)}getGroup(t){return this.groups.get(t)}addGroup(t){[t].flat().forEach(e=>{e instanceof et&&(this.setGroupNotifyReload(e),e.setMainCanvas(this.mainCanvas),e.parent=this,this.groups.set(e.name,e))})}removeGroup(t){var i;let e=!1;[t].flat().forEach(n=>{n instanceof et&&(this.groups.delete(n.name),n.setNotifyReload(),n.setMainCanvas(),n.parent=void 0,e=!0)}),e&&((i=this.notifyReload)==null||i.call(this))}clearGroup(){var t;this.groups.size&&(this.groups.forEach(e=>{e.setNotifyReload(),e.setMainCanvas(),e.parent=void 0}),this.groups.clear(),(t=this.notifyReload)==null||t.call(this))}getCanvas(){if(!this.mainCanvas)return;const{rect:t,isThemeUpdated:e}=this.mainCanvas,i=this.shouldRender(),n=this.groups.size;if(i&&n){if(this.isReload||this.isRecalculate||e){this.currentDrawOverlays=[],this.isReload=!1,this.canvas.width=t.width||0,this.canvas.height=t.height||0;const o=[];this.groups.forEach(a=>{a.equalsMainCanvas(this.mainCanvas)?o.push(...a.getOverlaysDrawingMethod()):this.groups.delete(a.name)}),o.sort((a,l)=>a[0]-l[0]),o.forEach(([a,[l,c]])=>{l.call(c,this.ctx),this.currentDrawOverlays.push([[Number(this.zIndex)||0,a],c])})}return[Number(this.zIndex)||0,this.canvas,this.currentDrawOverlays]}}}class Vt extends At{constructor(t){super(t);d(this,"layers",new Map);d(this,"defaultContextmenu",(t,e)=>t.stopPropagation());d(this,"defaultClick",(t,e)=>t.stopPropagation());d(this,"defaultDoubleClick",(t,e)=>t.stopPropagation());d(this,"defaultHover",(t,e)=>t.stopPropagation());d(this,"defaultDragg",(t,e)=>t.stopPropagation());d(this,"defaultDown",(t,e)=>t.stopPropagation());this.inheritOpacity=!1,this.setNotifyReload(t.notifyReload),this.addEventListener("contextmenu",this.defaultContextmenu),this.addEventListener("click",this.defaultClick),this.addEventListener("doubleClick",this.defaultDoubleClick),this.addEventListener("hover",this.defaultHover),this.addEventListener("dragg",this.defaultDragg),this.addEventListener("down",this.defaultDown)}setMainCanvas(t){super.setMainCanvas(t),this.layers.forEach(e=>{e.setMainCanvas(t),e.parent=this})}setNotifyReload(t){this.notifyReload=t?e=>{e&&(this.isRecalculate=!0),(e||this.shouldRender()&&this.layers.size)&&t()}:void 0,this.layers.forEach(e=>e.setNotifyReload(this.notifyReload))}getLayer(t){return this.layers.get(t)}addLayer(t){[t].flat().forEach(e=>{e instanceof it&&(e.setNotifyReload(this.notifyReload),e.setMainCanvas(this.mainCanvas),e.parent=this,this.layers.set(e.name,e))})}removeLayer(t){var i;let e=!1;[t].flat().forEach(n=>{n instanceof it&&(this.layers.delete(n.name),n.setNotifyReload(),n.setMainCanvas(),n.parent=void 0,e=!0)}),e&&((i=this.notifyReload)==null||i.call(this))}clearLayers(){var t;this.layers.size&&(this.layers.forEach(e=>{e.setNotifyReload(),e.setMainCanvas(),e.parent=void 0}),this.layers.clear(),(t=this.notifyReload)==null||t.call(this))}fetchCanvas(){if(this.shouldRender()&&this.layers.size){const t=[];return this.layers.forEach(e=>{if(e.equalsMainCanvas(this.mainCanvas)){const i=e.getCanvas();i&&t.push(i)}else this.layers.delete(e.name)}),t}return[]}}class Ns extends Ts{getDefaultOverlayGroup(){var a,l,c,h,u;const s=this.layerGroups.get("默认图层群组");if(!s)return;const t=(a=s.getLayer("点位图层"))==null?void 0:a.getGroup("点位覆盖物群组"),e=(l=s.getLayer("线段图层"))==null?void 0:l.getGroup("线段覆盖物群组"),i=(c=s.getLayer("多边形图层"))==null?void 0:c.getGroup("多边形覆盖物群组"),n=(h=s.getLayer("文字图层"))==null?void 0:h.getGroup("文字覆盖物群组"),o=(u=s.getLayer("自定义绘制图层"))==null?void 0:u.getGroup("自定义绘制覆盖物群组");return{overlays_text:n,overlays_point:t,overlays_line:e,overlays_polygon:i,overlays_custom:o}}getAllOverlays(s){const t=[],e=s!==void 0?Array.isArray(s)?[...s]:[s]:Array.from(this.layerGroups.values());for(;e.length>0;){const i=e.pop();if(i instanceof Vt){if(!i.isVisible)continue;e.push(...i.layers.values())}else if(i instanceof it){if(!i.isVisible)continue;e.push(...i.groups.values())}else if(i instanceof et){if(!i.isVisible)continue;e.push(...i.overlays.values())}else i.isVisible&&t.push(i)}return t}}class Ls extends Ns{zoom(s){const{canvas:t,rect:e}=this;if(!t||!e)return console.error("canvas is not HTMLCanvasElement");this.setScale("center",s),this.redrawOnce()}zoomIn(){this.zoom(this.delta)}zoomOut(){this.zoom(-this.delta)}setStyle(s){super.setStyle(s),this.redrawOnce()}setTheme(s){super.setTheme(s),this.redrawOnce()}setAxis(s){super.setAxis(s),this.redrawOnce()}setDefaultCenter(s){super.setDefaultCenter(s),this.redrawOnce()}}class Hs extends Ls{setFitView(s=void 0,t=!1,e=[60,60,60,60],i){const n=this.getAllOverlays(s);if(n.length===0)return;const{minX:o,maxX:a,minY:l,maxY:c}=this.calculateBoundingBox(n),h=a-o,u=c-l,f=this.calculateOptimalScale(h,u,e,i),m=this.calculateOffsetDifference(o,a,l,c,e);f==this.scale&&m.x==0&&m.y==0||(t?this.applyTransformImmediately(f,m):this.animateTransform(f,m))}calculateBoundingBox(s){let t=1/0,e=-1/0,i=1/0,n=-1/0;for(const o of s){const a=o.valueScope;t=Math.min(t,a.minX),e=Math.max(e,a.maxX),i=Math.min(i,a.minY),n=Math.max(n,a.maxY)}return{minX:t,maxX:e,minY:i,maxY:n}}calculateOptimalScale(s,t,e,i){const{cycle:n,delta:o,axisConfig:a,rect:l}=this,{width:c,height:h}=l,u=Math.max(0,c-e[1]-e[3])||c,f=Math.max(0,h-e[0]-e[2])||h;if(u<=0||f<=0)return console.warn("无效的可视区域尺寸,边距设置可能不合理"),this.scale;const m=s/u,p=t/f,g=Math.max(m,p),y=a.count,w=y/a.min,C=n*o;let b;if(g>w){const M=Math.ceil(g/w);b=1-((y*M/g-a.min)/a.min+(M-2))*C}else{const M=(dt,rt,yt)=>dt<rt?yt-1:M(dt/2,rt,yt+1),A=M(w,g,0),X=Math.pow(2,A);b=1+((y/X/g-a.min)/a.min+A)*C}return i!==void 0&&(b=Math.min(i,b)),b=new D(b).div(o).round().mul(o).toNumber(),b}calculateOffsetDifference(s,t,e,i,n){const{width:o,height:a}=this.rect,{axisConfig:l,center:c}=this,h=(t+s)/2,u=(i+e)/2,f=this.getAxisPointByValue(h,u),m=this.getAxisValueByPoint((o/2-c.x)*l.x,(a/2-c.y)*l.y),p=this.getAxisPointByValue(m.xV,m.yV);return{x:Math.round(-(f.x+(n[3]-n[1])-p.x)*l.x),y:Math.round(-(f.y+(n[0]-n[2])-p.y)*l.y)}}applyTransformImmediately(s,t){this.offset={x:this.offset.x+t.x,y:this.offset.y+t.y},this.scale=s,this.updateSize(),this.redrawOnce()}animateTransform(s,t){const e=this.scale,i={...this.offset},n=300;this.isAuto=!0;const o=()=>this.isAuto=!1;(c=>this.animateOffset(i,t,n,c||o))(c=>this.animateScale(e,s,n,c||o))}animateScale(s,t,e,i){const n=t-s;let o=0;Rt(a=>{!this.isAuto||!this.canvas||!this.isInteractive||(this.setScale("center",(a-o)*n),o=a,this.redrawOnce(),a===1&&i())},e)}animateOffset(s,t,e,i){Rt(n=>{!this.isAuto||!this.canvas||!this.isInteractive||(this.offset={x:Number((s.x+t.x*n).toFixed(0)),y:Number((s.y+t.y*n).toFixed(0))},this.redrawOnce(),n===1&&i())},e)}returnToOrigin(){if(!this.isInteractive||this.scale==this.defaultScale&&this.offset.x==0&&this.offset.y==0)return;const{rect:s,axisConfig:t}=this,e=this.getDefaultCenterLocation(),i=(s.width/2-e.x)*t.x,n=(s.height/2-e.y)*t.y,o=this.getAxisValueByPoint(i,n,!0),a=this.getMousePositionOnAxis({clientX:s.x+s.width/2,clientY:s.y+s.height/2}),l=this.getAxisValueByPoint(a.x,a.y),c=t.size/this.getNowGridCount,h=Math.round((l.xV-o.xV)*t.x*c),u=Math.round((l.yV-o.yV)*t.y*c);h==0&&u==0||this.animateTransform(this.defaultScale,{x:h,y:u})}}class Fs extends Hs{toggleAxis(s){this.drawAxis.toggleAxis(s),this.redrawOnce()}togglePoint(s){const{overlays_point:t}=this.getDefaultOverlayGroup()||{};return t?(t.isVisible=s??!t.isVisible,this.redrawOnce(),t.isVisible):!1}toggleLine(s){const{overlays_line:t}=this.getDefaultOverlayGroup()||{};return t?(t.isVisible=s??!t.isVisible,this.redrawOnce(),t.isVisible):!1}togglePolygon(s){const{overlays_polygon:t}=this.getDefaultOverlayGroup()||{};return t?(t.isVisible=s??!t.isVisible,this.redrawOnce(),t.isVisible):!1}toggleLock(s){return this.isInteractive=s??!this.isInteractive,this.isInteractive}}class Bs extends Fs{static clearPathRegion(s,t){const{width:e,height:i}=s.canvas;s.save(),s.beginPath(),s.clip(t),s.clearRect(0,0,e,i),s.restore()}}class Us extends Bs{}class Gs{constructor(s){d(this,"canvas");d(this,"axis_canvas",document.createElement("canvas"));d(this,"ctx",this.axis_canvas.getContext("2d"));d(this,"isReload",!0);d(this,"show",{all:!0,grid:{main:!0,secondary:!0},axis:!0,axisText:!0});this.canvas=s,this.initAxisCanvas()}initAxisCanvas(){const{canvas:s,axis_canvas:t}=this;s&&(t.width=s.rect.width||0,t.height=s.rect.height||0)}toggleAxis(s){const t=(()=>{if(typeof s=="object"){const{all:e=!0,axis:i=!0,axisText:n=!0}=s,o=Object.assign({main:!0,secondary:!0},s.grid);return{all:e,grid:o,axis:i,axisText:n}}return typeof s=="boolean"?{all:!0,grid:{main:s,secondary:s},axis:s,axisText:s}:!this.show.all})();typeof t=="boolean"?this.show.all=t:this.show=t,this.isReload=!0}drawAxisAndGrid(){if(!(!this.canvas||!this.show.all))return(this.canvas.isRecalculate||this.isReload||this.canvas.isThemeUpdated)&&(this.isReload=!1,this.initAxisCanvas(),(this.show.grid.main||this.show.grid.secondary)&&this.drawGrid(),this.show.axis&&this.drawAxis(),this.show.axisText&&this.drawAxisText()),this.axis_canvas}color(){const{theme:s,style:t}=this.canvas;return(t[s]||t.light).grid}drawGrid(){const{canvas:s,ctx:t}=this,{rect:e,center:i,axisConfig:n}=s,{width:o,height:a}=e,l=this.color(),c=n.size,h=c/5;t.lineWidth=1;const u=(m,p)=>{const g=i.x%m>0?i.x%m:m+i.x%m;t.strokeStyle=p,t.beginPath();for(let y=0;y*m+g<=o;y++)t.moveTo(y*m+g,0),t.lineTo(y*m+g,a);t.stroke()},f=(m,p)=>{const g=i.y%m>0?i.y%m:m+i.y%m;t.strokeStyle=p,t.beginPath();for(let y=0;y*m+g<=a;y++)t.moveTo(0,y*m+g),t.lineTo(o,y*m+g);t.stroke()};this.show.grid.secondary&&(u(h,l.innerGrid),f(h,l.innerGrid)),this.show.grid.main&&(u(c,l.grid),f(c,l.grid))}drawAxis(){const{canvas:s,ctx:t}=this,{rect:e,center:i}=s,{width:n,height:o}=e,a=this.color();t.lineWidth=2,t.strokeStyle=a.axis;const l=()=>{i.y>=0&&i.y<=o&&(t.beginPath(),t.moveTo(0,i.y),t.lineTo(n,i.y),t.stroke())},c=()=>{i.x>=0&&i.x<=n&&(t.beginPath(),t.moveTo(i.x,0),t.lineTo(i.x,o),t.stroke())};l(),c()}drawText(s,t,e,i){const{canvas:n,ctx:o}=this,{theme:a}=n,l=this.canvas.style[a].text;o.font=`${l.bold?"bold":""} ${l.size}px ${l.family}`,o.strokeStyle=l.stroke,![s,t,e].includes(void 0)&&o.strokeText(s,t,e),o.fillStyle=l[i?"secondary":"color"],![s,t,e].includes(void 0)&&o.fillText(s,t,e)}drawAxisText(){const{canvas:s,ctx:t}=this,{rect:e,center:i,axisConfig:n,style:o,theme:a}=s,{width:l,height:c}=e;this.drawText();const h=g=>Math.ceil(t.measureText(g).width),u=4,f=o[a].text.size;{const g=h("0"),y=i.x<u||i.x>l+g+u,w=i.y<-(u+f)||i.y>c+f+u;!y&&!w&&this.drawText("0",i.x-g-u,i.y+f+u)}const m=s.getNowGridCount,p=n.size;{let g=i.y+f+u;g=Math.max(Math.min(g,c-u),u+f);const y=i.y>c||i.y<0;let w=i.x>0?i.x%p:i.x<0?p+i.x%p:0,C=s.getAxisValueByPoint((w-i.x)*n.x,0).xV;for(;w<=l;){const b=Wt(C),M=h(b);C!==0&&this.drawText(b,w-M/2,g,y),w+=p,C=new D(m).mul(n.x).add(C).toNumber()}}{const g=i.x>l||i.x<0;let y=i.y>0?i.y%p:i.y<0?p+i.y%p:0,w=s.getAxisValueByPoint(0,(y-i.y)*n.y).yV;for(;y<=c;){const C=Wt(w),b=h(C);let M=i.x-b-u;M=Math.max(Math.min(M,l-b-u),u),w!=0&&this.drawText(C,M,y+f/2,g),y+=p,w=new D(m).mul(n.y).add(w).toNumber()}}}}class Xs{constructor(s){d(this,"canvas");d(this,"layerGroup",new T.LayerGroup({name:"创建覆盖物图层群组"}));d(this,"overlayLayer",new T.Layer({name:"creator-layer",zIndex:9999}));d(this,"overlayGroup",new T.OverlayGroup({name:"creator-group"}));d(this,"overlay");d(this,"axisValueList");d(this,"savedLayerGroupInteractive",new Map);d(this,"axisValueLimiter");d(this,"finish");d(this,"handleMousemove",s=>{var e;if(!this.overlay||!s||(((e=this.axisValueList)==null?void 0:e.length)??0)===0)return;const t=this.getAxisValueFromEvent(s);if(t){const i=[...this.axisValueList||[],t],n=this.minPointCount-i.length;Array.from({length:n}).forEach(()=>i.push(t)),this.overlay.value=i}});d(this,"handleClick",(s,t)=>{if(!this.overlay||!t)return;const e=this.getAxisValueFromEvent(t);e&&(this.axisValueList=[...this.axisValueList||[],e],this.handleMousemove(t))});d(this,"handleContextmenu",(s,t)=>{var i,n;if(!this.overlay)return;(((i=this.axisValueList)==null?void 0:i.length)??0)>=this.minPointCount?(this.overlay.value=this.axisValueList,(n=this.finish)==null||n.call(this,this.overlay)):this.overlayGroup.removeOverlays(this.overlay),this.overlay=void 0,this.axisValueList=void 0,this.restoreLayerGroupsInteractive()});this.canvas=s,this.overlayLayer.addGroup(this.overlayGroup),this.layerGroup.addLayer(this.overlayLayer),s.setLayerGroup(this.layerGroup),s.addEventListener("click",this.handleClick),s.addEventListener("contextmenu",this.handleContextmenu),s.canvas.addEventListener("mousemove",this.handleMousemove)}create(s){if(s==="polygon")return this.createPolygon();if(s==="line")return this.createLine()}disableOtherLayerGroups(){this.canvas.layerGroups.forEach(s=>{this.layerGroup!==s&&(this.savedLayerGroupInteractive.has(s)||this.savedLayerGroupInteractive.set(s,s.isInteractive),s.isInteractive=!1)})}restoreLayerGroupsInteractive(){this.savedLayerGroupInteractive.forEach((s,t)=>{t.isInteractive=s}),this.savedLayerGroupInteractive.clear()}createLine(){return this.disableOtherLayerGroups(),this.overlay&&this.overlayGroup.removeOverlays(this.overlay),this.axisValueList=[],this.overlay=new T.Line({}),this.overlayGroup.addOverlays(this.overlay),this.overlay}createPolygon(){return this.disableOtherLayerGroups(),this.overlay&&this.overlayGroup.removeOverlays(this.overlay),this.axisValueList=[],this.overlay=new T.Polygon({}),this.overlayGroup.addOverlays(this.overlay),this.overlay}removeOverlays(s){s?this.overlayGroup.removeOverlays(s):this.overlayGroup.clearOverlays()}clear(){this.restoreLayerGroupsInteractive(),this.overlayGroup.clearOverlays(),this.overlay=void 0,this.axisValueList=void 0}destroy(){this.clear(),this.canvas.removeEventListener("click",this.handleClick),this.canvas.removeEventListener("contextmenu",this.handleContextmenu),this.canvas.canvas.removeEventListener("mousemove",this.handleMousemove)}get minPointCount(){return this.overlay instanceof T.Polygon?3:this.overlay instanceof T.Line?2:0}getAxisValueFromEvent(s){const t=this.canvas.getMousePositionOnAxis(s);if(t){const{xV:e,yV:i}=this.canvas.getAxisValueByPoint(t.x,t.y);let n=[e,i];return this.axisValueLimiter&&(n=this.axisValueLimiter(n)),n}}}class zs{static computeDefaultScale(s,t,e,i,n=.02,o=.2){const a=s/e,l=t/i;if(a>1||l>1){const m=Math.max(a,l),p=Math.floor(Math.log2(m)),g=(p+m/Math.pow(2,p)-1)*o;return 1-Math.ceil(g/n)*n}const c=Math.min(e/s,i/t),h=Math.floor(Math.log2(c)),u=(h+c/Math.pow(2,h)-1)*o;return 1+Math.floor(u/n)*n}static computeDefaultCenter(s,t,e,i){return{left:(s-e)/-2,top:(t-i)/-2}}}function Ht(r){return[r].flat(1/0)}class T extends Us{constructor(t){super(t);d(this,"overlayCreator");this.drawAxis=new Gs(this),"axisShow"in t&&this.toggleAxis(t.axisShow),this.overlayCreator=new Xs(this),this.initLayerGroups(),this.updateCenter()}initLayerGroups(){const t=new it({name:"多边形图层",zIndex:1});t.addGroup(new et({name:"多边形覆盖物群组"}));const e=new it({name:"线段图层",zIndex:2});e.addGroup(new et({name:"线段覆盖物群组"}));const i=new it({name:"点位图层",zIndex:3});i.addGroup(new et({name:"点位覆盖物群组"}));const n=new it({name:"文字图层",zIndex:4});n.addGroup(new et({name:"文字覆盖物群组"}));const o=new it({name:"自定义绘制图层",zIndex:5});o.addGroup(new et({name:"自定义绘制覆盖物群组"}));const a=new Vt({name:"默认图层群组"});a.addLayer([n,i,e,t,o]),this.setLayerGroup(a)}gteLayerGroups(t="默认图层群组"){return this.layerGroups.get(t)}setLayerGroup(t){t instanceof Vt&&(this.layerGroups.set(t.name,t),t.setNotifyReload(()=>this.redrawOnce()),t.setMainCanvas(this),t.parent=this)}removeLayerGroup(t){t instanceof Vt&&(this.layerGroups.delete(t.name),t.setNotifyReload(),t.setMainCanvas(),t.parent=void 0,this.redrawOnce())}addLayer(t){const e=this.layerGroups.get("默认图层群组");e&&e.addLayer(Ht(t))}removeLayer(t){const e=this.layerGroups.get("默认图层群组");e&&e.removeLayer(Ht(t))}addOverlay(t){const{overlays_text:e,overlays_point:i,overlays_line:n,overlays_polygon:o,overlays_custom:a}=this.getDefaultOverlayGroup()||{};Ht(t).forEach(l=>{l instanceof Xt?e==null||e.addOverlays(l):l instanceof lt?i==null||i.addOverlays(l):l instanceof zt||l instanceof ge||l instanceof pe?n==null||n.addOverlays(l):l instanceof Yt?o==null||o.addOverlays(l):l instanceof Gt&&(a==null||a.addOverlays(l))})}removeOverlay(t){const{overlays_text:e,overlays_point:i,overlays_line:n,overlays_polygon:o,overlays_custom:a}=this.getDefaultOverlayGroup()||{};Ht(t).forEach(l=>{l instanceof Xt?e==null||e.removeOverlays(l):l instanceof lt?i==null||i.removeOverlays(l):l instanceof zt?n==null||n.removeOverlays(l):l instanceof Yt?o==null||o.removeOverlays(l):l instanceof Gt&&(a==null||a.addOverlays(l))})}destroy(){super.destroy()}}d(T,"ViewFit",zs),d(T,"LayerGroup",Vt),d(T,"Layer",it),d(T,"OverlayGroup",et),d(T,"Text",Xt),d(T,"Point",lt),d(T,"Line",zt),d(T,"Polygon",Yt),d(T,"Custom",Gt),d(T,"Arc",ge),d(T,"ArcTo",pe);class Ys{constructor(s){d(this,"id");d(this,"canvas");d(this,"ctx",null);d(this,"width",0);d(this,"height",0);d(this,"resizeObserver");this.id=s}init(s){return this.canvas=document.getElementById(this.id),this.canvas?(this.ctx=this.canvas.getContext("2d"),this.ctx?(this.syncCanvasSize(),this.setupResizeListener(s),!0):(console.error("Failed to get canvas context"),!1)):(console.error(`Canvas with id ${this.id} not found`),!1)}getContext(){return this.ctx}getCanvas(){return this.canvas}getSize(){return{width:this.width,height:this.height}}syncCanvasSize(){const{canvas:s}=this;if(!s)return;const t=s.getBoundingClientRect(),e=Math.floor(t.width),i=Math.floor(t.height);s.width=e,s.height=i,this.width=e,this.height=i}setupResizeListener(s){this.canvas&&(this.resizeObserver=new ResizeObserver(()=>{this.syncCanvasSize(),s()}),this.resizeObserver.observe(this.canvas))}destroy(){this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=void 0)}}class Ws{constructor(s,t,e){d(this,"canvas");d(this,"onOffsetDelta");d(this,"onDragStart");d(this,"isDragging",!1);d(this,"lastX",0);d(this,"handleMouseDown",s=>{var t;(t=this.onDragStart)==null||t.call(this),this.isDragging=!0,this.lastX=s.clientX,window.addEventListener("mousemove",this.handleMouseMove),window.addEventListener("mouseup",this.handleMouseUp)});d(this,"handleMouseMove",s=>{if(!this.isDragging)return;const t=s.clientX-this.lastX;this.lastX=s.clientX,this.onOffsetDelta(t)});d(this,"handleMouseUp",()=>{this.isDragging=!1,window.removeEventListener("mousemove",this.handleMouseMove),window.removeEventListener("mouseup",this.handleMouseUp)});this.canvas=s,this.onOffsetDelta=t,this.onDragStart=e,this.canvas.addEventListener("mousedown",this.handleMouseDown)}destroy(){this.canvas.removeEventListener("mousedown",this.handleMouseDown),window.removeEventListener("mousemove",this.handleMouseMove),window.removeEventListener("mouseup",this.handleMouseUp)}}class js{constructor(s,t,e,i){d(this,"canvas");d(this,"getTimeSpacing");d(this,"onTimeSpacing");d(this,"minTimeSpacingMs");d(this,"maxTimeSpacingMs");d(this,"handleWheel",s=>{s.preventDefault();const t=this.canvas.getBoundingClientRect(),e=s.clientX-t.left,i=Math.max(0,Math.min(t.width,e)),n=this.getTimeSpacing(),a=(s.deltaY>0?1:-1)>0?2:.5,l=n*a,c=Math.ceil(Math.min(this.maxTimeSpacingMs,Math.max(this.minTimeSpacingMs,l)));c!==n&&this.onTimeSpacing(c,i)});this.canvas=s,this.getTimeSpacing=t,this.onTimeSpacing=e,this.minTimeSpacingMs=(i==null?void 0:i.minTimeSpacingMs)??30*1e3,this.maxTimeSpacingMs=(i==null?void 0:i.maxTimeSpacingMs)??24*60*60*1e3,this.canvas.addEventListener("wheel",this.handleWheel,{passive:!1})}destroy(){this.canvas.removeEventListener("wheel",this.handleWheel)}}class qs{constructor(s,t,e){d(this,"canvas");d(this,"getTimeAtX");d(this,"onNotify");d(this,"handleMouseMove",s=>{const t=this.canvas.getBoundingClientRect(),e=s.clientX-t.left,i=Math.max(0,Math.min(t.width,e)),n=s.clientY-t.top,o=Math.max(0,Math.min(t.height,n)),a=this.getTimeAtX(i);this.onNotify({visible:!0,canvasX:i,canvasY:o,time:a})});d(this,"handleMouseLeave",()=>{this.onNotify({visible:!1,canvasX:0,canvasY:0,time:0})});this.canvas=s,this.getTimeAtX=t,this.onNotify=e,this.canvas.addEventListener("mousemove",this.handleMouseMove),this.canvas.addEventListener("mouseleave",this.handleMouseLeave)}destroy(){this.canvas.removeEventListener("mousemove",this.handleMouseMove),this.canvas.removeEventListener("mouseleave",this.handleMouseLeave)}}const $s={easeInOutQuad:r=>r<.5?2*r*r:1-Math.pow(-2*r+2,2)/2};class Zs{constructor(s,t){d(this,"canvasManager");d(this,"offsetDrag");d(this,"wheelZoom");d(this,"mouseTimeReporter");d(this,"onMouseTimeChange");d(this,"centerTimeAnimationRunId",0);d(this,"currentTime",17807184e5);d(this,"timeSpacing",5*60*1e3);d(this,"timeSpacingInPixels",100);d(this,"styleConfig",{backgroundColor:"white",axisColor:"black",textFont:"bold 12px Arial"});d(this,"tickConfig",{heightMinor:10,heightMajor:20,labelOffsetY:25,minorTicksPerMajor:10});d(this,"onDrawOverlay");this.canvasManager=new Ys(s),this.onMouseTimeChange=t,requestAnimationFrame(()=>this.init())}init(){if(!this.canvasManager.init(()=>this.render()))return;const t=this.canvasManager.getCanvas();t&&(this.offsetDrag=new Ws(t,e=>{this.currentTime-=Math.round(e/this.timeSpacingInPixels*this.timeSpacing),this.render()},()=>{this.stopCenterTimeAnimation()}),this.wheelZoom=new js(t,()=>this.timeSpacing,(e,i)=>{const n=this.getTimeAtCanvasX(i);this.timeSpacing=e,this.setTimeAtCanvasX(n,i),this.render()}),this.centerTime=Date.now(),this.mouseTimeReporter=new qs(t,e=>this.getTimeAtCanvasX(e),e=>{var i;return(i=this.onMouseTimeChange)==null?void 0:i.call(this,e)}),this.render())}render(){var i;const s=this.canvasManager.getContext();if(!s)return;this.renderBackground();const{width:t,height:e}=this.canvasManager.getSize();(i=this.onDrawOverlay)==null||i.call(this,s,t,e),this.renderAxis()}renderBackground(){const s=this.canvasManager.getContext(),{width:t,height:e}=this.canvasManager.getSize(),{backgroundColor:i}=this.styleConfig;s&&(s.clearRect(0,0,t,e),s.fillStyle=i,s.fillRect(0,0,t,e))}renderAxis(){const s=this.canvasManager.getContext();if(!s)return;const{timeSpacing:t,timeSpacingInPixels:e,styleConfig:{textFont:i,axisColor:n},tickConfig:{minorTicksPerMajor:o,heightMajor:a,heightMinor:l,labelOffsetY:c}}=this,{startTimeMs:h,startX:u,endX:f}=this.axisDrawingRange;s.fillStyle=n,s.font=i,s.textAlign="center",s.textBaseline="top";const m=e/o;let p=h,g=0,y=u;for(;y<=f;){const w=g%o===0,C=w?a:l;if(s.fillRect(y,0,1,C),w){const b=ke(p,"MM-DD hh:mm:ss");s.fillText(b,y,c),p+=t}y+=m,g++}}get axisDrawingRange(){const{currentTime:s,timeSpacing:t,timeSpacingInPixels:e}=this,{width:i}=this.canvasManager.getSize(),n=s%t,o=Math.round(n/t*e),a=s-n,l=i/e,c=Math.ceil((s+l*t)/t)*t,h=-o+(c-a)/t*e;return{startTimeMs:a,startX:-o,endX:h}}get centerTime(){const{width:s}=this.canvasManager.getSize();return this.currentTime+s/2/this.timeSpacingInPixels*this.timeSpacing}set centerTime(s){const{width:t}=this.canvasManager.getSize(),{timeSpacing:e,timeSpacingInPixels:i}=this;this.currentTime=s-t/2/i*e}getTimeAtCanvasX(s){return this.currentTime+s/this.timeSpacingInPixels*this.timeSpacing}setTimeAtCanvasX(s,t){this.currentTime=s-t/this.timeSpacingInPixels*this.timeSpacing}getCanvasXAtTime(s){return(s-this.currentTime)/this.timeSpacing*this.timeSpacingInPixels}animateCenterTimeTo(s,t){const e=this.centerTime,i=e-s;if(!i)return;const n=++this.centerTimeAnimationRunId,o=(t==null?void 0:t.durationFrames)??(()=>{const h=Math.abs(i)/this.timeSpacing*.25,u=Math.min(5,Math.max(.5,h));return Math.max(1,Math.round(u*60))})(),a=(t==null?void 0:t.curve)??$s.easeInOutQuad;Re(0,1,o,l=>{const c=a(Math.min(1,Math.max(0,l)));n===this.centerTimeAnimationRunId&&(this.centerTime=e-i*c,this.render())},4)}stopCenterTimeAnimation(){this.centerTimeAnimationRunId++}destroy(){var s,t,e;(s=this.offsetDrag)==null||s.destroy(),(t=this.wheelZoom)==null||t.destroy(),(e=this.mouseTimeReporter)==null||e.destroy(),this.canvasManager.destroy()}}class Qs extends Zs{drawTimeRangeRoundedRect(s){const t=this.canvasManager.getContext();if(!t)return;const e=this.canvasManager.getSize(),{startTimeMs:i,endTimeMs:n,y:o=1,height:a=e.height-1,radius:l=10,fillStyle:c="#2080f029",strokeStyle:h="#2080f0",lineWidth:u=1}=s,f=this.getCanvasXAtTime(i),p=this.getCanvasXAtTime(n)-f;p&&(c&&(t.fillStyle=c),h&&(t.strokeStyle=h),t.lineWidth=u,t.beginPath(),typeof t.roundRect=="function"?t.roundRect(f,o,p,a-o,l):t.rect(f,o,p,a-o),c&&t.fill(),h&&t.stroke())}}function Js(r){const s=we(r,100);let t=0,e=0;return function(i){const n=i.target;if(!n||!(n instanceof Element))return;const{scrollTop:o,scrollHeight:a,clientHeight:l,scrollLeft:c,scrollWidth:h,clientWidth:u}=n;function f(){if(t==o)return;const p=t>o;if(t=o,p)return;a-o-l<=1&&s("vertical")}function m(){if(e==c)return;const p=e>c;if(e=c,p)return;h-c-u<=1&&s("horizontal")}f(),m()}}function Ks(r,s,t){const{isClickAllowed:e,uiLibrary:i=["naiveUI","ElementPlus","Element"]}=t||{},n=function(l){const c=[];for(const h in l)Object.hasOwnProperty.call(l,h)&&i.includes(h)&&c.push(...l[h]);return c}({naiveUI:[".v-binder-follower-container",".n-image-preview-container",".n-modal-container"],ElementPlus:[".el-popper"],Element:[".el-popper"]});function o(){s(),document.removeEventListener("mousedown",a)}function a(l){if(e){const u=e(l);if(u)return;if(u===!1)return o()}const c=l.target;if(!(c instanceof Element)||!c.isConnected)return;r.concat(n).some(u=>!!(c!=null&&c.closest(u)))||o()}requestAnimationFrame(()=>document.addEventListener("mousedown",a))}var Y,ft,mt,xt,Pt,Z,Q,st,Ct;class tn{constructor(){I(this,Y);I(this,ft,!1);I(this,mt,{});I(this,xt,0);I(this,Pt,0);I(this,Z,0);I(this,Q,0);I(this,st);I(this,Ct)}init(s,t){E(this,Y,s),E(this,st,t==null?void 0:t.limit),E(this,Ct,t==null?void 0:t.dragDom),E(this,mt,{mousedown:this.mousedown.bind(this),mousemove:this.mousemove.bind(this),mouseup:this.mouseup.bind(this)}),this.bindOrUnbindEvent("bind")}finish(){this.bindOrUnbindEvent("unbind")}bindOrUnbindEvent(s){const t=s==="bind"?"addEventListener":"removeEventListener";if(!x(this,Y))return console.error("No DOM");x(this,Y)[t]("mousedown",x(this,mt).mousedown),document[t]("mousemove",x(this,mt).mousemove),document[t]("mouseup",x(this,mt).mouseup)}alterLocation(){if(!x(this,Y))return console.error("No DOM");x(this,st)&&(E(this,Z,Math.min(x(this,Z),x(this,st).max.top)),E(this,Z,Math.max(x(this,Z),x(this,st).min.top)),E(this,Q,Math.min(x(this,Q),x(this,st).max.left)),E(this,Q,Math.max(x(this,Q),x(this,st).min.left))),x(this,Y).style.setProperty("--top",x(this,Z)+"px"),x(this,Y).style.setProperty("--left",x(this,Q)+"px")}mousedown(s){if(!x(this,Y))return console.error("No DOM");if(x(this,Ct)&&s.target!=x(this,Ct))return;document.body.classList.add("no-select"),E(this,ft,!0);const t=x(this,Y).getBoundingClientRect(),{pageX:e,pageY:i}=s;E(this,xt,e),E(this,Pt,i),E(this,Z,t.y),E(this,Q,t.x)}mousemove(s){const{pageX:t,pageY:e}=s;x(this,ft)&&(E(this,Z,x(this,Z)+(e-x(this,Pt))),E(this,Q,x(this,Q)+(t-x(this,xt))),E(this,xt,t),E(this,Pt,e),this.alterLocation())}mouseup(){x(this,ft)&&(E(this,ft,!1),document.body.classList.remove("no-select"))}}Y=new WeakMap,ft=new WeakMap,mt=new WeakMap,xt=new WeakMap,Pt=new WeakMap,Z=new WeakMap,Q=new WeakMap,st=new WeakMap,Ct=new WeakMap;var W,gt,pt,bt,_t,j,q,U,St,Mt;class en{constructor(){I(this,W);I(this,gt,!1);I(this,pt,{});I(this,bt,0);I(this,_t,0);I(this,j,0);I(this,q,0);I(this,U);I(this,St);I(this,Mt)}init(s,t={}){E(this,W,s),E(this,U,t.limit),E(this,St,t.update_move),E(this,Mt,t.update_up),E(this,pt,{mousedown:this.mousedown.bind(this),mousemove:this.mousemove.bind(this),mouseup:this.mouseup.bind(this)}),this.bindOrUnbindEvent("bind")}finish(){this.bindOrUnbindEvent("unbind")}bindOrUnbindEvent(s){const t=s==="bind"?"addEventListener":"removeEventListener";if(!x(this,W))return console.error("No DOM");x(this,W)[t]("mousedown",x(this,pt).mousedown),document[t]("mousemove",x(this,pt).mousemove),document[t]("mouseup",x(this,pt).mouseup)}updateValue(){const s={top:x(this,j),left:x(this,q),percentage:{top:0,left:0}};if(x(this,U)){const t=e=>x(this,U)?(s[e]-x(this,U).min[e])/(x(this,U).max[e]-x(this,U).min[e]):0;s.percentage={top:t("top")||0,left:t("left")||0}}return s}alterLocation(){if(!x(this,W))return console.error("No DOM");x(this,U)&&(E(this,j,Math.min(x(this,j),x(this,U).max.top)),E(this,j,Math.max(x(this,j),x(this,U).min.top)),E(this,q,Math.min(x(this,q),x(this,U).max.left)),E(this,q,Math.max(x(this,q),x(this,U).min.left))),x(this,St)&&x(this,St).call(this,this.updateValue()),x(this,W).style.setProperty("--top",x(this,j)+"px"),x(this,W).style.setProperty("--left",x(this,q)+"px")}mousedown(s){if(!x(this,W))return console.error("No DOM");document.body.classList.add("no-select"),E(this,gt,!0);const t=x(this,W).getBoundingClientRect();E(this,_t,t.y),E(this,bt,t.x);const{pageX:e,pageY:i}=s;E(this,j,i-x(this,_t)),E(this,q,e-x(this,bt)),this.alterLocation()}mousemove(s){const{pageX:t,pageY:e}=s;x(this,gt)&&(E(this,j,e-x(this,_t)),E(this,q,t-x(this,bt)),this.alterLocation())}mouseup(){x(this,gt)&&(E(this,gt,!1),document.body.classList.remove("no-select"),x(this,Mt)&&x(this,Mt).call(this,this.updateValue()))}}W=new WeakMap,gt=new WeakMap,pt=new WeakMap,bt=new WeakMap,_t=new WeakMap,j=new WeakMap,q=new WeakMap,U=new WeakMap,St=new WeakMap,Mt=new WeakMap;function re(r){if(typeof r=="string"){const s=document.querySelector(r);if(s)return s;console.error(`Element "${r}" not found`)}else return r||document.documentElement}function Qe(r){const s=re(r);return s?s.requestFullscreen?s.requestFullscreen():s.mozRequestFullScreen?s.mozRequestFullScreen():s.webkitRequestFullscreen?s.webkitRequestFullscreen():s.msRequestFullscreen?s.msRequestFullscreen():Promise.reject("No Fullscreen API"):Promise.reject("No Element")}function Je(){const r=document;return document.exitFullscreen?document.exitFullscreen():r.mozCancelFullScreen?r.mozCancelFullScreen():r.webkitExitFullscreen?r.webkitExitFullscreen():r.msExitFullscreen?r.msExitFullscreen():Promise.reject("No ExitFullscreen API")}function Pe(r){const s=re(r),t=document,e=document.fullscreenElement||t.webkitFullscreenElement||t.mozFullScreenElement||t.msFullscreenElement;return s==e||!r&&window.innerWidth==screen.width&&window.innerHeight==screen.height}function sn(r){if(r=re(r),!!r)return function(){Pe(r)?Je():Qe(r)}}function nn(r,s){const t=re(s);if(!t)return;const e=()=>{r(Pe(t))};return document.addEventListener("fullscreenchange",e),document.addEventListener("webkitfullscreenchange",e),document.addEventListener("mozfullscreenchange",e),document.addEventListener("MSFullscreenChange",e),e(),()=>{document.removeEventListener("fullscreenchange",e),document.removeEventListener("webkitfullscreenchange",e),document.removeEventListener("mozfullscreenchange",e),document.removeEventListener("MSFullscreenChange",e)}}function rn(r,s){if(typeof r=="number")return r;if(/px/.test(r))return Number(r.replace(/px/,""))||0;const t=document.createElement("div");t.style.width=r,s=s||document.body,s.appendChild(t);const e=t.getBoundingClientRect().width;return s.removeChild(t),e}function on(r,s){if(!r)return;let t,e;if(typeof s=="string"){const n=document.querySelector(s);if(!n)return;const o=n.getBoundingClientRect();t=o.width,e=o.height}else if(Array.isArray(s))t=s[0],e=s[1];else{const n=s.getBoundingClientRect();t=n.width,e=n.height}const i=t/e;return i>r?[r*e,e]:i<r?[t,t/r]:[t,e]}function an(r,s=5e3){return new Promise((t,e)=>{const i=new Image;i.src=r;const n=setTimeout(()=>{e(new Error("图片加载超时")),i.onload=null,i.onerror=null},s);i.onload=()=>{clearTimeout(n);const o=i.naturalWidth,a=i.naturalHeight,l=o/a;t([i,l])},i.onerror=()=>{clearTimeout(n),e(new Error("图片加载失败"))},i.crossOrigin="Anonymous"})}function ln(r){const t=document.getElementById(r).querySelectorAll("img"),e=t.length,i=[];let n=0;return e===0?Promise.resolve({allLoaded:!0,loaded:0,failed:0,total:0,errors:[]}):new Promise(o=>{const a=()=>{n===e&&o({allLoaded:i.length===0,loaded:e-i.length,failed:i.length,total:e,errors:i})};t.forEach(l=>{if(l.complete){l.naturalWidth===0&&i.push(l),n++,a();return}l.addEventListener("load",()=>{n++,a()},{once:!0}),l.addEventListener("error",()=>{i.push(l),n++,a()},{once:!0})})})}function cn(r){return new Promise((s,t)=>{fetch(r).then(e=>s(e.text())).catch(e=>{console.error("Error fetching :",e),t(e)})})}function Ke(r){const{href:s,fileName:t,onProgress:e,timeout:i=3e4,autoDownload:n=!0}=r;let o,a=!1,l=null,c;const h=t||jt(s,"downloaded_file");c=decodeURIComponent(h);const u=()=>{if(!l)return;const g=URL.createObjectURL(l),y=document.createElement("a");y.href=g,y.download=c,y.click(),URL.revokeObjectURL(g)};return{promise:new Promise((g,y)=>{try{o=new XMLHttpRequest,o.open("GET",s),o.responseType="blob",o.timeout=i,o.ontimeout=()=>{a||y(new Error(`请求超时(已超过${i/1e3}秒)`))},o.addEventListener("progress",w=>{if(w.lengthComputable&&!a){const C=w.loaded/w.total*100;e==null||e(Number(C.toFixed(2)))}}),o.addEventListener("load",()=>{a||(o.status>=200&&o.status<300?(l=o.response,n&&u(),g(o.response)):y(new Error(`下载失败,状态码: ${o.status}`)))}),o.addEventListener("error",()=>{a||y(new Error("网络错误,下载失败"))}),o.addEventListener("abort",()=>{a||(a=!0,y(new Error("下载已被中止")))}),o.send()}catch(w){a||y(w)}}),abort:()=>!a&&o.abort(),download:()=>{!a&&l&&u()}}}function hn(r,s,t){if(!t){let n=s.replace(/^[^.]+./,"");n=n==s?"text/plain":"application/"+n,t={type:n}}const e=new Blob(r,t),i=URL.createObjectURL(e);Ke({href:i,fileName:s})}const un=Math.PI/2,Kt=Math.PI/180,te=6378137,dn=85.05112878;function fn(r,s){const t=Math.max(Math.min(r,180),-180),e=Math.max(Math.min(s,dn),-85.05112878),i=t*Kt*te,n=e*Kt,o=Math.log(Math.tan(Math.PI/4+n/2))*te;return[i,o]}function mn(r,s){const t=r/te/Kt,e=(2*Math.atan(Math.exp(s/te))-un)/Kt;return[t,e]}function ti(r,s,t){const[e,i]=r,[n,o]=s,[a,l]=t,c=(a-n)**2+(l-o)**2;if(c===0)return Math.sqrt((e-n)**2+(i-o)**2);let h=((e-n)*(a-n)+(i-o)*(l-o))/c;return h=Math.max(0,Math.min(1,h)),Math.sqrt((e-(n+h*(a-n)))**2+(i-(o+h*(l-o)))**2)}function gn(r,s,t,e,i,n=1,o=1){const a=r+t*Math.cos(e)*n,l=s+t*Math.sin(e)*o,c=r+t*Math.cos(i)*n,h=s+t*Math.sin(i)*o;return[[a,l],[c,h]]}function ve(r,s,t,e){return Math.hypot(Math.abs(t-r),Math.abs(e-s))}function Ce(r,s,t,e){const i=(r+t)/2,n=(s+e)/2;return{x:i,y:n}}function pn(r,s,t,e){const[i,n]=r,[o,a]=s;let l=1/0;if(o!==0){const c=o>0?(t-i)/o:-i/o;c>0&&(l=Math.min(l,c))}if(a!==0){const c=a>0?(e-n)/a:-n/a;c>0&&(l=Math.min(l,c))}return l===1/0?r:[i+o*l,n+a*l]}const vn=new Set(["sin","cos","tan","asin","acos","atan","atan2"]),yn=new Proxy(Math,{get(r,s){return vn.has(s)?function(...t){const e=t.map(i=>i/180*Math.PI);return r[s](...e)}:r[s]},set(){throw new Error("DegreeMath 是只读的,不能修改属性")},deleteProperty(){throw new Error("DegreeMath 是只读的,不能删除属性")}});class wt{constructor(s,t){d(this,"resolve");d(this,"reject");this.resolve=s,this.reject=t}run(s){var t,e;return s instanceof Promise?s.then(i=>{var n;return(n=this.resolve)==null||n.call(this),i}).catch(i=>{var n;return(n=this.reject)==null||n.call(this),Promise.reject(i)}):s?(t=this.resolve)==null||t.call(this):(e=this.reject)==null||e.call(this),s}}class wn extends wt{constructor(s){super(),this.resolve=s}warning(...s){const t=()=>{var e,i;return(i=(e=vt.tips).warning)==null?void 0:i.call(e,...s)};return new wt(this.resolve,t)}error(...s){const t=()=>{var e,i;return(i=(e=vt.tips).error)==null?void 0:i.call(e,...s)};return new wt(this.resolve,t)}}class xn extends wt{constructor(s){super(),this.reject=s}info(...s){const t=()=>{var e,i;return(i=(e=vt.tips).info)==null?void 0:i.call(e,...s)};return new wt(t,this.reject)}success(...s){const t=()=>{var e,i;return(i=(e=vt.tips).success)==null?void 0:i.call(e,...s)};return new wt(t,this.reject)}}const B=class B{constructor(){if(new.target===B)throw new Error("请直接使用静态方法,而不是实例化此类")}static register(s,t){if(typeof t!="function")return console.error("TipHandler must be a function");B.tips[s]=t}static resolveTip(s){return function(...t){const e=()=>{var i,n;return(n=(i=B.tips)[s])==null?void 0:n.call(i,...t)};return new wn(e)}}static rejectTip(s){return function(...t){const e=()=>{var i,n;return(n=(i=B.tips)[s])==null?void 0:n.call(i,...t)};return new xn(e)}}};d(B,"tips",{info:void 0,success:void 0,warning:void 0,error:void 0}),d(B,"info",B.resolveTip("info")),d(B,"success",B.resolveTip("success")),d(B,"warning",B.rejectTip("warning")),d(B,"error",B.rejectTip("error"));let vt=B;exports.EXTENSION_TO_MIME=Ve;exports.FILE_EXTENSIONS=Ft;exports.PAPER_SIZE_DEFINITIONS=ye;exports.PAPER_SIZE_OPTIONS=ni;exports.UNIT_LABELS=le;exports.WINDOW_TARGET=si;exports._Animate_CreateOscillator=ri;exports._Animate_NumericTransition=Re;exports._Animate_Schedule=Rt;exports._Blob_ConvertDataToImageUrl=oi;exports._Browser_CalculatePrintableArea=Ri;exports._Browser_CopyToClipboard=Vi;exports._Browser_GetFrameRate=Di;exports._Browser_SameOriginTabManager=Dt;exports._Canvas_Axis=T;exports._Canvas_TimeAxis=Qs;exports._Element_CalculateCanvasSize=on;exports._Element_CheckImagesLoaded=ln;exports._Element_CloseOnOutsideClick=Ks;exports._Element_Drag=tn;exports._Element_EnterFullscreen=Qe;exports._Element_ExitFullscreen=Je;exports._Element_Fullscreen=sn;exports._Element_FullscreenObserver=nn;exports._Element_GetOtherSizeInPixels=rn;exports._Element_IsFullscreen=Pe;exports._Element_LoadImage=an;exports._Element_LocalDrag=en;exports._Element_ScrollEndListener=Js;exports._File_CreateAndDownload=hn;exports._File_Download=Ke;exports._File_Read=cn;exports._Format_CamelCase=ui;exports._Format_CapitalizeFirstLetter=ai;exports._Format_ChunkArray=gi;exports._Format_ExcludeSubstring=di;exports._Format_FileSize=hi;exports._Format_HrefName=jt;exports._Format_MillisecondToReadable=mi;exports._Format_NumberWithCommas=Wt;exports._Format_NumberWithUnit=ci;exports._Format_Percentage=li;exports._Format_Timestamp=ke;exports._Format_ToggleInvisibleChars=fi;exports._Math_CalculateDistance2D=ve;exports._Math_Degree=yn;exports._Math_GetArcPoints=gn;exports._Math_GetBoundaryIntersection=pn;exports._Math_GetMidpoint=Ce;exports._Math_LngLatToPlane=fn;exports._Math_PlaneToLngLat=mn;exports._Math_PointToLineDistance=ti;exports._Tip=vt;exports._Utility_Clone=Le;exports._Utility_Debounce=we;exports._Utility_ExecuteWhenIdle=Ci;exports._Utility_GenerateUUID=$t;exports._Utility_GetTargetByPath=_i;exports._Utility_MergeObjects=ct;exports._Utility_RotateList=Mi;exports._Utility_SetTargetByPath=Si;exports._Utility_Sleep=Ei;exports._Utility_Throttle=bi;exports._Utility_TimeConsumption=He;exports._Utility_WaitForCondition=Ne;exports._Valid_CheckConnectionWithXHR=xi;exports._Valid_DataType=qt;exports._Valid_DoesInfiniteLineIntersectRectangle=yi;exports._Valid_FileTypeChecker=ce;exports._Valid_Is2DNumberArray=kt;exports._Valid_IsInMargin=pi;exports._Valid_IsNumberArray=ee;exports._Valid_IsPointInPolygon=vi;exports._Valid_IsSecureContext=wi;
|