gis-common 4.2.3 → 4.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/dist/constant/ErrorTypeConstant.d.ts +11 -7
- package/dist/core/Color.d.ts +66 -0
- package/dist/core/HashMap.d.ts +1 -1
- package/dist/core/index.d.ts +1 -0
- package/dist/gis-common.es.js +1154 -1084
- package/dist/gis-common.umd.js +1 -1
- package/dist/utils/AssertUtil.d.ts +1 -1
- package/dist/utils/CommUtil.d.ts +1 -1
- package/dist/utils/CoordsUtil.d.ts +14 -6
- package/dist/utils/index.d.ts +0 -1
- package/package.json +1 -1
- package/dist/utils/ColorUtil.d.ts +0 -37
package/dist/gis-common.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("mqtt-browser")):"function"==typeof define&&define.amd?define(["exports","mqtt-browser"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self)["gis-common"]={},t.mqttBrowser)}(this,(function(t,e){"use strict";var n=Object.defineProperty,r=(t,e,r)=>((t,e,r)=>e in t?n(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r)(t,"symbol"!=typeof e?e+"":e,r),s=(t=>(t.MAP_RENDER="mapRender",t.MAP_READY="mapReady",t.MOUSE_CLICK="click",t.MOUSE_DOUBLE_CLICK="dblclick",t.MOUSE_MOVE="mousemove",t.MOUSE_IN="mousein",t.MOUSE_OUT="mouseout",t.MOUSE_RIGHT_CLICK="mouseRightClick",t.KEY_DOWN="keyDown",t.KEY_UP="keyUp",t.DRAW_ACTIVE="drawActive",t.DRAW_MOVE="drawMove",t.DRAW_COMPLETE="drawComplete",t.MQTT_CONNECT="mqttConnect",t.MQTT_ERROR="mqttError",t.MQTT_MESSAGE="mqttMessage",t.MQTT_CLOSE="mqttClose",t.WEB_SOCKET_CONNECT="webSocketConnect",t.WEB_SOCKET_ERROR="webSocketError",t.WEB_SOCKET_MESSAGE="webSocketMessage",t.WEB_SOCKET_CLOSE="webSocketClose",t))(s||{}),o=(t=>(t.LOGIN_EXPIRED="登录信息过期,请重新登录",t.CROSS_ERROR="跨域访问",t.UNEXIST_RESOURCE="资源不存在",t.TIMEOUT="请求超时",t.INTERNAL_ERROR="内部错误",t.NETWORK_ERROR="请求失败,请检查网络是否已连接",t.PROCESS_FAIL="处理失败",t.AUTH_VERIFY_ERROR="权限验证失败",t.NO_DATA_FOUND="未找到数据",t.DUPLICATE_INSTANCE="实例为单例模式,不允许重复构建",t.COORDINATE_ERROR="坐标验证失败",t.JSON_PARSE_ERROR="JSON解析失败,格式有误",t.JSON_VALUE_ERROR="JSON无此键",t.PARAMETER_ERROR="验证数据类型失败",t.PARAMETER_ERROR_ARRAY="格式类型验证失败:必须是数组",t.PARAMETER_ERROR_STRING="格式类型验证失败:必须是字符",t.PARAMETER_ERROR_FUNCTION="格式类型验证失败:必须是函数",t.PARAMETER_ERROR_OBJECT="格式类型验证失败:必须是对象",t.PARAMETER_ERROR_LACK="参数缺失",t.STRING_CHECK_LOSS="字符缺少关键字",t))(o||{}),a=(t=>(t.SUPER_MAP_IMAGES="SuperMapImages",t.SUPER_MAP_DATA="SuperMapData",t.ARC_GIS_MAP_IMAGES="ArcGisMapImages",t.ARC_GIS_MAP_DATA="ArcGisMapData",t.OSGB_LAYER="OSGBLayer",t.S3M_GROUP="S3MGroup",t.TERRAIN_LAYER="TerrainFileLayer",t))(a||{}),i=(t=>(t.POINT="point",t.POLYLINE="polyline",t.POLYGON="polygon",t.BILLBOARD="billboard",t.CYLINDER="cylinder",t.ELLIPSOID="ellipsoid",t.LABEL="label",t.MODEL="model",t.WALL="wall",t))(i||{}),l=(t=>(t.DASH="10,5",t.DOT="3",t.DASHDOT="10,3,3,3",t.DASHDOTDOT="10,3,3,3,3,3",t))(l||{}),c=(t=>(t.DISTANCE="distance",t.AREA="area",t.HEIGHT="height",t))(c||{}),h=(t=>(t.ADD="add",t.REMOVE="remove",t.INIT="init",t))(h||{});const u={DEG2RAD:Math.PI/180,RAD2DEG:180/Math.PI,randInt:(t,e)=>t+Math.floor(Math.random()*(e-t+1)),randFloat:(t,e)=>t+Math.random()*(e-t),deg2Rad(t){return t*this.DEG2RAD},rad2Deg(t){return t*this.RAD2DEG},round:(t,e=2)=>Math.round(t*Math.pow(10,e))/Math.pow(10,e),clamp:(t,e,n)=>Math.min(Math.max(t,e),n)};class d{constructor(){r(this,"_listeners"),r(this,"_mutex",{}),r(this,"_context")}addEventListener(t,e,n,r){void 0===this._listeners&&(this._listeners={}),this._context=n;const s=this._mutex,o=this._listeners;return void 0===o[t]&&(o[t]=[]),-1===o[t].indexOf(e)&&(r&&(s[t]=e),o[t].push(e)),this}hasEventListener(t,e){if(null===this._listeners||void 0===this._listeners)return!1;const n=this._listeners;return void 0!==n[t]&&-1!==n[t].indexOf(e)}removeEventListener(t,e){if(void 0===this._listeners)return;const n=this._listeners[t];if(this._mutex[t]===e&&(this._mutex[t]=null),void 0!==n){const t=n.map((t=>t.toString())).indexOf(e.toString());-1!==t&&n.splice(t,1)}}dispatchEvent(t){if(void 0===this._listeners)return;const e=this._listeners[t.type];if(void 0!==e){t.target=this;const n=e.slice(0);if(void 0!==this._mutex[t.type]){const e=n.find((e=>e===this._mutex[t.type]));if(e)return void e.call(this._context||this,t)}for(let e=0,r=n.length;e<r;e++){const r=n[e];"function"==typeof r&&r.call(this._context||this,t)}}}removeAllListener(){this._mutex={};for(const t in this._listeners)this._listeners[t]=[]}}class g extends Map{isEmpty(){return 0===this.size}_values(){return Array.from(this.values())}_keys(){return Array.from(this.keys())}_entries(){return Array.from(this.entries())}fromEntries(){}}g.prototype.fromEntries=function(t=[]){const e=new g;return t.forEach((t=>{Array.isArray(t)&&2===t.length&&e.set(t[0],t[1])})),e};const p={getDataType:t=>Object.prototype.toString.call(t).slice(8,-1),asArray(t){return this.isEmpty(t)?[]:Array.isArray(t)?t:[t]},asNumber:t=>Number.isNaN(Number(t))?0:Number(t),asString(t){if(this.isEmpty(t))return"";switch(this.getDataType(t)){case"Object":case"Array":return JSON.stringify(t);default:return t}},isEmpty(t){if(null==t)return!0;switch(this.getDataType(t)){case"String":return""===t.trim();case"Array":return!t.length;case"Object":return!Object.keys(t).length;case"Boolean":return!t;default:return!1}},json2form(t){const e=new FormData;return Object.keys(t).forEach((n=>{e.append(n,t[n]instanceof Object?JSON.stringify(t[n]):t[n])})),e},guid(){const t=function(){return(65536*(1+Math.random())|0).toString(16).substring(1)};return t()+t()+t()+t()+t()+t()+t()+t()},decodeDict(...t){let e="";if(t.length>1){const n=t.slice(1,t.length%2==0?t.length-1:t.length);for(let r=0;r<n.length;r+=2){const s=n[r];t[0]===s&&(e=n[r+1])}e||t.length%2!=0||(e=t[t.length-1])}else e=t[0];return e},extend(t,...e){let n,r,s,o;for(r=0,s=e.length;r<s;r++)for(n in o=e[r],o)t[n]=o[n];return t},convertToTree2(t,e="id",n="parentId",r="children"){const s=[];function o(a){const i=t.filter((t=>t[n]===a[e])).map((t=>(s.some((n=>n[e]===t[e]))||o(t),t)));i.length>0&&(a[r]=i)}return t.forEach((r=>{t.some((t=>t[n]===r[e]))||(o(r),s.push(r))})),s},asyncLoadScript:t=>new Promise(((e,n)=>{try{const r=document.createElement("script");r.type="text/javascript",r.src=t,"readyState"in r?r.onreadystatechange=function(){"complete"!==r.readyState&&"loaded"!==r.readyState||e(r)}:(r.onload=function(){e(r)},r.onerror=function(){n(new Error("Script failed to load for URL: "+t))}),document.body.appendChild(r)}catch(r){n(r)}})),loadStyle(t){t.forEach((t=>{const e=document.createElement("link");e.href=t,e.rel="stylesheet",e.type="text/css",e.onerror=function(){console.error(`Style loading failed for URL: ${t}`)},document.head.appendChild(e)}))},template:(t,e)=>t.replace(/\{ *([\w_-]+) *\}/g,((t,n)=>{const r=e[n];if(void 0===r)throw new Error(`${o.JSON_VALUE_ERROR}: ${t}`);return"function"==typeof r?r(e):r})),deleteEmptyProperty(t){return Object.fromEntries(Object.keys(t).filter((e=>!this.isEmpty(t[e]))).map((e=>[e,t[e]])))},deepAssign(t,...e){"object"==typeof t&&null!==t||(t={});for(const n of e)if("object"==typeof n&&null!==n)for(const e in n)Object.prototype.hasOwnProperty.call(n,e)&&("object"==typeof n[e]&&null!==n[e]?(t[e]||(t[e]=Array.isArray(n[e])?[]:{}),this.deepAssign(t[e],n[e])):t[e]=n[e]);return t},handleCopyValue(t){if(navigator.clipboard&&window.isSecureContext)return navigator.clipboard.writeText(t);{const e=document.createElement("textarea");return e.style.position="fixed",e.style.top=e.style.left="-100vh",e.style.opacity="0",e.value=t,document.body.appendChild(e),e.focus(),e.select(),new Promise(((t,n)=>{try{document.execCommand("copy"),t()}catch(r){n(new Error("copy failed"))}finally{e.remove()}}))}},isArray:t=>Array.isArray(t),isObject:t=>Object.prototype.toString.call(t).indexOf("Object")>-1,isNil:t=>void 0===t||"undefined"===t||null===t||"null"===t,isNumber:t=>"number"==typeof t&&!isNaN(t)||"string"==typeof t&&Number.isFinite(+t),isFunction(t){return!this.isNil(t)&&("function"==typeof t||null!==t.constructor&&t.constructor===Function)},isElement:t=>"object"==typeof t&&1===t.nodeType,checheVersion:(t,e)=>t.replace(/[^0-9]/gi,"")<e.replace(/[^0-9]/gi,"")},f={deepClone:t=>structuredClone(t),isEqual:(t,e)=>JSON.stringify(t)===JSON.stringify(e),parse:t=>t&&"string"==typeof t?JSON.parse(t):t},y=Object.create(Array);y.groupBy=function(t){var e={};return this.forEach((function(n){var r=JSON.stringify(t(n));e[r]=e[r]||[],e[r].push(n)})),Object.keys(e).map((t=>e[t]))},y.distinct=function(t=t=>t){const e=[],n={};return this.forEach((r=>{const s=t(r),o=String(s);n[o]||(n[o]=!0,e.push(r))})),e},y.prototype.max=function(){return Math.max.apply({},this)},y.prototype.min=function(){return Math.min.apply({},this)},y.sum=function(){return this.length>0?this.reduce(((t=0,e=0)=>t+e)):0},y.avg=function(){return this.length?this.sum()/this.length:0},y.desc=function(t=t=>t){return this.sort(((e,n)=>t(n)-t(e)))},y.asc=function(t=t=>t){return this.sort(((e,n)=>t(e)-t(n)))},y.remove=function(t){const e=this.indexOf(t);return e>-1&&this.splice(e,1),this};const m={create:t=>[...new Array(t).keys()],union(...t){let e=[];return t.forEach((t=>{Array.isArray(t)&&(e=e.concat(t.filter((t=>!e.includes(t)))))})),e},intersection(...t){let e=t[0]||[];return t.forEach((t=>{Array.isArray(t)&&(e=e.filter((e=>t.includes(e))))})),e},unionAll:(...t)=>[...t].flat().filter((t=>!!t)),difference(...t){return 0===t.length?[]:this.union(...t).filter((e=>!this.intersection(...t).includes(e)))}},E=class t extends d{constructor(n=`ws://${window.document.domain}:20007/mqtt`,s={}){super(),r(this,"state"),r(this,"url"),r(this,"context"),r(this,"options"),r(this,"client"),r(this,"topics"),this.context=p.extend(t.defaultContext,s),this.options={connectTimeout:this.context.MQTT_TIMEOUTM,clientId:p.guid(),username:this.context.MQTT_USERNAME,password:this.context.MQTT_PASSWORD,clean:!0},this.url=n,this.client=e.connect(this.url,this.options),this._onConnect(),this._onMessage(),this.state=0,this.topics=[]}_onConnect(){this.client.on("connect",(()=>{this.state=1,console.log("链接mqtt成功==>"+this.url),this.dispatchEvent({type:s.MQTT_CONNECT,message:this})})),this.client.on("error",(t=>{console.log("链接mqtt报错",t),this.state=-1,this.dispatchEvent({type:s.MQTT_ERROR,message:this}),this.client.end(),this.client.reconnect()}))}_onMessage(){this.client.on("message",((t,e)=>{let n=e,r="";e instanceof Uint8Array&&(n=e.toString());try{r=f.parse(n)}catch(a){throw new Error(o.JSON_PARSE_ERROR)}this.dispatchEvent({type:s.MQTT_MESSAGE,message:{topic:t,data:r}})}))}sendMsg(t,e){this.client.connected?this.client.publish(t,e,{qos:1,retain:!0}):console.error("客户端未连接")}subscribe(t){return 1===this.state?this.client.subscribe(t,{qos:1},((e,n)=>{e instanceof Error?console.error("订阅失败==>"+t,e):(this.topics=m.union(this.topics,t),console.log("订阅成功==>"+t))})):this.addEventListener(s.MQTT_CONNECT,(e=>{this.client.subscribe(t,{qos:1},((e,n)=>{e instanceof Error?console.error("订阅失败==>"+t,e):(this.topics=m.union(this.topics,t),console.log("订阅成功==>"+t))}))})),this}unsubscribe(t){return this.client.unsubscribe(t,{qos:1},((e,n)=>{e instanceof Error?console.error(`取消订阅失败==>${t}`,e):(this.topics=m.difference(this.topics,t),console.log(`取消订阅成功==>${t}`))})),this}unsubscribeAll(){this.unsubscribe(this.topics)}unconnect(){this.client.end(),this.client=null,this.dispatchEvent({type:s.MQTT_CLOSE,message:null}),console.log("断开mqtt成功==>"+this.url)}};r(E,"defaultContext",{MQTT_USERNAME:"iRVMS-WEB",MQTT_PASSWORD:"novasky888",MQTT_TIMEOUTM:2e4});let M=E;const w=class t{static set(t,e=null,n={}){var r=this._getPrefixedKey(t,n);try{const{expires:t}=n,s={data:e};t&&(s.expires=t),localStorage.setItem(r,JSON.stringify(s))}catch(s){console&&console.warn(`Storage didn't successfully save the '{"${t}": "${e}"}' pair, because the localStorage is full.`)}}static get(t,e,n){var r,s=this._getPrefixedKey(t,n);try{r=JSON.parse(localStorage.getItem(s)||"")}catch(o){r=localStorage[s]?{data:localStorage.getItem(s)}:null}if(!r)return e;if("object"==typeof r&&void 0!==r.data){const t=r.expires;return t&&Date.now()>t?e:r.data}}static keys(){const e=[];var n=Object.keys(localStorage);return 0===t.prefix.length?n:(n.forEach((function(n){-1!==n.indexOf(t.prefix)&&e.push(n.replace(t.prefix,""))})),e)}static getAll(e){var n=t.keys();if(e){const r=[];return n.forEach((n=>{if(e.includes(n)){const e={};e[n]=t.get(n,null,null),r.push(e)}})),r}return n.map((e=>t.get(e,null,null)))}static remove(t,e){var n=this._getPrefixedKey(t,e);localStorage.removeItem(n)}static clear(e){t.prefix.length?this.keys().forEach((t=>{localStorage.removeItem(this._getPrefixedKey(t,e))})):localStorage.clear()}};r(w,"prefix",""),r(w,"_getPrefixedKey",(function(t,e){return(e=e||{}).noPrefix?t:w.prefix+t}));let R=w;const b={emptyImageUrl:"data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",getURL(t){let e,n;if(/^data:/i.test(t.src))return t.src;if("undefined"==typeof HTMLCanvasElement)return t.src;if(t instanceof HTMLCanvasElement)n=t;else{void 0===e&&(e=document.createElementNS("http://www.w3.org/1999/xhtml","canvas")),e.width=t.width,e.height=t.height;const r=e.getContext("2d");r&&(t instanceof ImageData?r.putImageData(t,0,0):r.drawImage(t,0,0,t.width,t.height)),n=e}return n.width>2048||n.height>2048?(console.warn("ImageUtil.getDataURL: Image converted to jpg for performance reasons",t),n.toDataURL("image/jpeg",.6)):n.toDataURL("image/png")},getBase64(t){return new Promise(((e,n)=>{let r=new Image;r.setAttribute("crossOrigin","Anonymous"),r.src=t,r.onload=()=>{let t=this.getURL(r);e(t)},r.onerror=n}))},parseBase64(t){let e=new RegExp("data:(?<type>.*?);base64,(?<data>.*)").exec(t);return e&&e.groups?{type:e.groups.type,ext:e.groups.type.split("/").slice(-1)[0],data:e.groups.data}:null},async copyImage(t){try{const e=await this.getBase64(t),n=this.parseBase64(e.dataURL);if(!n)throw new Error("Failed to parse base64 data.");let r=n.type,s=atob(n.data),o=new ArrayBuffer(s.length),a=new Uint8Array(o);for(let t=0;t<s.length;t++)a[t]=s.charCodeAt(t);let i=new Blob([o],{type:r});await navigator.clipboard.write([new ClipboardItem({[r]:i})])}catch(e){console.error("Failed to copy image to clipboard:",e)}}},A={jsonp(t,e){const n="_jsonp_"+p.guid(),r=document.getElementsByTagName("head")[0];t.includes("?")?t+="&callback="+n:t+="?callback="+n;let s=document.createElement("script");s.type="text/javascript",s.src=t,window[n]=function(t){e(null,t),r.removeChild(s),s=null,delete window[n]},r.appendChild(s)},get(t,e,n){if(p.isFunction(e)){const t=n;n=e,e=t}const r=this._getClient(n);if(r.open("GET",t,!0),e){for(const t in e.headers)r.setRequestHeader(t,e.headers[t]);r.withCredentials="include"===e.credentials,e.responseType&&(r.responseType=e.responseType)}return r.send(null),r},post(t,e={},n){let r;if("string"!=typeof t?(n=e.cb,r=e.postData,delete(e={...e}).cb,delete e.postData,t=e.url):("function"==typeof e&&(n=e,e={}),r=e.postData),!n)throw new Error("Callback function is required");const s=this._getClient(n);return s.open("POST",t,!0),e.headers=e.headers||{},e.headers["Content-Type"]||(e.headers["Content-Type"]="application/x-www-form-urlencoded"),Object.keys(e.headers).forEach((t=>{s.setRequestHeader(t,e.headers[t])})),"string"!=typeof r&&(r=JSON.stringify(r)),s.send(r),s},_wrapCallback:(t,e)=>function(){if(4===t.readyState)if(200===t.status)if("arraybuffer"===t.responseType){0===t.response.byteLength?e(new Error("http status 200 returned without content.")):e(null,{data:t.response,cacheControl:t.getResponseHeader("Cache-Control"),expires:t.getResponseHeader("Expires"),contentType:t.getResponseHeader("Content-Type")})}else e(null,t.responseText);else e(new Error(t.statusText+","+t.status))},_getClient(t){let e=null;try{e=new XMLHttpRequest}catch(n){throw new Error("XMLHttpRequest not supported.")}return e&&(e.onreadystatechange=this._wrapCallback(e,t)),e},getArrayBuffer(t,e,n){if(p.isFunction(e)){const t=n;n=e,e=t}return e||(e={}),e.responseType="arraybuffer",this.get(t,e,n)},getImage(t,e,n){return this.getArrayBuffer(e,n,((e,n)=>{if(e)t.onerror&&t.onerror(e);else if(n){const e=window.URL||window.webkitURL,r=t.onload;t.onload=()=>{r&&r(),e.revokeObjectURL(t.src)};const s=new Blob([new Uint8Array(n.data)],{type:n.contentType});t.cacheControl=n.cacheControl,t.expires=n.expires,t.src=n.data.byteLength?e.createObjectURL(s):b.emptyImageUrl}}))},getJSON(t,e,n){if(p.isFunction(e)){const t=n;n=e,e=t}const r=function(t,e){const r=e?f.parse(e):null;n&&n(t,r)};return e&&e.jsonp?this.jsonp(t,r):this.get(t,e,r)}},x={toRadian:Math.PI/180,R:6371393,isLnglat:(t,e)=>!isNaN(t)&&!isNaN(e)&&!!(+e>-90&&+e<90&&+t>-180&&+t<180),distance:(t,e)=>Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),distanceByPoints(t,e){const{lng:n,lat:r}=t,{lng:s,lat:o}=e;let a=Math.cos(r*Math.PI/180)*Math.cos(o*Math.PI/180)*Math.cos((n-s)*Math.PI/180)+Math.sin(r*Math.PI/180)*Math.sin(o*Math.PI/180);a>1&&(a=1),a<-1&&(a=-1);return 6371e3*Math.acos(a)},formatLnglat(t,e){let n="";function r(t){const e=Math.floor(t),n=Math.floor(60*(t-e));return`${e}°${n}′${(3600*(t-e)-60*n).toFixed(2)}″`}return this.isLnglat(t,e)?n=r(t)+","+r(e):isNaN(t)?isNaN(e)||(n=r(e)):n=r(t),n},transformLnglat(t,e){function n(t){let e=/[sw]/i.test(t)?-1:1;const n=t.match(/[\d.]+/g)||[];let r=0;for(let s=0;s<n.length;s++)r+=parseFloat(n[s])/e,e*=60;return r}if(t&&e)return{lng:n(t),lat:n(e)}},rayCasting(t,e){for(var n=t.x,r=t.y,s=!1,o=0,a=e.length,i=a-1;o<a;i=o,o++){var l=e[o].x,c=e[o].y,h=e[i].x,u=e[i].y;if(l===n&&c===r||h===n&&u===r)return"on";if(c<r&&u>=r||c>=r&&u<r){var d=l+(r-c)*(h-l)/(u-c);if(d===n)return"on";d>n&&(s=!s)}}return s?"in":"out"},rotatePoint:(t,e,n)=>({x:(t.x-e.x)*Math.cos(Math.PI/180*-n)-(t.y-e.y)*Math.sin(Math.PI/180*-n)+e.x,y:(t.x-e.x)*Math.sin(Math.PI/180*-n)+(t.y-e.y)*Math.cos(Math.PI/180*-n)+e.y}),calcBearAndDis(t,e){const{x:n,y:r}=t,{x:s,y:o}=e,a=s-n,i=o-r,l=Math.sqrt(a*a+i*i);return{angle:(Math.atan2(i,a)*(180/Math.PI)+360+90)%360,distance:l}},calcBearAndDisByPoints(t,e){var n=1*t.lat,r=1*t.lng,s=1*e.lat,o=1*e.lng,a=Math.sin((o-r)*this.toRadian)*Math.cos(s*this.toRadian),i=Math.cos(n*this.toRadian)*Math.sin(s*this.toRadian)-Math.sin(n*this.toRadian)*Math.cos(s*this.toRadian)*Math.cos((o-r)*this.toRadian),l=Math.atan2(a,i)*(180/Math.PI),c=(s-n)*this.toRadian,h=(o-r)*this.toRadian,u=Math.sin(c/2)*Math.sin(c/2)+Math.cos(n*this.toRadian)*Math.cos(s*this.toRadian)*Math.sin(h/2)*Math.sin(h/2),d=2*Math.atan2(Math.sqrt(u),Math.sqrt(1-u));return{angle:l,distance:this.R*d}},distanceToSegment(t,e,n){const r=t.x,s=t.y,o=e.x,a=e.y,i=n.x,l=n.y,c=(i-o)*(r-o)+(l-a)*(s-a);if(c<=0)return Math.sqrt((r-o)*(r-o)+(s-a)*(s-a));const h=(i-o)*(i-o)+(l-a)*(l-a);if(c>=h)return Math.sqrt((r-i)*(r-i)+(s-l)*(s-l));const u=c/h,d=o+(i-o)*u,g=a+(l-a)*u;return Math.sqrt((r-d)*(r-d)+(s-g)*(s-g))},calcPointByBearAndDis(t,e,n){const r=u.deg2Rad(1*t.lat),s=u.deg2Rad(1*t.lng),o=n/this.R;e=u.deg2Rad(e);const a=Math.asin(Math.sin(r)*Math.cos(o)+Math.cos(r)*Math.sin(o)*Math.cos(e)),i=s+Math.atan2(Math.sin(e)*Math.sin(o)*Math.cos(r),Math.cos(o)-Math.sin(r)*Math.sin(a));return{lat:u.rad2Deg(a),lng:u.rad2Deg(i)}},mercatorTolonlat(t,e){var n=e/20037508.34*180;return{lng:t/20037508.34*180,lat:180/Math.PI*(2*Math.atan(Math.exp(n*Math.PI/180))-Math.PI/2)}},lonlatToMercator(t,e){var n=6378137;const r=t*Math.PI/180*n;var s=e*Math.PI/180;return{x:r,y:3189068.5*Math.log((1+Math.sin(s))/(1-Math.sin(s)))}},interpolate:({x:t,y:e,z:n=0},{x:r,y:s,z:o=0},a)=>({x:t+(r-t)*a,y:e+(s-e)*a,z:n+(o-n)*a})},S={checkStr(t,e){switch(e){case"phone":return/^1[3|4|5|6|7|8|9][0-9]{9}$/.test(t);case"tel":return/^(0\d{2,3}-\d{7,8})(-\d{1,4})?$/.test(t);case"card":return/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/.test(t);case"pwd":return/^[a-zA-Z]\w{5,17}$/.test(t);case"postal":return/[1-9]\d{5}(?!\d)/.test(t);case"QQ":return/^[1-9][0-9]{4,9}$/.test(t);case"email":return/^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/.test(t);case"money":return/^\d*(?:\.\d{0,2})?$/.test(t);case"URL":return/(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?/.test(t);case"IP":return/((?:(?:25[0-5]|2[0-4]\\d|[01]?\\d?\\d)\\.){3}(?:25[0-5]|2[0-4]\\d|[01]?\\d?\\d))/.test(t);case"date":return/^(\d{4})\-(\d{2})\-(\d{2}) (\d{2})(?:\:\d{2}|:(\d{2}):(\d{2}))$/.test(t)||/^(\d{4})\-(\d{2})\-(\d{2})$/.test(t);case"number":return/^[0-9]$/.test(t);case"english":return/^[a-zA-Z]+$/.test(t);case"chinese":return/^[\u4E00-\u9FA5]+$/.test(t);case"lower":return/^[a-z]+$/.test(t);case"upper":return/^[A-Z]+$/.test(t);case"HTML":return/<("[^"]*"|'[^']*'|[^'">])*>/.test(t);default:return!0}},changeCase(t,e){switch(e=e||4){case 1:return t.replace(/\b\w+\b/g,(function(t){return t.substring(0,1).toUpperCase()+t.substring(1).toLowerCase()}));case 2:return t.replace(/\b\w+\b/g,(function(t){return t.substring(0,1).toLowerCase()+t.substring(1).toUpperCase()}));case 3:return t.split("").map((function(t){return/[a-z]/.test(t)?t.toUpperCase():t.toLowerCase()})).join("");case 4:return t.toUpperCase();case 5:return t.toLowerCase();default:return t}},tag:(t,...e)=>(e=e.map((t=>{switch(p.getDataType(t)){case"Object":return t||"{}";case"Array":return t||"[]";default:return t||""}})),t.reduce(((t,n,r)=>`${t}${e[r-1]}${n}`))),getByteLength:t=>t.replace(/[\u0391-\uFFE5]/g,"aa").length,subStringByte(t,e,n){var r=/[^\x00-\xff]/g;if(t.replace(r,"mm").length<=n)return t;for(var s=Math.floor(n/2);s<t.length;s++){let o=t.substring(e,s);if(o.replace(r,"mm").length>=n)return o}return t}},T={random(){let t=Math.floor(256*Math.random()).toString(16),e=Math.floor(256*Math.random()).toString(16),n=Math.floor(256*Math.random()).toString(16);return t=1===t.length?"0"+t:t,e=1===e.length?"0"+e:e,n=1===n.length?"0"+n:n,"#"+t+e+n},rgb2hex:t=>"#"+((1<<24)+(t[0]<<16)+(t[1]<<8)+t[2]).toString(16).slice(1),rgbToRgba(t){const e=/rgb\((\d+,\s*[\d]+,\s*[\d]+)\)/g.exec(t);return e?`rgba(${e[1]}, 1)`:t},hexToRgba(t){const e=t.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i,((t,e,n,r)=>e+e+n+n+r+r)),n=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(!n)return t;return`rgba(${parseInt(n[1],16)},${parseInt(n[2],16)},${parseInt(n[3],16)},1)`},hslToRgba(t){if(!t)return null;const e=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(t)||/hsla\((\d+),\s*([\d.]+)%,\s*([\d.]+)%,\s*([\d.]+)\)/g.exec(t);if(!e)return null;const n=parseInt(e[1],10)/360,r=parseInt(e[2],10)/100,s=parseInt(e[3],10)/100,o=e[4]?parseFloat(e[4]):1;function a(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+6*(e-t)*n:n<.5?e:n<2/3?t+(e-t)*(2/3-n)*6:t}let i,l,c;if(0===r)i=l=c=s;else{const t=s<.5?s*(1+r):s+r-s*r,e=2*s-t;i=a(e,t,n+1/3),l=a(e,t,n),c=a(e,t,n-1/3)}return`rgba(${Math.round(255*i)},${Math.round(255*l)},${Math.round(255*c)},${o})`},isHex:t=>/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(t),isRgb:t=>/^rgb/.test(t),isHsl:t=>/^hsl/.test(t),isColor(t){return this.isHex(t)||this.isRgb(t)||this.isHsl(t)},colorToRgb(t){return this.isRgb(t)?this.rgbToRgba(t):this.isHex(t)?this.hexToRgba(t):this.isHsl(t)?this.hslToRgba(t):void 0}},O=["Point","MultiPoint","LineString","MultiLineString","Polygon","MultiPolygon"],C={getGeoJsonType:t=>t.geometry?t.geometry.type:null,isGeoJson(t){const e=this.getGeoJsonType(t);if(e)for(let n=0,r=O.length;n<r;n++)if(O[n]===e)return!0;return!1},isGeoJsonPolygon(t){const e=this.getGeoJsonType(t);return!(!e||e!==O[4]&&e!==O[5])},isGeoJsonLine(t){const e=this.getGeoJsonType(t);return!(!e||e!==O[2]&&e!==O[3])},isGeoJsonPoint(t){const e=this.getGeoJsonType(t);return!(!e||e!==O[0]&&e!==O[1])},isGeoJsonMulti(t){const e=this.getGeoJsonType(t);return!!(e&&e.indexOf("Multi")>-1)},getGeoJsonCoordinates:t=>t.geometry?t.geometry.coordinates:[],getGeoJsonCenter(t,e){const n=this.getGeoJsonType(t);if(!n||!t.geometry)return null;const r=t.geometry.coordinates;if(!r)return null;let s=0,o=0,a=0;switch(n){case"Point":s=r[0],o=r[1],a++;break;case"MultiPoint":case"LineString":for(let t=0,e=r.length;t<e;t++)s+=r[t][0],o+=r[t][1],a++;break;case"MultiLineString":case"Polygon":for(let t=0,e=r.length;t<e;t++)for(let n=0,i=r[t].length;n<i;n++)s+=r[t][n][0],o+=r[t][n][1],a++;break;case"MultiPolygon":for(let t=0,e=r.length;t<e;t++)for(let n=0,i=r[t].length;n<i;n++)for(let e=0,l=r[t][n].length;e<l;e++)s+=r[t][n][e][0],o+=r[t][n][e][1],a++}const i=s/a,l=o/a;return e?(e.x=i,e.y=l,e):{x:i,y:l}},spliteGeoJsonMulti(t){const e=this.getGeoJsonType(t);if(!e||!t.geometry)return null;const n=t.geometry,r=t.properties||{},s=n.coordinates;if(!s)return null;const o=[];let a;switch(e){case"MultiPoint":a="Point";break;case"MultiLineString":a="LineString";break;case"MultiPolygon":a="Polygon"}if(a)for(let i=0,l=s.length;i<l;i++)o.push({type:"Feature",geometry:{type:a,coordinates:s[i]},properties:r});else o.push(t);return o},getGeoJsonByCoordinates(t){if(!Array.isArray(t))throw Error("coordinates 参数格式错误");let e;if(2===t.length&&"number"==typeof t[0]&&"number"==typeof t[1])e="Point";else if(Array.isArray(t[0])&&2===t[0].length)e="LineString";else{if(!Array.isArray(t[0])||!Array.isArray(t[0][0]))throw Error("coordinates 参数格式错误");{const n=t[0];if(n[0].join(",")===n[n.length-1].join(","))e="Polygon";else{if(!(t.length>1))throw Error("coordinates 参数格式错误");e="MultiPolygon"}}}return{type:"Feature",geometry:{type:e,coordinates:t}}}},_={assertEmpty(...t){t.forEach((t=>{if(p.isEmpty(t))throw Error("变量为空:>>>"+t)}))},assertNumber(...t){t.forEach((t=>{if(!p.isNumber(t))throw Error("不是数字:>>>"+t)}))},assertArray(...t){t.forEach((t=>{if(!p.isArray(t))throw Error(o.PARAMETER_ERROR_ARRAY+":>>>"+t)}))},assertFunction(...t){t.forEach((t=>{if(!p.isFunction(t))throw Error(o.PARAMETER_ERROR_FUNCTION+":>>>"+t)}))},assertObject(...t){t.forEach((t=>{if(!p.isObject(t))throw Error(o.PARAMETER_ERROR_OBJECT+":>>>"+t)}))},assertColor(...t){t.forEach((t=>{if(!T.isColor(t))throw Error("颜色代码不正确:>>>"+t)}))},assertLnglat(...t){t.forEach((t=>{if(!x.isLnglat(t.lng,t.lat))throw Error(o.COORDINATE_ERROR+":>>>"+t)}))},assertGeoJson(...t){t.forEach((t=>{if(!C.isGeoJson(t))throw Error("不是GeoJSON:>>>"+t)}))},assertContain(t,...e){let n=!1;for(let r=0,s=e.length||0;r<s;r++)n=t.indexOf(e[r])>=0;if(n)throw Error(o.STRING_CHECK_LOSS+":>>>"+t)},assertLegal(t,e){const n=S.checkStr(t,e);let r="";switch(e){case"phone":r="电话";break;case"tel":r="座机";break;case"card":r="身份证";break;case"pwd":r="密码";break;case"postal":r="邮政编码";break;case"QQ":r="QQ";break;case"email":r="邮箱";break;case"money":r="金额";break;case"URL":r="网址";break;case"IP":r="IP";break;case"date":r="日期时间";break;case"number":r="数字";break;case"english":r="英文";break;case"chinese":r="中文";break;case"lower":r="小写";break;case"upper":r="大写";break;case"HTML":r="HTML标记"}if(!n)throw Error(o.PARAMETER_ERROR+":>>>不是"+r)}},D={getExplorer(){var t=window.navigator.userAgent;return t.indexOf("MSIE")>=0||/Trident\//.test(t)?"IE":t.indexOf("Firefox")>=0?"Firefox":t.indexOf("Chrome")>=0?"Chrome":t.indexOf("Opera")>=0?"Opera":t.indexOf("Safari")>=0&&-1===t.indexOf("Chrome")?"Safari":"Unknown"},detectOS(){let t="";const e=-1!=navigator.userAgent.indexOf("Windows",0)?1:0,n=-1!=navigator.userAgent.indexOf("mac",0)?1:0,r=-1!=navigator.userAgent.indexOf("Linux",0)?1:0,s=-1!=navigator.userAgent.indexOf("X11",0)?1:0;return e?t="MS Windows":n?t="Apple mac":r?t="Linux":s&&(t="Unix"),t},switchFullScreen(t){if(t){const t=document.documentElement;t.requestFullscreen?t.requestFullscreen():"msRequestFullscreen"in t?t.msRequestFullscreen():"mozRequestFullScreen"in t?t.mozRequestFullScreen():"webkitRequestFullscreen"in t&&t.webkitRequestFullscreen()}else document.exitFullscreen?document.exitFullscreen():"msExitFullscreen"in document?document.msExitFullscreen():"mozCancelFullScreen"in document?document.mozCancelFullScreen():"webkitExitFullscreen"in document&&document.webkitExitFullscreen()},refreshScale(){const t=document.documentElement.clientWidth||0,e=document.documentElement.clientHeight||0,n=document.getElementById("app");if(!n)return;const r=n.style;let s=t/1920;t/e>16/9&&(s=e/1080),r.transformOrigin="left top",r.transform=`scale(${s}) translateX(-49.99%)`,r.width=t/s+"px"},getHtmlFontSize(){const t=document.documentElement.clientWidth||document.body.clientWidth,e=document.querySelector("html");e&&(e.style.fontSize=t/192+"px")}},I={PI:3.141592653589793,XPI:52.35987755982988,delta(t,e){const n=6378245,r=.006693421622965943;let s=this.transformLat(e-105,t-35),o=this.transformLon(e-105,t-35);const a=t/180*this.PI;let i=Math.sin(a);i=1-r*i*i;const l=Math.sqrt(i);return s=180*s/(n*(1-r)/(i*l)*this.PI),o=180*o/(n/l*Math.cos(a)*this.PI),{lat:s,lng:o}},outOfChina:(t,e)=>t<72.004||t>137.8347||(e<.8293||e>55.8271),gcjEncrypt(t,e){if(this.outOfChina(t,e))return{lat:t,lng:e};const n=this.delta(t,e);return{lat:t+n.lat,lng:e+n.lng}},gcjDecrypt(t,e){if(this.outOfChina(t,e))return{lat:t,lng:e};const n=this.delta(t,e);return{lat:t-n.lat,lng:e-n.lng}},gcjDecryptExact(t,e){let n=.01,r=.01,s=t-n,o=e-r,a=t+n,i=e+r,l=0,c=0,h=0;for(;;){l=(s+a)/2,c=(o+i)/2;const u=this.gcjEncrypt(l,c);if(n=u.lat-t,r=u.lng-e,Math.abs(n)<1e-9&&Math.abs(r)<1e-9)break;if(n>0?a=l:s=l,r>0?i=c:o=c,++h>1e4)break}return{lat:l,lng:c}},bdEncrypt(t,e){const n=e,r=t,s=Math.sqrt(n*n+r*r)+2e-5*Math.sin(r*this.XPI),o=Math.atan2(r,n)+3e-6*Math.cos(n*this.XPI),a=s*Math.cos(o)+.0065;return{lat:s*Math.sin(o)+.006,lng:a}},bdDecrypt(t,e){const n=e-.0065,r=t-.006,s=Math.sqrt(n*n+r*r)-2e-5*Math.sin(r*this.XPI),o=Math.atan2(r,n)-3e-6*Math.cos(n*this.XPI),a=s*Math.cos(o);return{lat:s*Math.sin(o),lng:a}},mercatorEncrypt(t,e){const n=20037508.34*e/180;let r=Math.log(Math.tan((90+t)*this.PI/360))/(this.PI/180);return r=20037508.34*r/180,{lat:r,lng:n}},mercatorDecrypt(t,e){const n=e/20037508.34*180;let r=t/20037508.34*180;return r=180/this.PI*(2*Math.atan(Math.exp(r*this.PI/180))-this.PI/2),{lat:r,lng:n}},transformLat(t,e){let n=2*t-100+3*e+.2*e*e+.1*t*e+.2*Math.sqrt(Math.abs(t));return n+=2*(20*Math.sin(6*t*this.PI)+20*Math.sin(2*t*this.PI))/3,n+=2*(20*Math.sin(e*this.PI)+40*Math.sin(e/3*this.PI))/3,n+=2*(160*Math.sin(e/12*this.PI)+320*Math.sin(e*this.PI/30))/3,n},transformLon(t,e){let n=300+t+2*e+.1*t*t+.1*t*e+.1*Math.sqrt(Math.abs(t));return n+=2*(20*Math.sin(6*t*this.PI)+20*Math.sin(2*t*this.PI))/3,n+=2*(20*Math.sin(t*this.PI)+40*Math.sin(t/3*this.PI))/3,n+=2*(150*Math.sin(t/12*this.PI)+300*Math.sin(t/30*this.PI))/3,n},random:({x:t,y:e},{x:n,y:r})=>({lat:Math.random()*(r-e)+e,lng:Math.random()*(n-t)+t}),deCompose(t,e,n){if(!Array.isArray(t))return n?e.call(n,t):e(t);const r=[];let s,o;for(let a=0,i=t.length;a<i;a++)s=t[a],p.isNil(s)?r.push(null):Array.isArray(s)?r.push(this.deCompose(s,e,n)):(o=n?e.call(n,s):e(s),r.push(o));return r}},v=Object.create(Date);v.prototype.format=function(t="yyyy-MM-dd hh:mm:ss"){const e={"M+":this.getMonth()+1,"d+":this.getDate(),"h+":this.getHours()%12,"H+":this.getHours(),"m+":this.getMinutes(),"s+":this.getSeconds(),"q+":Math.floor((this.getMonth()+3)/3),S:this.getMilliseconds()};/(y+)/.test(t)&&(t=t.replace(RegExp.$1,(this.getFullYear()+"").substr(4-RegExp.$1.length)));for(const n in e)if(new RegExp("("+n+")").test(t)){const r=1===n.length?1:Number(n.slice(1));t=t.replace(RegExp.$1,("00"+e[n]).substr((""+e[n]).length+r-(e[n]+"").length))}return t},v.prototype.addDate=function(t,e){const n=new Date(this);switch(t){case"y":n.setFullYear(this.getFullYear()+e);break;case"q":n.setMonth(this.getMonth()+3*e);break;case"M":n.setMonth(this.getMonth()+e);break;case"w":n.setDate(this.getDate()+7*e);break;case"d":default:n.setDate(this.getDate()+e);break;case"h":n.setHours(this.getHours()+e);break;case"m":n.setMinutes(this.getMinutes()+e);break;case"s":n.setSeconds(this.getSeconds()+e)}return n};const P={lastMonthDate:new Date((new Date).getFullYear(),(new Date).getMonth()-1,1),thisMonthDate:new Date((new Date).getFullYear(),(new Date).getMonth(),1),nextMonthDate:new Date((new Date).getFullYear(),(new Date).getMonth()+1,1),lastWeekDate:new Date((new Date).getFullYear(),(new Date).getMonth(),(new Date).getDate()+1-7-(new Date).getDay()),thisWeekDate:new Date((new Date).getFullYear(),(new Date).getMonth(),(new Date).getDate()+1-(new Date).getDay()),nextWeekDate:new Date((new Date).getFullYear(),(new Date).getMonth(),(new Date).getDate()+1+7-(new Date).getDay()),lastDayDate:new Date((new Date).getFullYear(),(new Date).getMonth(),(new Date).getDate()-1),thisDayDate:new Date((new Date).setHours(0,0,0,0)),nextDayDate:new Date((new Date).getFullYear(),(new Date).getMonth(),(new Date).getDate()+1),parseDate(t){if("string"==typeof t){var e=t.match(/^ *(\d{4})-(\d{1,2})-(\d{1,2}) *$/);if(e&&e.length>3)return new Date(parseInt(e[1]),parseInt(e[2])-1,parseInt(e[3]));if((e=t.match(/^ *(\d{4})-(\d{1,2})-(\d{1,2}) +(\d{1,2}):(\d{1,2}):(\d{1,2}) *$/))&&e.length>6)return new Date(parseInt(e[1]),parseInt(e[2])-1,parseInt(e[3]),parseInt(e[4]),parseInt(e[5]),parseInt(e[6]));if((e=t.match(/^ *(\d{4})-(\d{1,2})-(\d{1,2}) +(\d{1,2}):(\d{1,2}):(\d{1,2})\.(\d{1,9}) *$/))&&e.length>7)return new Date(parseInt(e[1]),parseInt(e[2])-1,parseInt(e[3]),parseInt(e[4]),parseInt(e[5]),parseInt(e[6]),parseInt(e[7]))}return null},formatDateInterval(t,e){const n=new Date(t),r=new Date(e).getTime()-n.getTime(),s=Math.floor(r/864e5),o=r%864e5,a=Math.floor(o/36e5),i=o%36e5,l=Math.floor(i/6e4),c=i%6e4,h=Math.round(c/1e3);let u="";return s>0&&(u+=s+"天"),a>0&&(u+=a+"时"),l>0&&(u+=l+"分"),h>0&&(u+=h+"秒"),0===s&&0===a&&0===l&&0===h&&(u="少于1秒"),u},formatterCounter(t){const e=function(t){return(t>10?"":"0")+(t||0)},n=t%3600,r=n%60;return`${e(Math.floor(t/3600))}:${e(Math.floor(n/60))}:${e(Math.round(r))}`},sleep(t){}};function L(t){return function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).split(/\s+/)}const k={getStyle(t,e){var n;let r=t.style[e];if(!r||"auto"===r){const s=null==(n=document.defaultView)?void 0:n.getComputedStyle(t,null);r=s?s[e]:null,"auto"===r&&(r=null)}return r},create(t,e,n){const r=document.createElement(t);return r.className=e||"",n&&n.appendChild(r),r},remove(t){const e=t.parentNode;e&&e.removeChild(t)},empty(t){for(;t.firstChild;)t.removeChild(t.firstChild)},toFront(t){const e=t.parentNode;e&&e.lastChild!==t&&e.appendChild(t)},toBack(t){const e=t.parentNode;e&&e.firstChild!==t&&e.insertBefore(t,e.firstChild)},getClass:t=>((null==t?void 0:t.host)||t).className.toString(),hasClass(t,e){var n;if(null==(n=t.classList)?void 0:n.contains(e))return!0;const r=this.getClass(t);return r.length>0&&new RegExp(`(^|\\s)${e}(\\s|$)`).test(r)},addClass(t,e){if(void 0!==t.classList){const n=L(e);for(let e=0,r=n.length;e<r;e++)t.classList.add(n[e])}else if(!this.hasClass(t,e)){const n=this.getClass(t);this.setClass(t,(n?n+" ":"")+e)}},removeClass(t,e){if(void 0!==t.classList){L(e).forEach((e=>t.classList.remove(e)))}else this.setClass(t,(" "+this.getClass(t)+" ").replace(" "+e+" "," ").trim())},setClass(t,e){"classList"in t&&(t.classList.value="",e.split(" ").forEach((e=>t.classList.add(e))))},parseFromString:t=>(new DOMParser).parseFromString(t,"text/xml").children[0]},N={convertBase64ToBlob(t){const e=t.split(",")[0].split(":")[1].split(";")[0],n=atob(t.split(",")[1]),r=new Array(n.length);for(let o=0;o<n.length;o++)r[o]=n.charCodeAt(o);const s=new Uint8Array(r);return new Blob([s],{type:e})},convertBase64ToFile(t,e){const n=t.split(","),r=n[0].match(/:(.*?);/),s=r?r[1]:"image/png",o=atob(n[1]),a=new Uint8Array(o.length);for(let i=0;i<o.length;i++)a[i]=o.charCodeAt(i);return new File([a],e,{type:s})},downloadFromFile(t,e){if("object"==typeof t)if(t instanceof Blob)t=URL.createObjectURL(t);else{const e=JSON.stringify(t),n=new Blob([e],{type:"text/json"});t=window.URL.createObjectURL(n)}else if("string"==typeof t&&-1===t.indexOf("http")){const e=new Blob([t],{type:"text/json"});t=window.URL.createObjectURL(e)}var n=document.createElement("a");n.href=t,n.download=e||"",n.click(),window.URL.revokeObjectURL(n.href)}},U={debounce(t,e,n=!0){let r,s,o=null;const a=()=>{const i=Date.now()-r;i<e&&i>0?o=setTimeout(a,e-i):(o=null,n||(s=t.apply(this,undefined)))};return(...i)=>{r=Date.now();const l=n&&!o;return o||(o=setTimeout(a,e)),l&&(s=t.apply(this,i),o||(i=null)),s}},throttle(t,e,n=1){let r=0,s=null;return(...o)=>{if(1===n){const n=Date.now();n-r>=e&&(t.apply(this,o),r=n)}else 2===n&&(s||(s=setTimeout((()=>{s=null,t.apply(this,o)}),e)))}},memoize(t){const e=new Map;return(...n)=>{const r=JSON.stringify(n);if(e.has(r))return e.get(r);{const s=t.apply(this,n);return e.set(r,s),s}}},recurve(t,e=500,n=5e3){let r=0;setTimeout((()=>{r++,r<Math.floor(n/e)&&(t.call(this),setTimeout(this.recurve.bind(this,t,e,n),e))}),e)},once(t){let e=!1;return function(...n){if(!e)return e=!0,t(...n)}}},F={json2Query(t){var e=[];for(var n in t)if(t.hasOwnProperty(n)){var r=n,s=t[n];e.push(encodeURIComponent(r)+"="+encodeURIComponent(s))}return e.join("&")},query2Json(t=window.location.href,e=!0){const n=/([^&=]+)=([\w\W]*?)(&|$|#)/g,{search:r,hash:s}=new URL(t),o=[r,s];let a={};for(let i=0;i<o.length;i++){const t=o[i];if(t){const r=t.replace(/#|\//g,"").split("?");if(r.length>1)for(let t=1;t<r.length;t++){let s;for(;s=n.exec(r[t]);)a[s[1]]=e?decodeURIComponent(s[2]):s[2]}}}return a}};t.AjaxUtil=A,t.ArrayUtil=m,t.AssertUtil=_,t.AudioPlayer=class{constructor(t){r(this,"audio"),this.audio=new Audio,this.audio.src=t}static speak(t,e={}){const n=new SpeechSynthesisUtterance;n.text=t,n.lang=e.lang||"zh-CN",n.volume=e.volume||1,n.rate=e.rate||1,n.pitch=e.pitch||1,window.speechSynthesis.speak(n)}play(){!this.muted&&this.audio.play()}pause(){this.audio.pause()}get muted(){return this.audio.muted}set muted(t){this.audio.muted=t}},t.BrowserUtil=D,t.CanvasDrawer=class{constructor(t){if(r(this,"context",null),"string"==typeof t&&!(t=document.querySelector("#"+t)))throw new Error("Element not found");if(!(t instanceof HTMLElement))throw new Error("Element is not an HTMLElement");{const e=t;if(!e.getContext)throw new Error("getContext is not available on this element");this.context=e.getContext("2d")}}drawLine({x:t,y:e},{x:n,y:r},s={}){if(!this.context)throw new Error("Canvas context is null or undefined");this.context.beginPath();const o=s.width||1,a=s.color||"#000";this.context.lineWidth=o,this.context.strokeStyle=a,this.context.moveTo(t,e),this.context.lineTo(n,r),this.context.stroke()}drawArc({x:t,y:e},n,r,s,o,a,i){if(!this.context)throw new Error("Canvas context is null or undefined");a?(this.context.fillStyle=i,this.context.beginPath(),this.context.arc(t,e,n,u.deg2Rad(r),u.deg2Rad(s),o),this.context.fill()):(this.context.strokeStyle=i,this.context.beginPath(),this.context.arc(t,e,n,u.deg2Rad(r),u.deg2Rad(s),o),this.context.stroke())}static createCanvas(t=1,e=1){const n=document.createElement("canvas");return t&&(n.width=t),e&&(n.height=e),n}},t.ColorUtil=T,t.Cookie=class{static set(t,e,n=30){if("string"!=typeof t||"string"!=typeof e||"number"!=typeof n)throw new Error("Invalid arguments");const r=new Date;r.setTime(r.getTime()+24*n*60*60*1e3),document.cookie=`${t}=${encodeURIComponent(e)};expires=${r.toUTCString()}`}static remove(t){var e=new Date;e.setTime(e.getTime()-1);var n=this.get(t);null!=n&&(document.cookie=t+"="+n+";expires="+e.toUTCString())}static get(t){var e=document.cookie.match(new RegExp("(^| )"+t+"=([^;]*)(;|$)"));return null!=e?e[2]:""}},t.CoordsUtil=I,t.DateUtil=P,t.DomUtil=k,t.ErrorType=o,t.EventDispatcher=d,t.EventType=s,t.FileUtil=N,t.GeoJsonUtil=C,t.GeoUtil=x,t.GraphicType=i,t.HashMap=g,t.ImageUtil=b,t.LayerType=a,t.LineSymbol=l,t.MathUtil=u,t.MeasureMode=c,t.MqttClient=M,t.ObjectState=h,t.ObjectUtil=f,t.OptimizeUtil=U,t.Storage=R,t.StringUtil=S,t.UrlUtil=F,t.Util=p,t.WebSocketClient=class extends d{constructor(t="ws://127.0.0.1:10088"){super(),r(this,"maxCheckTimes",10),r(this,"url"),r(this,"checkTimes",0),r(this,"connectStatus",!1),r(this,"client",null),this.maxCheckTimes=10,this.url=t,this.checkTimes=0,this.connect(),this.connCheckStatus(this.maxCheckTimes)}connect(){if(this.disconnect(),this.url)try{if(console.info("创建ws连接>>>"+this.url),this.client=new WebSocket(this.url),this.client){const t=this;this.client.onopen=function(e){t.dispatchEvent({type:s.WEB_SOCKET_CONNECT,message:e})},this.client.onmessage=function(e){t.connectStatus=!0,t.dispatchEvent({type:s.WEB_SOCKET_MESSAGE,message:e})},this.client.onclose=function(e){t.dispatchEvent({type:s.WEB_SOCKET_CLOSE,message:e})},this.checkTimes===this.maxCheckTimes&&(this.client.onerror=function(e){t.dispatchEvent({type:s.WEB_SOCKET_ERROR,message:e})})}}catch(t){console.error("创建ws连接失败"+this.url+":"+t)}}disconnect(){if(this.client)try{console.log("ws断开连接"+this.url),this.client.close(),this.client=null}catch(t){this.client=null}}connCheckStatus(t){this.checkTimes>t||setTimeout((()=>{this.checkTimes++,this.client&&0!==this.client.readyState&&1!==this.client.readyState&&this.connect(),this.connCheckStatus(t)}),2e3)}send(t){return this.client&&1===this.client.readyState?(this.client.send(t),!0):(console.error(this.url+"消息发送失败:"+t),!1)}heartbeat(){setTimeout((()=>{this.client&&1===this.client.readyState&&this.send("HeartBeat"),console.log("HeartBeat,"+this.url),setTimeout(this.heartbeat,3e4)}),1e3)}},Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})}));
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("mqtt-browser")):"function"==typeof define&&define.amd?define(["exports","mqtt-browser"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self)["gis-common"]={},t.mqttBrowser)}(this,(function(t,e){"use strict";var n=Object.defineProperty,r=(t,e,r)=>((t,e,r)=>e in t?n(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r)(t,"symbol"!=typeof e?e+"":e,r),s=(t=>(t.MAP_RENDER="mapRender",t.MAP_READY="mapReady",t.MOUSE_CLICK="click",t.MOUSE_DOUBLE_CLICK="dblclick",t.MOUSE_MOVE="mousemove",t.MOUSE_IN="mousein",t.MOUSE_OUT="mouseout",t.MOUSE_RIGHT_CLICK="mouseRightClick",t.KEY_DOWN="keyDown",t.KEY_UP="keyUp",t.DRAW_ACTIVE="drawActive",t.DRAW_MOVE="drawMove",t.DRAW_COMPLETE="drawComplete",t.MQTT_CONNECT="mqttConnect",t.MQTT_ERROR="mqttError",t.MQTT_MESSAGE="mqttMessage",t.MQTT_CLOSE="mqttClose",t.WEB_SOCKET_CONNECT="webSocketConnect",t.WEB_SOCKET_ERROR="webSocketError",t.WEB_SOCKET_MESSAGE="webSocketMessage",t.WEB_SOCKET_CLOSE="webSocketClose",t))(s||{}),a=(t=>(t.LOGIN_EXPIRED="登录信息过期,请重新登录",t.CROSS_ERROR="跨域访问",t.UNEXIST_RESOURCE="资源不存在",t.TIMEOUT="请求超时",t.INTERNAL_ERROR="内部错误",t.NETWORK_ERROR="请求失败,请检查网络是否已连接",t.PROCESS_FAIL="处理失败",t.AUTH_VERIFY_ERROR="权限验证失败",t.NO_DATA_FOUND="未找到数据",t.DUPLICATE_INSTANCE="实例为单例模式,不允许重复构建",t.JSON_PARSE_ERROR="JSON解析失败,格式有误",t.JSON_VALUE_ERROR="JSON无此键",t.STRING_CHECK_LOSS="字符缺少关键字",t.PARAMETER_ERROR="验证数据类型失败",t.PARAMETER_ERROR_ARRAY="验证数据类型失败,必须是数组",t.PARAMETER_ERROR_STRING="验证数据类型失败,必须是字符",t.PARAMETER_ERROR_FUNCTION="验证数据类型失败,必须是函数",t.PARAMETER_ERROR_OBJECT="验证数据类型失败,必须是对象",t.PARAMETER_ERROR_NUMBER="验证数据类型失败,必须是数值",t.PARAMETER_ERROR_LACK="验证数据类型失败,必须非空",t.DATA_ERROR="格式类型验证失败",t.DATA_ERROR_COORDINATE="格式类型验证失败,必须是坐标",t.DATA_ERROR_COLOR="格式类型验证失败,必须是颜色代码",t.DATA_ERROR_GEOJSON="格式类型验证失败,必须是GeoJSON",t))(a||{}),i=(t=>(t.SUPER_MAP_IMAGES="SuperMapImages",t.SUPER_MAP_DATA="SuperMapData",t.ARC_GIS_MAP_IMAGES="ArcGisMapImages",t.ARC_GIS_MAP_DATA="ArcGisMapData",t.OSGB_LAYER="OSGBLayer",t.S3M_GROUP="S3MGroup",t.TERRAIN_LAYER="TerrainFileLayer",t))(i||{}),o=(t=>(t.POINT="point",t.POLYLINE="polyline",t.POLYGON="polygon",t.BILLBOARD="billboard",t.CYLINDER="cylinder",t.ELLIPSOID="ellipsoid",t.LABEL="label",t.MODEL="model",t.WALL="wall",t))(o||{}),l=(t=>(t.DASH="10,5",t.DOT="3",t.DASHDOT="10,3,3,3",t.DASHDOTDOT="10,3,3,3,3,3",t))(l||{}),c=(t=>(t.DISTANCE="distance",t.AREA="area",t.HEIGHT="height",t))(c||{}),h=(t=>(t.ADD="add",t.REMOVE="remove",t.INIT="init",t))(h||{});const u={getDataType:t=>Object.prototype.toString.call(t).slice(8,-1),asArray(t){return this.isEmpty(t)?[]:Array.isArray(t)?t:[t]},asNumber:t=>Number.isNaN(Number(t))?0:Number(t),asString(t){if(this.isEmpty(t))return"";switch(this.getDataType(t)){case"Object":case"Array":return JSON.stringify(t);default:return t}},isEmpty(t){if(null==t)return!0;switch(this.getDataType(t)){case"String":return""===t.trim();case"Array":return!t.length;case"Object":return!Object.keys(t).length;case"Boolean":return!t;default:return!1}},json2form(t){const e=new FormData;return Object.keys(t).forEach((n=>{e.append(n,t[n]instanceof Object?JSON.stringify(t[n]):t[n])})),e},guid(){const t=function(){return(65536*(1+Math.random())|0).toString(16).substring(1)};return t()+t()+t()+t()+t()+t()+t()+t()},decodeDict(...t){let e="";if(t.length>1){const n=t.slice(1,t.length%2==0?t.length-1:t.length);for(let r=0;r<n.length;r+=2){const s=n[r];t[0]===s&&(e=n[r+1])}e||t.length%2!=0||(e=t[t.length-1])}else e=t[0];return e},extend(t,...e){let n,r,s,a;for(r=0,s=e.length;r<s;r++)for(n in a=e[r],a)t[n]=a[n];return t},convertToTree2(t,e="id",n="parentId",r="children"){const s=[];function a(i){const o=t.filter((t=>t[n]===i[e])).map((t=>(s.some((n=>n[e]===t[e]))||a(t),t)));o.length>0&&(i[r]=o)}return t.forEach((r=>{t.some((t=>t[n]===r[e]))||(a(r),s.push(r))})),s},asyncLoadScript:t=>new Promise(((e,n)=>{try{const r=document.createElement("script");r.type="text/javascript",r.src=t,"readyState"in r?r.onreadystatechange=function(){"complete"!==r.readyState&&"loaded"!==r.readyState||e(r)}:(r.onload=function(){e(r)},r.onerror=function(){n(new Error("Script failed to load for URL: "+t))}),document.body.appendChild(r)}catch(r){n(r)}})),loadStyle(t){t.forEach((t=>{const e=document.createElement("link");e.href=t,e.rel="stylesheet",e.type="text/css",e.onerror=function(){console.error(`Style loading failed for URL: ${t}`)},document.head.appendChild(e)}))},template:(t,e)=>t.replace(/\{ *([\w_-]+) *\}/g,((t,n)=>{const r=e[n];if(void 0===r)throw new Error(`${a.JSON_VALUE_ERROR}: ${t}`);return"function"==typeof r?r(e):r})),deleteEmptyProperty(t){return Object.fromEntries(Object.keys(t).filter((e=>!this.isEmpty(t[e]))).map((e=>[e,t[e]])))},deepAssign(t,...e){"object"==typeof t&&null!==t||(t={});for(const n of e)if("object"==typeof n&&null!==n)for(const e in n)Object.prototype.hasOwnProperty.call(n,e)&&("object"==typeof n[e]&&null!==n[e]?(t[e]||(t[e]=Array.isArray(n[e])?[]:{}),this.deepAssign(t[e],n[e])):t[e]=n[e]);return t},handleCopyValue(t){if(navigator.clipboard&&window.isSecureContext)return navigator.clipboard.writeText(t);{const e=document.createElement("textarea");return e.style.position="fixed",e.style.top=e.style.left="-100vh",e.style.opacity="0",e.value=t,document.body.appendChild(e),e.focus(),e.select(),new Promise(((t,n)=>{try{document.execCommand("copy"),t()}catch(r){n(new Error("copy failed"))}finally{e.remove()}}))}},isArray:t=>Array.isArray(t),isObject:t=>Object.prototype.toString.call(t).indexOf("Object")>-1,isNil:t=>void 0===t||"undefined"===t||null===t||"null"===t,isNumber:t=>"number"==typeof t&&!isNaN(t)||"string"==typeof t&&Number.isFinite(+t),isFunction(t){return!this.isNil(t)&&("function"==typeof t||null!==t.constructor&&t.constructor===Function)},isElement:t=>"object"==typeof t&&1===t.nodeType,checheVersion:(t,e)=>t.replace(/[^0-9]/gi,"")<e.replace(/[^0-9]/gi,"")},d={deepClone:t=>structuredClone(t),isEqual:(t,e)=>JSON.stringify(t)===JSON.stringify(e),parse:t=>t&&"string"==typeof t?JSON.parse(t):t},p={emptyImageUrl:"data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",getURL(t){let e,n;if(/^data:/i.test(t.src))return t.src;if("undefined"==typeof HTMLCanvasElement)return t.src;if(t instanceof HTMLCanvasElement)n=t;else{void 0===e&&(e=document.createElementNS("http://www.w3.org/1999/xhtml","canvas")),e.width=t.width,e.height=t.height;const r=e.getContext("2d");r&&(t instanceof ImageData?r.putImageData(t,0,0):r.drawImage(t,0,0,t.width,t.height)),n=e}return n.width>2048||n.height>2048?(console.warn("ImageUtil.getDataURL: Image converted to jpg for performance reasons",t),n.toDataURL("image/jpeg",.6)):n.toDataURL("image/png")},getBase64(t){return new Promise(((e,n)=>{let r=new Image;r.setAttribute("crossOrigin","Anonymous"),r.src=t,r.onload=()=>{let t=this.getURL(r);e(t)},r.onerror=n}))},parseBase64(t){let e=new RegExp("data:(?<type>.*?);base64,(?<data>.*)").exec(t);return e&&e.groups?{type:e.groups.type,ext:e.groups.type.split("/").slice(-1)[0],data:e.groups.data}:null},async copyImage(t){try{const e=await this.getBase64(t),n=this.parseBase64(e.dataURL);if(!n)throw new Error("Failed to parse base64 data.");let r=n.type,s=atob(n.data),a=new ArrayBuffer(s.length),i=new Uint8Array(a);for(let t=0;t<s.length;t++)i[t]=s.charCodeAt(t);let o=new Blob([a],{type:r});await navigator.clipboard.write([new ClipboardItem({[r]:o})])}catch(e){console.error("Failed to copy image to clipboard:",e)}}},g={jsonp(t,e){const n="_jsonp_"+u.guid(),r=document.getElementsByTagName("head")[0];t.includes("?")?t+="&callback="+n:t+="?callback="+n;let s=document.createElement("script");s.type="text/javascript",s.src=t,window[n]=function(t){e(null,t),r.removeChild(s),s=null,delete window[n]},r.appendChild(s)},get(t,e,n){if(u.isFunction(e)){const t=n;n=e,e=t}const r=this._getClient(n);if(r.open("GET",t,!0),e){for(const t in e.headers)r.setRequestHeader(t,e.headers[t]);r.withCredentials="include"===e.credentials,e.responseType&&(r.responseType=e.responseType)}return r.send(null),r},post(t,e={},n){let r;if("string"!=typeof t?(n=e.cb,r=e.postData,delete(e={...e}).cb,delete e.postData,t=e.url):("function"==typeof e&&(n=e,e={}),r=e.postData),!n)throw new Error("Callback function is required");const s=this._getClient(n);return s.open("POST",t,!0),e.headers=e.headers||{},e.headers["Content-Type"]||(e.headers["Content-Type"]="application/x-www-form-urlencoded"),Object.keys(e.headers).forEach((t=>{s.setRequestHeader(t,e.headers[t])})),"string"!=typeof r&&(r=JSON.stringify(r)),s.send(r),s},_wrapCallback:(t,e)=>function(){if(4===t.readyState)if(200===t.status)if("arraybuffer"===t.responseType){0===t.response.byteLength?e(new Error("http status 200 returned without content.")):e(null,{data:t.response,cacheControl:t.getResponseHeader("Cache-Control"),expires:t.getResponseHeader("Expires"),contentType:t.getResponseHeader("Content-Type")})}else e(null,t.responseText);else e(new Error(t.statusText+","+t.status))},_getClient(t){let e=null;try{e=new XMLHttpRequest}catch(n){throw new Error("XMLHttpRequest not supported.")}return e&&(e.onreadystatechange=this._wrapCallback(e,t)),e},getArrayBuffer(t,e,n){if(u.isFunction(e)){const t=n;n=e,e=t}return e||(e={}),e.responseType="arraybuffer",this.get(t,e,n)},getImage(t,e,n){return this.getArrayBuffer(e,n,((e,n)=>{if(e)t.onerror&&t.onerror(e);else if(n){const e=window.URL||window.webkitURL,r=t.onload;t.onload=()=>{r&&r(),e.revokeObjectURL(t.src)};const s=new Blob([new Uint8Array(n.data)],{type:n.contentType});t.cacheControl=n.cacheControl,t.expires=n.expires,t.src=n.data.byteLength?e.createObjectURL(s):p.emptyImageUrl}}))},getJSON(t,e,n){if(u.isFunction(e)){const t=n;n=e,e=t}const r=function(t,e){const r=e?d.parse(e):null;n&&n(t,r)};return e&&e.jsonp?this.jsonp(t,r):this.get(t,e,r)}},f={DEG2RAD:Math.PI/180,RAD2DEG:180/Math.PI,randInt:(t,e)=>t+Math.floor(Math.random()*(e-t+1)),randFloat:(t,e)=>t+Math.random()*(e-t),deg2Rad(t){return t*this.DEG2RAD},rad2Deg(t){return t*this.RAD2DEG},round:(t,e=2)=>Math.round(t*Math.pow(10,e))/Math.pow(10,e),clamp:(t,e,n)=>Math.max(e,Math.min(n,t))},m={toRadian:Math.PI/180,R:6371393,isLnglat:(t,e)=>!isNaN(t)&&!isNaN(e)&&!!(+e>-90&&+e<90&&+t>-180&&+t<180),distance:(t,e)=>Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2)),distanceByPoints(t,e){const{lng:n,lat:r}=t,{lng:s,lat:a}=e;let i=Math.cos(r*Math.PI/180)*Math.cos(a*Math.PI/180)*Math.cos((n-s)*Math.PI/180)+Math.sin(r*Math.PI/180)*Math.sin(a*Math.PI/180);i>1&&(i=1),i<-1&&(i=-1);return 6371e3*Math.acos(i)},formatLnglat(t,e){let n="";function r(t){const e=Math.floor(t),n=Math.floor(60*(t-e));return`${e}°${n}′${(3600*(t-e)-60*n).toFixed(2)}″`}return this.isLnglat(t,e)?n=r(t)+","+r(e):isNaN(t)?isNaN(e)||(n=r(e)):n=r(t),n},transformLnglat(t,e){function n(t){let e=/[sw]/i.test(t)?-1:1;const n=t.match(/[\d.]+/g)||[];let r=0;for(let s=0;s<n.length;s++)r+=parseFloat(n[s])/e,e*=60;return r}if(t&&e)return{lng:n(t),lat:n(e)}},rayCasting(t,e){for(var n=t.x,r=t.y,s=!1,a=0,i=e.length,o=i-1;a<i;o=a,a++){var l=e[a].x,c=e[a].y,h=e[o].x,u=e[o].y;if(l===n&&c===r||h===n&&u===r)return"on";if(c<r&&u>=r||c>=r&&u<r){var d=l+(r-c)*(h-l)/(u-c);if(d===n)return"on";d>n&&(s=!s)}}return s?"in":"out"},rotatePoint:(t,e,n)=>({x:(t.x-e.x)*Math.cos(Math.PI/180*-n)-(t.y-e.y)*Math.sin(Math.PI/180*-n)+e.x,y:(t.x-e.x)*Math.sin(Math.PI/180*-n)+(t.y-e.y)*Math.cos(Math.PI/180*-n)+e.y}),calcBearAndDis(t,e){const{x:n,y:r}=t,{x:s,y:a}=e,i=s-n,o=a-r,l=Math.sqrt(i*i+o*o);return{angle:(Math.atan2(o,i)*(180/Math.PI)+360+90)%360,distance:l}},calcBearAndDisByPoints(t,e){var n=1*t.lat,r=1*t.lng,s=1*e.lat,a=1*e.lng,i=Math.sin((a-r)*this.toRadian)*Math.cos(s*this.toRadian),o=Math.cos(n*this.toRadian)*Math.sin(s*this.toRadian)-Math.sin(n*this.toRadian)*Math.cos(s*this.toRadian)*Math.cos((a-r)*this.toRadian),l=Math.atan2(i,o)*(180/Math.PI),c=(s-n)*this.toRadian,h=(a-r)*this.toRadian,u=Math.sin(c/2)*Math.sin(c/2)+Math.cos(n*this.toRadian)*Math.cos(s*this.toRadian)*Math.sin(h/2)*Math.sin(h/2),d=2*Math.atan2(Math.sqrt(u),Math.sqrt(1-u));return{angle:l,distance:this.R*d}},distanceToSegment(t,e,n){const r=t.x,s=t.y,a=e.x,i=e.y,o=n.x,l=n.y,c=(o-a)*(r-a)+(l-i)*(s-i);if(c<=0)return Math.sqrt((r-a)*(r-a)+(s-i)*(s-i));const h=(o-a)*(o-a)+(l-i)*(l-i);if(c>=h)return Math.sqrt((r-o)*(r-o)+(s-l)*(s-l));const u=c/h,d=a+(o-a)*u,p=i+(l-i)*u;return Math.sqrt((r-d)*(r-d)+(s-p)*(s-p))},calcPointByBearAndDis(t,e,n){const r=f.deg2Rad(1*t.lat),s=f.deg2Rad(1*t.lng),a=n/this.R;e=f.deg2Rad(e);const i=Math.asin(Math.sin(r)*Math.cos(a)+Math.cos(r)*Math.sin(a)*Math.cos(e)),o=s+Math.atan2(Math.sin(e)*Math.sin(a)*Math.cos(r),Math.cos(a)-Math.sin(r)*Math.sin(i));return{lat:f.rad2Deg(i),lng:f.rad2Deg(o)}},mercatorTolonlat(t,e){var n=e/20037508.34*180;return{lng:t/20037508.34*180,lat:180/Math.PI*(2*Math.atan(Math.exp(n*Math.PI/180))-Math.PI/2)}},lonlatToMercator(t,e){var n=6378137;const r=t*Math.PI/180*n;var s=e*Math.PI/180;return{x:r,y:3189068.5*Math.log((1+Math.sin(s))/(1-Math.sin(s)))}},interpolate:({x:t,y:e,z:n=0},{x:r,y:s,z:a=0},i)=>({x:t+(r-t)*i,y:e+(s-e)*i,z:n+(a-n)*i})},y={checkStr(t,e){switch(e){case"phone":return/^1[3|4|5|6|7|8|9][0-9]{9}$/.test(t);case"tel":return/^(0\d{2,3}-\d{7,8})(-\d{1,4})?$/.test(t);case"card":return/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/.test(t);case"pwd":return/^[a-zA-Z]\w{5,17}$/.test(t);case"postal":return/[1-9]\d{5}(?!\d)/.test(t);case"QQ":return/^[1-9][0-9]{4,9}$/.test(t);case"email":return/^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/.test(t);case"money":return/^\d*(?:\.\d{0,2})?$/.test(t);case"URL":return/(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?/.test(t);case"IP":return/((?:(?:25[0-5]|2[0-4]\\d|[01]?\\d?\\d)\\.){3}(?:25[0-5]|2[0-4]\\d|[01]?\\d?\\d))/.test(t);case"date":return/^(\d{4})\-(\d{2})\-(\d{2}) (\d{2})(?:\:\d{2}|:(\d{2}):(\d{2}))$/.test(t)||/^(\d{4})\-(\d{2})\-(\d{2})$/.test(t);case"number":return/^[0-9]$/.test(t);case"english":return/^[a-zA-Z]+$/.test(t);case"chinese":return/^[\u4E00-\u9FA5]+$/.test(t);case"lower":return/^[a-z]+$/.test(t);case"upper":return/^[A-Z]+$/.test(t);case"HTML":return/<("[^"]*"|'[^']*'|[^'">])*>/.test(t);default:return!0}},changeCase(t,e){switch(e=e||4){case 1:return t.replace(/\b\w+\b/g,(function(t){return t.substring(0,1).toUpperCase()+t.substring(1).toLowerCase()}));case 2:return t.replace(/\b\w+\b/g,(function(t){return t.substring(0,1).toLowerCase()+t.substring(1).toUpperCase()}));case 3:return t.split("").map((function(t){return/[a-z]/.test(t)?t.toUpperCase():t.toLowerCase()})).join("");case 4:return t.toUpperCase();case 5:return t.toLowerCase();default:return t}},tag:(t,...e)=>(e=e.map((t=>{switch(u.getDataType(t)){case"Object":return t||"{}";case"Array":return t||"[]";default:return t||""}})),t.reduce(((t,n,r)=>`${t}${e[r-1]}${n}`))),getByteLength:t=>t.replace(/[\u0391-\uFFE5]/g,"aa").length,subStringByte(t,e,n){var r=/[^\x00-\xff]/g;if(t.replace(r,"mm").length<=n)return t;for(var s=Math.floor(n/2);s<t.length;s++){let a=t.substring(e,s);if(a.replace(r,"mm").length>=n)return a}return t}},E=["Point","MultiPoint","LineString","MultiLineString","Polygon","MultiPolygon"],M={getGeoJsonType:t=>t.geometry?t.geometry.type:null,isGeoJson(t){const e=this.getGeoJsonType(t);if(e)for(let n=0,r=E.length;n<r;n++)if(E[n]===e)return!0;return!1},isGeoJsonPolygon(t){const e=this.getGeoJsonType(t);return!(!e||e!==E[4]&&e!==E[5])},isGeoJsonLine(t){const e=this.getGeoJsonType(t);return!(!e||e!==E[2]&&e!==E[3])},isGeoJsonPoint(t){const e=this.getGeoJsonType(t);return!(!e||e!==E[0]&&e!==E[1])},isGeoJsonMulti(t){const e=this.getGeoJsonType(t);return!!(e&&e.indexOf("Multi")>-1)},getGeoJsonCoordinates:t=>t.geometry?t.geometry.coordinates:[],getGeoJsonCenter(t,e){const n=this.getGeoJsonType(t);if(!n||!t.geometry)return null;const r=t.geometry.coordinates;if(!r)return null;let s=0,a=0,i=0;switch(n){case"Point":s=r[0],a=r[1],i++;break;case"MultiPoint":case"LineString":for(let t=0,e=r.length;t<e;t++)s+=r[t][0],a+=r[t][1],i++;break;case"MultiLineString":case"Polygon":for(let t=0,e=r.length;t<e;t++)for(let n=0,o=r[t].length;n<o;n++)s+=r[t][n][0],a+=r[t][n][1],i++;break;case"MultiPolygon":for(let t=0,e=r.length;t<e;t++)for(let n=0,o=r[t].length;n<o;n++)for(let e=0,l=r[t][n].length;e<l;e++)s+=r[t][n][e][0],a+=r[t][n][e][1],i++}const o=s/i,l=a/i;return e?(e.x=o,e.y=l,e):{x:o,y:l}},spliteGeoJsonMulti(t){const e=this.getGeoJsonType(t);if(!e||!t.geometry)return null;const n=t.geometry,r=t.properties||{},s=n.coordinates;if(!s)return null;const a=[];let i;switch(e){case"MultiPoint":i="Point";break;case"MultiLineString":i="LineString";break;case"MultiPolygon":i="Polygon"}if(i)for(let o=0,l=s.length;o<l;o++)a.push({type:"Feature",geometry:{type:i,coordinates:s[o]},properties:r});else a.push(t);return a},getGeoJsonByCoordinates(t){if(!Array.isArray(t))throw Error("coordinates 参数格式错误");let e;if(2===t.length&&"number"==typeof t[0]&&"number"==typeof t[1])e="Point";else if(Array.isArray(t[0])&&2===t[0].length)e="LineString";else{if(!Array.isArray(t[0])||!Array.isArray(t[0][0]))throw Error("coordinates 参数格式错误");{const n=t[0];if(n[0].join(",")===n[n.length-1].join(","))e="Polygon";else{if(!(t.length>1))throw Error("coordinates 参数格式错误");e="MultiPolygon"}}}return{type:"Feature",geometry:{type:e,coordinates:t}}}},R={assertEmpty(...t){t.forEach((t=>{if(u.isEmpty(t))throw Error(a.PARAMETER_ERROR_LACK+" -> "+t)}))},assertNumber(...t){t.forEach((t=>{if(!u.isNumber(t))throw Error(a.PARAMETER_ERROR_NUMBER+" -> "+t)}))},assertArray(...t){t.forEach((t=>{if(!u.isArray(t))throw Error(a.PARAMETER_ERROR_ARRAY+" -> "+t)}))},assertFunction(...t){t.forEach((t=>{if(!u.isFunction(t))throw Error(a.PARAMETER_ERROR_FUNCTION+" -> "+t)}))},assertObject(...t){t.forEach((t=>{if(!u.isObject(t))throw Error(a.PARAMETER_ERROR_OBJECT+" -> "+t)}))},assertColor(...t){t.forEach((t=>{if(!v.isColor(t))throw Error(a.DATA_ERROR_COLOR+" -> "+t)}))},assertLnglat(...t){t.forEach((t=>{if(!m.isLnglat(t.lng,t.lat))throw Error(a.DATA_ERROR_COORDINATE+" -> "+t)}))},assertGeoJson(...t){t.forEach((t=>{if(!M.isGeoJson(t))throw Error(a.DATA_ERROR_GEOJSON+" -> "+t)}))},assertContain(t,...e){let n=!1;for(let r=0,s=e.length||0;r<s;r++)n=t.indexOf(e[r])>=0;if(n)throw Error(a.STRING_CHECK_LOSS+" -> "+t)},assertLegal(t,e){const n=y.checkStr(t,e);let r="";switch(e){case"phone":r="电话";break;case"tel":r="座机";break;case"card":r="身份证";break;case"pwd":r="密码";break;case"postal":r="邮政编码";break;case"QQ":r="QQ";break;case"email":r="邮箱";break;case"money":r="金额";break;case"URL":r="网址";break;case"IP":r="IP";break;case"date":r="日期时间";break;case"number":r="数字";break;case"english":r="英文";break;case"chinese":r="中文";break;case"lower":r="小写";break;case"upper":r="大写";break;case"HTML":r="HTML标记"}if(!n)throw Error(a.DATA_ERROR+" -> 不是"+r)}},w=Object.create(Array);w.groupBy=function(t){var e={};return this.forEach((function(n){var r=JSON.stringify(t(n));e[r]=e[r]||[],e[r].push(n)})),Object.keys(e).map((t=>e[t]))},w.distinct=function(t=t=>t){const e=[],n={};return this.forEach((r=>{const s=t(r),a=String(s);n[a]||(n[a]=!0,e.push(r))})),e},w.prototype.max=function(){return Math.max.apply({},this)},w.prototype.min=function(){return Math.min.apply({},this)},w.sum=function(){return this.length>0?this.reduce(((t=0,e=0)=>t+e)):0},w.avg=function(){return this.length?this.sum()/this.length:0},w.desc=function(t=t=>t){return this.sort(((e,n)=>t(n)-t(e)))},w.asc=function(t=t=>t){return this.sort(((e,n)=>t(e)-t(n)))},w.random=function(){return this[Math.floor(Math.random()*this.length)]},w.remove=function(t){const e=this.indexOf(t);return e>-1&&this.splice(e,1),this};const A={create:t=>[...new Array(t).keys()],union(...t){let e=[];return t.forEach((t=>{Array.isArray(t)&&(e=e.concat(t.filter((t=>!e.includes(t)))))})),e},intersection(...t){let e=t[0]||[];return t.forEach((t=>{Array.isArray(t)&&(e=e.filter((e=>t.includes(e))))})),e},unionAll:(...t)=>[...t].flat().filter((t=>!!t)),difference(...t){return 0===t.length?[]:this.union(...t).filter((e=>!this.intersection(...t).includes(e)))}},b={getExplorer(){var t=window.navigator.userAgent;return t.indexOf("MSIE")>=0||/Trident\//.test(t)?"IE":t.indexOf("Firefox")>=0?"Firefox":t.indexOf("Chrome")>=0?"Chrome":t.indexOf("Opera")>=0?"Opera":t.indexOf("Safari")>=0&&-1===t.indexOf("Chrome")?"Safari":"Unknown"},detectOS(){let t="";const e=-1!=navigator.userAgent.indexOf("Windows",0)?1:0,n=-1!=navigator.userAgent.indexOf("mac",0)?1:0,r=-1!=navigator.userAgent.indexOf("Linux",0)?1:0,s=-1!=navigator.userAgent.indexOf("X11",0)?1:0;return e?t="MS Windows":n?t="Apple mac":r?t="Linux":s&&(t="Unix"),t},switchFullScreen(t){if(t){const t=document.documentElement;t.requestFullscreen?t.requestFullscreen():"msRequestFullscreen"in t?t.msRequestFullscreen():"mozRequestFullScreen"in t?t.mozRequestFullScreen():"webkitRequestFullscreen"in t&&t.webkitRequestFullscreen()}else document.exitFullscreen?document.exitFullscreen():"msExitFullscreen"in document?document.msExitFullscreen():"mozCancelFullScreen"in document?document.mozCancelFullScreen():"webkitExitFullscreen"in document&&document.webkitExitFullscreen()},refreshScale(){const t=document.documentElement.clientWidth||0,e=document.documentElement.clientHeight||0,n=document.getElementById("app");if(!n)return;const r=n.style;let s=t/1920;t/e>16/9&&(s=e/1080),r.transformOrigin="left top",r.transform=`scale(${s}) translateX(-49.99%)`,r.width=t/s+"px"},getHtmlFontSize(){const t=document.documentElement.clientWidth||document.body.clientWidth,e=document.querySelector("html");e&&(e.style.fontSize=t/192+"px")}},_={PI:3.141592653589793,XPI:52.35987755982988,delta(t,e){const n=6378245,r=.006693421622965943;let s=this.transformLat(e-105,t-35),a=this.transformLon(e-105,t-35);const i=t/180*this.PI;let o=Math.sin(i);o=1-r*o*o;const l=Math.sqrt(o);return s=180*s/(n*(1-r)/(o*l)*this.PI),a=180*a/(n/l*Math.cos(i)*this.PI),{lat:s,lng:a}},outOfChina:(t,e)=>t<72.004||t>137.8347||(e<.8293||e>55.8271),gcjEncrypt(t,e){if(this.outOfChina(t,e))return{lat:t,lng:e};const n=this.delta(t,e);return{lat:t+n.lat,lng:e+n.lng}},gcjDecrypt(t,e){if(this.outOfChina(t,e))return{lat:t,lng:e};const n=this.delta(t,e);return{lat:t-n.lat,lng:e-n.lng}},gcjDecryptExact(t,e){let n=.01,r=.01,s=t-n,a=e-r,i=t+n,o=e+r,l=0,c=0,h=0;for(;;){l=(s+i)/2,c=(a+o)/2;const u=this.gcjEncrypt(l,c);if(n=u.lat-t,r=u.lng-e,Math.abs(n)<1e-9&&Math.abs(r)<1e-9)break;if(n>0?i=l:s=l,r>0?o=c:a=c,++h>1e4)break}return{lat:l,lng:c}},bdEncrypt(t,e){const n=e,r=t,s=Math.sqrt(n*n+r*r)+2e-5*Math.sin(r*this.XPI),a=Math.atan2(r,n)+3e-6*Math.cos(n*this.XPI),i=s*Math.cos(a)+.0065;return{lat:s*Math.sin(a)+.006,lng:i}},bdDecrypt(t,e){const n=e-.0065,r=t-.006,s=Math.sqrt(n*n+r*r)-2e-5*Math.sin(r*this.XPI),a=Math.atan2(r,n)-3e-6*Math.cos(n*this.XPI),i=s*Math.cos(a);return{lat:s*Math.sin(a),lng:i}},mercatorEncrypt(t,e){const n=20037508.34*e/180;let r=Math.log(Math.tan((90+t)*this.PI/360))/(this.PI/180);return r=20037508.34*r/180,{lat:r,lng:n}},mercatorDecrypt(t,e){const n=e/20037508.34*180;let r=t/20037508.34*180;return r=180/this.PI*(2*Math.atan(Math.exp(r*this.PI/180))-this.PI/2),{lat:r,lng:n}},transformLat(t,e){let n=2*t-100+3*e+.2*e*e+.1*t*e+.2*Math.sqrt(Math.abs(t));return n+=2*(20*Math.sin(6*t*this.PI)+20*Math.sin(2*t*this.PI))/3,n+=2*(20*Math.sin(e*this.PI)+40*Math.sin(e/3*this.PI))/3,n+=2*(160*Math.sin(e/12*this.PI)+320*Math.sin(e*this.PI/30))/3,n},transformLon(t,e){let n=300+t+2*e+.1*t*t+.1*t*e+.1*Math.sqrt(Math.abs(t));return n+=2*(20*Math.sin(6*t*this.PI)+20*Math.sin(2*t*this.PI))/3,n+=2*(20*Math.sin(t*this.PI)+40*Math.sin(t/3*this.PI))/3,n+=2*(150*Math.sin(t/12*this.PI)+300*Math.sin(t/30*this.PI))/3,n},random:({x:t,y:e},{x:n,y:r})=>({x:Math.random()*(n-t)+t,y:Math.random()*(r-e)+e}),deCompose(t,e,n){if(!Array.isArray(t))return n?e.call(n,t):e(t);const r=[];let s,a;for(let i=0,o=t.length;i<o;i++)s=t[i],u.isNil(s)?r.push(null):Array.isArray(s)?r.push(this.deCompose(s,e,n)):(a=n?e.call(n,s):e(s),r.push(a));return r}},x=Object.create(Date);x.prototype.format=function(t="yyyy-MM-dd hh:mm:ss"){const e={"M+":this.getMonth()+1,"d+":this.getDate(),"h+":this.getHours()%12,"H+":this.getHours(),"m+":this.getMinutes(),"s+":this.getSeconds(),"q+":Math.floor((this.getMonth()+3)/3),S:this.getMilliseconds()};/(y+)/.test(t)&&(t=t.replace(RegExp.$1,(this.getFullYear()+"").substr(4-RegExp.$1.length)));for(const n in e)if(new RegExp("("+n+")").test(t)){const r=1===n.length?1:Number(n.slice(1));t=t.replace(RegExp.$1,("00"+e[n]).substr((""+e[n]).length+r-(e[n]+"").length))}return t},x.prototype.addDate=function(t,e){const n=new Date(this);switch(t){case"y":n.setFullYear(this.getFullYear()+e);break;case"q":n.setMonth(this.getMonth()+3*e);break;case"M":n.setMonth(this.getMonth()+e);break;case"w":n.setDate(this.getDate()+7*e);break;case"d":default:n.setDate(this.getDate()+e);break;case"h":n.setHours(this.getHours()+e);break;case"m":n.setMinutes(this.getMinutes()+e);break;case"s":n.setSeconds(this.getSeconds()+e)}return n};const O={lastMonthDate:new Date((new Date).getFullYear(),(new Date).getMonth()-1,1),thisMonthDate:new Date((new Date).getFullYear(),(new Date).getMonth(),1),nextMonthDate:new Date((new Date).getFullYear(),(new Date).getMonth()+1,1),lastWeekDate:new Date((new Date).getFullYear(),(new Date).getMonth(),(new Date).getDate()+1-7-(new Date).getDay()),thisWeekDate:new Date((new Date).getFullYear(),(new Date).getMonth(),(new Date).getDate()+1-(new Date).getDay()),nextWeekDate:new Date((new Date).getFullYear(),(new Date).getMonth(),(new Date).getDate()+1+7-(new Date).getDay()),lastDayDate:new Date((new Date).getFullYear(),(new Date).getMonth(),(new Date).getDate()-1),thisDayDate:new Date((new Date).setHours(0,0,0,0)),nextDayDate:new Date((new Date).getFullYear(),(new Date).getMonth(),(new Date).getDate()+1),parseDate(t){if("string"==typeof t){var e=t.match(/^ *(\d{4})-(\d{1,2})-(\d{1,2}) *$/);if(e&&e.length>3)return new Date(parseInt(e[1]),parseInt(e[2])-1,parseInt(e[3]));if((e=t.match(/^ *(\d{4})-(\d{1,2})-(\d{1,2}) +(\d{1,2}):(\d{1,2}):(\d{1,2}) *$/))&&e.length>6)return new Date(parseInt(e[1]),parseInt(e[2])-1,parseInt(e[3]),parseInt(e[4]),parseInt(e[5]),parseInt(e[6]));if((e=t.match(/^ *(\d{4})-(\d{1,2})-(\d{1,2}) +(\d{1,2}):(\d{1,2}):(\d{1,2})\.(\d{1,9}) *$/))&&e.length>7)return new Date(parseInt(e[1]),parseInt(e[2])-1,parseInt(e[3]),parseInt(e[4]),parseInt(e[5]),parseInt(e[6]),parseInt(e[7]))}return null},formatDateInterval(t,e){const n=new Date(t),r=new Date(e).getTime()-n.getTime(),s=Math.floor(r/864e5),a=r%864e5,i=Math.floor(a/36e5),o=a%36e5,l=Math.floor(o/6e4),c=o%6e4,h=Math.round(c/1e3);let u="";return s>0&&(u+=s+"天"),i>0&&(u+=i+"时"),l>0&&(u+=l+"分"),h>0&&(u+=h+"秒"),0===s&&0===i&&0===l&&0===h&&(u="少于1秒"),u},formatterCounter(t){const e=function(t){return(t>10?"":"0")+(t||0)},n=t%3600,r=n%60;return`${e(Math.floor(t/3600))}:${e(Math.floor(n/60))}:${e(Math.round(r))}`},sleep(t){}};function C(t){return function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).split(/\s+/)}const S={getStyle(t,e){var n;let r=t.style[e];if(!r||"auto"===r){const s=null==(n=document.defaultView)?void 0:n.getComputedStyle(t,null);r=s?s[e]:null,"auto"===r&&(r=null)}return r},create(t,e,n){const r=document.createElement(t);return r.className=e||"",n&&n.appendChild(r),r},remove(t){const e=t.parentNode;e&&e.removeChild(t)},empty(t){for(;t.firstChild;)t.removeChild(t.firstChild)},toFront(t){const e=t.parentNode;e&&e.lastChild!==t&&e.appendChild(t)},toBack(t){const e=t.parentNode;e&&e.firstChild!==t&&e.insertBefore(t,e.firstChild)},getClass:t=>((null==t?void 0:t.host)||t).className.toString(),hasClass(t,e){var n;if(null==(n=t.classList)?void 0:n.contains(e))return!0;const r=this.getClass(t);return r.length>0&&new RegExp(`(^|\\s)${e}(\\s|$)`).test(r)},addClass(t,e){if(void 0!==t.classList){const n=C(e);for(let e=0,r=n.length;e<r;e++)t.classList.add(n[e])}else if(!this.hasClass(t,e)){const n=this.getClass(t);this.setClass(t,(n?n+" ":"")+e)}},removeClass(t,e){if(void 0!==t.classList){C(e).forEach((e=>t.classList.remove(e)))}else this.setClass(t,(" "+this.getClass(t)+" ").replace(" "+e+" "," ").trim())},setClass(t,e){"classList"in t&&(t.classList.value="",e.split(" ").forEach((e=>t.classList.add(e))))},parseFromString:t=>(new DOMParser).parseFromString(t,"text/xml").children[0]},T={convertBase64ToBlob(t){const e=t.split(",")[0].split(":")[1].split(";")[0],n=atob(t.split(",")[1]),r=new Array(n.length);for(let a=0;a<n.length;a++)r[a]=n.charCodeAt(a);const s=new Uint8Array(r);return new Blob([s],{type:e})},convertBase64ToFile(t,e){const n=t.split(","),r=n[0].match(/:(.*?);/),s=r?r[1]:"image/png",a=atob(n[1]),i=new Uint8Array(a.length);for(let o=0;o<a.length;o++)i[o]=a.charCodeAt(o);return new File([i],e,{type:s})},downloadFromFile(t,e){if("object"==typeof t)if(t instanceof Blob)t=URL.createObjectURL(t);else{const e=JSON.stringify(t),n=new Blob([e],{type:"text/json"});t=window.URL.createObjectURL(n)}else if("string"==typeof t&&-1===t.indexOf("http")){const e=new Blob([t],{type:"text/json"});t=window.URL.createObjectURL(e)}var n=document.createElement("a");n.href=t,n.download=e||"",n.click(),window.URL.revokeObjectURL(n.href)}},D={debounce(t,e,n=!0){let r,s,a=null;const i=()=>{const o=Date.now()-r;o<e&&o>0?a=setTimeout(i,e-o):(a=null,n||(s=t.apply(this,undefined)))};return(...o)=>{r=Date.now();const l=n&&!a;return a||(a=setTimeout(i,e)),l&&(s=t.apply(this,o),a||(o=null)),s}},throttle(t,e,n=1){let r=0,s=null;return(...a)=>{if(1===n){const n=Date.now();n-r>=e&&(t.apply(this,a),r=n)}else 2===n&&(s||(s=setTimeout((()=>{s=null,t.apply(this,a)}),e)))}},memoize(t){const e=new Map;return(...n)=>{const r=JSON.stringify(n);if(e.has(r))return e.get(r);{const s=t.apply(this,n);return e.set(r,s),s}}},recurve(t,e=500,n=5e3){let r=0;setTimeout((()=>{r++,r<Math.floor(n/e)&&(t.call(this),setTimeout(this.recurve.bind(this,t,e,n),e))}),e)},once(t){let e=!1;return function(...n){if(!e)return e=!0,t(...n)}}},I={json2Query(t){var e=[];for(var n in t)if(t.hasOwnProperty(n)){var r=n,s=t[n];e.push(encodeURIComponent(r)+"="+encodeURIComponent(s))}return e.join("&")},query2Json(t=window.location.href,e=!0){const n=/([^&=]+)=([\w\W]*?)(&|$|#)/g,{search:r,hash:s}=new URL(t),a=[r,s];let i={};for(let o=0;o<a.length;o++){const t=a[o];if(t){const r=t.replace(/#|\//g,"").split("?");if(r.length>1)for(let t=1;t<r.length;t++){let s;for(;s=n.exec(r[t]);)i[s[1]]=e?decodeURIComponent(s[2]):s[2]}}}return i}};class v{constructor(t,e,n,s){r(this,"_r"),r(this,"_g"),r(this,"_b"),r(this,"_alpha"),this._validateColorChannel(t),this._validateColorChannel(e),this._validateColorChannel(n),this._r=t,this._g=e,this._b=n,this._alpha=f.clamp(s||1,0,1)}_validateColorChannel(t){if(t<0||t>255)throw new Error("Color channel must be between 0 and 255.")}get rgba(){return{r:this._r,g:this._g,b:this._b,a:this._alpha}}get hex(){return v.rgb2hex(this._r,this._g,this._b,this._alpha)}setRgb(t,e,n,r){return this._validateColorChannel(t),this._validateColorChannel(e),this._validateColorChannel(n),this._r=t,this._g=e,this._b=n,this._alpha=f.clamp(r,0,1),this}static fromRgba(t){const e=t.match(/^rgba?\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([\d.]+))?\s*\)$/);if(!e)throw new Error("Invalid RGBA color value");const n=parseInt(e[1],10),r=parseInt(e[2],10),s=parseInt(e[3],10),a=e[5]?parseFloat(e[5]):1;return new v(n,r,s,a)}static fromHex(t,e=1){const n=t.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i,((t,e,n,r)=>e+e+n+n+r+r)),r=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(n);if(!r)throw new Error("Invalid HEX color value");const s=parseInt(r[1],16),a=parseInt(r[2],16),i=parseInt(r[3],16);return new v(s,a,i,e)}static fromHsl(t){const e=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(t)||/hsla\((\d+),\s*([\d.]+)%,\s*([\d.]+)%,\s*([\d.]+)\)/g.exec(t);if(!e)throw new Error("Invalid HSL color value");const n=parseInt(e[1],10)/360,r=parseInt(e[2],10)/100,s=parseInt(e[3],10)/100,a=e[4]?parseFloat(e[4]):1;function i(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+6*(e-t)*n:n<.5?e:n<2/3?t+(e-t)*(2/3-n)*6:t}let o,l,c;if(0===r)o=l=c=s;else{const t=s<.5?s*(1+r):s+r-s*r,e=2*s-t;o=i(e,t,n+1/3),l=i(e,t,n),c=i(e,t,n-1/3)}return new v(Math.round(255*o),Math.round(255*l),Math.round(255*c),a)}static from(t){if(this.isRgb(t))return this.fromRgba(t);if(this.isHex(t))return this.fromHex(t);if(this.isHsl(t))return this.fromHsl(t);throw new Error("Invalid color value")}static rgb2hex(t,e,n,r){var s="#"+((1<<24)+(t<<16)+(e<<8)+n).toString(16).slice(1);if(void 0!==r){return s+Math.round(255*r).toString(16).padStart(2,"0")}return s}static isHex(t){return/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(t)}static isRgb(t){return/^rgb/.test(t)}static isHsl(t){return/^hsl/.test(t)}static isColor(t){return this.isHex(t)||this.isRgb(t)||this.isHsl(t)}static random(){let t=Math.floor(256*Math.random()),e=Math.floor(256*Math.random()),n=Math.floor(256*Math.random()),r=Math.random();return new v(t,e,n,r)}}class P{constructor(){r(this,"_listeners"),r(this,"_mutex",{}),r(this,"_context")}addEventListener(t,e,n,r){void 0===this._listeners&&(this._listeners={}),this._context=n;const s=this._mutex,a=this._listeners;return void 0===a[t]&&(a[t]=[]),-1===a[t].indexOf(e)&&(r&&(s[t]=e),a[t].push(e)),this}hasEventListener(t,e){if(null===this._listeners||void 0===this._listeners)return!1;const n=this._listeners;return void 0!==n[t]&&-1!==n[t].indexOf(e)}removeEventListener(t,e){if(void 0===this._listeners)return;const n=this._listeners[t];if(this._mutex[t]===e&&(this._mutex[t]=null),void 0!==n){const t=n.map((t=>t.toString())).indexOf(e.toString());-1!==t&&n.splice(t,1)}}dispatchEvent(t){if(void 0===this._listeners)return;const e=this._listeners[t.type];if(void 0!==e){t.target=this;const n=e.slice(0);if(void 0!==this._mutex[t.type]){const e=n.find((e=>e===this._mutex[t.type]));if(e)return void e.call(this._context||this,t)}for(let e=0,r=n.length;e<r;e++){const r=n[e];"function"==typeof r&&r.call(this._context||this,t)}}}removeAllListener(){this._mutex={};for(const t in this._listeners)this._listeners[t]=[]}}class L extends Map{isEmpty(){return 0===this.size}_values(){return Array.from(this.values())}_keys(){return Array.from(this.keys())}_entries(){return Array.from(this.entries())}static fromEntries(t=[]){const e=new L;return t.forEach((t=>{Array.isArray(t)&&2===t.length&&e.set(t[0],t[1])})),e}}const k=class t extends P{constructor(n=`ws://${window.document.domain}:20007/mqtt`,s={}){super(),r(this,"state"),r(this,"url"),r(this,"context"),r(this,"options"),r(this,"client"),r(this,"topics"),this.context=u.extend(t.defaultContext,s),this.options={connectTimeout:this.context.MQTT_TIMEOUTM,clientId:u.guid(),username:this.context.MQTT_USERNAME,password:this.context.MQTT_PASSWORD,clean:!0},this.url=n,this.client=e.connect(this.url,this.options),this._onConnect(),this._onMessage(),this.state=0,this.topics=[]}_onConnect(){this.client.on("connect",(()=>{this.state=1,console.log("链接mqtt成功==>"+this.url),this.dispatchEvent({type:s.MQTT_CONNECT,message:this})})),this.client.on("error",(t=>{console.log("链接mqtt报错",t),this.state=-1,this.dispatchEvent({type:s.MQTT_ERROR,message:this}),this.client.end(),this.client.reconnect()}))}_onMessage(){this.client.on("message",((t,e)=>{let n=e,r="";e instanceof Uint8Array&&(n=e.toString());try{r=d.parse(n)}catch(i){throw new Error(a.JSON_PARSE_ERROR)}this.dispatchEvent({type:s.MQTT_MESSAGE,message:{topic:t,data:r}})}))}sendMsg(t,e){this.client.connected?this.client.publish(t,e,{qos:1,retain:!0}):console.error("客户端未连接")}subscribe(t){return 1===this.state?this.client.subscribe(t,{qos:1},((e,n)=>{e instanceof Error?console.error("订阅失败==>"+t,e):(this.topics=A.union(this.topics,t),console.log("订阅成功==>"+t))})):this.addEventListener(s.MQTT_CONNECT,(e=>{this.client.subscribe(t,{qos:1},((e,n)=>{e instanceof Error?console.error("订阅失败==>"+t,e):(this.topics=A.union(this.topics,t),console.log("订阅成功==>"+t))}))})),this}unsubscribe(t){return this.client.unsubscribe(t,{qos:1},((e,n)=>{e instanceof Error?console.error(`取消订阅失败==>${t}`,e):(this.topics=A.difference(this.topics,t),console.log(`取消订阅成功==>${t}`))})),this}unsubscribeAll(){this.unsubscribe(this.topics)}unconnect(){this.client.end(),this.client=null,this.dispatchEvent({type:s.MQTT_CLOSE,message:null}),console.log("断开mqtt成功==>"+this.url)}};r(k,"defaultContext",{MQTT_USERNAME:"iRVMS-WEB",MQTT_PASSWORD:"novasky888",MQTT_TIMEOUTM:2e4});let N=k;const U=class t{static set(t,e=null,n={}){var r=this._getPrefixedKey(t,n);try{const{expires:t}=n,s={data:e};t&&(s.expires=t),localStorage.setItem(r,JSON.stringify(s))}catch(s){console&&console.warn(`Storage didn't successfully save the '{"${t}": "${e}"}' pair, because the localStorage is full.`)}}static get(t,e,n){var r,s=this._getPrefixedKey(t,n);try{r=JSON.parse(localStorage.getItem(s)||"")}catch(a){r=localStorage[s]?{data:localStorage.getItem(s)}:null}if(!r)return e;if("object"==typeof r&&void 0!==r.data){const t=r.expires;return t&&Date.now()>t?e:r.data}}static keys(){const e=[];var n=Object.keys(localStorage);return 0===t.prefix.length?n:(n.forEach((function(n){-1!==n.indexOf(t.prefix)&&e.push(n.replace(t.prefix,""))})),e)}static getAll(e){var n=t.keys();if(e){const r=[];return n.forEach((n=>{if(e.includes(n)){const e={};e[n]=t.get(n,null,null),r.push(e)}})),r}return n.map((e=>t.get(e,null,null)))}static remove(t,e){var n=this._getPrefixedKey(t,e);localStorage.removeItem(n)}static clear(e){t.prefix.length?this.keys().forEach((t=>{localStorage.removeItem(this._getPrefixedKey(t,e))})):localStorage.clear()}};r(U,"prefix",""),r(U,"_getPrefixedKey",(function(t,e){return(e=e||{}).noPrefix?t:U.prefix+t}));let F=U;t.AjaxUtil=g,t.ArrayUtil=A,t.AssertUtil=R,t.AudioPlayer=class{constructor(t){r(this,"audio"),this.audio=new Audio,this.audio.src=t}static speak(t,e={}){const n=new SpeechSynthesisUtterance;n.text=t,n.lang=e.lang||"zh-CN",n.volume=e.volume||1,n.rate=e.rate||1,n.pitch=e.pitch||1,window.speechSynthesis.speak(n)}play(){!this.muted&&this.audio.play()}pause(){this.audio.pause()}get muted(){return this.audio.muted}set muted(t){this.audio.muted=t}},t.BrowserUtil=b,t.CanvasDrawer=class{constructor(t){if(r(this,"context",null),"string"==typeof t&&!(t=document.querySelector("#"+t)))throw new Error("Element not found");if(!(t instanceof HTMLElement))throw new Error("Element is not an HTMLElement");{const e=t;if(!e.getContext)throw new Error("getContext is not available on this element");this.context=e.getContext("2d")}}drawLine({x:t,y:e},{x:n,y:r},s={}){if(!this.context)throw new Error("Canvas context is null or undefined");this.context.beginPath();const a=s.width||1,i=s.color||"#000";this.context.lineWidth=a,this.context.strokeStyle=i,this.context.moveTo(t,e),this.context.lineTo(n,r),this.context.stroke()}drawArc({x:t,y:e},n,r,s,a,i,o){if(!this.context)throw new Error("Canvas context is null or undefined");i?(this.context.fillStyle=o,this.context.beginPath(),this.context.arc(t,e,n,f.deg2Rad(r),f.deg2Rad(s),a),this.context.fill()):(this.context.strokeStyle=o,this.context.beginPath(),this.context.arc(t,e,n,f.deg2Rad(r),f.deg2Rad(s),a),this.context.stroke())}static createCanvas(t=1,e=1){const n=document.createElement("canvas");return t&&(n.width=t),e&&(n.height=e),n}},t.Color=v,t.Cookie=class{static set(t,e,n=30){if("string"!=typeof t||"string"!=typeof e||"number"!=typeof n)throw new Error("Invalid arguments");const r=new Date;r.setTime(r.getTime()+24*n*60*60*1e3),document.cookie=`${t}=${encodeURIComponent(e)};expires=${r.toUTCString()}`}static remove(t){var e=new Date;e.setTime(e.getTime()-1);var n=this.get(t);null!=n&&(document.cookie=t+"="+n+";expires="+e.toUTCString())}static get(t){var e=document.cookie.match(new RegExp("(^| )"+t+"=([^;]*)(;|$)"));return null!=e?e[2]:""}},t.CoordsUtil=_,t.DateUtil=O,t.DomUtil=S,t.ErrorType=a,t.EventDispatcher=P,t.EventType=s,t.FileUtil=T,t.GeoJsonUtil=M,t.GeoUtil=m,t.GraphicType=o,t.HashMap=L,t.ImageUtil=p,t.LayerType=i,t.LineSymbol=l,t.MathUtil=f,t.MeasureMode=c,t.MqttClient=N,t.ObjectState=h,t.ObjectUtil=d,t.OptimizeUtil=D,t.Storage=F,t.StringUtil=y,t.UrlUtil=I,t.Util=u,t.WebSocketClient=class extends P{constructor(t="ws://127.0.0.1:10088"){super(),r(this,"maxCheckTimes",10),r(this,"url"),r(this,"checkTimes",0),r(this,"connectStatus",!1),r(this,"client",null),this.maxCheckTimes=10,this.url=t,this.checkTimes=0,this.connect(),this.connCheckStatus(this.maxCheckTimes)}connect(){if(this.disconnect(),this.url)try{if(console.info("创建ws连接>>>"+this.url),this.client=new WebSocket(this.url),this.client){const t=this;this.client.onopen=function(e){t.dispatchEvent({type:s.WEB_SOCKET_CONNECT,message:e})},this.client.onmessage=function(e){t.connectStatus=!0,t.dispatchEvent({type:s.WEB_SOCKET_MESSAGE,message:e})},this.client.onclose=function(e){t.dispatchEvent({type:s.WEB_SOCKET_CLOSE,message:e})},this.checkTimes===this.maxCheckTimes&&(this.client.onerror=function(e){t.dispatchEvent({type:s.WEB_SOCKET_ERROR,message:e})})}}catch(t){console.error("创建ws连接失败"+this.url+":"+t)}}disconnect(){if(this.client)try{console.log("ws断开连接"+this.url),this.client.close(),this.client=null}catch(t){this.client=null}}connCheckStatus(t){this.checkTimes>t||setTimeout((()=>{this.checkTimes++,this.client&&0!==this.client.readyState&&1!==this.client.readyState&&this.connect(),this.connCheckStatus(t)}),2e3)}send(t){return this.client&&1===this.client.readyState?(this.client.send(t),!0):(console.error(this.url+"消息发送失败:"+t),!1)}heartbeat(){setTimeout((()=>{this.client&&1===this.client.readyState&&this.send("HeartBeat"),console.log("HeartBeat,"+this.url),setTimeout(this.heartbeat,3e4)}),1e3)}},Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})}));
|
package/dist/utils/CommUtil.d.ts
CHANGED
|
@@ -24,13 +24,21 @@ declare const _default: {
|
|
|
24
24
|
transformLat(x: number, y: number): number;
|
|
25
25
|
transformLon(x: number, y: number): number;
|
|
26
26
|
/**
|
|
27
|
-
*
|
|
27
|
+
* 生成一个介于两个坐标之间的随机坐标
|
|
28
28
|
*
|
|
29
|
-
* @param
|
|
30
|
-
* @param
|
|
31
|
-
* @returns
|
|
29
|
+
* @param start 起始坐标,包含x和y属性
|
|
30
|
+
* @param end 结束坐标,包含x和y属性
|
|
31
|
+
* @returns 返回一个包含x和y属性的随机坐标
|
|
32
32
|
*/
|
|
33
|
-
random({ x: minX, y: minY }: Coordinate, { x: maxX, y: maxY }: Coordinate):
|
|
34
|
-
|
|
33
|
+
random({ x: minX, y: minY }: Coordinate, { x: maxX, y: maxY }: Coordinate): Coordinate;
|
|
34
|
+
/**
|
|
35
|
+
* 对坐标数组进行解构并应用函数处理
|
|
36
|
+
*
|
|
37
|
+
* @param arr 待解构的数组
|
|
38
|
+
* @param fn 处理函数
|
|
39
|
+
* @param context 函数执行上下文,可选
|
|
40
|
+
* @returns 处理后的数组
|
|
41
|
+
*/
|
|
42
|
+
deCompose(arr: any[], fn: Function, context: any): any[];
|
|
35
43
|
};
|
|
36
44
|
export default _default;
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -3,7 +3,6 @@ export { default as AssertUtil } from './AssertUtil';
|
|
|
3
3
|
export { default as ArrayUtil } from './ArrayUtil';
|
|
4
4
|
export { default as BrowserUtil } from './BrowserUtil';
|
|
5
5
|
export { default as CoordsUtil } from './CoordsUtil';
|
|
6
|
-
export { default as ColorUtil } from './ColorUtil';
|
|
7
6
|
export { default as DateUtil } from './DateUtil';
|
|
8
7
|
export { default as DomUtil } from './DomUtil';
|
|
9
8
|
export { default as GeoJsonUtil } from './GeoJsonUtil';
|
package/package.json
CHANGED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
declare const _default: {
|
|
2
|
-
random(): string;
|
|
3
|
-
/**
|
|
4
|
-
* 将RGB颜色值转换为十六进制颜色值
|
|
5
|
-
*
|
|
6
|
-
* @param rgb RGB颜色值数组,包含三个0-255之间的整数
|
|
7
|
-
* @returns 转换后的十六进制颜色值,以#开头
|
|
8
|
-
*/
|
|
9
|
-
rgb2hex(rgb: number[]): string;
|
|
10
|
-
/**
|
|
11
|
-
* 将RGB颜色值转换为RGBA颜色值,并返回转换后的颜色值。
|
|
12
|
-
*
|
|
13
|
-
* @param rgbValue RGB颜色值,格式为"rgb(r, g, b)"。
|
|
14
|
-
* @returns 转换后的RGBA颜色值,格式为"rgba(r, g, b, 1)"。如果输入值不符合RGB格式,则返回原值。
|
|
15
|
-
*/
|
|
16
|
-
rgbToRgba(rgbValue: string): string;
|
|
17
|
-
/**
|
|
18
|
-
* 将十六进制颜色值转换为rgba格式的颜色值
|
|
19
|
-
*
|
|
20
|
-
* @param hexValue 十六进制颜色值,可带或不带#前缀,支持3位和6位表示
|
|
21
|
-
* @returns 返回rgba格式的颜色值,格式为rgba(r,g,b,1)
|
|
22
|
-
*/
|
|
23
|
-
hexToRgba(hexValue: string): string;
|
|
24
|
-
/**
|
|
25
|
-
* 将 HSL 颜色值转换为 RGBA 颜色值
|
|
26
|
-
*
|
|
27
|
-
* @param hslValue HSL 颜色值字符串,格式为 "hsl(h, s%, l%)" 或 "hsla(h, s%, l%, a)",其中 h 为色相,s 为饱和度,l 为亮度,a 为透明度(可选)。
|
|
28
|
-
* @returns 转换后的 RGBA 颜色值字符串,格式为 "rgba(r, g, b, a)",其中 r、g、b 为红绿蓝分量,a 为透明度。若输入为空或无效,则返回 null。
|
|
29
|
-
*/
|
|
30
|
-
hslToRgba(hslValue: string | null): string;
|
|
31
|
-
isHex(a: any): boolean;
|
|
32
|
-
isRgb(a: any): boolean;
|
|
33
|
-
isHsl(a: any): boolean;
|
|
34
|
-
isColor(a: any): any;
|
|
35
|
-
colorToRgb(val: string): any;
|
|
36
|
-
};
|
|
37
|
-
export default _default;
|