<html
    xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
    xmlns:ts="http://typo3.org/ns/TYPO3/CMS/Tstemplate/ViewHelpers"
    xmlns:core="http://typo3.org/ns/TYPO3/CMS/Core/ViewHelpers"
    data-namespace-typo3-fluid="true"
>

<f:for each="{tree.nextChild}" as="child">

    <ts:astCurrentObjectPathAppend currentObjectPath="{currentObjectPath}" node="{child}" />

    <li>
        <span class="list-tree-group">
            <f:if condition="{child.children}">
                <f:if condition="{child.expanded}">
                    <f:then>
                        <a
                            class="list-tree-control list-tree-control-open"
                            data-global-event="click"
                            data-action-submit="$form"
                            data-form-values="{ts:astCurrentObjectPathAsJson(currentObjectPath: currentObjectPath, key: '{type}Collapse')}"
                        >
                            <core:icon identifier="actions-caret-down"/>
                        </a>
                    </f:then>
                    <f:else>
                        <a
                            class="list-tree-control list-tree-control-closed"
                            data-global-event="click"
                            data-action-submit="$form"
                            data-form-values="{ts:astCurrentObjectPathAsJson(currentObjectPath: currentObjectPath, key: '{type}Expand')}"
                        >
                            <core:icon identifier="actions-caret-right"/>
                        </a>
                    </f:else>
                </f:if>
            </f:if>
            <span class="list-tree-label">
                <f:if condition="{child.searchMatchInName}">
                    <f:then>
                        [<f:be.link route="web_typoscript_objectbrowser" parameters="{id: pageUid, action:'edit', type: type, currentObjectPath: currentObjectPath.pathAsString}"><strong class="text-danger">{child.name}</strong></f:be.link>]
                    </f:then>
                    <f:else>
                        [<f:be.link route="web_typoscript_objectbrowser" parameters="{id: pageUid, action:'edit', type: type, currentObjectPath: currentObjectPath.pathAsString}">{child.name}</f:be.link>]
                    </f:else>
                </f:if>
            </span>
            <f:if condition="!{child.valueNull}">
                =
                <span class="list-tree-value {f:if(condition: child.searchMatchInValue, then:'text-danger')}">
                    {child.value}
                </span>
                <f:if condition="{displayConstantSubstitutions} && {child.originalValueTokenStream}">
                    <span class="diff-item-result diff-item-result-inline text-monospace text-normal p-0 ps-4">
                        <f:format.raw>
                            <f:variable name="trimmedStream"><ts:trim>{child.originalValueTokenStream}</ts:trim></f:variable>
                            <f:translate
                                key="LLL:EXT:tstemplate/Resources/Private/Language/locallang_objbrowser.xlf:valueWithConstant"
                                arguments="{
                                    0: '{ts:fineDiff(from: trimmedStream, to: child.value)}'
                                }"
                            />
                        </f:format.raw>
                    </span>
                </f:if>
            </f:if>
            <f:if condition="{child.referenceSourceStream}">
                =< <span class="list-tree-value {f:if(condition: child.searchMatchInValue, then:'text-danger')}">{child.referenceSourceStream}</span>
            </f:if>
            <f:if condition="{displayComments} && {child.comments}">
                <f:if condition="{displayConstantSubstitutions} && {child.originalValueTokenStream}">
                    <br />
                </f:if>
                <span class="diff-item-result diff-item-result-inline text-monospace text-normal p-0 ps-4">
                    <f:for each="{child.comments}" as="comment" iteration="iterator">
                        <f:if condition="!{iterator.isFirst}">
                            <br />
                        </f:if>
                        <f:translate key="LLL:EXT:tstemplate/Resources/Private/Language/locallang_objbrowser.xlf:comment" /> <ts:trim>{comment}</ts:trim>
                    </f:for>
                </span>
            </f:if>
        </span>
        <f:if condition="{child.children} && {child.expanded}">
            <ul class="list-tree text-monospace">
                <f:render
                    partial="ObjectBrowserTree"
                    arguments="{
                        type: type,
                        tree: child,
                        pageUid: pageUid,
                        currentObjectPath: currentObjectPath,
                        displayConstantSubstitutions: displayConstantSubstitutions,
                        displayComments: displayComments
                    }"
                />
            </ul>
        </f:if>
    </li>

    <ts:astCurrentObjectPathRemoveLast currentObjectPath="{currentObjectPath}" />
</f:for>

</html>
