import { a as m } from "./token-estimator-B45EKs9J.js";
import { a as c } from "./logger-CTb8_yz9.js";
const u = 2e5;
function p(e, n, r, s = u) {
  const o = new m().estimateTokens(n, r), i = o / s * 100, a = e + i;
  return c.debug(
    `[ContextProjection] Current: ${e}%, New content: ${o} tokens (${i.toFixed(1)}%), Projected: ${a.toFixed(1)}%`
  ), a;
}
function g(e) {
  return e >= 95 ? {
    type: "truncate",
    reason: "critical_overflow",
    projectedUsage: e
  } : e >= 80 ? {
    type: "summarize",
    reason: "high_usage",
    projectedUsage: e
  } : { type: "proceed", reason: "usage_ok" };
}
function d(e) {
  const n = e.indexOf(",");
  if (n !== -1)
    return e.slice(n + 1);
}
function x(e) {
  let n = "";
  const r = [], s = [];
  for (const t of e)
    if (["text", "mention"].includes(t.type) && t.text && (n += t.text), t.type === "imageUrl" && t.imageUrl && r.push(t.imageUrl.url), t.type === "documentUrl" && t.documentUrl) {
      const o = d(t.documentUrl.url);
      o && s.push({
        data: o,
        name: t.documentUrl.name,
        mimeType: t.documentUrl.mimeType
      });
    }
  return { entireMessage: n, imageBase64Urls: r, documentAttachments: s };
}
export {
  g as d,
  p as e,
  x as p
};
//# sourceMappingURL=message-parts-D8WKxpG9.js.map
