/**
 * Copyright 2019 Penn State University
 * @license Apache-2.0, see License.md for full text.
 */
import{LitElement as e,html as t,css as i}from"../../../lit/index.js";import{SimplePickerBehaviors as s}from"../simple-picker.js";import{IntersectionObserverMixin as o}from"../../intersection-element/lib/IntersectionObserverMixin.js";class SimpleEmojiPicker extends(o(s(e))){static get styles(){return[super.styles,i`
        simple-picker-option:not([part="sample-option"]) {
          justify-content: space-around;
          --simple-picker-option-size: 30px;
          font-size: 18px;
          text-align: left;
          line-height: 30px;
          width: 40px;
          height: 30px;
        }
        .row {
          width: auto;
        }
        simple-picker-option[part="sample-option"] {
          --simple-picker-option-size: unset;
        }
        #icon {
          margin-left: calc(-0.125 * var(--simple-picker-icon-size, 16px));
        }
      `]}static get properties(){return{...super.properties,emojiTypes:{type:Array,attribute:"emoji-types"}}}static get tag(){return"simple-emoji-picker"}constructor(){super(),this.emojiTypes=["emotions","people","nature","food","travel","activities","objects","symbols","flags"],this.icon="editor:insert-emoticon",this.label="Emoji",this.titleAsHtml=!0}firstUpdated(e){super.firstUpdated&&super.firstUpdated(e);let t=[{alt:null,icon:this.icon,value:null}];t=this._setPickerOptions(t),this.options=t}updated(e){super.updated(e),e.has("elementVisible")&&this.elementVisible&&import("./SimplePickerEmojis.js").then((()=>{let e=[{alt:null,icon:this.icon,value:null}];this.emojiTypes.forEach((t=>globalThis.SimplePickerEmojis[t].forEach((t=>e.push(t))))),e=this._setPickerOptions(e),this.options=e}))}render(){return t`${this.elementVisible?super.render():t``}`}_setPickerOptions(e=this.options||[]){let t=[],i=Math.sqrt(e.length)<11?Math.ceil(Math.sqrt(e.length)):10;return e.forEach(((e,s)=>{let o=Math.floor(s/i),r=s-o*i;t[o]||(t[o]=[]),t[o][r]=e})),t}_setSelectedOption(){this.options.length>1&&super._setSelectedOption()}}customElements.define(SimpleEmojiPicker.tag,SimpleEmojiPicker);export{SimpleEmojiPicker};