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
16if (!('finalizeConstruction' in ViewPU.prototype)) {
17  Reflect.set(ViewPU.prototype, 'finalizeConstruction', () => {});
18}
19const display = globalThis.requireNapi('display');
20const window = globalThis.requireNapi('window');
21const hilog = globalThis.requireNapi('hilog');
22const LengthMetrics = globalThis.requireNapi('arkui.node').LengthMetrics;
23const curves = globalThis.requireNativeModule('ohos.curves');
24const mediaQuery = requireNapi('mediaquery');
25export var ExtraRegionPosition;
26(function (k3) {
27  k3[(k3.TOP = 1)] = 'TOP';
28  k3[(k3.BOTTOM = 2)] = 'BOTTOM';
29})(ExtraRegionPosition || (ExtraRegionPosition = {}));
30export var PresetSplitRatio;
31(function (s4) {
32  s4[(s4.LAYOUT_1V1 = 1)] = 'LAYOUT_1V1';
33  s4[(s4.LAYOUT_2V3 = 0.6666666666666666)] = 'LAYOUT_2V3';
34  s4[(s4.LAYOUT_3V2 = 1.5)] = 'LAYOUT_3V2';
35})(PresetSplitRatio || (PresetSplitRatio = {}));
36function withDefaultValue(h3, i3) {
37  if (h3 === void 0 || h3 === null) {
38    return i3;
39  }
40  return h3;
41}
42function getSplitRatio(f3, g3) {
43  if (f3 === void 0 || f3 === null) {
44    return g3;
45  }
46  if (f3 <= 0) {
47    return g3;
48  }
49  return f3;
50}
51class Logger {
52  static debug(d3, ...e3) {
53    return hilog.debug(0x3900, 'FoldSplitContainer', d3, ...e3);
54  }
55  static info(b3, ...c3) {
56    return hilog.info(0x3900, 'FoldSplitContainer', b3, ...c3);
57  }
58  static error(z2, ...a3) {
59    return hilog.error(0x3900, 'FoldSplitContainer', z2, ...a3);
60  }
61}
62function initLayout() {
63  return {
64    size: { width: 0, height: 0 },
65    position: { x: 0, y: 0 },
66  };
67}
68export class FoldSplitContainer extends ViewPU {
69  constructor(t2, u2, v2, w2 = -1, x2 = undefined, y2) {
70    super(t2, v2, w2, y2);
71    if (typeof x2 === 'function') {
72      this.paramsGenerator_ = x2;
73    }
74    this.primary = undefined;
75    this.secondary = undefined;
76    this.extra = undefined;
77    this.__expandedLayoutOptions = new SynchedPropertyObjectOneWayPU(
78      u2.expandedLayoutOptions,
79      this,
80      'expandedLayoutOptions'
81    );
82    this.__hoverModeLayoutOptions = new SynchedPropertyObjectOneWayPU(
83      u2.hoverModeLayoutOptions,
84      this,
85      'hoverModeLayoutOptions'
86    );
87    this.__foldedLayoutOptions = new SynchedPropertyObjectOneWayPU(
88      u2.foldedLayoutOptions,
89      this,
90      'foldedLayoutOptions'
91    );
92    this.__animationOptions = new SynchedPropertyObjectOneWayPU(
93      u2.animationOptions,
94      this,
95      'animationOptions'
96    );
97    this.onHoverStatusChange = () => {};
98    this.__primaryLayout = new ObservedPropertyObjectPU(
99      initLayout(),
100      this,
101      'primaryLayout'
102    );
103    this.__secondaryLayout = new ObservedPropertyObjectPU(
104      initLayout(),
105      this,
106      'secondaryLayout'
107    );
108    this.__extraLayout = new ObservedPropertyObjectPU(
109      initLayout(),
110      this,
111      'extraLayout'
112    );
113    this.__extraOpacity = new ObservedPropertySimplePU(1, this, 'extraOpacity');
114    this.windowStatusType = window.WindowStatusType.UNDEFINED;
115    this.foldStatus = display.FoldStatus.FOLD_STATUS_UNKNOWN;
116    this.rotation = 0;
117    this.windowInstance = undefined;
118    this.containerSize = { width: 0, height: 0 };
119    this.containerGlobalPosition = { x: 0, y: 0 };
120    this.listener = undefined;
121    this.isSmallScreen = false;
122    this.isHoverMode = undefined;
123    this.setInitiallyProvidedValue(u2);
124    this.declareWatch('expandedLayoutOptions', this.updateLayout);
125    this.declareWatch('hoverModeLayoutOptions', this.updateLayout);
126    this.declareWatch('foldedLayoutOptions', this.updateLayout);
127    this.finalizeConstruction();
128  }
129  setInitiallyProvidedValue(s2) {
130    if (s2.primary !== undefined) {
131      this.primary = s2.primary;
132    }
133    if (s2.secondary !== undefined) {
134      this.secondary = s2.secondary;
135    }
136    if (s2.extra !== undefined) {
137      this.extra = s2.extra;
138    }
139    if (s2.expandedLayoutOptions === undefined) {
140      this.__expandedLayoutOptions.set({
141        horizontalSplitRatio: PresetSplitRatio.LAYOUT_3V2,
142        verticalSplitRatio: PresetSplitRatio.LAYOUT_1V1,
143        isExtraRegionPerpendicular: true,
144        extraRegionPosition: ExtraRegionPosition.TOP,
145      });
146    }
147    if (s2.hoverModeLayoutOptions === undefined) {
148      this.__hoverModeLayoutOptions.set({
149        horizontalSplitRatio: PresetSplitRatio.LAYOUT_3V2,
150        showExtraRegion: false,
151        extraRegionPosition: ExtraRegionPosition.TOP,
152      });
153    }
154    if (s2.foldedLayoutOptions === undefined) {
155      this.__foldedLayoutOptions.set({
156        verticalSplitRatio: PresetSplitRatio.LAYOUT_1V1,
157      });
158    }
159    if (s2.animationOptions === undefined) {
160      this.__animationOptions.set(undefined);
161    }
162    if (s2.onHoverStatusChange !== undefined) {
163      this.onHoverStatusChange = s2.onHoverStatusChange;
164    }
165    if (s2.primaryLayout !== undefined) {
166      this.primaryLayout = s2.primaryLayout;
167    }
168    if (s2.secondaryLayout !== undefined) {
169      this.secondaryLayout = s2.secondaryLayout;
170    }
171    if (s2.extraLayout !== undefined) {
172      this.extraLayout = s2.extraLayout;
173    }
174    if (s2.extraOpacity !== undefined) {
175      this.extraOpacity = s2.extraOpacity;
176    }
177    if (s2.windowStatusType !== undefined) {
178      this.windowStatusType = s2.windowStatusType;
179    }
180    if (s2.foldStatus !== undefined) {
181      this.foldStatus = s2.foldStatus;
182    }
183    if (s2.windowInstance !== undefined) {
184      this.windowInstance = s2.windowInstance;
185    }
186    if (s2.containerSize !== undefined) {
187      this.containerSize = s2.containerSize;
188    }
189    if (s2.containerGlobalPosition !== undefined) {
190      this.containerGlobalPosition = s2.containerGlobalPosition;
191    }
192    if (s2.listener !== undefined) {
193      this.listener = s2.listener;
194    }
195    if (s2.isSmallScreen !== undefined) {
196      this.isSmallScreen = s2.isSmallScreen;
197    }
198    if (s2.isHoverMode !== undefined) {
199      this.isHoverMode = s2.isHoverMode;
200    }
201  }
202  updateStateVars(r2) {
203    this.__expandedLayoutOptions.reset(r2.expandedLayoutOptions);
204    this.__hoverModeLayoutOptions.reset(r2.hoverModeLayoutOptions);
205    this.__foldedLayoutOptions.reset(r2.foldedLayoutOptions);
206    this.__animationOptions.reset(r2.animationOptions);
207  }
208  purgeVariableDependenciesOnElmtId(q2) {
209    this.__expandedLayoutOptions.purgeDependencyOnElmtId(q2);
210    this.__hoverModeLayoutOptions.purgeDependencyOnElmtId(q2);
211    this.__foldedLayoutOptions.purgeDependencyOnElmtId(q2);
212    this.__animationOptions.purgeDependencyOnElmtId(q2);
213    this.__primaryLayout.purgeDependencyOnElmtId(q2);
214    this.__secondaryLayout.purgeDependencyOnElmtId(q2);
215    this.__extraLayout.purgeDependencyOnElmtId(q2);
216    this.__extraOpacity.purgeDependencyOnElmtId(q2);
217  }
218  aboutToBeDeleted() {
219    this.__expandedLayoutOptions.aboutToBeDeleted();
220    this.__hoverModeLayoutOptions.aboutToBeDeleted();
221    this.__foldedLayoutOptions.aboutToBeDeleted();
222    this.__animationOptions.aboutToBeDeleted();
223    this.__primaryLayout.aboutToBeDeleted();
224    this.__secondaryLayout.aboutToBeDeleted();
225    this.__extraLayout.aboutToBeDeleted();
226    this.__extraOpacity.aboutToBeDeleted();
227    SubscriberManager.Get().delete(this.id__());
228    this.aboutToBeDeletedInternal();
229  }
230  get expandedLayoutOptions() {
231    return this.__expandedLayoutOptions.get();
232  }
233  set expandedLayoutOptions(p2) {
234    this.__expandedLayoutOptions.set(p2);
235  }
236  get hoverModeLayoutOptions() {
237    return this.__hoverModeLayoutOptions.get();
238  }
239  set hoverModeLayoutOptions(f1) {
240    this.__hoverModeLayoutOptions.set(f1);
241  }
242  get foldedLayoutOptions() {
243    return this.__foldedLayoutOptions.get();
244  }
245  set foldedLayoutOptions(n2) {
246    this.__foldedLayoutOptions.set(n2);
247  }
248  get animationOptions() {
249    return this.__animationOptions.get();
250  }
251  set animationOptions(n4) {
252    this.__animationOptions.set(n4);
253  }
254  get primaryLayout() {
255    return this.__primaryLayout.get();
256  }
257  set primaryLayout(m2) {
258    this.__primaryLayout.set(m2);
259  }
260  get secondaryLayout() {
261    return this.__secondaryLayout.get();
262  }
263  set secondaryLayout(l2) {
264    this.__secondaryLayout.set(l2);
265  }
266  get extraLayout() {
267    return this.__extraLayout.get();
268  }
269  set extraLayout(k2) {
270    this.__extraLayout.set(k2);
271  }
272  get extraOpacity() {
273    return this.__extraOpacity.get();
274  }
275  set extraOpacity(l1) {
276    this.__extraOpacity.set(l1);
277  }
278  aboutToAppear() {
279    this.listener = mediaQuery.matchMediaSync('(width<=600vp)');
280    this.isSmallScreen = this.listener.matches;
281    this.listener.on('change', (m4) => {
282      this.isSmallScreen = m4.matches;
283    });
284    try {
285      this.foldStatus = display.getFoldStatus();
286    } catch (exception) {
287      Logger.error('Failed getFoldStatus. code:%{public}d, message:%{public}s',
288        exception.code, exception.message);
289    }
290    try {
291      display.on('foldStatusChange', (j4) => {
292        if (this.foldStatus !== j4) {
293          this.foldStatus = j4;
294          this.updateLayout();
295          this.updatePreferredOrientation();
296        }
297      });
298    } catch (exception) {
299      Logger.error('Failed display.on foldStatusChange. code:%{public}d, message:%{public}s',
300        exception.code, exception.message);
301    }
302    try {
303      window.getLastWindow(this.getUIContext().getHostContext(), (e4, f4) => {
304        if (e4 && e4.code) {
305          Logger.error(
306            'Failed to get window instance, error code: %{public}d',
307            e4.code
308          );
309          return;
310        }
311        const g4 = f4.getWindowProperties().id;
312        if (g4 < 0) {
313          Logger.error(
314            'Failed to get window instance because the window id is invalid. window id: %{public}d', g4);
315          return;
316        }
317        this.windowInstance = f4;
318        this.updatePreferredOrientation();
319        this.dealWindowStatusChange();
320      });
321    } catch (exception) {
322      Logger.error('Failed getLastWindow code:%{public}d, message:%{public}s', exception.code, exception.message);
323    }
324  }
325
326  dealWindowStatusChange() {
327    try {
328      this.windowInstance.on('windowStatusChange', (i4) => {
329        this.windowStatusType = i4;
330      });
331    } catch (exception) {
332      Logger.error('Failed windowInstance.on windowStatusChange. code:%{public}d, message:%{public}s',
333        exception.code, exception.message);
334    }
335  }
336
337  aboutToDisappear() {
338    if (this.listener) {
339      this.listener.off('change');
340      this.listener = undefined;
341    }
342    try {
343      display.off('foldStatusChange');
344    } catch (exception) {
345      Logger.error('Failed display.off foldStatusChange. code:%{public}d, message:%{public}s',
346        exception.code, exception.message);
347    }
348    if (this.windowInstance) {
349      this.windowInstance.off('windowStatusChange');
350    }
351  }
352  initialRender() {
353    this.observeComponentCreation2((y1, z1) => {
354      Stack.create();
355      Stack.id('$$FoldSplitContainer$Stack$$');
356      Stack.width('100%');
357      Stack.height('100%');
358      Stack.onSizeChange((b2, d4) => {
359        this.updateContainerSize(d4);
360        this.updateContainerPosition();
361        this.updateLayout();
362      });
363    }, Stack);
364    this.observeComponentCreation2((w1, x1) => {
365      Column.create();
366      Column.size(this.primaryLayout.size);
367      Column.position({
368        start: LengthMetrics.vp(this.primaryLayout.position.x),
369        top: LengthMetrics.vp(this.primaryLayout.position.y),
370      });
371      Column.clip(true);
372    }, Column);
373    this.observeComponentCreation2((u1, v1) => {
374      If.create();
375      if (this.primary) {
376        this.ifElseBranchUpdateFunction(0, () => {
377          this.primary.bind(this)(this);
378        });
379      } else {
380        this.ifElseBranchUpdateFunction(1, () => {});
381      }
382    }, If);
383    If.pop();
384    Column.pop();
385    this.observeComponentCreation2((n1, o1) => {
386      Column.create();
387      Column.size(this.secondaryLayout.size);
388      Column.position({
389        start: LengthMetrics.vp(this.secondaryLayout.position.x),
390        top: LengthMetrics.vp(this.secondaryLayout.position.y),
391      });
392      Column.clip(true);
393    }, Column);
394    this.observeComponentCreation2((u3, v3) => {
395      If.create();
396      if (this.secondary) {
397        this.ifElseBranchUpdateFunction(0, () => {
398          this.secondary.bind(this)(this);
399        });
400      } else {
401        this.ifElseBranchUpdateFunction(1, () => {});
402      }
403    }, If);
404    If.pop();
405    Column.pop();
406    this.observeComponentCreation2((i2, j2) => {
407      If.create();
408      if (this.extra) {
409        this.ifElseBranchUpdateFunction(0, () => {
410          this.observeComponentCreation2((n3, o3) => {
411            Column.create();
412            Context.animation({ curve: Curve.Linear, duration: 250 });
413            Column.opacity(this.extraOpacity);
414            Context.animation(null);
415            Column.size(this.extraLayout.size);
416            Column.position({
417              start: LengthMetrics.vp(this.extraLayout.position.x),
418              top: LengthMetrics.vp(this.extraLayout.position.y),
419            });
420            Column.clip(true);
421          }, Column);
422          this.extra?.bind(this)?.(this);
423          Column.pop();
424        });
425      } else {
426        this.ifElseBranchUpdateFunction(1, () => {});
427      }
428    }, If);
429    If.pop();
430    Stack.pop();
431  }
432  dispatchHoverStatusChange(b4) {
433    if (this.onHoverStatusChange) {
434      try {
435        this.rotation = display.getDefaultDisplaySync().rotation;
436      } catch (exception) {
437        Logger.error('Failed display.getDefaultDisplaySync(). code:%{public}d, message:%{public}s',
438          exception.code, exception.message);
439      }
440      this.onHoverStatusChange({
441        foldStatus: this.foldStatus,
442        isHoverMode: b4,
443        appRotation: this.rotation,
444        windowStatusType: this.windowStatusType,
445      });
446    }
447  }
448  hasExtraRegion() {
449    return !!this.extra;
450  }
451  async updatePreferredOrientation() {
452    if (this.windowInstance) {
453      try {
454        if (this.foldStatus === display.FoldStatus.FOLD_STATUS_FOLDED) {
455          await this.windowInstance.setPreferredOrientation(
456            window.Orientation.AUTO_ROTATION_PORTRAIT
457          );
458        } else {
459          await this.windowInstance.setPreferredOrientation(
460            window.Orientation.AUTO_ROTATION
461          );
462        }
463      } catch (i1) {
464        Logger.error('Failed to update preferred orientation.');
465      }
466    }
467  }
468  updateContainerSize(a4) {
469    this.containerSize.width = a4.width;
470    this.containerSize.height = a4.height;
471  }
472  updateContainerPosition() {
473    const y3 = this.getUIContext();
474    const z3 = y3.getFrameNodeById('$$FoldSplitContainer$Stack$$');
475    if (z3) {
476      this.containerGlobalPosition = z3.getPositionToWindow();
477    }
478  }
479  updateLayout() {
480    let t1 = false;
481    let g1;
482    if (this.isSmallScreen) {
483      g1 = this.getFoldedRegionLayouts();
484    } else {
485      if (this.foldStatus === display.FoldStatus.FOLD_STATUS_EXPANDED) {
486        g1 = this.getExpandedRegionLayouts();
487      } else if (
488        this.foldStatus === display.FoldStatus.FOLD_STATUS_HALF_FOLDED
489      ) {
490        if (this.isPortraitOrientation()) {
491          g1 = this.getExpandedRegionLayouts();
492        } else {
493          g1 = this.getHoverModeRegionLayouts();
494          t1 = true;
495        }
496      } else if (this.foldStatus === display.FoldStatus.FOLD_STATUS_FOLDED) {
497        g1 = this.getFoldedRegionLayouts();
498      } else {
499        g1 = this.getExpandedRegionLayouts();
500      }
501    }
502    if (this.animationOptions === null) {
503      this.primaryLayout = g1.primary;
504      this.secondaryLayout = g1.secondary;
505      this.extraLayout = g1.extra;
506    } else if (this.animationOptions === void 0) {
507      Context.animateTo({ curve: curves.springMotion(0.35, 1, 0) }, () => {
508        this.primaryLayout = g1.primary;
509        this.secondaryLayout = g1.secondary;
510        this.extraLayout = g1.extra;
511      });
512    } else {
513      Context.animateTo(this.animationOptions, () => {
514        this.primaryLayout = g1.primary;
515        this.secondaryLayout = g1.secondary;
516        this.extraLayout = g1.extra;
517      });
518    }
519    if (this.isHoverMode !== t1) {
520      this.dispatchHoverStatusChange(t1);
521      this.isHoverMode = t1;
522    }
523    if (t1 && !this.hoverModeLayoutOptions.showExtraRegion) {
524      this.extraOpacity = 0;
525    } else {
526      this.extraOpacity = 1;
527    }
528  }
529  getExpandedRegionLayouts() {
530    const x = this.containerSize.width;
531    const y = this.containerSize.height;
532    const z = initLayout();
533    const a1 = initLayout();
534    const b1 = initLayout();
535    const c1 = getSplitRatio(
536      this.expandedLayoutOptions.horizontalSplitRatio,
537      PresetSplitRatio.LAYOUT_3V2
538    );
539    const d1 = getSplitRatio(
540      this.expandedLayoutOptions.verticalSplitRatio,
541      PresetSplitRatio.LAYOUT_1V1
542    );
543    if (this.hasExtraRegion()) {
544      b1.size.width = x / (c1 + 1);
545    } else {
546      b1.size.width = 0;
547    }
548    a1.size.height = y / (d1 + 1);
549    z.size.height = y - a1.size.height;
550    z.position.x = 0;
551    a1.position.x = 0;
552    z.position.y = 0;
553    a1.position.y = z.size.height;
554    const e1 = withDefaultValue(
555      this.expandedLayoutOptions.isExtraRegionPerpendicular,
556      true
557    );
558    if (e1) {
559      z.size.width = x - b1.size.width;
560      a1.size.width = x - b1.size.width;
561      b1.size.height = y;
562      b1.position.x = z.size.width;
563      b1.position.y = 0;
564    } else {
565      const j1 = withDefaultValue(
566        this.expandedLayoutOptions.extraRegionPosition,
567        ExtraRegionPosition.TOP
568      );
569      if (j1 === ExtraRegionPosition.BOTTOM) {
570        z.size.width = x;
571        a1.size.width = x - b1.size.width;
572        b1.size.height = a1.size.height;
573        b1.position.x = a1.size.width;
574        b1.position.y = z.size.height;
575      } else {
576        z.size.width = x - b1.size.width;
577        a1.size.width = x;
578        b1.size.height = z.size.height;
579        b1.position.x = z.size.width;
580        b1.position.y = 0;
581      }
582    }
583    return { primary: z, secondary: a1, extra: b1 };
584  }
585  getHoverModeRegionLayouts() {
586    const o = this.containerSize.width;
587    const p = this.containerSize.height;
588    const q = initLayout();
589    const r = initLayout();
590    const s = initLayout();
591    const t = this.getCreaseRegionRect();
592    q.position.x = 0;
593    q.position.y = 0;
594    r.position.x = 0;
595    r.position.y = t.top + t.height;
596    r.size.height = p - r.position.y;
597    q.size.height = t.top;
598    const u = withDefaultValue(
599      this.hoverModeLayoutOptions.showExtraRegion,
600      false
601    );
602    if (!u) {
603      q.size.width = o;
604      r.size.width = o;
605      s.position.x = o;
606      const r1 = withDefaultValue(
607        this.expandedLayoutOptions.isExtraRegionPerpendicular,
608        true
609      );
610      if (r1) {
611        s.size.height = this.extraLayout.size.height;
612      } else {
613        const s1 = withDefaultValue(
614          this.expandedLayoutOptions.extraRegionPosition,
615          ExtraRegionPosition.TOP
616        );
617        if (s1 === ExtraRegionPosition.BOTTOM) {
618          s.size.height = r.size.height;
619          s.position.y = r.position.y;
620        } else {
621          s.size.height = q.size.height;
622          s.position.y = 0;
623        }
624      }
625    } else {
626      const p1 = getSplitRatio(
627        this.hoverModeLayoutOptions.horizontalSplitRatio,
628        PresetSplitRatio.LAYOUT_3V2
629      );
630      const q1 = withDefaultValue(
631        this.hoverModeLayoutOptions.extraRegionPosition,
632        ExtraRegionPosition.TOP
633      );
634      if (this.hasExtraRegion()) {
635        s.size.width = o / (p1 + 1);
636      } else {
637        s.size.width = 0;
638      }
639      if (q1 === ExtraRegionPosition.BOTTOM) {
640        q.size.width = o;
641        r.size.width = o - s.size.width;
642        s.size.height = r.size.height;
643        s.position.x = r.size.width;
644        s.position.y = r.position.y;
645      } else {
646        s.size.height = q.size.height;
647        q.size.width = o - s.size.width;
648        r.size.width = o;
649        s.position.x = q.position.x + q.size.width;
650        s.position.y = 0;
651      }
652    }
653    return { primary: q, secondary: r, extra: s };
654  }
655  getFoldedRegionLayouts() {
656    const i = this.containerSize.width;
657    const j = this.containerSize.height;
658    const k = initLayout();
659    const l = initLayout();
660    const m = initLayout();
661    const n = getSplitRatio(
662      this.foldedLayoutOptions.verticalSplitRatio,
663      PresetSplitRatio.LAYOUT_1V1
664    );
665    l.size.height = j / (n + 1);
666    k.size.height = j - l.size.height;
667    m.size.height = 0;
668    k.size.width = i;
669    l.size.width = i;
670    m.size.width = 0;
671    k.position.x = 0;
672    l.position.x = 0;
673    m.position.x = i;
674    k.position.y = 0;
675    l.position.y = k.size.height;
676    m.position.y = 0;
677    return { primary: k, secondary: l, extra: m };
678  }
679  getCreaseRegionRect() {
680    const b = display.getCurrentFoldCreaseRegion();
681    const c = b.creaseRects;
682    let d = 0;
683    let e = 0;
684    let f = 0;
685    let g = 0;
686    if (c && c.length) {
687      const h = c[0];
688      d = px2vp(h.left) - this.containerGlobalPosition.x;
689      e = px2vp(h.top) - this.containerGlobalPosition.y;
690      f = px2vp(h.width);
691      g = px2vp(h.height);
692    }
693    return { left: d, top: e, width: f, height: g };
694  }
695  isPortraitOrientation() {
696    let a;
697    try {
698      a = display.getDefaultDisplaySync();
699    } catch (exception) {
700      Logger.error('Failed getDefaultDisplaySync. code:%{public}d, message:%{public}s',
701        exception.code, exception.message);
702    }
703    switch (a.orientation) {
704      case display.Orientation.PORTRAIT:
705      case display.Orientation.PORTRAIT_INVERTED:
706        return true;
707      case display.Orientation.LANDSCAPE:
708      case display.Orientation.LANDSCAPE_INVERTED:
709      default:
710        return false;
711    }
712  }
713  rerender() {
714    this.updateDirtyElements();
715  }
716}
717
718export default { ExtraRegionPosition, PresetSplitRatio, FoldSplitContainer };
719