local t,M="\070\114\097\109\101",30 local u=LibStub and LibStub("\065\099\101\071\085\073-\051\046\048",true)if not u or(u:GetWidgetVersion(t)or 0)>=M then return end local r,W,d=pairs,assert,type local g=table.wipe local V=PlaySound local a,L=CreateFrame,UIParent local function e(t)V(799)t.obj:Hide()end local function X(t)t.obj:Fire("\079\110\083\104\111\119")end local function S(t)t.obj:Fire("\079\110\067\108\111\115\101")end local function Q(t)u:ClearFocus()end local function A(t)(t:GetParent()):StartMoving()u:ClearFocus()end local function C(t)local M=t:GetParent()M:StopMovingOrSizing()local u=M.obj local r=u.status or u.localstatus r.width=M:GetWidth()r.height=M:GetHeight()r.top=M:GetTop()r.left=M:GetLeft()end local function b(t)(t:GetParent()):StartSizing("\066\079\084\084\079\077\082\073\071\072\084")u:ClearFocus()end local function p(t)(t:GetParent()):StartSizing("\066\079\084\084\079\077")u:ClearFocus()end local function R(t)(t:GetParent()):StartSizing("\082\073\071\072\084")u:ClearFocus()end local function l(t)t.obj:Fire("\079\110\069\110\116\101\114\083\116\097\116\117\115\066\097\114")end local function v(t)t.obj:Fire("\079\110\076\101\097\118\101\083\116\097\116\117\115\066\097\114")end local o={OnAcquire=function(t)t.frame:SetParent(L)t.frame:SetFrameStrata("\070\085\076\076\083\067\082\069\069\078\095\068\073\065\076\079\071")t.frame:SetFrameLevel(100)t:SetTitle()t:SetStatusText()t:ApplyStatus()t:Show()t:EnableResize(true)end,OnRelease=function(t)t.status=nil g(t.localstatus)end;OnWidthSet=function(t,M)local u=t.content local r=M-34 if r<0 then r=0 end u:SetWidth(r)u.width=r end,OnHeightSet=function(t,M)local u=t.content local r=M-57 if r<0 then r=0 end u:SetHeight(r)u.height=r end,SetTitle=function(t,M)t.titletext:SetText(M)t.titlebg:SetWidth((t.titletext:GetWidth()or 0)+10)end,SetStatusText=function(t,M)t.statustext:SetText(M)end,Hide=function(t)t.frame:Hide()end,Show=function(t)t.frame:Show()end;EnableResize=function(t,M)local u=M and"\083\104\111\119"or"\072\105\100\101"t.sizer_se[u](t.sizer_se)t.sizer_s[u](t.sizer_s)t.sizer_e[u](t.sizer_e)end,SetStatusTable=function(t,M)W(d(M)=="\116\097\098\108\101")t.status=M t:ApplyStatus()end;ApplyStatus=function(t)local M=t.status or t.localstatus local u=t.frame t:SetWidth(M.width or 700)t:SetHeight(M.height or 500)u:ClearAllPoints()if M.top and M.left then u:SetPoint("\084\079\080",L,"\066\079\084\084\079\077",0,M.top)u:SetPoint("\076\069\070\084",L,"\076\069\070\084",M.left,0)else u:SetPoint("\067\069\078\084\069\082")end end}local y={bgFile="\073\110\116\101\114\102\097\099\101\092\068\105\097\108\111\103\070\114\097\109\101\092\085\073-\068\105\097\108\111\103\066\111\120-\066\097\099\107\103\114\111\117\110\100";edgeFile="\073\110\116\101\114\102\097\099\101\092\068\105\097\108\111\103\070\114\097\109\101\092\085\073-\068\105\097\108\111\103\066\111\120-\066\111\114\100\101\114",tile=true,tileSize=32,edgeSize=32,insets={left=8,right=8,top=8,bottom=8}}local k={bgFile="\073\110\116\101\114\102\097\099\101\092\067\104\097\116\070\114\097\109\101\092\067\104\097\116\070\114\097\109\101\066\097\099\107\103\114\111\117\110\100";edgeFile="\073\110\116\101\114\102\097\099\101\092\084\111\111\108\116\105\112\115\092\085\073-\084\111\111\108\116\105\112-\066\111\114\100\101\114",tile=true,tileSize=16,edgeSize=16;insets={left=3,right=3,top=5;bottom=3}}local function f()local M=a("\070\114\097\109\101",nil,L,"\066\097\099\107\100\114\111\112\084\101\109\112\108\097\116\101")M:Hide()M:EnableMouse(true)M:SetMovable(true)M:SetResizable(true)M:SetFrameStrata("\070\085\076\076\083\067\082\069\069\078\095\068\073\065\076\079\071")M:SetFrameLevel(100)M:SetBackdrop(y)M:SetBackdropColor(0,0,0,1)if M.SetResizeBounds then M:SetResizeBounds(400,200)else M:SetMinResize(400,200)end M:SetToplevel(true)M:SetScript("\079\110\083\104\111\119",X)M:SetScript("\079\110\072\105\100\101",S)M:SetScript("\079\110\077\111\117\115\101\068\111\119\110",Q)local W=a("\066\117\116\116\111\110",nil,M,"\085\073\080\097\110\101\108\066\117\116\116\111\110\084\101\109\112\108\097\116\101")W:SetScript("\079\110\067\108\105\099\107",e)W:SetPoint("\066\079\084\084\079\077\082\073\071\072\084",-27,17)W:SetHeight(20)W:SetWidth(100)W:SetText(CLOSE)local d=a("\066\117\116\116\111\110",nil,M,"\066\097\099\107\100\114\111\112\084\101\109\112\108\097\116\101")d:SetPoint("\066\079\084\084\079\077\076\069\070\084",15,15)d:SetPoint("\066\079\084\084\079\077\082\073\071\072\084",-132,15)d:SetHeight(24)d:SetBackdrop(k)d:SetBackdropColor(.1,.1,.1)d:SetBackdropBorderColor(.4,.4,.4)d:SetScript("\079\110\069\110\116\101\114",l)d:SetScript("\079\110\076\101\097\118\101",v)local g=d:CreateFontString(nil,"\079\086\069\082\076\065\089","\071\097\109\101\070\111\110\116\078\111\114\109\097\108")g:SetPoint("\084\079\080\076\069\070\084",7,-2)g:SetPoint("\066\079\084\084\079\077\082\073\071\072\084",-7,2)g:SetHeight(20)g:SetJustifyH("\076\069\070\084")g:SetText("")local V=M:CreateTexture(nil,"\079\086\069\082\076\065\089")V:SetTexture(131080)V:SetTexCoord(.31,.67,0,.63)V:SetPoint("\084\079\080",0,12)V:SetWidth(100)V:SetHeight(40)local f=a("\070\114\097\109\101",nil,M)f:EnableMouse(true)f:SetScript("\079\110\077\111\117\115\101\068\111\119\110",A)f:SetScript("\079\110\077\111\117\115\101\085\112",C)f:SetAllPoints(V)local z=f:CreateFontString(nil,"\079\086\069\082\076\065\089","\071\097\109\101\070\111\110\116\078\111\114\109\097\108")z:SetPoint("\084\079\080",V,"\084\079\080",0,-14)local I=M:CreateTexture(nil,"\079\086\069\082\076\065\089")I:SetTexture(131080)I:SetTexCoord(.21,.31,0,.63)I:SetPoint("\082\073\071\072\084",V,"\076\069\070\084")I:SetWidth(30)I:SetHeight(40)local P=M:CreateTexture(nil,"\079\086\069\082\076\065\089")P:SetTexture(131080)P:SetTexCoord(.67,.77,0,.63)P:SetPoint("\076\069\070\084",V,"\082\073\071\072\084")P:SetWidth(30)P:SetHeight(40)local Z=a("\070\114\097\109\101",nil,M)Z:SetPoint("\066\079\084\084\079\077\082\073\071\072\084")Z:SetWidth(25)Z:SetHeight(25)Z:EnableMouse()Z:SetScript("\079\110\077\111\117\115\101\068\111\119\110",b)Z:SetScript("\079\110\077\111\117\115\101\085\112",C)local G=Z:CreateTexture(nil,"\066\065\067\075\071\082\079\085\078\068")G:SetWidth(14)G:SetHeight(14)G:SetPoint("\066\079\084\084\079\077\082\073\071\072\084",-8,8)G:SetTexture(137057)local F=.082352941176471 G:SetTexCoord(.05-F,.5,.05,.5+F,.05,.5-F,.5+F,.5)local B=Z:CreateTexture(nil,"\066\065\067\075\071\082\079\085\078\068")B:SetWidth(8)B:SetHeight(8)B:SetPoint("\066\079\084\084\079\077\082\073\071\072\084",-8,8)B:SetTexture(137057)F=.047058823529412 B:SetTexCoord(.05-F,.5,.05,.5+F,.05,.5-F,.5+F,.5)local J=a("\070\114\097\109\101",nil,M)J:SetPoint("\066\079\084\084\079\077\082\073\071\072\084",-25,0)J:SetPoint("\066\079\084\084\079\077\076\069\070\084")J:SetHeight(25)J:EnableMouse(true)J:SetScript("\079\110\077\111\117\115\101\068\111\119\110",p)J:SetScript("\079\110\077\111\117\115\101\085\112",C)local H=a("\070\114\097\109\101",nil,M)H:SetPoint("\066\079\084\084\079\077\082\073\071\072\084",0,25)H:SetPoint("\084\079\080\082\073\071\072\084")H:SetWidth(25)H:EnableMouse(true)H:SetScript("\079\110\077\111\117\115\101\068\111\119\110",R)H:SetScript("\079\110\077\111\117\115\101\085\112",C)local E=a("\070\114\097\109\101",nil,M)E:SetPoint("\084\079\080\076\069\070\084",17,-27)E:SetPoint("\066\079\084\084\079\077\082\073\071\072\084",-17,40)local m={localstatus={};titletext=z,statustext=g,titlebg=V;sizer_se=Z;sizer_s=J,sizer_e=H,content=E;frame=M;type=t}for t,M in r(o)do m[t]=M end W.obj,d.obj=m,m return u:RegisterAsContainer(m)end u:RegisterWidgetType(t,f,M)
--[[-----------------------------------------------------------------------------
Frame Container
-------------------------------------------------------------------------------]]
local Type, Version = "Frame", 30
local AceGUI = LibStub and LibStub("AceGUI-3.0", true)
if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end

