{"version":3,"sources":["../../src/components/masthead.tsx"],"sourcesContent":["import {\n  ComponentProps,\n  FunctionComponent,\n  ReactNode,\n  MouseEvent,\n} from \"react\";\nimport {\n  Collapsible,\n  CollapsibleTrigger,\n  CollapsibleContent,\n} from \"@radix-ui/react-collapsible\";\nimport { ChevronDownIcon } from \"../icons/chevron-down\";\nimport { MalaysiaFlagIcon } from \"../icons/malaysia-flag\";\nimport { clx } from \"../utils\";\nimport { Slot } from \"@radix-ui/react-slot\";\n\nconst Masthead: FunctionComponent<ComponentProps<\"div\">> = ({\n  children,\n  className,\n  ...props\n}) => {\n  // useEffect(() => {\n  //   const handleKeyDown = (event: KeyboardEvent) => {\n  //     const details = document.getElementById(\n  //       \"masthead\",\n  //     ) as HTMLDetailsElement | null;\n\n  //     if (\n  //       event.altKey &&\n  //       (event.metaKey || event.ctrlKey) &&\n  //       event.key === \"Enter\"\n  //     ) {\n  //       event.preventDefault();\n  //       if (details) {\n  //         details.open = !details.open;\n  //       }\n  //     }\n\n  //     if ((event.metaKey || event.ctrlKey) && event.key === \"k\") {\n  //       event.preventDefault();\n  //     }\n  //   };\n\n  //   document.addEventListener(\"keydown\", handleKeyDown);\n  //   return () => document.removeEventListener(\"keydown\", handleKeyDown);\n  // }, []);\n\n  return (\n    <Collapsible>\n      <div\n        id=\"masthead\"\n        className={clx(\"bg-bg-washed print:hidden\", className)}\n        data-nosnippet\n        {...props}\n      >\n        <div className=\"mx-auto grid w-full max-w-screen-xl outline-none transition-[grid-template-rows] duration-500 print:hidden\">\n          {children}\n        </div>\n      </div>\n    </Collapsible>\n  );\n};\n\nMasthead.displayName = \"Masthead\";\n\nconst MastheadHeader: FunctionComponent<ComponentProps<\"div\">> = ({\n  children,\n  ...props\n}) => {\n  return (\n    <div\n      className=\"px-4.5 flex items-center gap-2 overflow-x-hidden py-2 outline-none sm:py-1 md:px-6\"\n      {...props}\n    >\n      <MalaysiaFlagIcon className=\"inline-block aspect-auto w-fit shrink-0\" />\n      <div className=\"text-txt-black-700 text-body-sm flex w-full items-center justify-between truncate sm:justify-start\">\n        {children}\n      </div>\n    </div>\n  );\n};\n\nMastheadHeader.displayName = \"MastheadHeader\";\n\nconst MastheadTitle: FunctionComponent<ComponentProps<\"p\">> = ({\n  className,\n  ...props\n}) => {\n  return (\n    <p\n      className={clx(\n        \"text-txt-black-700 text-body-sm truncate sm:max-w-full sm:flex-grow-0\",\n        className,\n      )}\n      {...props}\n    />\n  );\n};\n\nMastheadTitle.displayName = \"MastheadTitle\";\n\nconst MastheadTrigger: FunctionComponent<ComponentProps<\"button\">> = ({\n  children,\n  onClick,\n  ...props\n}) => {\n  const handleToggle = (event: MouseEvent<HTMLButtonElement>) => {\n    if (onClick) onClick(event);\n  };\n\n  return (\n    <CollapsibleTrigger\n      className=\"text-txt-primary focus:ring-fr-primary bg-otl-gray-200 group flex items-center gap-0.5 rounded-md p-1 px-1 focus:outline-none focus:ring focus:ring-inset sm:bg-transparent sm:pl-1.5 xl:rounded-sm\"\n      aria-label=\"Toggle masthead\"\n      tabIndex={0}\n      onClick={handleToggle}\n      {...props}\n    >\n      <span className=\"text-txt-primary hidden select-none tracking-[-0.01em] sm:block\">\n        {children}\n      </span>\n      <ChevronDownIcon className=\"size-4 transform transition-transform group-data-[state=closed]:rotate-0 group-data-[state=open]:rotate-180\" />\n    </CollapsibleTrigger>\n  );\n};\n\nMastheadTrigger.displayName = \"MastheadTrigger\";\n\nconst MastheadContent: FunctionComponent<\n  ComponentProps<typeof CollapsibleContent>\n> = ({ children, className, ...props }) => {\n  return (\n    <CollapsibleContent\n      className={clx(\n        \"data-[state=open]:animate-collapsible-slide-down data-[state=closed]:animate-collapsible-slide-up overflow-hidden\",\n        \"motion-reduce:animate-none\",\n        className,\n      )}\n      {...props}\n    >\n      <div className=\"px-4.5 gap-4.5 flex flex-col pb-6 pt-3 sm:grid-cols-2 sm:flex-row sm:pb-8 sm:pt-6 md:px-6\">\n        {children}\n      </div>\n    </CollapsibleContent>\n  );\n};\n\nMastheadContent.displayName = \"MastheadContent\";\n\ninterface MastheadSectionProps extends ComponentProps<\"div\"> {\n  icon: ReactNode;\n  title: string;\n}\n\nconst MastheadSection: FunctionComponent<MastheadSectionProps> = ({\n  icon,\n  children,\n  title,\n  className,\n  ...props\n}) => {\n  return (\n    <div className={clx(\"flex w-full gap-3\", className)} {...props}>\n      <Slot className=\"text-txt-black-500 size-6 shrink-0\">{icon}</Slot>\n      <div className=\"space-y-1.5\">\n        <p className=\"text-txt-black-900 text-body-sm sm:text-body-md font-medium\">\n          {title}\n        </p>\n        <p className=\"text-txt-black-700 text-body-sm max-w-[50ch] text-balance\">\n          {children}\n        </p>\n      </div>\n    </div>\n  );\n};\n\nMastheadSection.displayName = \"MastheadSection\";\n\n// Exports\nexport {\n  Masthead,\n  MastheadHeader,\n  MastheadTitle,\n  MastheadTrigger,\n  MastheadContent,\n  MastheadSection,\n};\n"],"mappings":"sLAMA,OACE,eAAAA,EACA,sBAAAC,EACA,sBAAAC,MACK,8BAIP,OAAS,QAAAC,MAAY,uBAyCb,cAAAC,EAeJ,QAAAC,MAfI,oBAvCR,IAAMC,EAAsDC,GAItD,CAJsD,IAAAC,EAAAD,EAC1D,UAAAE,EACA,UAAAC,CAlBF,EAgB4DF,EAGvDG,EAAAC,EAHuDJ,EAGvD,CAFH,WACA,cA6BA,OACEJ,EAACS,EAAA,CACC,SAAAT,EAAC,MAAAU,EAAAC,EAAA,CACC,GAAG,WACH,UAAWC,EAAI,4BAA6BN,CAAS,EACrD,iBAAc,IACVC,GAJL,CAMC,SAAAP,EAAC,OAAI,UAAU,6GACZ,SAAAK,EACH,GACF,EACF,CAEJ,EAEAH,EAAS,YAAc,WAEvB,IAAMW,EAA4DV,GAG5D,CAH4D,IAAAC,EAAAD,EAChE,UAAAE,CAlEF,EAiEkED,EAE7DG,EAAAC,EAF6DJ,EAE7D,CADH,aAGA,OACEH,EAAC,MAAAS,EAAAC,EAAA,CACC,UAAU,sFACNJ,GAFL,CAIC,UAAAP,EA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ACEH,EAAC,MAAAS,EAAAC,EAAA,CAAI,UAAWC,EAAI,oBAAqBN,CAAS,GAAOC,GAAxD,CACC,UAAAP,EAAC0B,EAAA,CAAK,UAAU,qCAAsC,SAAAF,EAAK,EAC3DvB,EAAC,OAAI,UAAU,cACb,UAAAD,EAAC,KAAE,UAAU,8DACV,SAAAyB,EACH,EACAzB,EAAC,KAAE,UAAU,4DACV,SAAAK,EACH,GACF,IACF,CAEJ,EAEAkB,EAAgB,YAAc","names":["Collapsible","CollapsibleTrigger","CollapsibleContent","Slot","jsx","jsxs","Masthead","_a","_b","children","className","props","__objRest","Collapsible","__spreadProps","__spreadValues","clx","MastheadHeader","MalaysiaFlagIcon","MastheadTitle","MastheadTrigger","onClick","CollapsibleTrigger","event","ChevronDownIcon","MastheadContent","CollapsibleContent","MastheadSection","icon","title","Slot"]}