import { type E164PhoneNumber, type EmailAddress, type IsolateWebsitePathFunction, type ModelKey, type WebsiteUrl } from '@dereekb/util'; import { type WebsiteLink, type WebsiteLinkType } from './link'; /** * Isolates a username from a URL where the username is the first path segment after the domain. * * Strips trailing slashes and query parameters. Used by social platforms like Facebook, Instagram, and Twitter * where the profile URL pattern is `https://domain.com/{username}`. * * @example * ```typescript * WEBSITE_LINK_ISOLATE_BASE_URL_PROFILE_ID('https://www.facebook.com/myuser'); * // returns 'myuser' * ``` */ export declare const WEBSITE_LINK_ISOLATE_BASE_URL_PROFILE_ID: IsolateWebsitePathFunction; /** * Extracts a username from either a raw username string or a full profile URL where the username is the first path segment. * * Optionally prepends a prefix (e.g., "@" for TikTok, "$" for Cash App). * * @param input - A username or full profile URL. * @param prefix - Optional prefix to prepend to the extracted username. * @returns The isolated username, optionally prefixed. * * @example * ```typescript * usernameFromUsernameOrWebsiteWithBaseUrlUsername('https://facebook.com/myuser'); * // returns 'myuser' * * usernameFromUsernameOrWebsiteWithBaseUrlUsername('myuser', '@'); * // returns '@myuser' * ``` */ export declare function usernameFromUsernameOrWebsiteWithBaseUrlUsername(input: ModelKey | WebsiteUrl, prefix?: string): string; /** * Extracts a username from either a raw username string or a full profile URL using a custom path isolation function. * * Used for platforms with non-standard URL patterns (e.g., Snapchat's `/add/{username}`, YouTube's `/c/{username}`). * * @param input - A username or full profile URL. * @param isolateFn - Custom function that extracts the relevant path segment from the URL. * @returns The isolated username. */ export declare function usernameFromUsernameOrWebsiteWithOneOffBaseUrlUsername(input: ModelKey | WebsiteUrl, isolateFn: IsolateWebsitePathFunction): string; /** * Normalizes a string that may be either a plain username or a full website URL into a consistent URL format. * * If the input has a website domain, it is returned as-is. Otherwise, it is treated as a path and converted to an absolute slash path. * * @param input - A username or website URL. * @returns A normalized website URL. */ export declare function usernameOrWebsiteUrlToWebsiteUrl(input: string): WebsiteUrl; /** * {@link WebsiteLinkType} code for generic website URLs. */ export declare const WEBSITE_URL_WEBSITE_LINK_TYPE = "w"; /** * Converts a generic website URL into a {@link WebsiteLink}, stripping the HTTP/HTTPS protocol. * * @param input - The full website URL. * @returns A WebsiteLink with the protocol removed from the data. * * @example * ```typescript * const link = websiteUrlToWebsiteLink('https://example.com/page'); * // link.t === 'w', link.d === 'example.com/page' * ``` */ export declare function websiteUrlToWebsiteLink(input: WebsiteUrl): WebsiteLink; /** * {@link WebsiteLinkType} code for email addresses. */ export declare const EMAIL_URL_WEBSITE_LINK_TYPE = "e"; /** * Converts an email address into a {@link WebsiteLink}. * * @param input - The email address. * @returns A WebsiteLink storing the email as data. */ export declare function emailAddressToWebsiteLink(input: EmailAddress): WebsiteLink; /** * {@link WebsiteLinkType} code for phone numbers. */ export declare const PHONE_URL_WEBSITE_LINK_TYPE = "p"; /** * Converts an E.164 phone number into a {@link WebsiteLink}. * * @param input - The phone number in E.164 format. * @returns A WebsiteLink storing the phone number as data. */ export declare function phoneNumberToWebsiteLink(input: E164PhoneNumber): WebsiteLink; /** * Base URL for Facebook profiles. */ export declare const FACEBOOK_BASE_URL = "https://www.facebook.com"; /** * {@link WebsiteLinkType} code for Facebook. */ export declare const FACEBOOK_WEBSITE_LINK_TYPE: WebsiteLinkType; export type FacebookBaseUrl = typeof FACEBOOK_BASE_URL; export type FacebookProfileUrl

