const e=window.Ema.h;import"./chunk-de721f0a.js";import"./chunk-237a2f57.js";import{e as t,k as s}from"./chunk-f41c48db.js";import{a as i}from"./chunk-628d443f.js";class a{constructor(){this.app=i.instance}componentWillLoad(){this.data={title:"@ema/components"}}componentDidLoad(){this.postRender()}componentDidUpdate(){this.postRender()}iframeLoaded(e){console.log(e.detail)}postRender(){t.fadeIn(this.el.querySelector(".jumbotron"),350,1400)}render(){return e("div",{class:"text-center"},e("ema-svg",{src:"../assets/sketch-index/home-content/images/home-content.svg","data-json":JSON.stringify(this.data),class:"img-responsive"}),e("div",{class:"jumbotron pt-3 pb-3 hidden"},e("h5",null,"webcomponents"),e("ul",{class:"list-inline"},this.app.components.map(t=>e("li",{class:"list-inline-item"},e("ema-route-link",{url:"/components/"+t.tag},"<"+t.tag+">"))))))}static get is(){return"ema-app-home"}static get properties(){return{data:{state:!0},el:{elementRef:!0}}}static get listeners(){return[{name:"iframeLoaded",method:"iframeLoaded"}]}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-app-home .jumbotron{color:#868e96;border-top:1px solid #c5c9cd;border-bottom:1px solid #c5c9cd;padding-left:3rem;padding-right:3rem}ema-app-home .jumbotron li{font-size:.86rem;padding:.25rem .33333rem}"}}class l{constructor(){this.type="template"}componentDidLoad(){}componentDidUpdate(){}async loadSvg(){this.loading=!0;const e=await fetch(`${this.src}`).then(e=>e.text()).catch(e=>console.error("Error:",e));return this.loading=!1,e}parseSvg(e){let t=s;this._svg=e,e=e.replace("]>",""),e=t.replaceAll(e,"{{ ","{{"),e=t.replaceAll(e,"{{  ","{{"),e=t.replaceAll(e," }}","}}"),e=t.replaceAll(e,"  }}","}}"),this.data&&Object.keys(this.data).forEach(s=>{e=t.replaceAll(e,"{{"+s+"}}",this.data[s])}),this.svgResult=e,setTimeout(t=>{this.el.querySelector(".embedded").innerHTML=e,setTimeout(e=>{this.el.querySelector("svg")&&(this._svgElement=this.el.querySelector("svg"),this.renderSvg())},40),this.getElements()},20)}async getElements(){this.elements=[];let e=["Shape","Oval","Rectangle","Line","Group"],s=this.el.querySelectorAll("*");return Array.prototype.forEach.call(s,s=>{if(t.getAttributes(s).id){let i=t.getAttributes(s).id,a=!1;e.forEach(e=>{i.match(e)&&(a=!0)}),a||(i.match("btn-")&&(s.style.cursor="pointer",s.style.opacity="0"),this.elements.push({id:i,el:s}))}}),this.setClickHandlers(),this.elements}svgElementClickHandler(e){let t;e.stopPropagation(),this.elements.forEach(s=>{s.el===e.target&&(t=s)}),t&&this.svgElementClick.emit(t)}setClickHandlers(){this.elements.forEach(e=>{document.getElementById(e.id).addEventListener("click",e=>{this.svgElementClickHandler(e)}),e.id.match("btn-")})}renderSvg(){const e=this._svgElement,t=!(-1===this.el.className.indexOf("img-responsive"));let s,i,a;if(e.getAttribute("viewBox")&&(s=e.getAttribute("viewBox")),s&&(i=s.split(" ")[2],a=s.split(" ")[3],!1===t)){let t;this.el.style.width=i+"px",this.el.style.maxWidth=i+"px",this.el.style.height=a+"px",this.el.style.maxHeight=a+"px",e.style.width=i+"px",e.style.maxWidth=i+"px",e.style.height=a+"px",e.style.maxHeight=a+"px",(t=document.createAttribute("width")).value=i,e.setAttributeNode(t),(t=document.createAttribute("height")).value=a,e.setAttributeNode(t)}}render(){return this.dataJson&&(this.data=JSON.parse(this.dataJson)),this.src&&this.loadSvg().then(e=>{this.parseSvg(e)}),e("div",null,e("div",{class:"svg-container embedded"}))}static get is(){return"ema-svg"}static get properties(){return{data:{state:!0},dataJson:{type:"Any",attr:"data-json"},el:{elementRef:!0},getElements:{method:!0},src:{type:String,attr:"src"},svgResult:{state:!0},type:{type:String,attr:"type"}}}static get events(){return[{name:"svgElementClick",method:"svgElementClick",bubbles:!0,cancelable:!0,composed:!0}]}}export{a as EmaAppHome,l as EmaSvg};