<?xml version="1.0" encoding="UTF-8"?>
<!--
  Nivora Excel two-way add-in — PRODUCTION manifest (task pane, Excel host).

  SourceLocation points at the pane hosted by the app itself: https://nivorauw.com/addin/app/
  (staged into dist/addin/app by scripts/stage-addin.mjs during `npm run build`). Installing
  with THIS manifest needs no local dev server and no certificate trust — the site's real TLS
  certificate covers it. This file is served for download at /addin/nivora-addin-manifest.xml
  (copied into public/addin/ — keep the two in sync).

  Same <Id> GUID as the dev manifest (addin/manifest.xml): Office treats the Id as the add-in's
  identity, so replacing the manifest file upgrades the install in place.
-->
<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:ov="http://schemas.microsoft.com/office/taskpaneappversionoverrides"
  xsi:type="TaskPaneApp">

  <Id>3d5924ac-0969-46be-8423-a0b4d5e654ea</Id>
  <Version>1.2.1.0</Version>
  <ProviderName>Nivora</ProviderName>
  <DefaultLocale>en-US</DefaultLocale>
  <DisplayName DefaultValue="Nivora" />
  <Description DefaultValue="Open a Nivora deal in Excel as a live model and push/pull changes back to the platform." />
  <IconUrl DefaultValue="https://nivorauw.com/addin/app/assets/icon-32.png" />
  <HighResolutionIconUrl DefaultValue="https://nivorauw.com/addin/app/assets/icon-64.png" />
  <SupportUrl DefaultValue="https://nivorauw.com/help/excel-addin-install" />

  <!-- Domains the pane webview may navigate to without popping an external browser window:
       our own origin (help links from the pane) and the Supabase origin (auth/session
       endpoints supabase-js talks to). -->
  <AppDomains>
    <AppDomain>https://nivorauw.com</AppDomain>
    <AppDomain>https://kykehsumaekboxksprpc.supabase.co</AppDomain>
  </AppDomains>

  <!-- Restrict the add-in to the Excel application. -->
  <Hosts>
    <Host Name="Workbook" />
  </Hosts>

  <!-- Minimum API surface: ExcelApi 1.7 covers workbook.names range read/write used by CellIO. -->
  <Requirements>
    <Sets DefaultMinVersion="1.1">
      <Set Name="ExcelApi" MinVersion="1.7" />
    </Sets>
  </Requirements>

  <DefaultSettings>
    <SourceLocation DefaultValue="https://nivorauw.com/addin/app/index.html" />
  </DefaultSettings>

  <!-- ReadWriteDocument: the add-in reads named input cells and writes inputs back on open/pull. -->
  <Permissions>ReadWriteDocument</Permissions>

  <!--
    C7 — VersionOverrides add the custom-functions runtime WITHOUT changing the task pane above.
    The <DefaultSettings><SourceLocation> pane declaration is left untouched (backward-compat for
    hosts that ignore VersionOverrides). A SHARED runtime (lifetime="long") points at the SAME pane
    page, so NIVORA.IRR / NIVORA.NPV register in the runtime the pane hosts (the associate bootstrap
    in addin/src/main.tsx). functions.json is served next to the pane at /addin/app/functions.json
    (staged there by scripts/stage-addin.mjs during `npm run build`).
  -->
  <VersionOverrides xmlns="http://schemas.microsoft.com/office/taskpaneappversionoverrides" xsi:type="VersionOverridesV1_0">
    <!-- Gate the whole VersionOverrides on the CF + shared runtime being available. Hosts without
         them fall back to the base task-pane SourceLocation above (so the pane still opens). -->
    <Requirements>
      <bt:Sets DefaultMinVersion="1.1">
        <bt:Set Name="CustomFunctionsRuntime" MinVersion="1.1" />
        <bt:Set Name="SharedRuntime" MinVersion="1.1" />
      </bt:Sets>
    </Requirements>

    <Hosts>
      <Host xsi:type="Workbook">
        <!-- One long-lived shared runtime = the existing pane page hosts the custom functions. -->
        <Runtimes>
          <Runtime resid="Nivora.Taskpane.Url" lifetime="long" />
        </Runtimes>

        <!-- Custom functions register on every form factor; metadata comes from functions.json,
             namespace NIVORA → the functions surface as NIVORA.IRR / NIVORA.NPV. -->
        <AllFormFactors>
          <ExtensionPoint xsi:type="CustomFunctions">
            <Script>
              <SourceLocation resid="Nivora.Taskpane.Url" />
            </Script>
            <Page>
              <SourceLocation resid="Nivora.Taskpane.Url" />
            </Page>
            <Metadata>
              <SourceLocation resid="Nivora.Functions.Url" />
            </Metadata>
            <Namespace resid="Nivora.Namespace" />
          </ExtensionPoint>
        </AllFormFactors>

        <!-- Ribbon button to open the pane in the shared runtime (keeps the pane launchable and
             AppSource-listing-clean; the base SourceLocation stays as the no-VersionOverrides path). -->
        <DesktopFormFactor>
          <GetStarted>
            <Title resid="Nivora.GetStarted.Title" />
            <Description resid="Nivora.GetStarted.Desc" />
            <LearnMoreUrl resid="Nivora.LearnMore.Url" />
          </GetStarted>
          <FunctionFile resid="Nivora.Taskpane.Url" />
          <ExtensionPoint xsi:type="PrimaryCommandSurface">
            <OfficeTab id="TabHome">
              <Group id="Nivora.Group">
                <Label resid="Nivora.Group.Label" />
                <Icon>
                  <bt:Image size="16" resid="Nivora.Icon.16" />
                  <bt:Image size="32" resid="Nivora.Icon.32" />
                  <bt:Image size="80" resid="Nivora.Icon.80" />
                </Icon>
                <Control xsi:type="Button" id="Nivora.OpenPane">
                  <Label resid="Nivora.Button.Label" />
                  <Supertip>
                    <Title resid="Nivora.Supertip.Title" />
                    <Description resid="Nivora.Supertip.Desc" />
                  </Supertip>
                  <Icon>
                    <bt:Image size="16" resid="Nivora.Icon.16" />
                    <bt:Image size="32" resid="Nivora.Icon.32" />
                    <bt:Image size="80" resid="Nivora.Icon.80" />
                  </Icon>
                  <Action xsi:type="ShowTaskpane">
                    <TaskpaneId>NivoraTaskpane</TaskpaneId>
                    <SourceLocation resid="Nivora.Taskpane.Url" />
                  </Action>
                </Control>
              </Group>
            </OfficeTab>
          </ExtensionPoint>
        </DesktopFormFactor>
      </Host>
    </Hosts>

    <Resources>
      <!-- Schema-mandated child order: Images, Urls, ShortStrings, LongStrings. -->
      <bt:Images>
        <bt:Image id="Nivora.Icon.16" DefaultValue="https://nivorauw.com/addin/app/assets/icon-16.png" />
        <bt:Image id="Nivora.Icon.32" DefaultValue="https://nivorauw.com/addin/app/assets/icon-32.png" />
        <bt:Image id="Nivora.Icon.80" DefaultValue="https://nivorauw.com/addin/app/assets/icon-80.png" />
      </bt:Images>
      <bt:Urls>
        <bt:Url id="Nivora.Taskpane.Url" DefaultValue="https://nivorauw.com/addin/app/index.html" />
        <bt:Url id="Nivora.Functions.Url" DefaultValue="https://nivorauw.com/addin/app/functions.json" />
        <bt:Url id="Nivora.LearnMore.Url" DefaultValue="https://nivorauw.com/help/excel-addin-install" />
      </bt:Urls>
      <bt:ShortStrings>
        <bt:String id="Nivora.Namespace" DefaultValue="NIVORA" />
        <bt:String id="Nivora.Group.Label" DefaultValue="Nivora" />
        <bt:String id="Nivora.Button.Label" DefaultValue="Open Nivora" />
        <bt:String id="Nivora.Supertip.Title" DefaultValue="Nivora" />
        <bt:String id="Nivora.GetStarted.Title" DefaultValue="Nivora" />
      </bt:ShortStrings>
      <bt:LongStrings>
        <bt:String id="Nivora.Supertip.Desc" DefaultValue="Open the Nivora task pane to load a deal as a live model." />
        <bt:String id="Nivora.GetStarted.Desc" DefaultValue="Open the Nivora pane, or type =NIVORA.IRR / =NIVORA.NPV in any cell." />
      </bt:LongStrings>
    </Resources>
  </VersionOverrides>
</OfficeApp>
