'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

const __chunk_1 = require('./chunk-2755df65.js');

class Post {
    constructor(hostRef) {
        __chunk_1.registerInstance(this, hostRef);
    }
    componentDidLoad() {
        this.postRender();
    }
    componentDidUpdate() {
        this.postRender();
    }
    postRender() {
        let titleField = this.el.querySelector('.field--name-title');
        let bodyField = this.el.querySelector('.field--name-content');
        if (this.data.title)
            titleField.innerHTML = this.data.title.rendered;
        if (this.data.content) {
            bodyField.innerHTML = this.data.content.rendered;
        }
        else {
            bodyField.innerHTML = '';
        }
    }
    parsePost(post) {
        //console.log(post);
        // let type = post.type.split('--')[1];
        // switch (type) {
        //     case 'app':
        //         // this.postData = JSON.parse(post.field_json[0].value);
        //         break;
        //     case 'iframe':
        //         // code block
        //         break;
        //     case 'page':
        //         // code block
        //         break;
        //     default:
        //     // code block
        // }
        return post;
    }
    render() {
        if (this.dataJson) {
            var post = this.parsePost(JSON.parse(this.dataJson));
            this.data = post;
        }
        return (__chunk_1.h("article", { class: 'post post-type-' + post.type + ' clearfix', id: 'post-' + post.id }, __chunk_1.h("header", null, __chunk_1.h("h2", { class: "field field--name-title" })), __chunk_1.h("div", { class: "content clearfix" }, __chunk_1.h("div", { class: "field field--name-content" }), post.type == 'iframe' && post.url &&
            __chunk_1.h("div", { class: "field field--name-url" }, __chunk_1.h("ema-iframe", { src: post.url, width: post.width, height: post.height })))));
    }
    get el() { return __chunk_1.getElement(this); }
    static get style() { return ":root{--ema-color:#343a40;--ema-primary:#007bff;--ema-secondary:#6c757d;--ema-success:#28a745;--ema-info:#17a2b8;--ema-warning:#ffc107;--ema-danger:#dc3545;--ema-light:#f8f9fa;--ema-dark:#343a40;--ema-background:#fff;--ema-background-diap:rgba(29,29,29,0.97);--ema-border-color:#c5c9cd;--ema-border:1px solid #c5c9cd;--ema-border-radius:3px 3px 3px 3px;--ema-box-shadow:1px 1px 10px 1px #ccc;--ema-margin:0.25rem;--ema-margin-sm:0.5rem;--ema-margin-md:1rem;--ema-margin-lg:1.5rem;--ema-margin-xl:2rem;--ema-padding:0.25rem;--ema-padding-sm:0.5rem;--ema-padding-md:1rem;--ema-padding-lg:1.5rem;--ema-padding-xl:2rem;--ema-gray-100:#f8f9fa;--ema-gray-200:#e9ecef;--ema-gray-300:#dee2e6;--ema-gray-400:#ced4da;--ema-gray-500:#adb5bd;--ema-gray-600:#868e96;--ema-gray-700:#495057;--ema-gray-800:#343a40;--ema-gray-900:#212529}ema-post .node .field{margin-bottom:var(--ema-padding-md,1rem)}"; }
}

exports.ema_post = Post;
