Files
m.heisig 2d11c43579 Added minimal functionality for Robot teaching
- Added minimal HMI
- Added possibility to open and close all chamber doors
2026-01-17 09:20:39 +01:00

1 line
65 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,Callback}from"Beckhoff.TwinCAT.HMI.Framework/index.esm.js";import{RecipeEditor}from"./RecipeEditor.js";import{CreateRecipePrompt}from"./Popups/CreateRecipePrompt.js";import{FileConflictPrompt}from"./Popups/FileConflictPrompt.js";import{DirectoryBrowser}from"../Helpers/TcHmiDirectoryBrowser/DirectoryBrowser.js";import{PathDisplay}from"../Helpers/TcHmiDirectoryBrowser/PathDisplay.js";import{ListBrowsingDisplay}from"../Helpers/TcHmiDirectoryBrowser/ListBrowsingDisplay.js";import{TreeBrowsingDisplay}from"../Helpers/TcHmiDirectoryBrowser/TreeBrowsingDisplay.js";import{TextAndButtonsPrompt}from"../Helpers/TcHmiPopups/TextAndButtonsPrompt.js";import{InputPrompt}from"../Helpers/TcHmiPopups/InputPrompt.js";let TcHmiRecipeEdit=(()=>{var _a;let ___onNewFolderPressed_decorators,___onNewRecipePressed_decorators,___onRenamePressed_decorators,___onCopyPressed_decorators,___onCutPressed_decorators,___onPastePressed_decorators,___onDeletePressed_decorators,___onSearchChanged_decorators,___onClearSearchClick_decorators,___onSelectionChanged_decorators,___onBeforePathChange_decorators,___onPathChanged_decorators,___onDragAndDropped_decorators,___onActivatePressed_decorators,___onTeachPressed_decorators,___onSavePressed_decorators,___onClosePressed_decorators,___onRecipeEditorChanged_decorators,___onResolverForAllowedRecipeTypesWatchCallback_decorators,___onRecipeListWatch_decorators,_classSuper=TcHmiControl.Control,_instanceExtraInitializers=[];return class TcHmiRecipeEdit extends _classSuper{static{const _metadata="function"==typeof Symbol&&Symbol.metadata?Object.create(_classSuper[Symbol.metadata]??null):void 0;___onNewFolderPressed_decorators=[TcHmi.EventHandler({checkIsEnabled:!0,checkAccess:"operate"})],___onNewRecipePressed_decorators=[TcHmi.EventHandler({checkIsEnabled:!0,checkAccess:"operate"})],___onRenamePressed_decorators=[TcHmi.EventHandler({checkIsEnabled:!0,checkAccess:"operate"})],___onCopyPressed_decorators=[TcHmi.EventHandler({checkIsEnabled:!0,checkAccess:"operate"})],___onCutPressed_decorators=[TcHmi.EventHandler({checkIsEnabled:!0,checkAccess:"operate"})],___onPastePressed_decorators=[TcHmi.EventHandler({checkIsEnabled:!0,checkAccess:"operate"})],___onDeletePressed_decorators=[TcHmi.EventHandler({checkIsEnabled:!0,checkAccess:"operate"})],___onSearchChanged_decorators=[TcHmi.EventHandler()],___onClearSearchClick_decorators=[TcHmi.EventHandler({checkIsEnabled:!0,checkAccess:"operate"})],___onSelectionChanged_decorators=[TcHmi.EventHandler()],___onBeforePathChange_decorators=[TcHmi.EventHandler({checkIsEnabled:!0,checkAccess:"operate",earlyReturnValue:Promise.resolve(!0)})],___onPathChanged_decorators=[TcHmi.EventHandler()],___onDragAndDropped_decorators=[TcHmi.EventHandler({checkIsEnabled:!0,checkAccess:"operate"})],___onActivatePressed_decorators=[TcHmi.EventHandler({checkIsEnabled:!0,checkAccess:"operate"})],___onTeachPressed_decorators=[TcHmi.EventHandler({checkIsEnabled:!0,checkAccess:"operate"})],___onSavePressed_decorators=[TcHmi.EventHandler({checkIsEnabled:!0,checkAccess:"operate"})],___onClosePressed_decorators=[TcHmi.EventHandler({checkIsEnabled:!0,checkAccess:"operate"})],___onRecipeEditorChanged_decorators=[TcHmi.EventHandler({checkIsEnabled:!0,checkAccess:"operate"})],___onResolverForAllowedRecipeTypesWatchCallback_decorators=[(_a=TcHmi).CallbackMethod.bind(_a)],___onRecipeListWatch_decorators=[TcHmi.EventHandler()],__esDecorate(this,null,___onNewFolderPressed_decorators,{kind:"method",name:"__onNewFolderPressed",static:!1,private:!1,access:{has:obj=>"__onNewFolderPressed"in obj,get:obj=>obj.__onNewFolderPressed},metadata:_metadata},null,_instanceExtraInitializers),__esDecorate(this,null,___onNewRecipePressed_decorators,{kind:"method",name:"__onNewRecipePressed",static:!1,private:!1,access:{has:obj=>"__onNewRecipePressed"in obj,get:obj=>obj.__onNewRecipePressed},metadata:_metadata},null,_instanceExtraInitializers),__esDecorate(this,null,___onRenamePressed_decorators,{kind:"method",name:"__onRenamePressed",static:!1,private:!1,access:{has:obj=>"__onRenamePressed"in obj,get:obj=>obj.__onRenamePressed},metadata:_metadata},null,_instanceExtraInitializers),__esDecorate(this,null,___onCopyPressed_decorators,{kind:"method",name:"__onCopyPressed",static:!1,private:!1,access:{has:obj=>"__onCopyPressed"in obj,get:obj=>obj.__onCopyPressed},metadata:_metadata},null,_instanceExtraInitializers),__esDecorate(this,null,___onCutPressed_decorators,{kind:"method",name:"__onCutPressed",static:!1,private:!1,access:{has:obj=>"__onCutPressed"in obj,get:obj=>obj.__onCutPressed},metadata:_metadata},null,_instanceExtraInitializers),__esDecorate(this,null,___onPastePressed_decorators,{kind:"method",name:"__onPastePressed",static:!1,private:!1,access:{has:obj=>"__onPastePressed"in obj,get:obj=>obj.__onPastePressed},metadata:_metadata},null,_instanceExtraInitializers),__esDecorate(this,null,___onDeletePressed_decorators,{kind:"method",name:"__onDeletePressed",static:!1,private:!1,access:{has:obj=>"__onDeletePressed"in obj,get:obj=>obj.__onDeletePressed},metadata:_metadata},null,_instanceExtraInitializers),__esDecorate(this,null,___onSearchChanged_decorators,{kind:"method",name:"__onSearchChanged",static:!1,private:!1,access:{has:obj=>"__onSearchChanged"in obj,get:obj=>obj.__onSearchChanged},metadata:_metadata},null,_instanceExtraInitializers),__esDecorate(this,null,___onClearSearchClick_decorators,{kind:"method",name:"__onClearSearchClick",static:!1,private:!1,access:{has:obj=>"__onClearSearchClick"in obj,get:obj=>obj.__onClearSearchClick},metadata:_metadata},null,_instanceExtraInitializers),__esDecorate(this,null,___onSelectionChanged_decorators,{kind:"method",name:"__onSelectionChanged",static:!1,private:!1,access:{has:obj=>"__onSelectionChanged"in obj,get:obj=>obj.__onSelectionChanged},metadata:_metadata},null,_instanceExtraInitializers),__esDecorate(this,null,___onBeforePathChange_decorators,{kind:"method",name:"__onBeforePathChange",static:!1,private:!1,access:{has:obj=>"__onBeforePathChange"in obj,get:obj=>obj.__onBeforePathChange},metadata:_metadata},null,_instanceExtraInitializers),__esDecorate(this,null,___onPathChanged_decorators,{kind:"method",name:"__onPathChanged",static:!1,private:!1,access:{has:obj=>"__onPathChanged"in obj,get:obj=>obj.__onPathChanged},metadata:_metadata},null,_instanceExtraInitializers),__esDecorate(this,null,___onDragAndDropped_decorators,{kind:"method",name:"__onDragAndDropped",static:!1,private:!1,access:{has:obj=>"__onDragAndDropped"in obj,get:obj=>obj.__onDragAndDropped},metadata:_metadata},null,_instanceExtraInitializers),__esDecorate(this,null,___onActivatePressed_decorators,{kind:"method",name:"__onActivatePressed",static:!1,private:!1,access:{has:obj=>"__onActivatePressed"in obj,get:obj=>obj.__onActivatePressed},metadata:_metadata},null,_instanceExtraInitializers),__esDecorate(this,null,___onTeachPressed_decorators,{kind:"method",name:"__onTeachPressed",static:!1,private:!1,access:{has:obj=>"__onTeachPressed"in obj,get:obj=>obj.__onTeachPressed},metadata:_metadata},null,_instanceExtraInitializers),__esDecorate(this,null,___onSavePressed_decorators,{kind:"method",name:"__onSavePressed",static:!1,private:!1,access:{has:obj=>"__onSavePressed"in obj,get:obj=>obj.__onSavePressed},metadata:_metadata},null,_instanceExtraInitializers),__esDecorate(this,null,___onClosePressed_decorators,{kind:"method",name:"__onClosePressed",static:!1,private:!1,access:{has:obj=>"__onClosePressed"in obj,get:obj=>obj.__onClosePressed},metadata:_metadata},null,_instanceExtraInitializers),__esDecorate(this,null,___onRecipeEditorChanged_decorators,{kind:"method",name:"__onRecipeEditorChanged",static:!1,private:!1,access:{has:obj=>"__onRecipeEditorChanged"in obj,get:obj=>obj.__onRecipeEditorChanged},metadata:_metadata},null,_instanceExtraInitializers),__esDecorate(this,null,___onResolverForAllowedRecipeTypesWatchCallback_decorators,{kind:"method",name:"__onResolverForAllowedRecipeTypesWatchCallback",static:!1,private:!1,access:{has:obj=>"__onResolverForAllowedRecipeTypesWatchCallback"in obj,get:obj=>obj.__onResolverForAllowedRecipeTypesWatchCallback},metadata:_metadata},null,_instanceExtraInitializers),__esDecorate(this,null,___onRecipeListWatch_decorators,{kind:"method",name:"__onRecipeListWatch",static:!1,private:!1,access:{has:obj=>"__onRecipeListWatch"in obj,get:obj=>obj.__onRecipeListWatch},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);__elementPathBox;__elementBrowsingPane;__elementBrowsingBox;__elementTreeBox;__elementEmptyNotification;__elementEditingArea;__serverDomain;__path;__oldPath;__allowedRecipeTypes;__preselectedRecipeType;__promptBeforeActivating;__promptBeforeTeaching;__unwatchRecipeManagementDomain=null;__unwatchRecipeList=null;__watchRecipeConditions={extensionLoaded:!1,userHasRights:!1};__watchRecipeListResult=null;__onRecipeListReceivedManager=new Callback.Collection;__activeRecipesSubscriptionId=null;__watchActiveRecipeConditions={extensionLoaded:!1,userHasRights:!1,recipe:""};__symbolAccessSubscriptionId=null;__symbolAccess={"{0}.Config":TcHmi.Server.ACCESS.NONE,Rename:TcHmi.Server.ACCESS.NONE,"{0}.ActivateRecipe":TcHmi.Server.ACCESS.NONE,"{0}.ReadFromTarget":TcHmi.Server.ACCESS.NONE,"{0}.UpdateRecipe":TcHmi.Server.ACCESS.NONE,"{0}.GetActiveRecipes":TcHmi.Server.ACCESS.NONE};__buttons;__inputSearch;__elementClearSearch;__clipboard=null;__recipeBrowser;__treeBrowsingDisplay;__recipeEditor;__namePrompt=null;__createRecipePrompt=null;__confirmationPrompt=null;__activatePrompt=null;__teachErrorPopup=null;__confirmClosePrompt=null;__childControls=[];__localizedElements=new Map;__localizationReader=void 0;__isEnabledLock={locked:!1,unlockValue:null};__previnit(){super.__previnit();const elementTemplateRoot=this.__element[0].querySelector(".TcHmi_Controls_Beckhoff_TcHmiRecipeEdit-template"),elementPathBox=elementTemplateRoot?.querySelector("div.TcHmi_Controls_Beckhoff_TcHmiRecipeEdit-path-box"),elementBrowsingPane=elementTemplateRoot?.querySelector(".TcHmi_Controls_Beckhoff_TcHmiRecipeEdit-browsing-pane"),elementBrowsingBox=elementTemplateRoot?.querySelector("ul.TcHmi_Controls_Beckhoff_TcHmiRecipeEdit-browsing-box"),elementTreeBox=elementTemplateRoot?.querySelector("div.TcHmi_Controls_Beckhoff_TcHmiRecipeEdit-tree-box"),elementEditingArea=elementTemplateRoot?.querySelector("div.TcHmi_Controls_Beckhoff_TcHmiRecipeEdit-editing-area"),elementClearSearch=elementTemplateRoot?.querySelector("div.TcHmi_Controls_Beckhoff_TcHmiRecipeEdit-clear-search"),elementEmptyNotification=elementTemplateRoot?.querySelector("div.empty-notification");if(!(elementTemplateRoot&&elementPathBox&&elementBrowsingPane&&elementBrowsingBox&&elementTreeBox&&elementEditingArea&&elementClearSearch&&elementEmptyNotification))throw new Error("Invalid Template.html");this.__elementTemplateRoot=elementTemplateRoot,this.__elementPathBox=elementPathBox,this.__elementBrowsingPane=elementBrowsingPane,this.__elementBrowsingBox=elementBrowsingBox,this.__elementTreeBox=elementTreeBox,this.__elementEditingArea=elementEditingArea,this.__elementClearSearch=elementClearSearch,this.__elementEmptyNotification=elementEmptyNotification;const localizedElements=this.__element[0].querySelectorAll("[data-tchmi-localized-content-key]");for(const element of localizedElements){let localizeKey=element.dataset.tchmiLocalizedContentKey;localizeKey&&this.__localizedElements.set(element,{key:localizeKey})}this.__destroyOnDestroy.push(this.__localization.watch(data=>{if(data.error===TcHmi.Errors.NONE&&data.reader){for(const[element,info]of this.__localizedElements){let localizedText=data.reader.get(info.key);info.parameters&&(localizedText=tchmi_format_string(localizedText,...info.parameters)),element.textContent=tchmi_decode_control_characters(localizedText)}this.__localizationReader=data.reader}}))}__init(){super.__init();const pathDisplay=new PathDisplay(this.__elementPathBox,this),browsingDisplay=new ListBrowsingDisplay(this.__elementBrowsingBox,this);this.__recipeBrowser=new DirectoryBrowser([pathDisplay,browsingDisplay],this),this.__recipeBrowser.setMultiSelectAllowed(!0),this.__recipeBrowser.onBeforePathChange.add(this.__onBeforePathChange),this.__recipeBrowser.onSelectionChange.add(this.__onSelectionChanged),this.__recipeBrowser.onPathChange.add(this.__onPathChanged);const newFolderButton=TcHmi.Controls.get(this.__id+"_ButtonNewFolder"),newRecipeButton=TcHmi.Controls.get(this.__id+"_ButtonNewRecipe"),renameButton=TcHmi.Controls.get(this.__id+"_ButtonRename"),copyButton=TcHmi.Controls.get(this.__id+"_ButtonCopy"),cutButton=TcHmi.Controls.get(this.__id+"_ButtonCut"),pasteButton=TcHmi.Controls.get(this.__id+"_ButtonPaste"),deleteButton=TcHmi.Controls.get(this.__id+"_ButtonDelete"),searchInput=TcHmi.Controls.get(this.__id+"_InputSearch");this.__recipeEditor=new RecipeEditor(this.__elementEditingArea,this),this.__recipeEditor.onChange.add(this.__onRecipeEditorChanged),this.__recipeEditor.setLocalizations({tableHeaderName:this.__expandLocalizationSymbol("Table_Header_Name"),tableHeaderValue:this.__expandLocalizationSymbol("Table_Header_Value"),tableHeaderMin:this.__expandLocalizationSymbol("Table_Header_Min"),tableHeaderMax:this.__expandLocalizationSymbol("Table_Header_Max"),tableHeaderUnit:this.__expandLocalizationSymbol("Table_Header_Unit"),tableHeaderComment:this.__expandLocalizationSymbol("Table_Header_Comment"),editorLocalizations:{optionalEditor:{optionalCheckboxTooltip:this.__expandLocalizationSymbol("Editor_Checkbox_Tooltip_Optional")},booleanEditor:{falseText:this.__expandLocalizationSymbol("Editor_Combobox_Text_False"),trueText:this.__expandLocalizationSymbol("Editor_Combobox_Text_True")},buttonBasedEditor:{buttonTooltip:this.__expandLocalizationSymbol("Editor_Button_Tooltip_Open")},timeEditor:{dateTimeButtonTooltip:this.__expandLocalizationSymbol("Editor_Button_Tooltip_DateTime"),timespanButtonTooltip:this.__expandLocalizationSymbol("Editor_Button_Tooltip_Timespan")},choiceEditor:{comboboxText:this.__expandLocalizationSymbol("Editor_Combobox_Text_ChooseType")},arrayBasedEditorPane:{addButtonTooltip:this.__expandLocalizationSymbol("Editor_Button_Tooltip_AddItem"),removeButtonTooltip:this.__expandLocalizationSymbol("Editor_Button_Tooltip_RemoveItem"),upButtonTooltip:this.__expandLocalizationSymbol("Editor_Button_Tooltip_ItemUp"),downButtonTooltip:this.__expandLocalizationSymbol("Editor_Button_Tooltip_ItemDown")},objectEditorPane:{addButtonTooltip:this.__expandLocalizationSymbol("Editor_Button_Tooltip_AddProperty"),acceptButtonText:this.__expandLocalizationSymbol("Popup_Button_Text_OK"),acceptButtonTooltip:this.__expandLocalizationSymbol("Editor_Button_Tooltip_AcceptProperty"),cancelButtonTooltip:this.__expandLocalizationSymbol("Editor_Button_Tooltip_CancelProperty"),removeButtonTooltip:this.__expandLocalizationSymbol("Editor_Button_Tooltip_RemoveProperty")},arrayEditorPrompt:{buttonTextOk:this.__expandLocalizationSymbol("Popup_Button_Text_OK"),buttonTooltipOk:this.__expandLocalizationSymbol("Popup_Button_Tooltip_OK"),buttonTextCancel:this.__expandLocalizationSymbol("Popup_Button_Text_Cancel"),buttonTooltipCancel:this.__expandLocalizationSymbol("Popup_Button_Tooltip_Cancel")},objectEditorPrompt:{buttonTextOk:this.__expandLocalizationSymbol("Popup_Button_Text_OK"),buttonTooltipOk:this.__expandLocalizationSymbol("Popup_Button_Tooltip_OK"),buttonTextCancel:this.__expandLocalizationSymbol("Popup_Button_Text_Cancel"),buttonTooltipCancel:this.__expandLocalizationSymbol("Popup_Button_Tooltip_Cancel")},tupleEditorPrompt:{buttonTextOk:this.__expandLocalizationSymbol("Popup_Button_Text_OK"),buttonTooltipOk:this.__expandLocalizationSymbol("Popup_Button_Tooltip_OK"),buttonTextCancel:this.__expandLocalizationSymbol("Popup_Button_Text_Cancel"),buttonTooltipCancel:this.__expandLocalizationSymbol("Popup_Button_Tooltip_Cancel")}},recipeReferenceEditorLocalizations:{buttonTextOk:this.__expandLocalizationSymbol("Popup_Button_Text_OK"),buttonTooltipOk:this.__expandLocalizationSymbol("Popup_Button_Tooltip_OK"),buttonTextCancel:this.__expandLocalizationSymbol("Popup_Button_Text_Cancel"),buttonTooltipCancel:this.__expandLocalizationSymbol("Popup_Button_Tooltip_Cancel"),openPopupButtonTooltip:this.__expandLocalizationSymbol("Editor_Button_Tooltip_Open"),recipePopupHeaderText:this.__expandLocalizationSymbol("Popup_Header_Recipe")}});const activateButton=TcHmi.Controls.get(this.__id+"_ButtonActivate"),teachButton=TcHmi.Controls.get(this.__id+"_ButtonTeach"),saveButton=TcHmi.Controls.get(this.__id+"_ButtonSave"),closeButton=TcHmi.Controls.get(this.__id+"_ButtonClose");if(!(newFolderButton&&newRecipeButton&&renameButton&&copyButton&&cutButton&&pasteButton&&deleteButton&&activateButton&&teachButton&&saveButton&&closeButton&&searchInput))throw new Error("Controls in Template.html were not instantiated");this.__buttons={createFolder:newFolderButton,createRecipe:newRecipeButton,rename:renameButton,copy:copyButton,cut:cutButton,paste:pasteButton,delete:deleteButton,activate:activateButton,teach:teachButton,save:saveButton,close:closeButton},this.__inputSearch=searchInput;const createMapping={controlRight:"operate",virtualControlRight:"create"};this.__buttons.createFolder.setVirtualControlRightMappings([createMapping]),this.__buttons.createRecipe.setVirtualControlRightMappings([createMapping]),this.__buttons.rename.setVirtualControlRightMappings([{controlRight:"operate",virtualControlRight:"rename"}]),this.__buttons.copy.setVirtualControlRightMappings([createMapping]),this.__buttons.cut.setVirtualControlRightMappings([{controlRight:"operate",virtualControlRight:"cut"}]),this.__buttons.paste.setVirtualControlRightMappings([createMapping]),this.__buttons.delete.setVirtualControlRightMappings([{controlRight:"operate",virtualControlRight:"delete"}]),this.__buttons.activate.setVirtualControlRightMappings([{controlRight:"operate",virtualControlRight:"activateRecipe"}]),this.__buttons.teach.setVirtualControlRightMappings([{controlRight:"operate",virtualControlRight:"teachRecipe"}]),this.__buttons.save.setVirtualControlRightMappings([{controlRight:"operate",virtualControlRight:"editRecipe"}]),this.__processPath()}__attach(){super.__attach(),this.__recipeBrowser?.resume(),this.__destroyOnDetach.push(TcHmi.EventProvider.register(this.__buttons.createFolder.getId()+".onPressed",this.__onNewFolderPressed),TcHmi.EventProvider.register(this.__buttons.createRecipe.getId()+".onPressed",this.__onNewRecipePressed),TcHmi.EventProvider.register(this.__buttons.rename.getId()+".onPressed",this.__onRenamePressed),TcHmi.EventProvider.register(this.__buttons.copy.getId()+".onPressed",this.__onCopyPressed),TcHmi.EventProvider.register(this.__buttons.cut.getId()+".onPressed",this.__onCutPressed),TcHmi.EventProvider.register(this.__buttons.paste.getId()+".onPressed",this.__onPastePressed),TcHmi.EventProvider.register(this.__buttons.delete.getId()+".onPressed",this.__onDeletePressed),TcHmi.EventProvider.register(this.__buttons.activate.getId()+".onPressed",this.__onActivatePressed),TcHmi.EventProvider.register(this.__buttons.teach.getId()+".onPressed",this.__onTeachPressed),TcHmi.EventProvider.register(this.__buttons.save.getId()+".onPressed",this.__onSavePressed),TcHmi.EventProvider.register(this.__buttons.close.getId()+".onPressed",this.__onClosePressed),TcHmi.EventProvider.register(this.__inputSearch.getId()+".onTextChanged",this.__onSearchChanged),TcHmi.EventProvider.registerDomEvent(this.__elementClearSearch,"click",this.__onClearSearchClick)),this.__lockIsEnabled(),this.__updateRecipeWatches(),this.__updateSymbolAccessSubscription()}__detach(){super.__detach(),this.__updateRecipeWatches(!0),this.__updateSymbolAccessSubscription(!0)}destroy(){if(!this.__keepAlive){this.__recipeEditor?.destroy(),this.__namePrompt?.destroy(),this.__namePrompt=null,this.__createRecipePrompt?.destroy(),this.__createRecipePrompt=null,this.__confirmationPrompt?.destroy(),this.__confirmationPrompt=null,this.__activatePrompt?.destroy(),this.__activatePrompt=null,this.__teachErrorPopup?.destroy(),this.__teachErrorPopup=null,this.__confirmClosePrompt?.destroy(),this.__confirmClosePrompt=null;for(const control of this.__childControls)control.destroy();this.__childControls=[],super.destroy()}}__onNewFolderPressed(){this.__createFolder()}__onNewRecipePressed(){this.__createRecipe()}__onRenamePressed(){this.__rename()}__onCopyPressed(){this.__fillClipboard("copy")}__onCutPressed(){this.__fillClipboard("cut")}__onPastePressed(){this.__paste()}__onDeletePressed(){this.__delete()}__onSearchChanged(){const text=this.__inputSearch.getText()??null;text?(this.__treeBrowsingDisplay||(this.__treeBrowsingDisplay=new TreeBrowsingDisplay(this.__elementTreeBox,this),this.__recipeBrowser?.addDisplay(this.__treeBrowsingDisplay)),this.__treeBrowsingDisplay.resume()):this.__treeBrowsingDisplay?.suspend(),this.__treeBrowsingDisplay?.search(text),this.__treeBrowsingDisplay?.expandAll(),this.__elementClearSearch.classList.toggle("has-text",!!text),this.__elementBrowsingPane.classList.toggle("searching",!!text)}__onClearSearchClick(event){0===event.button&&(this.__inputSearch.setText(null),this.__inputSearch.focus())}__onSelectionChanged(selectedItems){TcHmi.EventProvider.raise(this.__id+".onPropertyChanged",{propertyName:"SelectedItems"}),TcHmi.EventProvider.raise(this.__id+".onSelectionChanged"),this.getIsEnabled()&&TcHmi.Access.checkAccess(this,"operate")&&this.__updateBrowsingButtons(selectedItems)}__onBeforePathChange(newCurrentItem,newPath,cancelable){return this.__checkUnsavedChanges()}__onPathChanged(currentItem,path){this.setPath(path?.join("::")??null),this.__inputSearch.setText(null),this.getIsEnabled()&&TcHmi.Access.checkAccess(this,"operate")&&this.__openOrCloseEditor(currentItem?.payload,path)}__onDragAndDropped(dragged,droppedOnto){this.__moveItem(dragged,droppedOnto)}__onActivatePressed(){this.__activate()}__onTeachPressed(){this.__teach()}__onSavePressed(){try{this.__save()}catch(ex){}}__onClosePressed(){this.__closeEditor()}__onRecipeEditorChanged(editor){this.__updateEditingButtons()}__expandLocalizationSymbol(key){return`%l%Control::${TcHmiRecipeEdit.#tchmiFQN}::${key}%/l%`}__updateButtonAccess(){const canWriteConfig=this.__symbolAccess["{0}.Config"]>=TcHmi.Server.ACCESS.WRITE,canRename=this.__symbolAccess.Rename>=TcHmi.Server.ACCESS.WRITE,canActivateRecipe=this.__symbolAccess["{0}.ActivateRecipe"]>=TcHmi.Server.ACCESS.WRITE,canReadFromTarget=this.__symbolAccess["{0}.ReadFromTarget"]>=TcHmi.Server.ACCESS.WRITE,canUpdateRecipe=this.__symbolAccess["{0}.UpdateRecipe"]>=TcHmi.Server.ACCESS.WRITE;TcHmi.Access.setControlRightOverride(this.__buttons.createFolder,"operate",canWriteConfig?null:"Deny"),TcHmi.Binding.createEx2(this.__expandLocalizationSymbol(canWriteConfig?"Button_Tooltip_CreateFolder":"Button_Tooltip_CreateFolder_MissingSymbolAccess"),"Tooltip",this.__buttons.createFolder),TcHmi.Access.setControlRightOverride(this.__buttons.createRecipe,"operate",canWriteConfig&&canUpdateRecipe?null:"Deny"),TcHmi.Binding.createEx2(this.__expandLocalizationSymbol(canWriteConfig&&canUpdateRecipe?"Button_Tooltip_CreateRecipe":"Button_Tooltip_CreateRecipe_MissingSymbolAccess"),"Tooltip",this.__buttons.createRecipe),TcHmi.Access.setControlRightOverride(this.__buttons.rename,"operate",canRename?null:"Deny"),TcHmi.Binding.createEx2(this.__expandLocalizationSymbol(canRename?"Button_Tooltip_Rename":"Button_Tooltip_Rename_MissingSymbolAccess"),"Tooltip",this.__buttons.rename),TcHmi.Access.setControlRightOverride(this.__buttons.copy,"operate",canWriteConfig&&canUpdateRecipe?null:"Deny"),TcHmi.Binding.createEx2(this.__expandLocalizationSymbol(canWriteConfig&&canUpdateRecipe?"Button_Tooltip_Copy":"Button_Tooltip_Copy_MissingSymbolAccess"),"Tooltip",this.__buttons.copy),TcHmi.Access.setControlRightOverride(this.__buttons.cut,"operate",canRename?null:"Deny"),TcHmi.Binding.createEx2(this.__expandLocalizationSymbol(canRename?"Button_Tooltip_Cut":"Button_Tooltip_Cut_MissingSymbolAccess"),"Tooltip",this.__buttons.cut),TcHmi.Access.setControlRightOverride(this.__buttons.paste,"operate",null===this.__clipboard||("copy"===this.__clipboard.action?canWriteConfig&&canUpdateRecipe:canRename)?null:"Deny"),TcHmi.Binding.createEx2(this.__expandLocalizationSymbol(null===this.__clipboard||("copy"===this.__clipboard.action?canWriteConfig&&canUpdateRecipe:canRename)?"Button_Tooltip_Paste":"Button_Tooltip_Paste_MissingSymbolAccess"),"Tooltip",this.__buttons.paste),TcHmi.Access.setControlRightOverride(this.__buttons.delete,"operate",canWriteConfig?null:"Deny"),TcHmi.Binding.createEx2(this.__expandLocalizationSymbol(canWriteConfig?"Button_Tooltip_Delete":"Button_Tooltip_Delete_MissingSymbolAccess"),"Tooltip",this.__buttons.delete),TcHmi.Access.setControlRightOverride(this.__buttons.activate,"operate",canActivateRecipe?null:"Deny"),TcHmi.Binding.createEx2(this.__expandLocalizationSymbol(canActivateRecipe?"Button_Tooltip_Activate":"Button_Tooltip_Activate_MissingSymbolAccess"),"Tooltip",this.__buttons.activate),TcHmi.Access.setControlRightOverride(this.__buttons.teach,"operate",canReadFromTarget?null:"Deny"),TcHmi.Binding.createEx2(this.__expandLocalizationSymbol(canReadFromTarget?"Button_Tooltip_ReadFromTarget":"Button_Tooltip_ReadFromTarget_MissingSymbolAccess"),"Tooltip",this.__buttons.teach),TcHmi.Access.setControlRightOverride(this.__buttons.save,"operate",canWriteConfig&&canUpdateRecipe?null:"Deny"),TcHmi.Binding.createEx2(this.__expandLocalizationSymbol(canWriteConfig&&canUpdateRecipe?"Button_Tooltip_Save":"Button_Tooltip_Save_MissingSymbolAccess"),"Tooltip",this.__buttons.save);const confirmCloseSaveButton=this.__confirmClosePrompt?.getButtons().get("save")?.button;confirmCloseSaveButton&&TcHmi.Access.setControlRightOverride(confirmCloseSaveButton,"operate",canWriteConfig&&canUpdateRecipe?null:"Deny")}__getNamePrompt(headerKey){return this.__namePrompt||(this.__namePrompt=new InputPrompt(this),this.__namePrompt.setBackgroundAction({close:!0,action:"cancel"}),this.__namePrompt.setValidationPatterns([{pattern:/::/,expectedTestResult:!1},{pattern:/^(?:|\.\.?)$/,expectedTestResult:!1}]),this.__namePrompt.setTexts({labelText:this.__expandLocalizationSymbol("Popup_Label_Name"),buttonTextOk:this.__expandLocalizationSymbol("Popup_Button_Text_OK"),buttonTooltipOk:this.__expandLocalizationSymbol("Popup_Button_Tooltip_OK"),buttonTextCancel:this.__expandLocalizationSymbol("Popup_Button_Text_Cancel"),buttonTooltipCancel:this.__expandLocalizationSymbol("Popup_Button_Tooltip_Cancel")})),this.__namePrompt.setTexts({headerText:this.__expandLocalizationSymbol(headerKey)}),this.__namePrompt}__getConfirmationPrompt(headerKey,contentKey){return this.__confirmationPrompt||(this.__confirmationPrompt=new TextAndButtonsPrompt({yes:{value:!0,attributes:{"data-tchmi-width-mode":"Content","data-tchmi-min-width":60,"data-tchmi-text-padding":{left:7,right:7},"data-tchmi-height":30,"data-tchmi-text":this.__expandLocalizationSymbol("Popup_Button_Text_Yes")}},no:{value:!1,attributes:{"data-tchmi-width-mode":"Content","data-tchmi-min-width":60,"data-tchmi-text-padding":{left:7,right:7},"data-tchmi-height":30,"data-tchmi-text":this.__expandLocalizationSymbol("Popup_Button_Text_No")}}},this),this.__confirmationPrompt.setBackgroundAction({close:!0,action:"no"})),this.__confirmationPrompt.setTexts({headerText:this.__expandLocalizationSymbol(headerKey),contentText:this.__expandLocalizationSymbol(contentKey)}),this.__confirmationPrompt}async __createFolder(){if(!TcHmi.Access.checkAccess(this,"create"))return;if(!this.__serverDomain)return;if(!this.__recipeBrowser)return;const currentItem=this.__recipeBrowser.getCurrentItem();if(!currentItem||currentItem.type===DirectoryBrowser.ItemType.File)return;const path=this.__recipeBrowser.getPath();if(!path)return;const namePrompt=this.__getNamePrompt("Popup_Header_NewFolder");try{const result=await namePrompt.prompt(currentItem.children.keys(),this.__localizationReader?.get("New_Folder"));if(result.isOk){path.push(result.value);const stringPath=path.join("::");TcHmi.Server.RecipeManagement.createRecipeFolderEx(stringPath,{domain:this.__serverDomain,parallel:!0},null,data=>{data.error!==TcHmi.Errors.NONE&&TcHmi.Log.Controls.error(this,TcHmiRecipeEdit.#tchmiFQN,`Failed to create recipe folder. ${TcHmi.Log.buildMessage(data.details)}`)})}}catch(e){}}async __createRecipe(){if(!TcHmi.Access.checkAccess(this,"create"))return;if(!this.__serverDomain)return;if(!this.__recipeBrowser)return;if(!this.__recipeEditor)return;const currentItem=this.__recipeBrowser.getCurrentItem();if(!currentItem||currentItem.type===DirectoryBrowser.ItemType.File)return;const path=this.__recipeBrowser.getPath();if(path){this.__createRecipePrompt||(this.__createRecipePrompt=new CreateRecipePrompt(this),this.__createRecipePrompt.setBackgroundAction({close:!0,action:"cancel"}),this.__createRecipePrompt.setRecipeManagementDomain(this.__serverDomain),this.__createRecipePrompt.setAllowedRecipeTypes(this.__allowedRecipeTypes??null),this.__createRecipePrompt.setPreselectedRecipeType(this.__preselectedRecipeType?.split("::")??[]),this.__createRecipePrompt.setLocalizations({buttonTextOk:this.__expandLocalizationSymbol("Popup_Button_Text_OK"),buttonTooltipOk:this.__expandLocalizationSymbol("Popup_Button_Tooltip_OK"),buttonTextCancel:this.__expandLocalizationSymbol("Popup_Button_Text_Cancel"),buttonTooltipCancel:this.__expandLocalizationSymbol("Popup_Button_Tooltip_Cancel"),headerText:this.__expandLocalizationSymbol("Popup_Header_NewRecipe"),nameLabelText:this.__expandLocalizationSymbol("Popup_Label_Name"),recipeTypeLabelText:this.__expandLocalizationSymbol("Popup_Label_RecipeType"),selectButtonTooltip:this.__expandLocalizationSymbol("Popup_Button_Tooltip_RecipeType"),recipeTypePopupHeaderText:this.__expandLocalizationSymbol("Popup_Header_RecipeType"),noRecipeTypesText:this.__expandLocalizationSymbol("Text_NoRecipeTypes")}));try{const result=await this.__createRecipePrompt.prompt(currentItem.children.keys(),this.__localizationReader?.get("New_Recipe"));if(result.isOk){const recipePath=path.concat(result.value.name);this.__recipeBrowser.fakeFile(recipePath,{recipeTypeName:result.value.recipeTypeName,values:{}}),this.__element[0].classList.add("editing"),this.__recipeBrowser.setPath(recipePath),this.__recipeEditor.populate({name:result.value.recipeTypeName,recipeType:result.value.recipeType},{name:recipePath.join("::")}),this.__recipeBrowser.suspendDirectoryUpdates()}}catch(e){}}}async __rename(){if(!TcHmi.Access.checkAccess(this,"rename"))return;if(!this.__serverDomain)return;if(!this.__recipeBrowser)return;const selectedItems=this.__recipeBrowser.getSelectedItems();if(!selectedItems||1!==selectedItems.length)return;const selectedItem=selectedItems[0],currentItem=selectedItem.parent,path=DirectoryBrowser.getPath(currentItem),namePrompt=this.__getNamePrompt("Popup_Header_Rename");try{const result=await namePrompt.prompt(Array.from(currentItem.children.keys()).filter(name=>name!==selectedItem.name),selectedItem.name);if(result.isOk&&result.value!==selectedItem.name){const stringPath=path.join("::");TcHmi.Server.RecipeManagement.isRecipe(selectedItem.payload)?TcHmi.Server.RecipeManagement.renameRecipeEx(selectedItem.name,stringPath,result.value,stringPath,{domain:this.__serverDomain,parallel:!0},null,data=>{data.error!==TcHmi.Errors.NONE&&TcHmi.Log.Controls.error(this,TcHmiRecipeEdit.#tchmiFQN,`Failed to rename recipe. ${TcHmi.Log.buildMessage(data.details)}`)}):TcHmi.Server.RecipeManagement.renameRecipeFolderEx(selectedItem.name,stringPath,result.value,stringPath,{domain:this.__serverDomain,parallel:!0},null,data=>{data.error!==TcHmi.Errors.NONE&&TcHmi.Log.Controls.error(this,TcHmiRecipeEdit.#tchmiFQN,`Failed to rename recipe folder. ${TcHmi.Log.buildMessage(data.details)}`)})}}catch(e){}}async __delete(){if(!TcHmi.Access.checkAccess(this,"delete"))return;if(!this.__serverDomain)return;if(!this.__recipeBrowser)return;const currentItem=this.__recipeBrowser.getCurrentItem()?.payload;if(!currentItem||TcHmi.Server.RecipeManagement.isRecipe(currentItem))return;const selectedItems=this.__recipeBrowser.getSelectedItems();if(!selectedItems||0===selectedItems.length)return;const path=this.__recipeBrowser.getPath();if(!path)return;const confirmationPrompt=this.__getConfirmationPrompt("Popup_Header_ConfirmDelete","Popup_Text_ConfirmDelete");try{if(await confirmationPrompt.prompt())for(const selectedItem of selectedItems)if(TcHmi.Server.RecipeManagement.isRecipe(selectedItem.payload)){const stringPath=path.join("::");TcHmi.Server.RecipeManagement.deleteRecipeEx(selectedItem.name,stringPath,{domain:this.__serverDomain,parallel:!0},null,data=>{data.error!==TcHmi.Errors.NONE&&TcHmi.Log.Controls.error(this,TcHmiRecipeEdit.#tchmiFQN,`Failed to delete recipe. ${TcHmi.Log.buildMessage(data.details)}`)})}else{path.push(selectedItem.name);const stringPath=path.join("::");TcHmi.Server.RecipeManagement.deleteRecipeFolderEx(stringPath,{domain:this.__serverDomain,parallel:!0},null,data=>{data.error!==TcHmi.Errors.NONE&&TcHmi.Log.Controls.error(this,TcHmiRecipeEdit.#tchmiFQN,`Failed to delete recipe folder. ${TcHmi.Log.buildMessage(data.details)}`)})}}catch(e){}}__fillClipboard(action){const items=this.__recipeBrowser?.getSelectedItems(),path=this.__recipeBrowser?.getPath();items&&path&&(this.__clipboard={action,origin:path,items},this.__buttons.paste.setIsEnabled(!0),this.__updateButtonAccess(),this.__buttons.paste.setVirtualControlRightMappings([{controlRight:"operate",virtualControlRight:"cut"===action?"cut":"create"}]))}async __paste(){if(!this.__clipboard||!this.__recipeBrowser)return;if("cut"===this.__clipboard.action&&tchmi_equal(this.__clipboard.origin,this.__recipeBrowser.getFolderPath()))return void(this.__clipboard.action="copy");const itemsToPaste=new Map(this.__clipboard.items.map(item=>[item.name,item])),existingNames=new Set(this.__recipeBrowser.getCurrentFolder()?.children.keys()),conflictingNames=new Set;for(const name of itemsToPaste.keys())existingNames.has(name)&&conflictingNames.add(name),existingNames.add(name);if(conflictingNames.size>0){const result=await this.__resolveFileNameConflicts(conflictingNames,existingNames);if(!result.isOk)return;for(const name of conflictingNames){const resolvedName=result.value.get(name);if(resolvedName){if(resolvedName!==name){const item=itemsToPaste.get(name);item&&itemsToPaste.set(resolvedName,item),itemsToPaste.delete(name)}}else itemsToPaste.delete(name)}}if(0!==itemsToPaste.size)switch(this.__clipboard.action){case"copy":this.__copyPaste(itemsToPaste,this.__recipeBrowser.getFolderPath()??[]);break;case"cut":this.__cutPaste(itemsToPaste,this.__clipboard.origin,this.__recipeBrowser.getFolderPath()??[])}}__copyPaste(itemsToPaste,target){if(!this.__serverDomain)return;const path=target.join("::");for(const[name,item]of itemsToPaste)if(item.type===DirectoryBrowser.ItemType.File)TcHmi.Server.RecipeManagement.createRecipeEx(name,path,item.payload,{domain:this.__serverDomain,parallel:!0},null,data=>{data.error!==TcHmi.Errors.NONE&&TcHmi.Log.Controls.error(this,TcHmiRecipeEdit.#tchmiFQN,`Failed to create recipe. ${TcHmi.Log.buildMessage(data.details)}`),TcHmi.EventProvider.raise(this.__id+".onRecipeCreated",{name:[...target,name].join("::"),recipe:item.payload})});else{const subPath=target.concat(name);TcHmi.Server.RecipeManagement.createRecipeFolderEx(subPath.join("::"),{domain:this.__serverDomain,parallel:!0},null,data=>{data.error!==TcHmi.Errors.NONE?TcHmi.Log.Controls.error(this,TcHmiRecipeEdit.#tchmiFQN,`Failed to create recipe folder. ${TcHmi.Log.buildMessage(data.details)}`):this.__copyPaste(item.children,subPath)})}}__cutPaste(itemsToPaste,origin,target){if(!this.__clipboard||!this.__serverDomain)return;const oldPath=origin.join("::"),newPath=target.join("::");for(const[newName,item]of itemsToPaste)item.type===DirectoryBrowser.ItemType.File?TcHmi.Server.RecipeManagement.renameRecipeEx(item.name,oldPath,newName,newPath,{domain:this.__serverDomain,parallel:!0},null,data=>{data.error!==TcHmi.Errors.NONE&&TcHmi.Log.Controls.error(this,TcHmiRecipeEdit.#tchmiFQN,`Failed to move recipe. ${TcHmi.Log.buildMessage(data.details)}`)}):TcHmi.Server.RecipeManagement.renameRecipeFolderEx(item.name,oldPath,newName,newPath,{domain:this.__serverDomain,parallel:!0},null,data=>{data.error!==TcHmi.Errors.NONE&&TcHmi.Log.Controls.error(this,TcHmiRecipeEdit.#tchmiFQN,`Failed to move recipe. ${TcHmi.Log.buildMessage(data.details)}`)});this.__clipboard.action="copy"}async __resolveFileNameConflicts(conflictingNames,existingNames){const currentFolder=this.__recipeBrowser?.getCurrentFolder();if(!currentFolder)return{isOk:!1};const conflictMap=new Map,canDelete=TcHmi.Access.checkAccess(this,"delete")??!1;for(const name of conflictingNames)conflictMap.set(name,canDelete);const popup=new FileConflictPrompt(conflictMap,existingNames,this);popup.setBackgroundAction({close:!0,action:"cancel"}),popup.setLocalizations({headerText:this.__expandLocalizationSymbol("Popup_Header_FileConflict"),labelText:this.__expandLocalizationSymbol("Popup_Label_FileConflict"),labelDoForAll:this.__expandLocalizationSymbol("Popup_FileConflict_Label_DoForAll"),radioTextSkip:this.__expandLocalizationSymbol("Popup_FileConflict_Radio_Text_Skip"),radioTextReplace:this.__expandLocalizationSymbol("Popup_FileConflict_Radio_Text_Replace"),radioTextKeepBoth:this.__expandLocalizationSymbol("Popup_FileConflict_Radio_Text_KeepBoth"),buttonTextOk:this.__expandLocalizationSymbol("Popup_Button_Text_OK"),buttonTextCancel:this.__expandLocalizationSymbol("Popup_Button_Text_Cancel"),buttonTooltipCancel:this.__expandLocalizationSymbol("Popup_Button_Tooltip_Cancel")});const result=await popup.prompt();return popup.destroy(!0),result}__updateBrowsingButtons(selectedItems){this.__buttons.rename.setIsEnabled(selectedItems&&1===selectedItems.length),this.__buttons.copy.setIsEnabled(selectedItems&&selectedItems.length>0),this.__buttons.cut.setIsEnabled(selectedItems&&selectedItems.length>0),this.__buttons.delete.setIsEnabled(selectedItems&&selectedItems.length>0)}__openOrCloseEditor(currentItem,path){if(this.__recipeEditor)if(path&&currentItem&&TcHmi.Server.RecipeManagement.isRecipe(currentItem)){if(!this.__element[0].classList.contains("editing")){const recipeName=path.join("::");this.__recipeEditor.populate({name:currentItem.recipeTypeName},{name:recipeName,recipe:currentItem}),this.__element[0].classList.add("editing"),this.__recipeBrowser?.suspendDirectoryUpdates(),this.__updateActiveRecipesSubscription(null,null,recipeName),TcHmi.EventProvider.raise(this.__id+".onEditStarted",{name:recipeName,recipe:currentItem})}}else this.__element[0].classList.contains("editing")&&(this.__element[0].classList.remove("editing"),this.__recipeEditor.clear(),this.__recipeBrowser?.clearFakedFile(),this.__recipeBrowser?.resumeDirectoryUpdates(),this.__updateActiveRecipesSubscription(null,null,""))}async __checkUnsavedChanges(){if(!this.__recipeEditor)return!0;if(!this.__element[0].classList.contains("editing")||!this.__recipeEditor.getRecipeName())return!0;const state=this.__recipeEditor.getState();if(state.isValid&&!state.hasChanges)return TcHmi.EventProvider.raise(this.__id+".onEditEnded",{name:state.recipeName,recipe:state.value}),!0;this.__confirmClosePrompt||(this.__confirmClosePrompt=new TextAndButtonsPrompt({save:{value:"save",attributes:{"data-tchmi-width-mode":"Content","data-tchmi-min-width":60,"data-tchmi-text-padding":{left:7,right:7},"data-tchmi-height":30,"data-tchmi-text":this.__expandLocalizationSymbol("Popup_Button_Text_SaveChanges")}},discard:{value:"discard",attributes:{"data-tchmi-width-mode":"Content","data-tchmi-min-width":60,"data-tchmi-text-padding":{left:7,right:7},"data-tchmi-height":30,"data-tchmi-text":this.__expandLocalizationSymbol("Popup_Button_Text_DiscardChanges")}},cancel:{value:"cancel",attributes:{"data-tchmi-width-mode":"Content","data-tchmi-min-width":60,"data-tchmi-text-padding":{left:7,right:7},"data-tchmi-height":30,"data-tchmi-text":this.__expandLocalizationSymbol("Popup_Button_Text_Cancel")}}},this),this.__confirmClosePrompt.setBackgroundAction({close:!0,action:"cancel"}),this.__confirmClosePrompt.setTexts({headerText:this.__expandLocalizationSymbol("Popup_Header_UnsavedChanges"),contentText:this.__expandLocalizationSymbol("Popup_Text_UnsavedChanges")}));const saveButton=this.__confirmClosePrompt.getButtons().get("save")?.button;saveButton?.setIsEnabled(state.isValid),saveButton?.setVirtualControlRightMappings([{controlRight:"operate",virtualControlRight:"editRecipe"}]),saveButton&&TcHmi.Access.setControlRightOverride(saveButton,"operate",this.__symbolAccess["{0}.Config"]>=TcHmi.Server.ACCESS.WRITE&&this.__symbolAccess["{0}.UpdateRecipe"]>=TcHmi.Server.ACCESS.WRITE?null:"Deny");try{switch(await this.__confirmClosePrompt.prompt()){case"save":try{await this.__save()}catch(e){return!1}return state.isValid&&TcHmi.EventProvider.raise(this.__id+".onEditEnded",{name:state.recipeName,recipe:state.value}),!0;case"discard":const path=this.__recipeBrowser?.getPath(),currentItem=this.__recipeBrowser?.getCurrentItem()?.payload;return path&&currentItem&&TcHmi.Server.RecipeManagement.isRecipe(currentItem)&&TcHmi.EventProvider.raise(this.__id+".onEditEnded",{name:path.join("::"),recipe:currentItem}),!0;case"cancel":return!1}}catch(e){return!1}}__moveItem(dragged,droppedOnto){if(!TcHmi.Access.checkAccess(this,"rename"))return;if(!this.__serverDomain)return;if(!this.__recipeBrowser)return;const currentItem=this.__recipeBrowser.getCurrentItem()?.payload;if(!currentItem||TcHmi.Server.RecipeManagement.isRecipe(currentItem))return;const path=this.__recipeBrowser.getPath();if(!path)return;const stringPath=path.join("::"),newPath=droppedOnto.isParent?path.slice(0,-1).join("::"):path.concat(droppedOnto.name).join("::");TcHmi.Server.RecipeManagement.isRecipe(currentItem[dragged])?TcHmi.Server.RecipeManagement.renameRecipeEx(dragged,stringPath,dragged,newPath,{domain:this.__serverDomain,parallel:!0},null,data=>{data.error!==TcHmi.Errors.NONE&&TcHmi.Log.Controls.error(this,TcHmiRecipeEdit.#tchmiFQN,`Failed to move recipe. ${TcHmi.Log.buildMessage(data.details)}`)}):TcHmi.Server.RecipeManagement.renameRecipeFolderEx(dragged,stringPath,dragged,newPath,{domain:this.__serverDomain,parallel:!0},null,data=>{data.error!==TcHmi.Errors.NONE&&TcHmi.Log.Controls.error(this,TcHmiRecipeEdit.#tchmiFQN,`Failed to move recipe folder. ${TcHmi.Log.buildMessage(data.details)}`)})}async __activate(){if(!this.__recipeEditor)return;const recipeName=this.__recipeEditor.getRecipeName();if(!recipeName)return;const state=this.__recipeEditor.getState();if(!state.isValid||state.hasChanges){this.__activatePrompt||(this.__activatePrompt=new TextAndButtonsPrompt({saveAndActivate:{value:"saveAndActivate",attributes:{"data-tchmi-width-mode":"Content","data-tchmi-min-width":60,"data-tchmi-text-padding":{left:7,right:7},"data-tchmi-height":30,"data-tchmi-text":this.__expandLocalizationSymbol("Popup_Button_Text_SaveAndActivate")}},justActivate:{value:"justActivate",attributes:{"data-tchmi-width-mode":"Content","data-tchmi-min-width":60,"data-tchmi-text-padding":{left:7,right:7},"data-tchmi-height":30,"data-tchmi-text":this.__expandLocalizationSymbol("Popup_Button_Text_JustActivate")}},cancel:{value:"cancel",attributes:{"data-tchmi-width-mode":"Content","data-tchmi-min-width":60,"data-tchmi-text-padding":{left:7,right:7},"data-tchmi-height":30,"data-tchmi-text":this.__expandLocalizationSymbol("Popup_Button_Text_Cancel")}}},this),this.__activatePrompt.setBackgroundAction({close:!0,action:"cancel"}),this.__activatePrompt.setTexts({headerText:this.__expandLocalizationSymbol("Popup_Header_UnsavedChanges"),contentText:this.__expandLocalizationSymbol("Popup_Text_UnsavedChangesActivating")}));const saveButton=this.__activatePrompt.getButtons().get("saveAndActivate")?.button;saveButton?.setIsEnabled(state.isValid),saveButton?.setVirtualControlRightMappings([{controlRight:"operate",virtualControlRight:"editRecipe"}]),saveButton&&TcHmi.Access.setControlRightOverride(saveButton,"operate",this.__symbolAccess["{0}.Config"]>=TcHmi.Server.ACCESS.WRITE&&this.__symbolAccess["{0}.UpdateRecipe"]>=TcHmi.Server.ACCESS.WRITE?null:"Deny");const activateButton=this.__activatePrompt.getButtons().get("justActivate")?.button;activateButton?.setIsEnabled(this.__recipeEditor.recipeExists());try{switch(await this.__activatePrompt.prompt()){case"saveAndActivate":await this.__save();break;case"justActivate":break;case"cancel":return}}catch(e){return}}else if(this.__promptBeforeActivating){const confirmationPrompt=this.__getConfirmationPrompt("Popup_Header_ConfirmActivate","Popup_Text_ConfirmActivate");if(!await confirmationPrompt.prompt())return}TcHmi.Server.RecipeManagement.activateEx(recipeName,null,{domain:this.__serverDomain,parallel:!0},null,data=>{data.error!==TcHmi.Errors.NONE&&TcHmi.Log.Controls.error(this,TcHmiRecipeEdit.#tchmiFQN,`Failed to activate recipe. ${TcHmi.Log.buildMessage(data.details)}`),this.__watchActiveRecipeConditions.userHasRights&&this.__elementPathBox.classList.add("active"),TcHmi.EventProvider.raise(this.__id+".onRecipeActivated",{name:recipeName})})}async __teach(){if(!this.__recipeEditor)return;const recipeName=this.__recipeEditor.getRecipeName();if(!recipeName)return;const exists=this.__recipeEditor.recipeExists(),isValid=this.__recipeEditor.getState().isValid;if(this.__promptBeforeTeaching&&(exists||isValid)){const confirmationPrompt=this.__getConfirmationPrompt("Popup_Header_ConfirmTeach","Popup_Text_ConfirmTeach");if(!await confirmationPrompt.prompt())return}if(!exists){if(!isValid)return this.__teachErrorPopup||(this.__teachErrorPopup=new TextAndButtonsPrompt({ok:{value:void 0,attributes:{"data-tchmi-width-mode":"Content","data-tchmi-min-width":60,"data-tchmi-text-padding":{left:7,right:7},"data-tchmi-height":30,"data-tchmi-text":this.__expandLocalizationSymbol("Popup_Button_Text_OK")}}},this),this.__teachErrorPopup.setBackgroundAction({close:!0,action:"ok"}),this.__teachErrorPopup.setTexts({headerText:this.__expandLocalizationSymbol("Popup_Header_ReadFromTargetError"),contentText:this.__expandLocalizationSymbol("Popup_Text_ReadFromTargetError")})),void this.__teachErrorPopup.show();try{await this.__save()}catch(e){return}}TcHmi.Server.RecipeManagement.readFromTargetEx(recipeName,null,{domain:this.__serverDomain,parallel:!0},null,data=>{const recipe=data.value?.[recipeName];data.error===TcHmi.Errors.NONE&&recipe?this.__recipeEditor.setRecipeValues(recipe):TcHmi.Log.Controls.error(this,TcHmiRecipeEdit.#tchmiFQN,`Failed to teach recipe. ${TcHmi.Log.buildMessage(data.details)}`)})}__save(){return new Promise((resolve,reject)=>{if(!this.__recipeEditor)return void reject(new Error);const state=this.__recipeEditor.getState();if(state.isValid){const recipe=state.value;this.__recipeEditor.recipeExists()?TcHmi.Server.RecipeManagement.updateRecipeEx(state.recipeName,null,recipe.values,{domain:this.__serverDomain,parallel:!0},null,data=>{data.error!==TcHmi.Errors.NONE?(TcHmi.Log.Controls.error(this,TcHmiRecipeEdit.#tchmiFQN,`Failed to update recipe. ${TcHmi.Log.buildMessage(data.details)}`),reject(new Error)):(this.__recipeEditor.confirmSave(),TcHmi.EventProvider.raise(this.__id+".onRecipeModified",{name:state.recipeName,recipe:state.value}),resolve())}):TcHmi.Server.RecipeManagement.createRecipeEx(state.recipeName,null,recipe,{domain:this.__serverDomain,parallel:!0},null,data=>{data.error!==TcHmi.Errors.NONE?(TcHmi.Log.Controls.error(this,TcHmiRecipeEdit.#tchmiFQN,`Failed to create recipe. ${TcHmi.Log.buildMessage(data.details)}`),reject(new Error)):(this.__recipeEditor.confirmSave(),this.__recipeBrowser?.clearFakedFile(),TcHmi.EventProvider.raise(this.__id+".onRecipeCreated",{name:state.recipeName,recipe:state.value}),resolve())})}else reject(new Error)})}async __closeEditor(){if(!this.__recipeBrowser)return;if(!this.__recipeEditor)return;await this.__checkUnsavedChanges()&&(this.__element[0].classList.remove("editing"),this.__recipeEditor.clear(),this.__recipeBrowser.clearFakedFile(),this.__recipeBrowser.resumeDirectoryUpdates(),this.__recipeBrowser.setPath(this.__recipeBrowser.getFolderPath()??[]))}__updateEditingButtons(){if(!this.__recipeEditor)return;const state=this.__recipeEditor.getState();this.__buttons.save.setIsEnabled(state.isValid&&state.hasChanges)}setServerDomain(valueNew){let convertedValue=TcHmi.ValueConverter.toString(valueNew);null===convertedValue&&(convertedValue=this.getAttributeDefaultValueInternal("ServerDomain")),tchmi_equal(convertedValue,this.__serverDomain)||(this.__serverDomain=convertedValue,TcHmi.EventProvider.raise(this.__id+".onPropertyChanged",{propertyName:"ServerDomain"}),this.__processServerDomain())}getServerDomain(){return this.__serverDomain}__processServerDomain(){this.__updateRecipeWatches(),this.__updateSymbolAccessSubscription(),this.__serverDomain&&this.__createRecipePrompt?.setRecipeManagementDomain(this.__serverDomain)}setPath(valueNew){let convertedValue=TcHmi.ValueConverter.toString(valueNew);null===convertedValue&&(convertedValue=this.getAttributeDefaultValueInternal("Path")),tchmi_equal(convertedValue,this.__path)||(this.__oldPath=this.__path,this.__path=convertedValue,TcHmi.EventProvider.raise(this.__id+".onPropertyChanged",{propertyName:"Path"}),this.__processPath())}getPath(){return this.__path}async __processPath(){if(!this.__recipeBrowser)return;await this.__recipeBrowser.setPath(this.__path?this.__path.split("::"):[])||(this.__path=this.__oldPath,TcHmi.Log.Controls.error(this,TcHmiRecipeEdit.#tchmiFQN,{Attribute:"Path"},TcHmi.Log.buildMessage({code:TcHmi.Errors.E_INVALID,message:TcHmi.Errors[TcHmi.Errors.E_INVALID],reason:`The path "${this.__path}" is invalid or was rejected by the user.`,domain:this.__type})))}setAllowedRecipeTypes(valueNew){let convertedValue=TcHmi.ValueConverter.toObject(valueNew)??this.getAttributeDefaultValueInternal("AllowedRecipeTypes"),resolverInfo=this.__objectResolvers.get("allowedRecipeTypes");resolverInfo?.watchDestroyer?.(),resolverInfo?.resolver.destroy();let resolver=new TcHmi.Symbol.ObjectResolver(convertedValue,{parentControl:this,type:this.getAttributeDescription("AllowedRecipeTypes")?.type});this.__objectResolvers.set("allowedRecipeTypes",{resolver,watchCallback:this.__onResolverForAllowedRecipeTypesWatchCallback,watchDestroyer:resolver.watch(this.__onResolverForAllowedRecipeTypesWatchCallback)})}__onResolverForAllowedRecipeTypesWatchCallback(data){this.__isAttached||this.__suspendObjectResolver("allowedRecipeTypes"),data.error===TcHmi.Errors.NONE?tchmi_equal(data.value,this.getAllowedRecipeTypes())||(this.__allowedRecipeTypes=data.value??this.getAttributeDefaultValueInternal("AllowedRecipeTypes"),TcHmi.EventProvider.raise(this.__id+".onPropertyChanged",{propertyName:"AllowedRecipeTypes"}),this.__processAllowedRecipeTypes()):TcHmi.Log.Controls.error(this,TcHmiRecipeEdit.#tchmiFQN,{Attribute:"AllowedRecipeTypes"},TcHmi.Log.buildMessage(data.details),`Resolving symbols from object failed with error: ${TcHmi.Log.buildMessage(data.details)}`)}getAllowedRecipeTypes(){return this.__allowedRecipeTypes}__processAllowedRecipeTypes(){this.__unwatchRecipeList&&(this.__unwatchRecipeList(),this.__unwatchRecipeList=null,this.__updateRecipeListWatch(null,null)),this.__createRecipePrompt?.setAllowedRecipeTypes(this.__allowedRecipeTypes??null)}setPreselectedRecipeType(valueNew){let convertedValue=TcHmi.ValueConverter.toString(valueNew);null===convertedValue&&(convertedValue=this.getAttributeDefaultValueInternal("PreselectedRecipeType")),tchmi_equal(convertedValue,this.__preselectedRecipeType)||(this.__preselectedRecipeType=convertedValue,TcHmi.EventProvider.raise(this.__id+".onPropertyChanged",{propertyName:"PreselectedRecipeType"}),this.__processPreselectedRecipeType())}getPreselectedRecipeType(){return this.__preselectedRecipeType}__processPreselectedRecipeType(){this.__createRecipePrompt?.setPreselectedRecipeType(this.__preselectedRecipeType?.split("::")??[])}getSelectedItems(){return(this.__recipeBrowser?.getSelectedItems()??[]).map(item=>item.name)}setPromptBeforeActivating(valueNew){let convertedValue=TcHmi.ValueConverter.toBoolean(valueNew);null===convertedValue&&(convertedValue=this.getAttributeDefaultValueInternal("PromptBeforeActivating")),tchmi_equal(convertedValue,this.__promptBeforeActivating)||(this.__promptBeforeActivating=convertedValue,TcHmi.EventProvider.raise(this.__id+".onPropertyChanged",{propertyName:"PromptBeforeActivating"}))}getPromptBeforeActivating(){return this.__promptBeforeActivating}setPromptBeforeTeaching(valueNew){let convertedValue=TcHmi.ValueConverter.toBoolean(valueNew);null===convertedValue&&(convertedValue=this.getAttributeDefaultValueInternal("PromptBeforeTeaching")),tchmi_equal(convertedValue,this.__promptBeforeTeaching)||(this.__promptBeforeTeaching=convertedValue,TcHmi.EventProvider.raise(this.__id+".onPropertyChanged",{propertyName:"PromptBeforeTeaching"}))}getPromptBeforeTeaching(){return this.__promptBeforeTeaching}__updateRecipeWatches(unwatchOnly=!1){TCHMI_DESIGNER||(this.__unwatchRecipeList?.(),this.__unwatchRecipeList=null,this.__unwatchRecipeManagementDomain?.(),this.__unwatchRecipeManagementDomain=null,null!==this.__activeRecipesSubscriptionId&&(TcHmi.Server.unsubscribeEx(this.__activeRecipesSubscriptionId,null),this.__activeRecipesSubscriptionId=null),!unwatchOnly&&this.__isAttached&&this.__serverDomain?this.__unwatchRecipeManagementDomain=TcHmi.Server.Domains.watch(this.__serverDomain,data=>{data.error===TcHmi.Errors.NONE?"Loaded"===data.value?.state||"Initialized"===data.value?.state?(this.__unlockIsEnabled(),this.__unwatchRecipeList||(this.__updateRecipeListWatch(!0,null),this.__updateActiveRecipesSubscription(!0,null,null)),this.__recipeEditor?.setRecipeManagementDomain(this.__serverDomain??null),this.__createRecipePrompt?.setRecipeManagementDomain(this.__serverDomain??null)):(this.__lockIsEnabled(),this.__updateRecipeListWatch(!1,null),this.__updateActiveRecipesSubscription(!1,null,null),this.__recipeEditor?.setRecipeManagementDomain(null),this.__createRecipePrompt?.setRecipeManagementDomain(null),TcHmi.Log.Controls.error(this,TcHmiRecipeEdit.#tchmiFQN,`Domain '${this.__serverDomain}' is not loaded. Please make sure the server extension is activated.`)):(this.__lockIsEnabled(),this.__updateRecipeListWatch(!1,null),this.__updateActiveRecipesSubscription(!1,null,null),this.__recipeEditor?.setRecipeManagementDomain(null),this.__createRecipePrompt?.setRecipeManagementDomain(null),TcHmi.Log.Controls.error(this,TcHmiRecipeEdit.#tchmiFQN,`Domain '${this.__serverDomain}' is not known. Please make sure the server extension is loaded and the domain name is correct. ${TcHmi.Log.buildMessage(data.details)}`))}):this.__recipeBrowser?.setDirectory(null,folder=>new Map(Object.entries(folder)),TcHmi.Server.RecipeManagement.isRecipe))}__lockIsEnabled(){const unlockValue=this.__isEnabledLock.unlockValue;this.setIsEnabled(!1),this.__isEnabledLock.locked=!0,this.__isEnabledLock.unlockValue=unlockValue}__unlockIsEnabled(){this.__isEnabledLock.locked=!1,this.setIsEnabled(this.__isEnabledLock.unlockValue)}setIsEnabled(valueNew){this.__isEnabledLock.unlockValue=valueNew,this.__isEnabledLock.locked||super.setIsEnabled(valueNew)}__updateRecipeListWatch(extensionLoaded,userHasRights){if(TCHMI_DESIGNER)return;let conditionsChanged=!1;null!==extensionLoaded&&extensionLoaded!==this.__watchRecipeConditions.extensionLoaded&&(this.__watchRecipeConditions.extensionLoaded=extensionLoaded,conditionsChanged=!0),null!==userHasRights&&userHasRights!==this.__watchRecipeConditions.userHasRights&&(this.__watchRecipeConditions.userHasRights=userHasRights,conditionsChanged=!0),(conditionsChanged||null===this.__unwatchRecipeList)&&(this.__unwatchRecipeList?.(),this.__unwatchRecipeList=null,this.__isAttached&&this.__serverDomain&&this.__watchRecipeConditions.extensionLoaded&&this.__watchRecipeConditions.userHasRights?this.__unwatchRecipeList=TcHmi.Server.RecipeManagement.watchRecipeList({domain:this.__serverDomain,parallel:!0},this.__onRecipeListWatch):this.__recipeBrowser?.setDirectory(null,folder=>new Map(Object.entries(folder)),TcHmi.Server.RecipeManagement.isRecipe))}__onRecipeListWatch(data){let recipes=null;if(data.error?TcHmi.Log.Controls.error(this,TcHmiRecipeEdit.#tchmiFQN,`Failed to list recipes of domain '${this.__serverDomain}'. Please make sure the domain is a recipe management extension. ${TcHmi.Log.buildMessage(data.details)}`):data.value?recipes=data.value:TcHmi.Log.Controls.error(this,TcHmiRecipeEdit.#tchmiFQN,`Failed to list recipes of domain '${this.__serverDomain}'. Please make sure the domain is a recipe management extension.`),this.__watchRecipeListResult=recipes,this.__onRecipeListReceivedManager.trigger(recipes),recipes&&this.__allowedRecipeTypes?.length){const filter=folder=>{const filtered={};for(const[name,item]of Object.entries(folder))TcHmi.Server.RecipeManagement.isRecipe(item)?this.__allowedRecipeTypes.includes(item.recipeTypeName)&&(filtered[name]=item):filtered[name]=filter(item);return filtered};recipes=filter(recipes)}this.__recipeBrowser?.setDirectory(recipes,folder=>new Map(Object.entries(folder)),TcHmi.Server.RecipeManagement.isRecipe),this.__elementEmptyNotification.classList.toggle("show",!recipes||0===Object.keys(recipes).length)}__registerOnRecipeListReceived(callback){return callback(this.__watchRecipeListResult),this.__onRecipeListReceivedManager.add(callback)}__unregisterOnRecipeListReceived(callback){this.__onRecipeListReceivedManager.remove(callback)}__updateActiveRecipesSubscription(extensionLoaded,userHasRights,recipe){if(TCHMI_DESIGNER)return;let conditionsChanged=!1;if(null!==extensionLoaded&&extensionLoaded!==this.__watchActiveRecipeConditions.extensionLoaded&&(this.__watchActiveRecipeConditions.extensionLoaded=extensionLoaded,conditionsChanged=!0),null!==userHasRights&&userHasRights!==this.__watchActiveRecipeConditions.userHasRights&&(this.__watchActiveRecipeConditions.userHasRights=userHasRights,conditionsChanged=!0),null!==recipe&&recipe!==this.__watchActiveRecipeConditions.recipe&&(this.__watchActiveRecipeConditions.recipe=recipe,conditionsChanged=!0),!conditionsChanged&&null!==this.__activeRecipesSubscriptionId)return;if(null!==this.__activeRecipesSubscriptionId&&(TcHmi.Server.unsubscribeEx(this.__activeRecipesSubscriptionId,null),this.__activeRecipesSubscriptionId=null),!this.__isAttached||!this.__serverDomain)return void this.__elementPathBox.classList.remove("active");if(!this.__watchActiveRecipeConditions.extensionLoaded||!this.__watchActiveRecipeConditions.userHasRights||!recipe)return void this.__elementPathBox.classList.remove("active");const symbol=this.__serverDomain+".GetActiveRecipes";this.__activeRecipesSubscriptionId=TcHmi.Server.subscribeEx([{commandOptions:["SendErrorMessage","SendWriteValue"],symbol,writeValue:[recipe]}],TcHmi.Config.get().tcHmiServer.websocketIntervalTime,{parallel:!0},data=>{if(data.error!==TcHmi.Errors.NONE)return void TcHmi.Log.Controls.error(this,TcHmiRecipeEdit.#tchmiFQN,{Symbol:"GetActiveRecipes"},TcHmi.Log.buildMessage(data.details));if(!data.response)return void TcHmi.Log.Controls.error(this,TcHmiRecipeEdit.#tchmiFQN,{Symbol:"GetActiveRecipes"},TcHmi.Log.buildMessage({code:TcHmi.Errors.E_SERVER_RESPONSE_MISSING,message:TcHmi.Errors[TcHmi.Errors.E_SERVER_RESPONSE_MISSING],reason:"Missing response from server.",domain:this.__type}));if(data.response.error)return void TcHmi.Log.Controls.error(this,TcHmiRecipeEdit.#tchmiFQN,{Symbol:"GetActiveRecipes"},TcHmi.Log.buildMessage(data.response.error));if(!data.response.commands)return void TcHmi.Log.Controls.error(this,TcHmiRecipeEdit.#tchmiFQN,{Symbol:"GetActiveRecipes"},TcHmi.Log.buildMessage({code:TcHmi.Errors.E_SERVER_COMMANDS_MISSING,message:TcHmi.Errors[TcHmi.Errors.E_SERVER_COMMANDS_MISSING],reason:`Missing commands in response from server with id: '${data.response.id}'.`,domain:this.__type}));const command=data.response.commands.find(command=>command.symbol===symbol&&command.writeValue?.includes(recipe));command?command.error?TcHmi.Log.Controls.error(this,TcHmiRecipeEdit.#tchmiFQN,{Symbol:"GetActiveRecipes"},TcHmi.Log.buildMessage(command.error)):command.readValue?this.__elementPathBox.classList.toggle("active",command.readValue.includes(recipe)):TcHmi.Log.Controls.error(this,TcHmiRecipeEdit.#tchmiFQN,{Symbol:"GetActiveRecipes"},TcHmi.Log.buildMessage({code:TcHmi.Errors.E_SERVER_READVALUE_MISSING,message:TcHmi.Errors[TcHmi.Errors.E_SERVER_READVALUE_MISSING],reason:`Missing readValue in response from server with id: '${data.response.id}'.`,domain:this.__type})):TcHmi.Log.Controls.error(this,TcHmiRecipeEdit.#tchmiFQN,{Symbol:"GetActiveRecipes"},TcHmi.Log.buildMessage({code:TcHmi.Errors.E_SERVER_COMMAND_MISSING,message:TcHmi.Errors[TcHmi.Errors.E_SERVER_COMMAND_MISSING],reason:`Missing command for symbol '${symbol}' in response from server with id: '${data.response.id}'.`,domain:this.__type}))})}__updateSymbolAccessSubscription(unsubscribeOnly=!1){if(TCHMI_DESIGNER)return;if(null!==this.__symbolAccessSubscriptionId&&(TcHmi.Server.unsubscribeEx(this.__symbolAccessSubscriptionId,null),this.__symbolAccessSubscriptionId=null),unsubscribeOnly||!this.__isAttached||!this.__serverDomain)return;const writeValuePropertyMap={},commands=Object.keys(this.__symbolAccess).map(symbolName=>{const writeValue=tchmi_format_string(symbolName,this.__serverDomain);return writeValuePropertyMap[writeValue]=symbolName,{symbol:"GetSymbolAccess",writeValue,commandOptions:["SendWriteValue","SendErrorMessage"]}});this.__symbolAccessSubscriptionId=TcHmi.Server.subscribeEx(commands,TcHmi.Config.get().tcHmiServer.websocketIntervalTime,{parallel:!0},data=>{if(data.error===TcHmi.Errors.NONE)if(data.response)if(data.response.error)TcHmi.Log.Controls.error(this,TcHmiRecipeEdit.#tchmiFQN,{Symbol:"GetSymbolAccess"},TcHmi.Log.buildMessage(data.response.error));else if(data.response.commands){for(const command of data.response.commands)command.error?TcHmi.Log.Controls.error(this,TcHmiRecipeEdit.#tchmiFQN,{Symbol:"GetSymbolAccess"},TcHmi.Log.buildMessage(command.error)):void 0!==command.readValue?command.writeValue?this.__symbolAccess[writeValuePropertyMap[command.writeValue]]=command.readValue:TcHmi.Log.Controls.error(this,TcHmiRecipeEdit.#tchmiFQN,{Symbol:"GetSymbolAccess"},TcHmi.Log.buildMessage({code:TcHmi.Errors.E_SERVER_WRITEVALUE_MISSING,message:TcHmi.Errors[TcHmi.Errors.E_SERVER_WRITEVALUE_MISSING],reason:`Missing writeValue in response from server with id: '${data.response.id}'.`,domain:this.__type})):TcHmi.Log.Controls.error(this,TcHmiRecipeEdit.#tchmiFQN,{Symbol:"GetSymbolAccess"},TcHmi.Log.buildMessage({code:TcHmi.Errors.E_SERVER_READVALUE_MISSING,message:TcHmi.Errors[TcHmi.Errors.E_SERVER_READVALUE_MISSING],reason:`Missing readValue in response from server with id: '${data.response.id}'.`,domain:this.__type}));this.__symbolAccess["{0}.Config"]===TcHmi.Server.ACCESS.NONE&&TcHmi.Log.Controls.error(this,TcHmiRecipeEdit.#tchmiFQN,{Symbol:"GetSymbolAccess"},`The TcHmiRecipeEdit control needs at least read access to the ${this.__serverDomain}.Config symbol to be able to display recipes.`),this.__symbolAccess["{0}.GetActiveRecipes"]<TcHmi.Server.ACCESS.WRITE&&TcHmi.Log.Controls.warn(this,TcHmiRecipeEdit.#tchmiFQN,{Symbol:"GetSymbolAccess"},`Without write access access to the ${this.__serverDomain}.GetActiveRecipes symbol the control cannot show recipe activation status.`),this.__updateButtonAccess(),this.__updateRecipeListWatch(null,!!(this.__symbolAccess["{0}.Config"]&TcHmi.Server.ACCESS.READ)),this.__updateActiveRecipesSubscription(null,this.__symbolAccess["{0}.GetActiveRecipes"]>=TcHmi.Server.ACCESS.WRITE,null)}else TcHmi.Log.Controls.error(this,TcHmiRecipeEdit.#tchmiFQN,{Symbol:"GetSymbolAccess"},TcHmi.Log.buildMessage({code:TcHmi.Errors.E_SERVER_COMMANDS_MISSING,message:TcHmi.Errors[TcHmi.Errors.E_SERVER_COMMANDS_MISSING],reason:`Missing commands in response from server with id: '${data.response.id}'.`,domain:this.__type}));else TcHmi.Log.Controls.error(this,TcHmiRecipeEdit.#tchmiFQN,{Symbol:"GetSymbolAccess"},TcHmi.Log.buildMessage({code:TcHmi.Errors.E_SERVER_RESPONSE_MISSING,message:TcHmi.Errors[TcHmi.Errors.E_SERVER_RESPONSE_MISSING],reason:"Missing response from server.",domain:this.__type}));else TcHmi.Log.Controls.error(this,TcHmiRecipeEdit.#tchmiFQN,{Symbol:"GetSymbolAccess"},TcHmi.Log.buildMessage(data.details))})}}})();TcHmi.Controls.registerEx("TcHmiRecipeEdit","TcHmi.Controls.Beckhoff",TcHmiRecipeEdit,{injectInGlobalObject:!0});export{TcHmiRecipeEdit as Control};