# Maintainer: dev-aly3n <dev.aly3n@gmail.com>
pkgname=aipager
pkgver=0.7.11
pkgrel=1
pkgdesc="Telegram remote-control daemon for Claude Code CLI sessions"
arch=('any')
url="https://aipager.run"
license=('MIT')
depends=(
  'python>=3.10'
  'python-telegram-bot>=20'
  'python-rich'
  'python-questionary'
  # Mini App server. Mandatory since aiohttp moved into the project's
  # base dependencies — this list is hand-maintained and does NOT track
  # pyproject.toml, so anything added there has to be added here too or
  # Arch users get an aipager whose Mini App silently cannot start.
  'python-aiohttp'
  # Base dependencies too: PyYAML reads aipager.yaml (nothing else pulls
  # it in), httpx is the rich-message client (python-telegram-bot happens
  # to pull it transitively today; listed so that stays true on purpose).
  'python-yaml'
  'python-httpx'
  'dtach'
)
makedepends=(
  'python-build'
  'python-installer'
  'python-hatchling'
  'python-wheel'
)
optdepends=(
  'claude-code: required at runtime; install separately via npm'
  'faster-whisper: optional voice input transcription'
)
source=("https://files.pythonhosted.org/packages/source/${pkgname:0:1}/${pkgname}/${pkgname}-${pkgver}.tar.gz")
sha256sums=('4657e97369f0e0a10eb5a730b73071235cbefd59efa89835f7f2ebdef55f04b5')

build() {
  cd "${pkgname}-${pkgver}"
  # System dtach replaces the bundled dtach-bin wheel — strip it
  # from the dependency list before building, same as the brew
  # formula and Nix flake do.
  sed -i '/dtach-bin/d' pyproject.toml
  python -m build --wheel --no-isolation
}

package() {
  cd "${pkgname}-${pkgver}"
  python -m installer --destdir="${pkgdir}" dist/*.whl
  # MIT is an "uncommon" identifier for namcap: ship the text.
  install -Dm644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}
