UNPKG

@frangoteam/fuxa

Version:

Web-based Process Visualization (SCADA/HMI/Dashboard) software

1 lines 6.94 MB
(self.webpackChunkFUXA=self.webpackChunkFUXA||[]).push([[792],{8326:(Rt,Be,ie)=>{"use strict";ie.d(Be,{G:()=>D});var N=ie(5312),K=ie(7705);let D=(()=>{class e{static url=null;static getURL(){if(!this.url)if(N.c.apiEndpoint)this.url=N.c.apiEndpoint;else{location;let p=location.origin.split("/")[2];const h=location.origin.split(":")[0],g=p.split(":")[0];g.length>1&&N.c.apiPort&&(p=g+":"+N.c.apiPort),this.url=h+"://"+p}return this.url}static getRemoteURL(_){return location.origin.split(":")[0]+"://"+_+":"+N.c.apiPort+"/api"}static \u0275fac=function(p){return new(p||e)};static \u0275prov=K.jDH({token:e,factory:e.\u0275fac})}return e})()},3728:(Rt,Be,ie)=>{"use strict";ie.d(Be,{Aq:()=>K,yN:()=>D});var N=ie(7705);class K{static _seed=Date.now();static minDate=new Date(1970,0,1);static maxDate=new Date(2100,11,31);static defaultColor=["#FFFFFF","#000000","#EEECE1","#1F497D","#4F81BD","#C0504D","#9BBB59","#8064A2","#4BACC6","#F79646","#C00000","#FF0000","#FFC000","#FFD04A","#FFFF00","#92D050","#0AC97D","#00B050","#00B0F0","#4484EF","#3358C0","#002060","#7030A0","#D8D8D8","#BFBFBF","#A5A5A5","#7F7F7F","#595959","#3F3F3F","#262626"];static lineColor=["#4484ef","#ef0909","#00b050","#ffd04a","#7030a0","#a5a5a5","#c0504d","#000000"];static svgTagToType=["rect","line","path","circle","ellipse","text"];static walkTree(_,p){if(_&&1==_.nodeType){p(_);for(var h=_.childNodes.length;h--;)this.walkTree(_.childNodes.item(h),p)}}static searchTreeStartWith(_,p){if(_.id.startsWith(p))return _;if(null!=_.children){var h,g=null;for(h=0;null==g&&h<_.children.length;h++)g=K.searchTreeStartWith(_.children[h],p);return g}return null}static childrenStartWith(_,p){let h=[];for(let g=0;g<_.children?.length;g++)_.children[g].id.startsWith(p)&&h.push(_.children[g]);return h}static searchTreeTagName(_,p){if(_.tagName===p)return _;if(null!=_.children){var h,g=null;for(h=0;null==g&&h<_.children.length;h++)g=K.searchTreeTagName(_.children[h],p);return g}return null}static findElementByIdRecursive(_,p){if(!_)return null;if(_.id===p)return _;for(let h=0;h<_.children.length;h++){const w=this.findElementByIdRecursive(_.children[h],p);if(w)return w}return null}static searchValuesByAttribute(_,p){const h=[];return function g(w){if(Array.isArray(w))for(const y of w)g(y);else if("object"==typeof w&&null!==w){w.hasOwnProperty(p)&&h.push(w[p]);for(const y in w)g(w[y])}}(_),h}static changeAttributeValue(_,p,h,g){!function w(y){if(Array.isArray(y))for(const b of y)w(b);else if("object"==typeof y&&null!==y){y.hasOwnProperty(p)&&y[p]===h&&(y[p]=g);for(const b in y)w(y[b])}}(_)}static replaceStringInObject(_,p,h){let g=JSON.stringify(_);const w=new RegExp(p,"g");return g=g.replace(w,h),JSON.parse(g)}static getInTreeIdAndType(_){let p=_.getAttribute("type");!p&&K.svgTagToType.includes(_.tagName.toLowerCase())&&(p="svg-ext-shapes-"+_.tagName.toLowerCase());let h=_.getAttribute("id"),g=[];h&&p&&(g=[{id:h,type:p}]);for(var w=0;w<_.children.length;w++){const y=K.getInTreeIdAndType(_.children[w]);g=[...g,...y]}return g}static cleanObject(_){const p={};for(const h in _)null!=_[h]&&(p[h]=_[h]);return p}static isNullOrUndefined(_){return null==_}static enumKeys(_){return Object.keys(_)}static enumValues(_){return Object.keys(_).map(h=>Object(_)[h])}static getGUID(_=""){var h,g,p="";for(h=0;h<16;h++)g=16*Math.random()|0,8==h&&(p+="-"),p+=(12==h?4:16==h?3&g|8:g).toString(16);return _+p}static getShortGUID(_="",p="-"){var g,w,h="";for(g=0;g<12;g++)w=16*Math.random()|0,8==g&&(h+=p),h+=(4==g?4:6==g?3&w|8:w).toString(12);return _+h}static getNextName(_,p){let h=1,g=_+h;for(;p.indexOf(g)>=0;)h++,g=_+h;return g}static isObject(_){return"object"==typeof _&&null!==_}static getType(_){return typeof _}static getTextHeight(_){var h=document.createElement("canvas").getContext("2d");return h.font=_,h.measureText("M").width}static getDomTextHeight(_,p){let h=document.createElement("span");document.body.appendChild(h),h.style.font=p,h.style.fontSize=_+"px",h.style.height="auto",h.style.width="auto",h.style.position="absolute",h.style.whiteSpace="no-wrap",h.innerHTML="M";let g=Math.ceil(h.clientHeight);return document.body.removeChild(h),g}static getEnumKey(_,p){return Object.keys(_).find(h=>_[h]===p)}static isJson(_){try{let p=JSON.parse(_);if(p&&Object.keys(p).length)return!0}catch{}return!1}static isNumeric(_){return!isNaN(parseFloat(_))&&isFinite(_)}static Boolify(_){return-1===[!0,!1,"true","false",1,0].indexOf(_)?null:1==_||"true"==_||1==_}static toNumber(_){const p=K.Boolify(_);return K.isNullOrUndefined(p)?_:Number(p)}static toFloatOrNumber(_){let p=parseFloat(_);return p=K.isNullOrUndefined(p)?Number(_):parseFloat(p.toFixed(5)),p}static formatValue(_,p){try{if(K.isNumeric(_))return numeral(_).format(p)}catch(h){console.error(h)}return _}static arrayToObject=(_,p)=>{_.reduce((h,g)=>(h[g[p]]=g,h),{})};static rand(_,p){return _=_||0,p=p||0,this._seed=(9301*this._seed+49297)%233280,Math.round(_+this._seed/233280*(p-_))}static randNumbers(_,p,h){let g=[];for(let w=0;w<_;++w)g.push(this.rand(p,h));return g}static formatDate(_,p,h){var g=["\0","January","February","March","April","May","June","July","August","September","October","November","December"],w=["\x01","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],y=["\x02","Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],b=["\x03","Sun","Mon","Tue","Wed","Thu","Fri","Sat"];let M=(Z,q)=>{var ae=Z+"";for(q=q||2;ae.length<q;)ae="0"+ae;return ae};var E=h?_.getUTCFullYear():_.getFullYear();p=(p=(p=p.replace(/(^|[^\\])yyyy+/g,"$1"+E)).replace(/(^|[^\\])yy/g,"$1"+E.toString().substr(2,2))).replace(/(^|[^\\])y/g,"$1"+E);var T=(h?_.getUTCMonth():_.getMonth())+1;p=(p=(p=(p=p.replace(/(^|[^\\])MMMM+/g,"$1"+g[0])).replace(/(^|[^\\])MMM/g,"$1"+w[0])).replace(/(^|[^\\])MM/g,"$1"+M(T))).replace(/(^|[^\\])M/g,"$1"+T);var F=h?_.getUTCDate():_.getDate();p=(p=(p=(p=p.replace(/(^|[^\\])dddd+/g,"$1"+y[0])).replace(/(^|[^\\])ddd/g,"$1"+b[0])).replace(/(^|[^\\])dd/g,"$1"+M(F))).replace(/(^|[^\\])d/g,"$1"+F);var k=h?_.getUTCHours():_.getHours(),A=k>12?k-12:0==k?12:k;p=(p=(p=(p=p.replace(/(^|[^\\])HH+/g,"$1"+M(k))).replace(/(^|[^\\])H/g,"$1"+k)).replace(/(^|[^\\])hh+/g,"$1"+M(A))).replace(/(^|[^\\])h/g,"$1"+A);var S=h?_.getUTCMinutes():_.getMinutes();p=(p=p.replace(/(^|[^\\])mm+/g,"$1"+M(S))).replace(/(^|[^\\])m/g,"$1"+S);var Q=h?_.getUTCSeconds():_.getSeconds();p=(p=p.replace(/(^|[^\\])ss+/g,"$1"+M(Q))).replace(/(^|[^\\])s/g,"$1"+Q);var O=h?_.getUTCMilliseconds():_.getMilliseconds();p=p.replace(/(^|[^\\])fff+/g,"$1"+M(O,3)),O=Math.round(O/10),p=p.replace(/(^|[^\\])ff/g,"$1"+M(O)),O=Math.round(O/10);var W=k<12?"AM":"PM";p=(p=(p=p.replace(/(^|[^\\])f/g,"$1"+O)).replace(/(^|[^\\])TT+/g,"$1"+W)).replace(/(^|[^\\])T/g,"$1"+W.charAt(0));var j=W.toLowerCase();p=(p=p.replace(/(^|[^\\])tt+/g,"$1"+j)).replace(/(^|[^\\])t/g,"$1"+j.charAt(0));var Y=-_.getTimezoneOffset(),U=h||!Y?"Z":Y>0?"+":"-";if(!h){var z=(Y=Math.abs(Y))%60;U+=M(Math.floor(Y/60))+":"+M(z)}p=p.replace(/(^|[^\\])K/g,"$1"+U);var R=(h?_.getUTCDay():_.getDay())+1;return(p=(p=(p=(p=p.replace(new RegExp(y[0],"g"),y[R])).replace(new RegExp(b[0],"g"),b[R])).replace(new RegExp(g[0],"g"),g[T])).replace(new RegExp(w[0],"g"),w[T])).replace(/\\(.)/g,"$1")}static findBitPosition(_){let p=[];for(let h=0;h<32;h++)_&1<<h&&p.push(h);return p}static assign=(_,...p)=>(p.forEach(h=>Object.keys(h).forEach(g=>{_[g]=h[g]})),_);static clone=_=>JSON.parse(JSON.stringify(_));static convertArrayToObject=(_,p)=>_.reduce((h,g)=>({...h,[g]:p}),{});static resizeView=_=>{document.querySelectorAll(_).forEach(p=>{let h=p.parentNode;p.style.transform="scale("+Math.min(h.offsetWidth/p.offsetWidth,h.offsetHeight/p.offsetHeight)+")",p.style.transformOrigin="top left"})};static resizeViewExt=(_,p,h)=>{const g=document.getElementById(p);if(!g)return void console.error(`resizeViewExt -> Parent element with ID '${p}' not found.`);const w=g.getBoundingClientRect(),y=h??"none";g.querySelectorAll(_).forEach(b=>{const M=w?.width/b.offsetWidth,E=w?.height/b.offsetHeight;"contain"===y?b.style.transform="scale("+Math.min(M,E)+")":"stretch"===y?b.style.transform="scale("+M+", "+E+")":"none"===y&&(b.style.transform="scale(1)"),b.style.transformOrigin="top left"})};static resizeViewRev=(_,p,h)=>{function g(b,M,E){const T=M?.width/b.clientWidth,F=M?.height/b.clientHeight;"contain"===E?(b.style.transform="scale("+Math.min(T,F)+")",b.parentElement.style.margin="unset"):"stretch"===E?(b.style.transform="scale("+T+", "+F+")",b.parentElement.style.margin="unset"):"none"===E&&(b.style.transform="scale(1)"),b.style.top="unset",b.style.left="unset",b.style.transformOrigin="top left"}const w="string"==typeof p?document.getElementById(p):p;if(!w)return void console.error(`resizeViewExt -> Parent element with ID '${p}' not found.`);const y=w.getBoundingClientRect();"string"==typeof _?w.querySelectorAll(_).forEach(b=>{g(b,y,h??"none")}):_&&g(_,y,h??"none")};static mergeDeep(..._){const p={};return _.forEach(h=>{h&&Object.keys(h).forEach(g=>{h[g]&&"object"==typeof h[g]&&!Array.isArray(h[g])?p[g]=K.mergeDeep(p[g],h[g]):Array.isArray(h[g])?(Array.isArray(p[g])||(p[g]=[]),p[g]=p[g].concat(h[g])):p[g]=h[g]})}),p}static mergeArray(_,p){const h=new Map;if(_)for(const g of _)if(g)for(const w of g){const y=w[p];y?h.set(y,{...h.get(y),...w}):console.warn(`L'oggetto ${JSON.stringify(w)} non ha la chiave ${p}`)}return Array.from(h.values())}static mergeUniqueBy(_,p,h){if(!(_&&0!==_.length||p&&0!==p.length))return null;const g=_?[..._]:[],w=new Set(g.map(b=>b[h]));let y=!1;return p&&p.forEach(b=>{w.has(b[h])||(g.push(b),w.add(b[h]),y=!0)}),y?g:_??null}static copyToClipboard(_){const p=document.createElement("textarea");p.value=_,p.style.position="fixed",p.style.opacity="0",document.body.appendChild(p),p.select(),document.execCommand("copy"),document.body.removeChild(p)}static millisecondsToTime(_){const p=Math.floor(_/36e5);_%=36e5;const h=Math.floor(_/6e4);return _%=6e4,{hours:p,minutes:h,seconds:Math.floor(_/1e3),milliseconds:_%=1e3}}static timeToString(_,p){function h(w,y){return w.toString().padStart(y,"0")}let g=`${h(_.hours,2)}:${h(_.minutes,2)}`;return p&&(g+=`:${h(_.seconds,2)}`,p>=1e3&&(g+=`.${h(_.milliseconds,3)}`)),g}static millisecondsToTimeString(_,p){return K.timeToString(K.millisecondsToTime(_),p)}static millisecondsToDateString(_,p){const h=new Date(_),g=h.getFullYear(),w=(h.getMonth()+1).toString().padStart(2,"0"),y=h.getDate().toString().padStart(2,"0"),b=h.getHours().toString().padStart(2,"0"),M=h.getMinutes().toString().padStart(2,"0"),E=h.getSeconds().toString().padStart(2,"0"),T=h.getMilliseconds().toString().padStart(3,"0");let F=`${g}-${w}-${y}`;return p>0&&(F+=`T${b}:${M}`,p>1&&(F+=`:${E}`,p>100&&(F+=`.${T}`))),F}static getTimeDifferenceInSeconds(_){const h=Date.now()-_;return Math.floor(h/1e3)}static isValidUrl(_){try{return new URL(_),!0}catch{return!1}}static \u0275fac=function(p){return new(p||K)};static \u0275prov=N.jDH({token:K,factory:K.\u0275fac})}let D=(()=>{class l{transform(p){let h=[];for(var g=Object.keys(p),w=Object.values(p),y=0;y<g.length;y++)h.push({key:g[y],value:w[y]});return h}static \u0275fac=function(h){return new(h||l)};static \u0275pipe=N.EJ8({name:"enumToArray",type:l,pure:!0})}return l})()},6334:(Rt,Be,ie)=>{"use strict";ie.d(Be,{K:()=>N});class N{scriptSystemFunctions=[]}},7546:(Rt,Be,ie)=>{"use strict";ie.d(Be,{$d:()=>U,C_:()=>j,JS:()=>M,PK:()=>b,Pl:()=>Q,Rs:()=>z,Vl:()=>S,Vz:()=>A,Wb:()=>T,Yp:()=>K,_z:()=>F,bI:()=>E,bq:()=>y,e4:()=>D,eq:()=>q,f0:()=>W,hD:()=>_,jN:()=>Y,kA:()=>k,lE:()=>X,lc:()=>O,n7:()=>w,oO:()=>ae,pF:()=>e,q9:()=>R,tk:()=>p,v_:()=>h,vw:()=>l});var N=ie(3728);const K={id:"0",name:"FUXA"},D={id:"@",name:"Placeholder",tags:[{id:"@",name:"@",device:"@"}]};let e=(()=>class re{id;name;enabled;property;type;polling;tags;constructor(be){this.id=be}static descriptor={id:"Device id, GUID",name:"Device name",enabled:"Enabled",type:"Device Type: FuxaServer | SiemensS7 | OPCUA | BACnet | ModbusRTU | ModbusTCP | WebAPI | MQTTclient | internal | EthernetIP | ADSclient | Gpio",polling:"Polling interval in millisec., check changed value after ask value, by OPCUA there is a monitor",property:"Connection property depending of type",tags:"Tags list of Tag"};static isWebApiProperty(be){return be.type===y.WebAPI&&be.property.getTags}})(),l=(()=>class re{id;name;label;value;type;memaddress;address;divisor;access;options;format;daq;init;scale;scaleReadFunction;scaleReadParams;scaleWriteFunction;scaleWriteParams;sysType;description;deadband;direction;edge;constructor(be){this.id=be,this.daq=new _(!1,!1,60,!1)}static descriptor={id:"Tag id, GUID",name:"Tag name, is like the id",label:"Tag label, used by BACnet and WebAPI",type:"Tag type, Bool, Byte, etc. depending of device type",memaddress:"Address of Tag, combine with address by Modbus, some property for WebAPI",address:"Tag address, for OPCUA like the id",divisor:"Value divisor, used by Modbus",options:"Options is a string JSON object, used for WebAPI and MQTT, pubs: items to publish | subs: items to subscribe",init:"Init value",daq:{enabled:"Daq enabled storage",interval:"min storage interval (without change value)"},format:"Number of digits to appear after the decimal point",direction:"A string specifying whether the GPIO should be configured as an input or output. The valid values are: 'in', 'out', 'high', and 'low'. If 'out' is specified the GPIO will be configured as an output and the value of the GPIO will be set to 0. 'high' and 'low' are variants of 'out' that configure the GPIO as an output with an initial level of 1 or 0 respectively.",edge:"An optional string specifying the interrupt generating edge or edges for an input GPIO. The valid values are: 'none', 'rising', 'falling' or 'both'. The default value is 'none' indicating that the GPIO will not generate interrupts. Whether or not interrupts are supported by an input GPIO is GPIO specific. If interrupts are not supported by a GPIO the edge argument should not be specified. The edge argument is ignored for output GPIOs."}})();class _{enabled;interval;changed;restored=!1;constructor(Se,be,Re,He){this.enabled=Se,this.changed=be,this.interval=Re,this.restored=He}}var p=function(re){return re.absolute="absolute",re}(p||{});let h=(()=>class re{address;port;slot;rack;slaveid;baudrate;databits;stopbits;parity;options;method;format;connectionOption;delay=10;socketReuse;static descriptor={address:"Device address (IP)"}})();class w{mode;username;password;clientId;grant_type;certificateFileName;privateKeyFileName;caCertificateFileName}var y=function(re){return re.FuxaServer="FuxaServer",re.SiemensS7="SiemensS7",re.OPCUA="OPCUA",re.BACnet="BACnet",re.ModbusRTU="ModbusRTU",re.ModbusTCP="ModbusTCP",re.WebAPI="WebAPI",re.MQTTclient="MQTTclient",re.internal="internal",re.EthernetIP="EthernetIP",re.ODBC="ODBC",re.ADSclient="ADSclient",re.GPIO="GPIO",re}(y||{}),b=function(re){return re.Bool="Bool",re.Byte="Byte",re.Int="Int",re.Word="Word",re.DInt="DInt",re.DWord="DWord",re.Real="Real",re}(b||{}),M=function(re){return re.Bool="Bool",re.Int16="Int16",re.UInt16="UInt16",re.Int32="Int32",re.UInt32="UInt32",re.Float32="Float32",re.Float64="Float64",re.Int64="Int64",re.Int16LE="Int16LE",re.UInt16LE="UInt16LE",re.Int32LE="Int32LE",re.UInt32LE="UInt32LE",re.Float32LE="Float32LE",re.Float64LE="Float64LE",re.Int64LE="Int64LE",re.Float32MLE="Float32MLE",re.Int32MLE="Int32MLE",re.UInt32MLE="UInt32MLE",re}(M||{}),E=function(re){return re.Boolean="Boolean",re.SByte="SByte",re.Byte="Byte",re.Int16="Int16",re.UInt16="UInt16",re.Int32="Int32",re.UInt32="UInt32",re.Int64="Int64",re.UInt64="UInt64",re.Float="Float",re.Double="Double",re.String="String",re.DateTime="DateTime",re.Guid="Guid",re.ByteString="ByteString",re}(E||{}),T=function(re){return re.Number="number",re.Boolean="boolean",re.String="string",re}(T||{}),F=function(re){return re.SerialPort="SerialPort",re.RTUBufferedPort="RTUBufferedPort",re.AsciiPort="AsciiPort",re.TcpPort="TcpPort",re.UdpPort="UdpPort",re.TcpRTUBufferedPort="TcpRTUBufferedPort",re.TelnetPort="TelnetPort",re}(F||{}),k=function(re){return re.Reuse="Reuse",re.ReuseSerial="ReuseSerial",re}(k||{}),A=function(re){return re.in="in",re.out="out",re.high=" - high",re.low=" - low",re}(A||{}),S=function(re){return re.none="none",re.rising="rising",re.falling="falling",re.both="both",re}(S||{}),Q=function(re){return re[re.INVALID=0]="INVALID",re.NONE="1",re.SIGN="2",re.SIGNANDENCRYPT="3",re}(Q||{}),O=function(re){return re.None="None",re.Basic128="Basic128",re.Basic128Rsa15="Basic128Rsa15",re.Basic192="Basic192",re.Basic192Rsa15="Basic192Rsa15",re.Basic256="Basic256",re.Basic256Rsa15="Basic256Rsa15",re.Basic256Sha256="Basic256Sha256",re.Aes256_Sha256_RsaPss="Aes256_Sha256_RsaPss",re.Aes128_Sha256_RsaOaep="Aes128_Sha256_RsaOaep",re}(O||{}),W=function(re){return re.ANALOG_INPUT="Analog Input",re.ANALOG_OUTPUT="Analog Output",re.ANALOG_VALUE="Analog Value",re.BINARY_INPUT="Binary Input",re.BINARY_OUTPUT="Binary Output",re.BINARY_VALUE="Binary Value",re.CALENDAR="",re.COMMAND="",re.DEVICE="",re}(W||{});const j="d_",Y="t_";let U=(()=>{class re{static getDeviceTagText(be,Re){for(let He=0;He<be.length;He++)if(be[He].tags[Re])return`${be[He].name} - ${be[He].tags[Re].name}`;return""}static getDeviceFromTagId(be,Re){for(let He=0;He<be.length;He++)if(be[He].tags[Re])return be[He];return null}static getTagFromTagId(be,Re){for(let He=0;He<be.length;He++)if(be[He].tags[Re])return be[He].tags[Re];return null}static getTagFromTagAddress(be,Re){return Object.values(be.tags).find(He=>He.address===Re)}static columnDelimiter=",";static lineDelimiter="\n";static lineComment="#";static lineDevice="D@";static lineTag="T@";static lineSectionHeader="@";static columnMaske="~";static devicesToCsv(be){let Re="",He=`!! CSV separator property convertion to "~"${re.lineDelimiter}`,ue=`${re.lineSectionHeader}header${re.columnDelimiter}`,le="";const fe=Object.keys(e.descriptor).filter(Ye=>"tags"!==Ye),ge=Object.keys(h.descriptor);fe.forEach(Ye=>{"property"!==Ye&&(He+=`${re.lineComment}${Ye}${re.columnDelimiter}: ${e.descriptor[Ye]}${re.lineDelimiter}`,ue+=`${Ye}${re.columnDelimiter}`)}),ge.forEach(Ye=>{He+=`${re.lineComment}property.${Ye}${re.columnDelimiter}: ${h.descriptor[Ye]}${re.lineDelimiter}`,ue+=`property.${Ye}${re.columnDelimiter}`});for(let Ye=0;Ye<be.length;Ye++)le+=re.device2Line(be[Ye],fe,ge),le+=`${re.lineDelimiter}`;Re+=`${He}${re.lineDelimiter}`,Re+=`${ue}${re.lineDelimiter}${le}`,Re+=`${re.lineDelimiter}`;let Te="",se="",we="";const ke=Object.keys(l.descriptor).filter(Ye=>"daq"!==Ye&&"options"!==Ye);Te+=`${re.lineComment}deviceId${re.columnDelimiter}:Reference to device${re.lineDelimiter}`,se+=`${re.lineSectionHeader}header${re.columnDelimiter}deviceId${re.columnDelimiter}`,ke.forEach(Ye=>{Te+=`${re.lineComment}${Ye}${re.columnDelimiter}: ${l.descriptor[Ye]}${re.lineDelimiter}`,se+=`${Ye}${re.columnDelimiter}`}),Te+=`${re.lineComment}options${re.columnDelimiter}: ${l.descriptor.options}${re.lineDelimiter}`,se+=`options${re.columnDelimiter}`,Te+=`${re.lineComment}daq.enabled${re.columnDelimiter}: ${l.descriptor.daq.enabled}${re.lineDelimiter}`,se+=`daq.enabled${re.columnDelimiter}`,Te+=`${re.lineComment}daq.interval${re.columnDelimiter}: ${l.descriptor.daq.interval}${re.lineDelimiter}`,se+=`daq.interval${re.columnDelimiter}`;for(let Ye=0;Ye<be.length;Ye++){if(be[Ye].tags){const _t=Object.values(be[Ye].tags);for(let Dt=0;Dt<_t.length;Dt++)we+=re.tag2Line(_t[Dt],be[Ye].id,ke),we+=`${re.lineDelimiter}`}we+=`${re.lineDelimiter}`}return Re+=`${Te}${re.lineDelimiter}`,Re+=`${se}${re.lineDelimiter}${we}`,Re+=`${re.lineDelimiter}`,Re}static csvToDevices(be){try{const Re=Object.keys(e.descriptor).length+Object.keys(h.descriptor).length,He=Object.keys(l.descriptor).length+4;let ue={};return be.split(re.lineDelimiter).filter(fe=>!fe.startsWith(re.lineComment)&&!fe.startsWith(re.lineSectionHeader)).forEach(fe=>{if(fe.startsWith(re.lineDevice)){let ge=re.line2Device(fe,Re);ue[ge.id]=ge}else if(fe.startsWith(re.lineTag)){let ge=re.line2Tag(fe,He);if(!ue[ge.deviceId])throw new Error(`Device don't exist: ${fe}`);if(ue[ge.deviceId].tags[ge.tag.id])throw new Error(`Tag already exist: ${fe}`);ue[ge.deviceId].tags[ge.tag.id]=ge.tag}}),Object.values(ue)}catch(Re){console.error(Re)}return null}static device2Line(be,Re,He){let ue=`${re.lineDevice}${re.columnDelimiter}`;return Re.forEach(le=>{if("property"!==le){let fe=be[le]?be[le].toString():"";ue+=`${fe.replace(new RegExp(re.columnDelimiter,"g"),re.columnMaske)}${re.columnDelimiter}`}}),be.property&&He.forEach(le=>{ue+=`${be.property[le]||""}${re.columnDelimiter}`}),ue}static line2Device(be,Re){const He=be.split(re.columnDelimiter);if(He.length<Re-1)throw new Error(`Format Error ${He.length}/${Re} ${be}`);let ue=new e(He[1]);return ue.name=He[2].replace(new RegExp(re.columnMaske,"g"),re.columnDelimiter),ue.enabled="true"===He[3].toLowerCase(),ue.type=He[4],ue.polling=parseInt(He[5])||1e3,ue.property={address:He[6],port:He[7],slot:He[8],rack:He[9],slaveid:He[10],baudrate:He[11],databits:He[12],stopbits:He[13],parity:He[14],options:He[15],method:He[16],format:He[17]},ue.tags={},ue}static tag2Line(be,Re,He){let ue=`${re.lineTag}${re.columnDelimiter}${Re}${re.columnDelimiter}`;He.forEach(fe=>{ue+=`${(be[fe]||"").toString().replace(new RegExp(re.columnDelimiter,"g"),re.columnMaske)}${re.columnDelimiter}`});let le=be.options?JSON.stringify(be.options):"";return ue+=`${le.replace(new RegExp(re.columnDelimiter,"g"),re.columnMaske)}${re.columnDelimiter}`,ue+=`${be.daq?be.daq.enabled:""}${re.columnDelimiter}`,ue+=`${be.daq?be.daq.interval:""}${re.columnDelimiter}`,ue}static line2Tag(be,Re){const He=be.split(re.columnDelimiter);if(He.length<Re-1)throw new Error(`Format Error: ${He.length}/${Re} ${be}`);const ue=He[1];let le=new l(He[2]);return le.name=He[3].replace(new RegExp(re.columnMaske,"g"),re.columnDelimiter),le.label=He[4].replace(new RegExp(re.columnMaske,"g"),re.columnDelimiter),le.type=He[5],le.memaddress=He[6].replace(new RegExp(re.columnMaske,"g"),re.columnDelimiter),le.address=He[7].replace(new RegExp(re.columnMaske,"g"),re.columnDelimiter),le.divisor=parseInt(He[8])||1,le.init=He[9],le.format=He[10]?parseInt(He[10]):null,le.options=He[11].replace(new RegExp(re.columnMaske,"g"),re.columnDelimiter),le.options&&N.Aq.isJson(le.options)&&(le.options=JSON.parse(le.options)),le.daq={enabled:!!N.Aq.Boolify(He[12]),changed:!0,interval:parseInt(He[13])||60},{tag:le,deviceId:ue}}static placeholderToTag(be,Re){const He=re.getPlaceholderContent(be);return He.firstContent?Re?.find(ue=>ue.name===He.firstContent):null}static getPlaceholderContent(be){const Re=be.indexOf("@");if(-1===Re)return{firstContent:null,secondContent:null};const He=be.indexOf("@",Re+1);return-1===He?{firstContent:be.substring(Re+1).trim(),secondContent:null}:{firstContent:be.substring(Re+1,He).trim(),secondContent:be.substring(He+1).trim()}}}return re})();var X=function(re){return re.tags="tags",re.devices="devices",re.list="devices-list",re.map="devices-map",re}(X||{}),z=function(re){return re.ok="device.connect-ok",re.error="device.connect-error",re.failed="device.connect-failed",re.off="device.connect-off",re.busy="device.connect-busy",re}(z||{}),R=function(re){return re.number="number",re.boolean="boolean",re.string="string",re}(R||{}),q=function(re){return re.undefined="device.tag-scale-mode-undefined",re.linear="device.tag-scale-mode-linear",re.convertDateTime="device.tag-convert-datetime",re.convertTickTime="device.tag-convert-ticktime",re}(q||{}),ae=function(re){return re[re.deviceConnectionStatus=1]="deviceConnectionStatus",re}(ae||{})},3276:(Rt,Be,ie)=>{"use strict";ie.d(Be,{AY:()=>Re,Ar:()=>_e,EV:()=>we,Eh:()=>Te,FV:()=>Bt,FY:()=>Y,Fo:()=>E,GF:()=>k,G_:()=>T,Hj:()=>je,J:()=>ti,Jf:()=>_t,Jh:()=>Ke,Ny:()=>qe,OX:()=>w,QQ:()=>_,Qk:()=>le,Qo:()=>y,Qs:()=>X,Ss:()=>e,TH:()=>Q,Uy:()=>ge,V0:()=>h,Ve:()=>ni,Vq:()=>M,Xp:()=>re,Y6:()=>St,Z4:()=>se,Z_:()=>b,_O:()=>be,a2:()=>ze,bv:()=>D,c$:()=>He,cH:()=>z,cq:()=>We,dE:()=>S,e6:()=>ue,f5:()=>O,iz:()=>q,k:()=>g,k4:()=>A,lG:()=>ke,lp:()=>Ye,mt:()=>ft,nA:()=>Dt,nW:()=>ut,oI:()=>p,pT:()=>De,qR:()=>j,qi:()=>l,rT:()=>Je,u6:()=>U,uR:()=>F,vo:()=>Z,yO:()=>ae,yy:()=>fe,zQ:()=>Se});var N=ie(3378),K=ie(7546);class D{layout=new _;views=[]}class e{id="";name="";profile=new k;items={};variables={};svgcontent="";type;property;constructor(Bi,fi,Xi){this.id=Bi,this.name=Xi,this.type=fi}}var l=function(et){return et.svg="svg",et.cards="cards",et.maps="maps",et}(l||{});class _{autoresize=!1;start="";navigation=new p;header=new b;showdev=!0;zoom;inputdialog="false";hidenavigation=!1;theme="";loginonstart=!1;loginoverlaycolor=h.none;show_connection_error=!0;customStyles=""}class p{mode;type;bkcolor="#F4F5F7";fgcolor="#1D1D1D";items;logo=!1;constructor(){this.mode=Object.keys(g).find(Bi=>g[Bi]===g.over),this.type=Object.keys(w).find(Bi=>w[Bi]===w.block)}}var h=function(et){return et.none="none",et.black="black",et.white="white",et}(h||{}),g=function(et){return et.void="item.navsmode-none",et.push="item.navsmode-push",et.over="item.navsmode-over",et.fix="item.navsmode-fix",et}(g||{}),w=function(et){return et.icon="item.navtype-icons",et.text="item.navtype-text",et.block="item.navtype-icons-text-block",et.inline="item.navtype-icons-text-inline",et}(w||{});class y{text;link;view;icon;image;permission;permissionRoles}class b{title;alarms;infos;bkcolor="#ffffff";fgcolor="#000000";fontFamily;fontSize=13;items;itemsAnchor="left";loginInfo;dateTimeDisplay;language}var M=function(et){return et.hide="item.notifymode-hide",et.fix="item.notifymode-fix",et.float="item.notifymode-float",et}(M||{}),E=function(et){return et.disabled="item.zoommode-disabled",et.enabled="item.zoommode-enabled",et.autoresize="item.zoommode-autoresize",et}(E||{}),T=function(et){return et.false="item.inputmode-disabled",et.true="item.inputmode-enabled",et.keyboard="item.inputmode-keyboard",et.keyboardFullScreen="item.inputmode-keyboard-full-screen",et}(T||{}),F=function(et){return et.true="item.headerbarmode-hide",et.false="item.headerbarmode-show",et}(F||{});class k{width=1024;height=768;bkcolor="#ffffffff";margin=10;align=A.topCenter;gridType=N.jJ.Fixed;viewRenderDelay=0}var A=function(et){return et.topCenter="topCenter",et.middleCenter="middleCenter",et}(A||{});class S{id;type;name="";property=null;label="";hide=!1;lock=!1;constructor(Bi,fi){this.id=Bi,this.type=fi}}class Q{events=[];startLocation;startZoom}class O{variableId;variableValue;bitmask;permission;permissionRoles;ranges;events=[];actions=[];options;readonly;text}var j=function(et){return et.number="number",et.text="text",et.date="date",et.time="time",et.datetime="datetime",et}(j||{}),Y=function(et){return et.normal="normal",et.seconds="seconds",et.milliseconds="milliseconds",et}(Y||{}),U=function(et){return et.milliseconds="milliseconds",et.string="string",et}(U||{}),X=function(et){return et.update="update",et.enter="enter",et}(X||{});class z{type;action;actparam;actoptions={}}var Z=function(et){return et.hide="shapes.action-hide",et.show="shapes.action-show",et.blink="shapes.action-blink",et.stop="shapes.action-stop",et.clockwise="shapes.action-clockwise",et.anticlockwise="shapes.action-anticlockwise",et.downup="shapes.action-downup",et.rotate="shapes.action-rotate",et.move="shapes.action-move",et.monitor="shapes.action-monitor",et}(Z||{});class q{variableId;bitmask;range;type;options={}}class ae{strokeA=null;strokeB=null;fillA=null;fillB=null;interval=1e3}class re{minAngle=0;maxAngle=90;delay=0}class Se{toX=0;toY=0;duration=100}class be{fill;stroke}class Re{variablesValue={};onlyChange=!1;takeValue=!1;actionRef}class He{type;timer=null;animr=null;spool;constructor(Bi){this.type=Bi}}var ue=function(et){return et.click="shapes.event-click",et.dblclick="shapes.event-dblclick",et.mousedown="shapes.event-mousedown",et.mouseup="shapes.event-mouseup",et.mouseover="shapes.event-mouseover",et.mouseout="shapes.event-mouseout",et.enter="shapes.event-enter",et.select="shapes.event-select",et.onLoad="shapes.event-onLoad",et}(ue||{}),le=function(et){return et.onpage="shapes.event-onpage",et.onwindow="shapes.event-onwindow",et.onOpenTab="shapes.event-onopentab",et.ondialog="shapes.event-ondialog",et.oniframe="shapes.event-oniframe",et.oncard="shapes.event-oncard",et.onSetValue="shapes.event-onsetvalue",et.onToggleValue="shapes.event-ontogglevalue",et.onSetInput="shapes.event-onsetinput",et.onclose="shapes.event-onclose",et.onRunScript="shapes.event-onrunscript",et.onViewToPanel="shapes.event-onViewToPanel",et.onMonitor="shapes.event-onmonitor",et}(le||{}),fe=function(et){return et.onopen="shapes.event-onopen",et.onclose="shapes.event-onclose",et}(fe||{}),ge=function(et){return et.onRunScript="shapes.event-onrunscript",et}(ge||{}),Te=function(et){return et.window="window",et.mouse="mouse",et}(Te||{}),se=function(et){return et.set="shapes.event-setvalue-set",et.add="shapes.event-setvalue-add",et.remove="shapes.event-setvalue-remove",et}(se||{});class we{min;max;text;textId;color;type;style;stroke}var ke=function(et){return et.none="none",et.contain="contain",et.stretch="stretch",et}(ke||{}),Ye=function(et){return et.data="data",et.history="history",et.alarms="alarms",et.alarmsHistory="alarmsHistory",et.reports="reports",et}(Ye||{}),_t=function(et){return et.label="label",et.variable="variable",et.timestamp="timestamp",et.device="device",et}(_t||{});class Dt{id;label;variableId;valueFormat;bitmask;type;constructor(Bi,fi,Xi){this.id=Bi,this.type=fi||_t.label,this.label=Xi}}class ni extends Dt{align=_e.left;width=100;exname;constructor(Bi,fi,Xi){super(Bi,fi,Xi)}}class je{cells;constructor(Bi){this.cells=Bi}}var _e=function(et){return et.left="left",et.center="center",et.right="right",et}(_e||{}),ze=function(et){return et.last1h="table.rangetype-last1h",et.last1d="table.rangetype-last1d",et.last3d="table.rangetype-last3d",et}(ze||{});class Je{id;name;source;value;error;timestamp;device;constructor(Bi,fi,Xi){this.id=Bi,this.name=fi,this.device=Xi,Xi?.type===K.bq.internal&&(this.value="0")}}class qe{type="";id;ele=null}class Ke{id="";dom;value=null;dbg="";type;ga;variableId}class Bt{gid;from;to;event;sids;chunked}class ft{page;tag}var We=function(et){return et.YYYY_MM_DD="1998/03/25",et.MM_DD_YYYY="03/25/1998",et.DD_MM_YYYY="25/03/1998",et.MM_DD_YY="03/25/98",et.DD_MM_YY="25/03/98",et}(We||{}),De=function(et){return et.hh_mm_ss="16:58:10",et.hh_mm_ss_AA="04:58:10 PM",et}(De||{}),ut=function(et){return et.view="view",et.alarms="alarms",et.iframe="iframe",et.table="table",et}(ut||{}),ti=function(et){return et.address="[link]",et.alarms="[alarms]",et}(ti||{});const St="rodevice"},1394:(Rt,Be,ie)=>{"use strict";ie.d(Be,{AT:()=>N,yq:()=>e});class N{default;options=[]}const e="@"},3367:(Rt,Be,ie)=>{"use strict";ie.d(Be,{cu:()=>p,wE:()=>_});var N=ie(7546),K=ie(3276),D=ie(1394),e=ie(3728),l=ie(6334);class _{version="1.01";name;server=new N.pF(e.Aq.getGUID(N.C_));hmi=new K.bv;devices={};charts=[];graphs=[];alarms=[];notifications=[];scripts=[];reports=[];texts=[];languages=new D.AT;plugin=[];mapsLocations=[];clientAccess=new l.K}var p=function(g){return g.SetDevice="set-device",g.DelDevice="del-device",g.SetView="set-view",g.DelView="del-view",g.HmiLayout="layout",g.Charts="charts",g.Graphs="graphs",g.Languages="languages",g.ClientAccess="client-access",g.SetText="set-text",g.DelText="del-text",g.SetAlarm="set-alarm",g.DelAlarm="del-alarm",g.SetNotification="set-notification",g.DelNotification="del-notification",g.SetScript="set-script",g.DelScript="del-script",g.SetReport="set-report",g.DelReport="del-report",g.SetMapsLocation="set-maps-location",g.DelMapsLocation="del-maps-location",g}(p||{})},3955:(Rt,Be,ie)=>{"use strict";ie.d(Be,{Bf:()=>l,FB:()=>D,H8:()=>e,Jg:()=>b,N0:()=>g,YA:()=>K,bR:()=>y,bj:()=>w,eF:()=>N,ju:()=>p,od:()=>_});class N{id;name;code;sync=!1;parameters=[];scheduling;permission;permissionRoles;mode=y.SERVER;constructor(E){this.id=E}}class K extends N{test=!0;outputId;constructor(E,T){super(E),this.name=T}}class D{name;type;value;constructor(E,T){this.name=E,this.type=T}}var e=function(M){return M.tagid="tagid",M.value="value",M.chart="chart",M}(e||{});const l="s_",_="params";var p=function(M){return M.interval="interval",M.start="start",M.scheduling="scheduling",M}(p||{});class g{functions=[];constructor(E){this.functions=this.allFunctions.filter(T=>!T.mode||!E||T.mode===E)}allFunctions=[{name:"$setTag",mode:null,text:"script.sys-fnc-settag-text",tooltip:"script.sys-fnc-settag-tooltip",params:[!0,!1]},{name:"$getTag",mode:null,text:"script.sys-fnc-gettag-text",tooltip:"script.sys-fnc-gettag-tooltip",params:[!0]},{name:"$getTagId",mode:null,text:"script.sys-fnc-getTagId-text",tooltip:"script.sys-fnc-getTagId-tooltip",params:[!1],paramsText:"script.sys-fnc-getTagId-params"},{name:"$getTagDaqSettings",mode:null,text:"script.sys-fnc-getTagDaqSettings-text",tooltip:"script.sys-fnc-getTagDaqSettings-tooltip",params:[!0],paramsText:"script.sys-fnc-getTagDaqSettings-params"},{name:"$setTagDaqSettings",mode:null,text:"script.sys-fnc-setTagDaqSettings-text",tooltip:"script.sys-fnc-setTagDaqSettings-tooltip",params:[!0,!1],paramsText:"script.sys-fnc-setTagDaqSettings-params"},{name:"$setView",mode:null,text:"script.sys-fnc-setview-text",tooltip:"script.sys-fnc-setview-tooltip",params:[!1],paramsText:"script.sys-fnc-setview-params"},{name:"$openCard",mode:null,text:"script.sys-fnc-opencard-text",tooltip:"script.sys-fnc-opencard-tooltip",params:[!1],paramsText:"script.sys-fnc-opencard-params"},{name:"$enableDevice",mode:null,text:"script.sys-fnc-enableDevice-text",tooltip:"script.sys-fnc-enableDevice-tooltip",params:[!1,!1],paramsText:"script.sys-fnc-enableDevice-params"},{name:"$getDeviceProperty",mode:null,text:"script.sys-fnc-getDeviceProperty-text",tooltip:"script.sys-fnc-getDeviceProperty-tooltip",params:[!1],paramsText:"script.sys-fnc-getDeviceProperty-params"},{name:"$setDeviceProperty",mode:null,text:"script.sys-fnc-setDeviceProperty-text",tooltip:"script.sys-fnc-setDeviceProperty-tooltip",params:[!1,!1],paramsText:"script.sys-fnc-setDeviceProperty-params"},{name:"$getDevice",mode:y.SERVER,text:"script.sys-fnc-getDevice-text",tooltip:"script.sys-fnc-getDevice-tooltip",params:[!1,!1],paramsText:"script.sys-fnc-getDevice-params"},{name:"$setAdapterToDevice",mode:y.CLIENT,text:"script.sys-fnc-setAdapterToDevice-text",tooltip:"script.sys-fnc-setAdapterToDevice-tooltip",params:[!1,!1],paramsText:"script.sys-fnc-setAdapterToDevice-params"},{name:"$resolveAdapterTagId",mode:y.CLIENT,text:"script.sys-fnc-resolveAdapterTagId-text",tooltip:"script.sys-fnc-resolveAdapterTagId-tooltip",params:[!0],paramsText:"script.sys-fnc-resolveAdapterTagId-params"},{name:"$invokeObject",mode:y.CLIENT,text:"script.sys-fnc-invokeObject-text",tooltip:"script.sys-fnc-invokeObject-tooltip",params:[!1,!1,!1],paramsText:"script.sys-fnc-invokeObject-params"},{name:"$runServerScript",mode:y.CLIENT,text:"script.sys-fnc-runServerScript-text",tooltip:"script.sys-fnc-runServerScript-tooltip",params:[!1,!1],paramsText:"script.sys-fnc-runServerScript-params"},{name:"$getHistoricalTags",mode:null,text:"script.sys-fnc-getHistoricalTag-text",tooltip:"script.sys-fnc-getHistoricalTag-tooltip",params:["array",!1,!1],paramsText:"script.sys-fnc-getHistoricalTag-params",paramFilter:b.history},{name:"$sendMessage",mode:null,text:"script.sys-fnc-sendMessage-text",tooltip:"script.sys-fnc-sendMessage-tooltip",params:[!1,!1,!1],paramsText:"script.sys-fnc-sendMessage-params"},{name:"$getAlarms",mode:null,text:"script.sys-fnc-getAlarms-text",tooltip:"script.sys-fnc-getAlarms-tooltip",params:[],paramsText:"script.sys-fnc-getAlarms-params"},{name:"$getAlarmsHistory",mode:null,text:"script.sys-fnc-getAlarmsHistory-text",tooltip:"script.sys-fnc-getAlarmsHistory-tooltip",params:[!1,!1],paramsText:"script.sys-fnc-getAlarmsHistory-params"},{name:"$ackAlarm",mode:null,text:"script.sys-fnc-ackAlarms-text",tooltip:"script.sys-fnc-ackAlarms-tooltip",params:[!1,!1],paramsText:"script.sys-fnc-ackAlarms-params"}]}class w{functions=[];constructor(E){this.functions=this.allFunctions.filter(T=>!T.mode||!E||T.mode===E)}allFunctions=[{name:"chart-data",mode:y.CLIENT,text:"script.template-chart-data-text",tooltip:"script.template-chart-data-tooltip",code:"// Add script parameter 'paramLines' as Chart lines (array)\nif (paramLines && Array.isArray(paramLines)) {\n const count = 10;\n paramLines.forEach(line => {\n var y = [];\n var x = [];\n for (var i = 0; i < count; i++) {\n const randomNumber = Math.floor(Math.random() * 21);\n y.push(randomNumber);\n x.push(i);\n }\n line['y'] = y;\n line['x'] = x;\n });\n return paramLines;\n} else {\n return 'Missing chart lines';\n}"},{name:"invoke-chart-update-options",mode:y.CLIENT,text:"script.template-invoke-chart-update-options-text",tooltip:"script.template-invoke-chart-update-options-tooltip",code:"let opt = $invokeObject('chart_1', 'getOptions');\nif (opt) {\n opt.scaleY1min = 100;\n opt.scaleY1max = 200;\n}\n$invokeObject('chart_1', 'updateOptions', opt);"},{name:"getHistoricalTags",mode:null,text:"script.template-getHistoricalTagsoptions-text",tooltip:"script.template-getHistoricalTagsoptions-tooltip",code:"const to = Date.now();\nvar from = Date.now() - (1000 * 3600); // 1 hour\nvar data = await $getHistoricalTags(['t_a95d5816-9f1e4a67' /* opcua - Byte */], from, to);\nconsole.log(JSON.stringify(data));"}]}var y=function(M){return M.CLIENT="CLIENT",M.SERVER="SERVER",M}(y||{}),b=function(M){return M.history="history",M}(b||{})},8329:(Rt,Be,ie)=>{"use strict";ie.d(Be,{$9:()=>N,CT:()=>D,Kb:()=>_,SC:()=>h,bO:()=>g,sd:()=>K,sr:()=>l});class N{language="en";uiPort=1881;secureEnabled=!1;tokenExpiresIn="1h";secureOnlyEditor=!1;broadcastAll=!1;smtp=new K;daqstore=new D;alarms=new e;logFull=!1;userRole=!1}class K{host="";port=587;mailsender="";username="";password="";constructor(b=null){b&&(this.host=b.host,this.port=b.port,this.mailsender=b.mailsender,this.username=b.username,this.password=b.password)}}class D{type=_.SQlite;varsion;url;organization;credentials;bucket;database;retention=h.year1;constructor(b=null){b&&(this.type=b.type,this.url=b.url,this.organization=b.organization,this.credentials=b.credentials,this.bucket=b.bucket,this.database=b.database,this.retention=b.retention||h.year1)}isEquals(b){return!(this.type!==b.type||this.bucket!==b.bucket||this.url!==b.url||this.organization!==b.organization||this.database!==b.database||!this.credentials||!l.isEquals(this.credentials,b.credentials)||this.retention!==b.retention)}}class e{retention=g.year1}class l{token;username;password;static isEquals(b,M){return b.token===M.token&&b.username===M.username&&b.password===M.password}}var _=function(y){return y.SQlite="SQlite",y.influxDB="influxDB",y.influxDB18="influxDB 1.8",y.TDengine="TDengine",y}(_||{}),h=function(y){return y.none="none",y.day1="day1",y.days2="days2",y.days3="days3",y.days7="days7",y.days14="days14",y.days30="days30",y.days90="days90",y.year1="year1",y.year3="year3",y.year5="year5",y}(h||{}),g=function(y){return y.none="none",y.days7="days7",y.days30="days30",y.days90="days90",y.year1="year1",y.year3="year3",y.year5="year5",y}(g||{})},8411:(Rt,Be,ie)=>{"use strict";ie.d(Be,{KJ:()=>N,Xh:()=>K,yD:()=>D});class N{username;fullname;password;groups;info}class K{id;name;index;description}let D=(()=>class e{static ADMINMASK=[-1,255];static EXTENSION=8;static Groups=[{id:1,label:"Viewer"},{id:2,label:"Operator"},{id:4,label:"Engineer"},{id:8,label:"Supervisor"},{id:16,label:"Manager"},{id:32,label:"F"},{id:64,label:"G"},{id:128,label:"Administrator"}];static GroupsToValue(_,p){let h=0;if(_)for(let w=0;w<_.length;w++)h+=_[w].id;return h<<(p?this.EXTENSION:0)}static ValueToGroups(_,p){let h=[],g=p?this.EXTENSION:0;for(let w=0;w<this.Groups.length;w++)_>>g&this.Groups[w].id&&h.push(this.Groups[w]);return h}static GroupToLabel(_){let p=[];for(let h=0;h<this.Groups.length;h++)_&this.Groups[h].id&&p.push(this.Groups[h].label);return p.join(", ")}})()},4910:(Rt,Be,ie)=>{"use strict";ie.d(Be,{d:()=>e});var N=ie(7705),K=ie(5312),D=ie(5174);let e=(()=>{class l{settingsService;onShowModeChanged=new N.bkB;onShowLoading=new N.bkB;static APP_DEMO="demo";static APP_CLIENT="client";showMode;constructor(p){this.settingsService=p}setShowMode(p){return"editor"===p&&this.settingsService.isEditModeLocked()?(this.settingsService.notifyEditorLocked(),this.showMode):(this.showMode=p,this.onShowModeChanged.emit(this.showMode),this.showMode)}lockEditMode(){this.settingsService.lockEditMode()}unlockEditMode(){this.settingsService.unlockEditMode()}showLoading(p){this.onShowLoading.emit(p)}get isDemoApp(){return K.c.type===l.APP_DEMO}get isClientApp(){return K.c.type===l.APP_CLIENT}static \u0275fac=function(h){return new(h||l)(N.KVO(D.h))};static \u0275prov=N.jDH({token:l,factory:l.\u0275fac})}return l})()},4205:(Rt,Be,ie)=>{"use strict";ie.d(Be,{u:()=>w});var N=ie(1626),K=ie(4412),D=ie(1985),e=ie(8411),l=ie(5312),_=ie(8326),p=ie(5174),h=ie(3728),g=ie(7705);let w=(()=>{class b{http;settings;currentUser;endPointConfig=_.G.getURL();currentUser$=new K.t(null);constructor(E,T){this.http=E,this.settings=T;let F=JSON.parse(localStorage.getItem("currentUser"));F&&(this.currentUser=F),this.currentUser$.next(this.currentUser)}signIn(E,T){return new D.c(F=>{if(l.c.serverEnabled)return new N.Lr({"Content-Type":"application/json"}),this.http.post(this.endPointConfig+"/api/signin",{username:E,password:T}).subscribe(A=>{A&&(this.currentUser=A.data,this.currentUser.info&&(this.currentUser.infoRoles=JSON.parse(this.currentUser.info)?.roles),this.saveUserToken(this.currentUser),this.currentUser$.next(this.currentUser)),F.next(null)},A=>{console.error(A),F.error(A)});F.next(null)})}signOut(){this.removeUser()}getUser(){return this.currentUser}getUserProfile(){return this.currentUser}getUserToken(){return this.currentUser?.token}isAdmin(){return!(!this.currentUser||-1===e.yD.ADMINMASK.indexOf(this.currentUser.groups))}setNewToken(E){this.currentUser.token=E,this.saveUserToken(this.currentUser)}saveUserToken(E){localStorage.setItem("currentUser",JSON.stringify(E))}removeUser(){this.currentUser=null,localStorage.removeItem("currentUser"),this.currentUser$.next(this.currentUser)}checkPermission(E,T=!1){var F=this.currentUser?.groups;const k=this.settings.getSettings();if(!F&&!E)return{show:T||!k.secureEnabled,enabled:T||!k.secureEnabled};if(-1===F||255===F||h.Aq.isNullOrUndefined(E))return{show:!0,enabled:!0};const A=k.userRole?E.permissionRoles:E.permission;if(k.userRole){if(F&&!A)return{show:T,enabled:T}}else if(F&&!E&&!A)return{show:!0,enabled:!1};var S={show:!1,enabled:!1};if(k.userRole){var Q=this.currentUser?.infoRoles;if(Q){let W={show:!0,enabled:!0};if(A.show&&A.show.length&&(S.show=Q.some(j=>A.show.includes(j)),W.show=!1),A.enabled&&A.enabled.length&&(S.enabled=Q.some(j=>A.enabled.includes(j)),W.enabled=!1),W.show&&W.enabled)return W}else S.show=!(A&&A.show&&A.show.length),S.enabled=!(A&&A.enabled&&A.enabled.length)}else if(F){var O=A>>8;S.show=!O||0!=(O&F),S.enabled=!(O=255&A)||0!=(O&F)}else S.show=!A,S.enabled=!A;return S}static \u0275fac=function(T){return new(T||b)(g.KVO(N.Qq),g.KVO(p.h))};static \u0275prov=g.jDH({token:b,factory:b.\u0275fac})}return b})()},3131:(Rt,Be,ie)=>{"use strict";ie.d(Be,{Em:()=>A,Ih:()=>T});var N=ie(7705),K=ie(5431),e=ie(5312),l=ie(7546),_=ie(3276),p=ie(4233),h=ie(8326),g=ie(3728),w=ie(4412),y=ie(4205),b=ie(751),M=ie(2576),E=ie(8256);let T=(()=>{class S{projectService;translateService;authService;deviceAdapaterService;toastr;onVariableChanged=new N.bkB;onDeviceChanged=new N.bkB;onDeviceBrowse=new N.bkB;onDeviceNodeAttribute=new N.bkB;onDaqResult=new N.bkB;onDeviceProperty=new N.bkB;onHostInterfaces=new N.bkB;onAlarmsStatus=new N.bkB;onDeviceWebApiRequest=new N.bkB;onDeviceTagsRequest=new N.bkB;onScriptConsole=new N.bkB;onGoTo=new N.bkB;onOpen=new N.bkB;onServerConnection$=new w.t(!1);static separator="^~^";hmi;viewSignalGaugeMap=new F;variables={};alarms={highhigh:0,high:0,low:0,info:0};socket;endPointConfig=h.G.getURL();bridge=null;addFunctionType=g.Aq.getEnumKey(_.Z4,_.Z4.add);removeFunctionType=g.Aq.getEnumKey(_.Z4,_.Z4.remove);homeTagsSubscription=[];viewsTagsSubscription=[];getGaugeMapped;constructor(O,W,j,Y,U){this.projectService=O,this.translateService=W,this.authService=j,this.deviceAdapaterService=Y,this.toastr=U,this.initSocket(),this.projectService.onLoadHmi.subscribe(()=>{this.hmi=this.projectService.getHmi()}),this.authService.currentUser$.subscribe(X=>{this.initSocket(X?.token)})}setSignalValue(O){this.onVariableChanged.emit(O)}putSignalValue(O,W,j=null){if(O=this.deviceAdapaterService.resolveAdapterTagsId([O])[0],this.variables[O]||(this.variables[O]=new _.rT(O,null,null)),this.variables[O].value=this.getValueInFunction(this.variables[O].value,W,j),this.socket){let Y=this.projectService.getDeviceFromTagId(O);Y&&(this.variables[O].source=Y.id),Y?.type===l.bq.internal?(this.variables[O].timestamp=(new Date).getTime(),this.setSignalValue(this.variables[O]),Y.tags[O].value=W):this.socket.emit(k.DEVICE_VALUES,{cmd:"set",var:this.variables[O],fnc:[j,W]})}else this.bridge?this.bridge.setDeviceValue(this.variables[O],{fnc:[j,W]}):e.c.serverEnabled||this.setSignalValue(this.variables[O])}getAllSignals(){return this.variables}initSignalValues(O){for(const[W,j]of Object.entries(O))g.Aq.isNullOrUndefined(this.variables[W])||(this.variables[W].value=this.variables[j]?.value||null)}getValueInFunction(O,W,j){try{if(!j)return W;if(O||(O=0),j===this.addFunctionType)return parseFloat(O)+parseFloat(W);if(j===this.removeFunctionType)return parseFloat(O)-parseFloat(W)}catch(Y){console.error(Y)}return W}initClient(O){return!!O&&(this.bridge=O,!!this.bridge&&(this.bridge.onDeviceValues=W=>this.onDeviceValues(W),this.askDeviceValues(),!0))}onDeviceValues(O){for(let W=0;W<O.length;W++){let j=O[W].id;this.variables[j]||(this.variables[j]=new _.rT(j,null,null)),this.variables[j].value=O[W].value,this.variables[j].error=O[W].error,this.setSignalValue(this.variables[j])}}initSocket(O=null){e.c.serverEnabled&&(this.socket?.close(),this.socket=K(`${this.endPointConfig}/?token=${O}`),this.socket.on("connect",()=>{this.onServerConnection$.next(!0),this.tagsSubscribe()}),this.socket.on("disconnect",W=>{this.onServerConnection$.next(!1),console.log("socket disconnected: ",W)}),this.socket.io.on("reconnect_attempt",()=>{console.log("socket.io try to reconnect...")}),this.socket.on(k.DEVICE_STATUS,W=>{if(this.onDeviceChanged.emit(W),"connect-error"===W.status&&this.hmi?.layout?.show_connection_error){let j=W.id,Y=this.projectService.getDeviceFromId(W.id);Y&&(j=Y.name);let U="";this.translateService.get("msg.device-connection-error",{value:j}).subscribe(X=>{U=X}),this.toastr.error(U,"",{timeOut:3e3,closeButton:!0})}}),this.socket.on(k.DEVICE_PROPERTY,W=>{this.onDeviceProperty.emit(W)}),this.socket.on(k.DEVICE_VALUES,W=>{const j=(Y,U,X)=>{g.Aq.isNullOrUndefined(this.variables[Y])&&(this.variables[Y]=new _.rT(Y,null,null)),this.variables[Y].value=U,this.variables[Y].timestamp=X,this.setSignalValue(this.variables[Y])};for(let Y=0;Y<W.values.length;Y++){const U=W.values[Y].id,X=W.values[Y].value,z=W.values[Y].timestamp;j(U,X,z);const R=this.deviceAdapaterService.resolveDeviceTagIdForAdapter(U);R?.length&&R.forEach(Z=>{j(Z,X,z)})}}),this.socket.on(k.DEVICE_BROWSE,W=>{this.onDeviceBrowse.emit(W)}),this.socket.on(k.DEVICE_NODE_ATTRIBUTE,W=>{this.onDeviceNodeAttribute.emit(W)}),this.socket.on(k.DAQ_RESULT,W=>{this.onDaqResult.emit(W)}),this.socket.on(k.ALARMS_STATUS,W=>{this.onAlarmsStatus.emit(W)}),this.socket.on(k.HOST_INTERFACES,W=>{this.onHostInterfaces.emit(W)}),this.socket.on(k.DEVICE_WEBAPI_REQUEST,W=>{this.onDeviceWebApiRequest.emit(W)}),this.socket.on(k.DEVICE_TAGS_REQUEST,W=>{this.onDeviceTagsRequest.emit(W)}),this.socket.on(k.SCRIPT_CONSOLE,W=>{this.onScriptConsole.emit(W)}),this.socket.on(k.SCRIPT_COMMAND,W=>{this.onScriptCommand(W)}),this.socket.on(k.ALIVE,W=>{this.onServerConnection$.next(!0)}),this.askDeviceValues(),this.askAlarmsStatus())}askDeviceStatus(){this.socket&&this.socket.emit(k.DEVICE_STATUS,"get")}askDeviceProperty(O,W){this.socket&&this.socket.emit(k.DEVICE_PROPERTY,{endpoint:O,type:W})}askWebApiProperty(O){this.socket&&this.socket.emit(k.DEVICE_WEBAPI_REQUEST,{property:O})}askDeviceTags(O){this.socket&&this.socket.emit(k.DEVICE_TAGS_REQUEST,{deviceId:O})}askHostInterface(){this.socket&&this.socket.emit(k.HOST_INTERFACES,"get")}askDeviceValues(){this.socket?this.socket.emit(k.DEVICE_VALUES,{cmd:"get"}):this.bridge&&this.bridge.getDeviceValues(null)}askAlarmsStatus(){this.socket&&this.socket.emit(k.ALARMS_STATUS,"get")}emitMappedSignalsGauge(O){let W=this.viewSignalGaugeMap.getSignalIds(O);for(let j=0;j<W.length;j++)this.variables[W[j]]&&this.setSignalValue(this.variables[W[j]])}askDeviceBrowse(O,W){this.socket&&this.socket.emit(k.DEVICE_BROWSE,{device:O,node:W})}askNodeAttributes(O,W){this.socket&&this.socket.emit(k.DEVICE_NODE_ATTRIBUTE,{device:O,node:W})}queryDaqValues(O){this.socket&&(O.sids=this.deviceAdapaterService.resolveAdapterTagsId(O.sids),this.socket.emit(k.DAQ_QUERY,O))}tagsSubscribe(O=!1){if(this.socket){const W=this.viewsTagsSubscription.concat(this.homeTagsSubscription),j=this.deviceAdapaterService.resolveAdapterTagsId(W);let Y={tagsId:[...new Set(j)],sendLastValue:O};this.socket.emit(k.DEVICE_TAGS_SUBSCRIBE,Y)}}viewsTagsSubscribe(O,W=!1){this.viewsTagsSubscription=O,this.tagsSubscribe(W)}homeTagsSubscribe(O){this.homeTagsSubscription=O,this.tagsSubscribe()}tagsUnsubscribe(O){this.socket&&this.socket.emit(k.DEVICE_TAGS_UNSUBSCRIBE,{tagsId:O})}deviceEnable(O,W){this.socket&&this.socket.emit(k.DEVICE_ENABLE,{deviceName:O,enable:W})}addSignal(O){this.variables[O]||(this.variables[O]=new _.rT(O,null,this.projectService.getDeviceFromTagId(O)))}addSignalGaugeToMap(O,W,j){this.viewSignalGaugeMap.add(O,W,j),this.variables[W]||(this.variables[W]=new _.rT(W,null,this.projectService.getDeviceFromTagId(W)))}removeSignalGaugeFromMap(O){let W=