/*
 * SDK Pullenti Unitext, version 4.33, fabruary 2026. Copyright (c) 2013-2026, Pullenti. All rights reserved. 
 * Non-Commercial Freeware and Commercial Software. 
 * This class is generated using the converter UniSharping (www.unisharping.ru) from Pullenti C# project. 
 * The latest version of the code is available on the site www.pullenti.ru
 */

const Utils = require("./../../../unisharp/Utils");
const StringBuilder = require("./../../../unisharp/StringBuilder");

const SinglePropertyModifiers = require("./SinglePropertyModifiers");
const SinglePropertyValue = require("./SinglePropertyValue");

class StyleCollection {
    
    getIndexerItem(name) {
        return this.get(name);
    }
    
    constructor(_prls) {
        this.prls = null;
        this.prls = _prls;
    }
    
    toString() {
        let res = new StringBuilder();
        for (const prlSet of this.prls) {
            for (const prl of prlSet) {
                let s = SinglePropertyModifiers.getSprmName(prl.sprm.sprm);
                if (s !== null) 
                    res.append(s).append("; ");
            }
        }
        return res.toString();
    }
    
    getByUshort(sprm) {
        for (const prlSet of this.prls) {
            for (const prl of prlSet) {
                if (Utils.compareUnsigned(prl.sprm.sprm, sprm) == 0) 
                    return SinglePropertyValue.parseValue(sprm, prl.operand);
            }
        }
        return null;
    }
    
    get(name) {
        if (name === null) 
            throw new Error("name");
        let sprm = SinglePropertyModifiers.getSprmByName(name);
        for (const prlSet of this.prls) {
            for (const prl of prlSet) {
                if (Utils.compareUnsigned(prl.sprm.sprm, sprm) == 0) 
                    return SinglePropertyValue.parseValue(sprm, prl.operand);
            }
        }
        return null;
    }
    
    getAll(name) {
        if (name === null) 
            throw new Error("name");
        let sprm = SinglePropertyModifiers.getSprmByName(name);
        let res = new Array();
        for (const prlSet of this.prls) {
            for (const prl of prlSet) {
                if (Utils.compareUnsigned(prl.sprm.sprm, sprm) == 0) 
                    res.push(SinglePropertyValue.parseValue(sprm, prl.operand));
            }
        }
        return res;
    }
    
    getNames() {
        return null;
    }
    
    static static_constructor() {
        StyleCollection.PROPERTY_NAME_PREFIX = "sprm";
    }
}


StyleCollection.static_constructor();

module.exports = StyleCollection