var __rest = (this && this.__rest) || function (s, e) {
    var t = {};
    for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
        t[p] = s[p];
    if (s != null && typeof Object.getOwnPropertySymbols === "function")
        for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
            if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
                t[p[i]] = s[p[i]];
        }
    return t;
};
import { assert } from '../../../utils';
import { amount } from '../../../types';
/** @group Model Helpers */
export const isSft = (value) => typeof value === 'object' && value.model === 'sft';
/** @group Model Helpers */
export function assertSft(value) {
    assert(isSft(value), `Expected Sft model`);
}
/** @group Model Helpers */
export const toSft = (metadata, mint) => {
    const { address, mintAddress } = metadata, shared = __rest(metadata, ["address", "mintAddress"]);
    assert(mintAddress.equals(mint.address), 'The provided mint does not match the mint address in the metadata');
    const currency = Object.assign(Object.assign({}, mint.currency), { symbol: metadata.symbol || 'Token' });
    return Object.assign(Object.assign({}, shared), { model: 'sft', address: mintAddress, metadataAddress: address, mint: Object.assign(Object.assign({}, mint), { currency, supply: amount(mint.supply.basisPoints, currency) }) });
};
/** @group Model Helpers */
export const isSftWithToken = (value) => isSft(value) && 'token' in value;
/** @group Model Helpers */
export function assertSftWithToken(value) {
    assert(isSftWithToken(value), `Expected Sft model with token`);
}
/** @group Model Helpers */
export const toSftWithToken = (metadata, mint, token) => {
    const sft = toSft(metadata, mint);
    const { currency } = sft.mint;
    return Object.assign(Object.assign({}, sft), { token: Object.assign(Object.assign({}, token), { amount: amount(token.amount.basisPoints, currency), delegateAmount: amount(token.delegateAmount.basisPoints, currency) }) });
};
//# sourceMappingURL=Sft.js.map