(()=>{function e(e,n,t,u,a,i,o,l,c,s,m){var r,d,g=this,f=t.PROFIBUS_DEVICE_FRAGMENT,h=t.CANOPEN_DEVICE_FRAGMENT,t=i.isElementChangePending,v=i.canUpdateElement,E=i.getCurrentElementValue,p=s("Value out of range. Allowed values from {{min | number}} to {{max | number}}."),b=[];function y(e){n(C,e)}function C(){_.forEach(g.categories,function(e){_.forEach(e.elements,function(e){var n;n=e,g.isElementChangePending(n)||_.includes(b,n)||(e.meta.type===a.ElementType.DISCRETE_IO&&(e.valueObj=_.find(e.meta.enumValues,{value:E(g.device,e)})),e.meta.type===a.ElementType.REGISTER&&(e.meta.enumType?e.valueObj=_.find(e.meta.enumValues,{value:E(g.device,e)}):_.set(e,"valueObj.value",E(g.device,e))))})})}_.assign(g,{$onChanges:function(e){e.config&&(e=>{e&&c.getWidgetModel(e).then(function(e){_.assign(g,e)})})(g.config)},$doCheck:function(){var e=!1;_.isEqual(r,g.categories)||(r=_.cloneDeep(g.categories),e=!0);_.isEqual(d,g.device)||(d=_.cloneDeep(g.device),e=!0);e&&y()},isElementChangePending:t,canUpdateElement:v,updateElement:function(e,n,t){var u=i.updateElement;_.has(e,f)?u=o.updateElement:_.has(e,h)&&(u=l.updateElement);return u(e,n,t).then(function(){b=_.without(b,n),y(500)})},shouldShowSwitch:function(e){return e.meta.enumType&&e.meta.enumValues&&2===e.meta.enumValues.length},shouldShowEnumSelect:function(e){return e.meta.enumType&&e.meta.enumValues&&(1===e.meta.enumValues.length||2<e.meta.enumValues.length)},shouldShowNumberInput:function(e){return!e.meta.enumType},validationHints:function(e,n){var t=[];n.meta.valuesRange.possiblePrecisionLoss&&t.push(m.getString("Precision loss may occur, check Cloud Fieldbus specification for details."));g.canUpdateElement(g.device,n)&&(n=_.get(n,"meta.valuesRange.custom"),t.push(u.validationHints(e,{required:s("This field is required."),"value-in-register-range":m.getString(p,n)})));return t.join(" ")},focus:function(e){b.push(e)},blur:_.debounce(function(e){b=_.without(b,e),y(500)},500)})}e.$inject=["$rootScope","$timeout","fieldbusConstants","c8yBase","c8yDeviceDatabase","c8yModbusDevice","c8yProfibusDevice","c8yCanopenDevice","modbusWidgetSvc","gettext","gettextCatalog"],angular.module("c8y.modbusWidget4").component("c8yModbusWidget",{templateUrl:":::PLUGIN_PATH:::/widget.html",bindings:{config:"<"},controllerAs:"vm",controller:e})})();