-- lx-bundle:true

--- Core Browser lifecycle and shared instance access
-- @module core.browser

local core = require("core")
local config = require("core.config")
local Browser = require("core.browser.view")

local browser = {}
local view

-- Set Browser defaults before layered user settings override them
config.browser_width = 200 * SCALE
config.browser_startup_visible = false
config.browser_reuse_single_tab = config.browser_reuse_single_tab ~= false

--- Create and dock the core Browser once
-- The workspace shell must exist before this is called
-- @return table view
function browser.init()
	if view then
		return view
	end

	view = Browser()

	local node = core.workspace_view:get_active_node()
	node:split("left", view, true)

	return view
end

--- Return the initialized core Browser
-- @return table|nil view
function browser.get_view()
	return view
end

return browser
