"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useCurrentUser = exports.usePDP = exports.useCartItem = exports.useCart = exports.useExtension = void 0;
const ApiProvider_1 = require("../providers/ApiProvider");
class ExtensionPointException extends Error {
    constructor({ extensionPoint, hookName }) {
        const message = `The extension point ${extensionPoint} has no access to the hook ${hookName}`;
        super(message);
        this.name = 'ExtensionPointException';
    }
}
const useExtension = () => {
    const api = (0, ApiProvider_1.useApi)();
    return api.useExtension();
};
exports.useExtension = useExtension;
const useCart = () => {
    const api = (0, ApiProvider_1.useApi)();
    const { extensionPoint } = api.useExtension();
    const useCartHook = api.useCart;
    if (useCartHook) {
        return useCartHook();
    }
    throw new ExtensionPointException({
        extensionPoint,
        hookName: 'useCart',
    });
};
exports.useCart = useCart;
const useCartItem = () => {
    const api = (0, ApiProvider_1.useApi)();
    const { extensionPoint } = api.useExtension();
    const useCartItemHook = api.useCartItem;
    if (useCartItemHook) {
        return useCartItemHook();
    }
    throw new ExtensionPointException({
        extensionPoint,
        hookName: 'useCartItem',
    });
};
exports.useCartItem = useCartItem;
const usePDP = () => {
    const api = (0, ApiProvider_1.useApi)();
    const { extensionPoint } = api.useExtension();
    const usePDPHook = api.usePDP;
    if (usePDPHook) {
        return usePDPHook();
    }
    throw new ExtensionPointException({
        extensionPoint,
        hookName: 'usePDP',
    });
};
exports.usePDP = usePDP;
const useCurrentUser = () => {
    const api = (0, ApiProvider_1.useApi)();
    const { extensionPoint } = api.useExtension();
    const useCurrentUserHook = api.useCurrentUser;
    if (useCurrentUserHook) {
        return useCurrentUserHook();
    }
    throw new ExtensionPointException({
        extensionPoint,
        hookName: 'useCurrentUser',
    });
};
exports.useCurrentUser = useCurrentUser;
//# sourceMappingURL=index.js.map