/**
 * Search help — part of the app, rendered as HTML.
 *
 * Help for a real app feature (as opposed to the JSONC config-file editors)
 * ships *inside the client*, not as a `.md` in the docs/ deploy set. The
 * `docs/*.md` files exist only as a stand-in for proper settings UI; feature
 * help like this is application content and must render as HTML.
 *
 * This module is dynamically imported the first time the search `?` button is
 * pressed, so the markup stays out of the cold-start bundle path.
 */

export const SEARCH_HELP_HTML = `
<p>Search runs in one of three modes depending on the scope you pick. The mode
decides which operators work.</p>
<ul>
  <li><strong>All folders</strong> (default) — searches the <em>local cache</em> with SQLite FTS5.</li>
  <li><strong>This folder</strong> — instant client-side filter on the visible rows; full FTS5 search on Enter.</li>
  <li><strong>Server</strong> (checkbox) — sends the query to the mail server (IMAP SEARCH; not yet wired for Gmail accounts).</li>
</ul>

<h3>Qualifiers — work in every mode</h3>
<table>
  <tr><th>Form</th><th>Effect</th></tr>
  <tr><td><code>from:bob</code></td><td>Sender (name or address) contains</td></tr>
  <tr><td><code>to:eleanor</code></td><td>Recipient contains — matches <strong>To <em>or</em> Cc</strong> (anyone the message was addressed to)</td></tr>
  <tr><td><code>cc:dana</code></td><td>Cc only — when you want to exclude the main To line</td></tr>
  <tr><td><code>subject:lunch</code></td><td>Subject contains</td></tr>
  <tr><td><code>date:2026-05-01</code></td><td>On that date — also <code>date:&gt;1w</code>, <code>date:&lt;=2026-01-15</code></td></tr>
  <tr><td><code>after:1w</code> / <code>before:1m</code></td><td>Newer / older than — <code>d</code>, <code>w</code>, <code>m</code>, <code>y</code>, a date, <code>today</code>, <code>yesterday</code></td></tr>
  <tr><td><code>has:attachment</code></td><td>Only messages that carry a file attachment</td></tr>
  <tr><td><code>is:unread</code></td><td>Also <code>is:flagged</code>, <code>is:read</code>, <code>is:answered</code>, <code>is:draft</code></td></tr>
  <tr><td><code>folder:sent</code></td><td>Restrict to folders whose name contains the term</td></tr>
  <tr><td><code>/regex/</code></td><td>Client-side regex over the currently-visible rows. Local only — never sent to the server.</td></tr>
</table>
<p>Any remaining unqualified text is the free-text term.</p>

<h3>Local search (FTS5) — default</h3>
<p>Full-text index over envelopes plus locally-cached bodies. Fast and indexed.</p>
<table>
  <tr><th>Operator</th><th>Example</th><th>Meaning</th></tr>
  <tr><td>implicit AND</td><td><code>bob lunch</code></td><td>Both terms must appear</td></tr>
  <tr><td><code>OR</code></td><td><code>bob OR eleanor</code></td><td>Either term</td></tr>
  <tr><td><code>NOT</code></td><td><code>bob NOT spam</code></td><td>First without the second</td></tr>
  <tr><td><code>"phrase"</code></td><td><code>"happy birthday"</code></td><td>Exact phrase</td></tr>
  <tr><td><code>term*</code></td><td><code>lunch*</code></td><td>Prefix</td></tr>
  <tr><td><code>NEAR(a b, 5)</code></td><td><code>NEAR(bob lunch, 5)</code></td><td>Both within 5 tokens</td></tr>
</table>
<p>Indexed: subject, from, to, cc, a body snippet, and the full body <em>if</em> it
has been downloaded locally (the blue dot in the list). Bodies not yet
prefetched aren't searchable until they are.</p>

<h3>This-folder filter</h3>
<p>With scope set to <strong>This folder</strong>, typing filters the rendered rows
instantly — no server hit, no FTS5, just substring match. Press <kbd>Enter</kbd>
to escalate to a full FTS5 search of the folder.</p>

<h3>Server search</h3>
<p>Tick <strong>Server</strong> and the query goes to the mail server. On Dovecot
(IMAP SEARCH) your <code>from:</code> / <code>to:</code> / <code>subject:</code>
qualifiers map to IMAP keys; remaining text becomes a body search. IMAP has no
literal <code>AND</code> keyword — keys are implicitly ANDed. Server search on
Gmail accounts is not yet wired and currently returns local results only.</p>

<h3>Case sensitivity</h3>
<p>All three modes — local FTS5, IMAP server SEARCH, and <code>/regex/</code> —
are <strong>case-insensitive</strong>. <code>Lunch</code>, <code>lunch</code>, and
<code>LUNCH</code> match the same messages. There is no case-sensitive mode.</p>

<h3>Limitations</h3>
<ul>
  <li>No regex on the server side, any provider — <code>/pattern/</code> only filters visible local rows.</li>
  <li>Server search results are stored locally (envelope-only) on first hit, so a server search also backfills those envelopes.</li>
  <li>Body search on bodies you haven't prefetched only works server-side; the local index can't search what isn't downloaded.</li>
</ul>
`;
