local J=game:GetService("\087\111\114\107\115\112\097\099\101")local p=game:GetService("\082\117\110\083\101\114\118\105\099\101")local w={}function w.reparentFromWorkspaceIfNeeded(w,P)assert(typeof(w)=="\073\110\115\116\097\110\099\101","\066\097\100 \112\097\114\101\110\116")assert(type(P)=="\115\116\114\105\110\103","\066\097\100 \110\097\109\101")local W=J:FindFirstChild(P)local B=w:FindFirstChild(P)if W then if B then error(("\068\117\112\108\105\099\097\116\101 \099\111\110\116\097\105\110\101\114 \105\110 \037\113 \097\110\100 \037\113"):format(W:GetFullName(),B:GetFullName()))end if p:IsRunning()then W.Parent=w end return W end if not B then error(("\078\111 \116\101\109\112\108\097\116\101 \099\111\110\116\097\105\110\101\114 \119\105\116\104 \110\097\109\101 \037\113 \105\110 \037\113"):format(w:GetFullName(),P))end return B end return w
--[=[
	Utility functions for the TemplateProvider
	@class TemplateContainerUtils
]=]

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

local TemplateContainerUtils = {}

function TemplateContainerUtils.reparentFromWorkspaceIfNeeded(parent, name)
	assert(typeof(parent) == "Instance", "Bad parent")
	assert(type(name) == "string", "Bad name")

	local workspaceContainer = Workspace:FindFirstChild(name)
	local parentedContainer = parent:FindFirstChild(name)
	if workspaceContainer then
		if parentedContainer then
			error(
				("Duplicate container in %q and %q"):format(
					workspaceContainer:GetFullName(),
					parentedContainer:GetFullName()
				)
			)
		end

		-- Reparent
		if RunService:IsRunning() then
			workspaceContainer.Parent = parent
		end

		return workspaceContainer
	end

	if not parentedContainer then
		error(("No template container with name %q in %q"):format(parent:GetFullName(), name))
	end

	return parentedContainer
end

return TemplateContainerUtils
