/**
 * What PIG says about Piggy, written once.
 *
 * The same four sentences existed three times — in the dock's starters, in the
 * workspace's starters and in the workspace title bar — and had already drifted
 * apart in the way duplicated copy always does. The dock's version never
 * mentioned that Piggy can write, which is the product's headline capability,
 * missing from the surface most people keep open all day. The workspace's
 * version had picked up release-note voice: "and now, act on the answer",
 * "Running on Prime Agent", "in this build". None of those sentences is about
 * the reader's business.
 *
 * So: one module, PIG's voice — plain, specific, and about consequence. It says
 * what Piggy reads, what it can change, and what stands between a proposal and
 * the book. It does not name the harness, the model or the release.
 *
 * Every line comes in two lengths because the same sentence has to work in a
 * 22rem dock and on a full page. `short` is not a truncation of `long`: it is
 * the same claim with the qualifications the narrow surface has no room to
 * carry, and it must survive alone. Where a fact cannot be dropped — that a
 * change waits for a person — it is in both.
 */

/** One sentence at two widths. Both are complete; neither is a summary. */
export interface PiggyLine {
  /** A full page, a sheet, anything wider than about 40rem. */
  long: string;
  /** The 22rem dock, the mobile drawer, a two-line header. */
  short: string;
}

/**
 * Pick the length for the surface.
 *
 * A boolean rather than a width: the caller already knows whether it is narrow
 * — the dock passes `compact`, the workspace passes `narrow` — and a component
 * measuring itself to choose a sentence is a component that reflows text on
 * resize.
 */
export function piggyLine(line: PiggyLine, narrow = false): string {
  return narrow ? line.short : line.long;
}

export const piggyCopy = {
  /**
   * The first sentence anyone reads. It names the subject (the book), the
   * capability (change), and the condition (your approval) in that order,
   * because a reader who stops after six words should still have learned the
   * thing the old dock never told them.
   */
  headline: {
    long: 'Ask anything about the book. Piggy can change it, with your approval.',
    short: 'Ask anything. Piggy can change it, with your approval.',
  },

  /**
   * What the answers rest on. The boundary is stated as a list of absences
   * because "scoped tools" alone is a claim, and the three things Piggy has no
   * access to are what make it a checkable one.
   */
  capability: {
    long:
      'Piggy reads your PIG records through scoped tools — no shell, no filesystem, ' +
      'no browser — and every answer carries the rows it read.',
    short: 'Piggy reads your PIG records through scoped tools, and shows the rows it read.',
  },

  /**
   * What stands between a proposal and the book. This is the sentence the
   * safety argument rests on, so the short form keeps the whole mechanism and
   * drops only the detail of what the card contains.
   */
  safety: {
    long:
      'A change arrives as a card naming the record and every field it would alter. ' +
      'Nothing reaches the book until you press Apply.',
    short: 'A change waits on a card. Nothing reaches the book until you press Apply.',
  },

  /** The thread title bar's second line, for a conversation already filed. */
  threadSaved: {
    long: 'Answered from your PIG records, and nothing else.',
    short: 'From your PIG records only.',
  },

  /** The same line before the first question has named the thread. */
  threadNew: {
    long: 'New conversation. It is filed under your history as soon as you ask.',
    short: 'Filed under your history as soon as you ask.',
  },

  /** Heading over the openers that only read. */
  readGroupTitle: {
    long: 'Look something up',
    short: 'Look something up',
  },

  /** The note under those openers. */
  readGroupNote: {
    long: 'Answered from your records, with the rows it read attached.',
    short: 'Answered from your records.',
  },

  /** Heading over the openers that end in a change. */
  writeGroupTitle: {
    long: 'Get something done',
    short: 'Get something done',
  },

  /**
   * The note under the write openers, in the three situations that change what
   * is true rather than only how it is worded.
   *
   * `readOnly` describes an escalation the user is about to perform, so it says
   * so before the press rather than after: pressing a write opener in Read only
   * moves the thread to Ask first, and a permission that changes silently is
   * the one thing this product must never do.
   */
  writeGroupNote: {
    askFirst: {
      long:
        'Piggy shows you exactly what it would write, and asks which record if your ' +
        'line does not say.',
      short: 'Piggy shows what it would write before anything lands.',
    },
    readOnly: {
      long:
        'These switch Piggy to Ask first: it proposes the change, you press Apply. ' +
        'It asks which record if your line does not say.',
      short: 'These switch Piggy to Ask first. It proposes, you press Apply.',
    },
    noAccess: {
      long: 'Your access does not allow changing records, so Piggy can only read here.',
      short: 'Your access is read-only, so Piggy can only read.',
    },
  },

  /** What the composer invites. One placeholder for every Piggy surface. */
  composerPlaceholder: {
    long: 'Ask about capacity, margin, paper or next actions…',
    short: 'Ask about capacity, margin or paper…',
  },

  /**
   * The empty run ledger. Says what would fill it, not that it is empty — a
   * panel that only reports its own emptiness has told the reader nothing they
   * could not see.
   */
  activityEmpty: {
    long:
      'Nothing has run yet. Ask Piggy a question and the turn appears here with its ' +
      'model, its cost and every tool it called.',
    short: 'Nothing has run yet. Ask Piggy something and the turn appears here.',
  },
} satisfies Record<string, PiggyLine | Record<string, PiggyLine>>;

/** The one name for the control that opens the agent, wherever it appears. */
export const PIGGY_ASK_LABEL = 'Ask Piggy';
