local ____lualib = require("lualib_bundle")
local __TS__New = ____lualib.__TS__New
local ____exports = {}
local emptyRoomEntities, EMPTY_ROOM_BLACKLIST_ENTITY_SET
local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
local EntityFlag = ____isaac_2Dtypescript_2Ddefinitions.EntityFlag
local EntityType = ____isaac_2Dtypescript_2Ddefinitions.EntityType
local GridEntityType = ____isaac_2Dtypescript_2Ddefinitions.GridEntityType
local ____cachedClasses = require("core.cachedClasses")
local game = ____cachedClasses.game
local ____ReadonlySet = require("types.ReadonlySet")
local ReadonlySet = ____ReadonlySet.ReadonlySet
local ____entities = require("functions.entities")
local getEntities = ____entities.getEntities
local ____gridEntities = require("functions.gridEntities")
local getGridEntities = ____gridEntities.getGridEntities
local removeGridEntity = ____gridEntities.removeGridEntity
local ____roomShapeWalls = require("functions.roomShapeWalls")
local isVanillaWallGridIndex = ____roomShapeWalls.isVanillaWallGridIndex
local ____rooms = require("functions.rooms")
local roomUpdateSafe = ____rooms.roomUpdateSafe
function emptyRoomEntities(self)
    local room = game:GetRoom()
    for ____, entity in ipairs(getEntities(nil)) do
        do
            if EMPTY_ROOM_BLACKLIST_ENTITY_SET:has(entity.Type) then
                goto __continue4
            end
            if entity:HasEntityFlags(EntityFlag.CHARM) or entity:HasEntityFlags(EntityFlag.FRIENDLY) or entity:HasEntityFlags(EntityFlag.PERSISTENT) then
                goto __continue4
            end
            entity:ClearEntityFlags(EntityFlag.APPEAR)
            entity:Remove()
            if entity.Type == EntityType.FIREPLACE then
                local gridIndex = room:GetGridIndex(entity.Position)
                room:SetGridPath(gridIndex, 0)
            end
        end
        ::__continue4::
    end
end
--- Helper function to remove all grid entities from a room except for doors and walls.
function ____exports.emptyRoomGridEntities(self)
    local removedOneOrMoreGridEntities = false
    for ____, gridEntity in ipairs(getGridEntities(nil)) do
        do
            local gridEntityType = gridEntity:GetType()
            local gridIndex = gridEntity:GetGridIndex()
            if gridEntityType == GridEntityType.WALL and isVanillaWallGridIndex(nil, gridIndex) then
                goto __continue10
            end
            if gridEntityType == GridEntityType.DOOR then
                goto __continue10
            end
            removeGridEntity(nil, gridEntity, false)
            removedOneOrMoreGridEntities = true
        end
        ::__continue10::
    end
    if removedOneOrMoreGridEntities then
        roomUpdateSafe(nil)
    end
end
EMPTY_ROOM_BLACKLIST_ENTITY_SET = __TS__New(ReadonlySet, {
    EntityType.PLAYER,
    EntityType.TEAR,
    EntityType.FAMILIAR,
    EntityType.LASER,
    EntityType.KNIFE,
    EntityType.PROJECTILE,
    EntityType.DARK_ESAU
})
--- Helper function to remove all naturally spawning entities and grid entities from a room. Notably,
-- this will not remove players (1), tears (2), familiars (3), lasers (7), knives (8), projectiles
-- (9), blacklisted NPCs such as Dark Esau, charmed NPCs, friendly NPCs, persistent NPCs, most
-- effects (1000), doors, and walls.
function ____exports.emptyRoom(self)
    emptyRoomEntities(nil)
    ____exports.emptyRoomGridEntities(nil)
end
return ____exports
