import{a as t,c}from"./chunk-ZVB66NUS.js";import"./chunk-HVV3ARZI.js";var d=class{static Parse(r){if(typeof DOMParser<"u"){let n=new DOMParser().parseFromString(r,"application/xml");if(n.documentElement.nodeName=="parsererror")throw new Error("XML parsing error");return n}return null}},i=class{render(r){let n=r;return n?t("div",{class:"comment"},"<--\xA0",n.nodeValue.trim(),"\xA0-->"):null}},a=class{render(r){if(!r)return null;let n=unescape(`<![CDATA[${r.textContent.trim()}]]>`);return t("ul",null,t("li",null,t("div",null,n)))}},u=class{constructor(r=new Array){this.renderers=r}renderNode(r){let n=this.getRenderer(r);return n?n.render(r):null}getRenderer(r){if(!r)return null;if(r.nodeName.toLowerCase()==="#comment"){let n=this.renderers.find(l=>l instanceof i);return n||(n=new i,this.renderers.push(n)),n}if(r.nodeName.toLowerCase()==="#cdata-section"){let n=this.renderers.find(l=>l instanceof a);return n||(n=new a,this.renderers.push(n)),n}return null}},m="code{margin:.1rem .25rem 1rem .25rem;padding:0;color:#767676;font-family:monospace, monospace;text-shadow:0 1px #fff;direction:ltr;text-align:left;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.2;-moz-tab-size:2;-o-tab-size:2;tab-size:2;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none}code ul{list-style-type:none;margin:0;padding-left:1rem}code div.element{font-weight:bold;color:darkred;display:inline-block}code div.element-content{font-weight:normal;display:inline-block}code span.attr{font-weight:bold;color:#535353}code span.attr-value{font-weight:normal}code div.comment{color:darkgreen}",h=class{constructor(e){c(this,e),this.nodeRenderer=new u}componentDidLoad(){}get Xml(){return this.xml}set Xml(e){this.xml=e}toArray(e){let r=[];for(let n=0;n<e.length;n++)r.push(e[n]);return r}prepareXml(){return d.Parse(this.xml.trim())}renderAttribute(e){return t("span",null,"\xA0",t("span",{class:"attr"},e.name,'="',t("span",{class:"attr-value"},e.value),'"'))}renderNodeValue(e){if(!e)return null;let r=unescape(e.trim());return r.length===0?null:r.length>150?t("ul",null,t("li",null,r)):t("span",null,r)}renderNode(e){return this.nodeRenderer.renderNode(e)}renderElement(e){if(!e)return null;let r=this.toArray(e.attributes),n=this.toArray(e.childNodes),l=this.toArray(e.children),s=e.firstChild?e.firstChild.nodeValue:null;return s=s?s.trim():null,t("ul",null,t("li",null,t("div",{class:"element"},"<",e.nodeName,r.map(o=>this.renderAttribute(o)),">"),t("div",{class:"element-content"},this.renderNodeValue(s)),l.map(o=>this.renderElement(o)),n.map(o=>this.renderNode(o)),t("div",{class:"element"},"</",e.nodeName,">")))}render(){if(this.xml===null||this.xml===void 0||this.xml.length===0)return null;let e=null;try{e=this.prepareXml()}catch(r){console.error(r)}return!e||!e.documentElement.childNodes?t("code",null,this.xml):t("p",null,t("code",null,this.renderElement(e.documentElement)))}};h.style=m;export{h as xml_viewer_component};