-- Lua APIs
local pairs, assert, type = pairs, assert, type
local wipe = table.wipe

-- WoW APIs
local PlaySound = PlaySound
local CreateFrame, UIParent = CreateFrame, UIParent

--[[-----------------------------------------------------------------------------
Scripts
-------------------------------------------------------------------------------]]
local function Button_OnClick(frame)
	PlaySound(799) -- SOUNDKIT.GS_TITLE_OPTION_EXIT
	frame.obj:Hide()
end

local function Frame_OnShow(frame)
	frame.obj:Fire("OnShow")
end

local function Frame_OnClose(frame)
	frame.obj:Fire("OnClose")
end

local function Frame_OnMouseDown(frame)
	AceGUI:ClearFocus()
end

local function Title_OnMouseDown(frame)
	frame:GetParent():StartMoving()
	AceGUI:ClearFocus()
end

local function MoverSizer_OnMouseUp(mover)
	local frame = mover:GetParent()
	frame:StopMovingOrSizing()
	local self = frame.obj
	local status = self.status or self.localstatus
	status.width = frame:GetWidth()
	status.height = frame:GetHeight()
	status.top = frame:GetTop()
	status.left = frame:GetLeft()
end

local function SizerSE_OnMouseDown(frame)
	frame:GetParent():StartSizing("BOTTOMRIGHT")
	AceGUI:ClearFocus()
