export default Behavior({
  data: {},
  lifetimes: {
    attached() {
      const { windowWidth, windowHeight, safeArea } = wx.getWindowInfo();
      const { top, bottom, right } = wx.getMenuButtonBoundingClientRect();
      const offsetTop = Math.max(0, top - safeArea.top);
      const bleeding = windowWidth - right;
      const container = {
        width: windowWidth,
        height: windowHeight - bottom - offsetTop,
        maxHeight: windowHeight - bottom,
        safeWidth: safeArea.right - safeArea.left,
        safeHeight: safeArea.bottom - bottom - offsetTop,
        safeBottomOffset: windowHeight - safeArea.bottom,
        bleeding,
      }
      this.setData({
        container,
        containerStyle: Object.entries(container).map(([key, value]) => `--page-container-${key}:${value}px;`).join('')
      })
    }
  }
})