";else{r+=">";let s=!1;for(let o=0;o"}}}else{const t=e.nodeValue.trim();t&&(r+=t)}};const o=(new DOMParser).parseFromString(t,"text/xml");if(o.getElementsByTagName("parsererror").length>0)return void window.showToast(e.xmlErrorMsg||e.xmlFormatError,2500);new XMLSerializer;let r="";n(o.documentElement,0),r=r.trim(),h.dispatch({changes:{from:0,to:h.state.doc.length,insert:r}}),window.showToast(e.xmlValidMsg||e.xmlFormatCorrect,2500)}catch(t){console.error("格式化XML失败:",t),window.showToast(e.xmlErrorMsg||e.xmlFormatError,2500)}}function x(){const t=g.state.doc.toString();t.trim()&&navigator.clipboard.writeText(t).then((()=>{window.showToast(e.copySuccess||e.copySuccess,2500)})).catch((t=>{console.error(e.copyFailure,t)}))}function v(){h.dispatch({changes:{from:0,to:h.state.doc.length,insert:""}}),g.dispatch({changes:{from:0,to:g.state.doc.length,insert:""}})}function M(e,t){if(!e||!t)return;const n=e.dom.closest(".cp");n&&(n.style.height="");const o=t.split("\n").length,r=Math.min(Math.max(o,10),30);if(n){const e=20*r+50;n.style.height=`${e}px`}e.requestMeasure()}function T(){const e=h.state.doc.toString();if(!e.trim())return void g.dispatch({changes:{from:0,to:g.state.doc.length,insert:""}});y(window.stringToBase64(e))}!function(){try{p(),function(){let e,t;const n=document.querySelector(".cp");r.addEventListener("mousedown",(function(o){f=!0,e=o.clientY,t=parseInt(getComputedStyle(n).height,10),document.body.style.cursor="ns-resize",o.preventDefault(),w&&(w=!1,m&&(m.checked=!1))})),document.addEventListener("mousemove",(function(o){if(!f)return;const r=t+(o.clientY-e);r>=150&&r<=800&&(n.style.height=r+"px")})),document.addEventListener("mouseup",(function(e){f&&(f=!1,document.body.style.cursor="",h&&h.requestMeasure(),g&&g.requestMeasure())}))}(),s&&s.addEventListener("click",S),c&&c.addEventListener("click",T),i&&i.addEventListener("click",x),d&&d.addEventListener("click",v),document.querySelectorAll(".cu").forEach((e=>{const t=e.querySelector(".cw");let n;e.addEventListener("mouseenter",(function(){t&&(clearTimeout(n),t.classList.add("show"),n=setTimeout((()=>{t.classList.remove("show")}),1e3))}))})),m&&m.addEventListener("change",(function(){if(w=this.checked,w){const e=g.state.doc.toString();M(g,e)}}))}catch(t){console.error(e.initFailure,t)}}()}))