-- vim: ft=terra
local terra 
render_compose(co: &lib.srv.convo, edit: &lib.store.post, acc: &lib.str.acc)
	var target, tgtlen = co:getv('to')
	var form: data.view.compose
	form = data.view.compose {
		handle = co.who.handle;
		circles = ''; -- TODO: list user's circles, rooms, and saved aclexps
	}
	if edit == nil then
		form.content = lib.coalesce(target, '')
		form.acl = lib.trn(target == nil, 'all', 'mentioned') -- TODO default acl setting?
	else
		form.content = lib.coalesce(edit.body, '')
		form.acl = edit.acl
	end
	if acc ~= nil then form:append(acc) return end 

	var cotxt = form:poolstr(&co.srv.pool) -- defer cotxt:free()

	var doc = [lib.srv.convo.page] {
		title = lib.str.plit 'compose';
		body = cotxt;
		class = lib.str.plit 'compose';
		cache = true;
	}

	co:stdpage(doc)
end

return render_compose
