{
  "version": 3,
  "sources": ["../../../lib.web.board_chooser/board_chooser_items.tsx", "../../../lib.web.board_chooser/board_chooser_menu.tsx", "../../board/toggle_sort_boards_alphabetically.tsx"],
  "sourcesContent": ["import * as React from \"react\"\nimport {ListItem, MenuItem, MenuItemDivider, Icon} from \"@cling/lib.web.mdc\"\nimport {i18n} from \"@cling/lib.web.i18n\"\nimport {\n    BoardType,\n    BoardUID,\n    board_uid_type,\n    board_vanity_uri,\n    is_system_board_uid,\n} from \"@cling/lib.shared.model\"\n\nexport type BoardChooserItem = {\n    uid: BoardUID\n    sort: {\n        name: string\n        date_ms: number\n    }\n    user_board_title: any\n    user_board_title_str: string\n    background_style: React.CSSProperties\n    show_badge?: boolean\n    disabled?: boolean\n    selected?: boolean\n    can_be_folded?: boolean\n    archived?: boolean\n    num_participants_in_video_chat: number\n}\n\nexport function board_chooser_items({\n    element_type,\n    items,\n    onSelected,\n    sort_boards_alphabetically,\n}: {\n    element_type: \"ListItem\" | \"MenuItem\"\n    items: BoardChooserItem[]\n    onSelected?: (board_uid: BoardUID) => void\n    sort_boards_alphabetically: boolean\n}) {\n    const system_boards = items.filter((x) => is_system_board_uid(x.uid))\n    const normal_boards = items.filter((x) => !is_system_board_uid(x.uid))\n    // Sort the boards by whether they are archived, can be folded, modification date, or name\n    // based on `sort_boards_alphabetically`.\n    normal_boards.sort((a, b) => {\n        let res = (a.archived ? 1 : 0) - (b.archived ? 1 : 0)\n        if (res !== 0) {\n            return res\n        }\n        if (!sort_boards_alphabetically) {\n            res = (a.can_be_folded ? 1 : 0) - (b.can_be_folded ? 1 : 0)\n            if (res !== 0) {\n                return res\n            }\n            res = b.sort.date_ms - a.sort.date_ms\n            if (res !== 0) {\n                return res\n            }\n        }\n        return a.sort.name.localeCompare(b.sort.name)\n    })\n    const chooser_item = (item: BoardChooserItem, key_prefix = \"\") => {\n        const graphic = (\n            <div className=\"board-chooser-item__icon\" style={item.background_style}>\n                {item.show_badge && (\n                    <div className=\"board-chooser-item__new-or-changed-badge mdcx-badge mdcx-badge--small mdcx-badge--secondary\">\n                        &nbsp;\n                    </div>\n                )}\n            </div>\n        )\n        const board_type = board_uid_type(item.uid)\n        const title =\n            board_type === BoardType.dashboard\n                ? i18n.cling_home_screen\n                : board_type === BoardType.trashcan\n                  ? i18n.trashcan\n                  : board_type === BoardType.clipboard\n                    ? i18n.clipboard\n                    : item.user_board_title\n        const meta =\n            item.num_participants_in_video_chat > 0 ? (\n                <div>\n                    <Icon icon=\"voice_chat\" primary />\n                </div>\n            ) : undefined\n        if (element_type === \"ListItem\") {\n            return (\n                <ListItem\n                    key={key_prefix + item.uid}\n                    className=\"board-chooser-item\"\n                    disabled={item.disabled}\n                    selected={item.selected}\n                    onClick={onSelected ? () => onSelected(item.uid) : undefined}\n                    data-test-id={`BoardChooser_board_${item.uid}`}\n                    data-can-be-folded={item.can_be_folded}\n                    value={item.uid}\n                >\n                    {graphic}\n                    <a\n                        href={board_vanity_uri(item.uid, item.user_board_title_str)}\n                        onClick={on_click}\n                        tabIndex={-1}\n                    >\n                        {title}\n                    </a>\n                    {meta}\n                </ListItem>\n            )\n        }\n        return (\n            <MenuItem\n                key={key_prefix + item.uid}\n                title={title}\n                className=\"board-chooser-item\"\n                disabled={item.disabled}\n                graphic={graphic}\n                value={item.uid}\n                meta={meta}\n                data-test-id={`BoardChooser_board_${item.uid}`}\n                data-can-be-folded={item.can_be_folded}\n            />\n        )\n    }\n    const result = []\n    if (system_boards.length > 0) {\n        // Render in order \"dashboard\", \"clipboard\", \"trashcan\" ...\n        for (const board_type of [BoardType.dashboard, BoardType.clipboard, BoardType.trashcan]) {\n            const item = system_boards.find((x) => board_uid_type(x.uid) === board_type)\n            if (item) {\n                result.push(chooser_item(item))\n            }\n        }\n    }\n    if (normal_boards.length > 0) {\n        if (system_boards.length > 1) {\n            result.push(<MenuItemDivider key=\"regular\" title={i18n.all_your_boards} />)\n        }\n        result.push(...normal_boards.map((x) => chooser_item(x)))\n    }\n    return result\n}\n\nfunction on_click(e: React.MouseEvent) {\n    e.preventDefault()\n    if (e.ctrlKey || e.metaKey) {\n        // Open the board in a new window ...\n        const url = e.currentTarget.getAttribute(\"href\")\n        if (url) {\n            open(url, \"_blank\")\n            e.stopPropagation()\n        }\n    }\n}\n", "import * as React from \"react\"\nimport {observer} from \"mobx-react\"\nimport {Menu} from \"@cling/lib.web.mdc\"\nimport type {BoardUID} from \"@cling/lib.shared.model\"\nimport {board_chooser_items, BoardChooserItem} from \"./board_chooser_items\"\nimport {i18n} from \"@cling/lib.web.i18n\"\nimport {running_on_mobile_device} from \"@cling/lib.web.utils\"\n\ninterface Props {\n    anchor: React.ReactElement\n    onSelected: (board_uid: BoardUID) => void\n    onOpen?: () => void\n    onClose?: () => void\n    is_open: boolean\n    sort_boards_alphabetically: boolean\n    items: BoardChooserItem[]\n    first_menu_item?: any\n    \"data-test-id\"?: string\n}\n\nexport const BoardChooserMenu = observer(\n    ({\n        anchor,\n        items,\n        first_menu_item,\n        onOpen,\n        onClose,\n        onSelected,\n        sort_boards_alphabetically,\n        \"data-test-id\": data_test_id,\n        is_open,\n    }: Props) => {\n        const menu_ref = React.createRef<Menu>()\n        React.useEffect(() => {\n            if (is_open) {\n                menu_ref.current?.open_menu()\n            } else {\n                menu_ref.current?.close_menu()\n            }\n        })\n        const menu_items = board_chooser_items({\n            element_type: \"MenuItem\",\n            items,\n            sort_boards_alphabetically,\n        })\n        return (\n            <Menu\n                ref={menu_ref}\n                searchable\n                data-test-id={data_test_id}\n                search_label={i18n.search}\n                search_initial_focus={!running_on_mobile_device()}\n                search_pos={running_on_mobile_device() ? \"bottom\" : \"top\"}\n                first_menu_item={first_menu_item}\n                onOpen={onOpen}\n                onClose={onClose}\n                onSelected={onSelected as any}\n                anchor={\n                    <>\n                        {anchor}\n                        {items.some((x) => x.show_badge) && (\n                            <div className=\"board-chooser__new-or-changed-badge mdcx-badge mdcx-badge--small mdcx-badge--secondary\">\n                                &nbsp;\n                            </div>\n                        )}\n                    </>\n                }\n                className=\"board-chooser__menu\"\n            >\n                {menu_items}\n            </Menu>\n        )\n    },\n)\n", "import * as React from \"react\"\nimport {report_error} from \"@cling/lib.shared.debug\"\nimport {call_function} from \"@cling/lib.shared.faas\"\nimport {\n    create_PatchUID,\n    PatchAccountSettings,\n    PatchFullAccountRequest,\n    TriState,\n} from \"@cling/lib.shared.model\"\nimport {i18n} from \"@cling/lib.web.i18n\"\nimport {runInAction} from \"mobx\"\nimport {current_user} from \"../state/index\"\nimport {observer} from \"mobx-react\"\nimport {IconButton} from \"@cling/lib.web.mdc\"\n\nexport const ToggleSortBoardsAlphabetically = observer(({display}: {display: \"icon\" | \"link\"}) => {\n    const {sort_boards_alphabetically} = current_user.account_settings\n    const on_click = React.useCallback(() => {\n        runInAction(\n            () =>\n                (current_user.account_settings.sort_boards_alphabetically =\n                    !sort_boards_alphabetically),\n        )\n        call_function(\n            new PatchFullAccountRequest({\n                patch_uid: create_PatchUID(),\n                patch_account_settings: new PatchAccountSettings({\n                    sort_boards_alphabetically: sort_boards_alphabetically\n                        ? TriState.false\n                        : TriState.true,\n                }),\n            }),\n        ).catch(report_error)\n    }, [sort_boards_alphabetically])\n    if (display === \"link\") {\n        return (\n            <a className=\"action\" onClick={on_click}>\n                {sort_boards_alphabetically\n                    ? i18n.recently_modified_first\n                    : i18n.sort_alphabetically}\n            </a>\n        )\n    } else {\n        return (\n            <IconButton\n                icon=\"sort_by_alpha\"\n                small\n                onClick={on_click}\n                outlined\n                className={sort_boards_alphabetically ? \"\" : \"mdcx-icon--not-pressed\"}\n                tooltip={\n                    sort_boards_alphabetically\n                        ? i18n.sort_alphabetically\n                        : i18n.recently_modified_first\n                }\n                data-test-id=\"ToggleSortBoardsAlphabetically\"\n            />\n        )\n    }\n})\n"],
  "mappings": "igBAAAA,IA4BO,SAASC,EAAoB,CAChC,aAAAC,EACA,MAAAC,EACA,WAAAC,EACA,2BAAAC,CACJ,EAKG,CACC,IAAMC,EAAgBH,EAAM,OAAQI,GAAMC,E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ACL,WAAU,GACV,eAAcF,EACd,aAAcS,EAAK,OACnB,qBAAsB,CAACC,EAAyB,EAChD,WAAYA,EAAyB,EAAI,SAAW,MACpD,gBAAiBf,EACjB,OAAQC,EACR,QAASC,EACT,WAAYC,EACZ,OACIS,EAAAI,EAAA,KACKlB,EACAC,EAAM,KAAMkB,GAAMA,EAAE,UAAU,GAC3BL,EAAC,OAAI,UAAU,0FAAyF,MAExG,CAER,EAEJ,UAAU,uBAETF,CACL,CAER,CACJ,ECzEAQ,IAeO,IAAMC,GAAiCC,EAAS,CAAC,CAAC,QAAAC,CAAO,IAAkC,CAC9F,GAAM,CAAC,2BAAAC,CAA0B,EAAIC,EAAa,iBAC5CC,EAAiBC,EAAY,IAAM,CACrCC,EACI,IACKH,EAAa,iBAAiB,2BAC3B,CAACD,CACb,EACAK,EACI,IAAIC,EAAwB,CACxB,UAAWC,EAAgB,EAC3B,uBAAwB,IAAIC,EAAqB,CAC7C,2BAA4BR,KAGhC,CAAC,CACL,CAAC,CACL,EAAE,MAAMS,CAAY,CACxB,EAAG,CAACT,CAA0B,CAAC,EAC/B,OAAID,IAAY,OAERW,EAAC,KAAE,UAAU,SAAS,QAASR,GAC1BF,EACKW,EAAK,wBACLA,EAAK,mBACf,EAIAD,EAACE,EAAA,CACG,KAAK,gBACL,MAAK,GACL,QAASV,EACT,SAAQ,GACR,UAAWF,EAA6B,GAAK,yBAC7C,QACIA,EACMW,EAAK,oBACLA,EAAK,wBAEf,eAAa,iCACjB,CAGZ,CAAC",
  "names": ["init_compat_module", "board_chooser_items", "element_type", "items", "onSelected", "sort_boards_alphabetically", "system_boards", "x", "is_system_board_uid", "normal_boards", "a", "b", "res", "chooser_item", "__name", "item", "key_prefix", "graphic", "_", "board_type", "board_uid_type", "title", "i18n", "meta", "Icon", "ListItem", "board_vanity_uri", "on_click", "MenuItem", "result", "MenuItemDivider", "e", "url", "init_compat_module", "BoardChooserMenu", "observer", "anchor", "items", "first_menu_item", "onOpen", "onClose", "onSelected", "sort_boards_alphabetically", "data_test_id", "is_open", "menu_ref", "b", "y", "menu_items", "board_chooser_items", "_", "Menu", "i18n", "running_on_mobile_device", "k", "x", "init_compat_module", "ToggleSortBoardsAlphabetically", "observer", "display", "sort_boards_alphabetically", "current_user", "on_click", "q", "runInAction", "call_function", "PatchFullAccountRequest", "create_PatchUID", "PatchAccountSettings", "report_error", "_", "i18n", "IconButton"]
}