= `${FacebookBaseUrl}/${P}`; /** * Facebook profile identifier. * * @semanticType * @semanticTopic identifier * @semanticTopic string * @semanticTopic dereekb-model:social */ export type FacebookProfileId = string; export type FacebookWebsiteLinkType = typeof FACEBOOK_WEBSITE_LINK_TYPE; /** * Converts a Facebook profile ID or URL into a {@link WebsiteLink}. * * Accepts either a raw username or a full Facebook profile URL. * * @param input - A Facebook profile ID or full profile URL. * @returns A WebsiteLink with the isolated username as data. * * @example * ```typescript * facebookProfileUrlToWebsiteLink('https://www.facebook.com/myuser'); * // { t: 'fb', d: 'myuser' } * * facebookProfileUrlToWebsiteLink('myuser'); * // { t: 'fb', d: 'myuser' } * ``` */ export declare function facebookProfileUrlToWebsiteLink(input: FacebookProfileId | WebsiteUrl): WebsiteLink; /** * Constructs a full Facebook profile URL from a profile ID. * * @param profileId - The Facebook profile ID or username. * @returns The full profile URL. */ export declare function facebookProfileUrl

(profileId: P): FacebookProfileUrl

; /** * Base URL for Instagram profiles. */ export declare const INSTAGRAM_BASE_URL = "https://www.instagram.com"; /** * {@link WebsiteLinkType} code for Instagram. */ export declare const INSTAGRAM_WEBSITE_LINK_TYPE: WebsiteLinkType; export type InstagramBaseUrl = typeof INSTAGRAM_BASE_URL; export type InstagramProfileUrl

= `${InstagramBaseUrl}/${P}`; /** * Instagram profile identifier. * * @semanticType * @semanticTopic identifier * @semanticTopic string * @semanticTopic dereekb-model:social */ export type InstagramProfileId = string; export type InstagramWebsiteLinkType = typeof INSTAGRAM_WEBSITE_LINK_TYPE; /** * Converts an Instagram profile ID or URL into a {@link WebsiteLink}. * * @param input - An Instagram username or full profile URL. * @returns A WebsiteLink with the isolated username as data. */ export declare function instagramProfileUrlToWebsiteLink(input: InstagramProfileId | WebsiteUrl): WebsiteLink; /** * Constructs a full Instagram profile URL from a profile ID. * * @param profileId - The Instagram username. * @returns The full profile URL. */ export declare function instagramProfileUrl

(profileId: P): InstagramProfileUrl

; /** * Base URL for Twitter profiles. */ export declare const TWITTER_BASE_URL = "https://www.twitter.com"; /** * {@link WebsiteLinkType} code for Twitter. */ export declare const TWITTER_WEBSITE_LINK_TYPE: WebsiteLinkType; export type TwitterBaseUrl = typeof TWITTER_BASE_URL; export type TwitterProfileUrl

= `${TwitterBaseUrl}/${P}`; /** * Twitter/X profile identifier. * * @semanticType * @semanticTopic identifier * @semanticTopic string * @semanticTopic dereekb-model:social */ export type TwitterProfileId = string; export type TwitterWebsiteLinkType = typeof TWITTER_WEBSITE_LINK_TYPE; /** * Converts a Twitter profile ID or URL into a {@link WebsiteLink}. * * @param input - A Twitter username or full profile URL. * @returns A WebsiteLink with the isolated username as data. */ export declare function twitterProfileUrlToWebsiteLink(input: TwitterProfileId | WebsiteUrl): WebsiteLink; /** * Constructs a full Twitter profile URL from a profile ID. * * @param profileId - The Twitter username. * @returns The full profile URL. */ export declare function twitterProfileUrl

(profileId: P): TwitterProfileUrl

; /** * Base URL for TikTok profiles. */ export declare const TIKTOK_BASE_URL = "https://tiktok.com"; /** * TikTok usernames are prefixed with "@" in URLs and stored data. */ export declare const TIKTOK_USERNAME_PREFIX = "@"; /** * {@link WebsiteLinkType} code for TikTok. */ export declare const TIKTOK_WEBSITE_LINK_TYPE: WebsiteLinkType; export type TikTokBaseUrl = typeof TIKTOK_BASE_URL; export type TikTokProfileUrl

= `${TikTokBaseUrl}/@${P}`; /** * TikTok profile identifier. * * @semanticType * @semanticTopic identifier * @semanticTopic string * @semanticTopic dereekb-model:social */ export type TikTokProfileId = string; export type TikTokWebsiteLinkType = typeof TIKTOK_WEBSITE_LINK_TYPE; /** * Converts a TikTok profile ID or URL into a {@link WebsiteLink}. * * Automatically prepends the "@" prefix if not already present. * * @param input - A TikTok username (with or without "@") or full profile URL. * @returns A WebsiteLink with the "@"-prefixed username as data. */ export declare function tiktokProfileUrlToWebsiteLink(input: TikTokProfileId | WebsiteUrl): WebsiteLink; /** * Constructs a full TikTok profile URL from a profile ID. * * @param profileId - The TikTok username (without "@" prefix) * @returns The full profile URL with "@" prefix. */ export declare function tiktokProfileUrl

