<?xml version="1.0" encoding="UTF-8"?>

<?context-directive job ctxfile x-setups.ctx ?>

<cd:interface xmlns:cd="http://www.pragma-ade.com/commands">

    <cd:command name="definecounter" level="system" category="counter" file="strc-num.mkiv">
        <cd:arguments>
            <cd:resolve name="keyword-name"/>
            <cd:resolve name="keyword-name-optional"/>
            <cd:assignments list="yes" optional="yes">
                <cd:inherit name="setupcounter"/>
            </cd:assignments>
        </cd:arguments>
    </cd:command>

    <cd:command name="setupcounter" level="system" category="counter" file="strc-num.mkiv">
        <cd:arguments>
            <cd:resolve name="keyword-name-list-optional"/>
            <cd:assignments list="yes">
                <!--
                    <cd:parameter name="name">
                        <cd:constant type="cd:name"/>
                    </cd:parameter>
                -->
                <cd:parameter name="start">
                    <cd:constant type="cd:number"/>
                </cd:parameter>
                <cd:parameter name="number">
                    <cd:constant type="cd:number"/>
                </cd:parameter>
                <cd:parameter name="counter">
                    <cd:constant type="cd:name"/>
                </cd:parameter>
                <cd:parameter name="method">
                    <cd:constant type="page"/>
                </cd:parameter>
                <cd:parameter name="state">
                    <cd:constant type="start" default="yes"/>
                    <cd:constant type="stop"/>
                </cd:parameter>
                <cd:parameter name="way">
                    <cd:constant type="page" prefix="by" method="none"/>
                    <cd:constant type="block" prefix="by" method="none"/>
                    <cd:constant type="text" prefix="by" method="none"/>
                    <cd:constant type="head" prefix="by" method="none"/>
                    <cd:constant type="cd:section" prefix="by" method="none"/>
                </cd:parameter>
                <cd:parameter name="prefix">
                    <cd:constant type="yes" default="yes"/>
                    <cd:constant type="no"/>
                </cd:parameter>
                <cd:parameter name="prefixseparatorset">
                    <cd:constant type="cd:name"/>
                </cd:parameter>
                <cd:parameter name="prefixconversion">
                    <cd:constant type="cd:name"/>
                </cd:parameter>
                <cd:parameter name="prefixconversionset">
                    <cd:constant type="cd:name"/>
                </cd:parameter>
                <cd:parameter name="prefixstarter">
                    <cd:resolve name="value-starter"/>
                </cd:parameter>
                <cd:parameter name="prefixstopper">
                    <cd:resolve name="value-stopper"/>
                </cd:parameter>
                <cd:parameter name="prefixset">
                    <cd:constant type="cd:name"/>
                </cd:parameter>
                <cd:parameter name="prefixsegments">
                    <cd:resolve name="value-prefixsegments"/>
                </cd:parameter>
                <cd:parameter name="numberorder">
                    <cd:constant type="reverse"/>
                </cd:parameter>
                <cd:parameter name="numberseparatorset">
                    <cd:constant type="cd:name"/>
                </cd:parameter>
                <cd:parameter name="numberconversion">
                    <cd:constant type="cd:name"/>
                </cd:parameter>
                <cd:parameter name="numberconversionset">
                    <cd:constant type="cd:name"/>
                </cd:parameter>
                <cd:parameter name="numberstarter">
                    <cd:resolve name="value-starter"/>
                </cd:parameter>
                <cd:parameter name="numberstopper">
                    <cd:resolve name="value-stopper"/>
                </cd:parameter>
                <cd:parameter name="numbersegments">
                    <cd:resolve name="value-numbersegments"/>
                </cd:parameter>
                <cd:parameter name="type">
                    <cd:constant type="first"/>
                    <cd:constant type="previous"/>
                    <!--
                        <cd:constant type="prev"/>
                    -->
                    <cd:constant type="next"/>
                    <cd:constant type="last"/>
                    <cd:constant type="number" default="yes"/>
                </cd:parameter>
                <cd:parameter name="criterium">
                    <cd:constant type="strict"/>
                    <cd:constant type="positive"/>
                    <cd:constant type="all"/>
                </cd:parameter>
                <cd:parameter name="prefixconnector">
                    <cd:resolve name="value-connector"/>
                </cd:parameter>
            </cd:assignments>
        </cd:arguments>
    </cd:command>

    <cd:command name="doifelsecounter" level="system" category="counter" keywords="conditional" file="strc-num.mkiv">
        <cd:arguments>
            <cd:resolve name="argument-name"/>
            <cd:resolve name="argument-true"/>
            <cd:resolve name="argument-false"/>
        </cd:arguments>
    </cd:command>

    <cd:command name="doifcounterelse" level="system" category="counter" keywords="conditional" file="strc-num.mkiv">
        <cd:arguments>
            <cd:resolve name="argument-name"/>
            <cd:resolve name="argument-true"/>
            <cd:resolve name="argument-false"/>
        </cd:arguments>
    </cd:command>

    <cd:command name="doifcounter" level="system" category="counter" keywords="conditional" file="strc-num.mkiv">
        <cd:arguments>
            <cd:resolve name="argument-name"/>
            <cd:resolve name="argument-true"/>
        </cd:arguments>
    </cd:command>

    <cd:command name="doifnotcounter" level="system" category="counter" keywords="conditional" file="strc-num.mkiv">
        <cd:arguments>
            <cd:resolve name="argument-name"/>
            <cd:resolve name="argument-true"/>
        </cd:arguments>
    </cd:command>

    <cd:command name="setcounter" level="system" category="counter" file="strc-num.mkiv">
        <cd:arguments>
            <cd:resolve name="keyword-name"/>
            <cd:resolve name="keyword-number-optional"/>
            <cd:resolve name="keyword-number"/>
        </cd:arguments>
    </cd:command>

    <cd:command name="setcounterown" level="system" category="counter" file="strc-num.mkiv">
        <cd:arguments>
            <cd:resolve name="keyword-name"/>
            <cd:resolve name="keyword-number-optional"/>
            <cd:resolve name="keyword-text"/>
        </cd:arguments>
    </cd:command>

    <cd:command name="restartcounter" level="system" category="counter" file="strc-num.mkiv">
        <cd:arguments>
            <cd:resolve name="keyword-name"/>
            <cd:resolve name="keyword-number-optional"/>
            <cd:resolve name="keyword-number"/>
        </cd:arguments>
    </cd:command>

    <cd:command name="resetcounter" level="system" category="counter" file="strc-num.mkiv">
        <cd:arguments>
            <cd:resolve name="keyword-name"/>
            <cd:resolve name="keyword-number-optional"/>
        </cd:arguments>
    </cd:command>

    <cd:command name="incrementcounter" level="system" category="counter" file="strc-num.mkiv">
        <cd:arguments>
            <cd:resolve name="keyword-name"/>
            <cd:resolve name="keyword-number-optional"/>
        </cd:arguments>
    </cd:command>

    <cd:command name="decrementcounter" level="system" category="counter" file="strc-num.mkiv">
        <cd:arguments>
            <cd:resolve name="keyword-name"/>
            <cd:resolve name="keyword-number-optional"/>
        </cd:arguments>
    </cd:command>

    <cd:command name="rawcounter" level="system" category="counter" file="strc-num.mkiv">
        <cd:arguments>
            <cd:resolve name="keyword-name"/>
            <cd:resolve name="keyword-number-optional"/>
        </cd:arguments>
    </cd:command>

    <cd:command name="lastcounter" level="system" category="counter" file="strc-num.mkiv">
        <cd:arguments>
            <cd:resolve name="keyword-name"/>
            <cd:resolve name="keyword-number-optional"/>
        </cd:arguments>
    </cd:command>

    <cd:command name="firstcounter" level="system" category="counter" file="strc-num.mkiv">
        <cd:arguments>
            <cd:resolve name="keyword-name"/>
            <cd:resolve name="keyword-number-optional"/>
        </cd:arguments>
    </cd:command>

    <cd:command name="nextcounter" level="system" category="counter" file="strc-num.mkiv">
        <cd:arguments>
            <cd:resolve name="keyword-name"/>
            <cd:resolve name="keyword-number-optional"/>
        </cd:arguments>
    </cd:command>

    <cd:command name="prevcounter" level="system" category="counter" file="strc-num.mkiv">
        <cd:arguments>
            <cd:resolve name="keyword-name"/>
            <cd:resolve name="keyword-number-optional"/>
        </cd:arguments>
    </cd:command>

    <cd:command name="countersubs" level="system" category="counter" file="strc-num.mkiv">
        <cd:arguments>
            <cd:resolve name="keyword-name"/>
            <cd:resolve name="keyword-number-optional"/>
        </cd:arguments>
    </cd:command>

    <cd:command name="savecounter" level="system" category="counter" file="strc-num.mkiv">
        <cd:arguments>
            <cd:resolve name="keyword-name"/>
        </cd:arguments>
    </cd:command>

    <cd:command name="restorecounter" level="system" category="counter" file="strc-num.mkiv">
        <cd:arguments>
            <cd:resolve name="keyword-name"/>
        </cd:arguments>
    </cd:command>

    <cd:command name="showcounter" level="system" category="counter" file="strc-num.mkiv">
        <cd:arguments>
            <cd:resolve name="keyword-name"/>
        </cd:arguments>
    </cd:command>

    <cd:command name="incrementedcounter" level="system" category="counter" file="strc-num.mkiv">
        <cd:arguments>
            <cd:resolve name="keyword-name"/>
        </cd:arguments>
    </cd:command>

    <cd:command name="decrementedcounter" level="system" category="counter" file="strc-num.mkiv">
        <cd:arguments>
            <cd:resolve name="keyword-name"/>
        </cd:arguments>
    </cd:command>

    <cd:command name="rawcountervalue" level="system" category="counter" file="strc-num.mkiv">
        <cd:arguments>
            <cd:resolve name="keyword-name"/>
        </cd:arguments>
    </cd:command>

    <cd:command name="lastcountervalue" level="system" category="counter" file="strc-num.mkiv">
        <cd:arguments>
            <cd:resolve name="keyword-name"/>
        </cd:arguments>
    </cd:command>

    <cd:command name="firstcountervalue" level="system" category="counter" file="strc-num.mkiv">
        <cd:arguments>
            <cd:resolve name="keyword-name"/>
        </cd:arguments>
    </cd:command>

    <cd:command name="nextcountervalue" level="system" category="counter" file="strc-num.mkiv">
        <cd:arguments>
            <cd:resolve name="keyword-name"/>
        </cd:arguments>
    </cd:command>

    <cd:command name="prevcountervalue" level="system" category="counter" file="strc-num.mkiv">
        <cd:arguments>
            <cd:resolve name="keyword-name"/>
        </cd:arguments>
    </cd:command>

    <cd:command name="rawsubcountervalue" level="system" category="counter" file="strc-num.mkiv">
        <cd:arguments>
            <cd:resolve name="keyword-name"/>
            <cd:resolve name="keyword-number"/>
        </cd:arguments>
    </cd:command>

    <cd:command name="lastsubcountervalue" level="system" category="counter" file="strc-num.mkiv">
        <cd:arguments>
            <cd:resolve name="keyword-name"/>
            <cd:resolve name="keyword-number"/>
        </cd:arguments>
    </cd:command>

    <cd:command name="firstsubcountervalue" level="system" category="counter" file="strc-num.mkiv">
        <cd:arguments>
            <cd:resolve name="keyword-name"/>
            <cd:resolve name="keyword-number"/>
        </cd:arguments>
    </cd:command>

    <cd:command name="nextsubcountervalue" level="system" category="counter" file="strc-num.mkiv">
        <cd:arguments>
            <cd:resolve name="keyword-name"/>
            <cd:resolve name="keyword-number"/>
        </cd:arguments>
    </cd:command>

    <cd:command name="prevsubcountervalue" level="system" category="counter" file="strc-num.mkiv">
        <cd:arguments>
            <cd:resolve name="keyword-name"/>
            <cd:resolve name="keyword-number"/>
        </cd:arguments>
    </cd:command>

    <cd:command name="convertedcounter" level="system" category="counter" file="strc-num.mkiv">
        <cd:arguments>
            <cd:resolve name="keyword-name"/>
            <cd:assignments list="yes" optional="yes">
                <cd:inherit name="setupcounter"/>
            </cd:assignments>
        </cd:arguments>
    </cd:command>

    <cd:command name="convertedsubcounter" level="system" category="counter" file="strc-num.mkiv">
        <cd:arguments>
            <cd:resolve name="keyword-name"/>
            <cd:keywords optional="yes">
                <cd:resolve name="value-numbersegments"/>
            </cd:keywords>
            <cd:assignments list="yes" optional="yes">
                <cd:inherit name="setupcounter"/>
            </cd:assignments>
        </cd:arguments>
    </cd:command>

    <cd:command name="directconvertedcounter" level="system" category="counter" file="strc-num.mkiv">
        <cd:arguments>
            <cd:resolve name="argument-name"/>
            <cd:keywords delimiters="braces">
                <cd:constant type="first"/>
                <cd:constant type="previous"/>
                <!--
                    <cd:constant type="prev"/>
                -->
                <cd:constant type="next"/>
                <cd:constant type="last"/>
                <cd:constant type="number"/>
            </cd:keywords>
        </cd:arguments>
    </cd:command>
    
    <cd:command name="doifelsedefinedcounter" level="system" category="counter" keywords="conditional" file="strc-num.mkiv">
        <cd:arguments>
            <cd:resolve name="argument-name"/>
            <cd:resolve name="argument-true"/>
            <cd:resolve name="argument-false"/>
        </cd:arguments>
    </cd:command>

    <cd:command name="doifdefinedcounterelse" level="system" category="counter" keywords="conditional" file="strc-num.mkiv">
        <cd:arguments>
            <cd:resolve name="argument-name"/>
            <cd:resolve name="argument-true"/>
            <cd:resolve name="argument-false"/>
        </cd:arguments>
    </cd:command>

    <cd:command name="doifdefinedcounter" level="system" category="counter" keywords="conditional" file="strc-num.mkiv">
        <cd:arguments>
            <cd:resolve name="argument-name"/>
            <cd:resolve name="argument-true"/>
        </cd:arguments>
    </cd:command>

    <cd:command name="doifundefinedcounter" level="system" category="counter" keywords="conditional" file="strc-num.mkiv">
        <cd:arguments>
            <cd:resolve name="argument-name"/>
            <cd:resolve name="argument-true"/>
        </cd:arguments>
    </cd:command>

    <cd:command name="defineresetset" level="style" category="counter" file="strc-ini.mkvi">
        <cd:arguments>
            <cd:keywords>
                <cd:constant type="cd:name"/>
                <cd:constant type="cd:name" prefix="cd:sectionblock" method="range"/>
            </cd:keywords>
            <cd:resolve name="keyword-number-list"/>
            <cd:resolve name="keyword-number-optional"/>
        </cd:arguments>
    </cd:command>

    <!--

        <cd:command name="definestructureresetset" level="style" category="counter" file="strc-ini.mkvi">
            <cd:arguments>
                <cd:keywords>
                    <cd:constant type="cd:name"/>
                    <cd:constant type="cd:name" prefix="cd:sectionblock" method="range"/>
                </cd:keywords>
                <cd:resolve name="keyword-number-list"/>
                <cd:resolve name="keyword-number-optional"/>
            </cd:arguments>
        </cd:command>

    -->

    <cd:command name="defineseparatorset" level="style" category="counter" file="strc-ini.mkvi">
        <cd:arguments>
            <cd:keywords>
                <cd:constant type="cd:name"/>
                <cd:constant type="cd:name" prefix="cd:sectionblock" method="range"/>
            </cd:keywords>
            <cd:keywords list="yes">
                <cd:resolve name="value-connector"/>
            </cd:keywords>
            <cd:keywords optional="yes">
                <cd:resolve name="value-connector"/>
            </cd:keywords>
        </cd:arguments>
    </cd:command>

    <!--

        <cd:command name="definestructureseparatorset" level="style" category="counter" file="strc-ini.mkvi">
            <cd:arguments>
                <cd:keywords>
                    <cd:constant type="cd:name"/>
                    <cd:constant type="cd:name" prefix="cd:sectionblock" method="range"/>
                </cd:keywords>
                <cd:keywords list="yes">
                    <cd:resolve name="value-connector"/>
                </cd:keywords>
                <cd:keywords optional="yes">
                    <cd:resolve name="value-connector"/>
                </cd:keywords>
            </cd:arguments>
        </cd:command>

    -->

    <cd:command name="defineconversionset" level="style" category="counter" file="strc-ini.mkvi">
        <cd:arguments>
            <cd:keywords>
                <cd:constant type="cd:name"/>
                <cd:constant type="cd:name" prefix="cd:sectionblock" method="range"/>
            </cd:keywords>
            <cd:keywords list="yes">
                <cd:constant type="cd:name"/>
                <cd:constant type="cd:name" prefix="cd:processor" method="apply"/>
            </cd:keywords>
            <cd:keywords optional="yes">
                <cd:constant type="cd:name"/>
                <cd:constant type="cd:name" prefix="cd:processor" method="apply"/>
            </cd:keywords>
        </cd:arguments>
    </cd:command>

    <!--

        <cd:command name="definestructureconversionset" level="style" category="counter" file="strc-ini.mkvi">
            <cd:arguments>
                <cd:keywords>
                    <cd:constant type="cd:name"/>
                    <cd:constant type="cd:name" prefix="cd:sectionblock" method="range"/>
                </cd:keywords>
                <cd:keywords list="yes">
                    <cd:constant type="cd:name"/>
                    <cd:constant type="cd:name" prefix="cd:processor" method="apply"/>
                </cd:keywords>
                <cd:keywords optional="yes">
                    <cd:constant type="cd:name"/>
                    <cd:constant type="cd:name" prefix="cd:processor" method="apply"/>
                </cd:keywords>
            </cd:arguments>
        </cd:command>

    -->

    <cd:command name="defineprefixset" level="style" category="counter" file="strc-ini.mkvi">
        <cd:arguments>
            <cd:keywords>
                <cd:constant type="cd:name"/>
                <cd:constant type="cd:name" prefix="cd:sectionblock" method="range"/>
            </cd:keywords>
            <cd:resolve name="keyword-section-list"/>
            <cd:resolve name="keyword-section-optional"/>
        </cd:arguments>
    </cd:command>

    <!--

        <cd:command name="definestructureprefixset" level="style" category="counter" file="strc-ini.mkvi">
            <cd:arguments>
                <cd:keywords>
                    <cd:constant type="cd:name"/>
                    <cd:constant type="cd:name" prefix="cd:sectionblock" method="range"/>
                </cd:keywords>
                <cd:resolve name="keyword-section-list"/>
                <cd:resolve name="keyword-section-optional"/>
            </cd:arguments>
        </cd:command>

    -->

</cd:interface>
