<?xml version="1.0" encoding="UTF-8"?>
<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">

  <!-- Basic Add-in Metadata -->
  <Id>a1b2c3d4-e5f6-7890-abcd-nzxplorer0001</Id>
  <Version>2.0.0</Version>
  <ProviderName>NZXplorer</ProviderName>
  <DefaultLocale>en-NZ</DefaultLocale>
  <DisplayName DefaultValue="NZXplorer for Excel" />
  <Description DefaultValue="NZX stock prices, governance scores, dividends, insider trading, financial metrics, and 200+ data points directly in Excel. Custom functions and array formulas for all 130 NZX-listed companies." />
  <IconUrl DefaultValue="https://nzxplorer.co.nz/icon.png" />
  <HighResolutionIconUrl DefaultValue="https://nzxplorer.co.nz/icon.png" />
  <SupportUrl DefaultValue="https://nzxplorer.co.nz/integrations/excel" />

  <!-- Domains the add-in accesses -->
  <AppDomains>
    <AppDomain>https://nzxplorer.co.nz</AppDomain>
  </AppDomains>

  <!-- Hosts: Excel only -->
  <Hosts>
    <Host Name="Workbook" />
  </Hosts>

  <!-- Requirements for dynamic arrays and custom functions -->
  <Requirements>
    <Sets>
      <Set Name="CustomFunctionsRuntime" MinVersion="1.1" />
    </Sets>
  </Requirements>

  <!-- Default Settings (fallback for older versions) -->
  <DefaultSettings>
    <SourceLocation DefaultValue="https://nzxplorer.co.nz/excel-addin/taskpane.html" />
  </DefaultSettings>

  <!-- Permissions -->
  <Permissions>ReadWriteDocument</Permissions>

  <!-- VersionOverrides for custom functions + ribbon -->
  <VersionOverrides xmlns="http://schemas.microsoft.com/office/taskpaneappversionoverrides" xsi:type="VersionOverridesV1_0">
    <Hosts>
      <Host xsi:type="Workbook">
        <!-- Custom Functions Runtime -->
        <Runtimes>
          <Runtime resid="CustomFunctions.Url" lifetime="long" />
        </Runtimes>

        <AllFormFactors>
          <ExtensionPoint xsi:type="CustomFunctions">
            <Script>
              <SourceLocation resid="CustomFunctions.Url" />
            </Script>
            <Page>
              <SourceLocation resid="CustomFunctions.Page" />
            </Page>
            <Metadata>
              <SourceLocation resid="CustomFunctions.Metadata" />
            </Metadata>
            <Namespace resid="CustomFunctions.Namespace" />
          </ExtensionPoint>
        </AllFormFactors>

        <!-- Desktop Form Factor (Ribbon + Task Pane) -->
        <DesktopFormFactor>
          <FunctionFile resid="Commands.Url" />

          <ExtensionPoint xsi:type="PrimaryCommandSurface">
            <CustomTab id="NZXplorerTab">
              <Group id="NZXplorerGroup">
                <Label resid="GroupLabel" />
                <Icon>
                  <bt:Image size="16" resid="Icon.16" />
                  <bt:Image size="32" resid="Icon.32" />
                  <bt:Image size="80" resid="Icon.80" />
                </Icon>

                <!-- Task Pane Button -->
                <Control xsi:type="Button" id="TaskpaneButton">
                  <Label resid="TaskpaneButton.Label" />
                  <Supertip>
                    <Title resid="TaskpaneButton.Label" />
                    <Description resid="TaskpaneButton.Tooltip" />
                  </Supertip>
                  <Icon>
                    <bt:Image size="16" resid="Icon.16" />
                    <bt:Image size="32" resid="Icon.32" />
                    <bt:Image size="80" resid="Icon.80" />
                  </Icon>
                  <Action xsi:type="ShowTaskpane">
                    <TaskpaneId>NZXplorerTaskpane</TaskpaneId>
                    <SourceLocation resid="Taskpane.Url" />
                  </Action>
                </Control>
              </Group>
              <Label resid="TabLabel" />
            </CustomTab>
          </ExtensionPoint>
        </DesktopFormFactor>
      </Host>
    </Hosts>

    <!-- Resources -->
    <Resources>
      <bt:Images>
        <bt:Image id="Icon.16" DefaultValue="https://nzxplorer.co.nz/icon.png" />
        <bt:Image id="Icon.32" DefaultValue="https://nzxplorer.co.nz/icon.png" />
        <bt:Image id="Icon.80" DefaultValue="https://nzxplorer.co.nz/icon.png" />
      </bt:Images>

      <bt:Urls>
        <bt:Url id="CustomFunctions.Url" DefaultValue="https://nzxplorer.co.nz/excel-addin/functions.js" />
        <bt:Url id="CustomFunctions.Page" DefaultValue="https://nzxplorer.co.nz/excel-addin/taskpane.html" />
        <bt:Url id="CustomFunctions.Metadata" DefaultValue="https://nzxplorer.co.nz/excel-addin/functions.json" />
        <bt:Url id="Taskpane.Url" DefaultValue="https://nzxplorer.co.nz/excel-addin/taskpane.html" />
        <bt:Url id="Commands.Url" DefaultValue="https://nzxplorer.co.nz/excel-addin/functions.js" />
      </bt:Urls>

      <bt:ShortStrings>
        <bt:String id="TabLabel" DefaultValue="NZXplorer" />
        <bt:String id="GroupLabel" DefaultValue="NZX Data" />
        <bt:String id="TaskpaneButton.Label" DefaultValue="NZXplorer" />
        <bt:String id="CustomFunctions.Namespace" DefaultValue="NZXPLORER" />
      </bt:ShortStrings>

      <bt:LongStrings>
        <bt:String id="TaskpaneButton.Tooltip" DefaultValue="Open the NZXplorer task pane to manage your API key, refresh data, and view function reference." />
      </bt:LongStrings>
    </Resources>
  </VersionOverrides>
</OfficeApp>
