• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2024 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
16var __decorate = (this && this.__decorate) || function (m10, n10, o10, p10) {
17    var q10 = arguments.length, r10 = q10 < 3 ? n10 : p10 === null ? p10 = Object.getOwnPropertyDescriptor(n10, o10) : p10, s10;
18    if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
19        r10 = Reflect.decorate(m10, n10, o10, p10);
20    else
21        for (var t10 = m10.length - 1; t10 >= 0; t10--)
22            if (s10 = m10[t10])
23                r10 = (q10 < 3 ? s10(r10) : q10 > 3 ? s10(n10, o10, r10) : s10(n10, o10)) || r10;
24    return q10 > 3 && r10 && Object.defineProperty(n10, o10, r10), r10;
25};
26if (!("finalizeConstruction" in ViewPU.prototype)) {
27    Reflect.set(ViewPU.prototype, "finalizeConstruction", () => { });
28}
29
30const hilog = requireNapi('hilog');
31const deviceInfo = requireNapi('deviceInfo');
32const display = requireNapi('display');
33const mediaquery = requireNapi('mediaquery');
34
35const TAG = 'DeviceHelper';
36export class DeviceHelper {
37    static isPhone() {
38        return (DeviceHelper.DEVICE_TYPE === DeviceHelper.TYPE_PHONE || DeviceHelper.DEVICE_TYPE === DeviceHelper.TYPE_DEFAULT);
39    }
40    static isTablet() {
41        return DeviceHelper.DEVICE_TYPE === DeviceHelper.TYPE_TABLET;
42    }
43    static isFold() {
44        let k10 = false;
45        try {
46            k10 = display.isFoldable();
47        }
48        catch (l10) {
49            hilog.error(0x0000, TAG, 'isFold -> isFoldable try error:', l10);
50        }
51        return k10;
52    }
53    static isExpanded() {
54        let i10 = false;
55        try {
56            i10 = display.getFoldStatus() === display.FoldStatus.FOLD_STATUS_EXPANDED;
57        }
58        catch (j10) {
59            hilog.error(0x0000, TAG, 'isExpanded -> try error:', j10);
60        }
61        return i10;
62    }
63    static isColumn() {
64        let g10 = false;
65        try {
66            g10 = display.isFoldable() && (display.getFoldStatus() === display.FoldStatus.FOLD_STATUS_EXPANDED ||
67                display.getFoldStatus() === display.FoldStatus.FOLD_STATUS_HALF_FOLDED);
68        }
69        catch (h10) {
70            hilog.error(0x0000, TAG, 'isColumn -> try error:', h10);
71        }
72        return g10;
73    }
74    static isStraightProduct() {
75        return DeviceHelper.isPhone() && !DeviceHelper.isFold();
76    }
77}
78DeviceHelper.TYPE_DEFAULT = 'default';
79DeviceHelper.TYPE_PHONE = 'phone';
80DeviceHelper.TYPE_TABLET = 'tablet';
81DeviceHelper.DEVICE_TYPE = deviceInfo.deviceType;
82export class DeviceListenerManager {
83    constructor() {
84        this.portraitListener = mediaquery.matchMediaSync('(orientation: portrait)');
85        this.drawableWidthLargeListener = mediaquery.matchMediaSync('(width >= 600vp)');
86        this.isPortrait = undefined;
87        this.onOrientationChange = undefined;
88        this.isLarge = undefined;
89        this.onDrawableWidthChange = undefined;
90    }
91    static getInstance() {
92        if (DeviceListenerManager.instance === undefined) {
93            DeviceListenerManager.instance = new DeviceListenerManager();
94        }
95        return DeviceListenerManager.instance;
96    }
97    onPortraitChange(e10) {
98        let f10 = false;
99        if (DeviceListenerManager.getInstance().isPortrait === undefined) {
100            DeviceListenerManager.getInstance().isPortrait = e10.matches;
101            f10 = true;
102        }
103        else {
104            if (e10.matches) {
105                if (!DeviceListenerManager.getInstance().isPortrait) {
106                    DeviceListenerManager.getInstance().isPortrait = true;
107                    f10 = true;
108                    hilog.debug(0x0000, 'MultiNavigation', 'display portrait');
109                }
110            }
111            else {
112                if (DeviceListenerManager.getInstance().isPortrait) {
113                    DeviceListenerManager.getInstance().isPortrait = false;
114                    f10 = true;
115                    hilog.debug(0x0000, 'MultiNavigation', 'display landscape');
116                }
117            }
118        }
119        if (f10) {
120            DeviceListenerManager.getInstance().notifyOrientationChange();
121        }
122    }
123    notifyOrientationChange() {
124        this.onOrientationChange && this.onOrientationChange(this.isPortrait);
125    }
126    onDrawableWidthLargeChange(c10) {
127        let d10 = false;
128        if (DeviceListenerManager.getInstance().isLarge === undefined) {
129            DeviceListenerManager.getInstance().isLarge = c10.matches;
130            d10 = true;
131        }
132        else {
133            if (c10.matches) {
134                if (!DeviceListenerManager.getInstance().isLarge) {
135                    DeviceListenerManager.getInstance().isLarge = true;
136                    d10 = true;
137                    hilog.debug(0x0000, 'MultiNavigation', 'display isLarge');
138                }
139            }
140            else {
141                if (DeviceListenerManager.getInstance().isLarge) {
142                    DeviceListenerManager.getInstance().isLarge = false;
143                    d10 = true;
144                    hilog.debug(0x0000, 'MultiNavigation', 'display not large');
145                }
146            }
147        }
148        if (d10) {
149            DeviceListenerManager.getInstance().notifyWidthChange();
150        }
151    }
152    notifyWidthChange() {
153        this.onDrawableWidthChange && this.onDrawableWidthChange(this.isLarge);
154    }
155    registerOrientationLister(b10) {
156        this.onOrientationChange = b10;
157        this.onOrientationChange && this.isPortrait && this.onOrientationChange(this.isPortrait);
158    }
159    unregisterOrientationLister() {
160        this.onOrientationChange = undefined;
161    }
162    registerDrawableWidthLister(a10) {
163        this.onDrawableWidthChange = a10;
164        this.onDrawableWidthChange && this.isLarge && this.onDrawableWidthChange(this.isLarge);
165    }
166    unregisterDrawableWidthLister() {
167        this.onDrawableWidthChange = undefined;
168    }
169    initListener() {
170        this.portraitListener.on('change', this.onPortraitChange);
171        this.drawableWidthLargeListener.on('change', this.onDrawableWidthLargeChange);
172    }
173    finalizeListener() {
174        this.portraitListener.off('change', this.onPortraitChange);
175        this.drawableWidthLargeListener.off('change', this.onDrawableWidthLargeChange);
176    }
177}
178let NavWidthRangeAttrModifier = class NavWidthRangeAttrModifier {
179    constructor() {
180        this.isApplicationSet = false;
181        this.minHomeWidth = '50%';
182        this.maxHomeWidth = '50%';
183    }
184    applyNormalAttribute(z9) {
185        if (this.isApplicationSet) {
186            z9.navBarWidthRange([this.minHomeWidth, this.maxHomeWidth]);
187        }
188    }
189};
190NavWidthRangeAttrModifier = __decorate([
191    Observed
192], NavWidthRangeAttrModifier);
193export { NavWidthRangeAttrModifier };
194export class SubNavigation extends ViewPU {
195    constructor(s9, t9, u9, v9 = -1, w9 = undefined, x9) {
196        super(s9, u9, v9, x9);
197        if (typeof w9 === "function") {
198            this.paramsGenerator_ = w9;
199        }
200        this.__isPortrait = new SynchedPropertySimpleTwoWayPU(t9.isPortrait, this, "isPortrait");
201        this.__displayMode = new ObservedPropertySimplePU(0, this, "displayMode");
202        this.__multiStack = new SynchedPropertyNesedObjectPU(t9.multiStack, this, "multiStack");
203        this.navDestination = undefined;
204        this.primaryStack = new MyNavPathStack();
205        this.__secondaryStack = new ObservedPropertyObjectPU(new MyNavPathStack(), this, "secondaryStack");
206        this.__primaryWidth = new ObservedPropertySimplePU('50%', this, "primaryWidth");
207        this.__needRenderIsFullScreen = new SynchedPropertyNesedObjectPU(t9.needRenderIsFullScreen, this, "needRenderIsFullScreen");
208        this.__needRenderLeftClickCount = new SynchedPropertyNesedObjectPU(t9.needRenderLeftClickCount, this, "needRenderLeftClickCount");
209        this.__navWidthRangeModifier = new SynchedPropertyNesedObjectPU(t9.navWidthRangeModifier, this, "navWidthRangeModifier");
210        this.__needRenderDisplayMode = new SynchedPropertyNesedObjectPU(t9.needRenderDisplayMode, this, "needRenderDisplayMode");
211        this.onNavigationModeChange = (y9) => { };
212        this.setInitiallyProvidedValue(t9);
213        this.finalizeConstruction();
214    }
215    setInitiallyProvidedValue(r9) {
216        if (r9.displayMode !== undefined) {
217            this.displayMode = r9.displayMode;
218        }
219        this.__multiStack.set(r9.multiStack);
220        if (r9.navDestination !== undefined) {
221            this.navDestination = r9.navDestination;
222        }
223        if (r9.primaryStack !== undefined) {
224            this.primaryStack = r9.primaryStack;
225        }
226        if (r9.secondaryStack !== undefined) {
227            this.secondaryStack = r9.secondaryStack;
228        }
229        if (r9.primaryWidth !== undefined) {
230            this.primaryWidth = r9.primaryWidth;
231        }
232        this.__needRenderIsFullScreen.set(r9.needRenderIsFullScreen);
233        this.__needRenderLeftClickCount.set(r9.needRenderLeftClickCount);
234        this.__navWidthRangeModifier.set(r9.navWidthRangeModifier);
235        this.__needRenderDisplayMode.set(r9.needRenderDisplayMode);
236        if (r9.onNavigationModeChange !== undefined) {
237            this.onNavigationModeChange = r9.onNavigationModeChange;
238        }
239    }
240    updateStateVars(q9) {
241        this.__multiStack.set(q9.multiStack);
242        this.__needRenderIsFullScreen.set(q9.needRenderIsFullScreen);
243        this.__needRenderLeftClickCount.set(q9.needRenderLeftClickCount);
244        this.__navWidthRangeModifier.set(q9.navWidthRangeModifier);
245        this.__needRenderDisplayMode.set(q9.needRenderDisplayMode);
246    }
247    purgeVariableDependenciesOnElmtId(p9) {
248        this.__isPortrait.purgeDependencyOnElmtId(p9);
249        this.__displayMode.purgeDependencyOnElmtId(p9);
250        this.__multiStack.purgeDependencyOnElmtId(p9);
251        this.__secondaryStack.purgeDependencyOnElmtId(p9);
252        this.__primaryWidth.purgeDependencyOnElmtId(p9);
253        this.__needRenderIsFullScreen.purgeDependencyOnElmtId(p9);
254        this.__needRenderLeftClickCount.purgeDependencyOnElmtId(p9);
255        this.__navWidthRangeModifier.purgeDependencyOnElmtId(p9);
256        this.__needRenderDisplayMode.purgeDependencyOnElmtId(p9);
257    }
258    aboutToBeDeleted() {
259        this.__isPortrait.aboutToBeDeleted();
260        this.__displayMode.aboutToBeDeleted();
261        this.__multiStack.aboutToBeDeleted();
262        this.__secondaryStack.aboutToBeDeleted();
263        this.__primaryWidth.aboutToBeDeleted();
264        this.__needRenderIsFullScreen.aboutToBeDeleted();
265        this.__needRenderLeftClickCount.aboutToBeDeleted();
266        this.__navWidthRangeModifier.aboutToBeDeleted();
267        this.__needRenderDisplayMode.aboutToBeDeleted();
268        SubscriberManager.Get().delete(this.id__());
269        this.aboutToBeDeletedInternal();
270    }
271    get isPortrait() {
272        return this.__isPortrait.get();
273    }
274    set isPortrait(o9) {
275        this.__isPortrait.set(o9);
276    }
277    get displayMode() {
278        return this.__displayMode.get();
279    }
280    set displayMode(n9) {
281        this.__displayMode.set(n9);
282    }
283    get multiStack() {
284        return this.__multiStack.get();
285    }
286    get secondaryStack() {
287        return this.__secondaryStack.get();
288    }
289    set secondaryStack(m9) {
290        this.__secondaryStack.set(m9);
291    }
292    get primaryWidth() {
293        return this.__primaryWidth.get();
294    }
295    set primaryWidth(l9) {
296        this.__primaryWidth.set(l9);
297    }
298    get needRenderIsFullScreen() {
299        return this.__needRenderIsFullScreen.get();
300    }
301    get needRenderLeftClickCount() {
302        return this.__needRenderLeftClickCount.get();
303    }
304    get navWidthRangeModifier() {
305        return this.__navWidthRangeModifier.get();
306    }
307    get needRenderDisplayMode() {
308        return this.__needRenderDisplayMode.get();
309    }
310    SubNavDestination(i9, j9, k9 = null) {
311        this.navDestination.bind(this)(i9, j9);
312    }
313    getMode() {
314        this.displayMode = this.needRenderDisplayMode.displayMode;
315        if (DeviceHelper.isPhone() && DeviceHelper.isStraightProduct()) {
316            return NavigationMode.Stack;
317        }
318        if (this.displayMode === display.FoldStatus.FOLD_STATUS_UNKNOWN) {
319            try {
320                this.displayMode = display.getFoldStatus();
321            } catch (err) {
322                hilog.warn(0x0000, 'MultiNavigation', 'Failed to get fold status. error:' + JSON.stringify(err));
323            }
324        }
325        if (DeviceHelper.isTablet() && this.isPortrait) {
326            hilog.info(0x0000, 'MultiNavigation', 'SubNavigation getMode tablet portrait');
327            return NavigationMode.Stack;
328        }
329        if (this.needRenderIsFullScreen.isFullScreen == undefined) {
330            if (DeviceHelper.isPhone()) {
331                return this.secondaryStack.size() > 0 && DeviceHelper.isColumn() ? NavigationMode.Auto : NavigationMode.Stack;
332            }
333            return this.secondaryStack.size() > 0 ? NavigationMode.Auto : NavigationMode.Stack;
334        }
335        return this.needRenderIsFullScreen.isFullScreen ? NavigationMode.Stack : NavigationMode.Auto;
336    }
337    aboutToAppear() {
338        hilog.debug(0x0000, 'MultiNavigation', 'SubNavigation aboutToAppear param = ' + JSON.stringify(this.primaryStack));
339    }
340    initialRender() {
341        this.observeComponentCreation2((a9, b9) => {
342            NavDestination.create(() => {
343                this.observeComponentCreation2((f9, g9) => {
344                    Navigation.create(this.secondaryStack, { moduleName: "MultiNavigation", pagePath: "", isUserCreateStack: true });
345                    Navigation.mode(this.getMode());
346                    Navigation.onNavigationModeChange(this?.onNavigationModeChange);
347                    Navigation.hideBackButton(true);
348                    Navigation.hideTitleBar(true);
349                    Navigation.navDestination({ builder: this.SubNavDestination.bind(this) });
350                    Navigation.navBarWidth(this.primaryWidth);
351                    Navigation.attributeModifier.bind(this)(ObservedObject.GetRawObject(this.navWidthRangeModifier));
352                    Navigation.onTouch((h9) => {
353                        if (h9.type === TouchType.Down) {
354                            hilog.info(0x0000, 'MultiNavigation', 'outer navigation this.outerStack.leftClickCount ' +
355                                this.needRenderLeftClickCount.leftClickCount);
356                            this.needRenderLeftClickCount.leftClickCount--;
357                        }
358                    });
359                }, Navigation);
360                this.observeComponentCreation2((c9, d9) => {
361                    Navigation.create(this.primaryStack, { moduleName: "MultiNavigation", pagePath: "", isUserCreateStack: true });
362                    Navigation.hideNavBar(true);
363                    Navigation.mode(NavigationMode.Stack);
364                    Navigation.navDestination({ builder: this.SubNavDestination.bind(this) });
365                    Navigation.hideTitleBar(true);
366                    Navigation.hideToolBar(true);
367                    Navigation.hideBackButton(true);
368                    Navigation.onTouch((e9) => {
369                        if (e9.type === TouchType.Down) {
370                            this.needRenderLeftClickCount.leftClickCount = 2;
371                        }
372                    });
373                }, Navigation);
374                Navigation.pop();
375                Navigation.pop();
376            }, { moduleName: "MultiNavigation", pagePath: "" });
377            NavDestination.onBackPressed(() => {
378                hilog.debug(0x0000, 'MultiNavigation', 'subNavigation NavDestination onBackPressed');
379                if (this.multiStack && this.secondaryStack.size() === 1) {
380                    hilog.info(0x0000, 'MultiNavigation', 'subNavigation NavDestination onBackPressed multiStack.pop');
381                    this.multiStack.pop();
382                    return true;
383                }
384                return false;
385            });
386            NavDestination.hideTitleBar(true);
387        }, NavDestination);
388        NavDestination.pop();
389    }
390    rerender() {
391        this.updateDirtyElements();
392    }
393}
394export var SplitPolicy;
395(function (z8) {
396    z8[z8["HOME_PAGE"] = 0] = "HOME_PAGE";
397    z8[z8["DETAIL_PAGE"] = 1] = "DETAIL_PAGE";
398    z8[z8["FULL_PAGE"] = 2] = "FULL_PAGE";
399    z8[z8["PlACE_HOLDER_PAGE"] = 3] = "PlACE_HOLDER_PAGE";
400})(SplitPolicy || (SplitPolicy = {}));
401let that;
402export class MultiNavigation extends ViewPU {
403    constructor(q8, r8, s8, t8 = -1, u8 = undefined, v8) {
404        super(q8, s8, t8, v8);
405        if (typeof u8 === "function") {
406            this.paramsGenerator_ = u8;
407        }
408        this.foldStatusCallback = (y8) => {
409            hilog.info(0x0000, 'MultiNavigation', 'foldStatusCallback data.valueOf()=' + y8.valueOf());
410            this.multiStack.needRenderDisplayMode.displayMode = y8.valueOf();
411            this.multiStack.handleRefreshPlaceHolderIfNeeded();
412        };
413        this.__multiStack = new ObservedPropertyObjectPU(new MultiNavPathStack(), this, "multiStack");
414        this.navDestination = undefined;
415        this.mode = undefined;
416        this.onNavigationModeChangeCallback = (x8) => {
417        };
418        this.onHomeShowOnTop = (w8) => { };
419        this.__isPortrait = new ObservedPropertySimplePU(false, this, "isPortrait");
420        this.setInitiallyProvidedValue(r8);
421        this.finalizeConstruction();
422    }
423    setInitiallyProvidedValue(p8) {
424        if (p8.foldStatusCallback !== undefined) {
425            this.foldStatusCallback = p8.foldStatusCallback;
426        }
427        if (p8.multiStack !== undefined) {
428            this.multiStack = p8.multiStack;
429        }
430        if (p8.navDestination !== undefined) {
431            this.navDestination = p8.navDestination;
432        }
433        if (p8.mode !== undefined) {
434            this.mode = p8.mode;
435        }
436        if (p8.onNavigationModeChangeCallback !== undefined) {
437            this.onNavigationModeChangeCallback = p8.onNavigationModeChangeCallback;
438        }
439        if (p8.onHomeShowOnTop !== undefined) {
440            this.onHomeShowOnTop = p8.onHomeShowOnTop;
441        }
442        if (p8.isPortrait !== undefined) {
443            this.isPortrait = p8.isPortrait;
444        }
445    }
446    updateStateVars(o8) {
447    }
448    purgeVariableDependenciesOnElmtId(n8) {
449        this.__multiStack.purgeDependencyOnElmtId(n8);
450        this.__isPortrait.purgeDependencyOnElmtId(n8);
451    }
452    aboutToBeDeleted() {
453        this.__multiStack.aboutToBeDeleted();
454        this.__isPortrait.aboutToBeDeleted();
455        SubscriberManager.Get().delete(this.id__());
456        this.aboutToBeDeletedInternal();
457    }
458    get multiStack() {
459        return this.__multiStack.get();
460    }
461    set multiStack(m8) {
462        this.__multiStack.set(m8);
463    }
464    get isPortrait() {
465        return this.__isPortrait.get();
466    }
467    set isPortrait(l8) {
468        this.__isPortrait.set(l8);
469    }
470    MultiNavDestination(c8, d8, e8 = null) {
471        this.observeComponentCreation2((f8, g8) => {
472            If.create();
473            if (c8 === 'SubNavigation') {
474                this.ifElseBranchUpdateFunction(0, () => {
475                    {
476                        this.observeComponentCreation2((h8, i8) => {
477                            if (i8) {
478                                let j8 = new SubNavigation(this, {
479                                    isPortrait: this.__isPortrait,
480                                    multiStack: this.multiStack,
481                                    navDestination: this.navDestination,
482                                    primaryStack: d8.primaryStack,
483                                    secondaryStack: d8.secondaryStack,
484                                    needRenderIsFullScreen: d8.needRenderIsFullScreen,
485                                    needRenderLeftClickCount: this.multiStack.needRenderLeftClickCount,
486                                    navWidthRangeModifier: this.multiStack.navWidthRangeModifier,
487                                    onNavigationModeChange: this?.callback,
488                                    needRenderDisplayMode: this.multiStack.needRenderDisplayMode,
489                                }, undefined, h8, () => { }, { page: "MultiNavigation/src/main/ets/components/MultiNavigation.ets", line: 333, col: 7 });
490                                ViewPU.create(j8);
491                                let k8 = () => {
492                                    return {
493                                        isPortrait: this.isPortrait,
494                                        multiStack: this.multiStack,
495                                        navDestination: this.navDestination,
496                                        primaryStack: d8.primaryStack,
497                                        secondaryStack: d8.secondaryStack,
498                                        needRenderIsFullScreen: d8.needRenderIsFullScreen,
499                                        needRenderLeftClickCount: this.multiStack.needRenderLeftClickCount,
500                                        navWidthRangeModifier: this.multiStack.navWidthRangeModifier,
501                                        onNavigationModeChange: this?.callback,
502                                        needRenderDisplayMode: this.multiStack.needRenderDisplayMode
503                                    };
504                                };
505                                j8.paramsGenerator_ = k8;
506                            }
507                            else {
508                                this.updateStateVarsOfChildByElmtId(h8, {
509                                    multiStack: this.multiStack,
510                                    needRenderIsFullScreen: d8.needRenderIsFullScreen,
511                                    needRenderLeftClickCount: this.multiStack.needRenderLeftClickCount,
512                                    navWidthRangeModifier: this.multiStack.navWidthRangeModifier,
513                                    needRenderDisplayMode: this.multiStack.needRenderDisplayMode
514                                });
515                            }
516                        }, { name: "SubNavigation" });
517                    }
518                });
519            }
520            else {
521                this.ifElseBranchUpdateFunction(1, () => {
522                    this.navDestination.bind(this)(c8, d8);
523                });
524            }
525        }, If);
526        If.pop();
527    }
528    callback(b8) {
529        if (that.onNavigationModeChangeCallback !== undefined) {
530            if (b8 !== that.mode || that.mode === undefined) {
531                that?.onNavigationModeChangeCallback(b8);
532            }
533            that.mode = b8;
534        }
535    }
536    aboutToAppear() {
537        that = this;
538        hilog.info(0x0000, 'MultiNavigation', 'MultiNavigation aboutToAppear');
539        try {
540            display.on('foldStatusChange', this.foldStatusCallback);
541        }
542        catch (a8) {
543            console.error('Failed to register callback. Code: ' + JSON.stringify(a8));
544        }
545        DeviceListenerManager.getInstance().registerOrientationLister((z7) => {
546            hilog.info(0x0000, 'MultiNavigation', 'MultiNavigation orientation change ' + z7);
547            this.isPortrait = z7;
548            this.multiStack.isPortrait = z7;
549            this.multiStack.handleRefreshPlaceHolderIfNeeded();
550        });
551        DeviceListenerManager.getInstance().registerDrawableWidthLister((y7) => {
552            hilog.debug(0x0000, 'MultiNavigation', 'MultiNavigation Drawable width change ' + y7);
553            this.multiStack.isLarge = y7;
554            this.multiStack.handleRefreshPlaceHolderIfNeeded();
555        });
556        try {
557            this.multiStack.needRenderDisplayMode.displayMode = display.getFoldStatus();
558        } catch (err) {
559            hilog.warn(0x0000, 'MultiNavigation', 'Failed to get fold status. error:' + JSON.stringify(err));
560        }
561        DeviceListenerManager.getInstance().initListener();
562        this.multiStack.registerHomeChangeListener({
563            onHomeShowOnTop: (x7) => {
564                this.onHomeShowOnTop?.(x7);
565            },
566        });
567    }
568    aboutToDisappear() {
569        try {
570            display.off('foldStatusChange');
571        }
572        catch (w7) {
573            console.error('Failed to unregister callback. Code: ' + JSON.stringify(w7));
574        }
575        DeviceListenerManager.getInstance().unregisterOrientationLister();
576        DeviceListenerManager.getInstance().unregisterDrawableWidthLister();
577        DeviceListenerManager.getInstance().finalizeListener();
578        this.multiStack.unregisterHomeChangeListener();
579    }
580    initialRender() {
581        this.observeComponentCreation2((u7, v7) => {
582            Navigation.create(this.multiStack.outerStack, { moduleName: "MultiNavigation", pagePath: "", isUserCreateStack: true });
583            Navigation.mode(NavigationMode.Stack);
584            Navigation.navDestination({ builder: this.MultiNavDestination.bind(this) });
585            Navigation.hideBackButton(true);
586            Navigation.hideTitleBar(true);
587            Navigation.hideToolBar(true);
588            Navigation.hideNavBar(true);
589        }, Navigation);
590        Navigation.pop();
591    }
592    rerender() {
593        this.updateDirtyElements();
594    }
595}
596let MultiNavPathStack = class MultiNavPathStack extends NavPathStack {
597    constructor() {
598        super();
599        this.outerStack = new MyNavPathStack();
600        this.totalStack = [];
601        this.subStackList = new Array();
602        this.needRenderLeftClickCount = new NeedRenderLeftClickCount();
603        this.needRenderDisplayMode = new NeedRenderDisplayMode();
604        this.disableAllAnimation = false;
605        this.mPolicyMap = new Map();
606        this.navWidthRangeModifier = new NavWidthRangeAttrModifier();
607        this.homeWidthPercents = [50, 50];
608        this.keepBottomPageFlag = false;
609        this.homeChangeListener = undefined;
610        this.placeHolderPolicyInfo = undefined;
611        this.isPortrait = false;
612        this.isLarge = false;
613        this.navPathStackOperate = {
614            onPrimaryPop: () => {
615                hilog.info(0x0000, 'MultiNavigation', 'MyNavPathStack onPrimaryPop');
616                this.totalStack.pop();
617                this.subStackList.pop();
618                this.outerStack.popInner(false);
619            },
620            onSecondaryPop: () => {
621                hilog.info(0x0000, 'MultiNavigation', 'MyNavPathStack onSecondaryPop');
622                this.totalStack.pop();
623                this.checkAndNotifyHomeChange();
624            }
625        };
626        this.outerStackOperate = {
627            onSystemPop: () => {
628                hilog.info(0x0000, 'MultiNavigation', 'MyNavPathStack onOuterPop');
629                this.totalStack.pop();
630                this.subStackList.pop();
631                this.checkAndNotifyHomeChange();
632            }
633        };
634        this.outerStack.registerStackOperateCallback(this.outerStackOperate);
635    }
636    pushPath(l7, m7, n7) {
637        hilog.info(0x0000, 'MultiNavigation', 'pushPath policy = ' + n7 + ', info.name = ' + l7.name);
638        let o7 = true;
639        if (m7 !== undefined) {
640            if (typeof m7 === 'boolean') {
641                o7 = m7;
642            }
643            else if (m7.animated !== undefined) {
644                o7 = m7.animated;
645            }
646            else {
647            }
648        }
649        n7 = (n7 === undefined) ? SplitPolicy.DETAIL_PAGE : n7;
650        const p7 = this.subStackList.length;
651        const q7 = new MultiNavPolicyInfo(n7, l7);
652        hilog.info(0x0000, 'MultiNavigation', 'pushPath subStackLength = ' + p7);
653        if (p7 > 0) {
654            hilog.info(0x0000, 'MultiNavigation', 'pushPath currentTopPrimaryPolicy = ' +
655                this.subStackList[p7 - 1].getPrimaryPolicy());
656        }
657        if (n7 === SplitPolicy.DETAIL_PAGE && p7 > 0 &&
658            this.subStackList[p7 - 1].getPrimaryPolicy() === SplitPolicy.HOME_PAGE) {
659            let s7 = this.subStackList[p7 - 1].getSecondaryInfoList().length;
660            hilog.info(0x0000, 'MultiNavigation', 'pushPath detailSize = ' + s7);
661            if (s7 === 0) {
662                this.subStackList[p7 - 1].pushSecondaryPath(q7, o7);
663            }
664            else {
665                if (this.needRenderLeftClickCount.leftClickCount > 0) {
666                    if (this.placeHolderPolicyInfo === undefined) {
667                        this.subStackList[p7 - 1].clearSecondary(false);
668                        this.totalStack.splice(this.totalStack.length - s7);
669                        this.subStackList[p7 - 1].pushSecondaryPath(q7, false);
670                    }
671                    else {
672                        const t7 = this.subStackList[p7 - 1].getSecondaryInfoList()[0].policy;
673                        if (t7 === SplitPolicy.PlACE_HOLDER_PAGE) {
674                            if (s7 === 1) {
675                                this.subStackList[p7 - 1].pushSecondaryPath(q7, o7);
676                            }
677                            else {
678                                this.subStackList[p7 - 1].clearSecondaryKeepPlaceHolder(false);
679                                this.totalStack.splice(this.totalStack.length - s7 + 1);
680                                this.subStackList[p7 - 1].pushSecondaryPath(q7, false);
681                            }
682                        }
683                        else {
684                            this.subStackList[p7 - 1].clearSecondary(false);
685                            this.totalStack.splice(this.totalStack.length - s7);
686                            this.subStackList[p7 - 1].pushSecondaryPath(q7, false);
687                        }
688                    }
689                }
690                else {
691                    this.subStackList[p7 - 1].pushSecondaryPath(q7, o7);
692                }
693            }
694        }
695        else {
696            let r7 = new SubNavigationStack();
697            r7.registerMultiStackOperateCallback(this.navPathStackOperate);
698            r7.disableAnimation(this.disableAllAnimation);
699            r7.pushPrimaryPath(q7, false);
700            this.subStackList.push(r7);
701            this.outerStack.pushPath({ name: 'SubNavigation', param: r7 }, o7);
702        }
703        this.totalStack.push(q7);
704        if (n7 === SplitPolicy.HOME_PAGE && this.placeHolderPolicyInfo !== undefined &&
705            this.needShowPlaceHolder()) {
706            this.pushPlaceHolder(p7);
707        }
708        hilog.info(0x0000, 'MultiNavigation', 'MultiNavPathStack pushPath policy = ' + n7 +
709            ' stackSize = ' + this.totalStack.length +
710            ' this.leftClickCount = ' + this.needRenderLeftClickCount.leftClickCount);
711        this.needRenderLeftClickCount.leftClickCount = 0;
712    }
713    pushPathByName(g7, h7, i7, j7, k7) {
714        if (i7 !== undefined && typeof i7 !== 'boolean') {
715            this.pushPath({ name: g7, param: h7, onPop: i7 }, j7, k7);
716            return;
717        }
718        if (typeof i7 === 'boolean') {
719            this.pushPath({ name: g7, param: h7 }, i7, j7);
720            return;
721        }
722        if (j7 !== undefined && typeof j7 !== 'boolean') {
723            this.pushPath({ name: g7, param: h7 }, undefined, j7);
724            return;
725        }
726        if (typeof j7 === 'boolean') {
727            this.pushPath({ name: g7, param: h7 }, j7, k7);
728            return;
729        }
730        this.pushPath({ name: g7, param: h7 }, undefined, k7);
731    }
732    pushDestination(c7, d7, e7) {
733        hilog.error(0x0000, 'MultiNavigation', 'pushDestination is not support');
734        let f7 = Promise.reject({ message: 'not support' });
735        return f7;
736    }
737    pushDestinationByName(w6, x6, y6, z6, a7) {
738        hilog.error(0x0000, 'MultiNavigation', 'pushDestinationByName is not support');
739        let b7 = Promise.reject({ message: 'not support' });
740        return b7;
741    }
742    replacePath(p6, q6) {
743        let r6 = true;
744        if (q6 !== undefined) {
745            if (typeof q6 === 'boolean') {
746                r6 = q6;
747            }
748            else if (q6.animated !== undefined) {
749                r6 = q6.animated;
750            }
751            else {
752            }
753        }
754        let s6 = this.totalStack.length;
755        let t6 = this.subStackList.length;
756        if (s6 < 1 || t6 < 1) {
757            hilog.error(0x0000, 'MultiNavigation', 'replacePath fail stack is empty');
758            return;
759        }
760        let u6 = this.totalStack[s6 - 1].policy;
761        if (u6 === SplitPolicy.PlACE_HOLDER_PAGE) {
762            hilog.warn(0x0000, 'MultiNavigation', 'replacePath fail, not support replace placeHolder');
763            return;
764        }
765        const v6 = new MultiNavPolicyInfo(u6, p6);
766        this.subStackList[t6 - 1].replacePath(v6, r6);
767        this.totalStack.pop();
768        this.totalStack.push(v6);
769    }
770    replacePathByName(m6, n6, o6) {
771        this.replacePath({ name: m6, param: n6 }, o6);
772    }
773    removeByIndexes(x5) {
774        let y5 = x5.length;
775        hilog.info(0x0000, 'MultiNavigation', 'removeByIndexes indexesLength=' + y5);
776        if (y5 <= 0) {
777            return 0;
778        }
779        let z5 = this.totalStack.length;
780        hilog.info(0x0000, 'MultiNavigation', 'removeByIndexes oriStackSize=' + z5);
781        x5.sort((k6, l6) => k6 - l6);
782        let a6 = 0;
783        let b6 = 0;
784        let c6 = [];
785        hilog.info(0x0000, 'MultiNavigation', 'removeByIndexes this.subStackList.length=' + this.subStackList.length +
786            ', oriStackSize=' + z5);
787        this.subStackList.forEach((g6, h6) => {
788            let i6 = b6;
789            b6 += g6.getAllInfoLength();
790            const j6 = [];
791            for (; a6 < x5.length;) {
792                if (x5[a6] < b6) {
793                    j6.push(x5[a6] - i6);
794                    a6++;
795                }
796                else {
797                    break;
798                }
799            }
800            g6.removeByIndexes(j6);
801            if (!g6.hasPrimaryInfo()) {
802                c6.push(h6);
803            }
804        });
805        hilog.info(0x0000, 'MultiNavigation', 'removeByIndexes outerIndexes.length=' + c6.length);
806        this.outerStack.removeByIndexes(c6);
807        this.subStackList = this.subStackList.filter((f6) => {
808            return f6.hasPrimaryInfo();
809        });
810        this.totalStack = [];
811        this.subStackList.forEach((e6) => {
812            this.totalStack.push(...e6.getPrimaryInfoList());
813            this.totalStack.push(...e6.getSecondaryInfoList());
814        });
815        this.handleRefreshPlaceHolderIfNeeded();
816        this.checkAndNotifyHomeChange();
817        let d6 = z5 - this.totalStack.length;
818        hilog.info(0x0000, 'MultiNavigation', 'removeByIndexes size=' + d6);
819        return d6;
820    }
821    removeByName(p5) {
822        let q5 = this.totalStack.length;
823        hilog.info(0x0000, 'MultiNavigation', 'removeByName name=' + p5 + ', oriStackSize=' + q5);
824        let r5 = [];
825        this.subStackList.forEach((v5, w5) => {
826            v5.removeByName(p5);
827            if (!v5.hasPrimaryInfo()) {
828                r5.push(w5);
829            }
830        });
831        this.outerStack.removeByIndexes(r5);
832        hilog.info(0x0000, 'MultiNavigation', 'removeByName outerIndexes.length=' + r5.length);
833        this.subStackList = this.subStackList.filter((u5) => {
834            return u5.hasPrimaryInfo();
835        });
836        this.totalStack = [];
837        this.subStackList.forEach((t5) => {
838            this.totalStack.push(...t5.getPrimaryInfoList());
839            this.totalStack.push(...t5.getSecondaryInfoList());
840        });
841        this.handleRefreshPlaceHolderIfNeeded();
842        this.checkAndNotifyHomeChange();
843        let s5 = q5 - this.totalStack.length;
844        hilog.info(0x0000, 'MultiNavigation', 'removeByName size=' + s5);
845        return s5;
846    }
847    pop(f5, g5) {
848        let h5 = this.totalStack.length;
849        let i5 = this.subStackList.length;
850        if (h5 < 1 || i5 < 1) {
851            hilog.error(0x0000, 'MultiNavigation', 'MultiNavPathStack pop fail stack is empty!');
852            return undefined;
853        }
854        hilog.info(0x0000, 'MultiNavigation', 'MultiNavPathStack pop totalSize=' + h5 +
855            ', subStackLength' + i5);
856        if (this.keepBottomPageFlag && (h5 === 1 ||
857            (this.placeHolderPolicyInfo !== undefined && h5 === 2 &&
858                this.totalStack[1].policy === SplitPolicy.PlACE_HOLDER_PAGE))) {
859            hilog.info(0x0000, 'MultiNavigation', 'MultiNavPathStack pop fail for keep bottom');
860            return undefined;
861        }
862        let j5 = this.totalStack[h5 - 1].navInfo;
863        let k5 = this.subStackList[i5 - 1].getAllInfoLength();
864        if (k5 < 1) {
865            hilog.error(0x0000, 'MultiNavigation', 'MultiNavPathStack pop fail sub stack is empty');
866            return undefined;
867        }
868        let l5 = undefined;
869        if (k5 > 1) {
870            l5 = this.subStackList[i5 - 1].getSecondaryInfoList()[0].policy;
871        }
872        hilog.info(0x0000, 'MultiNavigation', 'MultiNavPathStack pop allInfoLength=' + k5 +
873            ', secondaryStackFirstPolice' + l5);
874        this.totalStack.pop();
875        if (k5 === 1) {
876            this.outerStack.popInner(g5);
877            let o5 = this.subStackList.pop();
878            setTimeout(() => {
879                o5?.pop(false);
880                o5 = undefined;
881            }, 300);
882        }
883        else {
884            if (k5 === 2) {
885                if (this.placeHolderPolicyInfo !== undefined) {
886                    if (l5 === SplitPolicy.PlACE_HOLDER_PAGE) {
887                        this.outerStack.popInner(g5);
888                        let n5 = this.subStackList.pop();
889                        setTimeout(() => {
890                            n5?.clear(false);
891                            n5 = undefined;
892                        }, 300);
893                        j5 = this.totalStack.pop()?.navInfo;
894                    }
895                    else {
896                        if (this.needShowPlaceHolder()) {
897                            this.subStackList[i5 - 1].pop(g5);
898                            this.pushPlaceHolder(i5 - 1);
899                        }
900                        else {
901                            this.subStackList[i5 - 1].pop(g5);
902                        }
903                    }
904                }
905                else {
906                    this.subStackList[i5 - 1].pop(g5);
907                }
908            }
909            else {
910                this.subStackList[i5 - 1].pop(g5);
911            }
912        }
913        hilog.info(0x0000, 'MultiNavigation', 'MultiNavPathStack pop currentPath.name = ' + j5?.name);
914        if (f5 !== undefined && typeof f5 !== 'boolean' &&
915            j5 !== undefined && j5.onPop !== undefined) {
916            let m5 = {
917                info: j5,
918                result: f5,
919            };
920            j5.onPop(m5);
921        }
922        this.handleRefreshPlaceHolderIfNeeded();
923        this.checkAndNotifyHomeChange();
924        hilog.info(0x0000, 'MultiNavigation', 'MultiNavPathStack pop stackSize = ' + this.totalStack.length);
925        return j5;
926    }
927    popToName(r4, s4, t4) {
928        let u4 = this.totalStack.findIndex((e5) => {
929            return e5.navInfo?.name === r4;
930        });
931        let v4 = this.totalStack.length;
932        let w4 = this.subStackList.length;
933        if (v4 < 1 || w4 < 1) {
934            hilog.error(0x0000, 'MultiNavigation', 'popToName fail stack is empty!');
935            return -1;
936        }
937        if (u4 !== -1) {
938            let x4 = this.totalStack[v4 - 1].navInfo;
939            let y4 = [];
940            this.subStackList.forEach((c5, d5) => {
941                y4.push(this.subStackList[d5].secondaryStack.size());
942            });
943            let z4 = 0;
944            for (let b5 = 0; b5 < w4; b5++) {
945                z4++;
946                if (u4 === z4 - 1) {
947                    this.subStackList[b5]?.secondaryStack.clear();
948                    this.subStackList[b5].secondaryStack.policyInfoList.splice(0);
949                    this.totalStack.splice(u4 + 1);
950                    this.clearTrashStack(b5 + 1, s4, t4);
951                    break;
952                }
953                else if (u4 > z4 - 1 && u4 < z4 + y4[b5]) {
954                    this.subStackList[b5].secondaryStack.popToIndex(u4 - z4);
955                    this.subStackList[b5].secondaryStack.policyInfoList.splice(u4 - z4 + 1);
956                    this.totalStack.splice(u4 + 1);
957                    this.clearTrashStack(b5 + 1, s4, t4);
958                }
959                z4 += y4[b5];
960            }
961            if (s4 !== undefined && typeof s4 !== 'boolean' &&
962                x4 !== undefined && x4.onPop !== undefined) {
963                let a5 = {
964                    info: x4,
965                    result: s4,
966                };
967                x4.onPop(a5);
968            }
969        }
970        this.handleRefreshPlaceHolderIfNeeded();
971        this.checkAndNotifyHomeChange();
972        return u4;
973    }
974    popToIndex(f4, g4, h4) {
975        hilog.info(0x0000, 'MultiNavigation', 'MultiNavPathStack popToIndex index = ' + f4);
976        if (f4 > this.totalStack.length || f4 < 0) {
977            hilog.error(0x0000, 'MultiNavigation', 'popToIndex fail wrong index');
978            return;
979        }
980        let i4 = this.totalStack.length;
981        let j4 = this.subStackList.length;
982        if (i4 < 1 || j4 < 1) {
983            hilog.error(0x0000, 'MultiNavigation', 'popToIndex fail stack is empty!');
984            return;
985        }
986        let k4 = this.totalStack[i4 - 1].navInfo;
987        let l4 = [];
988        this.subStackList.forEach((p4, q4) => {
989            l4.push(this.subStackList[q4].secondaryStack.size());
990        });
991        let m4 = 0;
992        for (let o4 = 0; o4 < j4; o4++) {
993            m4++;
994            if (f4 === m4 - 1) {
995                hilog.info(0x0000, 'MultiNavigation', 'MultiNavPathStack popToIndex home' + o4);
996                this.subStackList[o4]?.secondaryStack.clear();
997                this.subStackList[o4].secondaryStack.policyInfoList.splice(0);
998                this.totalStack.splice(f4 + 1);
999                this.clearTrashStack(o4 + 1, g4, h4);
1000                hilog.info(0x0000, 'MultiNavigation', 'MultiNavPathStack popToIndex totalStack=' + this.totalStack.length);
1001                break;
1002            }
1003            else if (f4 > m4 - 1 && f4 < m4 + l4[o4]) {
1004                this.subStackList[o4].secondaryStack.popToIndex(f4 - m4);
1005                this.subStackList[o4].secondaryStack.policyInfoList.splice(f4 - m4 + 1);
1006                this.totalStack.splice(f4 + 1);
1007                this.clearTrashStack(o4 + 1, g4, h4);
1008            }
1009            m4 += l4[o4];
1010        }
1011        if (g4 !== undefined && typeof g4 !== 'boolean' &&
1012            k4 !== undefined && k4.onPop !== undefined) {
1013            let n4 = {
1014                info: k4,
1015                result: g4,
1016            };
1017            k4.onPop(n4);
1018        }
1019        this.handleRefreshPlaceHolderIfNeeded();
1020        this.checkAndNotifyHomeChange();
1021    }
1022    clearTrashStack(b4, c4, d4) {
1023        hilog.info(0x0000, 'MultiNavigation', 'MultiNavPathStack popToIndex clearTrashStack' + b4);
1024        for (let e4 = b4; e4 < this.subStackList.length; e4++) {
1025            hilog.info(0x0000, 'MultiNavigation', 'MultiNavPathStack popToIndex subStackList' + b4);
1026            this.subStackList[e4].primaryStack.clear();
1027            this.subStackList[e4].secondaryStack.clear();
1028            this.subStackList[e4].primaryStack.policyInfoList.splice(0);
1029            this.subStackList[e4].secondaryStack.policyInfoList.splice(0);
1030        }
1031        this.subStackList.splice(b4);
1032        hilog.info(0x0000, 'MultiNavigation', 'MultiNavPathStack popToIndex subStackList.length=' + this.subStackList.length);
1033        this.outerStack.popToIndex(b4 - 1, c4, d4);
1034        hilog.info(0x0000, 'MultiNavigation', 'MultiNavPathStack popToIndex outerStack.size=' + this.outerStack.size());
1035    }
1036    moveToTop(x3, y3) {
1037        hilog.info(0x0000, 'MultiNavigation', 'MultiNavPathStack moveToTop name=' + x3);
1038        let z3 = this.totalStack.findIndex((a4) => {
1039            return a4.navInfo?.name === x3;
1040        });
1041        if (z3 !== -1) {
1042            this.moveIndexToTop(z3, y3);
1043        }
1044        return z3;
1045    }
1046    moveIndexToTop(m3, n3) {
1047        hilog.info(0x0000, 'MultiNavigation', 'MultiNavPathStack moveIndexToTop index=' + m3);
1048        if (m3 < 0 || m3 > this.totalStack.length) {
1049            hilog.error(0x0000, 'MultiNavigation', 'MultiNavPathStack moveIndexToTop wrong index');
1050            return;
1051        }
1052        let o3 = this.subStackList.length;
1053        let p3 = 0;
1054        let q3 = -1;
1055        for (let t3 = 0; t3 < o3; t3++) {
1056            let u3 = p3;
1057            p3 += this.subStackList[t3].getAllInfoLength();
1058            if (m3 < p3) {
1059                q3 = t3;
1060                if (this.subStackList[t3].getPrimaryPolicy() === SplitPolicy.HOME_PAGE) {
1061                    let v3 = m3 - u3;
1062                    if (v3 !== 0) {
1063                        this.subStackList[t3].secondaryStack.moveIndexToTop(v3 - 1, n3);
1064                        const w3 = this.subStackList[t3].secondaryStack.policyInfoList.splice(v3 - 1, 1);
1065                        this.subStackList[t3].secondaryStack.policyInfoList.push(...w3);
1066                    }
1067                }
1068                break;
1069            }
1070        }
1071        if (q3 !== -1) {
1072            let s3 = this.subStackList.splice(q3, 1);
1073            this.subStackList.push(...s3);
1074            this.outerStack.moveIndexToTop(q3, n3);
1075        }
1076        this.totalStack = [];
1077        this.subStackList.forEach((r3) => {
1078            this.totalStack.push(...r3.getPrimaryInfoList());
1079            this.totalStack.push(...r3.getSecondaryInfoList());
1080        });
1081        this.handleRefreshPlaceHolderIfNeeded();
1082        this.checkAndNotifyHomeChange();
1083    }
1084    clear(i3) {
1085        hilog.info(0x0000, 'MultiNavigation', 'MultiNavPathStack clear animated = ' + i3 + ', keepBottomPageFlag=' +
1086            this.keepBottomPageFlag);
1087        if (this.subStackList.length === 0 || this.totalStack.length === 0) {
1088            hilog.info(0x0000, 'MultiNavigation', 'MultiNavPathStack clear return size is 0');
1089            return;
1090        }
1091        if (this.keepBottomPageFlag) {
1092            let k3 = this.subStackList.length;
1093            for (let l3 = 1; l3 < k3; l3++) {
1094                this.subStackList[l3].clear(i3);
1095            }
1096            this.outerStack.popToIndex(0, i3);
1097            this.subStackList.splice(1);
1098            if (this.placeHolderPolicyInfo !== undefined) {
1099                if (this.subStackList[0].getSecondaryInfoList().length > 1 &&
1100                    this.subStackList[0].secondaryStack.policyInfoList[0].policy === SplitPolicy.PlACE_HOLDER_PAGE) {
1101                    this.subStackList[0].clearSecondaryKeepPlaceHolder(i3);
1102                    this.totalStack.splice(2);
1103                }
1104                else {
1105                    this.subStackList[0].clearSecondary(i3);
1106                    this.totalStack.splice(1);
1107                    if (this.needShowPlaceHolder()) {
1108                        this.subStackList[0].pushSecondaryPath(this.placeHolderPolicyInfo, i3);
1109                        this.totalStack.push(this.placeHolderPolicyInfo);
1110                    }
1111                }
1112            }
1113            else {
1114                this.subStackList[0].clearSecondary(i3);
1115                this.totalStack.splice(1);
1116            }
1117            this.checkAndNotifyHomeChange();
1118            return;
1119        }
1120        this.subStackList.forEach((j3) => {
1121            j3.clear(i3);
1122        });
1123        this.outerStack.clear(i3);
1124        this.subStackList.splice(0);
1125        this.totalStack.splice(0);
1126    }
1127    getAllPathName() {
1128        let g3 = [];
1129        this.totalStack.forEach((h3) => {
1130            if (h3.navInfo !== undefined) {
1131                g3.push(h3.navInfo.name);
1132            }
1133        });
1134        return g3;
1135    }
1136    getParamByIndex(e3) {
1137        let f3 = undefined;
1138        if (e3 >= 0 && e3 < this.totalStack.length) {
1139            f3 = this.totalStack[e3].navInfo?.param;
1140        }
1141        return f3;
1142    }
1143    getParamByName(b3) {
1144        let c3 = [];
1145        this.totalStack.forEach((d3) => {
1146            if (d3.navInfo !== undefined && d3.navInfo.name == b3) {
1147                c3.push(d3.navInfo.param);
1148            }
1149        });
1150        return c3;
1151    }
1152    getIndexByName(y2) {
1153        let z2 = [];
1154        for (let a3 = 0; a3 < this.totalStack.length; a3++) {
1155            if (this.totalStack[a3].navInfo?.name === y2) {
1156                z2.push(a3);
1157            }
1158        }
1159        return z2;
1160    }
1161    getParent() {
1162        hilog.error(0x0000, 'MultiNavigation', 'getParent is not support!');
1163        throw new Error('getParent is not support in multi navigation');
1164    }
1165    size() {
1166        return this.totalStack.length;
1167    }
1168    disableAnimation(w2) {
1169        for (const x2 of this.subStackList) {
1170            x2.disableAnimation(w2);
1171        }
1172        this.outerStack.disableAnimation(w2);
1173        this.disableAllAnimation = w2;
1174    }
1175    setInterception(v2) {
1176        hilog.error(0x0000, 'MultiNavigation', 'setInterception is not support!');
1177        throw new Error('setInterception is not support in multi navigation');
1178    }
1179    setPagePolicy(u2) {
1180        this.mPolicyMap = u2;
1181    }
1182    switchFullScreenState(r2) {
1183        let s2 = this.totalStack.length;
1184        let t2 = this.subStackList.length;
1185        if (t2 < 1 || s2 < 1) {
1186            return false;
1187        }
1188        if (this.subStackList[t2 - 1].getPrimaryPolicy() !== SplitPolicy.HOME_PAGE) {
1189            return false;
1190        }
1191        if (this.totalStack[s2 - 1].policy === SplitPolicy.PlACE_HOLDER_PAGE) {
1192            return false;
1193        }
1194        if (this.totalStack[s2 - 1].isFullScreen === r2) {
1195            hilog.info(0x0000, 'MultiNavigation', 'switchFullScreen is same:' + r2);
1196            return true;
1197        }
1198        hilog.info(0x0000, 'MultiNavigation', 'switchFullScreen name=' +
1199            this.totalStack[s2 - 1].navInfo?.name +
1200            ', from ' + this.totalStack[s2 - 1].isFullScreen + ' to ' + r2);
1201        this.totalStack[s2 - 1].isFullScreen = r2;
1202        this.subStackList[t2 - 1].refreshFullScreen();
1203        return true;
1204    }
1205    setHomeWidthRange(p2, q2) {
1206        if (!this.checkInputPercent(p2) || !this.checkInputPercent(q2)) {
1207            hilog.error(0x0000, 'MultiNavigation', 'setHomeWidthRange failed, wrong param:' +
1208                ', ' + p2 + ', ' + q2);
1209            return;
1210        }
1211        this.homeWidthPercents = [p2, q2];
1212        this.refreshHomeWidth();
1213    }
1214    keepBottomPage(o2) {
1215        this.keepBottomPageFlag = o2;
1216    }
1217    registerHomeChangeListener(n2) {
1218        if (this.homeChangeListener === undefined) {
1219            this.homeChangeListener = n2;
1220        }
1221    }
1222    unregisterHomeChangeListener() {
1223        this.homeChangeListener = undefined;
1224    }
1225    setPlaceholderPage(m2) {
1226        this.placeHolderPolicyInfo = new MultiNavPolicyInfo(SplitPolicy.PlACE_HOLDER_PAGE, m2);
1227    }
1228    handleRefreshPlaceHolderIfNeeded() {
1229        if (this.placeHolderPolicyInfo === undefined) {
1230            return;
1231        }
1232        const i2 = this.subStackList.length;
1233        if (i2 < 1) {
1234            return;
1235        }
1236        const j2 = this.subStackList[i2 - 1].getPrimaryPolicy();
1237        if (j2 !== SplitPolicy.HOME_PAGE) {
1238            return;
1239        }
1240        const k2 = this.subStackList[i2 - 1].getAllInfoLength();
1241        let l2 = undefined;
1242        if (k2 > 1) {
1243            l2 = this.subStackList[i2 - 1].getSecondaryInfoList()[0].policy;
1244        }
1245        if (this.needShowPlaceHolder()) {
1246            if (k2 === 1) {
1247                this.pushPlaceHolder(i2 - 1);
1248            }
1249        }
1250        else {
1251            if (l2 === SplitPolicy.PlACE_HOLDER_PAGE) {
1252                if (k2 === 2) {
1253                    this.popPlaceHolder(i2 - 1);
1254                }
1255                else {
1256                    this.removeFirstPlaceHolder(i2 - 1);
1257                }
1258            }
1259        }
1260    }
1261    removeFirstPlaceHolder(g2) {
1262        this.subStackList[g2].removeByIndexes([1]);
1263        this.totalStack = [];
1264        this.subStackList.forEach((h2) => {
1265            this.totalStack.push(...h2.getPrimaryInfoList());
1266            this.totalStack.push(...h2.getSecondaryInfoList());
1267        });
1268    }
1269    pushPlaceHolder(f2) {
1270        this.subStackList[f2].pushSecondaryPath(this.placeHolderPolicyInfo, false);
1271        this.totalStack.push(this.placeHolderPolicyInfo);
1272    }
1273    popPlaceHolder(e2) {
1274        this.subStackList[e2].pop(false);
1275        this.totalStack.pop();
1276        this.checkAndNotifyHomeChange();
1277    }
1278    needShowPlaceHolder() {
1279        if (!this.isLarge) {
1280            hilog.info(0x0000, 'MultiNavigation', 'do not show placeHolder for drawable width is less then breakpoint');
1281            return false;
1282        }
1283        if (DeviceHelper.isStraightProduct()) {
1284            hilog.info(0x0000, 'MultiNavigation', 'do not show placeHolder for straight product');
1285            return false;
1286        }
1287        if (DeviceHelper.isPhone() && DeviceHelper.isFold() &&
1288            this.needRenderDisplayMode.displayMode === display.FoldStatus.FOLD_STATUS_FOLDED) {
1289            hilog.info(0x0000, 'MultiNavigation', 'do not show placeHolder for fold status');
1290            return false;
1291        }
1292        if (DeviceHelper.isTablet() && this.isPortrait) {
1293            hilog.info(0x0000, 'MultiNavigation', 'do not show placeHolder for portrait tablet');
1294            return false;
1295        }
1296        return true;
1297    }
1298    checkAndNotifyHomeChange() {
1299        if (this.totalStack.length === 0) {
1300            return;
1301        }
1302        let c2 = this.totalStack[this.totalStack.length - 1];
1303        if (c2 === undefined) {
1304            return;
1305        }
1306        if (c2.policy === SplitPolicy.HOME_PAGE && c2.navInfo !== undefined) {
1307            this.homeChangeListener && this.homeChangeListener.onHomeShowOnTop(c2.navInfo.name);
1308        }
1309        if (this.totalStack.length <= 1) {
1310            return;
1311        }
1312        let d2 = this.totalStack[this.totalStack.length - 2];
1313        if (d2 === undefined) {
1314            return;
1315        }
1316        if (c2.policy === SplitPolicy.PlACE_HOLDER_PAGE &&
1317            d2.policy === SplitPolicy.HOME_PAGE && d2.navInfo !== undefined) {
1318            this.homeChangeListener && this.homeChangeListener.onHomeShowOnTop(d2.navInfo.name);
1319        }
1320    }
1321    refreshHomeWidth() {
1322        this.navWidthRangeModifier.minHomeWidth = `${this.homeWidthPercents[0]}%`;
1323        this.navWidthRangeModifier.maxHomeWidth = `${this.homeWidthPercents[1]}%`;
1324        this.navWidthRangeModifier.isApplicationSet = true;
1325    }
1326    checkInputPercent(b2) {
1327        return (0 <= b2 && b2 <= 100);
1328    }
1329};
1330MultiNavPathStack = __decorate([
1331    Observed
1332], MultiNavPathStack);
1333export { MultiNavPathStack };
1334let NeedRenderIsFullScreen = class NeedRenderIsFullScreen {
1335    constructor() {
1336        this.isFullScreen = undefined;
1337    }
1338};
1339NeedRenderIsFullScreen = __decorate([
1340    Observed
1341], NeedRenderIsFullScreen);
1342export { NeedRenderIsFullScreen };
1343let NeedRenderLeftClickCount = class NeedRenderLeftClickCount {
1344    constructor() {
1345        this.leftClickCount = 0;
1346    }
1347};
1348NeedRenderLeftClickCount = __decorate([
1349    Observed
1350], NeedRenderLeftClickCount);
1351export { NeedRenderLeftClickCount };
1352let NeedRenderDisplayMode = class NeedRenderDisplayMode {
1353    constructor() {
1354        this.displayMode = 0;
1355    }
1356};
1357NeedRenderDisplayMode = __decorate([
1358    Observed
1359], NeedRenderDisplayMode);
1360export { NeedRenderDisplayMode };
1361class MultiNavPolicyInfo {
1362    constructor(z1, a2) {
1363        this.policy = SplitPolicy.DETAIL_PAGE;
1364        this.navInfo = undefined;
1365        this.isFullScreen = undefined;
1366        this.policy = z1;
1367        this.navInfo = a2;
1368    }
1369}
1370export class MyNavPathStack extends NavPathStack {
1371    constructor() {
1372        super(...arguments);
1373        this.operates = [];
1374        this.type = 'NavPathStack';
1375        this.policyInfoList = [];
1376    }
1377    registerStackOperateCallback(w1) {
1378        let x1 = this.operates.findIndex((y1) => { return y1 === w1; });
1379        if (x1 === -1) {
1380            this.operates.push(w1);
1381        }
1382    }
1383    unregisterStackOperateCallback(t1) {
1384        let u1 = this.operates.findIndex((v1) => { return v1 === t1; });
1385        if (u1 !== -1) {
1386            this.operates.splice(u1, 1);
1387        }
1388    }
1389    popInner(r1, s1) {
1390        hilog.info(0x0000, 'MultiNavigation', 'MyNavPathStack pop from inner:');
1391        return super.pop(r1, s1);
1392    }
1393    pop(n1, o1) {
1394        hilog.info(0x0000, 'MultiNavigation', 'MyNavPathStack pop from system:');
1395        let p1 = undefined;
1396        if (typeof o1 === 'boolean') {
1397            p1 = super.pop(o1);
1398        }
1399        else {
1400            p1 = super.pop(n1, o1);
1401        }
1402        this.policyInfoList.pop();
1403        this.operates.forEach((q1) => {
1404            q1.onSystemPop?.();
1405        });
1406        return p1;
1407    }
1408}
1409class SubNavigationStack {
1410    constructor() {
1411        this.primaryStack = new MyNavPathStack();
1412        this.secondaryStack = new MyNavPathStack();
1413        this.needRenderIsFullScreen = new NeedRenderIsFullScreen();
1414        this.multiOperates = [];
1415        this.primaryNavPathStackOperate = {
1416            onSystemPop: () => {
1417                this.multiOperates.forEach((m1) => {
1418                    m1.onPrimaryPop?.();
1419                });
1420            }
1421        };
1422        this.secondaryNavPathStackOperate = {
1423            onSystemPop: () => {
1424                this.multiOperates.forEach((l1) => {
1425                    l1.onSecondaryPop?.();
1426                });
1427                this.refreshFullScreen();
1428            }
1429        };
1430        this.primaryStack.registerStackOperateCallback(this.primaryNavPathStackOperate);
1431        this.secondaryStack.registerStackOperateCallback(this.secondaryNavPathStackOperate);
1432    }
1433    registerMultiStackOperateCallback(i1) {
1434        let j1 = this.multiOperates.findIndex((k1) => { return k1 === i1; });
1435        if (j1 === -1) {
1436            this.multiOperates.push(i1);
1437        }
1438    }
1439    unregisterMultiStackOperateCallback(f1) {
1440        let g1 = this.multiOperates.findIndex((h1) => { return h1 === f1; });
1441        if (g1 !== -1) {
1442            this.multiOperates.splice(g1, 1);
1443        }
1444    }
1445    getPrimaryPolicy() {
1446        if (this.primaryStack.policyInfoList.length < 1) {
1447            return undefined;
1448        }
1449        return this.primaryStack.policyInfoList[0].policy;
1450    }
1451    getPrimaryInfoList() {
1452        return this.primaryStack.policyInfoList.slice();
1453    }
1454    getSecondaryInfoList() {
1455        return this.secondaryStack.policyInfoList.slice();
1456    }
1457    getAllInfoLength() {
1458        return this.primaryStack.size() + this.secondaryStack.size();
1459    }
1460    hasPrimaryInfo() {
1461        return this.primaryStack.size() !== 0;
1462    }
1463    hasSecondaryInfo() {
1464        return this.secondaryStack.size() !== 0;
1465    }
1466    pushPrimaryPath(d1, e1) {
1467        this.primaryStack.policyInfoList.push(d1);
1468        this.primaryStack.pushPath(d1.navInfo, e1);
1469        this.refreshFullScreen();
1470    }
1471    pushSecondaryPath(b1, c1) {
1472        this.secondaryStack.policyInfoList.push(b1);
1473        this.secondaryStack.pushPath(b1.navInfo, c1);
1474        this.refreshFullScreen();
1475    }
1476    removeByIndexes(w) {
1477        if (w.length < 1) {
1478            return;
1479        }
1480        if (w[0] === 0) {
1481            hilog.info(0x0000, 'MultiNavigation', 'SubNavigationStack removeByIndexes primaryStack');
1482            this.primaryStack.removeByIndexes([0]);
1483            this.primaryStack.policyInfoList.pop();
1484            this.clear(false);
1485            return;
1486        }
1487        if (w.length !== 0) {
1488            let x = [];
1489            w.forEach((a1) => {
1490                x.push(a1 - 1);
1491            });
1492            this.secondaryStack.removeByIndexes(x);
1493            this.secondaryStack.policyInfoList = this.secondaryStack.policyInfoList.filter((y, z) => {
1494                return y && !x.includes(z);
1495            });
1496        }
1497        this.refreshFullScreen();
1498    }
1499    removeByName(t) {
1500        this.primaryStack.removeByName(t);
1501        this.primaryStack.policyInfoList = this.primaryStack.policyInfoList.filter((v) => {
1502            return v.navInfo?.name !== t;
1503        });
1504        if (!this.hasPrimaryInfo()) {
1505            this.clear(false);
1506            return;
1507        }
1508        this.secondaryStack.removeByName(t);
1509        this.secondaryStack.policyInfoList = this.secondaryStack.policyInfoList.filter((u) => {
1510            return u.navInfo?.name !== t;
1511        });
1512        this.refreshFullScreen();
1513    }
1514    pop(q, r) {
1515        let s = undefined;
1516        if (this.secondaryStack.policyInfoList.length > 0) {
1517            s = this.popSecondary(q, r);
1518        }
1519        else {
1520            s = this.popPrimary(q, r);
1521        }
1522        this.refreshFullScreen();
1523        return s;
1524    }
1525    clearSecondary(p) {
1526        this.secondaryStack.clear(p);
1527        this.secondaryStack.policyInfoList.splice(0);
1528        this.refreshFullScreen();
1529    }
1530    clearSecondaryKeepPlaceHolder(o) {
1531        this.secondaryStack.popToIndex(0, o);
1532        this.secondaryStack.policyInfoList.splice(1);
1533        this.refreshFullScreen();
1534    }
1535    clear(n) {
1536        this.secondaryStack.clear(n);
1537        this.primaryStack.clear(n);
1538        this.secondaryStack.policyInfoList.splice(0);
1539        this.primaryStack.policyInfoList.splice(0);
1540    }
1541    disableAnimation(m) {
1542        this.primaryStack.disableAnimation(m);
1543        this.secondaryStack.disableAnimation(m);
1544    }
1545    replacePath(k, l) {
1546        if (this.secondaryStack.policyInfoList.length > 0) {
1547            this.replaceSecond(k, l);
1548        }
1549        else {
1550            this.replacePrimary(k, l);
1551        }
1552        this.refreshFullScreen();
1553    }
1554    refreshFullScreen() {
1555        let i = this.secondaryStack.policyInfoList.length;
1556        if (i > 0) {
1557            this.needRenderIsFullScreen.isFullScreen = this.secondaryStack.policyInfoList[i - 1].isFullScreen;
1558            return;
1559        }
1560        let j = this.primaryStack.policyInfoList.length;
1561        if (j > 0) {
1562            this.needRenderIsFullScreen.isFullScreen = this.primaryStack.policyInfoList[j - 1].isFullScreen;
1563        }
1564    }
1565    replacePrimary(g, h) {
1566        this.primaryStack.policyInfoList.pop();
1567        this.primaryStack.policyInfoList.push(g);
1568        return this.primaryStack.replacePath(g.navInfo, h);
1569    }
1570    replaceSecond(e, f) {
1571        this.secondaryStack.policyInfoList.pop();
1572        this.secondaryStack.policyInfoList.push(e);
1573        return this.secondaryStack.replacePath(e.navInfo, f);
1574    }
1575    popPrimary(c, d) {
1576        this.primaryStack.policyInfoList.pop();
1577        return this.primaryStack.popInner(c, d);
1578    }
1579    popSecondary(a, b) {
1580        this.secondaryStack.policyInfoList.pop();
1581        return this.secondaryStack.popInner(a, b);
1582    }
1583}
1584
1585export default { MultiNavigation, MultiNavPathStack, SplitPolicy }