local I=require(game.ReplicatedStorage.Packages.Fusion)local j=I.New local b=I.Children local o=I.OnEvent local u=I.OnChange local K=I.State local t=I.Computed local z=I.Spring local N=game:GetService("\087\111\114\107\115\112\097\099\101")local D=game:GetService("\071\117\105\083\101\114\118\105\099\101")local U=N.CurrentCamera local g,V=D:GetGuiInset()local function c(I)local b=K()local function o()local j=I.Size local o=U.ViewportSize-(g+V)b:set(1/math.max(j.X/o.X,j.Y/o.Y))end o();(U:GetPropertyChangedSignal("\086\105\101\119\112\111\114\116\083\105\122\101")):Connect(o)return(j("\085\073\083\099\097\108\101"))({Scale=t(function()return b:get()*I.Scale end)})end return c
--[[ local Workspace = game:GetService("Workspace")
local GuiService = game:GetService("GuiService")

local Camera = Workspace.CurrentCamera
local TopInset, BottomInset = GuiService:GetGuiInset()

local Roact = require("Roact")

local Scale = Roact.PureComponent:extend("Scale")

function Scale:init()
	self:update()

	self.Listener = Camera:GetPropertyChangedSignal("ViewportSize"):Connect(function()
		self:update()
	end)
end

function Scale:update()
	local currentSize = self.props.Size
	local viewportSize = Camera.ViewportSize - (TopInset + BottomInset)

	self:setState({
		Scale = 1 / math.max(
			currentSize.X / viewportSize.X,
			currentSize.Y / viewportSize.Y
		)
	})
end

function Scale:willUnmount()
	self.Listener:Disconnect()
end

function Scale:render()
	return Roact.createElement("UIScale", {
		Scale = self.state.Scale * self.props.Scale
	})
end

Scale.defaultProps = {
	Scale = 1
}

return Scale

 ]]

local Fusion = require(game.ReplicatedStorage.Packages.Fusion)
local New = Fusion.New
local Children = Fusion.Children
local OnEvent = Fusion.OnEvent
local OnChange = Fusion.OnChange
local State = Fusion.State
local Computed = Fusion.Computed
local Spring = Fusion.Spring

local Workspace = game:GetService("Workspace")
local GuiService = game:GetService("GuiService")

local Camera = Workspace.CurrentCamera
local TopInset, BottomInset = GuiService:GetGuiInset()

local function UIScale(props)
	--props:  Size = v3   Scale = float
	local ScaleState = State()

	local function update()
		local currentSize = props.Size
		local viewportSize = Camera.ViewportSize - (TopInset + BottomInset)

		ScaleState:set(1 / math.max(currentSize.X / viewportSize.X, currentSize.Y / viewportSize.Y))
	end

	update()
	Camera:GetPropertyChangedSignal("ViewportSize"):Connect(update)

	return New("UIScale")({
		Scale = Computed(function()
			return ScaleState:get() * props.Scale
		end),
	})
end

return UIScale
