"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.useShareableLink = useShareableLink;
var _reactQuery = require("@tanstack/react-query");
var _types = require("../../social/types");
var _tsSdkReactNative = require("@amityco/ts-sdk-react-native");
const REFERENCE_KEY = {
  [_types.ShareableLinkModel.posts]: 'postId',
  [_types.ShareableLinkModel.communities]: 'communityId',
  [_types.ShareableLinkModel.users]: 'userId',
  [_types.ShareableLinkModel.livestreams]: 'livestreamId'
};
function useShareableLink() {
  const {
    data: config
  } = (0, _reactQuery.useQuery)({
    queryKey: ['social-plus-uikit', 'shareable-link-config'],
    queryFn: () => _tsSdkReactNative.Client === null || _tsSdkReactNative.Client === void 0 ? void 0 : _tsSdkReactNative.Client.getShareableLinkConfiguration(),
    enabled: !!_tsSdkReactNative.Client,
    staleTime: Infinity
  });
  const getShareLink = (model, referenceId) => {
    var _config$patterns;
    if (!(config !== null && config !== void 0 && config.domain) || !(config !== null && config !== void 0 && (_config$patterns = config.patterns) !== null && _config$patterns !== void 0 && _config$patterns[model])) return null;
    return config.domain + config.patterns[model].replace(`{${REFERENCE_KEY[model]}}`, referenceId);
  };
  return {
    getShareLink
  };
}
//# sourceMappingURL=useShareableLink.js.map