• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2023 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16/// <reference path='./import.ts' />
17const arkUINativeModule = globalThis.getArkUINativeModule();
18function getUINativeModule(): Object {
19  if (arkUINativeModule) {
20    return arkUINativeModule;
21  }
22  return globalThis.getArkUINativeModule();
23}
24
25const arkUINativeAdvancedModule = globalThis.getArkUIAdvancedModule();
26function getUINativeAdvancedModule(): Object {
27  if (arkUINativeAdvancedModule) {
28    return arkUINativeAdvancedModule;
29  }
30  return globalThis.getArkUIAdvancedModule();
31}
32
33enum ModifierType {
34  ORIGIN = 0,
35  STATE = 1,
36  FRAME_NODE = 2,
37  EXPOSE_MODIFIER = 3,
38}
39
40type AttributeModifierWithKey = ModifierWithKey<number | string | boolean | object>;
41
42class ObservedMap {
43  private map_: Map<Symbol, AttributeModifierWithKey>;
44  private changeCallback: ((key: Symbol, value: AttributeModifierWithKey) => void) | undefined;
45  private isFrameNode_: boolean = false;
46
47  constructor() {
48    this.map_ = new Map();
49  }
50
51  public clear(): void {
52    this.map_.clear();
53  }
54
55  public delete(key: Symbol): boolean {
56    return this.map_.delete(key);
57  }
58
59  public forEach(callbackfn: (value: AttributeModifierWithKey, key: Symbol,
60    map: Map<Symbol, AttributeModifierWithKey>) => void, thisArg?: any): void {
61    this.map_.forEach(callbackfn, thisArg);
62  }
63  public get(key: Symbol): AttributeModifierWithKey | undefined {
64    return this.map_.get(key);
65  }
66  public has(key: Symbol): boolean {
67    return this.map_.has(key);
68  }
69  public set(key: Symbol, value: AttributeModifierWithKey): this {
70    const _a = this.changeCallback;
71    this.map_.set(key, value);
72    _a === null || _a === void 0 ? void 0 : _a(key, value);
73    return this;
74  }
75  public get size(): number {
76    return this.map_.size;
77  }
78  public entries(): IterableIterator<[Symbol, AttributeModifierWithKey]> {
79    return this.map_.entries();
80  }
81  public keys(): IterableIterator<Symbol> {
82    return this.map_.keys();
83  }
84  public values(): IterableIterator<AttributeModifierWithKey> {
85    return this.map_.values();
86  }
87  public [Symbol.iterator](): IterableIterator<[Symbol, AttributeModifierWithKey]> {
88    return this.map_.entries();
89  }
90  public get [Symbol.toStringTag](): string {
91    return 'ObservedMapTag';
92  }
93  public setOnChange(callback: (key: Symbol, value: AttributeModifierWithKey) => void): void {
94    if (this.changeCallback === undefined) {
95      this.changeCallback = callback;
96    }
97  }
98  public setFrameNode(isFrameNode: boolean): void {
99    this.isFrameNode_ = isFrameNode;
100  }
101  public isFrameNode(): boolean {
102    return this.isFrameNode_;
103  }
104}
105
106const UI_STATE_NORMAL = 0;
107const UI_STATE_PRESSED = 1;
108const UI_STATE_FOCUSED = 1 << 1;
109const UI_STATE_DISABLED = 1 << 2;
110const UI_STATE_SELECTED = 1 << 3;
111
112function applyUIAttributesInit(modifier: AttributeModifier<CommonAttribute>, nativeNode: KNode): void {
113  if (modifier.applyPressedAttribute === undefined &&
114    modifier.applyFocusedAttribute === undefined &&
115    modifier.applyDisabledAttribute === undefined &&
116    modifier.applySelectedAttribute === undefined) {
117    return;
118  }
119  let state = 0;
120  if (modifier.applyPressedAttribute !== undefined) {
121    state |= UI_STATE_PRESSED;
122  }
123  if (modifier.applyFocusedAttribute !== undefined) {
124    state |= UI_STATE_FOCUSED;
125  }
126  if (modifier.applyDisabledAttribute !== undefined) {
127    state |= UI_STATE_DISABLED;
128  }
129  if (modifier.applySelectedAttribute !== undefined) {
130    state |= UI_STATE_SELECTED;
131  }
132
133  getUINativeModule().setSupportedUIState(nativeNode, state);
134}
135
136function applyUIAttributes(modifier: AttributeModifier<CommonAttribute>, nativeNode: KNode, component: ArkComponent): void {
137  applyUIAttributesInit(modifier, nativeNode);
138  const currentUIState = getUINativeModule().getUIState(nativeNode);
139
140  if (modifier.applyNormalAttribute !== undefined) {
141    modifier.applyNormalAttribute(component);
142  }
143  if ((currentUIState & UI_STATE_PRESSED) && (modifier.applyPressedAttribute !== undefined)) {
144    modifier.applyPressedAttribute(component);
145  }
146  if ((currentUIState & UI_STATE_FOCUSED) && (modifier.applyFocusedAttribute !== undefined)) {
147    modifier.applyFocusedAttribute(component);
148  }
149  if ((currentUIState & UI_STATE_DISABLED) && (modifier.applyDisabledAttribute !== undefined)) {
150    modifier.applyDisabledAttribute(component);
151  }
152  if ((currentUIState & UI_STATE_SELECTED) && (modifier.applySelectedAttribute !== undefined)) {
153    modifier.applySelectedAttribute(component);
154  }
155}
156
157function isResource(variable: any): variable is Resource {
158  return (variable as Resource)?.bundleName !== undefined;
159}
160
161function isResourceEqual(stageValue: Resource, value: Resource): boolean {
162  return (stageValue.bundleName === value.bundleName) &&
163    (stageValue.moduleName === value.moduleName) &&
164    (stageValue.id === value.id) &&
165    (stageValue.params === value.params) &&
166    (stageValue.type === value.type);
167}
168function isBaseOrResourceEqual(stageValue: any, value: any): boolean {
169  if (isResource(stageValue) && isResource(value)) {
170    return isResourceEqual(stageValue, value);
171  } else if (!isResource(stageValue) && !isResource(value)) {
172    return (stageValue === value);
173  }
174  return false;
175}
176
177const SAFE_AREA_TYPE_NONE = 0;
178const SAFE_AREA_TYPE_SYSTEM = 1;
179const SAFE_AREA_TYPE_CUTOUT = 2;
180const SAFE_AREA_TYPE_KEYBOARD = 4;
181const SAFE_AREA_TYPE_ALL = 7;
182
183const SAFE_AREA_EDGE_NONE = 0;
184const SAFE_AREA_EDGE_TOP = 1;
185const SAFE_AREA_EDGE_BOTTOM = 2;
186const SAFE_AREA_EDGE_START = 4;
187const SAFE_AREA_EDGE_END = 8;
188const SAFE_AREA_EDGE_ALL = 15;
189
190const SAFE_AREA_TYPE_LIMIT = 3;
191const SAFE_AREA_EDGE_LIMIT = 4;
192const DIRECTION_RANGE = 3;
193
194type KNode = number | null
195
196interface Equable {
197  isEqual(value: Equable): boolean;
198}
199
200class ModifierWithKey<T extends number | string | boolean | object | Function> {
201  stageValue?: T;
202  value?: T;
203  constructor(value: T) {
204    this.stageValue = value;
205  }
206
207  applyStage(node: KNode, component?: ArkComponent): boolean {
208    if (this.stageValue === undefined || this.stageValue === null) {
209      this.value = this.stageValue;
210      this.applyPeer(node, true, component);
211      return true;
212    }
213    const stageTypeInfo: string = typeof this.stageValue;
214    const valueTypeInfo: string = typeof this.value;
215    let different: boolean = false;
216    if (stageTypeInfo !== valueTypeInfo) {
217      different = true;
218    } else if (stageTypeInfo === 'number' || stageTypeInfo === 'string' || stageTypeInfo === 'boolean') {
219      different = (this.stageValue !== this.value);
220    } else {
221      different = this.checkObjectDiff();
222    }
223    if (different) {
224      this.value = this.stageValue;
225      this.applyPeer(node, false, component);
226    }
227    return false;
228  }
229
230  applyStageImmediately(node: KNode, component?: ArkComponent): void {
231    this.value = this.stageValue;
232    if (this.stageValue === undefined || this.stageValue === null) {
233      this.applyPeer(node, true, component);
234      return;
235    }
236    this.applyPeer(node, false, component);
237  }
238
239  applyPeer(node: KNode, reset: boolean, component?: ArkComponent): void { }
240
241  checkObjectDiff(): boolean {
242    return true;
243  }
244}
245
246class BackgroundColorModifier extends ModifierWithKey<ResourceColor> {
247  constructor(value: ResourceColor) {
248    super(value);
249  }
250  static identity: Symbol = Symbol('backgroundColor');
251  applyPeer(node: KNode, reset: boolean): void {
252    if (reset) {
253      getUINativeModule().common.resetBackgroundColor(node);
254    } else {
255      getUINativeModule().common.setBackgroundColor(node, this.value);
256    }
257  }
258
259  checkObjectDiff(): boolean {
260    if (isResource(this.stageValue) && isResource(this.value)) {
261      return !isResourceEqual(this.stageValue, this.value);
262    } else {
263      return true;
264    }
265  }
266}
267
268class WidthModifier extends ModifierWithKey<Length> {
269  constructor(value: Length) {
270    super(value);
271  }
272  static identity: Symbol = Symbol('width');
273  applyPeer(node: KNode, reset: boolean): void {
274    if (reset) {
275      getUINativeModule().common.resetWidth(node);
276    } else {
277      getUINativeModule().common.setWidth(node, this.value);
278    }
279  }
280
281  checkObjectDiff(): boolean {
282    if (isResource(this.stageValue) && isResource(this.value)) {
283      return !isResourceEqual(this.stageValue, this.value);
284    } else {
285      return true;
286    }
287  }
288}
289
290class BorderWidthModifier extends ModifierWithKey<Length | EdgeWidths> {
291  constructor(value: Length | EdgeWidths | LocalizedEdgeWidths) {
292    super(value);
293  }
294  static identity: Symbol = Symbol('borderWidth');
295  applyPeer(node: KNode, reset: boolean): void {
296    if (reset) {
297      getUINativeModule().common.resetBorderWidth(node);
298    } else {
299      if (isNumber(this.value) || isString(this.value) || isResource(this.value)) {
300        getUINativeModule().common.setBorderWidth(node, this.value, this.value, this.value, this.value);
301      } else {
302        if ((Object.keys(this.value).indexOf('start') >= 0) ||
303            (Object.keys(this.value).indexOf('end') >= 0)) {
304          getUINativeModule().common.setBorderWidth(node,
305            (this.value as LocalizedEdgeWidths).top,
306            (this.value as LocalizedEdgeWidths).end,
307            (this.value as LocalizedEdgeWidths).bottom,
308            (this.value as LocalizedEdgeWidths).start);
309        } else {
310          getUINativeModule().common.setBorderWidth(node,
311            (this.value as EdgeWidths).top,
312            (this.value as EdgeWidths).right,
313            (this.value as EdgeWidths).bottom,
314            (this.value as EdgeWidths).left);
315        }
316      }
317    }
318  }
319
320  checkObjectDiff(): boolean {
321    if (isResource(this.stageValue) && isResource(this.value)) {
322      return !isResourceEqual(this.stageValue, this.value);
323    } else if (!isResource(this.stageValue) && !isResource(this.value)) {
324      if ((Object.keys(this.value).indexOf('start') >= 0) ||
325          (Object.keys(this.value).indexOf('end') >= 0)) {
326        return !((this.stageValue as LocalizedEdgeWidths).start === (this.value as LocalizedEdgeWidths).start &&
327          (this.stageValue as LocalizedEdgeWidths).end === (this.value as LocalizedEdgeWidths).end &&
328          (this.stageValue as LocalizedEdgeWidths).top === (this.value as LocalizedEdgeWidths).top &&
329          (this.stageValue as LocalizedEdgeWidths).bottom === (this.value as LocalizedEdgeWidths).bottom);
330      }
331      return !((this.stageValue as EdgeWidths).left === (this.value as EdgeWidths).left &&
332        (this.stageValue as EdgeWidths).right === (this.value as EdgeWidths).right &&
333        (this.stageValue as EdgeWidths).top === (this.value as EdgeWidths).top &&
334        (this.stageValue as EdgeWidths).bottom === (this.value as EdgeWidths).bottom);
335    } else {
336      return true;
337    }
338  }
339}
340
341class HeightModifier extends ModifierWithKey<Length> {
342  constructor(value: Length) {
343    super(value);
344  }
345  static identity: Symbol = Symbol('height');
346  applyPeer(node: KNode, reset: boolean): void {
347    if (reset) {
348      getUINativeModule().common.resetHeight(node);
349    } else {
350      getUINativeModule().common.setHeight(node, this.value);
351    }
352  }
353
354  checkObjectDiff(): boolean {
355    if (isResource(this.stageValue) && isResource(this.value)) {
356      return !isResourceEqual(this.stageValue, this.value);
357    } else {
358      return true;
359    }
360  }
361}
362
363class ChainModeifier extends ModifierWithKey<Length> {
364  constructor(value: Length) {
365    super(value);
366  }
367  static identity: Symbol = Symbol('chainMode');
368  applyPeer(node: KNode, reset: boolean): void {
369    if (reset) {
370      getUINativeModule().common.resetChainMode(node);
371    } else {
372      getUINativeModule().common.setChainMode(node, this.value.direction, this.value.style);
373    }
374  }
375
376  checkObjectDiff(): boolean {
377    return !isBaseOrResourceEqual(this.stageValue, this.value);
378  }
379}
380
381class BorderRadiusModifier extends ModifierWithKey<Length | BorderRadiuses | LocalizedBorderRadius> {
382  constructor(value: Length | BorderRadiuses | LocalizedBorderRadius) {
383    super(value);
384  }
385  static identity: Symbol = Symbol('borderRadius');
386  applyPeer(node: KNode, reset: boolean): void {
387    if (reset) {
388      getUINativeModule().common.resetBorderRadius(node);
389    } else {
390      if (isNumber(this.value) || isString(this.value) || isResource(this.value)) {
391        getUINativeModule().common.setBorderRadius(node, this.value, this.value, this.value, this.value);
392      } else {
393        if ((Object.keys(this.value).indexOf('topStart') >= 0) ||
394            (Object.keys(this.value).indexOf('topEnd') >= 0) ||
395            (Object.keys(this.value).indexOf('bottomStart') >= 0) ||
396            (Object.keys(this.value).indexOf('bottomEnd') >= 0)) {
397          getUINativeModule().common.setBorderRadius(node,
398            (this.value as LocalizedBorderRadius).topStart,
399            (this.value as LocalizedBorderRadius).topEnd,
400            (this.value as LocalizedBorderRadius).bottomStart,
401            (this.value as LocalizedBorderRadius).bottomEnd);
402        } else {
403          getUINativeModule().common.setBorderRadius(node,
404            (this.value as BorderRadiuses).topLeft,
405            (this.value as BorderRadiuses).topRight,
406            (this.value as BorderRadiuses).bottomLeft,
407            (this.value as BorderRadiuses).bottomRight);
408        }
409      }
410    }
411  }
412
413  checkObjectDiff(): boolean {
414    if (isResource(this.stageValue) && isResource(this.value)) {
415      return !isResourceEqual(this.stageValue, this.value);
416    } else if (!isResource(this.stageValue) && !isResource(this.value)) {
417      if ((Object.keys(this.value).indexOf('topStart') >= 0) ||
418          (Object.keys(this.value).indexOf('topEnd') >= 0) ||
419          (Object.keys(this.value).indexOf('bottomStart') >= 0) ||
420          (Object.keys(this.value).indexOf('bottomEnd') >= 0)) {
421        return !((this.stageValue as LocalizedBorderRadius).topStart === (this.value as LocalizedBorderRadius).topStart &&
422          (this.stageValue as LocalizedBorderRadius).topEnd === (this.value as LocalizedBorderRadius).topEnd &&
423          (this.stageValue as LocalizedBorderRadius).bottomStart === (this.value as LocalizedBorderRadius).bottomStart &&
424          (this.stageValue as LocalizedBorderRadius).bottomEnd === (this.value as LocalizedBorderRadius).bottomEnd);
425      }
426      return !((this.stageValue as BorderRadiuses).topLeft === (this.value as BorderRadiuses).topLeft &&
427        (this.stageValue as BorderRadiuses).topRight === (this.value as BorderRadiuses).topRight &&
428        (this.stageValue as BorderRadiuses).bottomLeft === (this.value as BorderRadiuses).bottomLeft &&
429        (this.stageValue as BorderRadiuses).bottomRight === (this.value as BorderRadiuses).bottomRight);
430    } else {
431      return true;
432    }
433  }
434}
435
436class PositionModifier extends ModifierWithKey<Position | Edges | LocalizedEdges> {
437  constructor(value: Position | Edges | LocalizedEdges) {
438    super(value);
439  }
440  static identity: Symbol = Symbol('position');
441  applyPeer(node: KNode, reset: boolean): void {
442    if (reset) {
443      getUINativeModule().common.resetPosition(node);
444    } else {
445      if (isUndefined(this.value)) {
446        getUINativeModule().common.resetPosition(node);
447      } else if (('x' in this.value) || ('y' in this.value)) {
448        getUINativeModule().common.setPosition(node, false, this.value.x, this.value.y);
449      } else if (('top' in this.value) || ('bottom' in this.value) || ('left' in this.value) || ('start' in this.value) || ('right' in this.value) || ('end' in this.value)) {
450        if (('start' in this.value)) {
451          this.value.left = this.value.start;
452        }
453        if (('end' in this.value)) {
454          this.value.right = this.value.end;
455        }
456        getUINativeModule().common.setPosition(node, true, this.value.top, this.value.left, this.value.bottom, this.value.right);
457      } else {
458        getUINativeModule().common.resetPosition(node);
459      }
460    }
461  }
462
463  checkObjectDiff(): boolean {
464    return !isBaseOrResourceEqual(this.stageValue.x, this.value.x) ||
465      !isBaseOrResourceEqual(this.stageValue.y, this.value.y) ||
466      !isBaseOrResourceEqual(this.stageValue.top, this.value.top) ||
467      !isBaseOrResourceEqual(this.stageValue.left, this.value.left) ||
468      !isBaseOrResourceEqual(this.stageValue.bottom, this.value.bottom) ||
469      !isBaseOrResourceEqual(this.stageValue.right, this.value.right) ||
470      !isBaseOrResourceEqual(this.stageValue.start, this.value.start) ||
471      !isBaseOrResourceEqual(this.stageValue.end, this.value.end);
472  }
473}
474
475class BorderColorModifier extends ModifierWithKey<ResourceColor | EdgeColors | LocalizedEdgeColors> {
476  constructor(value: ResourceColor | EdgeColors | LocalizedEdgeColors) {
477    super(value);
478  }
479  static identity: Symbol = Symbol('borderColor');
480  applyPeer(node: KNode, reset: boolean): void {
481    if (reset) {
482      getUINativeModule().common.resetBorderColor(node);
483    } else {
484      const valueType: string = typeof this.value;
485      if (valueType === 'number' || valueType === 'string' || isResource(this.value)) {
486        getUINativeModule().common.setBorderColor(node, this.value, this.value, this.value, this.value);
487      } else {
488        if ((Object.keys(this.value).indexOf('start') >= 0) ||
489            (Object.keys(this.value).indexOf('end') >= 0)) {
490          getUINativeModule().common.setBorderColor(node,
491            (this.value as LocalizedEdgeColors).top,
492            (this.value as LocalizedEdgeColors).end,
493            (this.value as LocalizedEdgeColors).bottom,
494            (this.value as LocalizedEdgeColors).start,
495            true);
496        } else {
497          getUINativeModule().common.setBorderColor(node,
498            (this.value as EdgeColors).top,
499            (this.value as EdgeColors).right,
500            (this.value as EdgeColors).bottom,
501            (this.value as EdgeColors).left,
502            false);
503        }
504      }
505
506    }
507  }
508
509  checkObjectDiff(): boolean {
510    if (isResource(this.stageValue) && isResource(this.value)) {
511      return !isResourceEqual(this.stageValue, this.value);
512    } else if (!isResource(this.stageValue) && !isResource(this.value)) {
513      if ((Object.keys(this.value).indexOf('start') >= 0) ||
514          (Object.keys(this.value).indexOf('end') >= 0)) {
515        return !((this.stageValue as LocalizedEdgeColors).start === (this.value as LocalizedEdgeColors).start &&
516          (this.stageValue as LocalizedEdgeColors).end === (this.value as LocalizedEdgeColors).end &&
517          (this.stageValue as LocalizedEdgeColors).top === (this.value as LocalizedEdgeColors).top &&
518          (this.stageValue as LocalizedEdgeColors).bottom === (this.value as LocalizedEdgeColors).bottom);
519      }
520      return !((this.stageValue as EdgeColors).left === (this.value as EdgeColors).left &&
521        (this.stageValue as EdgeColors).right === (this.value as EdgeColors).right &&
522        (this.stageValue as EdgeColors).top === (this.value as EdgeColors).top &&
523        (this.stageValue as EdgeColors).bottom === (this.value as EdgeColors).bottom);
524    } else {
525      return true;
526    }
527  }
528}
529
530interface Matrix {
531  matrix4x4: []
532}
533
534
535class TransformModifier extends ModifierWithKey<object> {
536  constructor(value: object) {
537    super(value);
538  }
539  static identity: Symbol = Symbol('transform');
540  applyPeer(node: KNode, reset: boolean): void {
541    if (reset) {
542      getUINativeModule().common.resetTransform(node);
543    } else {
544      getUINativeModule().common.setTransform(node, (this.value as Matrix).matrix4x4);
545    }
546  }
547  checkObjectDiff(): boolean {
548    return !deepCompareArrays((this.stageValue as Matrix).matrix4x4, (this.value as Matrix).matrix4x4);
549  }
550}
551
552class BorderStyleModifier extends ModifierWithKey<BorderStyle | EdgeStyles> {
553  constructor(value: BorderStyle | EdgeStyles) {
554    super(value);
555  }
556  static identity: Symbol = Symbol('borderStyle');
557  applyPeer(node: KNode, reset: boolean): void {
558    if (reset) {
559      getUINativeModule().common.resetBorderStyle(node);
560    } else {
561      let type: boolean;
562      let style: BorderStyle;
563      let top: BorderStyle;
564      let right: BorderStyle;
565      let bottom: BorderStyle;
566      let left: BorderStyle;
567      if (isNumber(this.value)) {
568        style = this.value as BorderStyle;
569        type = true;
570      } else if (isObject(this.value)) {
571        top = (this.value as EdgeStyles)?.top;
572        right = (this.value as EdgeStyles)?.right;
573        bottom = (this.value as EdgeStyles)?.bottom;
574        left = (this.value as EdgeStyles)?.left;
575        type = true;
576      }
577      if (type === true) {
578        getUINativeModule().common.setBorderStyle(node, type, style, top, right, bottom, left);
579      } else {
580        getUINativeModule().common.resetBorderStyle(node);
581      }
582    }
583  }
584  checkObjectDiff(): boolean {
585    return !((this.value as EdgeStyles)?.top === (this.stageValue as EdgeStyles)?.top &&
586      (this.value as EdgeStyles)?.right === (this.stageValue as EdgeStyles)?.right &&
587      (this.value as EdgeStyles)?.bottom === (this.stageValue as EdgeStyles)?.bottom &&
588      (this.value as EdgeStyles)?.left === (this.stageValue as EdgeStyles)?.left);
589  }
590}
591
592class ShadowModifier extends ModifierWithKey<ShadowOptions | ShadowStyle> {
593  constructor(value: ShadowOptions | ShadowStyle) {
594    super(value);
595  }
596  static identity: Symbol = Symbol('shadow');
597  applyPeer(node: KNode, reset: boolean): void {
598    if (reset) {
599      getUINativeModule().common.resetShadow(node);
600    } else {
601      if (isNumber(this.value)) {
602        getUINativeModule().common.setShadow(node, this.value, undefined, undefined, undefined, undefined, undefined, undefined);
603      } else {
604        getUINativeModule().common.setShadow(node, undefined,
605          (this.value as ShadowOptions).radius,
606          (this.value as ShadowOptions).type,
607          (this.value as ShadowOptions).color,
608          (this.value as ShadowOptions).offsetX,
609          (this.value as ShadowOptions).offsetY,
610          (this.value as ShadowOptions).fill);
611      }
612    }
613  }
614
615  checkObjectDiff(): boolean {
616    return !((this.stageValue as ShadowOptions).radius === (this.value as ShadowOptions).radius &&
617      (this.stageValue as ShadowOptions).type === (this.value as ShadowOptions).type &&
618      (this.stageValue as ShadowOptions).color === (this.value as ShadowOptions).color &&
619      (this.stageValue as ShadowOptions).offsetX === (this.value as ShadowOptions).offsetX &&
620      (this.stageValue as ShadowOptions).offsetY === (this.value as ShadowOptions).offsetY &&
621      (this.stageValue as ShadowOptions).fill === (this.value as ShadowOptions).fill);
622  }
623}
624
625class HitTestBehaviorModifier extends ModifierWithKey<number> {
626  constructor(value: number) {
627    super(value);
628  }
629  static identity: Symbol = Symbol('hitTestBehavior');
630  applyPeer(node: KNode, reset: boolean): void {
631    if (reset) {
632      getUINativeModule().common.resetHitTestBehavior(node);
633    } else {
634      getUINativeModule().common.setHitTestBehavior(node, this.value);
635    }
636  }
637}
638
639class ZIndexModifier extends ModifierWithKey<number> {
640  constructor(value: number) {
641    super(value);
642  }
643  static identity: Symbol = Symbol('zIndex');
644  applyPeer(node: KNode, reset: boolean): void {
645    if (reset) {
646      getUINativeModule().common.resetZIndex(node);
647    } else {
648      getUINativeModule().common.setZIndex(node, this.value);
649    }
650  }
651}
652
653class OpacityModifier extends ModifierWithKey<number | Resource> {
654  constructor(value: number | Resource) {
655    super(value);
656  }
657  static identity: Symbol = Symbol('opacity');
658  applyPeer(node: KNode, reset: boolean): void {
659    if (reset) {
660      getUINativeModule().common.resetOpacity(node);
661    } else {
662      getUINativeModule().common.setOpacity(node, this.value);
663    }
664  }
665
666  checkObjectDiff(): boolean {
667    if (isResource(this.stageValue) && isResource(this.value)) {
668      return !isResourceEqual(this.stageValue, this.value);
669    } else {
670      return true;
671    }
672  }
673}
674
675class AlignModifier extends ModifierWithKey<number> {
676  constructor(value: number) {
677    super(value);
678  }
679  static identity: Symbol = Symbol('align');
680  applyPeer(node: KNode, reset: boolean): void {
681    if (reset) {
682      getUINativeModule().common.resetAlign(node);
683    } else {
684      getUINativeModule().common.setAlign(node, this.value);
685    }
686  }
687}
688
689class BackdropBlurModifier extends ModifierWithKey<ArkBlurOptions> {
690  constructor(value: ArkBlurOptions) {
691    super(value);
692  }
693  static identity: Symbol = Symbol('backdropBlur');
694  applyPeer(node: KNode, reset: boolean): void {
695    if (reset) {
696      getUINativeModule().common.resetBackdropBlur(node);
697    } else {
698      getUINativeModule().common.setBackdropBlur(node, this.value.value, this.value.options?.grayscale);
699    }
700  }
701  checkObjectDiff(): boolean {
702    return !((this.stageValue.value === this.value.value) &&
703      (this.stageValue.options === this.value.options));
704  }
705}
706
707class HueRotateModifier extends ModifierWithKey<number | string> {
708  constructor(value: number | string) {
709    super(value);
710  }
711  static identity: Symbol = Symbol('hueRotate');
712  applyPeer(node: KNode, reset: boolean): void {
713    if (reset) {
714      getUINativeModule().common.resetHueRotate(node);
715    } else {
716      getUINativeModule().common.setHueRotate(node, this.value);
717    }
718  }
719}
720
721class InvertModifier extends ModifierWithKey<number | InvertOptions> {
722  constructor(value: number | InvertOptions) {
723    super(value);
724  }
725  static identity: Symbol = Symbol('invert');
726  applyPeer(node: KNode, reset: boolean): void {
727    if (reset) {
728      getUINativeModule().common.resetInvert(node);
729    } else {
730      if (isNumber(this.value)) {
731        getUINativeModule().common.setInvert(node, this.value, undefined, undefined, undefined, undefined);
732      } else {
733        getUINativeModule().common.setInvert(node, undefined,
734          (this.value as InvertOptions).low,
735          (this.value as InvertOptions).high,
736          (this.value as InvertOptions).threshold,
737          (this.value as InvertOptions).thresholdRange);
738      }
739    }
740  }
741  checkObjectDiff(): boolean {
742    return !((this.stageValue as InvertOptions).high === (this.value as InvertOptions).high &&
743      (this.stageValue as InvertOptions).low === (this.value as InvertOptions).low &&
744      (this.stageValue as InvertOptions).threshold === (this.value as InvertOptions).threshold &&
745      (this.stageValue as InvertOptions).thresholdRange === (this.value as InvertOptions).thresholdRange);
746  }
747}
748
749class SepiaModifier extends ModifierWithKey<number> {
750  constructor(value: number) {
751    super(value);
752  }
753  static identity: Symbol = Symbol('sepia');
754  applyPeer(node: KNode, reset: boolean): void {
755    if (reset) {
756      getUINativeModule().common.resetSepia(node);
757    } else {
758      getUINativeModule().common.setSepia(node, this.value);
759    }
760  }
761}
762
763class SaturateModifier extends ModifierWithKey<number> {
764  constructor(value: number) {
765    super(value);
766  }
767  static identity: Symbol = Symbol('saturate');
768  applyPeer(node: KNode, reset: boolean): void {
769    if (reset) {
770      getUINativeModule().common.resetSaturate(node);
771    } else {
772      getUINativeModule().common.setSaturate(node, this.value);
773    }
774  }
775}
776
777class ColorBlendModifier extends ModifierWithKey<Color | string | Resource> {
778  constructor(value: Color | string | Resource) {
779    super(value);
780  }
781  static identity: Symbol = Symbol('colorBlend');
782  applyPeer(node: KNode, reset: boolean): void {
783    if (reset) {
784      getUINativeModule().common.resetColorBlend(node);
785    } else {
786      getUINativeModule().common.setColorBlend(node, this.value);
787    }
788  }
789
790  checkObjectDiff(): boolean {
791    if (isResource(this.stageValue) && isResource(this.value)) {
792      return !isResourceEqual(this.stageValue, this.value);
793    } else {
794      return true;
795    }
796  }
797}
798
799class GrayscaleModifier extends ModifierWithKey<number> {
800  constructor(value: number) {
801    super(value);
802  }
803  static identity: Symbol = Symbol('grayscale');
804  applyPeer(node: KNode, reset: boolean): void {
805    if (reset) {
806      getUINativeModule().common.resetGrayscale(node);
807    } else {
808      getUINativeModule().common.setGrayscale(node, this.value);
809    }
810  }
811}
812
813class ContrastModifier extends ModifierWithKey<number> {
814  constructor(value: number) {
815    super(value);
816  }
817  static identity: Symbol = Symbol('contrast');
818  applyPeer(node: KNode, reset: boolean): void {
819    if (reset) {
820      getUINativeModule().common.resetContrast(node);
821    } else {
822      getUINativeModule().common.setContrast(node, this.value);
823    }
824  }
825}
826
827class BrightnessModifier extends ModifierWithKey<number> {
828  constructor(value: number) {
829    super(value);
830  }
831  static identity: Symbol = Symbol('brightness');
832  applyPeer(node: KNode, reset: boolean): void {
833    if (reset) {
834      getUINativeModule().common.resetBrightness(node);
835    } else {
836      getUINativeModule().common.setBrightness(node, this.value);
837    }
838  }
839}
840
841class BlurModifier extends ModifierWithKey<ArkBlurOptions> {
842  constructor(value: ArkBlurOptions) {
843    super(value);
844  }
845  static identity: Symbol = Symbol('blur');
846  applyPeer(node: KNode, reset: boolean): void {
847    if (reset) {
848      getUINativeModule().common.resetBlur(node);
849    } else {
850      getUINativeModule().common.setBlur(node, this.value.value, this.value.options?.grayscale);
851    }
852  }
853  checkObjectDiff(): boolean {
854    return !((this.stageValue.value === this.value.value) &&
855      (this.stageValue.options === this.value.options));
856  }
857}
858
859class LinearGradientModifier extends ModifierWithKey<{
860  angle?: number | string;
861  direction?: GradientDirection; colors: Array<any>; repeating?: boolean;
862}> {
863  constructor(value: {
864    angle?: number | string; direction?: GradientDirection;
865    colors: Array<any>; repeating?: boolean;
866  }) {
867    super(value);
868  }
869  static identity: Symbol = Symbol('linearGradient');
870  applyPeer(node: KNode, reset: boolean): void {
871    if (reset) {
872      getUINativeModule().common.resetLinearGradient(node);
873    } else {
874      getUINativeModule().common.setLinearGradient(node,
875        this.value.angle, this.value.direction,
876        this.value.colors, this.value.repeating);
877    }
878  }
879  checkObjectDiff(): boolean {
880    return !((this.stageValue.angle === this.value.angle) &&
881      (this.stageValue.direction === this.value.direction) &&
882      (this.stageValue.colors === this.value.colors) &&
883      (this.stageValue.repeating === this.value.repeating));
884  }
885}
886
887class RadialGradientModifier extends ModifierWithKey<{ center: Array<any>; radius: number | string; colors: Array<any>; repeating?: boolean }> {
888  constructor(value: { center: Array<any>; radius: number | string; colors: Array<any>; repeating?: boolean }) {
889    super(value);
890  }
891  static identity: Symbol = Symbol('radialGradient');
892  applyPeer(node: KNode, reset: boolean): void {
893    if (reset) {
894      getUINativeModule().common.resetRadialGradient(node);
895    } else {
896      getUINativeModule().common.setRadialGradient(node,
897        this.value.center, this.value.radius, this.value.colors, this.value.repeating);
898    }
899  }
900  checkObjectDiff(): boolean {
901    return !((this.stageValue.center === this.value.center) &&
902      (this.stageValue.radius === this.value.radius) &&
903      (this.stageValue.colors === this.value.colors) &&
904      (this.stageValue.repeating === this.value.repeating));
905  }
906}
907
908class SweepGradientModifier extends ModifierWithKey<{
909  center: Array<any>; start?: number |
910  string; end?: number | string; rotation?: number | string;
911  colors: Array<any>; repeating?: boolean;
912}> {
913  constructor(value: {
914    center: Array<any>;
915    start?: number | string; end?: number | string;
916    rotation?: number | string; colors: Array<any>; repeating?: boolean;
917  }) {
918    super(value);
919  }
920  static identity: Symbol = Symbol('sweepGradient');
921  applyPeer(node: KNode, reset: boolean): void {
922    if (reset) {
923      getUINativeModule().common.resetSweepGradient(node);
924    } else {
925      getUINativeModule().common.setSweepGradient(node,
926        this.value.center,
927        this.value.start, this.value.end, this.value.rotation,
928        this.value.colors, this.value.repeating);
929    }
930  }
931  checkObjectDiff(): boolean {
932    return !((this.stageValue.center === this.value.center) &&
933      (this.stageValue.start === this.value.start) &&
934      (this.stageValue.end === this.value.end) &&
935      (this.stageValue.rotation === this.value.rotation) &&
936      (this.stageValue.colors === this.value.colors) &&
937      (this.stageValue.repeating === this.value.repeating));
938  }
939}
940
941class OverlayModifier extends ModifierWithKey<ArkOverlay> {
942  constructor(value: ArkOverlay) {
943    super(value);
944  }
945  static identity: Symbol = Symbol('overlay');
946  applyPeer(node: KNode, reset: boolean): void {
947    if (reset) {
948      getUINativeModule().common.resetOverlay(node);
949    } else {
950      getUINativeModule().common.setOverlay(node,
951        this.value.value, this.value.align,
952        this.value.offsetX, this.value.offsetY,
953        this.value.hasOptions, this.value.hasOffset);
954    }
955  }
956  checkObjectDiff(): boolean {
957    if (isUndefined(this.value)) {
958      return !isUndefined(this.stageValue);
959    }
960    return this.value.checkObjectDiff(this.stageValue);
961  }
962}
963
964class BorderImageModifier extends ModifierWithKey<BorderImageOption> {
965  constructor(value: BorderImageOption) {
966    super(value);
967  }
968  static identity: Symbol = Symbol('borderImage');
969  applyPeer(node: KNode, reset: boolean): void {
970    if (reset) {
971      getUINativeModule().common.resetBorderImage(node);
972    } else {
973      let sliceTop: Length | undefined;
974      let sliceRight: Length | undefined;
975      let sliceBottom: Length | undefined;
976      let sliceLeft: Length | undefined;
977      let repeat: RepeatMode | undefined;
978      let source: string | Resource | LinearGradient | undefined;
979      let sourceAngle: number | string | undefined;
980      let sourceDirection: GradientDirection | undefined;
981      let sourceColors: Array<any> | undefined;
982      let sourceRepeating: boolean | undefined;
983      let widthTop: Length | undefined;
984      let widthRight: Length | undefined;
985      let widthBottom: Length | undefined;
986      let widthLeft: Length | undefined;
987      let outsetTop: Length | undefined;
988      let outsetRight: Length | undefined;
989      let outsetBottom: Length | undefined;
990      let outsetLeft: Length | undefined;
991      let fill: boolean | undefined;
992
993      if (!isUndefined(this.value.slice)) {
994        if (isLengthType(this.value.slice) || isResource(this.value.slice)) {
995          let tmpSlice = this.value.slice as Length;
996          sliceTop = tmpSlice;
997          sliceRight = tmpSlice;
998          sliceBottom = tmpSlice;
999          sliceLeft = tmpSlice;
1000        } else {
1001          let tmpSlice = this.value.slice as EdgeWidths;
1002          sliceTop = tmpSlice.top;
1003          sliceRight = tmpSlice.right;
1004          sliceBottom = tmpSlice.bottom;
1005          sliceLeft = tmpSlice.left;
1006        }
1007      }
1008      repeat = this.value.repeat;
1009      if (!isUndefined(this.value.source)) {
1010        if (isString(this.value.source) || isResource(this.value.source)) {
1011          source = this.value.source;
1012        } else {
1013          let tmpSource = this.value.source as LinearGradient;
1014          sourceAngle = tmpSource.angle;
1015          sourceDirection = tmpSource.direction;
1016          sourceColors = tmpSource.colors;
1017          sourceRepeating = tmpSource.repeating;
1018        }
1019      }
1020      if (!isUndefined(this.value.width)) {
1021        if (isLengthType(this.value.width) || isResource(this.value.width)) {
1022          let tmpWidth = this.value.width as Length;
1023          widthTop = tmpWidth;
1024          widthRight = tmpWidth;
1025          widthBottom = tmpWidth;
1026          widthLeft = tmpWidth;
1027        } else {
1028          let tmpWidth = this.value.width as EdgeWidths;
1029          widthTop = tmpWidth.top;
1030          widthRight = tmpWidth.right;
1031          widthBottom = tmpWidth.bottom;
1032          widthLeft = tmpWidth.left;
1033        }
1034      }
1035      if (!isUndefined(this.value.outset)) {
1036        if (isLengthType(this.value.outset) || isResource(this.value.outset)) {
1037          let tmpOutset = this.value.outset as Length;
1038          outsetTop = tmpOutset;
1039          outsetRight = tmpOutset;
1040          outsetBottom = tmpOutset;
1041          outsetLeft = tmpOutset;
1042        } else {
1043          let tmpOutset = this.value.outset as EdgeWidths;
1044          outsetTop = tmpOutset.top;
1045          outsetRight = tmpOutset.right;
1046          outsetBottom = tmpOutset.bottom;
1047          outsetLeft = tmpOutset.left;
1048        }
1049      }
1050      fill = this.value.fill;
1051      getUINativeModule().common.setBorderImage(node,
1052        sliceTop, sliceRight, sliceBottom, sliceLeft,
1053        repeat,
1054        source, sourceAngle, sourceDirection, sourceColors, sourceRepeating,
1055        widthTop, widthRight, widthBottom, widthLeft,
1056        outsetTop, outsetRight, outsetBottom, outsetLeft,
1057        fill);
1058    }
1059  }
1060}
1061
1062class BorderModifier extends ModifierWithKey<ArkBorder> {
1063  constructor(value: ArkBorder) {
1064    super(value);
1065  }
1066  static identity: Symbol = Symbol('border');
1067  applyPeer(node: KNode, reset: boolean): void {
1068    if (reset) {
1069      getUINativeModule().common.resetBorder(node);
1070    } else {
1071      let isLocalizedBorderWidth;
1072      let isLocalizedBorderColor;
1073      let isLocalizedBorderRadius;
1074      if ((Object.keys(this.value.arkWidth).indexOf('start') >= 0 && isUndefined(this.value.arkWidth.start)) ||
1075        (Object.keys(this.value.arkWidth).indexOf('end') >= 0 && isUndefined(this.value.arkWidth.end))) {
1076        isLocalizedBorderWidth = true;
1077      } else {
1078        isLocalizedBorderWidth = false;
1079      }
1080      if ((Object.keys(this.value.arkColor).indexOf('startColor') >= 0 && isUndefined(this.value.arkColor.startColor)) ||
1081        (Object.keys(this.value.arkColor).indexOf('endColor') >= 0 && isUndefined(this.value.arkColor.endColor))) {
1082        isLocalizedBorderColor = true;
1083      } else {
1084        isLocalizedBorderColor = false;
1085      }
1086      if ((Object.keys(this.value.arkRadius).indexOf('topStart') >= 0 && isUndefined(this.value.arkRadius.topStart)) ||
1087        (Object.keys(this.value.arkRadius).indexOf('topEnd') >= 0 && isUndefined(this.value.arkRadius.topEnd)) ||
1088        (Object.keys(this.value.arkRadius).indexOf('bottomStart') >= 0 && isUndefined(this.value.arkRadius.bottomStart)) ||
1089        (Object.keys(this.value.arkRadius).indexOf('bottomEnd') >= 0 && isUndefined(this.value.arkRadius.bottomEnd))) {
1090        isLocalizedBorderRadius = true;
1091      } else {
1092        isLocalizedBorderRadius = false;
1093      }
1094      getUINativeModule().common.setBorderWithDashParams(node,
1095        this.value.arkWidth.left, this.value.arkWidth.right, this.value.arkWidth.top, this.value.arkWidth.bottom,
1096        this.value.arkColor.leftColor, this.value.arkColor.rightColor, this.value.arkColor.topColor, this.value.arkColor.bottomColor,
1097        this.value.arkRadius.topLeft, this.value.arkRadius.topRight, this.value.arkRadius.bottomLeft, this.value.arkRadius.bottomRight,
1098        this.value.arkStyle.top, this.value.arkStyle.right, this.value.arkStyle.bottom, this.value.arkStyle.left,
1099        this.value.arkDashGap.left, this.value.arkDashGap.right, this.value.arkDashGap.top, this.value.arkDashGap.bottom,
1100        this.value.arkDashWidth.left, this.value.arkDashWidth.right, this.value.arkDashWidth.top, this.value.arkDashWidth.bottom,
1101        this.value.arkWidth.start, this.value.arkWidth.end, this.value.arkColor.startColor, this.value.arkColor.endColor,
1102        this.value.arkRadius.topStart, this.value.arkRadius.topEnd, this.value.arkRadius.bottomStart, this.value.arkRadius.bottomEnd,
1103        isLocalizedBorderWidth, isLocalizedBorderColor, isLocalizedBorderRadius,
1104        this.value.arkDashGap.start, this.value.arkDashGap.end, this.value.arkDashWidth.start, this.value.arkDashWidth.end
1105      );
1106    }
1107  }
1108
1109  checkObjectDiff(): boolean {
1110    return this.value.checkObjectDiff(this.stageValue);
1111  }
1112}
1113
1114class OutlineColorModifier extends ModifierWithKey<ResourceColor | EdgeColors> {
1115  constructor(value: ResourceColor | EdgeColors) {
1116    super(value);
1117  }
1118  static identity: Symbol = Symbol('outlineColor');
1119  applyPeer(node: KNode, reset: boolean): void {
1120    if (reset) {
1121      getUINativeModule().common.resetOutlineColor(node);
1122    } else {
1123      const valueType: string = typeof this.value;
1124      if (valueType === 'number' || valueType === 'string' || isResource(this.value)) {
1125        getUINativeModule().common.setOutlineColor(node, this.value, this.value, this.value, this.value);
1126      } else {
1127        getUINativeModule().common.setOutlineColor(node, (this.value as EdgeColors).left,
1128          (this.value as EdgeColors).right, (this.value as EdgeColors).top,
1129          (this.value as EdgeColors).bottom);
1130      }
1131    }
1132  }
1133
1134  checkObjectDiff(): boolean {
1135    if (isResource(this.stageValue) && isResource(this.value)) {
1136      return !isResourceEqual(this.stageValue, this.value);
1137    } else if (!isResource(this.stageValue) && !isResource(this.value)) {
1138      return !((this.stageValue as EdgeColors).left === (this.value as EdgeColors).left &&
1139        (this.stageValue as EdgeColors).right === (this.value as EdgeColors).right &&
1140        (this.stageValue as EdgeColors).top === (this.value as EdgeColors).top &&
1141        (this.stageValue as EdgeColors).bottom === (this.value as EdgeColors).bottom);
1142    } else {
1143      return true;
1144    }
1145  }
1146}
1147
1148class OutlineRadiusModifier extends ModifierWithKey<Dimension | OutlineRadiuses> {
1149  constructor(value: Dimension | OutlineRadiuses) {
1150    super(value);
1151  }
1152  static identity: Symbol = Symbol('outlineRadius');
1153  applyPeer(node: KNode, reset: boolean): void {
1154    if (reset) {
1155      getUINativeModule().common.resetOutlineRadius(node);
1156    } else {
1157      const valueType: string = typeof this.value;
1158      if (valueType === 'number' || valueType === 'string' || isResource(this.value)) {
1159        getUINativeModule().common.setOutlineRadius(node, this.value, this.value, this.value, this.value);
1160      } else {
1161        getUINativeModule().common.setOutlineRadius(node, (this.value as OutlineRadiuses).topLeft,
1162          (this.value as OutlineRadiuses).topRight, (this.value as OutlineRadiuses).bottomLeft,
1163          (this.value as OutlineRadiuses).bottomRight);
1164      }
1165    }
1166  }
1167  checkObjectDiff(): boolean {
1168    if (isResource(this.stageValue) && isResource(this.value)) {
1169      return !isResourceEqual(this.stageValue, this.value);
1170    } else if (!isResource(this.stageValue) && !isResource(this.value)) {
1171      return !((this.stageValue as BorderRadiuses).topLeft === (this.value as BorderRadiuses).topLeft &&
1172        (this.stageValue as BorderRadiuses).topRight === (this.value as BorderRadiuses).topRight &&
1173        (this.stageValue as BorderRadiuses).bottomLeft === (this.value as BorderRadiuses).bottomLeft &&
1174        (this.stageValue as BorderRadiuses).bottomRight === (this.value as BorderRadiuses).bottomRight);
1175    } else {
1176      return true;
1177    }
1178  }
1179}
1180
1181class OutlineStyleModifier extends ModifierWithKey<OutlineStyle | EdgeOutlineStyles> {
1182  constructor(value: OutlineStyle | EdgeOutlineStyles) {
1183    super(value);
1184  }
1185  static identity: Symbol = Symbol('outlineStyle');
1186  applyPeer(node: KNode, reset: boolean): void {
1187    if (reset) {
1188      getUINativeModule().common.resetOutlineStyle(node);
1189    } else {
1190      if (isNumber(this.value)) {
1191        getUINativeModule().common.setOutlineStyle(node, this.value, this.value, this.value, this.value);
1192      } else {
1193        getUINativeModule().common.setOutlineStyle(node,
1194          (this.value as EdgeOutlineStyles).top,
1195          (this.value as EdgeOutlineStyles).right,
1196          (this.value as EdgeOutlineStyles).bottom,
1197          (this.value as EdgeOutlineStyles).left);
1198      }
1199    }
1200  }
1201  checkObjectDiff(): boolean {
1202    return !((this.value as EdgeOutlineStyles).top === (this.stageValue as EdgeOutlineStyles).top &&
1203      (this.value as EdgeOutlineStyles).right === (this.stageValue as EdgeOutlineStyles).right &&
1204      (this.value as EdgeOutlineStyles).bottom === (this.stageValue as EdgeOutlineStyles).bottom &&
1205      (this.value as EdgeOutlineStyles).left === (this.stageValue as EdgeOutlineStyles).left);
1206  }
1207}
1208
1209class OutlineWidthModifier extends ModifierWithKey<Dimension | EdgeOutlineWidths> {
1210  constructor(value: Dimension | EdgeOutlineWidths) {
1211    super(value);
1212  }
1213  static identity: Symbol = Symbol('outlineWidth');
1214  applyPeer(node: KNode, reset: boolean): void {
1215    if (reset) {
1216      getUINativeModule().common.resetOutlineWidth(node);
1217    } else {
1218      if (isNumber(this.value) || isString(this.value) || isResource(this.value)) {
1219        getUINativeModule().common.setOutlineWidth(node, this.value, this.value, this.value, this.value);
1220      } else {
1221        getUINativeModule().common.setOutlineWidth(node,
1222          (this.value as EdgeOutlineWidths).left,
1223          (this.value as EdgeOutlineWidths).right,
1224          (this.value as EdgeOutlineWidths).top,
1225          (this.value as EdgeOutlineWidths).bottom);
1226      }
1227    }
1228  }
1229
1230  checkObjectDiff(): boolean {
1231    if (isResource(this.stageValue) && isResource(this.value)) {
1232      return !isResourceEqual(this.stageValue, this.value);
1233    } else if (!isResource(this.stageValue) && !isResource(this.value)) {
1234      return !((this.stageValue as EdgeOutlineWidths).left === (this.value as EdgeOutlineWidths).left &&
1235        (this.stageValue as EdgeOutlineWidths).right === (this.value as EdgeOutlineWidths).right &&
1236        (this.stageValue as EdgeOutlineWidths).top === (this.value as EdgeOutlineWidths).top &&
1237        (this.stageValue as EdgeOutlineWidths).bottom === (this.value as EdgeOutlineWidths).bottom);
1238    } else {
1239      return true;
1240    }
1241  }
1242}
1243
1244class OutlineModifier extends ModifierWithKey<OutlineOptions> {
1245  constructor(value: OutlineOptions) {
1246    super(value);
1247  }
1248  static identity: Symbol = Symbol('outline');
1249  applyPeer(node: KNode, reset: boolean): void {
1250    if (reset) {
1251      getUINativeModule().common.resetOutline(node);
1252    } else {
1253      let widthLeft;
1254      let widthRight;
1255      let widthTop;
1256      let widthBottom;
1257      if (!isUndefined(this.value.width) && this.value.width != null) {
1258        if (isNumber(this.value.width) || isString(this.value.width) || isResource(this.value.width)) {
1259          widthLeft = this.value.width;
1260          widthRight = this.value.width;
1261          widthTop = this.value.width;
1262          widthBottom = this.value.width;
1263        } else {
1264          widthLeft = (this.value.width as EdgeOutlineWidths).left;
1265          widthRight = (this.value.width as EdgeOutlineWidths).right;
1266          widthTop = (this.value.width as EdgeOutlineWidths).top;
1267          widthBottom = (this.value.width as EdgeOutlineWidths).bottom;
1268        }
1269      }
1270      let leftColor;
1271      let rightColor;
1272      let topColor;
1273      let bottomColor;
1274      if (!isUndefined(this.value.color) && this.value.color != null) {
1275        if (isNumber(this.value.color) || isString(this.value.color) || isResource(this.value.color)) {
1276          leftColor = this.value.color;
1277          rightColor = this.value.color;
1278          topColor = this.value.color;
1279          bottomColor = this.value.color;
1280        } else {
1281          leftColor = (this.value.color as EdgeColors).left;
1282          rightColor = (this.value.color as EdgeColors).right;
1283          topColor = (this.value.color as EdgeColors).top;
1284          bottomColor = (this.value.color as EdgeColors).bottom;
1285        }
1286      }
1287      let topLeft;
1288      let topRight;
1289      let bottomLeft;
1290      let bottomRight;
1291      if (!isUndefined(this.value.radius) && this.value.radius != null) {
1292        if (isNumber(this.value.radius) || isString(this.value.radius) || isResource(this.value.radius)) {
1293          topLeft = this.value.radius;
1294          topRight = this.value.radius;
1295          bottomLeft = this.value.radius;
1296          bottomRight = this.value.radius;
1297        } else {
1298          topLeft = (this.value.radius as OutlineRadiuses).topLeft;
1299          topRight = (this.value.radius as OutlineRadiuses).topRight;
1300          bottomLeft = (this.value.radius as OutlineRadiuses).bottomLeft;
1301          bottomRight = (this.value.radius as OutlineRadiuses).bottomRight;
1302        }
1303      }
1304      let styleTop;
1305      let styleRight;
1306      let styleBottom;
1307      let styleLeft;
1308      if (!isUndefined(this.value.style) && this.value.style != null) {
1309        if (isNumber(this.value.style) || isString(this.value.style) || isResource(this.value.style)) {
1310          styleTop = this.value.style;
1311          styleRight = this.value.style;
1312          styleBottom = this.value.style;
1313          styleLeft = this.value.style;
1314        } else {
1315          styleTop = (this.value.style as EdgeOutlineStyles).top;
1316          styleRight = (this.value.style as EdgeOutlineStyles).right;
1317          styleBottom = (this.value.style as EdgeOutlineStyles).bottom;
1318          styleLeft = (this.value.style as EdgeOutlineStyles).left;
1319        }
1320      }
1321      getUINativeModule().common.setOutline(node, widthLeft, widthRight, widthTop, widthBottom,
1322        leftColor, rightColor, topColor, bottomColor,
1323        topLeft, topRight, bottomLeft, bottomRight,
1324        styleTop, styleRight, styleBottom, styleLeft);
1325    }
1326  }
1327
1328  checkObjectDiff(): boolean {
1329    return !isBaseOrResourceEqual(this.stageValue.width, this.value.width) ||
1330      !isBaseOrResourceEqual(this.stageValue.color, this.value.color) ||
1331      !isBaseOrResourceEqual(this.stageValue.radius, this.value.radius) ||
1332      !isBaseOrResourceEqual(this.stageValue.style, this.value.style);
1333  }
1334}
1335
1336class ForegroundBlurStyleModifier extends ModifierWithKey<ArkForegroundBlurStyle> {
1337  constructor(value: ArkForegroundBlurStyle) {
1338    super(value);
1339  }
1340  static identity: Symbol = Symbol('foregroundBlurStyle');
1341  applyPeer(node: KNode, reset: boolean): void {
1342    if (reset) {
1343      getUINativeModule().common.resetForegroundBlurStyle(node);
1344    } else {
1345      getUINativeModule().common.setForegroundBlurStyle(node,
1346        this.value.blurStyle, this.value.colorMode, this.value.adaptiveColor, this.value.scale,
1347          this.value.blurOptions?.grayscale);
1348    }
1349  }
1350
1351  checkObjectDiff(): boolean {
1352    return !((this.stageValue as ArkForegroundBlurStyle).blurStyle === (this.value as ArkForegroundBlurStyle).blurStyle &&
1353      (this.stageValue as ArkForegroundBlurStyle).colorMode === (this.value as ArkForegroundBlurStyle).colorMode &&
1354      (this.stageValue as ArkForegroundBlurStyle).adaptiveColor === (this.value as ArkForegroundBlurStyle).adaptiveColor &&
1355      (this.stageValue as ArkForegroundBlurStyle).scale === (this.value as ArkForegroundBlurStyle).scale &&
1356      (this.stageValue as ArkForegroundBlurStyle).blurOptions === (this.value as ArkForegroundBlurStyle).blurOptions);
1357  }
1358}
1359
1360class BackgroundImagePositionModifier extends ModifierWithKey<Position | Alignment> {
1361  constructor(value: Position | Alignment) {
1362    super(value);
1363  }
1364  static identity: Symbol = Symbol('backgroundImagePosition');
1365  applyPeer(node: KNode, reset: boolean): void {
1366    if (reset) {
1367      getUINativeModule().common.resetBackgroundImagePosition(node);
1368    } else {
1369      if (isNumber(this.value)) {
1370        getUINativeModule().common.setBackgroundImagePosition(node, this.value, undefined, undefined);
1371      } else {
1372        getUINativeModule().common.setBackgroundImagePosition(node, undefined, (this.value as Position)?.x, (this.value as Position)?.y);
1373      }
1374    }
1375  }
1376  checkObjectDiff(): boolean {
1377    return !((this.value as Position)?.x === (this.stageValue as Position)?.x &&
1378      (this.value as Position)?.y === (this.stageValue as Position)?.y);
1379  }
1380}
1381
1382class BackgroundImageResizableModifier extends ModifierWithKey<ResizableOptions> {
1383  constructor(value: ResizableOptions) {
1384    super(value);
1385  }
1386  static identity: Symbol = Symbol('backgroundImageResizable');
1387  applyPeer(node: KNode, reset: boolean): void {
1388    if (reset) {
1389      getUINativeModule().common.resetBackgroundImageResizable(node);
1390    } else {
1391      let sliceTop: Length | undefined;
1392      let sliceBottom: Length | undefined;
1393      let sliceLeft: Length | undefined;
1394      let sliceRight: Length | undefined;
1395      if (!isUndefined(this.value.slice)) {
1396        let tempSlice = this.value.slice as EdgeWidths;
1397        sliceTop = tempSlice.top;
1398        sliceBottom = tempSlice.bottom;
1399        sliceLeft = tempSlice.left;
1400        sliceRight = tempSlice.right;
1401      }
1402      getUINativeModule().common.setBackgroundImageResizable(node, sliceTop, sliceBottom, sliceLeft, sliceRight);
1403    }
1404  }
1405  checkObjectDiff(): boolean {
1406    return !isBaseOrResourceEqual(this.stageValue, this.value);
1407  }
1408}
1409
1410class LinearGradientBlurModifier extends ModifierWithKey<ArkLinearGradientBlur> {
1411  constructor(value: ArkLinearGradientBlur) {
1412    super(value);
1413  }
1414  static identity: Symbol = Symbol('linearGradientBlur');
1415  applyPeer(node: KNode, reset: boolean): void {
1416    if (reset) {
1417      getUINativeModule().common.resetLinearGradientBlur(node);
1418    } else {
1419      getUINativeModule().common.setLinearGradientBlur(node,
1420        this.value.blurRadius, this.value.fractionStops, this.value.direction);
1421    }
1422  }
1423  checkObjectDiff(): boolean {
1424    return !this.value.isEqual(this.stageValue);
1425  }
1426}
1427
1428class BackgroundImageModifier extends ModifierWithKey<ArkBackgroundImage> {
1429  constructor(value: ArkBackgroundImage) {
1430    super(value);
1431  }
1432  static identity: Symbol = Symbol('backgroundImage');
1433  applyPeer(node: KNode, reset: boolean): void {
1434    if (reset) {
1435      getUINativeModule().common.resetBackgroundImage(node);
1436    } else {
1437      getUINativeModule().common.setBackgroundImage(node, this.value.src, this.value.repeat);
1438    }
1439  }
1440  checkObjectDiff(): boolean {
1441    return !((this.stageValue as ArkBackgroundImage).src === (this.value as ArkBackgroundImage).src &&
1442      (this.stageValue as ArkBackgroundImage).repeat === (this.value as ArkBackgroundImage).repeat);
1443  }
1444}
1445
1446class BackgroundBlurStyleModifier extends ModifierWithKey<ArkBackgroundBlurStyle> {
1447  constructor(value: ArkBackgroundBlurStyle) {
1448    super(value);
1449  }
1450  static identity: Symbol = Symbol('backgroundBlurStyle');
1451  applyPeer(node: KNode, reset: boolean): void {
1452    if (reset) {
1453      getUINativeModule().common.resetBackgroundBlurStyle(node);
1454    } else {
1455      getUINativeModule().common.setBackgroundBlurStyle(node,
1456        this.value.blurStyle, this.value.colorMode, this.value.adaptiveColor, this.value.scale,
1457          this.value.blurOptions?.grayscale, this.value.policy, this.value.inactiveColor, this.value.type);
1458    }
1459  }
1460}
1461
1462class BackgroundImageSizeModifier extends ModifierWithKey<SizeOptions | ImageSize> {
1463  constructor(value: SizeOptions | ImageSize) {
1464    super(value);
1465  }
1466  static identity: Symbol = Symbol('backgroundImageSize');
1467  applyPeer(node: KNode, reset: boolean): void {
1468    if (reset) {
1469      getUINativeModule().common.resetBackgroundImageSize(node);
1470    } else {
1471      if (isNumber(this.value)) {
1472        getUINativeModule().common.setBackgroundImageSize(node, this.value, undefined, undefined);
1473      } else {
1474        getUINativeModule().common.setBackgroundImageSize(node, undefined, (this.value as SizeOptions)?.width, (this.value as SizeOptions)?.height);
1475      }
1476    }
1477  }
1478  checkObjectDiff(): boolean {
1479    return !((this.value as SizeOptions).width === (this.stageValue as SizeOptions).width &&
1480      (this.value as SizeOptions).height === (this.stageValue as SizeOptions).height);
1481  }
1482}
1483
1484class TranslateModifier extends ModifierWithKey<TranslateOptions> {
1485  constructor(value: TranslateOptions) {
1486    super(value);
1487  }
1488  static identity: Symbol = Symbol('translate');
1489  applyPeer(node: KNode, reset: boolean): void {
1490    if (reset) {
1491      getUINativeModule().common.resetTranslate(node);
1492    } else {
1493      getUINativeModule().common.setTranslate(node, this.value.x, this.value.y, this.value.z);
1494    }
1495  }
1496  checkObjectDiff(): boolean {
1497    return !(this.value.x === this.stageValue.x &&
1498      this.value.y === this.stageValue.y &&
1499      this.value.z === this.stageValue.z);
1500  }
1501}
1502
1503class ScaleModifier extends ModifierWithKey<ScaleOptions> {
1504  constructor(value: ScaleOptions) {
1505    super(value);
1506  }
1507  static identity: Symbol = Symbol('scale');
1508  applyPeer(node: KNode, reset: boolean): void {
1509    if (reset) {
1510      getUINativeModule().common.resetScale(node);
1511    } else {
1512      getUINativeModule().common.setScale(node, this.value.x, this.value.y, this.value.z, this.value.centerX, this.value.centerY);
1513    }
1514  }
1515  checkObjectDiff(): boolean {
1516    return !(
1517      this.value.x === this.stageValue.x &&
1518      this.value.y === this.stageValue.y &&
1519      this.value.z === this.stageValue.z &&
1520      this.value.centerX === this.stageValue.centerX &&
1521      this.value.centerY === this.stageValue.centerY
1522    );
1523  }
1524}
1525
1526class RotateModifier extends ModifierWithKey<RotateOptions> {
1527  constructor(value: RotateOptions) {
1528    super(value);
1529  }
1530  static identity: Symbol = Symbol('rotate');
1531  applyPeer(node: KNode, reset: boolean): void {
1532    if (reset) {
1533      getUINativeModule().common.resetRotate(node);
1534    } else {
1535      getUINativeModule().common.setRotate(node, this.value.x, this.value.y, this.value.z, this.value.angle,
1536        this.value.centerX, this.value.centerY, this.value.centerY, this.value.perspective);
1537    }
1538  }
1539  checkObjectDiff(): boolean {
1540    return !(
1541      this.value.x === this.stageValue.x &&
1542      this.value.y === this.stageValue.y &&
1543      this.value.z === this.stageValue.z &&
1544      this.value.angle === this.stageValue.angle &&
1545      this.value.centerX === this.stageValue.centerX &&
1546      this.value.centerY === this.stageValue.centerY &&
1547      this.value.centerZ === this.stageValue.centerZ &&
1548      this.value.perspective === this.stageValue.perspective
1549    );
1550  }
1551}
1552
1553class GeometryTransitionModifier extends ModifierWithKey<ArkGeometryTransition> {
1554  constructor(value: ArkGeometryTransition) {
1555    super(value);
1556  }
1557  static identity: Symbol = Symbol('geometryTransition');
1558  applyPeer(node: KNode, reset: boolean): void {
1559    if (reset) {
1560      getUINativeModule().common.resetGeometryTransition(node);
1561    } else {
1562      getUINativeModule().common.setGeometryTransition(node, this.value.id,
1563        (this.value.options as GeometryTransitionOptions)?.follow,
1564        (this.value.options as GeometryTransitionOptions)?.hierarchyStrategy);
1565    }
1566  }
1567}
1568
1569class AdvancedBlendModeModifier extends ModifierWithKey<ArkBlendMode> {
1570  constructor(value: ArkBlendMode) {
1571    super(value);
1572  }
1573  static identity: Symbol = Symbol('advancedBlendMode');
1574  applyPeer(node: KNode, reset: boolean): void {
1575    if (reset) {
1576      getUINativeModule().common.resetAdvancedBlendMode(node);
1577    } else {
1578      getUINativeModule().common.setAdvancedBlendMode(node, this.value.blendMode, this.value.blendApplyType);
1579    }
1580  }
1581}
1582
1583class BlendModeModifier extends ModifierWithKey<ArkBlendMode> {
1584  constructor(value: ArkBlendMode) {
1585    super(value);
1586  }
1587  static identity: Symbol = Symbol('blendMode');
1588  applyPeer(node: KNode, reset: boolean): void {
1589    if (reset) {
1590      getUINativeModule().common.resetBlendMode(node);
1591    } else {
1592      getUINativeModule().common.setBlendMode(node, this.value.blendMode, this.value.blendApplyType);
1593    }
1594  }
1595}
1596
1597class ClipModifier extends ModifierWithKey<boolean | object> {
1598  constructor(value: boolean | object) {
1599    super(value);
1600  }
1601  static identity: Symbol = Symbol('clip');
1602  applyPeer(node: KNode, reset: boolean): void {
1603    if (reset) {
1604      getUINativeModule().common.resetClip(node);
1605    } else {
1606      getUINativeModule().common.setClip(node, this.value);
1607    }
1608  }
1609
1610  checkObjectDiff(): boolean {
1611    return true;
1612  }
1613}
1614
1615class ClipShapeModifier extends ModifierWithKey<object> {
1616  constructor(value: object) {
1617    super(value);
1618  }
1619  static identity: Symbol = Symbol('clipShape');
1620  applyPeer(node: KNode, reset: boolean): void {
1621    if (reset) {
1622      getUINativeModule().common.resetClipShape(node);
1623    } else {
1624      getUINativeModule().common.setClipShape(node, this.value);
1625    }
1626  }
1627
1628  checkObjectDiff(): boolean {
1629    return true;
1630  }
1631}
1632
1633class MaskModifier extends ModifierWithKey<boolean | object> {
1634  constructor(value: boolean | object) {
1635    super(value);
1636  }
1637  static identity: Symbol = Symbol('mask');
1638  applyPeer(node: KNode, reset: boolean): void {
1639    if (reset) {
1640      getUINativeModule().common.resetMask(node);
1641    } else {
1642      getUINativeModule().common.setMask(node, this.value);
1643    }
1644  }
1645
1646  checkObjectDiff(): boolean {
1647    return true;
1648  }
1649}
1650
1651class MaskShapeModifier extends ModifierWithKey<object> {
1652  constructor(value: object) {
1653    super(value);
1654  }
1655  static identity: Symbol = Symbol('maskShape');
1656  applyPeer(node: KNode, reset: boolean): void {
1657    if (reset) {
1658      getUINativeModule().common.resetMaskShape(node);
1659    } else {
1660      getUINativeModule().common.setMaskShape(node, this.value);
1661    }
1662  }
1663
1664  checkObjectDiff(): boolean {
1665    return true;
1666  }
1667}
1668
1669class PixelStretchEffectModifier extends ModifierWithKey<PixelStretchEffectOptions> {
1670  constructor(value: PixelStretchEffectOptions) {
1671    super(value);
1672  }
1673  static identity: Symbol = Symbol('pixelStretchEffect');
1674  applyPeer(node: KNode, reset: boolean): void {
1675    if (reset) {
1676      getUINativeModule().common.resetPixelStretchEffect(node);
1677    } else {
1678      getUINativeModule().common.setPixelStretchEffect(node,
1679        this.value.top, this.value.right, this.value.bottom, this.value.left);
1680    }
1681  }
1682
1683  checkObjectDiff(): boolean {
1684    return !((this.stageValue as PixelStretchEffectOptions).left === (this.value as PixelStretchEffectOptions).left &&
1685      (this.stageValue as PixelStretchEffectOptions).right === (this.value as PixelStretchEffectOptions).right &&
1686      (this.stageValue as PixelStretchEffectOptions).top === (this.value as PixelStretchEffectOptions).top &&
1687      (this.stageValue as PixelStretchEffectOptions).bottom === (this.value as PixelStretchEffectOptions).bottom);
1688  }
1689}
1690
1691class LightUpEffectModifier extends ModifierWithKey<number> {
1692  constructor(value: number) {
1693    super(value);
1694  }
1695  static identity: Symbol = Symbol('lightUpEffect');
1696  applyPeer(node: KNode, reset: boolean): void {
1697    if (reset) {
1698      getUINativeModule().common.resetLightUpEffect(node);
1699    } else {
1700      getUINativeModule().common.setLightUpEffect(node, this.value);
1701    }
1702  }
1703}
1704
1705class SphericalEffectModifier extends ModifierWithKey<number> {
1706  constructor(value: number) {
1707    super(value);
1708  }
1709  static identity: Symbol = Symbol('sphericalEffect');
1710  applyPeer(node: KNode, reset: boolean): void {
1711    if (reset) {
1712      getUINativeModule().common.resetSphericalEffect(node);
1713    } else {
1714      getUINativeModule().common.setSphericalEffect(node, this.value);
1715    }
1716  }
1717}
1718
1719class RenderGroupModifier extends ModifierWithKey<boolean> {
1720  constructor(value: boolean) {
1721    super(value);
1722  }
1723  static identity: Symbol = Symbol('renderGroup');
1724  applyPeer(node: KNode, reset: boolean): void {
1725    if (reset) {
1726      getUINativeModule().common.resetRenderGroup(node);
1727    } else {
1728      getUINativeModule().common.setRenderGroup(node, this.value);
1729    }
1730  }
1731}
1732
1733class RenderFitModifier extends ModifierWithKey<number> {
1734  constructor(value: number) {
1735    super(value);
1736  }
1737  static identity: Symbol = Symbol('renderFit');
1738  applyPeer(node: KNode, reset: boolean): void {
1739    if (reset) {
1740      getUINativeModule().common.resetRenderFit(node);
1741    } else {
1742      getUINativeModule().common.setRenderFit(node, this.value);
1743    }
1744  }
1745}
1746
1747class UseEffectModifier extends ModifierWithKey<ArkUseEffect> {
1748  constructor(value: ArkUseEffect) {
1749    super(value);
1750  }
1751  static identity: Symbol = Symbol('useEffect');
1752  applyPeer(node: KNode, reset: boolean): void {
1753    if (reset) {
1754      getUINativeModule().common.resetUseEffect(node);
1755    } else {
1756      getUINativeModule().common.setUseEffect(node, this.value.useEffect, this.value.effectType);
1757    }
1758  }
1759}
1760
1761class ForegroundColorModifier extends ModifierWithKey<ResourceColor | ColoringStrategy> {
1762  constructor(value: ResourceColor | ColoringStrategy) {
1763    super(value);
1764  }
1765  static identity: Symbol = Symbol('foregroundColor');
1766  applyPeer(node: KNode, reset: boolean): void {
1767    if (reset) {
1768      getUINativeModule().common.resetForegroundColor(node);
1769    } else {
1770      getUINativeModule().common.setForegroundColor(node, this.value);
1771    }
1772  }
1773
1774  checkObjectDiff(): boolean {
1775    if (isResource(this.stageValue) && isResource(this.value)) {
1776      return !isResourceEqual(this.stageValue, this.value);
1777    } else {
1778      return true;
1779    }
1780  }
1781}
1782
1783declare type ClickCallback = (event: ClickEvent) => void;
1784class OnClickModifier extends ModifierWithKey<ClickCallback> {
1785  constructor(value: ClickCallback) {
1786    super(value);
1787  }
1788  static identity: Symbol = Symbol('onClick');
1789  applyPeer(node: KNode, reset: boolean): void {
1790    if (reset) {
1791      getUINativeModule().common.resetOnClick(node);
1792    } else {
1793      getUINativeModule().common.setOnClick(node, this.value);
1794    }
1795  }
1796}
1797
1798declare type DragStartCallback = (event?: DragEvent, extraParams?: string) => CustomBuilder | DragItemInfo;
1799class DragStartModifier extends ModifierWithKey<DragStartCallback> {
1800  constructor(value: DragStartCallback) {
1801    super(value);
1802  }
1803  static identity: Symbol = Symbol('onDragStart');
1804  applyPeer(node: KNode, reset: boolean): void {
1805    if (reset) {
1806      getUINativeModule().common.resetOnDragStart(node);
1807    } else {
1808      getUINativeModule().common.setOnDragStart(node, this.value);
1809    }
1810  }
1811}
1812
1813declare type DragEnterCallback = (event?: DragEvent, extraParams?: string) => void;
1814class DragEnterModifier extends ModifierWithKey<DragEnterCallback> {
1815  constructor(value: DragEnterCallback) {
1816    super(value);
1817  }
1818  static identity: Symbol = Symbol('onDragEnter');
1819  applyPeer(node: KNode, reset: boolean): void {
1820    if (reset) {
1821      getUINativeModule().common.resetOnDragEnter(node);
1822    } else {
1823      getUINativeModule().common.setOnDragEnter(node, this.value);
1824    }
1825  }
1826}
1827
1828declare type DragMoveCallback = (event?: DragEvent, extraParams?: string) => void;
1829class DragMoveModifier extends ModifierWithKey<DragMoveCallback> {
1830  constructor(value: DragMoveCallback) {
1831    super(value);
1832  }
1833  static identity: Symbol = Symbol('onDragMove');
1834  applyPeer(node: KNode, reset: boolean): void {
1835    if (reset) {
1836      getUINativeModule().common.resetOnDragMove(node);
1837    } else {
1838      getUINativeModule().common.setOnDragMove(node, this.value);
1839    }
1840  }
1841}
1842
1843declare type DragLeaveCallback = (event?: DragEvent, extraParams?: string) => void;
1844class DragLeaveModifier extends ModifierWithKey<DragLeaveCallback> {
1845  constructor(value: DragLeaveCallback) {
1846    super(value);
1847  }
1848  static identity: Symbol = Symbol('onDragLeave');
1849  applyPeer(node: KNode, reset: boolean): void {
1850    if (reset) {
1851      getUINativeModule().common.resetOnDragLeave(node);
1852    } else {
1853      getUINativeModule().common.setOnDragLeave(node, this.value);
1854    }
1855  }
1856}
1857
1858declare type DropCallback = (event?: DragEvent, extraParams?: string) => void;
1859class DropModifier extends ModifierWithKey<DropCallback> {
1860  constructor(value: DropCallback) {
1861    super(value);
1862  }
1863  static identity: Symbol = Symbol('onDrop');
1864  applyPeer(node: KNode, reset: boolean): void {
1865    if (reset) {
1866      getUINativeModule().common.resetOnDrop(node);
1867    } else {
1868      getUINativeModule().common.setOnDrop(node, this.value);
1869    }
1870  }
1871}
1872
1873declare type DragEndCallback = (event?: DragEvent, extraParams?: string) => void;
1874class DragEndModifier extends ModifierWithKey<DragEndCallback> {
1875  constructor(value: DragEndCallback) {
1876    super(value);
1877  }
1878  static identity: Symbol = Symbol('onDragEnd');
1879  applyPeer(node: KNode, reset: boolean): void {
1880    if (reset) {
1881      getUINativeModule().common.resetOnDragEnd(node);
1882    } else {
1883      getUINativeModule().common.setOnDragEnd(node, this.value);
1884    }
1885  }
1886}
1887
1888declare type TouchCallback = (event: TouchEvent) => void;
1889class OnTouchModifier extends ModifierWithKey<TouchCallback> {
1890  constructor(value: TouchCallback) {
1891    super(value);
1892  }
1893  static identity: Symbol = Symbol('onTouch');
1894  applyPeer(node: KNode, reset: boolean): void {
1895    if (reset) {
1896      getUINativeModule().common.resetOnTouch(node);
1897    } else {
1898      getUINativeModule().common.setOnTouch(node, this.value);
1899    }
1900  }
1901}
1902
1903declare type VoidCallback = () => void;
1904class OnAppearModifier extends ModifierWithKey<VoidCallback> {
1905  constructor(value: VoidCallback) {
1906    super(value);
1907  }
1908  static identity: Symbol = Symbol('onAppear');
1909  applyPeer(node: KNode, reset: boolean): void {
1910    if (reset) {
1911      getUINativeModule().common.resetOnAppear(node);
1912    } else {
1913      getUINativeModule().common.setOnAppear(node, this.value);
1914    }
1915  }
1916}
1917
1918class OnDisappearModifier extends ModifierWithKey<VoidCallback> {
1919  constructor(value: VoidCallback) {
1920    super(value);
1921  }
1922  static identity: Symbol = Symbol('onDisappear');
1923  applyPeer(node: KNode, reset: boolean): void {
1924    if (reset) {
1925      getUINativeModule().common.resetOnDisappear(node);
1926    } else {
1927      getUINativeModule().common.setOnDisappear(node, this.value);
1928    }
1929  }
1930}
1931
1932class OnAttachModifier extends ModifierWithKey<VoidCallback> {
1933  constructor(value: VoidCallback) {
1934    super(value);
1935  }
1936  static identity: Symbol = Symbol('onAttach');
1937  applyPeer(node: KNode, reset: boolean): void {
1938    if (reset) {
1939      getUINativeModule().common.resetOnAttach(node);
1940    } else {
1941      getUINativeModule().common.setOnAttach(node, this.value);
1942    }
1943  }
1944}
1945
1946class OnDetachModifier extends ModifierWithKey<VoidCallback> {
1947  constructor(value: VoidCallback) {
1948    super(value);
1949  }
1950  static identity: Symbol = Symbol('onDetach');
1951  applyPeer(node: KNode, reset: boolean): void {
1952    if (reset) {
1953      getUINativeModule().common.resetOnDetach(node);
1954    } else {
1955      getUINativeModule().common.setOnDetach(node, this.value);
1956    }
1957  }
1958}
1959
1960declare type KeyEventCallback = (event: KeyEvent) => void;
1961class OnKeyEventModifier extends ModifierWithKey<KeyEventCallback> {
1962  constructor(value: KeyEventCallback) {
1963    super(value);
1964  }
1965  static identity: Symbol = Symbol('onKeyEvent');
1966  applyPeer(node: KNode, reset: boolean): void {
1967    if (reset) {
1968      getUINativeModule().common.resetOnKeyEvent(node);
1969    } else {
1970      getUINativeModule().common.setOnKeyEvent(node, this.value);
1971    }
1972  }
1973}
1974
1975class OnKeyPreImeModifier extends ModifierWithKey<Callback<KeyEvent, boolean>> {
1976  constructor(value: Callback<KeyEvent, boolean>) {
1977    super(value);
1978  }
1979  static identity: Symbol = Symbol('onKeyPreIme');
1980  applyPeer(node: KNode, reset: boolean): void {
1981    if (reset) {
1982      getUINativeModule().common.resetOnKeyPreIme(node);
1983    } else {
1984      getUINativeModule().common.setOnKeyPreIme(node, this.value);
1985    }
1986  }
1987}
1988
1989class OnFocusModifier extends ModifierWithKey<VoidCallback> {
1990  constructor(value: VoidCallback) {
1991    super(value);
1992  }
1993  static identity: Symbol = Symbol('onFocus');
1994  applyPeer(node: KNode, reset: boolean): void {
1995    if (reset) {
1996      getUINativeModule().common.resetOnFocus(node);
1997    } else {
1998      getUINativeModule().common.setOnFocus(node, this.value);
1999    }
2000  }
2001}
2002
2003class OnBlurModifier extends ModifierWithKey<VoidCallback> {
2004  constructor(value: VoidCallback) {
2005    super(value);
2006  }
2007  static identity: Symbol = Symbol('onBlur');
2008  applyPeer(node: KNode, reset: boolean): void {
2009    if (reset) {
2010      getUINativeModule().common.resetOnBlur(node);
2011    } else {
2012      getUINativeModule().common.setOnBlur(node, this.value);
2013    }
2014  }
2015}
2016
2017declare type HoverEventCallback = (isHover: boolean, event: HoverEvent) => void;
2018class OnHoverModifier extends ModifierWithKey<HoverEventCallback> {
2019  constructor(value: HoverEventCallback) {
2020    super(value);
2021  }
2022  static identity: Symbol = Symbol('onHover');
2023  applyPeer(node: KNode, reset: boolean): void {
2024    if (reset) {
2025      getUINativeModule().common.resetOnHover(node);
2026    } else {
2027      getUINativeModule().common.setOnHover(node, this.value);
2028    }
2029  }
2030}
2031
2032declare type HoverMoveEventCallback = (event: HoverEvent) => void;
2033class OnHoverMoveModifier extends ModifierWithKey<HoverMoveEventCallback> {
2034  constructor(value: HoverMoveEventCallback) {
2035    super(value);
2036  }
2037  static identity: Symbol = Symbol('onHoverMove');
2038  applyPeer(node: KNode, reset: boolean): void {
2039    if (reset) {
2040      getUINativeModule().common.resetOnHoverMove(node);
2041    } else {
2042      getUINativeModule().common.setOnHoverMove(node, this.value);
2043    }
2044  }
2045}
2046
2047declare type MouseEventCallback = (event: MouseEvent) => void;
2048class OnMouseModifier extends ModifierWithKey<MouseEventCallback> {
2049  constructor(value: MouseEventCallback) {
2050    super(value);
2051  }
2052  static identity: Symbol = Symbol('onMouse');
2053  applyPeer(node: KNode, reset: boolean): void {
2054    if (reset) {
2055      getUINativeModule().common.resetOnMouse(node);
2056    } else {
2057      getUINativeModule().common.setOnMouse(node, this.value);
2058    }
2059  }
2060}
2061
2062declare type SizeChangeEventCallback = (oldValue: SizeOptions, newValue: SizeOptions) => void;
2063class OnSizeChangeModifier extends ModifierWithKey<SizeChangeEventCallback> {
2064  constructor(value: SizeChangeEventCallback) {
2065    super(value);
2066  }
2067  static identity: Symbol = Symbol('onSizeChange');
2068  applyPeer(node: KNode, reset: boolean): void {
2069    if (reset) {
2070      getUINativeModule().common.resetOnSizeChange(node);
2071    } else {
2072      getUINativeModule().common.setOnSizeChange(node, this.value);
2073    }
2074  }
2075}
2076
2077declare type AreaChangeEventCallback = (oldValue: Area, newValue: Area) => void;
2078class OnAreaChangeModifier extends ModifierWithKey<AreaChangeEventCallback> {
2079  constructor(value: AreaChangeEventCallback) {
2080    super(value);
2081  }
2082  static identity: Symbol = Symbol('onAreaChange');
2083  applyPeer(node: KNode, reset: boolean): void {
2084    if (reset) {
2085      getUINativeModule().common.resetOnAreaChange(node);
2086    } else {
2087      getUINativeModule().common.setOnAreaChange(node, this.value);
2088    }
2089  }
2090}
2091
2092declare type GestureJudgeBeginCallback = (gestureInfo: GestureInfo, event: BaseGestureEvent) => GestureJudgeResult;
2093class OnGestureJudgeBeginModifier extends ModifierWithKey<GestureJudgeBeginCallback> {
2094  constructor(value: GestureJudgeBeginCallback) {
2095    super(value);
2096  }
2097  static identity: Symbol = Symbol('onGestureJudgeBegin');
2098  applyPeer(node: KNode, reset: boolean): void {
2099    if (reset) {
2100      getUINativeModule().common.resetOnGestureJudgeBegin(node);
2101    } else {
2102      getUINativeModule().common.setOnGestureJudgeBegin(node, this.value);
2103    }
2104  }
2105}
2106
2107declare type GestureRecognizerJudgeBeginCallback = (event: BaseGestureEvent, current: GestureRecognizer, recognizers: Array<GestureRecognizer>) => GestureJudgeResult;
2108class OnGestureRecognizerJudgeBeginModifier extends ModifierWithKey<GestureRecognizerJudgeBeginCallback> {
2109  constructor(value: GestureRecognizerJudgeBeginCallback) {
2110    super(value);
2111  }
2112  static identity: Symbol = Symbol('onGestureRecognizerJudgeBegin');
2113  applyPeer(node: KNode, reset: boolean): void {
2114    if (reset) {
2115      getUINativeModule().common.resetOnGestureRecognizerJudgeBegin(node);
2116    } else {
2117      getUINativeModule().common.setOnGestureRecognizerJudgeBegin(node, this.value);
2118    }
2119  }
2120}
2121
2122declare type ShouldBuiltInRecognizerParallelWithCallback = (current: GestureRecognizer, others: Array<GestureRecognizer>) => GestureRecognizer;
2123class ShouldBuiltInRecognizerParallelWithModifier extends ModifierWithKey<ShouldBuiltInRecognizerParallelWithCallback> {
2124  constructor(value: ShouldBuiltInRecognizerParallelWithCallback) {
2125    super(value);
2126  }
2127  static identity: Symbol = Symbol('shouldBuiltInRecognizerParallelWith');
2128  applyPeer(node: KNode, reset: boolean): void {
2129    if (reset) {
2130      getUINativeModule().common.resetShouldBuiltInRecognizerParallelWith(node);
2131    } else {
2132      getUINativeModule().common.setShouldBuiltInRecognizerParallelWith(node, this.value);
2133    }
2134  }
2135}
2136
2137declare type FocusAxisEventCallback = (event: FocusAxisEvent) => void;
2138class OnFocusAxisEventModifier extends ModifierWithKey<FocusAxisEventCallback> {
2139  constructor(value: FocusAxisEventCallback) {
2140    super(value);
2141  }
2142  static identity: Symbol = Symbol('onFocusAxisEvent');
2143  applyPeer(node: KNode, reset: boolean): void {
2144    if (reset) {
2145      getUINativeModule().common.resetOnKeyEvent(node);
2146    } else {
2147      getUINativeModule().common.setOnKeyEvent(node, this.value);
2148    }
2149  }
2150}
2151
2152class MotionPathModifier extends ModifierWithKey<MotionPathOptions> {
2153  constructor(value: MotionPathOptions) {
2154    super(value);
2155  }
2156  static identity: Symbol = Symbol('motionPath');
2157  applyPeer(node: KNode, reset: boolean): void {
2158    if (reset) {
2159      getUINativeModule().common.resetMotionPath(node);
2160    } else {
2161      let path: string;
2162      let rotatable: boolean;
2163      let from: number;
2164      let to: number;
2165      if (isString(this.value.path)) {
2166        path = this.value.path;
2167      }
2168      if (isBoolean(this.value.rotatable)) {
2169        rotatable = this.value.rotatable;
2170      }
2171      if (isNumber(this.value.from) && isNumber(this.value.to)) {
2172        from = this.value.from;
2173        to = this.value.to;
2174      }
2175      getUINativeModule().common.setMotionPath(node, path, from, to, rotatable);
2176    }
2177  }
2178  checkObjectDiff(): boolean {
2179    return !(this.value.path === this.stageValue.path &&
2180      this.value.from === this.stageValue.from &&
2181      this.value.to === this.stageValue.to &&
2182      this.value.rotatable === this.stageValue.rotatable);
2183  }
2184}
2185
2186class MotionBlurModifier extends ModifierWithKey<MotionBlurOptions> {
2187  constructor(value: MotionBlurOptions) {
2188    super(value);
2189  }
2190  static identity: Symbol = Symbol('motionBlur');
2191  applyPeer(node: KNode, reset: boolean): void {
2192    if (reset) {
2193      getUINativeModule().common.resetMotionBlur(node);
2194    } else {
2195      getUINativeModule().common.setMotionBlur(node, this.value.radius, this.value.anchor.x, this.value.anchor.y);
2196    }
2197  }
2198}
2199
2200class GroupDefaultFocusModifier extends ModifierWithKey<boolean> {
2201  constructor(value: boolean) {
2202    super(value);
2203  }
2204  static identity: Symbol = Symbol('groupDefaultFocus');
2205  applyPeer(node: KNode, reset: boolean): void {
2206    if (reset) {
2207      getUINativeModule().common.resetGroupDefaultFocus(node);
2208    } else {
2209      getUINativeModule().common.setGroupDefaultFocus(node, this.value);
2210    }
2211  }
2212}
2213
2214class FocusOnTouchModifier extends ModifierWithKey<boolean> {
2215  constructor(value: boolean) {
2216    super(value);
2217  }
2218  static identity: Symbol = Symbol('focusOnTouch');
2219  applyPeer(node: KNode, reset: boolean): void {
2220    if (reset) {
2221      getUINativeModule().common.resetFocusOnTouch(node);
2222    } else {
2223      getUINativeModule().common.setFocusOnTouch(node, this.value);
2224    }
2225  }
2226}
2227class OffsetModifier extends ModifierWithKey<Position | Edges | LocalizedEdges> {
2228  constructor(value: Position | Edges | LocalizedEdges) {
2229    super(value);
2230  }
2231  static identity: Symbol = Symbol('offset');
2232  applyPeer(node: KNode, reset: boolean): void {
2233    if (reset) {
2234      getUINativeModule().common.resetOffset(node);
2235    } else {
2236      if (isUndefined(this.value)) {
2237        getUINativeModule().common.resetOffset(node);
2238      } else if (('x' in this.value) || ('y' in this.value)) {
2239        getUINativeModule().common.setOffset(node, false, this.value.x, this.value.y);
2240      } else if (('top' in this.value) || ('bottom' in this.value) || ('left' in this.value) || ('start' in this.value) || ('right' in this.value) || ('end' in this.value)) {
2241        if (('start' in this.value)) {
2242          this.value.left = this.value.start;
2243        }
2244        if (('end' in this.value)) {
2245          this.value.right = this.value.end;
2246        }
2247        getUINativeModule().common.setOffset(node, true, this.value.top, this.value.left, this.value.bottom, this.value.right);
2248      } else {
2249        getUINativeModule().common.resetOffset(node);
2250      }
2251    }
2252  }
2253
2254  checkObjectDiff(): boolean {
2255    return !isBaseOrResourceEqual(this.stageValue.x, this.value.x) ||
2256      !isBaseOrResourceEqual(this.stageValue.y, this.value.y) ||
2257      !isBaseOrResourceEqual(this.stageValue.top, this.value.top) ||
2258      !isBaseOrResourceEqual(this.stageValue.left, this.value.left) ||
2259      !isBaseOrResourceEqual(this.stageValue.bottom, this.value.bottom) ||
2260      !isBaseOrResourceEqual(this.stageValue.right, this.value.right) ||
2261      !isBaseOrResourceEqual(this.stageValue.start, this.value.start) ||
2262      !isBaseOrResourceEqual(this.stageValue.end, this.value.end);
2263  }
2264}
2265
2266class MarkAnchorModifier extends ModifierWithKey<Position | LocalizedPosition> {
2267  constructor(value: Position | LocalizedPosition) {
2268    super(value);
2269  }
2270  static identity: Symbol = Symbol('markAnchor');
2271  applyPeer(node: KNode, reset: boolean): void {
2272    if (reset) {
2273      getUINativeModule().common.resetMarkAnchor(node);
2274    } else {
2275      if (this.value === void 0) {
2276        getUINativeModule().common.resetMarkAnchor(node);
2277      } else {
2278        if ('start' in this.value) {
2279          this.value.x = this.value.start;
2280        }
2281        if ('top' in this.value) {
2282          this.value.y = this.value.top;
2283        }
2284      }
2285      getUINativeModule().common.setMarkAnchor(node, this.value.x, this.value.y);
2286    }
2287  }
2288
2289  checkObjectDiff(): boolean {
2290    return !isBaseOrResourceEqual(this.stageValue.x, this.value.x) ||
2291      !isBaseOrResourceEqual(this.stageValue.y, this.value.y) ||
2292      !isBaseOrResourceEqual(this.stageValue.start, this.value.start) ||
2293      !isBaseOrResourceEqual(this.stageValue.top, this.value.top);
2294  }
2295}
2296class DefaultFocusModifier extends ModifierWithKey<boolean> {
2297  constructor(value: boolean) {
2298    super(value);
2299  }
2300  static identity: Symbol = Symbol('defaultFocus');
2301  applyPeer(node: KNode, reset: boolean): void {
2302    if (reset) {
2303      getUINativeModule().common.resetDefaultFocus(node);
2304    } else {
2305      getUINativeModule().common.setDefaultFocus(node, this.value);
2306    }
2307  }
2308}
2309
2310class FocusableModifier extends ModifierWithKey<boolean> {
2311  constructor(value: boolean) {
2312    super(value);
2313  }
2314  static identity: Symbol = Symbol('focusable');
2315  applyPeer(node: KNode, reset: boolean): void {
2316    getUINativeModule().common.setFocusable(node, this.value);
2317  }
2318}
2319
2320class TabStopModifier extends ModifierWithKey<boolean> {
2321  constructor(value: boolean) {
2322    super(value);
2323  }
2324  static identity: Symbol = Symbol('tabStop');
2325  applyPeer(node: KNode, reset: boolean): void {
2326    getUINativeModule().common.setTabStop(node, this.value);
2327  }
2328}
2329
2330class TouchableModifier extends ModifierWithKey<boolean> {
2331  constructor(value: boolean) {
2332    super(value);
2333  }
2334  static identity: Symbol = Symbol('touchable');
2335  applyPeer(node: KNode, reset: boolean): void {
2336    if (reset) {
2337      getUINativeModule().common.resetTouchable(node);
2338    } else {
2339      getUINativeModule().common.setTouchable(node, this.value);
2340    }
2341  }
2342}
2343
2344class MarginModifier extends ModifierWithKey<ArkPadding> {
2345  static identity: Symbol = Symbol('margin');
2346  applyPeer(node: KNode, reset: boolean): void {
2347    if (reset) {
2348      getUINativeModule().common.resetMargin(node);
2349    } else {
2350      getUINativeModule().common.setMargin(node, this.value.top,
2351        this.value.right, this.value.bottom, this.value.left);
2352    }
2353  }
2354
2355  checkObjectDiff(): boolean {
2356    return !isBaseOrResourceEqual(this.stageValue.top, this.value.top) ||
2357      !isBaseOrResourceEqual(this.stageValue.right, this.value.right) ||
2358      !isBaseOrResourceEqual(this.stageValue.bottom, this.value.bottom) ||
2359      !isBaseOrResourceEqual(this.stageValue.left, this.value.left);
2360  }
2361}
2362
2363class PaddingModifier extends ModifierWithKey<ArkPadding> {
2364  static identity: Symbol = Symbol('padding');
2365  applyPeer(node: KNode, reset: boolean): void {
2366    if (reset) {
2367      getUINativeModule().common.resetPadding(node);
2368    } else {
2369      getUINativeModule().common.setPadding(node, this.value.top,
2370        this.value.right, this.value.bottom, this.value.left);
2371    }
2372  }
2373
2374  checkObjectDiff(): boolean {
2375    return !isBaseOrResourceEqual(this.stageValue.top, this.value.top) ||
2376      !isBaseOrResourceEqual(this.stageValue.right, this.value.right) ||
2377      !isBaseOrResourceEqual(this.stageValue.bottom, this.value.bottom) ||
2378      !isBaseOrResourceEqual(this.stageValue.left, this.value.left);
2379  }
2380}
2381
2382class VisibilityModifier extends ModifierWithKey<number> {
2383  static identity: Symbol = Symbol('visibility');
2384  applyPeer(node: KNode, reset: boolean): void {
2385    if (reset) {
2386      getUINativeModule().common.resetVisibility(node);
2387    } else {
2388      getUINativeModule().common.setVisibility(node, this.value!);
2389    }
2390  }
2391  checkObjectDiff(): boolean {
2392    return this.stageValue !== this.value;
2393  }
2394}
2395
2396class AccessibilityTextModifier extends ModifierWithKey<string> {
2397  constructor(value: string) {
2398    super(value);
2399  }
2400  static identity: Symbol = Symbol('accessibilityText');
2401  applyPeer(node: KNode, reset: boolean): void {
2402    if (reset) {
2403      getUINativeModule().common.resetAccessibilityText(node);
2404    } else {
2405      getUINativeModule().common.setAccessibilityText(node, this.value);
2406    }
2407  }
2408}
2409
2410class AllowDropModifier extends ModifierWithKey<Array<UniformDataType>> {
2411  constructor(value: Array<UniformDataType>) {
2412    super(value);
2413  }
2414  static identity: Symbol = Symbol('allowDrop');
2415  applyPeer(node: KNode, reset: boolean): void {
2416    if (reset) {
2417      getUINativeModule().common.resetAllowDrop(node);
2418    } else {
2419      getUINativeModule().common.setAllowDrop(node, this.value);
2420    }
2421  }
2422  checkObjectDiff(): boolean {
2423    return !(Array.isArray(this.value) && Array.isArray(this.stageValue) &&
2424      this.value.length === this.stageValue.length &&
2425      this.value.every((value, index) => value === this.stageValue[index]));
2426  }
2427}
2428
2429class AccessibilityLevelModifier extends ModifierWithKey<string> {
2430  constructor(value: string) {
2431    super(value);
2432  }
2433  static identity: Symbol = Symbol('accessibilityLevel');
2434  applyPeer(node: KNode, reset: boolean): void {
2435    if (reset) {
2436      getUINativeModule().common.resetAccessibilityLevel(node);
2437    } else {
2438      getUINativeModule().common.setAccessibilityLevel(node, this.value);
2439    }
2440  }
2441}
2442
2443class AccessibilityDescriptionModifier extends ModifierWithKey<string> {
2444  constructor(value: string) {
2445    super(value);
2446  }
2447  static identity: Symbol = Symbol('accessibilityDescription');
2448  applyPeer(node: KNode, reset: boolean): void {
2449    if (reset) {
2450      getUINativeModule().common.resetAccessibilityDescription(node);
2451    } else {
2452      getUINativeModule().common.setAccessibilityDescription(node, this.value);
2453    }
2454  }
2455}
2456
2457class DirectionModifier extends ModifierWithKey<number> {
2458  static identity: Symbol = Symbol('direction');
2459  applyPeer(node: KNode, reset: boolean): void {
2460    if (reset) {
2461      getUINativeModule().common.resetDirection(node);
2462    } else {
2463      getUINativeModule().common.setDirection(node, this.value!);
2464    }
2465  }
2466  checkObjectDiff(): boolean {
2467    return !isBaseOrResourceEqual(this.stageValue, this.value);
2468  }
2469}
2470class AlignRulesModifier extends ModifierWithKey<ArkAlignRules> {
2471  constructor(value: ArkAlignRules) {
2472    super(value);
2473  }
2474  static identity: Symbol = Symbol('alignRules');
2475  applyPeer(node: KNode, reset: boolean): void {
2476    if (reset) {
2477      getUINativeModule().common.resetAlignRules(node);
2478    } else {
2479      getUINativeModule().common.setAlignRules(node, this.value.left,
2480        this.value.middle, this.value.right, this.value.top, this.value.center, this.value.bottom);
2481    }
2482  }
2483  checkObjectDiff(): boolean {
2484    return !isBaseOrResourceEqual(this.stageValue.left, this.value.left) ||
2485      !isBaseOrResourceEqual(this.stageValue.middle, this.value.middle) ||
2486      !isBaseOrResourceEqual(this.stageValue.right, this.value.right) ||
2487      !isBaseOrResourceEqual(this.stageValue.top, this.value.top) ||
2488      !isBaseOrResourceEqual(this.stageValue.center, this.value.center) ||
2489      !isBaseOrResourceEqual(this.stageValue.bottom, this.value.bottom);
2490  }
2491}
2492
2493class ExpandSafeAreaModifier extends ModifierWithKey<ArkSafeAreaExpandOpts | undefined> {
2494  constructor(value: ArkSafeAreaExpandOpts | undefined) {
2495    super(value);
2496  }
2497  static identity: Symbol = Symbol('expandSafeArea');
2498  applyPeer(node: KNode, reset: boolean): void {
2499    if (reset) {
2500      getUINativeModule().common.resetExpandSafeArea(node);
2501    } else {
2502      getUINativeModule().common.setExpandSafeArea(node, this.value.type, this.value.edges);
2503    }
2504  }
2505  checkObjectDiff(): boolean {
2506    return !isBaseOrResourceEqual(this.stageValue.type, this.value.type) ||
2507      !isBaseOrResourceEqual(this.stageValue.edges, this.value.edges);
2508  }
2509}
2510
2511class GridSpanModifier extends ModifierWithKey<number> {
2512  constructor(value: number) {
2513    super(value);
2514  }
2515  static identity: Symbol = Symbol('gridSpan');
2516  applyPeer(node: KNode, reset: boolean): void {
2517    if (reset) {
2518      getUINativeModule().common.resetGridSpan(node);
2519    } else {
2520      getUINativeModule().common.setGridSpan(node, this.value!);
2521    }
2522  }
2523}
2524
2525class GridOffsetModifier extends ModifierWithKey<number> {
2526  constructor(value: number) {
2527    super(value);
2528  }
2529  static identity: Symbol = Symbol('gridOffset');
2530  applyPeer(node: KNode, reset: boolean): void {
2531    if (reset) {
2532      getUINativeModule().common.resetGridOffset(node);
2533    } else {
2534      getUINativeModule().common.setGridOffset(node, this.value!);
2535    }
2536  }
2537}
2538
2539class AlignSelfModifier extends ModifierWithKey<number> {
2540  static identity: Symbol = Symbol('alignSelf');
2541  applyPeer(node: KNode, reset: boolean): void {
2542    if (reset) {
2543      getUINativeModule().common.resetAlignSelf(node);
2544    } else {
2545      getUINativeModule().common.setAlignSelf(node, this.value!);
2546    }
2547  }
2548  checkObjectDiff(): boolean {
2549    return !isBaseOrResourceEqual(this.stageValue, this.value);
2550  }
2551}
2552
2553class SizeModifier extends ModifierWithKey<SizeOptions> {
2554  static identity: Symbol = Symbol('size');
2555  applyPeer(node: KNode, reset: boolean): void {
2556    if (reset) {
2557      getUINativeModule().common.resetSize(node);
2558    } else {
2559      getUINativeModule().common.setSize(node, this.value.width, this.value.height);
2560    }
2561  }
2562
2563  checkObjectDiff(): boolean {
2564    return !isBaseOrResourceEqual(this.stageValue.width, this.value.width) ||
2565      !isBaseOrResourceEqual(this.stageValue.height, this.value.height);
2566  }
2567}
2568
2569class DisplayPriorityModifier extends ModifierWithKey<number> {
2570  static identity: Symbol = Symbol('displayPriority');
2571  applyPeer(node: KNode, reset: boolean): void {
2572    if (reset) {
2573      getUINativeModule().common.resetDisplayPriority(node);
2574    } else {
2575      getUINativeModule().common.setDisplayPriority(node, this.value!);
2576    }
2577  }
2578  checkObjectDiff(): boolean {
2579    return !isBaseOrResourceEqual(this.stageValue, this.value);
2580  }
2581}
2582
2583class IdModifier extends ModifierWithKey<string> {
2584  constructor(value: string) {
2585    super(value);
2586  }
2587  static identity: Symbol = Symbol('id');
2588  applyPeer(node: KNode, reset: boolean): void {
2589    if (reset) {
2590      getUINativeModule().common.resetId(node);
2591    } else {
2592      getUINativeModule().common.setId(node, this.value);
2593    }
2594  }
2595}
2596
2597class KeyModifier extends ModifierWithKey<string> {
2598  constructor(value: string) {
2599    super(value);
2600  }
2601  static identity: Symbol = Symbol('key');
2602  applyPeer(node: KNode, reset: boolean): void {
2603    if (reset) {
2604      getUINativeModule().common.resetKey(node);
2605    } else {
2606      getUINativeModule().common.setKey(node, this.value);
2607    }
2608  }
2609}
2610
2611class RestoreIdModifier extends ModifierWithKey<number> {
2612  constructor(value: number) {
2613    super(value);
2614  }
2615  static identity: Symbol = Symbol('restoreId');
2616  applyPeer(node: KNode, reset: boolean): void {
2617    if (reset) {
2618      getUINativeModule().common.resetRestoreId(node);
2619    } else {
2620      getUINativeModule().common.setRestoreId(node, this.value);
2621    }
2622  }
2623}
2624
2625class TabIndexModifier extends ModifierWithKey<number> {
2626  constructor(value: number) {
2627    super(value);
2628  }
2629  static identity: Symbol = Symbol('tabIndex');
2630  applyPeer(node: KNode, reset: boolean): void {
2631    if (reset) {
2632      getUINativeModule().common.resetTabIndex(node);
2633    } else {
2634      getUINativeModule().common.setTabIndex(node, this.value);
2635    }
2636  }
2637}
2638
2639class ObscuredModifier extends ModifierWithKey<Array<ObscuredReasons>> {
2640  constructor(value: Array<ObscuredReasons>) {
2641    super(value);
2642  }
2643  static identity: Symbol = Symbol('obscured');
2644  applyPeer(node: KNode, reset: boolean): void {
2645    if (reset || (!Array.isArray(this.value))) {
2646      getUINativeModule().common.resetObscured(node);
2647    } else {
2648      getUINativeModule().common.setObscured(node, this.value);
2649    }
2650  }
2651  checkObjectDiff(): boolean {
2652    return !(Array.isArray(this.value) && Array.isArray(this.stageValue) &&
2653      this.value.length === this.stageValue.length &&
2654      this.value.every((value, index) => value === this.stageValue[index]));
2655  }
2656}
2657
2658class ForegroundEffectModifier extends ModifierWithKey<ForegroundEffectOptions> {
2659  constructor(value: ForegroundEffectOptions) {
2660    super(value);
2661  }
2662  static identity: Symbol = Symbol('foregroundEffect');
2663  applyPeer(node: KNode, reset: boolean): void {
2664    if (reset) {
2665      getUINativeModule().common.resetForegroundEffect(node);
2666    } else {
2667      getUINativeModule().common.setForegroundEffect(node, this.value.radius);
2668    }
2669  }
2670
2671  checkObjectDiff(): boolean {
2672    return !(this.value.radius === this.stageValue.radius);
2673  }
2674}
2675
2676class BackgroundEffectModifier extends ModifierWithKey<BackgroundEffectOptions> {
2677  constructor(options: BackgroundEffectOptions) {
2678    super(options);
2679  }
2680  static identity: Symbol = Symbol('backgroundEffect');
2681  applyPeer(node: KNode, reset: boolean): void {
2682    if (reset) {
2683      getUINativeModule().common.resetBackgroundEffect(node);
2684    } else {
2685      getUINativeModule().common.setBackgroundEffect(node, this.value.radius, this.value.saturation,
2686        this.value.brightness, this.value.color, this.value.adaptiveColor, this.value.blurOptions?.grayscale,
2687        this.value.policy, this.value.inactiveColor, this.value.type);
2688    }
2689  }
2690
2691  checkObjectDiff(): boolean {
2692    return !(this.value.radius === this.stageValue.radius && this.value.saturation === this.stageValue.saturation &&
2693      this.value.brightness === this.stageValue.brightness &&
2694      isBaseOrResourceEqual(this.stageValue.color, this.value.color) &&
2695      this.value.adaptiveColor === this.stageValue.adaptiveColor &&
2696      this.value.policy === this.stageValue.policy &&
2697      this.value.inactiveColor === this.stageValue.inactiveColor &&
2698      this.value.type === this.stageValue.type &&
2699      this.value.blurOptions?.grayscale === this.stageValue.blurOptions?.grayscale);
2700  }
2701}
2702
2703class BackgroundBrightnessModifier extends ModifierWithKey<BackgroundBrightnessOptions> {
2704  constructor(params: BackgroundBrightnessOptions) {
2705    super(params);
2706  }
2707  static identity: Symbol = Symbol('backgroundBrightness');
2708  applyPeer(node: KNode, reset: boolean): void {
2709    if (reset) {
2710      getUINativeModule().common.resetBackgroundBrightness(node);
2711    } else {
2712      getUINativeModule().common.setBackgroundBrightness(node, this.value.rate, this.value.lightUpDegree);
2713    }
2714  }
2715
2716  checkObjectDiff(): boolean {
2717    return !(this.value.rate === this.stageValue.rate && this.value.lightUpDegree === this.stageValue.lightUpDegree);
2718  }
2719}
2720
2721class BackgroundBrightnessInternalModifier extends ModifierWithKey<BrightnessOptions> {
2722  constructor(params: BrightnessOptions) {
2723    super(params);
2724  }
2725  static identity: Symbol = Symbol('backgroundBrightnessInternal');
2726  applyPeer(node: KNode, reset: boolean): void {
2727    if (reset) {
2728      getUINativeModule().common.resetBackgroundBrightnessInternal(node);
2729    } else {
2730      getUINativeModule().common.setBackgroundBrightnessInternal(node, this.value.rate, this.value.lightUpDegree, this.value.cubicCoeff,
2731        this.value.quadCoeff, this.value.saturation, this.value.posRGB, this.value.negRGB, this.value.fraction);
2732    }
2733  }
2734
2735  checkObjectDiff(): boolean {
2736    return !(this.value.rate === this.stageValue.rate && this.value.lightUpDegree === this.stageValue.lightUpDegree &&
2737      this.value.cubicCoeff === this.stageValue.cubicCoeff && this.value.quadCoeff === this.stageValue.quadCoeff &&
2738      this.value.saturation === this.stageValue.saturation && this.value.posRGB === this.stageValue.posRGB &&
2739      this.value.negRGB === this.stageValue.negRGB && this.value.fraction === this.stageValue.fraction);
2740  }
2741}
2742
2743class ForegroundBrightnessModifier extends ModifierWithKey<BrightnessOptions> {
2744  constructor(params: BrightnessOptions) {
2745    super(params);
2746  }
2747  static identity: Symbol = Symbol('foregroundBrightness');
2748  applyPeer(node: KNode, reset: boolean): void {
2749    if (reset) {
2750      getUINativeModule().common.resetForegroundBrightness(node);
2751    } else {
2752      getUINativeModule().common.setForegroundBrightness(node, this.value.rate, this.value.lightUpDegree, this.value.cubicCoeff,
2753        this.value.quadCoeff, this.value.saturation, this.value.posRGB, this.value.negRGB, this.value.fraction);
2754    }
2755  }
2756
2757  checkObjectDiff(): boolean {
2758    return !(this.value.rate === this.stageValue.rate && this.value.lightUpDegree === this.stageValue.lightUpDegree &&
2759      this.value.cubicCoeff === this.stageValue.cubicCoeff && this.value.quadCoeff === this.stageValue.quadCoeff &&
2760      this.value.saturation === this.stageValue.saturation && this.value.posRGB === this.stageValue.posRGB &&
2761      this.value.negRGB === this.stageValue.negRGB && this.value.fraction === this.stageValue.fraction);
2762  }
2763}
2764
2765class DragPreviewOptionsModifier extends ModifierWithKey<ArkDragPreviewOptions> {
2766  constructor(value: ArkDragPreviewOptions) {
2767    super(value);
2768  }
2769  static identity: Symbol = Symbol('dragPreviewOptions');
2770  applyPeer(node: KNode, reset: boolean): void {
2771    if (reset) {
2772      getUINativeModule().common.resetDragPreviewOptions(node);
2773    } else {
2774      getUINativeModule().common.setDragPreviewOptions(node, this.value);
2775    }
2776  }
2777
2778  checkObjectDiff(): boolean {
2779    return !this.value.isEqual(this.stageValue);
2780  }
2781}
2782
2783class DragPreviewModifier extends ModifierWithKey<ArkDragPreview> {
2784  constructor(value: ArkDragPreview) {
2785    super(value);
2786  }
2787  static identity: Symbol = Symbol('dragPreview');
2788  applyPeer(node: KNode, reset: boolean): void {
2789    if (reset) {
2790      getUINativeModule().common.resetDragPreview(node);
2791    } else {
2792      getUINativeModule().common.setDragPreview(node, this.value);
2793    }
2794  }
2795
2796  checkObjectDiff(): boolean {
2797    return !this.value.isEqual(this.stageValue);
2798  }
2799}
2800
2801class MouseResponseRegionModifier extends ModifierWithKey<Array<Rectangle> | Rectangle> {
2802  constructor(value: Array<Rectangle> | Rectangle) {
2803    super(value);
2804  }
2805  static identity = Symbol('mouseResponseRegion');
2806  applyPeer(node: KNode, reset: boolean): void {
2807    if (reset) {
2808      getUINativeModule().common.resetMouseResponseRegion(node);
2809    } else {
2810      let responseRegion: (number | string | Resource)[] = [];
2811      if (Array.isArray(this.value)) {
2812        for (let i = 0; i < this.value.length; i++) {
2813          responseRegion.push(this.value[i].x ?? 'PLACEHOLDER');
2814          responseRegion.push(this.value[i].y ?? 'PLACEHOLDER');
2815          responseRegion.push(this.value[i].width ?? 'PLACEHOLDER');
2816          responseRegion.push(this.value[i].height ?? 'PLACEHOLDER');
2817        }
2818      } else {
2819        responseRegion.push(this.value.x ?? 'PLACEHOLDER');
2820        responseRegion.push(this.value.y ?? 'PLACEHOLDER');
2821        responseRegion.push(this.value.width ?? 'PLACEHOLDER');
2822        responseRegion.push(this.value.height ?? 'PLACEHOLDER');
2823      }
2824      getUINativeModule().common.setMouseResponseRegion(node, responseRegion, responseRegion.length);
2825    }
2826  }
2827
2828  checkObjectDiff(): boolean {
2829    if (Array.isArray(this.value) && Array.isArray(this.stageValue)) {
2830      if (this.value.length !== this.stageValue.length) {
2831        return true;
2832      } else {
2833        for (let i = 0; i < this.value.length; i++) {
2834          if (!(isBaseOrResourceEqual(this.stageValue[i].x, this.value[i].x) &&
2835            isBaseOrResourceEqual(this.stageValue[i].y, this.value[i].y) &&
2836            isBaseOrResourceEqual(this.stageValue[i].width, this.value[i].width) &&
2837            isBaseOrResourceEqual(this.stageValue[i].height, this.value[i].height)
2838          )) {
2839            return true;
2840          }
2841        }
2842        return false;
2843      }
2844    } else if (!Array.isArray(this.value) && !Array.isArray(this.stageValue)) {
2845      return (!(isBaseOrResourceEqual(this.stageValue.x, this.value.x) &&
2846        isBaseOrResourceEqual(this.stageValue.y, this.value.y) &&
2847        isBaseOrResourceEqual(this.stageValue.width, this.value.width) &&
2848        isBaseOrResourceEqual(this.stageValue.height, this.value.height)
2849      ));
2850    } else {
2851      return false;
2852    }
2853  }
2854}
2855
2856class ResponseRegionModifier extends ModifierWithKey<Array<Rectangle> | Rectangle> {
2857  constructor(value: Array<Rectangle> | Rectangle) {
2858    super(value);
2859  }
2860  static identity = Symbol('responseRegion');
2861  applyPeer(node: KNode, reset: boolean): void {
2862    if (reset) {
2863      getUINativeModule().common.resetResponseRegion(node);
2864    } else {
2865      let responseRegion: (number | string | Resource)[] = [];
2866      if (Array.isArray(this.value)) {
2867        for (let i = 0; i < this.value.length; i++) {
2868          responseRegion.push(this.value[i].x ?? 'PLACEHOLDER');
2869          responseRegion.push(this.value[i].y ?? 'PLACEHOLDER');
2870          responseRegion.push(this.value[i].width ?? 'PLACEHOLDER');
2871          responseRegion.push(this.value[i].height ?? 'PLACEHOLDER');
2872        }
2873      } else {
2874        responseRegion.push(this.value.x ?? 'PLACEHOLDER');
2875        responseRegion.push(this.value.y ?? 'PLACEHOLDER');
2876        responseRegion.push(this.value.width ?? 'PLACEHOLDER');
2877        responseRegion.push(this.value.height ?? 'PLACEHOLDER');
2878      }
2879      getUINativeModule().common.setResponseRegion(node, responseRegion, responseRegion.length);
2880    }
2881  }
2882
2883  checkObjectDiff(): boolean {
2884    if (Array.isArray(this.value) && Array.isArray(this.stageValue)) {
2885      if (this.value.length !== this.stageValue.length) {
2886        return true;
2887      } else {
2888        for (let i = 0; i < this.value.length; i++) {
2889          if (!(isBaseOrResourceEqual(this.stageValue[i].x, this.value[i].x) &&
2890            isBaseOrResourceEqual(this.stageValue[i].y, this.value[i].y) &&
2891            isBaseOrResourceEqual(this.stageValue[i].width, this.value[i].width) &&
2892            isBaseOrResourceEqual(this.stageValue[i].height, this.value[i].height)
2893          )) {
2894            return true;
2895          }
2896        }
2897        return false;
2898      }
2899    } else if (!Array.isArray(this.value) && !Array.isArray(this.stageValue)) {
2900      return (!(isBaseOrResourceEqual(this.stageValue.x, this.value.x) &&
2901        isBaseOrResourceEqual(this.stageValue.y, this.value.y) &&
2902        isBaseOrResourceEqual(this.stageValue.width, this.value.width) &&
2903        isBaseOrResourceEqual(this.stageValue.height, this.value.height)
2904      ));
2905    } else {
2906      return false;
2907    }
2908  }
2909}
2910class FlexGrowModifier extends ModifierWithKey<number> {
2911  static identity: Symbol = Symbol('flexGrow');
2912  applyPeer(node: KNode, reset: boolean): void {
2913    if (reset) {
2914      getUINativeModule().common.resetFlexGrow(node);
2915    } else {
2916      getUINativeModule().common.setFlexGrow(node, this.value!);
2917    }
2918  }
2919  checkObjectDiff(): boolean {
2920    return this.stageValue !== this.value;
2921  }
2922}
2923
2924class FlexShrinkModifier extends ModifierWithKey<number> {
2925  static identity: Symbol = Symbol('flexShrink');
2926  applyPeer(node: KNode, reset: boolean): void {
2927    if (reset) {
2928      getUINativeModule().common.resetFlexShrink(node);
2929    } else {
2930      getUINativeModule().common.setFlexShrink(node, this.value!);
2931    }
2932  }
2933  checkObjectDiff(): boolean {
2934    return this.stageValue !== this.value;
2935  }
2936}
2937
2938class AspectRatioModifier extends ModifierWithKey<number> {
2939  static identity: Symbol = Symbol('aspectRatio');
2940  applyPeer(node: KNode, reset: boolean): void {
2941    if (reset) {
2942      getUINativeModule().common.resetAspectRatio(node);
2943    } else {
2944      getUINativeModule().common.setAspectRatio(node, this.value!);
2945    }
2946  }
2947  checkObjectDiff(): boolean {
2948    return this.stageValue !== this.value;
2949  }
2950}
2951
2952class ConstraintSizeModifier extends ModifierWithKey<ConstraintSizeOptions> {
2953  static identity: Symbol = Symbol('constraintSize');
2954  applyPeer(node: KNode, reset: boolean): void {
2955    if (reset) {
2956      getUINativeModule().common.resetConstraintSize(node);
2957    } else {
2958      getUINativeModule().common.setConstraintSize(node, this.value.minWidth,
2959        this.value.maxWidth, this.value.minHeight, this.value.maxHeight);
2960    }
2961  }
2962
2963  checkObjectDiff(): boolean {
2964    return !isBaseOrResourceEqual(this.stageValue.minWidth, this.value.minWidth) ||
2965      !isBaseOrResourceEqual(this.stageValue.maxWidth, this.value.maxWidth) ||
2966      !isBaseOrResourceEqual(this.stageValue.minHeight, this.value.minHeight) ||
2967      !isBaseOrResourceEqual(this.stageValue.maxHeight, this.value.maxHeight);
2968  }
2969}
2970
2971class FlexBasisModifier extends ModifierWithKey<number | string> {
2972  static identity: Symbol = Symbol('flexBasis');
2973  applyPeer(node: KNode, reset: boolean): void {
2974    if (reset) {
2975      getUINativeModule().common.resetFlexBasis(node);
2976    } else {
2977      getUINativeModule().common.setFlexBasis(node, this.value!);
2978    }
2979  }
2980  checkObjectDiff(): boolean {
2981    return this.stageValue !== this.value;
2982  }
2983}
2984
2985class LayoutWeightModifier extends ModifierWithKey<number | string> {
2986  constructor(value: number | string) {
2987    super(value);
2988  }
2989  static identity: Symbol = Symbol('layoutWeight');
2990  applyPeer(node: KNode, reset: boolean): void {
2991    if (reset) {
2992      getUINativeModule().common.resetLayoutWeight(node);
2993    } else {
2994      getUINativeModule().common.setLayoutWeight(node, this.value!);
2995    }
2996  }
2997}
2998
2999class EnabledModifier extends ModifierWithKey<boolean> {
3000  constructor(value: boolean) {
3001    super(value);
3002  }
3003  static identity: Symbol = Symbol('enabled');
3004  applyPeer(node: KNode, reset: boolean): void {
3005    if (reset) {
3006      getUINativeModule().common.resetEnabled(node);
3007
3008    } else {
3009      getUINativeModule().common.setEnabled(node, this.value);
3010    }
3011  }
3012}
3013
3014class UseShadowBatchingModifier extends ModifierWithKey<boolean> {
3015  constructor(value: boolean) {
3016    super(value);
3017  }
3018  static identity: Symbol = Symbol('useShadowBatching');
3019  applyPeer(node: KNode, reset: boolean): void {
3020    if (reset) {
3021      getUINativeModule().common.resetUseShadowBatching(node);
3022
3023    } else {
3024      getUINativeModule().common.setUseShadowBatching(node, this.value);
3025    }
3026  }
3027}
3028
3029class MonopolizeEventsModifier extends ModifierWithKey<boolean> {
3030  constructor(value: boolean) {
3031    super(value);
3032  }
3033  static identity: Symbol = Symbol('monopolizeEvents');
3034  applyPeer(node: KNode, reset: boolean): void {
3035    if (reset) {
3036      getUINativeModule().common.resetMonopolizeEvents(node);
3037
3038    } else {
3039      getUINativeModule().common.setMonopolizeEvents(node, this.value);
3040    }
3041  }
3042}
3043
3044class DraggableModifier extends ModifierWithKey<boolean> {
3045  constructor(value: boolean) {
3046    super(value);
3047  }
3048  static identity: Symbol = Symbol('draggable');
3049  applyPeer(node: KNode, reset: boolean): void {
3050    if (reset) {
3051      getUINativeModule().common.resetDraggable(node);
3052    } else {
3053      getUINativeModule().common.setDraggable(node, this.value);
3054    }
3055  }
3056}
3057
3058class AccessibilityGroupModifier extends ModifierWithKey<boolean> {
3059  constructor(value: boolean) {
3060    super(value);
3061  }
3062  static identity: Symbol = Symbol('accessibilityGroup');
3063  applyPeer(node: KNode, reset: boolean): void {
3064    if (reset) {
3065      getUINativeModule().common.resetAccessibilityGroup(node);
3066    } else {
3067      getUINativeModule().common.setAccessibilityGroup(node, this.value);
3068    }
3069  }
3070}
3071
3072class HoverEffectModifier extends ModifierWithKey<HoverEffect> {
3073  constructor(value: HoverEffect) {
3074    super(value);
3075  }
3076  static identity: Symbol = Symbol('hoverEffect');
3077  applyPeer(node: KNode, reset: boolean): void {
3078    if (reset) {
3079      getUINativeModule().common.resetHoverEffect(node);
3080    } else {
3081      getUINativeModule().common.setHoverEffect(node, this.value);
3082    }
3083  }
3084}
3085
3086class ClickEffectModifier extends ModifierWithKey<ClickEffect | null> {
3087  constructor(value: ClickEffect | null) {
3088    super(value);
3089  }
3090  static identity: Symbol = Symbol('clickEffect');
3091  applyPeer(node: KNode, reset: boolean): void {
3092    if (reset || !this.value) {
3093      getUINativeModule().common.resetClickEffect(node);
3094    } else {
3095      getUINativeModule().common.setClickEffect(node, this.value.level, this.value.scale);
3096    }
3097  }
3098  checkObjectDiff(): boolean {
3099    return !((this.value.level === this.stageValue.level) && (this.value.scale === this.stageValue.scale));
3100  }
3101}
3102
3103class KeyBoardShortCutModifier extends ModifierWithKey<ArkKeyBoardShortCut> {
3104  constructor(value: ArkKeyBoardShortCut) {
3105    super(value);
3106  }
3107  static identity: Symbol = Symbol('keyboardShortcut');
3108  applyPeer(node: KNode, reset: boolean): void {
3109    if (reset) {
3110      getUINativeModule().common.resetKeyBoardShortCut(node);
3111    } else {
3112      getUINativeModule().common.setKeyBoardShortCut(node, this.value.value, this.value.keys);
3113    }
3114  }
3115  checkObjectDiff(): boolean {
3116    return !this.value.isEqual(this.stageValue);
3117  }
3118}
3119
3120class CustomPropertyModifier extends ModifierWithKey<ArkCustomProperty> {
3121  constructor(value: ArkCustomProperty) {
3122    super(value);
3123  }
3124  static identity: Symbol = Symbol('customProperty');
3125  applyPeer(node: KNode, reset: boolean): void {
3126    const nodeId = getUINativeModule().frameNode.getIdByNodePtr(node);
3127    if (reset) {
3128      __removeCustomProperty__(nodeId, this.value.key);
3129    } else {
3130      __setValidCustomProperty__(nodeId, this.value.key, this.value.value);
3131    }
3132  }
3133}
3134
3135class TransitionModifier extends ModifierWithKey<object> {
3136  constructor(value: object) {
3137    super(value);
3138  }
3139  static identity: Symbol = Symbol('transition');
3140  applyPeer(node: KNode, reset: boolean): void {
3141    if (reset) {
3142      getUINativeModule().common.resetTransition(node);
3143    } else {
3144      getUINativeModule().common.setTransition(node, this.value);
3145    }
3146  }
3147}
3148
3149class SharedTransitionModifier extends ModifierWithKey<ArkSharedTransition> {
3150  constructor(value: ArkSharedTransition) {
3151    super(value);
3152  }
3153  static identity: Symbol = Symbol('sharedTransition');
3154  applyPeer(node: KNode, reset: boolean): void {
3155    if (reset) {
3156      getUINativeModule().common.resetSharedTransition(node);
3157    } else {
3158      getUINativeModule().common.setSharedTransition(node, this.value.id, this.value.options);
3159    }
3160  }
3161}
3162
3163class SystemBarEffectModifier extends ModifierWithKey<null> {
3164  constructor(value: null) {
3165    super(value);
3166  }
3167  static identity: Symbol = Symbol('systemBarEffect');
3168  applyPeer(node: KNode, reset: boolean): void {
3169    getUINativeModule().common.setSystemBarEffect(node, true);
3170  }
3171}
3172class PixelRoundModifier extends ModifierWithKey<PixelRoundPolicy> {
3173  constructor(value: PixelRoundPolicy) {
3174    super(value);
3175  }
3176  static identity: Symbol = Symbol('pixelRound');
3177  applyPeer(node: KNode, reset: boolean): void {
3178    if (reset) {
3179      getUINativeModule().common.resetPixelRound(node);
3180    } else {
3181      let start: PixelRoundCalcPolicy;
3182      let top: PixelRoundCalcPolicy;
3183      let end: PixelRoundCalcPolicy;
3184      let bottom: PixelRoundCalcPolicy;
3185      if (isObject(this.value)) {
3186        start = (this.value as PixelRoundCalcPolicy)?.start;
3187        top = (this.value as PixelRoundCalcPolicy)?.top;
3188        end = (this.value as PixelRoundCalcPolicy)?.end;
3189        bottom = (this.value as PixelRoundCalcPolicy)?.bottom;
3190      }
3191      getUINativeModule().common.setPixelRound(node, start, top, end, bottom);
3192    }
3193  }
3194  checkObjectDiff(): boolean {
3195    return !(this.stageValue.start === this.value.start &&
3196      this.stageValue.end === this.value.end &&
3197      this.stageValue.top === this.value.top &&
3198      this.stageValue.bottom === this.value.bottom);
3199  }
3200}
3201
3202class FocusScopeIdModifier extends ModifierWithKey<ArkFocusScopeId> {
3203  constructor(value: ArkFocusScopeId) {
3204    super(value);
3205  }
3206  static identity: Symbol = Symbol('focusScopeId');
3207  applyPeer(node: KNode, reset: boolean): void {
3208    if (reset) {
3209      getUINativeModule().common.resetFocusScopeId(node);
3210    } else {
3211      getUINativeModule().common.setFocusScopeId(node, this.value.id, this.value.isGroup, this.value.arrowStepOut);
3212    }
3213  }
3214}
3215
3216class FocusScopePriorityModifier extends ModifierWithKey<ArkFocusScopePriority> {
3217  constructor(value: ArkFocusScopePriority) {
3218    super(value);
3219  }
3220  static identity: Symbol = Symbol('focusScopePriority');
3221  applyPeer(node: KNode, reset: boolean): void {
3222    if (reset) {
3223      getUINativeModule().common.resetFocusScopePriority(node);
3224    } else {
3225      getUINativeModule().common.setFocusScopePriority(node, this.value.scopeId, this.value.priority);
3226    }
3227  }
3228}
3229
3230class FocusBoxModifier extends ModifierWithKey<FocusBoxStyle> {
3231  constructor(value: FocusBoxStyle) {
3232    super(value);
3233  }
3234  static identity: Symbol = Symbol('focusBox');
3235  applyPeer(node: KNode, reset: boolean): void {
3236    if (reset) {
3237      getUINativeModule().common.resetFocusBox(node);
3238    } else {
3239      getUINativeModule().common.setFocusBox(node, this.value?.margin,
3240        this.value?.strokeWidth, this.value?.strokeColor);
3241    }
3242  }
3243}
3244
3245const JSCallbackInfoType = { STRING: 0, NUMBER: 1, OBJECT: 2, BOOLEAN: 3, FUNCTION: 4 };
3246type basicType = string | number | bigint | boolean | symbol | undefined | object | null;
3247const isString = (val: basicType): boolean => typeof val === 'string';
3248const isNumber = (val: basicType): boolean => typeof val === 'number';
3249const isBigint = (val: basicType): boolean => typeof val === 'bigint';
3250const isBoolean = (val: basicType): boolean => typeof val === 'boolean';
3251const isSymbol = (val: basicType): boolean => typeof val === 'symbol';
3252const isUndefined = (val: basicType): boolean => typeof val === 'undefined';
3253const isObject = (val: basicType): boolean => typeof val === 'object';
3254const isFunction = (val: basicType): boolean => typeof val === 'function';
3255const isLengthType = (val: any): boolean => typeof val === 'string' || typeof val === 'number';
3256function parseWithDefaultNumber(val, defaultValue) {
3257  if (isNumber(val)) {
3258    return val;
3259  }
3260  else { return defaultValue; }
3261}
3262function modifierWithKey<T extends number | string | boolean | object, M extends ModifierWithKey<T>>(
3263  modifiers: Map<Symbol, AttributeModifierWithKey>,
3264  identity: Symbol,
3265  modifierClass: new (value: T) => M,
3266  value: T
3267) {
3268  if (typeof (modifiers as ObservedMap).isFrameNode === 'function' && (modifiers as ObservedMap).isFrameNode()) {
3269    if (!(modifierClass as any).instance) {
3270      (modifierClass as any).instance = new modifierClass(value);
3271    } else {
3272      (modifierClass as any).instance.stageValue = value;
3273    }
3274    modifiers.set(identity, (modifierClass as any).instance);
3275    return;
3276  }
3277  const item = modifiers.get(identity);
3278  if (item) {
3279    item.stageValue = value;
3280    modifiers.set(identity, item);
3281  } else {
3282    modifiers.set(identity, new modifierClass(value));
3283  }
3284}
3285
3286declare class __JSScopeUtil__ {
3287  static syncInstanceId(instanceId: number): void;
3288  static restoreInstanceId(): void;
3289}
3290
3291class ArkComponent implements CommonMethod<CommonAttribute> {
3292  _modifiersWithKeys: Map<Symbol, AttributeModifierWithKey>;
3293  _changed: boolean;
3294  nativePtr: KNode;
3295  _weakPtr: JsPointerClass;
3296  _classType: ModifierType | undefined;
3297  _nativePtrChanged: boolean;
3298  _gestureEvent: UIGestureEvent;
3299  _instanceId: number;
3300
3301  constructor(nativePtr: KNode, classType?: ModifierType) {
3302    this._modifiersWithKeys = new Map();
3303    this.nativePtr = nativePtr;
3304    this._changed = false;
3305    this._classType = classType;
3306    if (classType === ModifierType.FRAME_NODE) {
3307      this._instanceId = -1;
3308      this._modifiersWithKeys = new ObservedMap();
3309      (this._modifiersWithKeys as ObservedMap).setOnChange((key, value) => {
3310        if (this.nativePtr === undefined) {
3311          return;
3312        }
3313        if (this._instanceId !== -1) {
3314          __JSScopeUtil__.syncInstanceId(this._instanceId);
3315        }
3316        value.applyStageImmediately(this.nativePtr, this);
3317        getUINativeModule().frameNode.propertyUpdate(this.nativePtr);
3318        if (this._instanceId !== -1) {
3319          __JSScopeUtil__.restoreInstanceId();
3320        }
3321      });
3322      (this._modifiersWithKeys as ObservedMap).setFrameNode(true);
3323    } else if (classType === ModifierType.EXPOSE_MODIFIER || classType === ModifierType.STATE) {
3324      this._modifiersWithKeys = new ObservedMap();
3325      this._weakPtr = getUINativeModule().nativeUtils.createNativeWeakRef(nativePtr);
3326    } else {
3327      this._modifiersWithKeys = new Map();
3328      this._weakPtr = getUINativeModule().nativeUtils.createNativeWeakRef(nativePtr);
3329    }
3330    this._nativePtrChanged = false;
3331  }
3332
3333  setNodePtr(nodePtr: KNode) {
3334    this.nativePtr = nodePtr;
3335  }
3336
3337  setInstanceId(instanceId: number): void {
3338    this._instanceId = instanceId;
3339  }
3340
3341  getOrCreateGestureEvent() {
3342    if (this._gestureEvent !== null) {
3343      this._gestureEvent = new UIGestureEvent();
3344      this._gestureEvent.setNodePtr(this.nativePtr);
3345      this._gestureEvent.setWeakNodePtr(this._weakPtr);
3346      this._gestureEvent.registerFrameNodeDeletedCallback(this.nativePtr);
3347    }
3348    return this._gestureEvent;
3349  }
3350
3351  cleanStageValue(): void {
3352    if (!this._modifiersWithKeys) {
3353      return;
3354    }
3355    this._modifiersWithKeys.forEach((value, key) => {
3356        value.stageValue = undefined;
3357    });
3358  }
3359
3360  applyStateUpdatePtr(instance: ArkComponent): void {
3361    if (this.nativePtr !== instance.nativePtr) {
3362      this.nativePtr = instance.nativePtr;
3363      this._nativePtrChanged = true;
3364      if (instance._weakPtr) {
3365        this._weakPtr = instance._weakPtr;
3366      } else {
3367        this._weakPtr = getUINativeModule().nativeUtils.createNativeWeakRef(this.nativePtr);
3368      }
3369    }
3370  }
3371
3372  applyModifierPatch(): void {
3373    let expiringItemsWithKeys = [];
3374    this._modifiersWithKeys.forEach((value, key) => {
3375      if (value.applyStage(this.nativePtr, this)) {
3376        expiringItemsWithKeys.push(key);
3377      }
3378    });
3379    expiringItemsWithKeys.forEach(key => {
3380      this._modifiersWithKeys.delete(key);
3381    });
3382  }
3383  onGestureJudgeBegin(callback: (gestureInfo: GestureInfo, event: BaseGestureEvent) => GestureJudgeResult): this {
3384    modifierWithKey(this._modifiersWithKeys, OnGestureJudgeBeginModifier.identity, OnGestureJudgeBeginModifier, callback);
3385    return this;
3386  }
3387  onGestureRecognizerJudgeBegin(callback: (event: BaseGestureEvent, current: GestureRecognizer, recognizers: Array<GestureRecognizer>) => GestureJudgeResult): this {
3388    modifierWithKey(this._modifiersWithKeys, OnGestureRecognizerJudgeBeginModifier.identity, OnGestureRecognizerJudgeBeginModifier, callback);
3389    return this;
3390  }
3391  shouldBuiltInRecognizerParallelWith(callback: (current: GestureRecognizer, others: Array<GestureRecognizer>) => GestureRecognizer): this {
3392    modifierWithKey(this._modifiersWithKeys, ShouldBuiltInRecognizerParallelWithModifier.identity, ShouldBuiltInRecognizerParallelWithModifier, callback);
3393    return this;
3394  }
3395  onSizeChange(callback: (oldValue: SizeOptions, newValue: SizeOptions) => void): this {
3396    modifierWithKey(this._modifiersWithKeys, OnSizeChangeModifier.identity, OnSizeChangeModifier, callback);
3397    return this;
3398  }
3399  outline(value: OutlineOptions): this {
3400    modifierWithKey(this._modifiersWithKeys, OutlineModifier.identity, OutlineModifier, value);
3401    return this;
3402  }
3403  outlineColor(value: ResourceColor | EdgeColors): this {
3404    modifierWithKey(this._modifiersWithKeys, OutlineColorModifier.identity, OutlineColorModifier, value);
3405    return this;
3406  }
3407  outlineRadius(value: Dimension | OutlineRadiuses): this {
3408    modifierWithKey(this._modifiersWithKeys, OutlineRadiusModifier.identity, OutlineRadiusModifier, value);
3409    return this;
3410  }
3411  outlineStyle(value: OutlineStyle | EdgeOutlineStyles): this {
3412    modifierWithKey(this._modifiersWithKeys, OutlineStyleModifier.identity, OutlineStyleModifier, value);
3413    return this;
3414  }
3415  outlineWidth(value: Dimension | EdgeOutlineWidths): this {
3416    modifierWithKey(this._modifiersWithKeys, OutlineWidthModifier.identity, OutlineWidthModifier, value);
3417    return this;
3418  }
3419  width(value: Length): this {
3420    modifierWithKey(this._modifiersWithKeys, WidthModifier.identity, WidthModifier, value);
3421    return this;
3422  }
3423
3424  height(value: Length): this {
3425    modifierWithKey(this._modifiersWithKeys, HeightModifier.identity, HeightModifier, value);
3426    return this;
3427  }
3428
3429  expandSafeArea(types?: Array<SafeAreaType>, edges?: Array<SafeAreaEdge>): this {
3430    let opts = new ArkSafeAreaExpandOpts();
3431    if (types && types.length > 0) {
3432      let safeAreaType: string | number = '';
3433      for (let param of types) {
3434        if (!isNumber(param) || param >= SAFE_AREA_TYPE_LIMIT) {
3435          safeAreaType = undefined;
3436          break;
3437        }
3438        if (safeAreaType) {
3439          safeAreaType += '|';
3440          safeAreaType += param.toString();
3441        } else {
3442          safeAreaType += param.toString();
3443        }
3444      }
3445      opts.type = safeAreaType;
3446    }
3447    if (edges && edges.length > 0) {
3448      let safeAreaEdge: string | number = '';
3449      for (let param of edges) {
3450        if (!isNumber(param) || param >= SAFE_AREA_EDGE_LIMIT) {
3451          safeAreaEdge = undefined;
3452          break;
3453        }
3454        if (safeAreaEdge) {
3455          safeAreaEdge += '|';
3456          safeAreaEdge += param.toString();
3457        } else {
3458          safeAreaEdge += param.toString();
3459        }
3460      }
3461      opts.edges = safeAreaEdge;
3462    }
3463    if (opts.type === undefined && opts.edges === undefined) {
3464      modifierWithKey(this._modifiersWithKeys, ExpandSafeAreaModifier.identity, ExpandSafeAreaModifier, undefined);
3465    } else {
3466      modifierWithKey(this._modifiersWithKeys, ExpandSafeAreaModifier.identity, ExpandSafeAreaModifier, opts);
3467    }
3468    return this;
3469  }
3470
3471  backgroundEffect(options: BackgroundEffectOptions): this {
3472    modifierWithKey(this._modifiersWithKeys, BackgroundEffectModifier.identity,
3473      BackgroundEffectModifier, options);
3474    return this;
3475  }
3476
3477  backgroundBrightness(params: BackgroundBrightnessOptions): this {
3478    modifierWithKey(this._modifiersWithKeys, BackgroundBrightnessModifier.identity,
3479      BackgroundBrightnessModifier, params);
3480    return this;
3481  }
3482
3483  backgroundBrightnessInternal(params: BrightnessOptions): this {
3484    modifierWithKey(this._modifiersWithKeys, BackgroundBrightnessInternalModifier.identity,
3485      BackgroundBrightnessInternalModifier, params);
3486    return this;
3487  }
3488
3489  foregroundBrightness(params: BrightnessOptions): this {
3490    modifierWithKey(this._modifiersWithKeys, ForegroundBrightnessModifier.identity,
3491      ForegroundBrightnessModifier, params);
3492    return this;
3493  }
3494
3495  dragPreviewOptions(value: DragPreviewOptions, options?: DragInteractionOptions): this {
3496    if (isUndefined(value)) {
3497      modifierWithKey(this._modifiersWithKeys, DragPreviewOptionsModifier.identity,
3498        DragPreviewOptionsModifier, undefined);
3499      return this;
3500    }
3501    let arkDragPreviewOptions = new ArkDragPreviewOptions();
3502    if (typeof value === 'object') {
3503      arkDragPreviewOptions.mode = value.mode;
3504      arkDragPreviewOptions.numberBadge = value.numberBadge;
3505    }
3506    if (typeof options === 'object') {
3507      arkDragPreviewOptions.isMultiSelectionEnabled = options.isMultiSelectionEnabled;
3508      arkDragPreviewOptions.defaultAnimationBeforeLifting = options.defaultAnimationBeforeLifting;
3509      arkDragPreviewOptions.isLiftingDisabled = options.isLiftingDisabled;
3510    }
3511    modifierWithKey(this._modifiersWithKeys, DragPreviewOptionsModifier.identity,
3512      DragPreviewOptionsModifier, arkDragPreviewOptions);
3513    return this;
3514  }
3515
3516  responseRegion(value: Array<Rectangle> | Rectangle): this {
3517    modifierWithKey(this._modifiersWithKeys, ResponseRegionModifier.identity,
3518      ResponseRegionModifier, value);
3519    return this;
3520  }
3521
3522  mouseResponseRegion(value: Array<Rectangle> | Rectangle): this {
3523    modifierWithKey(this._modifiersWithKeys, MouseResponseRegionModifier.identity,
3524      MouseResponseRegionModifier, value);
3525    return this;
3526  }
3527
3528  size(value: SizeOptions): this {
3529    modifierWithKey(this._modifiersWithKeys, SizeModifier.identity, SizeModifier, value);
3530    return this;
3531  }
3532
3533  constraintSize(value: ConstraintSizeOptions): this {
3534    modifierWithKey(this._modifiersWithKeys, ConstraintSizeModifier.identity,
3535      ConstraintSizeModifier, value);
3536    return this;
3537  }
3538
3539  touchable(value: boolean): this {
3540    if (typeof value === 'boolean') {
3541      modifierWithKey(this._modifiersWithKeys, TouchableModifier.identity, TouchableModifier, value);
3542    } else {
3543      modifierWithKey(this._modifiersWithKeys, TouchableModifier.identity, TouchableModifier, undefined);
3544    }
3545    return this;
3546  }
3547
3548  hitTestBehavior(value: HitTestMode): this {
3549    if (value) {
3550      modifierWithKey(this._modifiersWithKeys, HitTestBehaviorModifier.identity, HitTestBehaviorModifier, value);
3551    } else {
3552      modifierWithKey(this._modifiersWithKeys, HitTestBehaviorModifier.identity, HitTestBehaviorModifier, undefined);
3553    }
3554    return this;
3555  }
3556
3557  layoutWeight(value: number | string): this {
3558    if (isNumber(value)) {
3559      modifierWithKey(this._modifiersWithKeys, LayoutWeightModifier.identity, LayoutWeightModifier, value);
3560    } else if (isString(value) && !isNaN(Number(value))) {
3561      modifierWithKey(this._modifiersWithKeys, LayoutWeightModifier.identity, LayoutWeightModifier, parseInt(value.toString()));
3562    } else {
3563      modifierWithKey(this._modifiersWithKeys, LayoutWeightModifier.identity, LayoutWeightModifier, undefined);
3564    }
3565    return this;
3566  }
3567
3568  padding(value: Padding | Length | LocalizedPadding): this {
3569    let arkValue = new ArkPadding();
3570    if (value !== null && value !== undefined) {
3571      if (isLengthType(value) || isResource(value)) {
3572        arkValue.top = <Length>value;
3573        arkValue.right = <Length>value;
3574        arkValue.bottom = <Length>value;
3575        arkValue.left = <Length>value;
3576      } else {
3577        arkValue.top = value.top;
3578        arkValue.bottom = value.bottom;
3579        if (Object.keys(value).indexOf('right') >= 0) {
3580          arkValue.right = value.right;
3581        }
3582        if (Object.keys(value).indexOf('end') >= 0) {
3583          arkValue.right = value.end;
3584        }
3585        if (Object.keys(value).indexOf('left') >= 0) {
3586          arkValue.left = value.left;
3587        }
3588        if (Object.keys(value).indexOf('start') >= 0) {
3589          arkValue.left = value.start;
3590        }
3591      }
3592      modifierWithKey(this._modifiersWithKeys, PaddingModifier.identity, PaddingModifier, arkValue);
3593    } else {
3594      modifierWithKey(this._modifiersWithKeys, PaddingModifier.identity, PaddingModifier, undefined);
3595    }
3596    return this;
3597  }
3598
3599  margin(value: Margin | Length | LocalizedMargin): this {
3600    let arkValue = new ArkPadding();
3601    if (value !== null && value !== undefined) {
3602      if (isLengthType(value) || isResource(value)) {
3603        arkValue.top = <Length>value;
3604        arkValue.right = <Length>value;
3605        arkValue.bottom = <Length>value;
3606        arkValue.left = <Length>value;
3607      } else {
3608        arkValue.top = value.top;
3609        arkValue.bottom = value.bottom;
3610        if (Object.keys(value).indexOf('right') >= 0) {
3611          arkValue.right = value.right;
3612        }
3613        if (Object.keys(value).indexOf('end') >= 0) {
3614          arkValue.right = value.end;
3615        }
3616        if (Object.keys(value).indexOf('left') >= 0) {
3617          arkValue.left = value.left;
3618        }
3619        if (Object.keys(value).indexOf('start') >= 0) {
3620          arkValue.left = value.start;
3621        }
3622      }
3623      modifierWithKey(this._modifiersWithKeys, MarginModifier.identity, MarginModifier, arkValue);
3624    } else {
3625      modifierWithKey(this._modifiersWithKeys, MarginModifier.identity, MarginModifier, undefined);
3626    }
3627    return this;
3628  }
3629
3630  background(builder: CustomBuilder, options?: { align?: Alignment }): this {
3631    throw new Error('Method not implemented.');
3632  }
3633
3634  backgroundColor(value: ResourceColor): this {
3635    modifierWithKey(this._modifiersWithKeys, BackgroundColorModifier.identity, BackgroundColorModifier, value);
3636    return this;
3637  }
3638
3639  backgroundImage(src: ResourceStr | PixelMap, repeat?: ImageRepeat): this {
3640    let arkBackgroundImage = new ArkBackgroundImage();
3641    arkBackgroundImage.src = src;
3642    arkBackgroundImage.repeat = repeat;
3643    modifierWithKey(this._modifiersWithKeys, BackgroundImageModifier.identity, BackgroundImageModifier, arkBackgroundImage);
3644    return this;
3645  }
3646
3647  backgroundImageSize(value: SizeOptions | ImageSize): this {
3648    modifierWithKey(this._modifiersWithKeys, BackgroundImageSizeModifier.identity, BackgroundImageSizeModifier, value);
3649    return this;
3650  }
3651
3652  backgroundImagePosition(value: Position | Alignment): this {
3653    modifierWithKey(this._modifiersWithKeys, BackgroundImagePositionModifier.identity, BackgroundImagePositionModifier, value);
3654    return this;
3655  }
3656
3657  backgroundImageResizable(value: ResizableOptions): this {
3658    modifierWithKey(this._modifiersWithKeys, BackgroundImageResizableModifier.identity, BackgroundImageResizableModifier, value);
3659    return this;
3660  }
3661
3662  backgroundBlurStyle(value: BlurStyle, options?: BackgroundBlurStyleOptions): this {
3663    if (isUndefined(value)) {
3664      modifierWithKey(this._modifiersWithKeys, BackgroundBlurStyleModifier.identity,
3665        BackgroundBlurStyleModifier, undefined);
3666      return this;
3667    }
3668    let arkBackgroundBlurStyle = new ArkBackgroundBlurStyle();
3669    arkBackgroundBlurStyle.blurStyle = value;
3670    if (typeof options === 'object') {
3671      arkBackgroundBlurStyle.colorMode = options.colorMode;
3672      arkBackgroundBlurStyle.adaptiveColor = options.adaptiveColor;
3673      arkBackgroundBlurStyle.scale = options.scale;
3674      arkBackgroundBlurStyle.blurOptions = options.blurOptions;
3675      arkBackgroundBlurStyle.policy = options.policy;
3676      arkBackgroundBlurStyle.inactiveColor = options.inactiveColor;
3677      arkBackgroundBlurStyle.type = options.type;
3678    }
3679    modifierWithKey(this._modifiersWithKeys, BackgroundBlurStyleModifier.identity,
3680      BackgroundBlurStyleModifier, arkBackgroundBlurStyle);
3681    return this;
3682  }
3683
3684  foregroundBlurStyle(value: BlurStyle, options?: ForegroundBlurStyleOptions): this {
3685    if (isUndefined(value)) {
3686      modifierWithKey(this._modifiersWithKeys, ForegroundBlurStyleModifier.identity,
3687        ForegroundBlurStyleModifier, undefined);
3688      return this;
3689    }
3690    let arkForegroundBlurStyle = new ArkForegroundBlurStyle();
3691    arkForegroundBlurStyle.blurStyle = value;
3692    if (typeof options === 'object') {
3693      arkForegroundBlurStyle.colorMode = options.colorMode;
3694      arkForegroundBlurStyle.adaptiveColor = options.adaptiveColor;
3695      arkForegroundBlurStyle.scale = options.scale;
3696      arkForegroundBlurStyle.blurOptions = options.blurOptions;
3697    }
3698    modifierWithKey(this._modifiersWithKeys, ForegroundBlurStyleModifier.identity,
3699      ForegroundBlurStyleModifier, arkForegroundBlurStyle);
3700    return this;
3701  }
3702
3703  opacity(value: number | Resource): this {
3704    modifierWithKey(this._modifiersWithKeys, OpacityModifier.identity, OpacityModifier, value);
3705    return this;
3706  }
3707
3708  border(value: BorderOptions): this {
3709    let arkBorder = new ArkBorder();
3710    if (isUndefined(value)) {
3711      arkBorder = undefined;
3712    }
3713
3714    if (!isUndefined(value?.width) && value?.width !== null) {
3715      if (isNumber(value.width) || isString(value.width) || isResource(value.width)) {
3716        arkBorder.arkWidth.left = value.width;
3717        arkBorder.arkWidth.right = value.width;
3718        arkBorder.arkWidth.top = value.width;
3719        arkBorder.arkWidth.bottom = value.width;
3720      } else {
3721        if ((Object.keys(value.width).indexOf('start') >= 0) ||
3722        (Object.keys(value.width).indexOf('end') >= 0)) {
3723          arkBorder.arkWidth.start = (value.width as LocalizedEdgeWidths).start;
3724          arkBorder.arkWidth.end = (value.width as LocalizedEdgeWidths).end;
3725          arkBorder.arkWidth.top = (value.width as LocalizedEdgeWidths).top;
3726          arkBorder.arkWidth.bottom = (value.width as LocalizedEdgeWidths).bottom;
3727        } else {
3728          arkBorder.arkWidth.left = (value.width as EdgeWidths).left;
3729          arkBorder.arkWidth.right = (value.width as EdgeWidths).right;
3730          arkBorder.arkWidth.top = (value.width as EdgeWidths).top;
3731          arkBorder.arkWidth.bottom = (value.width as EdgeWidths).bottom;
3732        }
3733    }
3734    if (!isUndefined(value?.color) && value?.color !== null) {
3735      if (isNumber(value.color) || isString(value.color) || isResource(value.color)) {
3736        arkBorder.arkColor.leftColor = value.color;
3737        arkBorder.arkColor.rightColor = value.color;
3738        arkBorder.arkColor.topColor = value.color;
3739        arkBorder.arkColor.bottomColor = value.color;
3740      } else {
3741        if ((Object.keys(value.color).indexOf('start') >= 0) ||
3742          (Object.keys(value.color).indexOf('end') >= 0)) {
3743            arkBorder.arkColor.startColor = (value.color as LocalizedEdgeColors).start;
3744            arkBorder.arkColor.endColor = (value.color as LocalizedEdgeColors).end;
3745            arkBorder.arkColor.topColor = (value.color as LocalizedEdgeColors).top;
3746            arkBorder.arkColor.bottomColor = (value.color as LocalizedEdgeColors).bottom;
3747          } else {
3748            arkBorder.arkColor.leftColor = (value.color as EdgeColors).left;
3749            arkBorder.arkColor.rightColor = (value.color as EdgeColors).right;
3750            arkBorder.arkColor.topColor = (value.color as EdgeColors).top;
3751            arkBorder.arkColor.bottomColor = (value.color as EdgeColors).bottom;
3752          }
3753      }
3754    }
3755    if (!isUndefined(value?.radius) && value?.radius !== null) {
3756      if (isNumber(value.radius) || isString(value.radius) || isResource(value.radius)) {
3757        arkBorder.arkRadius.topLeft = value.radius;
3758        arkBorder.arkRadius.topRight = value.radius;
3759        arkBorder.arkRadius.bottomLeft = value.radius;
3760        arkBorder.arkRadius.bottomRight = value.radius;
3761      } else {
3762        if ((Object.keys(this.value).indexOf('topStart') >= 0) ||
3763          (Object.keys(this.value).indexOf('topEnd') >= 0) ||
3764          (Object.keys(this.value).indexOf('bottomStart') >= 0) ||
3765          (Object.keys(this.value).indexOf('bottomEnd') >= 0)) {
3766          arkBorder.arkRadius.topStart = (value.radius as LocalizedBorderRadius)?.topStart;
3767          arkBorder.arkRadius.topEnd = (value.radius as LocalizedBorderRadius)?.topEnd;
3768          arkBorder.arkRadius.bottomStart = (value.radius as LocalizedBorderRadius)?.bottomStart;
3769          arkBorder.arkRadius.bottomEnd = (value.radius as LocalizedBorderRadius)?.bottomEnd;
3770        } else {
3771          arkBorder.arkRadius.topLeft = (value.radius as BorderRadiuses)?.topLeft;
3772          arkBorder.arkRadius.topRight = (value.radius as BorderRadiuses)?.topRight;
3773          arkBorder.arkRadius.bottomLeft = (value.radius as BorderRadiuses)?.bottomLeft;
3774          arkBorder.arkRadius.bottomRight = (value.radius as BorderRadiuses)?.bottomRight;
3775        }
3776    }
3777    if (!isUndefined(value?.style) && value?.style !== null) {
3778      let arkBorderStyle = new ArkBorderStyle();
3779      if (arkBorderStyle.parseBorderStyle(value.style)) {
3780        if (!isUndefined(arkBorderStyle.style)) {
3781          arkBorder.arkStyle.top = arkBorderStyle.style;
3782          arkBorder.arkStyle.left = arkBorderStyle.style;
3783          arkBorder.arkStyle.bottom = arkBorderStyle.style;
3784          arkBorder.arkStyle.right = arkBorderStyle.style;
3785        } else {
3786          arkBorder.arkStyle.top = arkBorderStyle.top;
3787          arkBorder.arkStyle.left = arkBorderStyle.left;
3788          arkBorder.arkStyle.bottom = arkBorderStyle.bottom;
3789          arkBorder.arkStyle.right = arkBorderStyle.right;
3790        }
3791      }
3792    }
3793    if (!isUndefined(value?.dashGap) && value?.dashGap !== null) {
3794      if (isNumber(value.dashGap) || isString(value.dashGap) || isResource(value.dashGap) ||
3795        isObject(value.dashGap) && isNumber(value.dashGap.value)) {
3796        arkBorder.arkDashGap.left = value.dashGap;
3797        arkBorder.arkDashGap.right = value.dashGap;
3798        arkBorder.arkDashGap.top = value.dashGap;
3799        arkBorder.arkDashGap.bottom = value.dashGap;
3800      } else {
3801        arkBorder.arkDashGap.left = (value.dashGap as EdgeWidths).left;
3802        arkBorder.arkDashGap.right = (value.dashGap as EdgeWidths).right;
3803        arkBorder.arkDashGap.top = (value.dashGap as EdgeWidths).top;
3804        arkBorder.arkDashGap.bottom = (value.dashGap as EdgeWidths).bottom;
3805        arkBorder.arkDashGap.start = (value.dashGap as LocalizedEdgeWidths).start;
3806        arkBorder.arkDashGap.end = (value.dashGap as LocalizedEdgeWidths).end;
3807      }
3808    }
3809    if (!isUndefined(value?.dashWidth) && value?.dashWidth !== null) {
3810      if (isNumber(value.dashWidth) || isString(value.dashWidth) || isResource(value.dashWidth) ||
3811        isObject(value.dashWidth) && isNumber(value.dashWidth.value)) {
3812        arkBorder.arkDashWidth.left = value.dashWidth;
3813        arkBorder.arkDashWidth.right = value.dashWidth;
3814        arkBorder.arkDashWidth.top = value.dashWidth;
3815        arkBorder.arkDashWidth.bottom = value.dashWidth;
3816      } else {
3817        arkBorder.arkDashWidth.left = (value.dashWidth as EdgeWidths).left;
3818        arkBorder.arkDashWidth.right = (value.dashWidth as EdgeWidths).right;
3819        arkBorder.arkDashWidth.top = (value.dashWidth as EdgeWidths).top;
3820        arkBorder.arkDashWidth.bottom = (value.dashWidth as EdgeWidths).bottom;
3821        arkBorder.arkDashWidth.start = (value.dashWidth as EdgeWidths).start;
3822        arkBorder.arkDashWidth.end = (value.dashWidth as EdgeWidths).end;
3823      }
3824    }
3825    modifierWithKey(this._modifiersWithKeys, BorderModifier.identity, BorderModifier, arkBorder);
3826    return this;
3827  }
3828
3829  borderStyle(value: BorderStyle | EdgeStyles): this {
3830    modifierWithKey(this._modifiersWithKeys, BorderStyleModifier.identity, BorderStyleModifier, value);
3831    return this;
3832  }
3833
3834  borderWidth(value: Length | EdgeWidths): this {
3835    modifierWithKey(this._modifiersWithKeys, BorderWidthModifier.identity, BorderWidthModifier, value);
3836    return this;
3837  }
3838
3839  borderColor(value: ResourceColor | EdgeColors): this {
3840    modifierWithKey(this._modifiersWithKeys, BorderColorModifier.identity, BorderColorModifier, value);
3841    return this;
3842  }
3843
3844  borderRadius(value: Length | BorderRadiuses): this {
3845    modifierWithKey(this._modifiersWithKeys, BorderRadiusModifier.identity, BorderRadiusModifier, value);
3846    return this;
3847  }
3848
3849
3850  borderImage(value: BorderImageOption): this {
3851    modifierWithKey(this._modifiersWithKeys, BorderImageModifier.identity, BorderImageModifier, value);
3852    return this;
3853  }
3854
3855  foregroundColor(value: ResourceColor | ColoringStrategy): this {
3856    modifierWithKey(this._modifiersWithKeys, ForegroundColorModifier.identity, ForegroundColorModifier, value);
3857    return this;
3858  }
3859
3860  onClick(event: (event?: ClickEvent) => void): this {
3861    modifierWithKey(this._modifiersWithKeys, OnClickModifier.identity, OnClickModifier, event);
3862    return this;
3863  }
3864
3865  onHover(event: (isHover?: boolean, event?: HoverEvent) => void): this {
3866    modifierWithKey(this._modifiersWithKeys, OnHoverModifier.identity, OnHoverModifier, event);
3867    return this;
3868  }
3869
3870  onHoverMove(event: (event?: HoverMoveEvent) => void): this {
3871    modifierWithKey(this._modifiersWithKeys, OnHoverMoveModifier.identity, OnHoverMoveModifier, event);
3872    return this;
3873  }
3874
3875  hoverEffect(value: HoverEffect): this {
3876    modifierWithKey(this._modifiersWithKeys, HoverEffectModifier.identity, HoverEffectModifier, value);
3877    return this;
3878  }
3879
3880  onMouse(event: (event?: MouseEvent) => void): this {
3881    modifierWithKey(this._modifiersWithKeys, OnMouseModifier.identity, OnMouseModifier, event);
3882    return this;
3883  }
3884
3885  onTouch(event: (event?: TouchEvent) => void): this {
3886    modifierWithKey(this._modifiersWithKeys, OnTouchModifier.identity, OnTouchModifier, event);
3887    return this;
3888  }
3889
3890  onKeyEvent(event: (event?: KeyEvent) => void): this {
3891    modifierWithKey(this._modifiersWithKeys, OnKeyEventModifier.identity, OnKeyEventModifier, event);
3892    return this;
3893  }
3894
3895  onKeyPreIme(event: Callback<KeyEvent, boolean>): this {
3896    modifierWithKey(this._modifiersWithKeys, OnKeyPreImeModifier.identity, OnKeyPreImeModifier, event);
3897    return this;
3898  }
3899
3900  onFocusAxisEvent(event: (event?: FocusAxisEvent) => void): this {
3901    modifierWithKey(this._modifiersWithKeys, OnFocusAxisEventModifier.identity, OnFocusAxisEventModifier, event);
3902    return this;
3903  }
3904
3905  focusable(value: boolean): this {
3906    if (typeof value === 'boolean') {
3907      modifierWithKey(this._modifiersWithKeys, FocusableModifier.identity, FocusableModifier, value);
3908    } else {
3909      modifierWithKey(this._modifiersWithKeys, FocusableModifier.identity, FocusableModifier, undefined);
3910    }
3911    return this;
3912  }
3913
3914  tabStop(value: boolean): this {
3915    if (typeof value === 'boolean') {
3916      modifierWithKey(this._modifiersWithKeys, TabStopModifier.identity, TabStopModifier, value);
3917    } else {
3918      modifierWithKey(this._modifiersWithKeys, TabStopModifier.identity, TabStopModifier, undefined);
3919    }
3920    return this;
3921  }
3922
3923  onFocus(event: () => void): this {
3924    modifierWithKey(this._modifiersWithKeys, OnFocusModifier.identity, OnFocusModifier, event);
3925    return this;
3926  }
3927
3928  onBlur(event: () => void): this {
3929    modifierWithKey(this._modifiersWithKeys, OnBlurModifier.identity, OnBlurModifier, event);
3930    return this;
3931  }
3932
3933  tabIndex(index: number): this {
3934    if (typeof index !== 'number') {
3935      modifierWithKey(this._modifiersWithKeys, TabIndexModifier.identity, TabIndexModifier, undefined);
3936    } else {
3937      modifierWithKey(this._modifiersWithKeys, TabIndexModifier.identity, TabIndexModifier, index);
3938    }
3939    return this;
3940  }
3941
3942  defaultFocus(value: boolean): this {
3943    if (typeof value === 'boolean') {
3944      modifierWithKey(this._modifiersWithKeys, DefaultFocusModifier.identity, DefaultFocusModifier, value);
3945    } else {
3946      modifierWithKey(this._modifiersWithKeys, DefaultFocusModifier.identity, DefaultFocusModifier, undefined);
3947    }
3948    return this;
3949  }
3950
3951  groupDefaultFocus(value: boolean): this {
3952    if (typeof value === 'boolean') {
3953      modifierWithKey(this._modifiersWithKeys, GroupDefaultFocusModifier.identity, GroupDefaultFocusModifier, value);
3954    } else {
3955      modifierWithKey(this._modifiersWithKeys, GroupDefaultFocusModifier.identity, GroupDefaultFocusModifier, undefined);
3956    }
3957    return this;
3958  }
3959
3960  focusOnTouch(value: boolean): this {
3961    if (typeof value === 'boolean') {
3962      modifierWithKey(this._modifiersWithKeys, FocusOnTouchModifier.identity, FocusOnTouchModifier, value);
3963    } else {
3964      modifierWithKey(this._modifiersWithKeys, FocusOnTouchModifier.identity, FocusOnTouchModifier, undefined);
3965    }
3966    return this;
3967  }
3968
3969  animation(value: AnimateParam): this {
3970    throw new Error('Method not implemented.');
3971  }
3972
3973  transition(value: TransitionOptions | TransitionEffect): this {
3974    modifierWithKey(this._modifiersWithKeys, TransitionModifier.identity, TransitionModifier, value);
3975    return this;
3976  }
3977
3978  gesture(gesture: GestureType, mask?: GestureMask): this {
3979    throw new Error('Method not implemented.');
3980  }
3981
3982  priorityGesture(gesture: GestureType, mask?: GestureMask): this {
3983    throw new Error('Method not implemented.');
3984  }
3985
3986  parallelGesture(gesture: GestureType, mask?: GestureMask): this {
3987    throw new Error('Method not implemented.');
3988  }
3989
3990  blur(value: number, options?: BlurOptions): this {
3991    let blur: ArkBlurOptions = new ArkBlurOptions();
3992    blur.value = value;
3993    blur.options = options;
3994    modifierWithKey(this._modifiersWithKeys, BlurModifier.identity, BlurModifier, blur);
3995    return this;
3996  }
3997
3998  linearGradientBlur(value: number, options: LinearGradientBlurOptions): this {
3999    if (isUndefined(value) || isNull(value) || isUndefined(options) || isNull(options)) {
4000      modifierWithKey(this._modifiersWithKeys, LinearGradientBlurModifier.identity, LinearGradientBlurModifier,
4001        undefined);
4002      return this;
4003    }
4004    let arkLinearGradientBlur = new ArkLinearGradientBlur();
4005    arkLinearGradientBlur.blurRadius = value;
4006    arkLinearGradientBlur.fractionStops = options.fractionStops;
4007    arkLinearGradientBlur.direction = options.direction;
4008    modifierWithKey(this._modifiersWithKeys, LinearGradientBlurModifier.identity, LinearGradientBlurModifier,
4009      arkLinearGradientBlur);
4010    return this;
4011  }
4012
4013  brightness(value: number): this {
4014    if (!isNumber(value)) {
4015      modifierWithKey(this._modifiersWithKeys, BrightnessModifier.identity, BrightnessModifier, undefined);
4016    } else {
4017      modifierWithKey(this._modifiersWithKeys, BrightnessModifier.identity, BrightnessModifier, value);
4018    }
4019    return this;
4020  }
4021
4022  contrast(value: number): this {
4023    if (!isNumber(value)) {
4024      modifierWithKey(this._modifiersWithKeys, ContrastModifier.identity, ContrastModifier, undefined);
4025    } else {
4026      modifierWithKey(this._modifiersWithKeys, ContrastModifier.identity, ContrastModifier, value);
4027    }
4028    return this;
4029  }
4030
4031  grayscale(value: number): this {
4032    if (!isNumber(value)) {
4033      modifierWithKey(this._modifiersWithKeys, GrayscaleModifier.identity, GrayscaleModifier, undefined);
4034    } else {
4035      modifierWithKey(this._modifiersWithKeys, GrayscaleModifier.identity, GrayscaleModifier, value);
4036    }
4037    return this;
4038  }
4039
4040  colorBlend(value: Color | string | Resource): this {
4041    modifierWithKey(this._modifiersWithKeys, ColorBlendModifier.identity, ColorBlendModifier, value);
4042    return this;
4043  }
4044
4045  saturate(value: number): this {
4046    if (!isNumber(value)) {
4047      modifierWithKey(this._modifiersWithKeys, SaturateModifier.identity, SaturateModifier, undefined);
4048    } else {
4049      modifierWithKey(this._modifiersWithKeys, SaturateModifier.identity, SaturateModifier, value);
4050    }
4051    return this;
4052  }
4053
4054  sepia(value: number): this {
4055    if (!isNumber(value)) {
4056      modifierWithKey(this._modifiersWithKeys, SepiaModifier.identity, SepiaModifier, undefined);
4057    } else {
4058      modifierWithKey(this._modifiersWithKeys, SepiaModifier.identity, SepiaModifier, value);
4059    }
4060    return this;
4061  }
4062
4063  invert(value: number | InvertOptions): this {
4064    if (!isUndefined(value)) {
4065      modifierWithKey(this._modifiersWithKeys, InvertModifier.identity, InvertModifier, value);
4066    } else {
4067      modifierWithKey(this._modifiersWithKeys, InvertModifier.identity, InvertModifier, undefined);
4068    }
4069    return this;
4070  }
4071
4072  hueRotate(value: number | string): this {
4073    if (!isNumber(value) && !isString(value)) {
4074      modifierWithKey(this._modifiersWithKeys, HueRotateModifier.identity, HueRotateModifier, undefined);
4075    } else {
4076      modifierWithKey(this._modifiersWithKeys, HueRotateModifier.identity, HueRotateModifier, value);
4077    }
4078    return this;
4079  }
4080
4081  useEffect(value: boolean, type: EffectType = EffectType.DEFAULT): this {
4082    let useEffectObj = new ArkUseEffect();
4083    useEffectObj.useEffect = value;
4084    useEffectObj.effectType = type;
4085    modifierWithKey(this._modifiersWithKeys, UseEffectModifier.identity, UseEffectModifier, useEffectObj);
4086    return this;
4087  }
4088
4089  backdropBlur(value: number, options?: BlurOptions): this {
4090    let blur: ArkBlurOptions = new ArkBlurOptions();
4091    blur.value = value;
4092    blur.options = options;
4093    modifierWithKey(this._modifiersWithKeys, BackdropBlurModifier.identity, BackdropBlurModifier, blur);
4094    return this;
4095  }
4096
4097  renderGroup(value: boolean): this {
4098    modifierWithKey(this._modifiersWithKeys, RenderGroupModifier.identity, RenderGroupModifier, value);
4099    return this;
4100  }
4101
4102  translate(value: TranslateOptions): this {
4103    modifierWithKey(this._modifiersWithKeys, TranslateModifier.identity, TranslateModifier, value);
4104    return this;
4105  }
4106
4107  scale(value: ScaleOptions): this {
4108    modifierWithKey(this._modifiersWithKeys, ScaleModifier.identity, ScaleModifier, value);
4109    return this;
4110  }
4111  gridSpan(value: number): this {
4112    if (isNumber(value)) {
4113      modifierWithKey(this._modifiersWithKeys, GridSpanModifier.identity, GridSpanModifier, value);
4114    } else {
4115      modifierWithKey(this._modifiersWithKeys, GridSpanModifier.identity, GridSpanModifier, undefined);
4116    }
4117    return this;
4118  }
4119
4120  gridOffset(value: number): this {
4121    if (isNumber(value)) {
4122      modifierWithKey(this._modifiersWithKeys, GridOffsetModifier.identity, GridOffsetModifier, value);
4123    } else {
4124      modifierWithKey(this._modifiersWithKeys, GridOffsetModifier.identity, GridOffsetModifier, undefined);
4125    }
4126    return this;
4127  }
4128
4129  rotate(value: RotateOptions): this {
4130    modifierWithKey(this._modifiersWithKeys, RotateModifier.identity, RotateModifier, value);
4131    return this;
4132  }
4133
4134  transform(value: object): this {
4135    modifierWithKey(this._modifiersWithKeys, TransformModifier.identity, TransformModifier, value);
4136    return this;
4137  }
4138
4139  onAppear(event: () => void): this {
4140    modifierWithKey(this._modifiersWithKeys, OnAppearModifier.identity, OnAppearModifier, event);
4141    return this;
4142  }
4143
4144  onDisAppear(event: () => void): this {
4145    modifierWithKey(this._modifiersWithKeys, OnDisappearModifier.identity, OnDisappearModifier, event);
4146    return this;
4147  }
4148
4149  onAttach(event: () => void): this {
4150    modifierWithKey(this._modifiersWithKeys, OnAttachModifier.identity, OnAttachModifier, event);
4151    return this;
4152  }
4153
4154  onDetach(event: () => void): this {
4155    modifierWithKey(this._modifiersWithKeys, OnDetachModifier.identity, OnDetachModifier, event);
4156    return this;
4157  }
4158  onAreaChange(event: (oldValue: Area, newValue: Area) => void): this {
4159    modifierWithKey(this._modifiersWithKeys, OnAreaChangeModifier.identity, OnAreaChangeModifier, event);
4160    return this;
4161  }
4162
4163  visibility(value: Visibility): this {
4164    modifierWithKey(this._modifiersWithKeys, VisibilityModifier.identity, VisibilityModifier, value);
4165    return this;
4166  }
4167
4168  flexGrow(value: number): this {
4169    modifierWithKey(this._modifiersWithKeys, FlexGrowModifier.identity, FlexGrowModifier, value);
4170    return this;
4171  }
4172
4173  flexShrink(value: number): this {
4174    modifierWithKey(this._modifiersWithKeys, FlexShrinkModifier.identity, FlexShrinkModifier, value);
4175    return this;
4176  }
4177
4178  flexBasis(value: number | string): this {
4179    modifierWithKey(this._modifiersWithKeys, FlexBasisModifier.identity, FlexBasisModifier, value);
4180    return this;
4181  }
4182
4183  alignSelf(value: ItemAlign): this {
4184    modifierWithKey(this._modifiersWithKeys, AlignSelfModifier.identity, AlignSelfModifier, value);
4185    return this;
4186  }
4187
4188  displayPriority(value: number): this {
4189    modifierWithKey(this._modifiersWithKeys, DisplayPriorityModifier.identity, DisplayPriorityModifier, value);
4190    return this;
4191  }
4192
4193  zIndex(value: number): this {
4194    if (value !== null) {
4195      let zIndex = 0;
4196      if (typeof (value) === 'number') {
4197        zIndex = value;
4198      }
4199      modifierWithKey(this._modifiersWithKeys, ZIndexModifier.identity, ZIndexModifier, zIndex);
4200    }
4201    return this;
4202  }
4203
4204  sharedTransition(id: string, options?: sharedTransitionOptions): this {
4205    let arkSharedTransition = new ArkSharedTransition();
4206    if (isString(id)) {
4207      arkSharedTransition.id = id;
4208    }
4209    if (typeof options === 'object') {
4210      arkSharedTransition.options = options;
4211    }
4212    modifierWithKey(
4213      this._modifiersWithKeys, SharedTransitionModifier.identity, SharedTransitionModifier, arkSharedTransition);
4214    return this;
4215  }
4216
4217  direction(value: Direction): this {
4218    modifierWithKey(this._modifiersWithKeys, DirectionModifier.identity, DirectionModifier, value);
4219    return this;
4220  }
4221
4222  align(value: Alignment): this {
4223    if (isNumber(value)) {
4224      modifierWithKey(this._modifiersWithKeys, AlignModifier.identity, AlignModifier, value);
4225    } else {
4226      modifierWithKey(this._modifiersWithKeys, AlignModifier.identity, AlignModifier, undefined);
4227    }
4228    return this;
4229  }
4230
4231  position(value: Position | Edges): this {
4232    if (isObject(value)) {
4233      modifierWithKey(this._modifiersWithKeys, PositionModifier.identity, PositionModifier, value);
4234    } else {
4235      modifierWithKey(this._modifiersWithKeys, PositionModifier.identity, PositionModifier, undefined);
4236    }
4237    return this;
4238  }
4239
4240  markAnchor(value: Position): this {
4241    modifierWithKey(this._modifiersWithKeys, MarkAnchorModifier.identity, MarkAnchorModifier, value);
4242    return this;
4243  }
4244
4245  offset(value: Position | Edges): this {
4246    if (isObject(value)) {
4247      modifierWithKey(this._modifiersWithKeys, OffsetModifier.identity, OffsetModifier, value);
4248    } else {
4249      modifierWithKey(this._modifiersWithKeys, OffsetModifier.identity, OffsetModifier, undefined);
4250    }
4251    return this;
4252  }
4253
4254  enabled(value: boolean): this {
4255    if (typeof value === 'boolean') {
4256      modifierWithKey(this._modifiersWithKeys, EnabledModifier.identity, EnabledModifier, value);
4257    } else {
4258      modifierWithKey(this._modifiersWithKeys, EnabledModifier.identity, EnabledModifier, undefined);
4259    }
4260    return this;
4261  }
4262
4263  useShadowBatching(value: boolean): this {
4264    modifierWithKey(this._modifiersWithKeys, UseShadowBatchingModifier.identity, UseShadowBatchingModifier, value);
4265    return this;
4266  }
4267
4268  monopolizeEvents(value: boolean): this {
4269    modifierWithKey(this._modifiersWithKeys, MonopolizeEventsModifier.identity, MonopolizeEventsModifier, value);
4270    return this;
4271  }
4272
4273  useSizeType(value: {
4274    xs?: number | { span: number; offset: number };
4275    sm?: number | { span: number; offset: number };
4276    md?: number | { span: number; offset: number };
4277    lg?: number | { span: number; offset: number };
4278  }): this {
4279    throw new Error('Method not implemented.');
4280  }
4281
4282  alignRules(value: AlignRuleOption): this {
4283    if (!isObject(value) || JSON.stringify(value) === '{}') {
4284      modifierWithKey(this._modifiersWithKeys, AlignRulesModifier.identity, AlignRulesModifier, undefined);
4285      return this;
4286    }
4287    let keys: string[] = ['left', 'middle', 'right', 'top', 'center', 'bottom'];
4288    let arkValue = new ArkAlignRules();
4289    for (let i = 0; i < keys.length; i++) {
4290      let rule = value[keys[i]];
4291      let alignRule: string = '';
4292      if (isObject(rule)) {
4293        let alignSign = false;
4294        let anchorSign = false;
4295        let align = rule.align;
4296        let anchor = rule.anchor;
4297        if (isString(anchor)) {
4298          anchorSign = true;
4299        }
4300        if (i < DIRECTION_RANGE) {
4301          if (align in HorizontalAlign) {
4302            alignSign = true;
4303          }
4304        } else {
4305          if (align in VerticalAlign) {
4306            alignSign = true;
4307          }
4308        }
4309        if (!alignSign && !anchorSign) {
4310          alignRule += '';
4311        } else if (!anchorSign) {
4312          alignRule += align.toString();
4313          alignRule += '|';
4314          alignRule += '__container__';
4315        } else if (!alignSign) {
4316          alignRule += '2';
4317          alignRule += '|';
4318          alignRule += anchor;
4319        } else {
4320          alignRule += align.toString();
4321          alignRule += '|';
4322          alignRule += anchor;
4323        }
4324      } else {
4325        alignRule += '';
4326      }
4327      switch (keys[i]) {
4328        case 'left':
4329          arkValue.left = alignRule;
4330          break;
4331        case 'middle':
4332          arkValue.middle = alignRule;
4333          break;
4334        case 'right':
4335          arkValue.right = alignRule;
4336          break;
4337        case 'top':
4338          arkValue.top = alignRule;
4339          break;
4340        case 'center':
4341          arkValue.center = alignRule;
4342          break;
4343        case 'bottom':
4344          arkValue.bottom = alignRule;
4345          break;
4346      }
4347    }
4348    modifierWithKey(this._modifiersWithKeys, AlignRulesModifier.identity, AlignRulesModifier, arkValue);
4349    return this;
4350  }
4351
4352  aspectRatio(value: number): this {
4353    modifierWithKey(this._modifiersWithKeys, AspectRatioModifier.identity, AspectRatioModifier, value);
4354    return this;
4355  }
4356
4357  clickEffect(value: ClickEffect | null): this {
4358    modifierWithKey(this._modifiersWithKeys, ClickEffectModifier.identity, ClickEffectModifier, value);
4359    return this;
4360  }
4361
4362  onDragStart(event: (event?: DragEvent, extraParams?: string) => CustomBuilder | DragItemInfo): this {
4363    modifierWithKey(this._modifiersWithKeys, DragStartModifier.identity, DragStartModifier, event);
4364    return this;
4365  }
4366
4367  onDragEnter(event: (event?: DragEvent, extraParams?: string) => void): this {
4368    modifierWithKey(this._modifiersWithKeys, DragEnterModifier.identity, DragEnterModifier, event);
4369    return this;
4370  }
4371
4372  onDragMove(event: (event?: DragEvent, extraParams?: string) => void): this {
4373    modifierWithKey(this._modifiersWithKeys, DragMoveModifier.identity, DragMoveModifier, event);
4374    return this;
4375  }
4376
4377  onDragLeave(event: (event?: DragEvent, extraParams?: string) => void): this {
4378    modifierWithKey(this._modifiersWithKeys, DragLeaveModifier.identity, DragLeaveModifier, event);
4379    return this;
4380  }
4381
4382  onDrop(event: (event?: DragEvent, extraParams?: string) => void): this {
4383    modifierWithKey(this._modifiersWithKeys, DropModifier.identity, DropModifier, event);
4384    return this;
4385  }
4386
4387  onDragEnd(event: (event: DragEvent, extraParams?: string) => void): this {
4388    modifierWithKey(this._modifiersWithKeys, DragEndModifier.identity, DragEndModifier, event);
4389    return this;
4390  }
4391
4392  onPreDrag(event: (preDragStatus: PreDragStatus) => void): this {
4393    throw new Error('Method not implemented.');
4394  }
4395
4396  allowDrop(value: Array<UniformDataType>): this {
4397    modifierWithKey(this._modifiersWithKeys, AllowDropModifier.identity, AllowDropModifier, value);
4398    return this;
4399  }
4400
4401  draggable(value: boolean): this {
4402    if (typeof value === 'boolean') {
4403      modifierWithKey(this._modifiersWithKeys, DraggableModifier.identity, DraggableModifier, value);
4404    } else {
4405      modifierWithKey(this._modifiersWithKeys, DraggableModifier.identity, DraggableModifier, undefined);
4406
4407    }
4408    return this;
4409  }
4410
4411  dragPreview(preview: CustomBuilder | DragItemInfo | string, config: PreviewConfiguration): this {
4412    let arkDragPreview = new ArkDragPreview();
4413    if (typeof config === 'object') {
4414      arkDragPreview.onlyForLifting = config.onlyForLifting;
4415    }
4416    if (typeof preview === 'string') {
4417      arkDragPreview.inspetorId = preview;
4418      modifierWithKey(this._modifiersWithKeys, DragPreviewModifier.identity, DragPreviewModifier, arkDragPreview);
4419    } else if (typeof preview === 'object') {
4420      arkDragPreview.pixelMap = preview.pixelMap;
4421      arkDragPreview.extraInfo = preview.extraInfo;
4422      if (preview.builder) {
4423        throw new Error('Builder is not supported.');
4424      }
4425      modifierWithKey(this._modifiersWithKeys, DragPreviewModifier.identity, DragPreviewModifier, arkDragPreview);
4426    } else if (typeof preview === 'function') {
4427      throw new Error('Method not implemented.');
4428    }
4429    return this;
4430  }
4431
4432  overlay(value: string | CustomBuilder, options?: { align?: Alignment; offset?: { x?: number; y?: number } }): this {
4433    if (typeof value === 'undefined') {
4434      modifierWithKey(this._modifiersWithKeys, OverlayModifier.identity, OverlayModifier, undefined);
4435      return this;
4436    }
4437    let arkOverlay = new ArkOverlay();
4438    if (arkOverlay.splitOverlayValue(value, options)) {
4439      modifierWithKey(this._modifiersWithKeys, OverlayModifier.identity, OverlayModifier, arkOverlay);
4440    } else {
4441      modifierWithKey(this._modifiersWithKeys, OverlayModifier.identity, OverlayModifier, undefined);
4442    }
4443    return this;
4444  }
4445
4446  linearGradient(value: {
4447    angle?: number | string;
4448    direction?: GradientDirection;
4449    colors: Array<any>;
4450    repeating?: boolean;
4451  }): this {
4452    modifierWithKey(this._modifiersWithKeys, LinearGradientModifier.identity, LinearGradientModifier, value);
4453    return this;
4454  }
4455
4456  sweepGradient(value: {
4457    center: Array<any>;
4458    start?: number | string;
4459    end?: number | string;
4460    rotation?: number | string;
4461    colors: Array<any>;
4462    repeating?: boolean;
4463  }): this {
4464    modifierWithKey(this._modifiersWithKeys, SweepGradientModifier.identity, SweepGradientModifier, value);
4465    return this;
4466  }
4467
4468  radialGradient(value: { center: Array<any>; radius: number | string; colors: Array<any>; repeating?: boolean }): this {
4469    modifierWithKey(this._modifiersWithKeys, RadialGradientModifier.identity, RadialGradientModifier, value);
4470    return this;
4471  }
4472
4473  motionPath(value: MotionPathOptions): this {
4474    modifierWithKey(this._modifiersWithKeys, MotionPathModifier.identity, MotionPathModifier, value);
4475    return this;
4476  }
4477
4478  motionBlur(value: MotionBlurOptions): this {
4479    modifierWithKey(this._modifiersWithKeys, MotionBlurModifier.identity, MotionBlurModifier, value);
4480    return this;
4481  }
4482
4483  shadow(value: ShadowOptions | ShadowStyle): this {
4484    modifierWithKey(this._modifiersWithKeys, ShadowModifier.identity, ShadowModifier, value);
4485    return this;
4486  }
4487
4488  mask(value: CircleAttribute | EllipseAttribute | PathAttribute | RectAttribute | ProgressMask): this {
4489    modifierWithKey(this._modifiersWithKeys, MaskModifier.identity, MaskModifier, value);
4490    return this;
4491  }
4492
4493  chainMode(direction: Axis, style: ChainStyle): this {
4494    let arkChainMode = new ArkChainMode();
4495    arkChainMode.direction = direction;
4496    arkChainMode.style = style;
4497    modifierWithKey(this._modifiersWithKeys, ChainModeifier.identity, ChainModeifier, arkChainMode);
4498    return this;
4499  }
4500
4501  key(value: string): this {
4502    if (typeof value === 'string') {
4503      modifierWithKey(this._modifiersWithKeys, KeyModifier.identity, KeyModifier, value);
4504    } else {
4505      modifierWithKey(this._modifiersWithKeys, KeyModifier.identity, KeyModifier, undefined);
4506    }
4507    return this;
4508  }
4509
4510  id(value: string): this {
4511    if (typeof value === 'string') {
4512      modifierWithKey(this._modifiersWithKeys, IdModifier.identity, IdModifier, value);
4513    } else {
4514      modifierWithKey(this._modifiersWithKeys, IdModifier.identity, IdModifier, undefined);
4515    }
4516    return this;
4517  }
4518
4519  geometryTransition(id: string, options?: GeometryTransitionOptions): this {
4520    let arkGeometryTransition = new ArkGeometryTransition();
4521    arkGeometryTransition.id = id;
4522    arkGeometryTransition.options = options;
4523    modifierWithKey(this._modifiersWithKeys, GeometryTransitionModifier.identity, GeometryTransitionModifier, arkGeometryTransition);
4524    return this;
4525  }
4526
4527  bindPopup(show: boolean, popup: PopupOptions | CustomPopupOptions): this {
4528    throw new Error('Method not implemented.');
4529  }
4530
4531  bindMenu(content: Array<MenuElement> | CustomBuilder, options?: MenuOptions): this {
4532    throw new Error('Method not implemented.');
4533  }
4534
4535  bindContextMenu(content: CustomBuilder, responseType: ResponseType, options?: ContextMenuOptions): this {
4536    throw new Error('Method not implemented.');
4537  }
4538
4539  bindContentCover(isShow: boolean, builder: CustomBuilder, type?: ModalTransition | ContentCoverOptions): this {
4540    throw new Error('Method not implemented.');
4541  }
4542
4543  blendMode(blendMode: BlendMode, blendApplyType?: BlendApplyType): this {
4544    let arkBlendMode = new ArkBlendMode();
4545    arkBlendMode.blendMode = blendMode;
4546    arkBlendMode.blendApplyType = blendApplyType;
4547    modifierWithKey(this._modifiersWithKeys, BlendModeModifier.identity, BlendModeModifier, arkBlendMode);
4548    return this;
4549  }
4550
4551  advancedBlendMode(blendMode: BlendMode, blendApplyType?: BlendApplyType): this {
4552    let arkBlendMode = new ArkBlendMode();
4553    arkBlendMode.blendMode = blendMode;
4554    arkBlendMode.blendApplyType = blendApplyType;
4555    modifierWithKey(this._modifiersWithKeys, AdvancedBlendModeModifier.identity,
4556      AdvancedBlendModeModifier, arkBlendMode);
4557    return this;
4558  }
4559
4560  clip(value: boolean | CircleAttribute | EllipseAttribute | PathAttribute | RectAttribute): this {
4561    modifierWithKey(this._modifiersWithKeys, ClipModifier.identity, ClipModifier, value);
4562    return this;
4563  }
4564
4565  bindSheet(isShow: boolean, builder: CustomBuilder, options?: SheetOptions): this {
4566    throw new Error('Method not implemented.');
4567  }
4568
4569  stateStyles(value: StateStyles): this {
4570    throw new Error('Method not implemented.');
4571  }
4572
4573  restoreId(value: number): this {
4574    if (typeof value !== 'number') {
4575      modifierWithKey(this._modifiersWithKeys, RestoreIdModifier.identity, RestoreIdModifier, undefined);
4576    } else {
4577      modifierWithKey(this._modifiersWithKeys, RestoreIdModifier.identity, RestoreIdModifier, value);
4578    }
4579    return this;
4580  }
4581
4582  onVisibleAreaChange(ratios: Array<number>, event: (isVisible: boolean, currentRatio: number) => void): this {
4583    throw new Error('Method not implemented.');
4584  }
4585
4586  sphericalEffect(value: number): this {
4587    modifierWithKey(this._modifiersWithKeys, SphericalEffectModifier.identity, SphericalEffectModifier, value);
4588    return this;
4589  }
4590
4591  lightUpEffect(value: number): this {
4592    modifierWithKey(this._modifiersWithKeys, LightUpEffectModifier.identity, LightUpEffectModifier, value);
4593    return this;
4594  }
4595
4596  pixelStretchEffect(options: PixelStretchEffectOptions): this {
4597    modifierWithKey(this._modifiersWithKeys, PixelStretchEffectModifier.identity, PixelStretchEffectModifier, options);
4598    return this;
4599  }
4600
4601  keyboardShortcut(value: string | FunctionKey, keys: Array<ModifierKey>, action?: () => void): this {
4602    let keyboardShortCut = new ArkKeyBoardShortCut();
4603    keyboardShortCut.value = value;
4604    keyboardShortCut.keys = keys;
4605    modifierWithKey(this._modifiersWithKeys, KeyBoardShortCutModifier.identity, KeyBoardShortCutModifier, keyboardShortCut);
4606    return this;
4607  }
4608
4609  accessibilityGroup(value: boolean): this {
4610    if (typeof value === 'boolean') {
4611      modifierWithKey(this._modifiersWithKeys, AccessibilityGroupModifier.identity, AccessibilityGroupModifier, value);
4612    } else {
4613      modifierWithKey(this._modifiersWithKeys, AccessibilityGroupModifier.identity, AccessibilityGroupModifier, undefined);
4614
4615    }
4616    return this;
4617  }
4618
4619  accessibilityText(value: string): this {
4620    if (typeof value === 'string') {
4621      modifierWithKey(this._modifiersWithKeys, AccessibilityTextModifier.identity, AccessibilityTextModifier, value);
4622    } else {
4623      modifierWithKey(this._modifiersWithKeys, AccessibilityTextModifier.identity, AccessibilityTextModifier, undefined);
4624    }
4625    return this;
4626  }
4627
4628  accessibilityDescription(value: string): this {
4629    if (typeof value !== 'string') {
4630      modifierWithKey(this._modifiersWithKeys, AccessibilityDescriptionModifier.identity, AccessibilityDescriptionModifier, undefined);
4631    } else {
4632      modifierWithKey(this._modifiersWithKeys, AccessibilityDescriptionModifier.identity, AccessibilityDescriptionModifier, value);
4633    }
4634    return this;
4635  }
4636
4637  accessibilityLevel(value: string): this {
4638    if (typeof value !== 'string') {
4639      modifierWithKey(this._modifiersWithKeys, AccessibilityLevelModifier.identity, AccessibilityLevelModifier, undefined);
4640    } else {
4641      modifierWithKey(this._modifiersWithKeys, AccessibilityLevelModifier.identity, AccessibilityLevelModifier, value);
4642    }
4643    return this;
4644  }
4645
4646  obscured(reasons: Array<ObscuredReasons>): this {
4647    modifierWithKey(this._modifiersWithKeys, ObscuredModifier.identity, ObscuredModifier, reasons);
4648    return this;
4649  }
4650
4651  reuseId(id: string): this {
4652    throw new Error('Method not implemented.');
4653  }
4654
4655  renderFit(fitMode: RenderFit): this {
4656    modifierWithKey(this._modifiersWithKeys, RenderFitModifier.identity, RenderFitModifier, fitMode);
4657    return this;
4658  }
4659
4660  attributeModifier(modifier: AttributeModifier<CommonAttribute>): this {
4661    return this;
4662  }
4663
4664  customProperty(key: string, value: object): this {
4665    let returnBool = getUINativeModule().frameNode.setCustomPropertyModiferByKey(this.nativePtr, key, value);
4666    if (!returnBool) {
4667      const property = new ArkCustomProperty();
4668      property.key = key;
4669      property.value = value;
4670      modifierWithKey(this._modifiersWithKeys, CustomPropertyModifier.identity, CustomPropertyModifier, property);
4671    }
4672    return this;
4673  }
4674
4675  systemBarEffect(): this {
4676    modifierWithKey(this._modifiersWithKeys, SystemBarEffectModifier.identity, SystemBarEffectModifier, null);
4677    return this;
4678  }
4679
4680  focusScopeId(id: string, isGroup?: boolean, arrowStepOut?: boolean): this {
4681    let arkFocusScopeId = new ArkFocusScopeId();
4682    if (isString(id)) {
4683      arkFocusScopeId.id = id;
4684    }
4685    if (typeof isGroup === 'boolean') {
4686      arkFocusScopeId.isGroup = isGroup;
4687    }
4688    if (typeof arrowStepOut === 'boolean') {
4689      arkFocusScopeId.arrowStepOut = arrowStepOut;
4690    }
4691    modifierWithKey(
4692      this._modifiersWithKeys, FocusScopeIdModifier.identity, FocusScopeIdModifier, arkFocusScopeId);
4693    return this;
4694  }
4695
4696  focusScopePriority(scopeId: string, priority?: number): this {
4697    let arkFocusScopePriority = new ArkFocusScopePriority();
4698    if (isString(scopeId)) {
4699      arkFocusScopePriority.scopeId = scopeId;
4700    }
4701    if (typeof priority === 'number') {
4702      arkFocusScopePriority.priority = priority;
4703    }
4704    modifierWithKey(
4705      this._modifiersWithKeys, FocusScopePriorityModifier.identity, FocusScopePriorityModifier, arkFocusScopePriority);
4706    return this;
4707  }
4708
4709  pixelRound(value:PixelRoundPolicy): this {
4710    modifierWithKey(this._modifiersWithKeys, PixelRoundModifier.identity, PixelRoundModifier, value);
4711  }
4712  focusBox(value:FocusBoxStyle):this {
4713    modifierWithKey(this._modifiersWithKeys, FocusBoxModifier.identity, FocusBoxModifier, value);
4714  }
4715}
4716
4717const isNull = (val: any) => typeof val === 'object' && val === null;
4718const isArray = (val: any) => Array.isArray(val);
4719const isDate = (val: any) => val instanceof Date;
4720const isRegExp = (val: any) => val instanceof RegExp;
4721const isError = (val: any) => val instanceof Error;
4722const isFloat = (val: any) => Number.isFinite(val) && !Number.isInteger(val);
4723const isInteger = (val: any) => Number.isInteger(val);
4724const isNonEmptyMap = (val: any) => val instanceof Map && val.size > 0;
4725const isTruthyString = (val: any) => typeof val === 'string' && val.trim() !== '';
4726
4727class UICommonEvent {
4728  private _nodePtr: Object | null;
4729  private _instanceId: number;
4730  private _onAttachEvent?: () => void;
4731  private _onDetachEvent?: () => void;
4732  private _clickEvent?: (event: ClickEvent) => void;
4733  private _touchEvent?: (event: TouchEvent) => void;
4734  private _onAppearEvent?: () => void;
4735  private _onDisappearEvent?: () => void;
4736  private _onKeyEvent?: (event: KeyEvent) => void;
4737  private _onFocusEvent?: () => void;
4738  private _onBlur?: () => void;
4739  private _onHoverEvent?: (isHover: boolean, event: HoverEvent) => void;
4740  private _onHoverMoveEvent?: (event: HoverEvent) => void;
4741  private _onMouseEvent?: (event: MouseEvent) => void;
4742  private _onSizeChangeEvent?: SizeChangeCallback;
4743  private _onVisibleAreaApproximateChange?: VisibleAreaChangeCallback;
4744
4745  setInstanceId(instanceId: number): void {
4746    this._instanceId = instanceId;
4747  }
4748  setNodePtr(nodePtr: Object | null): void {
4749    this._nodePtr = nodePtr;
4750  }
4751  // the first param is used to indicate frameNode
4752  // the second param is used to indicate the callback
4753  // the third param is used to indicate the instanceid
4754  // other options will be indicated after them
4755  setOnClick(callback: (event: ClickEvent) => void): void {
4756    this._clickEvent = callback;
4757    getUINativeModule().frameNode.setOnClick(this._nodePtr, callback, this._instanceId);
4758  }
4759  setOnTouch(callback: (event: TouchEvent) => void): void {
4760    this._touchEvent = callback;
4761    getUINativeModule().frameNode.setOnTouch(this._nodePtr, callback, this._instanceId);
4762  }
4763  setOnAppear(callback: () => void): void {
4764    this._onAppearEvent = callback;
4765    getUINativeModule().frameNode.setOnAppear(this._nodePtr, callback, this._instanceId);
4766  }
4767  setOnDisappear(callback: () => void): void {
4768    this._onDisappearEvent = callback;
4769    getUINativeModule().frameNode.setOnDisappear(this._nodePtr, callback, this._instanceId);
4770  }
4771  setOnAttach(callback: () => void): void {
4772    this._onAttachEvent = callback;
4773    getUINativeModule().frameNode.setOnAttach(this._nodePtr, callback, this._instanceId);
4774  }
4775  setOnDetach(callback: () => void): void {
4776    this._onDetachEvent = callback;
4777    getUINativeModule().frameNode.setOnDetach(this._nodePtr, callback, this._instanceId);
4778  }
4779  setOnKeyEvent(callback: (event: KeyEvent) => void): void {
4780    this._onKeyEvent = callback;
4781    getUINativeModule().frameNode.setOnKeyEvent(this._nodePtr, callback, this._instanceId);
4782  }
4783  setOnFocus(callback: () => void): void {
4784    this._onFocusEvent = callback;
4785    getUINativeModule().frameNode.setOnFocus(this._nodePtr, callback, this._instanceId);
4786  }
4787  setOnBlur(callback: () => void): void {
4788    this._onBlur = callback;
4789    getUINativeModule().frameNode.setOnBlur(this._nodePtr, callback, this._instanceId);
4790  }
4791  setOnHover(callback: (isHover: boolean, event: HoverEvent) => void): void {
4792    this._onHoverEvent = callback;
4793    getUINativeModule().frameNode.setOnHover(this._nodePtr, callback, this._instanceId);
4794  }
4795  setOnHoverMove(callback: (event: HoverMoveEvent) => void): void {
4796    this._onHoverMoveEvent = callback;
4797    getUINativeModule().frameNode.setOnHoverMove(this._nodePtr, callback, this._instanceId);
4798  }
4799  setOnMouse(callback: (event: MouseEvent) => void): void {
4800    this._onMouseEvent = callback;
4801    getUINativeModule().frameNode.setOnMouse(this._nodePtr, callback, this._instanceId);
4802  }
4803  setOnSizeChange(callback: SizeChangeCallback): void {
4804    this._onSizeChangeEvent = callback;
4805    getUINativeModule().frameNode.setOnSizeChange(this._nodePtr, callback, this._instanceId);
4806  }
4807  setOnVisibleAreaApproximateChange(options: VisibleAreaEventOptions, callback: VisibleAreaChangeCallback): void {
4808    this._onVisibleAreaApproximateChange = callback;
4809    getUINativeModule().frameNode.setOnVisibleAreaApproximateChange(this._nodePtr, callback, this._instanceId, options.ratios, options.expectedUpdateInterval ? options.expectedUpdateInterval : 1000);
4810  }
4811}
4812
4813function attributeModifierFunc<T>(modifier: AttributeModifier<T>,
4814  componentBuilder: (nativePtr: KNode) => ArkComponent,
4815  modifierBuilder: (nativePtr: KNode, classType: ModifierType, modifierJS: ModifierJS) => ArkComponent)
4816{
4817  if (modifier === undefined || modifier === null) {
4818    return;
4819  }
4820  const elmtId = ViewStackProcessor.GetElmtIdToAccountFor();
4821  let nativeNode = getUINativeModule().getFrameNodeById(elmtId);
4822  let component = this.createOrGetNode(elmtId, () => {
4823    return componentBuilder(nativeNode);
4824  });
4825  if (modifier.isAttributeUpdater === true) {
4826    let modifierJS = globalThis.requireNapi('arkui.modifier');
4827    if (modifier.modifierState === modifierJS.AttributeUpdater.StateEnum.INIT) {
4828      modifier.modifierState = modifierJS.AttributeUpdater.StateEnum.UPDATE;
4829      modifier.attribute = modifierBuilder(nativeNode, ModifierType.STATE, modifierJS);
4830      modifierJS.ModifierUtils.applySetOnChange(modifier.attribute);
4831      modifier.initializeModifier(modifier.attribute);
4832      applyUIAttributesInit(modifier, nativeNode, component);
4833      component.applyModifierPatch();
4834    } else {
4835      modifier.attribute.applyStateUpdatePtr(component);
4836      if (modifier.attribute._nativePtrChanged) {
4837        modifier.onComponentChanged(modifier.attribute);
4838      }
4839      modifier.attribute.applyNormalAttribute(component);
4840      applyUIAttributes(modifier, nativeNode, component);
4841      component.applyModifierPatch();
4842    }
4843  } else {
4844    applyUIAttributes(modifier, nativeNode, component);
4845    component.applyModifierPatch();
4846  }
4847}
4848
4849function attributeModifierFuncWithoutStateStyles<T>(modifier: AttributeModifier<T>,
4850  componentBuilder: (nativePtr: KNode) => ArkComponent,
4851  modifierBuilder: (nativePtr: KNode, classType: ModifierType, modifierJS: ModifierJS) => ArkComponent)
4852{
4853  const elmtId = ViewStackProcessor.GetElmtIdToAccountFor();
4854  let nativeNode = getUINativeModule().getFrameNodeById(elmtId);
4855  let component = this.createOrGetNode(elmtId, () => {
4856    return componentBuilder(nativeNode);
4857  });
4858  if (modifier.isAttributeUpdater === true) {
4859    let modifierJS = globalThis.requireNapi('arkui.modifier');
4860    if (modifier.modifierState === modifierJS.AttributeUpdater.StateEnum.INIT) {
4861      modifier.modifierState = modifierJS.AttributeUpdater.StateEnum.UPDATE;
4862      modifier.attribute = modifierBuilder(nativeNode, ModifierType.STATE, modifierJS);
4863      modifierJS.ModifierUtils.applySetOnChange(modifier.attribute);
4864      modifier.initializeModifier(modifier.attribute);
4865      component.applyModifierPatch();
4866    } else {
4867      modifier.attribute.applyStateUpdatePtr(component);
4868      modifier.attribute.applyNormalAttribute(component);
4869      if (modifier.applyNormalAttribute) {
4870        modifier.applyNormalAttribute(component);
4871      }
4872      component.applyModifierPatch();
4873    }
4874  } else {
4875    if (modifier.applyNormalAttribute) {
4876      modifier.applyNormalAttribute(component);
4877    }
4878    component.applyModifierPatch();
4879  }
4880}
4881
4882class UIGestureEvent {
4883  private _nodePtr: Object | null;
4884  private _weakNodePtr: JsPointerClass;
4885  private _gestures: GestureHandler[] | undefined;
4886  private _destructorCallback: Callback<number>;
4887  setNodePtr(nodePtr: Object | null): void {
4888    this._nodePtr = nodePtr;
4889  }
4890  setWeakNodePtr(weakNodePtr: JsPointerClass): void {
4891    this._weakNodePtr = weakNodePtr;
4892  }
4893  registerFrameNodeDeletedCallback(nodePtr): void {
4894    this._destructorCallback = (elementId: number) => {
4895      globalThis.__mapOfModifier__.delete(elementId);
4896    };
4897    getUINativeModule().common.registerFrameNodeDestructorCallback(nodePtr, this._destructorCallback);
4898  }
4899  addGesture(gesture: GestureHandler, priority?: GesturePriority, mask?: GestureMask): void {
4900    if (this._weakNodePtr.invalid()) {
4901      return;
4902    }
4903    if (this._gestures === undefined) {
4904      this._gestures = [gesture];
4905    } else {
4906      this._gestures.push(gesture);
4907    }
4908    switch (gesture.gestureType) {
4909      case CommonGestureType.TAP_GESTURE: {
4910        let tapGesture: TapGestureHandler = gesture as TapGestureHandler;
4911        getUINativeModule().common.addTapGesture(this._nodePtr, priority, mask, tapGesture.gestureTag,
4912          tapGesture.allowedTypes, tapGesture.fingers, tapGesture.count, tapGesture.limitFingerCount, tapGesture.onActionCallback);
4913        break;
4914      }
4915      case CommonGestureType.LONG_PRESS_GESTURE: {
4916        let longPressGesture: LongPressGestureHandler = gesture as LongPressGestureHandler;
4917        getUINativeModule().common.addLongPressGesture(this._nodePtr, priority, mask, longPressGesture.gestureTag,
4918          longPressGesture.allowedTypes, longPressGesture.fingers, longPressGesture.repeat,
4919          longPressGesture.duration, longPressGesture.limitFingerCount,
4920          longPressGesture.onActionCallback, longPressGesture.onActionEndCallback, longPressGesture.onActionCancelCallback);
4921        break;
4922      }
4923      case CommonGestureType.PAN_GESTURE: {
4924        let panGesture: PanGestureHandler = gesture as PanGestureHandler;
4925        getUINativeModule().common.addPanGesture(this._nodePtr, priority, mask, panGesture.gestureTag,
4926          panGesture.allowedTypes, panGesture.fingers, panGesture.direction, panGesture.distance,
4927          panGesture.limitFingerCount, panGesture.onActionStartCallback, panGesture.onActionUpdateCallback,
4928          panGesture.onActionEndCallback, panGesture.onActionCancelCallback);
4929        break;
4930      }
4931      case CommonGestureType.SWIPE_GESTURE: {
4932        let swipeGesture: SwipeGestureHandler = gesture as SwipeGestureHandler;
4933        getUINativeModule().common.addSwipeGesture(this._nodePtr, priority, mask, swipeGesture.gestureTag,
4934          swipeGesture.allowedTypes, swipeGesture.fingers, swipeGesture.direction, swipeGesture.speed,
4935          swipeGesture.limitFingerCount, swipeGesture.onActionCallback);
4936        break;
4937      }
4938      case CommonGestureType.PINCH_GESTURE: {
4939        let pinchGesture: PinchGestureHandler = gesture as PinchGestureHandler;
4940        getUINativeModule().common.addPinchGesture(this._nodePtr, priority, mask, pinchGesture.gestureTag,
4941          pinchGesture.allowedTypes, pinchGesture.fingers, pinchGesture.distance,
4942          pinchGesture.limitFingerCount, pinchGesture.onActionStartCallback,
4943          pinchGesture.onActionUpdateCallback, pinchGesture.onActionEndCallback, pinchGesture.onActionCancelCallback);
4944        break;
4945      }
4946      case CommonGestureType.ROTATION_GESTURE: {
4947        let rotationGesture: RotationGestureHandler = gesture as RotationGestureHandler;
4948        getUINativeModule().common.addRotationGesture(this._nodePtr, priority, mask, rotationGesture.gestureTag,
4949          rotationGesture.allowedTypes, rotationGesture.fingers, rotationGesture.angle,
4950          rotationGesture.limitFingerCount, rotationGesture.onActionStartCallback,
4951          rotationGesture.onActionUpdateCallback, rotationGesture.onActionEndCallback,
4952          rotationGesture.onActionCancelCallback);
4953        break;
4954      }
4955      case CommonGestureType.GESTURE_GROUP: {
4956        let gestureGroup: GestureGroupHandler = gesture as GestureGroupHandler;
4957        let groupPtr = getUINativeModule().common.addGestureGroup(this._nodePtr,
4958          gestureGroup.gestureTag, gestureGroup.onCancelCallback, gestureGroup.mode);
4959        gestureGroup.gestures.forEach((item) => {
4960          addGestureToGroup(this._nodePtr, item, groupPtr);
4961        });
4962        getUINativeModule().common.attachGestureGroup(this._nodePtr, priority, mask, groupPtr);
4963        break;
4964      }
4965      default:
4966        break;
4967    }
4968  }
4969  addParallelGesture(gesture: GestureHandler, mask?: GestureMask): void {
4970    this.addGesture(gesture, GesturePriority.PARALLEL, mask);
4971  }
4972  removeGestureByTag(tag: string): void {
4973    if (this._weakNodePtr.invalid()) {
4974      return;
4975    }
4976    getUINativeModule().common.removeGestureByTag(this._nodePtr, tag);
4977    for (let index = this._gestures.length - 1; index >= 0; index--) {
4978      if (this._gestures[index].gestureTag === tag) {
4979        this._gestures.splice(index, 1);
4980        continue;
4981      }
4982      if (this._gestures[index].gestureType === CommonGestureType.GESTURE_GROUP) {
4983        let gestureGroup: GestureGroupHandler = this._gestures[index] as GestureGroupHandler;
4984        removeGestureByTagInGroup(gestureGroup, tag);
4985      }
4986    }
4987  }
4988  clearGestures(): void {
4989    if (this._weakNodePtr.invalid()) {
4990      return;
4991    }
4992    getUINativeModule().common.clearGestures(this._nodePtr);
4993    this._gestures = [];
4994  }
4995}
4996
4997function removeGestureByTagInGroup(gestureGroup: GestureGroupHandler, tag: string) {
4998  for (let index = gestureGroup.gestures.length - 1; index >= 0; index--) {
4999    if (gestureGroup.gestures[index].gestureTag === tag) {
5000      gestureGroup.gestures.splice(index, 1);
5001      continue;
5002    }
5003    if (gestureGroup.gestures[index].gestureType === CommonGestureType.GESTURE_GROUP) {
5004      removeGestureByTagInGroup(gestureGroup.gestures[index], tag);
5005    }
5006  }
5007}
5008
5009function addGestureToGroup(nodePtr: Object | null, gesture: any, gestureGroupPtr: any) {
5010  switch (gesture.gestureType) {
5011    case CommonGestureType.TAP_GESTURE: {
5012      let tapGesture: TapGestureHandler = gesture as TapGestureHandler;
5013      getUINativeModule().common.addTapGestureToGroup(nodePtr, tapGesture.gestureTag, tapGesture.allowedTypes,
5014        tapGesture.fingers, tapGesture.count, tapGesture.limitFingerCount, tapGesture.onActionCallback,
5015        gestureGroupPtr);
5016      break;
5017    }
5018    case CommonGestureType.LONG_PRESS_GESTURE: {
5019      let longPressGesture: LongPressGestureHandler = gesture as LongPressGestureHandler;
5020      getUINativeModule().common.addLongPressGestureToGroup(nodePtr, longPressGesture.gestureTag, longPressGesture.allowedTypes,
5021        longPressGesture.fingers, longPressGesture.repeat, longPressGesture.duration, longPressGesture.limitFingerCount,
5022        longPressGesture.onActionCallback, longPressGesture.onActionEndCallback, longPressGesture.onActionCancelCallback, gestureGroupPtr);
5023      break;
5024    }
5025    case CommonGestureType.PAN_GESTURE: {
5026      let panGesture: PanGestureHandler = gesture as PanGestureHandler;
5027      getUINativeModule().common.addPanGestureToGroup(nodePtr, panGesture.gestureTag, panGesture.allowedTypes,
5028        panGesture.fingers, panGesture.direction, panGesture.distance, panGesture.limitFingerCount, panGesture.onActionStartCallback,
5029        panGesture.onActionUpdateCallback, panGesture.onActionEndCallback, panGesture.onActionCancelCallback, gestureGroupPtr);
5030      break;
5031    }
5032    case CommonGestureType.SWIPE_GESTURE: {
5033      let swipeGesture: SwipeGestureHandler = gesture as SwipeGestureHandler;
5034      getUINativeModule().common.addSwipeGestureToGroup(nodePtr, swipeGesture.gestureTag, swipeGesture.allowedTypes,
5035        swipeGesture.fingers, swipeGesture.direction, swipeGesture.speed, swipeGesture.limitFingerCount,
5036        swipeGesture.onActionCallback, gestureGroupPtr);
5037      break;
5038    }
5039    case CommonGestureType.PINCH_GESTURE: {
5040      let pinchGesture: PinchGestureHandler = gesture as PinchGestureHandler;
5041      getUINativeModule().common.addPinchGestureToGroup(nodePtr, pinchGesture.gestureTag, pinchGesture.allowedTypes,
5042        pinchGesture.fingers, pinchGesture.distance, pinchGesture.limitFingerCount, pinchGesture.onActionStartCallback,
5043        pinchGesture.onActionUpdateCallback, pinchGesture.onActionEndCallback, pinchGesture.onActionCancelCallback, gestureGroupPtr);
5044      break;
5045    }
5046    case CommonGestureType.ROTATION_GESTURE: {
5047      let rotationGesture: RotationGestureHandler = gesture as RotationGestureHandler;
5048      getUINativeModule().common.addRotationGestureToGroup(nodePtr, rotationGesture.gestureTag, rotationGesture.allowedTypes,
5049        rotationGesture.fingers, rotationGesture.angle, rotationGesture.limitFingerCount,
5050        rotationGesture.onActionStartCallback, rotationGesture.onActionUpdateCallback,
5051        rotationGesture.onActionEndCallback, rotationGesture.onActionCancelCallback, gestureGroupPtr);
5052      break;
5053    }
5054    case CommonGestureType.GESTURE_GROUP: {
5055      let gestureGroup: GestureGroupHandler = gesture as GestureGroupHandler;
5056      let groupPtr = getUINativeModule().common.addGestureGroupToGroup(nodePtr, gestureGroup.gestureTag,
5057        gestureGroup.onCancelCallback, gestureGroup.mode, gestureGroupPtr);
5058      gestureGroup.gestures.forEach((item) => {
5059        addGestureToGroup(nodePtr, item, groupPtr);
5060      });
5061      break;
5062    }
5063    default:
5064      break;
5065  }
5066}
5067
5068function applyGesture(modifier: GestureModifier, component: ArkComponent): void {
5069
5070  if (modifier.applyGesture !== undefined) {
5071    let gestureEvent: UIGestureEvent = component.getOrCreateGestureEvent();
5072    gestureEvent.clearGestures();
5073    modifier.applyGesture(gestureEvent);
5074  }
5075}
5076
5077globalThis.__mapOfModifier__ = new Map();
5078function __gestureModifier__(modifier) {
5079  const elmtId = ViewStackProcessor.GetElmtIdToAccountFor();
5080  let nativeNode = getUINativeModule().getFrameNodeById(elmtId);
5081  if (globalThis.__mapOfModifier__.get(elmtId)) {
5082    let component = globalThis.__mapOfModifier__.get(elmtId);
5083    applyGesture(modifier, component);
5084  } else {
5085    let component = new ArkComponent(nativeNode);
5086    globalThis.__mapOfModifier__.set(elmtId, component);
5087    applyGesture(modifier, component);
5088  }
5089}
5090
5091const __elementIdToCustomProperties__ = new Map();
5092
5093function __setValidCustomProperty__(nodeId: number, key: string, value: Object): void {
5094  if (!__elementIdToCustomProperties__.has(nodeId)) {
5095    __elementIdToCustomProperties__.set(nodeId, new Map());
5096  }
5097
5098  const customProperties = __elementIdToCustomProperties__.get(nodeId);
5099
5100  if (customProperties) {
5101    customProperties.set(key, value);
5102  }
5103}
5104
5105function __removeCustomProperty__(nodeId: number, key: string): boolean {
5106  if (__elementIdToCustomProperties__.has(nodeId)) {
5107    const customProperties = __elementIdToCustomProperties__.get(nodeId);
5108
5109    if (customProperties) {
5110      customProperties.delete(key);
5111      return customProperties.size > 0;
5112    }
5113  }
5114
5115  return false;
5116}
5117
5118function __removeCustomProperties__(nodeId: number): void {
5119  __elementIdToCustomProperties__.delete(nodeId);
5120}
5121
5122function __getCustomProperty__(nodeId: number, key: string): Object | undefined {
5123  if (__elementIdToCustomProperties__.has(nodeId)) {
5124    const customProperties = __elementIdToCustomProperties__.get(nodeId);
5125
5126    if (customProperties) {
5127      return customProperties.get(key);
5128    }
5129  }
5130
5131  return undefined;
5132}
5133
5134function __getCustomPropertyString__(nodeId: number, key: string): string | undefined {
5135  if (__elementIdToCustomProperties__.has(nodeId)) {
5136    const customProperties = __elementIdToCustomProperties__.get(nodeId);
5137
5138    if (customProperties) {
5139      return JSON.stringify(customProperties.get(key));
5140    }
5141  }
5142
5143  return undefined;
5144}
5145
5146function __setCustomProperty__(nodeId: number, key: string, value: Object): boolean {
5147  if (value !== undefined) {
5148    __setValidCustomProperty__(nodeId, key, value);
5149    return true;
5150  } else {
5151    return __removeCustomProperty__(nodeId, key);
5152  }
5153}
5154