function choiceParse(choices, sessionData) {

    return Object.entries(choices).flatMap(choice => {
        var index = choice[0];
        var text = choice[1].text;

        var choiceContainer = {
            text: text,
            index: index
        };

        /* Attempt to parse the interface syntax, returning the choice text
         * unaltered if it did not contain an interface call
         */
        var parse = parsing.parseInterface(text);
        if (parse === undefined) {
            return [choiceContainer];
        }

        /* Handle a hooks interface call, parsing out additional information
         * such as the hook to create, or whether to display the choice to the
         * user via choicetext
         */
        if (parse.interface === "Hooks") {
            var dParse = parsing.parseAltText(parse.data, { data: 'hookname', alttext: 'choicetext' });
            var hook = {
                name: dParse?.hookname ?? parse.data,
                fn: (sessionData, index) => FoundryInk.continueSession(sessionData, index)
            };

            choiceContainer.text = dParse?.choicetext ?? parse.data;
            choiceContainer.hook = hook;
            Hooks.once(hook.name, hook.fn);
        }

        /* When hooks are registered with no alt text, alert the developer that
         * a choice won't appear.
         */
        if (dParse === undefined) {
            console.warn(FoundryInk.i18n('templates.issue', {
                header: FoundryInk.i18n('title'),
                cause: 'Hook parsing',
                body: FoundryInk.i18n('warnings.no-choicetext', {
                    name: parse.data
                })
            }));

            return [];
        }

        return [choiceContainer];
    });
}
/* parses out scripting syntax from choices */
parses out scripting syntax from choices
parses out scripting syntax from choices
function choiceParse(choices, sessionData) {
    return Object.entries(choices).flatMap(choice => {
        var index = choice[0];
        var text = choice[1].text;
        var choiceContainer = {
            text: text,
            index: index
        };
        var parse = parsing.parseInterface(text);
        if (parse === undefined) {
            return [choiceContainer];
        }
        if (parse.interface === "Hooks") {
            var dParse = parsing.parseAltText(parse.data, { data: 'hookname', alttext: 'choicetext' });
            var hook = {
                name: dParse?.hookname ?? parse.data,
                fn: (sessionData, index) => FoundryInk.continueSession(sessionData, index)
            };
            choiceContainer.text = dParse?.choicetext ?? parse.data;
            choiceContainer.hook = hook;
            Hooks.once(hook.name, hook.fn);
        }
        if (dParse === undefined) {
            console.warn(FoundryInk.i18n('templates.issue', {
                header: FoundryInk.i18n('title'),
                cause: 'Hook parsing',
                body: FoundryInk.i18n('warnings.no-choicetext', {
                    name: parse.data
                })
            }));
            return [];
        }
        return [choiceContainer];
    });
}
function choiceParse ( choices , sessionData ) { return Object . entries ( choices ) . flatMap ( choice => { var index = choice [ 0 ] ; var text = choice [ 1 ] . text ; var choiceContainer = { text : text , index : index } ; var parse = parsing . parseInterface ( text ) ; if ( parse === undefined ) { return [ choiceContainer ] ; } if ( parse . interface === "Hooks" ) { var dParse = parsing . parseAltText ( parse . data , { data : 'hookname' , alttext : 'choicetext' } ) ; var hook = { name : dParse ?. hookname ?? parse . data , fn : ( sessionData , index ) => FoundryInk . continueSession ( sessionData , index ) } ; choiceContainer . text = dParse ?. choicetext ?? parse . data ; choiceContainer . hook = hook ; Hooks . once ( hook . name , hook . fn ) ; } if ( dParse === undefined ) { console . warn ( FoundryInk . i18n ( 'templates.issue' , { header : FoundryInk . i18n ( 'title' ) , cause : 'Hook parsing' , body : FoundryInk . i18n ( 'warnings.no-choicetext' , { name : parse . data } ) } ) ) ; return [ ] ; } return [ choiceContainer ] ; } ) ; }
parses out scripting syntax from choices
parses out scripting syntax from choices
/* Attempt to parse the interface syntax, returning the choice text
         * unaltered if it did not contain an interface call
         */ /* Handle a hooks interface call, parsing out additional information
         * such as the hook to create, or whether to display the choice to the
         * user via choicetext
         */ /* When hooks are registered with no alt text, alert the developer that
         * a choice won't appear.
         */