local A=script.Parent.Parent local m=require(A:WaitForChild("\076\097\122\121\076\111\097\100\101\114"))local Y=game:GetService("\085\115\101\114\073\110\112\117\116\083\101\114\118\105\099\101")local x=game:GetService("\082\117\110\083\101\114\118\105\099\101")local a=.0225 local s=Vector3.new(1,-1,1)local t={[Enum.UserInputType.MouseButton1]=true,[Enum.UserInputType.Touch]=true}local I={[Enum.UserInputType.MouseMovement]=true,[Enum.UserInputType.Touch]=true}local Q={}Q.__index=Q Q.__type="\068\114\097\103\103\101\114"function Q.__tostring(A)return Q.__type end function Q.new(A)local Y=setmetatable({},Q)Y._Maid=m.Utilities.Maid.new()Y._DragBind=Instance.new("\066\105\110\100\097\098\108\101\069\118\101\110\116")Y._StartBind=Instance.new("\066\105\110\100\097\098\108\101\069\118\101\110\116")Y._StopBind=Instance.new("\066\105\110\100\097\098\108\101\069\118\101\110\116")Y.Element=A Y.IsDragging=false Y.DragChanged=Y._DragBind.Event Y.DragStart=Y._StartBind.Event Y.DragStop=Y._StopBind.Event init(Y)return Y end function init(A)local m=A.Element local x=A._Maid local a=A._DragBind local s=Vector3.new()x:Mark(A._DragBind)x:Mark(A._StartBind)x:Mark(A._StopBind)x:Mark(m.InputBegan:Connect(function(m)if t[m.UserInputType]then s=m.Position A.IsDragging=true A._StartBind:Fire()end end))x:Mark(Y.InputEnded:Connect(function(m)if t[m.UserInputType]then A.IsDragging=false A._StopBind:Fire()end end))x:Mark(Y.InputChanged:Connect(function(Y,x)if A.IsDragging then if I[Y.UserInputType]then local A=Y.Position-s s=Y.Position a:Fire(m,Y,A)end end end))end function Q.Destroy(A)A._Maid:Sweep()A.DragChanged=nil A.DragStart=nil A.DragStop=nil A.Element=nil end return Q
-- Meant for internal use, no documentation given

-- CONSTANTS

local GuiLib = script.Parent.Parent
local Lazy = require(GuiLib:WaitForChild("LazyLoader"))

local UIS = game:GetService("UserInputService")
local RUNSERVICE = game:GetService("RunService")

local DEADZONE2 = 0.15^2
local FLIP_THUMB = Vector3.new(1, -1, 1)

local VALID_PRESS = {
	[Enum.UserInputType.MouseButton1] = true;
	[Enum.UserInputType.Touch] = true;
}

local VALID_MOVEMENT = {
	[Enum.UserInputType.MouseMovement] = true;
	[Enum.UserInputType.Touch] = true;
}

-- Class

local DraggerClass = {}
DraggerClass.__index = DraggerClass
DraggerClass.__type = "Dragger"

function DraggerClass:__tostring()
	return DraggerClass.__type
end

-- Public Constructors

function DraggerClass.new(element)
	local self = setmetatable({}, DraggerClass)
	
	self._Maid = Lazy.Utilities.Maid.new()
	self._DragBind = Instance.new("BindableEvent")
	self._StartBind = Instance.new("BindableEvent")
	self._StopBind = Instance.new("BindableEvent")
	
	self.Element = element
	self.IsDragging = false
	self.DragChanged = self._DragBind.Event
	self.DragStart = self._StartBind.Event
	self.DragStop = self._StopBind.Event
	
	init(self)
	
	return self
end

-- Private Methods

function init(self)
	local element = self.Element
	local maid = self._Maid
	local dragBind = self._DragBind
	local lastMousePosition = Vector3.new()
	
	maid:Mark(self._DragBind)
	maid:Mark(self._StartBind)
	maid:Mark(self._StopBind)
	
	maid:Mark(element.InputBegan:Connect(function(input)
		if (VALID_PRESS[input.UserInputType]) then
			lastMousePosition = input.Position
			self.IsDragging = true
			self._StartBind:Fire()
		end
	end))
	
	maid:Mark(UIS.InputEnded:Connect(function(input)
		if (VALID_PRESS[input.UserInputType]) then
			self.IsDragging = false
			self._StopBind:Fire()
		end
	end))
	
	maid:Mark(UIS.InputChanged:Connect(function(input, process)
		if (self.IsDragging) then
			if (VALID_MOVEMENT[input.UserInputType]) then
				local delta = input.Position - lastMousePosition
				lastMousePosition = input.Position
				dragBind:Fire(element, input, delta)
			end
		end
	end))
end

-- Public Methods

function DraggerClass:Destroy()
	self._Maid:Sweep()
	self.DragChanged = nil
	self.DragStart = nil
	self.DragStop = nil
	self.Element = nil
end

--

return DraggerClass