import React, { createContext, useContext } from 'react';

/**
 * OsKey Context
 * 用于在 TicketBooking 组件树中提供 pisellos 的 osKey
 * osKey 用于区分不同页面使用同一个组件时的模块标识
 */

var OsKeyContext = /*#__PURE__*/createContext({
  osKey: undefined
});
/**
 * OsKey Provider
 * 提供 osKey 给子组件使用
 */
export var OsKeyProvider = function OsKeyProvider(_ref) {
  var osKey = _ref.osKey,
    children = _ref.children;
  return /*#__PURE__*/React.createElement(OsKeyContext.Provider, {
    value: {
      osKey: osKey
    }
  }, children);
};

/**
 * useOsKey Hook
 * 在子组件中使用此 hook 获取 osKey
 */
export var useOsKey = function useOsKey() {
  var context = useContext(OsKeyContext);
  if (!context) {
    throw new Error('useOsKey must be used within an OsKeyProvider');
  }
  return (context === null || context === void 0 ? void 0 : context.osKey) || "ticket";
};
export default OsKeyContext;