import { fromEntries } from "../utils/fromEntries.js";
import { containsAllOfType } from "../utils/containsAllOf.js";

//#region src/customizables/elementDescriptors.ts
const CLASS_PREFIX = "cl-";
const OBJ_KEY_DELIMITER = "__";
const containsAllElementsConfigKeys = containsAllOfType();
const camelize = (s) => s.replace(/-./g, (x) => x[1].toUpperCase());
/**
* This object is strictly typed using the ElementsConfig type
* and is used as the single source of truth to generate the
* descriptor map
*/
const APPEARANCE_KEYS = containsAllElementsConfigKeys([
	"button",
	"input",
	"checkbox",
	"radio",
	"table",
	"rootBox",
	"cardBox",
	"card",
	"footerItem",
	"popoverBox",
	"disclosureRoot",
	"disclosureTrigger",
	"disclosureContentRoot",
	"disclosureContentInner",
	"disclosureContent",
	"lineItemsRoot",
	"lineItemsDivider",
	"lineItemsGroup",
	"lineItemsTitle",
	"lineItemsTitleDescription",
	"lineItemsDescription",
	"lineItemsDescriptionInner",
	"lineItemsDescriptionSuffix",
	"lineItemsDescriptionPrefix",
	"lineItemsDescriptionText",
	"lineItemsCopyButton",
	"lineItemsDowngradeNotice",
	"actionCard",
	"logoBox",
	"logoImage",
	"header",
	"headerTitle",
	"headerSubtitle",
	"headerBackLink",
	"main",
	"footer",
	"footerAction",
	"footerActionText",
	"footerActionLink",
	"footerPages",
	"footerPagesLink",
	"backRow",
	"backLink",
	"socialButtonsRoot",
	"socialButtons",
	"socialButtonsIconButton",
	"socialButtonsBlockButton",
	"socialButtonsBlockButtonText",
	"socialButtonsProviderIcon",
	"socialButtonsProviderInitialIcon",
	"lastAuthenticationStrategyBadge",
	"enterpriseButtonsProviderIcon",
	"providerIcon",
	"providerInitialIcon",
	"alternativeMethods",
	"alternativeMethodsBlockButton",
	"alternativeMethodsBlockButtonText",
	"alternativeMethodsBlockButtonArrow",
	"checkoutFormLineItemsRoot",
	"checkoutFormElementsRoot",
	"checkoutSuccessRoot",
	"checkoutSuccessRings",
	"checkoutSuccessBadge",
	"checkoutSuccessTitle",
	"checkoutSuccessDescription",
	"otpCodeField",
	"otpCodeFieldInputs",
	"otpCodeFieldInput",
	"otpCodeFieldInputContainer",
	"otpCodeFieldErrorText",
	"otpCodeFieldSuccessText",
	"formResendCodeLink",
	"dividerRow",
	"dividerColumn",
	"dividerText",
	"dividerLine",
	"drawerBackdrop",
	"drawerRoot",
	"drawerContent",
	"drawerHeader",
	"drawerTitle",
	"drawerBody",
	"drawerFooter",
	"drawerFooterTitle",
	"drawerFooterDescription",
	"drawerClose",
	"drawerConfirmationBackdrop",
	"drawerConfirmationRoot",
	"drawerConfirmationTitle",
	"drawerConfirmationDescription",
	"drawerConfirmationActions",
	"formHeader",
	"formHeaderTitle",
	"formHeaderSubtitle",
	"verificationLinkStatusBox",
	"verificationLinkStatusIconBox",
	"verificationLinkStatusIcon",
	"verificationLinkStatusText",
	"form",
	"formContainer",
	"formFieldRow",
	"formField",
	"formFieldLabelRow",
	"formFieldLabel",
	"formFieldRadioGroup",
	"formFieldRadioGroupItem",
	"formFieldRadioInput",
	"formFieldRadioLabel",
	"formFieldRadioLabelTitle",
	"formFieldRadioLabelDescription",
	"formFieldCheckboxInput",
	"formFieldCheckboxLabel",
	"formFieldAction",
	"formFieldInput",
	"formFieldErrorText",
	"formFieldWarningText",
	"formFieldSuccessText",
	"formFieldInfoText",
	"formFieldHintText",
	"formButtonPrimary",
	"formButtonReset",
	"formFieldInputGroup",
	"formFieldInputShowPasswordButton",
	"formFieldInputShowPasswordIcon",
	"formFieldInputCopyToClipboardButton",
	"formFieldInputCopyToClipboardIcon",
	"phoneInputBox",
	"formInputGroup",
	"avatarBox",
	"avatarImage",
	"avatarImageActions",
	"avatarImageActionsUpload",
	"avatarImageActionsRemove",
	"userButtonBox",
	"userButtonOuterIdentifier",
	"userButtonTrigger",
	"userButtonAvatarBox",
	"userButtonAvatarImage",
	"userButtonPopoverRootBox",
	"userButtonPopoverCard",
	"userButtonPopoverMain",
	"userButtonPopoverActions",
	"userButtonPopoverActionButton",
	"userButtonPopoverActionButtonIconBox",
	"userButtonPopoverActionButtonIcon",
	"userButtonPopoverCustomItemButton",
	"userButtonPopoverCustomItemButtonIconBox",
	"userButtonPopoverActionItemButtonIcon",
	"userButtonPopoverFooter",
	"userButtonPopoverFooterPagesLink",
	"organizationSwitcherTrigger",
	"organizationSwitcherTriggerIcon",
	"organizationSwitcherPopoverRootBox",
	"organizationSwitcherPopoverCard",
	"organizationSwitcherPopoverMain",
	"organizationSwitcherPopoverActions",
	"organizationSwitcherPopoverInvitationActions",
	"organizationSwitcherPopoverInvitationActionsBox",
	"organizationSwitcherPopoverActionButton",
	"organizationSwitcherPreviewButton",
	"organizationSwitcherInvitationAcceptButton",
	"organizationSwitcherPopoverActionButtonIconBox",
	"organizationSwitcherPopoverActionButtonIcon",
	"organizationSwitcherPopoverFooter",
	"organizationProfileMembersSearchInputIcon",
	"organizationProfileMembersSearchInput",
	"organizationListPreviewItems",
	"organizationListPreviewItem",
	"organizationListPreviewButton",
	"organizationListPreviewItemActionButton",
	"organizationListCreateOrganizationActionButton",
	"taskChooseOrganizationPreviewItem",
	"taskChooseOrganizationPreviewItems",
	"taskChooseOrganizationCreateOrganizationActionButton",
	"taskChooseOrganizationPreviewButton",
	"userAvatarBox",
	"userAvatarImage",
	"userPreview",
	"userPreviewAvatarContainer",
	"userPreviewAvatarBox",
	"userPreviewAvatarImage",
	"userPreviewAvatarIcon",
	"userPreviewTextContainer",
	"userPreviewMainIdentifier",
	"userPreviewMainIdentifierText",
	"userPreviewSecondaryIdentifier",
	"organizationPreview",
	"organizationPreviewAvatarContainer",
	"organizationPreviewAvatarBox",
	"organizationPreviewAvatarImage",
	"organizationPreviewTextContainer",
	"organizationPreviewMainIdentifier",
	"organizationPreviewSecondaryIdentifier",
	"organizationAvatarUploaderContainer",
	"membersPageInviteButton",
	"identityPreview",
	"identityPreviewText",
	"identityPreviewEditButton",
	"identityPreviewEditButtonIcon",
	"passkeyIcon",
	"accountSwitcherActionButton",
	"accountSwitcherActionButtonIconBox",
	"accountSwitcherActionButtonIcon",
	"pricingTable",
	"pricingTableCard",
	"pricingTableCardHeader",
	"pricingTableCardTitleContainer",
	"pricingTableCardTitle",
	"pricingTableCardDescription",
	"pricingTableCardBody",
	"pricingTableCardStatusRow",
	"pricingTableCardStatus",
	"pricingTableCardFeatures",
	"pricingTableCardFeaturesList",
	"pricingTableCardFeaturesListItem",
	"pricingTableCardFeaturesListItemContent",
	"pricingTableCardFeaturesListItemTitle",
	"pricingTableCardPeriodToggle",
	"pricingTableCardFeeContainer",
	"pricingTableCardFee",
	"pricingTableCardFeePeriod",
	"pricingTableCardFeePeriodNotice",
	"pricingTableCardFooter",
	"pricingTableCardFooterButton",
	"pricingTableCardFooterNotice",
	"pricingTableMatrix",
	"pricingTableMatrixTable",
	"pricingTableMatrixRowGroup",
	"pricingTableMatrixRowGroupHeader",
	"pricingTableMatrixRowGroupBody",
	"pricingTableMatrixRow",
	"pricingTableMatrixRowHeader",
	"pricingTableMatrixRowBody",
	"pricingTableMatrixColumnHeader",
	"pricingTableMatrixCell",
	"pricingTableMatrixCellFooter",
	"pricingTableMatrixAvatar",
	"pricingTableMatrixBadge",
	"pricingTableMatrixPlanName",
	"pricingTableMatrixFee",
	"pricingTableMatrixFeePeriod",
	"pricingTableMatrixFeePeriodNotice",
	"pricingTableMatrixFeePeriodNoticeInner",
	"pricingTableMatrixFeePeriodNoticeLabel",
	"pricingTableMatrixFooter",
	"planDetailHeader",
	"planDetailAvatar",
	"planDetailBadgeAvatarTitleDescriptionContainer",
	"planDetailBadgeContainer",
	"planDetailBadge",
	"planDetailTitle",
	"planDetailTitleDescriptionContainer",
	"planDetailDescription",
	"planDetailAction",
	"planDetailFeeContainer",
	"planDetailFee",
	"planDetailFeePeriod",
	"planDetailFeePeriodNotice",
	"planDetailFeePeriodNoticeInner",
	"planDetailFeePeriodNoticeLabel",
	"planDetailCaption",
	"planDetailFeatures",
	"planDetailFeaturesList",
	"planDetailFeaturesListItem",
	"planDetailFeaturesListItemContent",
	"planDetailFeaturesListItemTitle",
	"planDetailFeaturesListItemDescription",
	"planDetailPeriodToggle",
	"segmentedControlRoot",
	"segmentedControlButton",
	"switchRoot",
	"switchIndicator",
	"switchThumb",
	"switchLabel",
	"alert",
	"alertIcon",
	"alertText",
	"alertTextContainer",
	"tagInputContainer",
	"tagPillIcon",
	"tagPillContainer",
	"tabPanel",
	"tabButton",
	"tabListContainer",
	"tableHead",
	"tableBody",
	"tableRow",
	"tableHeaderCell",
	"tableBodyCell",
	"paginationButton",
	"paginationButtonIcon",
	"paginationRowText",
	"selectButton",
	"selectSearchInput",
	"selectButtonIcon",
	"selectOptionsContainer",
	"selectOption",
	"paymentMethodRow",
	"paymentMethodRowIcon",
	"paymentMethodRowText",
	"paymentMethodRowType",
	"paymentMethodRowValue",
	"paymentMethodRowBadge",
	"statementRoot",
	"statementHeader",
	"statementHeaderTitleContainer",
	"statementHeaderTitle",
	"statementHeaderBadge",
	"statementBody",
	"statementSection",
	"statementSectionHeader",
	"statementSectionHeaderTitle",
	"statementSectionContent",
	"statementSectionContentItem",
	"statementSectionContentDetailsList",
	"statementSectionContentDetailsListItem",
	"statementSectionContentDetailsListItemLabelContainer",
	"statementSectionContentDetailsListItemLabel",
	"statementSectionContentDetailsListItemValue",
	"statementSectionContentDetailsHeader",
	"statementSectionContentDetailsHeaderItem",
	"statementSectionContentDetailsHeaderItemIcon",
	"statementSectionContentDetailsHeaderTitle",
	"statementSectionContentDetailsHeaderDescription",
	"statementSectionContentDetailsHeaderSecondaryTitle",
	"statementSectionContentDetailsHeaderSecondaryDescription",
	"statementFooter",
	"statementFooterLabel",
	"statementFooterValueContainer",
	"statementFooterCurrency",
	"statementFooterValue",
	"statementCopyButton",
	"menuButton",
	"menuButtonEllipsis",
	"menuButtonEllipsisBordered",
	"menuList",
	"menuItem",
	"paymentAttemptRoot",
	"paymentAttemptHeader",
	"paymentAttemptHeaderTitleContainer",
	"paymentAttemptHeaderTitle",
	"paymentAttemptHeaderBadge",
	"paymentAttemptBody",
	"paymentAttemptFooter",
	"paymentAttemptFooterLabel",
	"paymentAttemptFooterValueContainer",
	"paymentAttemptFooterCurrency",
	"paymentAttemptFooterValue",
	"paymentAttemptCopyButton",
	"modalBackdrop",
	"modalContent",
	"modalCloseButton",
	"profileSection",
	"profileSectionItemList",
	"profileSectionItem",
	"profileSectionHeader",
	"profileSectionTitle",
	"profileSectionTitleText",
	"profileSectionSubtitle",
	"profileSectionSubtitleText",
	"profileSectionContent",
	"profileSectionPrimaryButton",
	"profileSectionButtonGroup",
	"profilePage",
	"formattedPhoneNumber",
	"formattedPhoneNumberFlag",
	"formattedPhoneNumberText",
	"formattedDate",
	"scrollBox",
	"navbar",
	"navbarButtons",
	"navbarButton",
	"navbarButtonIcon",
	"navbarButtonText",
	"navbarMobileMenuRow",
	"navbarMobileMenuButton",
	"navbarMobileMenuButtonIcon",
	"pageScrollBox",
	"page",
	"activeDevice",
	"activeDeviceListItem",
	"activeDeviceIcon",
	"impersonationFab",
	"impersonationFabIcon",
	"impersonationFabIconContainer",
	"impersonationFabTitle",
	"impersonationFabActionLink",
	"invitationsSentIconBox",
	"invitationsSentIcon",
	"qrCodeRow",
	"qrCodeContainer",
	"tooltip",
	"tooltipContent",
	"tooltipText",
	"badge",
	"notificationBadge",
	"buttonArrowIcon",
	"spinner",
	"apiKeys",
	"apiKeysHeader",
	"apiKeysSearchBox",
	"apiKeysSearchInput",
	"apiKeysAddButton",
	"apiKeysTable",
	"apiKeysCopyButton",
	"apiKeysRevealButton",
	"apiKeysCreateForm",
	"apiKeysCreateFormNameInput",
	"apiKeysCreateFormDescriptionInput",
	"apiKeysCreateFormExpirationInput",
	"apiKeysCreateFormSubmitButton",
	"apiKeysCreateFormExpirationCaption",
	"apiKeysRevokeModal",
	"apiKeysRevokeModalInput",
	"apiKeysRevokeModalSubmitButton",
	"apiKeysCopyModal",
	"apiKeysCopyModalInput",
	"apiKeysCopyModalSubmitButton",
	"subscriptionDetailsCard",
	"subscriptionDetailsCardHeader",
	"subscriptionDetailsCardBadge",
	"subscriptionDetailsCardTitle",
	"subscriptionDetailsCardBody",
	"subscriptionDetailsCardFooter",
	"subscriptionDetailsCardActions",
	"subscriptionDetailsActionButton",
	"subscriptionDetailsCancelButton",
	"subscriptionDetailsDetailRow",
	"subscriptionDetailsDetailRowLabel",
	"subscriptionDetailsDetailRowValue",
	"enterpriseConnectionsRoot",
	"enterpriseConnectionButton",
	"enterpriseConnectionButtonText",
	"web3SolanaWalletButtonsRoot",
	"web3SolanaWalletButtons",
	"web3SolanaWalletButtonsIconButton",
	"web3SolanaWalletButtonsBlockButton",
	"web3SolanaWalletButtonsBlockButtonText",
	"web3SolanaWalletButtonsWalletIcon",
	"web3SolanaWalletButtonsWalletInitialIcon",
	"walletIcon",
	"walletInitialIcon"
]).map(camelize);
/**
* Turns a key from the ElementsConfig object to a targettable classname
* socialButtons-buttonIcon ->  cl-socialButtons-buttonIcon
*/
const toTargettableClassname = (key) => {
	return CLASS_PREFIX + key;
};
/**
* Turns a key from the ElementsConfig object to a appearance.elements key
* socialButtons-buttonIcon -> socialButtonsButtonIcon
*/
const toObjectKey = (key) => {
	return key.replace(/([-][a-z])/, (match) => match[1].toUpperCase());
};
const createElementDescriptor = (key) => {
	const objectKey = toObjectKey(key);
	return {
		objectKey,
		targettableClassname: toTargettableClassname(key),
		getTargettableIdClassname: (params) => toTargettableClassname(key) + "__" + params.id,
		getObjectKeyWithState: (state) => objectKey + OBJ_KEY_DELIMITER + state,
		getObjectKeyWithId: (idObj) => objectKey + OBJ_KEY_DELIMITER + idObj.id,
		getObjectKeyWithIdAndState: (idObj, state) => objectKey + OBJ_KEY_DELIMITER + idObj.id + OBJ_KEY_DELIMITER + state,
		setId: (id) => id ? {
			id,
			__type: "id"
		} : void 0
	};
};
const createDescriptorMap = (keys = APPEARANCE_KEYS) => {
	return fromEntries(keys.map((key) => [toObjectKey(key), createElementDescriptor(key)]));
};
const descriptors = createDescriptorMap();

//#endregion
export { CLASS_PREFIX, descriptors };
//# sourceMappingURL=elementDescriptors.js.map