local r=(require(script.Parent.loader)).load(script)local Q=r("\066\097\115\105\099\080\097\110\101")local t=r("\083\105\103\110\097\108")local x=setmetatable({},Q)x.ClassName="\067\111\110\118\101\114\116\080\097\110\101"x.__index=x function x.new(r,w,E,k)local I=setmetatable(Q.new(w),x)I._serviceBag=assert(r,"\078\111 \115\101\114\118\105\099\101\066\097\103")I.RequestConvert=t.new()I._terrainConverter=k or error("\078\111 \116\101\114\114\097\105\110\067\111\110\118\101\114\116\101\114")I._selectionService=E or error("\078\111 \115\101\108\101\099\116\105\111\110\083\101\114\118\105\099\101")I._canConvert=Instance.new("\066\111\111\108\086\097\108\117\101")I._canConvert.Value=false I._maid:GiveTask(I._canConvert)I._maid:GiveTask(I._canConvert.Changed:Connect(function()I:_updateButton()end))I._convertButton=I.Gui.ConvertButton I._statusLabel=I.Gui.StatusLabel I._maid:GiveTask(I._convertButton.MouseButton1Click:Connect(function()if I._canConvert.Value then local r=I._selectionService:Get()if#r>0 then I.RequestConvert:Fire(r)end end end))I._maid:GiveTask(I._selectionService.SelectionChanged:Connect(function()I:_updateStatus()end))I:_updateStatus()I:_updateButton()return I end function x._updateButton(r)if r._canConvert.Value then r._convertButton.AutoButtonColor=true r._convertButton.TextTransparency=0 r._convertButton.Active=true r._convertButton.Style=Enum.ButtonStyle.RobloxRoundDefaultButton else r._convertButton.AutoButtonColor=false r._convertButton.Active=false r._convertButton.TextTransparency=.7 r._convertButton.Style=Enum.ButtonStyle.RobloxRoundButton end end function x._updateStatus(r)local Q=r._selectionService:Get()local t if#Q==0 then r._statusLabel.Text="\078\111\116\104\105\110\103 \115\101\108\101\099\116\101\100"t=false elseif not r._terrainConverter:CanConvert(Q)then r._statusLabel.Text=("\067\097\110\110\111\116 \099\111\110\118\101\114\116 \037\100 \105\116\101\109\037\115"):format(#Q,#Q==1 and""or"\115")t=false else r._statusLabel.Text=("\037\100 \105\116\101\109\037\115 \115\101\108\101\099\116\101\100"):format(#Q,#Q==1 and""or"\115")t=true end r._canConvert.Value=t end return x
--[=[
	@class ConvertPane
]=]

local require = require(script.Parent.loader).load(script)

local BasicPane = require("BasicPane")
local Signal = require("Signal")

local ConvertPane = setmetatable({}, BasicPane)
ConvertPane.ClassName = "ConvertPane"
ConvertPane.__index = ConvertPane

function ConvertPane.new(serviceBag, gui, selectionService, terrainConverter)
	local self = setmetatable(BasicPane.new(gui), ConvertPane)

	self._serviceBag = assert(serviceBag, "No serviceBag")

	self.RequestConvert = Signal.new() -- :Fire(selection)

	self._terrainConverter = terrainConverter or error("No terrainConverter")
	self._selectionService = selectionService or error("No selectionService")

	self._canConvert = Instance.new("BoolValue")
	self._canConvert.Value = false
	self._maid:GiveTask(self._canConvert)

	self._maid:GiveTask(self._canConvert.Changed:Connect(function()
		self:_updateButton()
	end))

	self._convertButton = self.Gui.ConvertButton
	self._statusLabel = self.Gui.StatusLabel

	self._maid:GiveTask(self._convertButton.MouseButton1Click:Connect(function()
		if self._canConvert.Value then
			local selection = self._selectionService:Get()
			if #selection > 0 then
				self.RequestConvert:Fire(selection)
			end
		end
	end))

	self._maid:GiveTask(self._selectionService.SelectionChanged:Connect(function()
		self:_updateStatus()
	end))
	self:_updateStatus()
	self:_updateButton()


	return self
end

function ConvertPane:_updateButton()
	if self._canConvert.Value then
		self._convertButton.AutoButtonColor = true
		self._convertButton.TextTransparency = 0
		self._convertButton.Active = true
		self._convertButton.Style = Enum.ButtonStyle.RobloxRoundDefaultButton
	else
		self._convertButton.AutoButtonColor = false
		self._convertButton.Active = false
		self._convertButton.TextTransparency = 0.7
		self._convertButton.Style = Enum.ButtonStyle.RobloxRoundButton
	end
end

function ConvertPane:_updateStatus()
	local selection = self._selectionService:Get()

	local canConvert
	if #selection == 0 then
		self._statusLabel.Text = "Nothing selected"
		canConvert = false
	elseif not self._terrainConverter:CanConvert(selection) then
		self._statusLabel.Text = ("Cannot convert %d item%s"):format(#selection, #selection == 1 and "" or "s")
		canConvert = false
	else
		self._statusLabel.Text = ("%d item%s selected"):format(#selection, #selection == 1 and "" or "s")
		canConvert = true
	end

	self._canConvert.Value = canConvert
end

return ConvertPane