@notifi-network/notifi-react
Version:
React components to access Notifi core services
788 lines (777 loc) • 467 kB
JavaScript
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// lib/index.ts
var index_exports = {};
__export(index_exports, {
ConvertOptionDirection: () => ConvertOptionDirection,
FtuStage: () => FtuStage,
NotifiCardModal: () => NotifiCardModal,
NotifiContextProvider: () => NotifiContextProvider,
NotifiFrontendClientContext: () => NotifiFrontendClientContext,
NotifiFrontendClientContextProvider: () => NotifiFrontendClientContextProvider,
NotifiHistoryContextProvider: () => NotifiHistoryContextProvider,
NotifiSmartLink: () => NotifiSmartLink,
NotifiSmartLinkContextProvider: () => NotifiSmartLinkContextProvider,
NotifiTargetContextProvider: () => NotifiTargetContextProvider,
NotifiTenantConfigContextProvider: () => NotifiTenantConfigContextProvider,
NotifiTopicContextProvider: () => NotifiTopicContextProvider,
NotifiUserSettingContextProvider: () => NotifiUserSettingContextProvider,
areUserInputParamsStrictlyEqual: () => areUserInputParamsStrictlyEqual,
categorizeTopics: () => categorizeTopics,
composeTopicStackAlertName: () => composeTopicStackAlertName,
convertOptionValue: () => convertOptionValue,
defaultCopy: () => defaultCopy,
derivePrefixAndSuffixFromValueType: () => derivePrefixAndSuffixFromValueType,
formTargets: () => formTargets,
getFusionEventMetadata: () => getFusionEventMetadata,
getFusionFilter: () => getFusionFilter,
getTargetValidateRegex: () => getTargetValidateRegex,
getUiConfigOverride: () => getUiConfigOverride,
getUpdatedAlertFilterOptions: () => getUpdatedAlertFilterOptions,
getUserInputParams: () => getUserInputParams,
hasTarget: () => hasTarget,
hasValidTargetMoreThan: () => hasValidTargetMoreThan,
isAlertFilter: () => isAlertFilter,
isAlertMetadataForTopicStack: () => isAlertMetadataForTopicStack,
isCtaInfo: () => isCtaInfo,
isEqual: () => isEqual,
isFormTarget: () => isFormTarget,
isFrequencyFilter: () => isFrequencyFilter,
isFusionEventMetadata: () => isFusionEventMetadata,
isFusionFilterOptions: () => isFusionFilterOptions,
isTargetCta: () => isTargetCta,
isTargetVerified: () => isTargetVerified,
isToggleTarget: () => isToggleTarget,
isTopicGroupValid: () => isTopicGroupValid,
loginViaSolanaHardwareWallet: () => loginViaSolanaHardwareWallet,
resolveAlertName: () => resolveAlertName,
resolveTopicStackAlertName: () => resolveTopicStackAlertName,
toggleTargets: () => toggleTargets,
useNotifiFrontendClientContext: () => useNotifiFrontendClientContext,
useNotifiHistoryContext: () => useNotifiHistoryContext,
useNotifiSmartLinkContext: () => useNotifiSmartLinkContext,
useNotifiTargetContext: () => useNotifiTargetContext,
useNotifiTenantConfigContext: () => useNotifiTenantConfigContext,
useNotifiTopicContext: () => useNotifiTopicContext,
useNotifiUserSettingContext: () => useNotifiUserSettingContext,
validateEventDetails: () => validateEventDetails
});
module.exports = __toCommonJS(index_exports);
// lib/context/NotifiFrontendClientContext.tsx
var import_notifi_frontend_client4 = require("@notifi-network/notifi-frontend-client");
var import_react = __toESM(require("react"));
// package.json
var version = "7.4.0";
// lib/utils/constants.ts
var defaultCopy = {
connect: {
title: "Notifications",
description: "See your activity and gain access to alerts",
hardwareWalletLabel: "Use Hardware Wallet",
buttonText: "Next"
},
poweredByNotifi: "Powered by",
inputFields: {
email: "Enter your email address",
phoneNumber: "Phone Number"
},
ftu: {
headerTitles: {
ftuTargetEdit: "How do you want to be notified?",
ftuAlertEdit: "Select alerts"
}
},
ftuTargetEdit: {
description: "Select a minimum of one destination",
headerTitle: "How do you want to be notified?",
buttonText: "Next"
},
ftuTargetList: {
headerTitle: "How do you want to be notified?",
buttonText: "Next"
},
ftuAlertEdit: {
headerTitle: "Select alerts",
buttonText: "Done"
},
targetList: {
email: "Email",
phoneNumber: "SMS",
telegram: "Telegram",
discord: "Discord",
slack: "Slack",
wallet: "Wallets",
emailVerifyMessage: "Verification email sent",
discordVerifiedMessage: "Make sure Discord DMs are enabled",
discordVerifiedPromptTooltip: "Make sure you have enabled DMs in Discord. Right click on the server after joining, go to Privacy Settings, and enable Direct Messages.",
walletVerifyMessage: "2-3 signatures required to verify",
walletVerifyTooltip: "Wallet messages are powered by XMTP and delivered natively into Coinbase Wallet. Download the Coinbase Wallet App.",
walletVerifiedMessage: "Enable messages in Coinbase Wallet App",
walletVerifiedTooltip: "Make sure messages are enabled in your Coinbase Wallet Mobile App.",
walletVerifiedTooltipLink: {
text: "More info",
url: "https://docs.notifi.network/docs/target-setup/wallet-integration"
}
},
topicOptions: {
customInputPlaceholder: "Custom"
},
subscriptionValueInput: {
dropdownPlaceholder: "--- Select one option ---"
},
topicStackRowInput: {
buttonContent: "Save"
},
topicStackRow: {
cta: "+ Add"
},
historyRow: {
legacyTopic: "Legacy: topic is removed"
},
inboxHistoryList: {
headerTitle: "Notifications",
buttonText: "Load More"
},
inboxHistoryDetail: {
headerTitle: ""
},
historyList: {
inboxEmptyTitle: "Inbox empty",
inboxEmptyDescription: `You haven\u2019t received any notifications yet. You can manage your
destinations and alerts under settings.`
},
inboxConfigTopic: {
header: "Manage Notifications",
title: "Manage the alerts you want to receive:"
},
targetStateBanner: {
verify: {
title: "Manage alert destinations",
description: "You have unverified destinations"
},
verifyInHistory: {
title: "Verify your",
ctaText: "Verify"
},
Signup: {
textInHistory: "Get alerts via",
ctaInHistory: "Sign Up",
textInConfig: "Get notifications to the destinations of your choice."
}
},
inboxConfigTargetList: {
header: "Manage Destinations",
buttonText: "Edit Destinations"
},
errorGlobal: {
header: "An error occurred",
title: "Something went wrong, please try again: ",
detail: "Contact support if the issue persists"
},
targetInputField: {
inValidErrorMessage: (target) => `Please enter a valid ${target} address`
}
};
// lib/utils/topic.ts
var import_notifi_frontend_client = require("@notifi-network/notifi-frontend-client");
var validateEventType = (eventType) => {
return eventType.type === "fusion" || eventType.type === "label";
};
var categorizeTopics = (topics, unCategorizedTopicsLabelName) => {
const categorizedEventTypeItems = [];
const uncategorizedEventTypeItem = {
name: unCategorizedTopicsLabelName ?? "General",
type: "label",
subTopics: []
};
let currentLabel = void 0;
topics.filter(validateEventType).forEach((row) => {
if (row.type === "label") {
currentLabel = {
...row,
subTopics: []
};
categorizedEventTypeItems.push(currentLabel);
} else {
if (currentLabel) {
currentLabel.subTopics.push(row);
} else {
uncategorizedEventTypeItem.subTopics.push(row);
}
}
});
return {
categorizedTopics: categorizedEventTypeItems,
uncategorizedTopics: uncategorizedEventTypeItem
};
};
var getUserInputParams = (topic) => {
const parsedMetadata = JSON.parse(
topic.fusionEventDescriptor.metadata ?? "{}"
);
if (!isFusionEventMetadata(parsedMetadata)) {
return [];
}
const filters = parsedMetadata?.filters?.filter(isAlertFilter) ?? [];
return filters[0]?.userInputParams ?? [];
};
var getUiConfigOverride = (topic) => {
const parsedMetadata = JSON.parse(
topic.fusionEventDescriptor.metadata ?? "{}"
);
if (!isFusionEventMetadata(parsedMetadata)) {
return {};
}
return parsedMetadata?.uiConfigOverride ?? {};
};
var getFusionEventMetadata = (topic) => {
const parsedMetadata = JSON.parse(
topic.fusionEventDescriptor.metadata ?? "{}"
);
if (isFusionEventMetadata(parsedMetadata)) {
return parsedMetadata;
}
return null;
};
var getFusionFilter = (topic) => {
const parsedMetadata = JSON.parse(
topic.fusionEventDescriptor.metadata ?? "{}"
);
if (isFusionEventMetadata(parsedMetadata)) {
return parsedMetadata?.filters?.[0] ?? {};
}
return null;
};
var isTopicGroupValid = (topics) => {
const groupName = topics[0].uiConfig.topicGroupName;
const isGroupNameConsistent = topics.every(
(topic) => topic.uiConfig.topicGroupName === groupName
);
if (!isGroupNameConsistent) {
console.info(
`WARN - Failed grouping Topic Group - "${groupName}" due to inconsistent group name`
);
return false;
}
const isLegacyCmTopicGroup = topics.every(
(topic) => Object.keys(getFusionEventMetadata(topic) ?? {}).length === 0
);
if (isLegacyCmTopicGroup) return true;
const isAllTopicWithoutAlertFilters = topics.every(
(topic) => getFusionEventMetadata(topic)?.filters.filter(isAlertFilter).length === 0
);
if (isAllTopicWithoutAlertFilters) return true;
const isAllTopicsWithAlertFilters = topics.every((topic) => {
const alertFilterCount = getFusionEventMetadata(topic)?.filters?.filter(isAlertFilter).length;
return !!alertFilterCount && alertFilterCount > 0;
});
if (!isAllTopicsWithAlertFilters) {
console.info(
`WARN - Failed to group Topic Group "${groupName}" due to missing AlertFilter(s)`
);
return false;
}
const benchmarkTopic = topics[0];
const benchmarkTopicMetadata = getFusionEventMetadata(benchmarkTopic);
const benchmarkAlertFilter = benchmarkTopicMetadata.filters.find(isAlertFilter);
const benchmarkUserInputParams = benchmarkAlertFilter.userInputParams;
if (benchmarkUserInputParams && benchmarkUserInputParams.length > 0) {
for (let i = 1; i < topics.length; i++) {
const topic = topics[i];
const currentUserParams = getUserInputParams(topic);
if (!areUserInputParamsStrictlyEqual(
benchmarkUserInputParams,
currentUserParams
)) {
console.info(
`WARN - Failed to group Topic Group "${groupName}" due to inconsistent userInputParams`
);
return false;
}
}
}
const benchmarkSubscriptionValueOrRef = benchmarkTopicMetadata?.uiConfigOverride?.subscriptionValueOrRef;
const benchmarkSubscriptionRef = benchmarkSubscriptionValueOrRef?.type === "ref" ? benchmarkSubscriptionValueOrRef.ref : null;
if (benchmarkTopicMetadata?.uiConfigOverride?.isSubscriptionValueInputable && benchmarkSubscriptionRef) {
const isValid = topics.every((topic) => {
const subTopicMetadata = getFusionEventMetadata(topic);
const subTopicSubscriptionValueOrRef = subTopicMetadata?.uiConfigOverride?.subscriptionValueOrRef;
const subTopicSubscriptionRef = subTopicSubscriptionValueOrRef?.type === "ref" ? subTopicSubscriptionValueOrRef.ref : null;
return benchmarkSubscriptionRef === subTopicSubscriptionRef;
});
return isValid;
}
return true;
};
var areUserInputParamsStrictlyEqual = (a, b) => {
if (a.length !== b.length) return false;
for (let i = 0; i < a.length; i++) {
const param1 = a[i];
const param2 = b[i];
if (param1.name !== param2.name) return false;
if (param1.defaultValue !== param2.defaultValue) return false;
if (param1.options.length !== param2.options.length) return false;
for (let j = 0; j < param1.options.length; j++) {
if (param1.options[j] !== param2.options[j]) return false;
}
}
return true;
};
var isFusionEventMetadata = (metadata) => {
if (typeof metadata !== "object" || !metadata) {
return false;
}
return "filters" in metadata && Array.isArray(metadata.filters);
};
var isAlertFilter = (filter) => {
return "userInputParams" in filter && "type" in filter && filter.type === "AlertFilter";
};
var isFrequencyFilter = (filter) => filter.type === "FrequencyAlertFilter";
var isFusionFilterOptions = (filterOptions) => {
if (typeof filterOptions !== "object" || !filterOptions) {
return false;
}
return "version" in filterOptions && filterOptions.version === 1;
};
var getUpdatedAlertFilterOptions = (filterName, alertFilterOptions, inputParmName, value) => {
return {
...alertFilterOptions,
input: {
...alertFilterOptions.input,
[filterName]: {
...alertFilterOptions.input[filterName],
[inputParmName]: value
}
}
};
};
var isAlertMetadataForTopicStack = (alertMetadata) => {
return (0, import_notifi_frontend_client.objectKeys)(alertMetadata).length > 1 && "timestamp" in alertMetadata && "subscriptionValue" in alertMetadata && "subscriptionLabel" in alertMetadata && "fusionEventTypeId" in alertMetadata;
};
var resolveAlertName = (alertName) => {
const resolved = alertName.split(":;:");
if (resolved.length === 1) {
return {
fusionEventTypeId: resolved[0]
};
}
const [fusionEventTypeId, subscriptionValue, subscriptionLabel, timestamp] = resolved;
return {
fusionEventTypeId,
subscriptionValue,
subscriptionLabel,
timestamp
};
};
var composeTopicStackAlertName = (fusionEventTypeId, subscriptionValue, subscriptionLabel) => {
return `${fusionEventTypeId}:;:${subscriptionValue}:;:${subscriptionLabel}:;:${Date.now()}`;
};
var convertOptionValue = (value, type, direction) => {
if (value === "") return "";
direction = direction ?? "frontendToBackend" /* FtoB */;
if (type === "percentage") {
return direction === "frontendToBackend" /* FtoB */ ? Number(value) / 100 : Number(value) * 100;
}
return value;
};
var ConvertOptionDirection = /* @__PURE__ */ ((ConvertOptionDirection2) => {
ConvertOptionDirection2["FtoB"] = "frontendToBackend";
ConvertOptionDirection2["BtoF"] = "BackendToFrontend";
return ConvertOptionDirection2;
})(ConvertOptionDirection || {});
var resolveTopicStackAlertName = (alertName) => {
const [fusionEventTypeId, subscriptionValue, subscriptionLabel, timestamp] = alertName.split(":;:");
return {
fusionEventTypeId,
subscriptionValue,
subscriptionLabel,
timestamp
};
};
var derivePrefixAndSuffixFromValueType = (kind) => {
switch (kind) {
case "price":
return {
prefix: "$",
suffix: ""
};
case "percentage":
return {
prefix: "",
suffix: "%"
};
case "string":
case "integer":
return {
prefix: "",
suffix: ""
};
default:
return {
prefix: "",
suffix: ""
};
}
};
// lib/utils/target.ts
var import_notifi_frontend_client2 = require("@notifi-network/notifi-frontend-client");
var formTargets = ["email", "phoneNumber"];
var toggleTargets = [
"discord",
"slack",
"telegram",
"wallet"
];
var hasTarget = (targetData) => {
return !(0, import_notifi_frontend_client2.objectKeys)(targetData).every((key) => {
const target = targetData[key];
if (typeof target === "string") {
return !target;
}
if (typeof target === "object") {
return !target.data;
}
});
};
var hasValidTargetMoreThan = (targetData, moreThan) => {
return (0, import_notifi_frontend_client2.objectKeys)(targetData).filter((key) => {
const target = targetData[key];
if (typeof target === "string" && target !== "") {
return target;
}
if (typeof target === "object") {
if (key === "discord" || key === "wallet" || key === "telegram") {
return !!targetData[key].data?.isConfirmed;
}
if (key === "slack") {
return targetData[key].data?.verificationStatus === "VERIFIED";
}
}
}).length > moreThan;
};
var isTargetCta = (targetInfoPrompt) => {
return targetInfoPrompt?.type === "cta";
};
var isTargetVerified = (targetInfoPrompt) => {
return targetInfoPrompt?.type === "message" && targetInfoPrompt.message === "Verified";
};
var isFormTarget = (target) => {
const supportedFormTargets = ["email", "phoneNumber"];
return supportedFormTargets.includes(target);
};
var isToggleTarget = (target) => toggleTargets.includes(target);
var getTargetValidateRegex = (target) => {
switch (target) {
case "email":
return new RegExp("^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$");
case "phoneNumber":
return void 0;
default:
throw new Error("Not supported target type");
}
};
// lib/utils/frontendClient.ts
var import_notifi_frontend_client3 = require("@notifi-network/notifi-frontend-client");
var loginViaSolanaHardwareWallet = async (frontendClient, walletWithSignParams) => {
if (walletWithSignParams.walletBlockchain !== "SOLANA")
throw new Error("loginViaSolanaHardwareWallet: Only SOLANA is supported");
if (!walletWithSignParams.hardwareLoginPlugin)
throw new Error(
"loginViaSolanaHardwareWallet: loginViaSolanaHardwareWallet: Missing hardwareLoginPlugin"
);
const plugin = walletWithSignParams.hardwareLoginPlugin;
const { nonce } = await frontendClient._beginLogInWithWeb3({
walletPubkey: walletWithSignParams.walletPublicKey,
authType: "SOLANA_HARDWARE_SIGN_MESSAGE",
authAddress: walletWithSignParams.walletPublicKey
});
const signedMessage = `${import_notifi_frontend_client3.SIGNING_MESSAGE}${nonce}`;
const transactionSignature = await plugin.signTransaction(nonce);
const logInResult = await frontendClient.completeLogInWithWeb3({
nonce,
signedMessage,
signature: transactionSignature,
signingAddress: walletWithSignParams.walletPublicKey,
signingPubkey: walletWithSignParams.walletPublicKey
});
if (logInResult?.completeLogInWithWeb3 === void 0) {
throw new Error("Log in via Web3 failed");
}
return logInResult;
};
// lib/utils/math.ts
function deepEqual(a, b) {
if (a === b) return true;
if (typeof a !== "object" || typeof b !== "object" || a === null || b === null)
return false;
const keysA = Object.keys(a).sort();
const keysB = Object.keys(b).sort();
if (keysA.length !== keysB.length) return false;
for (const key of keysA) {
if (!keysB.includes(key) || !deepEqual(a[key], b[key])) return false;
}
return true;
}
function customSort(a, b) {
if (typeof a === "object" && typeof b === "object") {
return JSON.stringify(a).localeCompare(JSON.stringify(b));
}
return a < b ? -1 : a > b ? 1 : 0;
}
function isEqual(value, other) {
if (value === other) return true;
if (typeof value !== typeof other) return false;
if (Array.isArray(value) && Array.isArray(other)) {
if (value.length !== other.length) return false;
const sortedValue = [...value].sort(customSort);
const sortedOther = [...other].sort(customSort);
for (let i = 0; i < sortedValue.length; i++) {
if (!isEqual(sortedValue[i], sortedOther[i])) return false;
}
return true;
}
if (Array.isArray(value) || Array.isArray(other)) return false;
return deepEqual(value, other);
}
// lib/context/NotifiFrontendClientContext.tsx
var import_jsx_runtime = require("react/jsx-runtime");
var NotifiFrontendClientContext = import_react.default.createContext(
{}
);
var NotifiFrontendClientContextProvider = ({
children,
tenantId,
env,
storageOption,
isEnabledLoginViaTransaction,
...walletWithSignParams
}) => {
const [isLoading, setIsLoading] = import_react.default.useState(false);
const [error, setError] = import_react.default.useState(null);
const [transactionNonce, setTransactionNonce] = import_react.default.useState(
null
);
const [frontendClient, setFrontendClient] = import_react.default.useState(null);
const [frontendClientStatus, setFrontendClientStatus] = import_react.default.useState({
isExpired: false,
isInitialized: false,
isAuthenticated: false
});
const userId = walletWithSignParams.walletBlockchain === "OFF_CHAIN" ? walletWithSignParams.userAccount : walletWithSignParams.walletPublicKey;
const isLogInViaTransactionAvailable = walletWithSignParams.walletBlockchain !== "OFF_CHAIN" && isEnabledLoginViaTransaction;
import_react.default.useEffect(() => {
const requestHeaders = {
"X-Notifi-Client-Version": version
};
const frontendClient2 = (0, import_notifi_frontend_client4.instantiateFrontendClient)(
tenantId,
walletWithSignParams,
env,
storageOption,
void 0,
requestHeaders
);
setIsLoading(true);
frontendClient2.initialize().then(() => {
_refreshFrontendClient(frontendClient2);
setError(null);
}).catch((e) => {
if (e instanceof Error) {
setError({
...e,
message: ` failed to initialize frontendClient (.initialize): ${e.message}`
});
}
console.error(e);
}).finally(() => setIsLoading(false));
}, [userId]);
import_react.default.useEffect(() => {
if (!frontendClient || !frontendClientStatus.isInitialized || !isLogInViaTransactionAvailable)
return;
const getNonce = async () => {
const nonce = await frontendClient?.beginLoginViaTransaction({
walletAddress: walletWithSignParams.walletPublicKey,
walletBlockchain: walletWithSignParams.walletBlockchain
});
return nonce.nonce;
};
getNonce().then((nonce) => setTransactionNonce(nonce));
const interval = setInterval(async () => {
getNonce().then((nonce) => setTransactionNonce(nonce));
}, 6e5);
return () => clearInterval(interval);
}, [frontendClientStatus.isInitialized, isLogInViaTransactionAvailable]);
const login = async () => {
if (!frontendClient || !frontendClientStatus.isInitialized) {
setError(new Error(".login: Frontend client not initialized"));
return;
}
setIsLoading(true);
try {
await frontendClient.logIn(walletWithSignParams);
_refreshFrontendClient(frontendClient);
setError(null);
} catch (error2) {
if (error2 instanceof Error) {
const newError = {
...error2,
message: `login: Failed to login User rejects to sign, or mis-impl the signMessage method: ${JSON.stringify(
error2.message
)}`
};
setError(newError);
console.error(newError);
}
} finally {
setIsLoading(false);
}
return frontendClient;
};
const logout = async () => {
if (!frontendClient) {
setError(
new Error(".logout: Failed to logout - client not instantiated")
);
return;
}
try {
await frontendClient?.logOut();
_refreshFrontendClient(frontendClient);
setError(null);
} catch (error2) {
if (error2 instanceof Error) {
const newError = {
...error2,
message: `logout: Failed to logout - ${JSON.stringify(error2.message)}`
};
setError(newError);
console.error(newError);
}
}
};
const _loginViaTransaction = import_react.default.useCallback(
async (signatureSignedWithNotifiNonce) => {
if (!isLogInViaTransactionAvailable) return;
if (!frontendClient || !frontendClientStatus.isInitialized) {
setError(
new Error(".loginViaTransaction: Frontend client not initialized")
);
return;
}
setIsLoading(true);
try {
await frontendClient?.completeLoginViaTransaction({
walletAddress: walletWithSignParams.walletPublicKey,
walletBlockchain: walletWithSignParams.walletBlockchain,
transactionSignature: signatureSignedWithNotifiNonce
});
_refreshFrontendClient(frontendClient);
setError(null);
} catch (error2) {
if (error2 instanceof Error) {
const newError = {
...error2,
message: `loginViaTrasaction: failed to call .completeLoginViaTransaction: ${error2.message}`
};
setError(newError);
console.error(newError);
}
} finally {
setIsLoading(false);
}
return frontendClient;
},
[userId, !!frontendClient, isEnabledLoginViaTransaction]
);
const _refreshFrontendClient = import_react.default.useCallback(
(frontendClient2) => {
setFrontendClientStatus({
isExpired: frontendClient2.userState?.status === "expired",
isInitialized: !!frontendClient2,
isAuthenticated: frontendClient2.userState?.status === "authenticated"
});
setFrontendClient(frontendClient2);
},
[setFrontendClientStatus, setFrontendClient]
);
const loginViaHardwareWallet = import_react.default.useCallback(async () => {
if (!frontendClient || !frontendClientStatus.isInitialized || walletWithSignParams.walletBlockchain === "OFF_CHAIN") {
setError(
new Error(
".loginViaHardwareWallet: Frontend client not initialized / or Invalid blockchain"
)
);
return;
}
setIsLoading(true);
try {
await loginViaSolanaHardwareWallet(frontendClient, walletWithSignParams);
_refreshFrontendClient(frontendClient);
setError(null);
} catch (error2) {
if (error2 instanceof Error) {
const newError = {
...error2,
message: `loginViaHardwareWallet: User rejects to sign, or mis-impl the signMessage method: ${error2.message}`
};
setError(newError);
console.error(newError);
}
} finally {
setIsLoading(false);
}
return frontendClient;
}, [userId, !!frontendClient]);
if (!frontendClient) return null;
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
NotifiFrontendClientContext.Provider,
{
value: {
frontendClient,
frontendClientStatus,
isLoading,
error,
login,
logout,
loginViaHardwareWallet,
walletWithSignParams,
loginViaTransaction: isLogInViaTransactionAvailable && transactionNonce ? {
nonce: transactionNonce,
login: _loginViaTransaction
} : null
},
children
}
);
};
var useNotifiFrontendClientContext = () => import_react.default.useContext(NotifiFrontendClientContext);
// lib/context/NotifiTargetContext.tsx
var import_notifi_frontend_client5 = require("@notifi-network/notifi-frontend-client");
// ../../node_modules/libphonenumber-js/metadata.min.json.js
var metadata_min_json_default = { "version": 4, "country_calling_codes": { "1": ["US", "AG", "AI", "AS", "BB", "BM", "BS", "CA", "DM", "DO", "GD", "GU", "JM", "KN", "KY", "LC", "MP", "MS", "PR", "SX", "TC", "TT", "VC", "VG", "VI"], "7": ["RU", "KZ"], "20": ["EG"], "27": ["ZA"], "30": ["GR"], "31": ["NL"], "32": ["BE"], "33": ["FR"], "34": ["ES"], "36": ["HU"], "39": ["IT", "VA"], "40": ["RO"], "41": ["CH"], "43": ["AT"], "44": ["GB", "GG", "IM", "JE"], "45": ["DK"], "46": ["SE"], "47": ["NO", "SJ"], "48": ["PL"], "49": ["DE"], "51": ["PE"], "52": ["MX"], "53": ["CU"], "54": ["AR"], "55": ["BR"], "56": ["CL"], "57": ["CO"], "58": ["VE"], "60": ["MY"], "61": ["AU", "CC", "CX"], "62": ["ID"], "63": ["PH"], "64": ["NZ"], "65": ["SG"], "66": ["TH"], "81": ["JP"], "82": ["KR"], "84": ["VN"], "86": ["CN"], "90": ["TR"], "91": ["IN"], "92": ["PK"], "93": ["AF"], "94": ["LK"], "95": ["MM"], "98": ["IR"], "211": ["SS"], "212": ["MA", "EH"], "213": ["DZ"], "216": ["TN"], "218": ["LY"], "220": ["GM"], "221": ["SN"], "222": ["MR"], "223": ["ML"], "224": ["GN"], "225": ["CI"], "226": ["BF"], "227": ["NE"], "228": ["TG"], "229": ["BJ"], "230": ["MU"], "231": ["LR"], "232": ["SL"], "233": ["GH"], "234": ["NG"], "235": ["TD"], "236": ["CF"], "237": ["CM"], "238": ["CV"], "239": ["ST"], "240": ["GQ"], "241": ["GA"], "242": ["CG"], "243": ["CD"], "244": ["AO"], "245": ["GW"], "246": ["IO"], "247": ["AC"], "248": ["SC"], "249": ["SD"], "250": ["RW"], "251": ["ET"], "252": ["SO"], "253": ["DJ"], "254": ["KE"], "255": ["TZ"], "256": ["UG"], "257": ["BI"], "258": ["MZ"], "260": ["ZM"], "261": ["MG"], "262": ["RE", "YT"], "263": ["ZW"], "264": ["NA"], "265": ["MW"], "266": ["LS"], "267": ["BW"], "268": ["SZ"], "269": ["KM"], "290": ["SH", "TA"], "291": ["ER"], "297": ["AW"], "298": ["FO"], "299": ["GL"], "350": ["GI"], "351": ["PT"], "352": ["LU"], "353": ["IE"], "354": ["IS"], "355": ["AL"], "356": ["MT"], "357": ["CY"], "358": ["FI", "AX"], "359": ["BG"], "370": ["LT"], "371": ["LV"], "372": ["EE"], "373": ["MD"], "374": ["AM"], "375": ["BY"], "376": ["AD"], "377": ["MC"], "378": ["SM"], "380": ["UA"], "381": ["RS"], "382": ["ME"], "383": ["XK"], "385": ["HR"], "386": ["SI"], "387": ["BA"], "389": ["MK"], "420": ["CZ"], "421": ["SK"], "423": ["LI"], "500": ["FK"], "501": ["BZ"], "502": ["GT"], "503": ["SV"], "504": ["HN"], "505": ["NI"], "506": ["CR"], "507": ["PA"], "508": ["PM"], "509": ["HT"], "590": ["GP", "BL", "MF"], "591": ["BO"], "592": ["GY"], "593": ["EC"], "594": ["GF"], "595": ["PY"], "596": ["MQ"], "597": ["SR"], "598": ["UY"], "599": ["CW", "BQ"], "670": ["TL"], "672": ["NF"], "673": ["BN"], "674": ["NR"], "675": ["PG"], "676": ["TO"], "677": ["SB"], "678": ["VU"], "679": ["FJ"], "680": ["PW"], "681": ["WF"], "682": ["CK"], "683": ["NU"], "685": ["WS"], "686": ["KI"], "687": ["NC"], "688": ["TV"], "689": ["PF"], "690": ["TK"], "691": ["FM"], "692": ["MH"], "850": ["KP"], "852": ["HK"], "853": ["MO"], "855": ["KH"], "856": ["LA"], "880": ["BD"], "886": ["TW"], "960": ["MV"], "961": ["LB"], "962": ["JO"], "963": ["SY"], "964": ["IQ"], "965": ["KW"], "966": ["SA"], "967": ["YE"], "968": ["OM"], "970": ["PS"], "971": ["AE"], "972": ["IL"], "973": ["BH"], "974": ["QA"], "975": ["BT"], "976": ["MN"], "977": ["NP"], "992": ["TJ"], "993": ["TM"], "994": ["AZ"], "995": ["GE"], "996": ["KG"], "998": ["UZ"] }, "countries": { "AC": ["247", "00", "(?:[01589]\\d|[46])\\d{4}", [5, 6]], "AD": ["376", "00", "(?:1|6\\d)\\d{7}|[135-9]\\d{5}", [6, 8, 9], [["(\\d{3})(\\d{3})", "$1 $2", ["[135-9]"]], ["(\\d{4})(\\d{4})", "$1 $2", ["1"]], ["(\\d{3})(\\d{3})(\\d{3})", "$1 $2 $3", ["6"]]]], "AE": ["971", "00", "(?:[4-7]\\d|9[0-689])\\d{7}|800\\d{2,9}|[2-4679]\\d{7}", [5, 6, 7, 8, 9, 10, 11, 12], [["(\\d{3})(\\d{2,9})", "$1 $2", ["60|8"]], ["(\\d)(\\d{3})(\\d{4})", "$1 $2 $3", ["[236]|[479][2-8]"], "0$1"], ["(\\d{3})(\\d)(\\d{5})", "$1 $2 $3", ["[479]"]], ["(\\d{2})(\\d{3})(\\d{4})", "$1 $2 $3", ["5"], "0$1"]], "0"], "AF": ["93", "00", "[2-7]\\d{8}", [9], [["(\\d{2})(\\d{3})(\\d{4})", "$1 $2 $3", ["[2-7]"], "0$1"]], "0"], "AG": ["1", "011", "(?:268|[58]\\d\\d|900)\\d{7}", [10], 0, "1", 0, "([457]\\d{6})$|1", "268$1", 0, "268"], "AI": ["1", "011", "(?:264|[58]\\d\\d|900)\\d{7}", [10], 0, "1", 0, "([2457]\\d{6})$|1", "264$1", 0, "264"], "AL": ["355", "00", "(?:700\\d\\d|900)\\d{3}|8\\d{5,7}|(?:[2-5]|6\\d)\\d{7}", [6, 7, 8, 9], [["(\\d{3})(\\d{3,4})", "$1 $2", ["80|9"], "0$1"], ["(\\d)(\\d{3})(\\d{4})", "$1 $2 $3", ["4[2-6]"], "0$1"], ["(\\d{2})(\\d{3})(\\d{3})", "$1 $2 $3", ["[2358][2-5]|4"], "0$1"], ["(\\d{3})(\\d{5})", "$1 $2", ["[23578]"], "0$1"], ["(\\d{2})(\\d{3})(\\d{4})", "$1 $2 $3", ["6"], "0$1"]], "0"], "AM": ["374", "00", "(?:[1-489]\\d|55|60|77)\\d{6}", [8], [["(\\d{3})(\\d{2})(\\d{3})", "$1 $2 $3", ["[89]0"], "0 $1"], ["(\\d{3})(\\d{5})", "$1 $2", ["2|3[12]"], "(0$1)"], ["(\\d{2})(\\d{6})", "$1 $2", ["1|47"], "(0$1)"], ["(\\d{2})(\\d{6})", "$1 $2", ["[3-9]"], "0$1"]], "0"], "AO": ["244", "00", "[29]\\d{8}", [9], [["(\\d{3})(\\d{3})(\\d{3})", "$1 $2 $3", ["[29]"]]]], "AR": ["54", "00", "(?:11|[89]\\d\\d)\\d{8}|[2368]\\d{9}", [10, 11], [["(\\d{4})(\\d{2})(\\d{4})", "$1 $2-$3", ["2(?:2[024-9]|3[0-59]|47|6[245]|9[02-8])|3(?:3[28]|4[03-9]|5[2-46-8]|7[1-578]|8[2-9])", "2(?:[23]02|6(?:[25]|4[6-8])|9(?:[02356]|4[02568]|72|8[23]))|3(?:3[28]|4(?:[04679]|3[5-8]|5[4-68]|8[2379])|5(?:[2467]|3[237]|8[2-5])|7[1-578]|8(?:[2469]|3[2578]|5[4-8]|7[36-8]|8[5-8]))|2(?:2[24-9]|3[1-59]|47)", "2(?:[23]02|6(?:[25]|4(?:64|[78]))|9(?:[02356]|4(?:[0268]|5[2-6])|72|8[23]))|3(?:3[28]|4(?:[04679]|3[78]|5(?:4[46]|8)|8[2379])|5(?:[2467]|3[237]|8[23])|7[1-578]|8(?:[2469]|3[278]|5[56][46]|86[3-6]))|2(?:2[24-9]|3[1-59]|47)|38(?:[58][78]|7[378])|3(?:4[35][56]|58[45]|8(?:[38]5|54|76))[4-6]", "2(?:[23]02|6(?:[25]|4(?:64|[78]))|9(?:[02356]|4(?:[0268]|5[2-6])|72|8[23]))|3(?:3[28]|4(?:[04679]|3(?:5(?:4[0-25689]|[56])|[78])|58|8[2379])|5(?:[2467]|3[237]|8(?:[23]|4(?:[45]|60)|5(?:4[0-39]|5|64)))|7[1-578]|8(?:[2469]|3[278]|54(?:4|5[13-7]|6[89])|86[3-6]))|2(?:2[24-9]|3[1-59]|47)|38(?:[58][78]|7[378])|3(?:454|85[56])[46]|3(?:4(?:36|5[56])|8(?:[38]5|76))[4-6]"], "0$1", 1], ["(\\d{2})(\\d{4})(\\d{4})", "$1 $2-$3", ["1"], "0$1", 1], ["(\\d{3})(\\d{3})(\\d{4})", "$1-$2-$3", ["[68]"], "0$1"], ["(\\d{3})(\\d{3})(\\d{4})", "$1 $2-$3", ["[23]"], "0$1", 1], ["(\\d)(\\d{4})(\\d{2})(\\d{4})", "$2 15-$3-$4", ["9(?:2[2-469]|3[3-578])", "9(?:2(?:2[024-9]|3[0-59]|47|6[245]|9[02-8])|3(?:3[28]|4[03-9]|5[2-46-8]|7[1-578]|8[2-9]))", "9(?:2(?:[23]02|6(?:[25]|4[6-8])|9(?:[02356]|4[02568]|72|8[23]))|3(?:3[28]|4(?:[04679]|3[5-8]|5[4-68]|8[2379])|5(?:[2467]|3[237]|8[2-5])|7[1-578]|8(?:[2469]|3[2578]|5[4-8]|7[36-8]|8[5-8])))|92(?:2[24-9]|3[1-59]|47)", "9(?:2(?:[23]02|6(?:[25]|4(?:64|[78]))|9(?:[02356]|4(?:[0268]|5[2-6])|72|8[23]))|3(?:3[28]|4(?:[04679]|3[78]|5(?:4[46]|8)|8[2379])|5(?:[2467]|3[237]|8[23])|7[1-578]|8(?:[2469]|3[278]|5(?:[56][46]|[78])|7[378]|8(?:6[3-6]|[78]))))|92(?:2[24-9]|3[1-59]|47)|93(?:4[35][56]|58[45]|8(?:[38]5|54|76))[4-6]", "9(?:2(?:[23]02|6(?:[25]|4(?:64|[78]))|9(?:[02356]|4(?:[0268]|5[2-6])|72|8[23]))|3(?:3[28]|4(?:[04679]|3(?:5(?:4[0-25689]|[56])|[78])|5(?:4[46]|8)|8[2379])|5(?:[2467]|3[237]|8(?:[23]|4(?:[45]|60)|5(?:4[0-39]|5|64)))|7[1-578]|8(?:[2469]|3[278]|5(?:4(?:4|5[13-7]|6[89])|[56][46]|[78])|7[378]|8(?:6[3-6]|[78]))))|92(?:2[24-9]|3[1-59]|47)|93(?:4(?:36|5[56])|8(?:[38]5|76))[4-6]"], "0$1", 0, "$1 $2 $3-$4"], ["(\\d)(\\d{2})(\\d{4})(\\d{4})", "$2 15-$3-$4", ["91"], "0$1", 0, "$1 $2 $3-$4"], ["(\\d{3})(\\d{3})(\\d{5})", "$1-$2-$3", ["8"], "0$1"], ["(\\d)(\\d{3})(\\d{3})(\\d{4})", "$2 15-$3-$4", ["9"], "0$1", 0, "$1 $2 $3-$4"]], "0", 0, "0?(?:(11|2(?:2(?:02?|[13]|2[13-79]|4[1-6]|5[2457]|6[124-8]|7[1-4]|8[13-6]|9[1267])|3(?:02?|1[467]|2[03-6]|3[13-8]|[49][2-6]|5[2-8]|[67])|4(?:7[3-578]|9)|6(?:[0136]|2[24-6]|4[6-8]?|5[15-8])|80|9(?:0[1-3]|[19]|2\\d|3[1-6]|4[02568]?|5[2-4]|6[2-46]|72?|8[23]?))|3(?:3(?:2[79]|6|8[2578])|4(?:0[0-24-9]|[12]|3[5-8]?|4[24-7]|5[4-68]?|6[02-9]|7[126]|8[2379]?|9[1-36-8])|5(?:1|2[1245]|3[237]?|4[1-46-9]|6[2-4]|7[1-6]|8[2-5]?)|6[24]|7(?:[069]|1[1568]|2[15]|3[145]|4[13]|5[14-8]|7[2-57]|8[126])|8(?:[01]|2[15-7]|3[2578]?|4[13-6]|5[4-8]?|6[1-357-9]|7[36-8]?|8[5-8]?|9[124])))15)?", "9$1"], "AS": ["1", "011", "(?:[58]\\d\\d|684|900)\\d{7}", [10], 0, "1", 0, "([267]\\d{6})$|1", "684$1", 0, "684"], "AT": ["43", "00", "1\\d{3,12}|2\\d{6,12}|43(?:(?:0\\d|5[02-9])\\d{3,9}|2\\d{4,5}|[3467]\\d{4}|8\\d{4,6}|9\\d{4,7})|5\\d{4,12}|8\\d{7,12}|9\\d{8,12}|(?:[367]\\d|4[0-24-9])\\d{4,11}", [4, 5, 6, 7, 8, 9, 10, 11, 12, 13], [["(\\d)(\\d{3,12})", "$1 $2", ["1(?:11|[2-9])"], "0$1"], ["(\\d{3})(\\d{2})", "$1 $2", ["517"], "0$1"], ["(\\d{2})(\\d{3,5})", "$1 $2", ["5[079]"], "0$1"], ["(\\d{3})(\\d{3,10})", "$1 $2", ["(?:31|4)6|51|6(?:5[0-3579]|[6-9])|7(?:20|32|8)|[89]"], "0$1"], ["(\\d{4})(\\d{3,9})", "$1 $2", ["[2-467]|5[2-6]"], "0$1"], ["(\\d{2})(\\d{3})(\\d{3,4})", "$1 $2 $3", ["5"], "0$1"], ["(\\d{2})(\\d{4})(\\d{4,7})", "$1 $2 $3", ["5"], "0$1"]], "0"], "AU": ["61", "001[14-689]|14(?:1[14]|34|4[17]|[56]6|7[47]|88)0011", "1(?:[0-79]\\d{7}(?:\\d(?:\\d{2})?)?|8[0-24-9]\\d{7})|[2-478]\\d{8}|1\\d{4,7}", [5, 6, 7, 8, 9, 10, 12], [["(\\d{2})(\\d{3,4})", "$1 $2", ["16"], "0$1"], ["(\\d{2})(\\d{3})(\\d{2,4})", "$1 $2 $3", ["16"], "0$1"], ["(\\d{3})(\\d{3})(\\d{3})", "$1 $2 $3", ["14|4"], "0$1"], ["(\\d)(\\d{4})(\\d{4})", "$1 $2 $3", ["[2378]"], "(0$1)"], ["(\\d{4})(\\d{3})(\\d{3})", "$1 $2 $3", ["1(?:30|[89])"]]], "0", 0, "(183[12])|0", 0, 0, 0, [["(?:(?:(?:2(?:[0-26-9]\\d|3[0-8]|4[02-9]|5[0135-9])|7(?:[013-57-9]\\d|2[0-8]))\\d|3(?:(?:[0-3589]\\d|6[1-9]|7[0-35-9])\\d|4(?:[0-578]\\d|90)))\\d\\d|8(?:51(?:0(?:0[03-9]|[12479]\\d|3[2-9]|5[0-8]|6[1-9]|8[0-7])|1(?:[0235689]\\d|1[0-69]|4[0-589]|7[0-47-9])|2(?:0[0-79]|[18][13579]|2[14-9]|3[0-46-9]|[4-6]\\d|7[89]|9[0-4])|3\\d\\d)|(?:6[0-8]|[78]\\d)\\d{3}|9(?:[02-9]\\d{3}|1(?:(?:[0-58]\\d|6[0135-9])\\d|7(?:0[0-24-9]|[1-9]\\d)|9(?:[0-46-9]\\d|5[0-79])))))\\d{3}", [9]], ["4(?:79[01]|83[0-389]|94[0-4])\\d{5}|4(?:[0-36]\\d|4[047-9]|5[0-25-9]|7[02-8]|8[0-24-9]|9[0-37-9])\\d{6}", [9]], ["180(?:0\\d{3}|2)\\d{3}", [7, 10]], ["190[0-26]\\d{6}", [10]], 0, 0, 0, ["163\\d{2,6}", [5, 6, 7, 8, 9]], ["14(?:5(?:1[0458]|[23][458])|71\\d)\\d{4}", [9]], ["13(?:00\\d{6}(?:\\d{2})?|45[0-4]\\d{3})|13\\d{4}", [6, 8, 10, 12]]], "0011"], "AW": ["297", "00", "(?:[25-79]\\d\\d|800)\\d{4}", [7], [["(\\d{3})(\\d{4})", "$1 $2", ["[25-9]"]]]], "AX": ["358", "00|99(?:[01469]|5(?:[14]1|3[23]|5[59]|77|88|9[09]))", "2\\d{4,9}|35\\d{4,5}|(?:60\\d\\d|800)\\d{4,6}|7\\d{5,11}|(?:[14]\\d|3[0-46-9]|50)\\d{4,8}", [5, 6, 7, 8, 9, 10, 11, 12], 0, "0", 0, 0, 0, 0, "18", 0, "00"], "AZ": ["994", "00", "365\\d{6}|(?:[124579]\\d|60|88)\\d{7}", [9], [["(\\d{3})(\\d{2})(\\d{2})(\\d{2})", "$1 $2 $3 $4", ["90"], "0$1"], ["(\\d{2})(\\d{3})(\\d{2})(\\d{2})", "$1 $2 $3 $4", ["1[28]|2|365|46", "1[28]|2|365[45]|46", "1[28]|2|365(?:4|5[02])|46"], "(0$1)"], ["(\\d{2})(\\d{3})(\\d{2})(\\d{2})", "$1 $2 $3 $4", ["[13-9]"], "0$1"]], "0"], "BA": ["387", "00", "6\\d{8}|(?:[35689]\\d|49|70)\\d{6}", [8, 9], [["(\\d{2})(\\d{3})(\\d{3})", "$1 $2 $3", ["6[1-3]|[7-9]"], "0$1"], ["(\\d{2})(\\d{3})(\\d{3})", "$1 $2-$3", ["[3-5]|6[56]"], "0$1"], ["(\\d{2})(\\d{2})(\\d{2})(\\d{3})", "$1 $2 $3 $4", ["6"], "0$1"]], "0"], "BB": ["1", "011", "(?:246|[58]\\d\\d|900)\\d{7}", [10], 0, "1", 0, "([2-9]\\d{6})$|1", "246$1", 0, "246"], "BD": ["880", "00", "[1-469]\\d{9}|8[0-79]\\d{7,8}|[2-79]\\d{8}|[2-9]\\d{7}|[3-9]\\d{6}|[57-9]\\d{5}", [6, 7, 8, 9, 10], [["(\\d{2})(\\d{4,6})", "$1-$2", ["31[5-8]|[459]1"], "0$1"], ["(\\d{3})(\\d{3,7})", "$1-$2", ["3(?:[67]|8[013-9])|4(?:6[168]|7|[89][18])|5(?:6[128]|9)|6(?:[15]|28|4[14])|7[2-589]|8(?:0[014-9]|[12])|9[358]|(?:3[2-5]|4[235]|5[2-578]|6[0389]|76|8[3-7]|9[24])1|(?:44|66)[01346-9]"], "0$1"], ["(\\d{4})(\\d{3,6})", "$1-$2", ["[13-9]|2[23]"], "0$1"], ["(\\d)(\\d{7,8})", "$1-$2", ["2"], "0$1"]], "0"], "BE": ["32", "00", "4\\d{8}|[1-9]\\d{7}", [8, 9], [["(\\d{3})(\\d{2})(\\d{3})", "$1 $2 $3", ["(?:80|9)0"], "0$1"], ["(\\d)(\\d{3})(\\d{2})(\\d{2})", "$1 $2 $3 $4", ["[239]|4[23]"], "0$1"], ["(\\d{2})(\\d{2})(\\d{2})(\\d{2})", "$1 $2 $3 $4", ["[15-8]"], "0$1"], ["(\\d{3})(\\d{2})(\\d{2})(\\d{2})", "$1 $2 $3 $4", ["4"], "0$1"]], "0"], "BF": ["226", "00", "[025-7]\\d{7}", [8], [["(\\d{2})(\\d{2})(\\d{2})(\\d{2})", "$1 $2 $3 $4", ["[025-7]"]]]], "BG": ["359", "00", "00800\\d{7}|[2-7]\\d{6,7}|[89]\\d{6,8}|2\\d{5}", [6, 7, 8, 9, 12], [["(\\d)(\\d)(\\d{2})(\\d{2})", "$1 $2 $3 $4", ["2"], "0$1"], ["(\\d{3})(\\d{4})", "$1 $2", ["43[1-6]|70[1-9]"], "0$1"], ["(\\d)(\\d{3})(\\d{3,4})", "$1 $2 $3", ["2"], "0$1"], ["(\\d{2})(\\d{3})(\\d{2,3})", "$1 $2 $3", ["[356]|4[124-7]|7[1-9]|8[1-6]|9[1-7]"], "0$1"], ["(\\d{3})(\\d{2})(\\d{3})", "$1 $2 $3", ["(?:70|8)0"], "0$1"], ["(\\d{3})(\\d{3})(\\d{2})", "$1 $2 $3", ["43[1-7]|7"], "0$1"], ["(\\d{2})(\\d{3})(\\d{3,4})", "$1 $2 $3", ["[48]|9[08]"], "0$1"], ["(\\d{3})(\\d{3})(\\d{3})", "$1 $2 $3", ["9"], "0$1"]], "0"], "BH": ["973", "00", "[136-9]\\d{7}", [8], [["(\\d{4})(\\d{4})", "$1 $2", ["[13679]|8[02-4679]"]]]], "BI": ["257", "00", "(?:[267]\\d|31)\\d{6}", [8], [["(\\d{2})(\\d{2})(\\d{2})(\\d{2})", "$1 $2 $3 $4", ["[2367]"]]]], "BJ": ["229", "00", "(?:01\\d|[24-689])\\d{7}", [8, 10], [["(\\d{2})(\\d{2})(\\d{2})(\\d{2})", "$1 $2 $3 $4", ["[24-689]"]], ["(\\d{2})(\\d{2})(\\d{2})(\\d{2})(\\d{2})", "$1 $2 $3 $4 $5", ["0"]]]], "BL": ["590", "00", "(?:590\\d|7090)\\d{5}|(?:69|80|9\\d)\\d{7}", [9], 0, "0", 0, 0, 0, 0, 0, [["590(?:2[7-9]|3[3-7]|5[12]|87)\\d{4}"], ["(?:69(?:0\\d\\d|1(?:2[2-9]|3[0-5])|4(?:0[89]|1[2-6]|9\\d)|6(?:1[016-9]|5[0-4]|[67]\\d))|7090[0-4])\\d{4}"], ["80[0-5]\\d{6}"], 0, 0, 0, 0, 0, ["9(?:(?:39[5-7]|76[018])\\d|475[0-6])\\d{4}"]]], "BM": ["1", "011", "(?:441|[58]\\d\\d|900)\\d{7}", [10], 0, "1", 0, "([2-9]\\d{6})$|1", "441$1", 0, "441"], "BN": ["673", "00", "[2-578]\\d{6}", [7], [["(\\d{3})(\\d{4})", "$1 $2", ["[2-578]"]]]], "BO": ["591", "00(?:1\\d)?", "8001\\d{5}|(?:[2-467]\\d|50)\\d{6}", [8, 9], [["(\\d)(\\d{7})", "$1 $2", ["[235]|4[46]"]], ["(\\d{8})", "$1", ["[67]"]], ["(\\d{3})(\\d{2})(\\d{4})", "$1 $2 $3", ["8"]]], "0", 0, "0(1\\d)?"], "BQ": ["599", "00", "(?:[34]1|7\\d)\\d{5}", [7], 0, 0, 0, 0, 0, 0, "[347]"], "BR": ["55", "00(?:1[245]|2[1-35]|31|4[13]|[56]5|99)", "(?:[1-46-9]\\d\\d|5(?:[0-46-9]\\d|5[0-46-9]))\\d{8}|[1-9]\\d{9}|[3589]\\d{8}|[34]\\d{7}", [8, 9, 10, 11], [["(\\d{4})(\\d{4})", "$1-$2", ["300|4(?:0[02]|37)", "4(?:02|37)0|[34]00"]], ["(\\d{3})(\\d{2,3})(\\d{4})", "$1 $2 $3", ["(?:[358]|90)0"], "0$1"], ["(\\d{2})(\\d{4})(\\d{4})", "$1 $2-$3", ["(?:[14689][1-9]|2[12478]|3[1-578]|5[13-5]|7[13-579])[2-57]"], "($1)"], ["(\\d{2})(\\d{5})(\\d{4})", "$1 $2-$3", ["[16][1-9]|[2-57-9]"], "($1)"]], "0", 0, "(?:0|90)(?:(1[245]|2[1-35]|31|4[13]|[56]5|99)(\\d{10,11}))?", "$2"], "BS": ["1", "011", "(?:242|[58]\\d\\d|900)\\d{7}", [10], 0, "1", 0, "([3-8]\\d{6})$|1", "242$1", 0, "242"], "BT": ["975", "00", "[17]\\d{7}|[2-8]\\d{6}", [7, 8], [["(\\d)(\\d{3})(\\d{3})", "$1 $2 $3", ["[2-68]|7[246]"]], ["(\\d{2})(\\d{2})(\\d{2})(\\d{2})", "$1 $2 $3 $4", ["1[67]|7"]]]], "BW": ["267", "00", "(?:0800|(?:[37]|800)\\d)\\d{6}|(?:[2-6]\\d|90)\\d{5}", [7, 8, 10], [["(\\d{2})(\\d{5})", "$1 $2", ["90"]], ["(\\d{3})(\\d{4})", "$1 $2", ["[24-6]|3[15-9]"]], ["(\\d{2})(\\d{3})(\\d{3})", "$1 $2 $3", ["[37]"]], ["(\\d{4})(\\d{3})(\\d{3})", "$1 $2 $3", ["0"]], ["(\\d{3})(\\d{4})(\\d{3})", "$1 $2 $3", ["8"]]]], "BY": ["375", "810", "(?:[12]\\d|33|44|902)\\d{7}|8(?:0[0-79]\\d{5,7}|[1-7]\\d{9})|8(?:1[0-489]|[5-79]\\d)\\d{7}|8[1-79]\\d{6,7}|8[0-79]\\d{5}|8\\d{5}", [6, 7, 8, 9, 10, 11], [["(\\d{3})(\\d{3})", "$1 $2", ["800"], "8 $1"], ["(\\d{3})(\\d{2})(\\d{2,4})", "$1 $2 $3", ["800"], "8 $1"], ["(\\d{4})(\\d{2})(\\d{3})", "$1 $2-$3", ["1(?:5[169]|6[3-5]|7[179])|2(?:1[35]|2[34]|3[3-5])", "1(?:5[169]|6(?:3[1-3]|4|5[125])|7(?:1[3-9]|7[0-24-6]|9[2-7]))|2(?:1[35]|2[34]|3[3-5])"], "8 0$1"], ["(\\d{3})(\\d{2})(\\d{2})(\\d{2})", "$1 $2-$3-$4", ["1(?:[56]|7[467])|2[1-3]"], "8 0$1"], ["(\\d{2})(\\d{3})(\\d{2})(\\d{2})", "$1 $2-$3-$4", ["[1-4]"], "8 0$1"], ["(\\d{3})(\\d{3,4})(\\d{4})", "$1 $2 $3", ["[89]"], "8 $1"]], "8", 0, "0|80?", 0, 0, 0, 0, "8~10"], "BZ": ["501", "00", "(?:0800\\d|[2-8])\\d{6}", [7, 11], [["(\\d{3})(\\d{4})", "$1-$2", ["[2-8]"]], ["(\\d)(\\d{3})(\\d{4})(\\d{3})", "$1-$2-$3-$4", ["0"]]]], "CA": ["1", "011", "[2-9]\\d{9}|3\\d{6}", [7, 10], 0, "1", 0, 0, 0, 0, 0, [["(?:2(?:04|[23]6|[48]9|50|63)|3(?:06|43|54|6[578]|82)|4(?:03|1[68]|[26]8|3[178]|50|74)|5(?:06|1[49]|48|79|8[147])|6(?:04|[18]3|39|47|72)|7(?:0[59]|42|53|78|8[02])|8(?:[06]7|19|25|7[39])|9(?:0[25]|42))[2-9]\\d{6}", [10]], ["", [10]], ["8(?:00|33|44|55|66|77|88)[2-9]\\d{6}", [10]], ["900[2-9]\\d{6}", [10]], ["52(?:3(?:[2-46-9][02-9]\\d|5(?:[02-46-9]\\d|5[0-46-9]))|4(?:[2-478][02-9]\\d|5(?:[034]\\d|2[024-9]|5[0-46-9])|6(?:0[1-9]|[2-9]\\d)|9(?:[05-9]\\d|2[0-5]|49)))\\d{4}|52[34][2-9]1[02-9]\\d{4}|(?:5(?:2[125-9]|33|44|66|77|88)|6(?:22|33))[2-9]\\d{6}", [10]], 0, ["310\\d{4}", [7]], 0, ["600[2-9]\\d{6}", [10]]]], "CC": ["61", "001[14-689]|14(?:1[14]|34|4[17]|[56]6|7[47]|88)0011", "1(?:[0-79]\\d{8}(?:\\d{2})?|8[0-24-9]\\d{7})|[148]\\d{8}|1\\d{5,7}", [6, 7, 8, 9, 10, 12], 0, "0", 0, "([59]\\d{7})$|0", "8$1", 0, 0, [["8(?:51(?:0(?:02|31|60|89)|1(?:18|76)|223)|91(?:0(?:1[0-2]|29)|1(?:[28]2|50|79)|2(?:10|64)|3(?:[06]8|22)|4[29]8|62\\d|70[23]|959))\\d{3}", [9]], ["4(?:79[01]|83[0-389]|94[0-4])\\d{5}|4(?:[0-36]\\d|4[047-9]|5[0-25-9]|7[02-8]|8[0-24-9]|9[0-37-9])\\d{6}", [9]], ["180(?:0\\d{3}|2)\\d{3}", [7, 10]], ["190[0-26]\\d{6}", [10]], 0, 0, 0, 0, ["14(?:5(?:1[0458]|[23][458])|71\\d)\\d{4}", [9]], ["13(?:00\\d{6}(?:\\d{2})?|45[0-4]\\d{3})|13\\d{4}", [6, 8, 10, 12]]], "0011"], "CD": ["243", "00", "(?:(?:[189]|5\\d)\\d|2)\\d{7}|[1-68]\\d{6}", [7, 8, 9, 10], [["(\\d{2})(\\d{2})(\\d{3})", "$1 $2 $3", ["88"], "0$1"], ["(\\d{2})(\\d{5})", "$1 $2", ["[1-6]"], "0$1"], ["(\\d{2})(\\d{2})(\\d{4})", "$1 $2 $3", ["2"], "0$1"], ["(\\d{2})(\\d{3})(\\d{4})", "$1 $2 $3", ["1"], "0$1"], ["(\\d{3})(\\d{3})(\\d{3})", "$1 $2 $3", ["[89]"], "0$1"], ["(\\d{2})(\\d{2})(\\d{3})(\\d{3})", "$1 $2 $3 $4", ["5"], "0$1"]], "0"], "CF": ["236", "00", "(?:[27]\\d{3}|8776)\\d{4}", [8], [["(\\d{2})(\\d{2})(\\d{2})(\\d{2})", "$1 $2 $3 $4", ["[278]"]]]], "CG": ["242", "00", "222\\d{6}|(?:0\\d|80)\\d{7}", [9], [["(\\d)(\\d{4})(\\d{4})", "$1 $2 $3", ["8"]], ["(\\d{2})(\\d{3})(\\d{4})", "$1 $2 $3", ["[02]"]]]], "CH": ["41", "00", "8\\d{11}|[2-9]\\d{8}", [9, 12], [["(\\d{3})(\\d{3})(\\d{3})", "$1 $2 $3", ["8[047]|90"], "0$1"], ["(\\d{2})(\\d{3})(\\d{2})(\\d{2})", "$1 $2 $3 $4", ["[2-79]|81"], "0$1"], ["(\\d{3})(\\d{2})(\\d{3})(\\d{2})(\\d{2})", "$1 $2 $3 $4 $5", ["8"], "0$1"]], "0"], "CI": ["225", "00", "[02]\\d{9}", [10], [["(\\d{2})(\\d{2})(\\d)(\\d{5})", "$1 $2 $3 $4", ["2"]], ["(\\d{2})(\\d{2})(\\d{2})(\\d{4})", "$1 $2 $3 $4", ["0"]]]], "CK": ["682", "00", "[2-578]\\d{4}", [5], [["(\\d{2})(\\d{3})", "$1 $2", ["[2-578]"]]]], "CL": ["56", "(?:0|1(?:1[0-69]|2[02-5]|5[13-58]|69|7[0167]|8[018]))0", "12300\\d{6}|6\\d{9,10}|[2-9]\\d{8}", [9, 10, 11], [["(\\d{5})(\\d{4})", "$1 $2", ["219", "2196"], "($1)"], ["(\\d{2})(\\d{3})(\\d{4})", "$1 $2 $3", ["44"]], ["(\\d)(\\d{4})(\\d{4})", "$1 $2 $3", ["2[1-36]"], "($1)"], ["(\\d)(\\d{4})(\\d{4})", "$1 $2 $3", ["9[2-9]"]], ["(\\d{2})(\\d{3})(\\d{4})", "$1 $2 $3", ["3[2-5]|[47]|5[1-3578]|6[13-57]|8(?:0[1-9]|[1-9])"], "($1)"], ["(\\d{3})(\\d{3})(\\d{3,4})", "$1 $2 $3", ["60|8"]], ["(\\d{4})(\\d{3})(\\d{4})", "$1 $2 $3", ["1"]], ["(\\d{3})(\\d{3})(\\d{2})(\\d{3})", "$1 $2 $3 $4", ["60"]]]], "CM": ["237", "00", "[26]\\d{8}|88\\d{6,7}", [8, 9], [["(\\d{2})(\\d{2})(\\d{2})(\\d{2})", "$1 $2 $3 $4", ["88"]], ["(\\d)(\\d{2})(\\d{2})(\\d{2})(\\d{2})", "$1 $2 $3 $4 $5", ["[26]|88"]]]], "CN": ["86", "00|1(?:[12]\\d|79)\\d\\d00", "(?:(?:1[03-689]|2\\d)\\d\\d|6)\\d{8}|1\\d{10}|[126]\\d{6}(?:\\d(?:\\d{2})?)?|86\\d{5,6}|(?:[3-579]\\d|8[0-57-9])\\d{5,9}", [7, 8, 9, 10, 11, 12], [["(\\d{2})(\\d{5,6})", "$1 $2", ["(?:10|2[0-57-9])[19]|3(?:[157]|35|49|9[1-68])|4(?:1[124-9]|2[179]|6[47-9]|7|8[23])|5(?:[1357]|2[37]|4[36]|6[1-46]|80)|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:07|1[236-8]|2[5-7]|[37]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|3|4[13]|5[1-5]|7[0-79]|9[0-35-9])|(?:4[35]|59|85)[1-9]", "(?:10|2[0-57-9])(?:1[02]|9[56])|8078|(?:3(?:[157]\\d|35|49|9[1-68])|4(?:1[124-9]|2[179]|[35][1-9]|6[47-9]|7\\d|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]\\d|5[1-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|3\\d|4[13]|5[1-5]|7[0-79]|9[0-35-9]))1", "10(?:1(?:0|23)|9[56])|2[0-57-9](?:1(?:00|23)|9[56])|80781|(?:3(?:[157]\\d|35|49|9[1-68])|4(?:1[124-9]|2[179]|[35][1-9]|6[47-9]|7\\d|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]\\d|5[1-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|3\\d|4[13]|5[1-5]|7[0-79]|9[0-35-9]))12", "10(?:1(?:0|23)|9[56])|2[0-57-9](?:1(?:00|23)|9[56])|807812|(?:3(?:[157]\\d|35|49|9[1-68])|4(?:1[124-9]|2[179]|[35][1-9]|6[47-9]|7\\d|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]\\d|5[1-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|3\\d|4[13]|5[1-5]|7[0-79]|9[0-35-9]))123", "10(?:1(?:0|23)|9[56])|2[0-57-9](?:1(?:00|23)|9[56])|(?:3(?:[157]\\d|35|49|9[1-68])|4(?:1[124-9]|2[179]|[35][1-9]|6[47-9]|7\\d|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:078|1[236-8]|2[5-7]|[37]\\d|5[1-9]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|3\\d|4[13]|5[1-5]|7[0-79]|9[0-35-9]))123"], "0$1"], ["(\\d{3})(\\d{5,6})", "$1 $2", ["3(?:[157]|35|49|9[1-68])|4(?:[17]|2[179]|6[47-9]|8[23])|5(?:[1357]|2[37]|4[36]|6[1-46]|80)|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7]|[37]|8[36-8]|9[1-8])|9(?:0[1-3689]|1[1-79]|[379]|4[13]|5[1-5])|(?:4[35]|59|85)[1-9]", "(?:3(?:[157]\\d|35|49|9[1-68])|4(?:[17]\\d|2[179]|[35][1-9]|6[47-9]|8[23])|5(?:[1357]\\d|2[37]|4[36]|6[1-46]|80|9[1-9])|6(?:3[1-5]|6[0238]|9[12])|7(?:01|[1579]\\d|2[248]|3[014-9]|4[3-6]|6[023689])|8(?:1[236-8]|2[5-7