!function(t,e){"use strict";class s{constructor(){this.reset()}reset(){return this.stroke=0,this.strokeColor="#000000",this.leading=0,this.lineHeight=0,this.letterSpacing=0,this.href=null,this}recover(){this!=s.EMPTY&&e.Pool.recover("HTMLExtendStyle",this.reset())}static create(){return e.Pool.getItemByClass("HTMLExtendStyle",s)}}s.EMPTY=new s,e.ClassUtils.regClass("laya.html.utils.HTMLExtendStyle",s),e.ClassUtils.regClass("Laya.HTMLExtendStyle",s);class i{constructor(){this.padding=i._PADDING,this.reset()}_getExtendStyle(){return this._extendStyle===s.EMPTY&&(this._extendStyle=s.create()),this._extendStyle}get href(){return this._extendStyle.href}set href(t){t!==this._extendStyle.href&&(this._getExtendStyle().href=t)}get stroke(){return this._extendStyle.stroke}set stroke(t){this._extendStyle.stroke!==t&&(this._getExtendStyle().stroke=t)}get strokeColor(){return this._extendStyle.strokeColor}set strokeColor(t){this._extendStyle.strokeColor!==t&&(this._getExtendStyle().strokeColor=t)}get leading(){return this._extendStyle.leading}set leading(t){this._extendStyle.leading!==t&&(this._getExtendStyle().leading=t)}get lineHeight(){return this._extendStyle.lineHeight}set lineHeight(t){this._extendStyle.lineHeight!==t&&(this._getExtendStyle().lineHeight=t)}set align(t){t in i.alignVDic&&(this._type&=~i._ALIGN,this._type|=i.alignVDic[t])}get align(){var t=this._type&i._ALIGN;return i.align_Value[t]}set valign(t){t in i.alignVDic&&(this._type&=~i._VALIGN,this._type|=i.alignVDic[t])}get valign(){var t=this._type&i._VALIGN;return i.vAlign_Value[t]}set font(t){for(var e=t.split(" "),s=0,i=e.length;s0&&(this.fontSize=parseInt(r),this.family=e[s+1],s++)}}get font(){return(this.italic?"italic ":"")+(this.bold?"bold ":"")+this.fontSize+"px "+(e.ILaya.Browser.onIPhone&&e.ILaya.Text.fontFamilyMap[this.family]||this.family)}set block(t){t?this._type|=i._CSS_BLOCK:this._type&=~i._CSS_BLOCK}get block(){return 0!=(this._type&i._CSS_BLOCK)}reset(){return this.ower=null,this._type=0,this.wordWrap=!0,this.fontSize=e.ILaya.Text.defaultFontSize,this.family=e.ILaya.Text.defaultFont,this.color="#000000",this.valign=i.VALIGN_TOP,this.padding=i._PADDING,this.bold=!1,this.italic=!1,this.align=i.ALIGN_LEFT,this.textDecoration=null,this.bgColor=null,this.borderColor=null,this._extendStyle&&this._extendStyle.recover(),this._extendStyle=s.EMPTY,this}recover(){e.Pool.recover("HTMLStyle",this.reset())}static create(){return e.Pool.getItemByClass("HTMLStyle",i)}inherit(t){var e,s,r,h;for(s=(r=i._inheritProps).length,e=0;e=0&&(this._type|=i._WIDTHAUTO,t=t.substr(0,e)),this._calculation("width",t))return;t=parseInt(t)}this.size(t,-1)}set height(t){if(this._type|=i._HEIGHT_SET,"string"==typeof t){if(this._calculation("height",t))return;t=parseInt(t)}this.size(-1,t)}heighted(t){return 0!=(this._type&i._HEIGHT_SET)}size(t,e){var s=this.ower,r=!1;-1!==t&&t!=s.width&&(this._type|=i._WIDTH_SET,s.width=t,r=!0),-1!==e&&e!=s.height&&(this._type|=i._HEIGHT_SET,s.height=e,r=!0),r&&s._layoutLater()}getLineElement(){return 0!=(this._type&i._LINE_ELEMENT)}setLineElement(t){t?this._type|=i._LINE_ELEMENT:this._type&=~i._LINE_ELEMENT}_enableLayout(){return 0==(this._type&i._DISPLAY_NONE)&&0==(this._type&i._ABSOLUTE)}get letterSpacing(){return this._extendStyle.letterSpacing}set letterSpacing(t){"string"==typeof t&&(t=parseInt(t+"")),t!=this._extendStyle.letterSpacing&&(this._getExtendStyle().letterSpacing=t)}cssText(t){this.attrs(i.parseOneCSS(t,";"))}attrs(t){if(t)for(var e=0,s=t.length;e1||(s[1]=s[2]=s[3]=s[0]),g[1]=[parseInt(s[0]),parseInt(s[1]),parseInt(s[2]),parseInt(s[3])];break;default:(g[0]=i._CSSTOVALUE[d])||(g[0]=d)}r.push(g)}}return r}static parseCSS(t,e){for(var s;null!=(s=i._parseCSSRegExp.exec(t));)i.styleSheets[s[1]]=i.parseOneCSS(s[2],";")}}i._CSSTOVALUE={"letter-spacing":"letterSpacing","white-space":"whiteSpace","line-height":"lineHeight","font-family":"family","vertical-align":"valign","text-decoration":"textDecoration","background-color":"bgColor","border-color":"borderColor"},i._parseCSSRegExp=new RegExp("([.#]\\w+)\\s*{([\\s\\S]*?)}","g"),i._inheritProps=["italic","align","valign","leading","letterSpacing","stroke","strokeColor","bold","fontWeight","fontSize","lineHeight","wordWrap","color"],i.ALIGN_LEFT="left",i.ALIGN_CENTER="center",i.ALIGN_RIGHT="right",i.VALIGN_TOP="top",i.VALIGN_MIDDLE="middle",i.VALIGN_BOTTOM="bottom",i.styleSheets={},i.ADDLAYOUTED=512,i._PADDING=[0,0,0,0],i._HEIGHT_SET=8192,i._LINE_ELEMENT=65536,i._NOWARP=131072,i._WIDTHAUTO=262144,i._BOLD=1024,i._ITALIC=2048,i._CSS_BLOCK=1,i._DISPLAY_NONE=2,i._ABSOLUTE=4,i._WIDTH_SET=8,i.alignVDic={left:0,center:16,right:32,top:0,middle:64,bottom:128},i.align_Value={0:"left",16:"center",32:"right"},i.vAlign_Value={0:"top",64:"middle",128:"bottom"},i._ALIGN=48,i._VALIGN=192,e.ClassUtils.regClass("laya.html.utils.HTMLStyle",i),e.ClassUtils.regClass("Laya.HTMLStyle",i);class r{constructor(){this.all=[],this.styleSheets=i.styleSheets}getElementById(t){return this.all[t]}setElementById(t,e){this.all[t]=e}}r.document=new r,e.ClassUtils.regClass("laya.html.dom.HTMLDocument",r),e.ClassUtils.regClass("Laya.HTMLDocument",r);class h{constructor(){this.rec=new e.Rectangle,this.reset()}reset(){return this.rec.reset(),this.href=null,this}recover(){e.Pool.recover("HTMLHitRect",this.reset())}static create(){return e.Pool.getItemByClass("HTMLHitRect",h)}}e.ClassUtils.regClass("laya.html.dom.HTMLHitRect",h),e.ClassUtils.regClass("Laya.HTMLHitRect",h);class l{}l.HTMLDivElement=null,l.HTMLImageElement=null,l.HTMLBrElement=null,l.HTMLDivParser=null,l.HTMLParse=null,l.HTMLElementType=null;class a{constructor(){this.elements=[],this.x=0,this.y=0,this.w=0,this.h=0,this.wordStartIndex=0,this.minTextHeight=99999,this.mWidth=0}updatePos(t,e,s,r,h,a,n){var o,d=0;this.elements.length>0&&(d=(o=this.elements[this.elements.length-1]).x+o.width-this.elements[0].x),n=n||this.h;var _,g=0;h===i.ALIGN_CENTER&&(g=(e-d)/2),h===i.ALIGN_RIGHT&&(g=e-d);for(var c=0,y=this.elements.length;c0&&w+H>m&&U.wordStartIndex>0){var R;R=U.elements.length-U.wordStartIndex+1,U.elements.length=U.wordStartIndex,s-=R,addLine();continue}d=!1,D+=_.width}H=_.width+_.style.letterSpacing,v=_.height,b=!1,(d=d||w+H>m)&&addLine(),U.minTextHeight=Math.min(U.minTextHeight,r.height)}else h=r._getCSSStyle(),g=r,o=h.padding,d=b||h.getLineElement(),H=g.width+o[1]+o[3]+h.letterSpacing,v=g.height+o[0]+o[2],b=h.getLineElement(),(d=d||w+H>m&&h.wordWrap)&&addLine();U.elements.push(r),U.h=Math.max(U.h,v),r.x=w,r.y=I,w+=H,U.w=w-u,U.y=I,f=Math.max(w+C,f)}else A||(w+=n.DIV_ELEMENT_PADDING),U.wordStartIndex=U.elements.length;if(I=U.y+U.h,x){var P=0,O=m;for(T&&t.width>0&&(O=t.width),s=0,c=M.length;st.height&&(t.height=I),[f,I]}}var o;n.DIV_ELEMENT_PADDING=0,e.ClassUtils.regClass("laya.html.utils.Layout",n),e.ClassUtils.regClass("Laya.Layout",n),(o=t.HTMLElementType||(t.HTMLElementType={}))[o.BASE=0]="BASE",o[o.IMAGE=1]="IMAGE";class d{constructor(){this.eletype=t.HTMLElementType.BASE,this._creates(),this.reset()}static formatURL1(t,s=null){if(!t)return"null path";if(s||(s=e.URL.basePath),t.indexOf(":")>0)return t;if(null!=e.URL.customFormat&&(t=e.URL.customFormat(t)),t.indexOf(":")>0)return t;var i=t.charAt(0);if("."===i)return e.URL._formatRelativePath(s+t);if("~"===i)return e.URL.rootPath+t.substring(1);if("d"===i){if(0===t.indexOf("data:image"))return t}else if("/"===i)return t;return s+t}_creates(){this._style=i.create()}reset(){if(this.URI=null,this.parent=null,this._style.reset(),this._style.ower=this,this._style.valign="middle",this._text&&this._text.words){var t,e,s,i=this._text.words;for(e=i.length,t=0;t-1;t--)this._children[t].destroy();this._children.length=0}}get style(){return this._style}_getWords(){if(!this._text)return null;var t=this._text.text;if(!t||0===t.length)return null;var s,i=this._text.words;if(i&&i.length===t.length)return i;null===i&&(this._text.words=i=[]),i.length=t.length;for(var r=this.style,h=r.font,l=0,a=t.length;l0||null!=this._getWords())&&t.block?(n.later(this),t._type|=i.ADDLAYOUTED):this.parent&&this.parent._layoutLater())}set x(t){this._x!=t&&(this._x=t,this.parentRepaint())}get x(){return this._x}set y(t){this._y!=t&&(this._y=t,this.parentRepaint())}get y(){return this._y}get width(){return this._width}set width(t){this._width!==t&&(this._width=t,this.repaint())}get height(){return this._height}set height(t){this._height!==t&&(this._height=t,this.repaint())}_setAttributes(t,e){switch(t){case"style":this.style.cssText(e);break;case"class":this.className=e;break;case"x":this.x=parseFloat(e);break;case"y":this.y=parseFloat(e);break;case"width":this.width=parseFloat(e);break;case"height":this.height=parseFloat(e);break;default:this[t]=e}}set href(t){this._style&&t!=this._style.href&&(this._style.href=t,this.repaint())}get href(){return this._style?this._style.href:null}formatURL(t){return this.URI?d.formatURL1(t,this.URI?this.URI.path:null):t}set color(t){this.style.color=t}set className(t){this.style.attrs(r.document.styleSheets["."+t])}drawToGraphic(t,e,s,i){e+=this.x,s+=this.y;var r,h,l,a=this.style;if(a.paddingLeft&&(e+=a.paddingLeft),a.paddingTop&&(s+=a.paddingTop),(null!=a.bgColor||a.borderColor)&&t.drawRect(e,s,this.width,this.height,a.bgColor,a.borderColor,1),this.renderSelfToGraphic(t,e,s,i),this._children&&this._children.length>0)for(h=this._children.length,r=0;r"+(s=s.replace(/
/g,"
"))+"").replace(p.spacePattern,p.char255);var r=e.Utils.parseXMLFromString(s);p._parseXML(t,r.childNodes[0].childNodes,i)}static _parseXML(t,e,s,i=null){var r,h;if(e.join||e.item)for(r=0,h=e.length;r0&&(a=p.getInstance(n))&&(t.addChild(a),a.innerTEXT=o.replace(p.char255AndOneSpacePattern," "));else if((o=e.textContent.replace(/^\s+|\s+$/g,"")).length>0){var _=t;if(t instanceof d&&t.innerTEXT&&t.innerTEXT.length>0){let e=p.getInstance("p");e&&(t.addChild(e),_=e)}_.innerTEXT=o.replace(p.char255AndOneSpacePattern," ")}return}if("#comment"==(n=e.nodeName.toLowerCase()))return;if(a=p.getInstance(n)){"p"==n?(t.addChild(p.getInstance("br")),a=t.addChild(a),t.addChild(p.getInstance("br"))):a=t.addChild(a),a.URI=s,a.href=i;var g=e.attributes;if(g&&g.length>0)for(r=0,h=g.length;r0&&this._setGraphicDirty()}_updateGraphicWork(){switch(this._repaintState){case 1:this._updateGraphic();break;case 2:this._refresh()}}_setGraphicDirty(){this.callLater(this._updateGraphicWork)}_doClears(){if(this._recList){var t,e=this._recList.length;for(t=0;t{var i=this._element.URI;this._element.URI=new e.URL(t),this.innerHTML=s,!i||(this._element.URI=i)}),s.load(t,e.Loader.TEXT)}}e.ClassUtils.regClass("laya.html.dom.HTMLIframeElement",T),e.ClassUtils.regClass("Laya.HTMLIframeElement",T),t.HTMLBrElement=_,t.HTMLDivElement=L,t.HTMLDivParser=y,t.HTMLDocument=r,t.HTMLElement=d,t.HTMLExtendStyle=s,t.HTMLHitRect=h,t.HTMLIframeElement=T,t.HTMLImageElement=u,t.HTMLLinkElement=c,t.HTMLParse=p,t.HTMLStyle=i,t.HTMLStyleElement=g,t.IHtml=l,t.Layout=n,t.LayoutLine=a}(window.Laya=window.Laya||{},Laya);