@wdslib/go-utils 0.3.2 → 0.3.4
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/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"axios";import t,{uniq as i}from"lodash";import o from"crypto-js";import r from"dexie";import a from"workerpool";import{setOptionColorByTheme as n}from"@anov/ui/lib/utils/option-theme.js";function s(e,t,i,o){return new(i||(i=Promise))((function(r,a){function n(e){try{l(o.next(e))}catch(e){a(e)}}function s(e){try{l(o.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(n,s)}l((o=o.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class l{constructor(){this.requests=[],console.log("RequestTracker")}static getInstance(){return l.instance||(l.instance=new l),l.instance}addRequest(e){if(this.isDuplicateRequest(e)){let t=this.findRequest(e);this.cancelRequest(t)}this.requests.push(e)}findRequest(e){let t;for(const i of this.requests)if(this.areRequestsEqual(i,e)){t=i;break}return t}removeRequest(e){const t=this.requests.indexOf(e);-1!==t&&this.requests.splice(t,1)}cancelRequest(e){e.cancelToken.cancel("Request canceled"),this.removeRequest(e)}isDuplicateRequest(e){return this.requests.some((t=>this.areRequestsEqual(t,e)))}areRequestsEqual(e,t){var i,o;return e.url===t.url&&JSON.stringify(null===(i=e.headers)||void 0===i?void 0:i.sponsor)===JSON.stringify(null===(o=t.headers)||void 0===o?void 0:o.sponsor)&&JSON.stringify(e.data)===JSON.stringify(t.data)&&JSON.stringify(e.params)===JSON.stringify(t.params)&&e.method===t.method}}const d=l.getInstance(),c=3e4,u=3e4,h=(t="",i)=>{let o,r=e.create({baseURL:t,timeout:c,headers:{"Content-Type":"application/x-www-form-urlencoded;charset=UTF-8"}});return r.interceptors.request.use((function(t){let{url:i,params:r,headers:a,data:n,method:s}=t;const l=e.CancelToken.source();return o={url:i,params:r,headers:a,data:n,method:s,cancelToken:l},t.cancelToken=l.token,d.addRequest(o),sessionStorage.getItem("anov-go-token")&&"null"!=sessionStorage.getItem("anov-go-token")&&(t.headers["X-ANOV-ACCESS-TOKEN"]=sessionStorage.getItem("anov-go-token")),sessionStorage.getItem("unify-access-token")&&"null"!=sessionStorage.getItem("unify-access-token")&&(t.headers["X-UNIFY-ACCESS-TOKEN"]=sessionStorage.getItem("unify-access-token")),sessionStorage.getItem("dgcc_authorization")&&"null"!=sessionStorage.getItem("dgcc_authorization")&&(t.headers.dgcc_authorization=sessionStorage.getItem("dgcc_authorization")),"post"===t.method?(t.headers["Content-Type"]="application/json;",t):"get"===t.method?t:"put"===t.method?(t.headers["Content-Type"]="application/json; charset=UTF-8",t):"delete"===t.method?t:void 0}),(function(e){return Promise.reject(e)})),r.interceptors.response.use((function(e){return 200===e.status||e.data.code,i&&i(e),d.removeRequest(o),e.data}),(function(e){return i&&(d.removeRequest(o),i(null==e?void 0:e.response)),Promise.reject(e.response)})),r},p=(e,t)=>{try{let i=t||window.location.href;if(-1!=i.indexOf("?")){let t={};return i.slice(i.indexOf("?")+1).split("&").forEach((e=>{let i=e.split("=");t[i[0]]=i[1]})),e?t[e]?t[e]:null:t}return console.log("没有参数"),null}catch(e){console.error(e)}};function m(e,t=!1){try{return t?f(e)?e:JSON.stringify(e):f(e)?JSON.parse(e):e}catch(t){return console.log("转化JSON 发生错我!",e),e}}const f=e=>{if("string"==typeof e)try{const t=JSON.parse(e);return"object"==typeof t&&null!==t}catch(e){return!1}return!1},g=(e,t)=>{try{const i=JSON.stringify(t);sessionStorage.setItem(e,i)}catch(t){console.error(`Error setting session data for key ${e}:`,t)}},v=e=>{const t=sessionStorage.getItem(e);if(t)try{return JSON.parse(t)}catch(t){console.error(`Error parsing session data for key ${e}:`,t)}return null},y=e=>{for(const t of e)t.code&&(t.code=t.code.replace(/>/g,">").replace(/</g,"<"))},b=(e,t)=>{e instanceof Map?e.forEach((e=>{t([e])})):Array.isArray(e)&&e.forEach((e=>{t(e.children)}))},w=(e,t)=>{const i=e=>{var o,r,a;if(e)for(const n of e){const e=null===(a=null===(r=null===(o=null==n?void 0:n.tmpData)||void 0===o?void 0:o.source)||void 0===r?void 0:r.converse)||void 0===a?void 0:a.data;(null==e?void 0:e.length)&&y(e),t(n),n.children?i(n.children):n.dynamicChildren?b(n.dynamicChildren,i):n.stateChildren&&i(n.stateChildren)}};i(e)},D=(e,t,i,o)=>{const r=e.match(/({{[\w]*}})|((@)[\w]*)/gm);if(r){const e=r.map((e=>e.replace(/{{|}}|@/gm,"")));for(const r of e)if(r&&t&&!(t.findIndex((e=>e.mapField===r))<0))return i&&o&&k(o,r,i.cid),!0}return!1},k=(e,t,i)=>{if(!e)throw new Error("Share variable tree is not defined");if("string"!=typeof t)throw new Error("Variable name should be a string");if(!i)throw new Error("ID is required");Array.isArray(e[t])||(e[t]=[]),e[t].includes(i)||e[t].push(i)},N=(e,t,i)=>{var o;let r=!1;const a=null==t?void 0:t.converse;if(a&&a.use&&a.data.length)for(const t of a.data)if((null==t?void 0:t.dependVars)&&t.dependVars.includes(e))return!0;const n=null==t?void 0:t[null==t?void 0:t.type];return((null==n?void 0:n.inputSql)||(null==n?void 0:n.url)||(null==n?void 0:n.headers)||(null==n?void 0:n.params))&&(r=D(n.inputSql||n.url||(null===(o=n.headers)||void 0===o?void 0:o.value)||n.params,i)),r},x=(e,i,o=!1)=>{let r=null;const a=e=>{for(const n of e){if(n.cid===i){r=n,o&&t.remove(e,(e=>e.cid===i));break}if(n.children&&a(n.children),n.dynamicChildren&&Array.isArray(n.dynamicChildren))for(const[,e]of Array.from(n.dynamicChildren))a(e);n.stateChildren&&a(n.stateChildren)}};return a(e),r},S=(e,i,o)=>{let r=!1;const a=e=>{for(let n=0;n<e.length;n++){if(e[n].cid==i){r=e[n],o&&t.remove(e,(e=>e.cid==i));break}if(e[n].children)a(e[n].children);else if(e[n].dynamicChildren){if(e[n].dynamicChildren instanceof Map){let t=Array.from(e[n].dynamicChildren);for(let e=0;e<t.length;e++)if(t[e]instanceof Array){let i=t[e][1];a(i)}}else if(e[n].dynamicChildren instanceof Array){let t=e[n].dynamicChildren;for(let e=0;e<t.length;e++)if(t[e]instanceof Array){let i=t[e][1];a(i)}}}else e[n].stateChildren&&a(e[n].stateChildren)}};return a(e),r||!1};function C(e,t,i){const o={};i&&i.forEach((e=>{(null==e?void 0:e.name)&&(o[e.name]=e.value||e.originvalue)}));try{return new Function("data","vars",e)(t,o)}catch(e){return console.error(e),t}}function A(e,i,o){let r=t.cloneDeep(i);const a={};o&&o.forEach((e=>{(null==e?void 0:e.name)&&(a[e.name]=e.value||e.originvalue)}));try{return new Function("data","vars",e)(r,a)}catch(e){return console.error(e),r}}const O=e=>{let t=window.goFetchList;return t||(window.goFetchList={},t=window.goFetchList),t[e]?!t[e]&&void 0:(t[e]={id:e,time:(new Date).getTime()},!0)},I=e=>{let t=window.goFetchList;t&&t[e]&&delete t[e]},T="anov@2019:helloX",V="anov@2020:helloX";function F(e){let t=o.enc.Utf8.parse(T),i=o.enc.Utf8.parse(V);return o.AES.encrypt(e,t,{iv:i,mode:o.mode.CBC,padding:o.pad.Pkcs7}).toString()}function E(e,t){if(0===e.length)throw new Error("Array is empty.");if(!t)return e[Math.floor(Math.random()*e.length)];if(t.length!==e.length)throw new Error("Length of probabilities array must match length of array.");const i=t.reduce(((e,t)=>e+t),0),o=Math.random()*i;let r=0;for(let i=0;i<e.length;i++)if(r+=t[i],o<r)return e[i];return e[0]}const P=new Blob(["\nfunction proxyObj(originObj) {\n const exposeObj = new Proxy(originObj, {\n has: (target, key) => {\n if (['fetch', 'XMLHttpRequest', 'postMessage'].indexOf(key) >= 0) {\n throw new Error('Illegal operation for key'+key)\n } else {\n return target[key]\n }\n },\n })\n return exposeObj\n}\nfunction compileCode(src) {\n src = 'with (exposeObj) {'+src+'}'\n //console.log(src)\n return new Function('exposeObj', src)\n}\nfunction run(code) {\n let proxy = proxyObj({})\n let result = compileCode(code)(proxy)\n return result\n}\n\nonmessage = (e) => {\n try {\n let result = run(e.data.code)\n postMessage({\n code: 1,\n result,\n })\n } catch (err) {\n postMessage({\n code: -1,\n err,\n })\n }\n}\n"]),j=URL.createObjectURL(P);function R(e,t){return s(this,arguments,void 0,(function*(e,t,i={},o="worker"){try{if("window"==o){let[o,r]=[["data"],[t]];"object"==typeof i&&Object.keys(i).forEach((e=>{o.push(e),r.push(i[e])}));const a=new Function(...o,e);return{success:!0,data:a(...r)}}{let[o,r,a]=[t,i,""];"object"==typeof o&&(o=JSON.stringify(t)),"object"==typeof i&&(r=JSON.stringify(i)),Object.keys(i).forEach((e=>a+=`${e},`));let n=`let data=eval(${o}); \n let app=${JSON.stringify({})};`;n+=a?`let {${a}} = eval(${r}); `:"",n+=`${e}`;let l=yield function(e){return s(this,arguments,void 0,(function*(e,t=5e3){let i=new Worker(j);return new Promise(((o,r)=>{const a=()=>{clearTimeout(s),i.removeEventListener("message",n),i.terminate(),i=null},n=e=>{let{code:t,result:i,err:n}=e.data;a(),1===t?o(i):r(n)};i.postMessage({code:e}),i.addEventListener("message",n);let s=setTimeout((()=>{a(),r("timeout")}),t)}))}))}(n);return{success:!0,data:l}}}catch(e){return{success:!1,error:e,data:t}}}))}var $,q,M,U;!function(e){e.StaticFile="staticFile",e.DataSource="datasource"}($||($={})),function(e){e.json="application/json;charset=UTF-8",e.form="application/x-www-form-urlencoded; charset=UTF-8"}(q||(q={})),function(e){e.get="GET",e.post="POST",e.put="PUT",e.patch="PATCH",e.delete="DELETE"}(M||(M={}));class L{constructor(e){this.db=null,this.dbName=e.databaseName,this.tableName=e.tableName,this.keyPath=e.keyPath}static getInstance(e){return L.instance||(L.instance=new L(e)),L.instance}init(){return s(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{const i=indexedDB.open(this.dbName,1);i.onerror=e=>{t(e.target.error)},i.onupgradeneeded=e=>{this.db=e.target.result,this.db.objectStoreNames.contains(this.tableName)||this.db.createObjectStore(this.tableName,{keyPath:this.keyPath})},i.onsuccess=t=>{this.db=t.target.result,e()}}))}))}addRecord(e){return s(this,void 0,void 0,(function*(){if(!this.db)throw new Error("数据库未初始化。");return new Promise(((t,i)=>{const o=this.db.transaction([this.tableName],"readwrite").objectStore(this.tableName).add(e);o.onsuccess=()=>{t()},o.onerror=e=>{i(e.target.error)}}))}))}deleteRecord(e){return s(this,void 0,void 0,(function*(){if(!this.db)throw new Error("数据库未初始化。");return new Promise(((t,i)=>{const o=this.db.transaction([this.tableName],"readwrite").objectStore(this.tableName).delete(e);o.onsuccess=()=>{t()},o.onerror=e=>{i(e.target.error)}}))}))}updateRecord(e){return s(this,void 0,void 0,(function*(){if(!this.db)throw new Error("数据库未初始化。");return new Promise(((t,i)=>{const o=this.db.transaction([this.tableName],"readwrite").objectStore(this.tableName).put(e);o.onsuccess=()=>{t()},o.onerror=e=>{i(e.target.error)}}))}))}getRecord(e){return s(this,void 0,void 0,(function*(){if(!this.db)throw new Error("数据库未初始化。");return new Promise(((t,i)=>{const o=this.db.transaction([this.tableName],"readonly").objectStore(this.tableName).get(e);o.onsuccess=()=>{t(o.result)},o.onerror=e=>{i(e.target.error)}}))}))}getAllRecords(){return s(this,void 0,void 0,(function*(){if(!this.db)throw new Error("数据库未初始化。");return new Promise(((e,t)=>{const i=this.db.transaction([this.tableName],"readonly").objectStore(this.tableName).getAll();i.onsuccess=()=>{e(i.result)},i.onerror=e=>{t(e.target.error)}}))}))}}L.instance=null,function(e){e[e.FATAL=0]="FATAL",e[e.ERROR=1]="ERROR",e[e.WARN=2]="WARN",e[e.INFO=3]="INFO",e[e.DEBUG=4]="DEBUG",e[e.TRACE=5]="TRACE"}(U||(U={}));const H={databaseName:"GODB",tableName:"go-log",keyPath:"time"};class B{constructor(){this.logLevel=U.INFO,this.indexedDBInstance=L.getInstance(H);try{this.indexedDBInstance.init(),console.log("IndexedDB 初始化成功。")}catch(e){console.error("初始化 IndexedDB 时出错:",e)}}static getInstance(){return B.instance||(B.instance=new B),B.instance}setLogLevel(e){this.logLevel=e}getColor(e){switch(e){case U.FATAL:return"[31;1m";case U.ERROR:return"[31m";case U.WARN:return"[33m";case U.INFO:return"[32m";case U.DEBUG:return"[36m";case U.TRACE:return"[34m";default:return"[0m"}}log(e,t){if(t<=this.logLevel){const i=(new Date).toISOString(),o=`[${i}] [${U[t]}]`,r=this.getColor(t);if(null===window||void 0===window?void 0:window.goDev)console.log(`${r}${o} ${e}[0m`);else{let t=v("anov-go-userInfo"),a=v("anov-go-proid"),n=` [操作人:${null==t?void 0:t.userName} 项目ID:${a}] `;const s={time:i,value:`${e}`};try{this.indexedDBInstance.addRecord(s)}catch(e){console.error("添加记录时出错:",e)}console.log(`${r}${o} ${n} ${e}[0m`)}}}fatal(e){this.log(e,U.FATAL)}error(e){this.log(e,U.ERROR)}warn(e){this.log(e,U.WARN)}info(e){this.log(e,U.INFO)}debug(e){this.log(e,U.DEBUG)}trace(e){this.log(e,U.TRACE)}}const z=B.getInstance(),J=(e,t)=>"string"!=typeof e?Promise.reject(new Error("URL should be a string")):h(e,t),G=h();let _=h();function W(e){return s(this,arguments,void 0,(function*(e,i="get",o={},r={},a){try{const n={method:M[i],url:e,headers:r,timeout:u};["post","put"].includes(i.toLowerCase())?n.data=t.cloneDeep(o):n.params=t.cloneDeep(o),a&&(n.headers.sponsor=a);return/.json$/.test(e)?function(e){return s(this,void 0,void 0,(function*(){try{return(yield G({method:"get",url:e})).data}catch(e){throw console.error("JSON 数据请求:",e),e}}))}(e):function(e){return s(this,void 0,void 0,(function*(){try{return{code:2e4,data:(yield G(e)).data}}catch(e){throw console.error("请求数据发生错误-Error:",e),e}}))}(n)}catch(e){throw console.error("获取数据:Error:",e),e}}))}function X(e,t,i,o,r){return s(this,void 0,void 0,(function*(){try{const a=window.anUrl||"",n=a+(window.agentPath||"/ds/v1/api-proxy/v1/query"),s=m(i,!0);return yield G({url:n,method:"post",headers:{"Content-Type":"application/json;charset=UTF-8",sponsor:r||""},data:{body:"post"===e?s:void 0,headers:f(o)?m(o,!0):o,method:e,url:t}})}catch(e){throw console.error("代理请求数据:Error1:",e),e}}))}function K(e,t,i,o,r,a){return s(this,void 0,void 0,(function*(){return r?X(t,e,i,o,a):W(e,t,i,o,a)}))}function Q(e,t="",i){var o,r,a,n;const s=`${null!==(r=null===(o=null===window||void 0===window?void 0:window.BaseUrl)||void 0===o?void 0:o.replace("/management",""))&&void 0!==r?r:""}/ds/data-engine/v1/${e}/zb-query?${`token=${(null===(a=de("YZH_EXCHANGE_TOKEN"))||void 0===a?void 0:a.YZH_EXCHANGE_TOKEN)||(null===(n=null===window||void 0===window?void 0:window.yzhAuth)||void 0===n?void 0:n.getToken())}&passid=${null===window||void 0===window?void 0:window.gdPassid}`}${(null===window||void 0===window?void 0:window.BASE_RELEASE)?"&preview=1":""}`;let l={};try{l=t?JSON.parse(t):{}}catch(e){l=t||{}}return G({method:"POST",url:s,data:{headers:i,param:l},timeout:c})}function Y(e="",t){const i=`${null===window||void 0===window?void 0:window.BaseUrl}/ds/v1/data-views/query`;let o={};try{o=e?JSON.parse(e):{}}catch(t){o=e||{}}return G({method:"POST",url:i,data:{headers:t,param:o},timeout:c})}const Z=(e,t)=>s(void 0,void 0,void 0,(function*(){const i=window.BaseUrl,{dateType:o="",endPeriod:r="",metricsName:a=e,startPeriod:n=""}=t;return _({method:"GET",url:`${i}ds/v1/metrics/v1/data-alarm?dateType=${o}&endPeriod=${r}&metricsName=${a}&startPeriod=${n}`,timeout:c})})),ee=(e,t,i)=>s(void 0,void 0,void 0,(function*(){var o;const r=(null===(o=window.BaseUrl)||void 0===o?void 0:o.replace("/management",""))||"";t.newEncryption=!0;const a={staticFile:{method:"get",params:t,url:`${r}/ds/v1/file/v1/${e}/query`},datasource:{method:"post",url:`${r}/ds/v1/database/v1/${e}/query`,data:Object.assign({},t)}}[i];if(!a)throw new Error("Invalid data type provided");return G(Object.assign({timeout:c},a))})),te=e=>new Promise(((t,i)=>{let o;o=e.originData&&Object.keys(e.originData).length?e.originData:e.data,void 0!==o?t({data:o}):i("Failed to retrieve cdata")})),ie=(e,t,i)=>{try{switch(t){case"api":{let t=he(e,i);return{requestType:t.requestType,url:t.url,params:t.params,headers:t.headers,agency:t.agency}}case"static":return{data:e};case"datasource":{const t=ue(e.inputSql,i);return{dsName:e.dsName,dsType:"1",sql:F(t),filter:e.sqlFilter}}case"staticFile":return{dsName:e.dsName,dsType:e.dsType,sql:""};case"indicator":return{zbId:e.zbId,params:ue(e.params,i),headers:ue(e.headers,i)};case"dataSet":return{params:ue(e.params,i),headers:ue(e.headers,i)};case"indicatorCQ":return{zbName:e.zbName,params:ue(e.params,i)};case"packData":return{};default:throw new Error("Invalid type")}}catch(t){console.log("准备请求数据发生错误",t,e)}},oe=(e,t,i)=>s(void 0,void 0,void 0,(function*(){try{switch(t){case"api":return yield K(e.url,e.requestType,e.params,e.headers,e.agency,i);case"static":return yield te(e.data);case"datasource":return yield ee(e.dsName,{dsType:e.dsType,sql:e.sql,filter:e.filter},"datasource");case"staticFile":return yield ee(e.dsName,{dsType:e.dsType,sql:e.sql},"staticFile");case"indicator":return yield Q(e.zbId,e.params,e.headers);case"dataSet":return yield Y(e.params,e.headers);case"indicatorCQ":return yield Z(e.zbName,e.params);case"packData":return{};default:throw new Error("Invalid type")}}catch(e){return console.warn(e,"执行请求并获取数据发生错误"),yield new Promise(((e,t)=>{e({error:!0})}))}})),re=(e,t,i,...o)=>s(void 0,[e,t,i,...o],void 0,(function*(e,t,i,o=[],r=!1){const a=t||e.tmpData.source.dataType,n=e.tmpData.source["indicatorCQ"==a?"indicator":a];if("globalData"===a){const e=o.find((e=>e.key===n.id||e.key===n.key)),t=v(n.id);if(t&&!r)return t.data;if(e){let t=yield ae(e,i),o={key:n.id,data:t};return g(n.id,o),t}return}const s=ie(n,a,i),l=yield oe(s,a,e.cid?e.cid:"");return(null==l?void 0:l.data)?l.data:l})),ae=(e,t)=>s(void 0,void 0,void 0,(function*(){let i=Object.assign({},{tmpData:{source:e.value}});const o=i.tmpData.source.type,r=i.tmpData.source[o],a=ie(r,o,t),n=yield oe(a,o);return yield ne(n.data,i,!0,t)})),ne=(e,i,...o)=>s(void 0,[e,i,...o],void 0,(function*(e,i,o=!0,r){try{const{converse:a,mapFields:n}=i.tmpData.source;return a&&a.use&&o?yield new Promise(((i,o)=>{const n=function(e,i,o,r,a){return s(this,void 0,void 0,(function*(){let o,a=e,{use:n,data:s}=t.cloneDeep(i);if(n)for(let e=0;e<s.length;e++)if(s[e].use){let i=s[e].dependVars,n={};r&&n&&i&&i.length&&i.map((e=>{let i=t.cloneDeep(r).filter((t=>{let i=t.mapField==e;return i&&(n[e]=t.value),i}));i&&0!=i.length||(n[e]="")})),o=yield R(s[e].code,a,n,s[e].mode?s[e].mode:"worker"),a=o.data}return a}))}(e,a,0,r);i(n)})):yield new Promise(((t,i)=>{t(e)}))}catch(t){return console.error("执行过滤器发生错误:"+t),yield new Promise(((t,i)=>{t(e)}))}})),se=(e,t,i)=>{const{source:o}=e.tmpData,r=o.type;i?("static"===r&&o[r]&&(o[r].originData=i),"indicatorCQ"===r?o.indicator.data=t:o[r].data=t):"indicatorCQ"===r?o.indicator.data=t:o[r].data=t,e.source=t},le=(e,t,...i)=>s(void 0,[e,t,...i],void 0,(function*(e,t,i=[],o,r,a){try{let n=e.tmpData.source.type,s=yield re(e,n,i,o,a||!1);if(null==s||!s)return r&&r({error:!0}),Promise.resolve({error:!0});let l=yield ne(s,e,t,i);return se(e,l),r&&r(l),(null==e?void 0:e.cid)&&I(e.cid),Promise.resolve(l)}catch(e){return r&&r(e),z.error("Error in updateComData"),console.error("Error in updateComData:",e),Promise.reject(e)}})),de=e=>{const t={};if(e&&e.includes("?")){const i=e.split("?")[1].split("&");for(let e of i){const[i,o]=e.split("=").map(decodeURIComponent);t[i]=o}}return t},ce=e=>{try{return(null==e?void 0:e.value)&&"string"==typeof e.value?JSON.parse(e.value):"string"==typeof e?JSON.parse(e):e}catch(t){return e}},ue=(e,t)=>{if(!t)return ce(e);if("string"==typeof e){if(""===e.trim())return"";try{if("string"!=typeof JSON.parse(e))return ue(JSON.parse(e),t);{let i=e.replace(/@(\w+)|{{(\w+)}}/g,((e,i,o)=>{const r=i||o,a=t.find((e=>e.mapField===r));return a?a.value||a.originalValue||"":e}));return ce(i)}}catch(i){let o=e.replace(/@(\w+)|{{(\w+)}}/g,((e,i,o)=>{const r=i||o,a=t.find((e=>e.mapField===r));return a?a.value:e}));return ce(o)}}else{if(Array.isArray(e))return e.map((e=>ue(e,t)));if("object"==typeof e&&null!==e){const i={};for(let o in e)i[o]=ue(e[o],t);return ce(i)}}return ce(e)},he=(e,t)=>{const i=e.agency,o=e,{url:r=null,headers:a,params:n,requestType:s}=o,l=r?ue(r,t):void 0,d=a&&a.use?ue(a.value,t):{};return{url:l,requestType:s,params:n?ue(n,t):{},headers:d,agency:i}},pe=(e,t,i,o,r)=>s(void 0,void 0,void 0,(function*(){if(e&&e.length)for(const a of e){N(t,a.value,i)&&(yield le({tmpData:{source:{type:"globalData",globalData:{id:a.key}}}},!0,i,e,(e=>{console.log("数据更新成功-变量改变全局数据跟新")}),!0),w(o,(t=>{var o,n,s;if("globalData"===(null===(n=null===(o=null==t?void 0:t.tmpData)||void 0===o?void 0:o.source)||void 0===n?void 0:n.type)){(null===(s=null==t?void 0:t.tmpData)||void 0===s?void 0:s.source.globalData).id===a.key&&le(t,!0,i,e,(e=>{r(t,e)}),!1)}})))}})),me=(e,t,i,o,r)=>s(void 0,void 0,void 0,(function*(){e&&(yield le({tmpData:{source:{type:"globalData",globalData:{id:e.key}}}},!0,t,i,(e=>{console.log("数据更新成功-数据源编辑")}),!0),w(o,(o=>{var a,n,s;if("globalData"===(null===(n=null===(a=null==o?void 0:o.tmpData)||void 0===a?void 0:a.source)||void 0===n?void 0:n.type)){(null===(s=null==o?void 0:o.tmpData)||void 0===s?void 0:s.source.globalData).id===e.key&&le(o,!0,t,i,(e=>{r(o,e)}),!1)}})))}));class fe{constructor(e,t){this.isUpdating=!1,this.des=e.des,this.field=e.field,this.id=e.id,this.key=e.key,this.mapping=e.mapping,this.mapField=e.mapField,this.type=e.type,this.originalValue=e.originalValue,this.model=(null==e?void 0:e.model)?null==e?void 0:e.model:1,this.converter=e.converter,this.converterCode=e.converterCode,this.fork=e.fork,this.delayUpdate=!!(null==e?void 0:e.delayUpdate),t&&(this.globalVariables=t),e.fork&&(this.model=5,this.forkValue=e.forkValue,this.originalValue=this.getForkedValue())}get value(){if(this.fork&&(this.originalValue=this.getForkedValue()),this.converter&&this.converterCode){let e=[];return A(this.converterCode,this.originalValue,e)}return this.originalValue}togglePropertyState(e){let t=Object.prototype.hasOwnProperty.call(this,e);this[e]=!t||!e}getForkedValue(){if(this.forkValue&&Array.isArray(this.forkValue))return this.forkValue.map((e=>{const t=this.globalVariables.get(e);return t?t.value:null}));if(this.forkValue){const e=this.globalVariables.get(this.forkValue);return e?e.value:null}return null}updateValue(e,t){var o;const r=Object.assign({},this,e);this.des=r.des,this.field=r.field,this.mapping=r.mapping,this.type=r.type,this.originalValue=r.originalValue,this.converter=r.converter,this.converterCode=r.converterCode,this.fork=r.fork,this.delayUpdate=null==r?void 0:r.delayUpdate,this.model=null==r?void 0:r.model,e.id&&(this.id?"string"==typeof this.id?e.id instanceof Array?this.id=i([this.id,...e.id]):this.id=[this.id,e.id]:this.id instanceof Array&&(e.id instanceof Array?this.id=i([...this.id,...e.id]):this.id=i([...this.id,e.id])):this.id=e.id),e.fork&&(this.model=5,this.forkValue=null!==(o=e.forkValue)&&void 0!==o?o:this.forkValue,this.originalValue=this.getForkedValue()),t&&t(this)}updateWidthOriginalValue(e,t){var i;this.originalValue=e,this.fork&&(this.forkValue=null!==(i=this.forkValue)&&void 0!==i?i:this.forkValue,this.originalValue=this.getForkedValue()),t&&t(this)}renew(e){e&&e(this)}static create(e,t){return new fe(e,t)}}class ge{constructor(){this.variables=new Map,this.globalObservers=[],this.url=window.location.search,this.list=[]}clearVars(){this.list=[],this.variables.clear()}togglePropertyState(e,t,i){try{let o=this.getVariable(e);if(!o)throw new Error("没有找到相应的变量!");o.togglePropertyState(t),this.addToObjectArray(this.list,o),i&&i()}catch(e){console.error(e)}}static getInstance(){return ge.instance||(ge.instance=new ge),ge.instance}getFullUrl(){this.url=window.location.search}getAllUrlParams(){const e=new URLSearchParams(window.location.search),t={};for(const[i,o]of e.entries())t[i]=o;return t}delVariable(e,t){this.variables.delete(e),this.list=this.list.filter((t=>t.mapField!=e)),t&&t()}addUrlParamsToGlobalVars(){this.getFullUrl();let e=this.getAllUrlParams(),t=Object.keys(e),i=[];for(const o of t)i.push({mapField:o,originalValue:e[o],model:4});if(i.length)for(const e of i)this.addVariable(e)}addVariables(e){Array.isArray(e)?e.map(((e,t)=>{this.addVariable(e)})):this.addVariable(e),this.addUrlParamsToGlobalVars()}addVariable(e,t){if(!e||!(null==e?void 0:e.mapField))return console.error(e+"参数不合法!"),!1;if(this.isVariableNameExist(e.mapField)){let i=this.getVariable(e.mapField);return this.sameValue(i,e)?i:(this.editVariable(e,t),!1)}const i=fe.create(e,this.variables);return this.variables.set(i.mapField,i),this.addToObjectArray(this.list,i),t&&t(i),this.notifyGlobalObservers(i),i}toJSON(e){try{return!!e&&JSON.stringify(e)}catch(e){return!1}}sameValue(e,t){if(e.mapfield!==t.mapfield)return!1;for(const i in t)if(!(["mapfield","field","key","value","name","globalVariables"].includes(i)||i in e&&e[i]==t[i]))return!1;return!0}creatVarJson(e){const{des:t,field:i,id:o,key:r,mapping:a,mapField:n,type:s,value:l,originalValue:d,model:c,converter:u,converterCode:h,fork:p,forkValue:m,update:f,delayUpdate:g}=e,v={};return void 0!==t&&(v.des=t),void 0!==i&&(v.field=i),void 0!==o&&(v.id=o),void 0!==r&&(v.key=r),void 0!==a&&(v.mapping=a),void 0!==n&&(v.mapField=n),void 0!==s&&(v.type=s),void 0!==l&&(v.value=l),void 0!==d&&(v.originalValue=d),void 0!==c&&(v.model=c),void 0!==u&&(v.converter=u),void 0!==h&&(v.converterCode=h),void 0!==p&&(v.fork=p),void 0!==m&&(v.forkValue=m),void 0!==f&&(v.update=f),void 0!==g&&(v.delayUpdate=g),v}addToObjectArray(e,t){let i=!1;for(let o=0;o<e.length;o++)if(e[o].mapField==t.mapField){e[o]=this.creatVarJson(t),i=!0;break}i||e.push(t)}editVariable(e,t){const i=this.getVariable(e.mapField);if(i&&this.isVariableNameExist(e.mapField)){if(this.sameValue(i,e))return}const o=e=>{if(!e.isUpdating){e.isUpdating=!0,this.notifyGlobalObservers(e);this.isMapFieldInForkValues(e.mapField).forEach((e=>{let t=this.getVariable(e.mapField);t&&t.renew((e=>{this.addToObjectArray(this.list,e),this.notifyGlobalObservers(e)}))})),this.addToObjectArray(this.list,e),t&&t(e),e.isUpdating=!1}};i?i.updateValue(e,o):this.addVariable(e,o)}getForkList(e){let t=this.isMapFieldInForkValues(e);return t||[]}editVariableForValue(e,t,i){const o=this.getVariable(e),r=e=>{if(!e.isUpdating){e.isUpdating=!0,this.notifyGlobalObservers(e);this.isMapFieldInForkValues(e.mapField).forEach((e=>{let t=this.getVariable(e.mapField);t&&t.renew((e=>{this.addToObjectArray(this.list,e),this.notifyGlobalObservers(e)}))})),this.addToObjectArray(this.list,e),i&&i(e),e.isUpdating=!1}};o&&o.updateWidthOriginalValue(t,r)}isMapFieldInForkValues(e){return this.getAllVariables().filter((e=>e.fork&&e.forkValue)).filter((t=>t.forkValue==e||Array.from(t.forkValue).includes(e)))}isVariableNameExist(e){return this.variables.has(e)}checkExist(e,t){if("string"==typeof e&&this.isVariableNameExist(e)){let i=this.getVariable(e);return t==i.id&&!i.id.includes(t)&&[{key:e}]}if(Array.isArray(e)){const i=e.filter((e=>{let i=this.getVariable(e);return this.isVariableNameExist(e)&&t!=i.id&&!(i.id&&i.id.includes(t))})).map((e=>({key:e})));return!!i.length&&i}return!1}getVariable(e){return this.variables.get(e)}getVariableForId(e){var i;let o=[];for(const[,t]of this.variables)(t.id===e||(null===(i=t.id)||void 0===i?void 0:i.includes(e)))&&o.push(t);return t.uniq(o)}getAllVariables(e=!1){return this.addUrlParamsToGlobalVars(),e?(this.list=Array.from(this.variables.values()),this.list):[...this.list]}restoreVariables(e){e.forEach((e=>{this.addVariable(e)}))}registerGlobalObserver(e){this.globalObservers.push(e)}notifyGlobalObservers(e){this.globalObservers.forEach((t=>{t.update(e)}))}}ge.instance=null;const ve=ge.getInstance(),ye=(e,t)=>Array.isArray(t)?t.some((t=>e&&(void 0!==e[t]||e.hasOwnProperty(t)))):"string"==typeof t&&(e&&(void 0!==e[t]||e.hasOwnProperty(t))),be=(e,t,i,o)=>{const r=((e,t,i,o)=>{var r;let a;if(ye(e,null==t?void 0:t.field)||ye(e,null==t?void 0:t.forkValue))a=e[null==t?void 0:t.field]||"";else if(ye(e.data,null==t?void 0:t.field)||ye(e.data,null==t?void 0:t.forkValue))a=e.data[null==t?void 0:t.field]||"";else{const e=x(i,o),n=(null===(r=null==e?void 0:e.tmpData)||void 0===r?void 0:r.actions)||[];for(const e of n){const i=e.vars.find((e=>(null==e?void 0:e.mapField)===(null==t?void 0:t.mapField)));if(i){a=i.value;break}}}return a})(e,t,i,o);return void 0!==r?r:t.value},we=(e,t,i,o,r,a,n,s,l)=>{var d;switch(e.type){case"link":let c=ue(e.link,a);window.open(c,e.target);break;case"page":if(null===(d=null==e?void 0:e.params)||void 0===d?void 0:d.length)for(let t=0;t<e.params.length;t++){const i=e.params[t],o=a.find((e=>e.mapField==i.mapField));o&&(i.value=o.value)}l&&l(e);break;case"dynamic":((e,t,i,o,r)=>{const a=e.dynamic||[];for(const n of a){if(e.id!==t.cid)continue;const a=x(i,n.pid);a&&(a.activeDynamic=n.name,a.isShow=n.visible||!o||e.index===t.index-1,r({cid:a.cid,flag:n.visible}))}})(e,t,i,o,r);break;case"toggle":((e,t,i,o,r)=>{const a=e.children||[];for(const i of a){const a=i.visible&&(!o||e.index===t.index-1);r({cid:i.cid,flag:a})}})(e,t,0,o,r);break;case"update":((e,t,i,o,r)=>{const a=e.children||[];for(const e of a){const a=x(t,e.cid);a&&le(a,!0,i,o,(e=>{r({cid:a.cid,data:e})}))}})(e,i,a,n,s)}},De=(e,i,o,r,a,n,s,l,d,c)=>{const{cid:u,actions:h,index:p}=a,{eventName:m,mode:f}=h,g=2===f;((e,i,o,r,a,n)=>{let s=ve.getVariableForId(i.cid);if(null==s?void 0:s.length)for(const l of s)if(l.type==e){let e=be(i,l,o,r);ve.editVariableForValue(l.mapField,e,(()=>{let e=a[l.mapField]||[],i=ve.getForkList(l.mapField);if(i)for(const o of i){let i=a[o.mapField];e=t.concat(e,i)}n&&n(l,t.uniq(e))}))}})(m,a,r,u,o,((e,t)=>{if(pe(d,e.mapFile,ve.getAllVariables(),r,((e,t)=>{s({cid:e.cid,data:t})})),null==t?void 0:t.length)for(const i of t){e.eventSourceId=i;const t=x(r,i);!(null==e?void 0:e.delayUpdate)&&t&&le(t,!0,ve.getAllVariables(),d,(e=>{s({cid:t.cid,data:e})}))}}));const v=((e,t,i,o,r)=>e.filter((e=>e.id===t&&e.eventType===i&&(!r||parseInt(e.index||"0")+1===parseInt(o||"0")))))(e,u,m,p,g);for(const e of v)we(e,a,r,g,n,ve.getAllVariables(),d,s,l)},ke=(e,t={})=>{let i={},o={type:"static",converse:{use:!1,data:[]},static:{data:e},api:{requestType:"get",url:"",headers:{use:!1,value:""},params:"",agency:!1,cookie:!0,autoUpdate:{open:!1,time:10},data:""}};return Object.assign(i,o,t),i},Ne=(e,i)=>{let{option:o,actions:r,data:a,optionDes:n,actionsDes:s,source:l,theme:d}=((e,i)=>{let{option:o,actions:r,data:a,optionDes:n,actionsDes:s,source:l,theme:d}=t.cloneDeep(i[e]);return{option:o,actions:r,data:a,optionDes:n,actionsDes:s,source:l,theme:d}})(e,i);return{iconClass:null,isAssembly:null,source:a,cid:(Math.random().toString().substr(3,10)+Date.now()).toString(),isLock:!1,isShow:!0,tmpData:{option:o,source:ke(a,l),actions:r},baseData:Se(),dynamic:null,filePath:"",origin:"anov-ui",name:"",componentType:"",viewComName:e,optionComName:"AnOptionPanel",dataComName:"AnSourcePanel",eventComName:"AnActionsPanel",assemblyDeveloper:"",devEmail:"",version:"",devDept:""}},xe=(e,i,o)=>{let r=Ne(e,i);return o?t.merge(r,o):r},Se=e=>{let t={left:0,top:0,width:100,height:100,angle:0,penetrate:0,opacity:100,perspective:100,rotateX:0,rotateY:0,rotateZ:0,transformOriginX:"center",transformOriginY:"center",transformSwitch:!1};return e?Object.assign(t,e):t};class Ce{constructor(e,t,i){this.theme=null,this.plant=null,this.list=[],this.titleHeqadeHeight=70,this.clearance=3,this.checkComponentIntersection=(e,t,i=10)=>{const o=e.left,r=e.left+e.width,a=e.top,n=e.top+e.height,s=t.left,l=t.left+t.width,d=t.top,c=t.top+t.height,u=o<l&&r>s&&a<c&&n>d,h=Math.abs(e.left+e.width/2-(t.left+t.width/2)),p=Math.abs(e.top+e.height/2-(t.top+t.height/2));return u||h<i&&p<i},this.calculateCombinedComponent=e=>{if(0===e.length)return{left:0,top:0,width:0,height:0};let t=e[0].left,i=e[0].top,o=e[0].left+e[0].width,r=e[0].top+e[0].height;for(let a=1;a<e.length;a++){const n=e[a];t=Math.min(t,n.left),i=Math.min(i,n.top),o=Math.max(o,n.left+n.width),r=Math.max(r,n.top+n.height)}return{left:t,top:i,width:o-t,height:r-i}},this.getAnTextNormaltText=e=>{var t,i;try{return null===(i=null===(t=null==e?void 0:e.tmpData)||void 0===t?void 0:t.option)||void 0===i?void 0:i.text}catch(e){return console.error("配置优化(ConfigOptimizer):",e),""}},this.initProp(e),this.upgradePlant(),this.staticComponentData=t,this.upgradeHeaderComponent(),i&&Object.assign(this,i)}isStringOrObject(e){return"string"==typeof e?"string":"object"==typeof e&&null!==e&&"object"}initProp(e){try{let t,i=this.isStringOrObject(e);if(i&&"string"===i)t=JSON.parse(e);else{if(!i||"object"!==i)throw new Error(`initProp fn error :-- 传入参数${e}不合法!`);t=e}if(t){this.originData=t;const{theme:e,plant:i,list:o}=t;this.theme=e,this.plant=i,this.list=o,this.filterFileGroup()}}catch(e){console.error("配置优化(ConfigOptimizer):",e)}}upgradePlant(){this.plant&&(this.plant.option.bg={type:1,code:"70942ec525344c96aa32b81b2c9155f6",path:"/anov-prod/resources/page/png/bg22 科技星球背景.png",thumb:"/anov-prod/resources/page/thumbnail/1e48f8fb26ec4edfb1a0f499627e84fc.png"})}areComponentsIntersecting(e,t){let i=e.baseData,o=t.baseData;const r=Math.max(0,Math.min(i.left+i.width,o.left+o.width)-Math.max(i.left,o.left)),a=Math.max(0,Math.min(i.top+i.height,o.top+o.height)-Math.max(i.top,o.top));return r>0&&a>0}filterFileGroup(){this.list=t.cloneDeep(this.list).map((e=>{var t,i;if(1===(null===(t=null==e?void 0:e.children)||void 0===t?void 0:t.length)&&!(null===(i=null==e?void 0:e.children[0])||void 0===i?void 0:i.children)){const t=e.children[0],{left:i,top:o}=e.baseData;return t.baseData.left=i,t.baseData.top=o,t}return e}))}getText(e,t,i){const o=document.createElement("canvas").getContext("2d");if(!o)throw new Error("Failed to get 2D context from canvas.");o.font=`${i}px ${t}`;return o.measureText(e).width}calculateMaxWidths(e){const t=Math.min(...e.map((e=>e.width))),i=[];let o=[],r=e[0].width;for(const a of e){const e=a.width;Math.abs(e-r)<=t?o.push(e):(o.length>0&&i.push(o),o=[e]),r=e}o.length>0&&i.push(o);const a=[];for(const e of i){const t=Math.max(...e);a.push(t)}return a}findClosestValue(e,t){let i=t[0],o=Math.abs(e-i);for(const r of t){const t=Math.abs(e-r);t<o&&(o=t,i=r)}return i}adjustHeightAndTop(e,t){const i=t-e.height;return Object.assign(Object.assign({},e),{height:t,top:e.top-i/2})}findNearestComponent(e,i,o){let r=null,a=1/0;i.tmpData.option.textNormal.text;try{const n=t.cloneDeep(e).sort(((e,t)=>e.baseData.top-t.baseData.top)).sort(((e,t)=>e.baseData.left-t.baseData.left)).filter((e=>!(e.cid===i.cid||"AnTextNormal"===e.viewComName||o&&o.includes(e.cid)))),s=t.cloneDeep(i).baseData;s.top,s.height;for(const e of n){const t=e.baseData;t.top,t.height;if(s.left<t.left+t.width&&s.left+s.width>t.left){const i=t.top-s.top;i<a&&i<100&&(a=i,r=e)}}}catch(e){console.error("配置优化(ConfigOptimizer)- findNearestComponent :",e)}return r}findNearestComponentForPoint(e,t,i){let o=null,r=1/0;t.tmpData.option.textNormal.text;try{const a=e.sort(((e,t)=>e.baseData.top-t.baseData.top)).sort(((e,t)=>e.baseData.left-t.baseData.left)).filter((e=>!(e.cid===t.cid||"AnTextNormal"===e.viewComName||i&&i.includes(e.cid)))),n=t.baseData;n.top,n.height;for(const e of a){const t=e.baseData;let i=this.getDistance(n.left,n.top+n.height,t.left,t.top);i<r&&i<n.width&&(r=i,o=e)}}catch(e){console.error("配置优化(ConfigOptimizer)- findNearestComponent :",e)}return o}findNearestComponentForTitlePoint(e,t,i){let o=null,r=1/0;t.tmpData.option.textNormal.text;try{const a=e.sort(((e,t)=>e.baseData.top-t.baseData.top)).sort(((e,t)=>e.baseData.left-t.baseData.left)).filter((e=>!(e.cid===t.cid||"AnTextNormal"===e.viewComName||i&&i.includes(e.cid)))),n=t.baseData;n.top,n.height;for(const e of a){const t=e.baseData;let i=this.getDistance(n.left,n.top+n.height,t.left,t.top);i<r&&i<n.width&&t.top-n.top>100&&(r=i,o=e)}}catch(e){console.error("配置优化(ConfigOptimizer)- findNearestComponent :",e)}return o}findNearestTitleForPoint(e,t,i){let o=null,r=1/0;t.tmpData.option.textNormal.text;try{const a=e.sort(((e,t)=>e.baseData.top-t.baseData.top)).sort(((e,t)=>e.baseData.left-t.baseData.left)).filter((e=>!(e.cid===t.cid||"AnTextNormal"===e.viewComName||i&&i.includes(e.cid)))),n=t.baseData;n.top,n.height;for(const e of a){const t=e.baseData;let i=t.top-n.top;i<r&&i<n.width&&t.top-n.top>100&&(r=i,o=e)}}catch(e){console.error("配置优化(ConfigOptimizer)- findNearestComponent :",e)}return o}getDistance(e,t,i,o){return Math.sqrt(Math.pow(i-e,2)+Math.pow(o-t,2))}findNearestComponent2(e,i,o){let r=null,a=1/0,n=t.cloneDeep(e).sort(((e,t)=>e.baseData.top-t.baseData.top));try{const e=n.filter((e=>!(e.cid===i.cid||"AnTextNormal"===e.viewComName||o&&o.includes(e.cid)))),s=t.cloneDeep(i).baseData,l=s.top+s.height;for(const t of e){const e=t.baseData,i=e.top+e.height;if(s.left<e.left+e.width&&s.left+s.width>e.left){const e=i-l;e>=0&&e<a&&(a=e,r=t)}}}catch(e){console.error("配置优化(ConfigOptimizer)- findNearestComponent :",e)}return r}verticalDistance(e,t){e.left,e.width;const i=e.top+e.height,o=(t.left,t.width,t.top);return Math.abs(i-o)}extractAmount(e){const t=e.match(/(\d{1,3}(?:,\d{3})*)(\D+)/);if(t){const e=t[1].replace(/,/g,"");return[parseInt(e,10),t[2].trim()]}return[!1,!1]}getAnTextNormal(){return this.list.filter((e=>"AnTextNormal"==e.viewComName))}getAnDeckTitle3(){return this.list.filter((e=>"AnDeckTitle3"==e.viewComName)).sort(((e,t)=>e.baseData.left-t.baseData.left))}judgeAnOdometer(){let e=this.getAnTextNormal().sort(((e,t)=>e.baseData.left-t.baseData.left)),t=[],i=new Set;for(const o of e){if(i.has(o.cid))continue;let r=[];for(const t of e){if(!i.has(t.cid)&&o.cid!=t.cid){this.checkComponentIntersection(o.baseData,t.baseData)&&(i.add(t.cid),i.add(o.cid),r.push(t))}}t.push([o,...r])}let o=[];for(const e of t)for(const t of e){let i=this.getAnTextNormaltText(t);this.extractAmount(i).every((e=>e))&&o.push(e)}return o}createAnOdometer(){var e,i;let o=this.judgeAnOdometer();for(const r of o){let o,a,n,s=this.calculateCombinedComponent(r.map((e=>e.baseData)));for(const e of r){let i=this.getAnTextNormaltText(e),r=this.extractAmount(i);r.every((e=>!e))&&(o=i),r.every((e=>e))&&(a=r[0],n=r[1]),t.remove(this.list,(t=>t.cid==e.cid))}let l=xe("AnIndicatorNormal",this.staticComponentData,t.cloneDeep({baseData:s}));(null===(i=null===(e=null==l?void 0:l.tmpData)||void 0===e?void 0:e.source)||void 0===i?void 0:i.static)&&(l.tmpData.source.static.data={text:o,num:a,unit:n},l.tmpData.source.static.originData={text:o,num:a,unit:n}),this.list.push(l)}}upgradeHeaderComponent(){for(let e=0;e<this.list.length;e++){const t=this.list[e];"AnDeckHeader3"==t.viewComName&&(t.baseData.left=0,t.baseData.top=0)}}upgradeTitleComponent(){let e=this.getAnDeckTitle3().map((e=>e.baseData)),t=this.calculateMaxWidths(e);for(let e=0;e<this.list.length;e++){const i=this.list[e];if("AnDeckTitle3"==i.viewComName){let e=this.findClosestValue(i.baseData.width,t);i.baseData.width=e>300?e:300,i.baseData=this.adjustHeightAndTop(i.baseData,this.titleHeqadeHeight)}}this.removeErroneousComponents()}containsFractionStructure(e){return/\b\d+\/\d+\b/.test(e)}removeErroneousComponents(){let e=this.getAnDeckTitle3(),t=[];for(let i=0;i<e.length;i++){const o=e[i];let r=o.tmpData.option.textNormal.text;if(this.containsFractionStructure(r))for(let i=0;i<e.length;i++){const r=e[i];if(o.cid!=r.cid){this.areComponentsIntersecting(o,r)&&t.push(o.cid)}}}this.list=this.list.filter((e=>!t.includes(e.cid)))}upgradeGroupComponent(){try{let e=this.getAnDeckTitle3(),t=this.list.filter((e=>"AnDeckTitle3"!=e.viewComName&&"AnDeckHeader3"!=e.viewComName&&"AnTextNormal"!=e.viewComName)),i=[],o=[];for(let r=0;r<e.length;r++){const a=e[r];let n=this.findNearestComponentForPoint(t,a,i);if(n&&n.cid&&i.push(n.cid),n){a.baseData.left=n.baseData.left;let t=this.upgradeComponentHeight(a,e,o);t&&t>=30&&(n.baseData=Object.assign({},n.baseData,{top:a.baseData.top+a.baseData.height+this.clearance}))}}}catch(e){console.error("配置优化(ConfigOptimizer):",e)}}upgradeComponentHeight(e,i,o=[]){const r=e;let a=this.findNearestTitleForPoint(t.cloneDeep(i),r);return a?a.baseData.top-r.baseData.top-this.titleHeqadeHeight:1080-r.baseData.top-this.titleHeqadeHeight}getData(){return this.originData.list=this.list,this.originData.plant=this.plant,this.originData}}const Ae=new class{randomNum(e,t){return Math.floor(Math.random()*(t-e+1))+e}generateRandomIntArray(e,t,i,o){const r=[];for(let o=0;o<e;o++){const e=this.randomNum(t,i);r.push(e)}return o&&"asc"===o?r.sort(((e,t)=>e-t)):o&&"desc"===o?r.sort(((e,t)=>t-e)):r}randomString(e,t){const i="abcdefghijklmnopqrstuvwxyz",o=this.randomNum(e,t);let r="";for(let e=0;e<o;e++){const e=Math.floor(26*Math.random());r+=i.charAt(e)}return r}generateRandomNameArray(e,t,i){const o=[];for(let r=0;r<e;r++){const e=this.randomString(t,i);o.push(e)}return o}pick(e,t){const i=void 0!==t?e.filter((e=>e!==t)):e;return i[Math.floor(Math.random()*i.length)]}},Oe=()=>{const e=[],t=Ae.pick([!0,!1]);let i=Ae.randomNum(3,20);const o=Ae.pick([null,null,null,{}]);let r=Ae.pick(["asc","desc",void 0,void 0,void 0]);for(let a=0;a<Ae.randomNum(1,9);a++)e.push({data:Ae.generateRandomIntArray(i,0,300,r),type:"line",smooth:t,symbolSize:Ae.randomNum(1,10),lineStyle:{width:Ae.randomNum(1,4)},areaStyle:o});return{xAxis:{type:"category",show:!1,boundaryGap:!1,data:Ae.generateRandomNameArray(i,3,6)},grid:{left:0,top:0,bottom:0,right:0},yAxis:{show:!1,type:"value"},series:e}},Ie=(e,t)=>{let i={type:e,show:!1};return"category"===e&&(i.data=Ae.generateRandomNameArray(t,3,6)),i},Te=()=>{const e=[],t=Ae.pick([!0,!1]);let i=Ae.randomNum(3,20);const o=Ae.pick([null,null,null,{}]);let r=Ae.pick(["asc","desc",void 0,void 0,void 0]),a=Ae.randomNum(1,9),n=Ae.pick([!0,!1]);for(let s=0;s<a;s++){let a={data:Ae.generateRandomIntArray(i,0,300,r),type:"bar",smooth:t,stack:n,areaStyle:o};e.push(a)}let s=Ae.pick(["value","category"]),l=Ae.pick(["value","category"],s);return{xAxis:Ie(s,i),grid:{left:0,top:0,bottom:0,right:0},yAxis:Ie(l,i),series:e}},Ve=()=>{const e=[];let t=Ae.randomNum(3,20);Ae.pick([null,null,null,{}]);let i=Ae.pick(["asc","desc",void 0,void 0,void 0]),o=Ae.pick([1,2]),r=[Ae.pick(["10%","20%","30%","40%","50%","60%","70%","80%"]),Ae.pick(["90%","100%"])];return e.push({data:Ae.generateRandomIntArray(t,3,20,i),type:"pie",radius:1==o?"100%":r,roseType:1==o?Ae.pick(["area",null,null]):null,padAngle:1==o?0:Ae.randomNum(1,5),startAngle:1==o?Ae.pick([0,180]):0,endAngle:360,label:{show:!1},itemStyle:{borderRadius:3}}),{grid:{left:0,top:0,bottom:0,right:0},series:e}},Fe=()=>{const e=[];Ae.pick([!0,!1]),Ae.randomNum(3,20),Ae.pick([null,null,null,{}]),Ae.pick(["asc","desc",void 0,void 0,void 0]);for(let t=0;t<Ae.randomNum(1,20);t++){let t=Ae.randomNum(3,Ae.randomNum(3,20)),i=[];for(let e=0;e<t;e++){let e=[];for(let t=0;t<2;t++)e.push(Ae.randomNum(1,30));i.push(e)}e.push({type:"scatter",symbolSize:Ae.randomNum(3,30),data:i})}return{xAxis:{show:!1},grid:{left:0,top:0,bottom:0,right:0},yAxis:{show:!1,type:"value"},series:e}},Ee=()=>{const e=[],t=Ae.pick(["polygon","circle"]);let i=Ae.randomNum(1e4,99999),o=Ae.randomNum(3,10),r=[];for(let e=0;e<o;e++)r.push({name:Ae.randomString(4,8),max:i});for(let t=0;t<Ae.randomNum(2,10);t++)e.push({value:Ae.generateRandomIntArray(o,1e4,i),name:Ae.randomString(4,8)});return{radar:{shape:t,indicator:r,axisName:{show:!1},radius:"100%"},grid:{left:0,top:0,bottom:0,right:0},series:[{type:"radar",symbol:"none",lineStyle:{width:1},data:e}]}},Pe=()=>{const e=[];for(let t=0;t<Ae.randomNum(4,15);t++)e.push({value:Ae.randomNum(1,100),name:Ae.randomString(4,8)});return{grid:{left:0,top:0,bottom:0,right:0},series:[{type:"funnel",left:"0%",top:0,bottom:0,width:"100%",min:0,minSize:"0%",maxSize:"100%",label:{show:!1,position:"inside"},sort:Ae.pick(["descending","ascending"]),gap:2,lineStyle:{width:1},data:e}]}};let je=Ae.randomNum(5,20);const Re={width:je};Ae.pick([!0,!1])&&(Re.color=[[.3,"#67e0e3"],[.7,"#37a2da"],[1,"#fd666d"]]);class $e{constructor(){this.names=["line","bar","pie","scatter","radar","funnel","gauge"]}static getInstance(){return $e.instance||($e.instance=new $e),$e.instance}createLine(){switch(Ae.pick(this.names)){case"line":return{type:"line",typeNum:1,option:Oe()};case"bar":return{type:"bar",typeNum:2,option:Te()};case"pie":return{type:"pie",typeNum:3,option:Ve()};case"scatter":return{type:"scatter",typeNum:4,option:Fe()};case"radar":return{type:"radar",typeNum:5,option:Ee()};case"funnel":return{type:"funnel",typeNum:6,option:Pe()};case"gauge":return{type:"gauge",typeNum:7,option:{grid:{left:0,top:0,bottom:0,right:0},series:[{type:"gauge",radius:"100%",detail:{formatter:"{value}"},progress:{show:Ae.pick([!0,!1]),width:je},axisLine:{lineStyle:Re},data:[{value:Ae.randomNum(1,100),name:"SCORE"}]}]}}}}}$e.instance=null;const qe=$e.getInstance();const Me=new class{constructor(){this.directions=["row","row"],this.direction="column",this.splitNumbers=24,this.margin=[0,0]}baseLayout(e){const t=(null==e?void 0:e.maRrows)?null==e?void 0:e.maRrows:this.splitNumbers,i=(null==e?void 0:e.colNum)?null==e?void 0:e.colNum:this.splitNumbers,o=e.wrapWidth/i,r=e.wrapHeight/t;let a=E(this.directions);a&&(this.direction=a);let n=[];if("row"===this.direction){let e=E([3,4]);n=this.simulateRandomSegments(24,4,12,e)}else{let e=E([2,3]);n=this.simulateRandomSegments(24,4,6,e)}let s=[],l=[];if("row"===this.direction){for(let e=0;e<n.length;e++)if(0==e)s.push({x:0,y:0,w:n[e],h:24,i:e,wStep:o,hStep:r});else{let t=s[e-1].x;s.push({x:n[e-1]+t,y:0,w:n[e],h:24,i:e,wStep:o,hStep:r})}let e=E([2,3]),t=this.simulateRandomSegments(24,6,12,e);for(let e=0;e<s.length;e++){const i=s[e];for(let a=0;a<t.length;a++){const n=t[a];l.push({x:i.x,y:n,w:i.w,h:n,i:10*e+a,wStep:o,hStep:r})}}}else{for(let e=0;e<n.length;e++)if(0==e)s.push({x:0,y:0,w:24,h:n[e],i:e,wStep:o,hStep:r});else{let t=s[e-1].y;s.push({x:0,y:n[e-1]+t,w:24,h:n[e],i:e,wStep:o,hStep:r})}for(let e=0;e<s.length;e++){const t=s[e];let i=E([1,2,3,4]),a=this.simulateRandomSegments(24,5,12,i),n=[];for(let i=0;i<a.length;i++){const s=a[i];if(0==i)n.push({x:0,y:t.y,w:s,h:t.h,i:10*e+i,wStep:o,hStep:r}),l.push({x:0,y:t.y,w:s,h:t.h,i:10*e+i,wStep:o,hStep:r});else{let d=n[i-1].x;n.push({x:a[i-1]+d,y:t.y,w:s,h:t.h,i:10*e+i,wStep:o,hStep:r}),l.push({x:a[i-1]+d,y:t.y,w:s,h:t.h,i:10*e+i,wStep:o,hStep:r})}}}}return{layouts:l.map((t=>{let{option:i,typeNum:o}=qe.createLine(),r=t.x*t.wStep+t.w*t.wStep/2,a=t.y*t.hStep+t.h*t.hStep/2,n=t.w*t.wStep,s=t.h*t.hStep;if(3==o||5==o||7==o){let e=Math.min(n,s);n=e,s=e}let l=e.wrapWidth,d=e.wrapHeight;return t.chartsOption=i,t.typeNum=o,t.txt=o+" "+r/l+" "+a/d+" "+n/l+" "+s/d,console.log(t.txt),t})),option:{colNum:i,margin:(null==e?void 0:e.margin)?null==e?void 0:e.margin:this.margin,isDraggable:!!(null==e?void 0:e.isDraggable)&&(null==e?void 0:e.isDraggable),isResizable:!!(null==e?void 0:e.isResizable)&&(null==e?void 0:e.isResizable),verticalCompact:!(null==e?void 0:e.verticalCompact)||(null==e?void 0:e.verticalCompact),useCssTransforms:!(null==e?void 0:e.useCssTransforms)||(null==e?void 0:e.useCssTransforms),rowHeight:e.wrapHeight/t,maRrows:t}}}simulateRandomSegments(e,t,i,o){const r=[];let a=e,n=o;for(;n>0;)if(1===n)r.push(a),n--;else{const e=Math.min(i,a-t*(n-1)),o=Math.floor(Math.random()*(e-t+1))+t;r.push(o),a-=o,n--}return r}simulateRandomSegments2(e,t,i,o){const r=[];let a=e,n=o;for(;n>0;)if(1==n){const t=e-r.reduce(((e,t)=>e+t),0);r.push(t),n--}else{let e=Math.floor(Math.random()*i),o=Math.max(t,e),s=a-t*n;const l=Math.min(o,s);r.push(l),a-=l,n--}return r}},Ue=a.pool(),Le=e=>{try{return JSON.parse(e)}catch(t){return e}};const He=new class{constructor(){this.requested=new Set,this.db=new r("go-db"),this.init()}init(){return s(this,void 0,void 0,(function*(){this.db.version(1).stores({store:"key, value"})}))}pushCaseIdToRequested(e){this.requested.add(e)}add(e,t){return s(this,void 0,void 0,(function*(){try{(yield this.isExist(e))||(t.caseDetailData&&(t.caseDetailData="string"==typeof t.caseDetailData?Le(t.caseDetailData):t.caseDetailData),this.pushCaseIdToRequested(e),yield this.db.table("store").add({key:e,value:t}))}catch(e){console.error(e)}}))}bulkPut(e){return s(this,void 0,void 0,(function*(){let t=yield Promise.all(e.map((e=>s(this,void 0,void 0,(function*(){const{caseId:t,id:i}=e,o=`${t}_${i}`;if(yield this.isExist(o))return null;if(e.caseDetailData){const t=yield Ue.exec(Le,[e.caseDetailData]);e.caseDetailData=t,Ue.terminate()}return e})))));t=t.filter((e=>null!==e));const i=t.map((e=>{const{caseId:t,id:i}=e,o=`${t}_${i}`;return this.pushCaseIdToRequested(o),{key:o,value:e}}));this.db.table("store").bulkPut(i).then((()=>{})).catch((e=>console.error(e)))}))}get(e){return s(this,void 0,void 0,(function*(){if(!(yield this.isExist(e)))return null;const t=yield this.db.table("store").where("key").equals(e).first();return t?t.value:null}))}getAllData(){return s(this,void 0,void 0,(function*(){return yield this.db.table("store").toArray()}))}update(e,t){return s(this,void 0,void 0,(function*(){if(yield this.isExist(e)){const i=yield this.get(e),o=yield Ue.exec(Le,[t]);Ue.terminate(),yield this.db.table("store").update(e,{value:Object.assign(Object.assign({},i),{caseDetailData:o})})}else console.error("update indexdb error")}))}delete(e){this.requested.delete(e),this.db.table("store").delete(e)}isExist(e){return s(this,void 0,void 0,(function*(){return(yield this.db.table("store").where("key").equals(e).count())>0}))}reset(){this.requested.clear(),this.db.table("store").clear()}clear(){return s(this,void 0,void 0,(function*(){yield this.db.table("store").clear()}))}isExistStore(){return s(this,void 0,void 0,(function*(){try{return yield this.db.open(),!0}catch(e){return!1}}))}},Be=function(e){return s(this,void 0,void 0,(function*(){try{let{fontUrl:t,fontName:i}=e;const o="__custom_font__";let r=document.getElementById(o);if(!r){r=document.createElement("style"),r.id=o;const e=document.head||document.getElementsByTagName("head")[0];yield e.appendChild(r)}r.innerText+=`@font-face{font-family:'${i}';src:url(${t});}`}catch(e){console.warn(e)}}))},ze=(e,...t)=>s(void 0,[e,...t],void 0,(function*(e,t="jspaths",i){const o="csspaths"===t?"link":"script",r=document.createElement(o);"jspaths"===t?r.defer=!0:r.rel="stylesheet",r.className=t,r.src=e;(i||document.head||document.getElementsByTagName("head")[0]).appendChild(r),yield new Promise(((e,t)=>{r.addEventListener("load",e),r.addEventListener("error",e)}))})),Je=(e,...t)=>s(void 0,[e,...t],void 0,(function*(e,t="jspaths"){const i="fonts"===t?Be:ze;yield Promise.all(e.map((e=>i(e))))}));function Ge(e){!function(e,t){e.depends?n(e):_e(e,t)}(e,!1)}function _e(e,t=!0){let{theme:i,option:o,optionDes:r}=e;o&&r&&i&&Object.keys(r).forEach((a=>{"conditionSeries"!==r[a].type&&"tabs"!==r[a].type||!o[a]?r[a].theme?o.hasOwnProperty(a)&&function({theme:e,option:t,optionDes:i},o,r){let a;if("color"!=i[o].type||!r&&t[o]){if("bgcolor"==i[o].type&&(r||!t[o]||!t[o].style)){t[o]||(t[o]={});let{key:r,points:n,degree:s,type:l,opacity:d}=i[o].theme;if(n){s||(s=90),l||(l="linear");let i=`${l}-gradient(${s}deg`,r=100/(n.length-1),c=[];n.forEach(((t,o)=>{a=We(e,t),i+=`,${Xe(a,t.opacity)} ${r*o}%`;let{red:n,green:s,blue:l,alpha:u}=Ke(a,d);c.push({red:n,green:s,blue:l,alpha:u,left:r*o})})),i+=")",t[o].style=i,t[o].degree=s,t[o].flag=n.length?3:2,t[o].points=c,t[o].type=l}else r&&(a=We(e,i[o].theme),t[o]=Object.assign(Object.assign({},Ke(a,d)),{style:Xe(a,d)}))}}else{let{opacity:r}=i[o].theme;a=We(e,i[o].theme),t[o]=Xe(a,r)}}(e,a,t):r[a].hasOwnProperty("type")&&"slot"!=r[a].type&&"textStyle"!=r[a].type&&"sheet"!=r[a].type||r[a].constructor!=Object||_e({option:o[a],optionDes:r[a],theme:i},t):function(e,t,i,o,r,a){let n=t.form,s=e;if(Array.isArray(n))for(let e=0;e<n.length;e++){let t,i=n[e];t=a?s[e].form:s[e],_e({option:t,optionDes:i,theme:o},r)}else{let e=s.length;for(let t=0;t<e;t++){let e;e=a?s[t].form:s[t],_e({option:e,optionDes:n,theme:o},r)}}}(o[a],r[a],0,i,t,"conditionSeries"===r[a].type)}))}function We(e,t){if(e[t.key])return e[t.key]||e.color;if(t.key.indexOf(".")>-1){return[e,...t.key.split(".")].reduce(((t,i)=>"object"==typeof t&&i in t?t[i]:(Qe(`属性${i}不存在,获取主题颜色错误,将使用默认主题色`),e.color)))}return Qe(`属性${t.key}不存在,获取主题颜色错误,将使用默认主题色`),e.color}function Xe(e,t){let{red:i,green:o,blue:r,alpha:a}=Ke(e,t);return`rgba(${i},${o},${r},${a})`}function Ke(e,t){return-1!=e.indexOf("#")&&(e=e.substr(1)),null==t&&(t=1),{red:parseInt("0x"+e.slice(0,2)),green:parseInt("0x"+e.slice(2,4)),blue:parseInt("0x"+e.slice(4,6)),alpha:t}}function Qe(e){console.warn(e)}class Ye{constructor(e){this.processedIds=new Set,this.validateAccessResolve=null,e?(e.caseId&&(this.caseId=e.caseId),e.pageId&&(this.pageId=e.pageId),e.mode&&(this.mode=e.mode),e.environment&&(this.environment=e.environment),e.xhr&&(this.xhr=e.xhr),e.staticComponentData&&(this.staticComponentData=e.staticComponentData),e.theme&&(this.theme=e.theme)):console.log("初始化错误!"),this.defaultTheme={name:"科技蓝",color:"#006aee",background:"#00000033",pageBackground:"#051836",text:"#F0F0F0",groups:["#006aee","#00eae9","#00a9ec","#00ec80","#edc700","#9913ee"]}}checkHardware(){return s(this,void 0,void 0,(function*(){return yield new Promise(((e,t)=>{e("Hardware is not available")}))}))}checkSecurity(e){return s(this,void 0,void 0,(function*(){return yield new Promise(((t,i)=>{"preview"==this.environment?t(0):this.getShareForRelease(e).then((e=>{2e4==e.code&&e.data?(e.data,e.data.loginLimitSwitch?t(1):e.data.hasAuth?t(2):t(3)):t(4)}))}))}))}validateAccess(e,t){return s(this,void 0,void 0,(function*(){return new Promise(((i,o)=>{this.validateAccessResolve=i,t&&t(e)}))}))}initBefore(){return new Promise(((e,t)=>{let i=p("secretFree");i?sessionStorage.setItem("secret-free",i):sessionStorage.setItem("secret-free",null),console.log("运行免登录设置完成!"),e(!0)}))}fetchCaseId(e,t){return s(this,void 0,void 0,(function*(){try{const i=yield this.getKey(e,t);return 2e4===(null==i?void 0:i.code)&&(null==i?void 0:i.data)?i.data:e}catch(t){return console.error("Error fetching caseId:",t),e}}))}getDataForrelease(){return new Promise(((e,t)=>{e("data")}))}onProjectLoaded(e){}authenticate(){return s(this,void 0,void 0,(function*(){this.environment}))}getShareForRelease(e){return this.xhr.get(`/go/v1/go-share/v1/${e}/config`)}findById(e,t="",i=0,o=""){return"release"===this.environment?this.xhr.get(`/go/v1/go-share/v1/${e}?pwd=${t}&mode=${i}&token=${o}`):this.xhr.get(`/go/v1/go-cases/v1/${e}?mode=${i}&token=${o}`)}getKey(e,t=0){return this.xhr.get(`/go/v1/go-cases/v1/key/${e}?caseMode=${t}`)}getPageData(e,t){return s(this,void 0,void 0,(function*(){const i=yield He.get(e+"_"+t);return i?{data:i}:"release"===this.environment?this.xhr.get(`/go/v1/go-share/v1/${e}/pages/${t}`):this.xhr.get(`/go/v1/go-cases/v1/${e}/pages/${t}`)}))}getPageId(e,t){if(null==t?void 0:t.length){if(t.find((t=>t.id==e)))return e;let i=t.find((t=>t.caseDetailPath==e||t.caseDetailName==e));return i?i.id:e}return e}fetchProjectForId(e){return s(this,arguments,void 0,(function*(e,t="",i=0,o=""){return yield this.findById(e,t,i,o)}))}updataPageData(e,t){return s(this,void 0,void 0,(function*(){var i;let o=yield this.getPageDataForID(e,t);(null==o?void 0:o.data)?null===(i=null==this?void 0:this.lifecycleHooks)||void 0===i||i.onPageDataReady(o.data.caseDetailData):console.error("请求数据发生错误!")}))}getPageDataForID(e,t,i){return s(this,void 0,void 0,(function*(){const o=this.getPageId(t,this.projectInfo.details);if(this.processedIds.has(o)){console.log(`ID ${o} has already been processed.`);const t=yield He.get(e+"_"+o);if(t)return{data:t}}const r=this.getPageData(e,o);this.processedIds.add(o),i&&i.length&&i.map((t=>s(this,void 0,void 0,(function*(){try{if(this.processedIds.has(t))return void console.log(`ID ${o} has already been processed.`);const i=yield this.getPageData(e,t);He.add(e+"_"+t,i.data),this.processedIds.add(t)}catch(e){console.error(`Error processing ID ${t}: ${e}`)}}))));const a=yield r;return He.add(e+"_"+o,a.data),yield r}))}fetchPageDataForId(e){return s(this,arguments,void 0,(function*(e,t="",i=0,o=""){return yield this.findById(e,t,i,o)}))}setTheme(){console.log("设置主题")}setBackground(){console.log("设置背景信息")}updateVariables(){console.log("更新变量信息")}beforeRender(e){}renderComponents(){return s(this,void 0,void 0,(function*(){}))}setGlobalThemeVars(e){document.body.style.cssText=`\n --theme-background: ${e.background};\n --theme-color: ${e.color};\n --theme-pageBackground: ${e.pageBackground};\n --theme-text: ${e.text};\n ${e.groups.map(((e,t)=>`--theme-groups-${t}: ${e};`)).join("\n")}\n `}listenForRenderCompletion(){}showAnimation(){console.log("所有组件渲染完成,显示动画。")}setComTheme(e,t){var i,o;let r=null===(i=this.staticComponentData[t.viewComName])||void 0===i?void 0:i.optionDes,a=null===(o=this.staticComponentData[t.viewComName])||void 0===o?void 0:o.theme;return Ge({theme:e,option:t.tmpData.option,optionDes:r,depends:a}),t}getComData(e,t,i,o){return s(this,void 0,void 0,(function*(){return new Promise(((r,a)=>{if(e.tmpData&&e.tmpData.source){this.setComTheme(o,e);try{le(e,!0,t,i).then((t=>{t&&(e.source=t)})),r(1)}catch(e){r(e)}}else r("")}))}))}pageInit(e){return s(this,void 0,void 0,(function*(){var i;try{let o=null==e?void 0:e.caseDetailData,r=this.defaultTheme;if((null==o?void 0:o.theme)&&(r=o.theme),this.setGlobalThemeVars(r),o.resource){let e=(null===(i=null===window||void 0===window?void 0:window.anovuiConfig)||void 0===i?void 0:i.fonts)||[],r=t.concat(o.resource.fonts,e),a=t.cloneDeep(o.resource);a.fonts=r,yield(e=>s(void 0,[e],void 0,(function*({jspaths:e=[],csspaths:i=[],fonts:o=[]}){const r=t.uniqBy(o,"fontName");yield Promise.all([Je(e,"jspaths"),Je(i,"csspaths"),Je(r,"fonts")])})))(a)}ve.clearVars(),ve.addVariables(o.globalVars);let a=ve.getAllVariables();return w(o.list,(e=>s(this,void 0,void 0,(function*(){yield this.getComData(e,a,o.globalSource,r)})))),o}catch(t){return console.warn("页面初始化发生错误:",t),(null==e?void 0:e.data)?e.data:e}}))}validate(e,t,i){return s(this,void 0,void 0,(function*(){return new Promise(((o,r)=>{const a=(e,i)=>s(this,void 0,void 0,(function*(){let r=yield this.validateAccess(e,i),n=(null==r?void 0:r.pwd)?r.pwd:"",s=(null==r?void 0:r.mode)?r.mode:0,l=(null==r?void 0:r.token)?r.token:"",d=yield this.fetchProjectForId(t,n,s,l);2e4==(null==d?void 0:d.code)&&(null==d?void 0:d.data)?(this.projectInfo=d.data,console.log("验证成功!"),this.lifecycleHooks.message("验证成功!"),o(!0)):(this.lifecycleHooks.validateError(d),this.lifecycleHooks.message(d.msg,"warning"),a(e,i))}));a(e,i)}))}))}init(e){return s(this,void 0,void 0,(function*(){var t;try{this.lifecycleHooks=e,yield this.checkHardware();let i=yield this.fetchCaseId(this.caseId,this.mode),o=yield this.checkSecurity(i),r=e.onValidateAccess||(()=>{});(yield this.validate(o,i,r))&&e.onCaseReady(this.projectInfo);let a=(null===(t=this.projectInfo)||void 0===t?void 0:t.details).map((e=>e.id)),n=this.getPageId(this.pageId,this.projectInfo.details);console.log(n,this.pageId,"this.pageId");let s=yield this.getPageDataForID(i,n||a[0],a);const l=yield this.pageInit(s.data);return e.onPageDataReady(l),{currentData:this.projectInfo,currentPageData:l}}catch(e){console.error("加载页面时出错:",e)}}))}}export{Ce as ConfigOptimizer,ge as GlobalVariables,J as Http,z as Log,Ye as PageLoader,X as agentData,I as delFetchStatus,Me as displayGenerator,se as editItem,De as emitEvent,ae as fetchDataByGlobal,re as fetchDataByType,ne as filterData,x as findItemDeep,S as findItemDeep2,W as getData,K as getDataForApi,Y as getDataForDataSet,ee as getDataForSource,te as getDataForStatic,Q as getDataForZb,Z as getDataForZbCQ,v as getSessionData,m as getStandardData,D as getStringVars,p as getUrlParams,be as getVarDefaultVal,ve as globalVars,N as hasVar,f as isJSON,w as recursion,ue as replaceVariable,C as safeEval,A as safeEvalForCode,O as setFetchStatus,g as setSessionData,pe as updataGlobalDataSourceForVar,le as updateComData,me as updateGlobalDataSource};
|
|
1
|
+
import e from"axios";import t,{uniq as o}from"lodash";import i from"crypto-js";import r from"dexie";import a from"workerpool";import{setOptionColorByTheme as n}from"@anov/ui/lib/utils/option-theme.js";function s(e,t,o,i){return new(o||(o=Promise))((function(r,a){function n(e){try{l(i.next(e))}catch(e){a(e)}}function s(e){try{l(i.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof o?t:new o((function(e){e(t)}))).then(n,s)}l((i=i.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const l=3e4,d=3e4,c=(t="",o)=>{let i=e.create({baseURL:t,timeout:l,headers:{"Content-Type":"application/x-www-form-urlencoded;charset=UTF-8"}});return i.interceptors.request.use((function(e){return sessionStorage.getItem("anov-go-token")&&"null"!=sessionStorage.getItem("anov-go-token")&&(e.headers["X-ANOV-ACCESS-TOKEN"]=sessionStorage.getItem("anov-go-token")),sessionStorage.getItem("unify-access-token")&&"null"!=sessionStorage.getItem("unify-access-token")&&(e.headers["X-UNIFY-ACCESS-TOKEN"]=sessionStorage.getItem("unify-access-token")),sessionStorage.getItem("dgcc_authorization")&&"null"!=sessionStorage.getItem("dgcc_authorization")&&(e.headers.dgcc_authorization=sessionStorage.getItem("dgcc_authorization")),"post"===e.method?(e.headers["Content-Type"]="application/json;",e):"get"===e.method?e:"put"===e.method?(e.headers["Content-Type"]="application/json; charset=UTF-8",e):"delete"===e.method?e:void 0}),(function(e){return Promise.reject(e)})),i.interceptors.response.use((function(e){return 200===e.status||e.data.code,o&&o(e),e.data}),(function(e){return o&&o(null==e?void 0:e.response),Promise.reject(e.response)})),i},u=function(e){return s(this,void 0,void 0,(function*(){try{let{fontUrl:t,fontName:o}=e;const i="__custom_font__";let r=document.getElementById(i);if(!r){r=document.createElement("style"),r.id=i;const e=document.head||document.getElementsByTagName("head")[0];yield e.appendChild(r)}r.innerText+=`@font-face{font-family:'${o}';src:url(${t});}`}catch(e){console.warn(e)}}))},h=(e,t="jspaths",o)=>s(void 0,void 0,void 0,(function*(){const i="csspaths"===t?"link":"script",r=document.createElement(i);"jspaths"===t?r.defer=!0:r.rel="stylesheet",r.className=t,r.src=e;(o||document.head||document.getElementsByTagName("head")[0]).appendChild(r),yield new Promise(((e,t)=>{r.addEventListener("load",e),r.addEventListener("error",e)}))})),p=(e,t="jspaths")=>s(void 0,void 0,void 0,(function*(){const o="fonts"===t?u:h;yield Promise.all(e.map((e=>o(e))))})),m=e=>s(void 0,void 0,void 0,(function*(){e.fonts&&e.fonts.length&&(yield p(e.fonts,"fonts"))})),f=({jspaths:e=[],csspaths:o=[],fonts:i=[]})=>s(void 0,void 0,void 0,(function*(){const r=t.uniqBy(i,"fontName");yield Promise.all([p(e,"jspaths"),p(o,"csspaths"),p(r,"fonts")])})),g=()=>{var e;(null==(e=document.getElementById("__custom_font__"))?void 0:e.parentNode)&&e.parentNode.removeChild(e),Array.from(document.getElementsByTagName("script")).filter((e=>"jspaths"==e.className)).forEach((e=>{!function(e){for(var t,o=Array.from(document.getElementsByTagName("script")),i=0;i<o.length;i++)o[i]&&o[i].src&&-1!=o[i].src.indexOf(e)&&(null===(t=o[i])||void 0===t?void 0:t.parentNode)&&o[i].parentNode.removeChild(o[i])}(e.src)})),Array.from(document.getElementsByTagName("link")).filter((e=>"csspaths"==e.className)).forEach((e=>{!function(e){for(var t,o=Array.from(document.getElementsByTagName("link")),i=0;i<o.length;i++)o[i].href,o[i]&&o[i].href&&-1!=o[i].href.indexOf(e)&&(null===(t=o[i])||void 0===t?void 0:t.parentNode)&&o[i].parentNode.removeChild(o[i])}(e.href)}))};const v=(e,t,o)=>{const i=document.createElement("link");switch(i.rel="preload",i.href=e,i.crossorigin="anonymous",t){case"video":i.as="video";break;case"script":i.as="script";break;case"image":i.as="image"}i.onload=()=>{console.log(`success to preload ${e}`),o&&o()},i.onerror=()=>{console.error(`Failed to preload ${e}`)},document.head.appendChild(i)},y=(e,t)=>{try{let o=t||window.location.href;if(-1!=o.indexOf("?")){let t={};return o.slice(o.indexOf("?")+1).split("&").forEach((e=>{let o=e.split("=");t[o[0]]=o[1]})),e?t[e]?t[e]:null:t}return console.log("没有参数"),null}catch(e){console.error(e)}};function b(e,t=!1){try{return t?w(e)?e:JSON.stringify(e):w(e)?JSON.parse(e):e}catch(t){return console.log("转化JSON 发生错我!",e),e}}const w=e=>{if("string"==typeof e)try{const t=JSON.parse(e);return"object"==typeof t&&null!==t}catch(e){return!1}return!1},D=(e,t)=>{try{const o=JSON.stringify(t);sessionStorage.setItem(e,o)}catch(t){console.error(`Error setting session data for key ${e}:`,t)}},N=e=>{const t=sessionStorage.getItem(e);if(t)try{return JSON.parse(t)}catch(t){console.error(`Error parsing session data for key ${e}:`,t)}return null},k=e=>{for(const t of e)t.code&&(t.code=t.code.replace(/>/g,">").replace(/</g,"<"))},A=(e,t)=>{e instanceof Map?e.forEach((e=>{t([e])})):Array.isArray(e)&&e.forEach((e=>{t(e.children)}))},C=(e,t)=>{const o=e=>{var i,r,a;if(e)for(const n of e){const e=null===(a=null===(r=null===(i=null==n?void 0:n.tmpData)||void 0===i?void 0:i.source)||void 0===r?void 0:r.converse)||void 0===a?void 0:a.data;(null==e?void 0:e.length)&&k(e),t(n),n.children?o(n.children):n.dynamicChildren?A(n.dynamicChildren,o):n.stateChildren&&o(n.stateChildren)}};o(e)},x=(e,t,o,i)=>{const r=e.match(/({{[\w]*}})|((@)[\w]*)/gm);if(r){const e=r.map((e=>e.replace(/{{|}}|@/gm,"")));for(const r of e)if(r&&t&&!(t.findIndex((e=>e.mapField===r))<0))return o&&i&&S(i,r,o.cid),!0}return!1},S=(e,t,o)=>{if(!e)throw new Error("Share variable tree is not defined");if("string"!=typeof t)throw new Error("Variable name should be a string");if(!o)throw new Error("ID is required");Array.isArray(e[t])||(e[t]=[]),e[t].includes(o)||e[t].push(o)},O=(e,t,o)=>{var i;let r=!1;const a=null==t?void 0:t.converse;if(a&&a.use&&a.data.length)for(const t of a.data)if((null==t?void 0:t.dependVars)&&t.dependVars.includes(e))return!0;const n=null==t?void 0:t[null==t?void 0:t.type];return((null==n?void 0:n.inputSql)||(null==n?void 0:n.url)||(null==n?void 0:n.headers)||(null==n?void 0:n.params))&&(r=x(n.inputSql||n.url||(null===(i=n.headers)||void 0===i?void 0:i.value)||n.params,o)),r},I=(e,o,i=!1)=>{let r=null;const a=e=>{for(const n of e){if(n.cid===o){r=n,i&&t.remove(e,(e=>e.cid===o));break}if(n.children&&a(n.children),n.dynamicChildren&&Array.isArray(n.dynamicChildren))for(const[,e]of Array.from(n.dynamicChildren))a(e);n.stateChildren&&a(n.stateChildren)}};return a(e),r},T=(e,o,i)=>{let r=!1;const a=e=>{for(let n=0;n<e.length;n++){if(e[n].cid==o){r=e[n],i&&t.remove(e,(e=>e.cid==o));break}if(e[n].children)a(e[n].children);else if(e[n].dynamicChildren){if(e[n].dynamicChildren instanceof Map){let t=Array.from(e[n].dynamicChildren);for(let e=0;e<t.length;e++)if(t[e]instanceof Array){let o=t[e][1];a(o)}}else if(e[n].dynamicChildren instanceof Array){let t=e[n].dynamicChildren;for(let e=0;e<t.length;e++)if(t[e]instanceof Array){let o=t[e][1];a(o)}}}else e[n].stateChildren&&a(e[n].stateChildren)}};return a(e),r||!1};function V(e,t,o){const i={};o&&o.forEach((e=>{(null==e?void 0:e.name)&&(i[e.name]=e.value||e.originvalue)}));try{return new Function("data","vars",e)(t,i)}catch(e){return console.error(e),t}}function E(e,o,i){let r=t.cloneDeep(o);const a={};i&&i.forEach((e=>{(null==e?void 0:e.name)&&(a[e.name]=e.value||e.originvalue)}));try{return new Function("data","vars",e)(r,a)}catch(e){return console.error(e),r}}const F=e=>{let t=window.goFetchList;return t||(window.goFetchList={},t=window.goFetchList),t[e]?!t[e]&&void 0:(t[e]={id:e,time:(new Date).getTime()},!0)},P=e=>{let t=window.goFetchList;t&&t[e]&&delete t[e]};function j(e){const t=e.match(/\.([^\/\\]+)$/);return t?t[1].toLowerCase():void 0}const $=e=>{const t=[];let o=function(e){return e.endsWith("/")?e.slice(0,-1):e}(window.baseUrl);return C(e,(e=>{var i,r,a,n,s,l,d,c,u;if("AnDeckHeader3"==e.viewComName&&(null===(a=null===(r=null===(i=null==e?void 0:e.tmpData)||void 0===i?void 0:i.option)||void 0===r?void 0:r.bgImage)||void 0===a?void 0:a.path)){let i=j(e.tmpData.option.bgImage.path);t.push({type:i,url:o+e.tmpData.option.bgImage.path})}if("AnVideoNormal"==e.viewComName&&(null===(s=null===(n=null==e?void 0:e.tmpData)||void 0===n?void 0:n.option)||void 0===s?void 0:s.dynamicUrl)){let i=j(null===(d=null===(l=null==e?void 0:e.tmpData)||void 0===l?void 0:l.option)||void 0===d?void 0:d.dynamicUrl);t.push({type:i,url:o+(null===(u=null===(c=null==e?void 0:e.tmpData)||void 0===c?void 0:c.option)||void 0===u?void 0:u.dynamicUrl)})}})),t},R="anov@2019:helloX",M="anov@2020:helloX";function U(e){let t=i.enc.Utf8.parse(R),o=i.enc.Utf8.parse(M);return i.AES.encrypt(e,t,{iv:o,mode:i.mode.CBC,padding:i.pad.Pkcs7}).toString()}function q(e,t){if(0===e.length)throw new Error("Array is empty.");if(!t)return e[Math.floor(Math.random()*e.length)];if(t.length!==e.length)throw new Error("Length of probabilities array must match length of array.");const o=t.reduce(((e,t)=>e+t),0),i=Math.random()*o;let r=0;for(let o=0;o<e.length;o++)if(r+=t[o],i<r)return e[o];return e[0]}const L=new Blob(["\nfunction proxyObj(originObj) {\n const exposeObj = new Proxy(originObj, {\n has: (target, key) => {\n if (['fetch', 'XMLHttpRequest', 'postMessage'].indexOf(key) >= 0) {\n throw new Error('Illegal operation for key'+key)\n } else {\n return target[key]\n }\n },\n })\n return exposeObj\n}\nfunction compileCode(src) {\n src = 'with (exposeObj) {'+src+'}'\n //console.log(src)\n return new Function('exposeObj', src)\n}\nfunction run(code) {\n let proxy = proxyObj({})\n let result = compileCode(code)(proxy)\n return result\n}\n\nonmessage = (e) => {\n try {\n let result = run(e.data.code)\n postMessage({\n code: 1,\n result,\n })\n } catch (err) {\n postMessage({\n code: -1,\n err,\n })\n }\n}\n"]),B=URL.createObjectURL(L);function H(e,t,o={},i="worker"){return s(this,void 0,void 0,(function*(){try{if("window"==i){let[i,r]=[["data"],[t]];"object"==typeof o&&Object.keys(o).forEach((e=>{i.push(e),r.push(o[e])}));const a=new Function(...i,e);return{success:!0,data:a(...r)}}{let[i,r,a]=[t,o,""];"object"==typeof i&&(i=JSON.stringify(t)),"object"==typeof o&&(r=JSON.stringify(o)),Object.keys(o).forEach((e=>a+=`${e},`));let n=`let data=eval(${i}); \n let app=${JSON.stringify({})};`;n+=a?`let {${a}} = eval(${r}); `:"",n+=`${e}`;let l=yield function(e,t=5e3){return s(this,void 0,void 0,(function*(){let o=new Worker(B);return new Promise(((i,r)=>{const a=()=>{clearTimeout(s),o.removeEventListener("message",n),o.terminate(),o=null},n=e=>{let{code:t,result:o,err:n}=e.data;a(),1===t?i(o):r(n)};o.postMessage({code:e}),o.addEventListener("message",n);let s=setTimeout((()=>{a(),r("timeout")}),t)}))}))}(n);return{success:!0,data:l}}}catch(e){return{success:!1,error:e,data:t}}}))}var z,G,_,J;!function(e){e.StaticFile="staticFile",e.DataSource="datasource"}(z||(z={})),function(e){e.json="application/json;charset=UTF-8",e.form="application/x-www-form-urlencoded; charset=UTF-8"}(G||(G={})),function(e){e.get="GET",e.post="POST",e.put="PUT",e.patch="PATCH",e.delete="DELETE"}(_||(_={}));class W{constructor(e){this.db=null,this.dbName=e.databaseName,this.tableName=e.tableName,this.keyPath=e.keyPath}static getInstance(e){return W.instance||(W.instance=new W(e)),W.instance}init(){return s(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{const o=indexedDB.open(this.dbName,1);o.onerror=e=>{t(e.target.error)},o.onupgradeneeded=e=>{this.db=e.target.result,this.db.objectStoreNames.contains(this.tableName)||this.db.createObjectStore(this.tableName,{keyPath:this.keyPath})},o.onsuccess=t=>{this.db=t.target.result,e()}}))}))}addRecord(e){return s(this,void 0,void 0,(function*(){if(!this.db)throw new Error("数据库未初始化。");return new Promise(((t,o)=>{const i=this.db.transaction([this.tableName],"readwrite").objectStore(this.tableName).add(e);i.onsuccess=()=>{t()},i.onerror=e=>{o(e.target.error)}}))}))}deleteRecord(e){return s(this,void 0,void 0,(function*(){if(!this.db)throw new Error("数据库未初始化。");return new Promise(((t,o)=>{const i=this.db.transaction([this.tableName],"readwrite").objectStore(this.tableName).delete(e);i.onsuccess=()=>{t()},i.onerror=e=>{o(e.target.error)}}))}))}updateRecord(e){return s(this,void 0,void 0,(function*(){if(!this.db)throw new Error("数据库未初始化。");return new Promise(((t,o)=>{const i=this.db.transaction([this.tableName],"readwrite").objectStore(this.tableName).put(e);i.onsuccess=()=>{t()},i.onerror=e=>{o(e.target.error)}}))}))}getRecord(e){return s(this,void 0,void 0,(function*(){if(!this.db)throw new Error("数据库未初始化。");return new Promise(((t,o)=>{const i=this.db.transaction([this.tableName],"readonly").objectStore(this.tableName).get(e);i.onsuccess=()=>{t(i.result)},i.onerror=e=>{o(e.target.error)}}))}))}getAllRecords(){return s(this,void 0,void 0,(function*(){if(!this.db)throw new Error("数据库未初始化。");return new Promise(((e,t)=>{const o=this.db.transaction([this.tableName],"readonly").objectStore(this.tableName).getAll();o.onsuccess=()=>{e(o.result)},o.onerror=e=>{t(e.target.error)}}))}))}}W.instance=null,function(e){e[e.FATAL=0]="FATAL",e[e.ERROR=1]="ERROR",e[e.WARN=2]="WARN",e[e.INFO=3]="INFO",e[e.DEBUG=4]="DEBUG",e[e.TRACE=5]="TRACE"}(J||(J={}));const X={databaseName:"GODB",tableName:"go-log",keyPath:"time"};class K{constructor(){this.logLevel=J.INFO,this.indexedDBInstance=W.getInstance(X);try{this.indexedDBInstance.init(),console.log("IndexedDB 初始化成功。")}catch(e){console.error("初始化 IndexedDB 时出错:",e)}}static getInstance(){return K.instance||(K.instance=new K),K.instance}setLogLevel(e){this.logLevel=e}getColor(e){switch(e){case J.FATAL:return"[31;1m";case J.ERROR:return"[31m";case J.WARN:return"[33m";case J.INFO:return"[32m";case J.DEBUG:return"[36m";case J.TRACE:return"[34m";default:return"[0m"}}log(e,t){if(t<=this.logLevel){const o=(new Date).toISOString(),i=`[${o}] [${J[t]}]`,r=this.getColor(t);if(null===window||void 0===window?void 0:window.goDev)console.log(`${r}${i} ${e}[0m`);else{let t=N("anov-go-userInfo"),a=N("anov-go-proid"),n=` [操作人:${null==t?void 0:t.userName} 项目ID:${a}] `;const s={time:o,value:`${e}`};try{this.indexedDBInstance.addRecord(s)}catch(e){console.error("添加记录时出错:",e)}console.log(`${r}${i} ${n} ${e}[0m`)}}}fatal(e){this.log(e,J.FATAL)}error(e){this.log(e,J.ERROR)}warn(e){this.log(e,J.WARN)}info(e){this.log(e,J.INFO)}debug(e){this.log(e,J.DEBUG)}trace(e){this.log(e,J.TRACE)}}const Q=K.getInstance(),Y=(e,t)=>"string"!=typeof e?Promise.reject(new Error("URL should be a string")):c(e,t),Z=c();let ee=c();function te(e,o="get",i={},r={},a){return s(this,void 0,void 0,(function*(){try{const n={method:_[o],url:e,headers:r,timeout:d};["post","put"].includes(o.toLowerCase())?n.data=t.cloneDeep(i):n.params=t.cloneDeep(i),a&&(n.headers.sponsor=a);return/.json$/.test(e)?function(e){return s(this,void 0,void 0,(function*(){try{return(yield Z({method:"get",url:e})).data}catch(e){throw console.error("JSON 数据请求:",e),e}}))}(e):function(e){return s(this,void 0,void 0,(function*(){try{return{code:2e4,data:(yield Z(e)).data}}catch(e){throw console.error("请求数据发生错误-Error:",e),e}}))}(n)}catch(e){throw console.error("获取数据:Error:",e),e}}))}function oe(e,t,o,i,r){return s(this,void 0,void 0,(function*(){try{const a=window.anUrl||"",n=a+(window.agentPath||"/ds/v1/api-proxy/v1/query"),s=b(o,!0);return yield Z({url:n,method:"post",headers:{"Content-Type":"application/json;charset=UTF-8",sponsor:r||""},data:{body:"post"===e?s:void 0,headers:w(i)?b(i,!0):i,method:e,url:t}})}catch(e){throw console.error("代理请求数据:Error12:",e),e}}))}function ie(e,t,o,i,r,a){return s(this,void 0,void 0,(function*(){return r?oe(t,e,o,i,a):te(e,t,o,i,a)}))}function re(e,t="",o){var i,r,a,n;const s=`${null!==(r=null===(i=null===window||void 0===window?void 0:window.BaseUrl)||void 0===i?void 0:i.replace("/management",""))&&void 0!==r?r:""}/ds/data-engine/v1/${e}/zb-query?${`token=${(null===(a=ge("YZH_EXCHANGE_TOKEN"))||void 0===a?void 0:a.YZH_EXCHANGE_TOKEN)||(null===(n=null===window||void 0===window?void 0:window.yzhAuth)||void 0===n?void 0:n.getToken())}&passid=${null===window||void 0===window?void 0:window.gdPassid}`}${(null===window||void 0===window?void 0:window.BASE_RELEASE)?"&preview=1":""}`;let d={};try{d=t?JSON.parse(t):{}}catch(e){d=t||{}}return Z({method:"POST",url:s,data:{headers:o,param:d},timeout:l})}function ae(e="",t){const o=`${null===window||void 0===window?void 0:window.BaseUrl}/ds/v1/data-views/query`;let i={};try{i=e?JSON.parse(e):{}}catch(t){i=e||{}}return Z({method:"POST",url:o,data:{headers:t,param:i},timeout:l})}const ne=(e,t)=>s(void 0,void 0,void 0,(function*(){const o=window.BaseUrl,{dateType:i="",endPeriod:r="",metricsName:a=e,startPeriod:n=""}=t;return ee({method:"GET",url:`${o}ds/v1/metrics/v1/data-alarm?dateType=${i}&endPeriod=${r}&metricsName=${a}&startPeriod=${n}`,timeout:l})})),se=(e,t,o)=>s(void 0,void 0,void 0,(function*(){var i;const r=(null===(i=window.BaseUrl)||void 0===i?void 0:i.replace("/management",""))||"";t.newEncryption=!0;const a={staticFile:{method:"get",params:t,url:`${r}/ds/v1/file/v1/${e}/query`},datasource:{method:"post",url:`${r}/ds/v1/database/v1/${e}/query`,data:Object.assign({},t)}}[o];if(!a)throw new Error("Invalid data type provided");return Z(Object.assign({timeout:l},a))})),le=e=>new Promise(((t,o)=>{let i;i=e.originData&&Object.keys(e.originData).length?e.originData:e.data,void 0!==i?t({data:i}):o("Failed to retrieve cdata")})),de=(e,t,o)=>{try{switch(t){case"api":{let t=be(e,o);return{requestType:t.requestType,url:t.url,params:t.params,headers:t.headers,agency:t.agency}}case"static":return{data:e};case"datasource":{const t=ye(e.inputSql,o);return{dsName:e.dsName,dsType:"1",sql:U(t),filter:e.sqlFilter}}case"staticFile":return{dsName:e.dsName,dsType:e.dsType,sql:""};case"indicator":return{zbId:e.zbId,params:ye(e.params,o),headers:ye(e.headers,o)};case"dataSet":return{params:ye(e.params,o),headers:ye(e.headers,o)};case"indicatorCQ":return{zbName:e.zbName,params:ye(e.params,o)};case"packData":return{};default:throw new Error("Invalid type")}}catch(t){console.log("准备请求数据发生错误",t,e)}},ce=(e,t,o)=>s(void 0,void 0,void 0,(function*(){try{switch(t){case"api":return yield ie(e.url,e.requestType,e.params,e.headers,e.agency,o);case"static":return yield le(e.data);case"datasource":return yield se(e.dsName,{dsType:e.dsType,sql:e.sql,filter:e.filter},"datasource");case"staticFile":return yield se(e.dsName,{dsType:e.dsType,sql:e.sql},"staticFile");case"indicator":return yield re(e.zbId,e.params,e.headers);case"dataSet":return yield ae(e.params,e.headers);case"indicatorCQ":return yield ne(e.zbName,e.params);case"packData":return{};default:throw new Error("Invalid type")}}catch(e){return console.warn(e,"执行请求并获取数据发生错误"),yield new Promise(((e,t)=>{e({error:!0})}))}})),ue=(e,t,o,i=[],r=!1)=>s(void 0,void 0,void 0,(function*(){const a=t||e.tmpData.source.dataType;if(!a)return console.warn(`fetdata error on fetchDataByType', dataType is ${a}`),new Promise(((e,t)=>{e({error:!0,data:null,msg:`dataType is ${a}`})}));const n=e.tmpData.source["indicatorCQ"==a?"indicator":a];if("globalData"===a){const e=i.find((e=>e.key===n.id||e.key===n.key)),t=N(n.id);if(t&&!r)return t.data;if(e){let t=yield he(e,o),i={key:n.id,data:t};return D(n.id,i),t}return}const s=de(n,a,o),l=yield ce(s,a,e.cid?e.cid:"");return(null==l?void 0:l.data)?l.data:l})),he=(e,t)=>s(void 0,void 0,void 0,(function*(){let o=Object.assign({},{tmpData:{source:e.value}});const i=o.tmpData.source.type,r=o.tmpData.source[i],a=de(r,i,t),n=yield ce(a,i);return yield pe(n.data,o,!0,t)})),pe=(e,o,i=!0,r)=>s(void 0,void 0,void 0,(function*(){try{const{converse:a,mapFields:n}=o.tmpData.source;return a&&a.use&&i?yield new Promise(((o,i)=>{const n=function(e,o,i,r,a){return s(this,void 0,void 0,(function*(){let i,a=e,{use:n,data:s}=t.cloneDeep(o);if(n)for(let e=0;e<s.length;e++)if(s[e].use){let o=s[e].dependVars,n={};r&&n&&o&&o.length&&o.map((e=>{let o=t.cloneDeep(r).filter((t=>{let o=t.mapField==e;return o&&(n[e]=t.value),o}));o&&0!=o.length||(n[e]="")})),i=yield H(s[e].code,a,n,s[e].mode?s[e].mode:"worker"),a=i.data}return a}))}(t.cloneDeep(e),a,0,r);o(n)})):yield new Promise(((t,o)=>{t(e)}))}catch(t){return console.error("执行过滤器发生错误:"+t),yield new Promise(((t,o)=>{t(e)}))}})),me=(e,t,o)=>{const{source:i}=e.tmpData,r=i.type;o?("static"===r&&i[r]&&(i[r].originData=o),"indicatorCQ"===r?i.indicator.data=t:i[r].data=t):"indicatorCQ"===r?i.indicator.data=t:i[r].data=t,e.source=t},fe=(e,t,o=[],i,r,a)=>s(void 0,void 0,void 0,(function*(){try{let n=e.tmpData.source.type,s=yield ue(e,n,o,i,a||!1);if(null==s||!s)return r&&r({error:!0}),Promise.resolve({error:!0});let l=yield pe(s,e,t,o);return me(e,l),r&&r(l),(null==e?void 0:e.cid)&&P(e.cid),Promise.resolve(l)}catch(t){return r&&r(t),Q.error("Error in updateComData"),console.error("Error in updateComData:",t,e),Promise.reject(t)}})),ge=e=>{const t={};if(e&&e.includes("?")){const o=e.split("?")[1].split("&");for(let e of o){const[o,i]=e.split("=").map(decodeURIComponent);t[o]=i}}return t},ve=e=>{try{return(null==e?void 0:e.value)&&"string"==typeof e.value?JSON.parse(e.value):"string"==typeof e?JSON.parse(e):e}catch(t){return e}},ye=(e,t)=>{if(!t)return ve(e);if("string"==typeof e){if(""===e.trim())return"";try{if("string"!=typeof JSON.parse(e))return ye(JSON.parse(e),t);{let o=e.replace(/@(\w+)|{{(\w+)}}/g,((e,o,i)=>{const r=o||i,a=t.find((e=>e.mapField===r));return a?a.value||a.originalValue||"":e}));return ve(o)}}catch(o){let i=e.replace(/@(\w+)|{{(\w+)}}/g,((e,o,i)=>{const r=o||i,a=t.find((e=>e.mapField===r));return a?a.value:e}));return ve(i)}}else{if(Array.isArray(e))return e.map((e=>ye(e,t)));if("object"==typeof e&&null!==e){const o={};for(let i in e)o[i]=ye(e[i],t);return ve(o)}}return ve(e)},be=(e,t)=>{const o=e.agency,i=e,{url:r=null,headers:a,params:n,requestType:s}=i,l=r?ye(r,t):void 0,d=a&&a.use?ye(a.value,t):{};return{url:l,requestType:s,params:n?ye(n,t):{},headers:d,agency:o}},we=(e,t,o,i,r)=>s(void 0,void 0,void 0,(function*(){if(e&&e.length)for(const a of e){O(t,a.value,o)&&(yield fe({tmpData:{source:{type:"globalData",globalData:{id:a.key}}}},!0,o,e,(e=>{console.log("数据更新成功-变量改变全局数据跟新")}),!0),C(i,(t=>{var i,n,s;if("globalData"===(null===(n=null===(i=null==t?void 0:t.tmpData)||void 0===i?void 0:i.source)||void 0===n?void 0:n.type)){(null===(s=null==t?void 0:t.tmpData)||void 0===s?void 0:s.source.globalData).id===a.key&&fe(t,!0,o,e,(e=>{r(t,e)}),!1)}})))}})),De=(e,t,o,i,r)=>s(void 0,void 0,void 0,(function*(){e&&(yield fe({tmpData:{source:{type:"globalData",globalData:{id:e.key}}}},!0,t,o,(e=>{console.log("数据更新成功-数据源编辑")}),!0),C(i,(i=>{var a,n,s;if("globalData"===(null===(n=null===(a=null==i?void 0:i.tmpData)||void 0===a?void 0:a.source)||void 0===n?void 0:n.type)){(null===(s=null==i?void 0:i.tmpData)||void 0===s?void 0:s.source.globalData).id===e.key&&fe(i,!0,t,o,(e=>{r(i,e)}),!1)}})))}));class Ne{constructor(e,t){this.isUpdating=!1,this.des=e.des,this.field=e.field,this.id=e.id,this.key=e.key,this.mapping=e.mapping,this.mapField=e.mapField,this.type=e.type,this.originalValue=e.originalValue,this.model=(null==e?void 0:e.model)?null==e?void 0:e.model:1,this.converter=e.converter,this.converterCode=e.converterCode,this.fork=e.fork,this.delayUpdate=!!(null==e?void 0:e.delayUpdate),t&&(this.globalVariables=t),e.fork&&(this.model=5,this.forkValue=e.forkValue,this.originalValue=this.getForkedValue())}get value(){if(this.fork&&(this.originalValue=this.getForkedValue()),this.converter&&this.converterCode){let e=[];return E(this.converterCode,this.originalValue,e)}return this.originalValue}togglePropertyState(e){let t=Object.prototype.hasOwnProperty.call(this,e);this[e]=!t||!e}getForkedValue(){if(this.forkValue&&Array.isArray(this.forkValue))return this.forkValue.map((e=>{const t=this.globalVariables.get(e);return t?t.value:null}));if(this.forkValue){const e=this.globalVariables.get(this.forkValue);return e?e.value:null}return null}updateValue(e,t){var i;const r=Object.assign({},this,e);this.des=r.des,this.field=r.field,this.mapping=r.mapping,this.type=r.type,this.originalValue=r.originalValue,this.converter=r.converter,this.converterCode=r.converterCode,this.fork=r.fork,this.delayUpdate=null==r?void 0:r.delayUpdate,this.model=null==r?void 0:r.model,e.id&&(this.id?"string"==typeof this.id?e.id instanceof Array?this.id=o([this.id,...e.id]):this.id=[this.id,e.id]:this.id instanceof Array&&(e.id instanceof Array?this.id=o([...this.id,...e.id]):this.id=o([...this.id,e.id])):this.id=e.id),e.fork&&(this.model=5,this.forkValue=null!==(i=e.forkValue)&&void 0!==i?i:this.forkValue,this.originalValue=this.getForkedValue()),t&&t(this)}updateWidthOriginalValue(e,t){var o;this.originalValue=e,this.fork&&(this.forkValue=null!==(o=this.forkValue)&&void 0!==o?o:this.forkValue,this.originalValue=this.getForkedValue()),t&&t(this)}renew(e){e&&e(this)}static create(e,t){return new Ne(e,t)}}class ke{constructor(){this.variables=new Map,this.globalObservers=[],this.url=window.location.search,this.list=[]}clearVars(){this.list=[],this.variables.clear()}togglePropertyState(e,t,o){try{let i=this.getVariable(e);if(!i)throw new Error("没有找到相应的变量!");i.togglePropertyState(t),this.addToObjectArray(this.list,i),o&&o()}catch(e){console.error(e)}}static getInstance(){return ke.instance||(ke.instance=new ke),ke.instance}getFullUrl(){this.url=window.location.search}getAllUrlParams(){const e=new URLSearchParams(window.location.search),t={};for(const[o,i]of e.entries())t[o]=i;return t}delVariable(e,t){this.variables.delete(e),this.list=this.list.filter((t=>t.mapField!=e)),t&&t()}addUrlParamsToGlobalVars(){this.getFullUrl();let e=this.getAllUrlParams(),t=Object.keys(e),o=[];for(const i of t)o.push({mapField:i,originalValue:e[i],model:4});if(o.length)for(const e of o)this.addVariable(e)}addVariables(e){Array.isArray(e)?e.map(((e,t)=>{this.addVariable(e)})):this.addVariable(e),this.addUrlParamsToGlobalVars()}addVariable(e,t){if(!e||!(null==e?void 0:e.mapField))return console.error(e+"参数不合法!"),!1;if(this.isVariableNameExist(e.mapField)){let o=this.getVariable(e.mapField);return this.sameValue(o,e)?o:(this.editVariable(e,t),!1)}const o=Ne.create(e,this.variables);return this.variables.set(o.mapField,o),this.addToObjectArray(this.list,o),t&&t(o),this.notifyGlobalObservers(o),o}toJSON(e){try{return!!e&&JSON.stringify(e)}catch(e){return!1}}sameValue(e,t){if(e.mapfield!==t.mapfield)return!1;for(const o in t)if(!(["mapfield","field","key","value","name","globalVariables"].includes(o)||o in e&&e[o]==t[o]))return!1;return!0}creatVarJson(e){const{des:t,field:o,id:i,key:r,mapping:a,mapField:n,type:s,value:l,originalValue:d,model:c,converter:u,converterCode:h,fork:p,forkValue:m,update:f,delayUpdate:g}=e,v={};return void 0!==t&&(v.des=t),void 0!==o&&(v.field=o),void 0!==i&&(v.id=i),void 0!==r&&(v.key=r),void 0!==a&&(v.mapping=a),void 0!==n&&(v.mapField=n),void 0!==s&&(v.type=s),void 0!==l&&(v.value=l),void 0!==d&&(v.originalValue=d),void 0!==c&&(v.model=c),void 0!==u&&(v.converter=u),void 0!==h&&(v.converterCode=h),void 0!==p&&(v.fork=p),void 0!==m&&(v.forkValue=m),void 0!==f&&(v.update=f),void 0!==g&&(v.delayUpdate=g),v}addToObjectArray(e,t){let o=!1;for(let i=0;i<e.length;i++)if(e[i].mapField==t.mapField){e[i]=this.creatVarJson(t),o=!0;break}o||e.push(t)}editVariable(e,t){const o=this.getVariable(e.mapField);if(o&&this.isVariableNameExist(e.mapField)){if(this.sameValue(o,e))return}const i=e=>{if(!e.isUpdating){e.isUpdating=!0,this.notifyGlobalObservers(e);this.isMapFieldInForkValues(e.mapField).forEach((e=>{let t=this.getVariable(e.mapField);t&&t.renew((e=>{this.addToObjectArray(this.list,e),this.notifyGlobalObservers(e)}))})),this.addToObjectArray(this.list,e),t&&t(e),e.isUpdating=!1}};o?o.updateValue(e,i):this.addVariable(e,i)}getForkList(e){let t=this.isMapFieldInForkValues(e);return t||[]}editVariableForValue(e,t,o){const i=this.getVariable(e),r=e=>{if(!e.isUpdating){e.isUpdating=!0,this.notifyGlobalObservers(e);this.isMapFieldInForkValues(e.mapField).forEach((e=>{let t=this.getVariable(e.mapField);t&&t.renew((e=>{this.addToObjectArray(this.list,e),this.notifyGlobalObservers(e)}))})),this.addToObjectArray(this.list,e),o&&o(e),e.isUpdating=!1}};i&&i.updateWidthOriginalValue(t,r)}isMapFieldInForkValues(e){return this.getAllVariables().filter((e=>e.fork&&e.forkValue)).filter((t=>t.forkValue==e||Array.from(t.forkValue).includes(e)))}isVariableNameExist(e){return this.variables.has(e)}checkExist(e,t){if("string"==typeof e&&this.isVariableNameExist(e)){let o=this.getVariable(e);return t==o.id&&!o.id.includes(t)&&[{key:e}]}if(Array.isArray(e)){const o=e.filter((e=>{let o=this.getVariable(e);return this.isVariableNameExist(e)&&t!=o.id&&!(o.id&&o.id.includes(t))})).map((e=>({key:e})));return!!o.length&&o}return!1}getVariable(e){return this.variables.get(e)}getVariableForId(e){var o;let i=[];for(const[,t]of this.variables)(t.id===e||(null===(o=t.id)||void 0===o?void 0:o.includes(e)))&&i.push(t);return t.uniq(i)}getAllVariables(e=!1){return this.addUrlParamsToGlobalVars(),e?(this.list=Array.from(this.variables.values()),this.list):[...this.list]}restoreVariables(e){e.forEach((e=>{this.addVariable(e)}))}registerGlobalObserver(e){this.globalObservers.push(e)}notifyGlobalObservers(e){this.globalObservers.forEach((t=>{t.update(e)}))}}ke.instance=null;const Ae=ke.getInstance(),Ce=(e,t)=>Array.isArray(t)?t.some((t=>e&&(void 0!==e[t]||e.hasOwnProperty(t)))):"string"==typeof t&&(e&&(void 0!==e[t]||e.hasOwnProperty(t))),xe=(e,t,o,i)=>{const r=((e,t,o,i)=>{var r;let a;if(Ce(e,null==t?void 0:t.field)||Ce(e,null==t?void 0:t.forkValue))a=e[null==t?void 0:t.field]||"";else if(Ce(e.data,null==t?void 0:t.field)||Ce(e.data,null==t?void 0:t.forkValue))a=e.data[null==t?void 0:t.field]||"";else{const e=I(o,i),n=(null===(r=null==e?void 0:e.tmpData)||void 0===r?void 0:r.actions)||[];for(const e of n){const o=e.vars.find((e=>(null==e?void 0:e.mapField)===(null==t?void 0:t.mapField)));if(o){a=o.value;break}}}return a})(e,t,o,i);return void 0!==r?r:t.value},Se=(e,t,o,i,r,a,n,s,l)=>{var d;switch(e.type){case"link":let c=ye(e.link,a);window.open(c,e.target);break;case"page":if(null===(d=null==e?void 0:e.params)||void 0===d?void 0:d.length)for(let t=0;t<e.params.length;t++){const o=e.params[t],i=a.find((e=>e.mapField==o.mapField));i&&(o.value=i.value)}l&&l(e);break;case"dynamic":((e,t,o,i,r)=>{const a=e.dynamic||[];for(const n of a){if(e.id!==t.cid)continue;const a=I(o,n.pid);a&&(a.activeDynamic=n.name,a.isShow=n.visible||!i||e.index===t.index-1,r({cid:a.cid,flag:n.visible}))}})(e,t,o,i,r);break;case"toggle":((e,t,o,i,r)=>{const a=e.children||[];for(const o of a){const a=o.visible&&(!i||e.index===t.index-1);r({cid:o.cid,flag:a})}})(e,t,0,i,r);break;case"update":((e,t,o,i,r)=>{const a=e.children||[];for(const e of a){const a=I(t,e.cid);a&&fe(a,!0,o,i,(e=>{r({cid:a.cid,data:e})}))}})(e,o,a,n,s)}},Oe=(e,o,i,r,a,n,s,l,d,c)=>{const{cid:u,actions:h,index:p}=a,{eventName:m,mode:f}=h,g=2===f;((e,o,i,r,a,n)=>{let s=Ae.getVariableForId(o.cid);if(null==s?void 0:s.length)for(const l of s)if(l.type==e){let e=xe(o,l,i,r);Ae.editVariableForValue(l.mapField,e,(()=>{let e=a[l.mapField]||[],o=Ae.getForkList(l.mapField);if(o)for(const i of o){let o=a[i.mapField];e=t.concat(e,o)}n&&n(l,t.uniq(e))}))}})(m,a,r,u,i,((e,t)=>{if(we(d,e.mapFile,Ae.getAllVariables(),r,((e,t)=>{s({cid:e.cid,data:t})})),null==t?void 0:t.length)for(const o of t){e.eventSourceId=o;const t=I(r,o);!(null==e?void 0:e.delayUpdate)&&t&&fe(t,!0,Ae.getAllVariables(),d,(e=>{s({cid:t.cid,data:e})}))}}));const v=((e,t,o,i,r)=>e.filter((e=>e.id===t&&e.eventType===o&&(!r||parseInt(e.index||"0")+1===parseInt(i||"0")))))(e,u,m,p,g);for(const e of v)Se(e,a,r,g,n,Ae.getAllVariables(),d,s,l)};function Ie(e,t){const o={};for(const i in e)if(e.hasOwnProperty(i))if("object"!=typeof e[i]||null===e[i]||Array.isArray(e[i]))Array.isArray(e[i])?JSON.stringify(e[i])!==JSON.stringify(t[i])&&(o[i]=t[i]):e[i]!==t[i]&&(o[i]=t[i]);else{const r=Ie(e[i],t[i]);null!==r&&Object.keys(r).length>0&&(o[i]=r)}return Object.keys(o).length>0?o:null}function Te(e,t){const o=Object.assign({},e);for(const e in t)t.hasOwnProperty(e)&&("object"!=typeof t[e]||null===t[e]||Array.isArray(t[e])?o[e]=t[e]:o[e]=Te(o[e],t[e]));return o}const Ve=(e,t={})=>{let o={},i={type:"static",converse:{use:!1,data:[]},static:{data:e},api:{requestType:"get",url:"",headers:{use:!1,value:""},params:"",agency:!1,cookie:!0,autoUpdate:{open:!1,time:10},data:""}};return Object.assign(o,i,t),o},Ee=(e,o)=>{let{option:i,actions:r,data:a,optionDes:n,actionsDes:s,source:l,theme:d}=((e,o)=>{let{option:i,actions:r,data:a,optionDes:n,actionsDes:s,source:l,theme:d}=t.cloneDeep(o[e]);return{option:i,actions:r,data:a,optionDes:n,actionsDes:s,source:l,theme:d}})(e,o);return{iconClass:null,isAssembly:null,source:a,cid:(Math.random().toString().substr(3,10)+Date.now()).toString(),isLock:!1,isShow:!0,tmpData:{option:i,source:Ve(a,l),actions:r},baseData:Pe(),dynamic:null,filePath:"",origin:"anov-ui",name:"",componentType:"",viewComName:e,optionComName:"AnOptionPanel",dataComName:"AnSourcePanel",eventComName:"AnActionsPanel",assemblyDeveloper:"",devEmail:"",version:"",devDept:""}},Fe=(e,o,i)=>{let r=Ee(e,o);return i?t.merge(r,i):r},Pe=e=>{let t={left:0,top:0,width:100,height:100,angle:0,penetrate:0,opacity:100,perspective:100,rotateX:0,rotateY:0,rotateZ:0,transformOriginX:"center",transformOriginY:"center",transformSwitch:!1};return e?Object.assign(t,e):t};class je{constructor(e,t,o){this.theme=null,this.plant=null,this.list=[],this.titleHeqadeHeight=70,this.clearance=3,this.checkComponentIntersection=(e,t,o=10)=>{const i=e.left,r=e.left+e.width,a=e.top,n=e.top+e.height,s=t.left,l=t.left+t.width,d=t.top,c=t.top+t.height,u=i<l&&r>s&&a<c&&n>d,h=Math.abs(e.left+e.width/2-(t.left+t.width/2)),p=Math.abs(e.top+e.height/2-(t.top+t.height/2));return u||h<o&&p<o},this.calculateCombinedComponent=e=>{if(0===e.length)return{left:0,top:0,width:0,height:0};let t=e[0].left,o=e[0].top,i=e[0].left+e[0].width,r=e[0].top+e[0].height;for(let a=1;a<e.length;a++){const n=e[a];t=Math.min(t,n.left),o=Math.min(o,n.top),i=Math.max(i,n.left+n.width),r=Math.max(r,n.top+n.height)}return{left:t,top:o,width:i-t,height:r-o}},this.getAnTextNormaltText=e=>{var t,o;try{return null===(o=null===(t=null==e?void 0:e.tmpData)||void 0===t?void 0:t.option)||void 0===o?void 0:o.text}catch(e){return console.error("配置优化(ConfigOptimizer):",e),""}},this.initProp(e),this.upgradePlant(),this.staticComponentData=t,this.upgradeHeaderComponent(),o&&Object.assign(this,o)}isStringOrObject(e){return"string"==typeof e?"string":"object"==typeof e&&null!==e&&"object"}initProp(e){try{let t,o=this.isStringOrObject(e);if(o&&"string"===o)t=JSON.parse(e);else{if(!o||"object"!==o)throw new Error(`initProp fn error :-- 传入参数${e}不合法!`);t=e}if(t){this.originData=t;const{theme:e,plant:o,list:i}=t;this.theme=e,this.plant=o,this.list=i,this.filterFileGroup()}}catch(e){console.error("配置优化(ConfigOptimizer):",e)}}upgradePlant(){this.plant&&(this.plant.option.bg={type:1,code:"70942ec525344c96aa32b81b2c9155f6",path:"/anov-prod/resources/page/png/bg22 科技星球背景.png",thumb:"/anov-prod/resources/page/thumbnail/1e48f8fb26ec4edfb1a0f499627e84fc.png"})}areComponentsIntersecting(e,t){let o=e.baseData,i=t.baseData;const r=Math.max(0,Math.min(o.left+o.width,i.left+i.width)-Math.max(o.left,i.left)),a=Math.max(0,Math.min(o.top+o.height,i.top+i.height)-Math.max(o.top,i.top));return r>0&&a>0}filterFileGroup(){this.list=t.cloneDeep(this.list).map((e=>{var t,o;if(1===(null===(t=null==e?void 0:e.children)||void 0===t?void 0:t.length)&&!(null===(o=null==e?void 0:e.children[0])||void 0===o?void 0:o.children)){const t=e.children[0],{left:o,top:i}=e.baseData;return t.baseData.left=o,t.baseData.top=i,t}return e}))}getText(e,t,o){const i=document.createElement("canvas").getContext("2d");if(!i)throw new Error("Failed to get 2D context from canvas.");i.font=`${o}px ${t}`;return i.measureText(e).width}calculateMaxWidths(e){const t=Math.min(...e.map((e=>e.width))),o=[];let i=[],r=e[0].width;for(const a of e){const e=a.width;Math.abs(e-r)<=t?i.push(e):(i.length>0&&o.push(i),i=[e]),r=e}i.length>0&&o.push(i);const a=[];for(const e of o){const t=Math.max(...e);a.push(t)}return a}findClosestValue(e,t){let o=t[0],i=Math.abs(e-o);for(const r of t){const t=Math.abs(e-r);t<i&&(i=t,o=r)}return o}adjustHeightAndTop(e,t){const o=t-e.height;return Object.assign(Object.assign({},e),{height:t,top:e.top-o/2})}findNearestComponent(e,o,i){let r=null,a=1/0;o.tmpData.option.textNormal.text;try{const n=t.cloneDeep(e).sort(((e,t)=>e.baseData.top-t.baseData.top)).sort(((e,t)=>e.baseData.left-t.baseData.left)).filter((e=>!(e.cid===o.cid||"AnTextNormal"===e.viewComName||i&&i.includes(e.cid)))),s=t.cloneDeep(o).baseData;s.top,s.height;for(const e of n){const t=e.baseData;t.top,t.height;if(s.left<t.left+t.width&&s.left+s.width>t.left){const o=t.top-s.top;o<a&&o<100&&(a=o,r=e)}}}catch(e){console.error("配置优化(ConfigOptimizer)- findNearestComponent :",e)}return r}findNearestComponentForPoint(e,t,o){let i=null,r=1/0;t.tmpData.option.textNormal.text;try{const a=e.sort(((e,t)=>e.baseData.top-t.baseData.top)).sort(((e,t)=>e.baseData.left-t.baseData.left)).filter((e=>!(e.cid===t.cid||"AnTextNormal"===e.viewComName||o&&o.includes(e.cid)))),n=t.baseData;n.top,n.height;for(const e of a){const t=e.baseData;let o=this.getDistance(n.left,n.top+n.height,t.left,t.top);o<r&&o<n.width&&(r=o,i=e)}}catch(e){console.error("配置优化(ConfigOptimizer)- findNearestComponent :",e)}return i}findNearestComponentForTitlePoint(e,t,o){let i=null,r=1/0;t.tmpData.option.textNormal.text;try{const a=e.sort(((e,t)=>e.baseData.top-t.baseData.top)).sort(((e,t)=>e.baseData.left-t.baseData.left)).filter((e=>!(e.cid===t.cid||"AnTextNormal"===e.viewComName||o&&o.includes(e.cid)))),n=t.baseData;n.top,n.height;for(const e of a){const t=e.baseData;let o=this.getDistance(n.left,n.top+n.height,t.left,t.top);o<r&&o<n.width&&t.top-n.top>100&&(r=o,i=e)}}catch(e){console.error("配置优化(ConfigOptimizer)- findNearestComponent :",e)}return i}findNearestTitleForPoint(e,t,o){let i=null,r=1/0;t.tmpData.option.textNormal.text;try{const a=e.sort(((e,t)=>e.baseData.top-t.baseData.top)).sort(((e,t)=>e.baseData.left-t.baseData.left)).filter((e=>!(e.cid===t.cid||"AnTextNormal"===e.viewComName||o&&o.includes(e.cid)))),n=t.baseData;n.top,n.height;for(const e of a){const t=e.baseData;let o=t.top-n.top;o<r&&o<n.width&&t.top-n.top>100&&(r=o,i=e)}}catch(e){console.error("配置优化(ConfigOptimizer)- findNearestComponent :",e)}return i}getDistance(e,t,o,i){return Math.sqrt(Math.pow(o-e,2)+Math.pow(i-t,2))}findNearestComponent2(e,o,i){let r=null,a=1/0,n=t.cloneDeep(e).sort(((e,t)=>e.baseData.top-t.baseData.top));try{const e=n.filter((e=>!(e.cid===o.cid||"AnTextNormal"===e.viewComName||i&&i.includes(e.cid)))),s=t.cloneDeep(o).baseData,l=s.top+s.height;for(const t of e){const e=t.baseData,o=e.top+e.height;if(s.left<e.left+e.width&&s.left+s.width>e.left){const e=o-l;e>=0&&e<a&&(a=e,r=t)}}}catch(e){console.error("配置优化(ConfigOptimizer)- findNearestComponent :",e)}return r}verticalDistance(e,t){e.left,e.width;const o=e.top+e.height,i=(t.left,t.width,t.top);return Math.abs(o-i)}extractAmount(e){const t=e.match(/(\d{1,3}(?:,\d{3})*)(\D+)/);if(t){const e=t[1].replace(/,/g,"");return[parseInt(e,10),t[2].trim()]}return[!1,!1]}getAnTextNormal(){return this.list.filter((e=>"AnTextNormal"==e.viewComName))}getAnDeckTitle3(){return this.list.filter((e=>"AnDeckTitle3"==e.viewComName)).sort(((e,t)=>e.baseData.left-t.baseData.left))}judgeAnOdometer(){let e=this.getAnTextNormal().sort(((e,t)=>e.baseData.left-t.baseData.left)),t=[],o=new Set;for(const i of e){if(o.has(i.cid))continue;let r=[];for(const t of e){if(!o.has(t.cid)&&i.cid!=t.cid){this.checkComponentIntersection(i.baseData,t.baseData)&&(o.add(t.cid),o.add(i.cid),r.push(t))}}t.push([i,...r])}let i=[];for(const e of t)for(const t of e){let o=this.getAnTextNormaltText(t);this.extractAmount(o).every((e=>e))&&i.push(e)}return i}createAnOdometer(){var e,o;let i=this.judgeAnOdometer();for(const r of i){let i,a,n,s=this.calculateCombinedComponent(r.map((e=>e.baseData)));for(const e of r){let o=this.getAnTextNormaltText(e),r=this.extractAmount(o);r.every((e=>!e))&&(i=o),r.every((e=>e))&&(a=r[0],n=r[1]),t.remove(this.list,(t=>t.cid==e.cid))}let l=Fe("AnIndicatorNormal",this.staticComponentData,t.cloneDeep({baseData:s}));(null===(o=null===(e=null==l?void 0:l.tmpData)||void 0===e?void 0:e.source)||void 0===o?void 0:o.static)&&(l.tmpData.source.static.data={text:i,num:a,unit:n},l.tmpData.source.static.originData={text:i,num:a,unit:n}),this.list.push(l)}}upgradeHeaderComponent(){for(let e=0;e<this.list.length;e++){const t=this.list[e];"AnDeckHeader3"==t.viewComName&&(t.baseData.left=0,t.baseData.top=0)}}upgradeTitleComponent(){let e=this.getAnDeckTitle3().map((e=>e.baseData)),t=this.calculateMaxWidths(e);for(let e=0;e<this.list.length;e++){const o=this.list[e];if("AnDeckTitle3"==o.viewComName){let e=this.findClosestValue(o.baseData.width,t);o.baseData.width=e>300?e:300,o.baseData=this.adjustHeightAndTop(o.baseData,this.titleHeqadeHeight)}}this.removeErroneousComponents()}containsFractionStructure(e){return/\b\d+\/\d+\b/.test(e)}removeErroneousComponents(){let e=this.getAnDeckTitle3(),t=[];for(let o=0;o<e.length;o++){const i=e[o];let r=i.tmpData.option.textNormal.text;if(this.containsFractionStructure(r))for(let o=0;o<e.length;o++){const r=e[o];if(i.cid!=r.cid){this.areComponentsIntersecting(i,r)&&t.push(i.cid)}}}this.list=this.list.filter((e=>!t.includes(e.cid)))}upgradeGroupComponent(){try{let e=this.getAnDeckTitle3(),t=this.list.filter((e=>"AnDeckTitle3"!=e.viewComName&&"AnDeckHeader3"!=e.viewComName&&"AnTextNormal"!=e.viewComName)),o=[],i=[];for(let r=0;r<e.length;r++){const a=e[r];let n=this.findNearestComponentForPoint(t,a,o);if(n&&n.cid&&o.push(n.cid),n){a.baseData.left=n.baseData.left;let t=this.upgradeComponentHeight(a,e,i);t&&t>=30&&(n.baseData=Object.assign({},n.baseData,{top:a.baseData.top+a.baseData.height+this.clearance}))}}}catch(e){console.error("配置优化(ConfigOptimizer):",e)}}upgradeComponentHeight(e,o,i=[]){const r=e;let a=this.findNearestTitleForPoint(t.cloneDeep(o),r);return a?a.baseData.top-r.baseData.top-this.titleHeqadeHeight:1080-r.baseData.top-this.titleHeqadeHeight}getData(){return this.originData.list=this.list,this.originData.plant=this.plant,this.originData}}const $e=new class{randomNum(e,t){return Math.floor(Math.random()*(t-e+1))+e}generateRandomIntArray(e,t,o,i){const r=[];for(let i=0;i<e;i++){const e=this.randomNum(t,o);r.push(e)}return i&&"asc"===i?r.sort(((e,t)=>e-t)):i&&"desc"===i?r.sort(((e,t)=>t-e)):r}randomString(e,t){const o="abcdefghijklmnopqrstuvwxyz",i=this.randomNum(e,t);let r="";for(let e=0;e<i;e++){const e=Math.floor(26*Math.random());r+=o.charAt(e)}return r}generateRandomNameArray(e,t,o){const i=[];for(let r=0;r<e;r++){const e=this.randomString(t,o);i.push(e)}return i}pick(e,t){const o=void 0!==t?e.filter((e=>e!==t)):e;return o[Math.floor(Math.random()*o.length)]}},Re=()=>{const e=[],t=$e.pick([!0,!1]);let o=$e.randomNum(3,20);const i=$e.pick([null,null,null,{}]);let r=$e.pick(["asc","desc",void 0,void 0,void 0]);for(let a=0;a<$e.randomNum(1,9);a++)e.push({data:$e.generateRandomIntArray(o,0,300,r),type:"line",smooth:t,symbolSize:$e.randomNum(1,10),lineStyle:{width:$e.randomNum(1,4)},areaStyle:i});return{xAxis:{type:"category",show:!1,boundaryGap:!1,data:$e.generateRandomNameArray(o,3,6)},grid:{left:0,top:0,bottom:0,right:0},yAxis:{show:!1,type:"value"},series:e}},Me=(e,t)=>{let o={type:e,show:!1};return"category"===e&&(o.data=$e.generateRandomNameArray(t,3,6)),o},Ue=()=>{const e=[],t=$e.pick([!0,!1]);let o=$e.randomNum(3,20);const i=$e.pick([null,null,null,{}]);let r=$e.pick(["asc","desc",void 0,void 0,void 0]),a=$e.randomNum(1,9),n=$e.pick([!0,!1]);for(let s=0;s<a;s++){let a={data:$e.generateRandomIntArray(o,0,300,r),type:"bar",smooth:t,stack:n,areaStyle:i};e.push(a)}let s=$e.pick(["value","category"]),l=$e.pick(["value","category"],s);return{xAxis:Me(s,o),grid:{left:0,top:0,bottom:0,right:0},yAxis:Me(l,o),series:e}},qe=()=>{const e=[];let t=$e.randomNum(3,20);$e.pick([null,null,null,{}]);let o=$e.pick(["asc","desc",void 0,void 0,void 0]),i=$e.pick([1,2]),r=[$e.pick(["10%","20%","30%","40%","50%","60%","70%","80%"]),$e.pick(["90%","100%"])];return e.push({data:$e.generateRandomIntArray(t,3,20,o),type:"pie",radius:1==i?"100%":r,roseType:1==i?$e.pick(["area",null,null]):null,padAngle:1==i?0:$e.randomNum(1,5),startAngle:1==i?$e.pick([0,180]):0,endAngle:360,label:{show:!1},itemStyle:{borderRadius:3}}),{grid:{left:0,top:0,bottom:0,right:0},series:e}},Le=()=>{const e=[];$e.pick([!0,!1]),$e.randomNum(3,20),$e.pick([null,null,null,{}]),$e.pick(["asc","desc",void 0,void 0,void 0]);for(let t=0;t<$e.randomNum(1,20);t++){let t=$e.randomNum(3,$e.randomNum(3,20)),o=[];for(let e=0;e<t;e++){let e=[];for(let t=0;t<2;t++)e.push($e.randomNum(1,30));o.push(e)}e.push({type:"scatter",symbolSize:$e.randomNum(3,30),data:o})}return{xAxis:{show:!1},grid:{left:0,top:0,bottom:0,right:0},yAxis:{show:!1,type:"value"},series:e}},Be=()=>{const e=[],t=$e.pick(["polygon","circle"]);let o=$e.randomNum(1e4,99999),i=$e.randomNum(3,10),r=[];for(let e=0;e<i;e++)r.push({name:$e.randomString(4,8),max:o});for(let t=0;t<$e.randomNum(2,10);t++)e.push({value:$e.generateRandomIntArray(i,1e4,o),name:$e.randomString(4,8)});return{radar:{shape:t,indicator:r,axisName:{show:!1},radius:"100%"},grid:{left:0,top:0,bottom:0,right:0},series:[{type:"radar",symbol:"none",lineStyle:{width:1},data:e}]}},He=()=>{const e=[];for(let t=0;t<$e.randomNum(4,15);t++)e.push({value:$e.randomNum(1,100),name:$e.randomString(4,8)});return{grid:{left:0,top:0,bottom:0,right:0},series:[{type:"funnel",left:"0%",top:0,bottom:0,width:"100%",min:0,minSize:"0%",maxSize:"100%",label:{show:!1,position:"inside"},sort:$e.pick(["descending","ascending"]),gap:2,lineStyle:{width:1},data:e}]}};let ze=$e.randomNum(5,20);const Ge={width:ze};$e.pick([!0,!1])&&(Ge.color=[[.3,"#67e0e3"],[.7,"#37a2da"],[1,"#fd666d"]]);class _e{constructor(){this.names=["line","bar","pie","scatter","radar","funnel","gauge"]}static getInstance(){return _e.instance||(_e.instance=new _e),_e.instance}createLine(){switch($e.pick(this.names)){case"line":return{type:"line",typeNum:1,option:Re()};case"bar":return{type:"bar",typeNum:2,option:Ue()};case"pie":return{type:"pie",typeNum:3,option:qe()};case"scatter":return{type:"scatter",typeNum:4,option:Le()};case"radar":return{type:"radar",typeNum:5,option:Be()};case"funnel":return{type:"funnel",typeNum:6,option:He()};case"gauge":return{type:"gauge",typeNum:7,option:{grid:{left:0,top:0,bottom:0,right:0},series:[{type:"gauge",radius:"100%",detail:{formatter:"{value}"},progress:{show:$e.pick([!0,!1]),width:ze},axisLine:{lineStyle:Ge},data:[{value:$e.randomNum(1,100),name:"SCORE"}]}]}}}}}_e.instance=null;const Je=_e.getInstance();const We=new class{constructor(){this.directions=["row","row"],this.direction="column",this.splitNumbers=24,this.margin=[0,0]}baseLayout(e){const t=(null==e?void 0:e.maRrows)?null==e?void 0:e.maRrows:this.splitNumbers,o=(null==e?void 0:e.colNum)?null==e?void 0:e.colNum:this.splitNumbers,i=e.wrapWidth/o,r=e.wrapHeight/t;let a=q(this.directions);a&&(this.direction=a);let n=[];if("row"===this.direction){let e=q([3,4]);n=this.simulateRandomSegments(24,4,12,e)}else{let e=q([2,3]);n=this.simulateRandomSegments(24,4,6,e)}let s=[],l=[];if("row"===this.direction){for(let e=0;e<n.length;e++)if(0==e)s.push({x:0,y:0,w:n[e],h:24,i:e,wStep:i,hStep:r});else{let t=s[e-1].x;s.push({x:n[e-1]+t,y:0,w:n[e],h:24,i:e,wStep:i,hStep:r})}let e=q([2,3]),t=this.simulateRandomSegments(24,6,12,e);for(let e=0;e<s.length;e++){const o=s[e];for(let a=0;a<t.length;a++){const n=t[a];l.push({x:o.x,y:n,w:o.w,h:n,i:10*e+a,wStep:i,hStep:r})}}}else{for(let e=0;e<n.length;e++)if(0==e)s.push({x:0,y:0,w:24,h:n[e],i:e,wStep:i,hStep:r});else{let t=s[e-1].y;s.push({x:0,y:n[e-1]+t,w:24,h:n[e],i:e,wStep:i,hStep:r})}for(let e=0;e<s.length;e++){const t=s[e];let o=q([1,2,3,4]),a=this.simulateRandomSegments(24,5,12,o),n=[];for(let o=0;o<a.length;o++){const s=a[o];if(0==o)n.push({x:0,y:t.y,w:s,h:t.h,i:10*e+o,wStep:i,hStep:r}),l.push({x:0,y:t.y,w:s,h:t.h,i:10*e+o,wStep:i,hStep:r});else{let d=n[o-1].x;n.push({x:a[o-1]+d,y:t.y,w:s,h:t.h,i:10*e+o,wStep:i,hStep:r}),l.push({x:a[o-1]+d,y:t.y,w:s,h:t.h,i:10*e+o,wStep:i,hStep:r})}}}}return{layouts:l.map((t=>{let{option:o,typeNum:i}=Je.createLine(),r=t.x*t.wStep+t.w*t.wStep/2,a=t.y*t.hStep+t.h*t.hStep/2,n=t.w*t.wStep,s=t.h*t.hStep;if(3==i||5==i||7==i){let e=Math.min(n,s);n=e,s=e}let l=e.wrapWidth,d=e.wrapHeight;return t.chartsOption=o,t.typeNum=i,t.txt=i+" "+r/l+" "+a/d+" "+n/l+" "+s/d,console.log(t.txt),t})),option:{colNum:o,margin:(null==e?void 0:e.margin)?null==e?void 0:e.margin:this.margin,isDraggable:!!(null==e?void 0:e.isDraggable)&&(null==e?void 0:e.isDraggable),isResizable:!!(null==e?void 0:e.isResizable)&&(null==e?void 0:e.isResizable),verticalCompact:!(null==e?void 0:e.verticalCompact)||(null==e?void 0:e.verticalCompact),useCssTransforms:!(null==e?void 0:e.useCssTransforms)||(null==e?void 0:e.useCssTransforms),rowHeight:e.wrapHeight/t,maRrows:t}}}simulateRandomSegments(e,t,o,i){const r=[];let a=e,n=i;for(;n>0;)if(1===n)r.push(a),n--;else{const e=Math.min(o,a-t*(n-1)),i=Math.floor(Math.random()*(e-t+1))+t;r.push(i),a-=i,n--}return r}simulateRandomSegments2(e,t,o,i){const r=[];let a=e,n=i;for(;n>0;)if(1==n){const t=e-r.reduce(((e,t)=>e+t),0);r.push(t),n--}else{let e=Math.floor(Math.random()*o),i=Math.max(t,e),s=a-t*n;const l=Math.min(i,s);r.push(l),a-=l,n--}return r}},Xe=a.pool(),Ke=e=>{try{return JSON.parse(e)}catch(t){return e}};const Qe=new class{constructor(){this.requested=new Set,this.db=new r("go-db"),this.init()}init(){return s(this,void 0,void 0,(function*(){this.db.version(1).stores({store:"key, value"})}))}pushCaseIdToRequested(e){this.requested.add(e)}add(e,t){return s(this,void 0,void 0,(function*(){try{(yield this.isExist(e))||(t.caseDetailData&&(t.caseDetailData="string"==typeof t.caseDetailData?Ke(t.caseDetailData):t.caseDetailData),this.pushCaseIdToRequested(e),yield this.db.table("store").add({key:e,value:t}))}catch(e){console.error(e)}}))}bulkPut(e){return s(this,void 0,void 0,(function*(){let t=yield Promise.all(e.map((e=>s(this,void 0,void 0,(function*(){const{caseId:t,id:o}=e,i=`${t}_${o}`;if(yield this.isExist(i))return null;if(e.caseDetailData){const t=yield Xe.exec(Ke,[e.caseDetailData]);e.caseDetailData=t,Xe.terminate()}return e})))));t=t.filter((e=>null!==e));const o=t.map((e=>{const{caseId:t,id:o}=e,i=`${t}_${o}`;return this.pushCaseIdToRequested(i),{key:i,value:e}}));this.db.table("store").bulkPut(o).then((()=>{})).catch((e=>console.error(e)))}))}get(e){return s(this,void 0,void 0,(function*(){if(!(yield this.isExist(e)))return null;const t=yield this.db.table("store").where("key").equals(e).first();return t?t.value:null}))}getAllData(){return s(this,void 0,void 0,(function*(){return yield this.db.table("store").toArray()}))}update(e,t){return s(this,void 0,void 0,(function*(){if(yield this.isExist(e)){const o=yield this.get(e),i=yield Xe.exec(Ke,[t]);Xe.terminate(),yield this.db.table("store").update(e,{value:Object.assign(Object.assign({},o),{caseDetailData:i})})}else console.error("update indexdb error")}))}delete(e){this.requested.delete(e),this.db.table("store").delete(e)}isExist(e){return s(this,void 0,void 0,(function*(){return(yield this.db.table("store").where("key").equals(e).count())>0}))}reset(){this.requested.clear(),this.db.table("store").clear()}clear(){return s(this,void 0,void 0,(function*(){yield this.db.table("store").clear()}))}isExistStore(){return s(this,void 0,void 0,(function*(){try{return yield this.db.open(),!0}catch(e){return!1}}))}};function Ye(e){!function(e,t){e.depends?n(e):Ze(e,t)}(e,!1)}function Ze(e,t=!0){let{theme:o,option:i,optionDes:r}=e;i&&r&&o&&Object.keys(r).forEach((a=>{"conditionSeries"!==r[a].type&&"tabs"!==r[a].type||!i[a]?r[a].theme?i.hasOwnProperty(a)&&function({theme:e,option:t,optionDes:o},i,r){let a;if("color"!=o[i].type||!r&&t[i]){if("bgcolor"==o[i].type&&(r||!t[i]||!t[i].style)){t[i]||(t[i]={});let{key:r,points:n,degree:s,type:l,opacity:d}=o[i].theme;if(n){s||(s=90),l||(l="linear");let o=`${l}-gradient(${s}deg`,r=100/(n.length-1),c=[];n.forEach(((t,i)=>{a=et(e,t),o+=`,${tt(a,t.opacity)} ${r*i}%`;let{red:n,green:s,blue:l,alpha:u}=ot(a,d);c.push({red:n,green:s,blue:l,alpha:u,left:r*i})})),o+=")",t[i].style=o,t[i].degree=s,t[i].flag=n.length?3:2,t[i].points=c,t[i].type=l}else r&&(a=et(e,o[i].theme),t[i]=Object.assign(Object.assign({},ot(a,d)),{style:tt(a,d)}))}}else{let{opacity:r}=o[i].theme;a=et(e,o[i].theme),t[i]=tt(a,r)}}(e,a,t):r[a].hasOwnProperty("type")&&"slot"!=r[a].type&&"textStyle"!=r[a].type&&"sheet"!=r[a].type||r[a].constructor!=Object||Ze({option:i[a],optionDes:r[a],theme:o},t):function(e,t,o,i,r,a){let n=t.form,s=e;if(Array.isArray(n))for(let e=0;e<n.length;e++){let t,o=n[e];t=a?s[e].form:s[e],Ze({option:t,optionDes:o,theme:i},r)}else{let e=s.length;for(let t=0;t<e;t++){let e;e=a?s[t].form:s[t],Ze({option:e,optionDes:n,theme:i},r)}}}(i[a],r[a],0,o,t,"conditionSeries"===r[a].type)}))}function et(e,t){if(e[t.key])return e[t.key]||e.color;if(t.key.indexOf(".")>-1){return[e,...t.key.split(".")].reduce(((t,o)=>"object"==typeof t&&o in t?t[o]:(it(`属性${o}不存在,获取主题颜色错误,将使用默认主题色`),e.color)))}return it(`属性${t.key}不存在,获取主题颜色错误,将使用默认主题色`),e.color}function tt(e,t){let{red:o,green:i,blue:r,alpha:a}=ot(e,t);return`rgba(${o},${i},${r},${a})`}function ot(e,t){return-1!=e.indexOf("#")&&(e=e.substr(1)),null==t&&(t=1),{red:parseInt("0x"+e.slice(0,2)),green:parseInt("0x"+e.slice(2,4)),blue:parseInt("0x"+e.slice(4,6)),alpha:t}}function it(e){console.warn(e)}class rt{constructor(e){this.processedIds=new Set,this.validateAccessResolve=null,e?(e.caseId&&(this.caseId=e.caseId),e.pageId&&(this.pageId=e.pageId),e.mode&&(this.mode=e.mode),e.environment&&(this.environment=e.environment),e.xhr&&(this.xhr=e.xhr),e.staticComponentData&&(this.staticComponentData=e.staticComponentData),e.theme&&(this.theme=e.theme)):console.log("初始化错误!"),this.defaultTheme={name:"科技蓝",color:"#006aee",background:"#00000033",pageBackground:"#051836",text:"#F0F0F0",groups:["#006aee","#00eae9","#00a9ec","#00ec80","#edc700","#9913ee"]}}checkHardware(){return s(this,void 0,void 0,(function*(){return yield new Promise(((e,t)=>{e("Hardware is not available")}))}))}checkSecurity(e){return s(this,void 0,void 0,(function*(){return yield new Promise(((t,o)=>{"preview"==this.environment?t(0):this.getShareForRelease(e).then((e=>{2e4==e.code&&e.data?(e.data,e.data.loginLimitSwitch?t(1):e.data.hasAuth?t(2):t(3)):t(4)}))}))}))}validateAccess(e,t){return s(this,void 0,void 0,(function*(){return new Promise(((o,i)=>{this.validateAccessResolve=o,t&&t(e)}))}))}initBefore(){return new Promise(((e,t)=>{let o=y("secretFree");o?sessionStorage.setItem("secret-free",o):sessionStorage.setItem("secret-free",null),console.log("运行免登录设置完成!"),e(!0)}))}fetchCaseId(e,t){return s(this,void 0,void 0,(function*(){try{const o=yield this.getKey(e,t);return 2e4===(null==o?void 0:o.code)&&(null==o?void 0:o.data)?o.data:e}catch(t){return console.error("Error fetching caseId:",t),e}}))}getDataForrelease(){return new Promise(((e,t)=>{e("data")}))}onProjectLoaded(e){}authenticate(){return s(this,void 0,void 0,(function*(){this.environment}))}getShareForRelease(e){return this.xhr.get(`/go/v1/go-share/v1/${e}/config`)}findById(e,t="",o=0,i=""){return"release"===this.environment?this.xhr.get(`/go/v1/go-share/v1/${e}?pwd=${t}&mode=${o}&token=${i}`):this.xhr.get(`/go/v1/go-cases/v1/${e}?mode=${o}&token=${i}`)}getKey(e,t=0){return this.xhr.get(`/go/v1/go-cases/v1/key/${e}?caseMode=${t}`)}getPageData(e,t){return s(this,void 0,void 0,(function*(){const o=yield Qe.get(e+"_"+t);return o?{data:o}:"release"===this.environment?this.xhr.get(`/go/v1/go-share/v1/${e}/pages/${t}`):this.xhr.get(`/go/v1/go-cases/v1/${e}/pages/${t}`)}))}getPageId(e,t){if(null==t?void 0:t.length){if(t.find((t=>t.id==e)))return e;let o=t.find((t=>t.caseDetailPath==e||t.caseDetailName==e));return o?o.id:e}return e}fetchProjectForId(e,t="",o=0,i=""){return s(this,void 0,void 0,(function*(){return yield this.findById(e,t,o,i)}))}updataPageData(e,t){var o;return s(this,void 0,void 0,(function*(){let i=yield this.getPageDataForID(e,t);(null==i?void 0:i.data)?null===(o=null==this?void 0:this.lifecycleHooks)||void 0===o||o.onPageDataReady(i.data.caseDetailData):console.error("请求数据发生错误!")}))}getPageDataForID(e,t,o){return s(this,void 0,void 0,(function*(){const i=this.getPageId(t,this.projectInfo.details);if(this.processedIds.has(i)){console.log(`ID ${i} has already been processed.`);const t=yield Qe.get(e+"_"+i);if(t)return{data:t}}const r=this.getPageData(e,i);this.processedIds.add(i),o&&o.length&&o.map((t=>s(this,void 0,void 0,(function*(){try{if(this.processedIds.has(t))return void console.log(`ID ${i} has already been processed.`);const o=yield this.getPageData(e,t);Qe.add(e+"_"+t,o.data),this.processedIds.add(t)}catch(e){console.error(`Error processing ID ${t}: ${e}`)}}))));const a=yield r;return Qe.add(e+"_"+i,a.data),yield r}))}fetchPageDataForId(e,t="",o=0,i=""){return s(this,void 0,void 0,(function*(){return yield this.findById(e,t,o,i)}))}setTheme(){console.log("设置主题")}setBackground(){console.log("设置背景信息")}updateVariables(){console.log("更新变量信息")}beforeRender(e){}renderComponents(){return s(this,void 0,void 0,(function*(){}))}setGlobalThemeVars(e){document.body.style.cssText=`\n --theme-background: ${e.background};\n --theme-color: ${e.color};\n --theme-pageBackground: ${e.pageBackground};\n --theme-text: ${e.text};\n ${e.groups.map(((e,t)=>`--theme-groups-${t}: ${e};`)).join("\n")}\n `}listenForRenderCompletion(){}showAnimation(){console.log("所有组件渲染完成,显示动画。")}setComTheme(e,t){var o,i;let r=null===(o=this.staticComponentData[t.viewComName])||void 0===o?void 0:o.optionDes,a=null===(i=this.staticComponentData[t.viewComName])||void 0===i?void 0:i.theme;return Ye({theme:e,option:t.tmpData.option,optionDes:r,depends:a}),t}getComData(e,t,o,i){return s(this,void 0,void 0,(function*(){return new Promise(((r,a)=>{if(e.tmpData&&e.tmpData.source){this.setComTheme(i,e);try{fe(e,!0,t,o).then((t=>{t&&(e.source=t)})),r(1)}catch(e){r(e)}}else r("")}))}))}pageInit(e){var o;return s(this,void 0,void 0,(function*(){try{let i=null==e?void 0:e.caseDetailData,r=this.defaultTheme;if((null==i?void 0:i.theme)&&(r=i.theme),this.setGlobalThemeVars(r),i.resource){let e=(null===(o=null===window||void 0===window?void 0:window.anovuiConfig)||void 0===o?void 0:o.fonts)||[],r=t.concat(i.resource.fonts,e),a=t.cloneDeep(i.resource);a.fonts=r,yield f(a)}Ae.clearVars(),Ae.addVariables(i.globalVars);let a=Ae.getAllVariables();return C(i.list,(e=>s(this,void 0,void 0,(function*(){yield this.getComData(e,a,i.globalSource,r)})))),i}catch(t){return console.warn("页面初始化发生错误:",t),(null==e?void 0:e.data)?e.data:e}}))}validate(e,t,o){return s(this,void 0,void 0,(function*(){return new Promise(((i,r)=>{const a=(e,o)=>s(this,void 0,void 0,(function*(){let r=yield this.validateAccess(e,o),n=(null==r?void 0:r.pwd)?r.pwd:"",s=(null==r?void 0:r.mode)?r.mode:0,l=(null==r?void 0:r.token)?r.token:"",d=yield this.fetchProjectForId(t,n,s,l);2e4==(null==d?void 0:d.code)&&(null==d?void 0:d.data)?(this.projectInfo=d.data,console.log("验证成功!"),this.lifecycleHooks.message("验证成功!"),i(!0)):(this.lifecycleHooks.validateError(d),this.lifecycleHooks.message(d.msg,"warning"),a(e,o))}));a(e,o)}))}))}init(e){var t;return s(this,void 0,void 0,(function*(){try{this.lifecycleHooks=e,yield this.checkHardware();let o=yield this.fetchCaseId(this.caseId,this.mode),i=yield this.checkSecurity(o),r=e.onValidateAccess||(()=>{});(yield this.validate(i,o,r))&&e.onCaseReady(this.projectInfo);let a=(null===(t=this.projectInfo)||void 0===t?void 0:t.details).map((e=>e.id)),n=this.getPageId(this.pageId,this.projectInfo.details);console.log(n,this.pageId,"this.pageId");let s=yield this.getPageDataForID(o,n||a[0],a);const l=yield this.pageInit(s.data);return e.onPageDataReady(l),{currentData:this.projectInfo,currentPageData:l}}catch(e){console.error("加载页面时出错:",e)}}))}}export{je as ConfigOptimizer,ke as GlobalVariables,Y as Http,Q as Log,rt as PageLoader,v as addPreloadLink,oe as agentData,Te as applyDiff,P as delFetchStatus,Ie as diffObjects,We as displayGenerator,me as editItem,Oe as emitEvent,he as fetchDataByGlobal,ue as fetchDataByType,pe as filterData,I as findItemDeep,T as findItemDeep2,te as getData,ie as getDataForApi,ae as getDataForDataSet,se as getDataForSource,le as getDataForStatic,re as getDataForZb,ne as getDataForZbCQ,$ as getResourceForComponent,N as getSessionData,b as getStandardData,x as getStringVars,y as getUrlParams,xe as getVarDefaultVal,Ae as globalVars,O as hasVar,w as isJSON,m as loadFont,u as loadFontResource,h as loadScript,f as loadTag,C as recursion,g as removeTag,ye as replaceVariable,V as safeEval,E as safeEvalForCode,F as setFetchStatus,D as setSessionData,we as updataGlobalDataSourceForVar,fe as updateComData,De as updateGlobalDataSource};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* @returns {T} 返回标准数据格式
|
|
6
6
|
*/
|
|
7
7
|
import { GoComponent } from "../fetchUtils/type";
|
|
8
|
+
export * from "./loadScript";
|
|
8
9
|
/**
|
|
9
10
|
* 获取url 参数
|
|
10
11
|
* @param {string} attr 可选参数 查找的属性名称
|
|
@@ -87,3 +88,10 @@ export declare function safeEvalForCode(code: string, _params: any, globalVars?:
|
|
|
87
88
|
*/
|
|
88
89
|
export declare const setFetchStatus: (fetchId: string) => any;
|
|
89
90
|
export declare const delFetchStatus: (fetchId: string) => void;
|
|
91
|
+
/**
|
|
92
|
+
*
|
|
93
|
+
* 获取装饰资源路径
|
|
94
|
+
* @param {GoComponent[]} list
|
|
95
|
+
* @return {*}
|
|
96
|
+
*/
|
|
97
|
+
export declare const getResourceForComponent: (list: GoComponent[]) => any[];
|
|
@@ -10,5 +10,7 @@ declare const loadTag: ({ jspaths, csspaths, fonts }: {
|
|
|
10
10
|
fonts?: never[] | undefined;
|
|
11
11
|
}) => Promise<void>;
|
|
12
12
|
declare const removeTag: () => void;
|
|
13
|
-
|
|
13
|
+
type PreloadType = 'video' | 'script' | 'image';
|
|
14
|
+
declare const addPreloadLink: (url: string, type: PreloadType, onLoadCallback?: () => void) => void;
|
|
15
|
+
export { loadScript, removeTag, loadTag, loadFont, addPreloadLink };
|
|
14
16
|
export default loadScript;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wdslib/go-utils",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.4",
|
|
4
4
|
"description": "go-core utils",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "dist/types/index.d.ts",
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@rollup/plugin-typescript": "^11.1.5",
|
|
28
28
|
"@types/crypto-js": "^4.1.1",
|
|
29
|
+
"@types/deep-diff": "^1.0.5",
|
|
29
30
|
"@types/lodash": "^4.14.186",
|
|
30
31
|
"axios": "^1.7.2",
|
|
31
32
|
"eslint": "^8.55.0",
|
|
@@ -45,6 +46,7 @@
|
|
|
45
46
|
"bunyan": "^1.8.15",
|
|
46
47
|
"chalk": "^5.3.0",
|
|
47
48
|
"crypto-js": "^4.1.1",
|
|
49
|
+
"deep-diff": "^1.0.2",
|
|
48
50
|
"dexie": "^4.0.4",
|
|
49
51
|
"lodash": "^4.17.21",
|
|
50
52
|
"rollup-plugin-typescript": "^1.0.1",
|