1 line
124 KiB
JavaScript
1 line
124 KiB
JavaScript
var __runInitializers=this&&this.__runInitializers||function(thisArg,initializers,value){for(var useValue=arguments.length>2,i=0;i<initializers.length;i++)value=useValue?initializers[i].call(thisArg,value):initializers[i].call(thisArg);return useValue?value:void 0},__esDecorate=this&&this.__esDecorate||function(ctor,descriptorIn,decorators,contextIn,initializers,extraInitializers){function accept(f){if(void 0!==f&&"function"!=typeof f)throw new TypeError("Function expected");return f}for(var _,kind=contextIn.kind,key="getter"===kind?"get":"setter"===kind?"set":"value",target=!descriptorIn&&ctor?contextIn.static?ctor:ctor.prototype:null,descriptor=descriptorIn||(target?Object.getOwnPropertyDescriptor(target,contextIn.name):{}),done=!1,i=decorators.length-1;i>=0;i--){var context={};for(var p in contextIn)context[p]="access"===p?{}:contextIn[p];for(var p in contextIn.access)context.access[p]=contextIn.access[p];context.addInitializer=function(f){if(done)throw new TypeError("Cannot add initializers after decoration has completed");extraInitializers.push(accept(f||null))};var result=(0,decorators[i])("accessor"===kind?{get:descriptor.get,set:descriptor.set}:descriptor[key],context);if("accessor"===kind){if(void 0===result)continue;if(null===result||"object"!=typeof result)throw new TypeError("Object expected");(_=accept(result.get))&&(descriptor.get=_),(_=accept(result.set))&&(descriptor.set=_),(_=accept(result.init))&&initializers.unshift(_)}else(_=accept(result))&&("field"===kind?initializers.unshift(_):descriptor[key]=_)}target&&Object.defineProperty(target,contextIn.name,descriptor),done=!0};import{TcHmiControl}from"Beckhoff.TwinCAT.HMI.Framework/index.esm.js";import*as Helper from"./InputHints.js";export var KeyType;!function(KeyType){KeyType[KeyType.CHARACTER=0]="CHARACTER",KeyType[KeyType.MODIFIER=1]="MODIFIER",KeyType[KeyType.ACTION=2]="ACTION",KeyType[KeyType.EDIT=3]="EDIT",KeyType[KeyType.LAYOUTSWITCH=4]="LAYOUTSWITCH",KeyType[KeyType.INDIRECTINPUT=5]="INDIRECTINPUT",KeyType[KeyType.INPUTHINTS=6]="INPUTHINTS"}(KeyType||(KeyType={}));export var KeyMode;!function(KeyMode){KeyMode[KeyMode.NORMAL=0]="NORMAL",KeyMode[KeyMode.STICKY=1]="STICKY",KeyMode[KeyMode.TOGGLE=2]="TOGGLE"}(KeyMode||(KeyMode={}));export var KeyLocation;!function(KeyLocation){KeyLocation[KeyLocation.STANDARD=0]="STANDARD",KeyLocation[KeyLocation.LEFT=1]="LEFT",KeyLocation[KeyLocation.RIGHT=2]="RIGHT",KeyLocation[KeyLocation.NUMPAD=3]="NUMPAD"}(KeyLocation||(KeyLocation={}));export var LongpressAction;!function(LongpressAction){LongpressAction[LongpressAction.NONE=0]="NONE",LongpressAction[LongpressAction.REPEAT=1]="REPEAT",LongpressAction[LongpressAction.ADDITIONALKEYS=2]="ADDITIONALKEYS",LongpressAction[LongpressAction.LOCK=3]="LOCK"}(LongpressAction||(LongpressAction={}));export var IndirectInputComponent;!function(IndirectInputComponent){IndirectInputComponent[IndirectInputComponent.TEXTBOX=0]="TEXTBOX",IndirectInputComponent[IndirectInputComponent.ACCEPT=1]="ACCEPT",IndirectInputComponent[IndirectInputComponent.CANCEL=2]="CANCEL"}(IndirectInputComponent||(IndirectInputComponent={}));export var ValidationLevel;!function(ValidationLevel){ValidationLevel[ValidationLevel.None=0]="None",ValidationLevel[ValidationLevel.HighlightHints=1]="HighlightHints",ValidationLevel[ValidationLevel.DisableAccept=2]="DisableAccept"}(ValidationLevel||(ValidationLevel={}));let TcHmiKeyboard=(()=>{var _a,_b,_c,_d,_e,_f,_g,_h,_j;let ___onResized_decorators,___onIframeElementAdded_decorators,___onIframeElementRemoved_decorators,___onIframeLoad_decorators,___onFocusIn_decorators,___onFocusOut_decorators,___onRootMouseDownOrTouchStart_decorators,___onDocumentMouseDownOrTouchStart_decorators,___onMouseDown_decorators,___onMouseOver_decorators,___onMouseOut_decorators,___onMouseUp_decorators,___onTouchStart_decorators,___onTouchMove_decorators,___onTouchEndOrCancel_decorators,___onInput_decorators,___onResolverForIndirectInputPaddingWatchCallback_decorators,___onResolverForKeyboardPaddingWatchCallback_decorators,___onResolverForKeyPaddingWatchCallback_decorators,___onResolverForAdditionalKeyBackdropPaddingWatchCallback_decorators,___onResolverForKeyBackgroundColorWatchCallback_decorators,___onResolverForLabelColorWatchCallback_decorators,___onResolverForLabelStrokeColorWatchCallback_decorators,___onResolverForLabelFillColorWatchCallback_decorators,___onResolverForAdditionalKeyBackdropColorWatchCallback_decorators,_classSuper=TcHmiControl.Control,_instanceExtraInitializers=[];return class TcHmiKeyboard extends _classSuper{static{const _metadata="function"==typeof Symbol&&Symbol.metadata?Object.create(_classSuper[Symbol.metadata]??null):void 0;___onResized_decorators=[TcHmi.EventHandler()],___onIframeElementAdded_decorators=[TcHmi.EventHandler()],___onIframeElementRemoved_decorators=[TcHmi.EventHandler()],___onIframeLoad_decorators=[TcHmi.EventHandler()],___onFocusIn_decorators=[TcHmi.EventHandler({checkIsEnabled:!0})],___onFocusOut_decorators=[TcHmi.EventHandler({checkIsEnabled:!0})],___onRootMouseDownOrTouchStart_decorators=[TcHmi.EventHandler()],___onDocumentMouseDownOrTouchStart_decorators=[TcHmi.EventHandler()],___onMouseDown_decorators=[TcHmi.EventHandler({checkIsEnabled:!0,checkAccess:"operate"})],___onMouseOver_decorators=[TcHmi.EventHandler({checkIsEnabled:!0,checkAccess:"operate"})],___onMouseOut_decorators=[TcHmi.EventHandler({checkIsEnabled:!0,checkAccess:"operate"})],___onMouseUp_decorators=[TcHmi.EventHandler({checkIsEnabled:!0,checkAccess:"operate"})],___onTouchStart_decorators=[TcHmi.EventHandler({checkIsEnabled:!0,checkAccess:"operate"})],___onTouchMove_decorators=[TcHmi.EventHandler({checkIsEnabled:!0,checkAccess:"operate"})],___onTouchEndOrCancel_decorators=[TcHmi.EventHandler({checkIsEnabled:!0,checkAccess:"operate"})],___onInput_decorators=[TcHmi.EventHandler()],___onResolverForIndirectInputPaddingWatchCallback_decorators=[(_a=TcHmi).CallbackMethod.bind(_a)],___onResolverForKeyboardPaddingWatchCallback_decorators=[(_b=TcHmi).CallbackMethod.bind(_b)],___onResolverForKeyPaddingWatchCallback_decorators=[(_c=TcHmi).CallbackMethod.bind(_c)],___onResolverForAdditionalKeyBackdropPaddingWatchCallback_decorators=[(_d=TcHmi).CallbackMethod.bind(_d)],___onResolverForKeyBackgroundColorWatchCallback_decorators=[(_e=TcHmi).CallbackMethod.bind(_e)],___onResolverForLabelColorWatchCallback_decorators=[(_f=TcHmi).CallbackMethod.bind(_f)],___onResolverForLabelStrokeColorWatchCallback_decorators=[(_g=TcHmi).CallbackMethod.bind(_g)],___onResolverForLabelFillColorWatchCallback_decorators=[(_h=TcHmi).CallbackMethod.bind(_h)],___onResolverForAdditionalKeyBackdropColorWatchCallback_decorators=[(_j=TcHmi).CallbackMethod.bind(_j)],__esDecorate(this,null,___onResized_decorators,{kind:"method",name:"__onResized",static:!1,private:!1,access:{has:obj=>"__onResized"in obj,get:obj=>obj.__onResized},metadata:_metadata},null,_instanceExtraInitializers),__esDecorate(this,null,___onIframeElementAdded_decorators,{kind:"method",name:"__onIframeElementAdded",static:!1,private:!1,access:{has:obj=>"__onIframeElementAdded"in obj,get:obj=>obj.__onIframeElementAdded},metadata:_metadata},null,_instanceExtraInitializers),__esDecorate(this,null,___onIframeElementRemoved_decorators,{kind:"method",name:"__onIframeElementRemoved",static:!1,private:!1,access:{has:obj=>"__onIframeElementRemoved"in obj,get:obj=>obj.__onIframeElementRemoved},metadata:_metadata},null,_instanceExtraInitializers),__esDecorate(this,null,___onIframeLoad_decorators,{kind:"method",name:"__onIframeLoad",static:!1,private:!1,access:{has:obj=>"__onIframeLoad"in obj,get:obj=>obj.__onIframeLoad},metadata:_metadata},null,_instanceExtraInitializers),__esDecorate(this,null,___onFocusIn_decorators,{kind:"method",name:"__onFocusIn",static:!1,private:!1,access:{has:obj=>"__onFocusIn"in obj,get:obj=>obj.__onFocusIn},metadata:_metadata},null,_instanceExtraInitializers),__esDecorate(this,null,___onFocusOut_decorators,{kind:"method",name:"__onFocusOut",static:!1,private:!1,access:{has:obj=>"__onFocusOut"in obj,get:obj=>obj.__onFocusOut},metadata:_metadata},null,_instanceExtraInitializers),__esDecorate(this,null,___onRootMouseDownOrTouchStart_decorators,{kind:"method",name:"__onRootMouseDownOrTouchStart",static:!1,private:!1,access:{has:obj=>"__onRootMouseDownOrTouchStart"in obj,get:obj=>obj.__onRootMouseDownOrTouchStart},metadata:_metadata},null,_instanceExtraInitializers),__esDecorate(this,null,___onDocumentMouseDownOrTouchStart_decorators,{kind:"method",name:"__onDocumentMouseDownOrTouchStart",static:!1,private:!1,access:{has:obj=>"__onDocumentMouseDownOrTouchStart"in obj,get:obj=>obj.__onDocumentMouseDownOrTouchStart},metadata:_metadata},null,_instanceExtraInitializers),__esDecorate(this,null,___onMouseDown_decorators,{kind:"method",name:"__onMouseDown",static:!1,private:!1,access:{has:obj=>"__onMouseDown"in obj,get:obj=>obj.__onMouseDown},metadata:_metadata},null,_instanceExtraInitializers),__esDecorate(this,null,___onMouseOver_decorators,{kind:"method",name:"__onMouseOver",static:!1,private:!1,access:{has:obj=>"__onMouseOver"in obj,get:obj=>obj.__onMouseOver},metadata:_metadata},null,_instanceExtraInitializers),__esDecorate(this,null,___onMouseOut_decorators,{kind:"method",name:"__onMouseOut",static:!1,private:!1,access:{has:obj=>"__onMouseOut"in obj,get:obj=>obj.__onMouseOut},metadata:_metadata},null,_instanceExtraInitializers),__esDecorate(this,null,___onMouseUp_decorators,{kind:"method",name:"__onMouseUp",static:!1,private:!1,access:{has:obj=>"__onMouseUp"in obj,get:obj=>obj.__onMouseUp},metadata:_metadata},null,_instanceExtraInitializers),__esDecorate(this,null,___onTouchStart_decorators,{kind:"method",name:"__onTouchStart",static:!1,private:!1,access:{has:obj=>"__onTouchStart"in obj,get:obj=>obj.__onTouchStart},metadata:_metadata},null,_instanceExtraInitializers),__esDecorate(this,null,___onTouchMove_decorators,{kind:"method",name:"__onTouchMove",static:!1,private:!1,access:{has:obj=>"__onTouchMove"in obj,get:obj=>obj.__onTouchMove},metadata:_metadata},null,_instanceExtraInitializers),__esDecorate(this,null,___onTouchEndOrCancel_decorators,{kind:"method",name:"__onTouchEndOrCancel",static:!1,private:!1,access:{has:obj=>"__onTouchEndOrCancel"in obj,get:obj=>obj.__onTouchEndOrCancel},metadata:_metadata},null,_instanceExtraInitializers),__esDecorate(this,null,___onInput_decorators,{kind:"method",name:"__onInput",static:!1,private:!1,access:{has:obj=>"__onInput"in obj,get:obj=>obj.__onInput},metadata:_metadata},null,_instanceExtraInitializers),__esDecorate(this,null,___onResolverForIndirectInputPaddingWatchCallback_decorators,{kind:"method",name:"__onResolverForIndirectInputPaddingWatchCallback",static:!1,private:!1,access:{has:obj=>"__onResolverForIndirectInputPaddingWatchCallback"in obj,get:obj=>obj.__onResolverForIndirectInputPaddingWatchCallback},metadata:_metadata},null,_instanceExtraInitializers),__esDecorate(this,null,___onResolverForKeyboardPaddingWatchCallback_decorators,{kind:"method",name:"__onResolverForKeyboardPaddingWatchCallback",static:!1,private:!1,access:{has:obj=>"__onResolverForKeyboardPaddingWatchCallback"in obj,get:obj=>obj.__onResolverForKeyboardPaddingWatchCallback},metadata:_metadata},null,_instanceExtraInitializers),__esDecorate(this,null,___onResolverForKeyPaddingWatchCallback_decorators,{kind:"method",name:"__onResolverForKeyPaddingWatchCallback",static:!1,private:!1,access:{has:obj=>"__onResolverForKeyPaddingWatchCallback"in obj,get:obj=>obj.__onResolverForKeyPaddingWatchCallback},metadata:_metadata},null,_instanceExtraInitializers),__esDecorate(this,null,___onResolverForAdditionalKeyBackdropPaddingWatchCallback_decorators,{kind:"method",name:"__onResolverForAdditionalKeyBackdropPaddingWatchCallback",static:!1,private:!1,access:{has:obj=>"__onResolverForAdditionalKeyBackdropPaddingWatchCallback"in obj,get:obj=>obj.__onResolverForAdditionalKeyBackdropPaddingWatchCallback},metadata:_metadata},null,_instanceExtraInitializers),__esDecorate(this,null,___onResolverForKeyBackgroundColorWatchCallback_decorators,{kind:"method",name:"__onResolverForKeyBackgroundColorWatchCallback",static:!1,private:!1,access:{has:obj=>"__onResolverForKeyBackgroundColorWatchCallback"in obj,get:obj=>obj.__onResolverForKeyBackgroundColorWatchCallback},metadata:_metadata},null,_instanceExtraInitializers),__esDecorate(this,null,___onResolverForLabelColorWatchCallback_decorators,{kind:"method",name:"__onResolverForLabelColorWatchCallback",static:!1,private:!1,access:{has:obj=>"__onResolverForLabelColorWatchCallback"in obj,get:obj=>obj.__onResolverForLabelColorWatchCallback},metadata:_metadata},null,_instanceExtraInitializers),__esDecorate(this,null,___onResolverForLabelStrokeColorWatchCallback_decorators,{kind:"method",name:"__onResolverForLabelStrokeColorWatchCallback",static:!1,private:!1,access:{has:obj=>"__onResolverForLabelStrokeColorWatchCallback"in obj,get:obj=>obj.__onResolverForLabelStrokeColorWatchCallback},metadata:_metadata},null,_instanceExtraInitializers),__esDecorate(this,null,___onResolverForLabelFillColorWatchCallback_decorators,{kind:"method",name:"__onResolverForLabelFillColorWatchCallback",static:!1,private:!1,access:{has:obj=>"__onResolverForLabelFillColorWatchCallback"in obj,get:obj=>obj.__onResolverForLabelFillColorWatchCallback},metadata:_metadata},null,_instanceExtraInitializers),__esDecorate(this,null,___onResolverForAdditionalKeyBackdropColorWatchCallback_decorators,{kind:"method",name:"__onResolverForAdditionalKeyBackdropColorWatchCallback",static:!1,private:!1,access:{has:obj=>"__onResolverForAdditionalKeyBackdropColorWatchCallback"in obj,get:obj=>obj.__onResolverForAdditionalKeyBackdropColorWatchCallback},metadata:_metadata},null,_instanceExtraInitializers),_metadata&&Object.defineProperty(this,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:_metadata})}static#tchmiFQN="TcHmi.Controls.Beckhoff."+this.name;constructor(element,pcElement,attrs){super(element,pcElement,attrs)}__elementTemplateRoot=__runInitializers(this,_instanceExtraInitializers);__elementPaddingContainer;__localizedElements=new Map;__localizationReader=void 0;__layouts=null;__currentLayout={name:"empty",dimensions:{width:1,height:1},keys:[]};__layoutLoaded=null;__fixedTargetInputElements=null;__fixedTargetTextareaElements=null;__layoutFile;__scaleMode;__fixedTarget;__releaseStickyKeysManually;__inputHintsValidation;__keyboardPadding;__keyPadding;__additionalKeyBackdropPadding;__longpressDelay;__repetitionDelay;__indirectInputHorizontalAlignment;__indirectInputFontSize;__indirectInputFontSizeUnit;__indirectInputPadding;__labelFontSize;__labelFontSizeUnit;__labelFontFamily;__labelFontStyle;__labelFontWeight;__labelStrokeThickness;__keyBackgroundColor;__labelColor;__labelStrokeColor;__labelFillColor;__additionalKeyBackdropColor;__modifiers={Shift:!1,Control:!1,Alt:!1,Meta:!1,CapsLock:!1,NumLock:!0,Insert:!1};__keys=new Map;__additionalKeys=new Map;__pressedKeyMouse=null;__pressedKeysTouch=[];__pressedKeys=[];static __layoutCache=new Map;__keyActions={KeyChar:{press:(key,activeInput,sequenceIndex)=>{if(null===activeInput)return;const text=activeInput.value??"",specialKey=this.__specialKeys[key.key[sequenceIndex]];let typedChar=specialKey?.char??key.key[sequenceIndex];typedChar=this.__unescape(typedChar),void 0!==this.__compositionKey?.composition[typedChar]&&(typedChar=this.__compositionKey.composition[typedChar]);const selectionStart=this.__getSelectionStartOrEnd(activeInput,"selectionStart"),selectionEnd=this.__getSelectionStartOrEnd(activeInput,"selectionEnd");this.__setInputElementValue(activeInput,text.substring(0,selectionStart)+typedChar+text.substring(this.__modifiers.Insert?selectionEnd+1:selectionEnd)),this.__setCaretPosition(activeInput,selectionStart+typedChar.length)},release:(key,activeInput,sequenceIndex)=>{key.ignoreModifiers||this.__unstickAllKeys()},getInputEventInit:(key,activeInput,sequenceIndex)=>{if(null===activeInput)return null;if("Enter"===key.key[sequenceIndex])return"TEXTAREA"===activeInput?.tagName.toUpperCase()?{inputType:"insertLineBreak",data:null}:null;const specialKey=this.__specialKeys[key.key[sequenceIndex]];let typedChar=specialKey?.char??key.key[sequenceIndex];return typedChar=this.__unescape(typedChar),void 0!==this.__compositionKey?.composition[typedChar]&&(typedChar=this.__compositionKey.composition[typedChar]),{inputType:"insertText",data:typedChar}}},Shift:{press:(key,activeInput,sequenceIndex)=>this.__toggleModifier("Shift",!0),release:(key,activeInput,sequenceIndex)=>this.__toggleModifier("Shift",!1)},Control:{press:(key,activeInput,sequenceIndex)=>this.__toggleModifier("Control",!0),release:(key,activeInput,sequenceIndex)=>this.__toggleModifier("Control",!1)},Alt:{press:(key,activeInput,sequenceIndex)=>this.__toggleModifier("Alt",!0),release:(key,activeInput,sequenceIndex)=>this.__toggleModifier("Alt",!1)},Meta:{press:(key,activeInput,sequenceIndex)=>this.__toggleModifier("Meta",!0),release:(key,activeInput,sequenceIndex)=>this.__toggleModifier("Meta",!1)},CapsLock:{press:(key,activeInput,sequenceIndex)=>this.__toggleModifier("CapsLock")},NumLock:{press:(key,activeInput,sequenceIndex)=>this.__toggleModifier("NumLock")},Insert:{press:(key,activeInput,sequenceIndex)=>this.__toggleModifier("Insert")},ArrowLeft:{press:(key,activeInput,sequenceIndex)=>{if(null===activeInput)return;const selectionStart=this.__getSelectionStartOrEnd(activeInput,"selectionStart"),selectionEnd=this.__getSelectionStartOrEnd(activeInput,"selectionEnd"),isPasswordInput="password"===activeInput.type.toLowerCase();selectionStart===selectionEnd||this.__modifiers.Shift?this.__moveCaret(activeInput,"backward",currentPosition=>this.__caretPositionLeft(currentPosition,activeInput.value,key.ignoreModifiers,isPasswordInput),key.ignoreModifiers):this.__setCaretPosition(activeInput,selectionStart),this.__arrowUpDownTarget=null}},ArrowRight:{press:(key,activeInput,sequenceIndex)=>{if(null===activeInput)return;const selectionStart=this.__getSelectionStartOrEnd(activeInput,"selectionStart"),selectionEnd=this.__getSelectionStartOrEnd(activeInput,"selectionEnd"),isPasswordInput="password"===activeInput.type.toLowerCase();selectionStart===selectionEnd||this.__modifiers.Shift?this.__moveCaret(activeInput,"forward",currentPosition=>this.__caretPositionRight(currentPosition,activeInput.value,key.ignoreModifiers,isPasswordInput),key.ignoreModifiers):this.__setCaretPosition(activeInput,selectionEnd),this.__arrowUpDownTarget=null}},ArrowUp:{press:(key,activeInput,sequenceIndex)=>{if(null===activeInput)return;const[newSelectionStart,newSelectionEnd]=this.__moveCaret(activeInput,"backward",currentPosition=>{const mirrorElement=this.__getMirrorElement(activeInput),currentCoords=this.__getCaretCoordinates(mirrorElement,activeInput.value,currentPosition);let lastCoords=currentCoords,newPosition=currentPosition-1,newCoords=this.__getCaretCoordinates(mirrorElement,activeInput.value,newPosition);const selectionStart=this.__getSelectionStartOrEnd(activeInput,"selectionStart"),selectionEnd=this.__getSelectionStartOrEnd(activeInput,"selectionEnd");for(null!==this.__arrowUpDownTarget&&this.__arrowUpDownTarget.input===activeInput&&this.__arrowUpDownTarget.selectionStart===selectionStart&&this.__arrowUpDownTarget.selectionEnd===selectionEnd||(this.__arrowUpDownTarget={left:currentCoords.left,input:activeInput,selectionStart,selectionEnd});newPosition>=0&&(newCoords.top===currentCoords.top||newCoords.left>this.__arrowUpDownTarget.left);)lastCoords=newCoords,newPosition--,newCoords=this.__getCaretCoordinates(mirrorElement,activeInput.value,newPosition);return mirrorElement.remove(),newPosition<0?0:this.__arrowUpDownTarget.left-newCoords.left<=lastCoords.left-this.__arrowUpDownTarget.left||lastCoords.top===currentCoords.top?newPosition:newPosition+1},key.ignoreModifiers);null!==this.__arrowUpDownTarget&&(this.__arrowUpDownTarget.selectionStart=newSelectionStart,this.__arrowUpDownTarget.selectionEnd=newSelectionEnd)}},ArrowDown:{press:(key,activeInput,sequenceIndex)=>{if(null===activeInput)return;const[newSelectionStart,newSelectionEnd]=this.__moveCaret(activeInput,"forward",currentPosition=>{const mirrorElement=this.__getMirrorElement(activeInput),currentCoords=this.__getCaretCoordinates(mirrorElement,activeInput.value,currentPosition);let lastCoords=currentCoords,newPosition=currentPosition+1,newCoords=this.__getCaretCoordinates(mirrorElement,activeInput.value,newPosition),topDifference=0;const selectionStart=this.__getSelectionStartOrEnd(activeInput,"selectionStart"),selectionEnd=this.__getSelectionStartOrEnd(activeInput,"selectionEnd");for(null!==this.__arrowUpDownTarget&&this.__arrowUpDownTarget.input===activeInput&&this.__arrowUpDownTarget.selectionStart===selectionStart&&this.__arrowUpDownTarget.selectionEnd===selectionEnd||(this.__arrowUpDownTarget={left:currentCoords.left,input:activeInput,selectionStart,selectionEnd});newPosition<=activeInput.value.length&&(newCoords.top===currentCoords.top||newCoords.left<this.__arrowUpDownTarget.left)&&(0===topDifference||newCoords.top-currentCoords.top<=topDifference);)topDifference=newCoords.top-currentCoords.top,lastCoords=newCoords,newPosition++,newCoords=this.__getCaretCoordinates(mirrorElement,activeInput.value,newPosition);return mirrorElement.remove(),newPosition>activeInput.value.length?activeInput.value.length:0!==topDifference&&newCoords.top-currentCoords.top>topDifference?newPosition-1:newCoords.left-this.__arrowUpDownTarget.left<this.__arrowUpDownTarget.left-lastCoords.left||lastCoords.top===currentCoords.top?newPosition:newPosition-1},key.ignoreModifiers);null!==this.__arrowUpDownTarget&&(this.__arrowUpDownTarget.selectionStart=newSelectionStart,this.__arrowUpDownTarget.selectionEnd=newSelectionEnd)}},Home:{press:(key,activeInput,sequenceIndex)=>{if(null===activeInput)return;this.__moveCaret(activeInput,"backward",currentPosition=>{if(this.__modifiers.Control&&!key.ignoreModifiers)return 0;const mirrorElement=this.__getMirrorElement(activeInput),currentCoords=this.__getCaretCoordinates(mirrorElement,activeInput.value,currentPosition);let newPosition=currentPosition-1,newCoords=this.__getCaretCoordinates(mirrorElement,activeInput.value,newPosition);for(;newPosition>=0&&newCoords.top===currentCoords.top;)newPosition--,newCoords=this.__getCaretCoordinates(mirrorElement,activeInput.value,newPosition);return mirrorElement.remove(),newPosition<0?0:newPosition+1},key.ignoreModifiers)}},End:{press:(key,activeInput,sequenceIndex)=>{if(null===activeInput)return;this.__moveCaret(activeInput,"forward",currentPosition=>{if(this.__modifiers.Control&&!key.ignoreModifiers)return activeInput.value.length;const mirrorElement=this.__getMirrorElement(activeInput),currentCoords=this.__getCaretCoordinates(mirrorElement,activeInput.value,currentPosition);let newPosition=currentPosition+1,newCoords=this.__getCaretCoordinates(mirrorElement,activeInput.value,newPosition);for(;newPosition<=activeInput.value.length&&newCoords.top===currentCoords.top;)newPosition++,newCoords=this.__getCaretCoordinates(mirrorElement,activeInput.value,newPosition);return mirrorElement.remove(),newPosition>activeInput.value.length?activeInput.value.length:newPosition-1},key.ignoreModifiers)}},Backspace:{press:(key,activeInput,sequenceIndex)=>{if(null===activeInput)return;let selectionStart=this.__getSelectionStartOrEnd(activeInput,"selectionStart");const selectionEnd=this.__getSelectionStartOrEnd(activeInput,"selectionEnd");let text=activeInput.value;const isPasswordInput="password"===activeInput.type.toLowerCase();selectionStart===selectionEnd&&(selectionStart=this.__caretPositionLeft(selectionStart,text,key.ignoreModifiers,isPasswordInput)),text=text.substring(0,selectionStart)+text.substring(selectionEnd),this.__setInputElementValue(activeInput,text),this.__setCaretPosition(activeInput,selectionStart)},getInputEventInit:(key,activeInput,sequenceIndex)=>{if(null===activeInput)return null;const selectionStart=this.__getSelectionStartOrEnd(activeInput,"selectionStart"),selectionEnd=this.__getSelectionStartOrEnd(activeInput,"selectionEnd");return 0===selectionStart&&0===selectionEnd?null:{inputType:this.__modifiers.Control&&!key.ignoreModifiers?"deleteWordBackward":"deleteContentBackward",data:null}}},Delete:{press:(key,activeInput,sequenceIndex)=>{if(null===activeInput)return;const selectionStart=this.__getSelectionStartOrEnd(activeInput,"selectionStart");let selectionEnd=this.__getSelectionStartOrEnd(activeInput,"selectionEnd"),text=activeInput.value;const isPasswordInput="password"===activeInput.type.toLowerCase();selectionStart===selectionEnd&&(selectionEnd=this.__caretPositionRight(selectionEnd,text,key.ignoreModifiers,isPasswordInput)),text=text.substring(0,selectionStart)+text.substring(selectionEnd),this.__setInputElementValue(activeInput,text),this.__setCaretPosition(activeInput,selectionStart)},getInputEventInit:(key,activeInput,sequenceIndex)=>{if(null===activeInput)return null;const selectionStart=this.__getSelectionStartOrEnd(activeInput,"selectionStart"),selectionEnd=this.__getSelectionStartOrEnd(activeInput,"selectionEnd"),textLength=activeInput.value.length;return selectionStart===textLength&&selectionEnd===textLength?null:{inputType:this.__modifiers.Control&&!key.ignoreModifiers?"deleteWordForward":"deleteContentForward",data:null}}},SelectAll:{press:(key,activeInput,sequenceIndex)=>{if(null!==activeInput){this.__setSelectionStartOrEnd(activeInput,"selectionStart",0),this.__setSelectionStartOrEnd(activeInput,"selectionEnd",activeInput.value.length);try{activeInput.selectionDirection="forward"}catch(ex){TcHmi.Log.Controls.error(this,TcHmiKeyboard.#tchmiFQN,'Tried to set selectionDirection on an input element that does not support this. Try using an <input type="text" /> element.')}}},release:(key,activeInput,sequenceIndex)=>{key.ignoreModifiers||this.__unstickAllKeys()}},PlusMinus:{press:(key,activeInput,sequenceIndex)=>{if(null===activeInput)return;const text=activeInput.value,convertedText=Number(text),selectionEnd=this.__getSelectionStartOrEnd(activeInput,"selectionEnd");""===text?(this.__setInputElementValue(activeInput,"-"),this.__setCaretPosition(activeInput,1)):"-"===text?(this.__setInputElementValue(activeInput,""),this.__setCaretPosition(activeInput,0)):isNaN(convertedText)||(convertedText>0?(this.__setInputElementValue(activeInput,"-"+text),this.__setCaretPosition(activeInput,selectionEnd+1)):convertedText<0||text.startsWith("-")?(this.__setInputElementValue(activeInput,text.substring(1)),this.__setCaretPosition(activeInput,selectionEnd-1)):(this.__setInputElementValue(activeInput,"-"+text),this.__setCaretPosition(activeInput,selectionEnd+1)))},getInputEventInit:(key,activeInput,sequenceIndex)=>{if(null===activeInput)return null;const text=activeInput.value,convertedText=Number(text);let data=null;return""===text?data="-":"-"===text?data="":isNaN(convertedText)||(data=convertedText>0?"-"+text:convertedText<0||text.startsWith("-")?text.substring(1):"-"+text),null===data?null:{inputType:"insertReplacementText",data}}}};__keyCodes={Backspace:8,Tab:9,Enter:13,Shift:16,Control:17,Alt:18,CapsLock:20,Escape:27,Space:32,PageUp:33,PageDown:34,End:35,Home:36,ArrowLeft:37,ArrowUp:38,ArrowRight:39,ArrowDown:40,Delete:46,";":186,":":186,"=":187,"+":187,",":188,"<":188,"-":189,_:189,".":190,">":190,"/":191,"?":191,"~":192,"[":219,"{":219,"\\":220,"|":220,"]":221,"}":221,"'":222,'"':222,"^":220,"´":221,"`":221};__specialKeys={Tab:{char:"\t"},Enter:{char:"\n",code:13}};__stickiedKeys=[];__keysToStick=[];__compositionKey=null;__interactedKeys=[];__additionalKeysBaseKey=null;__arrowUpDownTarget=null;__shownLabels=[];__hiddenLabels=[];__indirectInputElement=null;__indirectInputAcceptElements=[];__inputHints;__activeElement=null;__fixedTargetObserver=null;__ignoreSetActiveElement=!1;__indirectInputInProgress=!1;__iframes=new Set;__processWidthOnResized=!1;__processHeightOnResized=!1;__destroyOnAttached=null;__destroyOnDestroyed=null;__destroyOnHideAdditionalKeys=[];__previnit(){if(this.__elementTemplateRoot=this.__element.find(".TcHmi_Controls_Beckhoff_TcHmiKeyboard-template"),0===this.__elementTemplateRoot.length&&(this.__elementTemplateRoot=this.__element.find(".tchmi-keyboard-template")),this.__elementPaddingContainer=this.__elementTemplateRoot.find(".TcHmi_Controls_Beckhoff_TcHmiKeyboard-template-padding-container"),0===this.__elementPaddingContainer.length&&(this.__elementPaddingContainer=this.__elementTemplateRoot.find(".tchmi-keyboard-template-padding-container")),0===this.__elementTemplateRoot.length||0===this.__elementPaddingContainer.length)throw new Error("Invalid Template.html");this.__inputHints=new Helper.InputHints(this.__elementPaddingContainer[0],this),this.__destroyOnDestroy.push(this.__inputHints.onUpdate.add(()=>{this.__processInputHintsValidation()})),TCHMI_DESIGNER&&this.__destroyOnDestroy.push(this.__localization.watchEx({level:TcHmi.Locale.Level.Engineering},data=>{if(data.error===TcHmi.Errors.NONE&&data.reader){this.__localizationReader=data.reader;for(const[key,info]of this.__localizedElements){const localizedText=data.reader.get(key);info.textContent=localizedText}}})),super.__previnit()}__init(){if(super.__init(),!this.__layoutFile){const controlBasedLayoutAttr=this.__attrs["data-tchmi-layout"];controlBasedLayoutAttr&&this.setLayout(controlBasedLayoutAttr.value)}this.__destroyOnDestroy.push(TcHmi.EventProvider.registerDomEvent(this.__element,"mousedown",this.__onRootMouseDownOrTouchStart,{passive:!1}),TcHmi.EventProvider.registerDomEvent(this.__element,"touchstart",this.__onRootMouseDownOrTouchStart,{passive:!1}),TcHmi.EventProvider.registerDomEvent(this.__element,"mousedown",this.__onMouseDown),TcHmi.EventProvider.registerDomEvent(this.__element,"mouseover",this.__onMouseOver),TcHmi.EventProvider.registerDomEvent(this.__element,"mouseout",this.__onMouseOut),TcHmi.EventProvider.registerDomEvent(this.__element,"mouseup",this.__onMouseUp),TcHmi.EventProvider.registerDomEvent(this.__element,"touchstart",this.__onTouchStart),TcHmi.EventProvider.registerDomEvent(this.__element,"touchmove",this.__onTouchMove),TcHmi.EventProvider.registerDomEvent(this.__element,"touchend",this.__onTouchEndOrCancel),TcHmi.EventProvider.registerDomEvent(this.__element,"touchcancel",this.__onTouchEndOrCancel))}__attach(){super.__attach(),this.__iframes=new Set(document.getElementsByTagName("iframe"));for(const iframe of this.__iframes)iframe.addEventListener("load",this.__onIframeLoad,{passive:!0}),iframe.contentDocument&&this.__addDocumentLevelEventListeners(iframe.contentDocument);this.__destroyOnDetach.push(TcHmi.EventProvider.register(this.__id+".onResized",this.__onResized),TcHmi.EventProvider.register("System.onIFrameElementAdded",this.__onIframeElementAdded),TcHmi.EventProvider.register("System.onIFrameElementRemoved",this.__onIframeElementRemoved)),this.__addDocumentLevelEventListeners(document),this.__processFixedTarget(),this.__setInitialActiveElements()}__detach(){super.__detach();for(const iframe of this.__iframes)iframe.contentDocument&&this.__removeDocumentLevelEventListeners(iframe.contentDocument),iframe.removeEventListener("load",this.__onIframeLoad);this.__iframes.clear(),this.__hideAdditionalKeys(),this.__destroyOnAttached?.(),this.__destroyOnAttached=null,this.__destroyOnDestroyed?.(),this.__destroyOnDestroyed=null,this.__fixedTargetObserver?.disconnect(),this.__fixedTargetObserver=null,this.__removeDocumentLevelEventListeners(document)}destroy(){if(this.__keepAlive)return;const passiveEventOptions={passive:!0};this.__indirectInputElement?.removeEventListener("input",this.__onInput,passiveEventOptions),this.__activeElement?.removeEventListener("input",this.__onInput,passiveEventOptions),super.destroy()}__onResized(_event,_control){this.__processScaleMode(),this.__processWidthOnResized&&this.__processWidth(),this.__processHeightOnResized&&this.__processHeight()}__onIframeElementAdded(_event,iFrame){this.__iframes.has(iFrame)||(this.__iframes.add(iFrame),iFrame.addEventListener("load",this.__onIframeLoad,{passive:!0,capture:!1}),this.__handleIframeAddedOrLoaded(iFrame))}__onIframeElementRemoved(_event,iFrame){this.__iframes.has(iFrame)&&(iFrame.contentDocument&&this.__removeDocumentLevelEventListeners(iFrame.contentDocument),iFrame.removeEventListener("load",this.__onIframeLoad,{capture:!1}),this.__iframes.delete(iFrame))}__onIframeLoad(event){event.target instanceof HTMLIFrameElement&&this.__handleIframeAddedOrLoaded(event.target)}__handleIframeAddedOrLoaded(iframe){if(iframe.contentDocument&&(this.__addDocumentLevelEventListeners(iframe.contentDocument),this.__fixedTargetObserver)){const targetControl=TcHmi.Controls.get(this.__fixedTarget);targetControl&&targetControl.getElement()[0].contains(iframe)&&this.__fixedTargetObserver.observe(iframe.contentDocument,{childList:!0,subtree:!0})}}__onFocusIn(event){if(!this.__layouts||this.__fixedTarget)return;if(event.target&&event.target===this.__indirectInputElement)return void this.__startIndirectInput();const target=event.target&&"tagName"in event.target?event.target:null;target?.classList.contains("TcHmi_Controls_Beckhoff_TcHmiKeyboard-template-textbox")||(this.__isSuitableElement(target,!0)?this.__setActiveElement(target):this.__setActiveElement(null))}__onFocusOut(event){if(!this.__layouts||this.__fixedTarget||this.__indirectInputElement&&event.relatedTarget===this.__indirectInputElement)return;const target=event.target&&"tagName"in event.target?event.target:null;target?.classList.contains("TcHmi_Controls_Beckhoff_TcHmiKeyboard-template-textbox")||(event.view===window?this.__setActiveElement(null):event.target&&event.target===this.__activeElement&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{event.target===this.__activeElement&&document.activeElement!==this.__indirectInputElement&&this.__setActiveElement(null)})}))}__onRootMouseDownOrTouchStart(event){"mousedown"===event.type&&0!==event.button||this.__layouts&&this.__layouts.useIndirectInput&&event.target===this.__indirectInputElement||event.cancelable&&event.preventDefault()}__onDocumentMouseDownOrTouchStart(event){if(null!==this.__additionalKeysBaseKey&&event.target!==this.__additionalKeysBaseKey.element&&event.target&&"tagName"in event.target){const additionalKeysContainer=this.__additionalKeys.get(this.__additionalKeysBaseKey.element);additionalKeysContainer&&!additionalKeysContainer.contains(event.target)&&this.__hideAdditionalKeys()}}__onMouseDown(event){if(0!==event.button||!(event.target instanceof HTMLElement))return;const keyElement=event.target.closest(".TcHmi_Controls_Beckhoff_TcHmiKeyboard-template-key, .tchmi-keyboard-template-key");keyElement&&keyElement!==this.__pressedKeyMouse&&(keyElement.classList.add("down"),this.__pressedKeyMouse=keyElement,this.__keyInteractionStarted(keyElement),this.__raiseKeyPressStarted(keyElement))}__onMouseOver(event){if(!(event.target instanceof HTMLElement))return;const keyElement=event.target.closest(".TcHmi_Controls_Beckhoff_TcHmiKeyboard-template-key, .tchmi-keyboard-template-key");keyElement&&(keyElement.classList.add("hover"),event.buttons>0&&null!==this.__additionalKeysBaseKey&&this.__additionalKeysBaseKey.dragging&&this.__additionalKeys.get(this.__additionalKeysBaseKey.element)===keyElement.parentElement&&!keyElement.classList.contains("down")&&(keyElement.classList.add("down"),this.__raiseKeyPressStarted(keyElement)))}__onMouseOut(event){if(!(event.target instanceof HTMLElement))return;const keyElement=event.target.closest(".TcHmi_Controls_Beckhoff_TcHmiKeyboard-template-key, .tchmi-keyboard-template-key");keyElement&&(this.__handleMouseOrTouchLeave(keyElement,{x:event.clientX,y:event.clientY}),this.__pressedKeyMouse=null,this.__raiseKeyPressEnded(keyElement,"Canceled"))}__onMouseUp(event){if(!(event.target instanceof HTMLElement))return;const keyElement=event.target.closest(".TcHmi_Controls_Beckhoff_TcHmiKeyboard-template-key, .tchmi-keyboard-template-key");keyElement&&(keyElement.classList.remove("down"),null!==this.__additionalKeysBaseKey&&(this.__additionalKeysBaseKey.dragging&&this.__additionalKeys.get(this.__additionalKeysBaseKey.element)===keyElement.parentElement&&(this.__pressedKeyMouse=keyElement,this.__keyInteractionStarted(keyElement)),this.__additionalKeysBaseKey.dragging=!1),keyElement===this.__pressedKeyMouse&&(this.__pressedKeyMouse=null,this.__keyInteractionEnded(keyElement),this.__raiseKeyPressEnded(keyElement,"Finished")))}__onTouchStart(event){for(const touch of event.changedTouches){if(!(touch.target instanceof HTMLElement))continue;const keyElement=touch.target.closest(".TcHmi_Controls_Beckhoff_TcHmiKeyboard-template-key, .tchmi-keyboard-template-key");keyElement&&(this.__pressedKeysTouch.some(pressedKey=>pressedKey.keyElement===keyElement)||(keyElement.classList.add("hover","down"),this.__pressedKeysTouch.push({touchID:touch.identifier,keyElement}),this.__keyInteractionStarted(keyElement),this.__raiseKeyPressStarted(keyElement)))}}__onTouchMove(event){for(const touch of event.changedTouches){const pressedKey=this.__pressedKeysTouch.find(pressedKey=>pressedKey.touchID===touch.identifier);if(!pressedKey)continue;const keyElement=document.elementFromPoint(touch.clientX,touch.clientY)?.closest(".TcHmi_Controls_Beckhoff_TcHmiKeyboard-template-key, .tchmi-keyboard-template-key");if(keyElement!==pressedKey.keyElement&&null!==pressedKey.keyElement){const interactedKeyRemoved=this.__handleMouseOrTouchLeave(pressedKey.keyElement,{x:touch.clientX,y:touch.clientY});if(this.__raiseKeyPressEnded(pressedKey.keyElement,"Canceled"),pressedKey.keyElement=null,!interactedKeyRemoved)continue}keyElement&&null===pressedKey.keyElement&&(keyElement.classList.add("hover"),null!==this.__additionalKeysBaseKey&&this.__additionalKeysBaseKey.dragging&&this.__additionalKeys.get(this.__additionalKeysBaseKey.element)===keyElement.parentElement&&(keyElement.classList.add("down"),this.__raiseKeyPressStarted(keyElement)),pressedKey.keyElement=keyElement)}}__onTouchEndOrCancel(event){for(const touch of event.changedTouches){const pressedKey=this.__pressedKeysTouch.find(pressedKey=>pressedKey.touchID===touch.identifier);if(!(pressedKey&&touch.target instanceof HTMLElement))continue;const originalKeyElement=touch.target.closest(".TcHmi_Controls_Beckhoff_TcHmiKeyboard-template-key, .tchmi-keyboard-template-key");if(!originalKeyElement)continue;originalKeyElement.classList.remove("hover","down"),this.__pressedKeysTouch.splice(this.__pressedKeysTouch.indexOf(pressedKey),1);const keyElement=document.elementFromPoint(touch.clientX,touch.clientY)?.closest(".TcHmi_Controls_Beckhoff_TcHmiKeyboard-template-key, .tchmi-keyboard-template-key");keyElement?.classList.remove("hover","down"),!keyElement||keyElement!==event.target&&keyElement.parentElement!==event.target||(null!==this.__additionalKeysBaseKey&&(this.__additionalKeysBaseKey.dragging&&this.__additionalKeys.get(this.__additionalKeysBaseKey.element)===keyElement.parentElement&&this.__keyInteractionStarted(keyElement),this.__additionalKeysBaseKey.dragging=!1),this.__keyInteractionEnded(keyElement),this.__raiseKeyPressEnded(keyElement,"Finished"))}}__handleMouseOrTouchLeave(keyElement,coordinates){keyElement.classList.remove("hover","down");const interactedKey=this.__interactedKeys.find(iKey=>iKey.element===keyElement);if(void 0===interactedKey)return!1;if(interactedKey.key.longpressAction===LongpressAction.ADDITIONALKEYS&&!interactedKey.timedOut){const boundingRectKey=keyElement.getBoundingClientRect(),keyCenter={x:boundingRectKey.left+boundingRectKey.width/2,y:boundingRectKey.top+boundingRectKey.height/2},additionalKeyBoundingRect=keyElement.getElementsByClassName("TcHmi_Controls_Beckhoff_TcHmiKeyboard-template-backdrop")[0].getBoundingClientRect(),direction={x:Math.round((coordinates.x-keyCenter.x)/boundingRectKey.width),y:Math.round((coordinates.y-keyCenter.y)/boundingRectKey.height)};let showAdditionalKeys=!1;if((additionalKeyBoundingRect.top<keyCenter.y&&additionalKeyBoundingRect.left<keyCenter.x&&additionalKeyBoundingRect.right>keyCenter.x&&direction.y<=-1||additionalKeyBoundingRect.bottom>keyCenter.y&&additionalKeyBoundingRect.left<keyCenter.x&&additionalKeyBoundingRect.right>keyCenter.x&&direction.y>=1||additionalKeyBoundingRect.left<keyCenter.x&&additionalKeyBoundingRect.top<keyCenter.y&&additionalKeyBoundingRect.bottom>keyCenter.y&&direction.x<=-1||additionalKeyBoundingRect.right>keyCenter.x&&additionalKeyBoundingRect.top<keyCenter.y&&additionalKeyBoundingRect.bottom>keyCenter.y&&direction.x>=1)&&(showAdditionalKeys=!0),showAdditionalKeys)return-1!==interactedKey.timeoutID&&(window.clearTimeout(interactedKey.timeoutID),interactedKey.timeoutID=-1),interactedKey.timedOut=!0,this.__showAdditionalKeys(interactedKey.element),!1}return this.__interactedKeys=this.__interactedKeys.filter(iKey=>iKey.element!==interactedKey.element),-1!==interactedKey.timeoutID&&(window.clearTimeout(interactedKey.timeoutID),interactedKey.timeoutID=-1),!0}__onInput(_event){this.__processInputHintsValidation()}__addDocumentLevelEventListeners(target){const passiveEventOptions={passive:!0};target.addEventListener("focusin",this.__onFocusIn,passiveEventOptions),target.addEventListener("focusout",this.__onFocusOut,passiveEventOptions),target.addEventListener("mousedown",this.__onDocumentMouseDownOrTouchStart,passiveEventOptions),target.addEventListener("touchstart",this.__onDocumentMouseDownOrTouchStart,passiveEventOptions)}__removeDocumentLevelEventListeners(target){const passiveEventOptions={passive:!0};target.removeEventListener("focusin",this.__onFocusIn,passiveEventOptions),target.removeEventListener("focusout",this.__onFocusOut,passiveEventOptions),target.removeEventListener("mousedown",this.__onDocumentMouseDownOrTouchStart,passiveEventOptions),target.removeEventListener("touchstart",this.__onDocumentMouseDownOrTouchStart,passiveEventOptions)}__showAdditionalKeys(keyElement){const additionalKeysContainer=this.__additionalKeys.get(keyElement);if(!additionalKeysContainer)return;const keyBoundingRect=keyElement.getBoundingClientRect();additionalKeysContainer.style.width=keyBoundingRect.width+"px",additionalKeysContainer.style.height=keyBoundingRect.height+"px",additionalKeysContainer.style.left=keyBoundingRect.left+"px",additionalKeysContainer.style.top=keyBoundingRect.top+"px",this.__destroyOnHideAdditionalKeys.push(TcHmi.EventProvider.registerDomEvent(additionalKeysContainer,"mousedown",this.__onRootMouseDownOrTouchStart,{passive:!1}),TcHmi.EventProvider.registerDomEvent(additionalKeysContainer,"touchstart",this.__onRootMouseDownOrTouchStart,{passive:!1}),TcHmi.EventProvider.registerDomEvent(additionalKeysContainer,"mousedown",this.__onMouseDown),TcHmi.EventProvider.registerDomEvent(additionalKeysContainer,"mouseover",this.__onMouseOver),TcHmi.EventProvider.registerDomEvent(additionalKeysContainer,"mouseout",this.__onMouseOut),TcHmi.EventProvider.registerDomEvent(additionalKeysContainer,"mouseup",this.__onMouseUp),TcHmi.EventProvider.registerDomEvent(additionalKeysContainer,"touchstart",this.__onTouchStart),TcHmi.EventProvider.registerDomEvent(additionalKeysContainer,"touchmove",this.__onTouchMove),TcHmi.EventProvider.registerDomEvent(additionalKeysContainer,"touchend",this.__onTouchEndOrCancel),TcHmi.EventProvider.registerDomEvent(additionalKeysContainer,"touchcancel",this.__onTouchEndOrCancel)),TcHmi.TopMostLayer.add(this,additionalKeysContainer,{dimBackground:!1,modal:!1,removeCb:()=>keyElement.appendChild(additionalKeysContainer)}),keyElement.classList.add("show-additional-keys"),this.__additionalKeysBaseKey={element:keyElement,dragging:!0}}__hideAdditionalKeys(){if(null===this.__additionalKeysBaseKey)return;const additionalKeysContainer=this.__additionalKeys.get(this.__additionalKeysBaseKey.element);if(additionalKeysContainer){for(const destroy of this.__destroyOnHideAdditionalKeys)destroy();this.__destroyOnHideAdditionalKeys=[],TcHmi.TopMostLayer.remove(this,additionalKeysContainer),this.__additionalKeysBaseKey.element.classList.remove("show-additional-keys"),this.__interactedKeys=this.__interactedKeys.filter(iKey=>iKey.element!==this.__additionalKeysBaseKey.element),this.__additionalKeysBaseKey=null}}__keyInteractionStarted(keyElement){null!==this.__additionalKeysBaseKey&&this.__additionalKeysBaseKey.element!==keyElement&&this.__additionalKeys.get(this.__additionalKeysBaseKey.element)!==keyElement.parentElement&&this.__hideAdditionalKeys();const existingKey=this.__interactedKeys.find(iKey=>iKey.element===keyElement);if(void 0!==existingKey)return void(existingKey.hideAdditionalKeys=!0);const interactedKey={element:keyElement,key:this.__getKey(keyElement),pressed:!1,timeoutID:-1,timedOut:!1};if(null!==this.__additionalKeysBaseKey&&this.__additionalKeysBaseKey.element===interactedKey.element)interactedKey.hideAdditionalKeys=!0;else if(isStandardKey(interactedKey.key)){const key=interactedKey.key;switch(key.longpressAction){case LongpressAction.REPEAT:interactedKey.timeoutID=window.setTimeout(()=>{const repeat=()=>{this.__pressKey(key,!0),interactedKey.pressed=!0,interactedKey.timeoutID=window.setTimeout(repeat,this.__repetitionDelay)};this.__pressKey(key),interactedKey.pressed=!0,interactedKey.timedOut=!0,interactedKey.timeoutID=window.setTimeout(repeat,this.__repetitionDelay)},this.__longpressDelay);break;case LongpressAction.ADDITIONALKEYS:interactedKey.timeoutID=window.setTimeout(()=>{this.__showAdditionalKeys(interactedKey.element),interactedKey.timedOut=!0,interactedKey.timeoutID=-1},this.__longpressDelay);break;case LongpressAction.LOCK:if(key.mode===KeyMode.STICKY){if(key.active&&!key.locked){const stickiedKey=this.__getStickiedKey(key,this.__stickiedKeys);if(void 0!==stickiedKey&&void 0!==this.__longpressDelay&&Date.now()-stickiedKey.stickTime<=this.__longpressDelay){const keyToStick=this.__getStickiedKey(key,this.__keysToStick);if(void 0===keyToStick){const stickiedKey=this.__keyToStickiedKey(key,!0);this.__keysToStick.push(stickiedKey)}else keyToStick.locked=!0;break}}interactedKey.timeoutID=window.setTimeout(()=>{const keyToStick=this.__getStickiedKey(key,this.__keysToStick);void 0!==keyToStick&&(keyToStick.locked=!0),interactedKey.timedOut=!0,interactedKey.timeoutID=-1},this.__longpressDelay)}case LongpressAction.NONE:if(key.mode===KeyMode.STICKY&&(this.__pressKey(key),interactedKey.pressed=!0,void 0===this.__getStickiedKey(key,this.__keysToStick))){const stickiedKey=this.__keyToStickiedKey(key,!1);this.__keysToStick.push(stickiedKey)}}}this.__interactedKeys.push(interactedKey)}__keyInteractionEnded(keyElement){const interactedKey=this.__interactedKeys.find(iKey=>iKey.element===keyElement);if(void 0===interactedKey)return;if(null!==this.__additionalKeysBaseKey&&this.__additionalKeysBaseKey.element===interactedKey.element)return void(interactedKey.hideAdditionalKeys&&this.__hideAdditionalKeys());interactedKey.element.classList.contains("additional-key")&&this.__hideAdditionalKeys();const key=interactedKey.key;if(this.__interactedKeys.splice(this.__interactedKeys.indexOf(interactedKey),1),interactedKey.pressed||(this.__pressKey(key),interactedKey.pressed=!0),-1!==interactedKey.timeoutID&&(window.clearTimeout(interactedKey.timeoutID),interactedKey.timeoutID=-1),isStandardKey(key)){if(key.mode===KeyMode.STICKY){const keyToStick=this.__getStickiedKey(key,this.__keysToStick);!key.active||!key.locked&&void 0!==keyToStick&&keyToStick.locked?void 0!==keyToStick?(this.__stickKey(key,keyToStick.locked),this.__keysToStick.splice(this.__keysToStick.indexOf(keyToStick),1)):this.__releaseKey(key):this.__unstickKey(key,!0)}else if(this.__releaseKey(key),key.mode===KeyMode.TOGGLE)for(const[element,definition]of this.__keys)key.specialCapslock&&isStandardKeyDefinition(definition)?definition.capsLock&&definition.capsLock[key.keyPath.join("")]===key.key.join(",")&&element.classList.toggle("active"):definition[key.keyPath.join("")]===key.key.join(",")&&element.classList.toggle("active")}else this.__releaseKey(key)}__pressKey(key,repeat=!1){if(!isStandardKey(key)||key.mode===KeyMode.STICKY&&key.active)return;this.__layouts&&this.__layouts.useIndirectInput&&this.__indirectInputElement&&document.activeElement!==this.__indirectInputElement&&this.__startIndirectInput();const targetElement=this.__getTargetElement();if(targetElement)for(let sequenceIndex=0;sequenceIndex<key.code.length;sequenceIndex++){let canceled=!this.__dispatchKeyEvent(targetElement,"keydown",key,sequenceIndex,repeat),compositionKeyFirstPress=!1;key.composition&&(compositionKeyFirstPress=null===this.__compositionKey,compositionKeyFirstPress&&(this.__compositionKey=key)),canceled||(null===this.__compositionKey||key.type!==KeyType.CHARACTER||compositionKeyFirstPress||void 0!==this.__compositionKey.composition[key.key[sequenceIndex]]||this.__sendKeyPressToInput(this.__compositionKey,targetElement,0,repeat),key.valid&&!compositionKeyFirstPress&&this.__sendKeyPressToInput(key,targetElement,sequenceIndex,repeat)),!this.__compositionKey||compositionKeyFirstPress||key.type!==KeyType.CHARACTER&&key.type!==KeyType.EDIT||(this.__compositionKey=null)}}__sendKeyPressToInput(key,targetElement,sequenceIndex,repeat){if(key.type===KeyType.CHARACTER&&!this.__dispatchKeyEvent(targetElement,"keypress",key,sequenceIndex,repeat))return;const action=this.__keyActions[key.type===KeyType.CHARACTER?"KeyChar":key.key[sequenceIndex]??""];if(action)if(this.__isSuitableElement(targetElement)){const inputEventInit=action.getInputEventInit?.(key,targetElement,sequenceIndex);if(inputEventInit&&!targetElement.disabled&&!targetElement.readOnly){const event=new InputEvent("beforeinput",{...inputEventInit,bubbles:!0});targetElement.dispatchEvent(event)}if(action.press(key,targetElement,sequenceIndex),inputEventInit&&!targetElement.disabled&&!targetElement.readOnly){const event=new InputEvent("input",{...inputEventInit,bubbles:!0});targetElement.dispatchEvent(event)}}else action.press(key,null,sequenceIndex),"INPUT"===targetElement.tagName.toUpperCase()&&TcHmi.Log.Controls.error(this,TcHmiKeyboard.#tchmiFQN,"Tried to interact with an input element (",targetElement,`) that does not support this (type=${targetElement.type}). Try using an <input type="text" /> element or change to an indirect keyboard layout.`)}__releaseKey(key){if(key.type!==KeyType.INPUTHINTS)if(key.type===KeyType.LAYOUTSWITCH){if(null!==this.__layouts){const layout=this.__layouts.layouts.find(layout=>layout.name===key.layoutName);void 0!==layout&&this.__activateLayout(layout)}}else if(key.type===KeyType.INDIRECTINPUT){if(this.__indirectInputElement)switch(key.component){case IndirectInputComponent.ACCEPT:this.__endIndirectInput();break;case IndirectInputComponent.CANCEL:this.__endIndirectInput(!0)}}else{this.__layouts&&this.__layouts.useIndirectInput&&this.__indirectInputElement&&document.activeElement!==this.__indirectInputElement&&this.__startIndirectInput();const targetElement=this.__getTargetElement();if(!targetElement)return;for(let sequenceIndex=0;sequenceIndex<key.code.length;sequenceIndex++){const canceled=!this.__dispatchKeyEvent(targetElement,"keyup",key,sequenceIndex);if(key.valid&&!canceled){const action=this.__keyActions[key.type===KeyType.CHARACTER?"KeyChar":key.key[sequenceIndex]||""];void 0!==action&&void 0!==action.release&&(this.__isSuitableElement(targetElement)?action.release(key,targetElement,sequenceIndex):(action.release(key,null,sequenceIndex),"INPUT"===targetElement.tagName.toUpperCase()&&TcHmi.Log.Controls.error(this,TcHmiKeyboard.#tchmiFQN,"Tried to interact with an input element (",targetElement,`) that does not support this (type=${targetElement.type}). Try using an <input type="text" /> element or change to an indirect keyboard layout.`)))}}}}__getKey(keyElement){function splitWithConsecutiveTokens(value,token){if(void 0===value)return[];let lastIndex=0,tokenIndex=value.indexOf(token,lastIndex+1);const res=[];for(;tokenIndex>-1;)res.push(value.substring(lastIndex,tokenIndex)),lastIndex=tokenIndex+token.length,tokenIndex=value.indexOf(token,lastIndex+1);return lastIndex<value.length&&res.push(value.substring(lastIndex)),res}const keyDefinition=this.__keys.get(keyElement);if(!keyDefinition)throw new Error("Invalid key");if("layout-switch"===keyDefinition.type)return{type:KeyType.LAYOUTSWITCH,layoutName:keyDefinition.layoutName};if("indirect-input"===keyDefinition.type){const component=TcHmi.ValueConverter.toEnum(keyDefinition.component,IndirectInputComponent);if(null===component)throw new Error("Invalid value for component in indirect input definition");return{type:KeyType.INDIRECTINPUT,component}}if("input-hints"===keyDefinition.type)return{type:KeyType.INPUTHINTS};const key={code:splitWithConsecutiveTokens(keyDefinition.code,","),key:[],keyPath:[],unmodifiedKey:splitWithConsecutiveTokens(keyDefinition.key,","),type:TcHmi.ValueConverter.toEnum(keyDefinition.type,KeyType,KeyType.CHARACTER),mode:TcHmi.ValueConverter.toEnum(keyDefinition.mode,KeyMode,KeyMode.NORMAL),location:(keyDefinition.location??"").split(",").map(value=>TcHmi.ValueConverter.toEnum(value,KeyLocation,KeyLocation.STANDARD)),active:keyElement.classList.contains("active"),locked:keyElement.classList.contains("locked"),noCapsLock:keyDefinition.noCapsLock||!1,ignoreModifiers:keyDefinition.ignoreModifiers||!1,valid:!0,longpressAction:TcHmi.ValueConverter.toEnum(keyDefinition.longpressAction,LongpressAction,LongpressAction.NONE),specialCapslock:!1};let path=[];if(!key.ignoreModifiers){if(this.__modifiers.Shift&&path.push("Shift"),this.__modifiers.Control&&path.push("Ctrl"),this.__modifiers.Alt&&path.push("Alt"),this.__modifiers.CapsLock&&!key.noCapsLock){if(keyDefinition.capsLock){let capslockPath=path.join("")+"Key";capslockPath=capslockPath.substring(0,1).toLowerCase()+capslockPath.substring(1),void 0!==keyDefinition.capsLock[capslockPath]&&(key.specialCapslock=!0)}key.specialCapslock||(path.includes("Shift")?path.shift():path.unshift("Shift"))}this.__modifiers.NumLock&&Object.keys(keyDefinition).filter(key=>key.startsWith("numlock")).length>0&&path.unshift("Numlock"),path.length>0&&(path[0]=path[0].toLowerCase())}const pathedType=(key.specialCapslock?keyDefinition.capsLock:keyDefinition)[path.length>0?path.concat(["Type"]).join(""):"type"];void 0!==pathedType&&path.length>0?key.type=TcHmi.ValueConverter.toEnum(pathedType,KeyType,KeyType.CHARACTER):key.type!==KeyType.CHARACTER&&(path=[]);let keyData=(key.specialCapslock?keyDefinition.capsLock:keyDefinition)[path.length>0?path.concat(["Key"]).join(""):"key"];const compositionPath=path.length>0?path.concat(["Composition"]).join(""):"composition";if(void 0!==(key.specialCapslock?keyDefinition.capsLock:keyDefinition)[compositionPath]&&(key.composition=TcHmi.ValueConverter.toObject((key.specialCapslock?keyDefinition.capsLock:keyDefinition)[compositionPath],void 0)),void 0===keyData&&(key.valid=!1,keyData=keyDefinition.key),key.key=splitWithConsecutiveTokens(keyData,","),"Any"===key.key[0]&&(key.unmodifiedKey[0]=key.key[0]=String.fromCharCode(Math.floor(95*Math.random()+32))),key.keyPath=path.length>0?path.concat(["Key"]):["key"],key.code.length>key.key.length?key.code.splice(key.key.length,key.code.length-key.key.length):key.key.length>key.code.length&&key.key.splice(key.code.length,key.key.length-key.code.length),key.location.length<key.code.length)for(let i=key.location.length,ii=key.code.length;i<ii;i++)key.location.push(KeyLocation.STANDARD);else key.location.length>key.code.length&&key.location.splice(key.code.length,key.location.length-key.code.length);return key}__getTargetElement(){if(this.__layouts?.useIndirectInput&&this.__indirectInputElement)return this.__indirectInputElement;if(this.__fixedTarget){let elements=[];null!==this.__fixedTargetInputElements&&(elements=elements.concat(Array.from(this.__fixedTargetInputElements))),null!==this.__fixedTargetTextareaElements&&(elements=elements.concat(Array.from(this.__fixedTargetTextareaElements)));const targetControl=TcHmi.Controls.get(this.__fixedTarget);if(targetControl)for(const iframe of targetControl.getElement()[0].getElementsByTagName("iframe"))iframe.contentDocument&&(elements=elements.concat(Array.from(iframe.contentDocument.querySelectorAll("input, textarea"))));return 0===elements.length&&void 0!==targetControl&&elements.push(targetControl.getElement()[0]),elements.length>1?(TcHmi.Log.Controls.error(this,TcHmiKeyboard.#tchmiFQN,"The fixedTarget control contains more than on input or textarea element and is thus not suitable to be used as a fixedTarget."),null):0===elements.length?null:elements[0]}return document.activeElement?document.activeElement instanceof HTMLIFrameElement&&document.activeElement.contentDocument?.activeElement?document.activeElement.contentDocument.activeElement:document.activeElement:null}__dispatchKeyEvent(target,type,key,sequenceIndex,repeat=!1){const eventInit={key:void 0!==key.composition&&"keypress"!==type?"Dead":key.key[sequenceIndex],code:key.code[sequenceIndex],location:key.location[sequenceIndex],shiftKey:this.__modifiers.Shift,ctrlKey:this.__modifiers.Control,altKey:this.__modifiers.Alt,metaKey:this.__modifiers.Meta,bubbles:!0,cancelable:!0,repeat};if(null!==this.__compositionKey&&void 0!==this.__compositionKey.composition[eventInit.key]&&(eventInit.key=this.__compositionKey.composition[eventInit.key]),"keypress"===type&&key.type===KeyType.CHARACTER){if(void 0!==key.key[sequenceIndex]){const specialKey=this.__specialKeys[key.key[sequenceIndex]];let typedChar=specialKey?.char??key.key[sequenceIndex];typedChar=this.__unescape(typedChar),null!==this.__compositionKey&&void 0!==this.__compositionKey.composition[typedChar]&&(typedChar=this.__compositionKey.composition[typedChar]),eventInit.charCode=specialKey?.code??typedChar.charCodeAt(0),eventInit.keyCode=eventInit.charCode,eventInit.which=eventInit.charCode}}else void 0!==this.__keyCodes[key.key[sequenceIndex]]?(eventInit.keyCode=this.__keyCodes[key.key[sequenceIndex]],eventInit.which=eventInit.keyCode):key.type===KeyType.CHARACTER&&(void 0!==key.unmodifiedKey[sequenceIndex]?eventInit.keyCode=this.__unescape(key.unmodifiedKey[sequenceIndex]).toUpperCase().charCodeAt(0):void 0!==key.key[sequenceIndex]&&(eventInit.keyCode=this.__unescape(key.key[sequenceIndex]).toUpperCase().charCodeAt(0)),eventInit.which=eventInit.keyCode);const event=new KeyboardEvent(type,eventInit);return event.which!==eventInit.which&&void 0!==eventInit.which&&(Object.defineProperty(event,"which",{get:function(){return this.whichVal}}),event.whichVal=eventInit.which,void 0!==eventInit.charCode&&(Object.defineProperty(event,"charCode",{get:function(){return this.charCodeVal}}),event.charCodeVal=eventInit.charCode),void 0!==eventInit.keyCode&&(Object.defineProperty(event,"keyCode",{get:function(){return this.keyCodeVal}}),event.keyCodeVal=eventInit.keyCode)),target.dispatchEvent(event)}__toggleModifier(key,value){this.__modifiers[key]=void 0===value?!this.__modifiers[key]:value,this.__updateActiveModifiers()}__updateActiveModifiers(){const toRemove=[];for(const className of this.__element[0].classList)className.includes("-active")&&toRemove.push(className);this.__element[0].classList.remove(...toRemove);for(const label of this.__shownLabels)label.classList.remove("show");for(const label of this.__hiddenLabels)label.classList.remove("hide");if(this.__shownLabels=[],this.__hiddenLabels=[],this.__modifiers.Shift||this.__modifiers.Control||this.__modifiers.Alt||this.__modifiers.Meta||this.__modifiers.CapsLock){let activeModifiers="";this.__modifiers.Shift&&(activeModifiers+="shift"),this.__modifiers.Control&&this.__modifiers.Alt?activeModifiers+="altgr":this.__modifiers.Control?activeModifiers+="control":this.__modifiers.Alt&&(activeModifiers+="alt"),this.__modifiers.Meta&&(activeModifiers+="meta"),activeModifiers.length>0&&this.__element[0].classList.add(activeModifiers+"-active");const activeOrDefault=activeModifiers.length>0?activeModifiers:"default";if(this.__modifiers.CapsLock){this.__element[0].classList.add("capslock-active");let selectorShow=".TcHmi_Controls_Beckhoff_TcHmiKeyboard-template-key.no-caps-lock .TcHmi_Controls_Beckhoff_TcHmiKeyboard-template-label.show-"+activeOrDefault,selectorHide=".TcHmi_Controls_Beckhoff_TcHmiKeyboard-template-key.no-caps-lock .TcHmi_Controls_Beckhoff_TcHmiKeyboard-template-label.hide-"+activeOrDefault,modifiedModifiers=activeModifiers;this.__modifiers.Shift?(modifiedModifiers=modifiedModifiers.replace("shift",""),0===modifiedModifiers.length&&(modifiedModifiers="default")):modifiedModifiers="shift"+modifiedModifiers,selectorShow+=", .TcHmi_Controls_Beckhoff_TcHmiKeyboard-template-key:not(.no-caps-lock) .TcHmi_Controls_Beckhoff_TcHmiKeyboard-template-label.show-"+modifiedModifiers,selectorHide+=", .TcHmi_Controls_Beckhoff_TcHmiKeyboard-template-key:not(.no-caps-lock) .TcHmi_Controls_Beckhoff_TcHmiKeyboard-template-label.hide-"+modifiedModifiers,activeModifiers="capslock"+activeModifiers,selectorShow+=", .TcHmi_Controls_Beckhoff_TcHmiKeyboard-template-key:not(.no-caps-lock) .TcHmi_Controls_Beckhoff_TcHmiKeyboard-template-label.show-"+activeModifiers,selectorHide+=", .TcHmi_Controls_Beckhoff_TcHmiKeyboard-template-key:not(.no-caps-lock) .TcHmi_Controls_Beckhoff_TcHmiKeyboard-template-label.hide-"+activeModifiers,this.__shownLabels.push(...this.__elementPaddingContainer[0].querySelectorAll(selectorShow)),this.__hiddenLabels.push(...this.__elementPaddingContainer[0].querySelectorAll(selectorHide))}else this.__shownLabels.push(...this.__elementPaddingContainer[0].querySelectorAll(".TcHmi_Controls_Beckhoff_TcHmiKeyboard-template-label.show-"+activeOrDefault)),this.__hiddenLabels.push(...this.__elementPaddingContainer[0].querySelectorAll(".TcHmi_Controls_Beckhoff_TcHmiKeyboard-template-label.hide-"+activeOrDefault))}else this.__element[0].classList.add("default-active"),this.__shownLabels.push(...this.__elementPaddingContainer[0].querySelectorAll(".TcHmi_Controls_Beckhoff_TcHmiKeyboard-template-label.show-default")),this.__hiddenLabels.push(...this.__elementPaddingContainer[0].querySelectorAll(".TcHmi_Controls_Beckhoff_TcHmiKeyboard-template-label.hide-default"));this.__modifiers.NumLock&&(this.__element[0].classList.add("numlock-active"),this.__shownLabels.push(...this.__elementPaddingContainer[0].querySelectorAll(".TcHmi_Controls_Beckhoff_TcHmiKeyboard-template-label.show-numlock")),this.__hiddenLabels.push(...this.__elementPaddingContainer[0].querySelectorAll(".TcHmi_Controls_Beckhoff_TcHmiKeyboard-template-label.hide-numlock"))),this.__modifiers.Insert&&(this.__element[0].classList.add("insert-active"),this.__shownLabels.push(...this.__elementPaddingContainer[0].querySelectorAll(".TcHmi_Controls_Beckhoff_TcHmiKeyboard-template-label.show-insert")),this.__hiddenLabels.push(...this.__elementPaddingContainer[0].querySelectorAll(".TcHmi_Controls_Beckhoff_TcHmiKeyboard-template-label.hide-insert")));for(const label of this.__shownLabels)label.classList.add("show");for(const label of this.__hiddenLabels)label.classList.add("hide")}__stickKey(key,lock=!1){if(key.mode!==KeyMode.STICKY)return;let stickiedKey=this.__getStickiedKey(key,this.__stickiedKeys);void 0===stickiedKey?(stickiedKey=this.__keyToStickiedKey(key,lock),stickiedKey.stickTime=Date.now(),this.__stickiedKeys.push(stickiedKey)):stickiedKey.locked=lock;for(const[element,definition]of this.__keys)key.specialCapslock&&isStandardKeyDefinition(definition)?definition.capsLock&&definition.capsLock[key.keyPath.join("")]===key.key.join(",")&&(element.classList.add("active"),element.classList.toggle("locked",lock)):definition[key.keyPath.join("")]===key.key.join(",")&&(element.classList.add("active"),element.classList.toggle("locked",lock))}__unstickKey(key,unlock=!1){if(key.mode!==KeyMode.STICKY)return;let keyIndex=this.__stickiedKeys.indexOf(key);if(-1===keyIndex&&(keyIndex=this.__stickiedKeys.findIndex(stickiedKey=>stickiedKey.key.join(",")===key.key.join(",")&&stickiedKey.keyPath.join("-")===key.keyPath.join("-"))),-1!==keyIndex){if(!this.__stickiedKeys[keyIndex].locked||unlock){this.__releaseKey(this.__stickiedKeys[keyIndex]),this.__stickiedKeys.splice(keyIndex,1);for(const[element,definition]of this.__keys)key.specialCapslock&&isStandardKeyDefinition(definition)?definition.capsLock&&definition.capsLock[key.keyPath.join("")]===key.key.join(",")&&element.classList.remove("active","locked"):definition[key.keyPath.join("")]===key.key.join(",")&&element.classList.remove("active","locked");return!0}}return!1}__unstickAllKeys(force=!1){if(!this.__releaseStickyKeysManually||force){let keyIndex=0;for(let i=0,ii=this.__stickiedKeys.length;i<ii;i++){this.__unstickKey(this.__stickiedKeys[keyIndex],force)||keyIndex++}}this.__keysToStick=[]}__getStickiedKey(searchKey,stickiedKeyCollection){return stickiedKeyCollection.find(k=>k.key.join(",")===searchKey.key.join(",")&&k.keyPath.join("-")===searchKey.keyPath.join("-"))}__keyToStickiedKey(key,locked){return{code:key.code,key:key.key,keyPath:key.keyPath,unmodifiedKey:key.unmodifiedKey,type:key.type,mode:key.mode,location:key.location,active:key.active,noCapsLock:key.noCapsLock,ignoreModifiers:key.ignoreModifiers,valid:key.valid,longpressAction:key.longpressAction,composition:key.composition,specialCapslock:key.specialCapslock,locked,stickTime:-1}}__caretPositionLeft(currentPosition,text,ignoreModifiers,ignoreWhitespace){if(currentPosition<=0)return 0;if(this.__modifiers.Control&&!ignoreModifiers){if(ignoreWhitespace)return 0;const boundariesRegEx=/\b\S/g;let match=boundariesRegEx.exec(text),previousIndex=0;for(;match&&!(match.index>=currentPosition);)previousIndex=match.index,match=boundariesRegEx.exec(text);return previousIndex}{if(1===currentPosition)return 0;const charCodeLow=text.charCodeAt(currentPosition-1),charCodeHigh=text.charCodeAt(currentPosition-2);return charCodeLow>=56320&&charCodeLow<=57343&&charCodeHigh>=55296&&charCodeHigh<=56319?currentPosition-2:currentPosition-1}}__caretPositionRight(currentPosition,text,ignoreModifiers,ignoreWhitespace){if(currentPosition>=text.length)return text.length;if(this.__modifiers.Control&&!ignoreModifiers){if(ignoreWhitespace)return text.length;const boundariesRegEx=/\S\s*\b/g;let match=boundariesRegEx.exec(text);for(;match&&!(match.index+1>currentPosition);)match=boundariesRegEx.exec(text);return null!==match?match.index+1:text.length}{if(currentPosition===text.length-1)return text.length;const charCodeHigh=text.charCodeAt(currentPosition),charCodeLow=text.charCodeAt(currentPosition+1);return charCodeHigh>=55296&&charCodeHigh<=56319&&charCodeLow>=56320&&charCodeLow<=57343?currentPosition+2:currentPosition+1}}__moveCaret(activeInput,direction,positionFinder,ignoreModifiers){const selectionStart=this.__getSelectionStartOrEnd(activeInput,"selectionStart"),selectionEnd=this.__getSelectionStartOrEnd(activeInput,"selectionEnd");if(this.__modifiers.Shift&&!ignoreModifiers){let newSelectionStart=null,newSelectionEnd=null,newSelectionDirection=null;if(selectionStart===selectionEnd||activeInput.selectionDirection===direction)"forward"===direction?newSelectionEnd=positionFinder(selectionEnd):newSelectionStart=positionFinder(selectionStart),newSelectionDirection=direction;else if("forward"===direction){const newCaretPosition=positionFinder(selectionStart);newCaretPosition<selectionEnd?newSelectionStart=newCaretPosition:(newSelectionStart=selectionEnd,newSelectionEnd=newCaretPosition,newSelectionDirection=direction)}else{const newCaretPosition=positionFinder(selectionEnd);newCaretPosition>=selectionStart?newSelectionEnd=newCaretPosition:(newSelectionEnd=selectionStart,newSelectionStart=newCaretPosition,newSelectionDirection=direction)}if(null!==newSelectionStart&&this.__setSelectionStartOrEnd(activeInput,"selectionStart",newSelectionStart),null!==newSelectionEnd&&this.__setSelectionStartOrEnd(activeInput,"selectionEnd",newSelectionEnd),null!==newSelectionDirection)try{activeInput.selectionDirection=newSelectionDirection}catch(ex){TcHmi.Log.Controls.error(this,TcHmiKeyboard.#tchmiFQN,'Tried to set selectionDirection on an input element that does not support this. Try using an <input type="text" /> element.')}return this.__scrollCaretIntoViewbox(activeInput),[newSelectionStart??selectionStart,newSelectionEnd??selectionEnd]}{const newCaretPosition=positionFinder("backward"===activeInput.selectionDirection?selectionStart:selectionEnd);return this.__setCaretPosition(activeInput,newCaretPosition),[newCaretPosition,newCaretPosition]}}__setCaretPosition(activeInput,position){const setPosition=()=>{this.__setSelectionStartOrEnd(activeInput,"selectionStart",position),this.__setSelectionStartOrEnd(activeInput,"selectionEnd",position);try{activeInput.selectionDirection="forward"}catch(ex){TcHmi.Log.Controls.error(this,TcHmiKeyboard.#tchmiFQN,'Tried to set selectionDirection on an input element that does not support this. Try using an <input type="text" /> element.')}};setPosition(),this.__scrollCaretIntoViewbox(activeInput);const initialValue=activeInput.value;activeInput!==document.activeElement&&requestAnimationFrame(()=>{activeInput.value===initialValue&&null!==activeInput.selectionStart&&0===activeInput.selectionStart&&0!==position&&setPosition()})}__setSelectionStartOrEnd(activeInput,startOrEnd,position){if(position<0?position=0:position>activeInput.value.length&&(position=activeInput.value.length),activeInput[startOrEnd]!==position)try{activeInput[startOrEnd]=position}catch(ex){TcHmi.Log.Controls.error(this,TcHmiKeyboard.#tchmiFQN,'Tried to set selection or caret position on an input element that does not support this. Try using an <input type="text" /> element.')}}__getSelectionStartOrEnd(activeInput,startOrEnd){let position=activeInput[startOrEnd]??0;return position<0?position=0:position>activeInput.value.length&&(position=activeInput.value.length),position}__scrollCaretIntoViewbox(activeInput){const caretPosition="backward"===activeInput.selectionDirection?this.__getSelectionStartOrEnd(activeInput,"selectionStart"):this.__getSelectionStartOrEnd(activeInput,"selectionEnd"),mirrorElement=this.__getMirrorElement(activeInput),caretCoords=this.__getCaretCoordinates(mirrorElement,activeInput.value,caretPosition);mirrorElement.style.width="auto",mirrorElement.style.height="auto",mirrorElement.style.padding="",mirrorElement.style.overflow="hidden",mirrorElement.textContent=".";const caretHeight=mirrorElement.clientHeight;mirrorElement.remove();const computed=window.getComputedStyle(activeInput),paddingTop=parseInt(computed.paddingTop,10),paddingRight=parseInt(computed.paddingRight,10),paddingBottom=parseInt(computed.paddingBottom,10),paddingLeft=parseInt(computed.paddingLeft,10);caretCoords.left<activeInput.scrollLeft+paddingLeft?activeInput.scrollLeft=caretCoords.left-paddingLeft:caretCoords.left+1>activeInput.scrollLeft+activeInput.clientWidth-paddingLeft-paddingRight&&(activeInput.scrollLeft=caretCoords.left+1-(activeInput.clientWidth-paddingLeft-paddingRight)),caretCoords.top<activeInput.scrollTop+paddingTop?activeInput.scrollTop=caretCoords.top-paddingTop:caretCoords.top+caretHeight>activeInput.scrollTop+activeInput.clientHeight-paddingTop-paddingBottom&&(activeInput.scrollTop=caretCoords.top+caretHeight-(activeInput.clientHeight-paddingTop-paddingBottom))}__getMirrorElement(element){const div=document.createElement("div"),style=div.style,computed=window.getComputedStyle(element);return style.position="absolute",style.visibility="hidden",["whiteSpace","wordWrap","direction","boxSizing","width","height","overflowX","overflowY","borderTopWidth","borderRightWidth","borderBottomWidth","borderLeftWidth","borderStyle","paddingTop","paddingRight","paddingBottom","paddingLeft","fontStyle","fontVariant","fontWeight","fontStretch","fontSize","fontSizeAdjust","lineHeight","fontFamily","textAlign","textTransform","textIndent","textDecoration","letterSpacing","wordSpacing","tabSize"].forEach(function(prop){style[prop]=computed[prop]}),null!==window.mozInnerScreenX?element.scrollHeight>parseInt(computed.height||"0",10)&&(style.overflowY="scroll"):style.overflow="hidden",document.body.appendChild(div),div}__getCaretCoordinates(mirrorElement,text,caretPosition){const span=mirrorElement.getElementsByTagName("span")[0]||document.createElement("span");mirrorElement.textContent=text.substring(0,caretPosition).replace(/ /g," "),span.textContent=text.substring(caretPosition)||".",mirrorElement.appendChild(span);return{top:span.offsetTop,left:span.offsetLeft}}__unescape(value){return value.replace(/\\b/g,"\b").replace(/\\t/g,"\t").replace(/\\n/g,"\n").replace(/\\v/g,"\v").replace(/\\f/g,"\f").replace(/\\r/g,"\r").replace(/\\"/g,'"').replace(/\\'/g,"'").replace(/\\\\/g,"\\")}__isSuitableElement(element,forIndirectInput=!1){if(!element)return!1;if("TEXTAREA"===element.tagName.toUpperCase())return!0;const allowedTypes=["password","search","tel","text","url"];return forIndirectInput&&allowedTypes.push("color","date","datetime-local","email","month","number","range","time","week"),element instanceof element.ownerDocument.defaultView.HTMLInputElement&&allowedTypes.includes(element.type)}async isSupported(element){return await this.__layoutLoaded,this.__isSuitableElement(element,this.__layouts?.useIndirectInput)}__mapLayoutNameToLayoutFileName(oldName){let newPath="";switch(oldName){case"DE-DE_QWERTZ_full":newPath="German - with NumPad";break;case"DE-DE_QWERTZ_standard":newPath="German - basic";break;case"EN-US_QWERTY_full":newPath="US - with NumPad";break;case"EN-US_QWERTY_standard":newPath="US - basic";break;case"DE-DE_QWERTZ_compact":newPath="German - compact";break;case"EN-US_QWERTY_compact":newPath="US - compact";break;case"Calculator":case"Numpad":case"PINpad":newPath=oldName;break;default:return null}return"KeyboardLayouts/"+newPath+".keyboard.json"}__processWidth(){if("Content"===this.getWidthMode()){let newWidthStr="";const contentPixelSize=this.__getContentWidth();null!==contentPixelSize&&(newWidthStr=contentPixelSize+"px"),TcHmi.StyleProvider.setSimpleElementStyle(this.__element,"width",newWidthStr)}super.__processWidth(),"Content"===this.getHeightMode()&&"Content"!==this.getWidthMode()&&this.__processHeight()}__processHeight(){if("Content"===this.getHeightMode()){this.__intHeight=null;const contentPixelSize=this.__getContentHeight();null!==contentPixelSize&&(this.__intHeight=contentPixelSize+"px")}super.__processHeight(),"Content"===this.getWidthMode()&&"Content"!==this.getHeightMode()&&this.__processWidth()}setWidthMode(valueNew){let convertedValue=TcHmi.ValueConverter.toSizeModeWithContent(valueNew);null===convertedValue&&(convertedValue=this.getAttributeDefaultValueInternal("WidthMode")),convertedValue!==this.__widthMode&&(this.__widthMode=convertedValue,TcHmi.EventProvider.raise(this.__id+".onPropertyChanged",{propertyName:"WidthMode"}),this.__processWidthMode(),"Content"===convertedValue&&"Content"===this.getHeightMode()&&this.__processHeightMode())}setHeightMode(valueNew){let convertedValue=TcHmi.ValueConverter.toSizeModeWithContent(valueNew);null===convertedValue&&(convertedValue=this.getAttributeDefaultValueInternal("HeightMode")),convertedValue!==this.__heightMode&&(this.__heightMode=convertedValue,TcHmi.EventProvider.raise(this.__id+".onPropertyChanged",{propertyName:"HeightMode"}),this.__processHeightMode(),"Content"===convertedValue&&"Content"===this.getWidthMode()&&this.__processWidthMode())}__getContentWidth(){if(this.__processWidthOnResized=!1,"Content"!==this.getWidthMode())return super.__getContentWidth();if(!this.__layoutFile)return TCHMI_DESIGNER?374:null;if("Content"===this.getHeightMode()||"None"===this.__scaleMode){let width=this.__currentLayout.dimensions.width;return this.__keyboardPadding&&(width+=this.__keyboardPadding.left+this.__keyboardPadding.right),width}let height;if(null!==this.__height&&void 0!==this.__height&&"%"!==this.__heightUnit&&"Value"===this.getHeightMode())height=this.__height;else{this.__processWidthOnResized=!0;const renderedHeight=this.getRenderedHeight();if(!this.__isAttached||null===renderedHeight)return null;height=renderedHeight}this.__keyboardPadding&&(height-=this.__keyboardPadding.top+this.__keyboardPadding.bottom);let width=height*this.__currentLayout.dimensions.width/this.__currentLayout.dimensions.height;return this.__keyboardPadding&&(width+=this.__keyboardPadding.left+this.__keyboardPadding.right),width}__getContentHeight(){if(this.__processHeightOnResized=!1,"Content"!==this.getHeightMode())return super.__getContentHeight();if(!this.__layoutFile)return TCHMI_DESIGNER?53:null;if("Content"===this.getWidthMode()||"None"===this.__scaleMode){let height=this.__currentLayout.dimensions.height;return this.__keyboardPadding&&(height+=this.__keyboardPadding.top+this.__keyboardPadding.bottom),height}let width;if(null!==this.__width&&void 0!==this.__width&&"%"!==this.__widthUnit&&"Value"===this.getWidthMode())width=this.__width;else{this.__processHeightOnResized=!0;const renderedWidth=this.getRenderedWidth();if(!this.__isAttached||null===renderedWidth)return null;width=renderedWidth}this.__keyboardPadding&&(width-=this.__keyboardPadding.left+this.__keyboardPadding.right);let height=width*this.__currentLayout.dimensions.height/this.__currentLayout.dimensions.width;return this.__keyboardPadding&&(height+=this.__keyboardPadding.top+this.__keyboardPadding.bottom),height}setLayout(valueNew){const convertedValue=TcHmi.ValueConverter.toString(valueNew),mappedValue=this.__mapLayoutNameToLayoutFileName(convertedValue);null!==mappedValue&&this.setLayoutFile(mappedValue)}getLayout(){return null}setLayoutFile(valueNew){let convertedValue=TcHmi.ValueConverter.toString(valueNew);null===convertedValue&&(convertedValue=this.getAttributeDefaultValueInternal("LayoutFile")),convertedValue!==this.__layoutFile&&(this.__layoutFile=convertedValue,TcHmi.EventProvider.raise(this.__id+".onPropertyChanged",{propertyName:"LayoutFile"}),this.__processLayoutFile())}getLayoutFile(){return this.__layoutFile}async __processLayoutFile(){let resolve;if(this.__layoutLoaded=new Promise(res=>{resolve=res}),this.__unstickAllKeys(!0),this.__layoutFile&&TCHMI_DESIGNER){const designerInfoElement=this.__element[0].querySelector(".tchmi-designer-control-message");designerInfoElement&&(designerInfoElement.remove(),this.__localizedElements.delete("Engineering_Not_Configured"))}else if(!this.__layoutFile){if(this.__elementPaddingContainer[0].innerHTML="",this.__currentLayout={name:"empty",dimensions:{width:1,height:1},keys:[]},TCHMI_DESIGNER){const designerMessage=this.__element.find(".tchmi-designer-control-message")[0]||document.createElement("div");designerMessage.classList.add("tchmi-designer-control-message"),designerMessage.textContent="Engineering_Not_Configured",this.__element[0].appendChild(designerMessage),this.__localizedElements.set("Engineering_Not_Configured",designerMessage),this.__localizationReader&&(designerMessage.textContent=this.__localizationReader.get("Engineering_Not_Configured"))}return this.__processWidth(),this.__processHeight(),resolve(),void TcHmi.EventProvider.raise(this.__id+".onLayoutLoaded",{layoutFile:this.__currentLayout})}const path=tchmi_path(this.__layoutFile);let layoutPromise=TcHmiKeyboard.__layoutCache.get(path);layoutPromise||(layoutPromise=fetch(tchmi_encode_uri_components(path)).then(response=>response.ok?response.json():Promise.reject(new Error(`Failed request to ${path} Details: HTTP error ${response.status} ${response.statusText}`))),TcHmiKeyboard.__layoutCache.set(path,layoutPromise));try{if(this.__layouts=await layoutPromise,this.__isDestroyed)return void resolve()}catch(error){TcHmiKeyboard.__layoutCache.delete(path),TcHmi.Log.Controls.error(this,TcHmiKeyboard.#tchmiFQN,{Attribute:"LayoutPath"},`Loading layout file "${this.__layoutFile}" failed with error: `,error),this.__layouts=null,this.__elementPaddingContainer[0].textContent=""}resolve(),this.__processLayoutJsonFile()}__processLayoutJsonFile(){if(null!==this.__layouts){Array.isArray(this.__layouts.layouts)&&0!==this.__layouts.layouts.length||TcHmi.Log.Controls.error(this,TcHmiKeyboard.#tchmiFQN,'Loading layout failed. Invalid layout file: "layouts" property is missing or empty!');const filteredLayouts=this.__layouts.layouts.filter(layout=>"string"==typeof layout.name&&"default"===layout.name.toLowerCase());filteredLayouts.length>0?this.__activateLayout(filteredLayouts[0]):this.__activateLayout(this.__layouts.layouts[0]),this.__indirectInputElement&&!this.__layouts.useIndirectInput&&(this.__setActiveElement(null),this.__indirectInputElement.remove(),this.__indirectInputElement=null),this.__isAttached&&this.__setInitialActiveElements()}this.__fixedTarget&&this.__processFixedTarget(),TcHmi.EventProvider.raise(this.__id+".onLayoutLoaded",{layoutFile:this.__currentLayout})}__activateLayout(layout){if(!Array.isArray(layout.keys))return void TcHmi.Log.Controls.error(this,TcHmiKeyboard.#tchmiFQN,"Activating layout failed. Missing property=keys.");this.__keys.clear(),this.__additionalKeys.clear(),this.__indirectInputAcceptElements=[];const fragment=document.createDocumentFragment();let indirectInputTextboxFound=!1,indirectInputAcceptFound=!1;this.__inputHints.setDisplayType(this.__layouts?.useIndirectInput&&!1!==this.__layouts?.showHintsInIndirectInputTextbox?Helper.DisplayType.TextboxOverlay:Helper.DisplayType.None);for(const definition of layout.keys){if("indirect-input"===definition.type)switch(definition.component){case"textbox":indirectInputTextboxFound=!0;break;case"accept":indirectInputAcceptFound=!0}const keyElement=this.__createKey(definition);keyElement&&!keyElement.parentElement&&fragment.appendChild(keyElement)}this.__layouts&&this.__layouts.useIndirectInput?(indirectInputTextboxFound||(TcHmi.Log.Controls.error(this,TcHmiKeyboard.#tchmiFQN,'Layout has "useIndirectInput" = true, but is missing the textbox.'),this.__inputHints.getDisplayType()===Helper.DisplayType.TextboxOverlay&&this.__inputHints.setDisplayType(Helper.DisplayType.None)),indirectInputAcceptFound||TcHmi.Log.Controls.error(this,TcHmiKeyboard.#tchmiFQN,'Layout has "useIndirectInput" = true, but is missing the accept key.')):(indirectInputTextboxFound||indirectInputAcceptFound)&&TcHmi.Log.Controls.warn(this,TcHmiKeyboard.#tchmiFQN,'Layout contains elements for indirect input, but has "useIndirectInput" not set to true.');for(let i=this.__elementPaddingContainer[0].childElementCount-1;i>=0;i--){const element=this.__elementPaddingContainer[0].children.item(i);element instanceof HTMLDivElement&&element.remove()}this.__elementPaddingContainer[0].appendChild(fragment),this.__currentLayout=layout,this.__updateActiveModifiers(),this.__processScaleMode(),this.__processWidth(),this.__processHeight(),this.__processKeyPadding(),this.__processAdditionalKeyBackdropPadding(),this.__processLabelFontFamily(),this.__processLabelFontSize(),this.__processLabelFontStyle(),this.__processLabelFontWeight(),this.__processLabelStrokeThickness(),this.__processLabelStrokeColor(),this.__processLabelFillColor(),this.__processLabelColor(),this.__processKeyBackgroundColor(),this.__processAdditionalKeyBackdropColor(),this.__inputHints.update(this.__activeElement),TcHmi.EventProvider.raise(this.__id+".onLayoutActivated",{layout:this.__currentLayout})}__createKey(definition){if(!this.__layouts||!this.__layouts.useIndirectInput&&"indirect-input"===definition.type)return;if(void 0===definition.geometry||null===definition.geometry)return void TcHmi.Log.Controls.error(this,TcHmiKeyboard.#tchmiFQN,"Creating key failed. Key definition is missing property=geometry.");if(void 0===definition.geometry.top||null===definition.geometry.top)return void TcHmi.Log.Controls.error(this,TcHmiKeyboard.#tchmiFQN,"Creating key failed. Key definition is missing property=geometry.top.");if(void 0===definition.geometry.left||null===definition.geometry.left)return void TcHmi.Log.Controls.error(this,TcHmiKeyboard.#tchmiFQN,"Creating key failed. Key definition is missing property=geometry.left.");if(void 0===definition.geometry.width||null===definition.geometry.width)return void TcHmi.Log.Controls.error(this,TcHmiKeyboard.#tchmiFQN,"Creating key failed. Key definition is missing property=geometry.width.");if(void 0===definition.geometry.height||null===definition.geometry.height)return void TcHmi.Log.Controls.error(this,TcHmiKeyboard.#tchmiFQN,"Creating key failed. Key definition is missing property=geometry.height.");if("layout-switch"===definition.type){if(void 0===definition.layoutName||null===definition.layoutName)return void TcHmi.Log.Controls.error(this,TcHmiKeyboard.#tchmiFQN,"Creating key failed. Key definition is missing property=layoutName.")}else if("indirect-input"===definition.type){if(void 0===definition.component||null===definition.component)return void TcHmi.Log.Controls.error(this,TcHmiKeyboard.#tchmiFQN,"Creating key failed. Key definition is missing property=component.")}else if("input-hints"!==definition.type){if(void 0===definition.code||null===definition.code)return void TcHmi.Log.Controls.error(this,TcHmiKeyboard.#tchmiFQN,"Creating key failed. Key definition is missing property=code.");if(void 0===definition.key||null===definition.key)return void TcHmi.Log.Controls.error(this,TcHmiKeyboard.#tchmiFQN,"Creating key failed. Key definition is missing property=key.")}let keyElement;if("indirect-input"===definition.type&&"textbox"===definition.component){if(this.__updateIndirectInputElement(definition,this.__activeElement),!this.__indirectInputElement)throw new Error("Could not create textbox for indirect input.");if(keyElement=this.__indirectInputElement,this.__inputHints.getDisplayType()===Helper.DisplayType.TextboxOverlay){const hintElement=this.__inputHints.getElement();hintElement.style.top=definition.geometry.top+"%",hintElement.style.left=definition.geometry.left+"%",hintElement.style.width=definition.geometry.width+"%",hintElement.style.height=definition.geometry.height+"%"}}else if("input-hints"===definition.type)keyElement=this.__inputHints.getElement(),this.__inputHints.setDisplayType(Helper.DisplayType.LayoutDefined);else{keyElement=document.createElement("div"),keyElement.classList.add("TcHmi_Controls_Beckhoff_TcHmiKeyboard-template-key","tchmi-keyboard-template-key");for(const[prop,value]of Object.entries(definition))"object"!=typeof value?keyElement.dataset[prop]=value:prop.includes("omposition")&&(keyElement.dataset[prop]=JSON.stringify(value));if("indirect-input"===definition.type&&"accept"===definition.component&&this.__indirectInputAcceptElements.push(keyElement),isStandardKeyDefinition(definition)&&(definition.noCapsLock&&keyElement.classList.add("no-caps-lock"),definition.additionalKeys)){const additionalKeysContainer=document.createElement("div");additionalKeysContainer.classList.add("TcHmi_Controls_Beckhoff_TcHmiKeyboard-template-additional-keys-container");for(const additionalKey of definition.additionalKeys){const additionalKeyElement=this.__createKey(additionalKey);if(void 0===additionalKeyElement)return;additionalKeyElement.classList.add("additional-key"),additionalKeysContainer.appendChild(additionalKeyElement)}const backdropTop=Math.min(...definition.additionalKeys.map(def=>def.geometry.top)),backdropLeft=Math.min(...definition.additionalKeys.map(def=>def.geometry.left)),backdropWidth=Math.max(...definition.additionalKeys.map(def=>def.geometry.left+def.geometry.width-backdropLeft)),backdropHeight=Math.max(...definition.additionalKeys.map(def=>def.geometry.top+def.geometry.height-backdropTop)),backdrop=document.createElement("div");backdrop.classList.add("TcHmi_Controls_Beckhoff_TcHmiKeyboard-template-backdrop","tchmi-keyboard-template-backdrop"),backdrop.style.top=backdropTop+"%",backdrop.style.left=backdropLeft+"%",backdrop.style.width=backdropWidth+"%",backdrop.style.height=backdropHeight+"%",additionalKeysContainer.insertAdjacentElement("afterbegin",backdrop),keyElement.appendChild(additionalKeysContainer),this.__additionalKeys.set(keyElement,additionalKeysContainer)}if(Array.isArray(definition.labels))for(const label of definition.labels){const labelElement=document.createElement("span");if(labelElement.classList.add("TcHmi_Controls_Beckhoff_TcHmiKeyboard-template-label","tchmi-keyboard-template-label"),void 0!==label.position&&null!==label.position&&label.position.length>0&&labelElement.classList.add(...label.position.split(" ")),"text"===label.type&&void 0!==label.text&&null!==label.text)labelElement.textContent=label.text;else if("svg"===label.type&&void 0!==label.svg&&null!==label.svg)labelElement.innerHTML=`<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="${label.svg.dimensions.width}" height="${label.svg.dimensions.height}"><path d="${label.svg.path}"></path></svg>`;else if("image"===label.type&&void 0!==label.image&&null!==label.image){const labelBackground={color:null,image:label.image.source,imageWidth:void 0!==label.image.dimensions?label.image.dimensions.width:null,imageWidthUnit:"px",imageHeight:void 0!==label.image.dimensions?label.image.dimensions.height:null,imageHeightUnit:"px",imageHorizontalAlignment:"Center",imageVerticalAlignment:"Center",imagePadding:null};TcHmi.StyleProvider.processBackground(labelElement,labelBackground)}if(label.visible?.length)for(const visibleCondition of label.visible)labelElement.classList.add("show-"+visibleCondition);else labelElement.classList.add("show-always");if(label.hidden)for(const hiddenCondition of label.hidden)labelElement.classList.add("hide-"+hiddenCondition);keyElement.appendChild(labelElement)}}return keyElement.style.top=definition.geometry.top+"%",keyElement.style.left=definition.geometry.left+"%",keyElement.style.width=definition.geometry.width+"%",keyElement.style.height=definition.geometry.height+"%",isStandardKeyDefinition(definition)&&this.__modifiers[definition.key]&&keyElement.classList.add("active"),this.__keys.set(keyElement,definition),keyElement}__updateIndirectInputElement(definition,activeElement,replaceOld=!1){if("textbox"!==definition.component)return;if(!activeElement&&this.__indirectInputElement)return;const multiline="TEXTAREA"===activeElement?.tagName.toUpperCase();if(!this.__indirectInputElement||multiline&&this.__indirectInputElement instanceof HTMLInputElement||!multiline&&this.__indirectInputElement instanceof HTMLTextAreaElement){const oldElement=this.__indirectInputElement;this.__indirectInputElement=multiline?document.createElement("textarea"):document.createElement("input"),this.__indirectInputElement.setAttribute("data-tchmi-input-mode","skip"),this.__indirectInputElement.classList.add("TcHmi_Controls_Beckhoff_TcHmiKeyboard-template-textbox"),this.__indirectInputElement.setAttribute("spellcheck","false"),this.__indirectInputElement.style.top=definition.geometry.top+"%",this.__indirectInputElement.style.left=definition.geometry.left+"%",this.__indirectInputElement.style.width=definition.geometry.width+"%",this.__indirectInputElement.style.height=definition.geometry.height+"%",this.__processIndirectInputHorizontalAlignment(),this.__processIndirectInputFontSize(),this.__processIndirectInputPadding();const passiveEventOptions={passive:!0,capture:!1};this.__indirectInputElement.addEventListener("input",this.__onInput,passiveEventOptions),replaceOld&&(oldElement&&oldElement.parentElement===this.__elementPaddingContainer[0]?(oldElement.removeEventListener("input",this.__onInput,passiveEventOptions),this.__elementPaddingContainer[0].replaceChild(this.__indirectInputElement,oldElement)):this.__elementPaddingContainer[0].appendChild(this.__indirectInputElement))}this.__indirectInputElement instanceof HTMLInputElement&&(this.__indirectInputElement.type="password"===activeElement?.type.toLowerCase()?"password":"text")}setScaleMode(valueNew){let convertedValue=TcHmi.ValueConverter.toScaleModeString(valueNew);null===convertedValue&&(convertedValue=this.getAttributeDefaultValueInternal("ScaleMode")),convertedValue!==this.__scaleMode&&(this.__scaleMode=convertedValue,TcHmi.EventProvider.raise(this.__id+".onPropertyChanged",{propertyName:"ScaleMode"}),this.__processScaleMode())}getScaleMode(){return this.__scaleMode}__processScaleMode(){if(void 0===this.__scaleMode)return;if("ScaleToFill"===this.__scaleMode||"None"===this.__scaleMode){switch(this.__scaleMode){case"ScaleToFill":this.__elementPaddingContainer[0].style.width="",this.__elementPaddingContainer[0].style.height="",this.__elementPaddingContainer[0].style.minWidth="",this.__elementPaddingContainer[0].style.minHeight="";break;case"None":this.__elementPaddingContainer[0].style.width=this.__currentLayout.dimensions.width+"px",this.__elementPaddingContainer[0].style.height=this.__currentLayout.dimensions.height+"px",this.__elementPaddingContainer[0].style.minWidth=this.__currentLayout.dimensions.width+"px",this.__elementPaddingContainer[0].style.minHeight=this.__currentLayout.dimensions.height+"px"}return this.__processWidth(),void this.__processHeight()}let width=this.getRenderedWidth();if(!width)return;let scale,height=this.getRenderedHeight();if(height){switch(this.__keyboardPadding&&(width-=this.__keyboardPadding.left+this.__keyboardPadding.right,height-=this.__keyboardPadding.top+this.__keyboardPadding.bottom),this.__scaleMode){case"ScaleToFit":{const scaleX=width/this.__currentLayout.dimensions.width,scaleY=height/this.__currentLayout.dimensions.height;scale=scaleX<scaleY?scaleX:scaleY}break;case"ScaleToFitWidth":scale=width/this.__currentLayout.dimensions.width;break;case"ScaleToFitHeight":scale=height/this.__currentLayout.dimensions.height}this.__elementPaddingContainer[0].style.width=this.__currentLayout.dimensions.width*scale+"px",this.__elementPaddingContainer[0].style.height=this.__currentLayout.dimensions.height*scale+"px",this.__elementPaddingContainer[0].style.minWidth=this.__currentLayout.dimensions.width*scale+"px",this.__elementPaddingContainer[0].style.minHeight=this.__currentLayout.dimensions.height*scale+"px",this.__processWidth(),this.__processHeight()}}setFixedTarget(valueNew){let convertedValue=TcHmi.ValueConverter.toString(valueNew);null===convertedValue&&(convertedValue=this.getAttributeDefaultValueInternal("FixedTarget")),convertedValue!==this.__fixedTarget&&(this.__fixedTarget=convertedValue,TcHmi.EventProvider.raise(this.__id+".onPropertyChanged",{propertyName:"FixedTarget"}),this.__processFixedTarget())}getFixedTarget(){return this.__fixedTarget}__processFixedTarget(){if(this.__destroyOnAttached?.(),this.__destroyOnAttached=null,this.__destroyOnDestroyed?.(),this.__destroyOnDestroyed=null,this.__fixedTargetObserver?.disconnect(),this.__fixedTargetObserver=null,!this.__fixedTarget)return this.__fixedTargetInputElements=null,this.__fixedTargetTextareaElements=null,void(this.__isAttached&&this.__setInitialActiveElements());const targetControl=TcHmi.Controls.get(this.__fixedTarget);if(!targetControl)return this.__fixedTargetInputElements=null,this.__fixedTargetTextareaElements=null,void(this.__destroyOnAttached=TcHmi.EventProvider.register(this.__fixedTarget+".onAttached",()=>{this.__processFixedTarget()}));this.__destroyOnDestroyed=TcHmi.EventProvider.register(this.__fixedTarget+".onDestroyed",()=>{this.__processFixedTarget()});const element=targetControl.getElement()[0];if(this.__fixedTargetInputElements=element.getElementsByTagName("input"),this.__fixedTargetTextareaElements=element.getElementsByTagName("textarea"),!this.__layouts||!this.__layouts.useIndirectInput)return;let errorLogged=!1;const updateActiveElement=()=>{let elements=[];null!==this.__fixedTargetInputElements&&(elements=elements.concat(Array.from(this.__fixedTargetInputElements))),null!==this.__fixedTargetTextareaElements&&(elements=elements.concat(Array.from(this.__fixedTargetTextareaElements)));for(const iframe of element.getElementsByTagName("iframe"))iframe.contentDocument&&(elements=elements.concat(Array.from(iframe.contentDocument.querySelectorAll("input, textarea"))));elements=elements.filter(element=>this.__isSuitableElement(element,!0)),1===elements.length?this.__setActiveElement(elements[0]):elements.length>1&&!errorLogged&&(TcHmi.Log.Controls.error(this,TcHmiKeyboard.#tchmiFQN,"The fixedTarget control contains more than on input or textarea element and is thus not suitable to be used as a fixedTarget."),errorLogged=!0)};this.__fixedTargetObserver=new MutationObserver(updateActiveElement),this.__fixedTargetObserver.observe(element,{childList:!0,subtree:!0});for(const iframe of this.__iframes)iframe.contentDocument&&element.contains(iframe)&&this.__fixedTargetObserver.observe(iframe.contentDocument,{childList:!0,subtree:!0});updateActiveElement()}setReleaseStickyKeysManually(valueNew){let convertedValue=TcHmi.ValueConverter.toBoolean(valueNew);null===convertedValue&&(convertedValue=this.getAttributeDefaultValueInternal("ReleaseStickyKeysManually")),convertedValue!==this.__releaseStickyKeysManually&&(this.__releaseStickyKeysManually=convertedValue,TcHmi.EventProvider.raise(this.__id+".onPropertyChanged",{propertyName:"ReleaseStickyKeysManually"}),this.__processReleaseStickyKeysManually())}getReleaseStickyKeysManually(){return this.__releaseStickyKeysManually}__processReleaseStickyKeysManually(){}setInputHintsValidation(valueNew){let convertedValue=TcHmi.ValueConverter.toEnum(valueNew,ValidationLevel);null===convertedValue&&(convertedValue=TcHmi.ValueConverter.toEnum(this.getAttributeDefaultValueInternal("InputHintsValidation"),ValidationLevel,ValidationLevel.None)),convertedValue!==this.__inputHintsValidation&&(this.__inputHintsValidation=convertedValue,TcHmi.EventProvider.raise(this.__id+".onPropertyChanged",{propertyName:"InputHintsValidation"}),this.__processInputHintsValidation())}getInputHintsValidation(){return void 0!==this.__inputHintsValidation?ValidationLevel[this.__inputHintsValidation]:void 0}__processInputHintsValidation(){if(TCHMI_DESIGNER)return;let disableBecauseInvalid;switch(this.__inputHintsValidation){case ValidationLevel.None:this.__inputHints.resetValidation(),disableBecauseInvalid=!1;break;case ValidationLevel.HighlightHints:this.__inputHints.validate(this.__indirectInputElement?.value??this.__activeElement?.value??""),disableBecauseInvalid=!1;break;case ValidationLevel.DisableAccept:disableBecauseInvalid=!this.__inputHints.validate(this.__indirectInputElement?.value??this.__activeElement?.value??"")}const disableBecauseNotWriteable=(this.__indirectInputElement?.readOnly??!1)||(this.__indirectInputElement?.disabled??!1);for(const accept of this.__indirectInputAcceptElements)accept.classList.toggle("disabled",disableBecauseInvalid||disableBecauseNotWriteable)}__raiseKeyPressStarted(keyElement){const interactedKey=this.__interactedKeys.find(iKey=>iKey.element===keyElement);let key;if(key=void 0!==interactedKey?interactedKey.key:this.__getKey(keyElement),!isStandardKey(key))return;const pressedKeys=[];for(let i=0,ii=Math.min(key.code.length,key.key.length,key.location.length);i<ii;i++)pressedKeys.push({element:keyElement,key:{code:key.code[i],key:key.key[i],unmodifiedKey:key.unmodifiedKey[i],location:KeyLocation[key.location[0]].toLowerCase()}});this.__pressedKeys=this.__pressedKeys.concat(pressedKeys),TcHmi.EventProvider.raise(this.__id+".onKeyPressStarted",pressedKeys),TcHmi.EventProvider.raise(this.__id+".onPropertyChanged",{propertyName:"PressedKeys"})}__raiseKeyPressEnded(keyElement,canceledOrFinished){const releasedKeys=this.__pressedKeys.filter(item=>item.element===keyElement);0!==releasedKeys.length&&(this.__pressedKeys=this.__pressedKeys.filter(item=>item.element!==keyElement),TcHmi.EventProvider.raise(this.__id+".onKeyPress"+canceledOrFinished,releasedKeys),TcHmi.EventProvider.raise(this.__id+".onKeyPressEnded",releasedKeys),TcHmi.EventProvider.raise(this.__id+".onPropertyChanged",{propertyName:"PressedKeys"}))}__setActiveElement(element){if(!this.__ignoreSetActiveElement){if(this.__indirectInputInProgress&&this.__activeElement!==element&&this.__activeElement?.classList.contains("tchmi-keyboard-user-input")){if(this.__activeElement.classList.remove("tchmi-keyboard-user-input"),this.__activeElement.closest("[data-tchmi-type]")?.classList.remove("tchmi-keyboard-user-input"),this.__indirectInputElement){const indirectInputCanceledEvent=new CustomEvent("indirectinputcanceled",{bubbles:!0});this.__activeElement?.dispatchEvent(indirectInputCanceledEvent),TcHmi.EventProvider.raise(this.__id+".onIndirectInputCanceled",this.__indirectInputElement.value)}this.__indirectInputInProgress=!1}if(this.__indirectInputElement)if(element){const textboxDefintion=this.__keys.get(this.__indirectInputElement);textboxDefintion&&"indirect-input"===textboxDefintion.type&&(this.__keys.delete(this.__indirectInputElement),this.__updateIndirectInputElement(textboxDefintion,element,!0),this.__keys.set(this.__indirectInputElement,textboxDefintion)),this.__indirectInputElement.value=element.value,this.__indirectInputElement.disabled=element.disabled,this.__indirectInputElement.readOnly=element.readOnly}else{this.__indirectInputElement.value="",this.__indirectInputElement.disabled=!1,this.__indirectInputElement.readOnly=!1;for(const accept of this.__indirectInputAcceptElements)accept.classList.remove("disabled")}else{const passiveEventOptions={passive:!0,capture:!1};this.__activeElement?.removeEventListener("input",this.__onInput,passiveEventOptions),element?.addEventListener("input",this.__onInput,passiveEventOptions)}this.__activeElement=element,this.__inputHints.update(element)}}__setInitialActiveElements(){if(!this.__fixedTarget)if(this.__isSuitableElement(document.activeElement,!0))this.__setActiveElement(document.activeElement);else if(document.activeElement instanceof HTMLIFrameElement&&document.activeElement.contentWindow){const activeElement=document.activeElement.contentWindow.document.activeElement;this.__isSuitableElement(activeElement,!0)&&this.__setActiveElement(activeElement)}}__startIndirectInput(){if(!this.__indirectInputElement)return;this.__indirectInputInProgress=!0,this.__activeElement?.classList.add("tchmi-keyboard-user-input"),this.__activeElement?.closest("[data-tchmi-type]")?.classList.add("tchmi-keyboard-user-input"),this.__indirectInputElement.focus();const selectionStart=this.__activeElement?.selectionStart,selectionEnd=this.__activeElement?.selectionEnd,selectionDirection=this.__activeElement?.selectionDirection;this.__indirectInputElement.selectionStart=selectionStart??this.__indirectInputElement.value.length,this.__indirectInputElement.selectionEnd=selectionEnd??this.__indirectInputElement.value.length,this.__indirectInputElement.selectionDirection=selectionDirection??"forward"}__endIndirectInput(canceled=!1){if(!this.__indirectInputElement)return;const indirectInputText=this.__indirectInputElement.value;if(this.__ignoreSetActiveElement=!0,this.__activeElement?.focus(),this.__ignoreSetActiveElement=!1,this.__activeElement?.classList.remove("tchmi-keyboard-user-input"),this.__activeElement?.closest("[data-tchmi-type]")?.classList.remove("tchmi-keyboard-user-input"),canceled){this.__indirectInputElement.value=this.__activeElement?.value??"",this.__processInputHintsValidation();const indirectInputCanceledEvent=new CustomEvent("indirectinputcanceled",{bubbles:!0});this.__activeElement?.dispatchEvent(indirectInputCanceledEvent)}else{const selectionStart=this.__indirectInputElement.selectionStart,selectionEnd=this.__indirectInputElement.selectionEnd,selectionDirection=this.__indirectInputElement.selectionDirection;if(this.__activeElement){const isDifferent=this.__activeElement.value!==indirectInputText;if(isDifferent&&!this.__activeElement.disabled&&!this.__activeElement.readOnly){const inputEvent=new InputEvent("beforeinput",{inputType:"insertReplacementText",data:indirectInputText,bubbles:!0});this.__activeElement.dispatchEvent(inputEvent)}if(this.__setInputElementValue(this.__activeElement,indirectInputText),null!==this.__activeElement.selectionStart)try{this.__activeElement.selectionStart=selectionStart??this.__activeElement.value.length,this.__activeElement.selectionEnd=selectionEnd??this.__activeElement.value.length,this.__activeElement.selectionDirection=selectionDirection??"forward"}catch(ex){}if(isDifferent&&!this.__activeElement.disabled&&!this.__activeElement.readOnly){const inputEvent=new InputEvent("input",{inputType:"insertReplacementText",data:indirectInputText,bubbles:!0});this.__activeElement.dispatchEvent(inputEvent)}const indirectInputFinishedEvent=new CustomEvent("indirectinputfinished",{bubbles:!0});this.__activeElement.dispatchEvent(indirectInputFinishedEvent)}}TcHmi.EventProvider.raise(this.__id+(canceled?".onIndirectInputCanceled":".onIndirectInputAccepted"),indirectInputText),this.__indirectInputInProgress=!1}getIsIndirectInputInProgress(){return this.__indirectInputInProgress}focusIndirectInputTextbox(){this.__indirectInputElement?.focus()}getPressedKeys(){return this.__pressedKeys.map(item=>item.key)}__setInputElementValue(element,value){element.disabled||element.readOnly||(element.value=value)}setLongpressDelay(valueNew){let convertedValue=TcHmi.ValueConverter.toNumber(valueNew);null===convertedValue&&(convertedValue=this.getAttributeDefaultValueInternal("LongpressDelay")),convertedValue!==this.__longpressDelay&&(this.__longpressDelay=convertedValue,TcHmi.EventProvider.raise(this.__id+".onPropertyChanged",{propertyName:"LongpressDelay"}),this.__processLongpressDelay())}getLongpressDelay(){return this.__longpressDelay}__processLongpressDelay(){}setRepetitionDelay(valueNew){let convertedValue=TcHmi.ValueConverter.toNumber(valueNew);null===convertedValue&&(convertedValue=this.getAttributeDefaultValueInternal("RepetitionDelay")),convertedValue!==this.__repetitionDelay&&(this.__repetitionDelay=convertedValue,TcHmi.EventProvider.raise(this.__id+".onPropertyChanged",{propertyName:"RepetitionDelay"}),this.__processRepetitionDelay())}getRepetitionDelay(){return this.__repetitionDelay}__processRepetitionDelay(){}setIndirectInputHorizontalAlignment(valueNew){let convertedValue=TcHmi.ValueConverter.toHorizontalAlignment(valueNew);null===convertedValue&&(convertedValue=this.getAttributeDefaultValueInternal("IndirectInputHorizontalAlignment")),convertedValue!==this.__indirectInputHorizontalAlignment&&(this.__indirectInputHorizontalAlignment=convertedValue,TcHmi.EventProvider.raise(this.__id+".onPropertyChanged",{propertyName:"IndirectInputHorizontalAlignment"}),this.__processIndirectInputHorizontalAlignment())}getIndirectInputHorizontalAlignment(){return this.__indirectInputHorizontalAlignment}__processIndirectInputHorizontalAlignment(){this.__indirectInputHorizontalAlignment&&this.__indirectInputElement&&(this.__indirectInputElement.style.textAlign=this.__indirectInputHorizontalAlignment.toLowerCase(),this.__inputHints.setAlignment("Right"===this.__indirectInputHorizontalAlignment?"Left":"Right"))}setIndirectInputFontSize(valueNew){let convertedValue=TcHmi.ValueConverter.toNumber(valueNew);null===convertedValue&&(convertedValue=this.getAttributeDefaultValueInternal("IndirectInputFontSize")),convertedValue!==this.__indirectInputFontSize&&(this.__indirectInputFontSize=convertedValue,TcHmi.EventProvider.raise(this.__id+".onPropertyChanged",{propertyName:"IndirectInputFontSize"}),this.__processIndirectInputFontSize())}getIndirectInputFontSize(){return this.__indirectInputFontSize}__processIndirectInputFontSize(){void 0!==this.__indirectInputFontSize&&this.__indirectInputElement&&(null!==this.__indirectInputFontSize?this.__indirectInputElement.style.fontSize=this.__indirectInputFontSize+(this.__indirectInputFontSizeUnit||"px"):this.__indirectInputElement.style.fontSize="")}setIndirectInputFontSizeUnit(valueNew){let convertedValue=TcHmi.ValueConverter.toDimensionUnit(valueNew);null===convertedValue&&(convertedValue=this.getAttributeDefaultValueInternal("IndirectInputFontSizeUnit")),convertedValue!==this.__indirectInputFontSizeUnit&&(this.__indirectInputFontSizeUnit=convertedValue,TcHmi.EventProvider.raise(this.__id+".onPropertyChanged",{propertyName:"IndirectInputFontSizeUnit"}),this.__processIndirectInputFontSizeUnit())}getIndirectInputFontSizeUnit(){return this.__indirectInputFontSizeUnit}__processIndirectInputFontSizeUnit(){this.__processIndirectInputFontSize()}setIndirectInputPadding(valueNew){let convertedValue=TcHmi.ValueConverter.toObject(valueNew);null===convertedValue&&(convertedValue=this.getAttributeDefaultValueInternal("IndirectInputPadding"));const resolverInfo=this.__objectResolvers.get("indirectInputPadding");resolverInfo&&(resolverInfo.watchDestroyer&&resolverInfo.watchDestroyer(),resolverInfo.resolver.destroy());const resolver=new TcHmi.Symbol.ObjectResolver(convertedValue,{parentControl:this,type:this.getAttributeDescription("IndirectInputPadding")?.type});this.__objectResolvers.set("indirectInputPadding",{resolver,watchCallback:this.__onResolverForIndirectInputPaddingWatchCallback,watchDestroyer:resolver.watch(this.__onResolverForIndirectInputPaddingWatchCallback)})}__onResolverForIndirectInputPaddingWatchCallback(data){this.__isAttached||this.__suspendObjectResolver("indirectInputPadding"),data.error===TcHmi.Errors.NONE?tchmi_equal(data.value,this.__indirectInputPadding)||(this.__indirectInputPadding=data.value,TcHmi.EventProvider.raise(this.__id+".onPropertyChanged",{propertyName:"IndirectInputPadding"}),this.__processIndirectInputPadding()):TcHmi.Log.Controls.error(this,TcHmiKeyboard.#tchmiFQN,{Attribute:"IndirectInputPadding"},`Resolving symbols from object failed with error: ${TcHmi.Log.buildMessage(data.details)}`)}getIndirectInputPadding(){return this.__indirectInputPadding}__processIndirectInputPadding(){void 0!==this.__indirectInputPadding&&this.__indirectInputElement&&TcHmi.StyleProvider.processContentPadding(this.__indirectInputElement,this.__indirectInputPadding)}setKeyboardPadding(valueNew){let convertedValue=TcHmi.ValueConverter.toObject(valueNew);null===convertedValue&&(convertedValue=this.getAttributeDefaultValueInternal("KeyboardPadding"));const resolverInfo=this.__objectResolvers.get("keyboardPadding");resolverInfo&&(resolverInfo.watchDestroyer&&resolverInfo.watchDestroyer(),resolverInfo.resolver.destroy());const resolver=new TcHmi.Symbol.ObjectResolver(convertedValue,{parentControl:this,type:this.getAttributeDescription("KeyboardPadding")?.type});this.__objectResolvers.set("keyboardPadding",{resolver,watchCallback:this.__onResolverForKeyboardPaddingWatchCallback,watchDestroyer:resolver.watch(this.__onResolverForKeyboardPaddingWatchCallback)})}__onResolverForKeyboardPaddingWatchCallback(data){this.__isAttached||this.__suspendObjectResolver("keyboardPadding"),data.error===TcHmi.Errors.NONE?tchmi_equal(data.value,this.__keyboardPadding)||(this.__keyboardPadding=data.value,TcHmi.EventProvider.raise(this.__id+".onPropertyChanged",{propertyName:"KeyboardPadding"}),this.__processKeyboardPadding()):TcHmi.Log.Controls.error(this,TcHmiKeyboard.#tchmiFQN,{Attribute:"KeyboardPadding"},`Resolving symbols from object failed with error: ${TcHmi.Log.buildMessage(data.details)}`)}getKeyboardPadding(){return this.__keyboardPadding}__processKeyboardPadding(){void 0!==this.__keyboardPadding&&(TcHmi.StyleProvider.processContentPadding(this.__elementTemplateRoot,this.__keyboardPadding),this.__processScaleMode())}setKeyPadding(valueNew){let convertedValue=TcHmi.ValueConverter.toObject(valueNew);null===convertedValue&&(convertedValue=this.getAttributeDefaultValueInternal("KeyPadding"));const resolverInfo=this.__objectResolvers.get("keyPadding");resolverInfo&&(resolverInfo.watchDestroyer&&resolverInfo.watchDestroyer(),resolverInfo.resolver.destroy());const resolver=new TcHmi.Symbol.ObjectResolver(convertedValue,{parentControl:this,type:this.getAttributeDescription("KeyPadding")?.type});this.__objectResolvers.set("keyPadding",{resolver,watchCallback:this.__onResolverForKeyPaddingWatchCallback,watchDestroyer:resolver.watch(this.__onResolverForKeyPaddingWatchCallback)})}__onResolverForKeyPaddingWatchCallback(data){this.__isAttached||this.__suspendObjectResolver("keyPadding"),data.error===TcHmi.Errors.NONE?tchmi_equal(data.value,this.__keyPadding)||(this.__keyPadding=data.value,TcHmi.EventProvider.raise(this.__id+".onPropertyChanged",{propertyName:"KeyPadding"}),this.__processKeyPadding()):TcHmi.Log.Controls.error(this,TcHmiKeyboard.#tchmiFQN,{Attribute:"KeyPadding"},`Resolving symbols from object failed with error: ${TcHmi.Log.buildMessage(data.details)}`)}getKeyPadding(){return this.__keyPadding}__processKeyPadding(){if(void 0===this.__keyPadding)return;const labels=this.__elementPaddingContainer[0].getElementsByClassName("TcHmi_Controls_Beckhoff_TcHmiKeyboard-template-label"),sides=["top","right","bottom","left"];if(this.__keyPadding)for(const side of sides){const value=this.__keyPadding[side],unit=this.__keyPadding[side+"Unit"]??"px";null==value?TcHmi.StyleProvider.setSimpleElementStyle(labels,side,null):TcHmi.StyleProvider.setSimpleElementStyle(labels,side,value+unit)}else for(const side of sides)TcHmi.StyleProvider.setSimpleElementStyle(labels,side,null)}setAdditionalKeyBackdropPadding(valueNew){let convertedValue=TcHmi.ValueConverter.toObject(valueNew);null===convertedValue&&(convertedValue=this.getAttributeDefaultValueInternal("AdditionalKeyBackdropPadding"));const resolverInfo=this.__objectResolvers.get("additionalKeyBackdropPadding");resolverInfo&&(resolverInfo.watchDestroyer&&resolverInfo.watchDestroyer(),resolverInfo.resolver.destroy());const resolver=new TcHmi.Symbol.ObjectResolver(convertedValue,{parentControl:this,type:this.getAttributeDescription("AdditionalKeyBackdropPadding")?.type});this.__objectResolvers.set("additionalKeyBackdropPadding",{resolver,watchCallback:this.__onResolverForAdditionalKeyBackdropPaddingWatchCallback,watchDestroyer:resolver.watch(this.__onResolverForAdditionalKeyBackdropPaddingWatchCallback)})}__onResolverForAdditionalKeyBackdropPaddingWatchCallback(data){this.__isAttached||this.__suspendObjectResolver("additionalKeyBackdropPadding"),data.error===TcHmi.Errors.NONE?tchmi_equal(data.value,this.__additionalKeyBackdropPadding)||(this.__additionalKeyBackdropPadding=data.value,TcHmi.EventProvider.raise(this.__id+".onPropertyChanged",{propertyName:"AdditionalKeyBackdropPadding"}),this.__processAdditionalKeyBackdropPadding()):TcHmi.Log.Controls.error(this,TcHmiKeyboard.#tchmiFQN,{Attribute:"AdditionalKeyBackdropPadding"},`Resolving symbols from object failed with error: ${TcHmi.Log.buildMessage(data.details)}`)}getAdditionalKeyBackdropPadding(){return this.__additionalKeyBackdropPadding}__processAdditionalKeyBackdropPadding(){if(void 0===this.__additionalKeyBackdropPadding)return;const backdrops=Array.from(this.__additionalKeys.values()).map(element=>element.getElementsByClassName("TcHmi_Controls_Beckhoff_TcHmiKeyboard-template-backdrop")[0]);TcHmi.StyleProvider.processContentPadding(backdrops,this.__additionalKeyBackdropPadding),this.__additionalKeyBackdropPadding?TcHmi.StyleProvider.processTransform(backdrops,{transformType:"Translate",x:-(this.__additionalKeyBackdropPadding.left??0),xUnit:this.__additionalKeyBackdropPadding.leftUnit??"px",y:-(this.__additionalKeyBackdropPadding.top??0),yUnit:this.__additionalKeyBackdropPadding.topUnit??"px"}):TcHmi.StyleProvider.processTransform(backdrops,null)}setLabelFontSize(valueNew){let convertedValue=TcHmi.ValueConverter.toNumber(valueNew);null===convertedValue&&(convertedValue=this.getAttributeDefaultValueInternal("LabelFontSize")),convertedValue!==this.__labelFontSize&&(this.__labelFontSize=convertedValue,TcHmi.EventProvider.raise(this.__id+".onPropertyChanged",{propertyName:"LabelFontSize"}),this.__processLabelFontSize())}getLabelFontSize(){return this.__labelFontSize}__processLabelFontSize(){TcHmi.StyleProvider.processFontSize(this.__elementPaddingContainer[0].getElementsByClassName("TcHmi_Controls_Beckhoff_TcHmiKeyboard-template-key"),this.__labelFontSize,this.__labelFontSizeUnit)}setLabelFontSizeUnit(valueNew){let convertedValue=TcHmi.ValueConverter.toFontSizeUnit(valueNew);null===convertedValue&&(convertedValue=this.getAttributeDefaultValueInternal("LabelFontSizeUnit")),convertedValue!==this.__labelFontSizeUnit&&(this.__labelFontSizeUnit=convertedValue,TcHmi.EventProvider.raise(this.__id+".onPropertyChanged",{propertyName:"LabelFontSizeUnit"}),this.__processLabelFontSizeUnit())}getLabelFontSizeUnit(){return this.__labelFontSizeUnit}__processLabelFontSizeUnit(){this.__processLabelFontSize()}setLabelFontFamily(valueNew){let convertedValue=TcHmi.ValueConverter.toString(valueNew);null===convertedValue&&(convertedValue=this.getAttributeDefaultValueInternal("LabelFontFamily")),convertedValue!==this.__labelFontFamily&&(this.__labelFontFamily=convertedValue,TcHmi.EventProvider.raise(this.__id+".onPropertyChanged",{propertyName:"LabelFontFamily"}),this.__processLabelFontFamily())}getLabelFontFamily(){return this.__labelFontFamily}__processLabelFontFamily(){TcHmi.StyleProvider.processFontFamily(this.__elementPaddingContainer[0].getElementsByClassName("TcHmi_Controls_Beckhoff_TcHmiKeyboard-template-key"),this.__labelFontFamily)}setLabelFontStyle(valueNew){let convertedValue=TcHmi.ValueConverter.toFontStyle(valueNew);null===convertedValue&&(convertedValue=this.getAttributeDefaultValueInternal("LabelFontStyle")),convertedValue!==this.__labelFontStyle&&(this.__labelFontStyle=convertedValue,TcHmi.EventProvider.raise(this.__id+".onPropertyChanged",{propertyName:"LabelFontStyle"}),this.__processLabelFontStyle())}getLabelFontStyle(){return this.__labelFontStyle}__processLabelFontStyle(){TcHmi.StyleProvider.processFontStyle(this.__elementPaddingContainer[0].getElementsByClassName("TcHmi_Controls_Beckhoff_TcHmiKeyboard-template-key"),this.__labelFontStyle)}setLabelFontWeight(valueNew){let convertedValue=TcHmi.ValueConverter.toFontWeight(valueNew);null===convertedValue&&(convertedValue=this.getAttributeDefaultValueInternal("LabelFontWeight")),convertedValue!==this.__labelFontWeight&&(this.__labelFontWeight=convertedValue,TcHmi.EventProvider.raise(this.__id+".onPropertyChanged",{propertyName:"LabelFontWeight"}),this.__processLabelFontWeight())}getLabelFontWeight(){return this.__labelFontWeight}__processLabelFontWeight(){TcHmi.StyleProvider.processFontWeight(this.__elementPaddingContainer[0].getElementsByClassName("TcHmi_Controls_Beckhoff_TcHmiKeyboard-template-key"),this.__labelFontWeight)}setLabelStrokeThickness(valueNew){let convertedValue=TcHmi.ValueConverter.toNumber(valueNew);null===convertedValue&&(convertedValue=this.getAttributeDefaultValueInternal("LabelStrokeThickness")),convertedValue!==this.__labelStrokeThickness&&(this.__labelStrokeThickness=convertedValue,TcHmi.EventProvider.raise(this.__id+".onPropertyChanged",{propertyName:"LabelStrokeThickness"}),this.__processLabelStrokeThickness())}getLabelStrokeThickness(){return this.__labelStrokeThickness}__processLabelStrokeThickness(){TcHmi.StyleProvider.setSimpleElementStyle(this.__elementPaddingContainer[0].querySelectorAll(".TcHmi_Controls_Beckhoff_TcHmiKeyboard-template-label svg"),"stroke-width",this.__labelStrokeThickness+"px")}setKeyBackgroundColor(valueNew){let convertedValue=TcHmi.ValueConverter.toObject(valueNew);null===convertedValue&&(convertedValue=this.getAttributeDefaultValueInternal("KeyBackgroundColor"));const resolverInfo=this.__objectResolvers.get("keyBackgroundColor");resolverInfo&&(resolverInfo.watchDestroyer&&resolverInfo.watchDestroyer(),resolverInfo.resolver.destroy());const resolver=new TcHmi.Symbol.ObjectResolver(convertedValue,{parentControl:this,type:this.getAttributeDescription("KeyBackgroundColor")?.type});this.__objectResolvers.set("keyBackgroundColor",{resolver,watchCallback:this.__onResolverForKeyBackgroundColorWatchCallback,watchDestroyer:resolver.watch(this.__onResolverForKeyBackgroundColorWatchCallback)})}__onResolverForKeyBackgroundColorWatchCallback(data){this.__isAttached||this.__suspendObjectResolver("keyBackgroundColor"),data.error===TcHmi.Errors.NONE?tchmi_equal(data.value,this.__keyBackgroundColor)||(this.__keyBackgroundColor=data.value,TcHmi.EventProvider.raise(this.__id+".onPropertyChanged",{propertyName:"KeyBackgroundColor"}),this.__processKeyBackgroundColor()):TcHmi.Log.Controls.error(this,TcHmiKeyboard.#tchmiFQN,{Attribute:"KeyBackgroundColor"},`Resolving symbols from object failed with error: ${TcHmi.Log.buildMessage(data.details)}`)}getKeyBackgroundColor(){return this.__keyBackgroundColor}__processKeyBackgroundColor(){TcHmi.StyleProvider.processBackgroundColor(this.__elementPaddingContainer[0].getElementsByClassName("TcHmi_Controls_Beckhoff_TcHmiKeyboard-template-key"),this.__keyBackgroundColor)}setLabelColor(valueNew){let convertedValue=TcHmi.ValueConverter.toObject(valueNew);null===convertedValue&&(convertedValue=this.getAttributeDefaultValueInternal("LabelColor"));const resolverInfo=this.__objectResolvers.get("labelColor");resolverInfo&&(resolverInfo.watchDestroyer&&resolverInfo.watchDestroyer(),resolverInfo.resolver.destroy());const resolver=new TcHmi.Symbol.ObjectResolver(convertedValue,{parentControl:this,type:this.getAttributeDescription("LabelColor")?.type});this.__objectResolvers.set("labelColor",{resolver,watchCallback:this.__onResolverForLabelColorWatchCallback,watchDestroyer:resolver.watch(this.__onResolverForLabelColorWatchCallback)})}__onResolverForLabelColorWatchCallback(data){this.__isAttached||this.__suspendObjectResolver("labelColor"),data.error===TcHmi.Errors.NONE?tchmi_equal(data.value,this.__labelColor)||(this.__labelColor=data.value,TcHmi.EventProvider.raise(this.__id+".onPropertyChanged",{propertyName:"LabelColor"}),this.__processLabelColor()):TcHmi.Log.Controls.error(this,TcHmiKeyboard.#tchmiFQN,{Attribute:"LabelColor"},`Resolving symbols from object failed with error: ${TcHmi.Log.buildMessage(data.details)}`)}getLabelColor(){return this.__labelColor}__processLabelColor(){TcHmi.StyleProvider.processTextColor(this.__elementPaddingContainer[0].getElementsByClassName("TcHmi_Controls_Beckhoff_TcHmiKeyboard-template-key"),this.__labelColor)}setLabelStrokeColor(valueNew){let convertedValue=TcHmi.ValueConverter.toObject(valueNew);null===convertedValue&&(convertedValue=this.getAttributeDefaultValueInternal("LabelStrokeColor"));const resolverInfo=this.__objectResolvers.get("labelStrokeColor");resolverInfo&&(resolverInfo.watchDestroyer&&resolverInfo.watchDestroyer(),resolverInfo.resolver.destroy());const resolver=new TcHmi.Symbol.ObjectResolver(convertedValue,{parentControl:this,type:this.getAttributeDescription("LabelStrokeColor")?.type});this.__objectResolvers.set("labelStrokeColor",{resolver,watchCallback:this.__onResolverForLabelStrokeColorWatchCallback,watchDestroyer:resolver.watch(this.__onResolverForLabelStrokeColorWatchCallback)})}__onResolverForLabelStrokeColorWatchCallback(data){this.__isAttached||this.__suspendObjectResolver("labelStrokeColor"),data.error===TcHmi.Errors.NONE?tchmi_equal(data.value,this.__labelStrokeColor)||(this.__labelStrokeColor=data.value,TcHmi.EventProvider.raise(this.__id+".onPropertyChanged",{propertyName:"LabelStrokeColor"}),this.__processLabelStrokeColor()):TcHmi.Log.Controls.error(this,TcHmiKeyboard.#tchmiFQN,{Attribute:"LabelStrokeColor"},`Resolving symbols from object failed with error: ${TcHmi.Log.buildMessage(data.details)}`)}getLabelStrokeColor(){return this.__labelStrokeColor}__processLabelStrokeColor(){TcHmi.StyleProvider.processStrokeColor(this.__elementPaddingContainer[0].querySelectorAll(".TcHmi_Controls_Beckhoff_TcHmiKeyboard-template-label svg"),this.__labelStrokeColor)}setLabelFillColor(valueNew){let convertedValue=TcHmi.ValueConverter.toObject(valueNew);null===convertedValue&&(convertedValue=this.getAttributeDefaultValueInternal("LabelFillColor"));const resolverInfo=this.__objectResolvers.get("labelFillColor");resolverInfo&&(resolverInfo.watchDestroyer&&resolverInfo.watchDestroyer(),resolverInfo.resolver.destroy());const resolver=new TcHmi.Symbol.ObjectResolver(convertedValue,{parentControl:this,type:this.getAttributeDescription("LabelFillColor")?.type});this.__objectResolvers.set("labelFillColor",{resolver,watchCallback:this.__onResolverForLabelFillColorWatchCallback,watchDestroyer:resolver.watch(this.__onResolverForLabelFillColorWatchCallback)})}__onResolverForLabelFillColorWatchCallback(data){this.__isAttached||this.__suspendObjectResolver("labelFillColor"),data.error===TcHmi.Errors.NONE?tchmi_equal(data.value,this.__labelFillColor)||(this.__labelFillColor=data.value,TcHmi.EventProvider.raise(this.__id+".onPropertyChanged",{propertyName:"LabelFillColor"}),this.__processLabelFillColor()):TcHmi.Log.Controls.error(this,TcHmiKeyboard.#tchmiFQN,{Attribute:"LabelFillColor"},`Resolving symbols from object failed with error: ${TcHmi.Log.buildMessage(data.details)}`)}getLabelFillColor(){return this.__labelFillColor}__processLabelFillColor(){TcHmi.StyleProvider.processFillColor(this.__elementPaddingContainer[0].querySelectorAll(".TcHmi_Controls_Beckhoff_TcHmiKeyboard-template-label svg path"),this.__labelFillColor)}setAdditionalKeyBackdropColor(valueNew){let convertedValue=TcHmi.ValueConverter.toObject(valueNew);null===convertedValue&&(convertedValue=this.getAttributeDefaultValueInternal("AdditionalKeyBackdropColor"));const resolverInfo=this.__objectResolvers.get("additionalKeyBackdropColor");resolverInfo&&(resolverInfo.watchDestroyer&&resolverInfo.watchDestroyer(),resolverInfo.resolver.destroy());const resolver=new TcHmi.Symbol.ObjectResolver(convertedValue,{parentControl:this,type:this.getAttributeDescription("AdditionalKeyBackdropColor")?.type});this.__objectResolvers.set("additionalKeyBackdropColor",{resolver,watchCallback:this.__onResolverForAdditionalKeyBackdropColorWatchCallback,watchDestroyer:resolver.watch(this.__onResolverForAdditionalKeyBackdropColorWatchCallback)})}__onResolverForAdditionalKeyBackdropColorWatchCallback(data){this.__isAttached||this.__suspendObjectResolver("additionalKeyBackdropColor"),data.error===TcHmi.Errors.NONE?tchmi_equal(data.value,this.__additionalKeyBackdropColor)||(this.__additionalKeyBackdropColor=data.value,TcHmi.EventProvider.raise(this.__id+".onPropertyChanged",{propertyName:"AdditionalKeyBackdropColor"}),this.__processAdditionalKeyBackdropColor()):TcHmi.Log.Controls.error(this,TcHmiKeyboard.#tchmiFQN,{Attribute:"AdditionalKeyBackdropColor"},`Resolving symbols from object failed with error: ${TcHmi.Log.buildMessage(data.details)}`)}getAdditionalKeyBackdropColor(){return this.__additionalKeyBackdropColor}__processAdditionalKeyBackdropColor(){TcHmi.StyleProvider.processBackgroundColor(Array.from(this.__additionalKeys.values()).map(element=>element.getElementsByClassName("TcHmi_Controls_Beckhoff_TcHmiKeyboard-template-backdrop")[0]),this.__additionalKeyBackdropColor)}static KeyType=KeyType;static KeyMode=KeyMode;static KeyLocation=KeyLocation;static LongpressAction=LongpressAction;static IndirectInputComponent=IndirectInputComponent;static ValidationLevel=ValidationLevel}})();export function isStandardKeyDefinition(obj){return"layout-switch"!==obj.type&&"indirect-input"!==obj.type}export function isStandardKey(obj){return obj.type!==KeyType.LAYOUTSWITCH&&obj.type!==KeyType.INDIRECTINPUT}TcHmi.Controls.registerEx("TcHmiKeyboard","TcHmi.Controls.Beckhoff",TcHmiKeyboard,{injectInGlobalObject:!0});export{TcHmiKeyboard as Control}; |