/**
 * 
 * @param {event} e
 * @param {number|undefined} output
 * @param {string[]|{pattern: string[],output: number}} inItem
 * @param {string|{prefix:string,id:string}} id 
 */
function consturctRecipeShaped(e, output, inItem, id)
{
    console.log(id)
    if(id != null && typeof(id) != "object") id = {
        prefix: "rd",
        id: id
    }
    /**
     * @prop {pattern: string[],output: number}
     */
    let _item = {};
    if(inItem.pattern == undefined)
        _item.pattern = inItem;
    else _item.pattern = inItem.pattern;
    if(inItem.output  == undefined)
        _item.output = 1;
    else _item.output = inItem.output;

    const ids = 'ABCDEFGHIJKLMNOPQRSTUXYZabcdefghijqlmnopqrstuxyz0123456789';
    let items = {};
    let keyItem = {};
    let pattern = [];
    let i = 0;
    let r = 0;

    for(let row of _item.pattern)
    {
        pattern[r] = '';
        for(let cItem of row)
        {
            if(cItem == null)
            {
                pattern[r] += ' ';
                continue;
            }
            let key = keyItem[cItem];
            if(key === undefined) {
                key = ids[i++];
                items[key] = cItem;
                keyItem[cItem] = key;
            }
            pattern[r] += key;
        }
        r++;
    }
    
    let item = e.shaped(`${_item.output}x ${output}`, pattern, items);
    if(id != null) {
        let myId = `${id.prefix?id.prefix:''}:${id.id.replace(':','/')}`;
        item.id(myId);
    }
}