local o=game:GetService("\087\111\114\107\115\112\097\099\101")local T=game:GetService("\082\101\112\108\105\099\097\116\101\100\083\116\111\114\097\103\101")local m=T:WaitForChild("\099\111\109\109\111\110")local M=(o:WaitForChild("\112\111\114\116\097\108\115")):WaitForChild("\112\111\114\116\097\108\115\050")local N=require(m:WaitForChild("\083\101\108\101\099\116\111\114\115"))local y={}for o,T in pairs(M:GetChildren())do table.insert(y,T.Name)end local function k(o,T)local m=o.store:getState()local M=N.getPortals(m,T)if not M then return false end for o,T in pairs(y)do if not M[T]then return false end end return true end return{id="\065\108\108\095\080\111\114\116\097\108\115",name="\065\108\108 \080\111\114\116\097\108\115";desc="\065\099\116\105\118\097\116\101 \097\108\108 \112\111\114\116\097\108\115\046",badgeId=2124456121,startListening=function(o,T)local m=o:getModule("\080\111\114\116\097\108\115\076\105\115\116\101\110\101\114")m.portalActivated:connect(function(m,M)if k(o,m)then T(m)end end)end;queryComplete=k}
local Workspace = game:GetService("Workspace")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local common = ReplicatedStorage:WaitForChild("common")
local portalModels = Workspace:WaitForChild("portals"):WaitForChild("portals2")

local Selectors = require(common:WaitForChild("Selectors"))

local portalNames = {}
-- compile names
for _,portalModel in pairs(portalModels:GetChildren()) do
    table.insert(portalNames,portalModel.Name)
end

local function queryComplete(server,player)
    local state = server.store:getState()

    local portals = Selectors.getPortals(state,player)
    if not portals then return false end
    for _,portal in pairs(portalNames) do
        if not portals[portal] then
            return false
        end
    end
    return true
end

return {
    id = "All_Portals",
    name = "All Portals",
    desc = "Activate all portals.",
    badgeId = 2124456121,
    startListening = (function(server, awardBadge)
        local PortalsListener = server:getModule("PortalsListener")

        PortalsListener.portalActivated:connect(function(player,portal)
            if queryComplete(server, player) then
                awardBadge(player)
            end
        end)
    end),
    queryComplete = queryComplete,
}