(profileId: P): TikTokProfileUrl

; /** * Base URL for Snapchat profiles. */ export declare const SNAPCHAT_BASE_URL = "https://snapchat.com"; /** * {@link WebsiteLinkType} code for Snapchat. */ export declare const SNAPCHAT_WEBSITE_LINK_TYPE: WebsiteLinkType; export type SnapchatBaseUrl = typeof SNAPCHAT_BASE_URL; export type SnapchatProfileUrl

= `${SnapchatBaseUrl}/add/${P}`; /** * Snapchat profile identifier. * * @semanticType * @semanticTopic identifier * @semanticTopic string * @semanticTopic dereekb-model:social */ export type SnapchatProfileId = string; export type SnapchatWebsiteLinkType = typeof SNAPCHAT_WEBSITE_LINK_TYPE; /** * Isolates a Snapchat username from a URL, ignoring the `/add/` base path segment. */ export declare const SNAPCHAT_WEBSITE_LINK_ISOLATE_PROFILE_ID: IsolateWebsitePathFunction; /** * Converts a Snapchat profile ID or URL into a {@link WebsiteLink}. * * Handles Snapchat's `/add/{username}` URL pattern. * * @param input - A Snapchat username or full profile URL. * @returns A WebsiteLink with the isolated username as data. */ export declare function snapchatProfileUrlToWebsiteLink(input: SnapchatProfileId | WebsiteUrl): WebsiteLink; /** * Constructs a full Snapchat profile URL from a profile ID. * * @param profileId - The Snapchat username. * @returns The full profile URL with `/add/` path. */ export declare function snapchatProfileUrl

(profileId: P): SnapchatProfileUrl

; /** * Base URL for YouTube channels. */ export declare const YOUTUBE_BASE_URL = "https://youtube.com"; /** * {@link WebsiteLinkType} code for YouTube. */ export declare const YOUTUBE_WEBSITE_LINK_TYPE: WebsiteLinkType; export type YouTubeBaseUrl = typeof YOUTUBE_BASE_URL; export type YouTubeProfileUrl

= `${YouTubeBaseUrl}/c/${P}`; /** * YouTube profile identifier. * * @semanticType * @semanticTopic identifier * @semanticTopic string * @semanticTopic dereekb-model:social */ export type YouTubeProfileId = string; export type YouTubeWebsiteLinkType = typeof YOUTUBE_WEBSITE_LINK_TYPE; /** * Isolates a YouTube channel name from a URL, ignoring the `/c/` base path segment. */ export declare const YOUTUBE_WEBSITE_LINK_ISOLATE_PROFILE_ID: IsolateWebsitePathFunction; /** * Converts a YouTube channel ID or URL into a {@link WebsiteLink}. * * Handles YouTube's `/c/{channel}` URL pattern. * * @param input - A YouTube channel name or full channel URL. * @returns A WebsiteLink with the isolated channel name as data. */ export declare function youtubeProfileUrlToWebsiteLink(input: YouTubeProfileId | WebsiteUrl): WebsiteLink; /** * Constructs a full YouTube channel URL from a profile ID. * * @param profileId - The YouTube channel name. * @returns The full channel URL with `/c/` path. */ export declare function youtubeProfileUrl

(profileId: P): YouTubeProfileUrl

; /** * Base URL for PayPal.me profiles. */ export declare const PAYPAL_BASE_URL = "https://paypal.me"; /** * {@link WebsiteLinkType} code for PayPal. */ export declare const PAYPAL_WEBSITE_LINK_TYPE: WebsiteLinkType; export type PayPalBaseUrl = typeof PAYPAL_BASE_URL; export type PayPalProfileUrl

= `${PayPalBaseUrl}/${P}`; /** * PayPal profile identifier. * * @semanticType * @semanticTopic identifier * @semanticTopic string * @semanticTopic dereekb-model:social */ export type PayPalProfileId = string; export type PayPalWebsiteLinkType = typeof PAYPAL_WEBSITE_LINK_TYPE; /** * Converts a PayPal profile ID or URL into a {@link WebsiteLink}. * * @param input - A PayPal username or full PayPal.me URL. * @returns A WebsiteLink with the isolated username as data. */ export declare function paypalProfileUrlToWebsiteLink(input: PayPalProfileId | WebsiteUrl): WebsiteLink; /** * Constructs a full PayPal.me profile URL from a profile ID. * * @param profileId - The PayPal username. * @returns The full PayPal.me URL. */ export declare function paypalProfileUrl

