import{__decorate}from"tslib";import{SuperComponent,wxComponent}from"../common/src/index";import config from"../common/config";import props from"./props";const{prefix:prefix}=config,name=`${prefix}-chat-content`;let ChatContent=class extends SuperComponent{constructor(){super(...arguments),this.options={multipleSlots:!0},this.properties=props,this.data={classPrefix:name,textInfo:""},this.observers={content(){this.setTextInfo()}},this.methods={getEscapeReplacement:t=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"}[t]),escape(t,e=!1){const s=/[&<>"']/,o=new RegExp(s.source,"g"),n=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,a=new RegExp(n.source,"g");if(e){if(s.test(t))return t.replace(o,this.data.getEscapeReplacement)}else if(n.test(t))return t.replace(a,this.data.getEscapeReplacement);return t},setTextInfo(){"text"===this.properties.content.type||"error"===this.properties.status?this.setData({textInfo:this.escape(this.properties.content.data||"")}):this.setData({textInfo:this.properties.content.data})}},this.lifetimes={created(){this.data.getEscapeReplacement=this.getEscapeReplacement.bind(this),this.data.escape=this.escape.bind(this)},attached(){this.setTextInfo()},detached(){}}}};ChatContent=__decorate([wxComponent()],ChatContent);export default ChatContent;