import { adjustOpenCounter } from "./issue-counters";
import { waitUntil } from "cloudflare:workers";
import { first } from "./db";
import { repoDb, stmt } from "./scoped-db";
import { issueRepoId } from "./issue-scope";
import { addIssueEvent } from "./pulls";
import { dropPullRefsForIssue } from "./git/pull-bridge";
import { loadRepoById } from "./repos";
import { emitWebhook, publicUrl } from "./events/emit";
import { placeholders } from "./db";
import type { RepoRow } from "~/lib/types";
import { issuesChanged } from "./repo-state";
const MAX_CLOSING_REFERENCES = 10;
const CLOSING_KEYWORDS = /\b(?:close[sd]?|fix(?:e[sd])?|resolve[sd]?)\s+#(\d+)\b/gi;
export type IssueRow = {
id: string;
repo_id: string;
number: number;
author_id: string;
title: string;
body: string;
state: "open" | "closed";
is_pull: number;
comments_count: number;
locked: number;
closed_at: number | null;
closed_by: string | null;
milestone_id: string | null;
type_id: string | null;
parent_id: string | null;
created_at: number;
updated_at: number;
hidden_at?: number | null;
};
/**
* Hidden issues are left out unless `includeHidden`, which only read paths for site admins pass; every write path
* keeps the default so nothing hidden becomes writable.