(profileId: P): PayPalProfileUrl

; /** * Base URL for Cash App profiles. */ export declare const CASHAPP_BASE_URL = "https://cash.app"; /** * Cash App usernames are prefixed with "$" (cashtag). */ export declare const CASHAPP_USERNAME_PREFIX = "$"; /** * {@link WebsiteLinkType} code for Cash App. */ export declare const CASHAPP_WEBSITE_LINK_TYPE: WebsiteLinkType; export type CashappBaseUrl = typeof CASHAPP_BASE_URL; export type CashappProfileUrl

= `${CashappBaseUrl}/$${P}`; /** * Cash App profile identifier. * * @semanticType * @semanticTopic identifier * @semanticTopic string * @semanticTopic dereekb-model:social */ export type CashappProfileId = string; export type CashappWebsiteLinkType = typeof CASHAPP_WEBSITE_LINK_TYPE; /** * Converts a Cash App profile ID or URL into a {@link WebsiteLink}. * * Automatically prepends the "$" prefix if not already present. * * @param input - A Cash App username (with or without "$") or full profile URL. * @returns A WebsiteLink with the "$"-prefixed username as data. */ export declare function cashappProfileUrlToWebsiteLink(input: CashappProfileId | WebsiteUrl): WebsiteLink; /** * Constructs a full Cash App profile URL from a profile ID. * * @param profileId - The Cash App username (without "$" prefix) * @returns The full Cash App URL with "$" prefix. */ export declare function cashappProfileUrl

(profileId: P): CashappProfileUrl

; /** * Base URL for Venmo profiles. */ export declare const VENMO_BASE_URL = "https://account.venmo.com"; /** * {@link WebsiteLinkType} code for Venmo. */ export declare const VENMO_WEBSITE_LINK_TYPE: WebsiteLinkType; export type VenmoBaseUrl = typeof VENMO_BASE_URL; export type VenmoProfileUrl

= `${VenmoBaseUrl}/u/${P}`; /** * Venmo profile identifier. * * @semanticType * @semanticTopic identifier * @semanticTopic string * @semanticTopic dereekb-model:social */ export type VenmoProfileId = string; export type VenmoWebsiteLinkType = typeof VENMO_WEBSITE_LINK_TYPE; /** * Isolates a Venmo username from a URL, ignoring the `/u/` base path segment. */ export declare const VENMO_WEBSITE_LINK_ISOLATE_PROFILE_ID: IsolateWebsitePathFunction; /** * Converts a Venmo profile ID or URL into a {@link WebsiteLink}. * * Handles Venmo's `/u/{username}` URL pattern. * * @param input - A Venmo username or full profile URL. * @returns A WebsiteLink with the isolated username as data. */ export declare function venmoProfileUrlToWebsiteLink(input: VenmoProfileId | WebsiteUrl): WebsiteLink; /** * Constructs a full Venmo profile URL from a profile ID. * * @param profileId - The Venmo username. * @returns The full profile URL with `/u/` path. */ export declare function venmoProfileUrl

(profileId: P): VenmoProfileUrl

; /** * Base URL for Spotify profiles. */ export declare const SPOTIFY_BASE_URL = "https://open.spotify.com/"; /** * {@link WebsiteLinkType} code for Spotify. */ export declare const SPOTIFY_WEBSITE_LINK_TYPE: WebsiteLinkType; export type SpotifyBaseUrl = typeof SPOTIFY_BASE_URL; export type SpotifyProfileUrl

= `${SpotifyBaseUrl}/user/${P}`; /** * Spotify profile identifier. * * @semanticType * @semanticTopic identifier * @semanticTopic string * @semanticTopic dereekb-model:social */ export type SpotifyProfileId = string; export type SpotifyWebsiteLinkType = typeof SPOTIFY_WEBSITE_LINK_TYPE; /** * Isolates a Spotify username from a URL, ignoring the `/user/` base path segment. */ export declare const SPOTIFY_WEBSITE_LINK_ISOLATE_PROFILE_ID: IsolateWebsitePathFunction; /** * Converts a Spotify profile ID or URL into a {@link WebsiteLink}. * * Handles Spotify's `/user/{username}` URL pattern. * * @param input - A Spotify username or full profile URL. * @returns A WebsiteLink with the isolated username as data. */ export declare function spotifyProfileUrlToWebsiteLink(input: SpotifyProfileId | WebsiteUrl): WebsiteLink; /** * Constructs a full Spotify profile URL from a profile ID. * * @param profileId - The Spotify username. * @returns The full profile URL with `/user/` path. */ export declare function spotifyProfileUrl

(profileId: P): SpotifyProfileUrl

;