:: configurable[include]
<<set _furniture = $location.furniture>>
<<set _furnitureInPurse = $inventory.itemsInContainerByMetadata({furniture:{}})>>
<<if Object.keys(_furniture).length > 0 || Object.keys(_furnitureInPurse).length > 0>>
	<<act 'Configure Furniture' undefined `{priority:-1000}`>>
		<<gt 'ConfigureRoom'>>
	<</act>>
<</if>>

<<for _itemId, _itemData range _furniture>>
	<<set _itemMetaData = $inventory.metadata(_itemId)>>
	<<for _actionId, _actionData range _itemMetaData.furniture?.actions ?? {}>>
		<<act undefined undefined _actionData>><</act>>
	<</for>>
<</for>>

:: ConfigureRoom[menu]
<h2>Room Configuration</h2>
<<set _furniture = $location.furniture>>
<<set _furnitureInPurse = $inventory.itemsInContainerByMetadata({furniture:{}})>>
<<if Object.keys(_furnitureInPurse).length > 0>>
	<h3>Install</h3>
	<<for _itemId, _itemData range _furnitureInPurse>>
		<<capture _itemId>>
			<<link `'Install '+_itemData.label`>>
				<<gt 'ConfigureRoomInstall' _itemId>>
			<</link>>
		<</capture>>
	<</for>>
<</if>>

<<if Object.keys(_furniture).length > 0>>
	<h3>Uninstall</h3>
	<<for _itemId, _itemData range _furniture>>
		<<set _itemMetaData = $inventory.metadata(_itemId)>>
		<<capture _itemId>>
			<<link `'Uninstall '+_itemMetaData.label`>>
				<<gt 'ConfigureRoomUninstall' _itemId>>
			<</link>>
		<</capture>>
	<</for>>
<</if>>

<<ret>>

:: ConfigureRoomInstall[event]
<<set _itemId = $larg(0)>>
<<set _itemConstant = $inventory.metadataConst(_itemId)>>
<<run $location.updateFurniture(_itemId,$inventory.metadataDynamic(_itemId))>>
<<run $inventory.dec(_itemId)>>

<<set _installPassage = _itemConstant.furniture?.installPassage>>
<<if _installPassage>>
	<<gs _installPassage>>
<</if>>

<<act 'Continue'>><<gt 'ConfigureRoom'>><</act>>

:: ConfigureRoomUninstall[event]
<<set _itemId = $larg(0)>>
<<set _itemConstant = $inventory.metadataConst(_itemId)>>
<<set _furniture = $location.furniture>>
<<set _furnitureItem = _furniture[_itemId]>>
<<run $location.removeFurniture(_itemId)>>

<<run $inventory.inc(_itemId)>>
<<run $inventory.metadataSet(_itemId,'default',_furnitureItem)>>

<<set _uninstallPassage = _itemConstant.furniture?.uninstallPassage>>
<<if _uninstallPassage>>
	<<gs _uninstallPassage>>
<</if>>

<<act 'Continue'>><<gt 'ConfigureRoom'>><</act>>