'use strict';

const assert = require('assert');

const BemEntityName = require('@bem/entity-name');

module.exports = class BemCell {
    /**
     * @param {object} obj — representation of cell.
     * @param {BemEntityName} obj.entity — representation of entity name.
     * @param {string} [obj.tech] - tech of cell.
     * @param {string} [obj.layer] - layer of cell.
     */
    constructor(obj) {
        assert(obj && obj.entity, 'Required `entity` field');
        assert(BemEntityName.isBemEntityName(obj.entity), 'The `entity` field should be an instance of BemEntityName');

        this._entity = obj.entity;
        this._layer = obj.layer;
        this._tech = obj.tech;
    }

    /**
     * Returns the name of entity.
     *
     * @example
     * const BemCell = require('@bem/cell');
     * const BemEntityName = require('@bem/entity-name');
     *
     * const cell = new BemCell({
     *     entity: new BemEntityName({ block: 'button', elem: 'text' })
     * });
     *
     * cell.entity; // ➜ BemEntityName { block: 'button', elem: 'text' }
     *
     * @returns {BemEntityName} name of entity.
     */
    get entity() { return this._entity; }

    /**
     * Returns the tech of cell.
     *
     * @example
     * const BemCell = require('@bem/cell');
     * const BemEntityName = require('@bem/entity-name');
     *
     * const cell = new BemCell({
     *     entity: new BemEntityName({ block: 'button', elem: 'text' }),
     *     tech: 'css'
     * });
     *
     * cell.tech; // ➜ css
     *
     * @returns {string} tech of cell.
     */
    get tech() { return this._tech; }

    /**
     * Returns the layer of this cell.
     *
     * @example
     * const BemCell = require('@bem/cell');
     * const BemEntityName = require('@bem/entity-name');
     *
     * const cell = new BemCell({
     *     entity: new BemEntityName({ block: 'button', elem: 'text' }),
     *     layer: 'desktop'
     * });
     *
     * cell.layer; // ➜ desktop
     *
     * @returns {string} layer of cell.
     */
    get layer() { return this._layer; }
};

@@ -2065,12 +2065,843 @@
 layer; %7D
+%0A%0A    /**%0A     * Returns the identifier of this cell.%0A     *%0A     * Important: should only be used to determine uniqueness of cell.%0A     *%0A     * @example%0A     * const BemCell = require('@bem/cell');%0A     * const BemEntityName = require('@bem/entity-name');%0A     *%0A     * const cell = new BemCell(%7B%0A     *     entity: new BemEntityName(%7B block: 'button', elem: 'text' %7D),%0A     *     tech: 'css',%0A     *     layer: 'desktop'%0A     * %7D);%0A     *%0A     * cell.id; // %E2%9E%9C %22button__text@desktop.css%22%0A     *%0A     * @returns %7Bstring%7D identifier of cell.%0A     */%0A    get id() %7B%0A        if (this._id) %7B%0A            return this._id;%0A        %7D%0A%0A        const layer = this._layer ? %60@$%7Bthis._layer%7D%60 : '';%0A        const tech = this._tech ? %60.$%7Bthis._tech%7D%60 : '';%0A%0A        this._id = %60$%7Bthis._entity%7D$%7Blayer%7D$%7Btech%7D%60;%0A%0A        return this._id;%0A    %7D
 %0A%7D;%0A

add id field