{"version":3,"file":"c_bem.js","sources":["../../../../typescript/libraries/api_v2/routes/growth_provider.ts","../../../../metaserver/static/js/clean/bem.ts","../../../../js/esv_utils/internal.ts"],"sourcesContent":["// @generated by Stone, do not modify.\n/* eslint-disable */\n\nimport {GrowthRoutes} from 'typescript/libraries/api_v2/routes/growth';\nimport {ApiV2ClientBase} from 'typescript/libraries/api_v2/base_client';\n\nexport function GetGrowthRoutes\u003cP\u003e(client: ApiV2ClientBase\u003cP\u003e): GrowthRoutes\u003cP\u003e {\n return client.ns('growth');\n}\n","/**\n * Utilities for forming BEM-style classnames.\n */\n\ninterface Bemifier {\n (el?: string | null, mod?: string): string;\n mod(mod: string): string;\n}\n\n/**\n * Creates a 'Bemifier' namespaced to the given 'block' string. Use the returned function to\n * create block__element--modifier strings, or use .mod() to create block--modifer strings.\n *\n * .styles() creates an object of BEM classNames based on the given block string and an array\n * of element_modifier sub-strings.\n *\n * Example Usage:\n *\n * import React from 'react';\n * import {bem} from 'metaserver/static/js/clean/bem';\n *\n * const cn = bem('my-elaborately-named-modal');\n *\n * export class MyElaboratelyNameModal extends React.Component\u003c{}, {}\u003e {\n * render () {\n * return (\n * \u003cdiv className={`${cn()} ${cn.mod(this.props.lookAndFeel)}`}\u003e\n * \u003ch1 className={cn('title')}\u003eMy Modal Title\u003c/h1\u003e\n * \u003cdiv className={cn('body')}\u003e\n * \u003cbutton className={`${cn('button')} ${cn('button', 'small')}`}\u003e\n * Click Me\n * \u003c/button\u003e\n * \u003c/div\u003e\n * \u003c/div\u003e\n * )\n * }\n * }\n *\n * Example Output:\n *\n * \u003cdiv class=\"my-elaborately-named-modal my-elaborately-named-modal--hot\"\u003e\n * \u003ch1 class=\"my-elaborately-named-modal__title\"\u003eMy Modal Title\u003c/h1\u003e\n * \u003cdiv class=\"my-elaborately-named-modal__body\"\u003e\n * \u003cbutton class=\"my-elaborately-named-modal__button my-elaborately-named-modal__button--small\"\u003e\n * Click Me\n * \u003c/button\u003e\n * \u003c/div\u003e\n * \u003c/div\u003e\n */\nexport function bem(block: string): Bemifier {\n function bemify(el?: string | null, mod?: string): string {\n return block + (el ? `__${el}` : '') + (mod ? `--${mod}` : '');\n }\n\n // Need to use Object.assign for Typescript to allow attaching properties to a function.\n return Object.assign(bemify, {\n mod: bemify.bind(null, null),\n }) as Bemifier;\n}\n\n/**\n * Create a 'styles' object, which contains a mapping of keys to BEM classNames. The classNames\n * are constructred from the given 'block' string and a array of 'element_modifier' strings.\n *\n * We treat '_' as the delimiter (for easier key referencing in code), so your classes will\n * likely need to be camelCase (which prepares you better for CSS Module conventions anyhow).\n *\n * Strings that start with '_' are converted to 'block--modifier' classNames. A lone '_' character\n * will reference the base block className.\n *\n *\n * Example Usage:\n *\n * import React from 'react';\n * import {bemStyles} from 'metaserver/static/js/clean/bem';\n *\n * // This creates a type-safe map of style strings. '_' separates an element from a\n * // a modifier, therefore your elements and modifiers should be camelCase.\n * // (this is to adhere more closely with CSS Modules best practices).\n * const styles = bemStyles('my-elaborately-named-modal', [\n * '_',\n * '_myTheme',\n * 'title',\n * 'body',\n * 'button',\n * 'button_small',\n * ]);\n *\n * export class MyElaboratelyNameModal extends React.Component\u003c{}, {}\u003e {\n * render () {\n * return (\n * \u003cdiv className={`${styles._} ${styles._myTheme}`}\u003e\n * \u003ch1 className={styles.title}\u003eMy Modal Title\u003c/h1\u003e\n * \u003cdiv className={styles.body}\u003e\n * \u003cbutton className={`${styles.button} ${styles.button_small}`}\u003e\n * Click Me\n * \u003c/button\u003e\n * \u003c/div\u003e\n * \u003c/div\u003e\n * )\n * }\n * }\n *\n * Example Output:\n *\n * \u003cdiv class=\"my-elaborately-named-modal my-elaborately-named-modal--myTheme\"\u003e\n * \u003ch1 class=\"my-elaborately-named-modal__title\"\u003eMy Modal Title\u003c/h1\u003e\n * \u003cdiv class=\"my-elaborately-named-modal__body\"\u003e\n * \u003cbutton class=\"my-elaborately-named-modal__button my-elaborately-named-modal__button--small\"\u003e\n * Click Me\n * \u003c/button\u003e\n * \u003c/div\u003e\n * \u003c/div\u003e\n */\nexport function bemStyles\u003cStyleKey extends string\u003e(\n block: string,\n styleKeys: Array\u003cStyleKey\u003e = []\n): Record\u003cStyleKey, string\u003e {\n const cn = bem(block);\n const styles = {} as Record\u003cStyleKey, string\u003e;\n\n styleKeys.forEach((styleKey) =\u003e {\n const [el, mod, ...rest] = styleKey.split('_');\n if (rest.length) {\n throw new Error('Cannot define style keys with more then an element + modifer');\n }\n styles[styleKey] = cn(el, mod);\n });\n\n return styles;\n}\n","/*\n This file contains utility functions that are used internally for interacting with desktop code.\n They are they should not be used by code outside //js/esv_utils\n*/\n\nimport type {UdclEvent, UdclMeasure} from 'typescript/libraries/api_v2/datatypes/udcl';\nexport type UdclEntry = UdclEvent | UdclMeasure;\n\n// Note: We don't import the types from apex-metrics here because apex-metrics is defined\n// as a monolithic bazel target, and it needs to depend on this file, so importing those\n// types would create a circular dependency.\n//\n// **IMPORTANT**\n// This needs to be kept in sync/backwards compatible with the types in\n// //desktop/dropbox/electron/common/fenix/esv_base_journey_controller.ts\nexport type AmisSpan =\n | {\n type: 'histogram';\n namespace: string;\n metricName: string;\n tags: Record\u003cstring, string\u003e;\n samples: number[];\n }\n | {\n type: 'set';\n namespace: string;\n metricName: string;\n tags: Record\u003cstring, string\u003e;\n value: string;\n };\n\ninterface FssLauncherEventMap {\n // eslint-disable-next-line @typescript-eslint/naming-convention\n KEYBOARD_SHORTCUT_UPDATED_V1: {\n newShortcut: string;\n };\n}\ninterface BaseEsvController {\n logEvent?: (id: string, entry: UdclEntry) =\u003e void;\n logAmisEvent?: (span: AmisSpan) =\u003e void;\n logPAPEvent?: () =\u003e void;\n reportEsvLoadOutcome?: (outcome: unknown) =\u003e void;\n getExceptionTags?: () =\u003e Promise\u003cRecord\u003cstring, string\u003e\u003e;\n}\n\ninterface SharingController {\n closeShareModal?: () =\u003e void;\n openUrl?: (url: string) =\u003e void;\n}\nexport interface FssLauncherEventService {\n addEventListener: (\n eventName: keyof FssLauncherEventMap,\n callback: (args: FssLauncherEventMap[keyof FssLauncherEventMap]) =\u003e void\n ) =\u003e () =\u003e void;\n}\n\n//These globals are defined by the fenix framework. They will never be present\n//in a web environment, but should be defined always be defined in ESVs.\nexport interface FenixWindow extends Window {\n controller?: BaseEsvController | SharingController;\n fenixInitializationComplete?: Promise\u003cvoid\u003e;\n fssLauncherEventService?: FssLauncherEventService;\n}\n\nconst getFenixWindow = async (): Promise\u003cFenixWindow | null\u003e =\u003e {\n const maybeFenixWindow = window as unknown as FenixWindow;\n // == null is used to check for both null and undefined\n if (maybeFenixWindow.fenixInitializationComplete == null) {\n return null;\n }\n await maybeFenixWindow.fenixInitializationComplete;\n return maybeFenixWindow;\n};\n\nexport async function maybeGetFssLauncherEventService(): Promise\u003cFssLauncherEventService | null\u003e {\n const maybeFenixWindow = await getFenixWindow();\n\n return maybeFenixWindow?.fssLauncherEventService ?? null;\n}\n\n/**\n * Attempt to get a collection of Fenix methods exposed by a Fenix service.\n *\n * The latest version of web code can be loaded by all versions of the Desktop\n * application, so we need to assume that any Fenix (native) application\n * functionality may not be present.\n *\n * Callers should also pass the expected interface of the resulting environment\n * object as a type parameter. This will grant strong typing to the returned\n * value.\n *\n * @param {...string} methods\n * Pass the name(s) of the methods that you expect to be provided by this Fenix\n * service.\n *\n * @returns If any part of the requested Fenix environment was not verifiable,\n * returns null. Otherwise, returns the expected Fenix interface.\n *\n * @example\n * interface SharingEnvironment {\n * closeShareModal: () =\u003e void;\n * openUrl: (url: string) =\u003e void;\n * }\n *\n * export const getSharingEnvironment = () =\u003e\n * maybeGetFenixEnv\u003cSharingEnvironment\u003e('closeShareModal', 'openUrl');\n */\nexport async function maybeGetFenixEnv\u003cT extends {}\u003e(...methods: (keyof T)[]) {\n const maybeFenixWindow = await getFenixWindow();\n\n const controller = maybeFenixWindow?.controller as Partial\u003cT\u003e;\n\n // controller will be null if this is not an ESV execution environment\n if (!controller) {\n return null;\n }\n\n // try to instrument with AMIS if available\n const maybeLogAmisEvent = (controller as BaseEsvController).logAmisEvent;\n\n // \"pick\" the requested methods off of the base controller\n const env: Partial\u003cT\u003e = {};\n for (const method of methods) {\n // if we are running in an incompatible desktop app version, the requested\n // fenix methods may not be present\n if (!(controller.hasOwnProperty(method) \u0026\u0026 typeof controller[method] === 'function')) {\n maybeLogAmisEvent?.({\n metricName: 'maybe_get_fenix_env',\n namespace: 'desktop_esv',\n samples: [1],\n tags: {methods: methods.join(':'), result: 'method_not_available'},\n type: 'histogram',\n });\n\n return null;\n }\n\n env[method] = controller[method] as T[keyof T];\n }\n\n maybeLogAmisEvent?.({\n metricName: 'maybe_get_fenix_env',\n namespace: 'desktop_esv',\n samples: [1],\n tags: {methods: methods.join(':'), result: 'success'},\n type: 'histogram',\n });\n\n return env as T;\n}\n"],"names":["client","ns","block","bemify","el","mod","Object","assign","bind","async","methods","maybeFenixWindow","window","fenixInitializationComplete","getFenixWindow","controller","maybeLogAmisEvent","logAmisEvent","env","method","hasOwnProperty","metricName","namespace","samples","tags","join","result","type"],"mappings":";+DAMM,SAA6BA,GACjC,OAAOA,EAAOC,GAAG,SACnB,QCyCM,SAAcC,GAClB,SAASC,EAAOC,EAAoBC,GAClC,OAAOH,GAASE,EAAK,KAAKA,IAAO,KAAOC,EAAM,KAAKA,IAAQ,GAC5D,CAGD,OAAOC,OAAOC,OAAOJ,EAAQ,CAC3BE,IAAKF,EAAOK,KAAK,KAAM,OAE3B,qBCiDOC,kBAAiDC,GACtD,MAAMC,OA5CeF,WACrB,MAAME,EAAmBC,OAEzB,OAAoD,MAAhDD,EAAiBE,4BACZ,YAEHF,EAAiBE,4BAChBF,EAAgB,EAqCQG,GAEzBC,EAAaJ,aAAA,EAAAA,EAAkBI,WAGrC,IAAKA,EACH,OAAO,KAIT,MAAMC,EAAqBD,EAAiCE,aAGtDC,EAAkB,CAAA,EACxB,IAAK,MAAMC,KAAUT,EAAS,CAG5B,IAAMK,EAAWK,eAAeD,IAAyC,mBAAvBJ,EAAWI,GAS3D,OARAH,SAAAA,EAAoB,CAClBK,WAAY,sBACZC,UAAW,cACXC,QAAS,CAAC,GACVC,KAAM,CAACd,QAASA,EAAQe,KAAK,KAAMC,OAAQ,wBAC3CC,KAAM,cAGD,KAGTT,EAAIC,GAAUJ,EAAWI,EAC1B,CAUD,OARAH,SAAAA,EAAoB,CAClBK,WAAY,sBACZC,UAAW,cACXC,QAAS,CAAC,GACVC,KAAM,CAACd,QAASA,EAAQe,KAAK,KAAMC,OAAQ,WAC3CC,KAAM,cAGDT,CACT","debugId":"c29d36a5-ba8c-33dd-8d36-88d82e2e1f6f","debug_id":"c29d36a5-ba8c-33dd-8d36-88d82e2e1f6f"}