function RxInstanceUtils.observeFirstAncestorBrio(W,o)assert(typeof(W)=="\073\110\115\116\097\110\099\101","\066\097\100 \105\110\115\116\097\110\099\101")assert(type(o)=="\115\116\114\105\110\103","\066\097\100 \099\108\097\115\115\078\097\109\101")return Observable.new(function(O)local l=Maid.new()local b=nil local function N()local N=W:FindFirstAncestorWhichIsA(o)if N then if N~=b then b=N local W=Brio.new(N)l._current=W O:Fire(W)end elseif b then l._current=nil b=nil end end l:GiveTask(W.AncestryChanged:Connect(N))N()return l end)end

function RxInstanceUtils.observeFirstAncestorBrio(instance, className)
	assert(typeof(instance) == "Instance", "Bad instance")
	assert(type(className) == "string", "Bad className")

	return Observable.new(function(sub)
		local maid = Maid.new()

		local lastFound = nil
		local function handleAncestryChanged()
			local found = instance:FindFirstAncestorWhichIsA(className)

			if found then
				if found ~= lastFound then
					lastFound = found
					local brio = Brio.new(found)
					maid._current = brio
					sub:Fire(brio)
				end
			elseif lastFound then
				maid._current = nil
				lastFound = nil
			end
		end

		maid:GiveTask(instance.AncestryChanged:Connect(handleAncestryChanged))
		handleAncestryChanged()

		return maid
	end)
end
