// SubprocessorsContent.jsx: the third parties that process data for Skardi
// Cloud and skardi.ai. Every row is checked against skardi-cloud's prod
// config (deploy/gitops/envs/prod) as of the date below:
//   - AWS us-east-1: deploy/aws/terraform (EKS, EBS, KMS, Secrets Manager);
//   - Azure AI Foundry: catalog.llm in skardi-platform.yaml (DeepSeek-V4-Flash,
//     resource in westus3), used by catalog.digest, the daily brief;
//   - Brevo: SMTP relay for sign-in links, resets and invitations;
//   - Google: the OIDC sign-in adapter;
//   - website: Azure Static Web App skardi-homepage and its storage, East US 2.
// Postgres, MinIO, Vault, SpiceDB, OpenMeter, Open Connector and the
// monitoring stack are self-hosted inside the AWS account, so they are not
// listed. Stripe is built but billing.mode is "off"; add it here before it
// is turned on, as the page promises.
const SUBPROCESSORS_UPDATED = 'October 13, 2026';

const PRODUCT_SUBPROCESSORS = [
  {
    name: 'Amazon Web Services, Inc.',
    purpose: 'Hosts Skardi Cloud: the console, the APIs, each workspace\'s runtime, indexed content, encrypted credentials and backups.',
    data: 'All Customer Data and account data',
    location: 'United States (US East, N. Virginia)',
  },
  {
    name: 'Microsoft Corporation (Azure AI Foundry)',
    purpose: 'Runs the language model (DeepSeek, hosted by Microsoft) that writes the daily brief. Not used to index or search your sources.',
    data: 'Query patterns with literal values removed, table and column names, error summaries, and the intent text agents attach to their queries',
    location: 'United States (West US 3)',
  },
  {
    name: 'Sendinblue SAS (Brevo)',
    purpose: 'Delivers account email: sign-in links, password resets and workspace invitations.',
    data: 'Recipient email address and the content of those emails',
    location: 'European Union',
  },
  {
    name: 'Google LLC',
    purpose: 'Sign in with Google.',
    data: 'Name, email address and Google account identifier',
    location: 'United States',
  },
];

const WEBSITE_SUBPROCESSORS = [
  {
    name: 'Microsoft Corporation (Azure)',
    purpose: 'Hosts skardi.ai, stores demo-request submissions and emails us a notice of each one.',
    data: 'What you type into the demo-request form; standard server logs',
    location: 'United States (East US 2)',
  },
  {
    name: 'PostHog, Inc.',
    purpose: 'Website analytics, only after you accept analytics cookies. Not used in the console.',
    data: 'Page views, clicks and device details described in the Privacy Policy',
    location: 'United States',
  },
];

const SubprocessorTable = ({ rows }) => {
  const th = {
    padding: '10px 14px', textAlign: 'left', fontSize: 12, fontWeight: 600, color: '#3a5578',
    background: '#f2f6fb', borderBottom: '1px solid rgba(30,58,100,0.12)', whiteSpace: 'nowrap',
  };
  const td = {
    padding: '12px 14px', textAlign: 'left', verticalAlign: 'top', fontSize: 14, lineHeight: 1.55,
    color: '#3a5578', borderBottom: '1px solid rgba(30,58,100,0.08)',
  };
  return (
    <div style={{ overflowX: 'auto', margin: '0 0 20px', borderRadius: 12, border: '1px solid rgba(30,58,100,0.14)' }}>
      <table style={{ width: '100%', borderCollapse: 'collapse', minWidth: 640 }}>
        <thead>
          <tr><th style={th}>Subprocessor</th><th style={th}>What it does</th><th style={th}>Data</th><th style={th}>Location</th></tr>
        </thead>
        <tbody>
          {rows.map((r, i) => {
            const last = i === rows.length - 1 ? { borderBottom: 'none' } : {};
            return (
              <tr key={r.name}>
                <td style={{ ...td, ...last, color: '#0a1220', fontWeight: 600, minWidth: 150 }}>{r.name}</td>
                <td style={{ ...td, ...last }}>{r.purpose}</td>
                <td style={{ ...td, ...last }}>{r.data}</td>
                <td style={{ ...td, ...last, minWidth: 120 }}>{r.location}</td>
              </tr>
            );
          })}
        </tbody>
      </table>
    </div>
  );
};

const SUBPROCESSOR_SECTIONS = [
  {
    id: 'product', title: 'Skardi Cloud',
    body: <>
      <LP>These process Customer Data or account data to run Skardi Cloud.</LP>
      <SubprocessorTable rows={PRODUCT_SUBPROCESSORS} />
      <LP>The databases, search indexes, secrets vault, permission service and monitoring that Skardi Cloud uses run on our own infrastructure inside our AWS account. They are not operated by another company, so they are not listed separately.</LP>
    </>,
  },
  {
    id: 'website', title: 'skardi.ai website',
    body: <>
      <LP>These process information from visitors to this website. They have no access to Skardi Cloud data.</LP>
      <SubprocessorTable rows={WEBSITE_SUBPROCESSORS} />
    </>,
  },
  {
    id: 'your-services', title: 'Services you connect',
    body: <>
      <LP>The services you connect to a workspace, such as Google Workspace, Slack, Notion, GitHub, Dropbox, Feishu or your own databases, are not our subprocessors. You choose them, they hold your data under your own agreements with them, and Skardi Cloud reads from them on your instruction. The same is true of the AI agents you connect to receive context from Skardi Cloud.</LP>
    </>,
  },
  {
    id: 'changes', title: 'Changes to this list',
    body: <>
      <LP>We update this page before a new subprocessor starts processing Customer Data, and change the date at the top. Billing is not switched on yet; before it is, our payment processor will be added here. To be told about changes by email, or to ask a question about this list, write to <LLink href="mailto:info@skardi.ai">info@skardi.ai</LLink>.</LP>
    </>,
  },
];

const SubprocessorsContent = () => (
  <LegalLayout
    page="subprocessors"
    title="Subprocessors"
    updated={SUBPROCESSORS_UPDATED}
    intro={<>
      <LP>SkardiLabs, Inc. uses the third-party service providers below to process personal data and Customer Data on its behalf. Each one receives only what it needs for the purpose listed. How we handle that data is described in our <LLink href="/privacy">Privacy Policy</LLink> and <LLink href="/terms">Terms of Service</LLink>.</LP>
    </>}
    sections={SUBPROCESSOR_SECTIONS}
  />
);

window.SubprocessorsContent = SubprocessorsContent;
