local D=game:GetService("\084\101\120\116\083\101\114\118\105\099\101")local o=script:FindFirstAncestor("\084\101\120\116\069\100\105\116\111\114")local m=require(o.Packages.Roact)local c=require(script.Parent.StudioThemeContext)local f=m.Component:extend("\084\111\111\108\116\105\112")local R=5 f.defaultProps={BackgroundTransparency=0;BorderSizePixel=0;Visible=true;RichText=false;Font=Enum.Font.SourceSans,TextSize=20;Text="\112\114\111\112\115\046\084\101\120\116";TextXAlignment=Enum.TextXAlignment.Left,TextYAlignment=Enum.TextYAlignment.Center,ZIndex=1;themeType=Enum.StudioStyleGuideColor.MainText,themeModifier=Enum.StudioStyleGuideModifier.Default}function f.render(o)local f=o.props.Size if not f then local m=D:GetTextSize(o.props.Text,o.props.TextSize,o.props.Font,Vector2.new(math.huge,math.huge))f=UDim2.new(o.props.Width or UDim.new(0,m.X+R*2),UDim.new(0,m.Y+R*2))end return m.createElement(c.Consumer,{render=function(D)return m.createElement("\070\114\097\109\101",{AnchorPoint=o.props.AnchorPoint;LayoutOrder=o.props.LayoutOrder;Position=o.props.Position;Size=f,BackgroundColor3=o.props.BackgroundColor3 or D:GetColor(Enum.StudioStyleGuideColor.Tooltip);BackgroundTransparency=o.props.BackgroundTransparency,BorderSizePixel=o.props.BorderSizePixel,Visible=o.props.Visible,ZIndex=o.props.ZIndex},{Padding=m.createElement("\085\073\080\097\100\100\105\110\103",{PaddingTop=UDim.new(0,R);PaddingBottom=UDim.new(0,R),PaddingLeft=UDim.new(0,R);PaddingRight=UDim.new(0,R)});Label=m.createElement("\084\101\120\116\076\097\098\101\108",{BackgroundTransparency=1;Size=UDim2.fromScale(1,1);Font=o.props.Font;TextSize=o.props.TextSize,TextColor3=o.props.TextColor3 or D:GetColor(o.props.themeType,o.props.themeModifier);Text=o.props.Text;TextWrapped=o.props.TextWrapped,TextXAlignment=o.props.TextXAlignment;TextYAlignment=o.props.TextYAlignment,RichText=o.props.RichText;ZIndex=o.props.ZIndex})})end})end return f
-- Based off https://github.com/tiffany352/Roblox-Tag-Editor/blob/master/src/Components/TextLabel.lua
local TextService = game:GetService("TextService")
local TextEditor = script:FindFirstAncestor("TextEditor")
local Roact = require(TextEditor.Packages.Roact)

local StudioThemeContext = require(script.Parent.StudioThemeContext)
local Tooltip = Roact.Component:extend("Tooltip")

local TEXT_MARGIN = 5

Tooltip.defaultProps = {
  BackgroundTransparency = 0,
  BorderSizePixel = 0,
  Visible = true,

  RichText = false,
  Font = Enum.Font.SourceSans,
  TextSize = 20,
  Text = "props.Text",
  TextXAlignment = Enum.TextXAlignment.Left,
  TextYAlignment = Enum.TextYAlignment.Center,
  ZIndex = 1,

  themeType = Enum.StudioStyleGuideColor.MainText,
  themeModifier = Enum.StudioStyleGuideModifier.Default,
}

function Tooltip:render()
  local Size = self.props.Size
  if not Size then
    local TextBounds = TextService:GetTextSize(self.props.Text, self.props.TextSize, self.props.Font, Vector2.new(math.huge, math.huge))
    Size = UDim2.new(self.props.Width or UDim.new(0, TextBounds.X + TEXT_MARGIN * 2), UDim.new(0, TextBounds.Y + TEXT_MARGIN * 2))
  end

  return Roact.createElement(StudioThemeContext.Consumer, {
    render = function(theme)
      return Roact.createElement("Frame", {
        AnchorPoint = self.props.AnchorPoint,
        LayoutOrder = self.props.LayoutOrder,
        Position = self.props.Position,
        Size = Size,
        BackgroundColor3 = self.props.BackgroundColor3 or theme:GetColor(Enum.StudioStyleGuideColor.Tooltip),
        BackgroundTransparency = self.props.BackgroundTransparency,
        BorderSizePixel = self.props.BorderSizePixel,
        Visible = self.props.Visible,
        ZIndex = self.props.ZIndex,
      }, {
        Padding = Roact.createElement("UIPadding", {
          PaddingTop = UDim.new(0, TEXT_MARGIN),
          PaddingBottom = UDim.new(0, TEXT_MARGIN),
          PaddingLeft = UDim.new(0, TEXT_MARGIN),
          PaddingRight = UDim.new(0, TEXT_MARGIN),
        }),

        Label = Roact.createElement("TextLabel", {
          BackgroundTransparency = 1,
          Size = UDim2.fromScale(1, 1),

          Font = self.props.Font,
          TextSize = self.props.TextSize,
          TextColor3 = self.props.TextColor3 or theme:GetColor(self.props.themeType, self.props.themeModifier),
          Text = self.props.Text,
          TextWrapped = self.props.TextWrapped,
          TextXAlignment = self.props.TextXAlignment,
          TextYAlignment = self.props.TextYAlignment,
          RichText = self.props.RichText,
          ZIndex = self.props.ZIndex,
        }),
      })
    end
  })
end

return Tooltip