/* index.tsx generated by @compiled/babel-plugin v0.38.1 */
"use strict";

var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
require("./index.compiled.css");
var _react = _interopRequireWildcard(require("react"));
var React = _react;
var _runtime = require("@compiled/react/runtime");
var _storageClient = require("@atlaskit/frontend-utilities/storage-client");
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
var LOCAL_STORAGE_CLIENT_KEY = '@atlaskit/smart-card';
var LOCAL_STORAGE_DISCOVERY_KEY = 'action-discovery-ai-summarise';
var LOCAL_STORAGE_DISCOVERY_VALUE = 'discovered';
var LOCAL_STORAGE_DISCOVERY_EXPIRY_IN_MS = 15552000000; // 180 days
var LOCAL_STORAGE_DISCOVERY_REQUIRED_TIME = 2000;
var pulseKeyframes = null;
var pulseStyles = null;

/**
 * This is a hacky solution to help with the feature discovery.
 * This implementation must be removed once the experiment is completed.
 * Cleanup on https://product-fabric.atlassian.net/browse/EDM-9649
 */
var FeatureDiscovery = function FeatureDiscovery(_ref) {
  var children = _ref.children,
    testId = _ref.testId;
  var renderedTime = (0, _react.useRef)();
  var storageClient = (0, _react.useMemo)(function () {
    return new _storageClient.StorageClient(LOCAL_STORAGE_CLIENT_KEY);
  }, []);
  var discovered = (0, _react.useMemo)(function () {
    try {
      return storageClient.getItem(LOCAL_STORAGE_DISCOVERY_KEY) === LOCAL_STORAGE_DISCOVERY_VALUE;
    } catch (_unused) {
      // If localStorage is not available, don't show feature discovery component. Treat it as 'discovered'.
      return true;
    }
  }, [storageClient]);
  (0, _react.useEffect)(function () {
    renderedTime.current = Date.now();
    return function () {
      if (!discovered && renderedTime.current) {
        var duration = Date.now() - renderedTime.current;
        if (duration > LOCAL_STORAGE_DISCOVERY_REQUIRED_TIME) {
          try {
            storageClient.setItemWithExpiry(LOCAL_STORAGE_DISCOVERY_KEY, LOCAL_STORAGE_DISCOVERY_VALUE, LOCAL_STORAGE_DISCOVERY_EXPIRY_IN_MS);
          } catch (_unused2) {
            // silent error
          }
        }
      }
    };
  }, [storageClient, discovered]);
  var component = (0, _react.useMemo)(function () {
    if (!discovered) {
      return /*#__PURE__*/React.createElement("span", {
        "data-testid": "".concat(testId, "-discovery"),
        className: (0, _runtime.ax)(["_2rkofajl _1e0c116y _16qslqk2 _j7hq8j16 _5sagymdr _1pgl1trn _ju251doz _1o511hrf _tip8cs5v"])
      }, children);
    }
  }, [children, discovered, testId]);
  return component !== null && component !== void 0 ? component : children;
};
var _default = exports.default = FeatureDiscovery;