end

local function SizerS_OnMouseDown(frame)
	frame:GetParent():StartSizing("BOTTOM")
	AceGUI:ClearFocus()
end

local function SizerE_OnMouseDown(frame)
	frame:GetParent():StartSizing("RIGHT")
	AceGUI:ClearFocus()
end

local function StatusBar_OnEnter(frame)
	frame.obj:Fire("OnEnterStatusBar")
end

local function StatusBar_OnLeave(frame)
	frame.obj:Fire("OnLeaveStatusBar")
end

--[[-----------------------------------------------------------------------------
Methods
-------------------------------------------------------------------------------]]
local methods = {
	["OnAcquire"] = function(self)
		self.frame:SetParent(UIParent)
		self.frame:SetFrameStrata("FULLSCREEN_DIALOG")
		self.frame:SetFrameLevel(100) -- Lots of room to draw under it
		self:SetTitle()
		self:SetStatusText()
		self:ApplyStatus()
		self:Show()
        self:EnableResize(true)
	end,

	["OnRelease"] = function(self)
		self.status = nil
		wipe(self.localstatus)
	end,

	["OnWidthSet"] = function(self, width)
		local content = self.content
		local contentwidth = width - 34
		if contentwidth < 0 then
			contentwidth = 0
		end
		content:SetWidth(contentwidth)
		content.width = contentwidth
	end,

	["OnHeightSet"] = function(self, height)
		local content = self.content
		local contentheight = height - 57
		if contentheight < 0 then
			contentheight = 0
		end
		content:SetHeight(contentheight)
		content.height = contentheight
	end,

	["SetTitle"] = function(self, title)
		self.titletext:SetText(title)
		self.titlebg:SetWidth((self.titletext:GetWidth() or 0) + 10)
	end,

	["SetStatusText"] = function(self, text)
		self.statustext:SetText(text)
	end,

	["Hide"] = function(self)
		self.frame:Hide()
	end,

	["Show"] = function(self)
		self.frame:Show()
	end,

	["EnableResize"] = function(self, state)
		local func = state and "Show" or "Hide"
		self.sizer_se[func](self.sizer_se)
		self.sizer_s[func](self.sizer_s)
		self.sizer_e[func](self.sizer_e)
	end,

	-- called to set an external table to store status in
	["SetStatusTable"] = function(self, status)
		assert(type(status) == "table")
		self.status = status
		self:ApplyStatus()
	end,

	["ApplyStatus"] = function(self)
		local status = self.status or self.localstatus
		local frame = self.frame
		self:SetWidth(status.width or 700)
		self:SetHeight(status.height or 500)
		frame:ClearAllPoints()
		if status.top and status.left then
			frame:SetPoint("TOP", UIParent, "BOTTOM", 0, status.top)
			frame:SetPoint("LEFT", UIParent, "LEFT", status.left, 0)
		else
			frame:SetPoint("CENTER")
		end
	end
}

