{"version":3,"sources":["datatypes/Pages.ts","datatypes/Common.ts","components/TableOfContentsNode.tsx","pagetypes/TableOfContentsPage.tsx"],"names":["buildPageUrl","pageId","sanitizeId","getPage","id","locale","url","fetchServerUrl","then","response","json","page","navbarIcon","iconId","iconStringToIdConversions","transformIconLocatorStringId","catch","reason","console","log","link","faLink","question","faQuestion","industry","faIndustry","faClipboardCheck","getSectionNameForContentType","contentType","key","toLowerCase","i18n","exists","t","getTooltipForContentType","toString","getPageTitleForContentType","getContentTypeSectionIndex","getIconForContentType","iconType","IconType","FontAwesome","faTasks","faInfoCircle","faFileAlt","faBook","replace","Link","props","node","linkUrl","newWindow","isDocumentLink","isExternalLink","ContentLink","href","title","Icon","isExpanded","clickFunc","useTranslation","children","length","className","onClick","getCollapseIcon","icon","TableOfContentsNode","level","nodeKey","window","location","pathname","globalExpandedState","getGlobalExpandedState","useState","setIsExpanded","Row","e","preventDefault","setGlobalExpandedState","Collapse","isOpen","map","n","TableOfContentsPage","loadFunc","pageTitleKey","pageTitleIcon","toc","setToc","setPageTitle","useDDHPageContext","useEffect","x","Loading"],"mappings":"kGAAA,2RAgBO,SAASA,EAAaC,GACzB,MAAM,SAAN,OAAgBC,YAAWD,IAmCxB,SAASE,EAAQC,EAAYC,GAChC,IAAIC,EAAG,oBAAgBJ,YAAWE,GAA3B,mBAAyCC,GAChD,OAAOE,YAAeD,GACjBE,MAAK,SAACC,GAAD,OAAcA,EAASC,UAC5BF,MAAK,SAACG,GAAD,OAed,SAAsCA,GAE9BA,GACAA,EAAKC,YAC6B,kBAA3BD,EAAKC,WAAWC,QACvBC,EAA0BH,EAAKC,WAAWC,UAE1CF,EAAKC,WAAWC,OACZC,EAA0BH,EAAKC,WAAWC,SAElD,OAAOF,EAzBaI,CAA6BJ,MAC5CK,OAAM,SAACC,GAGJ,OAFAC,QAAQC,IAAR,gCAAqCb,IACrCY,QAAQC,IAAIF,GACL,QAInB,IAAMH,EAAwD,CAC1DM,KAAMC,IACNC,SAAUC,I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wC,cAIhC,EAAsBb,mBAA8B,MAApD,mBAAOc,EAAP,KAAYC,EAAZ,KAEQC,EAAiBC,cAAjBD,aAYR,OAXAE,qBAAU,WACNF,EAAa1D,EAAEsD,GAAetD,EAAEsD,GAAe,CAC3ChD,SAAUC,IAASC,YACnB5B,OAAQ2E,MAEb,CAACA,EAAeD,EAAcI,EAAc1D,IAE/C4D,qBAAU,WACNP,IAAW9E,MAAK,SAACsF,GAAD,OAAOJ,EAAOI,QAC/B,CAACR,IAEQ,OAARG,EACO,cAACM,EAAA,EAAD,IAIP,sBAAK3F,GAAG,UAAR,UACI,6BAAK6B,EAAEsD,KACP,qBAAKxB,UAAU,WAAf,SACK0B,EAAIN,KAAI,SAAClC,GAAD,OACL,cAACkB,EAAD,CAEIlB,KAAMA,EACNmB,MAAO,GAFFnB,EAAKpB,KAAOoB,EAAKhD,QAAUgD,EAAKO","file":"static/js/7.9fd41b91.chunk.js","sourcesContent":["import { sanitizeId } from \"./Common\";\r\nimport { i18n } from \"../ddh-translations\";\r\nimport { fetchServerUrl } from \"../util\";\r\nimport { IconLocator, IconType } from \"../components/IconRenderer\";\r\nimport {\r\n faTasks,\r\n faInfoCircle,\r\n faBook,\r\n faFileAlt,\r\n faLink,\r\n faQuestion,\r\n faIndustry,\r\n faClipboardCheck,\r\n} from \"@fortawesome/free-solid-svg-icons\";\r\nimport { IconProp } from \"@fortawesome/fontawesome-svg-core\";\r\n\r\nexport function buildPageUrl(pageId: string): string {\r\n return `/page/${sanitizeId(pageId)}`;\r\n}\r\n\r\n/**\r\n * Defines the header data and content for a page in the system.\r\n */\r\nexport interface DDHPage {\r\n /** The unique content ID used to retrieve this page. */\r\n id: string;\r\n\r\n /** The title of the page. Should be displayed at the top of the page and in link text to this page. */\r\n title: string;\r\n\r\n /** The type of page. Used to style and group links to this page. */\r\n contentType: string;\r\n\r\n navbarText?: string | undefined;\r\n\r\n navbarIcon?: IconLocator | undefined;\r\n\r\n /** The content of the page in markdown. */\r\n contentMarkdown: string;\r\n\r\n keywords: string[];\r\n\r\n libraries: string[] | null;\r\n\r\n collapseSectionsByDefault: boolean;\r\n}\r\n\r\n/**\r\n * Retrieves the complete contents of the page by doing a GET request to the API and returning the\r\n * resulting JSON. Returns a promise that resolves when the request is complete.\r\n * @param id The unique page content ID to retrieve.\r\n */\r\nexport function getPage(id: string, locale: string): Promise<DDHPage | null> {\r\n var url = `/api/page/${sanitizeId(id)}?locale=${locale}`;\r\n return fetchServerUrl(url)\r\n .then((response) => response.json())\r\n .then((page) => transformIconLocatorStringId(page))\r\n .catch((reason) => {\r\n console.log(`Error retrieving page ${url}`);\r\n console.log(reason);\r\n return null;\r\n });\r\n}\r\n\r\nconst iconStringToIdConversions: { [id: string]: IconProp } = {\r\n link: faLink,\r\n question: faQuestion,\r\n industry: faIndustry,\r\n \"clipboard-check\": faClipboardCheck,\r\n};\r\n\r\nfunction transformIconLocatorStringId(page: DDHPage | null) {\r\n if (\r\n page &&\r\n page.navbarIcon &&\r\n typeof page.navbarIcon.iconId === \"string\" &&\r\n iconStringToIdConversions[page.navbarIcon.iconId]\r\n ) {\r\n page.navbarIcon.iconId =\r\n iconStringToIdConversions[page.navbarIcon.iconId];\r\n }\r\n return page;\r\n}\r\n\r\n/**\r\n * Converts a page content type ID into a friendly name to show the user.\r\n * @param contentType The ID of the content type.\r\n */\r\nexport function getSectionNameForContentType(contentType: string): string {\r\n const key = `ContentTypeSectionName_${contentType.toLowerCase()}`;\r\n if (i18n.exists(key)) {\r\n return i18n.t(key);\r\n } else {\r\n return i18n.t(`ContentTypeSectionName_(default)`);\r\n }\r\n}\r\n\r\nexport function getTooltipForContentType(contentType: string): string | null {\r\n const key = `ContentTypeTooltip_${contentType.toLowerCase()}`;\r\n if (i18n.exists(key)) {\r\n return i18n.t(key).toString();\r\n } else {\r\n return null;\r\n }\r\n}\r\n\r\nexport function getPageTitleForContentType(contentType: string): string {\r\n const key = `ContentTypePageTitle_${contentType.toLowerCase()}`;\r\n if (i18n.exists(key)) {\r\n return i18n.t(key);\r\n } else {\r\n return i18n.t(`ContentTypePageTitle_(default)`);\r\n }\r\n}\r\n\r\n/** Defines the order in which contentTypes should be displayed in results. Higher weights are displayed first. */\r\nexport function getContentTypeSectionIndex(contentType: string): number {\r\n switch (contentType.toLowerCase()) {\r\n case \"requirement\":\r\n return 1000;\r\n case \"citation\":\r\n return 999;\r\n case \"document\":\r\n return 998;\r\n default:\r\n return 0;\r\n }\r\n}\r\n\r\nexport function getIconForContentType(contentType: string) {\r\n switch (contentType) {\r\n case \"requirement\":\r\n return {\r\n iconType: IconType.FontAwesome,\r\n iconId: faTasks,\r\n };\r\n case \"guidance\":\r\n return {\r\n iconType: IconType.FontAwesome,\r\n iconId: faInfoCircle,\r\n };\r\n case \"document\":\r\n return {\r\n iconType: IconType.FontAwesome,\r\n iconId: faFileAlt,\r\n };\r\n case \"glossary\":\r\n return {\r\n iconType: IconType.FontAwesome,\r\n iconId: faBook,\r\n };\r\n default:\r\n return null;\r\n }\r\n}\r\n","/**\r\n * Strips all characters other than a-z, A-Z, 0-9, and dashes (-) from a string.\r\n * @param id The ID to be sanitized.\r\n */\r\nexport function sanitizeId(id: string) {\r\n return id.replace(/[^a-zA-Z0-9-]/g, \"-\");\r\n}\r\n","import React, { useState } from \"react\";\r\nimport { Row, Collapse } from \"reactstrap\";\r\n\r\nimport { getCollapseIcon } from \"../ddh-styles\";\r\nimport { buildPageUrl } from \"../datatypes/Pages\";\r\nimport {\r\n getGlobalExpandedState,\r\n setGlobalExpandedState,\r\n} from \"../datatypes/CollapsedState\";\r\nimport { ContentLink, isDocumentLink, isExternalLink } from \"./ContentLink\";\r\nimport { FontAwesomeIcon } from \"@fortawesome/react-fontawesome\";\r\nimport { faFileAlt } from \"@fortawesome/free-regular-svg-icons\";\r\nimport { DDHTOCNode } from \"../datatypes/TableOfContents\";\r\nimport { useTranslation } from \"react-i18next\";\r\n\r\ninterface TableOfContentsNodeProps {\r\n node: DDHTOCNode;\r\n level: number;\r\n}\r\n\r\nfunction Link(props: { node: DDHTOCNode }) {\r\n const { node } = props;\r\n const { pageId, url } = node;\r\n\r\n if (pageId || url) {\r\n var linkUrl = (pageId ? buildPageUrl(pageId) : url) || \"\";\r\n var newWindow = isDocumentLink(linkUrl) || isExternalLink(linkUrl);\r\n return (\r\n <ContentLink href={linkUrl} newWindow={newWindow}>\r\n {node.title}\r\n </ContentLink>\r\n );\r\n } else {\r\n return <>{node.title}</>;\r\n }\r\n}\r\n\r\nfunction Icon(props: {\r\n node: DDHTOCNode;\r\n isExpanded: boolean;\r\n clickFunc: (e: any) => void;\r\n}) {\r\n const { node, isExpanded, clickFunc } = props;\r\n const { t } = useTranslation();\r\n\r\n if (!node.children || node.children.length === 0) {\r\n return (\r\n <span className=\"icon toc-leaf\">\r\n <FontAwesomeIcon icon={faFileAlt} />\r\n </span>\r\n );\r\n } else {\r\n return (\r\n <span className=\"icon\">\r\n <a\r\n onClick={clickFunc}\r\n href=\"#collapse\"\r\n title={\r\n isExpanded ? t(\"CollapseSection\") : t(\"ExpandSection\")\r\n }\r\n >\r\n {getCollapseIcon(isExpanded)}\r\n </a>\r\n </span>\r\n );\r\n }\r\n}\r\n\r\nexport default function TableOfContentsNode(props: TableOfContentsNodeProps) {\r\n const { node, level } = props;\r\n const nodeKey = `${window.location.pathname}_${\r\n node.key || node.pageId || node.title\r\n }`;\r\n const globalExpandedState = getGlobalExpandedState(nodeKey);\r\n\r\n const [isExpanded, setIsExpanded] = useState<boolean>(\r\n globalExpandedState !== null ? globalExpandedState : false\r\n );\r\n\r\n const click = function (e: any) {\r\n e.preventDefault();\r\n setGlobalExpandedState(nodeKey, !isExpanded);\r\n setIsExpanded(!isExpanded);\r\n return false;\r\n };\r\n\r\n return (\r\n <>\r\n <Row className=\"toc-node\">\r\n <div className=\"col-icon\">\r\n <Icon\r\n node={node}\r\n isExpanded={isExpanded}\r\n clickFunc={click}\r\n />\r\n </div>\r\n <div className=\"col-item\">\r\n <Link node={node} />\r\n </div>\r\n </Row>\r\n <Collapse isOpen={isExpanded} className=\"treeview-indent\">\r\n {(node.children || []).map((n) => (\r\n <TableOfContentsNode\r\n key={n.key || n.pageId || n.title}\r\n node={n}\r\n level={level + 1}\r\n />\r\n ))}\r\n </Collapse>\r\n </>\r\n );\r\n}\r\n","import { IconDefinition } from \"@fortawesome/free-solid-svg-icons\";\r\nimport React, { useEffect, useState } from \"react\";\r\nimport { useTranslation } from \"react-i18next\";\r\nimport { useDDHPageContext } from \"../components/DDHPageContext\";\r\nimport { IconType } from \"../components/IconRenderer\";\r\nimport Loading from \"../components/Loading\";\r\nimport TableOfContentsNode from \"../components/TableOfContentsNode\";\r\nimport { DDHTOCNode } from \"../datatypes/TableOfContents\";\r\n\r\nexport interface TableOfContentsPageProps {\r\n loadFunc: () => Promise<DDHTOCNode[]>;\r\n pageTitleKey: string;\r\n pageTitleIcon: IconDefinition;\r\n}\r\n\r\nexport default function TableOfContentsPage(props: TableOfContentsPageProps) {\r\n // Set title\r\n const { t } = useTranslation();\r\n const { loadFunc, pageTitleKey, pageTitleIcon } = props;\r\n\r\n // Get state\r\n // const [key, setKey] = useState<string | null>(null);\r\n const [toc, setToc] = useState<DDHTOCNode[] | null>(null);\r\n\r\n const { setPageTitle } = useDDHPageContext();\r\n useEffect(() => {\r\n setPageTitle(t(pageTitleKey), t(pageTitleKey), {\r\n iconType: IconType.FontAwesome,\r\n iconId: pageTitleIcon,\r\n });\r\n }, [pageTitleIcon, pageTitleKey, setPageTitle, t]);\r\n\r\n useEffect(() => {\r\n loadFunc().then((x) => setToc(x));\r\n }, [loadFunc]);\r\n\r\n if (toc === null) {\r\n return <Loading />;\r\n }\r\n\r\n return (\r\n <div id=\"content\">\r\n <h1>{t(pageTitleKey)}</h1>\r\n <div className=\"treeview\">\r\n {toc.map((node) => (\r\n <TableOfContentsNode\r\n key={node.key || node.pageId || node.title}\r\n node={node}\r\n level={0}\r\n />\r\n ))}\r\n </div>\r\n </div>\r\n );\r\n}\r\n"],"sourceRoot":""}