{"version":3,"file":"photos.cjs","sources":["../src/photos.ts"],"sourcesContent":["import { useContext, useEffect, createContext, ReactNode } from \"react\";\nimport h from \"@macrostrat/hyper\";\n// Default value for computePhotoPath\nconst passThrough = (src) => src;\n\ninterface PhotoLibraryCtx {\n  photos: PhotoData[] | null;\n  computePhotoPath: (src: string) => string;\n}\n\nexport const PhotoLibraryContext = createContext<PhotoLibraryCtx>({\n  photos: null,\n  computePhotoPath: passThrough,\n});\n\ninterface PhotoData {\n  id: number;\n  src: string;\n  caption?: string;\n}\n\ninterface PhotoLibraryProviderProps extends PhotoLibraryCtx {\n  children: ReactNode;\n}\n\nexport function PhotoLibraryProvider(props: PhotoLibraryProviderProps) {\n  const { children, computePhotoPath = passThrough, photos } = props;\n  return h(PhotoLibraryContext.Provider, {\n    value: {\n      photos,\n      computePhotoPath,\n    },\n    children,\n  });\n}\n\nexport function PhotoOverlay(props) {\n  const { photos, computePhotoPath } = useContext(PhotoLibraryContext);\n  if (photos == null) {\n    return null;\n  }\n  const { photoIDs, ...rest } = props;\n\n  const displayedPhotos = photoIDs.map((id) => {\n    return photos.find((d) => d.id === id);\n  });\n\n  const getPaths = function (d) {\n    const src = computePhotoPath(d);\n    return { src, caption: d.note };\n  };\n\n  const images = displayedPhotos.filter((d) => d != null).map(getPaths);\n\n  return h(PhotoGallery, {\n    images,\n    ...rest,\n  });\n}\n\nconst PhotoGallery = function ({ images, isOpen = false, onClose }) {\n  /** The photo gallery component  has been removed due to an outdated design.\n   * Please use another library for this functionality.\n   */\n  useEffect(() => {\n    console.error(\n      \"PhotoOverlay from @macrostrat/column-components has been disabled due to an outdated design. Please use another library for this functionality.\",\n    );\n  }, []);\n  return null;\n};\n"],"names":["createContext","h","useContext","useEffect"],"mappings":";;;;;;AAGA,MAAM,cAAc,CAAC,QAAQ;AAOtB,MAAM,sBAAsBA,MAAAA,cAA+B;AAAA,EAChE,QAAQ;AAAA,EACR,kBAAkB;AACpB,CAAC;AAYM,SAAS,qBAAqB,OAAkC;AACrE,QAAM,EAAE,UAAU,mBAAmB,aAAa,WAAW;AAC7D,SAAOC,WAAAA,QAAE,oBAAoB,UAAU;AAAA,IACrC,OAAO;AAAA,MACL;AAAA,MACA;AAAA,IAAA;AAAA,IAEF;AAAA,EAAA,CACD;AACH;AAEO,SAAS,aAAa,OAAO;AAClC,QAAM,EAAE,QAAQ,qBAAqBC,MAAAA,WAAW,mBAAmB;AACnE,MAAI,UAAU,MAAM;AAClB,WAAO;AAAA,EACT;AACA,QAAM,EAAE,UAAU,GAAG,KAAA,IAAS;AAE9B,QAAM,kBAAkB,SAAS,IAAI,CAAC,OAAO;AAC3C,WAAO,OAAO,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE;AAAA,EACvC,CAAC;AAED,QAAM,WAAW,SAAU,GAAG;AAC5B,UAAM,MAAM,iBAAiB,CAAC;AAC9B,WAAO,EAAE,KAAK,SAAS,EAAE,KAAA;AAAA,EAC3B;AAEA,QAAM,SAAS,gBAAgB,OAAO,CAAC,MAAM,KAAK,IAAI,EAAE,IAAI,QAAQ;AAEpE,SAAOD,WAAAA,QAAE,cAAc;AAAA,IACrB;AAAA,IACA,GAAG;AAAA,EAAA,CACJ;AACH;AAEA,MAAM,eAAe,SAAU,EAAE,QAAQ,SAAS,OAAO,WAAW;AAIlEE,QAAAA,UAAU,MAAM;AACd,YAAQ;AAAA,MACN;AAAA,IAAA;AAAA,EAEJ,GAAG,CAAA,CAAE;AACL,SAAO;AACT;;;;"}