-- =========================
-- CHANGELOG FRAME
-- =========================

local changelogFrame = CreateFrame(
    "Frame",
    "ClearChatChangelogFrame",
    UIParent,
    "BasicFrameTemplateWithInset"
)

changelogFrame:SetFrameStrata("TOOLTIP")
changelogFrame:SetToplevel(true)

changelogFrame:SetSize(500, 350)
changelogFrame:SetPoint("CENTER")

changelogFrame:SetMovable(true)
changelogFrame:EnableMouse(true)
changelogFrame:RegisterForDrag("LeftButton")

changelogFrame:SetScript("OnDragStart", function(self)
    self:StartMoving()
end)

changelogFrame:SetScript("OnDragStop", function(self)
    self:StopMovingOrSizing()
end)

changelogFrame:Hide()

changelogFrame.TitleText:SetText(
    "ClearChat Changelog"
)

-- =========================
-- SCROLL FRAME
-- =========================

local scrollFrame = CreateFrame(
    "ScrollFrame",
    nil,
    changelogFrame,
    "UIPanelScrollFrameTemplate"
)

scrollFrame:SetPoint("TOPLEFT", 10, -30)
scrollFrame:SetPoint("BOTTOMRIGHT", -30, 40)

local content = CreateFrame(
    "EditBox",
    nil,
    scrollFrame
)

content:SetMultiLine(true)
content:SetAutoFocus(false)
content:SetFontObject("ChatFontNormal")
content:SetWidth(440)

content:SetText([[

ClearChat Changelog

## V1.51 - 2026-07-26
-- Made all ClearChat frames remain above all other frames
-- tested on 12.1 PTR and confirmed it works for game verson 12.1

V1.5 - 2026-07-25
-- Added a verson frame

v1.4
- Added the ability to move the popup message
- Moved the color box to the right of the color picker button
- Added a slider to resize the text
- Added automatic popup resizing

v1.3
- Added a color picker

v1.2
- Corrected a bug that stopped Clear Chat from working

v1.01
- Added configuration frame

v1.0
- Initial development

]])

scrollFrame:SetScrollChild(content)

-- =========================
-- BACK BUTTON
-- =========================

local backButton = CreateFrame(
    "Button",
    nil,
    changelogFrame,
    "UIPanelButtonTemplate"
)

backButton:SetSize(120, 24)

backButton:SetPoint(
    "BOTTOM",
    0,
    10
)

backButton:SetText(
    "Back to Settings"
)

backButton:SetScript(
    "OnClick",
    function()

        changelogFrame:Hide()

        if ClearChatConfigFrame then
            ClearChatConfigFrame:Show()
        end

    end
)

-- =========================
-- GLOBAL FUNCTION
-- =========================

function ClearChat_ShowChangelog()

    if ClearChatConfigFrame then
        ClearChatConfigFrame:Hide()
    end

    changelogFrame:Show()

end