"use strict";var e=require("../../common/vendor.js"),t=require("./parser.js"),i=require("./editable/index.js");require("./editable/config.js");const n=[i.Editable],o={name:"mp-html",data:()=>({tooltip:null,slider:null,nodes:[]}),props:{editable:Boolean,placeholder:String,containerStyle:{type:String,default:""},content:{type:String,default:""},copyLink:{type:[Boolean,String],default:!0},domain:String,errorImg:{type:String,default:""},lazyLoad:{type:[Boolean,String],default:!1},loadingImg:{type:String,default:""},pauseVideo:{type:[Boolean,String],default:!0},previewImg:{type:[Boolean,String],default:!0},scrollTable:[Boolean,String],selectable:[Boolean,String],setTitle:{type:[Boolean,String],default:!0},showImgMenu:{type:[Boolean,String],default:!0},tagStyle:Object,useAnchor:[Boolean,Number]},emits:["load","ready","imgtap","linktap","play","error"],components:{node:()=>"./node/node.js"},watch:{editable(e){this.setContent(e?this.content:this.getContent()),e||this._maskTap()},content(e){this.setContent(e)}},created(){this.plugins=[];for(let e=n.length;e--;)this.plugins.push(new n[e](this))},mounted(){!this.content&&!this.editable||this.nodes.length||this.setContent(this.content)},beforeDestroy(){this._hook("onDetached"),clearInterval(this._timer)},methods:{_containTap(){this._lock||this.slider||(this._edit=void 0,this._maskTap())},_tooltipTap(e){this._tooltipcb(e.currentTarget.dataset.i),this.$set(this,"tooltip",null)},_sliderChanging(e){this._slideringcb(e.detail.value)},_sliderChange(e){this._slidercb(e.detail.value)},in(e,t,i){e&&t&&i&&(this._in={page:e,selector:t,scrollTop:i})},navigateTo(t,i){return new Promise(((n,o)=>{if(!this.useAnchor)return void o(Error("Anchor is disabled"));i=i||parseInt(this.useAnchor)||0;let s=" ";s=">>>";const l=e.index.createSelectorQuery().in(this._in?this._in.page:this).select((this._in?this._in.selector:"._root")+(t?`>>>#${t}`:"")).boundingClientRect();this._in?l.select(this._in.selector).scrollOffset().select(this._in.selector).boundingClientRect():l.selectViewport().scrollOffset(),l.exec((t=>{if(!t[0])return void o(Error("Label not found"));const s=t[1].scrollTop+t[0].top-(t[2]?t[2].top:0)+i;this._in?this._in.page[this._in.scrollTop]=s:e.index.pageScrollTo({scrollTop:s,duration:300}),n()}))}))},getText(e){let t="";return function e(i){for(let n=0;n"0"&&o.name[1]<"7";i&&t&&"\n"!==t[t.length-1]&&(t+="\n"),o.children&&e(o.children),i&&"\n"!==t[t.length-1]?t+="\n":"td"!==o.name&&"th"!==o.name||(t+="\t")}}}(e||this.nodes),t},getRect(){return new Promise(((t,i)=>{e.index.createSelectorQuery().in(this).select("#_root").boundingClientRect().exec((e=>e[0]?t(e[0]):i(Error("Root label not found"))))}))},pauseMedia(){for(let e=(this._videos||[]).length;e--;)this._videos[e].pause()},setContent(e,i){i&&this.imgList||(this.imgList=[]);const n=new t.Parser(this).parse(e);let o;this.$set(this,"nodes",i?(this.nodes||[]).concat(n):n),this._videos=[],this.$nextTick((()=>{this._hook("onLoad"),this.$emit("load")})),clearInterval(this._timer),this._timer=setInterval((()=>{this.getRect().then((e=>{e.height===o&&(this.$emit("ready",e),clearInterval(this._timer)),o=e.height})).catch((()=>{}))}),350)},_hook(e){for(let t=n.length;t--;)this.plugins[t][e]&&this.plugins[t][e]()}}};if(!Array){e.resolveComponent("node")()}var s=e._export_sfc(o,[["render",function(t,i,n,o,s,l){return e.e({a:!s.nodes[0]},s.nodes[0]?{b:e.p({childs:s.nodes,opts:[n.lazyLoad,n.loadingImg,n.errorImg,n.showImgMenu,n.selectable,n.editable,n.placeholder,"nodes"],name:"span"})}:{},{c:s.tooltip},s.tooltip?{d:e.f(s.tooltip.items,((t,i,n)=>({a:e.t(t),b:i,c:i,d:e.o(((...e)=>l._tooltipTap&&l._tooltipTap(...e)),i)}))),e:e.s("top:"+s.tooltip.top+"px")}:{},{f:s.slider},s.slider?{g:s.slider.value,h:s.slider.min,i:s.slider.max,j:e.o(((...e)=>l._sliderChanging&&l._sliderChanging(...e))),k:e.o(((...e)=>l._sliderChange&&l._sliderChange(...e))),l:e.s("top:"+s.slider.top+"px")}:{},{m:e.n((n.selectable?"_select ":"")+"_root"),n:e.s((n.editable?"min-height:200px;":"")+n.containerStyle),o:e.o(((...e)=>l._containTap&&l._containTap(...e)))})}]]);wx.createComponent(s);