\r\n
Device requires pairing
\r\n

\r\n
This device only allows authorized connections, you need to pair with the device in order to monitor and\r\n control it. Make sure that the device is within reach as you will need to press 'Accept' on the device itself.
\r\n
An example of how the pairing screen will look is presented above, pressing accept gives this connection complete\r\n control of the device. Ensure you only ever press accept when you are pairing yourself.
\r\n
\r\n \r\n
\r\n
;\r\n }\r\n}","import React, {Component} from \"react\";\r\nimport {FloatMenuItem, ListMenuItem, MenuItem, Rgb32MenuItem, SubMenuItem} from \"./api/MenuItem\";\r\nimport {ControllerState, MenuComponent, MenuController} from \"./api/MenuController\";\r\nimport {formatForDisplay, formatStringToWire} from \"./api/MenuItemFormatter\";\r\nimport {AckStatus, isAckStatusError} from \"./api/protocol/TagValEnums\";\r\nimport {PairingPanel} from \"./PairingPanel\";\r\n\r\nenum MenuUIState { READY, PENDING_UPDATE, RECENT_UPDATE, UPDATE_ERROR }\r\nconst UPDATE_HIGHLIGHT_TIME = 1000;\r\nconst MAXIMUM_WAIT_FOR_CORRELATION = 3000;\r\n\r\nexport class BaseMenuUI extends Component<{ itemId: string, controller: MenuController }, { value: string }> implements MenuComponent {\r\n protected itemName: string = \"\";\r\n protected itemId: string = \"\";\r\n protected readOnly: boolean = false;\r\n protected lastUpdate: number = Date.now();\r\n protected itemState: MenuUIState = MenuUIState.READY;\r\n protected outstandingCorrelation: number = 0;\r\n\r\n constructor(props: { itemId: string, controller: MenuController }) {\r\n super(props);\r\n this.bindAllControls();\r\n }\r\n\r\n componentDidMount() {\r\n this.updateItem();\r\n }\r\n\r\n private updateItem() {\r\n let item = this.props.controller.getTree().getMenuItemFor(this.props.itemId);\r\n if (item) {\r\n this.props.controller.putMenuComponent(item.getMenuId(), this);\r\n if(this.itemState === MenuUIState.READY) this.itemState = MenuUIState.RECENT_UPDATE;\r\n this.lastUpdate = Date.now();\r\n this.internalUpdateItem(item);\r\n }\r\n }\r\n\r\n ackReceived(correlationId: number, ackStatus: AckStatus) {\r\n if(correlationId === this.outstandingCorrelation) {\r\n this.outstandingCorrelation = 0;\r\n this.itemState = isAckStatusError(ackStatus) ? MenuUIState.UPDATE_ERROR : MenuUIState.RECENT_UPDATE;\r\n this.forceUpdate();\r\n }\r\n }\r\n\r\n tick(timeNow: number): void {\r\n const ticks = timeNow - this.lastUpdate;\r\n if(this.itemState === MenuUIState.PENDING_UPDATE) {\r\n if(ticks > MAXIMUM_WAIT_FOR_CORRELATION) {\r\n this.itemState = MenuUIState.UPDATE_ERROR;\r\n this.outstandingCorrelation = 0;\r\n this.lastUpdate = Date.now();\r\n this.forceUpdate();\r\n }\r\n }\r\n else if(this.itemState !== MenuUIState.READY && ticks > UPDATE_HIGHLIGHT_TIME) {\r\n this.itemState = MenuUIState.READY;\r\n this.forceUpdate();\r\n }\r\n }\r\n\r\n calculatedClass(baseClass: string): string {\r\n switch(this.itemState) {\r\n case MenuUIState.PENDING_UPDATE: return baseClass + \" pendingUpdate\";\r\n case MenuUIState.RECENT_UPDATE: return baseClass + \" itemHasUpdated\";\r\n case MenuUIState.UPDATE_ERROR: return baseClass + \" errorDuringUpdate\";\r\n default: return baseClass;\r\n }\r\n }\r\n\r\n internalUpdateItem(item: MenuItem