• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2023-2025 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/// <reference path="../../state_mgmt/distRelease/stateMgmt.d.ts" />
16/// <reference path="../../state_mgmt/src/lib/common/ace_console.native.d.ts" />
17var LogTag;
18(function (LogTag) {
19    LogTag[LogTag["ARK_COMPONENT"] = 1] = "ARK_COMPONENT";
20})(LogTag || (LogTag = {}));
21class JSXNodeLogConsole {
22    static warn(...args) {
23        aceConsole.warn(LogTag.ARK_COMPONENT, ...args);
24    }
25}
26var NodeRenderType;
27(function (NodeRenderType) {
28    NodeRenderType[NodeRenderType["RENDER_TYPE_DISPLAY"] = 0] = "RENDER_TYPE_DISPLAY";
29    NodeRenderType[NodeRenderType["RENDER_TYPE_TEXTURE"] = 1] = "RENDER_TYPE_TEXTURE";
30})(NodeRenderType || (NodeRenderType = {}));
31class BaseNode extends ViewBuildNodeBase {
32    constructor(uiContext, options) {
33        super(false);
34        let baseNode = new __JSBaseNode__(options);
35        this.builderBaseNode_ = baseNode;
36        if (uiContext === undefined) {
37            throw Error('Node constructor error, param uiContext error');
38        }
39        else {
40            if (!(typeof uiContext === 'object') || !('instanceId_' in uiContext)) {
41                throw Error('Node constructor error, param uiContext is invalid');
42            }
43        }
44        this.instanceId_ = uiContext.instanceId_;
45    }
46    getInstanceId() {
47        return this.instanceId_;
48    }
49    updateInstance(uiContext) {
50        this.instanceId_ = uiContext.instanceId_;
51    }
52    create(builder, params, update, updateConfiguration, supportLazyBuild) {
53        return this.builderBaseNode_.create(builder.bind(this), params, update.bind(this), updateConfiguration.bind(this), supportLazyBuild, this);
54    }
55    finishUpdateFunc() {
56        return this.builderBaseNode_.finishUpdateFunc();
57    }
58    postTouchEvent(touchEvent) {
59        return this.builderBaseNode_.postTouchEvent(touchEvent);
60    }
61    postInputEvent(event) {
62        return this.builderBaseNode_.postInputEvent(event);
63    }
64    disposeNode() {
65        return this.builderBaseNode_.disposeNode();
66    }
67    updateStart() {
68        return this.builderBaseNode_.updateStart();
69    }
70    updateEnd() {
71        return this.builderBaseNode_.updateEnd();
72    }
73    onRecycleWithBindObject() {
74        return this.builderBaseNode_.onRecycleWithBindObject();
75    }
76    onReuseWithBindObject(object) {
77        return this.builderBaseNode_.onReuseWithBindObject(object);
78    }
79}
80/*
81 * Copyright (c) 2025 Huawei Device Co., Ltd.
82 * Licensed under the Apache License, Version 2.0 (the "License");
83 * you may not use this file except in compliance with the License.
84 * You may obtain a copy of the License at
85 *
86 *     http://www.apache.org/licenses/LICENSE-2.0
87 *
88 * Unless required by applicable law or agreed to in writing, software
89 * distributed under the License is distributed on an "AS IS" BASIS,
90 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
91 * See the License for the specific language governing permissions and
92 * limitations under the License.
93 */
94/// <reference path="../../state_mgmt/src/lib/common/ifelse_native.d.ts" />
95/// <reference path="../../state_mgmt/src/lib/puv2_common/puv2_viewstack_processor.d.ts" />
96class Disposable {
97    constructor() {
98        this.isDisposed_  = false;
99    }
100    dispose() {
101        this.isDisposed_  = true;
102    }
103    isDisposed() {
104        return this.isDisposed_ ;
105    }
106}
107class BuilderNode extends Disposable {
108    constructor(uiContext, options) {
109        super();
110        let jsBuilderNode = new JSBuilderNode(uiContext, options);
111        this._JSBuilderNode = jsBuilderNode;
112        let id = Symbol('BuilderRootFrameNode');
113        BuilderNodeFinalizationRegisterProxy.ElementIdToOwningBuilderNode_.set(id, jsBuilderNode);
114        BuilderNodeFinalizationRegisterProxy.register(this, { name: 'BuilderRootFrameNode', idOfNode: id });
115    }
116    update(params) {
117        this._JSBuilderNode.update(params);
118    }
119    build(builder, params, options) {
120        this._JSBuilderNode.build(builder, params, options);
121        this.nodePtr_ = this._JSBuilderNode.getNodePtr();
122    }
123    getNodePtr() {
124        return this._JSBuilderNode.getValidNodePtr();
125    }
126    getFrameNode() {
127        return this._JSBuilderNode.getFrameNode();
128    }
129    getFrameNodeWithoutCheck() {
130        return this._JSBuilderNode.getFrameNodeWithoutCheck();
131    }
132    postTouchEvent(touchEvent) {
133        __JSScopeUtil__.syncInstanceId(this._JSBuilderNode.getInstanceId());
134        let ret = this._JSBuilderNode.postTouchEvent(touchEvent);
135        __JSScopeUtil__.restoreInstanceId();
136        return ret;
137    }
138    postInputEvent(event) {
139        __JSScopeUtil__.syncInstanceId(this._JSBuilderNode.getInstanceId());
140        let ret = this._JSBuilderNode.postInputEvent(event);
141        __JSScopeUtil__.restoreInstanceId();
142        return ret;
143    }
144    dispose() {
145        super.dispose();
146        this._JSBuilderNode.dispose();
147    }
148    isDisposed() {
149        return super.isDisposed() && (this._JSBuilderNode?.isDisposed() ?? true);
150    }
151    reuse(param) {
152        this._JSBuilderNode.reuse(param);
153    }
154    recycle() {
155        this._JSBuilderNode.recycle();
156    }
157    updateConfiguration() {
158        this._JSBuilderNode.updateConfiguration();
159    }
160    onReuseWithBindObject(param) {
161        this._JSBuilderNode.onReuseWithBindObject(param);
162    }
163    onRecycleWithBindObject() {
164        this._JSBuilderNode.onRecycleWithBindObject();
165    }
166    inheritFreezeOptions(enable) {
167        this._JSBuilderNode.inheritFreezeOptions(enable);
168    }
169}
170class JSBuilderNode extends BaseNode {
171    constructor(uiContext, options) {
172        super(uiContext, options);
173        this.uiContext_ = uiContext;
174        this.updateFuncByElmtId = new UpdateFuncsByElmtId();
175        this._supportNestingBuilder = false;
176        this.disposable_ = new Disposable();
177        this.inheritFreeze = false;
178        this.allowFreezeWhenInactive = false;
179        this.parentallowFreeze = false;
180        this.isFreeze = false;
181        this.__parentViewOfBuildNode = undefined;
182        this.updateParams_ = null;
183        this.activeCount_ = 1;
184    }
185    findProvidePU__(providePropName) {
186        if (this.__enableBuilderNodeConsume__ && this.__parentViewOfBuildNode) {
187            return this.__parentViewOfBuildNode.findProvidePU__(providePropName);
188        }
189        return undefined;
190    }
191    reuse(param) {
192        this.updateStart();
193        try {
194            this.childrenWeakrefMap_.forEach((weakRefChild) => {
195                const child = weakRefChild.deref();
196                if (child) {
197                    if (child instanceof ViewPU) {
198                        child.aboutToReuseInternal(param);
199                    }
200                    else {
201                        // FIXME fix for mixed V2 - V3 Hierarchies
202                        throw new Error('aboutToReuseInternal: Recycle not implemented for ViewV2, yet');
203                    }
204                } // if child
205            });
206        }
207        catch (err) {
208            this.updateEnd();
209            throw err;
210        }
211        this.updateEnd();
212    }
213    recycle() {
214        this.childrenWeakrefMap_.forEach((weakRefChild) => {
215            const child = weakRefChild.deref();
216            if (child) {
217                if (child instanceof ViewPU) {
218                    child.aboutToRecycleInternal();
219                }
220                else {
221                    // FIXME fix for mixed V2 - V3 Hierarchies
222                    throw new Error('aboutToRecycleInternal: Recycle not yet implemented for ViewV2');
223                }
224            } // if child
225        });
226    }
227    onReuseWithBindObject(param) {
228        __JSScopeUtil__.syncInstanceId(this.instanceId_);
229        super.onReuseWithBindObject(param);
230        __JSScopeUtil__.restoreInstanceId();
231    }
232    onRecycleWithBindObject() {
233        __JSScopeUtil__.syncInstanceId(this.instanceId_);
234        super.onRecycleWithBindObject();
235        __JSScopeUtil__.restoreInstanceId();
236    }
237    inheritFreezeOptions(enable) {
238        this.inheritFreeze = enable;
239        if (enable) {
240            this.setAllowFreezeWhenInactive(this.getParentAllowFreeze());
241        } else {
242            this.setAllowFreezeWhenInactive(false);
243        }
244    }
245    getInheritFreeze() {
246        return this.inheritFreeze;
247    }
248    setAllowFreezeWhenInactive(enable) {
249        this.allowFreezeWhenInactive = enable;
250    }
251    getAllowFreezeWhenInactive() {
252        return this.allowFreezeWhenInactive;
253    }
254    setParentAllowFreeze(enable) {
255        this.parentallowFreeze = enable;
256    }
257    getParentAllowFreeze() {
258        return this.parentallowFreeze;
259    }
260    getIsFreeze() {
261        return this.isFreeze;
262    }
263    getCardId() {
264        return -1;
265    }
266    isObject(param) {
267        const typeName = Object.prototype.toString.call(param);
268        const objectName = `[object Object]`;
269        if (typeName === objectName) {
270            return true;
271        }
272        else {
273            return false;
274        }
275    }
276    buildWithNestingBuilder(builder, supportLazyBuild) {
277        if (this._supportNestingBuilder && this.isObject(this.params_)) {
278            this._proxyObjectParam = new Proxy(this.params_, {
279                set(target, property, val) {
280                    throw Error(`@Builder : Invalid attempt to set(write to) parameter '${property.toString()}' error!`);
281                },
282                get: (target, property, receiver) => { return this.params_?.[property]; }
283            });
284            this.nodePtr_ = super.create(builder.builder?.bind(this.bindedViewOfBuilderNode ? this.bindedViewOfBuilderNode : this), this._proxyObjectParam, this.updateNodeFromNative, this.updateConfiguration, supportLazyBuild);
285        }
286        else {
287            this.nodePtr_ = super.create(builder.builder?.bind(this.bindedViewOfBuilderNode ? this.bindedViewOfBuilderNode : this), this.params_, this.updateNodeFromNative, this.updateConfiguration, supportLazyBuild);
288        }
289    }
290    build(builder, params, options) {
291        __JSScopeUtil__.syncInstanceId(this.instanceId_);
292        this._supportNestingBuilder = options?.nestingBuilderSupported ? options.nestingBuilderSupported : false;
293        const supportLazyBuild = options?.lazyBuildSupported ? options.lazyBuildSupported : false;
294        this.bindedViewOfBuilderNode = options?.bindedViewOfBuilderNode;
295        this.__enableBuilderNodeConsume__ = (options?.enableProvideConsumeCrossing) ? (options?.enableProvideConsumeCrossing) : false;
296        this.params_ = params;
297        if (options?.localStorage instanceof LocalStorage) {
298            this.setShareLocalStorage(options.localStorage);
299        }
300        this.updateFuncByElmtId.clear();
301        if (this.bindedViewOfBuilderNode) {
302            globalThis.__viewPuStack__?.push(this.bindedViewOfBuilderNode);
303        }
304        this.buildWithNestingBuilder(builder, supportLazyBuild);
305        if (this.bindedViewOfBuilderNode) {
306            globalThis.__viewPuStack__?.pop();
307        }
308        this._nativeRef = getUINativeModule().nativeUtils.createNativeStrongRef(this.nodePtr_);
309        if (this.frameNode_ === undefined || this.frameNode_ === null) {
310            this.frameNode_ = new BuilderRootFrameNode(this.uiContext_);
311        }
312        this.frameNode_.setNodePtr(this._nativeRef, this.nodePtr_);
313        this.frameNode_.setRenderNode(this._nativeRef);
314        this.frameNode_.setBaseNode(this);
315        this.frameNode_.setBuilderNode(this);
316        let id = this.frameNode_.getUniqueId();
317        if (this.id_ && this.id_ !== id) {
318            this.__parentViewOfBuildNode?.removeChildBuilderNode(this.id_);
319        }
320        this.id_ = id;
321        this.__parentViewOfBuildNode?.addChildBuilderNode(this);
322        FrameNodeFinalizationRegisterProxy.rootFrameNodeIdToBuilderNode_.set(this.frameNode_.getUniqueId(), new WeakRef(this.frameNode_));
323        __JSScopeUtil__.restoreInstanceId();
324    }
325    update(param) {
326        if (this.isFreeze) {
327            this.updateParams_ = param;
328            return;
329        }
330        __JSScopeUtil__.syncInstanceId(this.instanceId_);
331        this.updateStart();
332        try {
333            this.purgeDeletedElmtIds();
334            this.params_ = param;
335            Array.from(this.updateFuncByElmtId.keys()).sort((a, b) => {
336                return (a < b) ? -1 : (a > b) ? 1 : 0;
337            }).forEach(elmtId => this.UpdateElement(elmtId));
338        }
339        catch (err) {
340            this.updateEnd();
341            throw err;
342        }
343        this.updateEnd();
344        __JSScopeUtil__.restoreInstanceId();
345    }
346    updateConfiguration() {
347        __JSScopeUtil__.syncInstanceId(this.instanceId_);
348        this.updateStart();
349        try {
350            this.purgeDeletedElmtIds();
351            Array.from(this.updateFuncByElmtId.keys()).sort((a, b) => {
352                return (a < b) ? -1 : (a > b) ? 1 : 0;
353            }).forEach(elmtId => this.UpdateElement(elmtId));
354            for (const child of this.childrenWeakrefMap_.values()) {
355                const childView = child.deref();
356                if (childView) {
357                    childView.forceCompleteRerender(true);
358                }
359            }
360            getUINativeModule().frameNode.updateConfiguration(this.getFrameNode()?.getNodePtr());
361        }
362        catch (err) {
363            this.updateEnd();
364            throw err;
365        }
366        this.updateEnd();
367        __JSScopeUtil__.restoreInstanceId();
368    }
369    UpdateElement(elmtId) {
370        // do not process an Element that has been marked to be deleted
371        const obj = this.updateFuncByElmtId.get(elmtId);
372        const updateFunc = (typeof obj === 'object') ? obj.getUpdateFunc() : null;
373        if (typeof updateFunc === 'function') {
374            updateFunc(elmtId, /* isFirstRender */ false);
375            this.finishUpdateFunc();
376        }
377    }
378    isBuilderNodeActive() {
379        return this.activeCount_ > 0;
380    }
381    setActiveInternal(active, isReuse = false) {
382        stateMgmtProfiler.begin('BuilderNode.setActive');
383        if (!isReuse) {
384            this.activeCount_ += active ? 1 : -1;
385            if (this.isBuilderNodeActive()) {
386                this.isFreeze = false;
387            } else {
388                this.isFreeze = this.allowFreezeWhenInactive;
389            }
390            if (this.isBuilderNodeActive() && this.updateParams_ !== null) {
391                this.update(this.updateParams_);
392                this.updateParams_ = null;
393            }
394        }
395        if (this.inheritFreeze) {
396            this.propagateToChildren(this.childrenWeakrefMap_, active, isReuse);
397            this.propagateToChildren(this.builderNodeWeakrefMap_, active, isReuse);
398        }
399        stateMgmtProfiler.end();
400    }
401    purgeDeleteElmtId(rmElmtId) {
402        const result = this.updateFuncByElmtId.delete(rmElmtId);
403        if (result) {
404            UINodeRegisterProxy.ElementIdToOwningViewPU_.delete(rmElmtId);
405        }
406        return result;
407    }
408    getFrameNode() {
409        if (this.frameNode_ !== undefined &&
410            this.frameNode_ !== null &&
411            this.frameNode_.getNodePtr() !== null) {
412            return this.frameNode_;
413        }
414        return null;
415    }
416    getFrameNodeWithoutCheck() {
417        return this.frameNode_;
418    }
419    observeComponentCreation(func) {
420        let elmId = ViewStackProcessor.AllocateNewElmetIdForNextComponent();
421        UINodeRegisterProxy.ElementIdToOwningViewPU_.set(elmId, new WeakRef(this));
422        try {
423            func(elmId, true);
424        }
425        catch (error) {
426            // avoid the incompatible change that move set function before updateFunc.
427            UINodeRegisterProxy.ElementIdToOwningViewPU_.delete(elmId);
428            throw error;
429        }
430    }
431    observeComponentCreation2(compilerAssignedUpdateFunc, classObject) {
432        const _componentName = classObject && 'name' in classObject ? Reflect.get(classObject, 'name') : 'unspecified UINode';
433        const _popFunc = classObject && 'pop' in classObject ? classObject.pop : () => { };
434        const updateFunc = (elmtId, isFirstRender) => {
435            __JSScopeUtil__.syncInstanceId(this.instanceId_);
436            ViewBuildNodeBase.arkThemeScopeManager?.onComponentCreateEnter(_componentName, elmtId, isFirstRender, this);
437            ViewStackProcessor.StartGetAccessRecordingFor(elmtId);
438            // if V2 @Observed/@Track used anywhere in the app (there is no more fine grained criteria),
439            // enable V2 object deep observation
440            // FIXME: A @Component should only use PU or V2 state, but ReactNative dynamic viewer uses both.
441            if (ConfigureStateMgmt.instance.needsV2Observe()) {
442                // FIXME: like in V2 setting bindId_ in ObserveV2 does not work with 'stacked'
443                // update + initial render calls, like in if and ForEach case, convert to stack as well
444                ObserveV2.getObserve().startRecordDependencies(this, elmtId, true);
445            }
446            if (this._supportNestingBuilder) {
447                compilerAssignedUpdateFunc(elmtId, isFirstRender);
448            }
449            else {
450                compilerAssignedUpdateFunc(elmtId, isFirstRender, this.params_);
451            }
452            if (!isFirstRender) {
453                _popFunc();
454            }
455            if (ConfigureStateMgmt.instance.needsV2Observe()) {
456                ObserveV2.getObserve().stopRecordDependencies();
457            }
458            ViewStackProcessor.StopGetAccessRecording();
459            ViewBuildNodeBase.arkThemeScopeManager?.onComponentCreateExit(elmtId);
460            __JSScopeUtil__.restoreInstanceId();
461        };
462        const elmtId = ViewStackProcessor.AllocateNewElmetIdForNextComponent();
463        // needs to move set before updateFunc.
464        // make sure the key and object value exist since it will add node in attributeModifier during updateFunc.
465        this.updateFuncByElmtId.set(elmtId, { updateFunc: updateFunc, classObject: classObject });
466        UINodeRegisterProxy.ElementIdToOwningViewPU_.set(elmtId, new WeakRef(this));
467        try {
468            updateFunc(elmtId, /* is first render */ true);
469        }
470        catch (error) {
471            // avoid the incompatible change that move set function before updateFunc.
472            this.updateFuncByElmtId.delete(elmtId);
473            UINodeRegisterProxy.ElementIdToOwningViewPU_.delete(elmtId);
474            throw error;
475        }
476    }
477    /**
478     Partial updates for ForEach.
479     * @param elmtId ID of element.
480     * @param itemArray Array of items for use of itemGenFunc.
481     * @param itemGenFunc Item generation function to generate new elements. If index parameter is
482     *                    given set itemGenFuncUsesIndex to true.
483     * @param idGenFunc   ID generation function to generate unique ID for each element. If index parameter is
484     *                    given set idGenFuncUsesIndex to true.
485     * @param itemGenFuncUsesIndex itemGenFunc optional index parameter is given or not.
486     * @param idGenFuncUsesIndex idGenFunc optional index parameter is given or not.
487     */
488    forEachUpdateFunction(elmtId, itemArray, itemGenFunc, idGenFunc, itemGenFuncUsesIndex = false, idGenFuncUsesIndex = false) {
489        if (itemArray === null || itemArray === undefined) {
490            return;
491        }
492        if (itemGenFunc === null || itemGenFunc === undefined) {
493            return;
494        }
495        if (idGenFunc === undefined) {
496            idGenFuncUsesIndex = true;
497            // catch possible error caused by Stringify and re-throw an Error with a meaningful (!) error message
498            idGenFunc = (item, index) => {
499                try {
500                    return `${index}__${JSON.stringify(item)}`;
501                }
502                catch (e) {
503                    throw new Error(` ForEach id ${elmtId}: use of default id generator function not possible on provided data structure. Need to specify id generator function (ForEach 3rd parameter). Application Error!`);
504                }
505            };
506        }
507        let diffIndexArray = []; // New indexes compared to old one.
508        let newIdArray = [];
509        let idDuplicates = [];
510        const arr = itemArray; // just to trigger a 'get' onto the array
511        // ID gen is with index.
512        if (idGenFuncUsesIndex) {
513            // Create array of new ids.
514            arr.forEach((item, indx) => {
515                newIdArray.push(idGenFunc(item, indx));
516            });
517        }
518        else {
519            // Create array of new ids.
520            arr.forEach((item, index) => {
521                newIdArray.push(`${itemGenFuncUsesIndex ? index + '_' : ''}` + idGenFunc(item));
522            });
523        }
524        // removedChildElmtIds will be filled with the elmtIds of all children and their children will be deleted in response to foreach change
525        let removedChildElmtIds = [];
526        // Set new array on C++ side.
527        // C++ returns array of indexes of newly added array items.
528        // these are indexes in new child list.
529        ForEach.setIdArray(elmtId, newIdArray, diffIndexArray, idDuplicates, removedChildElmtIds);
530        // Item gen is with index.
531        diffIndexArray.forEach((indx) => {
532            ForEach.createNewChildStart(newIdArray[indx], this);
533            if (itemGenFuncUsesIndex) {
534                itemGenFunc(arr[indx], indx);
535            }
536            else {
537                itemGenFunc(arr[indx]);
538            }
539            ForEach.createNewChildFinish(newIdArray[indx], this);
540        });
541        // un-registers the removed child elementIDs using proxy
542        UINodeRegisterProxy.unregisterRemovedElmtsFromViewPUs(removedChildElmtIds);
543        // purging these elmtIds from state mgmt will make sure no more update function on any deleted child will be executed
544        this.purgeDeletedElmtIds();
545    }
546    getNodePtr() {
547        return this.nodePtr_;
548    }
549    getValidNodePtr() {
550        return this._nativeRef?.getNativeHandle();
551    }
552    dispose() {
553        this.disposable_.dispose();
554        if (this.nodePtr_) {
555            getUINativeModule().frameNode.fireArkUIObjectLifecycleCallback(new WeakRef(this),
556                'BuilderNode', this.getFrameNode()?.getNodeType() || 'BuilderNode', this.nodePtr_);
557        }
558        this.frameNode_?.dispose();
559    }
560    isDisposed() {
561        return this.disposable_.isDisposed() && (this._nativeRef === undefined || this._nativeRef === null);
562    }
563    disposeNode() {
564        super.disposeNode();
565        this.nodePtr_ = null;
566        this._nativeRef = null;
567        this.frameNode_?.resetNodePtr();
568    }
569    updateInstance(uiContext) {
570        this.uiContext_ = uiContext;
571        this.instanceId_ = uiContext.instanceId_;
572        if (this.frameNode_ !== undefined && this.frameNode_ !== null) {
573            this.frameNode_.updateInstance(uiContext);
574        }
575    }
576    updateNodePtr(nodePtr) {
577        if (nodePtr != this.nodePtr_) {
578            this.dispose();
579            this.nodePtr_ = nodePtr;
580            this._nativeRef = getUINativeModule().nativeUtils.createNativeStrongRef(this.nodePtr_);
581            this.frameNode_.setNodePtr(this._nativeRef, this.nodePtr_);
582        }
583    }
584    updateInstanceId(instanceId) {
585        this.instanceId_ = instanceId;
586    }
587    updateNodeFromNative(instanceId, nodePtr) {
588        this.updateNodePtr(nodePtr);
589        this.updateInstanceId(instanceId);
590    }
591    observeRecycleComponentCreation(name, recycleUpdateFunc) {
592        throw new Error('custom component in @Builder used by BuilderNode does not support @Reusable');
593    }
594    ifElseBranchUpdateFunctionDirtyRetaken() { }
595    forceCompleteRerender(deep) { }
596    forceRerenderNode(elmtId) { }
597}
598/*
599 * Copyright (c) 2024 Huawei Device Co., Ltd.
600 * Licensed under the Apache License, Version 2.0 (the "License");
601 * you may not use this file except in compliance with the License.
602 * You may obtain a copy of the License at
603 *
604 *     http://www.apache.org/licenses/LICENSE-2.0
605 *
606 * Unless required by applicable law or agreed to in writing, software
607 * distributed under the License is distributed on an "AS IS" BASIS,
608 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
609 * See the License for the specific language governing permissions and
610 * limitations under the License.
611 */
612class NodeAdapter extends Disposable {
613    constructor() {
614        super();
615        this.nodeRefs_ = new Array();
616        this.count_ = 0;
617        this.nativeRef_ = getUINativeModule().nodeAdapter.createAdapter();
618        this.nativePtr_ = this.nativeRef_.getNativeHandle();
619        getUINativeModule().nodeAdapter.setCallbacks(this.nativePtr_, this, this.onAttachToNodePtr, this.onDetachFromNodePtr, this.onGetChildId !== undefined ? this.onGetChildId : undefined, this.onCreateChild !== undefined ? this.onCreateNewNodePtr : undefined, this.onDisposeChild !== undefined ? this.onDisposeNodePtr : undefined, this.onUpdateChild !== undefined ? this.onUpdateNodePtr : undefined);
620    }
621    getNodeType() {
622        return getUINativeModule().nodeAdapter.getNodeType(this.nativePtr_);
623    }
624    dispose() {
625        super.dispose();
626        if (this.nativePtr_) {
627            getUINativeModule().nodeAdapter.fireArkUIObjectLifecycleCallback(new WeakRef(this),
628                'NodeAdapter', this.getNodeType() || 'NodeAdapter', this.nativePtr_);
629        }
630        let hostNode = this.attachedNodeRef_.deref();
631        if (hostNode !== undefined) {
632            NodeAdapter.detachNodeAdapter(hostNode);
633        }
634        this.nativeRef_.dispose();
635        this.nativePtr_ = null;
636    }
637    isDisposed() {
638        return super.isDisposed() && (this.nativePtr_ === undefined || this.nativePtr_ === null);
639    }
640    set totalNodeCount(count) {
641        if (count < 0) {
642            return;
643        }
644        getUINativeModule().nodeAdapter.setTotalNodeCount(this.nativePtr_, count);
645        this.count_ = count;
646    }
647    get totalNodeCount() {
648        return this.count_;
649    }
650    reloadAllItems() {
651        getUINativeModule().nodeAdapter.notifyItemReloaded(this.nativePtr_);
652    }
653    reloadItem(start, count) {
654        if (start < 0 || count < 0) {
655            return;
656        }
657        getUINativeModule().nodeAdapter.notifyItemChanged(this.nativePtr_, start, count);
658    }
659    removeItem(start, count) {
660        if (start < 0 || count < 0) {
661            return;
662        }
663        getUINativeModule().nodeAdapter.notifyItemRemoved(this.nativePtr_, start, count);
664    }
665    insertItem(start, count) {
666        if (start < 0 || count < 0) {
667            return;
668        }
669        getUINativeModule().nodeAdapter.notifyItemInserted(this.nativePtr_, start, count);
670    }
671    moveItem(from, to) {
672        if (from < 0 || to < 0) {
673            return;
674        }
675        getUINativeModule().nodeAdapter.notifyItemMoved(this.nativePtr_, from, to);
676    }
677    getAllAvailableItems() {
678        let result = new Array();
679        let nodes = getUINativeModule().nodeAdapter.getAllItems(this.nativePtr_);
680        if (nodes !== undefined) {
681            nodes.forEach(node => {
682                let nodeId = node.nodeId;
683                if (FrameNodeFinalizationRegisterProxy.ElementIdToOwningFrameNode_.has(nodeId)) {
684                    let frameNode = FrameNodeFinalizationRegisterProxy.ElementIdToOwningFrameNode_.get(nodeId).deref();
685                    result.push(frameNode);
686                }
687            });
688        }
689        return result;
690    }
691    onAttachToNodePtr(target) {
692        let nodeId = target.nodeId;
693        if (FrameNodeFinalizationRegisterProxy.ElementIdToOwningFrameNode_.has(nodeId)) {
694            let frameNode = FrameNodeFinalizationRegisterProxy.ElementIdToOwningFrameNode_.get(nodeId).deref();
695            if (frameNode === undefined) {
696                return;
697            }
698            frameNode.setAdapterRef(this);
699            this.attachedNodeRef_ = new WeakRef(frameNode);
700            if (this.onAttachToNode !== undefined) {
701                this.onAttachToNode(frameNode);
702            }
703        }
704    }
705    onDetachFromNodePtr() {
706        if (this === undefined) {
707            return;
708        }
709        if (this.onDetachFromNode !== undefined) {
710            this.onDetachFromNode();
711        }
712        let attachedNode = this.attachedNodeRef_.deref();
713        if (attachedNode !== undefined) {
714            attachedNode.setAdapterRef(undefined);
715        }
716        this.nodeRefs_.splice(0, this.nodeRefs_.length);
717    }
718    onCreateNewNodePtr(index) {
719        if (this.onCreateChild !== undefined) {
720            let node = this.onCreateChild(index);
721            if (!this.nodeRefs_.includes(node)) {
722                this.nodeRefs_.push(node);
723            }
724            return node.getNodePtr();
725        }
726        return null;
727    }
728    onDisposeNodePtr(id, node) {
729        let nodeId = node.nodeId;
730        if (FrameNodeFinalizationRegisterProxy.ElementIdToOwningFrameNode_.has(nodeId)) {
731            let frameNode = FrameNodeFinalizationRegisterProxy.ElementIdToOwningFrameNode_.get(nodeId).deref();
732            if (this.onDisposeChild !== undefined && frameNode !== undefined) {
733                this.onDisposeChild(id, frameNode);
734                let index = this.nodeRefs_.indexOf(frameNode);
735                if (index > -1) {
736                    this.nodeRefs_.splice(index, 1);
737                }
738            }
739        }
740    }
741    onUpdateNodePtr(id, node) {
742        let nodeId = node.nodeId;
743        if (FrameNodeFinalizationRegisterProxy.ElementIdToOwningFrameNode_.has(nodeId)) {
744            let frameNode = FrameNodeFinalizationRegisterProxy.ElementIdToOwningFrameNode_.get(nodeId).deref();
745            if (this.onUpdateChild !== undefined && frameNode !== undefined) {
746                this.onUpdateChild(id, frameNode);
747            }
748        }
749    }
750    static attachNodeAdapter(adapter, node) {
751        if (node === null || node === undefined) {
752            return false;
753        }
754        if (!node.isModifiable()) {
755            return false;
756        }
757        const hasAttributeProperty = Object.prototype.hasOwnProperty.call(node, 'attribute_');
758        if (hasAttributeProperty) {
759            let frameeNode = node;
760            if (frameeNode.attribute_.allowChildCount !== undefined) {
761                const allowCount = frameeNode.attribute_.allowChildCount();
762                if (allowCount <= 1) {
763                    return false;
764                }
765            }
766        }
767        return getUINativeModule().nodeAdapter.attachNodeAdapter(adapter.nativePtr_, node.getNodePtr());
768    }
769    static detachNodeAdapter(node) {
770        if (node === null || node === undefined) {
771            return;
772        }
773        getUINativeModule().nodeAdapter.detachNodeAdapter(node.getNodePtr());
774    }
775}
776/*
777 * Copyright (c) 2024 Huawei Device Co., Ltd.
778 * Licensed under the Apache License, Version 2.0 (the "License");
779 * you may not use this file except in compliance with the License.
780 * You may obtain a copy of the License at
781 *
782 *     http://www.apache.org/licenses/LICENSE-2.0
783 *
784 * Unless required by applicable law or agreed to in writing, software
785 * distributed under the License is distributed on an "AS IS" BASIS,
786 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
787 * See the License for the specific language governing permissions and
788 * limitations under the License.
789 */
790class BuilderNodeFinalizationRegisterProxy {
791    constructor() {
792        this.finalizationRegistry_ = new FinalizationRegistry((heldValue) => {
793            if (heldValue.name === 'BuilderRootFrameNode') {
794                const builderNode = BuilderNodeFinalizationRegisterProxy.ElementIdToOwningBuilderNode_.get(heldValue.idOfNode);
795                BuilderNodeFinalizationRegisterProxy.ElementIdToOwningBuilderNode_.delete(heldValue.idOfNode);
796                builderNode.dispose();
797            }
798        });
799    }
800    static register(target, heldValue) {
801        BuilderNodeFinalizationRegisterProxy.instance_.finalizationRegistry_.register(target, heldValue);
802    }
803}
804BuilderNodeFinalizationRegisterProxy.instance_ = new BuilderNodeFinalizationRegisterProxy();
805BuilderNodeFinalizationRegisterProxy.ElementIdToOwningBuilderNode_ = new Map();
806class FrameNodeFinalizationRegisterProxy {
807    constructor() {
808        this.finalizationRegistry_ = new FinalizationRegistry((heldValue) => {
809            if (!FrameNodeFinalizationRegisterProxy.ElementIdToOwningFrameNode_.get(heldValue)?.deref()) {
810                FrameNodeFinalizationRegisterProxy.ElementIdToOwningFrameNode_.delete(heldValue);
811            }
812            FrameNodeFinalizationRegisterProxy.rootFrameNodeIdToBuilderNode_.delete(heldValue);
813        });
814    }
815    static register(target, heldValue) {
816        FrameNodeFinalizationRegisterProxy.instance_.finalizationRegistry_.register(target, heldValue);
817    }
818}
819FrameNodeFinalizationRegisterProxy.instance_ = new FrameNodeFinalizationRegisterProxy();
820FrameNodeFinalizationRegisterProxy.ElementIdToOwningFrameNode_ = new Map();
821FrameNodeFinalizationRegisterProxy.FrameNodeInMainTree_ = new Map();
822FrameNodeFinalizationRegisterProxy.rootFrameNodeIdToBuilderNode_ = new Map();
823class NodeControllerRegisterProxy {
824}
825NodeControllerRegisterProxy.instance_ = new NodeControllerRegisterProxy();
826NodeControllerRegisterProxy.__NodeControllerMap__ = new Map();
827globalThis.__AddToNodeControllerMap__ = function __AddToNodeControllerMap__(containerId, nodeController) {
828    NodeControllerRegisterProxy.__NodeControllerMap__.set(containerId, nodeController);
829};
830globalThis.__RemoveFromNodeControllerMap__ = function __RemoveFromNodeControllerMap__(containerId) {
831    let nodeController = NodeControllerRegisterProxy.__NodeControllerMap__.get(containerId);
832    if (nodeController) {
833        nodeController._nodeContainerId.__rootNodeOfNodeController__ = undefined;
834        nodeController._nodeContainerId._value = -1;
835        NodeControllerRegisterProxy.__NodeControllerMap__.delete(containerId);
836    }
837};
838globalThis.__viewPuStack__ = new Array();
839globalThis.__CheckIsInBuilderNode__ = function __CheckIsInBuilderNode__(parent) {
840    if (globalThis.__viewPuStack__ === undefined || globalThis.__viewPuStack__.length === 0) {
841        return false;
842    }
843    const _BuilderNodeView = globalThis.__viewPuStack__?.pop();
844    if (_BuilderNodeView) {
845        globalThis.__viewPuStack__?.push(_BuilderNodeView);
846    }
847    return (_BuilderNodeView !== undefined && _BuilderNodeView === parent) ? true : false;
848};
849/*
850 * Copyright (c) 2023 Huawei Device Co., Ltd.
851 * Licensed under the Apache License, Version 2.0 (the "License");
852 * you may not use this file except in compliance with the License.
853 * You may obtain a copy of the License at
854 *
855 *     http://www.apache.org/licenses/LICENSE-2.0
856 *
857 * Unless required by applicable law or agreed to in writing, software
858 * distributed under the License is distributed on an "AS IS" BASIS,
859 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
860 * See the License for the specific language governing permissions and
861 * limitations under the License.
862 */
863class __InternalField__ {
864    constructor() {
865        this._value = -1;
866    }
867}
868class NodeController {
869    constructor() {
870        this._nodeContainerId = new __InternalField__();
871    }
872    __makeNode__(UIContext) {
873        this._nodeContainerId.__rootNodeOfNodeController__ = this.makeNode(UIContext);
874        return this._nodeContainerId.__rootNodeOfNodeController__;
875    }
876    rebuild() {
877        if (this._nodeContainerId !== undefined && this._nodeContainerId !== null && this._nodeContainerId._value >= 0) {
878            getUINativeModule().nodeContainer.rebuild(this._nodeContainerId._value);
879        }
880    }
881}
882/*
883 * Copyright (c) 2023-2024 Huawei Device Co., Ltd.
884 * Licensed under the Apache License, Version 2.0 (the "License");
885 * you may not use this file except in compliance with the License.
886 * You may obtain a copy of the License at
887 *
888 *     http://www.apache.org/licenses/LICENSE-2.0
889 *
890 * Unless required by applicable law or agreed to in writing, software
891 * distributed under the License is distributed on an "AS IS" BASIS,
892 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
893 * See the License for the specific language governing permissions and
894 * limitations under the License.
895 */
896var ExpandMode;
897(function (ExpandMode) {
898    ExpandMode[ExpandMode["NOT_EXPAND"] = 0] = "NOT_EXPAND";
899    ExpandMode[ExpandMode["EXPAND"] = 1] = "EXPAND";
900    ExpandMode[ExpandMode["LAZY_EXPAND"] = 2] = "LAZY_EXPAND";
901})(ExpandMode || (ExpandMode = {}));
902
903var UIState;
904(function (UIState) {
905    UIState[UIState["NORMAL"] = 0] = "NORMAL";
906    UIState[UIState["PRESSED"] = 1 << 0] = "PRESSED";
907    UIState[UIState["FOCUSED"] = 1 << 1] = "FOCUSED";
908    UIState[UIState["DISABLED"] = 1 << 2] = "DISABLED";
909    UIState[UIState["SELECTED"] = 1 << 3] = "SELECTED";
910})(UIState || (UIState = {}));
911class FrameNode extends Disposable {
912    constructor(uiContext, type, options) {
913        super();
914        if (uiContext === undefined) {
915            throw Error('Node constructor error, param uiContext error');
916        }
917        else {
918            if (!(typeof uiContext === "object") || !("instanceId_" in uiContext)) {
919                throw Error('Node constructor error, param uiContext is invalid');
920            }
921        }
922        this.instanceId_ = uiContext.instanceId_;
923        this.uiContext_ = uiContext;
924        this._nodeId = -1;
925        this._childList = new Map();
926        if (type === 'BuilderRootFrameNode') {
927            this.renderNode_ = new RenderNode(type);
928            this.renderNode_.setFrameNode(new WeakRef(this));
929            return;
930        }
931        if (type === 'ProxyFrameNode') {
932            return;
933        }
934        let result;
935        __JSScopeUtil__.syncInstanceId(this.instanceId_);
936        if (type === undefined || type === "CustomFrameNode") {
937            this.renderNode_ = new RenderNode('CustomFrameNode');
938            result = getUINativeModule().frameNode.createFrameNode(this);
939        }
940        else {
941            result = getUINativeModule().frameNode.createTypedFrameNode(this, type, options);
942        }
943        __JSScopeUtil__.restoreInstanceId();
944        this._nativeRef = result?.nativeStrongRef;
945        this._nodeId = result?.nodeId;
946        this.nodePtr_ = this._nativeRef?.getNativeHandle();
947        this.renderNode_?.setNodePtr(result?.nativeStrongRef);
948        this.renderNode_?.setFrameNode(new WeakRef(this));
949        if (result === undefined || this._nodeId === -1) {
950            return;
951        }
952        FrameNodeFinalizationRegisterProxy.ElementIdToOwningFrameNode_.set(this._nodeId, new WeakRef(this));
953        FrameNodeFinalizationRegisterProxy.register(this, this._nodeId);
954    }
955    invalidate() {
956        if (this.nodePtr_ === undefined || this.nodePtr_ === null) {
957            return;
958        }
959        getUINativeModule().frameNode.invalidate(this.nodePtr_);
960    }
961    getType() {
962        return 'CustomFrameNode';
963    }
964    setRenderNode(nativeRef) {
965        this.renderNode_?.setNodePtr(nativeRef);
966    }
967    getRenderNode() {
968        if (this.renderNode_ !== undefined &&
969            this.renderNode_ !== null &&
970            this.renderNode_.getNodePtr() !== null) {
971            return this.renderNode_;
972        }
973        return null;
974    }
975    setNodePtr(nativeRef, nodePtr) {
976        FrameNodeFinalizationRegisterProxy.ElementIdToOwningFrameNode_.delete(this._nodeId);
977        this._nativeRef = nativeRef;
978        this.nodePtr_ = nodePtr ? nodePtr : this._nativeRef?.getNativeHandle();
979        __JSScopeUtil__.syncInstanceId(this.instanceId_);
980        this._nodeId = getUINativeModule().frameNode.getIdByNodePtr(this.nodePtr_);
981        __JSScopeUtil__.restoreInstanceId();
982        if (this._nodeId === -1) {
983            return;
984        }
985        FrameNodeFinalizationRegisterProxy.ElementIdToOwningFrameNode_.set(this._nodeId, new WeakRef(this));
986        FrameNodeFinalizationRegisterProxy.register(this, this._nodeId);
987    }
988    resetNodePtr() {
989        FrameNodeFinalizationRegisterProxy.ElementIdToOwningFrameNode_.delete(this._nodeId);
990        this._nodeId = -1;
991        this._nativeRef = null;
992        this.nodePtr_ = null;
993        this.renderNode_?.resetNodePtr();
994    }
995    setBaseNode(baseNode) {
996        this.baseNode_ = baseNode;
997        this.renderNode_?.setBaseNode(baseNode);
998    }
999    setBuilderNode(builderNode) {
1000        this.builderNode_ = builderNode;
1001    }
1002    getBuilderNode() {
1003        return this.builderNode_ || null;
1004    }
1005    setAdapterRef(adapter) {
1006        this.nodeAdapterRef_ = adapter;
1007    }
1008    getNodePtr() {
1009        return this.nodePtr_;
1010    }
1011    getValidNodePtr() {
1012        const node = this.getNodePtr();
1013        if (node === null) {
1014            throw Error('The FrameNode has been disposed!');
1015        } else {
1016            return node;
1017        }
1018    }
1019    dispose() {
1020        super.dispose();
1021        if (this.nodePtr_) {
1022            getUINativeModule().frameNode.fireArkUIObjectLifecycleCallback(new WeakRef(this),
1023                'FrameNode', this.getNodeType() || 'FrameNode', this.nodePtr_);
1024        }
1025        this.renderNode_?.dispose();
1026        FrameNodeFinalizationRegisterProxy.ElementIdToOwningFrameNode_.delete(this._nodeId);
1027        this._nodeId = -1;
1028        this._nativeRef = null;
1029        this.nodePtr_ = null;
1030    }
1031    isDisposed() {
1032        return super.isDisposed() && (this._nativeRef === undefined || this._nativeRef === null || this._nativeRef.invalid());
1033    }
1034    static disposeTreeRecursively(node) {
1035        if (node === null) {
1036            return;
1037        }
1038        let child = node.getFirstChildWithoutExpand();
1039        FrameNode.disposeTreeRecursively(child);
1040        let sibling = node.getNextSiblingWithoutExpand();
1041        FrameNode.disposeTreeRecursively(sibling);
1042        node.dispose();
1043    }
1044    disposeTree() {
1045        let parent = this.getParent();
1046        if (parent?.getNodeType() === "NodeContainer") {
1047            getUINativeModule().nodeContainer.clean(parent?.getNodePtr());
1048        }
1049        else {
1050            parent?.removeChild(this);
1051        }
1052        FrameNode.disposeTreeRecursively(this);
1053    }
1054    checkType() {
1055        if (!this.isModifiable()) {
1056            throw { message: 'The FrameNode is not modifiable.', code: 100021 };
1057        }
1058    }
1059    isModifiable() {
1060        return this._nativeRef !== undefined && this._nativeRef !== null;
1061    }
1062    convertToFrameNode(nodePtr, nodeId = -1) {
1063        if (nodeId === -1) {
1064            __JSScopeUtil__.syncInstanceId(this.instanceId_);
1065            nodeId = getUINativeModule().frameNode.getIdByNodePtr(nodePtr);
1066            __JSScopeUtil__.restoreInstanceId();
1067        }
1068        if (FrameNodeFinalizationRegisterProxy.ElementIdToOwningFrameNode_.has(nodeId)) {
1069            let frameNode = FrameNodeFinalizationRegisterProxy.ElementIdToOwningFrameNode_.get(nodeId).deref();
1070            if (frameNode) {
1071                return frameNode;
1072            }
1073        }
1074        if (nodeId !== -1 && !getUINativeModule().frameNode.isModifiable(nodePtr)) {
1075            __JSScopeUtil__.syncInstanceId(this.instanceId_);
1076            let frameNode = new ProxyFrameNode(this.uiContext_);
1077            let node = getUINativeModule().nativeUtils.createNativeWeakRef(nodePtr);
1078            __JSScopeUtil__.restoreInstanceId();
1079            frameNode.setNodePtr(node);
1080            frameNode._nodeId = nodeId;
1081            FrameNodeFinalizationRegisterProxy.ElementIdToOwningFrameNode_.set(frameNode._nodeId, new WeakRef(frameNode));
1082            FrameNodeFinalizationRegisterProxy.register(frameNode, frameNode._nodeId);
1083            return frameNode;
1084        }
1085        return null;
1086    }
1087    checkValid(node) {
1088        return true;
1089    }
1090    appendChild(node) {
1091        if (node === undefined || node === null) {
1092            return;
1093        }
1094        if (node.getType() === 'ProxyFrameNode' || !this.checkValid(node)) {
1095            throw { message: 'The FrameNode is not modifiable.', code: 100021 };
1096        }
1097        __JSScopeUtil__.syncInstanceId(this.instanceId_);
1098        let flag = getUINativeModule().frameNode.appendChild(this.nodePtr_, node.nodePtr_);
1099        getUINativeModule().frameNode.addBuilderNode(this.nodePtr_, node.nodePtr_);
1100        __JSScopeUtil__.restoreInstanceId();
1101        if (!flag) {
1102            throw { message: 'The FrameNode is not modifiable.', code: 100021 };
1103        }
1104        this._childList.set(node._nodeId, node);
1105    }
1106    addComponentContent(content) {
1107        if (content === undefined || content === null || content.getNodePtr() === null || content.getNodePtr() == undefined) {
1108            return;
1109        }
1110        if (!this.checkValid() || !this.isModifiable()) {
1111            throw { message: 'The FrameNode is not modifiable.', code: 100021 };
1112        }
1113        __JSScopeUtil__.syncInstanceId(this.instanceId_);
1114        let flag = getUINativeModule().frameNode.appendChild(this.nodePtr_, content.getNodeWithoutProxy());
1115        getUINativeModule().frameNode.addBuilderNode(this.nodePtr_, content.getNodePtr());
1116        __JSScopeUtil__.restoreInstanceId();
1117        if (!flag) {
1118            throw { message: 'The FrameNode is not modifiable.', code: 100021 };
1119        }
1120        else {
1121            content.setAttachedParent(new WeakRef(this));
1122        }
1123    }
1124    removeComponentContent(content) {
1125        if (content === undefined || content === null || content.getNodePtr() === null || content.getNodePtr() === undefined) {
1126            return;
1127        }
1128        __JSScopeUtil__.syncInstanceId(this.instanceId_);
1129        getUINativeModule().frameNode.removeBuilderNode(this.nodePtr_, content.getNodePtr());
1130        getUINativeModule().frameNode.removeChild(this.nodePtr_, content.getNodePtr());
1131        content.setAttachedParent(undefined);
1132        __JSScopeUtil__.restoreInstanceId();
1133    }
1134    insertChildAfter(child, sibling) {
1135        if (child === undefined || child === null) {
1136            return;
1137        }
1138        if (child.getType() === 'ProxyFrameNode' || !this.checkValid(child)) {
1139            throw { message: 'The FrameNode is not modifiable.', code: 100021 };
1140        }
1141        let flag = true;
1142        __JSScopeUtil__.syncInstanceId(this.instanceId_);
1143        if (sibling === undefined || sibling === null) {
1144            flag = getUINativeModule().frameNode.insertChildAfter(this.nodePtr_, child.nodePtr_, null);
1145        }
1146        else {
1147            flag = getUINativeModule().frameNode.insertChildAfter(this.nodePtr_, child.nodePtr_, sibling.getNodePtr());
1148        }
1149        getUINativeModule().frameNode.addBuilderNode(this.nodePtr_, child.nodePtr_);
1150        __JSScopeUtil__.restoreInstanceId();
1151        if (!flag) {
1152            throw { message: 'The FrameNode is not modifiable.', code: 100021 };
1153        }
1154        this._childList.set(child._nodeId, child);
1155    }
1156    removeChild(node) {
1157        if (node === undefined || node === null) {
1158            return;
1159        }
1160        __JSScopeUtil__.syncInstanceId(this.instanceId_);
1161        getUINativeModule().frameNode.removeBuilderNode(this.nodePtr_, node.nodePtr_);
1162        getUINativeModule().frameNode.removeChild(this.nodePtr_, node.nodePtr_);
1163        __JSScopeUtil__.restoreInstanceId();
1164        this._childList.delete(node._nodeId);
1165    }
1166    clearChildren() {
1167        __JSScopeUtil__.syncInstanceId(this.instanceId_);
1168        getUINativeModule().frameNode.clearBuilderNode(this.nodePtr_);
1169        getUINativeModule().frameNode.clearChildren(this.nodePtr_);
1170        __JSScopeUtil__.restoreInstanceId();
1171        this._childList.clear();
1172    }
1173    moveTo(targetParent, index) {
1174        if (targetParent === undefined || targetParent === null) {
1175            return;
1176        }
1177        if (index === undefined || index === null) {
1178            index = -1;
1179        }
1180        const oldParent = this.getParent();
1181        if (oldParent && !oldParent.isModifiable() || !targetParent.isModifiable() || !targetParent.checkValid(this)) {
1182            throw { message: 'The FrameNode is not modifiable.', code: 100021 };
1183        }
1184        __JSScopeUtil__.syncInstanceId(this.instanceId_);
1185        getUINativeModule().frameNode.moveTo(this.nodePtr_, targetParent.nodePtr_, index);
1186        __JSScopeUtil__.restoreInstanceId();
1187        if (oldParent) {
1188            oldParent._childList.delete(this._nodeId);
1189        }
1190        targetParent._childList.set(this._nodeId, this);
1191    }
1192    getChild(index, expandMode) {
1193        const result = getUINativeModule().frameNode.getChild(this.getNodePtr(), index, expandMode);
1194        const nodeId = result?.nodeId;
1195        if (nodeId === undefined || nodeId === -1) {
1196            return null;
1197        }
1198        return this.convertToFrameNode(result.nodePtr, result.nodeId);
1199    }
1200    getFirstChildIndexWithoutExpand() {
1201        return getUINativeModule().frameNode.getFirstChildIndexWithoutExpand(this.getNodePtr());
1202    }
1203    getLastChildIndexWithoutExpand() {
1204        return getUINativeModule().frameNode.getLastChildIndexWithoutExpand(this.getNodePtr());
1205    }
1206    getFirstChild(isExpanded) {
1207        const result = getUINativeModule().frameNode.getFirst(this.getNodePtr(), isExpanded);
1208        const nodeId = result?.nodeId;
1209        if (nodeId === undefined || nodeId === -1) {
1210            return null;
1211        }
1212        return this.convertToFrameNode(result.nodePtr, result.nodeId);
1213    }
1214    getFirstChildWithoutExpand() {
1215        const result = getUINativeModule().frameNode.getFirst(this.getNodePtr(), false);
1216        const nodeId = result?.nodeId;
1217        if (nodeId === undefined || nodeId === -1) {
1218            return null;
1219        }
1220        return this.convertToFrameNode(result.nodePtr, result.nodeId);
1221    }
1222    getNextSibling(isExpanded) {
1223        const result = getUINativeModule().frameNode.getNextSibling(this.getNodePtr(), isExpanded);
1224        const nodeId = result?.nodeId;
1225        if (nodeId === undefined || nodeId === -1) {
1226            return null;
1227        }
1228        return this.convertToFrameNode(result.nodePtr, result.nodeId);
1229    }
1230    getNextSiblingWithoutExpand() {
1231        const result = getUINativeModule().frameNode.getNextSibling(this.getNodePtr(), false);
1232        const nodeId = result?.nodeId;
1233        if (nodeId === undefined || nodeId === -1) {
1234            return null;
1235        }
1236        return this.convertToFrameNode(result.nodePtr, result.nodeId);
1237    }
1238    getPreviousSibling(isExpanded) {
1239        const result = getUINativeModule().frameNode.getPreviousSibling(this.getNodePtr(), isExpanded);
1240        const nodeId = result?.nodeId;
1241        if (nodeId === undefined || nodeId === -1) {
1242            return null;
1243        }
1244        return this.convertToFrameNode(result.nodePtr, result.nodeId);
1245    }
1246    getParent() {
1247        __JSScopeUtil__.syncInstanceId(this.instanceId_);
1248        const result = getUINativeModule().frameNode.getParent(this.getNodePtr());
1249        const nodeId = result?.nodeId;
1250        __JSScopeUtil__.restoreInstanceId();
1251        if (nodeId === undefined || nodeId === -1) {
1252            return null;
1253        }
1254        return this.convertToFrameNode(result.nodePtr, result.nodeId);
1255    }
1256    getChildrenCount(isExpanded) {
1257        __JSScopeUtil__.syncInstanceId(this.instanceId_);
1258        const childrenCount = getUINativeModule().frameNode.getChildrenCount(this.nodePtr_, isExpanded);
1259        __JSScopeUtil__.restoreInstanceId();
1260        return childrenCount;
1261    }
1262    getPositionToParent() {
1263        const position = getUINativeModule().frameNode.getPositionToParent(this.getNodePtr());
1264        return { x: position[0], y: position[1] };
1265    }
1266    getPositionToScreen() {
1267        const position = getUINativeModule().frameNode.getPositionToScreen(this.getNodePtr());
1268        return { x: position[0], y: position[1] };
1269    }
1270    getPositionToWindow() {
1271        const position = getUINativeModule().frameNode.getPositionToWindow(this.getNodePtr());
1272        return { x: position[0], y: position[1] };
1273    }
1274    getGlobalPositionOnDisplay() {
1275        const position = getUINativeModule().frameNode.getGlobalPositionOnDisplay(this.getNodePtr());
1276        return { x: position[0], y: position[1] };
1277    }
1278    getPositionToParentWithTransform() {
1279        const position = getUINativeModule().frameNode.getPositionToParentWithTransform(this.getNodePtr());
1280        return { x: position[0], y: position[1] };
1281    }
1282    getPositionToScreenWithTransform() {
1283        const position = getUINativeModule().frameNode.getPositionToScreenWithTransform(this.getNodePtr());
1284        return { x: position[0], y: position[1] };
1285    }
1286    getPositionToWindowWithTransform() {
1287        const position = getUINativeModule().frameNode.getPositionToWindowWithTransform(this.getNodePtr());
1288        return { x: position[0], y: position[1] };
1289    }
1290    getMeasuredSize() {
1291        const size = getUINativeModule().frameNode.getMeasuredSize(this.getValidNodePtr());
1292        return { width: size[0], height: size[1] };
1293    }
1294    getLayoutPosition() {
1295        const position = getUINativeModule().frameNode.getLayoutPosition(this.getValidNodePtr());
1296        return { x: position[0], y: position[1] };
1297    }
1298    getUserConfigBorderWidth() {
1299        const borderWidth = getUINativeModule().frameNode.getConfigBorderWidth(this.getNodePtr());
1300        return {
1301            top: new LengthMetrics(borderWidth[0], borderWidth[1]),
1302            right: new LengthMetrics(borderWidth[2], borderWidth[3]),
1303            bottom: new LengthMetrics(borderWidth[4], borderWidth[5]),
1304            left: new LengthMetrics(borderWidth[6], borderWidth[7])
1305        };
1306    }
1307    getUserConfigPadding() {
1308        const borderWidth = getUINativeModule().frameNode.getConfigPadding(this.getNodePtr());
1309        return {
1310            top: new LengthMetrics(borderWidth[0], borderWidth[1]),
1311            right: new LengthMetrics(borderWidth[2], borderWidth[3]),
1312            bottom: new LengthMetrics(borderWidth[4], borderWidth[5]),
1313            left: new LengthMetrics(borderWidth[6], borderWidth[7])
1314        };
1315    }
1316    getUserConfigMargin() {
1317        const margin = getUINativeModule().frameNode.getConfigMargin(this.getNodePtr());
1318        return {
1319            top: new LengthMetrics(margin[0], margin[1]),
1320            right: new LengthMetrics(margin[2], margin[3]),
1321            bottom: new LengthMetrics(margin[4], margin[5]),
1322            left: new LengthMetrics(margin[6], margin[7])
1323        };
1324    }
1325    getUserConfigSize() {
1326        const size = getUINativeModule().frameNode.getConfigSize(this.getNodePtr());
1327        return {
1328            width: new LengthMetrics(size[0], size[1]),
1329            height: new LengthMetrics(size[2], size[3])
1330        };
1331    }
1332    getId() {
1333        return getUINativeModule().frameNode.getId(this.getNodePtr());
1334    }
1335    getUniqueId() {
1336        return getUINativeModule().frameNode.getIdByNodePtr(this.getNodePtr());
1337    }
1338    getNodeType() {
1339        return getUINativeModule().frameNode.getNodeType(this.getNodePtr());
1340    }
1341    getOpacity() {
1342        return getUINativeModule().frameNode.getOpacity(this.getNodePtr());
1343    }
1344    isVisible() {
1345        return getUINativeModule().frameNode.isVisible(this.getNodePtr());
1346    }
1347    isClipToFrame() {
1348        return getUINativeModule().frameNode.isClipToFrame(this.getNodePtr());
1349    }
1350    isAttached() {
1351        return getUINativeModule().frameNode.isAttached(this.getNodePtr());
1352    }
1353    getInspectorInfo() {
1354        __JSScopeUtil__.syncInstanceId(this.instanceId_);
1355        const inspectorInfoStr = getUINativeModule().frameNode.getInspectorInfo(this.getNodePtr());
1356        __JSScopeUtil__.restoreInstanceId();
1357        const inspectorInfo = JSON.parse(inspectorInfoStr);
1358        return inspectorInfo;
1359    }
1360    getCustomProperty(key) {
1361        if (key === undefined) {
1362            return undefined;
1363        }
1364        let value = __getCustomProperty__(this._nodeId, key);
1365        if (value === undefined) {
1366            const valueStr = getUINativeModule().frameNode.getCustomPropertyCapiByKey(this.getNodePtr(), key);
1367            value = valueStr === undefined ? undefined : valueStr;
1368        }
1369        return value;
1370    }
1371    setMeasuredSize(size) {
1372        getUINativeModule().frameNode.setMeasuredSize(this.getNodePtr(), Math.max(size.width, 0), Math.max(size.height, 0));
1373    }
1374    setLayoutPosition(position) {
1375        getUINativeModule().frameNode.setLayoutPosition(this.getNodePtr(), position.x, position.y);
1376    }
1377    measure(constraint) {
1378        const minSize = constraint.minSize;
1379        const maxSize = constraint.maxSize;
1380        const percentReference = constraint.percentReference;
1381        __JSScopeUtil__.syncInstanceId(this.instanceId_);
1382        getUINativeModule().frameNode.measureNode(this.getNodePtr(), minSize.width, minSize.height, maxSize.width, maxSize.height, percentReference.width, percentReference.height);
1383        __JSScopeUtil__.restoreInstanceId();
1384    }
1385    layout(position) {
1386        __JSScopeUtil__.syncInstanceId(this.instanceId_);
1387        getUINativeModule().frameNode.layoutNode(this.getNodePtr(), position.x, position.y);
1388        __JSScopeUtil__.restoreInstanceId();
1389    }
1390    setNeedsLayout() {
1391        getUINativeModule().frameNode.setNeedsLayout(this.getNodePtr());
1392    }
1393    setCrossLanguageOptions(options) {
1394        if (!this.isModifiable()) {
1395            throw { message: 'The FrameNode cannot be set whether to support cross-language common attribute setting.', code: 100022 };
1396        }
1397        __JSScopeUtil__.syncInstanceId(this.instanceId_);
1398        const result = getUINativeModule().frameNode.setCrossLanguageOptions(this.getNodePtr(), options.attributeSetting ?? false);
1399        __JSScopeUtil__.restoreInstanceId();
1400        if (result !== 0) {
1401            throw { message: 'The FrameNode cannot be set whether to support cross-language common attribute setting.', code: 100022 };
1402        }
1403    }
1404    getCrossLanguageOptions() {
1405        __JSScopeUtil__.syncInstanceId(this.instanceId_);
1406        const attributeSetting = getUINativeModule().frameNode.getCrossLanguageOptions(this.getNodePtr());
1407        __JSScopeUtil__.restoreInstanceId();
1408        return { attributeSetting: attributeSetting ?? false };
1409    }
1410    checkIfCanCrossLanguageAttributeSetting() {
1411        return this.isModifiable() || getUINativeModule().frameNode.checkIfCanCrossLanguageAttributeSetting(this.getNodePtr());
1412    }
1413    getInteractionEventBindingInfo(eventType) {
1414        if (eventType === undefined || eventType === null) {
1415            return undefined;
1416        }
1417        __JSScopeUtil__.syncInstanceId(this.instanceId_);
1418        const eventBindingInfo = getUINativeModule().frameNode.getInteractionEventBindingInfo(this.getNodePtr(), eventType);
1419        __JSScopeUtil__.restoreInstanceId();
1420        if (!eventBindingInfo || (!eventBindingInfo.baseEventRegistered && !eventBindingInfo.nodeEventRegistered &&
1421            !eventBindingInfo.nativeEventRegistered && !eventBindingInfo.builtInEventRegistered)) {
1422            return undefined;
1423        }
1424        return {
1425            baseEventRegistered: eventBindingInfo.baseEventRegistered,
1426            nodeEventRegistered: eventBindingInfo.nodeEventRegistered,
1427            nativeEventRegistered: eventBindingInfo.nativeEventRegistered,
1428            builtInEventRegistered: eventBindingInfo.builtInEventRegistered,
1429        };
1430    }
1431    get commonAttribute() {
1432        if (this._commonAttribute === undefined) {
1433            this._commonAttribute = new ArkComponent(this.nodePtr_, ModifierType.FRAME_NODE);
1434        }
1435        this._commonAttribute.setNodePtr(this.nodePtr_);
1436        this._commonAttribute.setInstanceId((this.uiContext_ === undefined || this.uiContext_ === null) ? -1 : this.uiContext_.instanceId_);
1437        return this._commonAttribute;
1438    }
1439    get commonEvent() {
1440        let node = this.getNodePtr();
1441        if (this._commonEvent === undefined) {
1442            this._commonEvent = new UICommonEvent(node);
1443        }
1444        this._commonEvent.setNodePtr(node);
1445        this._commonEvent.setInstanceId((this.uiContext_ === undefined || this.uiContext_ === null) ? -1 : this.uiContext_.instanceId_);
1446        return this._commonEvent;
1447    }
1448    get gestureEvent() {
1449        if (this._gestureEvent === undefined) {
1450            this._gestureEvent = new UIGestureEvent();
1451            this._gestureEvent.setNodePtr(this.nodePtr_);
1452            let weakPtr = getUINativeModule().nativeUtils.createNativeWeakRef(this.nodePtr_);
1453            this._gestureEvent.setWeakNodePtr(weakPtr);
1454            __JSScopeUtil__.syncInstanceId(this.instanceId_);
1455            this._gestureEvent.registerFrameNodeDeletedCallback(this.nodePtr_);
1456            __JSScopeUtil__.restoreInstanceId();
1457        }
1458        return this._gestureEvent;
1459    }
1460    updateInstance(uiContext) {
1461        this.uiContext_ = uiContext;
1462        this.instanceId_ = uiContext.instanceId_;
1463    }
1464    createAnimation(property, startValue, endValue, param) {
1465        __JSScopeUtil__.syncInstanceId(this.instanceId_);
1466        let result = getUINativeModule().frameNode.createAnimation(this.getNodePtr(), property, startValue, endValue, param);
1467        __JSScopeUtil__.restoreInstanceId();
1468        return result;
1469    }
1470    cancelAnimations(properties) {
1471        __JSScopeUtil__.syncInstanceId(this.instanceId_);
1472        let result = getUINativeModule().frameNode.cancelAnimations(this.getNodePtr(), properties);
1473        __JSScopeUtil__.restoreInstanceId();
1474        return result;
1475    }
1476    getNodePropertyValue(property) {
1477        return getUINativeModule().frameNode.getNodePropertyValue(this.getNodePtr(), property);
1478    }
1479    triggerOnReuse() {
1480        getUINativeModule().frameNode.triggerOnReuse(this.getNodePtr());
1481    }
1482    triggerOnRecycle() {
1483        getUINativeModule().frameNode.triggerOnRecycle(this.getNodePtr());
1484    }
1485    reuse() {
1486        this.triggerOnReuse();
1487    }
1488    recycle() {
1489        this.triggerOnRecycle();
1490    }
1491    addSupportedUIStates(uistates, statesChangeHandler, excludeInner) {
1492        __JSScopeUtil__.syncInstanceId(this.instanceId_);
1493        getUINativeModule().frameNode.addSupportedStates(this.getNodePtr(), uistates, (currentUIStates) => {
1494            statesChangeHandler(this, currentUIStates);
1495        }, excludeInner);
1496        __JSScopeUtil__.restoreInstanceId();
1497    }
1498    removeSupportedUIStates(uiStates) {
1499        __JSScopeUtil__.syncInstanceId(this.instanceId_);
1500        getUINativeModule().frameNode.removeSupportedStates(this.getNodePtr(), uiStates);
1501        __JSScopeUtil__.restoreInstanceId();
1502    }
1503    invalidateAttributes() {
1504        if (this.nodePtr_ === undefined || this.nodePtr_ === null) {
1505            return;
1506        }
1507        getUINativeModule().frameNode.applyAttributesFinish(this.nodePtr_);
1508    }
1509}
1510class ImmutableFrameNode extends FrameNode {
1511    isModifiable() {
1512        return false;
1513    }
1514    invalidate() {
1515        return;
1516    }
1517    appendChild(node) {
1518        throw { message: 'The FrameNode is not modifiable.', code: 100021 };
1519    }
1520    insertChildAfter(child, sibling) {
1521        throw { message: 'The FrameNode is not modifiable.', code: 100021 };
1522    }
1523    removeChild(node) {
1524        throw { message: 'The FrameNode is not modifiable.', code: 100021 };
1525    }
1526    clearChildren() {
1527        throw { message: 'The FrameNode is not modifiable.', code: 100021 };
1528    }
1529    get commonAttribute() {
1530        if (this._commonAttribute === undefined) {
1531            this._commonAttribute = new ArkComponent(undefined, ModifierType.FRAME_NODE);
1532        }
1533        this._commonAttribute.setNodePtr(undefined);
1534        return this._commonAttribute;
1535    }
1536    createAnimation(property, startValue, endValue, param) {
1537        JSXNodeLogConsole.warn("can't create animation on unmodifiable frameNode");
1538        return false;
1539    }
1540    cancelAnimations(properties) {
1541        JSXNodeLogConsole.warn("can't cancel animation on unmodifiable frameNode");
1542        return false;
1543    }
1544}
1545class BuilderRootFrameNode extends ImmutableFrameNode {
1546    constructor(uiContext, type = 'BuilderRootFrameNode') {
1547        super(uiContext, type);
1548    }
1549    getType() {
1550        return 'BuilderRootFrameNode';
1551    }
1552}
1553class ProxyFrameNode extends ImmutableFrameNode {
1554    constructor(uiContext, type = 'ProxyFrameNode') {
1555        super(uiContext, type);
1556    }
1557    setNodePtr(nativeRef) {
1558        this._nativeRef = nativeRef;
1559        this.nodePtr_ = this._nativeRef.getNativeHandle();
1560    }
1561    getType() {
1562        return 'ProxyFrameNode';
1563    }
1564    getRenderNode() {
1565        return null;
1566    }
1567    getNodePtr() {
1568        if (this._nativeRef === undefined || this._nativeRef === null || this._nativeRef.invalid()) {
1569            return null;
1570        }
1571        return this.nodePtr_;
1572    }
1573    moveTo(targetParent, index) {
1574        throw { message: 'The FrameNode is not modifiable.', code: 100021 };
1575    }
1576}
1577class FrameNodeUtils {
1578    static searchNodeInRegisterProxy(nodePtr) {
1579        let nodeId = getUINativeModule().frameNode.getIdByNodePtr(nodePtr);
1580        if (nodeId === -1) {
1581            return null;
1582        }
1583        if (FrameNodeFinalizationRegisterProxy.ElementIdToOwningFrameNode_.has(nodeId)) {
1584            let frameNode = FrameNodeFinalizationRegisterProxy.ElementIdToOwningFrameNode_.get(nodeId).deref();
1585            return frameNode === undefined ? null : frameNode;
1586        }
1587        return null;
1588    }
1589    static createFrameNode(uiContext, nodePtr) {
1590        let nodeId = getUINativeModule().frameNode.getIdByNodePtr(nodePtr);
1591        if (nodeId !== -1 && !getUINativeModule().frameNode.isModifiable(nodePtr)) {
1592            let frameNode = new ProxyFrameNode(uiContext);
1593            let node = getUINativeModule().nativeUtils.createNativeWeakRef(nodePtr);
1594            frameNode.setNodePtr(node);
1595            frameNode._nodeId = nodeId;
1596            FrameNodeFinalizationRegisterProxy.ElementIdToOwningFrameNode_.set(nodeId, new WeakRef(frameNode));
1597            FrameNodeFinalizationRegisterProxy.register(frameNode, nodeId);
1598            return frameNode;
1599        }
1600        return null;
1601    }
1602}
1603class TypedFrameNode extends FrameNode {
1604    constructor(uiContext, type, attrCreator, options) {
1605        super(uiContext, type, options);
1606        this.attrCreator_ = attrCreator;
1607    }
1608    dispose() {
1609        this.isDisposed_ = true;
1610        if (this.nodePtr_) {
1611            getUINativeModule().frameNode.fireArkUIObjectLifecycleCallback(new WeakRef(this), 'FrameNode', this.getNodeType() || 'FrameNode', this.nodePtr_);
1612        }
1613        FrameNodeFinalizationRegisterProxy.ElementIdToOwningFrameNode_.delete(this._nodeId);
1614        this._nodeId = -1;
1615        this._nativeRef?.dispose();
1616        this._nativeRef = null;
1617        this.nodePtr_ = null;
1618    }
1619    initialize(...args) {
1620        return this.attribute.initialize(args);
1621    }
1622    get attribute() {
1623        if (this.attribute_ === undefined) {
1624            this.attribute_ = this.attrCreator_(this.nodePtr_, ModifierType.FRAME_NODE);
1625        }
1626        this.attribute_.setNodePtr(this.nodePtr_);
1627        this.attribute_.setInstanceId((this.uiContext_ === undefined || this.uiContext_ === null) ? -1 : this.uiContext_.instanceId_);
1628        return this.attribute_;
1629    }
1630    checkValid(node) {
1631        if (this.attribute_ === undefined) {
1632            this.attribute_ = this.attrCreator_(this.nodePtr_, ModifierType.FRAME_NODE);
1633        }
1634        if (this.attribute_.allowChildCount !== undefined) {
1635            const allowCount = this.attribute_.allowChildCount();
1636            if (this.getChildrenCount() >= allowCount) {
1637                return false;
1638            }
1639        }
1640        if (this.attribute_.allowChildTypes !== undefined && node !== undefined) {
1641            const childType = node.getNodeType();
1642            const allowTypes = this.attribute_.allowChildTypes();
1643            let isValid = false;
1644            allowTypes.forEach((nodeType) => {
1645                if (nodeType === childType) {
1646                    isValid = true;
1647                }
1648            });
1649            return isValid;
1650        }
1651        return true;
1652    }
1653}
1654const __creatorMap__ = new Map([
1655    ['Text', (context) => {
1656            return new TypedFrameNode(context, 'Text', (node, type) => {
1657                return new ArkTextComponent(node, type);
1658            });
1659        }],
1660    ['Column', (context) => {
1661            return new TypedFrameNode(context, 'Column', (node, type) => {
1662                return new ArkColumnComponent(node, type);
1663            });
1664        }],
1665    ['Row', (context) => {
1666            return new TypedFrameNode(context, 'Row', (node, type) => {
1667                return new ArkRowComponent(node, type);
1668            });
1669        }],
1670    ['Stack', (context) => {
1671            return new TypedFrameNode(context, 'Stack', (node, type) => {
1672                return new ArkStackComponent(node, type);
1673            });
1674        }],
1675    ['GridRow', (context) => {
1676            let node = new TypedFrameNode(context, 'GridRow', (node, type) => {
1677                return new ArkGridRowComponent(node, type);
1678            });
1679            node.initialize();
1680            return node;
1681        }],
1682    ['TextInput', (context) => {
1683            return new TypedFrameNode(context, 'TextInput', (node, type) => {
1684                return new ArkTextInputComponent(node, type);
1685            });
1686        }],
1687    ['GridCol', (context) => {
1688            let node = new TypedFrameNode(context, 'GridCol', (node, type) => {
1689                return new ArkGridColComponent(node, type);
1690            });
1691            node.initialize();
1692            return node;
1693        }],
1694    ['Blank', (context) => {
1695            return new TypedFrameNode(context, 'Blank', (node, type) => {
1696                return new ArkBlankComponent(node, type);
1697            });
1698        }],
1699    ['Image', (context) => {
1700            return new TypedFrameNode(context, 'Image', (node, type) => {
1701                return new ArkImageComponent(node, type);
1702            });
1703        }],
1704    ['Flex', (context) => {
1705            return new TypedFrameNode(context, 'Flex', (node, type) => {
1706                return new ArkFlexComponent(node, type);
1707            });
1708        }],
1709    ['Swiper', (context) => {
1710            return new TypedFrameNode(context, 'Swiper', (node, type) => {
1711                return new ArkSwiperComponent(node, type);
1712            });
1713        }],
1714    ['Progress', (context) => {
1715            return new TypedFrameNode(context, 'Progress', (node, type) => {
1716                return new ArkProgressComponent(node, type);
1717            });
1718        }],
1719    ['Scroll', (context) => {
1720            return new TypedFrameNode(context, 'Scroll', (node, type) => {
1721                return new ArkScrollComponent(node, type);
1722            });
1723        }],
1724    ['RelativeContainer', (context) => {
1725            return new TypedFrameNode(context, 'RelativeContainer', (node, type) => {
1726                return new ArkRelativeContainerComponent(node, type);
1727            });
1728        }],
1729    ['List', (context) => {
1730            return new TypedFrameNode(context, 'List', (node, type) => {
1731                return new ArkListComponent(node, type);
1732            });
1733        }],
1734    ['ListItem', (context) => {
1735            return new TypedFrameNode(context, 'ListItem', (node, type) => {
1736                return new ArkListItemComponent(node, type);
1737            });
1738        }],
1739    ['Divider', (context) => {
1740            return new TypedFrameNode(context, 'Divider', (node, type) => {
1741                return new ArkDividerComponent(node, type);
1742            });
1743        }],
1744    ['LoadingProgress', (context) => {
1745            return new TypedFrameNode(context, 'LoadingProgress', (node, type) => {
1746                return new ArkLoadingProgressComponent(node, type);
1747            });
1748        }],
1749    ['Search', (context) => {
1750            return new TypedFrameNode(context, 'Search', (node, type) => {
1751                return new ArkSearchComponent(node, type);
1752            });
1753        }],
1754    ['Button', (context) => {
1755            return new TypedFrameNode(context, 'Button', (node, type) => {
1756                return new ArkButtonComponent(node, type);
1757            });
1758        }],
1759    ['XComponent', (context, options) => {
1760            return new TypedFrameNode(context, 'XComponent', (node, type) => {
1761                return new ArkXComponentComponent(node, type);
1762            }, options);
1763        }],
1764    ['ListItemGroup', (context) => {
1765            return new TypedFrameNode(context, 'ListItemGroup', (node, type) => {
1766                return new ArkListItemGroupComponent(node, type);
1767            });
1768        }],
1769    ['WaterFlow', (context) => {
1770            return new TypedFrameNode(context, 'WaterFlow', (node, type) => {
1771                return new ArkWaterFlowComponent(node, type);
1772            });
1773        }],
1774    ['SymbolGlyph', (context) => {
1775            return new TypedFrameNode(context, 'SymbolGlyph', (node, type) => {
1776                return new ArkSymbolGlyphComponent(node, type);
1777            });
1778        }],
1779    ['FlowItem', (context) => {
1780            return new TypedFrameNode(context, 'FlowItem', (node, type) => {
1781                return new ArkFlowItemComponent(node, type);
1782            });
1783        }],
1784    ['QRCode', (context) => {
1785            return new TypedFrameNode(context, 'QRCode', (node, type) => {
1786                return new ArkQRCodeComponent(node, type);
1787            });
1788        }],
1789    ['Badge', (context) => {
1790            return new TypedFrameNode(context, 'Badge', (node, type) => {
1791                return new ArkBadgeComponent(node, type);
1792            });
1793        }],
1794    ['Grid', (context) => {
1795            return new TypedFrameNode(context, 'Grid', (node, type) => {
1796                return new ArkGridComponent(node, type);
1797            });
1798        }],
1799    ['GridItem', (context) => {
1800            return new TypedFrameNode(context, 'GridItem', (node, type) => {
1801                return new ArkGridItemComponent(node, type);
1802            });
1803        }],
1804    ['TextClock', (context) => {
1805            return new TypedFrameNode(context, 'TextClock', (node, type) => {
1806                return new ArkTextClockComponent(node, type);
1807            });
1808        }],
1809    ['TextTimer', (context) => {
1810            return new TypedFrameNode(context, 'TextTimer', (node, type) => {
1811                return new ArkTextTimerComponent(node, type);
1812            });
1813        }],
1814    ['Marquee', (context) => {
1815            return new TypedFrameNode(context, 'Marquee', (node, type) => {
1816                return new ArkMarqueeComponent(node, type);
1817            });
1818        }],
1819    ['TextArea', (context) => {
1820            return new TypedFrameNode(context, 'TextArea', (node, type) => {
1821                return new ArkTextAreaComponent(node, type);
1822            });
1823        }],
1824    ['Checkbox', (context) => {
1825            return new TypedFrameNode(context, 'Checkbox', (node, type) => {
1826                return new ArkCheckboxComponent(node, type);
1827            });
1828        }],
1829    ['CheckboxGroup', (context) => {
1830            return new TypedFrameNode(context, 'CheckboxGroup', (node, type) => {
1831                return new ArkCheckboxGroupComponent(node, type);
1832            });
1833        }],
1834    ['Radio', (context) => {
1835            return new TypedFrameNode(context, 'Radio', (node, type) => {
1836                return new ArkRadioComponent(node, type);
1837            });
1838        }],
1839    ['Rating', (context) => {
1840            return new TypedFrameNode(context, 'Rating', (node, type) => {
1841                return new ArkRatingComponent(node, type);
1842            });
1843        }],
1844    ['Slider', (context) => {
1845            return new TypedFrameNode(context, 'Slider', (node, type) => {
1846                return new ArkSliderComponent(node, type);
1847            });
1848        }],
1849    ['Select', (context) => {
1850            return new TypedFrameNode(context, 'Select', (node, type) => {
1851                return new ArkSelectComponent(node, type);
1852            });
1853        }],
1854    ['Toggle', (context, options) => {
1855            return new TypedFrameNode(context, 'Toggle', (node, type) => {
1856                return new ArkToggleComponent(node, type);
1857            }, options);
1858        }],
1859]);
1860const __attributeMap__ = new Map([
1861    ['Swiper', (node) => {
1862        if (node._componentAttribute) {
1863            return node._componentAttribute;
1864        }
1865        if (!node.getNodePtr()) {
1866            return undefined;
1867        }
1868        node._componentAttribute = new ArkSwiperComponent(node.getNodePtr(), ModifierType.FRAME_NODE);
1869        return node._componentAttribute;
1870    }],
1871    ['Scroll', (node) => {
1872        if (node._componentAttribute) {
1873            return node._componentAttribute;
1874        }
1875        if (!node.getNodePtr()) {
1876            return undefined;
1877        }
1878        node._componentAttribute = new ArkScrollComponent(node.getNodePtr(), ModifierType.FRAME_NODE);
1879        return node._componentAttribute;
1880    }],
1881    ['List', (node) => {
1882        if (node._componentAttribute) {
1883            return node._componentAttribute;
1884        }
1885        if (!node.getNodePtr()) {
1886            return undefined;
1887        }
1888        node._componentAttribute = new ArkListComponent(node.getNodePtr(), ModifierType.FRAME_NODE);
1889        return node._componentAttribute;
1890    }],
1891    ['ListItem', (node) => {
1892        if (node._componentAttribute) {
1893            return node._componentAttribute;
1894        }
1895        if (!node.getNodePtr()) {
1896            return undefined;
1897        }
1898        node._componentAttribute = new ArkListItemComponent(node.getNodePtr(), ModifierType.FRAME_NODE);
1899        return node._componentAttribute;
1900    }],
1901    ['ListItemGroup', (node) => {
1902        if (node._componentAttribute) {
1903            return node._componentAttribute;
1904        }
1905        if (!node.getNodePtr()) {
1906            return undefined;
1907        }
1908        node._componentAttribute = new ArkListItemGroupComponent(node.getNodePtr(), ModifierType.FRAME_NODE);
1909        return node._componentAttribute;
1910    }],
1911    ['WaterFlow', (node) => {
1912        if (node._componentAttribute) {
1913            return node._componentAttribute;
1914        }
1915        if (!node.getNodePtr()) {
1916            return undefined;
1917        }
1918        node._componentAttribute = new ArkWaterFlowComponent(node.getNodePtr(), ModifierType.FRAME_NODE);
1919        return node._componentAttribute;
1920    }],
1921    ['FlowItem', (node) => {
1922        if (node._componentAttribute) {
1923            return node._componentAttribute;
1924        }
1925        if (!node.getNodePtr()) {
1926            return undefined;
1927        }
1928        node._componentAttribute = new ArkFlowItemComponent(node.getNodePtr(), ModifierType.FRAME_NODE);
1929        return node._componentAttribute;
1930    }],
1931    ['Grid', (node) => {
1932        if (node._componentAttribute) {
1933            return node._componentAttribute;
1934        }
1935        if (!node.getNodePtr()) {
1936            return undefined;
1937        }
1938        node._componentAttribute = new ArkGridComponent(node.getNodePtr(), ModifierType.FRAME_NODE);
1939        return node._componentAttribute;
1940    }],
1941    ['GridItem', (node) => {
1942        if (node._componentAttribute) {
1943            return node._componentAttribute;
1944        }
1945        if (!node.getNodePtr()) {
1946            return undefined;
1947        }
1948        node._componentAttribute = new ArkGridItemComponent(node.getNodePtr(), ModifierType.FRAME_NODE);
1949        return node._componentAttribute;
1950    }],
1951    ['Text', (node) => {
1952        if (node._componentAttribute) {
1953            return node._componentAttribute;
1954        }
1955        if (!node.getNodePtr()) {
1956            return undefined;
1957        }
1958        node._componentAttribute = new ArkTextComponent(node.getNodePtr(), ModifierType.FRAME_NODE);
1959        return node._componentAttribute;
1960    }],
1961    ['TextInput', (node) => {
1962        if (node._componentAttribute) {
1963            return node._componentAttribute;
1964        }
1965        if (!node.getNodePtr()) {
1966            return undefined;
1967        }
1968        node._componentAttribute = new ArkTextInputComponent(node.getNodePtr(), ModifierType.FRAME_NODE);
1969        return node._componentAttribute;
1970    }],
1971    ['TextArea', (node) => {
1972        if (node._componentAttribute) {
1973            return node._componentAttribute;
1974        }
1975        if (!node.getNodePtr()) {
1976            return undefined;
1977        }
1978        node._componentAttribute = new ArkTextAreaComponent(node.getNodePtr(), ModifierType.FRAME_NODE);
1979        return node._componentAttribute;
1980    }],
1981    ['Button', (node) => {
1982        if (node._componentAttribute) {
1983            return node._componentAttribute;
1984        }
1985        if (!node.getNodePtr()) {
1986            return undefined;
1987        }
1988        node._componentAttribute = new ArkButtonComponent(node.getNodePtr(), ModifierType.FRAME_NODE);
1989        return node._componentAttribute;
1990    }],
1991    ['Checkbox', (node) => {
1992        if (node._componentAttribute) {
1993            return node._componentAttribute;
1994        }
1995        if (!node.getNodePtr()) {
1996            return undefined;
1997        }
1998        node._componentAttribute = new ArkCheckboxComponent(node.getNodePtr(), ModifierType.FRAME_NODE);
1999        return node._componentAttribute;
2000    }],
2001    ['Radio', (node) => {
2002        if (node._componentAttribute) {
2003            return node._componentAttribute;
2004        }
2005        if (!node.getNodePtr()) {
2006            return undefined;
2007        }
2008        node._componentAttribute = new ArkRadioComponent(node.getNodePtr(), ModifierType.FRAME_NODE);
2009        return node._componentAttribute;
2010    }],
2011    ['Slider', (node) => {
2012        if (node._componentAttribute) {
2013            return node._componentAttribute;
2014        }
2015        if (!node.getNodePtr()) {
2016            return undefined;
2017        }
2018        node._componentAttribute = new ArkSliderComponent(node.getNodePtr(), ModifierType.FRAME_NODE);
2019        return node._componentAttribute;
2020    }],
2021    ['Toggle', (node) => {
2022        if (node._componentAttribute) {
2023            return node._componentAttribute;
2024        }
2025        if (!node.getNodePtr()) {
2026            return undefined;
2027        }
2028        node._componentAttribute = new ArkToggleComponent(node.getNodePtr(), ModifierType.FRAME_NODE);
2029        return node._componentAttribute;
2030    }],
2031    ['Column', (node) => {
2032        if (node._componentAttribute) {
2033            return node._componentAttribute;
2034        }
2035        if (!node.getNodePtr()) {
2036            return undefined;
2037        }
2038        node._componentAttribute = new ArkColumnComponent(node.getNodePtr(), ModifierType.FRAME_NODE);
2039        return node._componentAttribute;
2040    }],
2041    ['Row', (node) => {
2042        if (node._componentAttribute) {
2043            return node._componentAttribute;
2044        }
2045        if (!node.getNodePtr()) {
2046            return undefined;
2047        }
2048        node._componentAttribute = new ArkRowComponent(node.getNodePtr(), ModifierType.FRAME_NODE);
2049        return node._componentAttribute;
2050    }],
2051    ['Stack', (node) => {
2052        if (node._componentAttribute) {
2053            return node._componentAttribute;
2054        }
2055        if (!node.getNodePtr()) {
2056            return undefined;
2057        }
2058        node._componentAttribute = new ArkStackComponent(node.getNodePtr(), ModifierType.FRAME_NODE);
2059        return node._componentAttribute;
2060    }],
2061    ['Flex', (node) => {
2062        if (node._componentAttribute) {
2063            return node._componentAttribute;
2064        }
2065        if (!node.getNodePtr()) {
2066            return undefined;
2067        }
2068        node._componentAttribute = new ArkFlexComponent(node.getNodePtr(), ModifierType.FRAME_NODE);
2069        return node._componentAttribute;
2070    }],
2071    ['RelativeContainer', (node) => {
2072        if (node._componentAttribute) {
2073            return node._componentAttribute;
2074        }
2075        if (!node.getNodePtr()) {
2076            return undefined;
2077        }
2078        node._componentAttribute = new ArkRelativeContainerComponent(node.getNodePtr(), ModifierType.FRAME_NODE);
2079        return node._componentAttribute;
2080    }],
2081    ['XComponent', (node) => {
2082        if (node._componentAttribute) {
2083            return node._componentAttribute;
2084        }
2085        if (!node.getNodePtr()) {
2086            return undefined;
2087        }
2088        node._componentAttribute = new ArkXComponentComponent(node.getNodePtr(), ModifierType.FRAME_NODE);
2089        return node._componentAttribute;
2090    }],
2091    ['Progress', (node) => {
2092        if (node._componentAttribute) {
2093            return node._componentAttribute;
2094        }
2095        if (!node.getNodePtr()) {
2096            return undefined;
2097        }
2098        node._componentAttribute = new ArkProgressComponent(node.getNodePtr(), ModifierType.FRAME_NODE);
2099        return node._componentAttribute;
2100    }],
2101    ['LoadingProgress', (node) => {
2102        if (node._componentAttribute) {
2103            return node._componentAttribute;
2104        }
2105        if (!node.getNodePtr()) {
2106            return undefined;
2107        }
2108        node._componentAttribute = new ArkLoadingProgressComponent(node.getNodePtr(), ModifierType.FRAME_NODE);
2109        return node._componentAttribute;
2110    }],
2111    ['Image', (node) => {
2112        if (node._componentAttribute) {
2113            return node._componentAttribute;
2114        }
2115        if (!node.getNodePtr()) {
2116            return undefined;
2117        }
2118        node._componentAttribute = new ArkImageComponent(node.getNodePtr(), ModifierType.FRAME_NODE);
2119        return node._componentAttribute;
2120    }]
2121]);
2122const __eventMap__ = new Map(
2123    [
2124      ['List', (node) => {
2125        if (node._scrollableEvent) {
2126          return node._scrollableEvent;
2127        }
2128        if (!node.getNodePtr()) {
2129           return undefined;
2130        }
2131        node._scrollableEvent = new UIListEvent(node.getNodePtr());
2132        node._scrollableEvent.setNodePtr(node.getNodePtr());
2133        node._scrollableEvent.setInstanceId((node.uiContext_ === undefined || node.uiContext_ === null) ? -1 : node.uiContext_.instanceId_);
2134        return node._scrollableEvent;
2135      }],
2136      ['Scroll', (node) => {
2137        if (node._scrollableEvent) {
2138          return node._scrollableEvent;
2139        }
2140        if (!node.getNodePtr()) {
2141           return undefined;
2142        }
2143        node._scrollableEvent = new UIScrollEvent(node.getNodePtr());
2144        node._scrollableEvent.setNodePtr(node.getNodePtr());
2145        node._scrollableEvent.setInstanceId((node.uiContext_ === undefined || node.uiContext_ === null) ? -1 : node.uiContext_.instanceId_);
2146        return node._scrollableEvent;
2147      }],
2148      ['Grid', (node) => {
2149        if (node._scrollableEvent) {
2150          return node._scrollableEvent;
2151        }
2152        if (!node.getNodePtr()) {
2153           return undefined;
2154        }
2155        node._scrollableEvent = new UIGridEvent(node.getNodePtr());
2156        node._scrollableEvent.setNodePtr(node.getNodePtr());
2157        node._scrollableEvent.setInstanceId((node.uiContext_ === undefined || node.uiContext_ === null) ? -1 : node.uiContext_.instanceId_);
2158        return node._scrollableEvent;
2159      }],
2160      ['WaterFlow', (node) => {
2161        if (node._scrollableEvent) {
2162          return node._scrollableEvent;
2163        }
2164        if (!node.getNodePtr()) {
2165           return undefined;
2166        }
2167        node._scrollableEvent = new UIWaterFlowEvent(node.getNodePtr());
2168        node._scrollableEvent.setNodePtr(node.getNodePtr());
2169        node._scrollableEvent.setInstanceId((node.uiContext_ === undefined || node.uiContext_ === null) ? -1 : node.uiContext_.instanceId_);
2170        return node._scrollableEvent;
2171      }]
2172    ]
2173  )
2174const __bindControllerCallbackMap__ = new Map(
2175    [
2176        ['Swiper', (node, controller) => {
2177            getUINativeModule().swiper.setSwiperInitialize(node.getNodePtr(), controller);
2178        }],
2179        ['Scroll', (node, controller) => {
2180            getUINativeModule().scroll.setScrollInitialize(node.getNodePtr(), controller);
2181        }],
2182        ['List', (node, controller) => {
2183            getUINativeModule().list.setInitialScroller(node.getNodePtr(), controller);
2184        }],
2185        ['WaterFlow', (node, controller) => {
2186            getUINativeModule().waterFlow.setWaterFlowScroller(node.getNodePtr(), controller);
2187        }],
2188        ['Grid', (node, controller) => {
2189            getUINativeModule().grid.setGridScroller(node.getNodePtr(), controller);
2190        }],
2191        ['Text', (node, controller) => {
2192            getUINativeModule().text.setTextController(node.getNodePtr(), { controller: controller });
2193        }],
2194        ['TextInput', (node, controller) => {
2195            getUINativeModule().textInput.setController(node.getNodePtr(), controller);
2196        }],
2197        ['TextArea', (node, controller) => {
2198            getUINativeModule().textArea.setController(node.getNodePtr(), controller);
2199        }]
2200    ]
2201)
2202class typeNode {
2203    static createNode(context, type, options) {
2204        let creator = __creatorMap__.get(type);
2205        if (creator === undefined) {
2206            return undefined;
2207        }
2208        return creator(context, options);
2209    }
2210    static getAttribute(node, nodeType) {
2211        if (node === undefined || node === null || node.getNodeType() !== nodeType) {
2212            return undefined;
2213        }
2214        if (!node.checkIfCanCrossLanguageAttributeSetting()) {
2215            return undefined;
2216        }
2217        let attribute = __attributeMap__.get(nodeType);
2218        if (attribute === undefined || attribute === null) {
2219            return undefined;
2220        }
2221        return attribute(node);
2222    }
2223    static getEvent(node, nodeType) {
2224        if (node === undefined || node === null || node.getNodeType() !== nodeType) {
2225            return undefined;
2226        }
2227        let event = __eventMap__.get(nodeType);
2228        if (event === undefined || event === null) {
2229            return undefined;
2230        }
2231        return event(node);
2232    }
2233    static bindController(node, controller, nodeType) {
2234        if (node === undefined || node === null || controller === undefined || controller === null ||
2235            node.getNodeType() !== nodeType || node.getNodePtr() === null || node.getNodePtr() === undefined) {
2236            if (nodeType === undefined || nodeType === null || nodeType === 'Scroll') {
2237                throw { message: 'Parameter error. Possible causes: 1. The type of the node is error; 2. The node is null or undefined.', code: 401 };
2238            } else {
2239                throw { message: 'Parameter error. Possible causes: 1. The component type of the node is incorrect. 2. The node is null or undefined. 3. The controller is null or undefined.', code: 100023 };
2240            }
2241        }
2242        if (!node.checkIfCanCrossLanguageAttributeSetting()) {
2243            throw { message: 'The FrameNode is not modifiable.', code: 100021 };
2244        }
2245        let callback = __bindControllerCallbackMap__.get(nodeType);
2246        if (callback === undefined || callback === null) {
2247            return;
2248        }
2249        callback(node, controller);
2250    }
2251}
2252/*
2253 * Copyright (c) 2023 Huawei Device Co., Ltd.
2254 * Licensed under the Apache License, Version 2.0 (the "License");
2255 * you may not use this file except in compliance with the License.
2256 * You may obtain a copy of the License at
2257 *
2258 *     http://www.apache.org/licenses/LICENSE-2.0
2259 *
2260 * Unless required by applicable law or agreed to in writing, software
2261 * distributed under the License is distributed on an "AS IS" BASIS,
2262 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2263 * See the License for the specific language governing permissions and
2264 * limitations under the License.
2265 */
2266var BorderStyle;
2267(function (BorderStyle) {
2268    BorderStyle[BorderStyle["SOLID"] = 0] = "SOLID";
2269    BorderStyle[BorderStyle["DASHED"] = 1] = "DASHED";
2270    BorderStyle[BorderStyle["DOTTED"] = 2] = "DOTTED";
2271    BorderStyle[BorderStyle["NONE"] = 3] = "NONE";
2272})(BorderStyle || (BorderStyle = {}));
2273var LengthUnit;
2274(function (LengthUnit) {
2275    LengthUnit[LengthUnit["PX"] = 0] = "PX";
2276    LengthUnit[LengthUnit["VP"] = 1] = "VP";
2277    LengthUnit[LengthUnit["FP"] = 2] = "FP";
2278    LengthUnit[LengthUnit["PERCENT"] = 3] = "PERCENT";
2279    LengthUnit[LengthUnit["LPX"] = 4] = "LPX";
2280})(LengthUnit || (LengthUnit = {}));
2281var LengthMetricsUnit;
2282(function (LengthMetricsUnit) {
2283    LengthMetricsUnit[LengthMetricsUnit["DEFAULT"] = 0] = "DEFAULT";
2284    LengthMetricsUnit[LengthMetricsUnit["PX"] = 1] = "PX";
2285})(LengthMetricsUnit || (LengthMetricsUnit = {}));
2286class LengthMetrics {
2287    constructor(value, unit, res) {
2288        if (unit in LengthUnit) {
2289            this.unit = unit;
2290            this.value = value;
2291        }
2292        else {
2293            this.unit = LengthUnit.VP;
2294            this.value = unit === undefined ? value : 0;
2295        }
2296        this.res = res === undefined ? undefined : res;
2297    }
2298    static px(value) {
2299        return new LengthMetrics(value, LengthUnit.PX);
2300    }
2301    static vp(value) {
2302        return new LengthMetrics(value, LengthUnit.VP);
2303    }
2304    static fp(value) {
2305        return new LengthMetrics(value, LengthUnit.FP);
2306    }
2307    static percent(value) {
2308        return new LengthMetrics(value, LengthUnit.PERCENT);
2309    }
2310    static lpx(value) {
2311        return new LengthMetrics(value, LengthUnit.LPX);
2312    }
2313    static resource(res) {
2314        let length = getUINativeModule().nativeUtils.resoureToLengthMetrics(res);
2315        return new LengthMetrics(length[0], length[1], res);
2316    }
2317}
2318const MAX_CHANNEL_VALUE = 0xFF;
2319const MAX_ALPHA_VALUE = 1;
2320const ERROR_CODE_RESOURCE_GET_FAILED = 180003;
2321const ERROR_CODE_COLOR_PARAMETER_INCORRECT = 401;
2322class ColorMetrics {
2323    constructor(red, green, blue, alpha = MAX_CHANNEL_VALUE, res) {
2324        this.red_ = ColorMetrics.clamp(red);
2325        this.green_ = ColorMetrics.clamp(green);
2326        this.blue_ = ColorMetrics.clamp(blue);
2327        this.alpha_ = ColorMetrics.clamp(alpha);
2328        this.res_ = res === undefined ? undefined : res;
2329    }
2330    static clamp(value) {
2331        return Math.min(Math.max(value, 0), MAX_CHANNEL_VALUE);
2332    }
2333    toNumeric() {
2334        return (this.alpha_ << 24) + (this.red_ << 16) + (this.green_ << 8) + this.blue_;
2335    }
2336    static numeric(value) {
2337        const red = (value >> 16) & 0x000000FF;
2338        const green = (value >> 8) & 0x000000FF;
2339        const blue = value & 0x000000FF;
2340        const alpha = (value >> 24) & 0x000000FF;
2341        if (alpha === 0) {
2342            return new ColorMetrics(red, green, blue);
2343        }
2344        return new ColorMetrics(red, green, blue, alpha);
2345    }
2346    static rgba(red, green, blue, alpha = MAX_ALPHA_VALUE) {
2347        return new ColorMetrics(red, green, blue, alpha * MAX_CHANNEL_VALUE);
2348    }
2349    static colorWithSpace(colorSpace, red, green, blue, alpha = MAX_ALPHA_VALUE) {
2350        let redInt = Math.round(red * MAX_CHANNEL_VALUE);
2351        let greenInt = Math.round(green * MAX_CHANNEL_VALUE);
2352        let blueInt = Math.round(blue * MAX_CHANNEL_VALUE);
2353        let alphaInt = Math.round(alpha * MAX_CHANNEL_VALUE);
2354        const colorMetrics = new ColorMetrics(redInt, greenInt, blueInt, alphaInt);
2355        colorMetrics.setColorSpace(colorSpace);
2356        return colorMetrics;
2357    }
2358    static rgbOrRGBA(format) {
2359        const rgbPattern = /^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/i;
2360        const rgbaPattern = /^rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+(\.\d+)?)\s*\)$/i;
2361        const rgbMatch = rgbPattern.exec(format);
2362        const rgbaMatch = rgbaPattern.exec(format);
2363        if (rgbMatch) {
2364            const [, red, green, blue] = rgbMatch;
2365            return new ColorMetrics(Number.parseInt(red, 10), Number.parseInt(green, 10), Number.parseInt(blue, 10));
2366        }
2367        else if (rgbaMatch) {
2368            const [, red, green, blue, alpha] = rgbaMatch;
2369            return new ColorMetrics(Number.parseInt(red, 10), Number.parseInt(green, 10), Number.parseInt(blue, 10), Number.parseFloat(alpha) * MAX_CHANNEL_VALUE);
2370        }
2371        else {
2372            const error = new Error('Parameter error. The format of the input color string is not RGB or RGBA.');
2373            error.code = ERROR_CODE_COLOR_PARAMETER_INCORRECT;
2374            throw error;
2375        }
2376    }
2377    static resourceColor(color) {
2378        if (color === undefined || color === null) {
2379            const error = new Error('Parameter error. The type of the input color parameter is not ResourceColor.');
2380            error.code = ERROR_CODE_COLOR_PARAMETER_INCORRECT;
2381            throw error;
2382        }
2383        let chanels = [];
2384        if (typeof color === 'object') {
2385            chanels = getUINativeModule().nativeUtils.parseResourceColor(color);
2386            if (chanels === undefined) {
2387                const error = new Error('Failed to obtain the color resource.');
2388                error.code = ERROR_CODE_RESOURCE_GET_FAILED;
2389                throw error;
2390            }
2391            const red = chanels[0];
2392            const green = chanels[1];
2393            const blue = chanels[2];
2394            const alpha = chanels[3];
2395            const resourceId = chanels[4];
2396            const colorMetrics = new ColorMetrics(red, green, blue, alpha, color);
2397            colorMetrics.setResourceId(resourceId);
2398            return colorMetrics;
2399        }
2400        else if (typeof color === 'number') {
2401            return ColorMetrics.numeric(color);
2402        }
2403        else if (typeof color === 'string') {
2404            if (ColorMetrics.isHexFormat(color)) {
2405                return ColorMetrics.hex(color);
2406            }
2407            else {
2408                return ColorMetrics.rgbOrRGBA(color);
2409            }
2410        }
2411        else {
2412            const error = new Error('Parameter error. The type of the input color parameter is not ResourceColor.');
2413            error.code = ERROR_CODE_COLOR_PARAMETER_INCORRECT;
2414            throw error;
2415        }
2416    }
2417    static isHexFormat(format) {
2418        return /#(([0-9A-Fa-f]{3})|([0-9A-Fa-f]{6})|([0-9A-Fa-f]{4})|([0-9A-Fa-f]{8}))/.test(format);
2419    }
2420    static hex(hexFormat) {
2421        let r = 0;
2422        let g = 0;
2423        let b = 0;
2424        let a = 255;
2425        if (hexFormat.length === 4) {
2426            r = parseInt(hexFormat.slice(1, 2).repeat(2), 16);
2427            g = parseInt(hexFormat.slice(2, 3).repeat(2), 16);
2428            b = parseInt(hexFormat.slice(3).repeat(2), 16);
2429        }
2430        else if (hexFormat.length === 7) {
2431            r = parseInt(hexFormat.slice(1, 3), 16);
2432            g = parseInt(hexFormat.slice(3, 5), 16);
2433            b = parseInt(hexFormat.slice(5), 16);
2434        }
2435        else if (hexFormat.length === 5) {
2436            a = parseInt(hexFormat.slice(1, 2).repeat(2), 16);
2437            r = parseInt(hexFormat.slice(2, 3).repeat(2), 16);
2438            g = parseInt(hexFormat.slice(3, 4).repeat(2), 16);
2439            b = parseInt(hexFormat.slice(4).repeat(2), 16);
2440        }
2441        else if (hexFormat.length === 9) {
2442            a = parseInt(hexFormat.slice(1, 3), 16);
2443            r = parseInt(hexFormat.slice(3, 5), 16);
2444            g = parseInt(hexFormat.slice(5, 7), 16);
2445            b = parseInt(hexFormat.slice(7), 16);
2446        }
2447        return new ColorMetrics(r, g, b, a);
2448    }
2449    blendColor(overlayColor) {
2450        if (overlayColor === undefined || overlayColor === null) {
2451            const error = new Error('Parameter error. The type of the input parameter is not ColorMetrics.');
2452            error.code = ERROR_CODE_COLOR_PARAMETER_INCORRECT;
2453            throw error;
2454        }
2455        const chanels = getUINativeModule().nativeUtils.blendColor(this.toNumeric(), overlayColor.toNumeric());
2456        if (chanels === undefined) {
2457            const error = new Error('Parameter error. The type of the input parameter is not ColorMetrics.');
2458            error.code = ERROR_CODE_COLOR_PARAMETER_INCORRECT;
2459            throw error;
2460        }
2461        const red = chanels[0];
2462        const green = chanels[1];
2463        const blue = chanels[2];
2464        const alpha = chanels[3];
2465        return new ColorMetrics(red, green, blue, alpha);
2466    }
2467    get color() {
2468        return `rgba(${this.red_}, ${this.green_}, ${this.blue_}, ${this.alpha_ / MAX_CHANNEL_VALUE})`;
2469    }
2470    get red() {
2471        return this.red_;
2472    }
2473    get green() {
2474        return this.green_;
2475    }
2476    get blue() {
2477        return this.blue_;
2478    }
2479    get alpha() {
2480        return this.alpha_;
2481    }
2482    setResourceId(resourceId) {
2483        this.resourceId_ = resourceId;
2484    }
2485    getResourceId() {
2486        return this.resourceId_;
2487    }
2488    setColorSpace(colorSpace) {
2489        if (ColorSpace.DISPLAY_P3 === colorSpace || ColorSpace.SRGB === colorSpace) {
2490            this.colorSpace_ = colorSpace;
2491        }
2492    }
2493    getColorSpace() {
2494        return this.colorSpace_;
2495    }
2496}
2497class BaseShape {
2498    constructor() {
2499        this.rect = null;
2500        this.roundRect = null;
2501        this.circle = null;
2502        this.oval = null;
2503        this.path = null;
2504    }
2505    setRectShape(rect) {
2506        this.rect = rect;
2507        this.roundRect = null;
2508        this.circle = null;
2509        this.oval = null;
2510        this.path = null;
2511    }
2512    setRoundRectShape(roundRect) {
2513        this.roundRect = roundRect;
2514        this.rect = null;
2515        this.circle = null;
2516        this.oval = null;
2517        this.path = null;
2518    }
2519    setCircleShape(circle) {
2520        this.circle = circle;
2521        this.rect = null;
2522        this.roundRect = null;
2523        this.oval = null;
2524        this.path = null;
2525    }
2526    setOvalShape(oval) {
2527        this.oval = oval;
2528        this.rect = null;
2529        this.circle = null;
2530        this.roundRect = null;
2531        this.path = null;
2532    }
2533    setCommandPath(path) {
2534        this.path = path;
2535        this.oval = null;
2536        this.rect = null;
2537        this.circle = null;
2538        this.roundRect = null;
2539    }
2540}
2541class ShapeClip extends BaseShape {
2542}
2543class ShapeMask extends BaseShape {
2544    constructor(...args) {
2545        super(...args);
2546        this.fillColor = 0XFF000000;
2547        this.strokeColor = 0XFF000000;
2548        this.strokeWidth = 0;
2549    }
2550}
2551class RenderNode extends Disposable {
2552    constructor(type) {
2553        super();
2554        this.nodePtr = null;
2555        this.childrenList = [];
2556        this.parentRenderNode = null;
2557        this.backgroundColorValue = 0;
2558        this.apiTargetVersion = getUINativeModule().common.getApiTargetVersion();
2559        this.clipToFrameValue = true;
2560        if (this.apiTargetVersion && this.apiTargetVersion < 12) {
2561            this.clipToFrameValue = false;
2562        }
2563        this.frameValue = { x: 0, y: 0, width: 0, height: 0 };
2564        this.opacityValue = 1.0;
2565        this.pivotValue = { x: 0.5, y: 0.5 };
2566        this.rotationValue = { x: 0, y: 0, z: 0 };
2567        this.scaleValue = { x: 1.0, y: 1.0 };
2568        this.shadowColorValue = 0;
2569        this.shadowOffsetValue = { x: 0, y: 0 };
2570        this.labelValue = '';
2571        this.shadowAlphaValue = 0;
2572        this.shadowElevationValue = 0;
2573        this.shadowRadiusValue = 0;
2574        this.transformValue = [1, 0, 0, 0,
2575            0, 1, 0, 0,
2576            0, 0, 1, 0,
2577            0, 0, 0, 1];
2578        this.translationValue = { x: 0, y: 0 };
2579        this.lengthMetricsUnitValue = LengthMetricsUnit.DEFAULT;
2580        this.markNodeGroupValue = false;
2581        if (type === 'BuilderRootFrameNode' || type === 'CustomFrameNode') {
2582            return;
2583        }
2584        this._nativeRef = getUINativeModule().renderNode.createRenderNode(this);
2585        this.nodePtr = this._nativeRef?.getNativeHandle();
2586        if (this.apiTargetVersion && this.apiTargetVersion < 12) {
2587            this.clipToFrame = false;
2588        }
2589        else {
2590            this.clipToFrame = true;
2591        }
2592    }
2593    set backgroundColor(color) {
2594        this.backgroundColorValue = this.checkUndefinedOrNullWithDefaultValue(color, 0);
2595        getUINativeModule().renderNode.setBackgroundColor(this.nodePtr, this.backgroundColorValue);
2596    }
2597    set clipToFrame(useClip) {
2598        this.clipToFrameValue = this.checkUndefinedOrNullWithDefaultValue(useClip, true);
2599        getUINativeModule().renderNode.setClipToFrame(this.nodePtr, this.clipToFrameValue);
2600    }
2601    set frame(frame) {
2602        if (frame === undefined || frame === null) {
2603            this.frameValue = { x: 0, y: 0, width: 0, height: 0 };
2604        }
2605        else {
2606            this.size = { width: frame.width, height: frame.height };
2607            this.position = { x: frame.x, y: frame.y };
2608        }
2609    }
2610    set opacity(value) {
2611        this.opacityValue = this.checkUndefinedOrNullWithDefaultValue(value, 1.0);
2612        getUINativeModule().common.setOpacity(this.nodePtr, this.opacityValue);
2613    }
2614    set pivot(pivot) {
2615        if (pivot === undefined || pivot === null) {
2616            this.pivotValue = { x: 0.5, y: 0.5 };
2617        }
2618        else {
2619            this.pivotValue.x = this.checkUndefinedOrNullWithDefaultValue(pivot.x, 0.5);
2620            this.pivotValue.y = this.checkUndefinedOrNullWithDefaultValue(pivot.y, 0.5);
2621        }
2622        getUINativeModule().renderNode.setPivot(this.nodePtr, this.pivotValue.x, this.pivotValue.y);
2623    }
2624    set position(position) {
2625        if (position === undefined || position === null) {
2626            this.frameValue.x = 0;
2627            this.frameValue.y = 0;
2628        }
2629        else {
2630            this.frameValue.x = this.checkUndefinedOrNullWithDefaultValue(position.x, 0);
2631            this.frameValue.y = this.checkUndefinedOrNullWithDefaultValue(position.y, 0);
2632        }
2633        getUINativeModule().renderNode.setPosition(this.nodePtr, this.frameValue.x, this.frameValue.y, this.lengthMetricsUnitValue);
2634    }
2635    set rotation(rotation) {
2636        if (rotation === undefined || rotation === null) {
2637            this.rotationValue = { x: 0, y: 0, z: 0 };
2638        }
2639        else {
2640            this.rotationValue.x = this.checkUndefinedOrNullWithDefaultValue(rotation.x, 0);
2641            this.rotationValue.y = this.checkUndefinedOrNullWithDefaultValue(rotation.y, 0);
2642            this.rotationValue.z = this.checkUndefinedOrNullWithDefaultValue(rotation.z, 0);
2643        }
2644        getUINativeModule().renderNode.setRotation(this.nodePtr, this.rotationValue.x, this.rotationValue.y, this.rotationValue.z, this.lengthMetricsUnitValue);
2645    }
2646    set scale(scale) {
2647        if (scale === undefined || scale === null) {
2648            this.scaleValue = { x: 1.0, y: 1.0 };
2649        }
2650        else {
2651            this.scaleValue.x = this.checkUndefinedOrNullWithDefaultValue(scale.x, 1.0);
2652            this.scaleValue.y = this.checkUndefinedOrNullWithDefaultValue(scale.y, 1.0);
2653        }
2654        getUINativeModule().renderNode.setScale(this.nodePtr, this.scaleValue.x, this.scaleValue.y);
2655    }
2656    set shadowColor(color) {
2657        this.shadowColorValue = this.checkUndefinedOrNullWithDefaultValue(color, 0);
2658        getUINativeModule().renderNode.setShadowColor(this.nodePtr, this.shadowColorValue);
2659    }
2660    set shadowOffset(offset) {
2661        if (offset === undefined || offset === null) {
2662            this.shadowOffsetValue = { x: 0, y: 0 };
2663        }
2664        else {
2665            this.shadowOffsetValue.x = this.checkUndefinedOrNullWithDefaultValue(offset.x, 0);
2666            this.shadowOffsetValue.y = this.checkUndefinedOrNullWithDefaultValue(offset.y, 0);
2667        }
2668        getUINativeModule().renderNode.setShadowOffset(this.nodePtr, this.shadowOffsetValue.x, this.shadowOffsetValue.y, this.lengthMetricsUnitValue);
2669    }
2670    set label(label) {
2671        this.labelValue = this.checkUndefinedOrNullWithDefaultValue(label, '');
2672        getUINativeModule().renderNode.setLabel(this.nodePtr, this.labelValue);
2673    }
2674    set shadowAlpha(alpha) {
2675        this.shadowAlphaValue = this.checkUndefinedOrNullWithDefaultValue(alpha, 0);
2676        getUINativeModule().renderNode.setShadowAlpha(this.nodePtr, this.shadowAlphaValue);
2677    }
2678    set shadowElevation(elevation) {
2679        this.shadowElevationValue = this.checkUndefinedOrNullWithDefaultValue(elevation, 0);
2680        getUINativeModule().renderNode.setShadowElevation(this.nodePtr, this.shadowElevationValue);
2681    }
2682    set shadowRadius(radius) {
2683        this.shadowRadiusValue = this.checkUndefinedOrNullWithDefaultValue(radius, 0);
2684        getUINativeModule().renderNode.setShadowRadius(this.nodePtr, this.shadowRadiusValue);
2685    }
2686    set size(size) {
2687        if (size === undefined || size === null) {
2688            this.frameValue.width = 0;
2689            this.frameValue.height = 0;
2690        }
2691        else {
2692            this.frameValue.width = this.checkUndefinedOrNullWithDefaultValue(size.width, 0);
2693            this.frameValue.height = this.checkUndefinedOrNullWithDefaultValue(size.height, 0);
2694        }
2695        getUINativeModule().renderNode.setSize(this.nodePtr, this.frameValue.width, this.frameValue.height, this.lengthMetricsUnitValue);
2696    }
2697    set transform(transform) {
2698        if (transform === undefined || transform === null) {
2699            this.transformValue = [1, 0, 0, 0,
2700                0, 1, 0, 0,
2701                0, 0, 1, 0,
2702                0, 0, 0, 1];
2703        }
2704        else {
2705            let i = 0;
2706            while (i < transform.length && i < 16) {
2707                if (i % 5 === 0) {
2708                    this.transformValue[i] = this.checkUndefinedOrNullWithDefaultValue(transform[i], 1);
2709                }
2710                else {
2711                    this.transformValue[i] = this.checkUndefinedOrNullWithDefaultValue(transform[i], 0);
2712                }
2713                i = i + 1;
2714            }
2715        }
2716        getUINativeModule().common.setTransform(this.nodePtr, this.transformValue);
2717    }
2718    set translation(translation) {
2719        if (translation === undefined || translation === null) {
2720            this.translationValue = { x: 0, y: 0 };
2721        }
2722        else {
2723            this.translationValue.x = this.checkUndefinedOrNullWithDefaultValue(translation.x, 0);
2724            this.translationValue.y = this.checkUndefinedOrNullWithDefaultValue(translation.y, 0);
2725        }
2726        getUINativeModule().renderNode.setTranslate(this.nodePtr, this.translationValue.x, this.translationValue.y, 0);
2727    }
2728    set lengthMetricsUnit(unit) {
2729        if (unit === undefined || unit == null) {
2730            this.lengthMetricsUnitValue = LengthMetricsUnit.DEFAULT;
2731        }
2732        else {
2733            this.lengthMetricsUnitValue = unit;
2734        }
2735    }
2736    set markNodeGroup(isNodeGroup) {
2737        if (isNodeGroup === undefined || isNodeGroup === null) {
2738            this.markNodeGroupValue = false;
2739        }
2740        else {
2741            this.markNodeGroupValue = isNodeGroup;
2742        }
2743        getUINativeModule().renderNode.setMarkNodeGroup(this.nodePtr, this.markNodeGroupValue);
2744    }
2745    get backgroundColor() {
2746        return this.backgroundColorValue;
2747    }
2748    get clipToFrame() {
2749        return this.clipToFrameValue;
2750    }
2751    get opacity() {
2752        return this.opacityValue;
2753    }
2754    get frame() {
2755        return this.frameValue;
2756    }
2757    get pivot() {
2758        return this.pivotValue;
2759    }
2760    get position() {
2761        return { x: this.frameValue.x, y: this.frameValue.y };
2762    }
2763    get rotation() {
2764        return this.rotationValue;
2765    }
2766    get scale() {
2767        return this.scaleValue;
2768    }
2769    get shadowColor() {
2770        return this.shadowColorValue;
2771    }
2772    get shadowOffset() {
2773        return this.shadowOffsetValue;
2774    }
2775    get label() {
2776        return this.labelValue;
2777    }
2778    get shadowAlpha() {
2779        return this.shadowAlphaValue;
2780    }
2781    get shadowElevation() {
2782        return this.shadowElevationValue;
2783    }
2784    get shadowRadius() {
2785        return this.shadowRadiusValue;
2786    }
2787    get size() {
2788        return { width: this.frameValue.width, height: this.frameValue.height };
2789    }
2790    get transform() {
2791        return this.transformValue;
2792    }
2793    get translation() {
2794        return this.translationValue;
2795    }
2796    get lengthMetricsUnit() {
2797        return this.lengthMetricsUnitValue;
2798    }
2799    get markNodeGroup() {
2800        return this.markNodeGroupValue;
2801    }
2802    checkUndefinedOrNullWithDefaultValue(arg, defaultValue) {
2803        if (arg === undefined || arg === null) {
2804            return defaultValue;
2805        }
2806        else {
2807            return arg;
2808        }
2809    }
2810    appendChild(node) {
2811        if (node === undefined || node === null) {
2812            return;
2813        }
2814        if (this.childrenList.findIndex(element => element === node) !== -1) {
2815            return;
2816        }
2817        this.childrenList.push(node);
2818        node.parentRenderNode = new WeakRef(this);
2819        getUINativeModule().renderNode.appendChild(this.nodePtr, node.nodePtr);
2820        getUINativeModule().renderNode.addBuilderNode(this.nodePtr, node.nodePtr);
2821    }
2822    insertChildAfter(child, sibling) {
2823        if (child === undefined || child === null) {
2824            return;
2825        }
2826        let indexOfNode = this.childrenList.findIndex(element => element === child);
2827        if (indexOfNode !== -1) {
2828            return;
2829        }
2830        child.parentRenderNode = new WeakRef(this);
2831        let indexOfSibling = this.childrenList.findIndex(element => element === sibling);
2832        if (indexOfSibling === -1) {
2833            sibling === null;
2834        }
2835        if (sibling === undefined || sibling === null) {
2836            this.childrenList.splice(0, 0, child);
2837            getUINativeModule().renderNode.insertChildAfter(this.nodePtr, child.nodePtr, null);
2838        }
2839        else {
2840            this.childrenList.splice(indexOfSibling + 1, 0, child);
2841            getUINativeModule().renderNode.insertChildAfter(this.nodePtr, child.nodePtr, sibling.nodePtr);
2842        }
2843        getUINativeModule().renderNode.addBuilderNode(this.nodePtr, child.nodePtr);
2844    }
2845    removeChild(node) {
2846        if (node === undefined || node === null) {
2847            return;
2848        }
2849        const index = this.childrenList.findIndex(element => element === node);
2850        if (index === -1) {
2851            return;
2852        }
2853        const child = this.childrenList[index];
2854        child.parentRenderNode = null;
2855        this.childrenList.splice(index, 1);
2856        getUINativeModule().renderNode.removeBuilderNode(this.nodePtr, node.nodePtr);
2857        getUINativeModule().renderNode.removeChild(this.nodePtr, node.nodePtr);
2858    }
2859    clearChildren() {
2860        getUINativeModule().renderNode.clearBuilderNode(this.nodePtr);
2861        this.childrenList = new Array();
2862        getUINativeModule().renderNode.clearChildren(this.nodePtr);
2863    }
2864    getChild(index) {
2865        if (this.childrenList.length > index && index >= 0) {
2866            return this.childrenList[index];
2867        }
2868        return null;
2869    }
2870    getFirstChild() {
2871        if (this.childrenList.length > 0) {
2872            return this.childrenList[0];
2873        }
2874        return null;
2875    }
2876    getNextSibling() {
2877        if (this.parentRenderNode === undefined || this.parentRenderNode === null) {
2878            return null;
2879        }
2880        let parent = this.parentRenderNode.deref();
2881        if (parent === undefined || parent === null) {
2882            return null;
2883        }
2884        let siblingList = parent.childrenList;
2885        const index = siblingList.findIndex(element => element === this);
2886        if (index === -1) {
2887            return null;
2888        }
2889        return parent.getChild(index + 1);
2890    }
2891    getPreviousSibling() {
2892        if (this.parentRenderNode === undefined || this.parentRenderNode === null) {
2893            return null;
2894        }
2895        let parent = this.parentRenderNode.deref();
2896        if (parent === undefined || parent === null) {
2897            return null;
2898        }
2899        let siblingList = parent.childrenList;
2900        const index = siblingList.findIndex(element => element === this);
2901        if (index === -1) {
2902            return null;
2903        }
2904        return parent.getChild(index - 1);
2905    }
2906    setFrameNode(frameNode) {
2907        this._frameNode = frameNode;
2908    }
2909    setNodePtr(nativeRef) {
2910        this._nativeRef = nativeRef;
2911        this.nodePtr = this._nativeRef?.getNativeHandle();
2912    }
2913    setBaseNode(baseNode) {
2914        this.baseNode_ = baseNode;
2915    }
2916    resetNodePtr() {
2917        this.nodePtr = null;
2918        this._nativeRef = null;
2919    }
2920    getNodeType() {
2921        return getUINativeModule().renderNode.getNodeType(this.nodePtr);
2922    }
2923    dispose() {
2924        super.dispose();
2925        if (this.nodePtr) {
2926            getUINativeModule().renderNode.fireArkUIObjectLifecycleCallback(new WeakRef(this),
2927                'RenderNode', this.getNodeType() || 'RenderNode', this.nodePtr);
2928        }
2929        this._nativeRef?.dispose();
2930        this.baseNode_?.disposeNode();
2931        this._frameNode?.deref()?.resetNodePtr();
2932        this._nativeRef = null;
2933        this.nodePtr = null;
2934    }
2935    isDisposed() {
2936        return super.isDisposed() && (this._nativeRef === undefined || this._nativeRef === null);
2937    }
2938    getNodePtr() {
2939        return this.nodePtr;
2940    }
2941    invalidate() {
2942        getUINativeModule().renderNode.invalidate(this.nodePtr);
2943    }
2944    set borderStyle(style) {
2945        if (style === undefined || style === null) {
2946            this.borderStyleValue = { left: BorderStyle.NONE, top: BorderStyle.NONE, right: BorderStyle.NONE, bottom: BorderStyle.NONE };
2947        }
2948        else {
2949            this.borderStyleValue = style;
2950        }
2951        getUINativeModule().renderNode.setBorderStyle(this.nodePtr, this.borderStyleValue.left, this.borderStyleValue.top, this.borderStyleValue.right, this.borderStyleValue.bottom);
2952    }
2953    get borderStyle() {
2954        return this.borderStyleValue;
2955    }
2956    set borderWidth(width) {
2957        if (width === undefined || width === null) {
2958            this.borderWidthValue = { left: 0, top: 0, right: 0, bottom: 0 };
2959        }
2960        else {
2961            this.borderWidthValue = width;
2962        }
2963        getUINativeModule().renderNode.setBorderWidth(this.nodePtr, this.borderWidthValue.left, this.borderWidthValue.top, this.borderWidthValue.right, this.borderWidthValue.bottom, this.lengthMetricsUnitValue);
2964    }
2965    get borderWidth() {
2966        return this.borderWidthValue;
2967    }
2968    set borderColor(color) {
2969        if (color === undefined || color === null) {
2970            this.borderColorValue = { left: 0XFF000000, top: 0XFF000000, right: 0XFF000000, bottom: 0XFF000000 };
2971        }
2972        else {
2973            this.borderColorValue = color;
2974        }
2975        getUINativeModule().renderNode.setBorderColor(this.nodePtr, this.borderColorValue.left, this.borderColorValue.top, this.borderColorValue.right, this.borderColorValue.bottom);
2976    }
2977    get borderColor() {
2978        return this.borderColorValue;
2979    }
2980    set borderRadius(radius) {
2981        if (radius === undefined || radius === null) {
2982            this.borderRadiusValue = { topLeft: 0, topRight: 0, bottomLeft: 0, bottomRight: 0 };
2983        }
2984        else {
2985            this.borderRadiusValue = radius;
2986        }
2987        getUINativeModule().renderNode.setBorderRadius(this.nodePtr, this.borderRadiusValue.topLeft, this.borderRadiusValue.topRight, this.borderRadiusValue.bottomLeft, this.borderRadiusValue.bottomRight, this.lengthMetricsUnitValue);
2988    }
2989    get borderRadius() {
2990        return this.borderRadiusValue;
2991    }
2992    set shapeMask(shapeMask) {
2993        if (shapeMask === undefined || shapeMask === null) {
2994            this.shapeMaskValue = new ShapeMask();
2995        }
2996        else {
2997            this.shapeMaskValue = shapeMask;
2998        }
2999        if (this.shapeMaskValue.rect !== null) {
3000            const rectMask = this.shapeMaskValue.rect;
3001            getUINativeModule().renderNode.setRectMask(this.nodePtr, rectMask.left, rectMask.top, rectMask.right, rectMask.bottom, this.shapeMaskValue.fillColor, this.shapeMaskValue.strokeColor, this.shapeMaskValue.strokeWidth);
3002        }
3003        else if (this.shapeMaskValue.circle !== null) {
3004            const circle = this.shapeMaskValue.circle;
3005            getUINativeModule().renderNode.setCircleMask(this.nodePtr, circle.centerX, circle.centerY, circle.radius, this.shapeMaskValue.fillColor, this.shapeMaskValue.strokeColor, this.shapeMaskValue.strokeWidth);
3006        }
3007        else if (this.shapeMaskValue.roundRect !== null) {
3008            const roundRect = this.shapeMask.roundRect;
3009            const corners = roundRect.corners;
3010            const rect = roundRect.rect;
3011            getUINativeModule().renderNode.setRoundRectMask(this.nodePtr, corners.topLeft.x, corners.topLeft.y, corners.topRight.x, corners.topRight.y, corners.bottomLeft.x, corners.bottomLeft.y, corners.bottomRight.x, corners.bottomRight.y, rect.left, rect.top, rect.right, rect.bottom, this.shapeMaskValue.fillColor, this.shapeMaskValue.strokeColor, this.shapeMaskValue.strokeWidth);
3012        }
3013        else if (this.shapeMaskValue.oval !== null) {
3014            const oval = this.shapeMaskValue.oval;
3015            getUINativeModule().renderNode.setOvalMask(this.nodePtr, oval.left, oval.top, oval.right, oval.bottom, this.shapeMaskValue.fillColor, this.shapeMaskValue.strokeColor, this.shapeMaskValue.strokeWidth);
3016        }
3017        else if (this.shapeMaskValue.path !== null) {
3018            const path = this.shapeMaskValue.path;
3019            getUINativeModule().renderNode.setPath(this.nodePtr, path.commands, this.shapeMaskValue.fillColor, this.shapeMaskValue.strokeColor, this.shapeMaskValue.strokeWidth);
3020        }
3021    }
3022    get shapeMask() {
3023        return this.shapeMaskValue;
3024    }
3025    set shapeClip(shapeClip) {
3026        if (shapeClip === undefined || shapeClip === null) {
3027            this.shapeClipValue = new ShapeClip();
3028        }
3029        else {
3030            this.shapeClipValue = shapeClip;
3031        }
3032        if (this.shapeClipValue.rect !== null) {
3033            const rectClip = this.shapeClipValue.rect;
3034            getUINativeModule().renderNode.setRectClip(this.nodePtr, rectClip.left, rectClip.top, rectClip.right, rectClip.bottom);
3035        }
3036        else if (this.shapeClipValue.circle !== null) {
3037            const circle = this.shapeClipValue.circle;
3038            getUINativeModule().renderNode.setCircleClip(this.nodePtr, circle.centerX, circle.centerY, circle.radius);
3039        }
3040        else if (this.shapeClipValue.roundRect !== null) {
3041            const roundRect = this.shapeClipValue.roundRect;
3042            const corners = roundRect.corners;
3043            const rect = roundRect.rect;
3044            getUINativeModule().renderNode.setRoundRectClip(this.nodePtr, corners.topLeft.x, corners.topLeft.y, corners.topRight.x, corners.topRight.y, corners.bottomLeft.x, corners.bottomLeft.y, corners.bottomRight.x, corners.bottomRight.y, rect.left, rect.top, rect.right, rect.bottom);
3045        }
3046        else if (this.shapeClipValue.oval !== null) {
3047            const oval = this.shapeClipValue.oval;
3048            getUINativeModule().renderNode.setOvalClip(this.nodePtr, oval.left, oval.top, oval.right, oval.bottom);
3049        }
3050        else if (this.shapeClipValue.path !== null) {
3051            const path = this.shapeClipValue.path;
3052            getUINativeModule().renderNode.setPathClip(this.nodePtr, path.commands);
3053        }
3054    }
3055    get shapeClip() {
3056        this.shapeClipValue = this.shapeClipValue ? this.shapeClipValue : new ShapeClip();
3057        return this.shapeClipValue;
3058    }
3059}
3060function edgeColors(all) {
3061    return { left: all, top: all, right: all, bottom: all };
3062}
3063function edgeWidths(all) {
3064    return { left: all, top: all, right: all, bottom: all };
3065}
3066function borderStyles(all) {
3067    return { left: all, top: all, right: all, bottom: all };
3068}
3069function borderRadiuses(all) {
3070    return { topLeft: all, topRight: all, bottomLeft: all, bottomRight: all };
3071}
3072/*
3073 * Copyright (c) 2023 Huawei Device Co., Ltd.
3074 * Licensed under the Apache License, Version 2.0 (the "License");
3075 * you may not use this file except in compliance with the License.
3076 * You may obtain a copy of the License at
3077 *
3078 *     http://www.apache.org/licenses/LICENSE-2.0
3079 *
3080 * Unless required by applicable law or agreed to in writing, software
3081 * distributed under the License is distributed on an "AS IS" BASIS,
3082 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3083 * See the License for the specific language governing permissions and
3084 * limitations under the License.
3085 */
3086class XComponentNode extends FrameNode {
3087    constructor(uiContext, options, id, type, libraryname, controller) {
3088        super(uiContext, 'XComponentNode');
3089        const elmtId = ViewStackProcessor.AllocateNewElmetIdForNextComponent();
3090        this.xcomponentNode_ = getUINativeModule().xcomponentNode;
3091        this.renderType_ = options.type;
3092        const surfaceId = options.surfaceId;
3093        const selfIdealWidth = options.selfIdealSize.width;
3094        const selfIdealHeight = options.selfIdealSize.height;
3095        this.nativeModule_ = this.xcomponentNode_.create(elmtId, id, type, this.renderType_, surfaceId, selfIdealWidth, selfIdealHeight, libraryname, controller);
3096        this.xcomponentNode_.registerOnCreateCallback(this.nativeModule_, this.onCreate);
3097        this.xcomponentNode_.registerOnDestroyCallback(this.nativeModule_, this.onDestroy);
3098        this.nodePtr_ = this.xcomponentNode_.getFrameNode(this.nativeModule_);
3099        this.setNodePtr(getUINativeModule().nativeUtils.createNativeStrongRef(this.nodePtr_), this.nodePtr_);
3100    }
3101    onCreate(event) { }
3102    onDestroy() { }
3103    changeRenderType(type) {
3104        if (this.renderType_ === type) {
3105            return true;
3106        }
3107        if (this.xcomponentNode_.changeRenderType(this.nativeModule_, type)) {
3108            this.renderType_ = type;
3109            return true;
3110        }
3111        return false;
3112    }
3113}
3114/*
3115 * Copyright (c) 2024 Huawei Device Co., Ltd.
3116 * Licensed under the Apache License, Version 2.0 (the "License");
3117 * you may not use this file except in compliance with the License.
3118 * You may obtain a copy of the License at
3119 *
3120 *     http://www.apache.org/licenses/LICENSE-2.0
3121 *
3122 * Unless required by applicable law or agreed to in writing, software
3123 * distributed under the License is distributed on an "AS IS" BASIS,
3124 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3125 * See the License for the specific language governing permissions and
3126 * limitations under the License.
3127 */
3128class Content {
3129    constructor() { }
3130    onAttachToWindow() { }
3131    onDetachFromWindow() { }
3132}
3133/*
3134 * Copyright (c) 2024 Huawei Device Co., Ltd.
3135 * Licensed under the Apache License, Version 2.0 (the "License");
3136 * you may not use this file except in compliance with the License.
3137 * You may obtain a copy of the License at
3138 *
3139 *     http://www.apache.org/licenses/LICENSE-2.0
3140 *
3141 * Unless required by applicable law or agreed to in writing, software
3142 * distributed under the License is distributed on an "AS IS" BASIS,
3143 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3144 * See the License for the specific language governing permissions and
3145 * limitations under the License.
3146 */
3147class ComponentContent extends Content {
3148    constructor(uiContext, builder, params, options) {
3149        super();
3150        let builderNode = new BuilderNode(uiContext, {});
3151        this.builderNode_ = builderNode;
3152        this.builderNode_.build(builder, params ?? undefined, options);
3153        this.disposable_ = new Disposable();
3154    }
3155    update(params) {
3156        this.builderNode_.update(params);
3157    }
3158    getFrameNode() {
3159        return this.builderNode_.getFrameNodeWithoutCheck();
3160    }
3161    setAttachedParent(parent) {
3162        this.parentWeak_ = parent;
3163    }
3164    getNodePtr() {
3165        if (this.attachNodeRef_ !== undefined) {
3166            return this.attachNodeRef_.getNativeHandle();
3167        }
3168        return this.builderNode_.getNodePtr();
3169    }
3170    reuse(param) {
3171        this.builderNode_.reuse(param);
3172    }
3173    recycle() {
3174        this.builderNode_.recycle();
3175    }
3176    onReuseWithBindObject(param) {
3177        this.builderNode_.onReuseWithBindObject(param);
3178    }
3179    onRecycleWithBindObject() {
3180        this.builderNode_.onRecycleWithBindObject();
3181    }
3182    dispose() {
3183        if (this.getNodePtr()) {
3184            getUINativeModule().frameNode.fireArkUIObjectLifecycleCallback(new WeakRef(this),
3185                'ComponentContent', this.getFrameNode()?.getNodeType() || 'ComponentContent', this.getNodePtr());
3186        }
3187        this.disposable_.dispose();
3188        this.detachFromParent();
3189        this.attachNodeRef_?.dispose();
3190        this.builderNode_?.dispose();
3191    }
3192    isDisposed() {
3193        return this.disposable_.isDisposed() && (this.builderNode_?.isDisposed() ?? true);
3194    }
3195    detachFromParent() {
3196        if (this.parentWeak_ === undefined) {
3197            return;
3198        }
3199        let parent = this.parentWeak_.deref();
3200        if (parent !== undefined) {
3201            parent.removeComponentContent(this);
3202        }
3203    }
3204    getNodeWithoutProxy() {
3205        const node = this.getNodePtr();
3206        const nodeType = getUINativeModule().frameNode.getNodeType(node);
3207        if (nodeType === "BuilderProxyNode") {
3208            const result = getUINativeModule().frameNode.getFirstUINode(node);
3209            this.attachNodeRef_ = getUINativeModule().nativeUtils.createNativeStrongRef(result);
3210            getUINativeModule().frameNode.removeChild(node, result);
3211            return result;
3212        }
3213        return node;
3214    }
3215    updateConfiguration() {
3216        this.builderNode_.updateConfiguration();
3217    }
3218    inheritFreezeOptions(enable) {
3219        this.builderNode_.inheritFreezeOptions(enable);
3220    }
3221}
3222/*
3223 * Copyright (c) 2024 Huawei Device Co., Ltd.
3224 * Licensed under the Apache License, Version 2.0 (the "License");
3225 * you may not use this file except in compliance with the License.
3226 * You may obtain a copy of the License at
3227 *
3228 *     http://www.apache.org/licenses/LICENSE-2.0
3229 *
3230 * Unless required by applicable law or agreed to in writing, software
3231 * distributed under the License is distributed on an "AS IS" BASIS,
3232 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3233 * See the License for the specific language governing permissions and
3234 * limitations under the License.
3235 */
3236class NodeContent extends Content {
3237    constructor() {
3238        super();
3239        this.nativeRef_ = getUINativeModule().frameNode.createNodeContent();
3240        this.nativePtr_ = this.nativeRef_.getNativeHandle();
3241        this.nodeArray_ = new Array();
3242    }
3243    addFrameNode(node) {
3244        if (this.nodeArray_.includes(node)) {
3245            return;
3246        }
3247        if (getUINativeModule().frameNode.addFrameNodeToNodeContent(node.getNodePtr(), this.nativePtr_)) {
3248            this.nodeArray_.push(node);
3249        }
3250    }
3251    removeFrameNode(node) {
3252        if (!this.nodeArray_.includes(node)) {
3253            return;
3254        }
3255        if (getUINativeModule().frameNode.removeFrameNodeFromNodeContent(node.getNodePtr(), this.nativePtr_)) {
3256            let index = this.nodeArray_.indexOf(node);
3257            if (index > -1) {
3258                this.nodeArray_.splice(index, 1);
3259            }
3260        }
3261    }
3262}
3263/*
3264 * Copyright (c) 2025 Huawei Device Co., Ltd.
3265 * Licensed under the Apache License, Version 2.0 (the "License");
3266 * you may not use this file except in compliance with the License.
3267 * You may obtain a copy of the License at
3268 *
3269 *     http://www.apache.org/licenses/LICENSE-2.0
3270 *
3271 * Unless required by applicable law or agreed to in writing, software
3272 * distributed under the License is distributed on an "AS IS" BASIS,
3273 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3274 * See the License for the specific language governing permissions and
3275 * limitations under the License.
3276 */
3277function __establishConnection__(allow, parentView, builderIds) {
3278    if (!parentView) {
3279        return false;
3280    }
3281    builderIds.forEach((builderId, indx) => {
3282        let builderNodePtr = FrameNodeFinalizationRegisterProxy.rootFrameNodeIdToBuilderNode_.get(builderId);
3283        let builderNode = builderNodePtr?.deref()?.getBuilderNode();
3284        if (!builderNode) {
3285            return false;
3286        }
3287        builderNode.setParentAllowFreeze(allow);
3288        if (builderNode.getInheritFreeze()) {
3289            builderNode.setAllowFreezeWhenInactive(allow);
3290        }
3291        builderNode.__parentViewOfBuildNode = parentView;
3292        parentView?.addChildBuilderNode(builderNode);
3293    });
3294    return true;
3295}
3296function __disconnectConnection__(parentView, builderIds) {
3297    if (!parentView) {
3298        return false;
3299    }
3300    builderIds.forEach((builderId, indx) => {
3301        let builderNodePtr = FrameNodeFinalizationRegisterProxy.rootFrameNodeIdToBuilderNode_.get(builderId);
3302        let builderNode = builderNodePtr?.deref()?.getBuilderNode();
3303        if (!builderNode) {
3304            return false;
3305        }
3306        builderNode.setParentAllowFreeze(false);
3307        builderNode.setAllowFreezeWhenInactive(false);
3308        if (builderNode.getIsFreeze()) {
3309            builderNode.setActiveInternal(true);
3310        }
3311        builderNode.__parentViewOfBuildNode = undefined;
3312        parentView?.removeChildBuilderNode(builderId);
3313    });
3314    return true;
3315}
3316globalThis.__addBuilderNode__ = function __addBuilderNode__(id, builderIds) {
3317    let view = UINodeRegisterProxy.GetView(id);
3318    if (!view || !(view instanceof PUV2ViewBase)) {
3319        globalThis.__addBuilderNodeToBuilder__(id, builderIds);
3320        return false;
3321    }
3322    return __establishConnection__(view.isCompFreezeAllowed(), view, builderIds);
3323};
3324globalThis.__deleteBuilderNode__ = function __deleteBuilderNode__(id, builderIds) {
3325    return __disconnectConnection__(UINodeRegisterProxy.GetViewBuildNodeBase(id), builderIds);
3326};
3327globalThis.__addBuilderNodeToBuilder__ = function __addBuilderNodeToBuilder__(id, builderIds) {
3328    let builderNode = UINodeRegisterProxy.GetViewBuildNodeBase(id);
3329    if (!builderNode || !(builderNode instanceof JSBuilderNode)) {
3330        return false;
3331    }
3332    return __establishConnection__(builderNode.getAllowFreezeWhenInactive(), builderNode, builderIds);
3333};
3334globalThis.__deleteBuilderNodeFromBuilder__ = function __deleteBuilderNodeFromBuilder__(id, builderIds) {
3335    return __disconnectConnection__(UINodeRegisterProxy.GetViewBuildNodeBase(id), builderIds);
3336};
3337
3338export default {
3339    NodeController, BuilderNode, BaseNode, RenderNode, FrameNode, FrameNodeUtils,
3340    NodeRenderType, XComponentNode, LengthMetrics, ColorMetrics, LengthUnit, LengthMetricsUnit, ShapeMask, ShapeClip,
3341    edgeColors, edgeWidths, borderStyles, borderRadiuses, Content, ComponentContent, NodeContent,
3342    typeNode, NodeAdapter, ExpandMode, UIState
3343};
3344