function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
import React from 'react';
import classNames from 'classnames';
/**
 * 横向：指针容器宽度，与 SVG viewBox 宽一致（几何居中于 offsetPx）。
 * 竖向：横线高度的一半，用于 top 对齐。
 */
var CURSOR_ANCHOR_WIDTH_H = 22;
var CURSOR_LINE_HEIGHT_V = 2;

/**
 * 时间指示器层：横向为「顶三角 + 竖长方条」SVG，竖向为横线 + 时间气泡
 * 对齐基准为几何中心。Realtime 态 #FF692E，浏览态 #344054
 */
export function CursorLayer(_ref) {
  var orientation = _ref.orientation,
    value = _ref.value,
    timeFormat = _ref.timeFormat,
    locale = _ref.locale,
    isRealtime = _ref.isRealtime,
    offsetPx = _ref.offsetPx,
    fixedCenter = _ref.fixedCenter,
    style = _ref.style,
    className = _ref.className,
    dragInteractive = _ref.dragInteractive,
    onDragPointerDown = _ref.onDragPointerDown,
    onDragPointerMove = _ref.onDragPointerMove,
    onDragPointerUp = _ref.onDragPointerUp,
    onDragPointerCancel = _ref.onDragPointerCancel;
  if (value == null) return null;
  var label = locale ? value.locale(locale).format(timeFormat) : value.format(timeFormat);
  var isHorizontal = orientation === 'horizontal';
  /** 以指针水平/垂直中心为 offsetPx，故定位到 offsetPx - 锚宽(高)的一半 */
  var lineOffset = offsetPx - (isHorizontal ? CURSOR_ANCHOR_WIDTH_H / 2 : CURSOR_LINE_HEIGHT_V / 2);
  var positionStyle = fixedCenter ? style !== null && style !== void 0 ? style : {} : dragInteractive && isHorizontal ? _objectSpread(_objectSpread({}, style), {}, {
    left: offsetPx,
    transform: 'translateX(-50%)',
    width: 36
  }) : dragInteractive && !isHorizontal ? _objectSpread(_objectSpread({}, style), {}, {
    top: offsetPx,
    transform: 'translateX(-50%) translateY(-50%)',
    height: 40
  }) : _objectSpread(_objectSpread({}, style), {}, _defineProperty({}, isHorizontal ? 'left' : 'top', lineOffset));
  return /*#__PURE__*/React.createElement("div", {
    className: classNames('pisell-time-navigator-cursor', "pisell-time-navigator-cursor--".concat(orientation), {
      'pisell-time-navigator-cursor--realtime': isRealtime
    }, {
      'pisell-time-navigator-cursor--fixed': fixedCenter
    }, {
      'pisell-time-navigator-cursor--draggable': dragInteractive
    }, className),
    style: positionStyle,
    "aria-hidden": true,
    onPointerDown: dragInteractive ? onDragPointerDown : undefined,
    onPointerMove: dragInteractive ? onDragPointerMove : undefined,
    onPointerUp: dragInteractive ? onDragPointerUp : undefined,
    onPointerCancel: dragInteractive ? onDragPointerCancel : undefined
  }, isHorizontal ? /*#__PURE__*/React.createElement("svg", {
    className: "pisell-time-navigator-cursor-line pisell-time-navigator-cursor-line--token",
    viewBox: "0 0 22 100",
    preserveAspectRatio: "none",
    focusable: "false",
    "aria-hidden": true
  }, /*#__PURE__*/React.createElement("path", {
    fill: "currentColor",
    d: "M 11 0 L 18 11 L 18 100 L 4 100 L 4 11 Z"
  })) : /*#__PURE__*/React.createElement("span", {
    className: "pisell-time-navigator-cursor-line"
  }), /*#__PURE__*/React.createElement("span", {
    className: "pisell-time-navigator-cursor-bubble"
  }, label));
}