import{LitElement as t,html as e,css as i}from"../../../lit/index.js";import"../json-outline-schema.js";import{wipeSlot as s,valueMapTransform as r}from"../../utils/utils.js";import"../../dynamic-import-registry/dynamic-import-registry.js";class JosRender extends t{static get tag(){return"jos-render"}constructor(){super(),this.registry=globalThis.DynamicImportRegistry.requestAvailability(),globalThis.WCGlobalBasePath&&(this.registry.basePath=globalThis.WCGlobalBasePath),this.items=[]}static get styles(){return[i`
        :host {
          display: block;
        }
        .children {
          display: block;
          margin: 16px auto;
        }
        .children ::slotted(*) {
          display: inline-flex;
          margin: var(--jos-render-margin, 8px);
          padding: var(--jos-render-padding, 8px);
        }
      `]}static get properties(){return{source:{type:String},map:{type:Object},items:{type:Array}}}render(){return e`
      <div class="children">
        <slot></slot>
      </div>
    `}updated(t){t.forEach((async(t,e)=>{if("source"==e){let t=globalThis.JSONOutlineSchema.requestAvailability();await t.load(this[e])&&(this.items=[...t.items])}"map"==e&&this.map.path&&this.map.tag&&(this.registry.register({tag:this.map.tag,path:this.map.path}),this.registry.loadDefinition(this.map.tag),this.items.length>0&&this.renderItems(this.items)),"items"==e&&this.renderItems(this.items)}))}renderItems(t){if(this.map&&this.map.properties){s(this),r(t,this.map.properties).forEach((t=>{let e=globalThis.document.createElement(this.map.tag);Object.assign(e,t),this.appendChild(e)}))}}}customElements.define(JosRender.tag,JosRender);export{JosRender};