@wdslib/go-utils 0.2.96 → 0.2.97
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 +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"axios";import t,{uniq as r}from"lodash";import i from"crypto-js";function o(e,t,r,i){return new(r||(r=Promise))((function(o,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?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(n,s)}l((i=i.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class a{constructor(){this.requests=[],console.log("RequestTracker")}static getInstance(){return a.instance||(a.instance=new a),a.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 r of this.requests)if(this.areRequestsEqual(r,e)){t=r;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){return e.url===t.url&&JSON.stringify(e.data)===JSON.stringify(t.data)&&JSON.stringify(e.params)===JSON.stringify(t.params)&&e.method===t.method}}const n=a.getInstance(),s=3e3,l=3e3,d=(t="",r)=>{let i,o=e.create({baseURL:t,timeout:s,headers:{"Content-Type":"application/x-www-form-urlencoded;charset=UTF-8"}});return o.interceptors.request.use((function(t){let{url:r,params:o,headers:a,data:s,method:l}=t;const d=e.CancelToken.source();return i={url:r,params:o,headers:a,data:s,method:l,cancelToken:d},t.cancelToken=d.token,n.addRequest(i),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)})),o.interceptors.response.use((function(e){return 200===e.status||e.data.code,r&&r(e),n.removeRequest(i),e.data}),(function(e){return r&&(n.removeRequest(i),r(null==e?void 0:e.response)),Promise.reject(e.response)})),o},c=(e,t)=>{try{let r=t||window.location.href;if(-1!=r.indexOf("?")){let t={};return r.slice(r.indexOf("?")+1).split("&").forEach((e=>{let r=e.split("=");t[r[0]]=r[1]})),e?t[e]?t[e]:null:t}return console.log("没有参数"),null}catch(e){console.error(e)}};function u(e,t=!1){try{return t?h(e)?e:JSON.stringify(e):h(e)?JSON.parse(e):e}catch(t){return console.log("转化JSON 发生错我!",e),e}}const h=e=>{if("string"==typeof e)try{const t=JSON.parse(e);return"object"==typeof t&&null!==t}catch(e){return!1}return!1},p=(e,t)=>{try{const r=JSON.stringify(t);sessionStorage.setItem(e,r)}catch(t){console.error(`Error setting session data for key ${e}:`,t)}},m=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},f=e=>{for(const t of e)t.code&&(t.code=t.code.replace(/>/g,">").replace(/</g,"<"))},g=(e,t)=>{e instanceof Map?e.forEach((e=>{t([e])})):Array.isArray(e)&&e.forEach((e=>{t(e.children)}))},v=(e,t)=>{const r=e=>{var i,o,a;if(e)for(const n of e){const e=null===(a=null===(o=null===(i=null==n?void 0:n.tmpData)||void 0===i?void 0:i.source)||void 0===o?void 0:o.converse)||void 0===a?void 0:a.data;(null==e?void 0:e.length)&&f(e),t(n),n.children?r(n.children):n.dynamicChildren?g(n.dynamicChildren,r):n.stateChildren&&r(n.stateChildren)}};r(e)},y=(e,t,r,i)=>{const o=e.match(/({{[\w]*}})|((@)[\w]*)/gm);if(o){const e=o.map((e=>e.replace(/{{|}}|@/gm,"")));for(const o of e)if(o&&t&&!(t.findIndex((e=>e.mapField===o))<0))return r&&i&&b(i,o,r.cid),!0}return!1},b=(e,t,r)=>{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(!r)throw new Error("ID is required");Array.isArray(e[t])||(e[t]=[]),e[t].includes(r)||e[t].push(r)},w=(e,t,r)=>{var i;let o=!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))&&(o=y(n.inputSql||n.url||(null===(i=n.headers)||void 0===i?void 0:i.value)||n.params,r)),o},D=(e,r,i=!1)=>{let o=null;const a=e=>{for(const n of e){if(n.cid===r){o=n,i&&t.remove(e,(e=>e.cid===r));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),o},N=(e,r,i)=>{let o=!1;const a=e=>{for(let n=0;n<e.length;n++){if(e[n].cid==r){o=e[n],i&&t.remove(e,(e=>e.cid==r));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 r=t[e][1];a(r)}}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 r=t[e][1];a(r)}}}else e[n].stateChildren&&a(e[n].stateChildren)}};return a(e),o||!1};function k(e,t,r){const i={};r&&r.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 S(e,r,i){let o=t.cloneDeep(r);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)(o,a)}catch(e){return console.error(e),o}}const A=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)},C=e=>{let t=window.goFetchList;t&&t[e]&&delete t[e]},x="anov@2019:helloX",O="anov@2020:helloX";function V(e){let t=i.enc.Utf8.parse(x),r=i.enc.Utf8.parse(O);return i.AES.encrypt(e,t,{iv:r,mode:i.mode.CBC,padding:i.pad.Pkcs7}).toString()}function F(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 r=t.reduce(((e,t)=>e+t),0),i=Math.random()*r;let o=0;for(let r=0;r<e.length;r++)if(o+=t[r],i<o)return e[r];return e[0]}const T=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"]),E=URL.createObjectURL(T);function I(e,t,r={},i="worker"){return o(this,void 0,void 0,(function*(){try{if("window"==i){let[i,o]=[["data"],[t]];"object"==typeof r&&Object.keys(r).forEach((e=>{i.push(e),o.push(r[e])}));const a=new Function(...i,e);return{success:!0,data:a(...o)}}{let[i,a,n]=[t,r,""];"object"==typeof i&&(i=JSON.stringify(t)),"object"==typeof r&&(a=JSON.stringify(r)),Object.keys(r).forEach((e=>n+=`${e},`));let s=`let data=eval(${i}); \n let app=${JSON.stringify({})};`;s+=n?`let {${n}} = eval(${a}); `:"",s+=`${e}`;let l=yield function(e,t=5e3){return o(this,void 0,void 0,(function*(){let r=new Worker(E);return new Promise(((i,o)=>{const a=()=>{clearTimeout(s),r.removeEventListener("message",n),r.terminate(),r=null},n=e=>{let{code:t,result:r,err:n}=e.data;a(),1===t?i(r):o(n)};r.postMessage({code:e}),r.addEventListener("message",n);let s=setTimeout((()=>{a(),o("timeout")}),t)}))}))}(s);return{success:!0,data:l}}}catch(e){return{success:!1,error:e,data:t}}}))}var R,P,j,q;!function(e){e.StaticFile="staticFile",e.DataSource="datasource"}(R||(R={})),function(e){e.json="application/json;charset=UTF-8",e.form="application/x-www-form-urlencoded; charset=UTF-8"}(P||(P={})),function(e){e.get="GET",e.post="POST",e.put="PUT",e.patch="PATCH",e.delete="DELETE"}(j||(j={}));class M{constructor(e){this.db=null,this.dbName=e.databaseName,this.tableName=e.tableName,this.keyPath=e.keyPath}static getInstance(e){return M.instance||(M.instance=new M(e)),M.instance}init(){return o(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{const r=indexedDB.open(this.dbName,1);r.onerror=e=>{t(e.target.error)},r.onupgradeneeded=e=>{this.db=e.target.result,this.db.objectStoreNames.contains(this.tableName)||this.db.createObjectStore(this.tableName,{keyPath:this.keyPath})},r.onsuccess=t=>{this.db=t.target.result,e()}}))}))}addRecord(e){return o(this,void 0,void 0,(function*(){if(!this.db)throw new Error("数据库未初始化。");return new Promise(((t,r)=>{const i=this.db.transaction([this.tableName],"readwrite").objectStore(this.tableName).add(e);i.onsuccess=()=>{t()},i.onerror=e=>{r(e.target.error)}}))}))}deleteRecord(e){return o(this,void 0,void 0,(function*(){if(!this.db)throw new Error("数据库未初始化。");return new Promise(((t,r)=>{const i=this.db.transaction([this.tableName],"readwrite").objectStore(this.tableName).delete(e);i.onsuccess=()=>{t()},i.onerror=e=>{r(e.target.error)}}))}))}updateRecord(e){return o(this,void 0,void 0,(function*(){if(!this.db)throw new Error("数据库未初始化。");return new Promise(((t,r)=>{const i=this.db.transaction([this.tableName],"readwrite").objectStore(this.tableName).put(e);i.onsuccess=()=>{t()},i.onerror=e=>{r(e.target.error)}}))}))}getRecord(e){return o(this,void 0,void 0,(function*(){if(!this.db)throw new Error("数据库未初始化。");return new Promise(((t,r)=>{const i=this.db.transaction([this.tableName],"readonly").objectStore(this.tableName).get(e);i.onsuccess=()=>{t(i.result)},i.onerror=e=>{r(e.target.error)}}))}))}getAllRecords(){return o(this,void 0,void 0,(function*(){if(!this.db)throw new Error("数据库未初始化。");return new Promise(((e,t)=>{const r=this.db.transaction([this.tableName],"readonly").objectStore(this.tableName).getAll();r.onsuccess=()=>{e(r.result)},r.onerror=e=>{t(e.target.error)}}))}))}}M.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"}(q||(q={}));const $={databaseName:"GODB",tableName:"go-log",keyPath:"time"};class U{constructor(){this.logLevel=q.INFO,this.indexedDBInstance=M.getInstance($);try{this.indexedDBInstance.init(),console.log("IndexedDB 初始化成功。")}catch(e){console.error("初始化 IndexedDB 时出错:",e)}}static getInstance(){return U.instance||(U.instance=new U),U.instance}setLogLevel(e){this.logLevel=e}getColor(e){switch(e){case q.FATAL:return"[31;1m";case q.ERROR:return"[31m";case q.WARN:return"[33m";case q.INFO:return"[32m";case q.DEBUG:return"[36m";case q.TRACE:return"[34m";default:return"[0m"}}log(e,t){if(t<=this.logLevel){const r=(new Date).toISOString(),i=`[${r}] [${q[t]}]`,o=this.getColor(t);if(null===window||void 0===window?void 0:window.goDev)console.log(`${o}${i} ${e}[0m`);else{let t=m("anov-go-userInfo"),a=m("anov-go-proid"),n=` [操作人:${null==t?void 0:t.userName} 项目ID:${a}] `;const s={time:r,value:`${e}`};try{this.indexedDBInstance.addRecord(s)}catch(e){console.error("添加记录时出错:",e)}console.log(`${o}${i} ${n} ${e}[0m`)}}}fatal(e){this.log(e,q.FATAL)}error(e){this.log(e,q.ERROR)}warn(e){this.log(e,q.WARN)}info(e){this.log(e,q.INFO)}debug(e){this.log(e,q.DEBUG)}trace(e){this.log(e,q.TRACE)}}const L=U.getInstance(),z=(e,t)=>"string"!=typeof e?Promise.reject(new Error("URL should be a string")):d(e,t),H=d();let J=d();function G(e,r="get",i={},a={}){return o(this,void 0,void 0,(function*(){try{const n={method:j[r],url:e,headers:a,timeout:l};["post","put"].includes(r.toLowerCase())?n.data=t.cloneDeep(i):n.params=t.cloneDeep(i);return/.json$/.test(e)?function(e){return o(this,void 0,void 0,(function*(){try{return(yield H({method:"get",url:e})).data}catch(e){throw console.error("JSON 数据请求:",e),e}}))}(e):function(e){return o(this,void 0,void 0,(function*(){try{return{code:2e4,data:(yield H(e)).data}}catch(e){throw console.error("请求数据发生错误-Error:",e),e}}))}(n)}catch(e){throw console.error("获取数据:Error:",e),e}}))}function B(e,t,r,i){return o(this,void 0,void 0,(function*(){try{const o=window.anUrl||"",a=o+(window.agentPath||"/ds/v1/api-proxy/v1/query"),n=u(r,!0);return yield H({url:a,method:"post",headers:{"Content-Type":"application/json;charset=UTF-8"},data:{body:"post"===e?n:void 0,headers:h(i)?u(i,!0):i,method:e,url:t}})}catch(e){throw console.error("代理请求数据:Error:",e),e}}))}function W(e,t,r,i,a){return o(this,void 0,void 0,(function*(){return a?B(t,e,r,i):G(e,t,r,i)}))}function X(e,t="",r){var i,o,a,n;const l=`${null!==(o=null===(i=null===window||void 0===window?void 0:window.BaseUrl)||void 0===i?void 0:i.replace("/management",""))&&void 0!==o?o:""}/ds/data-engine/v1/${e}/zb-query?${`token=${(null===(a=ae("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 H({method:"POST",url:l,data:{headers:r,param:d},timeout:s})}const _=(e,t)=>o(void 0,void 0,void 0,(function*(){const r=window.BaseUrl,{dateType:i="",endPeriod:o="",metricsName:a=e,startPeriod:n=""}=t;return J({method:"GET",url:`${r}ds/v1/metrics/v1/data-alarm?dateType=${i}&endPeriod=${o}&metricsName=${a}&startPeriod=${n}`,timeout:s})})),K=(e,t,r)=>o(void 0,void 0,void 0,(function*(){var i;const o=(null===(i=window.BaseUrl)||void 0===i?void 0:i.replace("/management",""))||"";t.newEncryption=!0;const a={staticFile:{method:"get",params:t,url:`${o}/ds/v1/file/v1/${e}/query`},datasource:{method:"post",url:`${o}/ds/v1/database/v1/${e}/query`,data:Object.assign({},t)}}[r];if(!a)throw new Error("Invalid data type provided");return H(Object.assign({timeout:s},a))})),Q=e=>new Promise(((t,r)=>{let i;i=e.originData&&Object.keys(e.originData).length?e.originData:e.data,void 0!==i?t({data:i}):r("Failed to retrieve cdata")})),Y=(e,t,r)=>{try{switch(t){case"api":{let t=le(e,r);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=se(e.inputSql,r);return{dsName:e.dsName,dsType:"1",sql:V(t),filter:e.sqlFilter}}case"staticFile":return{dsName:e.dsName,dsType:e.dsType,sql:""};case"indicator":return{zbId:e.zbId,params:se(e.params,r),headers:se(e.headers,r)};case"indicatorCQ":return{zbName:e.zbName,params:se(e.params,r)};case"packData":return{};default:throw new Error("Invalid type")}}catch(t){console.log("准备请求数据发生错误",t,e)}},Z=(e,t)=>o(void 0,void 0,void 0,(function*(){try{switch(t){case"api":return yield W(e.url,e.requestType,e.params,e.headers,e.agency);case"static":return yield Q(e.data);case"datasource":return yield K(e.dsName,{dsType:e.dsType,sql:e.sql,filter:e.filter},"datasource");case"staticFile":return yield K(e.dsName,{dsType:e.dsType,sql:e.sql},"staticFile");case"indicator":return yield X(e.zbId,e.params,e.headers);case"indicatorCQ":return yield _(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})}))}})),ee=(e,t,r,i=[],a=!1)=>o(void 0,void 0,void 0,(function*(){const o=t||e.tmpData.source.dataType,n=e.tmpData.source["indicatorCQ"==o?"indicator":o];if("globalData"===o){const e=i.find((e=>e.key===n.id||e.key===n.key)),t=m(n.id);if(t&&!a)return t.data;if(e){let t=yield te(e,r),i={key:n.id,data:t};return p(n.id,i),t}return}const s=Y(n,o,r),l=yield Z(s,o);return(null==l?void 0:l.data)?l.data:l})),te=(e,t)=>o(void 0,void 0,void 0,(function*(){let r=Object.assign({},{tmpData:{source:e.value}});const i=r.tmpData.source.type,o=r.tmpData.source[i],a=Y(o,i,t),n=yield Z(a,i);return yield re(n.data,r,!0,t)})),re=(e,r,i=!0,a)=>o(void 0,void 0,void 0,(function*(){try{const{converse:n,mapFields:s}=r.tmpData.source;return n&&n.use&&i?yield new Promise(((r,i)=>{const s=function(e,r,i,a,n){return o(this,void 0,void 0,(function*(){let i,o=e,{use:n,data:s}=t.cloneDeep(r);if(n)for(let e=0;e<s.length;e++)if(s[e].use){let r=s[e].dependVars,n={};a&&n&&r&&r.length&&r.map((e=>{let r=t.cloneDeep(a).filter((t=>{let r=t.mapField==e;return r&&(n[e]=t.value),r}));r&&0!=r.length||(n[e]="")})),i=yield I(s[e].code,o,n,s[e].mode?s[e].mode:"worker"),o=i.data}return o}))}(e,n,0,a);r(s)})):yield new Promise(((t,r)=>{t(e)}))}catch(t){return console.error("执行过滤器发生错误:"+t),yield new Promise(((t,r)=>{t(e)}))}})),ie=(e,t,r)=>{const{source:i}=e.tmpData,o=i.type;r?("static"===o&&i[o]&&(i[o].originData=r),"indicatorCQ"===o?i.indicator.data=t:i[o].data=t):"indicatorCQ"===o?i.indicator.data=t:i[o].data=t,e.source=t},oe=(e,t,r=[],i,a,n)=>o(void 0,void 0,void 0,(function*(){try{let o=e.tmpData.source.type,s=yield ee(e,o,r,i,n||!1);if(null==s||!s)return a&&a({error:!0}),Promise.resolve({error:!0});let l=yield re(s,e,t,r);return ie(e,l),a&&a(l),(null==e?void 0:e.cid)&&C(e.cid),Promise.resolve(l)}catch(e){return a&&a(e),L.error("Error in updateComData"),console.error("Error in updateComData:",e),Promise.reject(e)}})),ae=e=>{const t={};if(e&&e.includes("?")){const r=e.split("?")[1].split("&");for(let e of r){const[r,i]=e.split("=").map(decodeURIComponent);t[r]=i}}return t},ne=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}},se=(e,t)=>{if(!t)return ne(e);if("string"==typeof e){if(""===e.trim())return"";try{if("string"!=typeof JSON.parse(e))return se(JSON.parse(e),t);{let r=e.replace(/@(\w+)|{{(\w+)}}/g,((e,r,i)=>{const o=r||i,a=t.find((e=>e.mapField===o));return a?a.value||a.originalValue||"":e}));return ne(r)}}catch(r){let i=e.replace(/@(\w+)|{{(\w+)}}/g,((e,r,i)=>{const o=r||i,a=t.find((e=>e.mapField===o));return a?a.value:e}));return ne(i)}}else{if(Array.isArray(e))return e.map((e=>se(e,t)));if("object"==typeof e&&null!==e){const r={};for(let i in e)r[i]=se(e[i],t);return ne(r)}}return ne(e)},le=(e,t)=>{const r=e.agency,i=e,{url:o=null,headers:a,params:n,requestType:s}=i,l=o?se(o,t):void 0,d=a&&a.use?se(a.value,t):{};return{url:l,requestType:s,params:n?se(n,t):{},headers:d,agency:r}},de=(e,t,r,i,a)=>o(void 0,void 0,void 0,(function*(){if(e&&e.length)for(const o of e){w(t,o.value,r)&&(yield oe({tmpData:{source:{type:"globalData",globalData:{id:o.key}}}},!0,r,e,(e=>{console.log("数据更新成功-变量改变全局数据跟新")}),!0),v(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===o.key&&oe(t,!0,r,e,(e=>{a(t,e)}),!1)}})))}})),ce=(e,t,r,i,a)=>o(void 0,void 0,void 0,(function*(){e&&(yield oe({tmpData:{source:{type:"globalData",globalData:{id:e.key}}}},!0,t,r,(e=>{console.log("数据更新成功-数据源编辑")}),!0),v(i,(i=>{var o,n,s;if("globalData"===(null===(n=null===(o=null==i?void 0:i.tmpData)||void 0===o?void 0:o.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&&oe(i,!0,t,r,(e=>{a(i,e)}),!1)}})))}));class ue{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 S(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 o=Object.assign({},this,e);this.des=o.des,this.field=o.field,this.mapping=o.mapping,this.type=o.type,this.originalValue=o.originalValue,this.converter=o.converter,this.converterCode=o.converterCode,this.fork=o.fork,this.delayUpdate=null==o?void 0:o.delayUpdate,this.model=null==o?void 0:o.model,e.id&&(this.id?"string"==typeof this.id?e.id instanceof Array?this.id=r([this.id,...e.id]):this.id=[this.id,e.id]:this.id instanceof Array&&(e.id instanceof Array?this.id=r([...this.id,...e.id]):this.id=r([...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 r;this.originalValue=e,this.fork&&(this.forkValue=null!==(r=this.forkValue)&&void 0!==r?r:this.forkValue,this.originalValue=this.getForkedValue()),t&&t(this)}renew(e){e&&e(this)}static create(e,t){return new ue(e,t)}}class he{constructor(){this.variables=new Map,this.globalObservers=[],this.url=window.location.search,this.list=[]}clearVars(){this.list=[],this.variables.clear()}togglePropertyState(e,t,r){try{let i=this.getVariable(e);if(!i)throw new Error("没有找到相应的变量!");i.togglePropertyState(t),this.addToObjectArray(this.list,i),r&&r()}catch(e){console.error(e)}}static getInstance(){return he.instance||(he.instance=new he),he.instance}getFullUrl(){this.url=window.location.search}getAllUrlParams(){const e=new URLSearchParams(window.location.search),t={};for(const[r,i]of e.entries())t[r]=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),r=[];for(const i of t)r.push({mapField:i,originalValue:e[i],model:4});if(r.length)for(const e of r)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 r=this.getVariable(e.mapField);return this.sameValue(r,e)?r:(this.editVariable(e,t),!1)}const r=ue.create(e,this.variables);return this.variables.set(r.mapField,r),this.addToObjectArray(this.list,r),t&&t(r),this.notifyGlobalObservers(r),r}toJSON(e){try{return!!e&&JSON.stringify(e)}catch(e){return!1}}sameValue(e,t){if(e.mapfield!==t.mapfield)return!1;for(const r in t)if(!(["mapfield","field","key","value","name","globalVariables"].includes(r)||r in e&&e[r]==t[r]))return!1;return!0}creatVarJson(e){const{des:t,field:r,id:i,key:o,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!==r&&(v.field=r),void 0!==i&&(v.id=i),void 0!==o&&(v.key=o),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 r=!1;for(let i=0;i<e.length;i++)if(e[i].mapField==t.mapField){e[i]=this.creatVarJson(t),r=!0;break}r||e.push(t)}editVariable(e,t){const r=this.getVariable(e.mapField);if(r&&this.isVariableNameExist(e.mapField)){if(this.sameValue(r,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}};r?r.updateValue(e,i):this.addVariable(e,i)}getForkList(e){let t=this.isMapFieldInForkValues(e);return t||[]}editVariableForValue(e,t,r){const i=this.getVariable(e),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),r&&r(e),e.isUpdating=!1}};i&&i.updateWidthOriginalValue(t,o)}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 r=this.getVariable(e);return t==r.id&&!r.id.includes(t)&&[{key:e}]}if(Array.isArray(e)){const r=e.filter((e=>{let r=this.getVariable(e);return this.isVariableNameExist(e)&&t!=r.id&&!(r.id&&r.id.includes(t))})).map((e=>({key:e})));return!!r.length&&r}return!1}getVariable(e){return this.variables.get(e)}getVariableForId(e){var r;let i=[];for(const[,t]of this.variables)(t.id===e||(null===(r=t.id)||void 0===r?void 0:r.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)}))}}he.instance=null;const pe=he.getInstance(),me=(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))),fe=(e,t,r,i)=>{const o=((e,t,r,i)=>{var o;let a;if(me(e,null==t?void 0:t.field)||me(e,null==t?void 0:t.forkValue))a=e[null==t?void 0:t.field]||"";else if(me(e.data,null==t?void 0:t.field)||me(e.data,null==t?void 0:t.forkValue))a=e.data[null==t?void 0:t.field]||"";else{const e=D(r,i),n=(null===(o=null==e?void 0:e.tmpData)||void 0===o?void 0:o.actions)||[];for(const e of n){const r=e.vars.find((e=>(null==e?void 0:e.mapField)===(null==t?void 0:t.mapField)));if(r){a=r.value;break}}}return a})(e,t,r,i);return void 0!==o?o:t.value},ge=(e,t,r,i,o,a,n,s,l)=>{var d;switch(e.type){case"link":let c=se(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 r=e.params[t],i=a.find((e=>e.mapField==r.mapField));i&&(r.value=i.value)}l&&l(e);break;case"dynamic":((e,t,r,i,o)=>{const a=e.dynamic||[];for(const n of a){if(e.id!==t.cid)continue;const a=D(r,n.pid);a&&(a.activeDynamic=n.name,a.isShow=n.visible||!i||e.index===t.index-1,o({cid:a.cid,flag:n.visible}))}})(e,t,r,i,o);break;case"toggle":((e,t,r,i,o)=>{const a=e.children||[];for(const r of a){const a=r.visible&&(!i||e.index===t.index-1);o({cid:r.cid,flag:a})}})(e,t,0,i,o);break;case"update":((e,t,r,i,o)=>{const a=e.children||[];for(const e of a){const a=D(t,e.cid);a&&oe(a,!0,r,i,(e=>{o({cid:a.cid,data:e})}))}})(e,r,a,n,s)}},ve=(e,r,i,o,a,n,s,l,d,c)=>{const{cid:u,actions:h,index:p}=a,{eventName:m,mode:f}=h,g=2===f;((e,r,i,o,a,n)=>{let s=pe.getVariableForId(r.cid);if(null==s?void 0:s.length)for(const l of s)if(l.type==e){let e=fe(r,l,i,o);pe.editVariableForValue(l.mapField,e,(()=>{let e=a[l.mapField]||[],r=pe.getForkList(l.mapField);if(r)for(const i of r){let r=a[i.mapField];e=t.concat(e,r)}n&&n(l,t.uniq(e))}))}})(m,a,o,u,i,((e,t)=>{if(de(d,e.mapFile,pe.getAllVariables(),o,((e,t)=>{s({cid:e.cid,data:t})})),null==t?void 0:t.length)for(const r of t){e.eventSourceId=r;const t=D(o,r);!(null==e?void 0:e.delayUpdate)&&t&&oe(t,!0,pe.getAllVariables(),d,(e=>{s({cid:t.cid,data:e})}))}}));const v=((e,t,r,i,o)=>e.filter((e=>e.id===t&&e.eventType===r&&(!o||parseInt(e.index||"0")+1===parseInt(i||"0")))))(e,u,m,p,g);for(const e of v)ge(e,a,o,g,n,pe.getAllVariables(),d,s,l)},ye=(e,t={})=>{let r={},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(r,i,t),r},be=(e,r)=>{let{option:i,actions:o,data:a,optionDes:n,actionsDes:s,source:l,theme:d}=((e,r)=>{let{option:i,actions:o,data:a,optionDes:n,actionsDes:s,source:l,theme:d}=t.cloneDeep(r[e]);return{option:i,actions:o,data:a,optionDes:n,actionsDes:s,source:l,theme:d}})(e,r);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:ye(a,l),actions:o},baseData:De(),dynamic:null,filePath:"",origin:"anov-ui",name:"",componentType:"",viewComName:e,optionComName:"AnOptionPanel",dataComName:"AnSourcePanel",eventComName:"AnActionsPanel",assemblyDeveloper:"",devEmail:"",version:"",devDept:""}},we=(e,r,i)=>{let o=be(e,r);return i?t.merge(o,i):o},De=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 Ne{constructor(e,t,r){this.theme=null,this.plant=null,this.list=[],this.titleHeqadeHeight=70,this.clearance=3,this.checkComponentIntersection=(e,t,r=10)=>{const i=e.left,o=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&&o>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<r&&p<r},this.calculateCombinedComponent=e=>{if(0===e.length)return{left:0,top:0,width:0,height:0};let t=e[0].left,r=e[0].top,i=e[0].left+e[0].width,o=e[0].top+e[0].height;for(let a=1;a<e.length;a++){const n=e[a];t=Math.min(t,n.left),r=Math.min(r,n.top),i=Math.max(i,n.left+n.width),o=Math.max(o,n.top+n.height)}return{left:t,top:r,width:i-t,height:o-r}},this.getAnTextNormaltText=e=>{var t,r;try{return null===(r=null===(t=null==e?void 0:e.tmpData)||void 0===t?void 0:t.option)||void 0===r?void 0:r.text}catch(e){return console.error("配置优化(ConfigOptimizer):",e),""}},this.initProp(e),this.upgradePlant(),this.staticComponentData=t,this.upgradeHeaderComponent(),r&&Object.assign(this,r)}isStringOrObject(e){return"string"==typeof e?"string":"object"==typeof e&&null!==e&&"object"}initProp(e){try{let t,r=this.isStringOrObject(e);if(r&&"string"===r)t=JSON.parse(e);else{if(!r||"object"!==r)throw new Error(`initProp fn error :-- 传入参数${e}不合法!`);t=e}if(t){this.originData=t;const{theme:e,plant:r,list:i}=t;this.theme=e,this.plant=r,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 r=e.baseData,i=t.baseData;const o=Math.max(0,Math.min(r.left+r.width,i.left+i.width)-Math.max(r.left,i.left)),a=Math.max(0,Math.min(r.top+r.height,i.top+i.height)-Math.max(r.top,i.top));return o>0&&a>0}filterFileGroup(){this.list=t.cloneDeep(this.list).map((e=>{var t,r;if(1===(null===(t=null==e?void 0:e.children)||void 0===t?void 0:t.length)&&!(null===(r=null==e?void 0:e.children[0])||void 0===r?void 0:r.children)){const t=e.children[0],{left:r,top:i}=e.baseData;return t.baseData.left=r,t.baseData.top=i,t}return e}))}getText(e,t,r){const i=document.createElement("canvas").getContext("2d");if(!i)throw new Error("Failed to get 2D context from canvas.");i.font=`${r}px ${t}`;return i.measureText(e).width}calculateMaxWidths(e){const t=Math.min(...e.map((e=>e.width))),r=[];let i=[],o=e[0].width;for(const a of e){const e=a.width;Math.abs(e-o)<=t?i.push(e):(i.length>0&&r.push(i),i=[e]),o=e}i.length>0&&r.push(i);const a=[];for(const e of r){const t=Math.max(...e);a.push(t)}return a}findClosestValue(e,t){let r=t[0],i=Math.abs(e-r);for(const o of t){const t=Math.abs(e-o);t<i&&(i=t,r=o)}return r}adjustHeightAndTop(e,t){const r=t-e.height;return Object.assign(Object.assign({},e),{height:t,top:e.top-r/2})}findNearestComponent(e,r,i){let o=null,a=1/0;r.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===r.cid||"AnTextNormal"===e.viewComName||i&&i.includes(e.cid)))),s=t.cloneDeep(r).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 r=t.top-s.top;r<a&&r<100&&(a=r,o=e)}}}catch(e){console.error("配置优化(ConfigOptimizer)- findNearestComponent :",e)}return o}findNearestComponentForPoint(e,t,r){let i=null,o=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||r&&r.includes(e.cid)))),n=t.baseData;n.top,n.height;for(const e of a){const t=e.baseData;let r=this.getDistance(n.left,n.top+n.height,t.left,t.top);r<o&&r<n.width&&(o=r,i=e)}}catch(e){console.error("配置优化(ConfigOptimizer)- findNearestComponent :",e)}return i}findNearestComponentForTitlePoint(e,t,r){let i=null,o=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||r&&r.includes(e.cid)))),n=t.baseData;n.top,n.height;for(const e of a){const t=e.baseData;let r=this.getDistance(n.left,n.top+n.height,t.left,t.top);r<o&&r<n.width&&t.top-n.top>100&&(o=r,i=e)}}catch(e){console.error("配置优化(ConfigOptimizer)- findNearestComponent :",e)}return i}findNearestTitleForPoint(e,t,r){let i=null,o=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||r&&r.includes(e.cid)))),n=t.baseData;n.top,n.height;for(const e of a){const t=e.baseData;let r=t.top-n.top;r<o&&r<n.width&&t.top-n.top>100&&(o=r,i=e)}}catch(e){console.error("配置优化(ConfigOptimizer)- findNearestComponent :",e)}return i}getDistance(e,t,r,i){return Math.sqrt(Math.pow(r-e,2)+Math.pow(i-t,2))}findNearestComponent2(e,r,i){let o=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===r.cid||"AnTextNormal"===e.viewComName||i&&i.includes(e.cid)))),s=t.cloneDeep(r).baseData,l=s.top+s.height;for(const t of e){const e=t.baseData,r=e.top+e.height;if(s.left<e.left+e.width&&s.left+s.width>e.left){const e=r-l;e>=0&&e<a&&(a=e,o=t)}}}catch(e){console.error("配置优化(ConfigOptimizer)- findNearestComponent :",e)}return o}verticalDistance(e,t){e.left,e.width;const r=e.top+e.height,i=(t.left,t.width,t.top);return Math.abs(r-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=[],r=new Set;for(const i of e){if(r.has(i.cid))continue;let o=[];for(const t of e){if(!r.has(t.cid)&&i.cid!=t.cid){this.checkComponentIntersection(i.baseData,t.baseData)&&(r.add(t.cid),r.add(i.cid),o.push(t))}}t.push([i,...o])}let i=[];for(const e of t)for(const t of e){let r=this.getAnTextNormaltText(t);this.extractAmount(r).every((e=>e))&&i.push(e)}return i}createAnOdometer(){var e,r;let i=this.judgeAnOdometer();for(const o of i){let i,a,n,s=this.calculateCombinedComponent(o.map((e=>e.baseData)));for(const e of o){let r=this.getAnTextNormaltText(e),o=this.extractAmount(r);o.every((e=>!e))&&(i=r),o.every((e=>e))&&(a=o[0],n=o[1]),t.remove(this.list,(t=>t.cid==e.cid))}let l=we("AnIndicatorNormal",this.staticComponentData,t.cloneDeep({baseData:s}));(null===(r=null===(e=null==l?void 0:l.tmpData)||void 0===e?void 0:e.source)||void 0===r?void 0:r.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 r=this.list[e];if("AnDeckTitle3"==r.viewComName){let e=this.findClosestValue(r.baseData.width,t);r.baseData.width=e>300?e:300,r.baseData=this.adjustHeightAndTop(r.baseData,this.titleHeqadeHeight)}}this.removeErroneousComponents()}containsFractionStructure(e){return/\b\d+\/\d+\b/.test(e)}removeErroneousComponents(){let e=this.getAnDeckTitle3(),t=[];for(let r=0;r<e.length;r++){const i=e[r];let o=i.tmpData.option.textNormal.text;if(this.containsFractionStructure(o))for(let r=0;r<e.length;r++){const o=e[r];if(i.cid!=o.cid){this.areComponentsIntersecting(i,o)&&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)),r=[],i=[];for(let o=0;o<e.length;o++){const a=e[o];let n=this.findNearestComponentForPoint(t,a,r);if(n&&n.cid&&r.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,r,i=[]){const o=e;let a=this.findNearestTitleForPoint(t.cloneDeep(r),o);return a?a.baseData.top-o.baseData.top-this.titleHeqadeHeight:1080-o.baseData.top-this.titleHeqadeHeight}getData(){return this.originData.list=this.list,this.originData.plant=this.plant,this.originData}}const ke=new class{randomNum(e,t){return Math.floor(Math.random()*(t-e+1))+e}generateRandomIntArray(e,t,r,i){const o=[];for(let i=0;i<e;i++){const e=this.randomNum(t,r);o.push(e)}return i&&"asc"===i?o.sort(((e,t)=>e-t)):i&&"desc"===i?o.sort(((e,t)=>t-e)):o}randomString(e,t){const r="abcdefghijklmnopqrstuvwxyz",i=this.randomNum(e,t);let o="";for(let e=0;e<i;e++){const e=Math.floor(26*Math.random());o+=r.charAt(e)}return o}generateRandomNameArray(e,t,r){const i=[];for(let o=0;o<e;o++){const e=this.randomString(t,r);i.push(e)}return i}pick(e,t){const r=void 0!==t?e.filter((e=>e!==t)):e;return r[Math.floor(Math.random()*r.length)]}},Se=()=>{const e=[],t=ke.pick([!0,!1]);let r=ke.randomNum(3,20);const i=ke.pick([null,null,null,{}]);let o=ke.pick(["asc","desc",void 0,void 0,void 0]);for(let a=0;a<ke.randomNum(1,9);a++)e.push({data:ke.generateRandomIntArray(r,0,300,o),type:"line",smooth:t,symbolSize:ke.randomNum(1,10),lineStyle:{width:ke.randomNum(1,4)},areaStyle:i});return{xAxis:{type:"category",show:!1,boundaryGap:!1,data:ke.generateRandomNameArray(r,3,6)},grid:{left:0,top:0,bottom:0,right:0},yAxis:{show:!1,type:"value"},series:e}},Ae=(e,t)=>{let r={type:e,show:!1};return"category"===e&&(r.data=ke.generateRandomNameArray(t,3,6)),r},Ce=()=>{const e=[],t=ke.pick([!0,!1]);let r=ke.randomNum(3,20);const i=ke.pick([null,null,null,{}]);let o=ke.pick(["asc","desc",void 0,void 0,void 0]),a=ke.randomNum(1,9),n=ke.pick([!0,!1]);for(let s=0;s<a;s++){let a={data:ke.generateRandomIntArray(r,0,300,o),type:"bar",smooth:t,stack:n,areaStyle:i};e.push(a)}let s=ke.pick(["value","category"]),l=ke.pick(["value","category"],s);return{xAxis:Ae(s,r),grid:{left:0,top:0,bottom:0,right:0},yAxis:Ae(l,r),series:e}},xe=()=>{const e=[];let t=ke.randomNum(3,20);ke.pick([null,null,null,{}]);let r=ke.pick(["asc","desc",void 0,void 0,void 0]),i=ke.pick([1,2]),o=[ke.pick(["10%","20%","30%","40%","50%","60%","70%","80%"]),ke.pick(["90%","100%"])];return e.push({data:ke.generateRandomIntArray(t,3,20,r),type:"pie",radius:1==i?"100%":o,roseType:1==i?ke.pick(["area",null,null]):null,padAngle:1==i?0:ke.randomNum(1,5),startAngle:1==i?ke.pick([0,180]):0,endAngle:360,label:{show:!1},itemStyle:{borderRadius:3}}),{grid:{left:0,top:0,bottom:0,right:0},series:e}},Oe=()=>{const e=[];ke.pick([!0,!1]),ke.randomNum(3,20),ke.pick([null,null,null,{}]),ke.pick(["asc","desc",void 0,void 0,void 0]);for(let t=0;t<ke.randomNum(1,20);t++){let t=ke.randomNum(3,ke.randomNum(3,20)),r=[];for(let e=0;e<t;e++){let e=[];for(let t=0;t<2;t++)e.push(ke.randomNum(1,30));r.push(e)}e.push({type:"scatter",symbolSize:ke.randomNum(3,30),data:r})}return{xAxis:{show:!1},grid:{left:0,top:0,bottom:0,right:0},yAxis:{show:!1,type:"value"},series:e}},Ve=()=>{const e=[],t=ke.pick(["polygon","circle"]);let r=ke.randomNum(1e4,99999),i=ke.randomNum(3,10),o=[];for(let e=0;e<i;e++)o.push({name:ke.randomString(4,8),max:r});for(let t=0;t<ke.randomNum(2,10);t++)e.push({value:ke.generateRandomIntArray(i,1e4,r),name:ke.randomString(4,8)});return{radar:{shape:t,indicator:o,axisName:{show:!1},radius:"100%"},grid:{left:0,top:0,bottom:0,right:0},series:[{type:"radar",symbol:"none",lineStyle:{width:1},data:e}]}},Fe=()=>{const e=[];for(let t=0;t<ke.randomNum(4,15);t++)e.push({value:ke.randomNum(1,100),name:ke.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:ke.pick(["descending","ascending"]),gap:2,lineStyle:{width:1},data:e}]}};let Te=ke.randomNum(5,20);const Ee={width:Te};ke.pick([!0,!1])&&(Ee.color=[[.3,"#67e0e3"],[.7,"#37a2da"],[1,"#fd666d"]]);class Ie{constructor(){this.names=["line","bar","pie","scatter","radar","funnel","gauge"]}static getInstance(){return Ie.instance||(Ie.instance=new Ie),Ie.instance}createLine(){switch(ke.pick(this.names)){case"line":return{type:"line",typeNum:1,option:Se()};case"bar":return{type:"bar",typeNum:2,option:Ce()};case"pie":return{type:"pie",typeNum:3,option:xe()};case"scatter":return{type:"scatter",typeNum:4,option:Oe()};case"radar":return{type:"radar",typeNum:5,option:Ve()};case"funnel":return{type:"funnel",typeNum:6,option:Fe()};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:ke.pick([!0,!1]),width:Te},axisLine:{lineStyle:Ee},data:[{value:ke.randomNum(1,100),name:"SCORE"}]}]}}}}}Ie.instance=null;const Re=Ie.getInstance();const Pe=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,r=(null==e?void 0:e.colNum)?null==e?void 0:e.colNum:this.splitNumbers,i=e.wrapWidth/r,o=e.wrapHeight/t;let a=F(this.directions);a&&(this.direction=a);let n=[];if("row"===this.direction){let e=F([3,4]);n=this.simulateRandomSegments(24,4,12,e)}else{let e=F([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:o});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:o})}let e=F([2,3]),t=this.simulateRandomSegments(24,6,12,e);for(let e=0;e<s.length;e++){const r=s[e];for(let a=0;a<t.length;a++){const n=t[a];l.push({x:r.x,y:n,w:r.w,h:n,i:10*e+a,wStep:i,hStep:o})}}}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:o});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:o})}for(let e=0;e<s.length;e++){const t=s[e];let r=F([1,2,3,4]),a=this.simulateRandomSegments(24,5,12,r),n=[];for(let r=0;r<a.length;r++){const s=a[r];if(0==r)n.push({x:0,y:t.y,w:s,h:t.h,i:10*e+r,wStep:i,hStep:o}),l.push({x:0,y:t.y,w:s,h:t.h,i:10*e+r,wStep:i,hStep:o});else{let d=n[r-1].x;n.push({x:a[r-1]+d,y:t.y,w:s,h:t.h,i:10*e+r,wStep:i,hStep:o}),l.push({x:a[r-1]+d,y:t.y,w:s,h:t.h,i:10*e+r,wStep:i,hStep:o})}}}}return{layouts:l.map((t=>{let{option:r,typeNum:i}=Re.createLine(),o=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=r,t.typeNum=i,t.txt=i+" "+o/l+" "+a/d+" "+n/l+" "+s/d,console.log(t.txt),t})),option:{colNum:r,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,r,i){const o=[];let a=e,n=i;for(;n>0;)if(1===n)o.push(a),n--;else{const e=Math.min(r,a-t*(n-1)),i=Math.floor(Math.random()*(e-t+1))+t;o.push(i),a-=i,n--}return o}simulateRandomSegments2(e,t,r,i){const o=[];let a=e,n=i;for(;n>0;)if(1==n){const t=e-o.reduce(((e,t)=>e+t),0);o.push(t),n--}else{let e=Math.floor(Math.random()*r),i=Math.max(t,e),s=a-t*n;const l=Math.min(i,s);o.push(l),a-=l,n--}return o}};class je{constructor(e,t,r,i){this.caseId=e,this.mode=t,this.environment=r,this.xhr=i}checkHardware(){return o(this,void 0,void 0,(function*(){return yield new Promise(((e,t)=>{e("Hardware is not available")}))}))}initBefore(){return new Promise(((e,t)=>{let r=c("secretFree");r?sessionStorage.setItem("secret-free",r):sessionStorage.setItem("secret-free",null),console.log("运行免登录设置完成!"),e(!0)}))}fetchCaseId(e,t){return o(this,void 0,void 0,(function*(){try{const r=yield this.getKey(e,t);return 2e4===(null==r?void 0:r.code)&&(null==r?void 0:r.data)?r.data:e}catch(t){return console.error("Error fetching caseId:",t),e}}))}getDataForPublish(){return new Promise(((e,t)=>{e("data")}))}detectEnvironment(){return"localhost"===window.location.hostname?"preview":"publish"}authenticate(){return o(this,void 0,void 0,(function*(){this.environment}))}getShareForRelease(e){return this.xhr.get(`/go/v1/go-share/v1/${e}/config`)}findById(e,t="",r=0,i=""){return"publish"===this.environment?this.xhr.get(`/go/v1/go-share/v1/${e}?pwd=${t}&mode=${r}`):this.xhr.get(`/go/v1/go-cases/v1/${e}?mode=${r}`)}getKey(e,t=0){return this.xhr.get(`/go/v1/go-cases/v1/key/${e}?caseMode=${t}`)}fetchProjectForId(e,t="",r=0,i=""){return o(this,void 0,void 0,(function*(){return yield this.findById(e,t,r,i)}))}setTheme(){console.log("设置主题")}setBackground(){console.log("设置背景信息")}updateVariables(){console.log("更新变量信息")}beforeRender(e){}renderComponents(){return o(this,void 0,void 0,(function*(){}))}listenForRenderCompletion(){}showAnimation(){console.log("所有组件渲染完成,显示动画。")}init(){return o(this,void 0,void 0,(function*(){try{let e=yield this.fetchCaseId(this.caseId,this.mode);console.log(e);const t=yield this.fetchProjectForId(e);console.log(t,"currentData"),this.updateVariables()}catch(e){console.error("加载页面时出错:",e)}}))}}export{Ne as ConfigOptimizer,he as GlobalVariables,z as Http,L as Log,je as PageLoader,B as agentData,C as delFetchStatus,Pe as displayGenerator,ie as editItem,ve as emitEvent,te as fetchDataByGlobal,ee as fetchDataByType,re as filterData,D as findItemDeep,N as findItemDeep2,G as getData,W as getDataForApi,K as getDataForSource,Q as getDataForStatic,X as getDataForZb,_ as getDataForZbCQ,m as getSessionData,u as getStandardData,y as getStringVars,c as getUrlParams,fe as getVarDefaultVal,pe as globalVars,w as hasVar,h as isJSON,v as recursion,se as replaceVariable,k as safeEval,S as safeEvalForCode,A as setFetchStatus,p as setSessionData,de as updataGlobalDataSourceForVar,oe as updateComData,ce as updateGlobalDataSource};
|
|
1
|
+
import e from"axios";import t,{uniq as r}from"lodash";import i from"crypto-js";function o(e,t,r,i){return new(r||(r=Promise))((function(o,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?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(n,s)}l((i=i.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class a{constructor(){this.requests=[],console.log("RequestTracker")}static getInstance(){return a.instance||(a.instance=new a),a.instance}addRequest(e){this.isDuplicateRequest(e)&&this.findRequest(e),this.requests.push(e)}findRequest(e){let t;for(const r of this.requests)if(this.areRequestsEqual(r,e)){t=r;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){return e.url===t.url&&JSON.stringify(e.data)===JSON.stringify(t.data)&&JSON.stringify(e.params)===JSON.stringify(t.params)&&e.method===t.method}}const n=a.getInstance(),s=3e3,l=3e3,d=(t="",r)=>{let i,o=e.create({baseURL:t,timeout:s,headers:{"Content-Type":"application/x-www-form-urlencoded;charset=UTF-8"}});return o.interceptors.request.use((function(t){let{url:r,params:o,headers:a,data:s,method:l}=t;const d=e.CancelToken.source();return i={url:r,params:o,headers:a,data:s,method:l,cancelToken:d},t.cancelToken=d.token,n.addRequest(i),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)})),o.interceptors.response.use((function(e){return 200===e.status||e.data.code,r&&r(e),n.removeRequest(i),e.data}),(function(e){return r&&(n.removeRequest(i),r(null==e?void 0:e.response)),Promise.reject(e.response)})),o},c=(e,t)=>{try{let r=t||window.location.href;if(-1!=r.indexOf("?")){let t={};return r.slice(r.indexOf("?")+1).split("&").forEach((e=>{let r=e.split("=");t[r[0]]=r[1]})),e?t[e]?t[e]:null:t}return console.log("没有参数"),null}catch(e){console.error(e)}};function u(e,t=!1){try{return t?h(e)?e:JSON.stringify(e):h(e)?JSON.parse(e):e}catch(t){return console.log("转化JSON 发生错我!",e),e}}const h=e=>{if("string"==typeof e)try{const t=JSON.parse(e);return"object"==typeof t&&null!==t}catch(e){return!1}return!1},p=(e,t)=>{try{const r=JSON.stringify(t);sessionStorage.setItem(e,r)}catch(t){console.error(`Error setting session data for key ${e}:`,t)}},m=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},f=e=>{for(const t of e)t.code&&(t.code=t.code.replace(/>/g,">").replace(/</g,"<"))},g=(e,t)=>{e instanceof Map?e.forEach((e=>{t([e])})):Array.isArray(e)&&e.forEach((e=>{t(e.children)}))},v=(e,t)=>{const r=e=>{var i,o,a;if(e)for(const n of e){const e=null===(a=null===(o=null===(i=null==n?void 0:n.tmpData)||void 0===i?void 0:i.source)||void 0===o?void 0:o.converse)||void 0===a?void 0:a.data;(null==e?void 0:e.length)&&f(e),t(n),n.children?r(n.children):n.dynamicChildren?g(n.dynamicChildren,r):n.stateChildren&&r(n.stateChildren)}};r(e)},y=(e,t,r,i)=>{const o=e.match(/({{[\w]*}})|((@)[\w]*)/gm);if(o){const e=o.map((e=>e.replace(/{{|}}|@/gm,"")));for(const o of e)if(o&&t&&!(t.findIndex((e=>e.mapField===o))<0))return r&&i&&b(i,o,r.cid),!0}return!1},b=(e,t,r)=>{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(!r)throw new Error("ID is required");Array.isArray(e[t])||(e[t]=[]),e[t].includes(r)||e[t].push(r)},w=(e,t,r)=>{var i;let o=!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))&&(o=y(n.inputSql||n.url||(null===(i=n.headers)||void 0===i?void 0:i.value)||n.params,r)),o},D=(e,r,i=!1)=>{let o=null;const a=e=>{for(const n of e){if(n.cid===r){o=n,i&&t.remove(e,(e=>e.cid===r));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),o},N=(e,r,i)=>{let o=!1;const a=e=>{for(let n=0;n<e.length;n++){if(e[n].cid==r){o=e[n],i&&t.remove(e,(e=>e.cid==r));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 r=t[e][1];a(r)}}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 r=t[e][1];a(r)}}}else e[n].stateChildren&&a(e[n].stateChildren)}};return a(e),o||!1};function k(e,t,r){const i={};r&&r.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 S(e,r,i){let o=t.cloneDeep(r);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)(o,a)}catch(e){return console.error(e),o}}const A=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)},C=e=>{let t=window.goFetchList;t&&t[e]&&delete t[e]},x="anov@2019:helloX",O="anov@2020:helloX";function V(e){let t=i.enc.Utf8.parse(x),r=i.enc.Utf8.parse(O);return i.AES.encrypt(e,t,{iv:r,mode:i.mode.CBC,padding:i.pad.Pkcs7}).toString()}function F(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 r=t.reduce(((e,t)=>e+t),0),i=Math.random()*r;let o=0;for(let r=0;r<e.length;r++)if(o+=t[r],i<o)return e[r];return e[0]}const T=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"]),E=URL.createObjectURL(T);function I(e,t,r={},i="worker"){return o(this,void 0,void 0,(function*(){try{if("window"==i){let[i,o]=[["data"],[t]];"object"==typeof r&&Object.keys(r).forEach((e=>{i.push(e),o.push(r[e])}));const a=new Function(...i,e);return{success:!0,data:a(...o)}}{let[i,a,n]=[t,r,""];"object"==typeof i&&(i=JSON.stringify(t)),"object"==typeof r&&(a=JSON.stringify(r)),Object.keys(r).forEach((e=>n+=`${e},`));let s=`let data=eval(${i}); \n let app=${JSON.stringify({})};`;s+=n?`let {${n}} = eval(${a}); `:"",s+=`${e}`;let l=yield function(e,t=5e3){return o(this,void 0,void 0,(function*(){let r=new Worker(E);return new Promise(((i,o)=>{const a=()=>{clearTimeout(s),r.removeEventListener("message",n),r.terminate(),r=null},n=e=>{let{code:t,result:r,err:n}=e.data;a(),1===t?i(r):o(n)};r.postMessage({code:e}),r.addEventListener("message",n);let s=setTimeout((()=>{a(),o("timeout")}),t)}))}))}(s);return{success:!0,data:l}}}catch(e){return{success:!1,error:e,data:t}}}))}var R,P,j,q;!function(e){e.StaticFile="staticFile",e.DataSource="datasource"}(R||(R={})),function(e){e.json="application/json;charset=UTF-8",e.form="application/x-www-form-urlencoded; charset=UTF-8"}(P||(P={})),function(e){e.get="GET",e.post="POST",e.put="PUT",e.patch="PATCH",e.delete="DELETE"}(j||(j={}));class M{constructor(e){this.db=null,this.dbName=e.databaseName,this.tableName=e.tableName,this.keyPath=e.keyPath}static getInstance(e){return M.instance||(M.instance=new M(e)),M.instance}init(){return o(this,void 0,void 0,(function*(){return new Promise(((e,t)=>{const r=indexedDB.open(this.dbName,1);r.onerror=e=>{t(e.target.error)},r.onupgradeneeded=e=>{this.db=e.target.result,this.db.objectStoreNames.contains(this.tableName)||this.db.createObjectStore(this.tableName,{keyPath:this.keyPath})},r.onsuccess=t=>{this.db=t.target.result,e()}}))}))}addRecord(e){return o(this,void 0,void 0,(function*(){if(!this.db)throw new Error("数据库未初始化。");return new Promise(((t,r)=>{const i=this.db.transaction([this.tableName],"readwrite").objectStore(this.tableName).add(e);i.onsuccess=()=>{t()},i.onerror=e=>{r(e.target.error)}}))}))}deleteRecord(e){return o(this,void 0,void 0,(function*(){if(!this.db)throw new Error("数据库未初始化。");return new Promise(((t,r)=>{const i=this.db.transaction([this.tableName],"readwrite").objectStore(this.tableName).delete(e);i.onsuccess=()=>{t()},i.onerror=e=>{r(e.target.error)}}))}))}updateRecord(e){return o(this,void 0,void 0,(function*(){if(!this.db)throw new Error("数据库未初始化。");return new Promise(((t,r)=>{const i=this.db.transaction([this.tableName],"readwrite").objectStore(this.tableName).put(e);i.onsuccess=()=>{t()},i.onerror=e=>{r(e.target.error)}}))}))}getRecord(e){return o(this,void 0,void 0,(function*(){if(!this.db)throw new Error("数据库未初始化。");return new Promise(((t,r)=>{const i=this.db.transaction([this.tableName],"readonly").objectStore(this.tableName).get(e);i.onsuccess=()=>{t(i.result)},i.onerror=e=>{r(e.target.error)}}))}))}getAllRecords(){return o(this,void 0,void 0,(function*(){if(!this.db)throw new Error("数据库未初始化。");return new Promise(((e,t)=>{const r=this.db.transaction([this.tableName],"readonly").objectStore(this.tableName).getAll();r.onsuccess=()=>{e(r.result)},r.onerror=e=>{t(e.target.error)}}))}))}}M.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"}(q||(q={}));const $={databaseName:"GODB",tableName:"go-log",keyPath:"time"};class U{constructor(){this.logLevel=q.INFO,this.indexedDBInstance=M.getInstance($);try{this.indexedDBInstance.init(),console.log("IndexedDB 初始化成功。")}catch(e){console.error("初始化 IndexedDB 时出错:",e)}}static getInstance(){return U.instance||(U.instance=new U),U.instance}setLogLevel(e){this.logLevel=e}getColor(e){switch(e){case q.FATAL:return"[31;1m";case q.ERROR:return"[31m";case q.WARN:return"[33m";case q.INFO:return"[32m";case q.DEBUG:return"[36m";case q.TRACE:return"[34m";default:return"[0m"}}log(e,t){if(t<=this.logLevel){const r=(new Date).toISOString(),i=`[${r}] [${q[t]}]`,o=this.getColor(t);if(null===window||void 0===window?void 0:window.goDev)console.log(`${o}${i} ${e}[0m`);else{let t=m("anov-go-userInfo"),a=m("anov-go-proid"),n=` [操作人:${null==t?void 0:t.userName} 项目ID:${a}] `;const s={time:r,value:`${e}`};try{this.indexedDBInstance.addRecord(s)}catch(e){console.error("添加记录时出错:",e)}console.log(`${o}${i} ${n} ${e}[0m`)}}}fatal(e){this.log(e,q.FATAL)}error(e){this.log(e,q.ERROR)}warn(e){this.log(e,q.WARN)}info(e){this.log(e,q.INFO)}debug(e){this.log(e,q.DEBUG)}trace(e){this.log(e,q.TRACE)}}const L=U.getInstance(),z=(e,t)=>"string"!=typeof e?Promise.reject(new Error("URL should be a string")):d(e,t),H=d();let J=d();function G(e,r="get",i={},a={}){return o(this,void 0,void 0,(function*(){try{const n={method:j[r],url:e,headers:a,timeout:l};["post","put"].includes(r.toLowerCase())?n.data=t.cloneDeep(i):n.params=t.cloneDeep(i);return/.json$/.test(e)?function(e){return o(this,void 0,void 0,(function*(){try{return(yield H({method:"get",url:e})).data}catch(e){throw console.error("JSON 数据请求:",e),e}}))}(e):function(e){return o(this,void 0,void 0,(function*(){try{return{code:2e4,data:(yield H(e)).data}}catch(e){throw console.error("请求数据发生错误-Error:",e),e}}))}(n)}catch(e){throw console.error("获取数据:Error:",e),e}}))}function B(e,t,r,i){return o(this,void 0,void 0,(function*(){try{const o=window.anUrl||"",a=o+(window.agentPath||"/ds/v1/api-proxy/v1/query"),n=u(r,!0);return yield H({url:a,method:"post",headers:{"Content-Type":"application/json;charset=UTF-8"},data:{body:"post"===e?n:void 0,headers:h(i)?u(i,!0):i,method:e,url:t}})}catch(e){throw console.error("代理请求数据:Error1:",e),e}}))}function W(e,t,r,i,a){return o(this,void 0,void 0,(function*(){return a?B(t,e,r,i):G(e,t,r,i)}))}function X(e,t="",r){var i,o,a,n;const l=`${null!==(o=null===(i=null===window||void 0===window?void 0:window.BaseUrl)||void 0===i?void 0:i.replace("/management",""))&&void 0!==o?o:""}/ds/data-engine/v1/${e}/zb-query?${`token=${(null===(a=ae("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 H({method:"POST",url:l,data:{headers:r,param:d},timeout:s})}const _=(e,t)=>o(void 0,void 0,void 0,(function*(){const r=window.BaseUrl,{dateType:i="",endPeriod:o="",metricsName:a=e,startPeriod:n=""}=t;return J({method:"GET",url:`${r}ds/v1/metrics/v1/data-alarm?dateType=${i}&endPeriod=${o}&metricsName=${a}&startPeriod=${n}`,timeout:s})})),K=(e,t,r)=>o(void 0,void 0,void 0,(function*(){var i;const o=(null===(i=window.BaseUrl)||void 0===i?void 0:i.replace("/management",""))||"";t.newEncryption=!0;const a={staticFile:{method:"get",params:t,url:`${o}/ds/v1/file/v1/${e}/query`},datasource:{method:"post",url:`${o}/ds/v1/database/v1/${e}/query`,data:Object.assign({},t)}}[r];if(!a)throw new Error("Invalid data type provided");return H(Object.assign({timeout:s},a))})),Q=e=>new Promise(((t,r)=>{let i;i=e.originData&&Object.keys(e.originData).length?e.originData:e.data,void 0!==i?t({data:i}):r("Failed to retrieve cdata")})),Y=(e,t,r)=>{try{switch(t){case"api":{let t=le(e,r);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=se(e.inputSql,r);return{dsName:e.dsName,dsType:"1",sql:V(t),filter:e.sqlFilter}}case"staticFile":return{dsName:e.dsName,dsType:e.dsType,sql:""};case"indicator":return{zbId:e.zbId,params:se(e.params,r),headers:se(e.headers,r)};case"indicatorCQ":return{zbName:e.zbName,params:se(e.params,r)};case"packData":return{};default:throw new Error("Invalid type")}}catch(t){console.log("准备请求数据发生错误",t,e)}},Z=(e,t)=>o(void 0,void 0,void 0,(function*(){try{switch(t){case"api":return yield W(e.url,e.requestType,e.params,e.headers,e.agency);case"static":return yield Q(e.data);case"datasource":return yield K(e.dsName,{dsType:e.dsType,sql:e.sql,filter:e.filter},"datasource");case"staticFile":return yield K(e.dsName,{dsType:e.dsType,sql:e.sql},"staticFile");case"indicator":return yield X(e.zbId,e.params,e.headers);case"indicatorCQ":return yield _(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})}))}})),ee=(e,t,r,i=[],a=!1)=>o(void 0,void 0,void 0,(function*(){const o=t||e.tmpData.source.dataType,n=e.tmpData.source["indicatorCQ"==o?"indicator":o];if("globalData"===o){const e=i.find((e=>e.key===n.id||e.key===n.key)),t=m(n.id);if(t&&!a)return t.data;if(e){let t=yield te(e,r),i={key:n.id,data:t};return p(n.id,i),t}return}const s=Y(n,o,r),l=yield Z(s,o);return(null==l?void 0:l.data)?l.data:l})),te=(e,t)=>o(void 0,void 0,void 0,(function*(){let r=Object.assign({},{tmpData:{source:e.value}});const i=r.tmpData.source.type,o=r.tmpData.source[i],a=Y(o,i,t),n=yield Z(a,i);return yield re(n.data,r,!0,t)})),re=(e,r,i=!0,a)=>o(void 0,void 0,void 0,(function*(){try{const{converse:n,mapFields:s}=r.tmpData.source;return n&&n.use&&i?yield new Promise(((r,i)=>{const s=function(e,r,i,a,n){return o(this,void 0,void 0,(function*(){let i,o=e,{use:n,data:s}=t.cloneDeep(r);if(n)for(let e=0;e<s.length;e++)if(s[e].use){let r=s[e].dependVars,n={};a&&n&&r&&r.length&&r.map((e=>{let r=t.cloneDeep(a).filter((t=>{let r=t.mapField==e;return r&&(n[e]=t.value),r}));r&&0!=r.length||(n[e]="")})),i=yield I(s[e].code,o,n,s[e].mode?s[e].mode:"worker"),o=i.data}return o}))}(e,n,0,a);r(s)})):yield new Promise(((t,r)=>{t(e)}))}catch(t){return console.error("执行过滤器发生错误:"+t),yield new Promise(((t,r)=>{t(e)}))}})),ie=(e,t,r)=>{const{source:i}=e.tmpData,o=i.type;r?("static"===o&&i[o]&&(i[o].originData=r),"indicatorCQ"===o?i.indicator.data=t:i[o].data=t):"indicatorCQ"===o?i.indicator.data=t:i[o].data=t,e.source=t},oe=(e,t,r=[],i,a,n)=>o(void 0,void 0,void 0,(function*(){try{let o=e.tmpData.source.type,s=yield ee(e,o,r,i,n||!1);if(null==s||!s)return a&&a({error:!0}),Promise.resolve({error:!0});let l=yield re(s,e,t,r);return ie(e,l),a&&a(l),(null==e?void 0:e.cid)&&C(e.cid),Promise.resolve(l)}catch(e){return a&&a(e),L.error("Error in updateComData"),console.error("Error in updateComData:",e),Promise.reject(e)}})),ae=e=>{const t={};if(e&&e.includes("?")){const r=e.split("?")[1].split("&");for(let e of r){const[r,i]=e.split("=").map(decodeURIComponent);t[r]=i}}return t},ne=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}},se=(e,t)=>{if(!t)return ne(e);if("string"==typeof e){if(""===e.trim())return"";try{if("string"!=typeof JSON.parse(e))return se(JSON.parse(e),t);{let r=e.replace(/@(\w+)|{{(\w+)}}/g,((e,r,i)=>{const o=r||i,a=t.find((e=>e.mapField===o));return a?a.value||a.originalValue||"":e}));return ne(r)}}catch(r){let i=e.replace(/@(\w+)|{{(\w+)}}/g,((e,r,i)=>{const o=r||i,a=t.find((e=>e.mapField===o));return a?a.value:e}));return ne(i)}}else{if(Array.isArray(e))return e.map((e=>se(e,t)));if("object"==typeof e&&null!==e){const r={};for(let i in e)r[i]=se(e[i],t);return ne(r)}}return ne(e)},le=(e,t)=>{const r=e.agency,i=e,{url:o=null,headers:a,params:n,requestType:s}=i,l=o?se(o,t):void 0,d=a&&a.use?se(a.value,t):{};return{url:l,requestType:s,params:n?se(n,t):{},headers:d,agency:r}},de=(e,t,r,i,a)=>o(void 0,void 0,void 0,(function*(){if(e&&e.length)for(const o of e){w(t,o.value,r)&&(yield oe({tmpData:{source:{type:"globalData",globalData:{id:o.key}}}},!0,r,e,(e=>{console.log("数据更新成功-变量改变全局数据跟新")}),!0),v(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===o.key&&oe(t,!0,r,e,(e=>{a(t,e)}),!1)}})))}})),ce=(e,t,r,i,a)=>o(void 0,void 0,void 0,(function*(){e&&(yield oe({tmpData:{source:{type:"globalData",globalData:{id:e.key}}}},!0,t,r,(e=>{console.log("数据更新成功-数据源编辑")}),!0),v(i,(i=>{var o,n,s;if("globalData"===(null===(n=null===(o=null==i?void 0:i.tmpData)||void 0===o?void 0:o.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&&oe(i,!0,t,r,(e=>{a(i,e)}),!1)}})))}));class ue{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 S(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 o=Object.assign({},this,e);this.des=o.des,this.field=o.field,this.mapping=o.mapping,this.type=o.type,this.originalValue=o.originalValue,this.converter=o.converter,this.converterCode=o.converterCode,this.fork=o.fork,this.delayUpdate=null==o?void 0:o.delayUpdate,this.model=null==o?void 0:o.model,e.id&&(this.id?"string"==typeof this.id?e.id instanceof Array?this.id=r([this.id,...e.id]):this.id=[this.id,e.id]:this.id instanceof Array&&(e.id instanceof Array?this.id=r([...this.id,...e.id]):this.id=r([...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 r;this.originalValue=e,this.fork&&(this.forkValue=null!==(r=this.forkValue)&&void 0!==r?r:this.forkValue,this.originalValue=this.getForkedValue()),t&&t(this)}renew(e){e&&e(this)}static create(e,t){return new ue(e,t)}}class he{constructor(){this.variables=new Map,this.globalObservers=[],this.url=window.location.search,this.list=[]}clearVars(){this.list=[],this.variables.clear()}togglePropertyState(e,t,r){try{let i=this.getVariable(e);if(!i)throw new Error("没有找到相应的变量!");i.togglePropertyState(t),this.addToObjectArray(this.list,i),r&&r()}catch(e){console.error(e)}}static getInstance(){return he.instance||(he.instance=new he),he.instance}getFullUrl(){this.url=window.location.search}getAllUrlParams(){const e=new URLSearchParams(window.location.search),t={};for(const[r,i]of e.entries())t[r]=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),r=[];for(const i of t)r.push({mapField:i,originalValue:e[i],model:4});if(r.length)for(const e of r)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 r=this.getVariable(e.mapField);return this.sameValue(r,e)?r:(this.editVariable(e,t),!1)}const r=ue.create(e,this.variables);return this.variables.set(r.mapField,r),this.addToObjectArray(this.list,r),t&&t(r),this.notifyGlobalObservers(r),r}toJSON(e){try{return!!e&&JSON.stringify(e)}catch(e){return!1}}sameValue(e,t){if(e.mapfield!==t.mapfield)return!1;for(const r in t)if(!(["mapfield","field","key","value","name","globalVariables"].includes(r)||r in e&&e[r]==t[r]))return!1;return!0}creatVarJson(e){const{des:t,field:r,id:i,key:o,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!==r&&(v.field=r),void 0!==i&&(v.id=i),void 0!==o&&(v.key=o),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 r=!1;for(let i=0;i<e.length;i++)if(e[i].mapField==t.mapField){e[i]=this.creatVarJson(t),r=!0;break}r||e.push(t)}editVariable(e,t){const r=this.getVariable(e.mapField);if(r&&this.isVariableNameExist(e.mapField)){if(this.sameValue(r,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}};r?r.updateValue(e,i):this.addVariable(e,i)}getForkList(e){let t=this.isMapFieldInForkValues(e);return t||[]}editVariableForValue(e,t,r){const i=this.getVariable(e),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),r&&r(e),e.isUpdating=!1}};i&&i.updateWidthOriginalValue(t,o)}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 r=this.getVariable(e);return t==r.id&&!r.id.includes(t)&&[{key:e}]}if(Array.isArray(e)){const r=e.filter((e=>{let r=this.getVariable(e);return this.isVariableNameExist(e)&&t!=r.id&&!(r.id&&r.id.includes(t))})).map((e=>({key:e})));return!!r.length&&r}return!1}getVariable(e){return this.variables.get(e)}getVariableForId(e){var r;let i=[];for(const[,t]of this.variables)(t.id===e||(null===(r=t.id)||void 0===r?void 0:r.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)}))}}he.instance=null;const pe=he.getInstance(),me=(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))),fe=(e,t,r,i)=>{const o=((e,t,r,i)=>{var o;let a;if(me(e,null==t?void 0:t.field)||me(e,null==t?void 0:t.forkValue))a=e[null==t?void 0:t.field]||"";else if(me(e.data,null==t?void 0:t.field)||me(e.data,null==t?void 0:t.forkValue))a=e.data[null==t?void 0:t.field]||"";else{const e=D(r,i),n=(null===(o=null==e?void 0:e.tmpData)||void 0===o?void 0:o.actions)||[];for(const e of n){const r=e.vars.find((e=>(null==e?void 0:e.mapField)===(null==t?void 0:t.mapField)));if(r){a=r.value;break}}}return a})(e,t,r,i);return void 0!==o?o:t.value},ge=(e,t,r,i,o,a,n,s,l)=>{var d;switch(e.type){case"link":let c=se(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 r=e.params[t],i=a.find((e=>e.mapField==r.mapField));i&&(r.value=i.value)}l&&l(e);break;case"dynamic":((e,t,r,i,o)=>{const a=e.dynamic||[];for(const n of a){if(e.id!==t.cid)continue;const a=D(r,n.pid);a&&(a.activeDynamic=n.name,a.isShow=n.visible||!i||e.index===t.index-1,o({cid:a.cid,flag:n.visible}))}})(e,t,r,i,o);break;case"toggle":((e,t,r,i,o)=>{const a=e.children||[];for(const r of a){const a=r.visible&&(!i||e.index===t.index-1);o({cid:r.cid,flag:a})}})(e,t,0,i,o);break;case"update":((e,t,r,i,o)=>{const a=e.children||[];for(const e of a){const a=D(t,e.cid);a&&oe(a,!0,r,i,(e=>{o({cid:a.cid,data:e})}))}})(e,r,a,n,s)}},ve=(e,r,i,o,a,n,s,l,d,c)=>{const{cid:u,actions:h,index:p}=a,{eventName:m,mode:f}=h,g=2===f;((e,r,i,o,a,n)=>{let s=pe.getVariableForId(r.cid);if(null==s?void 0:s.length)for(const l of s)if(l.type==e){let e=fe(r,l,i,o);pe.editVariableForValue(l.mapField,e,(()=>{let e=a[l.mapField]||[],r=pe.getForkList(l.mapField);if(r)for(const i of r){let r=a[i.mapField];e=t.concat(e,r)}n&&n(l,t.uniq(e))}))}})(m,a,o,u,i,((e,t)=>{if(de(d,e.mapFile,pe.getAllVariables(),o,((e,t)=>{s({cid:e.cid,data:t})})),null==t?void 0:t.length)for(const r of t){e.eventSourceId=r;const t=D(o,r);!(null==e?void 0:e.delayUpdate)&&t&&oe(t,!0,pe.getAllVariables(),d,(e=>{s({cid:t.cid,data:e})}))}}));const v=((e,t,r,i,o)=>e.filter((e=>e.id===t&&e.eventType===r&&(!o||parseInt(e.index||"0")+1===parseInt(i||"0")))))(e,u,m,p,g);for(const e of v)ge(e,a,o,g,n,pe.getAllVariables(),d,s,l)},ye=(e,t={})=>{let r={},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(r,i,t),r},be=(e,r)=>{let{option:i,actions:o,data:a,optionDes:n,actionsDes:s,source:l,theme:d}=((e,r)=>{let{option:i,actions:o,data:a,optionDes:n,actionsDes:s,source:l,theme:d}=t.cloneDeep(r[e]);return{option:i,actions:o,data:a,optionDes:n,actionsDes:s,source:l,theme:d}})(e,r);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:ye(a,l),actions:o},baseData:De(),dynamic:null,filePath:"",origin:"anov-ui",name:"",componentType:"",viewComName:e,optionComName:"AnOptionPanel",dataComName:"AnSourcePanel",eventComName:"AnActionsPanel",assemblyDeveloper:"",devEmail:"",version:"",devDept:""}},we=(e,r,i)=>{let o=be(e,r);return i?t.merge(o,i):o},De=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 Ne{constructor(e,t,r){this.theme=null,this.plant=null,this.list=[],this.titleHeqadeHeight=70,this.clearance=3,this.checkComponentIntersection=(e,t,r=10)=>{const i=e.left,o=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&&o>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<r&&p<r},this.calculateCombinedComponent=e=>{if(0===e.length)return{left:0,top:0,width:0,height:0};let t=e[0].left,r=e[0].top,i=e[0].left+e[0].width,o=e[0].top+e[0].height;for(let a=1;a<e.length;a++){const n=e[a];t=Math.min(t,n.left),r=Math.min(r,n.top),i=Math.max(i,n.left+n.width),o=Math.max(o,n.top+n.height)}return{left:t,top:r,width:i-t,height:o-r}},this.getAnTextNormaltText=e=>{var t,r;try{return null===(r=null===(t=null==e?void 0:e.tmpData)||void 0===t?void 0:t.option)||void 0===r?void 0:r.text}catch(e){return console.error("配置优化(ConfigOptimizer):",e),""}},this.initProp(e),this.upgradePlant(),this.staticComponentData=t,this.upgradeHeaderComponent(),r&&Object.assign(this,r)}isStringOrObject(e){return"string"==typeof e?"string":"object"==typeof e&&null!==e&&"object"}initProp(e){try{let t,r=this.isStringOrObject(e);if(r&&"string"===r)t=JSON.parse(e);else{if(!r||"object"!==r)throw new Error(`initProp fn error :-- 传入参数${e}不合法!`);t=e}if(t){this.originData=t;const{theme:e,plant:r,list:i}=t;this.theme=e,this.plant=r,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 r=e.baseData,i=t.baseData;const o=Math.max(0,Math.min(r.left+r.width,i.left+i.width)-Math.max(r.left,i.left)),a=Math.max(0,Math.min(r.top+r.height,i.top+i.height)-Math.max(r.top,i.top));return o>0&&a>0}filterFileGroup(){this.list=t.cloneDeep(this.list).map((e=>{var t,r;if(1===(null===(t=null==e?void 0:e.children)||void 0===t?void 0:t.length)&&!(null===(r=null==e?void 0:e.children[0])||void 0===r?void 0:r.children)){const t=e.children[0],{left:r,top:i}=e.baseData;return t.baseData.left=r,t.baseData.top=i,t}return e}))}getText(e,t,r){const i=document.createElement("canvas").getContext("2d");if(!i)throw new Error("Failed to get 2D context from canvas.");i.font=`${r}px ${t}`;return i.measureText(e).width}calculateMaxWidths(e){const t=Math.min(...e.map((e=>e.width))),r=[];let i=[],o=e[0].width;for(const a of e){const e=a.width;Math.abs(e-o)<=t?i.push(e):(i.length>0&&r.push(i),i=[e]),o=e}i.length>0&&r.push(i);const a=[];for(const e of r){const t=Math.max(...e);a.push(t)}return a}findClosestValue(e,t){let r=t[0],i=Math.abs(e-r);for(const o of t){const t=Math.abs(e-o);t<i&&(i=t,r=o)}return r}adjustHeightAndTop(e,t){const r=t-e.height;return Object.assign(Object.assign({},e),{height:t,top:e.top-r/2})}findNearestComponent(e,r,i){let o=null,a=1/0;r.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===r.cid||"AnTextNormal"===e.viewComName||i&&i.includes(e.cid)))),s=t.cloneDeep(r).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 r=t.top-s.top;r<a&&r<100&&(a=r,o=e)}}}catch(e){console.error("配置优化(ConfigOptimizer)- findNearestComponent :",e)}return o}findNearestComponentForPoint(e,t,r){let i=null,o=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||r&&r.includes(e.cid)))),n=t.baseData;n.top,n.height;for(const e of a){const t=e.baseData;let r=this.getDistance(n.left,n.top+n.height,t.left,t.top);r<o&&r<n.width&&(o=r,i=e)}}catch(e){console.error("配置优化(ConfigOptimizer)- findNearestComponent :",e)}return i}findNearestComponentForTitlePoint(e,t,r){let i=null,o=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||r&&r.includes(e.cid)))),n=t.baseData;n.top,n.height;for(const e of a){const t=e.baseData;let r=this.getDistance(n.left,n.top+n.height,t.left,t.top);r<o&&r<n.width&&t.top-n.top>100&&(o=r,i=e)}}catch(e){console.error("配置优化(ConfigOptimizer)- findNearestComponent :",e)}return i}findNearestTitleForPoint(e,t,r){let i=null,o=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||r&&r.includes(e.cid)))),n=t.baseData;n.top,n.height;for(const e of a){const t=e.baseData;let r=t.top-n.top;r<o&&r<n.width&&t.top-n.top>100&&(o=r,i=e)}}catch(e){console.error("配置优化(ConfigOptimizer)- findNearestComponent :",e)}return i}getDistance(e,t,r,i){return Math.sqrt(Math.pow(r-e,2)+Math.pow(i-t,2))}findNearestComponent2(e,r,i){let o=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===r.cid||"AnTextNormal"===e.viewComName||i&&i.includes(e.cid)))),s=t.cloneDeep(r).baseData,l=s.top+s.height;for(const t of e){const e=t.baseData,r=e.top+e.height;if(s.left<e.left+e.width&&s.left+s.width>e.left){const e=r-l;e>=0&&e<a&&(a=e,o=t)}}}catch(e){console.error("配置优化(ConfigOptimizer)- findNearestComponent :",e)}return o}verticalDistance(e,t){e.left,e.width;const r=e.top+e.height,i=(t.left,t.width,t.top);return Math.abs(r-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=[],r=new Set;for(const i of e){if(r.has(i.cid))continue;let o=[];for(const t of e){if(!r.has(t.cid)&&i.cid!=t.cid){this.checkComponentIntersection(i.baseData,t.baseData)&&(r.add(t.cid),r.add(i.cid),o.push(t))}}t.push([i,...o])}let i=[];for(const e of t)for(const t of e){let r=this.getAnTextNormaltText(t);this.extractAmount(r).every((e=>e))&&i.push(e)}return i}createAnOdometer(){var e,r;let i=this.judgeAnOdometer();for(const o of i){let i,a,n,s=this.calculateCombinedComponent(o.map((e=>e.baseData)));for(const e of o){let r=this.getAnTextNormaltText(e),o=this.extractAmount(r);o.every((e=>!e))&&(i=r),o.every((e=>e))&&(a=o[0],n=o[1]),t.remove(this.list,(t=>t.cid==e.cid))}let l=we("AnIndicatorNormal",this.staticComponentData,t.cloneDeep({baseData:s}));(null===(r=null===(e=null==l?void 0:l.tmpData)||void 0===e?void 0:e.source)||void 0===r?void 0:r.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 r=this.list[e];if("AnDeckTitle3"==r.viewComName){let e=this.findClosestValue(r.baseData.width,t);r.baseData.width=e>300?e:300,r.baseData=this.adjustHeightAndTop(r.baseData,this.titleHeqadeHeight)}}this.removeErroneousComponents()}containsFractionStructure(e){return/\b\d+\/\d+\b/.test(e)}removeErroneousComponents(){let e=this.getAnDeckTitle3(),t=[];for(let r=0;r<e.length;r++){const i=e[r];let o=i.tmpData.option.textNormal.text;if(this.containsFractionStructure(o))for(let r=0;r<e.length;r++){const o=e[r];if(i.cid!=o.cid){this.areComponentsIntersecting(i,o)&&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)),r=[],i=[];for(let o=0;o<e.length;o++){const a=e[o];let n=this.findNearestComponentForPoint(t,a,r);if(n&&n.cid&&r.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,r,i=[]){const o=e;let a=this.findNearestTitleForPoint(t.cloneDeep(r),o);return a?a.baseData.top-o.baseData.top-this.titleHeqadeHeight:1080-o.baseData.top-this.titleHeqadeHeight}getData(){return this.originData.list=this.list,this.originData.plant=this.plant,this.originData}}const ke=new class{randomNum(e,t){return Math.floor(Math.random()*(t-e+1))+e}generateRandomIntArray(e,t,r,i){const o=[];for(let i=0;i<e;i++){const e=this.randomNum(t,r);o.push(e)}return i&&"asc"===i?o.sort(((e,t)=>e-t)):i&&"desc"===i?o.sort(((e,t)=>t-e)):o}randomString(e,t){const r="abcdefghijklmnopqrstuvwxyz",i=this.randomNum(e,t);let o="";for(let e=0;e<i;e++){const e=Math.floor(26*Math.random());o+=r.charAt(e)}return o}generateRandomNameArray(e,t,r){const i=[];for(let o=0;o<e;o++){const e=this.randomString(t,r);i.push(e)}return i}pick(e,t){const r=void 0!==t?e.filter((e=>e!==t)):e;return r[Math.floor(Math.random()*r.length)]}},Se=()=>{const e=[],t=ke.pick([!0,!1]);let r=ke.randomNum(3,20);const i=ke.pick([null,null,null,{}]);let o=ke.pick(["asc","desc",void 0,void 0,void 0]);for(let a=0;a<ke.randomNum(1,9);a++)e.push({data:ke.generateRandomIntArray(r,0,300,o),type:"line",smooth:t,symbolSize:ke.randomNum(1,10),lineStyle:{width:ke.randomNum(1,4)},areaStyle:i});return{xAxis:{type:"category",show:!1,boundaryGap:!1,data:ke.generateRandomNameArray(r,3,6)},grid:{left:0,top:0,bottom:0,right:0},yAxis:{show:!1,type:"value"},series:e}},Ae=(e,t)=>{let r={type:e,show:!1};return"category"===e&&(r.data=ke.generateRandomNameArray(t,3,6)),r},Ce=()=>{const e=[],t=ke.pick([!0,!1]);let r=ke.randomNum(3,20);const i=ke.pick([null,null,null,{}]);let o=ke.pick(["asc","desc",void 0,void 0,void 0]),a=ke.randomNum(1,9),n=ke.pick([!0,!1]);for(let s=0;s<a;s++){let a={data:ke.generateRandomIntArray(r,0,300,o),type:"bar",smooth:t,stack:n,areaStyle:i};e.push(a)}let s=ke.pick(["value","category"]),l=ke.pick(["value","category"],s);return{xAxis:Ae(s,r),grid:{left:0,top:0,bottom:0,right:0},yAxis:Ae(l,r),series:e}},xe=()=>{const e=[];let t=ke.randomNum(3,20);ke.pick([null,null,null,{}]);let r=ke.pick(["asc","desc",void 0,void 0,void 0]),i=ke.pick([1,2]),o=[ke.pick(["10%","20%","30%","40%","50%","60%","70%","80%"]),ke.pick(["90%","100%"])];return e.push({data:ke.generateRandomIntArray(t,3,20,r),type:"pie",radius:1==i?"100%":o,roseType:1==i?ke.pick(["area",null,null]):null,padAngle:1==i?0:ke.randomNum(1,5),startAngle:1==i?ke.pick([0,180]):0,endAngle:360,label:{show:!1},itemStyle:{borderRadius:3}}),{grid:{left:0,top:0,bottom:0,right:0},series:e}},Oe=()=>{const e=[];ke.pick([!0,!1]),ke.randomNum(3,20),ke.pick([null,null,null,{}]),ke.pick(["asc","desc",void 0,void 0,void 0]);for(let t=0;t<ke.randomNum(1,20);t++){let t=ke.randomNum(3,ke.randomNum(3,20)),r=[];for(let e=0;e<t;e++){let e=[];for(let t=0;t<2;t++)e.push(ke.randomNum(1,30));r.push(e)}e.push({type:"scatter",symbolSize:ke.randomNum(3,30),data:r})}return{xAxis:{show:!1},grid:{left:0,top:0,bottom:0,right:0},yAxis:{show:!1,type:"value"},series:e}},Ve=()=>{const e=[],t=ke.pick(["polygon","circle"]);let r=ke.randomNum(1e4,99999),i=ke.randomNum(3,10),o=[];for(let e=0;e<i;e++)o.push({name:ke.randomString(4,8),max:r});for(let t=0;t<ke.randomNum(2,10);t++)e.push({value:ke.generateRandomIntArray(i,1e4,r),name:ke.randomString(4,8)});return{radar:{shape:t,indicator:o,axisName:{show:!1},radius:"100%"},grid:{left:0,top:0,bottom:0,right:0},series:[{type:"radar",symbol:"none",lineStyle:{width:1},data:e}]}},Fe=()=>{const e=[];for(let t=0;t<ke.randomNum(4,15);t++)e.push({value:ke.randomNum(1,100),name:ke.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:ke.pick(["descending","ascending"]),gap:2,lineStyle:{width:1},data:e}]}};let Te=ke.randomNum(5,20);const Ee={width:Te};ke.pick([!0,!1])&&(Ee.color=[[.3,"#67e0e3"],[.7,"#37a2da"],[1,"#fd666d"]]);class Ie{constructor(){this.names=["line","bar","pie","scatter","radar","funnel","gauge"]}static getInstance(){return Ie.instance||(Ie.instance=new Ie),Ie.instance}createLine(){switch(ke.pick(this.names)){case"line":return{type:"line",typeNum:1,option:Se()};case"bar":return{type:"bar",typeNum:2,option:Ce()};case"pie":return{type:"pie",typeNum:3,option:xe()};case"scatter":return{type:"scatter",typeNum:4,option:Oe()};case"radar":return{type:"radar",typeNum:5,option:Ve()};case"funnel":return{type:"funnel",typeNum:6,option:Fe()};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:ke.pick([!0,!1]),width:Te},axisLine:{lineStyle:Ee},data:[{value:ke.randomNum(1,100),name:"SCORE"}]}]}}}}}Ie.instance=null;const Re=Ie.getInstance();const Pe=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,r=(null==e?void 0:e.colNum)?null==e?void 0:e.colNum:this.splitNumbers,i=e.wrapWidth/r,o=e.wrapHeight/t;let a=F(this.directions);a&&(this.direction=a);let n=[];if("row"===this.direction){let e=F([3,4]);n=this.simulateRandomSegments(24,4,12,e)}else{let e=F([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:o});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:o})}let e=F([2,3]),t=this.simulateRandomSegments(24,6,12,e);for(let e=0;e<s.length;e++){const r=s[e];for(let a=0;a<t.length;a++){const n=t[a];l.push({x:r.x,y:n,w:r.w,h:n,i:10*e+a,wStep:i,hStep:o})}}}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:o});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:o})}for(let e=0;e<s.length;e++){const t=s[e];let r=F([1,2,3,4]),a=this.simulateRandomSegments(24,5,12,r),n=[];for(let r=0;r<a.length;r++){const s=a[r];if(0==r)n.push({x:0,y:t.y,w:s,h:t.h,i:10*e+r,wStep:i,hStep:o}),l.push({x:0,y:t.y,w:s,h:t.h,i:10*e+r,wStep:i,hStep:o});else{let d=n[r-1].x;n.push({x:a[r-1]+d,y:t.y,w:s,h:t.h,i:10*e+r,wStep:i,hStep:o}),l.push({x:a[r-1]+d,y:t.y,w:s,h:t.h,i:10*e+r,wStep:i,hStep:o})}}}}return{layouts:l.map((t=>{let{option:r,typeNum:i}=Re.createLine(),o=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=r,t.typeNum=i,t.txt=i+" "+o/l+" "+a/d+" "+n/l+" "+s/d,console.log(t.txt),t})),option:{colNum:r,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,r,i){const o=[];let a=e,n=i;for(;n>0;)if(1===n)o.push(a),n--;else{const e=Math.min(r,a-t*(n-1)),i=Math.floor(Math.random()*(e-t+1))+t;o.push(i),a-=i,n--}return o}simulateRandomSegments2(e,t,r,i){const o=[];let a=e,n=i;for(;n>0;)if(1==n){const t=e-o.reduce(((e,t)=>e+t),0);o.push(t),n--}else{let e=Math.floor(Math.random()*r),i=Math.max(t,e),s=a-t*n;const l=Math.min(i,s);o.push(l),a-=l,n--}return o}};class je{constructor(e,t,r,i){this.caseId=e,this.mode=t,this.environment=r,this.xhr=i}checkHardware(){return o(this,void 0,void 0,(function*(){return yield new Promise(((e,t)=>{e("Hardware is not available")}))}))}initBefore(){return new Promise(((e,t)=>{let r=c("secretFree");r?sessionStorage.setItem("secret-free",r):sessionStorage.setItem("secret-free",null),console.log("运行免登录设置完成!"),e(!0)}))}fetchCaseId(e,t){return o(this,void 0,void 0,(function*(){try{const r=yield this.getKey(e,t);return 2e4===(null==r?void 0:r.code)&&(null==r?void 0:r.data)?r.data:e}catch(t){return console.error("Error fetching caseId:",t),e}}))}getDataForPublish(){return new Promise(((e,t)=>{e("data")}))}detectEnvironment(){return"localhost"===window.location.hostname?"preview":"publish"}authenticate(){return o(this,void 0,void 0,(function*(){this.environment}))}getShareForRelease(e){return this.xhr.get(`/go/v1/go-share/v1/${e}/config`)}findById(e,t="",r=0,i=""){return"publish"===this.environment?this.xhr.get(`/go/v1/go-share/v1/${e}?pwd=${t}&mode=${r}`):this.xhr.get(`/go/v1/go-cases/v1/${e}?mode=${r}`)}getKey(e,t=0){return this.xhr.get(`/go/v1/go-cases/v1/key/${e}?caseMode=${t}`)}fetchProjectForId(e,t="",r=0,i=""){return o(this,void 0,void 0,(function*(){return yield this.findById(e,t,r,i)}))}setTheme(){console.log("设置主题")}setBackground(){console.log("设置背景信息")}updateVariables(){console.log("更新变量信息")}beforeRender(e){}renderComponents(){return o(this,void 0,void 0,(function*(){}))}listenForRenderCompletion(){}showAnimation(){console.log("所有组件渲染完成,显示动画。")}init(){return o(this,void 0,void 0,(function*(){try{let e=yield this.fetchCaseId(this.caseId,this.mode);console.log(e);const t=yield this.fetchProjectForId(e);console.log(t,"currentData"),this.updateVariables()}catch(e){console.error("加载页面时出错:",e)}}))}}export{Ne as ConfigOptimizer,he as GlobalVariables,z as Http,L as Log,je as PageLoader,B as agentData,C as delFetchStatus,Pe as displayGenerator,ie as editItem,ve as emitEvent,te as fetchDataByGlobal,ee as fetchDataByType,re as filterData,D as findItemDeep,N as findItemDeep2,G as getData,W as getDataForApi,K as getDataForSource,Q as getDataForStatic,X as getDataForZb,_ as getDataForZbCQ,m as getSessionData,u as getStandardData,y as getStringVars,c as getUrlParams,fe as getVarDefaultVal,pe as globalVars,w as hasVar,h as isJSON,v as recursion,se as replaceVariable,k as safeEval,S as safeEvalForCode,A as setFetchStatus,p as setSessionData,de as updataGlobalDataSourceForVar,oe as updateComData,ce as updateGlobalDataSource};
|