{"version":3,"file":"components/Alerts/compile.mjs","sources":["../../../src/components/Alerts/compile.tsx"],"sourcesContent":["import React, { useEffect } from 'react';\nimport { Rule, SDK } from '@rsdoctor/types';\nimport {\n  hasViewModeFromStorage,\n  useCompileAlertsByErrors,\n  useViewMode,\n} from '../../utils';\nimport { BundleAlert } from './bundle-alert';\nimport { withServerAPI } from '../Manifest';\nimport { ViewMode } from '../../constants';\nimport { PackageRelationReasonsWithServer } from '../Alert/package-relation';\n\ninterface CompileAlertsProps {\n  filter?(alert: Rule.RuleStoreDataItem): boolean;\n  project: SDK.ServerAPI.InferResponseType<SDK.ServerAPI.API.GetProjectInfo>;\n}\n\nconst CompileAlertsBase: React.FC<CompileAlertsProps> = ({\n  filter,\n  project,\n}) => {\n  const { root: cwd, errors } = project;\n  const compileAlerts = useCompileAlertsByErrors(errors);\n  const { setCompileAlertsViewMode, viewMode, setViewMode } = useViewMode();\n\n  const dataSource = filter ? compileAlerts.filter(filter) : compileAlerts;\n\n  useEffect(() => {\n    if (!hasViewModeFromStorage()) {\n      setViewMode(\n        {\n          compileAlerts:\n            compileAlerts.length >= 5 ? ViewMode.Group : ViewMode.List,\n        },\n        false,\n      );\n    }\n  }, []);\n\n  return (\n    <BundleAlert\n      title=\"Compile Alerts\"\n      dataSource={dataSource}\n      extraData={{\n        cwd,\n        getPackageRelationContentComponent: (res) => (\n          <PackageRelationReasonsWithServer\n            body={{ id: res.data.id, target: res.package.target }}\n            cwd={cwd}\n          />\n        ),\n      }}\n      viewMode={viewMode.compileAlerts}\n      setViewMode={setCompileAlertsViewMode}\n      cwd={cwd}\n    />\n  );\n};\n\nexport const CompileAlerts = withServerAPI({\n  api: SDK.ServerAPI.API.GetProjectInfo,\n  responsePropName: 'project',\n  Component: CompileAlertsBase,\n});\n"],"names":["CompileAlertsBase","filter","project","cwd","errors","compileAlerts","useCompileAlertsByErrors","setCompileAlertsViewMode","viewMode","setViewMode","useViewMode","dataSource","useEffect","hasViewModeFromStorage","ViewMode","BundleAlert","res","PackageRelationReasonsWithServer","CompileAlerts","withServerAPI","SDK"],"mappings":";;;;;;;;AAiBA,MAAMA,oBAAkD,CAAC,EACvDC,MAAM,EACNC,OAAO,EACR;IACC,MAAM,EAAE,MAAMC,GAAG,EAAEC,MAAM,EAAE,GAAGF;IAC9B,MAAMG,gBAAgBC,yBAAyBF;IAC/C,MAAM,EAAEG,wBAAwB,EAAEC,QAAQ,EAAEC,WAAW,EAAE,GAAGC;IAE5D,MAAMC,aAAaV,SAASI,cAAc,MAAM,CAACJ,UAAUI;IAE3DO,UAAU;QACR,IAAI,CAACC,0BACHJ,YACE;YACE,eACEJ,cAAc,MAAM,IAAI,IAAIS,SAAS,KAAK,GAAGA,SAAS,IAAI;QAC9D,GACA;IAGN,GAAG,EAAE;IAEL,OAAO,WAAP,GACE,IAACC,aAAWA;QACV,OAAM;QACN,YAAYJ;QACZ,WAAW;YACTR;YACA,oCAAoC,CAACa,MAAAA,WAAAA,GACnC,IAACC,kCAAgCA;oBAC/B,MAAM;wBAAE,IAAID,IAAI,IAAI,CAAC,EAAE;wBAAE,QAAQA,IAAI,OAAO,CAAC,MAAM;oBAAC;oBACpD,KAAKb;;QAGX;QACA,UAAUK,SAAS,aAAa;QAChC,aAAaD;QACb,KAAKJ;;AAGX;AAEO,MAAMe,gBAAgBC,cAAc;IACzC,KAAKC,IAAI,SAAS,CAAC,GAAG,CAAC,cAAc;IACrC,kBAAkB;IAClB,WAAWpB;AACb"}