function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
import React, { useState } from 'react';
import dayjs from 'dayjs';
import { PisellReservationScheduleBand } from "./PisellReservationScheduleBand";
/**
 * PisellReservationScheduleBand：营业日条 + 横向时间轴顶栏组合，统一 value `{ date, at }`。
 * 详见组件目录下 docs/PisellReservationScheduleBand.md。
 */
var meta = {
  title: 'Data Entry/PisellReservationScheduleBand',
  component: PisellReservationScheduleBand,
  tags: ['autodocs'],
  parameters: {
    layout: 'padded',
    docs: {
      description: {
        component: '纵向组合 PisellReservationSchedule 与 PisellTimeNavigator：选中日 `date` 与轴上时刻 `at` 由单一状态驱动；换日时会保留原时刻的时分并映射到新日。可通过 `scheduleProps` / `timeNavigatorProps` 透传子组件配置，适合作为 RecordBoard 等容器的 toolBar 顶栏。'
      }
    }
  },
  argTypes: {
    value: {
      description: '受控：{ date: Dayjs, at: Dayjs }',
      control: 'object'
    },
    defaultValue: {
      description: '非受控初始值，可只传 date 或 at',
      control: 'object'
    },
    scheduleProps: {
      description: '透传给 PisellReservationSchedule（不含 value/onChange/defaultValue）',
      control: 'object'
    },
    timeNavigatorProps: {
      description: '透传给 PisellTimeNavigator（不含 value/onChange/referenceDate）',
      control: 'object'
    },
    onChange: {
      action: 'onChange',
      description: 'date 或 at 变化时触发，参数已归一化'
    },
    className: {
      control: 'text'
    },
    scheduleStartSlot: {
      description: '日程行左侧插槽（如标题）',
      control: false
    },
    scheduleEndSlot: {
      description: '日程行右侧插槽（如状态、主按钮）',
      control: false
    }
  }
};
export default meta;
var wideDecorator = function wideDecorator(StoryComp) {
  return /*#__PURE__*/React.createElement("div", {
    style: {
      width: '100%',
      maxWidth: 960,
      minWidth: 480
    }
  }, /*#__PURE__*/React.createElement(StoryComp, null));
};
export var Default = {
  args: {},
  decorators: [wideDecorator]
};
export var CustomTimeNavigator = {
  args: {
    timeNavigatorProps: {
      stepMinutes: 30,
      majorStepMinutes: 120,
      showNowButton: true
    }
  },
  decorators: [wideDecorator]
};
export var ScheduleMinMax = {
  args: {
    scheduleProps: {
      minDate: dayjs().subtract(7, 'day'),
      maxDate: dayjs().add(7, 'day')
    },
    defaultValue: {
      date: dayjs().startOf('day')
    }
  },
  decorators: [wideDecorator]
};
export var Controlled = {
  render: function ControlledBandRender() {
    var _useState = useState(function () {
        return {
          date: dayjs().startOf('day'),
          at: dayjs()
        };
      }),
      _useState2 = _slicedToArray(_useState, 2),
      value = _useState2[0],
      setValue = _useState2[1];
    return /*#__PURE__*/React.createElement("div", {
      style: {
        width: '100%',
        maxWidth: 960,
        minWidth: 480
      }
    }, /*#__PURE__*/React.createElement(PisellReservationScheduleBand, {
      value: value,
      onChange: function onChange(next) {
        setValue(next);
        // eslint-disable-next-line no-console
        console.log('onChange', {
          date: next.date.format('YYYY-MM-DD'),
          at: next.at.format('YYYY-MM-DD HH:mm')
        });
      },
      timeNavigatorProps: {
        showNowButton: true
      }
    }), /*#__PURE__*/React.createElement("p", {
      style: {
        marginTop: 12,
        fontSize: 12,
        color: '#666'
      }
    }, "date: ", value.date.format('YYYY-MM-DD'), " \xB7 at:", ' ', value.at.format('HH:mm')));
  }
};
export var InitialPastDay = {
  args: {
    defaultValue: {
      date: dayjs().subtract(1, 'day').startOf('day'),
      at: dayjs().subtract(1, 'day').hour(14).minute(30).second(0)
    },
    timeNavigatorProps: {
      showNowButton: true
    }
  },
  decorators: [wideDecorator]
};

/** 日程行左右插槽：左标题 + 中间 PisellReservationSchedule + 右操作区（整条顶栏暗色背景需在业务外层自行包一层，避免压住下方时间轴） */
export var WithScheduleSlots = {
  render: function render() {
    return /*#__PURE__*/React.createElement("div", {
      style: {
        width: '100%',
        maxWidth: 960,
        minWidth: 480
      }
    }, /*#__PURE__*/React.createElement(PisellReservationScheduleBand, {
      scheduleStartSlot: /*#__PURE__*/React.createElement("span", {
        style: {
          fontSize: 15,
          fontWeight: 600
        }
      }, "Reservation"),
      scheduleEndSlot: /*#__PURE__*/React.createElement("div", {
        style: {
          display: 'flex',
          alignItems: 'center',
          gap: 12
        }
      }, /*#__PURE__*/React.createElement("span", {
        style: {
          fontSize: 13,
          color: '#595959'
        }
      }, /*#__PURE__*/React.createElement("span", {
        style: {
          color: '#52c41a',
          marginRight: 6
        }
      }, "\u25CF"), "Current"), /*#__PURE__*/React.createElement("button", {
        type: "button",
        style: {
          background: '#1677ff',
          color: '#fff',
          border: 'none',
          borderRadius: 8,
          padding: '6px 14px',
          fontSize: 14,
          cursor: 'pointer'
        }
      }, "+ \u65B0\u5EFA")),
      timeNavigatorProps: {
        showNowButton: true
      }
    }));
  }
};