--[[-----------------------------------------------------------------------------
Constructor
-------------------------------------------------------------------------------]]
local FrameBackdrop = {
	bgFile = "Interface\\DialogFrame\\UI-DialogBox-Background",
	edgeFile = "Interface\\DialogFrame\\UI-DialogBox-Border",
	tile = true, tileSize = 32, edgeSize = 32,
	insets = { left = 8, right = 8, top = 8, bottom = 8 }
}

local PaneBackdrop  = {
	bgFile = "Interface\\ChatFrame\\ChatFrameBackground",
	edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
	tile = true, tileSize = 16, edgeSize = 16,
	insets = { left = 3, right = 3, top = 5, bottom = 3 }
}

local function Constructor()
	local frame = CreateFrame("Frame", nil, UIParent, "BackdropTemplate")
	frame:Hide()

	frame:EnableMouse(true)
	frame:SetMovable(true)
	frame:SetResizable(true)
	frame:SetFrameStrata("FULLSCREEN_DIALOG")
	frame:SetFrameLevel(100) -- Lots of room to draw under it
	frame:SetBackdrop(FrameBackdrop)
	frame:SetBackdropColor(0, 0, 0, 1)
	if frame.SetResizeBounds then -- WoW 10.0
		frame:SetResizeBounds(400, 200)
	else
		frame:SetMinResize(400, 200)
	end
	frame:SetToplevel(true)
	frame:SetScript("OnShow", Frame_OnShow)
	frame:SetScript("OnHide", Frame_OnClose)
	frame:SetScript("OnMouseDown", Frame_OnMouseDown)

	local closebutton = CreateFrame("Button", nil, frame, "UIPanelButtonTemplate")
	closebutton:SetScript("OnClick", Button_OnClick)
	closebutton:SetPoint("BOTTOMRIGHT", -27, 17)
	closebutton:SetHeight(20)
	closebutton:SetWidth(100)
	closebutton:SetText(CLOSE)

	local statusbg = CreateFrame("Button", nil, frame, "BackdropTemplate")
	statusbg:SetPoint("BOTTOMLEFT", 15, 15)
	statusbg:SetPoint("BOTTOMRIGHT", -132, 15)
	statusbg:SetHeight(24)
	statusbg:SetBackdrop(PaneBackdrop)
	statusbg:SetBackdropColor(0.1,0.1,0.1)
	statusbg:SetBackdropBorderColor(0.4,0.4,0.4)
	statusbg:SetScript("OnEnter", StatusBar_OnEnter)
	statusbg:SetScript("OnLeave", StatusBar_OnLeave)

	local statustext = statusbg:CreateFontString(nil, "OVERLAY", "GameFontNormal")
	statustext:SetPoint("TOPLEFT", 7, -2)
	statustext:SetPoint("BOTTOMRIGHT", -7, 2)
	statustext:SetHeight(20)
	statustext:SetJustifyH("LEFT")
	statustext:SetText("")

	local titlebg = frame:CreateTexture(nil, "OVERLAY")
	titlebg:SetTexture(131080) -- Interface\\DialogFrame\\UI-DialogBox-Header
	titlebg:SetTexCoord(0.31, 0.67, 0, 0.63)
	titlebg:SetPoint("TOP", 0, 12)
	titlebg:SetWidth(100)
	titlebg:SetHeight(40)

	local title = CreateFrame("Frame", nil, frame)
	title:EnableMouse(true)
	title:SetScript("OnMouseDown", Title_OnMouseDown)
	title:SetScript("OnMouseUp", MoverSizer_OnMouseUp)
	title:SetAllPoints(titlebg)

	local titletext = title:CreateFontString(nil, "OVERLAY", "GameFontNormal")
	titletext:SetPoint("TOP", titlebg, "TOP", 0, -14)

	local titlebg_l = frame:CreateTexture(nil, "OVERLAY")
	titlebg_l:SetTexture(131080) -- Interface\\DialogFrame\\UI-DialogBox-Header
	titlebg_l:SetTexCoord(0.21, 0.31, 0, 0.63)
	titlebg_l:SetPoint("RIGHT", titlebg, "LEFT")
	titlebg_l:SetWidth(30)
	titlebg_l:SetHeight(40)

	local titlebg_r = frame:CreateTexture(nil, "OVERLAY")
	titlebg_r:SetTexture(131080) -- Interface\\DialogFrame\\UI-DialogBox-Header
	titlebg_r:SetTexCoord(0.67, 0.77, 0, 0.63)
	titlebg_r:SetPoint("LEFT", titlebg, "RIGHT")
	titlebg_r:SetWidth(30)
	titlebg_r:SetHeight(40)

	local sizer_se = CreateFrame("Frame", nil, frame)
	sizer_se:SetPoint("BOTTOMRIGHT")
	sizer_se:SetWidth(25)
	sizer_se:SetHeight(25)
	sizer_se:EnableMouse()
	sizer_se:SetScript("OnMouseDown",SizerSE_OnMouseDown)
	sizer_se:SetScript("OnMouseUp", MoverSizer_OnMouseUp)

	local line1 = sizer_se:CreateTexture(nil, "BACKGROUND")
	line1:SetWidth(14)
	line1:SetHeight(14)
	line1:SetPoint("BOTTOMRIGHT", -8, 8)
	line1:SetTexture(137057) -- Interface\\Tooltips\\UI-Tooltip-Border
	local x = 0.1 * 14/17
	line1:SetTexCoord(0.05 - x, 0.5, 0.05, 0.5 + x, 0.05, 0.5 - x, 0.5 + x, 0.5)

	local line2 = sizer_se:CreateTexture(nil, "BACKGROUND")
	line2:SetWidth(8)
	line2:SetHeight(8)
	line2:SetPoint("BOTTOMRIGHT", -8, 8)
	line2:SetTexture(137057) -- Interface\\Tooltips\\UI-Tooltip-Border
	x = 0.1 * 8/17
	line2:SetTexCoord(0.05 - x, 0.5, 0.05, 0.5 + x, 0.05, 0.5 - x, 0.5 + x, 0.5)

	local sizer_s = CreateFrame("Frame", nil, frame)
	sizer_s:SetPoint("BOTTOMRIGHT", -25, 0)
	sizer_s:SetPoint("BOTTOMLEFT")
	sizer_s:SetHeight(25)
	sizer_s:EnableMouse(true)
	sizer_s:SetScript("OnMouseDown", SizerS_OnMouseDown)
	sizer_s:SetScript("OnMouseUp", MoverSizer_OnMouseUp)

	local sizer_e = CreateFrame("Frame", nil, frame)
	sizer_e:SetPoint("BOTTOMRIGHT", 0, 25)
	sizer_e:SetPoint("TOPRIGHT")
	sizer_e:SetWidth(25)
	sizer_e:EnableMouse(true)
	sizer_e:SetScript("OnMouseDown", SizerE_OnMouseDown)
	sizer_e:SetScript("OnMouseUp", MoverSizer_OnMouseUp)

	--Container Support
	local content = CreateFrame("Frame", nil, frame)
	content:SetPoint("TOPLEFT", 17, -27)
	content:SetPoint("BOTTOMRIGHT", -17, 40)

	local widget = {
		localstatus = {},
		titletext   = titletext,
		statustext  = statustext,
		titlebg     = titlebg,
		sizer_se    = sizer_se,
		sizer_s     = sizer_s,
		sizer_e     = sizer_e,
		content     = content,
		frame       = frame,
		type        = Type
	}
	for method, func in pairs(methods) do
		widget[method] = func
	end
	closebutton.obj, statusbg.obj = widget, widget

	return AceGUI:RegisterAsContainer(widget)
end

AceGUI:RegisterWidgetType(Type, Constructor, Version)
