const c=function(t,o){if(o=o||{},!(this instanceof c))return new c(t,o);this.conf={styleStr:"",setDomHeightArr:[],echartDomArr:[],printBeforeFn:null,printDoneCallBack:null};for(const n in this.conf)n&&o.hasOwnProperty(n)&&(this.conf[n]=o[n]);typeof t=="string"?this.dom=document.querySelector(t):this.dom=this.isDOM(t)?t:t.$el,this.conf.setDomHeightArr&&this.conf.setDomHeightArr.length&&this.setDomHeight(this.conf.setDomHeightArr),this.init()};c.prototype={init:function(){const t=this.getStyle()+this.getHtml();this.writeIframe(t)},extendOptions:function(t,o){for(const n in o)t[n]=o[n];return t},getStyle:function(){let t="";const o=document.querySelectorAll("style,link");for(let n=0;n.no-print{display:none;}${this.conf.styleStr}`,t},getHtml:function(){const t=document.querySelectorAll("input"),o=document.querySelectorAll("select"),n=document.querySelectorAll("textarea");for(let e=0;e{i.toPrint(o),setTimeout(function(){document.body.removeChild(e),i.conf.printDoneCallBack&&i.conf.printDoneCallBack()},100)})}},drawEchartImg(t){return new Promise(o=>{this.conf.echartDomArr&&this.conf.echartDomArr.length>0&&this.conf.echartDomArr.forEach(n=>{const e=t.querySelector("#"+n.$el.id),r=new Image,i=e.offsetWidth+"px",s=e.offsetHeight+"px";r.style.width=i,r.style.height=s,r.src=n.imgSrc,e.innerHTML="",e.appendChild(r)}),o()})},toPrint:function(t){try{setTimeout(function(){t.focus();try{t.document.execCommand("print",!1,null)||t.print()}catch{t.print()}t.close()},10)}catch(o){console.error(o)}},isDOM:typeof HTMLElement=="object"?function(t){return t instanceof HTMLElement}:function(t){return t&&typeof t=="object"&&t.nodeType===1&&typeof t.nodeName=="string"},setDomHeight(t){t&&t.length&&t.forEach(o=>{document.querySelectorAll(o).forEach(e=>{e.style.height=e.offsetHeight+"px"})})}};export{c as P};