@node-projects/web-component-designer-visualization-addons 0.1.140 → 0.1.142

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -33,7 +33,7 @@ export class BlocklyScriptEditor extends BaseCustomWebComponentConstructorAppend
33
33
  //@ts-ignore
34
34
  const theme = Blockly.Theme.defineTheme(themename, {
35
35
  //@ts-ignore
36
- 'base': Blockly.Themes.Classic,
36
+ 'base': Blockly.Themes.Zelos,
37
37
  'blockStyles': {
38
38
  "hat_blocks": {
39
39
  "colourPrimary": "#4a148c"
@@ -2,6 +2,9 @@ import { BaseCustomWebComponentConstructorAppend } from "@node-projects/base-cus
2
2
  import { IContextMenuItem, IDesignItem, IEvent, InstanceServiceContainer } from "@node-projects/web-component-designer";
3
3
  import { VisualizationShell } from "../interfaces/VisualizationShell.js";
4
4
  import { VisualizationHandler } from "../interfaces/VisualizationHandler.js";
5
+ type eventWithDesignItem = IEvent & {
6
+ designItem: IDesignItem;
7
+ };
5
8
  type scriptType = 'jsdirect' | 'js' | 'script' | 'blockly' | 'none' | 'empty';
6
9
  export declare class EventAssignment extends BaseCustomWebComponentConstructorAppend {
7
10
  static style: CSSStyleSheet;
@@ -13,39 +16,43 @@ export declare class EventAssignment extends BaseCustomWebComponentConstructorAp
13
16
  script: string;
14
17
  empty: string;
15
18
  };
16
- static readonly is = "node-projects-visualization-event-assignment";
19
+ static readonly is: string;
17
20
  constructor();
18
21
  ready(): void;
19
22
  private _blocklyToolbox;
20
- private _instanceServiceContainer;
23
+ protected _instanceServiceContainer: InstanceServiceContainer;
21
24
  private _selectionChangedHandler;
22
25
  private _selectedItems;
23
26
  private _visualizationHandler;
24
27
  private _visualizationShell;
25
28
  private _scriptCommandsTypeInfo;
26
29
  private _propertiesTypeInfo;
27
- events: IEvent[];
30
+ events: (IEvent & {
31
+ designItem: IDesignItem;
32
+ })[];
28
33
  initialize(visualizationHandler: VisualizationHandler, visualizationShell: VisualizationShell, scriptCommandsTypeInfo: any, propertiesTypeInfo: any, blocklyToolbox: any): void;
29
34
  set instanceServiceContainer(value: InstanceServiceContainer);
30
- protected _createControlsForScript(eventItem: IEvent): any;
35
+ protected _createControlsForScript(eventItem: eventWithDesignItem): any;
31
36
  protected _getScriptName(eventItem: IEvent): any;
32
37
  protected _changeScriptName(e: KeyboardEvent, eventItem: IEvent): Promise<void>;
33
38
  protected _getRelativeSignalsPath(eventItem: IEvent): any;
34
39
  protected _changeRelativeSignalsPath(e: KeyboardEvent, eventItem: IEvent): Promise<void>;
35
40
  protected _hasParameters(eventItem: IEvent): boolean;
36
- protected _getScriptTypeColor(eventItem: IEvent): any;
37
- protected _getScriptType(eventItem: IEvent): scriptType;
41
+ protected _getScriptTypeColor(eventItem: eventWithDesignItem): any;
42
+ protected _getScriptType(eventItem: eventWithDesignItem): scriptType;
38
43
  protected _getEventMethodname(eventItem: IEvent): string;
39
44
  protected _inputMthName(event: InputEvent, eventItem: IEvent): void;
40
- protected _ctxMenu(e: MouseEvent, eventItem: IEvent): void;
45
+ protected _ctxMenu(e: MouseEvent, eventItem: eventWithDesignItem): void;
41
46
  protected _addEvent(e: KeyboardEvent): Promise<void>;
42
- protected _createAssignScriptContextMenu(event: MouseEvent, eventItem: IEvent): IContextMenuItem[];
43
- protected _showContextMenuAssignScript(event: MouseEvent, eventItem: IEvent, isCtxMenu: boolean): Promise<void>;
44
- protected _editParameter(e: MouseEvent, eventItem: IEvent): Promise<void>;
45
- protected _editBlockly(e: MouseEvent, eventItem: IEvent): Promise<void>;
46
- protected _editJavascript(e: MouseEvent, eventItem: IEvent): Promise<void>;
47
- protected _editSimpleScript(e: MouseEvent, eventItem: IEvent): Promise<void>;
48
- _editEvent(evtType: scriptType, e: MouseEvent, eventItem: IEvent): Promise<void>;
47
+ protected _createAssignScriptContextMenu(event: MouseEvent, eventItem: eventWithDesignItem): IContextMenuItem[];
48
+ protected _showContextMenuAssignScript(event: MouseEvent, eventItem: eventWithDesignItem, isCtxMenu: boolean): Promise<void>;
49
+ protected _editParameter(e: MouseEvent, eventItem: IEvent & {
50
+ designItem: IDesignItem;
51
+ }): Promise<void>;
52
+ protected _editBlockly(e: MouseEvent, eventItem: eventWithDesignItem): Promise<void>;
53
+ protected _editJavascript(e: MouseEvent, eventItem: eventWithDesignItem): Promise<void>;
54
+ protected _editSimpleScript(e: MouseEvent, eventItem: eventWithDesignItem): Promise<void>;
55
+ _editEvent(evtType: scriptType, e: MouseEvent, eventItem: eventWithDesignItem): Promise<void>;
49
56
  refresh(): void;
50
57
  get selectedItems(): IDesignItem[];
51
58
  set selectedItems(items: IDesignItem[]);
@@ -176,22 +176,20 @@ export class EventAssignment extends BaseCustomWebComponentConstructorAppend {
176
176
  return color ?? 'white';
177
177
  }
178
178
  _getScriptType(eventItem) {
179
- if (this.selectedItems && this.selectedItems.length) {
180
- if (this.selectedItems[0].hasAttribute('@' + eventItem.name)) {
181
- const val = this.selectedItems[0].getAttribute('@' + eventItem.name);
182
- if (val.startsWith('{')) {
183
- const parsed = JSON.parse(val);
184
- if ('blocks' in parsed)
185
- return 'blockly';
186
- if ('commands' in parsed)
187
- return 'script';
188
- return 'js';
189
- }
190
- else if (val == '')
191
- return 'empty';
192
- else
193
- return 'js';
179
+ if (eventItem.designItem.hasAttribute('@' + eventItem.name)) {
180
+ const val = eventItem.designItem.getAttribute('@' + eventItem.name);
181
+ if (val.startsWith('{')) {
182
+ const parsed = JSON.parse(val);
183
+ if ('blocks' in parsed)
184
+ return 'blockly';
185
+ if ('commands' in parsed)
186
+ return 'script';
187
+ return 'js';
194
188
  }
189
+ else if (val == '')
190
+ return 'empty';
191
+ else
192
+ return 'js';
195
193
  }
196
194
  return 'none';
197
195
  }
@@ -299,11 +297,10 @@ export class EventAssignment extends BaseCustomWebComponentConstructorAppend {
299
297
  }
300
298
  }
301
299
  async _editParameter(e, eventItem) {
302
- let selectedItem = this.selectedItems[0];
303
300
  const edt = new ParameterEditor();
304
301
  let existingParameter = {};
305
- edt.title = "ParameterEditor for '" + eventItem.name + "' of '" + selectedItem.name + "'";
306
- let data = selectedItem.getAttribute('@' + eventItem.name);
302
+ edt.title = "ParameterEditor for '" + eventItem.name + "' of '" + eventItem.designItem.name + "'";
303
+ let data = eventItem.designItem.getAttribute('@' + eventItem.name);
307
304
  if (data && data[0] == '{') {
308
305
  try {
309
306
  const parsed = JSON.parse(data);
@@ -326,15 +323,14 @@ export class EventAssignment extends BaseCustomWebComponentConstructorAppend {
326
323
  if (par == null)
327
324
  delete newObj.parameters;
328
325
  const newData = JSON.stringify(newObj);
329
- selectedItem.setAttribute('@' + eventItem.name, newData);
326
+ eventItem.designItem.setAttribute('@' + eventItem.name, newData);
330
327
  this._bindingsRefresh();
331
328
  }
332
329
  }
333
330
  async _editBlockly(e, eventItem) {
334
- let selectedItem = this.selectedItems[0];
335
331
  const edt = new BlocklyScriptEditor(this._blocklyToolbox);
336
- edt.title = "Blockly Script for '" + eventItem.name + "' of '" + selectedItem.name + "'";
337
- let data = selectedItem.getAttribute('@' + eventItem.name);
332
+ edt.title = "Blockly Script for '" + eventItem.name + "' of '" + eventItem.designItem.name + "'";
333
+ let data = eventItem.designItem.getAttribute('@' + eventItem.name);
338
334
  let parameters = null;
339
335
  let relativeSignalsPath = null;
340
336
  if (data) {
@@ -352,7 +348,7 @@ export class EventAssignment extends BaseCustomWebComponentConstructorAppend {
352
348
  if (relativeSignalsPath) {
353
349
  blockObj.relativeSignalsPath = relativeSignalsPath;
354
350
  }
355
- selectedItem.setAttribute('@' + eventItem.name, JSON.stringify(blockObj));
351
+ eventItem.designItem.setAttribute('@' + eventItem.name, JSON.stringify(blockObj));
356
352
  this._bindingsRefresh();
357
353
  }
358
354
  }
@@ -360,8 +356,7 @@ export class EventAssignment extends BaseCustomWebComponentConstructorAppend {
360
356
  // todo ?
361
357
  }
362
358
  async _editSimpleScript(e, eventItem) {
363
- let selectedItem = this.selectedItems[0];
364
- let scriptString = selectedItem.getAttribute('@' + eventItem.name);
359
+ let scriptString = eventItem.designItem.getAttribute('@' + eventItem.name);
365
360
  if (!scriptString || scriptString.startsWith('{')) {
366
361
  let script = { commands: [] };
367
362
  let parameters = null;
@@ -374,14 +369,14 @@ export class EventAssignment extends BaseCustomWebComponentConstructorAppend {
374
369
  relativeSignalsPath = script.relativeSignalsPath;
375
370
  }
376
371
  let sc = new SimpleScriptEditor();
377
- sc.serviceContainer = selectedItem.serviceContainer;
378
- sc.instanceServiceContainer = selectedItem.instanceServiceContainer;
372
+ sc.serviceContainer = eventItem.designItem.serviceContainer;
373
+ sc.instanceServiceContainer = eventItem.designItem.instanceServiceContainer;
379
374
  sc.scriptCommandsTypeInfo = this._scriptCommandsTypeInfo;
380
375
  sc.propertiesTypeInfo = this._propertiesTypeInfo;
381
376
  sc.visualizationShell = this._visualizationShell;
382
377
  sc.visualizationHandler = this._visualizationHandler;
383
378
  sc.loadScript(script);
384
- sc.title = "Script '" + eventItem.name + "' on " + selectedItem.name;
379
+ sc.title = "Script '" + eventItem.name + "' on " + eventItem.designItem.name;
385
380
  let res = await this._visualizationShell.openConfirmation(sc, { x: 100, y: 100, width: 600, height: 500 });
386
381
  if (res) {
387
382
  let scriptCommands = sc.getScriptCommands();
@@ -396,7 +391,7 @@ export class EventAssignment extends BaseCustomWebComponentConstructorAppend {
396
391
  sc.relativeSignalsPath = relativeSignalsPath;
397
392
  }
398
393
  let json = JSON.stringify(sc);
399
- selectedItem.setAttribute('@' + eventItem.name, json);
394
+ eventItem.designItem.setAttribute('@' + eventItem.name, json);
400
395
  this._bindingsRefresh();
401
396
  }
402
397
  }
@@ -415,7 +410,7 @@ export class EventAssignment extends BaseCustomWebComponentConstructorAppend {
415
410
  }
416
411
  refresh() {
417
412
  if (this._selectedItems != null && this._selectedItems.length) {
418
- this.events = this._selectedItems[0].serviceContainer.getLastServiceWhere('eventsService', x => x.isHandledElementFromEventsService(this._selectedItems[0])).getPossibleEvents(this._selectedItems[0]);
413
+ this.events = this._selectedItems[0].serviceContainer.getLastServiceWhere('eventsService', x => x.isHandledElementFromEventsService(this._selectedItems[0])).getPossibleEvents(this._selectedItems[0]).map(x => ({ ...x, designItem: this._selectedItems[0] }));
419
414
  }
420
415
  else {
421
416
  this.events = [];
@@ -38,7 +38,7 @@ export declare class BindingsHelper {
38
38
  serializeBinding(element: Element, targetName: string, binding: VisualizationBinding): [name: string, value: string];
39
39
  getBindingAttributeName(element: Element, propertyName: string, propertyTarget: BindingTarget): string;
40
40
  getBindings(element: Element): Generator<namedBinding, void, unknown>;
41
- applyAllBindings(rootElement: ParentNode, relativeSignalPath: string, root: HTMLElement, specialValueHandler?: SpecialValueHandler): (() => void)[];
41
+ applyAllBindings(rootElement: ParentNode, relativeSignalPath: string, root: HTMLElement, specialValueHandler?: SpecialValueHandler, skipChildrenFor?: (element: Element) => boolean): (() => void)[];
42
42
  parseCssBindings(sheet: string, element: Element, relativeSignalPath: string, root: HTMLElement): Promise<[stylesheet: CSSStyleSheet, unsub: (() => void)[]]>;
43
43
  parseCssBinding(value: string, element: Element, relativeSignalPath: string, root: HTMLElement, specialValueHandler?: SpecialValueHandler): [name: string, unsub: (() => void)[]];
44
44
  /**
@@ -488,7 +488,7 @@ export class BindingsHelper {
488
488
  }
489
489
  }
490
490
  }
491
- applyAllBindings(rootElement, relativeSignalPath, root, specialValueHandler) {
491
+ applyAllBindings(rootElement, relativeSignalPath, root, specialValueHandler, skipChildrenFor) {
492
492
  let retVal = [];
493
493
  const tw = document.createTreeWalker(rootElement, NodeFilter.SHOW_ELEMENT);
494
494
  let e;
@@ -514,6 +514,12 @@ export class BindingsHelper {
514
514
  console.warn("error applying binding", e, b, err);
515
515
  }
516
516
  }
517
+ if (skipChildrenFor) {
518
+ if (skipChildrenFor(e)) {
519
+ e = tw.nextSibling();
520
+ continue;
521
+ }
522
+ }
517
523
  }
518
524
  return retVal;
519
525
  }
package/dist/index-min.js CHANGED
@@ -1,12 +1,12 @@
1
- Blockly.Blocks.console={init:function(){this.appendDummyInput().appendField("console").appendField(new Blockly.FieldDropdown([["debug","DEBUG"],["error","ERROR"],["info","INFO"],["log","LOG"],["warn","WARN"]]),"LEVEL"),this.appendValueInput("VALUE").setCheck(null).appendField("value"),this.setInputsInline(!0),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(230)}};Blockly.JavaScript.forBlock.console=function(r,t){var s=r.getFieldValue("LEVEL");let e=Blockly.JavaScript.valueToCode(r,"VALUE",Blockly.JavaScript.ORDER_ATOMIC);return`console['${s.toLowerCase()}'](${e});
2
- `};Blockly.Blocks.debugger={init:function(){this.appendDummyInput().appendField("debugger"),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(230)}};Blockly.JavaScript.forBlock.debugger=function(r){return`debugger;
3
- `};Blockly.Blocks.delay={init:function(){this.appendValueInput("DELAY").setCheck("Number").appendField("delay"),this.setInputsInline(!0),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(230)}};Blockly.JavaScript.forBlock.delay=function(r){return"await delay("+Blockly.JavaScript.valueToCode(r,"DELAY",Blockly.JavaScript.ORDER_ATOMIC)+`);
4
- `};Blockly.Blocks.get_parameter={init:function(){this.appendValueInput("NAME").setCheck("String").appendField("get_parameter"),this.setInputsInline(!0),this.setOutput(!0,null),this.setColour(230)}};Blockly.JavaScript.forBlock.get_parameter=function(r,t){return[`context.parameters[${Blockly.JavaScript.valueToCode(r,"NAME",Blockly.JavaScript.ORDER_ATOMIC)}]`,Blockly.JavaScript.ORDER_NONE]};Blockly.Blocks.get_state={init:function(){this.appendValueInput("OID").setCheck("String").appendField("get_state"),this.setInputsInline(!0),this.setOutput(!0,null),this.setColour(230)}};Blockly.JavaScript.forBlock.get_state=function(r,t){let s=Blockly.JavaScript.valueToCode(r,"OID",Blockly.JavaScript.ORDER_ATOMIC);return[`(await visualizationHandler.getState((${s}[0] === '.' ? relativeSignalsPath : '') + ${s})).val`,Blockly.JavaScript.ORDER_NONE]};Blockly.Blocks.get_sub_property={init:function(){this.appendDummyInput().appendField("getSubProperty"),this.appendValueInput("OBJECT").setCheck("Object").appendField("object"),this.appendValueInput("PROPERTYPATH").setCheck("String").appendField("propertypath"),this.setInputsInline(!0),this.setOutput(!0,null),this.setColour(230)}};Blockly.JavaScript.forBlock.get_sub_property=function(r,t){let s=Blockly.JavaScript.valueToCode(r,"OBJECT",Blockly.JavaScript.ORDER_ATOMIC),e=Blockly.JavaScript.valueToCode(r,"PROPERTYPATH",Blockly.JavaScript.ORDER_ATOMIC);return[`extractPart(${s}, ${e})`,Blockly.JavaScript.ORDER_NONE]};Blockly.Blocks.open_screen={init:function(){this.appendDummyInput().appendField("open screen"),this.appendValueInput("SCREEN").setCheck("String").appendField("screen"),this.appendValueInput("RELATIVESIGNALSPATH").setCheck("String").appendField("relativeSignalsPath"),this.appendValueInput("NOHISTORY").setCheck("Boolean").appendField("noHistory"),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(230)}};Blockly.JavaScript.forBlock.open_screen=function(r){let t=Blockly.JavaScript.valueToCode(r,"SCREEN",Blockly.JavaScript.ORDER_ATOMIC),s=Blockly.JavaScript.valueToCode(r,"RELATIVESIGNALSPATH",Blockly.JavaScript.ORDER_ATOMIC),e=Blockly.JavaScript.valueToCode(r,"NOHISTORY",Blockly.JavaScript.ORDER_ATOMIC);return`RUNTIME.openScreen({screen: ${t}, relativeSignalsPath: ${s}, noHistory: ${e}})`};Blockly.Blocks.query_selector={init:function(){this.appendDummyInput().appendField("querySelector").appendField(new Blockly.FieldDropdown([["currentScreen","CURRENTSCREEN"],["parentScreen","PARENTSCREEN"]]),"SOURCE"),this.appendValueInput("SELECTOR").setCheck("String").appendField("selector"),this.setInputsInline(!0),this.setOutput(!0,"Element"),this.setColour(230)}};Blockly.JavaScript.forBlock.query_selector=function(r,t){var s=r.getFieldValue("SOURCE");let e=Blockly.JavaScript.valueToCode(r,"SELECTOR",Blockly.JavaScript.ORDER_ATOMIC),i;return s==="CURRENTSCREEN"?i=`shadowRoot.querySelector(${e})`:s==="PARENTSCREEN"&&(i=`shadowRoot.host.getRootNode().querySelector(${e})`),[i,Blockly.JavaScript.ORDER_NONE]};Blockly.Blocks.query_selector_all={init:function(){this.appendDummyInput().appendField("querySelectorAll").appendField(new Blockly.FieldDropdown([["currentScreen","CURRENTSCREEN"],["parentScreen","PARENTSCREEN"]]),"SOURCE"),this.appendValueInput("SELECTOR").setCheck("String").appendField("selector"),this.setInputsInline(!0),this.setOutput(!0,"Array"),this.setColour(230)}};Blockly.JavaScript.forBlock.query_selector_all=function(r,t){var s=r.getFieldValue("SOURCE");let e=Blockly.JavaScript.valueToCode(r,"SELECTOR",Blockly.JavaScript.ORDER_ATOMIC),i;return s==="CURRENTSCREEN"?i=`shadowRoot.querySelectorall(${e})`:s==="PARENTSCREEN"&&(i=`shadowRoot.querySelectorall(${e})`),[i,Blockly.JavaScript.ORDER_NONE]};Blockly.Blocks.set_element={init:function(){this.appendDummyInput().appendField("setElement").appendField(new Blockly.FieldDropdown([["property","PROPERTY"],["attribute","ATTRIBUTE"],["style","STYLE"]]),"TARGET"),this.appendValueInput("ELEMENT").setCheck("Element").appendField("element"),this.appendValueInput("NAME").setCheck("String").appendField("name"),this.appendValueInput("VALUE").setCheck(null).appendField("value"),this.setInputsInline(!0),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(230)}};Blockly.JavaScript.forBlock.set_element=function(r){var t=r.getFieldValue("TARGET");let s=Blockly.JavaScript.valueToCode(r,"ELEMENT",Blockly.JavaScript.ORDER_ATOMIC),e=Blockly.JavaScript.valueToCode(r,"NAME",Blockly.JavaScript.ORDER_ATOMIC),i=Blockly.JavaScript.valueToCode(r,"VALUE",Blockly.JavaScript.ORDER_ATOMIC),n="";return t==="PROPERTY"?n+=s+"["+e+"] = "+i+`;
5
- `:t==="ATTRIBUTE"?n+=s+".setAttribute("+e+", "+i+`);
6
- `:t==="STYLE"&&(n+=s+".style["+e+"] = "+i+`;
7
- `),n};Blockly.Blocks.set_state={init:function(){this.appendValueInput("OID").setCheck("String").appendField("set_state"),this.appendValueInput("VALUE").setCheck(null).appendField("with"),this.setInputsInline(!0),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(230)}};Blockly.JavaScript.forBlock.set_state=function(r){let t=Blockly.JavaScript.valueToCode(r,"OID",Blockly.JavaScript.ORDER_ATOMIC),s=Blockly.JavaScript.valueToCode(r,"VALUE",Blockly.JavaScript.ORDER_ATOMIC);return`await visualizationHandler.setState((${t}[0] === '.' ? relativeSignalsPath : '') + ${t}, ${s});
8
- `};Blockly.defineBlocksWithJsonArray([{type:"start_event",message0:"Event %1",nextStatement:null,style:"hat_blocks",args0:[{type:"field_variable",name:"EVENTVAR",variable:"event"}]}]);Blockly.JavaScript.forBlock.start_event=function(r){return Blockly.JavaScript.getVariableName(r.getField("EVENTVAR").variable.name)+` = eventData;
9
- `};var de=`function extractPart(obj, propertyPath) {
1
+ Blockly.Blocks.console={init:function(){this.appendDummyInput().appendField("console").appendField(new Blockly.FieldDropdown([["debug","DEBUG"],["error","ERROR"],["info","INFO"],["log","LOG"],["warn","WARN"]]),"LEVEL"),this.appendValueInput("VALUE").setCheck(null).appendField("value"),this.setInputsInline(!0),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(230)}};Blockly.JavaScript.forBlock.console=function(n,t){var s=n.getFieldValue("LEVEL");let e=Blockly.JavaScript.valueToCode(n,"VALUE",Blockly.JavaScript.ORDER_ATOMIC);return`console['${s.toLowerCase()}'](${e});
2
+ `};Blockly.Blocks.debugger={init:function(){this.appendDummyInput().appendField("debugger"),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(230)}};Blockly.JavaScript.forBlock.debugger=function(n){return`debugger;
3
+ `};Blockly.Blocks.delay={init:function(){this.appendValueInput("DELAY").setCheck("Number").appendField("delay"),this.setInputsInline(!0),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(230)}};Blockly.JavaScript.forBlock.delay=function(n){return"await delay("+Blockly.JavaScript.valueToCode(n,"DELAY",Blockly.JavaScript.ORDER_ATOMIC)+`);
4
+ `};Blockly.Blocks.get_parameter={init:function(){this.appendValueInput("NAME").setCheck("String").appendField("get_parameter"),this.setInputsInline(!0),this.setOutput(!0,null),this.setColour(230)}};Blockly.JavaScript.forBlock.get_parameter=function(n,t){return[`context.parameters[${Blockly.JavaScript.valueToCode(n,"NAME",Blockly.JavaScript.ORDER_ATOMIC)}]`,Blockly.JavaScript.ORDER_NONE]};Blockly.Blocks.get_state={init:function(){this.appendValueInput("OID").setCheck("String").appendField("get_state"),this.setInputsInline(!0),this.setOutput(!0,null),this.setColour(230)}};Blockly.JavaScript.forBlock.get_state=function(n,t){let s=Blockly.JavaScript.valueToCode(n,"OID",Blockly.JavaScript.ORDER_ATOMIC);return[`(await visualizationHandler.getState((${s}[0] === '.' ? relativeSignalsPath : '') + ${s})).val`,Blockly.JavaScript.ORDER_NONE]};Blockly.Blocks.get_sub_property={init:function(){this.appendDummyInput().appendField("getSubProperty"),this.appendValueInput("OBJECT").setCheck("Object").appendField("object"),this.appendValueInput("PROPERTYPATH").setCheck("String").appendField("propertypath"),this.setInputsInline(!0),this.setOutput(!0,null),this.setColour(230)}};Blockly.JavaScript.forBlock.get_sub_property=function(n,t){let s=Blockly.JavaScript.valueToCode(n,"OBJECT",Blockly.JavaScript.ORDER_ATOMIC),e=Blockly.JavaScript.valueToCode(n,"PROPERTYPATH",Blockly.JavaScript.ORDER_ATOMIC);return[`extractPart(${s}, ${e})`,Blockly.JavaScript.ORDER_NONE]};Blockly.Blocks.open_screen={init:function(){this.appendDummyInput().appendField("open screen"),this.appendValueInput("SCREEN").setCheck("String").appendField("screen"),this.appendValueInput("RELATIVESIGNALSPATH").setCheck("String").appendField("relativeSignalsPath"),this.appendValueInput("NOHISTORY").setCheck("Boolean").appendField("noHistory"),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(230)}};Blockly.JavaScript.forBlock.open_screen=function(n){let t=Blockly.JavaScript.valueToCode(n,"SCREEN",Blockly.JavaScript.ORDER_ATOMIC),s=Blockly.JavaScript.valueToCode(n,"RELATIVESIGNALSPATH",Blockly.JavaScript.ORDER_ATOMIC),e=Blockly.JavaScript.valueToCode(n,"NOHISTORY",Blockly.JavaScript.ORDER_ATOMIC);return`RUNTIME.openScreen({screen: ${t}, relativeSignalsPath: ${s}, noHistory: ${e}})`};Blockly.Blocks.query_selector={init:function(){this.appendDummyInput().appendField("querySelector").appendField(new Blockly.FieldDropdown([["currentScreen","CURRENTSCREEN"],["parentScreen","PARENTSCREEN"]]),"SOURCE"),this.appendValueInput("SELECTOR").setCheck("String").appendField("selector"),this.setInputsInline(!0),this.setOutput(!0,"Element"),this.setColour(230)}};Blockly.JavaScript.forBlock.query_selector=function(n,t){var s=n.getFieldValue("SOURCE");let e=Blockly.JavaScript.valueToCode(n,"SELECTOR",Blockly.JavaScript.ORDER_ATOMIC),i;return s==="CURRENTSCREEN"?i=`shadowRoot.querySelector(${e})`:s==="PARENTSCREEN"&&(i=`shadowRoot.host.getRootNode().querySelector(${e})`),[i,Blockly.JavaScript.ORDER_NONE]};Blockly.Blocks.query_selector_all={init:function(){this.appendDummyInput().appendField("querySelectorAll").appendField(new Blockly.FieldDropdown([["currentScreen","CURRENTSCREEN"],["parentScreen","PARENTSCREEN"]]),"SOURCE"),this.appendValueInput("SELECTOR").setCheck("String").appendField("selector"),this.setInputsInline(!0),this.setOutput(!0,"Array"),this.setColour(230)}};Blockly.JavaScript.forBlock.query_selector_all=function(n,t){var s=n.getFieldValue("SOURCE");let e=Blockly.JavaScript.valueToCode(n,"SELECTOR",Blockly.JavaScript.ORDER_ATOMIC),i;return s==="CURRENTSCREEN"?i=`shadowRoot.querySelectorall(${e})`:s==="PARENTSCREEN"&&(i=`shadowRoot.querySelectorall(${e})`),[i,Blockly.JavaScript.ORDER_NONE]};Blockly.Blocks.set_element={init:function(){this.appendDummyInput().appendField("setElement").appendField(new Blockly.FieldDropdown([["property","PROPERTY"],["attribute","ATTRIBUTE"],["style","STYLE"]]),"TARGET"),this.appendValueInput("ELEMENT").setCheck("Element").appendField("element"),this.appendValueInput("NAME").setCheck("String").appendField("name"),this.appendValueInput("VALUE").setCheck(null).appendField("value"),this.setInputsInline(!0),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(230)}};Blockly.JavaScript.forBlock.set_element=function(n){var t=n.getFieldValue("TARGET");let s=Blockly.JavaScript.valueToCode(n,"ELEMENT",Blockly.JavaScript.ORDER_ATOMIC),e=Blockly.JavaScript.valueToCode(n,"NAME",Blockly.JavaScript.ORDER_ATOMIC),i=Blockly.JavaScript.valueToCode(n,"VALUE",Blockly.JavaScript.ORDER_ATOMIC),r="";return t==="PROPERTY"?r+=s+"["+e+"] = "+i+`;
5
+ `:t==="ATTRIBUTE"?r+=s+".setAttribute("+e+", "+i+`);
6
+ `:t==="STYLE"&&(r+=s+".style["+e+"] = "+i+`;
7
+ `),r};Blockly.Blocks.set_state={init:function(){this.appendValueInput("OID").setCheck("String").appendField("set_state"),this.appendValueInput("VALUE").setCheck(null).appendField("with"),this.setInputsInline(!0),this.setPreviousStatement(!0,null),this.setNextStatement(!0,null),this.setColour(230)}};Blockly.JavaScript.forBlock.set_state=function(n){let t=Blockly.JavaScript.valueToCode(n,"OID",Blockly.JavaScript.ORDER_ATOMIC),s=Blockly.JavaScript.valueToCode(n,"VALUE",Blockly.JavaScript.ORDER_ATOMIC);return`await visualizationHandler.setState((${t}[0] === '.' ? relativeSignalsPath : '') + ${t}, ${s});
8
+ `};Blockly.defineBlocksWithJsonArray([{type:"start_event",message0:"Event %1",nextStatement:null,style:"hat_blocks",args0:[{type:"field_variable",name:"EVENTVAR",variable:"event"}]}]);Blockly.JavaScript.forBlock.start_event=function(n){return Blockly.JavaScript.getVariableName(n.getField("EVENTVAR").variable.name)+` = eventData;
9
+ `};var me=`function extractPart(obj, propertyPath) {
10
10
  let retVal = obj;
11
11
  for (let p of propertyPath.split('.')) {
12
12
  retVal = retVal?.[p];
@@ -21,16 +21,16 @@ function delay(ms) {
21
21
  }
22
22
 
23
23
  export async function run(eventData, shadowRoot, parameters, relativeSignalsPath, visualizationHandler, context) {
24
- `,he="}";async function X(r){let t=new Blockly.Workspace;Blockly.serialization.workspaces.load(r,t),Blockly.JavaScript.addReservedWords("eventData"),Blockly.JavaScript.addReservedWords("shadowRoot"),Blockly.JavaScript.addReservedWords("extractPart"),Blockly.JavaScript.addReservedWords("parameters"),Blockly.JavaScript.addReservedWords("relativeSignalsPath"),Blockly.JavaScript.addReservedWords("delay"),Blockly.JavaScript.addReservedWords("visualizationHandler"),Blockly.JavaScript.addReservedWords("context");let s=Blockly.JavaScript.workspaceToCode(t);return(await import(URL.createObjectURL(new Blob([de+s+he],{type:"application/javascript"})))).run}import{BaseCustomWebComponentConstructorAppend as me,html as ge,css as ye}from"@node-projects/base-custom-webcomponent";var C=class r extends me{static template=ge`
24
+ `,ge="}";async function G(n){let t=new Blockly.Workspace;Blockly.serialization.workspaces.load(n,t),Blockly.JavaScript.addReservedWords("eventData"),Blockly.JavaScript.addReservedWords("shadowRoot"),Blockly.JavaScript.addReservedWords("extractPart"),Blockly.JavaScript.addReservedWords("parameters"),Blockly.JavaScript.addReservedWords("relativeSignalsPath"),Blockly.JavaScript.addReservedWords("delay"),Blockly.JavaScript.addReservedWords("visualizationHandler"),Blockly.JavaScript.addReservedWords("context");let s=Blockly.JavaScript.workspaceToCode(t);return(await import(URL.createObjectURL(new Blob([me+s+ge],{type:"application/javascript"})))).run}import{BaseCustomWebComponentConstructorAppend as ye,html as fe,css as ve}from"@node-projects/base-custom-webcomponent";var C=class n extends ye{static template=fe`
25
25
  <div id="blocklyDiv" style="position: absolute; width: 100%; height: 100%;"></div>
26
- `;static style=ye`
26
+ `;static style=ve`
27
27
  :host {
28
28
  box-sizing: border-box;
29
29
  position: absolute;
30
30
  height: 100%;
31
31
  width: 100%;
32
32
  display: block;
33
- }`;static is="node-projects-blockly-script-editor";blocklyDiv;workspace;static blocklyStyle1;static blocklyStyle2;resizeObserver;_toolbox;constructor(t){super(),super._restoreCachedInititalValues(),this._toolbox=t,this.blocklyDiv=this._getDomElement("blocklyDiv"),this._assignEvents(),this.createBlockly()}createBlockly(){let t="zelos",s="webui",e=Blockly.Theme.defineTheme(s,{base:Blockly.Themes.Classic,blockStyles:{hat_blocks:{colourPrimary:"#4a148c"}},categoryStyles:{start_category:{colour:"#4a148c"},system_category:{colour:"#01579b"}}});this.workspace=Blockly.inject(this.blocklyDiv,{theme:e,toolbox:this._toolbox,renderer:t,trashcan:!0,zoom:{controls:!0,wheel:!1,startScale:.7,maxScale:3,minScale:.3,scaleSpeed:1.2,pinch:!1},move:{scrollbars:{horizontal:!0,vertical:!0},drag:!0,wheel:!0},maxInstances:{start_event:1}}),r.blocklyStyle1||(r.blocklyStyle1=new CSSStyleSheet,r.blocklyStyle1.replaceSync(document.getElementById("blockly-renderer-style-"+t+"-"+s).innerText),r.blocklyStyle2=new CSSStyleSheet,r.blocklyStyle2.replaceSync(document.getElementById("blockly-common-style").innerText)),this.shadowRoot.adoptedStyleSheets=[r.blocklyStyle1,r.blocklyStyle2,r.style],new ZoomToFitControl(this.workspace).init()}ready(){Blockly.svgResize(this.workspace),this.resizeObserver=new ResizeObserver(t=>{Blockly.svgResize(this.workspace)}),this.resizeObserver.observe(this)}save(){return Blockly.serialization.workspaces.save(this.workspace)}load(t){Blockly.serialization.workspaces.load(t,this.workspace)}};customElements.define(C.is,C);import{BaseCustomWebComponentConstructorAppend as xe,html as we,css as ke}from"@node-projects/base-custom-webcomponent";import{BindingMode as Se,BindingTarget as G}from"@node-projects/web-component-designer";import{BaseCustomWebComponentConstructorAppend as fe,html as ve,css as be}from"@node-projects/base-custom-webcomponent";var E=class extends fe{static template=ve`
33
+ }`;static is="node-projects-blockly-script-editor";blocklyDiv;workspace;static blocklyStyle1;static blocklyStyle2;resizeObserver;_toolbox;constructor(t){super(),super._restoreCachedInititalValues(),this._toolbox=t,this.blocklyDiv=this._getDomElement("blocklyDiv"),this._assignEvents(),this.createBlockly()}createBlockly(){let t="zelos",s="webui",e=Blockly.Theme.defineTheme(s,{base:Blockly.Themes.Zelos,blockStyles:{hat_blocks:{colourPrimary:"#4a148c"}},categoryStyles:{start_category:{colour:"#4a148c"},system_category:{colour:"#01579b"}}});this.workspace=Blockly.inject(this.blocklyDiv,{theme:e,toolbox:this._toolbox,renderer:t,trashcan:!0,zoom:{controls:!0,wheel:!1,startScale:.7,maxScale:3,minScale:.3,scaleSpeed:1.2,pinch:!1},move:{scrollbars:{horizontal:!0,vertical:!0},drag:!0,wheel:!0},maxInstances:{start_event:1}}),n.blocklyStyle1||(n.blocklyStyle1=new CSSStyleSheet,n.blocklyStyle1.replaceSync(document.getElementById("blockly-renderer-style-"+t+"-"+s).innerText),n.blocklyStyle2=new CSSStyleSheet,n.blocklyStyle2.replaceSync(document.getElementById("blockly-common-style").innerText)),this.shadowRoot.adoptedStyleSheets=[n.blocklyStyle1,n.blocklyStyle2,n.style],new ZoomToFitControl(this.workspace).init()}ready(){Blockly.svgResize(this.workspace),this.resizeObserver=new ResizeObserver(t=>{Blockly.svgResize(this.workspace)}),this.resizeObserver.observe(this)}save(){return Blockly.serialization.workspaces.save(this.workspace)}load(t){Blockly.serialization.workspaces.load(t,this.workspace)}};customElements.define(C.is,C);import{BaseCustomWebComponentConstructorAppend as ke,html as Se,css as _e}from"@node-projects/base-custom-webcomponent";import{BindingMode as Te,BindingTarget as $}from"@node-projects/web-component-designer";import{BaseCustomWebComponentConstructorAppend as be,html as xe,css as we}from"@node-projects/base-custom-webcomponent";var E=class extends be{static template=xe`
34
34
  <span style="position:absolute;left:30px;top:26px;">from</span>
35
35
  <span style="position:absolute;left:30px;top:77px;">count</span>
36
36
  <span style="position:absolute;left:30px;top:123px;">limit</span>
@@ -97,10 +97,10 @@ export async function run(eventData, shadowRoot, parameters, relativeSignalsPath
97
97
  <input css:visibility="[[this.historic.aggregate == 'quantile' ? 'visible' : 'collapse']]" value="{{this.historic.quantile}}" type="number" id="quantile" style="position:absolute;left:107px;top:325px;width:153px;">
98
98
  <span css:visibility="[[this.historic.aggregate == 'quantile' ? 'visible' : 'collapse']]" id="lblQuantile" style="position:absolute;left:30px;top:325px;">quantile</span>
99
99
  <span style="position:absolute;left:34px;top:417px;">instance</span>
100
- <input type="text" value="{{?this.historic.instance}}" style="position:absolute;left:104px;top:419px;width:155px;">`;static style=be`
100
+ <input type="text" value="{{?this.historic.instance}}" style="position:absolute;left:104px;top:419px;width:155px;">`;static style=we`
101
101
  :host {
102
102
  box-sizing: border-box;
103
- }`;static is="node-projects-visualization-bindings-editor-historic";historic;static properties={historic:Object};constructor(t){super(),this._restoreCachedInititalValues(),this.historic=t??{reloadInterval:2e3}}ready(){this._bindingsParse()}#e=!1;refresh(){this.#e||(this.#e=!0,this._bindingsRefresh(null,!0),this.#e=!1)}};customElements.define(E.is,E);var D=class extends xe{static template=we`
103
+ }`;static is="node-projects-visualization-bindings-editor-historic";historic;static properties={historic:Object};constructor(t){super(),this._restoreCachedInititalValues(),this.historic=t??{reloadInterval:2e3}}ready(){this._bindingsParse()}#e=!1;refresh(){this.#e||(this.#e=!0,this._bindingsRefresh(null,!0),this.#e=!1)}};customElements.define(E.is,E);var D=class extends ke{static template=Se`
104
104
  <div id="root">
105
105
  <div class="vertical-grid">
106
106
  <div style="grid-column: 1/3">
@@ -183,7 +183,7 @@ export async function run(eventData, shadowRoot, parameters, relativeSignalsPath
183
183
  </button>
184
184
  </div>
185
185
  </div>
186
- </div>`;static style=ke`
186
+ </div>`;static style=_e`
187
187
  :host {
188
188
  box-sizing: border-box;
189
189
  }
@@ -256,11 +256,11 @@ export async function run(eventData, shadowRoot, parameters, relativeSignalsPath
256
256
 
257
257
  node-projects-code-view-monaco[readonly] {
258
258
  border: 1px lightgray solid;
259
- }`;static is="node-projects-visualization-bindings-editor";static properties={twoWayPossible:Boolean,twoWay:Boolean,expression:String,objectNames:String,events:String,invert:Boolean,converters:Array,historic:Object};twoWayPossible=!1;twoWay=!1;expression="";writeBackSignal="";expressionTwoWay="";historic;objectNames="";events="";invert=!1;converters=[];convertersString;objectValueType;_property;_binding;_bindingTarget;_serviceContainer;_instanceServiceContainer;_shell;_activeRow=-1;_objNmInput;constructor(t,s,e,i,n,l,a={namedConverters:!0}){super(),super._restoreCachedInititalValues(),this._objNmInput=this._getDomElement("objectName"),this._property=t,this._binding=s,this._bindingTarget=e,this._serviceContainer=i,this._instanceServiceContainer=n,this._shell=l,a?.namedConverters||(this._getDomElement("namedConverterInput").style.display="none")}ready(){if(this._parseAttributesToProperties(),this._assignEvents(),this.twoWayPossible=!1,(this._bindingTarget==G.property||this._bindingTarget==G.attribute)&&(this.twoWayPossible=!0),this._binding){if(this.twoWay=this._binding.mode==Se.twoWay,this.expression=this._binding.expression,this.writeBackSignal=this._binding.writeBackSignal,this.expressionTwoWay=this._binding.expressionTwoWay,this.historic=this._binding.historic,this.invert=this._binding.invert,this.objectValueType=this._binding.type,this._binding.bindableObjectNames&&(this.objectNames=this._binding.bindableObjectNames.join(";")),this._binding.converter)if(typeof this._binding.converter=="string")this.convertersString=this._binding.converter;else for(let t in this._binding.converter)this.converters.push({key:t,value:this._binding.converter[t]});this._binding.changedEvents&&this._binding.changedEvents.length&&(this.events=this._binding.changedEvents.join(";"))}if(this.expression){let t=this._getDomElement("expression");this.expression.indexOf(`
259
+ }`;static is="node-projects-visualization-bindings-editor";static properties={twoWayPossible:Boolean,twoWay:Boolean,expression:String,objectNames:String,events:String,invert:Boolean,converters:Array,historic:Object};twoWayPossible=!1;twoWay=!1;expression="";writeBackSignal="";expressionTwoWay="";historic;objectNames="";events="";invert=!1;converters=[];convertersString;objectValueType;_property;_binding;_bindingTarget;_serviceContainer;_instanceServiceContainer;_shell;_activeRow=-1;_objNmInput;constructor(t,s,e,i,r,o,a={namedConverters:!0}){super(),super._restoreCachedInititalValues(),this._objNmInput=this._getDomElement("objectName"),this._property=t,this._binding=s,this._bindingTarget=e,this._serviceContainer=i,this._instanceServiceContainer=r,this._shell=o,a?.namedConverters||(this._getDomElement("namedConverterInput").style.display="none")}ready(){if(this._parseAttributesToProperties(),this._assignEvents(),this.twoWayPossible=!1,(this._bindingTarget==$.property||this._bindingTarget==$.attribute)&&(this.twoWayPossible=!0),this._binding){if(this.twoWay=this._binding.mode==Te.twoWay,this.expression=this._binding.expression,this.writeBackSignal=this._binding.writeBackSignal,this.expressionTwoWay=this._binding.expressionTwoWay,this.historic=this._binding.historic,this.invert=this._binding.invert,this.objectValueType=this._binding.type,this._binding.bindableObjectNames&&(this.objectNames=this._binding.bindableObjectNames.join(";")),this._binding.converter)if(typeof this._binding.converter=="string")this.convertersString=this._binding.converter;else for(let t in this._binding.converter)this.converters.push({key:t,value:this._binding.converter[t]});this._binding.changedEvents&&this._binding.changedEvents.length&&(this.events=this._binding.changedEvents.join(";"))}if(this.expression){let t=this._getDomElement("expression");this.expression.indexOf(`
260
260
  `)>=0&&(t.style.height="51px")}if(this.expressionTwoWay){let t=this._getDomElement("expression2way");this.expressionTwoWay.indexOf(`
261
- `)>=0&&(t.style.height="51px")}this._bindingsParse(),this._objNmInput.focus()}_focusRow(t){this._activeRow=t,this._updatefocusedRow()}_updatefocusedRow(){let t=this._getDomElement("converterGrid");t.querySelectorAll("div").forEach(s=>s.style.background=""),this._activeRow>=0&&(t.children[this._activeRow+1].style.background="gray")}_clear(){this.objectNames="",this._bindingsRefresh()}_refresh(){requestAnimationFrame(()=>{this._bindingsRefresh()})}async _select(){let t=this._shell.createBindableObjectBrowser();t.initialize(this._serviceContainer,this._instanceServiceContainer,"binding"),t.title="select signal...";let s=new AbortController;t.objectDoubleclicked.on(()=>{s.abort(),this.objectNames!=""&&(this.objectNames+=";"),t.selectedObject.specialType=="signalProperty"?this.objectNames+="?":t.selectedObject.bindabletype==="property"&&(this.objectNames+="??"),this.objectNames+=t.selectedObject.fullName,this._bindingsRefresh()}),await this._shell.openConfirmation(t,{x:100,y:100,width:400,height:300,parent:this,abortSignal:s.signal})&&(this.objectNames!=""&&(this.objectNames+=";"),this.objectNames+=t.selectedObject.fullName,this._bindingsRefresh())}async showHistoric(){let t=new E(this.historic),s=new AbortController;t.title="Edit historic binding to: "+this._property.name,await this._shell.openConfirmation(t,{x:100,y:100,width:420,height:510,parent:this,abortSignal:s.signal,disableResize:!0,cancelText:"Remove"})?this.historic=t.historic:this.historic=null,this._bindingsRefresh()}addConverter(){this.converters.push({key:"",value:""}),this._activeRow=this.converters.length-1,this._bindingsRefresh(),this._updatefocusedRow()}removeConverter(){this.converters.splice(this._activeRow,1),this._activeRow=-1,this._bindingsRefresh(),this._updatefocusedRow()}};customElements.define(D.is,D);import{BaseCustomWebComponentConstructorAppend as Ce,css as Ee,html as Ne}from"@node-projects/base-custom-webcomponent";import{ContextMenu as q}from"@node-projects/web-component-designer";import{typeInfoFromJsonSchema as $}from"@node-projects/propertygrid.webcomponent";import{defaultOptions as Ie}from"@node-projects/web-component-designer-widgets-wunderbaum";import{Wunderbaum as Oe}from"wunderbaum";import Be from"wunderbaum/dist/wunderbaum.css"with{type:"css"};import{PropertyGrid as _e}from"@node-projects/propertygrid.webcomponent";import{CodeViewMonaco as Te}from"@node-projects/web-component-designer-codeview-monaco";var W=class extends _e{serviceContainer;instanceServiceContainer;visualizationHandler;visualizationShell;bindableObjectsTarget="property";constructor(){super()}bindingDoubleClicked;async getEditorForType(t,s,e,i,n){if(this.getSpecialEditorForType){let l=await this.getSpecialEditorForType(t,s,e,i,n);if(l)return l}switch(t.format){case"screen":{let l=document.createElement("select");l.style.width="100%";let a=document.createElement("option");a.value=s??"",a.innerText=s??"",l.appendChild(a);for(let p of await this.visualizationHandler.getAllNames("screen")){if(p==s)continue;let o=document.createElement("option");o.value=p,o.innerText=p,l.appendChild(o)}return l.onchange=()=>{this.setPropertyValue(e,l.value)},l.value=s,l}case"signal":{let l=document.createElement("div");l.style.display="flex";let a=document.createElement("input");a.value=s??"",a.style.flexGrow="1",a.style.width="0",a.onchange=o=>this.setPropertyValue(e,a.value),a.onfocus=o=>{a.selectionStart=0,a.selectionEnd=a.value?.length},l.appendChild(a);let p=document.createElement("button");return p.textContent="...",p.onclick=async()=>{let o=this.visualizationShell.createBindableObjectBrowser();o.initialize(this.serviceContainer,this.instanceServiceContainer,this.bindableObjectsTarget),o.title="select signal...";let u=new AbortController;o.objectDoubleclicked.on(()=>{this.bindingDoubleClicked&&this.bindingDoubleClicked(o.selectedObject),u.abort(),a.value=o.selectedObject.fullName,this.setPropertyValue(e,a.value)}),await this.visualizationShell.openConfirmation(o,{x:100,y:100,width:400,height:300,parent:this,abortSignal:u.signal})&&(a.value=o.selectedObject.fullName,this.setPropertyValue(e,a.value))},l.appendChild(p),l}case"html":case"script":{let l=document.createElement("div");l.style.boxSizing="border-box",l.style.width="100%",l.style.display="flex";let a=document.createElement("textarea");a.style.boxSizing="border-box",a.value=s??"",a.style.width="100%",a.onblur=o=>{this.setPropertyValue(e,a.value)},l.appendChild(a);let p=document.createElement("button");return p.innerHTML="...",p.style.boxSizing="border-box",p.onclick=async()=>{let o=new Te;if(t.format=="html")o.language="html";else{let g={content:`declare global {
261
+ `)>=0&&(t.style.height="51px")}this._bindingsParse(),this._objNmInput.focus()}_focusRow(t){this._activeRow=t,this._updatefocusedRow()}_updatefocusedRow(){let t=this._getDomElement("converterGrid");t.querySelectorAll("div").forEach(s=>s.style.background=""),this._activeRow>=0&&(t.children[this._activeRow+1].style.background="gray")}_clear(){this.objectNames="",this._bindingsRefresh()}_refresh(){requestAnimationFrame(()=>{this._bindingsRefresh()})}async _select(){let t=this._shell.createBindableObjectBrowser();t.initialize(this._serviceContainer,this._instanceServiceContainer,"binding"),t.title="select signal...";let s=new AbortController;t.objectDoubleclicked.on(()=>{s.abort(),this.objectNames!=""&&(this.objectNames+=";"),t.selectedObject.specialType=="signalProperty"?this.objectNames+="?":t.selectedObject.bindabletype==="property"&&(this.objectNames+="??"),this.objectNames+=t.selectedObject.fullName,this._bindingsRefresh()}),await this._shell.openConfirmation(t,{x:100,y:100,width:400,height:300,parent:this,abortSignal:s.signal})&&(this.objectNames!=""&&(this.objectNames+=";"),this.objectNames+=t.selectedObject.fullName,this._bindingsRefresh())}async showHistoric(){let t=new E(this.historic),s=new AbortController;t.title="Edit historic binding to: "+this._property.name,await this._shell.openConfirmation(t,{x:100,y:100,width:420,height:510,parent:this,abortSignal:s.signal,disableResize:!0,cancelText:"Remove"})?this.historic=t.historic:this.historic=null,this._bindingsRefresh()}addConverter(){this.converters.push({key:"",value:""}),this._activeRow=this.converters.length-1,this._bindingsRefresh(),this._updatefocusedRow()}removeConverter(){this.converters.splice(this._activeRow,1),this._activeRow=-1,this._bindingsRefresh(),this._updatefocusedRow()}};customElements.define(D.is,D);import{BaseCustomWebComponentConstructorAppend as Ne,css as Oe,html as Ie}from"@node-projects/base-custom-webcomponent";import{ContextMenu as q}from"@node-projects/web-component-designer";import{typeInfoFromJsonSchema as Y}from"@node-projects/propertygrid.webcomponent";import{defaultOptions as Be}from"@node-projects/web-component-designer-widgets-wunderbaum";import{Wunderbaum as Re}from"wunderbaum";import Ve from"wunderbaum/dist/wunderbaum.css"with{type:"css"};import{PropertyGrid as Ce}from"@node-projects/propertygrid.webcomponent";import{CodeViewMonaco as Ee}from"@node-projects/web-component-designer-codeview-monaco";var j=class extends Ce{serviceContainer;instanceServiceContainer;visualizationHandler;visualizationShell;bindableObjectsTarget="property";constructor(){super()}bindingDoubleClicked;async getEditorForType(t,s,e,i,r){if(this.getSpecialEditorForType){let o=await this.getSpecialEditorForType(t,s,e,i,r);if(o)return o}switch(t.format){case"screen":{let o=document.createElement("select");o.style.width="100%";let a=document.createElement("option");a.value=s??"",a.innerText=s??"",o.appendChild(a);for(let l of await this.visualizationHandler.getAllNames("screen")){if(l==s)continue;let c=document.createElement("option");c.value=l,c.innerText=l,o.appendChild(c)}return o.onchange=()=>{this.setPropertyValue(e,o.value)},o.value=s,o}case"signal":{let o=document.createElement("div");o.style.display="flex";let a=document.createElement("input");a.value=s??"",a.style.flexGrow="1",a.style.width="0",a.onchange=c=>this.setPropertyValue(e,a.value),a.onfocus=c=>{a.selectionStart=0,a.selectionEnd=a.value?.length},o.appendChild(a);let l=document.createElement("button");return l.textContent="...",l.onclick=async()=>{let c=this.visualizationShell.createBindableObjectBrowser();c.initialize(this.serviceContainer,this.instanceServiceContainer,this.bindableObjectsTarget),c.title="select signal...";let p=new AbortController;c.objectDoubleclicked.on(()=>{this.bindingDoubleClicked&&this.bindingDoubleClicked(c.selectedObject),p.abort(),a.value=c.selectedObject.fullName,this.setPropertyValue(e,a.value)}),await this.visualizationShell.openConfirmation(c,{x:100,y:100,width:400,height:300,parent:this,abortSignal:p.signal})&&(a.value=c.selectedObject.fullName,this.setPropertyValue(e,a.value))},o.appendChild(l),o}case"html":case"script":{let o=document.createElement("div");o.style.boxSizing="border-box",o.style.width="100%",o.style.display="flex";let a=document.createElement("textarea");a.style.boxSizing="border-box",a.value=s??"",a.style.width="100%",a.onblur=c=>{this.setPropertyValue(e,a.value)},o.appendChild(a);let l=document.createElement("button");return l.innerHTML="...",l.style.boxSizing="border-box",l.onclick=async()=>{let c=new Ee;if(t.format=="html")c.language="html";else{let d={content:`declare global {
262
262
  var context: { event: Event, element: Element };
263
- }`,filePath:"global.d.ts"};monaco.languages.typescript.typescriptDefaults.setExtraLibs([g]),o.language="javascript"}o.code=a.value,o.style.position="relative",await this.visualizationShell.openConfirmation(o,{x:200,y:200,width:600,height:400,parent:this})&&(a.value=o.getText(),this.setPropertyValue(e,a.value))},l.appendChild(p),l}}return super.getEditorForType(t,s,e,i,n)}};customElements.define("node-projects-visualization-property-grid",W);import"@node-projects/splitview.webcomponent";var N=class r{static upgradeScriptCommand(t){return t.type==="SetElementProperty"?r.upgradeSetElementProperty(t):t}static upgradeSetElementProperty(t){return t.targetSelectorTarget==="currentScreen"?t.targetSelectorTarget="container":t.targetSelectorTarget==="parentScreen"?(t.targetSelectorTarget="container",t.parentIndex=1):t.targetSelectorTarget==="currentElement"?t.targetSelectorTarget="element":t.targetSelectorTarget==="parentElement"&&(t.targetSelectorTarget="element",t.parentIndex=1),t}};var I=class r extends Ce{static style=Ee`
263
+ }`,filePath:"global.d.ts"};monaco.languages.typescript.typescriptDefaults.setExtraLibs([d]),c.language="javascript"}c.code=a.value,c.style.position="relative",await this.visualizationShell.openConfirmation(c,{x:200,y:200,width:600,height:400,parent:this})&&(a.value=c.getText(),this.setPropertyValue(e,a.value))},o.appendChild(l),o}}return super.getEditorForType(t,s,e,i,r)}};customElements.define("node-projects-visualization-property-grid",j);import"@node-projects/splitview.webcomponent";var N=class n{static upgradeScriptCommand(t){return t.type==="SetElementProperty"?n.upgradeSetElementProperty(t):t}static upgradeSetElementProperty(t){return t.targetSelectorTarget==="currentScreen"?t.targetSelectorTarget="container":t.targetSelectorTarget==="parentScreen"?(t.targetSelectorTarget="container",t.parentIndex=1):t.targetSelectorTarget==="currentElement"?t.targetSelectorTarget="element":t.targetSelectorTarget==="parentElement"&&(t.targetSelectorTarget="element",t.parentIndex=1),t}};var O=class n extends Ne{static style=Oe`
264
264
  :host {
265
265
  background: white;
266
266
  }
@@ -285,7 +285,7 @@ export async function run(eventData, shadowRoot, parameters, relativeSignalsPath
285
285
  width: 100%;
286
286
  height: 100%;
287
287
  }
288
- `;static template=Ne`
288
+ `;static template=Ie`
289
289
  <div style="width:100%; height:100%; overflow: hidden;">
290
290
  <node-projects-split-view style="height: 100%; width: 100%; position: relative;" orientation="horizontal">
291
291
  <div style="width: 40%; position: relative;">
@@ -302,7 +302,7 @@ export async function run(eventData, shadowRoot, parameters, relativeSignalsPath
302
302
  </div>
303
303
  </node-projects-split-view>
304
304
  </div>
305
- `;static is="node-projects-visualization-simple-script-editor";serviceContainer;instanceServiceContainer;visualizationHandler;visualizationShell;scriptCommandsTypeInfo;propertiesTypeInfo;_script;_commandListDiv;_commandListFancyTree;_possibleCommands;_propertygrid;constructor(){super(),this._restoreCachedInititalValues(),this._commandListDiv=this._getDomElement("commandList"),this._possibleCommands=this._getDomElement("possibleCommands"),this._propertygrid=this._getDomElement("propertygrid"),this.shadowRoot.adoptedStyleSheets=[Be,r.style]}async ready(){this.addPossibleCommands(),this._parseAttributesToProperties(),this._bindingsParse(null,!0),this._assignEvents();let t=async s=>{let e=new W;e.visualizationHandler=this.visualizationHandler,e.visualizationShell=this.visualizationShell,e.serviceContainer=this.serviceContainer,e.instanceServiceContainer=this.instanceServiceContainer,e.bindableObjectsTarget="script",e.getTypeInfo=(n,l)=>$(this.propertiesTypeInfo,n,l),e.showHead=!1,e.typeName="IScriptMultiplexValue",e.title='Complex for "'+s.propertyPath+'"',typeof s.value=="object"?e.selectedObject=s.value??{}:e.selectedObject={},e.bindingDoubleClicked=n=>{n.bindabletype=="property"?e.setPropertyValue("source","property"):n.bindabletype=="context"?e.setPropertyValue("source","context"):e.setPropertyValue("source","signal"),e.setPropertyValue("name",n.fullName),e.refresh()},await this.visualizationShell.openConfirmation(e,{x:100,y:100,width:400,height:500,parent:this})&&(this._propertygrid.setPropertyValue(s.propertyPath,e.selectedObject),this._propertygrid.refresh())};this._propertygrid.visualizationHandler=this.visualizationHandler,this._propertygrid.visualizationShell=this.visualizationShell,this._propertygrid.serviceContainer=this.serviceContainer,this._propertygrid.instanceServiceContainer=this.instanceServiceContainer,this._propertygrid.bindableObjectsTarget="script",this._propertygrid.getTypeInfo=(s,e)=>$(this.scriptCommandsTypeInfo,s,e),this._propertygrid.getSpecialEditorForType=async(s,e,i,n,l)=>{if(!s.specialAllreadyAdded&&(s.specialAllreadyAdded=!0,s.format!=="collection"))if(typeof e=="object"&&e!==null||s.format==="complex"){let a=document.createElement("button");a.style.height="calc(100% - 6px)",a.style.position="relative",a.style.display="flex",a.style.justifyContent="center",a.style.width="20px",a.style.boxSizing="content-box",a.innerText="del",a.onclick=()=>{this._propertygrid.setPropertyValue(i,void 0),this._propertygrid.refresh()},n.nodeElem.insertAdjacentElement("afterbegin",a);let p=document.createElement("div");p.style.display="flex";let o=document.createElement("span");e?o.innerText=(e.source??"")+": "+(e.name??""):o.innerText="",o.style.overflow="hidden",o.style.whiteSpace="nowrap",o.style.textOverflow="ellipsis",o.style.flexGrow="1",o.title=JSON.stringify(e),p.appendChild(o);let u=document.createElement("button");return u.innerText="...",u.onclick=()=>{t({value:e,propertyPath:i})},p.appendChild(u),n.nodeElem.style.display="flex",p}else{let a=document.createElement("button");a.style.height="calc(100% - 6px)",a.style.position="relative",a.style.display="flex",a.style.justifyContent="center",a.style.width="20px",a.style.boxSizing="content-box",a.title="complex property value",a.style.opacity="0.2",a.innerText="...",a.onclick=()=>{t({value:e,propertyPath:i})},n.nodeElem.insertAdjacentElement("afterbegin",a),n.nodeElem.style.display="flex"}return null},this._propertygrid.propertyNodeContextMenu.on(s=>{q.show([{title:"edit complex value",action:async()=>{t(s)}},{title:"edit string",action:async()=>{let e=prompt("enter value:");e&&(this._propertygrid.setPropertyValue(s.propertyPath,e),this._propertygrid.refresh())}},{title:"remove complex value",action:async()=>{this._propertygrid.setPropertyValue(s.propertyPath,void 0),this._propertygrid.refresh()}}],s.event)})}async addPossibleCommands(){let t=Object.keys(this.scriptCommandsTypeInfo.definitions).filter(s=>this.scriptCommandsTypeInfo.definitions[s].type=="object");for(let s of t){if(s=="ScriptCommands")continue;let e=document.createElement("option");e.innerText=s,this._possibleCommands.add(e)}}loadScript(t){this._script=t;let s=[];for(let e of this._script.commands)e=N.upgradeScriptCommand(e),s.push(this.createTreeItem(e));this._commandListFancyTree=new Oe({...Ie,element:this._commandListDiv,icon:!1,source:s,activate:e=>{this._propertygrid.selectedObject=e.node.data.data.item},render:e=>{if(e.isNew){let i=e.nodeElem;i.oncontextmenu=n=>(e.node.setActive(),e.node.data.contextMenu&&e.node.data.contextMenu(n,e.node.data,e.node),n.preventDefault(),!1)}},dnd:{guessDropEffect:!0,preventRecursion:!0,preventVoidMoves:!1,serializeClipboardData:!1,dragStart:e=>(e.event.dataTransfer.effectAllowed="move",e.event.dataTransfer.dropEffect="move",!0),dragEnter:e=>(e.event.dataTransfer.dropEffect="move",!0),dragOver:e=>{e.event.dataTransfer.dropEffect="move"},drop:async e=>{e.sourceNode.moveTo(e.node,e.region=="before"?"before":"after")}}})}createTreeItem(t){return{title:t.type,data:{item:t},contextMenu:(e,i,n)=>{q.show([{title:"Remove Item",action:l=>n.remove()}],e)}}}addItem(){let s={type:this._possibleCommands.value},e=this.createTreeItem(s);this._commandListFancyTree.addChildren(e)}getScriptCommands(){return this._commandListFancyTree.root.children.map(s=>s.data.data.item)}};customElements.define(I.is,I);import{BaseCustomWebComponentConstructorAppend as Re,css as Ve,html as Ae}from"@node-projects/base-custom-webcomponent";var O=class extends Re{static style=Ve`
305
+ `;static is="node-projects-visualization-simple-script-editor";serviceContainer;instanceServiceContainer;visualizationHandler;visualizationShell;scriptCommandsTypeInfo;propertiesTypeInfo;_script;_commandListDiv;_commandListFancyTree;_possibleCommands;_propertygrid;constructor(){super(),this._restoreCachedInititalValues(),this._commandListDiv=this._getDomElement("commandList"),this._possibleCommands=this._getDomElement("possibleCommands"),this._propertygrid=this._getDomElement("propertygrid"),this.shadowRoot.adoptedStyleSheets=[Ve,n.style]}async ready(){this.addPossibleCommands(),this._parseAttributesToProperties(),this._bindingsParse(null,!0),this._assignEvents();let t=async s=>{let e=new j;e.visualizationHandler=this.visualizationHandler,e.visualizationShell=this.visualizationShell,e.serviceContainer=this.serviceContainer,e.instanceServiceContainer=this.instanceServiceContainer,e.bindableObjectsTarget="script",e.getTypeInfo=(r,o)=>Y(this.propertiesTypeInfo,r,o),e.showHead=!1,e.typeName="IScriptMultiplexValue",e.title='Complex for "'+s.propertyPath+'"',typeof s.value=="object"?e.selectedObject=s.value??{}:e.selectedObject={},e.bindingDoubleClicked=r=>{r.bindabletype=="property"?e.setPropertyValue("source","property"):r.bindabletype=="context"?e.setPropertyValue("source","context"):e.setPropertyValue("source","signal"),e.setPropertyValue("name",r.fullName),e.refresh()},await this.visualizationShell.openConfirmation(e,{x:100,y:100,width:400,height:500,parent:this})&&(this._propertygrid.setPropertyValue(s.propertyPath,e.selectedObject),this._propertygrid.refresh())};this._propertygrid.visualizationHandler=this.visualizationHandler,this._propertygrid.visualizationShell=this.visualizationShell,this._propertygrid.serviceContainer=this.serviceContainer,this._propertygrid.instanceServiceContainer=this.instanceServiceContainer,this._propertygrid.bindableObjectsTarget="script",this._propertygrid.getTypeInfo=(s,e)=>Y(this.scriptCommandsTypeInfo,s,e),this._propertygrid.getSpecialEditorForType=async(s,e,i,r,o)=>{if(!s.specialAllreadyAdded&&(s.specialAllreadyAdded=!0,s.format!=="collection"))if(typeof e=="object"&&e!==null||s.format==="complex"){let a=document.createElement("button");a.style.height="calc(100% - 6px)",a.style.position="relative",a.style.display="flex",a.style.justifyContent="center",a.style.width="20px",a.style.boxSizing="content-box",a.innerText="del",a.onclick=()=>{this._propertygrid.setPropertyValue(i,void 0),this._propertygrid.refresh()},r.nodeElem.insertAdjacentElement("afterbegin",a);let l=document.createElement("div");l.style.display="flex";let c=document.createElement("span");e?c.innerText=(e.source??"")+": "+(e.name??""):c.innerText="",c.style.overflow="hidden",c.style.whiteSpace="nowrap",c.style.textOverflow="ellipsis",c.style.flexGrow="1",c.title=JSON.stringify(e),l.appendChild(c);let p=document.createElement("button");return p.innerText="...",p.onclick=()=>{t({value:e,propertyPath:i})},l.appendChild(p),r.nodeElem.style.display="flex",l}else{let a=document.createElement("button");a.style.height="calc(100% - 6px)",a.style.position="relative",a.style.display="flex",a.style.justifyContent="center",a.style.width="20px",a.style.boxSizing="content-box",a.title="complex property value",a.style.opacity="0.2",a.innerText="...",a.onclick=()=>{t({value:e,propertyPath:i})},r.nodeElem.insertAdjacentElement("afterbegin",a),r.nodeElem.style.display="flex"}return null},this._propertygrid.propertyNodeContextMenu.on(s=>{q.show([{title:"edit complex value",action:async()=>{t(s)}},{title:"edit string",action:async()=>{let e=prompt("enter value:");e&&(this._propertygrid.setPropertyValue(s.propertyPath,e),this._propertygrid.refresh())}},{title:"remove complex value",action:async()=>{this._propertygrid.setPropertyValue(s.propertyPath,void 0),this._propertygrid.refresh()}}],s.event)})}async addPossibleCommands(){let t=Object.keys(this.scriptCommandsTypeInfo.definitions).filter(s=>this.scriptCommandsTypeInfo.definitions[s].type=="object");for(let s of t){if(s=="ScriptCommands")continue;let e=document.createElement("option");e.innerText=s,this._possibleCommands.add(e)}}loadScript(t){this._script=t;let s=[];for(let e of this._script.commands)e=N.upgradeScriptCommand(e),s.push(this.createTreeItem(e));this._commandListFancyTree=new Re({...Be,element:this._commandListDiv,icon:!1,source:s,activate:e=>{this._propertygrid.selectedObject=e.node.data.data.item},render:e=>{if(e.isNew){let i=e.nodeElem;i.oncontextmenu=r=>(e.node.setActive(),e.node.data.contextMenu&&e.node.data.contextMenu(r,e.node.data,e.node),r.preventDefault(),!1)}},dnd:{guessDropEffect:!0,preventRecursion:!0,preventVoidMoves:!1,serializeClipboardData:!1,dragStart:e=>(e.event.dataTransfer.effectAllowed="move",e.event.dataTransfer.dropEffect="move",!0),dragEnter:e=>(e.event.dataTransfer.dropEffect="move",!0),dragOver:e=>{e.event.dataTransfer.dropEffect="move"},drop:async e=>{e.sourceNode.moveTo(e.node,e.region=="before"?"before":"after")}}})}createTreeItem(t){return{title:t.type,data:{item:t},contextMenu:(e,i,r)=>{q.show([{title:"Remove Item",action:o=>r.remove()}],e)}}}addItem(){let s={type:this._possibleCommands.value},e=this.createTreeItem(s);this._commandListFancyTree.addChildren(e)}getScriptCommands(){return this._commandListFancyTree.root.children.map(s=>s.data.data.item)}};customElements.define(O.is,O);import{BaseCustomWebComponentConstructorAppend as Ae,css as We,html as je}from"@node-projects/base-custom-webcomponent";var I=class extends Ae{static style=We`
306
306
  :host {
307
307
  display: grid;
308
308
  grid-template-columns: 80px 80px 80px auto;
@@ -316,7 +316,7 @@ export async function run(eventData, shadowRoot, parameters, relativeSignalsPath
316
316
 
317
317
  span {
318
318
  font-size: 10px;
319
- }`;static template=Ae`
319
+ }`;static template=je`
320
320
  <span></span>
321
321
  <span>name</span>
322
322
  <span>type</span>
@@ -335,7 +335,7 @@ export async function run(eventData, shadowRoot, parameters, relativeSignalsPath
335
335
  <input hidden="[[item.type !== 'boolean']]" type="checkbox" checked="{{item.value}}">
336
336
  <div hidden="[[item.type !== 'null']]">-null-</div>
337
337
  </template>
338
- <button @click="[[this._add()]]" style="width: 40px; height: 20px; align-self: center;">add</button>`;static is="node-projects-visualization-parameter-editor";constructor(){super(),this._restoreCachedInititalValues()}ready(){this._bindingsParse()}_parameterArray;setParametersObject(t){t!=null?this._parameterArray=Object.keys(t).map(s=>({key:s,type:typeof t[s]=="object"?"null":typeof t[s],value:t[s]})):this._parameterArray=[],this._bindingsRefresh()}getParametersObject(){let t=!1,s={};for(let e of this._parameterArray)if(e.key)switch(t=!0,s[e.key]=null,e.type){case"string":s[e.key]=e.value.toString();break;case"number":let i=parseFloat(e.value);s[e.key]=isNaN(i)?0:i;break;case"boolean":s[e.key]=!!e.value;break}return t?s:null}_remove(t){this._parameterArray.splice(t,1),this._bindingsRefresh()}_add(){this._parameterArray.push({type:"null"}),this._bindingsRefresh()}};customElements.define(O.is,O);import{BaseCustomWebComponentConstructorAppend as je,css as We,html as Y}from"@node-projects/base-custom-webcomponent";import{ContextMenu as K,copyTextToClipboard as Q,getTextFromClipboard as Z,PropertiesHelper as ze}from"@node-projects/web-component-designer";var L=class r extends je{static style=We`
338
+ <button @click="[[this._add()]]" style="width: 40px; height: 20px; align-self: center;">add</button>`;static is="node-projects-visualization-parameter-editor";constructor(){super(),this._restoreCachedInititalValues()}ready(){this._bindingsParse()}_parameterArray;setParametersObject(t){t!=null?this._parameterArray=Object.keys(t).map(s=>({key:s,type:typeof t[s]=="object"?"null":typeof t[s],value:t[s]})):this._parameterArray=[],this._bindingsRefresh()}getParametersObject(){let t=!1,s={};for(let e of this._parameterArray)if(e.key)switch(t=!0,s[e.key]=null,e.type){case"string":s[e.key]=e.value.toString();break;case"number":let i=parseFloat(e.value);s[e.key]=isNaN(i)?0:i;break;case"boolean":s[e.key]=!!e.value;break}return t?s:null}_remove(t){this._parameterArray.splice(t,1),this._bindingsRefresh()}_add(){this._parameterArray.push({type:"null"}),this._bindingsRefresh()}};customElements.define(I.is,I);import{BaseCustomWebComponentConstructorAppend as ze,css as De,html as Z}from"@node-projects/base-custom-webcomponent";import{ContextMenu as K,copyTextToClipboard as Q,getTextFromClipboard as ee,PropertiesHelper as Pe}from"@node-projects/web-component-designer";var P=class n extends ze{static style=De`
339
339
  :host {
340
340
  display: grid;
341
341
  grid-template-columns: 20px 1fr auto;
@@ -369,22 +369,22 @@ export async function run(eventData, shadowRoot, parameters, relativeSignalsPath
369
369
  }
370
370
  button {
371
371
  cursor: pointer;
372
- }`;static template=Y`
372
+ }`;static template=Z`
373
373
  <template repeat:item="[[this.events]]">
374
374
  <div @click="[[this._ctxMenu(event, item)]]" @contextmenu="[[this._ctxMenu(event, item)]]" class="rect" title="[[this._getScriptType(item)]]" css:background-color="[[this._getScriptTypeColor(item)]]"></div>
375
375
  <a @click="[[this._showContextMenuAssignScript(event, item, false)]]" @contextmenu="[[this._ctxMenu(event, item)]]" title="[[item.name]]">[[item.name]]</a>
376
376
  <div>[[this._createControlsForScript(item)]]</div>
377
377
  </template>
378
378
  <span style="grid-column: 1 / span 3; margin-top: 8px; margin-left: 3px;">add event:</span>
379
- <input id="addEventInput" style="grid-column: 1 / span 3; margin: 5px;" @keypress="[[this._addEvent(event)]]" type="text">`;static editRowTemplate=Y`
379
+ <input id="addEventInput" style="grid-column: 1 / span 3; margin: 5px;" @keypress="[[this._addEvent(event)]]" type="text">`;static editRowTemplate=Z`
380
380
  <div style="display: flex; justify-content: flex-end;">
381
381
  <input value="[[this._getScriptName(item)]]" @keypress="[[this._changeScriptName(event, item)]]" hidden="[[this._getScriptType(item) !== 'js']]" placeholder="name" title="name" style="min-width: 50px; flex-basis: 30px; flex-grow: 2;" class="mth" type="text">
382
382
  <input value="[[this._getRelativeSignalsPath(item)]]" @keypress="[[this._changeRelativeSignalsPath(event, item)]]" placeholder="relative signals path" title="relative signals path" style="min-width: 50px; flex-basis: 20px; flex-grow: 1;" class="mth" type="text">
383
383
  <button css:background="[[this._hasParameters(item) ? 'lime' : '']]" style="display: flex; padding: 0; flex-grow: 0;" title="parameter" @click="[[this._editParameter(event, item)]]">p</button>
384
- </div>`;static scriptTypeColors={js:"purple",blockly:"yellow",script:"lightgreen",empty:"pink"};static is="node-projects-visualization-event-assignment";constructor(){super(),this._restoreCachedInititalValues()}ready(){this._bindingsParse()}_blocklyToolbox;_instanceServiceContainer;_selectionChangedHandler;_selectedItems;_visualizationHandler;_visualizationShell;_scriptCommandsTypeInfo;_propertiesTypeInfo;events;initialize(t,s,e,i,n){this._visualizationHandler=t,this._visualizationShell=s,this._scriptCommandsTypeInfo=e,this._propertiesTypeInfo=i,this._blocklyToolbox=n}set instanceServiceContainer(t){this._instanceServiceContainer=t,this._selectionChangedHandler?.dispose(),this._selectionChangedHandler=this._instanceServiceContainer.selectionService.onSelectionChanged.on(s=>{this.selectedItems=s.selectedElements}),this.selectedItems=this._instanceServiceContainer.selectionService.selectedElements}_createControlsForScript(t){switch(this._getScriptType(t)){case"none":return""}return this.constructor.editRowTemplate.content.cloneNode(!0)}_getScriptName(t){if(this.selectedItems[0].hasAttribute("@"+t.name)){let s=this.selectedItems[0].getAttribute("@"+t.name);if(s[0]==="{"){if(s.includes("name"))return JSON.parse(s).name}else return s}return null}async _changeScriptName(t,s){if(t.key=="Enter"&&this.selectedItems&&this.selectedItems.length&&this.selectedItems[0].hasAttribute("@"+s.name)){let e=t.target.value,i=this.selectedItems[0].getAttribute("@"+s.name);if(i.startsWith("{")){let n=JSON.parse(i);n.name=e,this._selectedItems[0].setAttribute("@"+s.name,JSON.stringify(n))}else this._selectedItems[0].setAttribute("@"+s.name,e)}}_getRelativeSignalsPath(t){if(this.selectedItems[0].hasAttribute("@"+t.name)){let s=this.selectedItems[0].getAttribute("@"+t.name);if(s[0]==="{"&&s.includes("relativeSignalsPath"))return JSON.parse(s).relativeSignalsPath}return null}async _changeRelativeSignalsPath(t,s){if(t.key=="Enter"&&this.selectedItems&&this.selectedItems.length&&this.selectedItems[0].hasAttribute("@"+s.name)){let e=t.target.value,i=this.selectedItems[0].getAttribute("@"+s.name);if(i.startsWith("{")){let n=JSON.parse(i);n.relativeSignalsPath=e,this._selectedItems[0].setAttribute("@"+s.name,JSON.stringify(n))}else{let n={name:i,relativeSignalsPath:e};this._selectedItems[0].setAttribute("@"+s.name,JSON.stringify(n))}}}_hasParameters(t){return this.selectedItems[0].hasAttribute("@"+t.name)?this.selectedItems[0].getAttribute("@"+t.name).includes("parameters"):!1}_getScriptTypeColor(t){let s=this._getScriptType(t);return r.scriptTypeColors[s]??"white"}_getScriptType(t){if(this.selectedItems&&this.selectedItems.length&&this.selectedItems[0].hasAttribute("@"+t.name)){let s=this.selectedItems[0].getAttribute("@"+t.name);if(s.startsWith("{")){let e=JSON.parse(s);return"blocks"in e?"blockly":"commands"in e?"script":"js"}else return s==""?"empty":"js"}return"none"}_getEventMethodname(t){return this.selectedItems.length?this.selectedItems[0].getAttribute("@"+t.name):""}_inputMthName(t,s){let e=t.target;this.selectedItems[0].setAttribute("@"+s.name,e.value)}_ctxMenu(t,s){t.preventDefault();let e=this._getScriptType(s);if(e=="empty")this._showContextMenuAssignScript(t,s,!0);else if(e!="none"){let i=[{title:"remove",action:()=>{this.selectedItems[0].removeAttribute("@"+s.name),this._bindingsRefresh()}},{title:"-"},{title:"copy",action:()=>{Q(this.selectedItems[0].getAttribute("@"+s.name))}},{title:"paste",action:async()=>{this.selectedItems[0].setAttribute("@"+s.name,await Z()),this._bindingsRefresh()}}];K.show(i,t)}else this._showContextMenuAssignScript(t,s,!0)}async _addEvent(t){if(t.key=="Enter"){let s=this._getDomElement("addEventInput");this._selectedItems[0].setAttribute("@"+ze.camelToDashCase(s.value.replaceAll(" ","-")),""),s.value="",this.scrollTop=0,this.refresh()}}_createAssignScriptContextMenu(t,s){let e=[{title:"Simple Script",action:()=>{this._editEvent("script",t,s)}},{title:"Javascript",action:()=>{let n=prompt("name of function ?");n&&(this._selectedItems[0].setAttribute("@"+s.name,n),this.refresh(),this._editEvent("js",null,s))}},{title:"Blockly",action:()=>{this._editBlockly(null,s)}}],i=this._getScriptType(s);return i!="none"&&(e.push({title:"-"}),e.push({title:"remove",action:()=>{this.selectedItems[0].removeAttribute("@"+s.name),this._bindingsRefresh()}})),i!="empty"&&e.push({title:"-"},{title:"copy",action:()=>{Q(this.selectedItems[0].getAttribute("@"+s.name))}},{title:"paste",action:async()=>{this.selectedItems[0].setAttribute("@"+s.name,await Z()),this._bindingsRefresh()}}),e}async _showContextMenuAssignScript(t,s,e){t.preventDefault();let i=this._getScriptType(s);if(i!="none"&&i!="empty"&&!e)this._editEvent(i,t,s);else{let n=this._createAssignScriptContextMenu(t,s);K.show(n,t)}}async _editParameter(t,s){let e=this.selectedItems[0],i=new O,n={};i.title="ParameterEditor for '"+s.name+"' of '"+e.name+"'";let l=e.getAttribute("@"+s.name);if(l&&l[0]=="{")try{n=JSON.parse(l).parameters}catch{}if(i.setParametersObject(n),await this._visualizationShell.openConfirmation(i,{x:100,y:100,width:700,height:500})){let p=i.getParametersObject(),o={name:l,parameters:p};l&&l[0]=="{"&&(o=JSON.parse(l),o.parameters=p),p==null&&delete o.parameters;let u=JSON.stringify(o);e.setAttribute("@"+s.name,u),this._bindingsRefresh()}}async _editBlockly(t,s){let e=this.selectedItems[0],i=new C(this._blocklyToolbox);i.title="Blockly Script for '"+s.name+"' of '"+e.name+"'";let n=e.getAttribute("@"+s.name),l=null,a=null;if(n){let o=JSON.parse(n);l=o.parameters,a=o.relativeSignalsPath,i.load(o)}if(await this._visualizationShell.openConfirmation(i,{x:100,y:100,width:700,height:500})){let o=i.save();l&&(o.parameters=l),a&&(o.relativeSignalsPath=a),e.setAttribute("@"+s.name,JSON.stringify(o)),this._bindingsRefresh()}}async _editJavascript(t,s){}async _editSimpleScript(t,s){let e=this.selectedItems[0],i=e.getAttribute("@"+s.name);if(!i||i.startsWith("{")){let n={commands:[]},l=null,a=null;i&&(n=JSON.parse(i),l=n.parameters,a=n.relativeSignalsPath);let p=new I;if(p.serviceContainer=e.serviceContainer,p.instanceServiceContainer=e.instanceServiceContainer,p.scriptCommandsTypeInfo=this._scriptCommandsTypeInfo,p.propertiesTypeInfo=this._propertiesTypeInfo,p.visualizationShell=this._visualizationShell,p.visualizationHandler=this._visualizationHandler,p.loadScript(n),p.title="Script '"+s.name+"' on "+e.name,await this._visualizationShell.openConfirmation(p,{x:100,y:100,width:600,height:500})){let u=p.getScriptCommands();if(u&&u.length){let g={commands:u};l&&(g.parameters=l),a&&(g.relativeSignalsPath=a);let d=JSON.stringify(g);e.setAttribute("@"+s.name,d),this._bindingsRefresh()}}}}async _editEvent(t,s,e){t=="js"?this._editJavascript(s,e):t=="blockly"?this._editBlockly(s,e):this._editSimpleScript(s,e)}refresh(){this._selectedItems!=null&&this._selectedItems.length?this.events=this._selectedItems[0].serviceContainer.getLastServiceWhere("eventsService",t=>t.isHandledElementFromEventsService(this._selectedItems[0])).getPossibleEvents(this._selectedItems[0]):this.events=[],this._bindingsRefresh()}get selectedItems(){return this._selectedItems}set selectedItems(t){this._selectedItems!=t&&(this._selectedItems=t,this.refresh())}};customElements.define(L.is,L);import{TypedEvent as De,cssFromString as Le}from"@node-projects/base-custom-webcomponent";import{BindingTarget as f}from"@node-projects/web-component-designer/dist/elements/item/BindingTarget.js";import{PropertiesHelper as v}from"@node-projects/web-component-designer/dist/elements/services/propertiesService/services/PropertiesHelper.js";var S="bind-prop:",B="bind-attr:",R="bind-class:",V="bind-css:",A="bind-cssvar:",w="bind-content:",F="bind-visible:",Pe="bind(",Me="--tmpBinding_",Ft=/{{(.*)}}/;function z(r){return r.constructor?.elementProperties!=null}function J(r){let t=[],s=[],e="";for(let i=0;i<r.length;i++)r[i]=="{"?(t.push(e),e=""):r[i]=="}"?(s.push(e),e=""):e+=r[i];return t.push(e),{parts:t,signals:s}}function P(r,t){let s=t.split("."),e=r;for(let i of s){if(e==null||typeof e!="object")return;e=e[i]}return e}var H=class{parts;signals;values;unsubscribeTargetValue;cleanupCalls=[];combinedName;disposed;valueChangedCb;visualizationHandler;element;relativeSignalPath;constructor(t,s,e,i,n,l,a,p){this.visualizationHandler=s,this.valueChangedCb=i,this.element=n,this.relativeSignalPath=l,this.parseIndirectBinding(e),this.values=new Array(this.signals.length);for(let o=0;o<this.signals.length;o++){let u=this.signals[o];if(u[0]==="?"&&u[1]==="?"){let h=u.substring(2);if(h.includes(".")){let c=P(a,h);this.handleValueChanged(c,o)}else{this.handleValueChanged(a[h],o);let c=()=>this.handleValueChanged(a[h],o),m=t.getChangedEventName(a,h);a.addEventListener(m,c),this.cleanupCalls.push(()=>a.removeEventListener(m,c))}continue}else if(u[0]==="#"&&u[1]==="#"){let h=u.substring(2);if(h.includes(".")){let c=P(n,h);this.handleValueChanged(c,o)}else{this.handleValueChanged(n[h],o);let c=()=>this.handleValueChanged(n[h],o),m=t.getChangedEventName(n,h);n.addEventListener(m,c),this.cleanupCalls.push(()=>n.removeEventListener(m,c))}continue}else if(u[0]==="\xA7"){let h=u.substring(1),c=p.valueProvider(h,{element:n,relativeSignalPath:l,root:a});c instanceof Promise?c.then(y=>this.handleValueChanged(y,o)):this.handleValueChanged(c,o),p.valueChangedCallbacks||(p.valueChangedCallbacks=new Map);let m=p.valueChangedCallbacks.get(h);m==null&&(m=[],p.valueChangedCallbacks.set(h,m)),m.push(()=>{let y=p.valueProvider(h,{element:n,relativeSignalPath:l,root:a});y instanceof Promise?y.then(x=>this.handleValueChanged(x,o)):this.handleValueChanged(y,o)})}else(u[0]==="?"||u[0]==="#")&&(u.includes(".")?u=P(a,u.substring(1)):u=a[u.substring(1)]);let g=(h,c)=>this.handleValueChanged(c.val,o),d=this.visualizationHandler.subscribeState(u,g);this.cleanupCalls.push(()=>this.visualizationHandler.unsubscribeState(this.signals[o],g,d))}}parseIndirectBinding(t){let{parts:s,signals:e}=J(t);this.parts=s,this.signals=e;for(let i=0;i<e.length;i++)e[i][0]=="."&&(e[i]=this.visualizationHandler.getNormalizedSignalName(e[i],this.relativeSignalPath,this.element))}handleValueChanged(t,s){this.values[s]=t;let e=this.parts[0];for(let i=0;i<this.parts.length-1;i++){let n=this.values[i];if(n==null)return;e+=n+this.parts[i+1]}if(e[0]=="."&&(e=this.visualizationHandler.getNormalizedSignalName(e,this.relativeSignalPath,this.element)),this.combinedName!=e&&(this.unsubscribeTargetValue&&this.visualizationHandler.unsubscribeState(this.combinedName,this.unsubscribeTargetValue[0],this.unsubscribeTargetValue[1]),!this.disposed)){this.combinedName=e;let i=(n,l)=>this.valueChangedCb(l);this.unsubscribeTargetValue=[i,this.visualizationHandler.subscribeState(e,i)]}}dispose(){this.disposed=!0,this.unsubscribeTargetValue&&(this.visualizationHandler.unsubscribeState(this.combinedName,this.unsubscribeTargetValue[0],this.unsubscribeTargetValue[1]),this.unsubscribeTargetValue=null);for(let t=0;t<this.signals.length;t++)this.cleanupCalls[t]()}setState(t){this.disposed||this.visualizationHandler.setState(this.combinedName,t)}},ee=class r{_visualizationHandler;namedConverterCallback;constructor(t){this._visualizationHandler=t}getChangedEventName(t,s){let e=s.indexOf("::");return e>=0?s.substring(e+2):t instanceof HTMLInputElement||t instanceof HTMLSelectElement?"change":z(t)?v.camelToDashCase(s):v.camelToDashCase(s)+"-changed"}parseBinding(t,s,e,i,n){let l=s.substring(n.length);if(i===f.cssvar&&(l="--"+l),!e.startsWith("{")){let p={signal:e,target:i};if(e[0]==="="){if(e=e.substring(1),p.signal=e,e.includes("::")){let o=e.split("::");e=o[0],p.signal=e,p.events=o[1].split(",")}p.twoWay=!0,p.events||(t instanceof HTMLInputElement?p.events=[this.getChangedEventName(t,l)]:t instanceof HTMLSelectElement?p.events=[this.getChangedEventName(t,l)]:z(t)?p.events=[this.getChangedEventName(t,l)]:(p.events=[this.getChangedEventName(t,l)],p.maybeLitElement=!0,p.litEventNames=[this.getChangedEventName(t,l)]))}if(e[0]==="!"&&(p.signal=e.substring(1),p.inverted=!0),p.signal.includes(";")){let o=p.signal.split(";");p.expression=o.pop(),p.signal=o.join(";")}return i===f.cssvar||i===f.class?[r.dotToCamelCase(l),p]:i===f.attribute?[l,p]:[v.dashToCamelCase(l),p]}let a=JSON.parse(e);return a.target=i,a.twoWay&&(a.events==null||a.events.length==0)&&(t instanceof HTMLInputElement?a.events=["change"]:t instanceof HTMLSelectElement?a.events=["change"]:a.events=[this.getChangedEventName(t,l)]),i===f.cssvar||i===f.class?[r.dotToCamelCase(l),a]:i===f.attribute?[l,a]:[v.dashToCamelCase(l),a]}serializeBinding(t,s,e){let i={...e};delete i.type,e.twoWay?e.events!=null&&e.events.length==1&&(t instanceof HTMLInputElement&&e.events?.[0]=="change"||t instanceof HTMLSelectElement&&e.events?.[0]=="change"||z(t)&&e.events?.[0]==s||!z(t)&&e.events?.[0]==s+"-changed")&&delete i.events:(delete i.events,delete i.expressionTwoWay);let n=i.twoWay&&i.events?.length>0?"::"+i.events.join(","):"",l=!1;return(n&&e.expression?.includes("::")||e.expressionTwoWay?.includes("::"))&&(l=!0),e.signal.trim()[0]=="{"&&(l=!0),!l&&e.target==f.property&&!e.expression&&!e.expressionTwoWay&&e.converter==null&&!e.historic&&!e.writeBackSignal?s=="textContent"?[w+"text",(e.twoWay?"=":"")+(e.inverted?"!":"")+e.signal+(!e.twoWay&&e.signal.includes(";")?";":"")+n]:s=="innerHTML"?[w+"html",(e.twoWay?"=":"")+(e.inverted?"!":"")+e.signal+(!e.twoWay&&e.signal.includes(";")?";":"")+n]:[S+v.camelToDashCase(s),(e.twoWay?"=":"")+(e.inverted?"!":"")+e.signal+(!e.twoWay&&e.signal.includes(";")?";":"")+n]:!l&&e.target==f.property&&e.expression&&!e.expression.includes(`
385
- `)&&!e.expression.includes(";")&&!e.expressionTwoWay&&e.converter==null&&!e.historic&&!e.writeBackSignal?s=="textContent"?[w+"text",(e.inverted?"!":"")+e.signal+";"+e.expression+n]:s=="innerHTML"?[w+"html",(e.inverted?"!":"")+e.signal+";"+e.expression+n]:[S+v.camelToDashCase(s),(e.twoWay?"=":"")+(e.inverted?"!":"")+e.signal+";"+e.expression+n]:!l&&e.target==f.attribute&&!e.expression&&!e.expressionTwoWay&&e.converter==null&&!e.historic&&!e.writeBackSignal?[B+v.camelToDashCase(s),(e.twoWay?"=":"")+(e.inverted?"!":"")+e.signal+(!e.twoWay&&e.signal.includes(";")?";":"")+n]:!l&&e.target==f.attribute&&e.expression&&!e.expression.includes(`
386
- `)&&!e.expression.includes(";")&&!e.expressionTwoWay&&e.converter==null&&!e.historic&&!e.writeBackSignal?[B+v.camelToDashCase(s),(e.twoWay?"=":"")+(e.inverted?"!":"")+e.signal+";"+e.expression+n]:!l&&e.target==f.class&&!e.expression&&!e.expressionTwoWay&&e.converter==null&&!e.historic&&!e.writeBackSignal?[R+v.camelToDashCase(s),(e.inverted?"!":"")+e.signal+(!e.twoWay&&e.signal.includes(";")?";":"")+n]:!l&&e.target==f.class&&e.expression&&!e.expression.includes(`
387
- `)&&!e.expression.includes(";")&&!e.expressionTwoWay&&e.converter==null&&!e.historic&&!e.writeBackSignal?[R+v.camelToDashCase(s),(e.inverted?"!":"")+e.signal+";"+e.expression+n]:!l&&e.target==f.css&&!e.expression&&!e.expressionTwoWay&&e.converter==null&&!e.historic&&!e.writeBackSignal?[V+v.camelToDashCase(s),(e.inverted?"!":"")+e.signal+(!e.twoWay&&e.signal.includes(";")?";":"")+n]:!l&&e.target==f.css&&e.expression&&!e.expression.includes(`
388
- `)&&!e.expression.includes(";")&&!e.expressionTwoWay&&e.converter==null&&!e.historic&&!e.writeBackSignal?[V+v.camelToDashCase(s),(e.inverted?"!":"")+e.signal+";"+e.expression+n]:!l&&e.target==f.cssvar&&!e.expression&&!e.expressionTwoWay&&e.converter==null&&!e.historic&&!e.writeBackSignal?[A+r.camelToDotCase(s.substring(2)),(e.inverted?"!":"")+e.signal+(!e.twoWay&&e.signal.includes(";")?";":"")+n]:!l&&e.target==f.cssvar&&e.expression&&!e.expression.includes(`
389
- `)&&!e.expression.includes(";")&&!e.expressionTwoWay&&e.converter==null&&!e.historic&&!e.writeBackSignal?[A+v.camelToDashCase(s),(e.inverted?"!":"")+e.signal+";"+e.expression+n]:((e.inverted===null||e.inverted===!1)&&delete i.inverted,(e.expression===null||e.expression==="")&&delete i.expression,(e.expressionTwoWay===null||e.expressionTwoWay==="")&&delete i.expressionTwoWay,(e.twoWay===null||e.twoWay===!1)&&delete i.twoWay,delete i.target,e.historic||delete i.historic,e.target==f.content?[w+"html",JSON.stringify(i)]:e.target==f.attribute?[B+v.camelToDashCase(s),JSON.stringify(i)]:e.target==f.class?[R+r.camelToDotCase(s),JSON.stringify(i)]:e.target==f.css?[V+v.camelToDashCase(s),JSON.stringify(i)]:e.target==f.cssvar?[A+r.camelToDotCase(s.substring(2)),JSON.stringify(i)]:e.target==f.property&&s=="innerHTML"?[w+"html",JSON.stringify(i)]:e.target==f.property&&s=="textContent"?[w+"text",JSON.stringify(i)]:[S+v.camelToDashCase(s),JSON.stringify(i)])}getBindingAttributeName(t,s,e){return e==f.attribute?B+v.camelToDashCase(s):e==f.class?R+r.camelToDotCase(s):e==f.css?V+v.camelToDashCase(s):e==f.visible?F:e==f.cssvar?A+r.camelToDotCase(s):e==f.property&&s=="innerHTML"?w+"html":e==f.property&&s=="textContent"?w+"text":S+v.camelToDashCase(s)}*getBindings(t){if(t.attributes)for(let s of t.attributes)s.name.startsWith(S)?yield this.parseBinding(t,s.name,s.value,f.property,S):s.name.startsWith(w)?yield this.parseBinding(t,s.name==="bind-content:html"?"bind-prop:inner-h-t-m-l":"bind-prop:text-content",s.value,f.property,S):s.name.startsWith(B)?yield this.parseBinding(t,s.name,s.value,f.attribute,B):s.name.startsWith(R)?yield this.parseBinding(t,s.name,s.value,f.class,R):s.name.startsWith(V)?yield this.parseBinding(t,s.name,s.value,f.css,V):s.name.startsWith(A)?yield this.parseBinding(t,s.name,s.value,f.cssvar,A):s.name.startsWith(F)&&(yield this.parseBinding(t,s.name,s.value,f.visible,F))}applyAllBindings(t,s,e,i){let n=[],l=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT),a;for(;a=l.nextNode();){let p=this.getBindings(a);for(let o of p)try{let u=this.applyBinding(a,o,s,e,i);if(n.push(u),o[1].maybeLitElement&&a.localName.includes("-")&&!customElements.get(a.localName)){let g=a,d=o;customElements.whenDefined(a.localName).then(()=>{z(g)&&(u(),d[1].events=d[1].litEventNames,n.push(this.applyBinding(g,d,s,e,i)))})}}catch(u){console.warn("error applying binding",a,o,u)}}return n}static#e=0;async parseCssBindings(t,s,e,i){let n=await import("@node-projects/css-parser"),l=n.parse(t),a;for(let o of l.stylesheet.rules)if(o.type===n.CssTypes.rule){for(let u of o.declarations)if(u.type===n.CssTypes.declaration&&u.value.includes(Pe)){let g=this.parseCssBinding(u.value,s,e,i);u.value=g[0],a?a.push(...g[1]):a=g[1]}}let p=n.stringify(l,{indent:"",compress:!0});return[Le(p),a]}parseCssBinding(t,s,e,i,n){t=t.trim();let l="",a="",p=!1,o="",u=!1,g=null,d=[];for(let h=0;h<t.length;h++){let c=t[h];if(p)if(u)o+=c;else if(g&&c==="\\")u=!0;else if(c===g)g=null;else if(g===null&&c===")"){let m=r.#e++,y=Me+m,x=[y,{signal:o,target:f.cssvar}];o.startsWith("{")&&(x=JSON.parse(o)),d.push(this.applyBinding(s,x,e,i,n)),l+="var("+y+")",p=!1,o=""}else o+=c;else c==="("?(a!=="bind"?(l+=a,l+=c):(p=!0,t[h+1]==="'"||t[h+1]==='"'?(h++,g=t[h]):g=null),a=""):c===" "||c===","||c==="("||c==="+"||c==="-"||c==="*"||c==="/"?(l+=a+c,a=""):a+=c}return[l+a,d]}applyBinding(t,s,e,i,n){let l=[],a,p=()=>{for(let d of l)this._visualizationHandler.unsubscribeState(d[0],d[1],d[2]);if(a)for(let d of a)d()},o=s[1].signal.split(";"),u=new Array(o.length);for(let d=0;d<o.length;d++){let h=o[d];if(u[d]="__"+d,h.includes(":")){let c=h.split(":");u[d]=c[0],h=c[1],o[d]=h}if(h[0]==="?"){if(i){let c=h.substring(1);if(c[0]=="?")o[d]=c;else{o[d]=i[c],c[0]==="$"&&(c=c.substring(1),o[d]="$"+i[c]);let m=()=>{p(),this.applyBinding(t,s,e,i,n)},y=this.getChangedEventName(i,c);i.addEventListener(y,m),a||(a=[]),a.push(()=>i.removeEventListener(y,m))}}}else if(h[0]==="#"){let c=h.substring(1);if(c[0]=="#")o[d]=c;else{o[d]=i[c],c[0]==="$"&&(c=c.substring(1),o[d]="$"+i[c]);let m=()=>{p(),this.applyBinding(t,s,e,i,n)},y=this.getChangedEventName(t,c);i.addEventListener(y,m),a||(a=[]),a.push(()=>i.removeEventListener(y,m))}}h[0]==="."&&(o[d]=this._visualizationHandler.getNormalizedSignalName(h,e,t))}let g=new Array(o.length);for(let d=0;d<o.length;d++){let h=o[d];if(h[0]==="?"){if(i){let c=h.substring(1),m=()=>{let y=!1;y||(y=!0,this.handleValueChanged(t,i,s,i[c],g,d,u,!1,e),y=!1)};i.addEventListener(v.camelToDashCase(c)+"-changed",m),a||(a=[]),a.push(()=>i.removeEventListener(v.camelToDashCase(c)+"-changed",m));try{this.handleValueChanged(t,i,s,i[c],g,d,u,!1,e)}catch(y){console.error(y)}s[1].twoWay&&d==0&&this.addTwoWayBinding(s,t,y=>i[c]=y)}}else if(h[0]==="#"){let c=h.substring(1),m=()=>{let y=!1;y||(y=!0,this.handleValueChanged(t,i,s,t[c],g,d,u,!1,e),y=!1)};t.addEventListener(v.camelToDashCase(c)+"-changed",m),a||(a=[]),a.push(()=>t.removeEventListener(v.camelToDashCase(c)+"-changed",m));try{this.handleValueChanged(t,i,s,t[c],g,d,u,!1,e)}catch(y){console.error(y)}s[1].twoWay&&d==0&&this.addTwoWayBinding(s,t,y=>t[c]=y)}else if(h[0]==="$"){let c=h.substring(1);c[0]==="."&&(c=this._visualizationHandler.getNormalizedSignalName(c,e,t)),this._visualizationHandler.getObject(c).then(m=>{this.handleValueChanged(t,i,s,m,g,d,u,!0,e)})}else if(h[0]==="\xA7"){let c=h.substring(1),m=n.valueProvider(c,{element:t,binding:s,relativeSignalPath:e,root:i});m instanceof Promise?m.then(x=>this.handleValueChanged(t,i,s,x,g,d,u,!0,e)):this.handleValueChanged(t,i,s,m,g,d,u,!0,e),n.valueChangedCallbacks||(n.valueChangedCallbacks=new Map);let y=n.valueChangedCallbacks.get(c);y==null&&(y=[],n.valueChangedCallbacks.set(c,y)),y.push(()=>{let x=n.valueProvider(c,{element:t,binding:s,relativeSignalPath:e,root:i});x instanceof Promise?x.then(ue=>this.handleValueChanged(t,i,s,ue,g,d,u,!0,e)):this.handleValueChanged(t,i,s,x,g,d,u,!0,e)})}else if(h.includes("{")){let c=new H(this,this._visualizationHandler,h,m=>this.handleValueChanged(t,i,s,m.val,g,d,u,!1,e),t,e,i,n);a||(a=[]),a.push(()=>c.dispose()),s[1].twoWay&&d==0&&this.addTwoWayBinding(s,t,m=>c.setState(m))}else if(s[1].historic)if(s[1].historic.reloadInterval){let c={timerId:-1},m=async()=>{let y=await this._visualizationHandler.getHistoricData(h,s[1].historic);this.handleValueChanged(t,i,s,y?.values,g,d,u,!0,e),c.timerId!==null&&(c.timerId=setTimeout(m,s[1].historic.reloadInterval))};m(),a||(a=[]),a.push(()=>{c.timerId>0&&clearTimeout(c.timerId),c.timerId=null})}else this._visualizationHandler.getHistoricData(h,s[1].historic).then(c=>this.handleValueChanged(t,i,s,c?.values,g,d,u,!0,e));else{let c=(m,y)=>this.handleValueChanged(t,i,s,y.val,g,d,u,!1,e);l.push([h,c,this._visualizationHandler.subscribeState(h,c)]),this._visualizationHandler.getState(h).then(m=>this.handleValueChanged(t,i,s,m?.val,g,d,u,!1,e)),s[1].twoWay&&d==0&&this.addTwoWayBinding(s,t,m=>this._visualizationHandler.setState(h,m))}}return p}addTwoWayBinding(t,s,e){t[1].expressionTwoWay&&(t[1].compiledExpressionTwoWay||(t[1].expressionTwoWay.includes("return ")?t[1].compiledExpressionTwoWay=new Function(["value"],t[1].expressionTwoWay):t[1].compiledExpressionTwoWay=new Function(["value"],"return "+t[1].expressionTwoWay)));for(let i of t[1].events){let n=s[i];n instanceof De?n.on(()=>{let l;t[1].target==f.attribute?l=s.getAttribute(t[0]):l=s[t[0]],l=r.parseValueWithType(l,t),t[1].compiledExpressionTwoWay&&(l=t[1].compiledExpressionTwoWay(l)),e(l)}):s.addEventListener(i,l=>{let a;t[1].target==f.attribute?a=s.getAttribute(t[0]):a=s[t[0]],a=r.parseValueWithType(a,t),t[1].compiledExpressionTwoWay&&(a=t[1].compiledExpressionTwoWay(a)),e(a)})}}static parseValueWithType(t,s){if(s[1].type)switch(s[1].type){case"number":return parseFloat(t);case"boolean":return t===!0||t==="true"||!!parseInt(t);case"string":return t?.toString();case"integer":return parseInt(t)}return t}handleValueChanged(t,s,e,i,n,l,a,p,o){let u=i;if(!p&&l==0&&(u=r.parseValueWithType(u,e)),n[l]=u,e[1].expression&&(e[1].compiledExpression||(a.push("__res"),a.push("__ctx"),e[1].expression.includes("return ")?e[1].compiledExpression=new Function(a,e[1].expression):e[1].compiledExpression=new Function(a,"return "+e[1].expression)),n[a.length-1]={element:t,root:s,boundNames:e[1].signal,boundTargetName:e[0],boundTargetType:e[1].target},u=e[1].compiledExpression(...n),n[a.length-1]=u),e[1].converter)if(typeof e[1].converter=="string")u=this.namedConverterCallback(e[1].converter,u,t,e);else{let g=u!=null?u.toString():u;if(g in e[1].converter){let d=e[1].converter[g];typeof d=="string"?u=new Function(a,"return `"+e[1].converter[g]+"`")(...n):u=d}else{let d=!1,h=parseFloat(u);for(let c in e[1].converter)if(c.length>2&&c[0]===">"&&c[1]==="="){let m=parseFloat(c.substring(2));if(h>=m){let y=e[1].converter[c];typeof y=="string"?u=new Function(a,"return `"+e[1].converter[c]+"`")(...n):u=y,d=!0;break}}else if(c.length>2&&c[0]==="<"&&c[1]==="="){let m=parseFloat(c.substring(2));if(h<=m){let y=e[1].converter[c];typeof y=="string"?u=new Function(a,"return `"+e[1].converter[c]+"`")(...n):u=y,d=!0;break}}else if(c.length>1&&c[0]===">"){let m=parseFloat(c.substring(1));if(h>m){let y=e[1].converter[c];typeof y=="string"?u=new Function(a,"return `"+e[1].converter[c]+"`")(...n):u=y,d=!0;break}}else if(c.length>1&&c[0]==="<"){let m=parseFloat(c.substring(1));if(h<m){let y=e[1].converter[c];typeof y=="string"?u=new Function(a,"return `"+e[1].converter[c]+"`")(...n):u=y,d=!0;break}}else{let m=c.split("-");if(m.length>1&&(m[0]===""||h>=parseFloat(m[0]))&&(m[1]===""||parseFloat(m[1])>=h)){let y=e[1].converter[c];typeof y=="string"?u=new Function(a,"return `"+e[1].converter[c]+"`")(...n):u=y,d=!0;break}}!d&&e[1].converterDefault!==void 0&&(u=e[1].converterDefault)}}if(e[1].inverted&&(u=!u),e[1].writeBackSignal){let g=e[1].writeBackSignal;g[0]==="."&&(g=o+g),this._visualizationHandler.setState(g,u,!0)}e[1].target==f.property?t[e[0]]=u:e[1].target==f.attribute?t.setAttribute(e[0],u):e[1].target==f.css?t.style[e[0]]=u:e[1].target==f.cssvar?t.style.setProperty(e[0],u):e[1].target==f.class?u?t.classList.add(e[0]):t.classList.remove(e[0]):e[1].target==f.visible&&(t.style.visibility=u?"":"collapse")}static camelToDotCase(t){return t.replace(/([A-Z])/g,s=>`.${s[0].toLowerCase()}`)}static dotToCamelCase(t){return t.replace(/\.([a-z])/g,s=>s[1].toUpperCase())}};var te=class{name;relativeSignalsPath;commands;parameters};import{deepValue as _,setDeepValue as se,sleep as Fe}from"@node-projects/web-component-designer/dist/elements/helper/Helper.js";import j from"long";var ie=class{_visualizationHandler;_subscriptionCallback=()=>{};constructor(r){this._visualizationHandler=r}async execute(r,t){for(let s=0;s<r.length;s++){let e=r[s];if(e.type=="Exit")break;if(e.type=="Goto"){let i=await this.getValue(e.label,t);if(s=r.findIndex(n=>n.type=="Label"&&n.label==i),s<0)break}else if(e.type=="Condition"){let i=await this.getValue(e.value1,t),n=await this.getValue(e.value2,t),l=await this.getValue(e.comparisonType,t),a=!1;switch(l){case"==null":a=i==null;break;case"!=null":a=i!=null;break;case"==true":a=i==!0;break;case"==false":a=i==!1;break;case"==":a=i==n;break;case"!=":a=i!=n;break;case">":a=i>n;break;case"<":a=i<n;break;case">=":a=i>=n;break;case"<=":a=i<=n;break;case"&&":a=i&&n;break;case"||":a=i||n;break}if(a){await this.runExternalScript(await this.getValue(e.trueScriptName,t),await this.getValue(e.trueScriptType,t));let p=await this.getValue(e.trueGotoLabel,t);if(p&&(s=r.findIndex(o=>o.type=="Label"&&o.label==p),s<0))break}else{await this.runExternalScript(await this.getValue(e.falseScriptName,t),await this.getValue(e.falseScriptType,t));let p=await this.getValue(e.falseGotoLabel,t);if(p&&(s=r.findIndex(o=>o.type=="Label"&&o.label==p),s<0))break}}else if(!await this.runScriptCommand(e,t))break}}async getValueFromTarget(r,t,s){return r==="property"?_(s.root,t):r==="elementProperty"?_(s.element,t):(await this._visualizationHandler.getState(this.getSignalName(t,s)))?.val}async setValueOnTarget(r,t,s,e){r==="property"?se(s.root,t,e):r==="elementProperty"?se(s.element,t,e):await this._visualizationHandler.setState(this.getSignalName(t,s),e)}async runExternalScript(r,t){}async runScriptCommand(command,context){switch(command.type){case"Comment":case"Label":case"Condition":case"Goto":case"Exit":break;case"OpenUrl":{window.open(await this.getValue(command.url,context),command.target);break}case"Delay":{let r=await this.getValue(command.value??500,context);await Fe(r);break}case"Console":{let r=await this.getValue(command.target??"log",context),t=await this.getValue(command.message,context);console[r](t);break}case"ToggleSignalValue":{let r=await this.getValue(command.signal,context),t=await this.getValue(command.target,context),s=await this.getValueFromTarget(t,r,context);await this._visualizationHandler.setState(this.getSignalName(r,context),!s);break}case"ToggleSignalValueThroughList":{let r=await this.getValue(command.valueList,context),t=await this.getValue(command.signal,context),s=await this.getValue(command.target,context),e=await this.getValueFromTarget(s,t,context),i=r.indexOf(e)+1;i>=r.length&&(i=0);let n=r[i];await this._visualizationHandler.setState(this.getSignalName(t,context),n);break}case"SetSignalValue":{let r=await this.getValue(command.signal,context),t=await this.getValue(command.target,context);await this.setValueOnTarget(t,r,context,await this.getValue(command.value,context));break}case"IncrementSignalValue":{let r=await this.getValue(command.signal,context),t=await this.getValue(command.target,context),e=await this.getValueFromTarget(t,r,context)+await this.getValue(command.value,context);await this.setValueOnTarget(t,r,context,e);break}case"DecrementSignalValue":{let r=await this.getValue(command.signal,context),t=await this.getValue(command.target,context),e=await this.getValueFromTarget(t,r,context)-await this.getValue(command.value,context);await this.setValueOnTarget(t,r,context,e);break}case"CalculateSignalValue":{let formula=await this.getValue(command.formula,context),target=await this.getValue(command.target,context),targetSignal=await this.getValue(command.targetSignal,context),nm=await this.parseStringWithValues(formula,context),result=eval(nm);await this.setValueOnTarget(target,targetSignal,context,result);break}case"SetBitInSignal":{let r=await this.getValue(command.signal,context),t=await this.getValue(command.bitNumber??0,context),s=await this.getValue(command.target,context),e=await this.getValueFromTarget(s,r,context),i=j.fromNumber(1).shiftLeft(t),n=j.fromNumber(e).or(i).toNumber();await this.setValueOnTarget(s,r,context,n);break}case"ClearBitInSignal":{let r=await this.getValue(command.signal,context),t=await this.getValue(command.bitNumber??0,context),s=await this.getValue(command.target,context),e=await this.getValueFromTarget(s,r,context),i=j.fromNumber(1).shiftLeft(t);i.negate();let n=j.fromNumber(e).and(i).toNumber();await this.setValueOnTarget(s,r,context,n);break}case"ToggleBitInSignal":{let r=await this.getValue(command.signal,context),t=await this.getValue(command.bitNumber??0,context),s=await this.getValue(command.target,context),e=await this.getValueFromTarget(s,r,context),i=j.fromNumber(1).shiftLeft(t),n=j.fromNumber(e).xor(i).toNumber();await this.setValueOnTarget(s,r,context,n);break}case"Javascript":{let r=await this.getValue(command.script,context),t=context;t.shadowRoot=context.element.getRootNode(),t.instance=context.shadowRoot.host,command.compiledScript||(command.compiledScript=new Function("context",r)),command.compiledScript(t);break}case"SetElementProperty":{command=N.upgradeSetElementProperty(command);let r=await this.getValue(command.name,context);r===""&&(r=null);let t=await this.getValue(command.value,context),s=await this.getValue(command.parentIndex??0,context),e=await this.getValue(command.target??"property",context),i=await this.getValue(command.targetSelectorTarget??"container",context),n=await this.getValue(command.targetSelector,context),l=await this.getValue(command.mode??"toggle",context),a=this.getTargetFromTargetSelector(context,i,s,n);for(let p of a)e=="attribute"?p.setAttribute(r,t):e=="property"?p[r]=t:e=="css"?p.style[r]=t:e=="class"&&(l==="toggle"?p.classList.toggle(r??t):l==="remove"?p.classList.remove(r??t):p.classList.add(r??t));break}case"SubscribeSignal":{let r=await this.getValue(command.signal,context);if(await this.getValue(command.oneTime,context)){let s=()=>{this._visualizationHandler.unsubscribeState(r,s,null)};this._visualizationHandler.subscribeState(r,s)}else this._visualizationHandler.subscribeState(r,this._subscriptionCallback);break}case"UnsubscribeSignal":{let r=await this.getValue(command.signal,context);this._visualizationHandler.unsubscribeState(r,this._subscriptionCallback,null);break}case"WriteSignalsInGroup":{let r=await this.getValue(command.group,context);this._visualizationHandler.writeSignalsInGroup(r);break}case"ClearSignalsInGroup":{let r=await this.getValue(command.group,context);this._visualizationHandler.clearSignalsInGroup(r);break}case"RunScript":{let r=await this.getValue(command.name,context),t=await this.getValue(command.scriptType,context);this.runExternalScript(r,t);break}case"ShowMessageBox":{let r=null,t=await this.getValue(command.exitScriptOnCancel,context);if(await this.getValue(command.buttons,context)=="yesNo"){let i=await this.getValue(command.message,context);confirm(i)?r=1:r=2}else{let i=await this.getValue(command.message,context);alert(i),r=1}let e=await this.getValue(command.resultSignal,context);if(e&&this._visualizationHandler.setState(e,r),t&&r!=1)return!1;break}case"ShowPrompt":{let r=await this.getValue(command.message,context),t=await this.getValue(command.default,context),s=prompt(r,t),e=await this.getValue(command.resultSignal,context);e&&s&&this._visualizationHandler.setState(e,s);break}case"Login":case"Logout":case"CloseDialog":case"OpenDialog":case"OpenScreen":case"SwitchLanguage":case"CopySignalValuesFromFolder":case"ExportSignalValuesAsJson":case"ImportSignalValuesFromJson":{alert('command: "'+command.type+'" is not yet implemented');break}}return!0}getTarget(r,t,s){if(t==="container"){let e=r.element.getRootNode().host;for(let i=0;i<(s??0);i++)e=e.getRootNode().host;return e}else if(t==="element"){let e=r.element;for(let i=0;i<(s??0);i++)e=e.parentElement;return e}return null}getTargetFromTargetSelector(r,t,s,e){let i=this.getTarget(r,t,s),n=[i];return e&&(t==="container"?n=i.shadowRoot.querySelectorAll(e):n=i.querySelectorAll(e)),n}async getValue(value,outerContext){if(value==null)return null;if(typeof value=="object")switch(value.source){case"property":return _(outerContext.root,value.name);case"elementProperty":return _(outerContext.element,value.name);case"signal":return(await this._visualizationHandler.getState(this.getSignalName(value.name,outerContext)))?.val;case"signalInProperty":{let r=_(outerContext.root,value.name);return(await this._visualizationHandler.getState(this.getSignalName(r,outerContext)))?.val}case"event":{let r=outerContext.event;return value.name&&(r=_(r,value.name)),r}case"parameter":return outerContext.parameters[value.name];case"context":return _(outerContext,value.name);case"complexString":{let r=value.name;return r!=null?await this.parseStringWithValues(r,outerContext):null}case"complexSignal":{let r=value.name;if(r!=null){let t=await this.parseStringWithValues(r,outerContext);return(await this._visualizationHandler.getState(this.getSignalName(t,outerContext)))?.val}return null}case"expression":{var ctx=outerContext;return eval(value.name)}}return value}async getStateOrFieldOrParameter(name,context){if(name[0]==="\xA7"){var ctx=context;return eval("ctx."+name.substring(1))}else{if(name[0]==="?"&&name[1]==="?")return context.root[name.substring(2)];if(name[0]==="?")return await this._visualizationHandler.getState(this.getSignalName(context.root[name.substring(1)],context))}return await this._visualizationHandler.getState(this.getSignalName(name,context))}async parseStringWithValues(r,t){let s=J(r),e=await Promise.all(s.signals.map(n=>this.getStateOrFieldOrParameter(this.getSignalName(n,t),t))),i=s.parts[0];for(let n=0;n<s.parts.length-1;n++){let l=e[n];typeof l=="object"&&(l=l.val),l==null&&(l=""),i+=l+s.parts[n+1]}return i}getSignalName(r,t){return r[0]==="."?t.relativeSignalsPath+r:r}createScriptContext(r,t,s,e,i){return{root:r,event:t,element:s,parameters:e,relativeSignalsPath:i}}async assignAllScripts(r,t,s,e,i,n,l,a){let p=s.querySelectorAll("*");n??=this.createScriptContext;let o=null;if(t)try{o=await import(URL.createObjectURL(new Blob([t],{type:"application/javascript"}))),a?a(o):o.init&&o.init(e,s)}catch(u){console.error("error parsing javascript - "+r,u)}for(let u of p)for(let g of u.attributes)if(g.name[0]=="@")try{let d=g.name.substring(1),h=g.value.trim();if(h[0]=="{"){let c=JSON.parse(h);if("commands"in c)u.addEventListener(d,m=>this.execute(c.commands,n(e,m,u,c.parameters,c.relativeSignalsPath)));else if("blocks"in c){let m=null;u.addEventListener(d,async y=>{m||(m=await X(c)),m(y,s,c.parameters,c.relativeSignalsPath??"",i,n(e,y,u,c.parameters,c.relativeSignalsPath))})}else if(l)l(u,d,c);else if("name"in c){let m=c.name;u.addEventListener(d,y=>{o[m]?o[m](y,u,s,e,c.parameters):console.warn("javascript function named: "+m+' not found, maybe missing a "export" ?')})}}else u.addEventListener(d,c=>{o[h]?o[h](c,u,s,e):console.warn("javascript function named: "+h+' not found, maybe missing a "export" ?')})}catch{console.warn("error assigning script",u,g)}return o}};import{OverlayLayer as He,DesignItem as T,InsertAction as Je,BindingTarget as k,PropertyType as M}from"@node-projects/web-component-designer";var ae=class{constructor(t,s){this._bindingsHelper=t,this._visualizationHandler=s}_bindingsHelper;_visualizationHandler;rectMap=new Map;rect;dragEnter(t,s,e){let i=T.GetDesignItem(e);if(i&&!i.isRootItem){let n=t.getNormalizedElementCoordinates(e);this.rect=t.overlayLayer.drawRect("IobrokerWebuiBindableObjectDragDropService",n.x,n.y,n.width,n.height,"",null,He.Background),this.rect.style.fill="#ff0000",this.rect.style.opacity="0.3",this.rectMap.set(e,this.rect)}}dragLeave(t,s,e){let i=T.GetDesignItem(e);if(i&&!i.isRootItem){let n=this.rectMap.get(e);t.overlayLayer.removeOverlay(n),this.rectMap.delete(e)}}dragOver(t,s,e){return"copy"}async drop(t,s,e,i){for(let p of this.rectMap.values())t.overlayLayer.removeOverlay(p);this.rectMap.clear();let n=T.GetDesignItem(i),l=await this._visualizationHandler.getObject(e.fullName),a=this._visualizationHandler.getSignalInformation(l);if(n&&!n.isRootItem)if(i instanceof HTMLInputElement){let p={signal:e.fullName,target:k.property},o=this._bindingsHelper.serializeBinding(i,i.type=="checkbox"?"checked":"value",p);n.setAttribute(o[0],o[1])}else{let p={signal:e.fullName,target:k.content},o=this._bindingsHelper.serializeBinding(i,null,p);n.setAttribute(o[0],o[1])}else{let p=t.getNormalizedEventCoordinates(s),o,u,g=await this._visualizationHandler.getState(e.fullName);if(a.role==="url"&&typeof g?.val=="string")if(g.val.endsWith("jpg")||g.val.endsWith("jpeg")||g.val.endsWith("png")||g.val.endsWith("gif")||g.val.endsWith("svg")){let d=document.createElement("img");o=T.createDesignItemFromInstance(d,t.serviceContainer,t.instanceServiceContainer),u=o.openGroup("Insert");let h={signal:e.fullName,target:k.property},c=this._bindingsHelper.serializeBinding(d,"src",h);o.setAttribute(c[0],c[1]),o.element.src=g.val}else if(g.val.endsWith("mp4")){let d=document.createElement("video");o=T.createDesignItemFromInstance(d,t.serviceContainer,t.instanceServiceContainer),u=o.openGroup("Insert");let h={signal:e.fullName,target:k.property},c=this._bindingsHelper.serializeBinding(d,"src",h);o.setAttribute(c[0],c[1]),o.element.src=g.val}else{let d=document.createElement("iframe");o=T.createDesignItemFromInstance(d,t.serviceContainer,t.instanceServiceContainer),u=o.openGroup("Insert");let h={signal:e.fullName,target:k.property},c=this._bindingsHelper.serializeBinding(d,"src",h);o.setAttribute(c[0],c[1]),o.element.src=g.val}if(!o){let d=document.createElement("input");o=T.createDesignItemFromInstance(d,t.serviceContainer,t.instanceServiceContainer),u=o.openGroup("Insert");let h=a.writeable!==!1,c={signal:e.fullName,target:k.property,twoWay:h},m=this._bindingsHelper.serializeBinding(d,"value",c);a.type==="boolean"?(m=this._bindingsHelper.serializeBinding(d,"checked",c),o.setAttribute("type","checkbox")):a.role=="date"?(c.twoWay=h,m=this._bindingsHelper.serializeBinding(d,"value-as-number",c),o.setAttribute("type","date"),o.setAttribute("readonly","")):a.role=="datetime"&&(c.twoWay=h,m=this._bindingsHelper.serializeBinding(d,"value-as-number",c),o.setAttribute("type","datetime-local"),o.setAttribute("readonly","")),o.setAttribute(m[0],m[1])}o.setStyle("position","absolute"),o.setStyle("left",p.x+"px"),o.setStyle("top",p.y+"px"),t.instanceServiceContainer.undoService.execute(new Je(t.rootDesignItem,t.rootDesignItem.childCount,o)),u.commit(),requestAnimationFrame(()=>t.instanceServiceContainer.selectionService.setSelectedElements([o]))}}dragOverOnProperty(t,s,e){return"copy"}dropOnProperty(t,s,e,i){if(s.type=="signal"){s.service.setValue(i,s,e.fullName);return}let n={signal:e.fullName,target:k.property};s.propertyType==M.attribute&&(n.target=k.attribute),s.propertyType==M.cssValue&&(n.target=k.css),n.signal=e.fullName,n.twoWay=s.propertyType==M.property||s.propertyType==M.propertyAndAttribute;let l=i[0].openGroup("drop binding");for(let a of i){let p=this._bindingsHelper.serializeBinding(a.element,s.name,n);a.setAttribute(p[0],p[1])}l.commit()}};import{BindingMode as U,BindingTarget as ne,PropertiesHelper as Ue}from"@node-projects/web-component-designer";var re=class r{constructor(t){this._bindingsHelper=t}_bindingsHelper;static type="visualization-binding";getBindings(t){return Array.from(this._bindingsHelper.getBindings(t.element)).map(e=>({targetName:e[1].target===ne.css||e[1].target===ne.attribute?Ue.camelToDashCase(e[0]):e[0],target:e[1].target,mode:e[1].twoWay?U.twoWay:U.oneWay,invert:e[1].inverted,bindableObjectNames:e[1].signal.split(";"),expression:e[1].expression,expressionTwoWay:e[1].expressionTwoWay,converter:e[1].converter,type:r.type,service:this,changedEvents:e[1].events,historic:e[1].historic,writeBackSignal:e[1].writeBackSignal}))}setBinding(t,s){let e={signal:s.bindableObjectNames.join(";"),target:s.target};e.inverted=s.invert,e.twoWay=s.mode==U.twoWay,e.expression=s.expression,e.expressionTwoWay=s.expressionTwoWay,e.historic=s.historic,e.type=s.type,e.converter=s.converters,e.target=s.target,e.events=s.changedEvents;let i=this._bindingsHelper.serializeBinding(t.element,s.targetName,e),n=t.openGroup("edit_binding");return t.setAttribute(i[0],i[1]),n.commit(),!0}clearBinding(t,s,e){let i=this._bindingsHelper.getBindingAttributeName(t.element,s,e);return t.removeAttribute(i),!0}};var le=class{getRefactorings(t){let s=[];for(let e of t){let i=e.serviceContainer.bindingService.getBindings(e);if(i)for(let n of i)for(let l of n.bindableObjectNames){let a="signal",p="";if(l.includes(":")){let o=l.split(":")[0],u=l.substring(o.length+1);u.startsWith("?")&&(u=u.substring(1),p="?",a="property",u.startsWith("?")&&(u=u.substring(1),p="??")),s.push({service:this,name:u,itemType:a,designItem:e,type:"binding",sourceObject:n,display:n.target+"/"+n.targetName+" - "+o+":",shortName:o,prefix:p})}else l.startsWith("?")&&(l=l.substring(1),p="?",a="property",l.startsWith("?")&&(l=l.substring(1),p="??")),s.push({service:this,name:l,itemType:a,designItem:e,type:"binding",sourceObject:n,display:n.target+"/"+n.targetName,prefix:p})}}return s}refactor(t,s,e){let i=t.sourceObject;t.shortName?i.bindableObjectNames=i.bindableObjectNames.map(n=>n==t.shortName+":"+t.prefix+s?t.shortName+":"+t.prefix+e:n):i.bindableObjectNames=i.bindableObjectNames.map(n=>n==t.prefix+s?t.prefix+e:n),t.designItem.serviceContainer.bindingService.setBinding(t.designItem,i)}};var oe=class{dragOverOnProperty(t,s,e){return"copy"}dropOnProperty(t,s,e,i){s.service.setValue(i,s,e.text)}};import{BindingTarget as b}from"@node-projects/web-component-designer";var ce=class{getRefactorings(t){let s=[];for(let e of t)for(let i of e.attributes())if(i[0][0]=="@"){let n=i[1];if(n[0]=="{"){let l=JSON.parse(n);if("commands"in l)for(let a of l.commands){for(let p in a){let o=a[p];if(o!=null&&typeof o=="object"){let u=o;if(u.source==="signal")s.push({name:u.name,itemType:"signal",target:b.event,targetName:i[0],service:this,designItem:e,type:"script",sourceObject:l,display:a.type+"/"+i[0].substring(1)+"/"+p+"[signal]",refactor:g=>u.name=g});else if(u.source==="property")s.push({name:u.name,itemType:"property",target:b.event,targetName:i[0],service:this,designItem:e,type:"script",sourceObject:l,display:a.type+"/"+i[0].substring(1)+"/"+p+"[property]",refactor:g=>u.name=g});else if(u.source==="complexString")for(let g of u.name.matchAll(/\{(.*?)\}/g)){let d=g[0],h=g[1];if(h[0]==="?"){let c="?";h=h.substring(1),h[0]==="?"&&(c="??",h=h.substring(1)),s.push({name:h,itemType:"property",target:b.event,targetName:i[0],service:this,designItem:e,type:"script",sourceObject:l,display:a.type+"/"+i[0].substring(1)+"/"+p+"[complexString]->property",refactor:m=>u.name=u.name.replace(d,"{"+c+m+"}")})}else s.push({name:h,itemType:"signal",target:b.event,targetName:i[0],service:this,designItem:e,type:"script",sourceObject:l,display:a.type+"/"+i[0].substring(1)+"/"+p+"[complexString]->signal",refactor:c=>u.name=u.name.replace(d,"{"+c+"}")})}}}switch(a.type){case"SetSignalValue":a.signal&&typeof a.signal=="string"&&s.push({name:a.signal,itemType:"signal",target:b.event,targetName:i[0],display:a.type+"/"+i[0].substring(1)+"/signal",service:this,designItem:e,type:"script",sourceObject:l,refactor:p=>a.signal=p});break;case"ToggleSignalValue":a.signal&&typeof a.signal=="string"&&s.push({name:a.signal,itemType:"signal",target:b.event,targetName:i[0],display:a.type+"/"+i[0].substring(1)+"/signal",service:this,designItem:e,type:"script",sourceObject:l,refactor:p=>a.signal=p});break;case"IncrementSignalValue":a.signal&&typeof a.signal=="string"&&s.push({name:a.signal,itemType:"signal",target:b.event,targetName:i[0],display:a.type+"/"+i[0].substring(1)+"/signal",service:this,designItem:e,type:"script",sourceObject:l,refactor:p=>a.signal=p});break;case"DecrementSignalValue":a.signal&&typeof a.signal=="string"&&s.push({name:a.signal,itemType:"signal",target:b.event,targetName:i[0],display:a.type+"/"+i[0].substring(1)+"/signal",service:this,designItem:e,type:"script",sourceObject:l,refactor:p=>a.signal=p});break;case"SetBitInSignal":a.signal&&typeof a.signal=="string"&&s.push({name:a.signal,itemType:"signal",target:b.event,targetName:i[0],display:a.type+"/"+i[0].substring(1)+"/signal",service:this,designItem:e,type:"script",sourceObject:l,refactor:p=>a.signal=p});break;case"ClearBitInSignal":a.signal&&typeof a.signal=="string"&&s.push({name:a.signal,itemType:"signal",target:b.event,targetName:i[0],display:a.type+"/"+i[0].substring(1)+"/signal",service:this,designItem:e,type:"script",sourceObject:l,refactor:p=>a.signal=p});break;case"ToggleBitInSignal":a.signal&&typeof a.signal=="string"&&s.push({name:a.signal,itemType:"signal",target:b.event,targetName:i[0],display:a.type+"/"+i[0].substring(1)+"/signal",service:this,designItem:e,type:"script",sourceObject:l,refactor:p=>a.signal=p});break;case"OpenScreen":a.screen&&typeof a.screen=="string"&&s.push({name:a.screen,itemType:"screen",target:b.event,targetName:i[0],display:a.type+"/"+i[0].substring(1)+"/screen",service:this,designItem:e,type:"script",sourceObject:l,refactor:p=>a.screen=p});break;case"OpenDialog":a.screen&&typeof a.screen=="string"&&s.push({name:a.screen,itemType:"screen",target:b.event,targetName:i[0],display:a.type+"/"+i[0].substring(1)+"/screen",service:this,designItem:e,type:"script",sourceObject:l,refactor:p=>a.screen=p});break;case"CalculateSignalValue":a.targetSignal&&typeof a.targetSignal=="string"&&s.push({name:a.targetSignal,itemType:"signal",target:b.event,targetName:i[0],display:a.type+"/"+i[0].substring(1)+"/targetSignal",service:this,designItem:e,type:"script",sourceObject:l,refactor:p=>a.targetSignal=p});break;case"SubscribeSignal":a.signal&&typeof a.signal=="string"&&s.push({name:a.signal,itemType:"signal",target:b.event,targetName:i[0],display:a.type+"/"+i[0].substring(1)+"/signal",service:this,designItem:e,type:"script",sourceObject:l,refactor:p=>a.signal=p});break;case"UnsubscribeSignal":a.signal&&typeof a.signal=="string"&&s.push({name:a.signal,itemType:"signal",target:b.event,targetName:i[0],display:a.type+"/"+i[0].substring(1)+"/signal",service:this,designItem:e,type:"script",sourceObject:l,refactor:p=>a.signal=p});break;case"ShowMessageBox":a.resultSignal&&typeof a.resultSignal=="string"&&s.push({name:a.resultSignal,itemType:"signal",target:b.event,targetName:i[0],display:a.type+"/"+i[0].substring(1)+"/resultSignal",service:this,designItem:e,type:"script",sourceObject:l,refactor:p=>a.resultSignal=p});break}}else"blocks"in l;if("parameters"in l)for(let a in l.parameters)typeof l.parameters[a]=="string"&&s.push({name:l.parameters[a],itemType:"parameter",target:b.event,targetName:i[0],service:this,designItem:e,type:"script",sourceObject:l,display:i[0].substring(1)+"/parameters/"+a,refactor:p=>l.parameters[a]=p})}}return s}refactor(t,s,e){t.refactor(e);let i=JSON.stringify(t.sourceObject);t.designItem.setAttribute(t.targetName,i)}};import{BasePropertyEditor as Xe}from"@node-projects/web-component-designer";var pe=class extends Xe{_ip;_container;constructor(t,s){super(t),this._container=document.createElement("div"),this._container.style.display="flex",this._ip=document.createElement("input"),this._ip.onchange=i=>this._valueChanged(this._ip.value),this._ip.onfocus=i=>{this._ip.selectionStart=0,this._ip.selectionEnd=this._ip.value?.length},this._container.appendChild(this._ip);let e=document.createElement("button");e.textContent="...",e.onclick=async()=>{let i=s.createBindableObjectBrowser();i.initialize(this.designItems[0].serviceContainer,this.designItems[0].instanceServiceContainer,"property"),i.title="select signal...";let n=new AbortController;i.objectDoubleclicked.on(()=>{n.abort(),this._ip.value=i.selectedObject.fullName,this._valueChanged(this._ip.value)}),await s.openConfirmation(i,{x:100,y:100,width:400,height:300,abortSignal:n.signal})&&(this._ip.value=i.selectedObject.fullName,this._valueChanged(this._ip.value))},this._container.appendChild(e),this.element=this._container}refreshValue(t,s){s==null?this._ip.value="":this._ip.value=s}};export{ae as BindableObjectDragDropService,D as BindingsEditor,E as BindingsEditorHistoric,ee as BindingsHelper,C as BlocklyScriptEditor,L as EventAssignment,O as ParameterEditor,oe as PropertyGridDragDropService,te as Script,ce as ScriptRefactorService,ie as ScriptSystem,pe as SignalPropertyEditor,I as SimpleScriptEditor,le as VisualizationBindingsRefactorService,re as VisualizationBindingsService,W as VisualizationPropertyGrid,B as bindingPrefixAttribute,R as bindingPrefixClass,w as bindingPrefixContent,V as bindingPrefixCss,A as bindingPrefixCssVar,Pe as bindingPrefixInsideCss,Me as bindingPrefixInsideCssVarName,S as bindingPrefixProperty,F as bindingPrefixVisible,Ft as bindingsInCssRegex,X as generateEventCodeFromBlockly,P as getNestedProperty,z as isLit,J as parseBindingString};
384
+ </div>`;static scriptTypeColors={js:"purple",blockly:"yellow",script:"lightgreen",empty:"pink"};static is="node-projects-visualization-event-assignment";constructor(){super(),this._restoreCachedInititalValues()}ready(){this._bindingsParse()}_blocklyToolbox;_instanceServiceContainer;_selectionChangedHandler;_selectedItems;_visualizationHandler;_visualizationShell;_scriptCommandsTypeInfo;_propertiesTypeInfo;events;initialize(t,s,e,i,r){this._visualizationHandler=t,this._visualizationShell=s,this._scriptCommandsTypeInfo=e,this._propertiesTypeInfo=i,this._blocklyToolbox=r}set instanceServiceContainer(t){this._instanceServiceContainer=t,this._selectionChangedHandler?.dispose(),this._selectionChangedHandler=this._instanceServiceContainer.selectionService.onSelectionChanged.on(s=>{this.selectedItems=s.selectedElements}),this.selectedItems=this._instanceServiceContainer.selectionService.selectedElements}_createControlsForScript(t){switch(this._getScriptType(t)){case"none":return""}return this.constructor.editRowTemplate.content.cloneNode(!0)}_getScriptName(t){if(this.selectedItems[0].hasAttribute("@"+t.name)){let s=this.selectedItems[0].getAttribute("@"+t.name);if(s[0]==="{"){if(s.includes("name"))return JSON.parse(s).name}else return s}return null}async _changeScriptName(t,s){if(t.key=="Enter"&&this.selectedItems&&this.selectedItems.length&&this.selectedItems[0].hasAttribute("@"+s.name)){let e=t.target.value,i=this.selectedItems[0].getAttribute("@"+s.name);if(i.startsWith("{")){let r=JSON.parse(i);r.name=e,this._selectedItems[0].setAttribute("@"+s.name,JSON.stringify(r))}else this._selectedItems[0].setAttribute("@"+s.name,e)}}_getRelativeSignalsPath(t){if(this.selectedItems[0].hasAttribute("@"+t.name)){let s=this.selectedItems[0].getAttribute("@"+t.name);if(s[0]==="{"&&s.includes("relativeSignalsPath"))return JSON.parse(s).relativeSignalsPath}return null}async _changeRelativeSignalsPath(t,s){if(t.key=="Enter"&&this.selectedItems&&this.selectedItems.length&&this.selectedItems[0].hasAttribute("@"+s.name)){let e=t.target.value,i=this.selectedItems[0].getAttribute("@"+s.name);if(i.startsWith("{")){let r=JSON.parse(i);r.relativeSignalsPath=e,this._selectedItems[0].setAttribute("@"+s.name,JSON.stringify(r))}else{let r={name:i,relativeSignalsPath:e};this._selectedItems[0].setAttribute("@"+s.name,JSON.stringify(r))}}}_hasParameters(t){return this.selectedItems[0].hasAttribute("@"+t.name)?this.selectedItems[0].getAttribute("@"+t.name).includes("parameters"):!1}_getScriptTypeColor(t){let s=this._getScriptType(t);return n.scriptTypeColors[s]??"white"}_getScriptType(t){if(t.designItem.hasAttribute("@"+t.name)){let s=t.designItem.getAttribute("@"+t.name);if(s.startsWith("{")){let e=JSON.parse(s);return"blocks"in e?"blockly":"commands"in e?"script":"js"}else return s==""?"empty":"js"}return"none"}_getEventMethodname(t){return this.selectedItems.length?this.selectedItems[0].getAttribute("@"+t.name):""}_inputMthName(t,s){let e=t.target;this.selectedItems[0].setAttribute("@"+s.name,e.value)}_ctxMenu(t,s){t.preventDefault();let e=this._getScriptType(s);if(e=="empty")this._showContextMenuAssignScript(t,s,!0);else if(e!="none"){let i=[{title:"remove",action:()=>{this.selectedItems[0].removeAttribute("@"+s.name),this._bindingsRefresh()}},{title:"-"},{title:"copy",action:()=>{Q(this.selectedItems[0].getAttribute("@"+s.name))}},{title:"paste",action:async()=>{this.selectedItems[0].setAttribute("@"+s.name,await ee()),this._bindingsRefresh()}}];K.show(i,t)}else this._showContextMenuAssignScript(t,s,!0)}async _addEvent(t){if(t.key=="Enter"){let s=this._getDomElement("addEventInput");this._selectedItems[0].setAttribute("@"+Pe.camelToDashCase(s.value.replaceAll(" ","-")),""),s.value="",this.scrollTop=0,this.refresh()}}_createAssignScriptContextMenu(t,s){let e=[{title:"Simple Script",action:()=>{this._editEvent("script",t,s)}},{title:"Javascript",action:()=>{let r=prompt("name of function ?");r&&(this._selectedItems[0].setAttribute("@"+s.name,r),this.refresh(),this._editEvent("js",null,s))}},{title:"Blockly",action:()=>{this._editBlockly(null,s)}}],i=this._getScriptType(s);return i!="none"&&(e.push({title:"-"}),e.push({title:"remove",action:()=>{this.selectedItems[0].removeAttribute("@"+s.name),this._bindingsRefresh()}})),i!="empty"&&e.push({title:"-"},{title:"copy",action:()=>{Q(this.selectedItems[0].getAttribute("@"+s.name))}},{title:"paste",action:async()=>{this.selectedItems[0].setAttribute("@"+s.name,await ee()),this._bindingsRefresh()}}),e}async _showContextMenuAssignScript(t,s,e){t.preventDefault();let i=this._getScriptType(s);if(i!="none"&&i!="empty"&&!e)this._editEvent(i,t,s);else{let r=this._createAssignScriptContextMenu(t,s);K.show(r,t)}}async _editParameter(t,s){let e=new I,i={};e.title="ParameterEditor for '"+s.name+"' of '"+s.designItem.name+"'";let r=s.designItem.getAttribute("@"+s.name);if(r&&r[0]=="{")try{i=JSON.parse(r).parameters}catch{}if(e.setParametersObject(i),await this._visualizationShell.openConfirmation(e,{x:100,y:100,width:700,height:500})){let a=e.getParametersObject(),l={name:r,parameters:a};r&&r[0]=="{"&&(l=JSON.parse(r),l.parameters=a),a==null&&delete l.parameters;let c=JSON.stringify(l);s.designItem.setAttribute("@"+s.name,c),this._bindingsRefresh()}}async _editBlockly(t,s){let e=new C(this._blocklyToolbox);e.title="Blockly Script for '"+s.name+"' of '"+s.designItem.name+"'";let i=s.designItem.getAttribute("@"+s.name),r=null,o=null;if(i){let l=JSON.parse(i);r=l.parameters,o=l.relativeSignalsPath,e.load(l)}if(await this._visualizationShell.openConfirmation(e,{x:100,y:100,width:700,height:500})){let l=e.save();r&&(l.parameters=r),o&&(l.relativeSignalsPath=o),s.designItem.setAttribute("@"+s.name,JSON.stringify(l)),this._bindingsRefresh()}}async _editJavascript(t,s){}async _editSimpleScript(t,s){let e=s.designItem.getAttribute("@"+s.name);if(!e||e.startsWith("{")){let i={commands:[]},r=null,o=null;e&&(i=JSON.parse(e),r=i.parameters,o=i.relativeSignalsPath);let a=new O;if(a.serviceContainer=s.designItem.serviceContainer,a.instanceServiceContainer=s.designItem.instanceServiceContainer,a.scriptCommandsTypeInfo=this._scriptCommandsTypeInfo,a.propertiesTypeInfo=this._propertiesTypeInfo,a.visualizationShell=this._visualizationShell,a.visualizationHandler=this._visualizationHandler,a.loadScript(i),a.title="Script '"+s.name+"' on "+s.designItem.name,await this._visualizationShell.openConfirmation(a,{x:100,y:100,width:600,height:500})){let c=a.getScriptCommands();if(c&&c.length){let p={commands:c};r&&(p.parameters=r),o&&(p.relativeSignalsPath=o);let d=JSON.stringify(p);s.designItem.setAttribute("@"+s.name,d),this._bindingsRefresh()}}}}async _editEvent(t,s,e){t=="js"?this._editJavascript(s,e):t=="blockly"?this._editBlockly(s,e):this._editSimpleScript(s,e)}refresh(){this._selectedItems!=null&&this._selectedItems.length?this.events=this._selectedItems[0].serviceContainer.getLastServiceWhere("eventsService",t=>t.isHandledElementFromEventsService(this._selectedItems[0])).getPossibleEvents(this._selectedItems[0]).map(t=>({...t,designItem:this._selectedItems[0]})):this.events=[],this._bindingsRefresh()}get selectedItems(){return this._selectedItems}set selectedItems(t){this._selectedItems!=t&&(this._selectedItems=t,this.refresh())}};customElements.define(P.is,P);import{TypedEvent as Le,cssFromString as Me}from"@node-projects/base-custom-webcomponent";import{BindingTarget as f}from"@node-projects/web-component-designer/dist/elements/item/BindingTarget.js";import{PropertiesHelper as v}from"@node-projects/web-component-designer/dist/elements/services/propertiesService/services/PropertiesHelper.js";var S="bind-prop:",B="bind-attr:",R="bind-class:",V="bind-css:",A="bind-cssvar:",w="bind-content:",F="bind-visible:",He="bind(",Fe="--tmpBinding_",Xt=/{{(.*)}}/;function z(n){return n.constructor?.elementProperties!=null}function U(n){let t=[],s=[],e="";for(let i=0;i<n.length;i++)n[i]=="{"?(t.push(e),e=""):n[i]=="}"?(s.push(e),e=""):e+=n[i];return t.push(e),{parts:t,signals:s}}function L(n,t){let s=t.split("."),e=n;for(let i of s){if(e==null||typeof e!="object")return;e=e[i]}return e}var J=class{parts;signals;values;unsubscribeTargetValue;cleanupCalls=[];combinedName;disposed;valueChangedCb;visualizationHandler;element;relativeSignalPath;constructor(t,s,e,i,r,o,a,l){this.visualizationHandler=s,this.valueChangedCb=i,this.element=r,this.relativeSignalPath=o,this.parseIndirectBinding(e),this.values=new Array(this.signals.length);for(let c=0;c<this.signals.length;c++){let p=this.signals[c];if(p[0]==="?"&&p[1]==="?"){let h=p.substring(2);if(h.includes(".")){let u=L(a,h);this.handleValueChanged(u,c)}else{this.handleValueChanged(a[h],c);let u=()=>this.handleValueChanged(a[h],c),g=t.getChangedEventName(a,h);a.addEventListener(g,u),this.cleanupCalls.push(()=>a.removeEventListener(g,u))}continue}else if(p[0]==="#"&&p[1]==="#"){let h=p.substring(2);if(h.includes(".")){let u=L(r,h);this.handleValueChanged(u,c)}else{this.handleValueChanged(r[h],c);let u=()=>this.handleValueChanged(r[h],c),g=t.getChangedEventName(r,h);r.addEventListener(g,u),this.cleanupCalls.push(()=>r.removeEventListener(g,u))}continue}else if(p[0]==="\xA7"){let h=p.substring(1),u=l.valueProvider(h,{element:r,relativeSignalPath:o,root:a});u instanceof Promise?u.then(y=>this.handleValueChanged(y,c)):this.handleValueChanged(u,c),l.valueChangedCallbacks||(l.valueChangedCallbacks=new Map);let g=l.valueChangedCallbacks.get(h);g==null&&(g=[],l.valueChangedCallbacks.set(h,g)),g.push(()=>{let y=l.valueProvider(h,{element:r,relativeSignalPath:o,root:a});y instanceof Promise?y.then(x=>this.handleValueChanged(x,c)):this.handleValueChanged(y,c)})}else(p[0]==="?"||p[0]==="#")&&(p.includes(".")?p=L(a,p.substring(1)):p=a[p.substring(1)]);let d=(h,u)=>this.handleValueChanged(u.val,c),m=this.visualizationHandler.subscribeState(p,d);this.cleanupCalls.push(()=>this.visualizationHandler.unsubscribeState(this.signals[c],d,m))}}parseIndirectBinding(t){let{parts:s,signals:e}=U(t);this.parts=s,this.signals=e;for(let i=0;i<e.length;i++)e[i][0]=="."&&(e[i]=this.visualizationHandler.getNormalizedSignalName(e[i],this.relativeSignalPath,this.element))}handleValueChanged(t,s){this.values[s]=t;let e=this.parts[0];for(let i=0;i<this.parts.length-1;i++){let r=this.values[i];if(r==null)return;e+=r+this.parts[i+1]}if(e[0]=="."&&(e=this.visualizationHandler.getNormalizedSignalName(e,this.relativeSignalPath,this.element)),this.combinedName!=e&&(this.unsubscribeTargetValue&&this.visualizationHandler.unsubscribeState(this.combinedName,this.unsubscribeTargetValue[0],this.unsubscribeTargetValue[1]),!this.disposed)){this.combinedName=e;let i=(r,o)=>this.valueChangedCb(o);this.unsubscribeTargetValue=[i,this.visualizationHandler.subscribeState(e,i)]}}dispose(){this.disposed=!0,this.unsubscribeTargetValue&&(this.visualizationHandler.unsubscribeState(this.combinedName,this.unsubscribeTargetValue[0],this.unsubscribeTargetValue[1]),this.unsubscribeTargetValue=null);for(let t=0;t<this.signals.length;t++)this.cleanupCalls[t]()}setState(t){this.disposed||this.visualizationHandler.setState(this.combinedName,t)}},te=class n{_visualizationHandler;namedConverterCallback;constructor(t){this._visualizationHandler=t}getChangedEventName(t,s){let e=s.indexOf("::");return e>=0?s.substring(e+2):t instanceof HTMLInputElement||t instanceof HTMLSelectElement?"change":z(t)?v.camelToDashCase(s):v.camelToDashCase(s)+"-changed"}parseBinding(t,s,e,i,r){let o=s.substring(r.length);if(i===f.cssvar&&(o="--"+o),!e.startsWith("{")){let l={signal:e,target:i};if(e[0]==="="){if(e=e.substring(1),l.signal=e,e.includes("::")){let c=e.split("::");e=c[0],l.signal=e,l.events=c[1].split(",")}l.twoWay=!0,l.events||(t instanceof HTMLInputElement?l.events=[this.getChangedEventName(t,o)]:t instanceof HTMLSelectElement?l.events=[this.getChangedEventName(t,o)]:z(t)?l.events=[this.getChangedEventName(t,o)]:(l.events=[this.getChangedEventName(t,o)],l.maybeLitElement=!0,l.litEventNames=[this.getChangedEventName(t,o)]))}if(e[0]==="!"&&(l.signal=e.substring(1),l.inverted=!0),l.signal.includes(";")){let c=l.signal.split(";");l.expression=c.pop(),l.signal=c.join(";")}return i===f.cssvar||i===f.class?[n.dotToCamelCase(o),l]:i===f.attribute?[o,l]:[v.dashToCamelCase(o),l]}let a=JSON.parse(e);return a.target=i,a.twoWay&&(a.events==null||a.events.length==0)&&(t instanceof HTMLInputElement?a.events=["change"]:t instanceof HTMLSelectElement?a.events=["change"]:a.events=[this.getChangedEventName(t,o)]),i===f.cssvar||i===f.class?[n.dotToCamelCase(o),a]:i===f.attribute?[o,a]:[v.dashToCamelCase(o),a]}serializeBinding(t,s,e){let i={...e};delete i.type,e.twoWay?e.events!=null&&e.events.length==1&&(t instanceof HTMLInputElement&&e.events?.[0]=="change"||t instanceof HTMLSelectElement&&e.events?.[0]=="change"||z(t)&&e.events?.[0]==s||!z(t)&&e.events?.[0]==s+"-changed")&&delete i.events:(delete i.events,delete i.expressionTwoWay);let r=i.twoWay&&i.events?.length>0?"::"+i.events.join(","):"",o=!1;return(r&&e.expression?.includes("::")||e.expressionTwoWay?.includes("::"))&&(o=!0),e.signal.trim()[0]=="{"&&(o=!0),!o&&e.target==f.property&&!e.expression&&!e.expressionTwoWay&&e.converter==null&&!e.historic&&!e.writeBackSignal?s=="textContent"?[w+"text",(e.twoWay?"=":"")+(e.inverted?"!":"")+e.signal+(!e.twoWay&&e.signal.includes(";")?";":"")+r]:s=="innerHTML"?[w+"html",(e.twoWay?"=":"")+(e.inverted?"!":"")+e.signal+(!e.twoWay&&e.signal.includes(";")?";":"")+r]:[S+v.camelToDashCase(s),(e.twoWay?"=":"")+(e.inverted?"!":"")+e.signal+(!e.twoWay&&e.signal.includes(";")?";":"")+r]:!o&&e.target==f.property&&e.expression&&!e.expression.includes(`
385
+ `)&&!e.expression.includes(";")&&!e.expressionTwoWay&&e.converter==null&&!e.historic&&!e.writeBackSignal?s=="textContent"?[w+"text",(e.inverted?"!":"")+e.signal+";"+e.expression+r]:s=="innerHTML"?[w+"html",(e.inverted?"!":"")+e.signal+";"+e.expression+r]:[S+v.camelToDashCase(s),(e.twoWay?"=":"")+(e.inverted?"!":"")+e.signal+";"+e.expression+r]:!o&&e.target==f.attribute&&!e.expression&&!e.expressionTwoWay&&e.converter==null&&!e.historic&&!e.writeBackSignal?[B+v.camelToDashCase(s),(e.twoWay?"=":"")+(e.inverted?"!":"")+e.signal+(!e.twoWay&&e.signal.includes(";")?";":"")+r]:!o&&e.target==f.attribute&&e.expression&&!e.expression.includes(`
386
+ `)&&!e.expression.includes(";")&&!e.expressionTwoWay&&e.converter==null&&!e.historic&&!e.writeBackSignal?[B+v.camelToDashCase(s),(e.twoWay?"=":"")+(e.inverted?"!":"")+e.signal+";"+e.expression+r]:!o&&e.target==f.class&&!e.expression&&!e.expressionTwoWay&&e.converter==null&&!e.historic&&!e.writeBackSignal?[R+v.camelToDashCase(s),(e.inverted?"!":"")+e.signal+(!e.twoWay&&e.signal.includes(";")?";":"")+r]:!o&&e.target==f.class&&e.expression&&!e.expression.includes(`
387
+ `)&&!e.expression.includes(";")&&!e.expressionTwoWay&&e.converter==null&&!e.historic&&!e.writeBackSignal?[R+v.camelToDashCase(s),(e.inverted?"!":"")+e.signal+";"+e.expression+r]:!o&&e.target==f.css&&!e.expression&&!e.expressionTwoWay&&e.converter==null&&!e.historic&&!e.writeBackSignal?[V+v.camelToDashCase(s),(e.inverted?"!":"")+e.signal+(!e.twoWay&&e.signal.includes(";")?";":"")+r]:!o&&e.target==f.css&&e.expression&&!e.expression.includes(`
388
+ `)&&!e.expression.includes(";")&&!e.expressionTwoWay&&e.converter==null&&!e.historic&&!e.writeBackSignal?[V+v.camelToDashCase(s),(e.inverted?"!":"")+e.signal+";"+e.expression+r]:!o&&e.target==f.cssvar&&!e.expression&&!e.expressionTwoWay&&e.converter==null&&!e.historic&&!e.writeBackSignal?[A+n.camelToDotCase(s.substring(2)),(e.inverted?"!":"")+e.signal+(!e.twoWay&&e.signal.includes(";")?";":"")+r]:!o&&e.target==f.cssvar&&e.expression&&!e.expression.includes(`
389
+ `)&&!e.expression.includes(";")&&!e.expressionTwoWay&&e.converter==null&&!e.historic&&!e.writeBackSignal?[A+v.camelToDashCase(s),(e.inverted?"!":"")+e.signal+";"+e.expression+r]:((e.inverted===null||e.inverted===!1)&&delete i.inverted,(e.expression===null||e.expression==="")&&delete i.expression,(e.expressionTwoWay===null||e.expressionTwoWay==="")&&delete i.expressionTwoWay,(e.twoWay===null||e.twoWay===!1)&&delete i.twoWay,delete i.target,e.historic||delete i.historic,e.target==f.content?[w+"html",JSON.stringify(i)]:e.target==f.attribute?[B+v.camelToDashCase(s),JSON.stringify(i)]:e.target==f.class?[R+n.camelToDotCase(s),JSON.stringify(i)]:e.target==f.css?[V+v.camelToDashCase(s),JSON.stringify(i)]:e.target==f.cssvar?[A+n.camelToDotCase(s.substring(2)),JSON.stringify(i)]:e.target==f.property&&s=="innerHTML"?[w+"html",JSON.stringify(i)]:e.target==f.property&&s=="textContent"?[w+"text",JSON.stringify(i)]:[S+v.camelToDashCase(s),JSON.stringify(i)])}getBindingAttributeName(t,s,e){return e==f.attribute?B+v.camelToDashCase(s):e==f.class?R+n.camelToDotCase(s):e==f.css?V+v.camelToDashCase(s):e==f.visible?F:e==f.cssvar?A+n.camelToDotCase(s):e==f.property&&s=="innerHTML"?w+"html":e==f.property&&s=="textContent"?w+"text":S+v.camelToDashCase(s)}*getBindings(t){if(t.attributes)for(let s of t.attributes)s.name.startsWith(S)?yield this.parseBinding(t,s.name,s.value,f.property,S):s.name.startsWith(w)?yield this.parseBinding(t,s.name==="bind-content:html"?"bind-prop:inner-h-t-m-l":"bind-prop:text-content",s.value,f.property,S):s.name.startsWith(B)?yield this.parseBinding(t,s.name,s.value,f.attribute,B):s.name.startsWith(R)?yield this.parseBinding(t,s.name,s.value,f.class,R):s.name.startsWith(V)?yield this.parseBinding(t,s.name,s.value,f.css,V):s.name.startsWith(A)?yield this.parseBinding(t,s.name,s.value,f.cssvar,A):s.name.startsWith(F)&&(yield this.parseBinding(t,s.name,s.value,f.visible,F))}applyAllBindings(t,s,e,i,r){let o=[],a=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT),l;for(;l=a.nextNode();){let c=this.getBindings(l);for(let p of c)try{let d=this.applyBinding(l,p,s,e,i);if(o.push(d),p[1].maybeLitElement&&l.localName.includes("-")&&!customElements.get(l.localName)){let m=l,h=p;customElements.whenDefined(l.localName).then(()=>{z(m)&&(d(),h[1].events=h[1].litEventNames,o.push(this.applyBinding(m,h,s,e,i)))})}}catch(d){console.warn("error applying binding",l,p,d)}if(r&&r(l)){l=a.nextSibling();continue}}return o}static#e=0;async parseCssBindings(t,s,e,i){let r=await import("@node-projects/css-parser"),o=r.parse(t),a;for(let c of o.stylesheet.rules)if(c.type===r.CssTypes.rule){for(let p of c.declarations)if(p.type===r.CssTypes.declaration&&p.value.includes(He)){let d=this.parseCssBinding(p.value,s,e,i);p.value=d[0],a?a.push(...d[1]):a=d[1]}}let l=r.stringify(o,{indent:"",compress:!0});return[Me(l),a]}parseCssBinding(t,s,e,i,r){t=t.trim();let o="",a="",l=!1,c="",p=!1,d=null,m=[];for(let h=0;h<t.length;h++){let u=t[h];if(l)if(p)c+=u;else if(d&&u==="\\")p=!0;else if(u===d)d=null;else if(d===null&&u===")"){let g=n.#e++,y=Fe+g,x=[y,{signal:c,target:f.cssvar}];c.startsWith("{")&&(x=JSON.parse(c)),m.push(this.applyBinding(s,x,e,i,r)),o+="var("+y+")",l=!1,c=""}else c+=u;else u==="("?(a!=="bind"?(o+=a,o+=u):(l=!0,t[h+1]==="'"||t[h+1]==='"'?(h++,d=t[h]):d=null),a=""):u===" "||u===","||u==="("||u==="+"||u==="-"||u==="*"||u==="/"?(o+=a+u,a=""):a+=u}return[o+a,m]}applyBinding(t,s,e,i,r){let o=[],a,l=()=>{for(let m of o)this._visualizationHandler.unsubscribeState(m[0],m[1],m[2]);if(a)for(let m of a)m()},c=s[1].signal.split(";"),p=new Array(c.length);for(let m=0;m<c.length;m++){let h=c[m];if(p[m]="__"+m,h.includes(":")){let u=h.split(":");p[m]=u[0],h=u[1],c[m]=h}if(h[0]==="?"){if(i){let u=h.substring(1);if(u[0]=="?")c[m]=u;else{c[m]=i[u],u[0]==="$"&&(u=u.substring(1),c[m]="$"+i[u]);let g=()=>{l(),this.applyBinding(t,s,e,i,r)},y=this.getChangedEventName(i,u);i.addEventListener(y,g),a||(a=[]),a.push(()=>i.removeEventListener(y,g))}}}else if(h[0]==="#"){let u=h.substring(1);if(u[0]=="#")c[m]=u;else{c[m]=i[u],u[0]==="$"&&(u=u.substring(1),c[m]="$"+i[u]);let g=()=>{l(),this.applyBinding(t,s,e,i,r)},y=this.getChangedEventName(t,u);i.addEventListener(y,g),a||(a=[]),a.push(()=>i.removeEventListener(y,g))}}h[0]==="."&&(c[m]=this._visualizationHandler.getNormalizedSignalName(h,e,t))}let d=new Array(c.length);for(let m=0;m<c.length;m++){let h=c[m];if(h[0]==="?"){if(i){let u=h.substring(1),g=()=>{let y=!1;y||(y=!0,this.handleValueChanged(t,i,s,i[u],d,m,p,!1,e),y=!1)};i.addEventListener(v.camelToDashCase(u)+"-changed",g),a||(a=[]),a.push(()=>i.removeEventListener(v.camelToDashCase(u)+"-changed",g));try{this.handleValueChanged(t,i,s,i[u],d,m,p,!1,e)}catch(y){console.error(y)}s[1].twoWay&&m==0&&this.addTwoWayBinding(s,t,y=>i[u]=y)}}else if(h[0]==="#"){let u=h.substring(1),g=()=>{let y=!1;y||(y=!0,this.handleValueChanged(t,i,s,t[u],d,m,p,!1,e),y=!1)};t.addEventListener(v.camelToDashCase(u)+"-changed",g),a||(a=[]),a.push(()=>t.removeEventListener(v.camelToDashCase(u)+"-changed",g));try{this.handleValueChanged(t,i,s,t[u],d,m,p,!1,e)}catch(y){console.error(y)}s[1].twoWay&&m==0&&this.addTwoWayBinding(s,t,y=>t[u]=y)}else if(h[0]==="$"){let u=h.substring(1);u[0]==="."&&(u=this._visualizationHandler.getNormalizedSignalName(u,e,t)),this._visualizationHandler.getObject(u).then(g=>{this.handleValueChanged(t,i,s,g,d,m,p,!0,e)})}else if(h[0]==="\xA7"){let u=h.substring(1),g=r.valueProvider(u,{element:t,binding:s,relativeSignalPath:e,root:i});g instanceof Promise?g.then(x=>this.handleValueChanged(t,i,s,x,d,m,p,!0,e)):this.handleValueChanged(t,i,s,g,d,m,p,!0,e),r.valueChangedCallbacks||(r.valueChangedCallbacks=new Map);let y=r.valueChangedCallbacks.get(u);y==null&&(y=[],r.valueChangedCallbacks.set(u,y)),y.push(()=>{let x=r.valueProvider(u,{element:t,binding:s,relativeSignalPath:e,root:i});x instanceof Promise?x.then(he=>this.handleValueChanged(t,i,s,he,d,m,p,!0,e)):this.handleValueChanged(t,i,s,x,d,m,p,!0,e)})}else if(h.includes("{")){let u=new J(this,this._visualizationHandler,h,g=>this.handleValueChanged(t,i,s,g.val,d,m,p,!1,e),t,e,i,r);a||(a=[]),a.push(()=>u.dispose()),s[1].twoWay&&m==0&&this.addTwoWayBinding(s,t,g=>u.setState(g))}else if(s[1].historic)if(s[1].historic.reloadInterval){let u={timerId:-1},g=async()=>{let y=await this._visualizationHandler.getHistoricData(h,s[1].historic);this.handleValueChanged(t,i,s,y?.values,d,m,p,!0,e),u.timerId!==null&&(u.timerId=setTimeout(g,s[1].historic.reloadInterval))};g(),a||(a=[]),a.push(()=>{u.timerId>0&&clearTimeout(u.timerId),u.timerId=null})}else this._visualizationHandler.getHistoricData(h,s[1].historic).then(u=>this.handleValueChanged(t,i,s,u?.values,d,m,p,!0,e));else{let u=(g,y)=>this.handleValueChanged(t,i,s,y.val,d,m,p,!1,e);o.push([h,u,this._visualizationHandler.subscribeState(h,u)]),this._visualizationHandler.getState(h).then(g=>this.handleValueChanged(t,i,s,g?.val,d,m,p,!1,e)),s[1].twoWay&&m==0&&this.addTwoWayBinding(s,t,g=>this._visualizationHandler.setState(h,g))}}return l}addTwoWayBinding(t,s,e){t[1].expressionTwoWay&&(t[1].compiledExpressionTwoWay||(t[1].expressionTwoWay.includes("return ")?t[1].compiledExpressionTwoWay=new Function(["value"],t[1].expressionTwoWay):t[1].compiledExpressionTwoWay=new Function(["value"],"return "+t[1].expressionTwoWay)));for(let i of t[1].events){let r=s[i];r instanceof Le?r.on(()=>{let o;t[1].target==f.attribute?o=s.getAttribute(t[0]):o=s[t[0]],o=n.parseValueWithType(o,t),t[1].compiledExpressionTwoWay&&(o=t[1].compiledExpressionTwoWay(o)),e(o)}):s.addEventListener(i,o=>{let a;t[1].target==f.attribute?a=s.getAttribute(t[0]):a=s[t[0]],a=n.parseValueWithType(a,t),t[1].compiledExpressionTwoWay&&(a=t[1].compiledExpressionTwoWay(a)),e(a)})}}static parseValueWithType(t,s){if(s[1].type)switch(s[1].type){case"number":return parseFloat(t);case"boolean":return t===!0||t==="true"||!!parseInt(t);case"string":return t?.toString();case"integer":return parseInt(t)}return t}handleValueChanged(t,s,e,i,r,o,a,l,c){let p=i;if(!l&&o==0&&(p=n.parseValueWithType(p,e)),r[o]=p,e[1].expression&&(e[1].compiledExpression||(a.push("__res"),a.push("__ctx"),e[1].expression.includes("return ")?e[1].compiledExpression=new Function(a,e[1].expression):e[1].compiledExpression=new Function(a,"return "+e[1].expression)),r[a.length-1]={element:t,root:s,boundNames:e[1].signal,boundTargetName:e[0],boundTargetType:e[1].target},p=e[1].compiledExpression(...r),r[a.length-1]=p),e[1].converter)if(typeof e[1].converter=="string")p=this.namedConverterCallback(e[1].converter,p,t,e);else{let d=p!=null?p.toString():p;if(d in e[1].converter){let m=e[1].converter[d];typeof m=="string"?p=new Function(a,"return `"+e[1].converter[d]+"`")(...r):p=m}else{let m=!1,h=parseFloat(p);for(let u in e[1].converter)if(u.length>2&&u[0]===">"&&u[1]==="="){let g=parseFloat(u.substring(2));if(h>=g){let y=e[1].converter[u];typeof y=="string"?p=new Function(a,"return `"+e[1].converter[u]+"`")(...r):p=y,m=!0;break}}else if(u.length>2&&u[0]==="<"&&u[1]==="="){let g=parseFloat(u.substring(2));if(h<=g){let y=e[1].converter[u];typeof y=="string"?p=new Function(a,"return `"+e[1].converter[u]+"`")(...r):p=y,m=!0;break}}else if(u.length>1&&u[0]===">"){let g=parseFloat(u.substring(1));if(h>g){let y=e[1].converter[u];typeof y=="string"?p=new Function(a,"return `"+e[1].converter[u]+"`")(...r):p=y,m=!0;break}}else if(u.length>1&&u[0]==="<"){let g=parseFloat(u.substring(1));if(h<g){let y=e[1].converter[u];typeof y=="string"?p=new Function(a,"return `"+e[1].converter[u]+"`")(...r):p=y,m=!0;break}}else{let g=u.split("-");if(g.length>1&&(g[0]===""||h>=parseFloat(g[0]))&&(g[1]===""||parseFloat(g[1])>=h)){let y=e[1].converter[u];typeof y=="string"?p=new Function(a,"return `"+e[1].converter[u]+"`")(...r):p=y,m=!0;break}}!m&&e[1].converterDefault!==void 0&&(p=e[1].converterDefault)}}if(e[1].inverted&&(p=!p),e[1].writeBackSignal){let d=e[1].writeBackSignal;d[0]==="."&&(d=c+d),this._visualizationHandler.setState(d,p,!0)}e[1].target==f.property?t[e[0]]=p:e[1].target==f.attribute?t.setAttribute(e[0],p):e[1].target==f.css?t.style[e[0]]=p:e[1].target==f.cssvar?t.style.setProperty(e[0],p):e[1].target==f.class?p?t.classList.add(e[0]):t.classList.remove(e[0]):e[1].target==f.visible&&(t.style.visibility=p?"":"collapse")}static camelToDotCase(t){return t.replace(/([A-Z])/g,s=>`.${s[0].toLowerCase()}`)}static dotToCamelCase(t){return t.replace(/\.([a-z])/g,s=>s[1].toUpperCase())}};var se=class{name;relativeSignalsPath;commands;parameters};import{deepValue as _,setDeepValue as ae,sleep as Ue}from"@node-projects/web-component-designer/dist/elements/helper/Helper.js";import W from"long";import{EventsService as Je}from"@node-projects/web-component-designer";var M="cyclic",ie=class n extends Je{static _cyclicEvent=[{name:`${M}:100`,propertyName:void 0,eventObjectName:"Event",description:"this event will retrigger itself every 100 ms"}];getPossibleEvents(t){let s=super.getPossibleEvents(t);return s.push(...n._cyclicEvent),s}getEvent(t,s){return s.includes(M)?n._cyclicEvent.find(i=>i.name==s)??{name:s,propertyName:"on"+s,eventObjectName:"Event"}:super.getEvent(t,s)}};var Xe={pointerdown:"pointerup",pointerenter:"pointerleave",mouseenter:"mouseleave",mouseover:"mouseout",focus:"blur",focusin:"focusout",keydown:"keyup"},ne=class{_visualizationHandler;_subscriptionCallback=()=>{};constructor(n){this._visualizationHandler=n}async execute(n,t){let s=-1,e=!1,i=t.event?.type,r=i?Xe[i]:null;if(r){let o=t.element;i=="pointerdown"&&(o=window),o.addEventListener(r,()=>{e=!0},{once:!0})}for(let o=0;o<n.length;o++){let a=n[o];if(a.type=="Exit")break;if(a.type=="Goto"){let l=await this.getValue(a.label,t);if(o=n.findIndex(c=>c.type=="Label"&&c.label==l),o<0)break}else if(a.type=="Condition"){let l=await this.getValue(a.value1,t),c=await this.getValue(a.value2,t),p=await this.getValue(a.comparisonType,t),d=!1;switch(p){case"==null":d=l==null;break;case"!=null":d=l!=null;break;case"==true":d=l==!0;break;case"==false":d=l==!1;break;case"==":d=l==c;break;case"!=":d=l!=c;break;case">":d=l>c;break;case"<":d=l<c;break;case">=":d=l>=c;break;case"<=":d=l<=c;break;case"&&":d=l&&c;break;case"||":d=l||c;break}if(d){await this.runExternalScript(await this.getValue(a.trueScriptName,t),await this.getValue(a.trueScriptType,t));let m=await this.getValue(a.trueGotoLabel,t);if(m&&(o=n.findIndex(h=>h.type=="Label"&&h.label==m),o<0))break}else{await this.runExternalScript(await this.getValue(a.falseScriptName,t),await this.getValue(a.falseScriptType,t));let m=await this.getValue(a.falseGotoLabel,t);if(m&&(o=n.findIndex(h=>h.type=="Label"&&h.label==m),o<0))break}}else if(a.type=="Repeat"){let l=await this.getValue(a.label,t),c=await this.getValue(a.count,t);if(await this.getValue(a.mode,t)=="eventValid"&&e){e=!1;continue}if(c!=0&&s==-1&&(s=c-1),s==0||(s>0&&s--,o=-1,l&&(o=n.findIndex(d=>d.type=="Label"&&d.label==l),o<0)))continue}else if(!await this.runScriptCommand(a,t))break}}async getValueFromTarget(n,t,s){return n==="property"?_(s.root,t):n==="elementProperty"?_(s.element,t):(await this._visualizationHandler.getState(this.getSignalName(t,s)))?.val}async setValueOnTarget(n,t,s,e){n==="property"?ae(s.root,t,e):n==="elementProperty"?ae(s.element,t,e):await this._visualizationHandler.setState(this.getSignalName(t,s),e)}async runExternalScript(n,t){}async runScriptCommand(command,context){switch(command.type){case"Comment":case"Label":case"Condition":case"Goto":case"Exit":case"Repeat":break;case"OpenUrl":{window.open(await this.getValue(command.url,context),command.target);break}case"Delay":{let n=await this.getValue(command.value??500,context);await Ue(n);break}case"Console":{let n=await this.getValue(command.target??"log",context),t=await this.getValue(command.message,context);console[n](t);break}case"ToggleSignalValue":{let n=await this.getValue(command.signal,context),t=await this.getValue(command.target,context),s=await this.getValueFromTarget(t,n,context);await this._visualizationHandler.setState(this.getSignalName(n,context),!s);break}case"ToggleSignalValueThroughList":{let n=await this.getValue(command.valueList,context),t=await this.getValue(command.signal,context),s=await this.getValue(command.target,context),e=await this.getValueFromTarget(s,t,context),i=n.indexOf(e)+1;i>=n.length&&(i=0);let r=n[i];await this._visualizationHandler.setState(this.getSignalName(t,context),r);break}case"SetSignalValue":{let n=await this.getValue(command.signal,context),t=await this.getValue(command.target,context);await this.setValueOnTarget(t,n,context,await this.getValue(command.value,context));break}case"IncrementSignalValue":{let n=await this.getValue(command.signal,context),t=await this.getValue(command.target,context),e=await this.getValueFromTarget(t,n,context)+await this.getValue(command.value,context);await this.setValueOnTarget(t,n,context,e);break}case"DecrementSignalValue":{let n=await this.getValue(command.signal,context),t=await this.getValue(command.target,context),e=await this.getValueFromTarget(t,n,context)-await this.getValue(command.value,context);await this.setValueOnTarget(t,n,context,e);break}case"CalculateSignalValue":{let formula=await this.getValue(command.formula,context),target=await this.getValue(command.target,context),targetSignal=await this.getValue(command.targetSignal,context),nm=await this.parseStringWithValues(formula,context),result=eval(nm);await this.setValueOnTarget(target,targetSignal,context,result);break}case"SetBitInSignal":{let n=await this.getValue(command.signal,context),t=await this.getValue(command.bitNumber??0,context),s=await this.getValue(command.target,context),e=await this.getValueFromTarget(s,n,context),i=W.fromNumber(1).shiftLeft(t),r=W.fromNumber(e).or(i).toNumber();await this.setValueOnTarget(s,n,context,r);break}case"ClearBitInSignal":{let n=await this.getValue(command.signal,context),t=await this.getValue(command.bitNumber??0,context),s=await this.getValue(command.target,context),e=await this.getValueFromTarget(s,n,context),i=W.fromNumber(1).shiftLeft(t);i.negate();let r=W.fromNumber(e).and(i).toNumber();await this.setValueOnTarget(s,n,context,r);break}case"ToggleBitInSignal":{let n=await this.getValue(command.signal,context),t=await this.getValue(command.bitNumber??0,context),s=await this.getValue(command.target,context),e=await this.getValueFromTarget(s,n,context),i=W.fromNumber(1).shiftLeft(t),r=W.fromNumber(e).xor(i).toNumber();await this.setValueOnTarget(s,n,context,r);break}case"Javascript":{let n=await this.getValue(command.script,context),t=context;t.shadowRoot=context.element.getRootNode(),t.instance=context.shadowRoot.host,command.compiledScript||(command.compiledScript=new Function("context",n)),command.compiledScript(t);break}case"SetElementProperty":{command=N.upgradeSetElementProperty(command);let n=await this.getValue(command.name,context);n===""&&(n=null);let t=await this.getValue(command.value,context),s=await this.getValue(command.parentIndex??0,context),e=await this.getValue(command.target??"property",context),i=await this.getValue(command.targetSelectorTarget??"container",context),r=await this.getValue(command.targetSelector,context),o=await this.getValue(command.mode??"toggle",context),a=this.getTargetFromTargetSelector(context,i,s,r);for(let l of a)e=="attribute"?l.setAttribute(n,t):e=="property"?l[n]=t:e=="css"?l.style[n]=t:e=="class"&&(o==="toggle"?l.classList.toggle(n??t):o==="remove"?l.classList.remove(n??t):l.classList.add(n??t));break}case"SubscribeSignal":{let n=await this.getValue(command.signal,context);if(await this.getValue(command.oneTime,context)){let s=()=>{this._visualizationHandler.unsubscribeState(n,s,null)};this._visualizationHandler.subscribeState(n,s)}else this._visualizationHandler.subscribeState(n,this._subscriptionCallback);break}case"UnsubscribeSignal":{let n=await this.getValue(command.signal,context);this._visualizationHandler.unsubscribeState(n,this._subscriptionCallback,null);break}case"WriteSignalsInGroup":{let n=await this.getValue(command.group,context);this._visualizationHandler.writeSignalsInGroup(n);break}case"ClearSignalsInGroup":{let n=await this.getValue(command.group,context);this._visualizationHandler.clearSignalsInGroup(n);break}case"RunScript":{let n=await this.getValue(command.name,context),t=await this.getValue(command.scriptType,context);this.runExternalScript(n,t);break}case"ShowMessageBox":{let n=null,t=await this.getValue(command.exitScriptOnCancel,context);if(await this.getValue(command.buttons,context)=="yesNo"){let i=await this.getValue(command.message,context);confirm(i)?n=1:n=2}else{let i=await this.getValue(command.message,context);alert(i),n=1}let e=await this.getValue(command.resultSignal,context);if(e&&this._visualizationHandler.setState(e,n),t&&n!=1)return!1;break}case"ShowPrompt":{let n=await this.getValue(command.message,context),t=await this.getValue(command.default,context),s=prompt(n,t),e=await this.getValue(command.resultSignal,context);e&&s&&this._visualizationHandler.setState(e,s);break}case"Login":case"Logout":case"CloseDialog":case"OpenDialog":case"OpenScreen":case"SwitchLanguage":case"CopySignalValuesFromFolder":case"ExportSignalValuesAsJson":case"ImportSignalValuesFromJson":{alert('command: "'+command.type+'" is not yet implemented');break}}return!0}getTarget(n,t,s){if(t==="container"){let e=n.element.getRootNode().host;for(let i=0;i<(s??0);i++)e=e.getRootNode().host;return e}else if(t==="element"){let e=n.element;for(let i=0;i<(s??0);i++)e=e.parentElement;return e}return null}getTargetFromTargetSelector(n,t,s,e){let i=this.getTarget(n,t,s),r=[i];return e&&(t==="container"?r=i.shadowRoot.querySelectorAll(e):r=i.querySelectorAll(e)),r}async getValue(value,outerContext){if(value==null)return null;if(typeof value=="object")switch(value.source){case"property":return _(outerContext.root,value.name);case"elementProperty":return _(outerContext.element,value.name);case"signal":return(await this._visualizationHandler.getState(this.getSignalName(value.name,outerContext)))?.val;case"signalInProperty":{let n=_(outerContext.root,value.name);return(await this._visualizationHandler.getState(this.getSignalName(n,outerContext)))?.val}case"event":{let n=outerContext.event;return value.name&&(n=_(n,value.name)),n}case"parameter":return outerContext.parameters[value.name];case"context":return _(outerContext,value.name);case"complexString":{let n=value.name;return n!=null?await this.parseStringWithValues(n,outerContext):null}case"complexSignal":{let n=value.name;if(n!=null){let t=await this.parseStringWithValues(n,outerContext);return(await this._visualizationHandler.getState(this.getSignalName(t,outerContext)))?.val}return null}case"expression":{var ctx=outerContext;return eval(value.name)}}return value}async getStateOrFieldOrParameter(name,context){if(name[0]==="\xA7"){var ctx=context;return eval("ctx."+name.substring(1))}else{if(name[0]==="?"&&name[1]==="?")return context.root[name.substring(2)];if(name[0]==="?")return await this._visualizationHandler.getState(this.getSignalName(context.root[name.substring(1)],context))}return await this._visualizationHandler.getState(this.getSignalName(name,context))}async parseStringWithValues(n,t){let s=U(n),e=await Promise.all(s.signals.map(r=>this.getStateOrFieldOrParameter(this.getSignalName(r,t),t))),i=s.parts[0];for(let r=0;r<s.parts.length-1;r++){let o=e[r];typeof o=="object"&&(o=o.val),o==null&&(o=""),i+=o+s.parts[r+1]}return i}getSignalName(n,t){return n[0]==="."?t.relativeSignalsPath+n:n}createScriptContext(n,t,s,e,i){return{root:n,event:t,element:s,parameters:e,relativeSignalsPath:i}}async assignAllScripts(n,t,s,e,i,r,o,a){r??=this.createScriptContext;let l=await this.loadAndInitJsObject(n,t,s,e,a);for(let c of s.querySelectorAll("*"))for(let p of c.attributes)if(p.name[0]==="@")try{let d=p.name.substring(1),m=p.value.trim(),h=d.startsWith(M),u=h?parseInt(d.substring(d.indexOf(":")+1)):null,g=await this.resolveHandler(m,l,c,s,e,i,r,o,d);g&&this.bindHandler(c,d,h,u,g)}catch{console.warn("error assigning script",c,p)}return l}async loadAndInitJsObject(n,t,s,e,i){if(!t)return null;try{let o=await import(URL.createObjectURL(new Blob([t],{type:"application/javascript"})));return i?i(o):o.init?.(e,s),o}catch(r){return console.error("error parsing javascript - "+n,r),null}}async resolveHandler(n,t,s,e,i,r,o,a,l){if(n[0]!=="{")return p=>{t?.[n]?t[n](p,s,e,i):console.warn(`javascript function named: "${n}" not found, maybe missing a "export" ?`)};let c=JSON.parse(n);if("commands"in c)return p=>this.execute(c.commands,o(i,p,s,c.parameters,c.relativeSignalsPath));if("blocks"in c){let p=null;return async d=>{p??=await G(c),p(d,e,c.parameters,c.relativeSignalsPath??"",r,o(i,d,s,c.parameters,c.relativeSignalsPath))}}if("name"in c){if(a)return a(s,l,c),null;let p=c.name;return d=>{t?.[p]?t[p](d,s,e,i,c.parameters):console.warn(`javascript function named: "${p}" not found, maybe missing a "export" ?`)}}return null}bindHandler(n,t,s,e,i){if(!s){n.addEventListener(t,i);return}let r=setInterval(()=>{n.isConnected?i(null):clearInterval(r)},e)}};import{OverlayLayer as Ge,DesignItem as T,InsertAction as $e,BindingTarget as k,PropertyType as H}from"@node-projects/web-component-designer";var re=class{constructor(t,s){this._bindingsHelper=t,this._visualizationHandler=s}_bindingsHelper;_visualizationHandler;rectMap=new Map;rect;dragEnter(t,s,e){let i=T.GetDesignItem(e);if(i&&!i.isRootItem){let r=t.getNormalizedElementCoordinates(e);this.rect=t.overlayLayer.drawRect("IobrokerWebuiBindableObjectDragDropService",r.x,r.y,r.width,r.height,"",null,Ge.Background),this.rect.style.fill="#ff0000",this.rect.style.opacity="0.3",this.rectMap.set(e,this.rect)}}dragLeave(t,s,e){let i=T.GetDesignItem(e);if(i&&!i.isRootItem){let r=this.rectMap.get(e);t.overlayLayer.removeOverlay(r),this.rectMap.delete(e)}}dragOver(t,s,e){return"copy"}async drop(t,s,e,i){for(let l of this.rectMap.values())t.overlayLayer.removeOverlay(l);this.rectMap.clear();let r=T.GetDesignItem(i),o=await this._visualizationHandler.getObject(e.fullName),a=this._visualizationHandler.getSignalInformation(o);if(r&&!r.isRootItem)if(i instanceof HTMLInputElement){let l={signal:e.fullName,target:k.property},c=this._bindingsHelper.serializeBinding(i,i.type=="checkbox"?"checked":"value",l);r.setAttribute(c[0],c[1])}else{let l={signal:e.fullName,target:k.content},c=this._bindingsHelper.serializeBinding(i,null,l);r.setAttribute(c[0],c[1])}else{let l=t.getNormalizedEventCoordinates(s),c,p,d=await this._visualizationHandler.getState(e.fullName);if(a.role==="url"&&typeof d?.val=="string")if(d.val.endsWith("jpg")||d.val.endsWith("jpeg")||d.val.endsWith("png")||d.val.endsWith("gif")||d.val.endsWith("svg")){let m=document.createElement("img");c=T.createDesignItemFromInstance(m,t.serviceContainer,t.instanceServiceContainer),p=c.openGroup("Insert");let h={signal:e.fullName,target:k.property},u=this._bindingsHelper.serializeBinding(m,"src",h);c.setAttribute(u[0],u[1]),c.element.src=d.val}else if(d.val.endsWith("mp4")){let m=document.createElement("video");c=T.createDesignItemFromInstance(m,t.serviceContainer,t.instanceServiceContainer),p=c.openGroup("Insert");let h={signal:e.fullName,target:k.property},u=this._bindingsHelper.serializeBinding(m,"src",h);c.setAttribute(u[0],u[1]),c.element.src=d.val}else{let m=document.createElement("iframe");c=T.createDesignItemFromInstance(m,t.serviceContainer,t.instanceServiceContainer),p=c.openGroup("Insert");let h={signal:e.fullName,target:k.property},u=this._bindingsHelper.serializeBinding(m,"src",h);c.setAttribute(u[0],u[1]),c.element.src=d.val}if(!c){let m=document.createElement("input");c=T.createDesignItemFromInstance(m,t.serviceContainer,t.instanceServiceContainer),p=c.openGroup("Insert");let h=a.writeable!==!1,u={signal:e.fullName,target:k.property,twoWay:h},g=this._bindingsHelper.serializeBinding(m,"value",u);a.type==="boolean"?(g=this._bindingsHelper.serializeBinding(m,"checked",u),c.setAttribute("type","checkbox")):a.role=="date"?(u.twoWay=h,g=this._bindingsHelper.serializeBinding(m,"value-as-number",u),c.setAttribute("type","date"),c.setAttribute("readonly","")):a.role=="datetime"&&(u.twoWay=h,g=this._bindingsHelper.serializeBinding(m,"value-as-number",u),c.setAttribute("type","datetime-local"),c.setAttribute("readonly","")),c.setAttribute(g[0],g[1])}c.setStyle("position","absolute"),c.setStyle("left",l.x+"px"),c.setStyle("top",l.y+"px"),t.instanceServiceContainer.undoService.execute(new $e(t.rootDesignItem,t.rootDesignItem.childCount,c)),p.commit(),requestAnimationFrame(()=>t.instanceServiceContainer.selectionService.setSelectedElements([c]))}}dragOverOnProperty(t,s,e){return"copy"}dropOnProperty(t,s,e,i){if(s.type=="signal"){s.service.setValue(i,s,e.fullName);return}let r={signal:e.fullName,target:k.property};s.propertyType==H.attribute&&(r.target=k.attribute),s.propertyType==H.cssValue&&(r.target=k.css),r.signal=e.fullName,r.twoWay=s.propertyType==H.property||s.propertyType==H.propertyAndAttribute;let o=i[0].openGroup("drop binding");for(let a of i){let l=this._bindingsHelper.serializeBinding(a.element,s.name,r);a.setAttribute(l[0],l[1])}o.commit()}};import{BindingMode as X,BindingTarget as oe,PropertiesHelper as qe}from"@node-projects/web-component-designer";var le=class n{constructor(t){this._bindingsHelper=t}_bindingsHelper;static type="visualization-binding";getBindings(t){return Array.from(this._bindingsHelper.getBindings(t.element)).map(e=>({targetName:e[1].target===oe.css||e[1].target===oe.attribute?qe.camelToDashCase(e[0]):e[0],target:e[1].target,mode:e[1].twoWay?X.twoWay:X.oneWay,invert:e[1].inverted,bindableObjectNames:e[1].signal.split(";"),expression:e[1].expression,expressionTwoWay:e[1].expressionTwoWay,converter:e[1].converter,type:n.type,service:this,changedEvents:e[1].events,historic:e[1].historic,writeBackSignal:e[1].writeBackSignal}))}setBinding(t,s){let e={signal:s.bindableObjectNames.join(";"),target:s.target};e.inverted=s.invert,e.twoWay=s.mode==X.twoWay,e.expression=s.expression,e.expressionTwoWay=s.expressionTwoWay,e.historic=s.historic,e.type=s.type,e.converter=s.converters,e.target=s.target,e.events=s.changedEvents;let i=this._bindingsHelper.serializeBinding(t.element,s.targetName,e),r=t.openGroup("edit_binding");return t.setAttribute(i[0],i[1]),r.commit(),!0}clearBinding(t,s,e){let i=this._bindingsHelper.getBindingAttributeName(t.element,s,e);return t.removeAttribute(i),!0}};var ce=class{getRefactorings(t){let s=[];for(let e of t){let i=e.serviceContainer.bindingService.getBindings(e);if(i)for(let r of i)for(let o of r.bindableObjectNames){let a="signal",l="";if(o.includes(":")){let c=o.split(":")[0],p=o.substring(c.length+1);p.startsWith("?")&&(p=p.substring(1),l="?",a="property",p.startsWith("?")&&(p=p.substring(1),l="??")),s.push({service:this,name:p,itemType:a,designItem:e,type:"binding",sourceObject:r,display:r.target+"/"+r.targetName+" - "+c+":",shortName:c,prefix:l})}else o.startsWith("?")&&(o=o.substring(1),l="?",a="property",o.startsWith("?")&&(o=o.substring(1),l="??")),s.push({service:this,name:o,itemType:a,designItem:e,type:"binding",sourceObject:r,display:r.target+"/"+r.targetName,prefix:l})}}return s}refactor(t,s,e){let i=t.sourceObject;t.shortName?i.bindableObjectNames=i.bindableObjectNames.map(r=>r==t.shortName+":"+t.prefix+s?t.shortName+":"+t.prefix+e:r):i.bindableObjectNames=i.bindableObjectNames.map(r=>r==t.prefix+s?t.prefix+e:r),t.designItem.serviceContainer.bindingService.setBinding(t.designItem,i)}};var pe=class{dragOverOnProperty(t,s,e){return"copy"}dropOnProperty(t,s,e,i){s.service.setValue(i,s,e.text)}};import{BindingTarget as b}from"@node-projects/web-component-designer";var ue=class{getRefactorings(t){let s=[];for(let e of t)for(let i of e.attributes())if(i[0][0]=="@"){let r=i[1];if(r[0]=="{"){let o=JSON.parse(r);if("commands"in o)for(let a of o.commands){for(let l in a){let c=a[l];if(c!=null&&typeof c=="object"){let p=c;if(p.source==="signal")s.push({name:p.name,itemType:"signal",target:b.event,targetName:i[0],service:this,designItem:e,type:"script",sourceObject:o,display:a.type+"/"+i[0].substring(1)+"/"+l+"[signal]",refactor:d=>p.name=d});else if(p.source==="property")s.push({name:p.name,itemType:"property",target:b.event,targetName:i[0],service:this,designItem:e,type:"script",sourceObject:o,display:a.type+"/"+i[0].substring(1)+"/"+l+"[property]",refactor:d=>p.name=d});else if(p.source==="complexString")for(let d of p.name.matchAll(/\{(.*?)\}/g)){let m=d[0],h=d[1];if(h[0]==="?"){let u="?";h=h.substring(1),h[0]==="?"&&(u="??",h=h.substring(1)),s.push({name:h,itemType:"property",target:b.event,targetName:i[0],service:this,designItem:e,type:"script",sourceObject:o,display:a.type+"/"+i[0].substring(1)+"/"+l+"[complexString]->property",refactor:g=>p.name=p.name.replace(m,"{"+u+g+"}")})}else s.push({name:h,itemType:"signal",target:b.event,targetName:i[0],service:this,designItem:e,type:"script",sourceObject:o,display:a.type+"/"+i[0].substring(1)+"/"+l+"[complexString]->signal",refactor:u=>p.name=p.name.replace(m,"{"+u+"}")})}}}switch(a.type){case"SetSignalValue":a.signal&&typeof a.signal=="string"&&s.push({name:a.signal,itemType:"signal",target:b.event,targetName:i[0],display:a.type+"/"+i[0].substring(1)+"/signal",service:this,designItem:e,type:"script",sourceObject:o,refactor:l=>a.signal=l});break;case"ToggleSignalValue":a.signal&&typeof a.signal=="string"&&s.push({name:a.signal,itemType:"signal",target:b.event,targetName:i[0],display:a.type+"/"+i[0].substring(1)+"/signal",service:this,designItem:e,type:"script",sourceObject:o,refactor:l=>a.signal=l});break;case"IncrementSignalValue":a.signal&&typeof a.signal=="string"&&s.push({name:a.signal,itemType:"signal",target:b.event,targetName:i[0],display:a.type+"/"+i[0].substring(1)+"/signal",service:this,designItem:e,type:"script",sourceObject:o,refactor:l=>a.signal=l});break;case"DecrementSignalValue":a.signal&&typeof a.signal=="string"&&s.push({name:a.signal,itemType:"signal",target:b.event,targetName:i[0],display:a.type+"/"+i[0].substring(1)+"/signal",service:this,designItem:e,type:"script",sourceObject:o,refactor:l=>a.signal=l});break;case"SetBitInSignal":a.signal&&typeof a.signal=="string"&&s.push({name:a.signal,itemType:"signal",target:b.event,targetName:i[0],display:a.type+"/"+i[0].substring(1)+"/signal",service:this,designItem:e,type:"script",sourceObject:o,refactor:l=>a.signal=l});break;case"ClearBitInSignal":a.signal&&typeof a.signal=="string"&&s.push({name:a.signal,itemType:"signal",target:b.event,targetName:i[0],display:a.type+"/"+i[0].substring(1)+"/signal",service:this,designItem:e,type:"script",sourceObject:o,refactor:l=>a.signal=l});break;case"ToggleBitInSignal":a.signal&&typeof a.signal=="string"&&s.push({name:a.signal,itemType:"signal",target:b.event,targetName:i[0],display:a.type+"/"+i[0].substring(1)+"/signal",service:this,designItem:e,type:"script",sourceObject:o,refactor:l=>a.signal=l});break;case"OpenScreen":a.screen&&typeof a.screen=="string"&&s.push({name:a.screen,itemType:"screen",target:b.event,targetName:i[0],display:a.type+"/"+i[0].substring(1)+"/screen",service:this,designItem:e,type:"script",sourceObject:o,refactor:l=>a.screen=l});break;case"OpenDialog":a.screen&&typeof a.screen=="string"&&s.push({name:a.screen,itemType:"screen",target:b.event,targetName:i[0],display:a.type+"/"+i[0].substring(1)+"/screen",service:this,designItem:e,type:"script",sourceObject:o,refactor:l=>a.screen=l});break;case"CalculateSignalValue":a.targetSignal&&typeof a.targetSignal=="string"&&s.push({name:a.targetSignal,itemType:"signal",target:b.event,targetName:i[0],display:a.type+"/"+i[0].substring(1)+"/targetSignal",service:this,designItem:e,type:"script",sourceObject:o,refactor:l=>a.targetSignal=l});break;case"SubscribeSignal":a.signal&&typeof a.signal=="string"&&s.push({name:a.signal,itemType:"signal",target:b.event,targetName:i[0],display:a.type+"/"+i[0].substring(1)+"/signal",service:this,designItem:e,type:"script",sourceObject:o,refactor:l=>a.signal=l});break;case"UnsubscribeSignal":a.signal&&typeof a.signal=="string"&&s.push({name:a.signal,itemType:"signal",target:b.event,targetName:i[0],display:a.type+"/"+i[0].substring(1)+"/signal",service:this,designItem:e,type:"script",sourceObject:o,refactor:l=>a.signal=l});break;case"ShowMessageBox":a.resultSignal&&typeof a.resultSignal=="string"&&s.push({name:a.resultSignal,itemType:"signal",target:b.event,targetName:i[0],display:a.type+"/"+i[0].substring(1)+"/resultSignal",service:this,designItem:e,type:"script",sourceObject:o,refactor:l=>a.resultSignal=l});break}}else"blocks"in o;if("parameters"in o)for(let a in o.parameters)typeof o.parameters[a]=="string"&&s.push({name:o.parameters[a],itemType:"parameter",target:b.event,targetName:i[0],service:this,designItem:e,type:"script",sourceObject:o,display:i[0].substring(1)+"/parameters/"+a,refactor:l=>o.parameters[a]=l})}}return s}refactor(t,s,e){t.refactor(e);let i=JSON.stringify(t.sourceObject);t.designItem.setAttribute(t.targetName,i)}};import{BasePropertyEditor as Ye}from"@node-projects/web-component-designer";var de=class extends Ye{_ip;_container;constructor(t,s){super(t),this._container=document.createElement("div"),this._container.style.display="flex",this._ip=document.createElement("input"),this._ip.onchange=i=>this._valueChanged(this._ip.value),this._ip.onfocus=i=>{this._ip.selectionStart=0,this._ip.selectionEnd=this._ip.value?.length},this._container.appendChild(this._ip);let e=document.createElement("button");e.textContent="...",e.onclick=async()=>{let i=s.createBindableObjectBrowser();i.initialize(this.designItems[0].serviceContainer,this.designItems[0].instanceServiceContainer,"property"),i.title="select signal...";let r=new AbortController;i.objectDoubleclicked.on(()=>{r.abort(),this._ip.value=i.selectedObject.fullName,this._valueChanged(this._ip.value)}),await s.openConfirmation(i,{x:100,y:100,width:400,height:300,abortSignal:r.signal})&&(this._ip.value=i.selectedObject.fullName,this._valueChanged(this._ip.value))},this._container.appendChild(e),this.element=this._container}refreshValue(t,s){s==null?this._ip.value="":this._ip.value=s}};export{re as BindableObjectDragDropService,D as BindingsEditor,E as BindingsEditorHistoric,te as BindingsHelper,C as BlocklyScriptEditor,P as EventAssignment,I as ParameterEditor,pe as PropertyGridDragDropService,se as Script,ue as ScriptRefactorService,ne as ScriptSystem,de as SignalPropertyEditor,O as SimpleScriptEditor,ce as VisualizationBindingsRefactorService,le as VisualizationBindingsService,ie as VisualizationEventsService,j as VisualizationPropertyGrid,B as bindingPrefixAttribute,R as bindingPrefixClass,w as bindingPrefixContent,V as bindingPrefixCss,A as bindingPrefixCssVar,He as bindingPrefixInsideCss,Fe as bindingPrefixInsideCssVarName,S as bindingPrefixProperty,F as bindingPrefixVisible,Xt as bindingsInCssRegex,M as cyclicAttributeName,G as generateEventCodeFromBlockly,L as getNestedProperty,z as isLit,U as parseBindingString};
390
390
  //!varname => inverted
package/dist/index.d.ts CHANGED
@@ -23,3 +23,4 @@ export * from './services/VisualizationBindingsRefactorService.js';
23
23
  export * from './services/PropertyGridDragDropService.js';
24
24
  export * from './services/ScriptRefactorService.js';
25
25
  export * from './services/SignalPropertyEditor.js';
26
+ export * from './services/VisualizationEventsService.js';
package/dist/index.js CHANGED
@@ -18,4 +18,5 @@ export * from './services/VisualizationBindingsRefactorService.js';
18
18
  export * from './services/PropertyGridDragDropService.js';
19
19
  export * from './services/ScriptRefactorService.js';
20
20
  export * from './services/SignalPropertyEditor.js';
21
+ export * from './services/VisualizationEventsService.js';
21
22
  //export * from './setupVisuService.js';
@@ -1,5 +1,5 @@
1
1
  export declare type ScriptCommands = RunnableScriptCommands | Comment | Condition | Exit | Label | Goto;
2
- export declare type RunnableScriptCommands = OpenScreen | OpenUrl | OpenDialog | CloseDialog | ToggleSignalValue | ToggleSignalValueThroughList | SetSignalValue | IncrementSignalValue | DecrementSignalValue | SetBitInSignal | ClearBitInSignal | ToggleBitInSignal | Console | CalculateSignalValue | Javascript | SetElementProperty | Delay | SwitchLanguage | Login | Logout | SubscribeSignal | UnsubscribeSignal | WriteSignalsInGroup | ClearSignalsInGroup | RunScript | CopySignalValuesFromFolder | ShowMessageBox | ShowPrompt | ExportSignalValuesAsJson | ImportSignalValuesFromJson;
2
+ export declare type RunnableScriptCommands = OpenScreen | OpenUrl | OpenDialog | CloseDialog | ToggleSignalValue | ToggleSignalValueThroughList | SetSignalValue | IncrementSignalValue | DecrementSignalValue | SetBitInSignal | ClearBitInSignal | ToggleBitInSignal | Console | CalculateSignalValue | Javascript | SetElementProperty | Delay | SwitchLanguage | Login | Logout | SubscribeSignal | UnsubscribeSignal | WriteSignalsInGroup | ClearSignalsInGroup | RunScript | CopySignalValuesFromFolder | ShowMessageBox | ShowPrompt | ExportSignalValuesAsJson | ImportSignalValuesFromJson | Repeat;
3
3
  /**
4
4
  * signal - a signal (the default)
5
5
  * property - a property defined in the current screen/control
@@ -445,3 +445,21 @@ export interface RunScript {
445
445
  scriptType: 'string';
446
446
  additionalData?: string;
447
447
  }
448
+ export interface Repeat {
449
+ type: 'Repeat';
450
+ /**
451
+ * Name of the Label to jump to, if empty it jumps to the start.
452
+ */
453
+ label?: string;
454
+ /**
455
+ * Number of times the script repeats itself. If 0, it repeats indefinitly
456
+ * @default 0
457
+ */
458
+ count?: number;
459
+ /**
460
+ * always: script repeats until count is 0 or indefinitly when count is 0
461
+ * eventValid: script repeats until event is no longer active
462
+ * @default eventValid
463
+ */
464
+ mode: 'eventValid' | 'always';
465
+ }
@@ -25,4 +25,7 @@ export declare class ScriptSystem {
25
25
  getSignalName(name: string, outerContext: contextType): string;
26
26
  createScriptContext(root: HTMLElement, event: Event, element: Element, parameters: Record<string, any>, relativeSignalsPath: string): any;
27
27
  assignAllScripts(source: string, javascriptCode: string, shadowRoot: ShadowRoot, instance: HTMLElement, visualizationHandler: VisualizationHandler, contextCreator?: (root: HTMLElement, event: Event, element: Element, parameters: Record<string, any>, relativeSignalsPath: string) => any, assignExternalScript?: (element: Element, event: string, scriptData: any) => void, runInitalization?: (jsObject: VisualisationElementScript) => void): Promise<VisualisationElementScript>;
28
+ private loadAndInitJsObject;
29
+ private resolveHandler;
30
+ private bindHandler;
28
31
  }
@@ -3,6 +3,16 @@ import { generateEventCodeFromBlockly } from "../blockly/BlocklyJavascriptHelper
3
3
  import { parseBindingString } from "../helpers/BindingsHelper.js";
4
4
  import Long from 'long';
5
5
  import { ScriptUpgrades } from "./ScriptUpgrader.js";
6
+ import { cyclicAttributeName } from "../services/VisualizationEventsService.js";
7
+ const eventOpposites = {
8
+ 'pointerdown': 'pointerup',
9
+ 'pointerenter': 'pointerleave',
10
+ 'mouseenter': 'mouseleave',
11
+ 'mouseover': 'mouseout',
12
+ 'focus': 'blur',
13
+ 'focusin': 'focusout',
14
+ 'keydown': 'keyup',
15
+ };
6
16
  export class ScriptSystem {
7
17
  _visualizationHandler;
8
18
  _subscriptionCallback = () => { };
@@ -10,6 +20,19 @@ export class ScriptSystem {
10
20
  this._visualizationHandler = visualizationHandler;
11
21
  }
12
22
  async execute(scriptCommands, outerContext) {
23
+ let repeatCount = -1;
24
+ let eventNotValid = false;
25
+ const triggerEvent = outerContext.event?.type;
26
+ const cancelEvent = triggerEvent ? eventOpposites[triggerEvent] : null;
27
+ if (cancelEvent) {
28
+ let element = outerContext.element;
29
+ if (triggerEvent == 'pointerdown') {
30
+ element = window;
31
+ }
32
+ element.addEventListener(cancelEvent, () => {
33
+ eventNotValid = true;
34
+ }, { once: true });
35
+ }
13
36
  for (let i = 0; i < scriptCommands.length; i++) {
14
37
  let c = scriptCommands[i];
15
38
  if (c.type == "Exit") {
@@ -83,6 +106,30 @@ export class ScriptSystem {
83
106
  }
84
107
  }
85
108
  }
109
+ else if (c.type == "Repeat") {
110
+ const label = await this.getValue(c.label, outerContext);
111
+ const count = await this.getValue(c.count, outerContext);
112
+ const mode = await this.getValue(c.mode, outerContext);
113
+ if (mode == 'eventValid' && eventNotValid) {
114
+ eventNotValid = false;
115
+ continue;
116
+ }
117
+ if (count != 0 && repeatCount == -1) {
118
+ repeatCount = count - 1;
119
+ }
120
+ if (repeatCount == 0) {
121
+ continue;
122
+ }
123
+ if (repeatCount > 0) {
124
+ repeatCount--;
125
+ }
126
+ i = -1;
127
+ if (label) {
128
+ i = scriptCommands.findIndex(x => x.type == "Label" && x.label == label);
129
+ if (i < 0)
130
+ continue;
131
+ }
132
+ }
86
133
  else {
87
134
  const continueScript = await this.runScriptCommand(c, outerContext);
88
135
  if (!continueScript) {
@@ -123,6 +170,7 @@ export class ScriptSystem {
123
170
  case 'Condition':
124
171
  case 'Goto':
125
172
  case 'Exit':
173
+ case 'Repeat':
126
174
  {
127
175
  //Do nothing on this commands
128
176
  break;
@@ -475,76 +523,105 @@ export class ScriptSystem {
475
523
  return { root, event, element, parameters, relativeSignalsPath };
476
524
  }
477
525
  async assignAllScripts(source, javascriptCode, shadowRoot, instance, visualizationHandler, contextCreator, assignExternalScript, runInitalization) {
478
- const allElements = shadowRoot.querySelectorAll('*');
479
526
  contextCreator ??= this.createScriptContext;
480
- let jsObject = null;
481
- if (javascriptCode) {
482
- try {
483
- const scriptUrl = URL.createObjectURL(new Blob([javascriptCode], { type: 'application/javascript' }));
484
- jsObject = await import(scriptUrl);
485
- if (runInitalization)
486
- runInitalization(jsObject);
487
- else {
488
- if (jsObject.init) {
489
- jsObject.init(instance, shadowRoot);
527
+ const jsObject = await this.loadAndInitJsObject(source, javascriptCode, shadowRoot, instance, runInitalization);
528
+ for (const element of shadowRoot.querySelectorAll('*')) {
529
+ for (const attr of element.attributes) {
530
+ if (attr.name[0] !== '@')
531
+ continue;
532
+ try {
533
+ const evtName = attr.name.substring(1);
534
+ const script = attr.value.trim();
535
+ const isCyclic = evtName.startsWith(cyclicAttributeName);
536
+ const interval = isCyclic ? parseInt(evtName.substring(evtName.indexOf(':') + 1)) : null;
537
+ const handler = await this.resolveHandler(script, jsObject, element, shadowRoot, instance, visualizationHandler, contextCreator, assignExternalScript, evtName);
538
+ if (handler) {
539
+ this.bindHandler(element, evtName, isCyclic, interval, handler);
490
540
  }
491
541
  }
542
+ catch (err) {
543
+ console.warn('error assigning script', element, attr);
544
+ }
545
+ }
546
+ }
547
+ return jsObject;
548
+ }
549
+ // --- Hilfsmethoden ---
550
+ async loadAndInitJsObject(source, javascriptCode, shadowRoot, instance, runInitalization) {
551
+ if (!javascriptCode)
552
+ return null;
553
+ try {
554
+ const scriptUrl = URL.createObjectURL(new Blob([javascriptCode], { type: 'application/javascript' }));
555
+ const jsObject = await import(scriptUrl);
556
+ if (runInitalization) {
557
+ runInitalization(jsObject);
492
558
  }
493
- catch (err) {
494
- console.error('error parsing javascript - ' + source, err);
559
+ else {
560
+ jsObject.init?.(instance, shadowRoot);
495
561
  }
562
+ return jsObject;
496
563
  }
497
- for (let e of allElements) {
498
- for (let a of e.attributes) {
499
- if (a.name[0] == '@') {
500
- try {
501
- let evtName = a.name.substring(1);
502
- let script = a.value.trim();
503
- if (script[0] == '{') {
504
- let scriptObj = JSON.parse(script);
505
- if ('commands' in scriptObj) {
506
- e.addEventListener(evtName, (evt) => this.execute(scriptObj.commands, contextCreator(instance, evt, e, scriptObj.parameters, scriptObj.relativeSignalsPath)));
507
- }
508
- else if ('blocks' in scriptObj) {
509
- let compiledFunc = null;
510
- e.addEventListener(evtName, async (evt) => {
511
- if (!compiledFunc)
512
- compiledFunc = await generateEventCodeFromBlockly(scriptObj);
513
- compiledFunc(evt, shadowRoot, scriptObj.parameters, scriptObj.relativeSignalsPath ?? '', visualizationHandler, contextCreator(instance, evt, e, scriptObj.parameters, scriptObj.relativeSignalsPath));
514
- });
515
- }
516
- else {
517
- if (assignExternalScript)
518
- assignExternalScript(e, evtName, scriptObj);
519
- else {
520
- if ('name' in scriptObj) {
521
- //@ts-ignore
522
- const nm = scriptObj.name;
523
- e.addEventListener(evtName, (evt) => {
524
- if (!jsObject[nm])
525
- console.warn('javascript function named: ' + nm + ' not found, maybe missing a "export" ?');
526
- else
527
- jsObject[nm](evt, e, shadowRoot, instance, scriptObj.parameters);
528
- });
529
- }
530
- }
531
- }
532
- }
533
- else {
534
- e.addEventListener(evtName, (evt) => {
535
- if (!jsObject[script])
536
- console.warn('javascript function named: ' + script + ' not found, maybe missing a "export" ?');
537
- else
538
- jsObject[script](evt, e, shadowRoot, instance);
539
- });
540
- }
541
- }
542
- catch (err) {
543
- console.warn('error assigning script', e, a);
544
- }
564
+ catch (err) {
565
+ console.error('error parsing javascript - ' + source, err);
566
+ return null;
567
+ }
568
+ }
569
+ // Gibt eine normalisierte Handler-Funktion (evt) => void zurück
570
+ async resolveHandler(script, jsObject, element, shadowRoot, instance, visualizationHandler, contextCreator, assignExternalScript, evtName) {
571
+ // Plain-String: direkte Referenz auf eine JS-Funktion
572
+ if (script[0] !== '{') {
573
+ return (evt) => {
574
+ if (!jsObject?.[script]) {
575
+ console.warn(`javascript function named: "${script}" not found, maybe missing a "export" ?`);
545
576
  }
577
+ else {
578
+ jsObject[script](evt, element, shadowRoot, instance);
579
+ }
580
+ };
581
+ }
582
+ const scriptObj = JSON.parse(script);
583
+ // commands-Script
584
+ if ('commands' in scriptObj) {
585
+ return (evt) => this.execute(scriptObj.commands, contextCreator(instance, evt, element, scriptObj.parameters, scriptObj.relativeSignalsPath));
586
+ }
587
+ // Blockly-Script
588
+ if ('blocks' in scriptObj) {
589
+ let compiledFunc = null;
590
+ return async (evt) => {
591
+ compiledFunc ??= await generateEventCodeFromBlockly(scriptObj);
592
+ compiledFunc(evt, shadowRoot, scriptObj.parameters, scriptObj.relativeSignalsPath ?? '', visualizationHandler, contextCreator(instance, evt, element, scriptObj.parameters, scriptObj.relativeSignalsPath));
593
+ };
594
+ }
595
+ // Externes Script oder benannte JS-Funktion
596
+ if ('name' in scriptObj) {
597
+ if (assignExternalScript) {
598
+ assignExternalScript(element, evtName, scriptObj);
599
+ return null; // wird extern verwaltet
546
600
  }
601
+ const nm = scriptObj.name;
602
+ return (evt) => {
603
+ if (!jsObject?.[nm]) {
604
+ console.warn(`javascript function named: "${nm}" not found, maybe missing a "export" ?`);
605
+ }
606
+ else {
607
+ jsObject[nm](evt, element, shadowRoot, instance, scriptObj.parameters);
608
+ }
609
+ };
547
610
  }
548
- return jsObject;
611
+ return null;
612
+ }
613
+ bindHandler(element, evtName, isCyclic, interval, handler) {
614
+ if (!isCyclic) {
615
+ element.addEventListener(evtName, handler);
616
+ return;
617
+ }
618
+ const intervalId = setInterval(() => {
619
+ if (!element.isConnected) {
620
+ clearInterval(intervalId);
621
+ }
622
+ else {
623
+ handler(null);
624
+ }
625
+ }, interval);
549
626
  }
550
627
  }
@@ -1,5 +1,5 @@
1
1
  import { ScriptCommands, SetElementProperty } from "./ScriptCommands";
2
2
  export declare class ScriptUpgrades {
3
- static upgradeScriptCommand(scriptCommand: ScriptCommands): SetElementProperty | import("./ScriptCommands").OpenScreen | import("./ScriptCommands").OpenUrl | import("./ScriptCommands").OpenDialog | import("./ScriptCommands").CloseDialog | import("./ScriptCommands").ToggleSignalValue | import("./ScriptCommands").ToggleSignalValueThroughList | import("./ScriptCommands").SetSignalValue | import("./ScriptCommands").IncrementSignalValue | import("./ScriptCommands").DecrementSignalValue | import("./ScriptCommands").SetBitInSignal | import("./ScriptCommands").ClearBitInSignal | import("./ScriptCommands").ToggleBitInSignal | import("./ScriptCommands").Console | import("./ScriptCommands").CalculateSignalValue | import("./ScriptCommands").Javascript | import("./ScriptCommands").Delay | import("./ScriptCommands").SwitchLanguage | import("./ScriptCommands").Login | import("./ScriptCommands").Logout | import("./ScriptCommands").SubscribeSignal | import("./ScriptCommands").UnsubscribeSignal | import("./ScriptCommands").WriteSignalsInGroup | import("./ScriptCommands").ClearSignalsInGroup | import("./ScriptCommands").RunScript | import("./ScriptCommands").CopySignalValuesFromFolder | import("./ScriptCommands").ShowMessageBox | import("./ScriptCommands").ShowPrompt | import("./ScriptCommands").ExportSignalValuesAsJson | import("./ScriptCommands").ImportSignalValuesFromJson | import("./ScriptCommands").Comment | import("./ScriptCommands").Condition | import("./ScriptCommands").Exit | import("./ScriptCommands").Label | import("./ScriptCommands").Goto;
3
+ static upgradeScriptCommand(scriptCommand: ScriptCommands): SetElementProperty | import("./ScriptCommands").OpenScreen | import("./ScriptCommands").OpenUrl | import("./ScriptCommands").OpenDialog | import("./ScriptCommands").CloseDialog | import("./ScriptCommands").ToggleSignalValue | import("./ScriptCommands").ToggleSignalValueThroughList | import("./ScriptCommands").SetSignalValue | import("./ScriptCommands").IncrementSignalValue | import("./ScriptCommands").DecrementSignalValue | import("./ScriptCommands").SetBitInSignal | import("./ScriptCommands").ClearBitInSignal | import("./ScriptCommands").ToggleBitInSignal | import("./ScriptCommands").Console | import("./ScriptCommands").CalculateSignalValue | import("./ScriptCommands").Javascript | import("./ScriptCommands").Delay | import("./ScriptCommands").SwitchLanguage | import("./ScriptCommands").Login | import("./ScriptCommands").Logout | import("./ScriptCommands").SubscribeSignal | import("./ScriptCommands").UnsubscribeSignal | import("./ScriptCommands").WriteSignalsInGroup | import("./ScriptCommands").ClearSignalsInGroup | import("./ScriptCommands").RunScript | import("./ScriptCommands").CopySignalValuesFromFolder | import("./ScriptCommands").ShowMessageBox | import("./ScriptCommands").ShowPrompt | import("./ScriptCommands").ExportSignalValuesAsJson | import("./ScriptCommands").ImportSignalValuesFromJson | import("./ScriptCommands").Repeat | import("./ScriptCommands").Comment | import("./ScriptCommands").Condition | import("./ScriptCommands").Exit | import("./ScriptCommands").Label | import("./ScriptCommands").Goto;
4
4
  static upgradeSetElementProperty(scriptCommand: SetElementProperty): SetElementProperty;
5
5
  }
@@ -0,0 +1,7 @@
1
+ import { EventsService, IDesignItem, IEvent } from "@node-projects/web-component-designer";
2
+ export declare const cyclicAttributeName = "cyclic";
3
+ export declare class VisualizationEventsService extends EventsService {
4
+ static _cyclicEvent: IEvent[];
5
+ getPossibleEvents(designItem: IDesignItem): IEvent[];
6
+ getEvent(designItem: IDesignItem, name: string): IEvent;
7
+ }
@@ -0,0 +1,24 @@
1
+ import { EventsService, } from "@node-projects/web-component-designer";
2
+ export const cyclicAttributeName = 'cyclic';
3
+ export class VisualizationEventsService extends EventsService {
4
+ static _cyclicEvent = [
5
+ {
6
+ name: `${cyclicAttributeName}:100`,
7
+ propertyName: undefined,
8
+ eventObjectName: "Event",
9
+ description: "this event will retrigger itself every 100 ms",
10
+ },
11
+ ];
12
+ getPossibleEvents(designItem) {
13
+ let events = super.getPossibleEvents(designItem);
14
+ events.push(...VisualizationEventsService._cyclicEvent);
15
+ return events;
16
+ }
17
+ getEvent(designItem, name) {
18
+ if (name.includes(cyclicAttributeName)) {
19
+ let evt = VisualizationEventsService._cyclicEvent.find((x) => x.name == name);
20
+ return (evt ?? { name, propertyName: "on" + name, eventObjectName: "Event" });
21
+ }
22
+ return super.getEvent(designItem, name);
23
+ }
24
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "description": "web-component-designer addon for visualizations",
3
3
  "name": "@node-projects/web-component-designer-visualization-addons",
4
- "version": "0.1.140",
4
+ "version": "0.1.142",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "author": "jochen.kuehner@gmx.de",