"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.commentField = commentField;
const solid_logic_1 = require("solid-logic");
const ns_1 = __importDefault(require("../../ns"));
const fieldFunction_1 = require("./fieldFunction");
const fieldParams_1 = require("./fieldParams");
const store = solid_logic_1.solidLogicSingleton.store;
/**
 * A [[FieldFunction]] for a simple comment box. It will look for
 * the first (form, ns.ui('contents'), ?) triple it can find in
 * store and use the value of the object of that triple as
 * the comment text.
 *
 * @param dom The DOM
 * @param container If set, the result will be appended to it as a child
 * @param already Unused
 * @param subject Unused
 * @param form RDF node with `ns.ui('contents')` attribute
 * @param _doc Unused
 * @param _callbackFunction Unused
 *
 * @returns a DOM element containing the comment.
 */
function commentField(dom, container, already, subject, form, _doc, _callbackFunction) {
    const kb = store;
    let contents = kb.any(form, ns_1.default.ui('contents'));
    if (!contents) {
        contents = 'Error: No contents in comment field.';
    }
    const uri = (0, fieldFunction_1.mostSpecificClassURI)(form);
    let params = fieldParams_1.fieldParams[uri];
    if (params === undefined) {
        params = {};
    } // non-bottom field types can do this
    const box = dom.createElement('div');
    if (container)
        container.appendChild(box);
    const p = box.appendChild(dom.createElement(params.element || 'p'));
    p.textContent = contents;
    let style = kb.any(form, ns_1.default.ui('style'));
    if (style === undefined) {
        style = params.style ? params.style : '';
    }
    if (style)
        p.setAttribute('style', style);
    return box;
}
//# sourceMappingURL=comment.js.map