-- LrPluginInfoProvider — renders the plugin's info section
-- inside Lightroom's Plug-in Manager dialog.  Shown when a
-- user selects "Random Pair Generator" in the list.  The
-- goal here is to make sure that even if the plugin gets
-- passed around outside the forum, users can reach the
-- author and the canonical home page.
--
-- Registered from Info.lua via `LrPluginInfoProvider = 'InfoProvider.lua'`.
-- SDK contract: this module returns a table with
-- sectionsForTopOfDialog (and/or sectionsForBottomOfDialog).
-- Each section is an LrView column.  The framework adds the
-- headers.

local LrHttp = import 'LrHttp'
local LrView = import 'LrView'

local Version = require 'Version'

-- Single source of truth for contact details.  Mirrored in
-- the Dashboard's Troubleshooting area.  Keep these in sync.
local HOMEPAGE_URL = 'https://alibosworth.com'
local CONTACT_EMAIL = 'ali@alibosworth.com'

return {
    sectionsForTopOfDialog = function(f, _propertyTable)
        return {
            {
                title = 'Random Pair Generator',
                synopsis = 'Pre-release',

                f:column {
                    spacing = f:control_spacing(),

                    f:static_text {
                        title = 'Version ' .. Version.string(),
                    },
                    -- Prominent pre-release notice so anyone
                    -- who acquired the plugin outside its
                    -- intended distribution channel understands
                    -- what they're running AND knows we want
                    -- to hear from them.  Not "alpha" — "pre-
                    -- release" reads more neutrally and doesn't
                    -- imply instability we can't back up.
                    f:static_text {
                        title = 'This is a pre-release: please '
                            .. 'send problem reports and feature '
                            .. 'requests.',
                        text_color = LrView.kColorGrey,
                    },
                    f:spacer { height = 8 },
                    f:static_text {
                        title = 'Made by Ali Bosworth',
                    },
                    -- Web and email surfaced as click-to-open
                    -- rather than plain text so they feel like
                    -- real affordances in the plug-in manager
                    -- (which already has a button-heavy UX).
                    f:row {
                        spacing = f:control_spacing(),
                        f:push_button {
                            title = HOMEPAGE_URL,
                            action = function()
                                LrHttp.openUrlInBrowser(HOMEPAGE_URL)
                            end,
                        },
                        f:push_button {
                            title = CONTACT_EMAIL,
                            action = function()
                                LrHttp.openUrlInBrowser(
                                    'mailto:' .. CONTACT_EMAIL)
                            end,
                        },
                    },
                },
            },
        }
    end,
}
