<?xml version="1.0" encoding="UTF-8"?>
<!--
  WAPD Email Agent - Outlook add-in (add-in-only XML manifest; Mac/classic compatible).
  Milestone 1 task pane: authenticates via MSAL.js popup against app reg
  ff92e55d (scope api://ff92e55d.../access_as_user) -> calls the WAPD Email
  Agent API. NON-SSO: the Office SSO (getAccessToken / WebApplicationInfo) path
  is a confirmed dead end (centralized-deployment eligibility wall) and was
  removed so this manifest can be sideloaded/deployed like the proven test
  build. Auth app reg ff92e55d is SEPARATE from the app-only Graph identity.
-->
<OfficeApp
  xmlns="http://schemas.microsoft.com/office/appforoffice/1.1"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:bt="http://schemas.microsoft.com/office/officeappbasictypes/1.0"
  xmlns:mailappor="http://schemas.microsoft.com/office/mailappversionoverrides/1.0"
  xsi:type="MailApp">

  <Id>f61f40c5-15af-4e84-a681-93de0038b570</Id>
  <Version>1.0.0.0</Version>
  <ProviderName>Workshop/APD</ProviderName>
  <DefaultLocale>en-US</DefaultLocale>
  <DisplayName DefaultValue="Email Assistant" />
  <Description DefaultValue="Watch senders so important email gets surfaced (and optionally drafted) for you. Drafts land in your Drafts; nothing is sent." />
  <IconUrl DefaultValue="https://mailagent.workshopapd.com/assets/email-assistant-64.png" />
  <HighResolutionIconUrl DefaultValue="https://mailagent.workshopapd.com/assets/email-assistant-128.png" />
  <SupportUrl DefaultValue="https://mailagent.workshopapd.com/" />

  <!-- Domains Office must permit the task pane to reach (the API + AAD for SSO). -->
  <AppDomains>
    <AppDomain>https://wapd-email-agent.azurewebsites.net</AppDomain>
    <AppDomain>https://login.microsoftonline.com</AppDomain>
  </AppDomains>

  <Hosts>
    <Host Name="Mailbox" />
  </Hosts>

  <Requirements>
    <Sets>
      <!-- 1.5 is the minimum for getAccessToken (SSO). -->
      <Set Name="Mailbox" MinVersion="1.5" />
    </Sets>
  </Requirements>

  <!-- Legacy read form (required in the base manifest even when using VersionOverrides). -->
  <FormSettings>
    <Form xsi:type="ItemRead">
      <DesktopSettings>
        <SourceLocation DefaultValue="https://mailagent.workshopapd.com/taskpane.html" />
        <RequestedHeight>250</RequestedHeight>
      </DesktopSettings>
    </Form>
  </FormSettings>

  <!-- Reading the open message's sender only. -->
  <Permissions>ReadItem</Permissions>

  <Rule xsi:type="RuleCollection" Mode="Or">
    <Rule xsi:type="ItemIs" ItemType="Message" FormType="Read" />
  </Rule>
  <DisableEntityHighlighting>false</DisableEntityHighlighting>

  <VersionOverrides xmlns="http://schemas.microsoft.com/office/mailappversionoverrides" xsi:type="VersionOverridesV1_0">
    <Requirements>
      <bt:Sets DefaultMinVersion="1.5">
        <bt:Set Name="Mailbox" />
      </bt:Sets>
    </Requirements>

    <Hosts>
      <Host xsi:type="MailHost">
        <DesktopFormFactor>
          <FunctionFile resid="functionFile" />
          <ExtensionPoint xsi:type="MessageReadCommandSurface">
            <OfficeTab id="TabDefault">
              <Group id="wapdGroup">
                <Label resid="groupLabel" />
                <Control xsi:type="Button" id="openPaneButton">
                  <Label resid="buttonLabel" />
                  <Supertip>
                    <Title resid="buttonLabel" />
                    <Description resid="buttonTip" />
                  </Supertip>
                  <Icon>
                    <bt:Image size="16" resid="icon16" />
                    <bt:Image size="32" resid="icon32" />
                    <bt:Image size="80" resid="icon80" />
                  </Icon>
                  <Action xsi:type="ShowTaskpane">
                    <SourceLocation resid="taskpaneUrl" />
                  </Action>
                </Control>
              </Group>
            </OfficeTab>
          </ExtensionPoint>
        </DesktopFormFactor>
      </Host>
    </Hosts>

    <Resources>
      <bt:Images>
        <bt:Image id="icon16" DefaultValue="https://mailagent.workshopapd.com/assets/email-assistant-16.png" />
        <bt:Image id="icon32" DefaultValue="https://mailagent.workshopapd.com/assets/email-assistant-32.png" />
        <bt:Image id="icon80" DefaultValue="https://mailagent.workshopapd.com/assets/email-assistant-80.png" />
      </bt:Images>
      <bt:Urls>
        <bt:Url id="taskpaneUrl" DefaultValue="https://mailagent.workshopapd.com/taskpane.html" />
        <bt:Url id="functionFile" DefaultValue="https://mailagent.workshopapd.com/commands.html" />
      </bt:Urls>
      <bt:ShortStrings>
        <bt:String id="groupLabel" DefaultValue="Email Assistant" />
        <bt:String id="buttonLabel" DefaultValue="Email Assistant" />
      </bt:ShortStrings>
      <bt:LongStrings>
        <bt:String id="buttonTip" DefaultValue="Open the WAPD Email Assistant pane to manage which senders you watch." />
      </bt:LongStrings>
    </Resources>

    <!-- Nested v1.1: the SAME command surface but with a pinnable task pane.
         SupportsPinning is a v1.1-schema element (invalid under v1.0), and
         OfficeApp requires the v1.0 VersionOverrides as its direct child — so
         the pinnable surface is declared here, nested. Mailbox 1.5+ clients
         (classic 2016+, new, Mac, OWA) use this; older clients fall back to the
         v1.0 surface above. Resids are shared from the v1.0 Resources. -->
    <VersionOverrides xmlns="http://schemas.microsoft.com/office/mailappversionoverrides/1.1" xsi:type="VersionOverridesV1_1">
      <Hosts>
        <Host xsi:type="MailHost">
          <DesktopFormFactor>
            <FunctionFile resid="functionFile" />
            <ExtensionPoint xsi:type="MessageReadCommandSurface">
              <OfficeTab id="TabDefault">
                <Group id="wapdGroup">
                  <Label resid="groupLabel" />
                  <Control xsi:type="Button" id="openPaneButton">
                    <Label resid="buttonLabel" />
                    <Supertip>
                      <Title resid="buttonLabel" />
                      <Description resid="buttonTip" />
                    </Supertip>
                    <Icon>
                      <bt:Image size="16" resid="icon16" />
                      <bt:Image size="32" resid="icon32" />
                      <bt:Image size="80" resid="icon80" />
                    </Icon>
                    <Action xsi:type="ShowTaskpane">
                      <SourceLocation resid="taskpaneUrl" />
                      <SupportsPinning>true</SupportsPinning>
                    </Action>
                  </Control>
                </Group>
              </OfficeTab>
            </ExtensionPoint>
          </DesktopFormFactor>
        </Host>
      </Hosts>

      <!-- A nested VersionOverrides v1.1 is a self-contained override: it must
           define its OWN Resources (the v1.1 Hosts can't resolve resids from the
           v1.0 Resources at runtime). Same resids/values as v1.0. Omitting this
           is why the v1.1-capable clients (web/new/Mac) rendered the button but
           ShowTaskpane resolved no URL. -->
      <Resources>
        <bt:Images>
          <bt:Image id="icon16" DefaultValue="https://mailagent.workshopapd.com/assets/email-assistant-16.png" />
          <bt:Image id="icon32" DefaultValue="https://mailagent.workshopapd.com/assets/email-assistant-32.png" />
          <bt:Image id="icon80" DefaultValue="https://mailagent.workshopapd.com/assets/email-assistant-80.png" />
        </bt:Images>
        <bt:Urls>
          <bt:Url id="taskpaneUrl" DefaultValue="https://mailagent.workshopapd.com/taskpane.html" />
          <bt:Url id="functionFile" DefaultValue="https://mailagent.workshopapd.com/commands.html" />
        </bt:Urls>
        <bt:ShortStrings>
          <bt:String id="groupLabel" DefaultValue="Email Assistant" />
          <bt:String id="buttonLabel" DefaultValue="Email Assistant" />
        </bt:ShortStrings>
        <bt:LongStrings>
          <bt:String id="buttonTip" DefaultValue="Open the WAPD Email Assistant pane to manage which senders you watch." />
        </bt:LongStrings>
      </Resources>
    </VersionOverrides>
  </VersionOverrides>
</OfficeApp>
