(()=>{function e(t,e,s,n,c,o,r){e=e.deviceId;function u(s){o.getDeviceTypeFromDevice(s).then(function(e){var i;s.c8y_ModbusDevice&&(i=e,t.discreteIOs=[],t.discreteInputs=[],t.discreteOutputs=[],i)&&i.c8y_Coils&&_.forEach(i.c8y_Coils,function(e){e.statusMapping&&e.statusMapping.status&&(_.assign(e,{selected:r.isDiscreteIOSelectedInConfig(e,t.config)}),t.discreteIOs.push(e),(e.input?t.discreteInputs:t.discreteOutputs).push(e))}),i=e,t.registers=[],t.inputRegisters=[],t.holdingRegisters=[],i&&i.c8y_Registers&&_.forEach(i.c8y_Registers,function(e){e.statusMapping&&e.statusMapping.status&&(_.assign(e,{selected:r.isRegisterSelectedInConfig(e,t.config)}),t.registers.push(e),(e.input?t.inputRegisters:t.holdingRegisters).push(e))}),t.showOnlyHoldingRegisters=!s.c8y_ModbusDevice,t.isOPCUADevice=s.c8y_OPCUADevice||s.c8y_OPCUAGateway,g()})}function g(){var e=t.config.coils&&t.config.registers&&0<t.config.coils.length+t.config.registers.length;t.forms.componentForm.fieldsControl.$setValidity("fields_selected",e)}t.deviceId=e,t.updateFields=function(){t.config.coils=_(t.discreteIOs).filter({selected:!0}).map(function(e){return e.id||[e.input,e.number].join(",")}).value(),t.config.registers=_(t.registers).filter({selected:!0}).map(function(e){return e.id||[e.input,e.number,e.startBit].join(",")}).value(),g()},t.$watch("config.device",function(e){var i;e&&(i=(e=e).id||e,(o.isFieldbusDevice(e)?s.when(e):c.detail(i).then(n.getResData)).then(u))})}e.$inject=["$scope","$routeParams","$q","c8yBase","c8yDevices","c8yDeviceDatabase","modbusWidgetSvc"],angular.module("c8y.modbusWidgets").controller("modbusWidgetConfigCtrl",e)})();