gp-designer 1.0.18 → 1.0.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/gp-designer.es.js +118 -121
- package/dist/gp-designer.umd.js +2 -2
- package/dist/style.css +2 -2
- package/package.json +1 -1
package/dist/gp-designer.umd.js
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
fieldset[disabled]:not(fieldset[disabled] legend:first-of-type *)
|
6
6
|
)`,enabled:":not(:disabled)",checked:":is(:is(input[type=radio], input[type=checkbox])[checked], option:selected)",required:":is(input, select, textarea)[required]",optional:":is(input, select, textarea):not([required])",selected:"option:is([selected], select:not([multiple]):not(:has(> option[selected])) > :first-of-type)",checkbox:"[type=checkbox]",file:"[type=file]",password:"[type=password]",radio:"[type=radio]",reset:"[type=reset]",image:"[type=image]",submit:"[type=submit]",parent:":not(:empty)",header:":is(h1, h2, h3, h4, h5, h6)",button:":is(button, input[type=button])",input:":is(input, textarea, select, button)",text:"input:is(:not([type!='']), [type=text])"},Di={};function so(e,t){return e===F.falseFunc?F.falseFunc:a=>t.isTag(a)&&e(a)}function Li(e,t){const a=t.getSiblings(e);if(a.length<=1)return[];const n=a.indexOf(e);return n<0||n===a.length-1?[]:a.slice(n+1).filter(t.isTag)}function sn(e){return{xmlMode:!!e.xmlMode,lowerCaseAttributeNames:!!e.lowerCaseAttributeNames,lowerCaseTags:!!e.lowerCaseTags,quirksMode:!!e.quirksMode,cacheResults:!!e.cacheResults,pseudos:e.pseudos,adapter:e.adapter,equals:e.equals}}const rn=(e,t,a,n,i)=>{const r=i(t,sn(a),n);return r===F.trueFunc?e:r===F.falseFunc?F.falseFunc:u=>r(u)&&e(u)},un={is:rn,matches:rn,where:rn,not(e,t,a,n,i){const r=i(t,sn(a),n);return r===F.falseFunc?e:r===F.trueFunc?F.falseFunc:u=>!r(u)&&e(u)},has(e,t,a,n,i){const{adapter:r}=a,u=sn(a);u.relativeSelector=!0;const o=t.some(m=>m.some(tn))?[Di]:void 0,l=i(t,u,o);if(l===F.falseFunc)return F.falseFunc;const h=so(l,r);if(o&&l!==F.trueFunc){const{shouldTestNextSiblings:m=!1}=l;return p=>{if(!e(p))return!1;o[0]=p;const T=r.getChildren(p),A=m?[...T,...Li(p,r)]:T;return r.existsOne(h,A)}}return m=>e(m)&&r.existsOne(h,r.getChildren(m))}};function ro(e,t,a,n,i){var r;const{name:u,data:o}=t;if(Array.isArray(o)){if(!(u in un))throw new Error(`Unknown pseudo-class :${u}(${o})`);return un[u](e,o,a,n,i)}const l=(r=a.pseudos)===null||r===void 0?void 0:r[u],h=typeof l=="string"?l:io[u];if(typeof h=="string"){if(o!=null)throw new Error(`Pseudo ${u} doesn't have any arguments`);const m=da(h);return un.is(e,m,a,n,i)}if(typeof l=="function")return Oi(l,u,o,1),m=>l(m,o)&&e(m);if(u in an)return an[u](e,o,a,n);if(u in xi){const m=xi[u];return Oi(m,u,o,2),p=>m(p,a,o)&&e(p)}throw new Error(`Unknown pseudo-class :${u}`)}function on(e,t){const a=t.getParent(e);return a&&t.isTag(a)?a:null}function uo(e,t,a,n,i){const{adapter:r,equals:u}=a;switch(t.type){case y.PseudoElement:throw new Error("Pseudo-elements are not supported by css-select");case y.ColumnCombinator:throw new Error("Column combinators are not yet supported by css-select");case y.Attribute:{if(t.namespace!=null)throw new Error("Namespaced attributes are not yet supported by css-select");return(!a.xmlMode||a.lowerCaseAttributeNames)&&(t.name=t.name.toLowerCase()),Ju[t.action](e,t,a)}case y.Pseudo:return ro(e,t,a,n,i);case y.Tag:{if(t.namespace!=null)throw new Error("Namespaced tag names are not yet supported by css-select");let{name:o}=t;return(!a.xmlMode||a.lowerCaseTags)&&(o=o.toLowerCase()),function(h){return r.getName(h)===o&&e(h)}}case y.Descendant:{if(a.cacheResults===!1||typeof WeakSet>"u")return function(h){let m=h;for(;m=on(m,r);)if(e(m))return!0;return!1};const o=new WeakSet;return function(h){let m=h;for(;m=on(m,r);)if(!o.has(m)){if(r.isTag(m)&&e(m))return!0;o.add(m)}return!1}}case"_flexibleDescendant":return function(l){let h=l;do if(e(h))return!0;while(h=on(h,r));return!1};case y.Parent:return function(l){return r.getChildren(l).some(h=>r.isTag(h)&&e(h))};case y.Child:return function(l){const h=r.getParent(l);return h!=null&&r.isTag(h)&&e(h)};case y.Sibling:return function(l){const h=r.getSiblings(l);for(let m=0;m<h.length;m++){const p=h[m];if(u(l,p))break;if(r.isTag(p)&&e(p))return!0}return!1};case y.Adjacent:return r.prevElementSibling?function(l){const h=r.prevElementSibling(l);return h!=null&&e(h)}:function(l){const h=r.getSiblings(l);let m;for(let p=0;p<h.length;p++){const T=h[p];if(u(l,T))break;r.isTag(T)&&(m=T)}return!!m&&e(m)};case y.Universal:{if(t.namespace!=null&&t.namespace!=="*")throw new Error("Namespaced universal selectors are not yet supported by css-select");return e}}}function yi(e){return e.type===y.Pseudo&&(e.name==="scope"||Array.isArray(e.data)&&e.data.some(t=>t.some(yi)))}const oo={type:y.Descendant},co={type:"_flexibleDescendant"},lo={type:y.Pseudo,name:"scope",data:null};function ho(e,{adapter:t},a){const n=!!(a!=null&&a.every(i=>{const r=t.isTag(i)&&t.getParent(i);return i===Di||r&&t.isTag(r)}));for(const i of e){if(!(i.length>0&&tn(i[0])&&i[0].type!==y.Descendant))if(n&&!i.some(yi))i.unshift(oo);else continue;i.unshift(lo)}}function Ri(e,t,a){var n;e.forEach(zu),a=(n=t.context)!==null&&n!==void 0?n:a;const i=Array.isArray(a),r=a&&(Array.isArray(a)?a:[a]);if(t.relativeSelector!==!1)ho(e,t,r);else if(e.some(l=>l.length>0&&tn(l[0])))throw new Error("Relative selectors are not allowed when the `relativeSelector` option is disabled");let u=!1;const o=e.map(l=>{if(l.length>=2){const[h,m]=l;h.type!==y.Pseudo||h.name!=="scope"||(i&&m.type===y.Descendant?l[1]=co:(m.type===y.Adjacent||m.type===y.Sibling)&&(u=!0))}return fo(l,t,r)}).reduce(mo,F.falseFunc);return o.shouldTestNextSiblings=u,o}function fo(e,t,a){var n;return e.reduce((i,r)=>i===F.falseFunc?F.falseFunc:uo(i,r,t,a,Ri),(n=t.rootFunc)!==null&&n!==void 0?n:F.trueFunc)}function mo(e,t){return t===F.falseFunc||e===F.trueFunc?e:e===F.falseFunc||t===F.trueFunc?t:function(n){return e(n)||t(n)}}const ki=(e,t)=>e===t,Eo={adapter:oa,equals:ki};function po(e){var t,a,n,i;const r=e??Eo;return(t=r.adapter)!==null&&t!==void 0||(r.adapter=oa),(a=r.equals)!==null&&a!==void 0||(r.equals=(i=(n=r.adapter)===null||n===void 0?void 0:n.equals)!==null&&i!==void 0?i:ki),r}function To(e){return function(a,n,i){const r=po(n);return e(a,r,i)}}const cn=To(Ri);function Mi(e,t,a=!1){return a&&(e=bo(e,t)),Array.isArray(e)?t.removeSubsets(e):t.getChildren(e)}function bo(e,t){const a=Array.isArray(e)?e.slice(0):[e],n=a.length;for(let i=0;i<n;i++){const r=Li(a[i],t);a.push(...r)}return a}const go=new Set(["first","last","eq","gt","nth","lt","even","odd"]);function Ea(e){return e.type!=="pseudo"?!1:go.has(e.name)?!0:e.name==="not"&&Array.isArray(e.data)?e.data.some(t=>t.some(Ea)):!1}function _o(e,t,a){const n=t!=null?parseInt(t,10):NaN;switch(e){case"first":return 1;case"nth":case"eq":return isFinite(n)?n>=0?n+1:1/0:0;case"lt":return isFinite(n)?n>=0?Math.min(n,a):1/0:0;case"gt":return isFinite(n)?1/0:0;case"odd":return 2*a;case"even":return 2*a-1;case"last":case"not":return 1/0}}function Ao(e){for(;e.parent;)e=e.parent;return e}function ln(e){const t=[],a=[];for(const n of e)n.some(Ea)?t.push(n):a.push(n);return[a,t]}const No={type:y.Universal,namespace:null},Co={type:y.Pseudo,name:"scope",data:null};function Pi(e,t,a={}){return vi([e],t,a)}function vi(e,t,a={}){if(typeof t=="function")return e.some(t);const[n,i]=ln(da(t));return n.length>0&&e.some(cn(n,a))||i.some(r=>Ui(r,e,a).length>0)}function Io(e,t,a,n){const i=typeof a=="string"?parseInt(a,10):NaN;switch(e){case"first":case"lt":return t;case"last":return t.length>0?[t[t.length-1]]:t;case"nth":case"eq":return isFinite(i)&&Math.abs(i)<t.length?[i<0?t[t.length+i]:t[i]]:[];case"gt":return isFinite(i)?t.slice(i+1):[];case"even":return t.filter((r,u)=>u%2===0);case"odd":return t.filter((r,u)=>u%2===1);case"not":{const r=new Set(wi(a,t,n));return t.filter(u=>!r.has(u))}}}function Bi(e,t,a={}){return wi(da(e),t,a)}function wi(e,t,a){if(t.length===0)return[];const[n,i]=ln(e);let r;if(n.length){const u=hn(t,n,a);if(i.length===0)return u;u.length&&(r=new Set(u))}for(let u=0;u<i.length&&(r==null?void 0:r.size)!==t.length;u++){const o=i[u];if((r?t.filter(m=>v(m)&&!r.has(m)):t).length===0)break;const h=Ui(o,t,a);if(h.length)if(r)h.forEach(m=>r.add(m));else{if(u===i.length-1)return h;r=new Set(h)}}return typeof r<"u"?r.size===t.length?t:t.filter(u=>r.has(u)):[]}function Ui(e,t,a){var n;if(e.some(Rt)){const i=(n=a.root)!==null&&n!==void 0?n:Ao(t[0]),r={...a,context:t,relativeSelector:!1};return e.push(Co),pa(i,e,r,!0,t.length)}return pa(t,e,a,!1,t.length)}function So(e,t,a={},n=1/0){if(typeof e=="function")return Fi(t,e);const[i,r]=ln(da(e)),u=r.map(o=>pa(t,o,a,!0,n));return i.length&&u.push(dn(t,i,a,n)),u.length===0?[]:u.length===1?u[0]:Et(u.reduce((o,l)=>[...o,...l]))}function pa(e,t,a,n,i){const r=t.findIndex(Ea),u=t.slice(0,r),o=t[r],l=t.length-1===r?i:1/0,h=_o(o.name,o.data,l);if(h===0)return[];const p=(u.length===0&&!Array.isArray(e)?ia(e).filter(v):u.length===0?(Array.isArray(e)?e:[e]).filter(v):n||u.some(Rt)?dn(e,[u],a,h):hn(e,[u],a)).slice(0,h);let T=Io(o.name,p,o.data,a);if(T.length===0||t.length===r+1)return T;const A=t.slice(r+1),I=A.some(Rt);if(I){if(Rt(A[0])){const{type:R}=A[0];(R===y.Sibling||R===y.Adjacent)&&(T=Mi(T,oa,!0)),A.unshift(No)}a={...a,relativeSelector:!1,rootFunc:R=>T.includes(R)}}else a.rootFunc&&a.rootFunc!==ha.trueFunc&&(a={...a,rootFunc:ha.trueFunc});return A.some(Ea)?pa(T,A,a,!1,i):I?dn(T,[A],a,i):hn(T,[A],a)}function dn(e,t,a,n){const i=cn(t,a,e);return Fi(e,i,n)}function Fi(e,t,a=1/0){const n=Mi(e,oa,t.shouldTestNextSiblings);return Xa(i=>v(i)&&t(i),n,!0,a)}function hn(e,t,a){const n=(Array.isArray(e)?e:[e]).filter(v);if(n.length===0)return n;const i=cn(t,a);return i===ha.trueFunc?n:n.filter(i)}const xo=/^\s*[+~]/;function Oo(e){if(!e)return this._make([]);if(typeof e!="string"){const t=Ve(e)?e.toArray():[e],a=this.toArray();return this._make(t.filter(n=>a.some(i=>li(i,n))))}return this._findBySelector(e,Number.POSITIVE_INFINITY)}function Do(e,t){var a;const n=this.toArray(),i=xo.test(e)?n:this.children().toArray(),r={context:n,root:(a=this._root)===null||a===void 0?void 0:a[0],xmlMode:this.options.xmlMode,lowerCaseTags:this.options.lowerCaseTags,lowerCaseAttributeNames:this.options.lowerCaseAttributeNames,pseudos:this.options.pseudos,quirksMode:this.options.quirksMode};return this._make(So(e,i,r,t))}function fn(e){return function(t,...a){return function(n){var i;let r=e(t,this);return n&&(r=pn(r,n,this.options.xmlMode,(i=this._root)===null||i===void 0?void 0:i[0])),this._make(this.length>1&&r.length>1?a.reduce((u,o)=>o(u),r):r)}}}const Mt=fn((e,t)=>{let a=[];for(let n=0;n<t.length;n++){const i=e(t[n]);i.length>0&&(a=a.concat(i))}return a}),mn=fn((e,t)=>{const a=[];for(let n=0;n<t.length;n++){const i=e(t[n]);i!==null&&a.push(i)}return a});function En(e,...t){let a=null;const n=fn((i,r)=>{const u=[];return te(r,o=>{for(let l;(l=i(o))&&!(a!=null&&a(l,u.length));o=l)u.push(l)}),u})(e,...t);return function(i,r){a=typeof i=="string"?o=>Pi(o,i,this.options):i?Pt(i):null;const u=n.call(this,r);return a=null,u}}function Tt(e){return e.length>1?Array.from(new Set(e)):e}const Lo=mn(({parent:e})=>e&&!We(e)?e:null,Tt),yo=Mt(e=>{const t=[];for(;e.parent&&!We(e.parent);)t.push(e.parent),e=e.parent;return t},Et,e=>e.reverse()),Ro=En(({parent:e})=>e&&!We(e)?e:null,Et,e=>e.reverse());function ko(e){var t;const a=[];if(!e)return this._make(a);const n={xmlMode:this.options.xmlMode,root:(t=this._root)===null||t===void 0?void 0:t[0]},i=typeof e=="string"?r=>Pi(r,e,n):Pt(e);return te(this,r=>{for(r&&!We(r)&&!v(r)&&(r=r.parent);r&&v(r);){if(i(r,0)){a.includes(r)||a.push(r);break}r=r.parent}}),this._make(a)}const Mo=mn(e=>Wa(e)),Po=Mt(e=>{const t=[];for(;e.next;)e=e.next,v(e)&&t.push(e);return t},Tt),vo=En(e=>Wa(e),Tt),Bo=mn(e=>Ga(e)),wo=Mt(e=>{const t=[];for(;e.prev;)e=e.prev,v(e)&&t.push(e);return t},Tt),Uo=En(e=>Ga(e),Tt),Fo=Mt(e=>ni(e).filter(t=>v(t)&&t!==e),Et),Ho=Mt(e=>ia(e).filter(v),Tt);function Vo(){const e=this.toArray().reduce((t,a)=>ce(a)?t.concat(a.children):t,[]);return this._make(e)}function Yo(e){let t=0;const a=this.length;for(;t<a&&e.call(this[t],t,this[t])!==!1;)++t;return this}function qo(e){let t=[];for(let a=0;a<this.length;a++){const n=this[a],i=e.call(n,a,n);i!=null&&(t=t.concat(i))}return this._make(t)}function Pt(e){return typeof e=="function"?(t,a)=>e.call(t,a,t):Ve(e)?t=>Array.prototype.includes.call(e,t):function(t){return e===t}}function $o(e){var t;return this._make(pn(this.toArray(),e,this.options.xmlMode,(t=this._root)===null||t===void 0?void 0:t[0]))}function pn(e,t,a,n){return typeof t=="string"?Bi(t,e,{xmlMode:a,root:n}):e.filter(Pt(t))}function Wo(e){const t=this.toArray();return typeof e=="string"?vi(t.filter(v),e,this.options):e?t.some(Pt(e)):!1}function Go(e){let t=this.toArray();if(typeof e=="string"){const a=new Set(Bi(e,t,this.options));t=t.filter(n=>!a.has(n))}else{const a=Pt(e);t=t.filter((n,i)=>!a(n,i))}return this._make(t)}function Xo(e){return this.filter(typeof e=="string"?`:has(${e})`:(t,a)=>this._make(a).find(e).length>0)}function Qo(){return this.length>1?this._make(this[0]):this}function jo(){return this.length>0?this._make(this[this.length-1]):this}function zo(e){var t;return e=+e,e===0&&this.length<=1?this:(e<0&&(e=this.length+e),this._make((t=this[e])!==null&&t!==void 0?t:[]))}function Ko(e){return e==null?this.toArray():this[e<0?this.length+e:e]}function Zo(){return Array.prototype.slice.call(this)}function Jo(e){let t,a;return e==null?(t=this.parent().children(),a=this[0]):typeof e=="string"?(t=this._make(e),a=this[0]):(t=this,a=Ve(e)?e[0]:e),Array.prototype.indexOf.call(t,a)}function ec(e,t){return this._make(Array.prototype.slice.call(this,e,t))}function tc(){var e;return(e=this.prevObject)!==null&&e!==void 0?e:this._make([])}function ac(e,t){const a=this._make(e,t),n=Et([...this.get(),...a.get()]);return this._make(n)}function nc(e){return this.prevObject?this.add(e?this.prevObject.filter(e):this.prevObject):this}const ic=Object.freeze(Object.defineProperty({__proto__:null,_findBySelector:Do,add:ac,addBack:nc,children:Ho,closest:ko,contents:Vo,each:Yo,end:tc,eq:zo,filter:$o,filterArray:pn,find:Oo,first:Qo,get:Ko,has:Xo,index:Jo,is:Wo,last:jo,map:qo,next:Mo,nextAll:Po,nextUntil:vo,not:Go,parent:Lo,parents:yo,parentsUntil:Ro,prev:Bo,prevAll:wo,prevUntil:Uo,siblings:Fo,slice:ec,toArray:Zo},Symbol.toStringTag,{value:"Module"}));function sc(e){return function(a,n,i,r){if(typeof Buffer<"u"&&Buffer.isBuffer(a)&&(a=a.toString()),typeof a=="string")return e(a,n,i,r);const u=a;if(!Array.isArray(u)&&We(u))return u;const o=new at([]);return rt(u,o),o}}function rt(e,t){const a=Array.isArray(e)?e:[e];t?t.children=a:t=null;for(let n=0;n<a.length;n++){const i=a[n];i.parent&&i.parent.children!==a&&nt(i),t?(i.prev=a[n-1]||null,i.next=a[n+1]||null):i.prev=i.next=null,i.parent=t}return t}function rc(e,t){if(e==null)return[];if(typeof e=="string")return this._parse(e,this.options,!1,null).children.slice(0);if("length"in e){if(e.length===1)return this._makeDomArray(e[0],t);const a=[];for(let n=0;n<e.length;n++){const i=e[n];if(typeof i=="object"){if(i==null)continue;if(!("length"in i)){a.push(t?Ot(i,!0):i);continue}}a.push(...this._makeDomArray(i,t))}return a}return[t?Ot(e,!0):e]}function Hi(e){return function(...t){const a=this.length-1;return te(this,(n,i)=>{if(!ce(n))return;const r=typeof t[0]=="function"?t[0].call(n,i,this._render(n.children)):t,u=this._makeDomArray(r,i<a);e(u,n.children,n)})}}function Qe(e,t,a,n,i){var r,u;const o=[t,a,...n],l=t===0?null:e[t-1],h=t+a>=e.length?null:e[t+a];for(let m=0;m<n.length;++m){const p=n[m],T=p.parent;if(T){const I=T.children.indexOf(p);I>-1&&(T.children.splice(I,1),i===T&&t>I&&o[0]--)}p.parent=i,p.prev&&(p.prev.next=(r=p.next)!==null&&r!==void 0?r:null),p.next&&(p.next.prev=(u=p.prev)!==null&&u!==void 0?u:null),p.prev=m===0?l:n[m-1],p.next=m===n.length-1?h:n[m+1]}return l&&(l.next=n[0]),h&&(h.prev=n[n.length-1]),e.splice(...o)}function uc(e){return(Ve(e)?e:this._make(e)).append(this),this}function oc(e){return(Ve(e)?e:this._make(e)).prepend(this),this}const cc=Hi((e,t,a)=>{Qe(t,t.length,0,e,a)}),lc=Hi((e,t,a)=>{Qe(t,0,0,e,a)});function Vi(e){return function(t){const a=this.length-1,n=this.parents().last();for(let i=0;i<this.length;i++){const r=this[i],u=typeof t=="function"?t.call(r,i,r):typeof t=="string"&&!za(t)?n.find(t).clone():t,[o]=this._makeDomArray(u,i<a);if(!o||!ce(o))continue;let l=o,h=0;for(;h<l.children.length;){const m=l.children[h];v(m)?(l=m,h=0):h++}e(r,l,[o])}return this}}const dc=Vi((e,t,a)=>{const{parent:n}=e;if(!n)return;const i=n.children,r=i.indexOf(e);rt([e],t),Qe(i,r,0,a,n)}),hc=Vi((e,t,a)=>{ce(e)&&(rt(e.children,t),rt(a,e))});function fc(e){return this.parent(e).not("body").each((t,a)=>{this._make(a).replaceWith(a.children)}),this}function mc(e){const t=this[0];if(t){const a=this._make(typeof e=="function"?e.call(t,0,t):e).insertBefore(t);let n;for(let r=0;r<a.length;r++)a[r].type==="tag"&&(n=a[r]);let i=0;for(;n&&i<n.children.length;){const r=n.children[i];r.type==="tag"?(n=r,i=0):i++}n&&this._make(n).append(this)}return this}function Ec(...e){const t=this.length-1;return te(this,(a,n)=>{if(!ce(a)||!a.parent)return;const i=a.parent.children,r=i.indexOf(a);if(r<0)return;const u=typeof e[0]=="function"?e[0].call(a,n,this._render(a.children)):e,o=this._makeDomArray(u,n<t);Qe(i,r+1,0,o,a.parent)})}function pc(e){typeof e=="string"&&(e=this._make(e)),this.remove();const t=[];for(const a of this._makeDomArray(e)){const n=this.clone().toArray(),{parent:i}=a;if(!i)continue;const r=i.children,u=r.indexOf(a);u<0||(Qe(r,u+1,0,n,i),t.push(...n))}return this._make(t)}function Tc(...e){const t=this.length-1;return te(this,(a,n)=>{if(!ce(a)||!a.parent)return;const i=a.parent.children,r=i.indexOf(a);if(r<0)return;const u=typeof e[0]=="function"?e[0].call(a,n,this._render(a.children)):e,o=this._makeDomArray(u,n<t);Qe(i,r,0,o,a.parent)})}function bc(e){const t=this._make(e);this.remove();const a=[];return te(t,n=>{const i=this.clone().toArray(),{parent:r}=n;if(!r)return;const u=r.children,o=u.indexOf(n);o<0||(Qe(u,o,0,i,r),a.push(...i))}),this._make(a)}function gc(e){const t=e?this.filter(e):this;return te(t,a=>{nt(a),a.prev=a.next=a.parent=null}),this}function _c(e){return te(this,(t,a)=>{const{parent:n}=t;if(!n)return;const i=n.children,r=typeof e=="function"?e.call(t,a,t):e,u=this._makeDomArray(r);rt(u,null);const o=i.indexOf(t);Qe(i,o,1,u,n),u.includes(t)||(t.parent=t.prev=t.next=null)})}function Ac(){return te(this,e=>{if(ce(e)){for(const t of e.children)t.next=t.prev=t.parent=null;e.children.length=0}})}function Nc(e){if(e===void 0){const t=this[0];return!t||!ce(t)?null:this._render(t.children)}return te(this,t=>{if(!ce(t))return;for(const n of t.children)n.next=n.prev=n.parent=null;const a=Ve(e)?e.toArray():this._parse(`${e}`,this.options,!1,t).children;rt(a,t)})}function Cc(){return this._render(this)}function Ic(e){return e===void 0?Dt(this):typeof e=="function"?te(this,(t,a)=>this._make(t).text(e.call(t,a,Dt([t])))):te(this,t=>{if(!ce(t))return;for(const n of t.children)n.next=n.prev=n.parent=null;const a=new xt(`${e}`);rt(a,t)})}function Sc(){const e=Array.prototype.map.call(this.get(),a=>Ot(a,!0)),t=new at(e);for(const a of e)a.parent=t;return this._make(e)}const xc=Object.freeze(Object.defineProperty({__proto__:null,_makeDomArray:rc,after:Ec,append:cc,appendTo:uc,before:Tc,clone:Sc,empty:Ac,html:Nc,insertAfter:pc,insertBefore:bc,prepend:lc,prependTo:oc,remove:gc,replaceWith:_c,text:Ic,toString:Cc,unwrap:fc,wrap:dc,wrapAll:mc,wrapInner:hc},Symbol.toStringTag,{value:"Module"}));function Oc(e,t){if(e!=null&&t!=null||typeof e=="object"&&!Array.isArray(e))return te(this,(a,n)=>{v(a)&&Yi(a,e,t,n)});if(this.length!==0)return qi(this[0],e)}function Yi(e,t,a,n){if(typeof t=="string"){const i=qi(e),r=typeof a=="function"?a.call(e,n,i[t]):a;r===""?delete i[t]:r!=null&&(i[t]=r),e.attribs.style=Dc(i)}else if(typeof t=="object"){const i=Object.keys(t);for(let r=0;r<i.length;r++){const u=i[r];Yi(e,u,t[u],r)}}}function qi(e,t){if(!e||!v(e))return;const a=Lc(e.attribs.style);if(typeof t=="string")return a[t];if(Array.isArray(t)){const n={};for(const i of t)a[i]!=null&&(n[i]=a[i]);return n}return a}function Dc(e){return Object.keys(e).reduce((t,a)=>`${t}${t?" ":""}${a}: ${e[a]};`,"")}function Lc(e){if(e=(e||"").trim(),!e)return{};const t={};let a;for(const n of e.split(";")){const i=n.indexOf(":");if(i<1||i===n.length-1){const r=n.trimEnd();r.length>0&&a!==void 0&&(t[a]+=`;${r}`)}else a=n.slice(0,i).trim(),t[a]=n.slice(i+1).trim()}return t}const yc=Object.freeze(Object.defineProperty({__proto__:null,css:Oc},Symbol.toStringTag,{value:"Module"})),$i="input,select,textarea,keygen",Rc=/%20/g,Wi=/\r?\n/g;function kc(){return this.serializeArray().map(a=>`${encodeURIComponent(a.name)}=${encodeURIComponent(a.value)}`).join("&").replace(Rc,"+")}function Mc(){return this.map((e,t)=>{const a=this._make(t);return v(t)&&t.name==="form"?a.find($i).toArray():a.filter($i).toArray()}).filter('[name!=""]:enabled:not(:submit, :button, :image, :reset, :file):matches([checked], :not(:checkbox, :radio))').map((e,t)=>{var a;const n=this._make(t),i=n.attr("name"),r=(a=n.val())!==null&&a!==void 0?a:"";return Array.isArray(r)?r.map(u=>({name:i,value:u.replace(Wi,`\r
|
7
7
|
`)})):{name:i,value:r.replace(Wi,`\r
|
8
|
-
`)}}).toArray()}const Pc=Object.freeze(Object.defineProperty({__proto__:null,serialize:kc,serializeArray:Mc},Symbol.toStringTag,{value:"Module"}));function vc(e){var t;return typeof e=="string"?{selector:e,value:"textContent"}:{selector:e.selector,value:(t=e.value)!==null&&t!==void 0?t:"textContent"}}function Bc(e){const t={};for(const a in e){const n=e[a],i=Array.isArray(n),{selector:r,value:u}=vc(i?n[0]:n),o=typeof u=="function"?u:typeof u=="string"?l=>this._make(l).prop(u):l=>this._make(l).extract(u);if(i)t[a]=this._findBySelector(r,Number.POSITIVE_INFINITY).map((l,h)=>o(h,a,t)).get();else{const l=this._findBySelector(r,1);t[a]=l.length>0?o(l[0],a,t):void 0}}return t}const wc=Object.freeze(Object.defineProperty({__proto__:null,extract:Bc},Symbol.toStringTag,{value:"Module"}));class vt{constructor(t,a,n){if(this.length=0,this.options=n,this._root=a,t){for(let i=0;i<t.length;i++)this[i]=t[i];this.length=t.length}}}vt.prototype.cheerio="[cheerio object]",vt.prototype.splice=Array.prototype.splice,vt.prototype[Symbol.iterator]=Array.prototype[Symbol.iterator],Object.assign(vt.prototype,Yu,ic,xc,yc,Pc,wc);function Uc(e,t){return function a(n,i,r=!0){if(n==null)throw new Error("cheerio.load() expects a string");const u=ja(i),o=e(n,u,r,null);class l extends vt{_make(p,T){const A=h(p,T);return A.prevObject=this,A}_parse(p,T,A,I){return e(p,T,A,I)}_render(p){return t(p,this.options)}}function h(m,p,T=o,A){if(m&&Ve(m))return m;const I=ja(A,u),R=typeof T=="string"?[e(T,I,!1,null)]:"length"in T?T:[T],M=Ve(R)?R:new l(R,null,I);if(M._root=M,!m)return new l(void 0,M,I);const B=typeof m=="string"&&za(m)?e(m,I,!1,null).children:Fc(m)?[m]:Array.isArray(m)?m:void 0,W=new l(B,M,I);if(B)return W;if(typeof m!="string")throw new TypeError("Unexpected type of selector");let q=m;const ae=p?typeof p=="string"?za(p)?new l([e(p,I,!1,null)],M,I):(q=`${p} ${q}`,M):Ve(p)?p:new l(Array.isArray(p)?p:[p],M,I):M;return ae?ae.find(q):W}return Object.assign(h,yu,{load:a,_root:o,_options:u,fn:l.prototype,prototype:l.prototype}),h}}function Fc(e){return!!e.name||e.type==="root"||e.type==="text"||e.type==="comment"}const Hc=new Set([65534,65535,131070,131071,196606,196607,262142,262143,327678,327679,393214,393215,458750,458751,524286,524287,589822,589823,655358,655359,720894,720895,786430,786431,851966,851967,917502,917503,983038,983039,1048574,1048575,1114110,1114111]),Z="�";var d;(function(e){e[e.EOF=-1]="EOF",e[e.NULL=0]="NULL",e[e.TABULATION=9]="TABULATION",e[e.CARRIAGE_RETURN=13]="CARRIAGE_RETURN",e[e.LINE_FEED=10]="LINE_FEED",e[e.FORM_FEED=12]="FORM_FEED",e[e.SPACE=32]="SPACE",e[e.EXCLAMATION_MARK=33]="EXCLAMATION_MARK",e[e.QUOTATION_MARK=34]="QUOTATION_MARK",e[e.AMPERSAND=38]="AMPERSAND",e[e.APOSTROPHE=39]="APOSTROPHE",e[e.HYPHEN_MINUS=45]="HYPHEN_MINUS",e[e.SOLIDUS=47]="SOLIDUS",e[e.DIGIT_0=48]="DIGIT_0",e[e.DIGIT_9=57]="DIGIT_9",e[e.SEMICOLON=59]="SEMICOLON",e[e.LESS_THAN_SIGN=60]="LESS_THAN_SIGN",e[e.EQUALS_SIGN=61]="EQUALS_SIGN",e[e.GREATER_THAN_SIGN=62]="GREATER_THAN_SIGN",e[e.QUESTION_MARK=63]="QUESTION_MARK",e[e.LATIN_CAPITAL_A=65]="LATIN_CAPITAL_A",e[e.LATIN_CAPITAL_Z=90]="LATIN_CAPITAL_Z",e[e.RIGHT_SQUARE_BRACKET=93]="RIGHT_SQUARE_BRACKET",e[e.GRAVE_ACCENT=96]="GRAVE_ACCENT",e[e.LATIN_SMALL_A=97]="LATIN_SMALL_A",e[e.LATIN_SMALL_Z=122]="LATIN_SMALL_Z"})(d||(d={}));const Ae={DASH_DASH:"--",CDATA_START:"[CDATA[",DOCTYPE:"doctype",SCRIPT:"script",PUBLIC:"public",SYSTEM:"system"};function Gi(e){return e>=55296&&e<=57343}function Vc(e){return e>=56320&&e<=57343}function Yc(e,t){return(e-55296)*1024+9216+t}function Xi(e){return e!==32&&e!==10&&e!==13&&e!==9&&e!==12&&e>=1&&e<=31||e>=127&&e<=159}function Qi(e){return e>=64976&&e<=65007||Hc.has(e)}var g;(function(e){e.controlCharacterInInputStream="control-character-in-input-stream",e.noncharacterInInputStream="noncharacter-in-input-stream",e.surrogateInInputStream="surrogate-in-input-stream",e.nonVoidHtmlElementStartTagWithTrailingSolidus="non-void-html-element-start-tag-with-trailing-solidus",e.endTagWithAttributes="end-tag-with-attributes",e.endTagWithTrailingSolidus="end-tag-with-trailing-solidus",e.unexpectedSolidusInTag="unexpected-solidus-in-tag",e.unexpectedNullCharacter="unexpected-null-character",e.unexpectedQuestionMarkInsteadOfTagName="unexpected-question-mark-instead-of-tag-name",e.invalidFirstCharacterOfTagName="invalid-first-character-of-tag-name",e.unexpectedEqualsSignBeforeAttributeName="unexpected-equals-sign-before-attribute-name",e.missingEndTagName="missing-end-tag-name",e.unexpectedCharacterInAttributeName="unexpected-character-in-attribute-name",e.unknownNamedCharacterReference="unknown-named-character-reference",e.missingSemicolonAfterCharacterReference="missing-semicolon-after-character-reference",e.unexpectedCharacterAfterDoctypeSystemIdentifier="unexpected-character-after-doctype-system-identifier",e.unexpectedCharacterInUnquotedAttributeValue="unexpected-character-in-unquoted-attribute-value",e.eofBeforeTagName="eof-before-tag-name",e.eofInTag="eof-in-tag",e.missingAttributeValue="missing-attribute-value",e.missingWhitespaceBetweenAttributes="missing-whitespace-between-attributes",e.missingWhitespaceAfterDoctypePublicKeyword="missing-whitespace-after-doctype-public-keyword",e.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers="missing-whitespace-between-doctype-public-and-system-identifiers",e.missingWhitespaceAfterDoctypeSystemKeyword="missing-whitespace-after-doctype-system-keyword",e.missingQuoteBeforeDoctypePublicIdentifier="missing-quote-before-doctype-public-identifier",e.missingQuoteBeforeDoctypeSystemIdentifier="missing-quote-before-doctype-system-identifier",e.missingDoctypePublicIdentifier="missing-doctype-public-identifier",e.missingDoctypeSystemIdentifier="missing-doctype-system-identifier",e.abruptDoctypePublicIdentifier="abrupt-doctype-public-identifier",e.abruptDoctypeSystemIdentifier="abrupt-doctype-system-identifier",e.cdataInHtmlContent="cdata-in-html-content",e.incorrectlyOpenedComment="incorrectly-opened-comment",e.eofInScriptHtmlCommentLikeText="eof-in-script-html-comment-like-text",e.eofInDoctype="eof-in-doctype",e.nestedComment="nested-comment",e.abruptClosingOfEmptyComment="abrupt-closing-of-empty-comment",e.eofInComment="eof-in-comment",e.incorrectlyClosedComment="incorrectly-closed-comment",e.eofInCdata="eof-in-cdata",e.absenceOfDigitsInNumericCharacterReference="absence-of-digits-in-numeric-character-reference",e.nullCharacterReference="null-character-reference",e.surrogateCharacterReference="surrogate-character-reference",e.characterReferenceOutsideUnicodeRange="character-reference-outside-unicode-range",e.controlCharacterReference="control-character-reference",e.noncharacterCharacterReference="noncharacter-character-reference",e.missingWhitespaceBeforeDoctypeName="missing-whitespace-before-doctype-name",e.missingDoctypeName="missing-doctype-name",e.invalidCharacterSequenceAfterDoctypeName="invalid-character-sequence-after-doctype-name",e.duplicateAttribute="duplicate-attribute",e.nonConformingDoctype="non-conforming-doctype",e.missingDoctype="missing-doctype",e.misplacedDoctype="misplaced-doctype",e.endTagWithoutMatchingOpenElement="end-tag-without-matching-open-element",e.closingOfElementWithOpenChildElements="closing-of-element-with-open-child-elements",e.disallowedContentInNoscriptInHead="disallowed-content-in-noscript-in-head",e.openElementsLeftAfterEof="open-elements-left-after-eof",e.abandonedHeadElementChild="abandoned-head-element-child",e.misplacedStartTagForHeadElement="misplaced-start-tag-for-head-element",e.nestedNoscriptInHead="nested-noscript-in-head",e.eofInElementThatCanContainOnlyText="eof-in-element-that-can-contain-only-text"})(g||(g={}));const qc=65536;class $c{constructor(t){this.handler=t,this.html="",this.pos=-1,this.lastGapPos=-2,this.gapStack=[],this.skipNextNewLine=!1,this.lastChunkWritten=!1,this.endOfChunkHit=!1,this.bufferWaterline=qc,this.isEol=!1,this.lineStartPos=0,this.droppedBufferSize=0,this.line=1,this.lastErrOffset=-1}get col(){return this.pos-this.lineStartPos+ +(this.lastGapPos!==this.pos)}get offset(){return this.droppedBufferSize+this.pos}getError(t,a){const{line:n,col:i,offset:r}=this,u=i+a,o=r+a;return{code:t,startLine:n,endLine:n,startCol:u,endCol:u,startOffset:o,endOffset:o}}_err(t){this.handler.onParseError&&this.lastErrOffset!==this.offset&&(this.lastErrOffset=this.offset,this.handler.onParseError(this.getError(t,0)))}_addGap(){this.gapStack.push(this.lastGapPos),this.lastGapPos=this.pos}_processSurrogate(t){if(this.pos!==this.html.length-1){const a=this.html.charCodeAt(this.pos+1);if(Vc(a))return this.pos++,this._addGap(),Yc(t,a)}else if(!this.lastChunkWritten)return this.endOfChunkHit=!0,d.EOF;return this._err(g.surrogateInInputStream),t}willDropParsedChunk(){return this.pos>this.bufferWaterline}dropParsedChunk(){this.willDropParsedChunk()&&(this.html=this.html.substring(this.pos),this.lineStartPos-=this.pos,this.droppedBufferSize+=this.pos,this.pos=0,this.lastGapPos=-2,this.gapStack.length=0)}write(t,a){this.html.length>0?this.html+=t:this.html=t,this.endOfChunkHit=!1,this.lastChunkWritten=a}insertHtmlAtCurrentPos(t){this.html=this.html.substring(0,this.pos+1)+t+this.html.substring(this.pos+1),this.endOfChunkHit=!1}startsWith(t,a){if(this.pos+t.length>this.html.length)return this.endOfChunkHit=!this.lastChunkWritten,!1;if(a)return this.html.startsWith(t,this.pos);for(let n=0;n<t.length;n++)if((this.html.charCodeAt(this.pos+n)|32)!==t.charCodeAt(n))return!1;return!0}peek(t){const a=this.pos+t;if(a>=this.html.length)return this.endOfChunkHit=!this.lastChunkWritten,d.EOF;const n=this.html.charCodeAt(a);return n===d.CARRIAGE_RETURN?d.LINE_FEED:n}advance(){if(this.pos++,this.isEol&&(this.isEol=!1,this.line++,this.lineStartPos=this.pos),this.pos>=this.html.length)return this.endOfChunkHit=!this.lastChunkWritten,d.EOF;let t=this.html.charCodeAt(this.pos);return t===d.CARRIAGE_RETURN?(this.isEol=!0,this.skipNextNewLine=!0,d.LINE_FEED):t===d.LINE_FEED&&(this.isEol=!0,this.skipNextNewLine)?(this.line--,this.skipNextNewLine=!1,this._addGap(),this.advance()):(this.skipNextNewLine=!1,Gi(t)&&(t=this._processSurrogate(t)),this.handler.onParseError===null||t>31&&t<127||t===d.LINE_FEED||t===d.CARRIAGE_RETURN||t>159&&t<64976||this._checkForProblematicCharacters(t),t)}_checkForProblematicCharacters(t){Xi(t)?this._err(g.controlCharacterInInputStream):Qi(t)&&this._err(g.noncharacterInInputStream)}retreat(t){for(this.pos-=t;this.pos<this.lastGapPos;)this.lastGapPos=this.gapStack.pop(),this.pos--;this.isEol=!1}}var $;(function(e){e[e.CHARACTER=0]="CHARACTER",e[e.NULL_CHARACTER=1]="NULL_CHARACTER",e[e.WHITESPACE_CHARACTER=2]="WHITESPACE_CHARACTER",e[e.START_TAG=3]="START_TAG",e[e.END_TAG=4]="END_TAG",e[e.COMMENT=5]="COMMENT",e[e.DOCTYPE=6]="DOCTYPE",e[e.EOF=7]="EOF",e[e.HIBERNATION=8]="HIBERNATION"})($||($={}));function ji(e,t){for(let a=e.attrs.length-1;a>=0;a--)if(e.attrs[a].name===t)return e.attrs[a].value;return null}var N;(function(e){e.HTML="http://www.w3.org/1999/xhtml",e.MATHML="http://www.w3.org/1998/Math/MathML",e.SVG="http://www.w3.org/2000/svg",e.XLINK="http://www.w3.org/1999/xlink",e.XML="http://www.w3.org/XML/1998/namespace",e.XMLNS="http://www.w3.org/2000/xmlns/"})(N||(N={}));var ut;(function(e){e.TYPE="type",e.ACTION="action",e.ENCODING="encoding",e.PROMPT="prompt",e.NAME="name",e.COLOR="color",e.FACE="face",e.SIZE="size"})(ut||(ut={}));var Se;(function(e){e.NO_QUIRKS="no-quirks",e.QUIRKS="quirks",e.LIMITED_QUIRKS="limited-quirks"})(Se||(Se={}));var b;(function(e){e.A="a",e.ADDRESS="address",e.ANNOTATION_XML="annotation-xml",e.APPLET="applet",e.AREA="area",e.ARTICLE="article",e.ASIDE="aside",e.B="b",e.BASE="base",e.BASEFONT="basefont",e.BGSOUND="bgsound",e.BIG="big",e.BLOCKQUOTE="blockquote",e.BODY="body",e.BR="br",e.BUTTON="button",e.CAPTION="caption",e.CENTER="center",e.CODE="code",e.COL="col",e.COLGROUP="colgroup",e.DD="dd",e.DESC="desc",e.DETAILS="details",e.DIALOG="dialog",e.DIR="dir",e.DIV="div",e.DL="dl",e.DT="dt",e.EM="em",e.EMBED="embed",e.FIELDSET="fieldset",e.FIGCAPTION="figcaption",e.FIGURE="figure",e.FONT="font",e.FOOTER="footer",e.FOREIGN_OBJECT="foreignObject",e.FORM="form",e.FRAME="frame",e.FRAMESET="frameset",e.H1="h1",e.H2="h2",e.H3="h3",e.H4="h4",e.H5="h5",e.H6="h6",e.HEAD="head",e.HEADER="header",e.HGROUP="hgroup",e.HR="hr",e.HTML="html",e.I="i",e.IMG="img",e.IMAGE="image",e.INPUT="input",e.IFRAME="iframe",e.KEYGEN="keygen",e.LABEL="label",e.LI="li",e.LINK="link",e.LISTING="listing",e.MAIN="main",e.MALIGNMARK="malignmark",e.MARQUEE="marquee",e.MATH="math",e.MENU="menu",e.META="meta",e.MGLYPH="mglyph",e.MI="mi",e.MO="mo",e.MN="mn",e.MS="ms",e.MTEXT="mtext",e.NAV="nav",e.NOBR="nobr",e.NOFRAMES="noframes",e.NOEMBED="noembed",e.NOSCRIPT="noscript",e.OBJECT="object",e.OL="ol",e.OPTGROUP="optgroup",e.OPTION="option",e.P="p",e.PARAM="param",e.PLAINTEXT="plaintext",e.PRE="pre",e.RB="rb",e.RP="rp",e.RT="rt",e.RTC="rtc",e.RUBY="ruby",e.S="s",e.SCRIPT="script",e.SEARCH="search",e.SECTION="section",e.SELECT="select",e.SOURCE="source",e.SMALL="small",e.SPAN="span",e.STRIKE="strike",e.STRONG="strong",e.STYLE="style",e.SUB="sub",e.SUMMARY="summary",e.SUP="sup",e.TABLE="table",e.TBODY="tbody",e.TEMPLATE="template",e.TEXTAREA="textarea",e.TFOOT="tfoot",e.TD="td",e.TH="th",e.THEAD="thead",e.TITLE="title",e.TR="tr",e.TRACK="track",e.TT="tt",e.U="u",e.UL="ul",e.SVG="svg",e.VAR="var",e.WBR="wbr",e.XMP="xmp"})(b||(b={}));var s;(function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.A=1]="A",e[e.ADDRESS=2]="ADDRESS",e[e.ANNOTATION_XML=3]="ANNOTATION_XML",e[e.APPLET=4]="APPLET",e[e.AREA=5]="AREA",e[e.ARTICLE=6]="ARTICLE",e[e.ASIDE=7]="ASIDE",e[e.B=8]="B",e[e.BASE=9]="BASE",e[e.BASEFONT=10]="BASEFONT",e[e.BGSOUND=11]="BGSOUND",e[e.BIG=12]="BIG",e[e.BLOCKQUOTE=13]="BLOCKQUOTE",e[e.BODY=14]="BODY",e[e.BR=15]="BR",e[e.BUTTON=16]="BUTTON",e[e.CAPTION=17]="CAPTION",e[e.CENTER=18]="CENTER",e[e.CODE=19]="CODE",e[e.COL=20]="COL",e[e.COLGROUP=21]="COLGROUP",e[e.DD=22]="DD",e[e.DESC=23]="DESC",e[e.DETAILS=24]="DETAILS",e[e.DIALOG=25]="DIALOG",e[e.DIR=26]="DIR",e[e.DIV=27]="DIV",e[e.DL=28]="DL",e[e.DT=29]="DT",e[e.EM=30]="EM",e[e.EMBED=31]="EMBED",e[e.FIELDSET=32]="FIELDSET",e[e.FIGCAPTION=33]="FIGCAPTION",e[e.FIGURE=34]="FIGURE",e[e.FONT=35]="FONT",e[e.FOOTER=36]="FOOTER",e[e.FOREIGN_OBJECT=37]="FOREIGN_OBJECT",e[e.FORM=38]="FORM",e[e.FRAME=39]="FRAME",e[e.FRAMESET=40]="FRAMESET",e[e.H1=41]="H1",e[e.H2=42]="H2",e[e.H3=43]="H3",e[e.H4=44]="H4",e[e.H5=45]="H5",e[e.H6=46]="H6",e[e.HEAD=47]="HEAD",e[e.HEADER=48]="HEADER",e[e.HGROUP=49]="HGROUP",e[e.HR=50]="HR",e[e.HTML=51]="HTML",e[e.I=52]="I",e[e.IMG=53]="IMG",e[e.IMAGE=54]="IMAGE",e[e.INPUT=55]="INPUT",e[e.IFRAME=56]="IFRAME",e[e.KEYGEN=57]="KEYGEN",e[e.LABEL=58]="LABEL",e[e.LI=59]="LI",e[e.LINK=60]="LINK",e[e.LISTING=61]="LISTING",e[e.MAIN=62]="MAIN",e[e.MALIGNMARK=63]="MALIGNMARK",e[e.MARQUEE=64]="MARQUEE",e[e.MATH=65]="MATH",e[e.MENU=66]="MENU",e[e.META=67]="META",e[e.MGLYPH=68]="MGLYPH",e[e.MI=69]="MI",e[e.MO=70]="MO",e[e.MN=71]="MN",e[e.MS=72]="MS",e[e.MTEXT=73]="MTEXT",e[e.NAV=74]="NAV",e[e.NOBR=75]="NOBR",e[e.NOFRAMES=76]="NOFRAMES",e[e.NOEMBED=77]="NOEMBED",e[e.NOSCRIPT=78]="NOSCRIPT",e[e.OBJECT=79]="OBJECT",e[e.OL=80]="OL",e[e.OPTGROUP=81]="OPTGROUP",e[e.OPTION=82]="OPTION",e[e.P=83]="P",e[e.PARAM=84]="PARAM",e[e.PLAINTEXT=85]="PLAINTEXT",e[e.PRE=86]="PRE",e[e.RB=87]="RB",e[e.RP=88]="RP",e[e.RT=89]="RT",e[e.RTC=90]="RTC",e[e.RUBY=91]="RUBY",e[e.S=92]="S",e[e.SCRIPT=93]="SCRIPT",e[e.SEARCH=94]="SEARCH",e[e.SECTION=95]="SECTION",e[e.SELECT=96]="SELECT",e[e.SOURCE=97]="SOURCE",e[e.SMALL=98]="SMALL",e[e.SPAN=99]="SPAN",e[e.STRIKE=100]="STRIKE",e[e.STRONG=101]="STRONG",e[e.STYLE=102]="STYLE",e[e.SUB=103]="SUB",e[e.SUMMARY=104]="SUMMARY",e[e.SUP=105]="SUP",e[e.TABLE=106]="TABLE",e[e.TBODY=107]="TBODY",e[e.TEMPLATE=108]="TEMPLATE",e[e.TEXTAREA=109]="TEXTAREA",e[e.TFOOT=110]="TFOOT",e[e.TD=111]="TD",e[e.TH=112]="TH",e[e.THEAD=113]="THEAD",e[e.TITLE=114]="TITLE",e[e.TR=115]="TR",e[e.TRACK=116]="TRACK",e[e.TT=117]="TT",e[e.U=118]="U",e[e.UL=119]="UL",e[e.SVG=120]="SVG",e[e.VAR=121]="VAR",e[e.WBR=122]="WBR",e[e.XMP=123]="XMP"})(s||(s={}));const Wc=new Map([[b.A,s.A],[b.ADDRESS,s.ADDRESS],[b.ANNOTATION_XML,s.ANNOTATION_XML],[b.APPLET,s.APPLET],[b.AREA,s.AREA],[b.ARTICLE,s.ARTICLE],[b.ASIDE,s.ASIDE],[b.B,s.B],[b.BASE,s.BASE],[b.BASEFONT,s.BASEFONT],[b.BGSOUND,s.BGSOUND],[b.BIG,s.BIG],[b.BLOCKQUOTE,s.BLOCKQUOTE],[b.BODY,s.BODY],[b.BR,s.BR],[b.BUTTON,s.BUTTON],[b.CAPTION,s.CAPTION],[b.CENTER,s.CENTER],[b.CODE,s.CODE],[b.COL,s.COL],[b.COLGROUP,s.COLGROUP],[b.DD,s.DD],[b.DESC,s.DESC],[b.DETAILS,s.DETAILS],[b.DIALOG,s.DIALOG],[b.DIR,s.DIR],[b.DIV,s.DIV],[b.DL,s.DL],[b.DT,s.DT],[b.EM,s.EM],[b.EMBED,s.EMBED],[b.FIELDSET,s.FIELDSET],[b.FIGCAPTION,s.FIGCAPTION],[b.FIGURE,s.FIGURE],[b.FONT,s.FONT],[b.FOOTER,s.FOOTER],[b.FOREIGN_OBJECT,s.FOREIGN_OBJECT],[b.FORM,s.FORM],[b.FRAME,s.FRAME],[b.FRAMESET,s.FRAMESET],[b.H1,s.H1],[b.H2,s.H2],[b.H3,s.H3],[b.H4,s.H4],[b.H5,s.H5],[b.H6,s.H6],[b.HEAD,s.HEAD],[b.HEADER,s.HEADER],[b.HGROUP,s.HGROUP],[b.HR,s.HR],[b.HTML,s.HTML],[b.I,s.I],[b.IMG,s.IMG],[b.IMAGE,s.IMAGE],[b.INPUT,s.INPUT],[b.IFRAME,s.IFRAME],[b.KEYGEN,s.KEYGEN],[b.LABEL,s.LABEL],[b.LI,s.LI],[b.LINK,s.LINK],[b.LISTING,s.LISTING],[b.MAIN,s.MAIN],[b.MALIGNMARK,s.MALIGNMARK],[b.MARQUEE,s.MARQUEE],[b.MATH,s.MATH],[b.MENU,s.MENU],[b.META,s.META],[b.MGLYPH,s.MGLYPH],[b.MI,s.MI],[b.MO,s.MO],[b.MN,s.MN],[b.MS,s.MS],[b.MTEXT,s.MTEXT],[b.NAV,s.NAV],[b.NOBR,s.NOBR],[b.NOFRAMES,s.NOFRAMES],[b.NOEMBED,s.NOEMBED],[b.NOSCRIPT,s.NOSCRIPT],[b.OBJECT,s.OBJECT],[b.OL,s.OL],[b.OPTGROUP,s.OPTGROUP],[b.OPTION,s.OPTION],[b.P,s.P],[b.PARAM,s.PARAM],[b.PLAINTEXT,s.PLAINTEXT],[b.PRE,s.PRE],[b.RB,s.RB],[b.RP,s.RP],[b.RT,s.RT],[b.RTC,s.RTC],[b.RUBY,s.RUBY],[b.S,s.S],[b.SCRIPT,s.SCRIPT],[b.SEARCH,s.SEARCH],[b.SECTION,s.SECTION],[b.SELECT,s.SELECT],[b.SOURCE,s.SOURCE],[b.SMALL,s.SMALL],[b.SPAN,s.SPAN],[b.STRIKE,s.STRIKE],[b.STRONG,s.STRONG],[b.STYLE,s.STYLE],[b.SUB,s.SUB],[b.SUMMARY,s.SUMMARY],[b.SUP,s.SUP],[b.TABLE,s.TABLE],[b.TBODY,s.TBODY],[b.TEMPLATE,s.TEMPLATE],[b.TEXTAREA,s.TEXTAREA],[b.TFOOT,s.TFOOT],[b.TD,s.TD],[b.TH,s.TH],[b.THEAD,s.THEAD],[b.TITLE,s.TITLE],[b.TR,s.TR],[b.TRACK,s.TRACK],[b.TT,s.TT],[b.U,s.U],[b.UL,s.UL],[b.SVG,s.SVG],[b.VAR,s.VAR],[b.WBR,s.WBR],[b.XMP,s.XMP]]);function Ta(e){var t;return(t=Wc.get(e))!==null&&t!==void 0?t:s.UNKNOWN}const x=s,Gc={[N.HTML]:new Set([x.ADDRESS,x.APPLET,x.AREA,x.ARTICLE,x.ASIDE,x.BASE,x.BASEFONT,x.BGSOUND,x.BLOCKQUOTE,x.BODY,x.BR,x.BUTTON,x.CAPTION,x.CENTER,x.COL,x.COLGROUP,x.DD,x.DETAILS,x.DIR,x.DIV,x.DL,x.DT,x.EMBED,x.FIELDSET,x.FIGCAPTION,x.FIGURE,x.FOOTER,x.FORM,x.FRAME,x.FRAMESET,x.H1,x.H2,x.H3,x.H4,x.H5,x.H6,x.HEAD,x.HEADER,x.HGROUP,x.HR,x.HTML,x.IFRAME,x.IMG,x.INPUT,x.LI,x.LINK,x.LISTING,x.MAIN,x.MARQUEE,x.MENU,x.META,x.NAV,x.NOEMBED,x.NOFRAMES,x.NOSCRIPT,x.OBJECT,x.OL,x.P,x.PARAM,x.PLAINTEXT,x.PRE,x.SCRIPT,x.SECTION,x.SELECT,x.SOURCE,x.STYLE,x.SUMMARY,x.TABLE,x.TBODY,x.TD,x.TEMPLATE,x.TEXTAREA,x.TFOOT,x.TH,x.THEAD,x.TITLE,x.TR,x.TRACK,x.UL,x.WBR,x.XMP]),[N.MATHML]:new Set([x.MI,x.MO,x.MN,x.MS,x.MTEXT,x.ANNOTATION_XML]),[N.SVG]:new Set([x.TITLE,x.FOREIGN_OBJECT,x.DESC]),[N.XLINK]:new Set,[N.XML]:new Set,[N.XMLNS]:new Set},Tn=new Set([x.H1,x.H2,x.H3,x.H4,x.H5,x.H6]),Xc=new Set([b.STYLE,b.SCRIPT,b.XMP,b.IFRAME,b.NOEMBED,b.NOFRAMES,b.PLAINTEXT]);function Qc(e,t){return Xc.has(e)||t&&e===b.NOSCRIPT}var f;(function(e){e[e.DATA=0]="DATA",e[e.RCDATA=1]="RCDATA",e[e.RAWTEXT=2]="RAWTEXT",e[e.SCRIPT_DATA=3]="SCRIPT_DATA",e[e.PLAINTEXT=4]="PLAINTEXT",e[e.TAG_OPEN=5]="TAG_OPEN",e[e.END_TAG_OPEN=6]="END_TAG_OPEN",e[e.TAG_NAME=7]="TAG_NAME",e[e.RCDATA_LESS_THAN_SIGN=8]="RCDATA_LESS_THAN_SIGN",e[e.RCDATA_END_TAG_OPEN=9]="RCDATA_END_TAG_OPEN",e[e.RCDATA_END_TAG_NAME=10]="RCDATA_END_TAG_NAME",e[e.RAWTEXT_LESS_THAN_SIGN=11]="RAWTEXT_LESS_THAN_SIGN",e[e.RAWTEXT_END_TAG_OPEN=12]="RAWTEXT_END_TAG_OPEN",e[e.RAWTEXT_END_TAG_NAME=13]="RAWTEXT_END_TAG_NAME",e[e.SCRIPT_DATA_LESS_THAN_SIGN=14]="SCRIPT_DATA_LESS_THAN_SIGN",e[e.SCRIPT_DATA_END_TAG_OPEN=15]="SCRIPT_DATA_END_TAG_OPEN",e[e.SCRIPT_DATA_END_TAG_NAME=16]="SCRIPT_DATA_END_TAG_NAME",e[e.SCRIPT_DATA_ESCAPE_START=17]="SCRIPT_DATA_ESCAPE_START",e[e.SCRIPT_DATA_ESCAPE_START_DASH=18]="SCRIPT_DATA_ESCAPE_START_DASH",e[e.SCRIPT_DATA_ESCAPED=19]="SCRIPT_DATA_ESCAPED",e[e.SCRIPT_DATA_ESCAPED_DASH=20]="SCRIPT_DATA_ESCAPED_DASH",e[e.SCRIPT_DATA_ESCAPED_DASH_DASH=21]="SCRIPT_DATA_ESCAPED_DASH_DASH",e[e.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN=22]="SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN",e[e.SCRIPT_DATA_ESCAPED_END_TAG_OPEN=23]="SCRIPT_DATA_ESCAPED_END_TAG_OPEN",e[e.SCRIPT_DATA_ESCAPED_END_TAG_NAME=24]="SCRIPT_DATA_ESCAPED_END_TAG_NAME",e[e.SCRIPT_DATA_DOUBLE_ESCAPE_START=25]="SCRIPT_DATA_DOUBLE_ESCAPE_START",e[e.SCRIPT_DATA_DOUBLE_ESCAPED=26]="SCRIPT_DATA_DOUBLE_ESCAPED",e[e.SCRIPT_DATA_DOUBLE_ESCAPED_DASH=27]="SCRIPT_DATA_DOUBLE_ESCAPED_DASH",e[e.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH=28]="SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH",e[e.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN=29]="SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN",e[e.SCRIPT_DATA_DOUBLE_ESCAPE_END=30]="SCRIPT_DATA_DOUBLE_ESCAPE_END",e[e.BEFORE_ATTRIBUTE_NAME=31]="BEFORE_ATTRIBUTE_NAME",e[e.ATTRIBUTE_NAME=32]="ATTRIBUTE_NAME",e[e.AFTER_ATTRIBUTE_NAME=33]="AFTER_ATTRIBUTE_NAME",e[e.BEFORE_ATTRIBUTE_VALUE=34]="BEFORE_ATTRIBUTE_VALUE",e[e.ATTRIBUTE_VALUE_DOUBLE_QUOTED=35]="ATTRIBUTE_VALUE_DOUBLE_QUOTED",e[e.ATTRIBUTE_VALUE_SINGLE_QUOTED=36]="ATTRIBUTE_VALUE_SINGLE_QUOTED",e[e.ATTRIBUTE_VALUE_UNQUOTED=37]="ATTRIBUTE_VALUE_UNQUOTED",e[e.AFTER_ATTRIBUTE_VALUE_QUOTED=38]="AFTER_ATTRIBUTE_VALUE_QUOTED",e[e.SELF_CLOSING_START_TAG=39]="SELF_CLOSING_START_TAG",e[e.BOGUS_COMMENT=40]="BOGUS_COMMENT",e[e.MARKUP_DECLARATION_OPEN=41]="MARKUP_DECLARATION_OPEN",e[e.COMMENT_START=42]="COMMENT_START",e[e.COMMENT_START_DASH=43]="COMMENT_START_DASH",e[e.COMMENT=44]="COMMENT",e[e.COMMENT_LESS_THAN_SIGN=45]="COMMENT_LESS_THAN_SIGN",e[e.COMMENT_LESS_THAN_SIGN_BANG=46]="COMMENT_LESS_THAN_SIGN_BANG",e[e.COMMENT_LESS_THAN_SIGN_BANG_DASH=47]="COMMENT_LESS_THAN_SIGN_BANG_DASH",e[e.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH=48]="COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH",e[e.COMMENT_END_DASH=49]="COMMENT_END_DASH",e[e.COMMENT_END=50]="COMMENT_END",e[e.COMMENT_END_BANG=51]="COMMENT_END_BANG",e[e.DOCTYPE=52]="DOCTYPE",e[e.BEFORE_DOCTYPE_NAME=53]="BEFORE_DOCTYPE_NAME",e[e.DOCTYPE_NAME=54]="DOCTYPE_NAME",e[e.AFTER_DOCTYPE_NAME=55]="AFTER_DOCTYPE_NAME",e[e.AFTER_DOCTYPE_PUBLIC_KEYWORD=56]="AFTER_DOCTYPE_PUBLIC_KEYWORD",e[e.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER=57]="BEFORE_DOCTYPE_PUBLIC_IDENTIFIER",e[e.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED=58]="DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED",e[e.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED=59]="DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED",e[e.AFTER_DOCTYPE_PUBLIC_IDENTIFIER=60]="AFTER_DOCTYPE_PUBLIC_IDENTIFIER",e[e.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS=61]="BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS",e[e.AFTER_DOCTYPE_SYSTEM_KEYWORD=62]="AFTER_DOCTYPE_SYSTEM_KEYWORD",e[e.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER=63]="BEFORE_DOCTYPE_SYSTEM_IDENTIFIER",e[e.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED=64]="DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED",e[e.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED=65]="DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED",e[e.AFTER_DOCTYPE_SYSTEM_IDENTIFIER=66]="AFTER_DOCTYPE_SYSTEM_IDENTIFIER",e[e.BOGUS_DOCTYPE=67]="BOGUS_DOCTYPE",e[e.CDATA_SECTION=68]="CDATA_SECTION",e[e.CDATA_SECTION_BRACKET=69]="CDATA_SECTION_BRACKET",e[e.CDATA_SECTION_END=70]="CDATA_SECTION_END",e[e.CHARACTER_REFERENCE=71]="CHARACTER_REFERENCE",e[e.AMBIGUOUS_AMPERSAND=72]="AMBIGUOUS_AMPERSAND"})(f||(f={}));const Ne={DATA:f.DATA,RCDATA:f.RCDATA,RAWTEXT:f.RAWTEXT,SCRIPT_DATA:f.SCRIPT_DATA,PLAINTEXT:f.PLAINTEXT,CDATA_SECTION:f.CDATA_SECTION};function jc(e){return e>=d.DIGIT_0&&e<=d.DIGIT_9}function Bt(e){return e>=d.LATIN_CAPITAL_A&&e<=d.LATIN_CAPITAL_Z}function zc(e){return e>=d.LATIN_SMALL_A&&e<=d.LATIN_SMALL_Z}function je(e){return zc(e)||Bt(e)}function zi(e){return je(e)||jc(e)}function ba(e){return e+32}function Ki(e){return e===d.SPACE||e===d.LINE_FEED||e===d.TABULATION||e===d.FORM_FEED}function Zi(e){return Ki(e)||e===d.SOLIDUS||e===d.GREATER_THAN_SIGN}function Kc(e){return e===d.NULL?g.nullCharacterReference:e>1114111?g.characterReferenceOutsideUnicodeRange:Gi(e)?g.surrogateCharacterReference:Qi(e)?g.noncharacterCharacterReference:Xi(e)||e===d.CARRIAGE_RETURN?g.controlCharacterReference:null}let Zc=class{constructor(t,a){this.options=t,this.handler=a,this.paused=!1,this.inLoop=!1,this.inForeignNode=!1,this.lastStartTagName="",this.active=!1,this.state=f.DATA,this.returnState=f.DATA,this.entityStartPos=0,this.consumedAfterSnapshot=-1,this.currentCharacterToken=null,this.currentToken=null,this.currentAttr={name:"",value:""},this.preprocessor=new $c(a),this.currentLocation=this.getCurrentLocation(-1),this.entityDecoder=new $a(Ha,(n,i)=>{this.preprocessor.pos=this.entityStartPos+i-1,this._flushCodePointConsumedAsCharacterReference(n)},a.onParseError?{missingSemicolonAfterCharacterReference:()=>{this._err(g.missingSemicolonAfterCharacterReference,1)},absenceOfDigitsInNumericCharacterReference:n=>{this._err(g.absenceOfDigitsInNumericCharacterReference,this.entityStartPos-this.preprocessor.pos+n)},validateNumericCharacterReference:n=>{const i=Kc(n);i&&this._err(i,1)}}:void 0)}_err(t,a=0){var n,i;(i=(n=this.handler).onParseError)===null||i===void 0||i.call(n,this.preprocessor.getError(t,a))}getCurrentLocation(t){return this.options.sourceCodeLocationInfo?{startLine:this.preprocessor.line,startCol:this.preprocessor.col-t,startOffset:this.preprocessor.offset-t,endLine:-1,endCol:-1,endOffset:-1}:null}_runParsingLoop(){if(!this.inLoop){for(this.inLoop=!0;this.active&&!this.paused;){this.consumedAfterSnapshot=0;const t=this._consume();this._ensureHibernation()||this._callState(t)}this.inLoop=!1}}pause(){this.paused=!0}resume(t){if(!this.paused)throw new Error("Parser was already resumed");this.paused=!1,!this.inLoop&&(this._runParsingLoop(),this.paused||t==null||t())}write(t,a,n){this.active=!0,this.preprocessor.write(t,a),this._runParsingLoop(),this.paused||n==null||n()}insertHtmlAtCurrentPos(t){this.active=!0,this.preprocessor.insertHtmlAtCurrentPos(t),this._runParsingLoop()}_ensureHibernation(){return this.preprocessor.endOfChunkHit?(this.preprocessor.retreat(this.consumedAfterSnapshot),this.consumedAfterSnapshot=0,this.active=!1,!0):!1}_consume(){return this.consumedAfterSnapshot++,this.preprocessor.advance()}_advanceBy(t){this.consumedAfterSnapshot+=t;for(let a=0;a<t;a++)this.preprocessor.advance()}_consumeSequenceIfMatch(t,a){return this.preprocessor.startsWith(t,a)?(this._advanceBy(t.length-1),!0):!1}_createStartTagToken(){this.currentToken={type:$.START_TAG,tagName:"",tagID:s.UNKNOWN,selfClosing:!1,ackSelfClosing:!1,attrs:[],location:this.getCurrentLocation(1)}}_createEndTagToken(){this.currentToken={type:$.END_TAG,tagName:"",tagID:s.UNKNOWN,selfClosing:!1,ackSelfClosing:!1,attrs:[],location:this.getCurrentLocation(2)}}_createCommentToken(t){this.currentToken={type:$.COMMENT,data:"",location:this.getCurrentLocation(t)}}_createDoctypeToken(t){this.currentToken={type:$.DOCTYPE,name:t,forceQuirks:!1,publicId:null,systemId:null,location:this.currentLocation}}_createCharacterToken(t,a){this.currentCharacterToken={type:t,chars:a,location:this.currentLocation}}_createAttr(t){this.currentAttr={name:t,value:""},this.currentLocation=this.getCurrentLocation(0)}_leaveAttrName(){var t,a;const n=this.currentToken;if(ji(n,this.currentAttr.name)===null){if(n.attrs.push(this.currentAttr),n.location&&this.currentLocation){const i=(t=(a=n.location).attrs)!==null&&t!==void 0?t:a.attrs=Object.create(null);i[this.currentAttr.name]=this.currentLocation,this._leaveAttrValue()}}else this._err(g.duplicateAttribute)}_leaveAttrValue(){this.currentLocation&&(this.currentLocation.endLine=this.preprocessor.line,this.currentLocation.endCol=this.preprocessor.col,this.currentLocation.endOffset=this.preprocessor.offset)}prepareToken(t){this._emitCurrentCharacterToken(t.location),this.currentToken=null,t.location&&(t.location.endLine=this.preprocessor.line,t.location.endCol=this.preprocessor.col+1,t.location.endOffset=this.preprocessor.offset+1),this.currentLocation=this.getCurrentLocation(-1)}emitCurrentTagToken(){const t=this.currentToken;this.prepareToken(t),t.tagID=Ta(t.tagName),t.type===$.START_TAG?(this.lastStartTagName=t.tagName,this.handler.onStartTag(t)):(t.attrs.length>0&&this._err(g.endTagWithAttributes),t.selfClosing&&this._err(g.endTagWithTrailingSolidus),this.handler.onEndTag(t)),this.preprocessor.dropParsedChunk()}emitCurrentComment(t){this.prepareToken(t),this.handler.onComment(t),this.preprocessor.dropParsedChunk()}emitCurrentDoctype(t){this.prepareToken(t),this.handler.onDoctype(t),this.preprocessor.dropParsedChunk()}_emitCurrentCharacterToken(t){if(this.currentCharacterToken){switch(t&&this.currentCharacterToken.location&&(this.currentCharacterToken.location.endLine=t.startLine,this.currentCharacterToken.location.endCol=t.startCol,this.currentCharacterToken.location.endOffset=t.startOffset),this.currentCharacterToken.type){case $.CHARACTER:{this.handler.onCharacter(this.currentCharacterToken);break}case $.NULL_CHARACTER:{this.handler.onNullCharacter(this.currentCharacterToken);break}case $.WHITESPACE_CHARACTER:{this.handler.onWhitespaceCharacter(this.currentCharacterToken);break}}this.currentCharacterToken=null}}_emitEOFToken(){const t=this.getCurrentLocation(0);t&&(t.endLine=t.startLine,t.endCol=t.startCol,t.endOffset=t.startOffset),this._emitCurrentCharacterToken(t),this.handler.onEof({type:$.EOF,location:t}),this.active=!1}_appendCharToCurrentCharacterToken(t,a){if(this.currentCharacterToken)if(this.currentCharacterToken.type===t){this.currentCharacterToken.chars+=a;return}else this.currentLocation=this.getCurrentLocation(0),this._emitCurrentCharacterToken(this.currentLocation),this.preprocessor.dropParsedChunk();this._createCharacterToken(t,a)}_emitCodePoint(t){const a=Ki(t)?$.WHITESPACE_CHARACTER:t===d.NULL?$.NULL_CHARACTER:$.CHARACTER;this._appendCharToCurrentCharacterToken(a,String.fromCodePoint(t))}_emitChars(t){this._appendCharToCurrentCharacterToken($.CHARACTER,t)}_startCharacterReference(){this.returnState=this.state,this.state=f.CHARACTER_REFERENCE,this.entityStartPos=this.preprocessor.pos,this.entityDecoder.startEntity(this._isCharacterReferenceInAttribute()?Oe.Attribute:Oe.Legacy)}_isCharacterReferenceInAttribute(){return this.returnState===f.ATTRIBUTE_VALUE_DOUBLE_QUOTED||this.returnState===f.ATTRIBUTE_VALUE_SINGLE_QUOTED||this.returnState===f.ATTRIBUTE_VALUE_UNQUOTED}_flushCodePointConsumedAsCharacterReference(t){this._isCharacterReferenceInAttribute()?this.currentAttr.value+=String.fromCodePoint(t):this._emitCodePoint(t)}_callState(t){switch(this.state){case f.DATA:{this._stateData(t);break}case f.RCDATA:{this._stateRcdata(t);break}case f.RAWTEXT:{this._stateRawtext(t);break}case f.SCRIPT_DATA:{this._stateScriptData(t);break}case f.PLAINTEXT:{this._statePlaintext(t);break}case f.TAG_OPEN:{this._stateTagOpen(t);break}case f.END_TAG_OPEN:{this._stateEndTagOpen(t);break}case f.TAG_NAME:{this._stateTagName(t);break}case f.RCDATA_LESS_THAN_SIGN:{this._stateRcdataLessThanSign(t);break}case f.RCDATA_END_TAG_OPEN:{this._stateRcdataEndTagOpen(t);break}case f.RCDATA_END_TAG_NAME:{this._stateRcdataEndTagName(t);break}case f.RAWTEXT_LESS_THAN_SIGN:{this._stateRawtextLessThanSign(t);break}case f.RAWTEXT_END_TAG_OPEN:{this._stateRawtextEndTagOpen(t);break}case f.RAWTEXT_END_TAG_NAME:{this._stateRawtextEndTagName(t);break}case f.SCRIPT_DATA_LESS_THAN_SIGN:{this._stateScriptDataLessThanSign(t);break}case f.SCRIPT_DATA_END_TAG_OPEN:{this._stateScriptDataEndTagOpen(t);break}case f.SCRIPT_DATA_END_TAG_NAME:{this._stateScriptDataEndTagName(t);break}case f.SCRIPT_DATA_ESCAPE_START:{this._stateScriptDataEscapeStart(t);break}case f.SCRIPT_DATA_ESCAPE_START_DASH:{this._stateScriptDataEscapeStartDash(t);break}case f.SCRIPT_DATA_ESCAPED:{this._stateScriptDataEscaped(t);break}case f.SCRIPT_DATA_ESCAPED_DASH:{this._stateScriptDataEscapedDash(t);break}case f.SCRIPT_DATA_ESCAPED_DASH_DASH:{this._stateScriptDataEscapedDashDash(t);break}case f.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN:{this._stateScriptDataEscapedLessThanSign(t);break}case f.SCRIPT_DATA_ESCAPED_END_TAG_OPEN:{this._stateScriptDataEscapedEndTagOpen(t);break}case f.SCRIPT_DATA_ESCAPED_END_TAG_NAME:{this._stateScriptDataEscapedEndTagName(t);break}case f.SCRIPT_DATA_DOUBLE_ESCAPE_START:{this._stateScriptDataDoubleEscapeStart(t);break}case f.SCRIPT_DATA_DOUBLE_ESCAPED:{this._stateScriptDataDoubleEscaped(t);break}case f.SCRIPT_DATA_DOUBLE_ESCAPED_DASH:{this._stateScriptDataDoubleEscapedDash(t);break}case f.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH:{this._stateScriptDataDoubleEscapedDashDash(t);break}case f.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN:{this._stateScriptDataDoubleEscapedLessThanSign(t);break}case f.SCRIPT_DATA_DOUBLE_ESCAPE_END:{this._stateScriptDataDoubleEscapeEnd(t);break}case f.BEFORE_ATTRIBUTE_NAME:{this._stateBeforeAttributeName(t);break}case f.ATTRIBUTE_NAME:{this._stateAttributeName(t);break}case f.AFTER_ATTRIBUTE_NAME:{this._stateAfterAttributeName(t);break}case f.BEFORE_ATTRIBUTE_VALUE:{this._stateBeforeAttributeValue(t);break}case f.ATTRIBUTE_VALUE_DOUBLE_QUOTED:{this._stateAttributeValueDoubleQuoted(t);break}case f.ATTRIBUTE_VALUE_SINGLE_QUOTED:{this._stateAttributeValueSingleQuoted(t);break}case f.ATTRIBUTE_VALUE_UNQUOTED:{this._stateAttributeValueUnquoted(t);break}case f.AFTER_ATTRIBUTE_VALUE_QUOTED:{this._stateAfterAttributeValueQuoted(t);break}case f.SELF_CLOSING_START_TAG:{this._stateSelfClosingStartTag(t);break}case f.BOGUS_COMMENT:{this._stateBogusComment(t);break}case f.MARKUP_DECLARATION_OPEN:{this._stateMarkupDeclarationOpen(t);break}case f.COMMENT_START:{this._stateCommentStart(t);break}case f.COMMENT_START_DASH:{this._stateCommentStartDash(t);break}case f.COMMENT:{this._stateComment(t);break}case f.COMMENT_LESS_THAN_SIGN:{this._stateCommentLessThanSign(t);break}case f.COMMENT_LESS_THAN_SIGN_BANG:{this._stateCommentLessThanSignBang(t);break}case f.COMMENT_LESS_THAN_SIGN_BANG_DASH:{this._stateCommentLessThanSignBangDash(t);break}case f.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH:{this._stateCommentLessThanSignBangDashDash(t);break}case f.COMMENT_END_DASH:{this._stateCommentEndDash(t);break}case f.COMMENT_END:{this._stateCommentEnd(t);break}case f.COMMENT_END_BANG:{this._stateCommentEndBang(t);break}case f.DOCTYPE:{this._stateDoctype(t);break}case f.BEFORE_DOCTYPE_NAME:{this._stateBeforeDoctypeName(t);break}case f.DOCTYPE_NAME:{this._stateDoctypeName(t);break}case f.AFTER_DOCTYPE_NAME:{this._stateAfterDoctypeName(t);break}case f.AFTER_DOCTYPE_PUBLIC_KEYWORD:{this._stateAfterDoctypePublicKeyword(t);break}case f.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER:{this._stateBeforeDoctypePublicIdentifier(t);break}case f.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED:{this._stateDoctypePublicIdentifierDoubleQuoted(t);break}case f.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED:{this._stateDoctypePublicIdentifierSingleQuoted(t);break}case f.AFTER_DOCTYPE_PUBLIC_IDENTIFIER:{this._stateAfterDoctypePublicIdentifier(t);break}case f.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS:{this._stateBetweenDoctypePublicAndSystemIdentifiers(t);break}case f.AFTER_DOCTYPE_SYSTEM_KEYWORD:{this._stateAfterDoctypeSystemKeyword(t);break}case f.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER:{this._stateBeforeDoctypeSystemIdentifier(t);break}case f.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED:{this._stateDoctypeSystemIdentifierDoubleQuoted(t);break}case f.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED:{this._stateDoctypeSystemIdentifierSingleQuoted(t);break}case f.AFTER_DOCTYPE_SYSTEM_IDENTIFIER:{this._stateAfterDoctypeSystemIdentifier(t);break}case f.BOGUS_DOCTYPE:{this._stateBogusDoctype(t);break}case f.CDATA_SECTION:{this._stateCdataSection(t);break}case f.CDATA_SECTION_BRACKET:{this._stateCdataSectionBracket(t);break}case f.CDATA_SECTION_END:{this._stateCdataSectionEnd(t);break}case f.CHARACTER_REFERENCE:{this._stateCharacterReference();break}case f.AMBIGUOUS_AMPERSAND:{this._stateAmbiguousAmpersand(t);break}default:throw new Error("Unknown state")}}_stateData(t){switch(t){case d.LESS_THAN_SIGN:{this.state=f.TAG_OPEN;break}case d.AMPERSAND:{this._startCharacterReference();break}case d.NULL:{this._err(g.unexpectedNullCharacter),this._emitCodePoint(t);break}case d.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateRcdata(t){switch(t){case d.AMPERSAND:{this._startCharacterReference();break}case d.LESS_THAN_SIGN:{this.state=f.RCDATA_LESS_THAN_SIGN;break}case d.NULL:{this._err(g.unexpectedNullCharacter),this._emitChars(Z);break}case d.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateRawtext(t){switch(t){case d.LESS_THAN_SIGN:{this.state=f.RAWTEXT_LESS_THAN_SIGN;break}case d.NULL:{this._err(g.unexpectedNullCharacter),this._emitChars(Z);break}case d.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateScriptData(t){switch(t){case d.LESS_THAN_SIGN:{this.state=f.SCRIPT_DATA_LESS_THAN_SIGN;break}case d.NULL:{this._err(g.unexpectedNullCharacter),this._emitChars(Z);break}case d.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(t)}}_statePlaintext(t){switch(t){case d.NULL:{this._err(g.unexpectedNullCharacter),this._emitChars(Z);break}case d.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateTagOpen(t){if(je(t))this._createStartTagToken(),this.state=f.TAG_NAME,this._stateTagName(t);else switch(t){case d.EXCLAMATION_MARK:{this.state=f.MARKUP_DECLARATION_OPEN;break}case d.SOLIDUS:{this.state=f.END_TAG_OPEN;break}case d.QUESTION_MARK:{this._err(g.unexpectedQuestionMarkInsteadOfTagName),this._createCommentToken(1),this.state=f.BOGUS_COMMENT,this._stateBogusComment(t);break}case d.EOF:{this._err(g.eofBeforeTagName),this._emitChars("<"),this._emitEOFToken();break}default:this._err(g.invalidFirstCharacterOfTagName),this._emitChars("<"),this.state=f.DATA,this._stateData(t)}}_stateEndTagOpen(t){if(je(t))this._createEndTagToken(),this.state=f.TAG_NAME,this._stateTagName(t);else switch(t){case d.GREATER_THAN_SIGN:{this._err(g.missingEndTagName),this.state=f.DATA;break}case d.EOF:{this._err(g.eofBeforeTagName),this._emitChars("</"),this._emitEOFToken();break}default:this._err(g.invalidFirstCharacterOfTagName),this._createCommentToken(2),this.state=f.BOGUS_COMMENT,this._stateBogusComment(t)}}_stateTagName(t){const a=this.currentToken;switch(t){case d.SPACE:case d.LINE_FEED:case d.TABULATION:case d.FORM_FEED:{this.state=f.BEFORE_ATTRIBUTE_NAME;break}case d.SOLIDUS:{this.state=f.SELF_CLOSING_START_TAG;break}case d.GREATER_THAN_SIGN:{this.state=f.DATA,this.emitCurrentTagToken();break}case d.NULL:{this._err(g.unexpectedNullCharacter),a.tagName+=Z;break}case d.EOF:{this._err(g.eofInTag),this._emitEOFToken();break}default:a.tagName+=String.fromCodePoint(Bt(t)?ba(t):t)}}_stateRcdataLessThanSign(t){t===d.SOLIDUS?this.state=f.RCDATA_END_TAG_OPEN:(this._emitChars("<"),this.state=f.RCDATA,this._stateRcdata(t))}_stateRcdataEndTagOpen(t){je(t)?(this.state=f.RCDATA_END_TAG_NAME,this._stateRcdataEndTagName(t)):(this._emitChars("</"),this.state=f.RCDATA,this._stateRcdata(t))}handleSpecialEndTag(t){if(!this.preprocessor.startsWith(this.lastStartTagName,!1))return!this._ensureHibernation();this._createEndTagToken();const a=this.currentToken;switch(a.tagName=this.lastStartTagName,this.preprocessor.peek(this.lastStartTagName.length)){case d.SPACE:case d.LINE_FEED:case d.TABULATION:case d.FORM_FEED:return this._advanceBy(this.lastStartTagName.length),this.state=f.BEFORE_ATTRIBUTE_NAME,!1;case d.SOLIDUS:return this._advanceBy(this.lastStartTagName.length),this.state=f.SELF_CLOSING_START_TAG,!1;case d.GREATER_THAN_SIGN:return this._advanceBy(this.lastStartTagName.length),this.emitCurrentTagToken(),this.state=f.DATA,!1;default:return!this._ensureHibernation()}}_stateRcdataEndTagName(t){this.handleSpecialEndTag(t)&&(this._emitChars("</"),this.state=f.RCDATA,this._stateRcdata(t))}_stateRawtextLessThanSign(t){t===d.SOLIDUS?this.state=f.RAWTEXT_END_TAG_OPEN:(this._emitChars("<"),this.state=f.RAWTEXT,this._stateRawtext(t))}_stateRawtextEndTagOpen(t){je(t)?(this.state=f.RAWTEXT_END_TAG_NAME,this._stateRawtextEndTagName(t)):(this._emitChars("</"),this.state=f.RAWTEXT,this._stateRawtext(t))}_stateRawtextEndTagName(t){this.handleSpecialEndTag(t)&&(this._emitChars("</"),this.state=f.RAWTEXT,this._stateRawtext(t))}_stateScriptDataLessThanSign(t){switch(t){case d.SOLIDUS:{this.state=f.SCRIPT_DATA_END_TAG_OPEN;break}case d.EXCLAMATION_MARK:{this.state=f.SCRIPT_DATA_ESCAPE_START,this._emitChars("<!");break}default:this._emitChars("<"),this.state=f.SCRIPT_DATA,this._stateScriptData(t)}}_stateScriptDataEndTagOpen(t){je(t)?(this.state=f.SCRIPT_DATA_END_TAG_NAME,this._stateScriptDataEndTagName(t)):(this._emitChars("</"),this.state=f.SCRIPT_DATA,this._stateScriptData(t))}_stateScriptDataEndTagName(t){this.handleSpecialEndTag(t)&&(this._emitChars("</"),this.state=f.SCRIPT_DATA,this._stateScriptData(t))}_stateScriptDataEscapeStart(t){t===d.HYPHEN_MINUS?(this.state=f.SCRIPT_DATA_ESCAPE_START_DASH,this._emitChars("-")):(this.state=f.SCRIPT_DATA,this._stateScriptData(t))}_stateScriptDataEscapeStartDash(t){t===d.HYPHEN_MINUS?(this.state=f.SCRIPT_DATA_ESCAPED_DASH_DASH,this._emitChars("-")):(this.state=f.SCRIPT_DATA,this._stateScriptData(t))}_stateScriptDataEscaped(t){switch(t){case d.HYPHEN_MINUS:{this.state=f.SCRIPT_DATA_ESCAPED_DASH,this._emitChars("-");break}case d.LESS_THAN_SIGN:{this.state=f.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;break}case d.NULL:{this._err(g.unexpectedNullCharacter),this._emitChars(Z);break}case d.EOF:{this._err(g.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateScriptDataEscapedDash(t){switch(t){case d.HYPHEN_MINUS:{this.state=f.SCRIPT_DATA_ESCAPED_DASH_DASH,this._emitChars("-");break}case d.LESS_THAN_SIGN:{this.state=f.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;break}case d.NULL:{this._err(g.unexpectedNullCharacter),this.state=f.SCRIPT_DATA_ESCAPED,this._emitChars(Z);break}case d.EOF:{this._err(g.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this.state=f.SCRIPT_DATA_ESCAPED,this._emitCodePoint(t)}}_stateScriptDataEscapedDashDash(t){switch(t){case d.HYPHEN_MINUS:{this._emitChars("-");break}case d.LESS_THAN_SIGN:{this.state=f.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;break}case d.GREATER_THAN_SIGN:{this.state=f.SCRIPT_DATA,this._emitChars(">");break}case d.NULL:{this._err(g.unexpectedNullCharacter),this.state=f.SCRIPT_DATA_ESCAPED,this._emitChars(Z);break}case d.EOF:{this._err(g.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this.state=f.SCRIPT_DATA_ESCAPED,this._emitCodePoint(t)}}_stateScriptDataEscapedLessThanSign(t){t===d.SOLIDUS?this.state=f.SCRIPT_DATA_ESCAPED_END_TAG_OPEN:je(t)?(this._emitChars("<"),this.state=f.SCRIPT_DATA_DOUBLE_ESCAPE_START,this._stateScriptDataDoubleEscapeStart(t)):(this._emitChars("<"),this.state=f.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(t))}_stateScriptDataEscapedEndTagOpen(t){je(t)?(this.state=f.SCRIPT_DATA_ESCAPED_END_TAG_NAME,this._stateScriptDataEscapedEndTagName(t)):(this._emitChars("</"),this.state=f.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(t))}_stateScriptDataEscapedEndTagName(t){this.handleSpecialEndTag(t)&&(this._emitChars("</"),this.state=f.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(t))}_stateScriptDataDoubleEscapeStart(t){if(this.preprocessor.startsWith(Ae.SCRIPT,!1)&&Zi(this.preprocessor.peek(Ae.SCRIPT.length))){this._emitCodePoint(t);for(let a=0;a<Ae.SCRIPT.length;a++)this._emitCodePoint(this._consume());this.state=f.SCRIPT_DATA_DOUBLE_ESCAPED}else this._ensureHibernation()||(this.state=f.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(t))}_stateScriptDataDoubleEscaped(t){switch(t){case d.HYPHEN_MINUS:{this.state=f.SCRIPT_DATA_DOUBLE_ESCAPED_DASH,this._emitChars("-");break}case d.LESS_THAN_SIGN:{this.state=f.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN,this._emitChars("<");break}case d.NULL:{this._err(g.unexpectedNullCharacter),this._emitChars(Z);break}case d.EOF:{this._err(g.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateScriptDataDoubleEscapedDash(t){switch(t){case d.HYPHEN_MINUS:{this.state=f.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH,this._emitChars("-");break}case d.LESS_THAN_SIGN:{this.state=f.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN,this._emitChars("<");break}case d.NULL:{this._err(g.unexpectedNullCharacter),this.state=f.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitChars(Z);break}case d.EOF:{this._err(g.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this.state=f.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitCodePoint(t)}}_stateScriptDataDoubleEscapedDashDash(t){switch(t){case d.HYPHEN_MINUS:{this._emitChars("-");break}case d.LESS_THAN_SIGN:{this.state=f.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN,this._emitChars("<");break}case d.GREATER_THAN_SIGN:{this.state=f.SCRIPT_DATA,this._emitChars(">");break}case d.NULL:{this._err(g.unexpectedNullCharacter),this.state=f.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitChars(Z);break}case d.EOF:{this._err(g.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this.state=f.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitCodePoint(t)}}_stateScriptDataDoubleEscapedLessThanSign(t){t===d.SOLIDUS?(this.state=f.SCRIPT_DATA_DOUBLE_ESCAPE_END,this._emitChars("/")):(this.state=f.SCRIPT_DATA_DOUBLE_ESCAPED,this._stateScriptDataDoubleEscaped(t))}_stateScriptDataDoubleEscapeEnd(t){if(this.preprocessor.startsWith(Ae.SCRIPT,!1)&&Zi(this.preprocessor.peek(Ae.SCRIPT.length))){this._emitCodePoint(t);for(let a=0;a<Ae.SCRIPT.length;a++)this._emitCodePoint(this._consume());this.state=f.SCRIPT_DATA_ESCAPED}else this._ensureHibernation()||(this.state=f.SCRIPT_DATA_DOUBLE_ESCAPED,this._stateScriptDataDoubleEscaped(t))}_stateBeforeAttributeName(t){switch(t){case d.SPACE:case d.LINE_FEED:case d.TABULATION:case d.FORM_FEED:break;case d.SOLIDUS:case d.GREATER_THAN_SIGN:case d.EOF:{this.state=f.AFTER_ATTRIBUTE_NAME,this._stateAfterAttributeName(t);break}case d.EQUALS_SIGN:{this._err(g.unexpectedEqualsSignBeforeAttributeName),this._createAttr("="),this.state=f.ATTRIBUTE_NAME;break}default:this._createAttr(""),this.state=f.ATTRIBUTE_NAME,this._stateAttributeName(t)}}_stateAttributeName(t){switch(t){case d.SPACE:case d.LINE_FEED:case d.TABULATION:case d.FORM_FEED:case d.SOLIDUS:case d.GREATER_THAN_SIGN:case d.EOF:{this._leaveAttrName(),this.state=f.AFTER_ATTRIBUTE_NAME,this._stateAfterAttributeName(t);break}case d.EQUALS_SIGN:{this._leaveAttrName(),this.state=f.BEFORE_ATTRIBUTE_VALUE;break}case d.QUOTATION_MARK:case d.APOSTROPHE:case d.LESS_THAN_SIGN:{this._err(g.unexpectedCharacterInAttributeName),this.currentAttr.name+=String.fromCodePoint(t);break}case d.NULL:{this._err(g.unexpectedNullCharacter),this.currentAttr.name+=Z;break}default:this.currentAttr.name+=String.fromCodePoint(Bt(t)?ba(t):t)}}_stateAfterAttributeName(t){switch(t){case d.SPACE:case d.LINE_FEED:case d.TABULATION:case d.FORM_FEED:break;case d.SOLIDUS:{this.state=f.SELF_CLOSING_START_TAG;break}case d.EQUALS_SIGN:{this.state=f.BEFORE_ATTRIBUTE_VALUE;break}case d.GREATER_THAN_SIGN:{this.state=f.DATA,this.emitCurrentTagToken();break}case d.EOF:{this._err(g.eofInTag),this._emitEOFToken();break}default:this._createAttr(""),this.state=f.ATTRIBUTE_NAME,this._stateAttributeName(t)}}_stateBeforeAttributeValue(t){switch(t){case d.SPACE:case d.LINE_FEED:case d.TABULATION:case d.FORM_FEED:break;case d.QUOTATION_MARK:{this.state=f.ATTRIBUTE_VALUE_DOUBLE_QUOTED;break}case d.APOSTROPHE:{this.state=f.ATTRIBUTE_VALUE_SINGLE_QUOTED;break}case d.GREATER_THAN_SIGN:{this._err(g.missingAttributeValue),this.state=f.DATA,this.emitCurrentTagToken();break}default:this.state=f.ATTRIBUTE_VALUE_UNQUOTED,this._stateAttributeValueUnquoted(t)}}_stateAttributeValueDoubleQuoted(t){switch(t){case d.QUOTATION_MARK:{this.state=f.AFTER_ATTRIBUTE_VALUE_QUOTED;break}case d.AMPERSAND:{this._startCharacterReference();break}case d.NULL:{this._err(g.unexpectedNullCharacter),this.currentAttr.value+=Z;break}case d.EOF:{this._err(g.eofInTag),this._emitEOFToken();break}default:this.currentAttr.value+=String.fromCodePoint(t)}}_stateAttributeValueSingleQuoted(t){switch(t){case d.APOSTROPHE:{this.state=f.AFTER_ATTRIBUTE_VALUE_QUOTED;break}case d.AMPERSAND:{this._startCharacterReference();break}case d.NULL:{this._err(g.unexpectedNullCharacter),this.currentAttr.value+=Z;break}case d.EOF:{this._err(g.eofInTag),this._emitEOFToken();break}default:this.currentAttr.value+=String.fromCodePoint(t)}}_stateAttributeValueUnquoted(t){switch(t){case d.SPACE:case d.LINE_FEED:case d.TABULATION:case d.FORM_FEED:{this._leaveAttrValue(),this.state=f.BEFORE_ATTRIBUTE_NAME;break}case d.AMPERSAND:{this._startCharacterReference();break}case d.GREATER_THAN_SIGN:{this._leaveAttrValue(),this.state=f.DATA,this.emitCurrentTagToken();break}case d.NULL:{this._err(g.unexpectedNullCharacter),this.currentAttr.value+=Z;break}case d.QUOTATION_MARK:case d.APOSTROPHE:case d.LESS_THAN_SIGN:case d.EQUALS_SIGN:case d.GRAVE_ACCENT:{this._err(g.unexpectedCharacterInUnquotedAttributeValue),this.currentAttr.value+=String.fromCodePoint(t);break}case d.EOF:{this._err(g.eofInTag),this._emitEOFToken();break}default:this.currentAttr.value+=String.fromCodePoint(t)}}_stateAfterAttributeValueQuoted(t){switch(t){case d.SPACE:case d.LINE_FEED:case d.TABULATION:case d.FORM_FEED:{this._leaveAttrValue(),this.state=f.BEFORE_ATTRIBUTE_NAME;break}case d.SOLIDUS:{this._leaveAttrValue(),this.state=f.SELF_CLOSING_START_TAG;break}case d.GREATER_THAN_SIGN:{this._leaveAttrValue(),this.state=f.DATA,this.emitCurrentTagToken();break}case d.EOF:{this._err(g.eofInTag),this._emitEOFToken();break}default:this._err(g.missingWhitespaceBetweenAttributes),this.state=f.BEFORE_ATTRIBUTE_NAME,this._stateBeforeAttributeName(t)}}_stateSelfClosingStartTag(t){switch(t){case d.GREATER_THAN_SIGN:{const a=this.currentToken;a.selfClosing=!0,this.state=f.DATA,this.emitCurrentTagToken();break}case d.EOF:{this._err(g.eofInTag),this._emitEOFToken();break}default:this._err(g.unexpectedSolidusInTag),this.state=f.BEFORE_ATTRIBUTE_NAME,this._stateBeforeAttributeName(t)}}_stateBogusComment(t){const a=this.currentToken;switch(t){case d.GREATER_THAN_SIGN:{this.state=f.DATA,this.emitCurrentComment(a);break}case d.EOF:{this.emitCurrentComment(a),this._emitEOFToken();break}case d.NULL:{this._err(g.unexpectedNullCharacter),a.data+=Z;break}default:a.data+=String.fromCodePoint(t)}}_stateMarkupDeclarationOpen(t){this._consumeSequenceIfMatch(Ae.DASH_DASH,!0)?(this._createCommentToken(Ae.DASH_DASH.length+1),this.state=f.COMMENT_START):this._consumeSequenceIfMatch(Ae.DOCTYPE,!1)?(this.currentLocation=this.getCurrentLocation(Ae.DOCTYPE.length+1),this.state=f.DOCTYPE):this._consumeSequenceIfMatch(Ae.CDATA_START,!0)?this.inForeignNode?this.state=f.CDATA_SECTION:(this._err(g.cdataInHtmlContent),this._createCommentToken(Ae.CDATA_START.length+1),this.currentToken.data="[CDATA[",this.state=f.BOGUS_COMMENT):this._ensureHibernation()||(this._err(g.incorrectlyOpenedComment),this._createCommentToken(2),this.state=f.BOGUS_COMMENT,this._stateBogusComment(t))}_stateCommentStart(t){switch(t){case d.HYPHEN_MINUS:{this.state=f.COMMENT_START_DASH;break}case d.GREATER_THAN_SIGN:{this._err(g.abruptClosingOfEmptyComment),this.state=f.DATA;const a=this.currentToken;this.emitCurrentComment(a);break}default:this.state=f.COMMENT,this._stateComment(t)}}_stateCommentStartDash(t){const a=this.currentToken;switch(t){case d.HYPHEN_MINUS:{this.state=f.COMMENT_END;break}case d.GREATER_THAN_SIGN:{this._err(g.abruptClosingOfEmptyComment),this.state=f.DATA,this.emitCurrentComment(a);break}case d.EOF:{this._err(g.eofInComment),this.emitCurrentComment(a),this._emitEOFToken();break}default:a.data+="-",this.state=f.COMMENT,this._stateComment(t)}}_stateComment(t){const a=this.currentToken;switch(t){case d.HYPHEN_MINUS:{this.state=f.COMMENT_END_DASH;break}case d.LESS_THAN_SIGN:{a.data+="<",this.state=f.COMMENT_LESS_THAN_SIGN;break}case d.NULL:{this._err(g.unexpectedNullCharacter),a.data+=Z;break}case d.EOF:{this._err(g.eofInComment),this.emitCurrentComment(a),this._emitEOFToken();break}default:a.data+=String.fromCodePoint(t)}}_stateCommentLessThanSign(t){const a=this.currentToken;switch(t){case d.EXCLAMATION_MARK:{a.data+="!",this.state=f.COMMENT_LESS_THAN_SIGN_BANG;break}case d.LESS_THAN_SIGN:{a.data+="<";break}default:this.state=f.COMMENT,this._stateComment(t)}}_stateCommentLessThanSignBang(t){t===d.HYPHEN_MINUS?this.state=f.COMMENT_LESS_THAN_SIGN_BANG_DASH:(this.state=f.COMMENT,this._stateComment(t))}_stateCommentLessThanSignBangDash(t){t===d.HYPHEN_MINUS?this.state=f.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH:(this.state=f.COMMENT_END_DASH,this._stateCommentEndDash(t))}_stateCommentLessThanSignBangDashDash(t){t!==d.GREATER_THAN_SIGN&&t!==d.EOF&&this._err(g.nestedComment),this.state=f.COMMENT_END,this._stateCommentEnd(t)}_stateCommentEndDash(t){const a=this.currentToken;switch(t){case d.HYPHEN_MINUS:{this.state=f.COMMENT_END;break}case d.EOF:{this._err(g.eofInComment),this.emitCurrentComment(a),this._emitEOFToken();break}default:a.data+="-",this.state=f.COMMENT,this._stateComment(t)}}_stateCommentEnd(t){const a=this.currentToken;switch(t){case d.GREATER_THAN_SIGN:{this.state=f.DATA,this.emitCurrentComment(a);break}case d.EXCLAMATION_MARK:{this.state=f.COMMENT_END_BANG;break}case d.HYPHEN_MINUS:{a.data+="-";break}case d.EOF:{this._err(g.eofInComment),this.emitCurrentComment(a),this._emitEOFToken();break}default:a.data+="--",this.state=f.COMMENT,this._stateComment(t)}}_stateCommentEndBang(t){const a=this.currentToken;switch(t){case d.HYPHEN_MINUS:{a.data+="--!",this.state=f.COMMENT_END_DASH;break}case d.GREATER_THAN_SIGN:{this._err(g.incorrectlyClosedComment),this.state=f.DATA,this.emitCurrentComment(a);break}case d.EOF:{this._err(g.eofInComment),this.emitCurrentComment(a),this._emitEOFToken();break}default:a.data+="--!",this.state=f.COMMENT,this._stateComment(t)}}_stateDoctype(t){switch(t){case d.SPACE:case d.LINE_FEED:case d.TABULATION:case d.FORM_FEED:{this.state=f.BEFORE_DOCTYPE_NAME;break}case d.GREATER_THAN_SIGN:{this.state=f.BEFORE_DOCTYPE_NAME,this._stateBeforeDoctypeName(t);break}case d.EOF:{this._err(g.eofInDoctype),this._createDoctypeToken(null);const a=this.currentToken;a.forceQuirks=!0,this.emitCurrentDoctype(a),this._emitEOFToken();break}default:this._err(g.missingWhitespaceBeforeDoctypeName),this.state=f.BEFORE_DOCTYPE_NAME,this._stateBeforeDoctypeName(t)}}_stateBeforeDoctypeName(t){if(Bt(t))this._createDoctypeToken(String.fromCharCode(ba(t))),this.state=f.DOCTYPE_NAME;else switch(t){case d.SPACE:case d.LINE_FEED:case d.TABULATION:case d.FORM_FEED:break;case d.NULL:{this._err(g.unexpectedNullCharacter),this._createDoctypeToken(Z),this.state=f.DOCTYPE_NAME;break}case d.GREATER_THAN_SIGN:{this._err(g.missingDoctypeName),this._createDoctypeToken(null);const a=this.currentToken;a.forceQuirks=!0,this.emitCurrentDoctype(a),this.state=f.DATA;break}case d.EOF:{this._err(g.eofInDoctype),this._createDoctypeToken(null);const a=this.currentToken;a.forceQuirks=!0,this.emitCurrentDoctype(a),this._emitEOFToken();break}default:this._createDoctypeToken(String.fromCodePoint(t)),this.state=f.DOCTYPE_NAME}}_stateDoctypeName(t){const a=this.currentToken;switch(t){case d.SPACE:case d.LINE_FEED:case d.TABULATION:case d.FORM_FEED:{this.state=f.AFTER_DOCTYPE_NAME;break}case d.GREATER_THAN_SIGN:{this.state=f.DATA,this.emitCurrentDoctype(a);break}case d.NULL:{this._err(g.unexpectedNullCharacter),a.name+=Z;break}case d.EOF:{this._err(g.eofInDoctype),a.forceQuirks=!0,this.emitCurrentDoctype(a),this._emitEOFToken();break}default:a.name+=String.fromCodePoint(Bt(t)?ba(t):t)}}_stateAfterDoctypeName(t){const a=this.currentToken;switch(t){case d.SPACE:case d.LINE_FEED:case d.TABULATION:case d.FORM_FEED:break;case d.GREATER_THAN_SIGN:{this.state=f.DATA,this.emitCurrentDoctype(a);break}case d.EOF:{this._err(g.eofInDoctype),a.forceQuirks=!0,this.emitCurrentDoctype(a),this._emitEOFToken();break}default:this._consumeSequenceIfMatch(Ae.PUBLIC,!1)?this.state=f.AFTER_DOCTYPE_PUBLIC_KEYWORD:this._consumeSequenceIfMatch(Ae.SYSTEM,!1)?this.state=f.AFTER_DOCTYPE_SYSTEM_KEYWORD:this._ensureHibernation()||(this._err(g.invalidCharacterSequenceAfterDoctypeName),a.forceQuirks=!0,this.state=f.BOGUS_DOCTYPE,this._stateBogusDoctype(t))}}_stateAfterDoctypePublicKeyword(t){const a=this.currentToken;switch(t){case d.SPACE:case d.LINE_FEED:case d.TABULATION:case d.FORM_FEED:{this.state=f.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER;break}case d.QUOTATION_MARK:{this._err(g.missingWhitespaceAfterDoctypePublicKeyword),a.publicId="",this.state=f.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED;break}case d.APOSTROPHE:{this._err(g.missingWhitespaceAfterDoctypePublicKeyword),a.publicId="",this.state=f.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED;break}case d.GREATER_THAN_SIGN:{this._err(g.missingDoctypePublicIdentifier),a.forceQuirks=!0,this.state=f.DATA,this.emitCurrentDoctype(a);break}case d.EOF:{this._err(g.eofInDoctype),a.forceQuirks=!0,this.emitCurrentDoctype(a),this._emitEOFToken();break}default:this._err(g.missingQuoteBeforeDoctypePublicIdentifier),a.forceQuirks=!0,this.state=f.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateBeforeDoctypePublicIdentifier(t){const a=this.currentToken;switch(t){case d.SPACE:case d.LINE_FEED:case d.TABULATION:case d.FORM_FEED:break;case d.QUOTATION_MARK:{a.publicId="",this.state=f.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED;break}case d.APOSTROPHE:{a.publicId="",this.state=f.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED;break}case d.GREATER_THAN_SIGN:{this._err(g.missingDoctypePublicIdentifier),a.forceQuirks=!0,this.state=f.DATA,this.emitCurrentDoctype(a);break}case d.EOF:{this._err(g.eofInDoctype),a.forceQuirks=!0,this.emitCurrentDoctype(a),this._emitEOFToken();break}default:this._err(g.missingQuoteBeforeDoctypePublicIdentifier),a.forceQuirks=!0,this.state=f.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateDoctypePublicIdentifierDoubleQuoted(t){const a=this.currentToken;switch(t){case d.QUOTATION_MARK:{this.state=f.AFTER_DOCTYPE_PUBLIC_IDENTIFIER;break}case d.NULL:{this._err(g.unexpectedNullCharacter),a.publicId+=Z;break}case d.GREATER_THAN_SIGN:{this._err(g.abruptDoctypePublicIdentifier),a.forceQuirks=!0,this.emitCurrentDoctype(a),this.state=f.DATA;break}case d.EOF:{this._err(g.eofInDoctype),a.forceQuirks=!0,this.emitCurrentDoctype(a),this._emitEOFToken();break}default:a.publicId+=String.fromCodePoint(t)}}_stateDoctypePublicIdentifierSingleQuoted(t){const a=this.currentToken;switch(t){case d.APOSTROPHE:{this.state=f.AFTER_DOCTYPE_PUBLIC_IDENTIFIER;break}case d.NULL:{this._err(g.unexpectedNullCharacter),a.publicId+=Z;break}case d.GREATER_THAN_SIGN:{this._err(g.abruptDoctypePublicIdentifier),a.forceQuirks=!0,this.emitCurrentDoctype(a),this.state=f.DATA;break}case d.EOF:{this._err(g.eofInDoctype),a.forceQuirks=!0,this.emitCurrentDoctype(a),this._emitEOFToken();break}default:a.publicId+=String.fromCodePoint(t)}}_stateAfterDoctypePublicIdentifier(t){const a=this.currentToken;switch(t){case d.SPACE:case d.LINE_FEED:case d.TABULATION:case d.FORM_FEED:{this.state=f.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS;break}case d.GREATER_THAN_SIGN:{this.state=f.DATA,this.emitCurrentDoctype(a);break}case d.QUOTATION_MARK:{this._err(g.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers),a.systemId="",this.state=f.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break}case d.APOSTROPHE:{this._err(g.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers),a.systemId="",this.state=f.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break}case d.EOF:{this._err(g.eofInDoctype),a.forceQuirks=!0,this.emitCurrentDoctype(a),this._emitEOFToken();break}default:this._err(g.missingQuoteBeforeDoctypeSystemIdentifier),a.forceQuirks=!0,this.state=f.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateBetweenDoctypePublicAndSystemIdentifiers(t){const a=this.currentToken;switch(t){case d.SPACE:case d.LINE_FEED:case d.TABULATION:case d.FORM_FEED:break;case d.GREATER_THAN_SIGN:{this.emitCurrentDoctype(a),this.state=f.DATA;break}case d.QUOTATION_MARK:{a.systemId="",this.state=f.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break}case d.APOSTROPHE:{a.systemId="",this.state=f.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break}case d.EOF:{this._err(g.eofInDoctype),a.forceQuirks=!0,this.emitCurrentDoctype(a),this._emitEOFToken();break}default:this._err(g.missingQuoteBeforeDoctypeSystemIdentifier),a.forceQuirks=!0,this.state=f.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateAfterDoctypeSystemKeyword(t){const a=this.currentToken;switch(t){case d.SPACE:case d.LINE_FEED:case d.TABULATION:case d.FORM_FEED:{this.state=f.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER;break}case d.QUOTATION_MARK:{this._err(g.missingWhitespaceAfterDoctypeSystemKeyword),a.systemId="",this.state=f.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break}case d.APOSTROPHE:{this._err(g.missingWhitespaceAfterDoctypeSystemKeyword),a.systemId="",this.state=f.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break}case d.GREATER_THAN_SIGN:{this._err(g.missingDoctypeSystemIdentifier),a.forceQuirks=!0,this.state=f.DATA,this.emitCurrentDoctype(a);break}case d.EOF:{this._err(g.eofInDoctype),a.forceQuirks=!0,this.emitCurrentDoctype(a),this._emitEOFToken();break}default:this._err(g.missingQuoteBeforeDoctypeSystemIdentifier),a.forceQuirks=!0,this.state=f.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateBeforeDoctypeSystemIdentifier(t){const a=this.currentToken;switch(t){case d.SPACE:case d.LINE_FEED:case d.TABULATION:case d.FORM_FEED:break;case d.QUOTATION_MARK:{a.systemId="",this.state=f.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break}case d.APOSTROPHE:{a.systemId="",this.state=f.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break}case d.GREATER_THAN_SIGN:{this._err(g.missingDoctypeSystemIdentifier),a.forceQuirks=!0,this.state=f.DATA,this.emitCurrentDoctype(a);break}case d.EOF:{this._err(g.eofInDoctype),a.forceQuirks=!0,this.emitCurrentDoctype(a),this._emitEOFToken();break}default:this._err(g.missingQuoteBeforeDoctypeSystemIdentifier),a.forceQuirks=!0,this.state=f.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateDoctypeSystemIdentifierDoubleQuoted(t){const a=this.currentToken;switch(t){case d.QUOTATION_MARK:{this.state=f.AFTER_DOCTYPE_SYSTEM_IDENTIFIER;break}case d.NULL:{this._err(g.unexpectedNullCharacter),a.systemId+=Z;break}case d.GREATER_THAN_SIGN:{this._err(g.abruptDoctypeSystemIdentifier),a.forceQuirks=!0,this.emitCurrentDoctype(a),this.state=f.DATA;break}case d.EOF:{this._err(g.eofInDoctype),a.forceQuirks=!0,this.emitCurrentDoctype(a),this._emitEOFToken();break}default:a.systemId+=String.fromCodePoint(t)}}_stateDoctypeSystemIdentifierSingleQuoted(t){const a=this.currentToken;switch(t){case d.APOSTROPHE:{this.state=f.AFTER_DOCTYPE_SYSTEM_IDENTIFIER;break}case d.NULL:{this._err(g.unexpectedNullCharacter),a.systemId+=Z;break}case d.GREATER_THAN_SIGN:{this._err(g.abruptDoctypeSystemIdentifier),a.forceQuirks=!0,this.emitCurrentDoctype(a),this.state=f.DATA;break}case d.EOF:{this._err(g.eofInDoctype),a.forceQuirks=!0,this.emitCurrentDoctype(a),this._emitEOFToken();break}default:a.systemId+=String.fromCodePoint(t)}}_stateAfterDoctypeSystemIdentifier(t){const a=this.currentToken;switch(t){case d.SPACE:case d.LINE_FEED:case d.TABULATION:case d.FORM_FEED:break;case d.GREATER_THAN_SIGN:{this.emitCurrentDoctype(a),this.state=f.DATA;break}case d.EOF:{this._err(g.eofInDoctype),a.forceQuirks=!0,this.emitCurrentDoctype(a),this._emitEOFToken();break}default:this._err(g.unexpectedCharacterAfterDoctypeSystemIdentifier),this.state=f.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateBogusDoctype(t){const a=this.currentToken;switch(t){case d.GREATER_THAN_SIGN:{this.emitCurrentDoctype(a),this.state=f.DATA;break}case d.NULL:{this._err(g.unexpectedNullCharacter);break}case d.EOF:{this.emitCurrentDoctype(a),this._emitEOFToken();break}}}_stateCdataSection(t){switch(t){case d.RIGHT_SQUARE_BRACKET:{this.state=f.CDATA_SECTION_BRACKET;break}case d.EOF:{this._err(g.eofInCdata),this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateCdataSectionBracket(t){t===d.RIGHT_SQUARE_BRACKET?this.state=f.CDATA_SECTION_END:(this._emitChars("]"),this.state=f.CDATA_SECTION,this._stateCdataSection(t))}_stateCdataSectionEnd(t){switch(t){case d.GREATER_THAN_SIGN:{this.state=f.DATA;break}case d.RIGHT_SQUARE_BRACKET:{this._emitChars("]");break}default:this._emitChars("]]"),this.state=f.CDATA_SECTION,this._stateCdataSection(t)}}_stateCharacterReference(){let t=this.entityDecoder.write(this.preprocessor.html,this.preprocessor.pos);if(t<0)if(this.preprocessor.lastChunkWritten)t=this.entityDecoder.end();else{this.active=!1,this.preprocessor.pos=this.preprocessor.html.length-1,this.consumedAfterSnapshot=0,this.preprocessor.endOfChunkHit=!0;return}t===0?(this.preprocessor.pos=this.entityStartPos,this._flushCodePointConsumedAsCharacterReference(d.AMPERSAND),this.state=!this._isCharacterReferenceInAttribute()&&zi(this.preprocessor.peek(1))?f.AMBIGUOUS_AMPERSAND:this.returnState):this.state=this.returnState}_stateAmbiguousAmpersand(t){zi(t)?this._flushCodePointConsumedAsCharacterReference(t):(t===d.SEMICOLON&&this._err(g.unknownNamedCharacterReference),this.state=this.returnState,this._callState(t))}};const Ji=new Set([s.DD,s.DT,s.LI,s.OPTGROUP,s.OPTION,s.P,s.RB,s.RP,s.RT,s.RTC]),es=new Set([...Ji,s.CAPTION,s.COLGROUP,s.TBODY,s.TD,s.TFOOT,s.TH,s.THEAD,s.TR]),ga=new Set([s.APPLET,s.CAPTION,s.HTML,s.MARQUEE,s.OBJECT,s.TABLE,s.TD,s.TEMPLATE,s.TH]),Jc=new Set([...ga,s.OL,s.UL]),el=new Set([...ga,s.BUTTON]),ts=new Set([s.ANNOTATION_XML,s.MI,s.MN,s.MO,s.MS,s.MTEXT]),as=new Set([s.DESC,s.FOREIGN_OBJECT,s.TITLE]),tl=new Set([s.TR,s.TEMPLATE,s.HTML]),al=new Set([s.TBODY,s.TFOOT,s.THEAD,s.TEMPLATE,s.HTML]),nl=new Set([s.TABLE,s.TEMPLATE,s.HTML]),il=new Set([s.TD,s.TH]);class sl{get currentTmplContentOrNode(){return this._isInTemplate()?this.treeAdapter.getTemplateContent(this.current):this.current}constructor(t,a,n){this.treeAdapter=a,this.handler=n,this.items=[],this.tagIDs=[],this.stackTop=-1,this.tmplCount=0,this.currentTagId=s.UNKNOWN,this.current=t}_indexOf(t){return this.items.lastIndexOf(t,this.stackTop)}_isInTemplate(){return this.currentTagId===s.TEMPLATE&&this.treeAdapter.getNamespaceURI(this.current)===N.HTML}_updateCurrentElement(){this.current=this.items[this.stackTop],this.currentTagId=this.tagIDs[this.stackTop]}push(t,a){this.stackTop++,this.items[this.stackTop]=t,this.current=t,this.tagIDs[this.stackTop]=a,this.currentTagId=a,this._isInTemplate()&&this.tmplCount++,this.handler.onItemPush(t,a,!0)}pop(){const t=this.current;this.tmplCount>0&&this._isInTemplate()&&this.tmplCount--,this.stackTop--,this._updateCurrentElement(),this.handler.onItemPop(t,!0)}replace(t,a){const n=this._indexOf(t);this.items[n]=a,n===this.stackTop&&(this.current=a)}insertAfter(t,a,n){const i=this._indexOf(t)+1;this.items.splice(i,0,a),this.tagIDs.splice(i,0,n),this.stackTop++,i===this.stackTop&&this._updateCurrentElement(),this.handler.onItemPush(this.current,this.currentTagId,i===this.stackTop)}popUntilTagNamePopped(t){let a=this.stackTop+1;do a=this.tagIDs.lastIndexOf(t,a-1);while(a>0&&this.treeAdapter.getNamespaceURI(this.items[a])!==N.HTML);this.shortenToLength(a<0?0:a)}shortenToLength(t){for(;this.stackTop>=t;){const a=this.current;this.tmplCount>0&&this._isInTemplate()&&(this.tmplCount-=1),this.stackTop--,this._updateCurrentElement(),this.handler.onItemPop(a,this.stackTop<t)}}popUntilElementPopped(t){const a=this._indexOf(t);this.shortenToLength(a<0?0:a)}popUntilPopped(t,a){const n=this._indexOfTagNames(t,a);this.shortenToLength(n<0?0:n)}popUntilNumberedHeaderPopped(){this.popUntilPopped(Tn,N.HTML)}popUntilTableCellPopped(){this.popUntilPopped(il,N.HTML)}popAllUpToHtmlElement(){this.tmplCount=0,this.shortenToLength(1)}_indexOfTagNames(t,a){for(let n=this.stackTop;n>=0;n--)if(t.has(this.tagIDs[n])&&this.treeAdapter.getNamespaceURI(this.items[n])===a)return n;return-1}clearBackTo(t,a){const n=this._indexOfTagNames(t,a);this.shortenToLength(n+1)}clearBackToTableContext(){this.clearBackTo(nl,N.HTML)}clearBackToTableBodyContext(){this.clearBackTo(al,N.HTML)}clearBackToTableRowContext(){this.clearBackTo(tl,N.HTML)}remove(t){const a=this._indexOf(t);a>=0&&(a===this.stackTop?this.pop():(this.items.splice(a,1),this.tagIDs.splice(a,1),this.stackTop--,this._updateCurrentElement(),this.handler.onItemPop(t,!1)))}tryPeekProperlyNestedBodyElement(){return this.stackTop>=1&&this.tagIDs[1]===s.BODY?this.items[1]:null}contains(t){return this._indexOf(t)>-1}getCommonAncestor(t){const a=this._indexOf(t)-1;return a>=0?this.items[a]:null}isRootHtmlElementCurrent(){return this.stackTop===0&&this.tagIDs[0]===s.HTML}hasInDynamicScope(t,a){for(let n=this.stackTop;n>=0;n--){const i=this.tagIDs[n];switch(this.treeAdapter.getNamespaceURI(this.items[n])){case N.HTML:{if(i===t)return!0;if(a.has(i))return!1;break}case N.SVG:{if(as.has(i))return!1;break}case N.MATHML:{if(ts.has(i))return!1;break}}}return!0}hasInScope(t){return this.hasInDynamicScope(t,ga)}hasInListItemScope(t){return this.hasInDynamicScope(t,Jc)}hasInButtonScope(t){return this.hasInDynamicScope(t,el)}hasNumberedHeaderInScope(){for(let t=this.stackTop;t>=0;t--){const a=this.tagIDs[t];switch(this.treeAdapter.getNamespaceURI(this.items[t])){case N.HTML:{if(Tn.has(a))return!0;if(ga.has(a))return!1;break}case N.SVG:{if(as.has(a))return!1;break}case N.MATHML:{if(ts.has(a))return!1;break}}}return!0}hasInTableScope(t){for(let a=this.stackTop;a>=0;a--)if(this.treeAdapter.getNamespaceURI(this.items[a])===N.HTML)switch(this.tagIDs[a]){case t:return!0;case s.TABLE:case s.HTML:return!1}return!0}hasTableBodyContextInTableScope(){for(let t=this.stackTop;t>=0;t--)if(this.treeAdapter.getNamespaceURI(this.items[t])===N.HTML)switch(this.tagIDs[t]){case s.TBODY:case s.THEAD:case s.TFOOT:return!0;case s.TABLE:case s.HTML:return!1}return!0}hasInSelectScope(t){for(let a=this.stackTop;a>=0;a--)if(this.treeAdapter.getNamespaceURI(this.items[a])===N.HTML)switch(this.tagIDs[a]){case t:return!0;case s.OPTION:case s.OPTGROUP:break;default:return!1}return!0}generateImpliedEndTags(){for(;Ji.has(this.currentTagId);)this.pop()}generateImpliedEndTagsThoroughly(){for(;es.has(this.currentTagId);)this.pop()}generateImpliedEndTagsWithExclusion(t){for(;this.currentTagId!==t&&es.has(this.currentTagId);)this.pop()}}const bn=3;var we;(function(e){e[e.Marker=0]="Marker",e[e.Element=1]="Element"})(we||(we={}));const ns={type:we.Marker};class rl{constructor(t){this.treeAdapter=t,this.entries=[],this.bookmark=null}_getNoahArkConditionCandidates(t,a){const n=[],i=a.length,r=this.treeAdapter.getTagName(t),u=this.treeAdapter.getNamespaceURI(t);for(let o=0;o<this.entries.length;o++){const l=this.entries[o];if(l.type===we.Marker)break;const{element:h}=l;if(this.treeAdapter.getTagName(h)===r&&this.treeAdapter.getNamespaceURI(h)===u){const m=this.treeAdapter.getAttrList(h);m.length===i&&n.push({idx:o,attrs:m})}}return n}_ensureNoahArkCondition(t){if(this.entries.length<bn)return;const a=this.treeAdapter.getAttrList(t),n=this._getNoahArkConditionCandidates(t,a);if(n.length<bn)return;const i=new Map(a.map(u=>[u.name,u.value]));let r=0;for(let u=0;u<n.length;u++){const o=n[u];o.attrs.every(l=>i.get(l.name)===l.value)&&(r+=1,r>=bn&&this.entries.splice(o.idx,1))}}insertMarker(){this.entries.unshift(ns)}pushElement(t,a){this._ensureNoahArkCondition(t),this.entries.unshift({type:we.Element,element:t,token:a})}insertElementAfterBookmark(t,a){const n=this.entries.indexOf(this.bookmark);this.entries.splice(n,0,{type:we.Element,element:t,token:a})}removeEntry(t){const a=this.entries.indexOf(t);a>=0&&this.entries.splice(a,1)}clearToLastMarker(){const t=this.entries.indexOf(ns);t>=0?this.entries.splice(0,t+1):this.entries.length=0}getElementEntryInScopeWithTagName(t){const a=this.entries.find(n=>n.type===we.Marker||this.treeAdapter.getTagName(n.element)===t);return a&&a.type===we.Element?a:null}getElementEntry(t){return this.entries.find(a=>a.type===we.Element&&a.element===t)}}const Ye={createDocument(){return{nodeName:"#document",mode:Se.NO_QUIRKS,childNodes:[]}},createDocumentFragment(){return{nodeName:"#document-fragment",childNodes:[]}},createElement(e,t,a){return{nodeName:e,tagName:e,attrs:a,namespaceURI:t,childNodes:[],parentNode:null}},createCommentNode(e){return{nodeName:"#comment",data:e,parentNode:null}},createTextNode(e){return{nodeName:"#text",value:e,parentNode:null}},appendChild(e,t){e.childNodes.push(t),t.parentNode=e},insertBefore(e,t,a){const n=e.childNodes.indexOf(a);e.childNodes.splice(n,0,t),t.parentNode=e},setTemplateContent(e,t){e.content=t},getTemplateContent(e){return e.content},setDocumentType(e,t,a,n){const i=e.childNodes.find(r=>r.nodeName==="#documentType");if(i)i.name=t,i.publicId=a,i.systemId=n;else{const r={nodeName:"#documentType",name:t,publicId:a,systemId:n,parentNode:null};Ye.appendChild(e,r)}},setDocumentMode(e,t){e.mode=t},getDocumentMode(e){return e.mode},detachNode(e){if(e.parentNode){const t=e.parentNode.childNodes.indexOf(e);e.parentNode.childNodes.splice(t,1),e.parentNode=null}},insertText(e,t){if(e.childNodes.length>0){const a=e.childNodes[e.childNodes.length-1];if(Ye.isTextNode(a)){a.value+=t;return}}Ye.appendChild(e,Ye.createTextNode(t))},insertTextBefore(e,t,a){const n=e.childNodes[e.childNodes.indexOf(a)-1];n&&Ye.isTextNode(n)?n.value+=t:Ye.insertBefore(e,Ye.createTextNode(t),a)},adoptAttributes(e,t){const a=new Set(e.attrs.map(n=>n.name));for(let n=0;n<t.length;n++)a.has(t[n].name)||e.attrs.push(t[n])},getFirstChild(e){return e.childNodes[0]},getChildNodes(e){return e.childNodes},getParentNode(e){return e.parentNode},getAttrList(e){return e.attrs},getTagName(e){return e.tagName},getNamespaceURI(e){return e.namespaceURI},getTextNodeContent(e){return e.value},getCommentNodeContent(e){return e.data},getDocumentTypeNodeName(e){return e.name},getDocumentTypeNodePublicId(e){return e.publicId},getDocumentTypeNodeSystemId(e){return e.systemId},isTextNode(e){return e.nodeName==="#text"},isCommentNode(e){return e.nodeName==="#comment"},isDocumentTypeNode(e){return e.nodeName==="#documentType"},isElementNode(e){return Object.prototype.hasOwnProperty.call(e,"tagName")},setNodeSourceCodeLocation(e,t){e.sourceCodeLocation=t},getNodeSourceCodeLocation(e){return e.sourceCodeLocation},updateNodeSourceCodeLocation(e,t){e.sourceCodeLocation={...e.sourceCodeLocation,...t}}},is="html",ul="about:legacy-compat",ol="http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd",ss=["+//silmaril//dtd html pro v0r11 19970101//","-//as//dtd html 3.0 aswedit + extensions//","-//advasoft ltd//dtd html 3.0 aswedit + extensions//","-//ietf//dtd html 2.0 level 1//","-//ietf//dtd html 2.0 level 2//","-//ietf//dtd html 2.0 strict level 1//","-//ietf//dtd html 2.0 strict level 2//","-//ietf//dtd html 2.0 strict//","-//ietf//dtd html 2.0//","-//ietf//dtd html 2.1e//","-//ietf//dtd html 3.0//","-//ietf//dtd html 3.2 final//","-//ietf//dtd html 3.2//","-//ietf//dtd html 3//","-//ietf//dtd html level 0//","-//ietf//dtd html level 1//","-//ietf//dtd html level 2//","-//ietf//dtd html level 3//","-//ietf//dtd html strict level 0//","-//ietf//dtd html strict level 1//","-//ietf//dtd html strict level 2//","-//ietf//dtd html strict level 3//","-//ietf//dtd html strict//","-//ietf//dtd html//","-//metrius//dtd metrius presentational//","-//microsoft//dtd internet explorer 2.0 html strict//","-//microsoft//dtd internet explorer 2.0 html//","-//microsoft//dtd internet explorer 2.0 tables//","-//microsoft//dtd internet explorer 3.0 html strict//","-//microsoft//dtd internet explorer 3.0 html//","-//microsoft//dtd internet explorer 3.0 tables//","-//netscape comm. corp.//dtd html//","-//netscape comm. corp.//dtd strict html//","-//o'reilly and associates//dtd html 2.0//","-//o'reilly and associates//dtd html extended 1.0//","-//o'reilly and associates//dtd html extended relaxed 1.0//","-//sq//dtd html 2.0 hotmetal + extensions//","-//softquad software//dtd hotmetal pro 6.0::19990601::extensions to html 4.0//","-//softquad//dtd hotmetal pro 4.0::19971010::extensions to html 4.0//","-//spyglass//dtd html 2.0 extended//","-//sun microsystems corp.//dtd hotjava html//","-//sun microsystems corp.//dtd hotjava strict html//","-//w3c//dtd html 3 1995-03-24//","-//w3c//dtd html 3.2 draft//","-//w3c//dtd html 3.2 final//","-//w3c//dtd html 3.2//","-//w3c//dtd html 3.2s draft//","-//w3c//dtd html 4.0 frameset//","-//w3c//dtd html 4.0 transitional//","-//w3c//dtd html experimental 19960712//","-//w3c//dtd html experimental 970421//","-//w3c//dtd w3 html//","-//w3o//dtd w3 html 3.0//","-//webtechs//dtd mozilla html 2.0//","-//webtechs//dtd mozilla html//"],cl=[...ss,"-//w3c//dtd html 4.01 frameset//","-//w3c//dtd html 4.01 transitional//"],ll=new Set(["-//w3o//dtd w3 html strict 3.0//en//","-/w3c/dtd html 4.0 transitional/en","html"]),rs=["-//w3c//dtd xhtml 1.0 frameset//","-//w3c//dtd xhtml 1.0 transitional//"],dl=[...rs,"-//w3c//dtd html 4.01 frameset//","-//w3c//dtd html 4.01 transitional//"];function us(e,t){return t.some(a=>e.startsWith(a))}function hl(e){return e.name===is&&e.publicId===null&&(e.systemId===null||e.systemId===ul)}function fl(e){if(e.name!==is)return Se.QUIRKS;const{systemId:t}=e;if(t&&t.toLowerCase()===ol)return Se.QUIRKS;let{publicId:a}=e;if(a!==null){if(a=a.toLowerCase(),ll.has(a))return Se.QUIRKS;let n=t===null?cl:ss;if(us(a,n))return Se.QUIRKS;if(n=t===null?rs:dl,us(a,n))return Se.LIMITED_QUIRKS}return Se.NO_QUIRKS}const os={TEXT_HTML:"text/html",APPLICATION_XML:"application/xhtml+xml"},ml="definitionurl",El="definitionURL",pl=new Map(["attributeName","attributeType","baseFrequency","baseProfile","calcMode","clipPathUnits","diffuseConstant","edgeMode","filterUnits","glyphRef","gradientTransform","gradientUnits","kernelMatrix","kernelUnitLength","keyPoints","keySplines","keyTimes","lengthAdjust","limitingConeAngle","markerHeight","markerUnits","markerWidth","maskContentUnits","maskUnits","numOctaves","pathLength","patternContentUnits","patternTransform","patternUnits","pointsAtX","pointsAtY","pointsAtZ","preserveAlpha","preserveAspectRatio","primitiveUnits","refX","refY","repeatCount","repeatDur","requiredExtensions","requiredFeatures","specularConstant","specularExponent","spreadMethod","startOffset","stdDeviation","stitchTiles","surfaceScale","systemLanguage","tableValues","targetX","targetY","textLength","viewBox","viewTarget","xChannelSelector","yChannelSelector","zoomAndPan"].map(e=>[e.toLowerCase(),e])),Tl=new Map([["xlink:actuate",{prefix:"xlink",name:"actuate",namespace:N.XLINK}],["xlink:arcrole",{prefix:"xlink",name:"arcrole",namespace:N.XLINK}],["xlink:href",{prefix:"xlink",name:"href",namespace:N.XLINK}],["xlink:role",{prefix:"xlink",name:"role",namespace:N.XLINK}],["xlink:show",{prefix:"xlink",name:"show",namespace:N.XLINK}],["xlink:title",{prefix:"xlink",name:"title",namespace:N.XLINK}],["xlink:type",{prefix:"xlink",name:"type",namespace:N.XLINK}],["xml:lang",{prefix:"xml",name:"lang",namespace:N.XML}],["xml:space",{prefix:"xml",name:"space",namespace:N.XML}],["xmlns",{prefix:"",name:"xmlns",namespace:N.XMLNS}],["xmlns:xlink",{prefix:"xmlns",name:"xlink",namespace:N.XMLNS}]]),bl=new Map(["altGlyph","altGlyphDef","altGlyphItem","animateColor","animateMotion","animateTransform","clipPath","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","foreignObject","glyphRef","linearGradient","radialGradient","textPath"].map(e=>[e.toLowerCase(),e])),gl=new Set([s.B,s.BIG,s.BLOCKQUOTE,s.BODY,s.BR,s.CENTER,s.CODE,s.DD,s.DIV,s.DL,s.DT,s.EM,s.EMBED,s.H1,s.H2,s.H3,s.H4,s.H5,s.H6,s.HEAD,s.HR,s.I,s.IMG,s.LI,s.LISTING,s.MENU,s.META,s.NOBR,s.OL,s.P,s.PRE,s.RUBY,s.S,s.SMALL,s.SPAN,s.STRONG,s.STRIKE,s.SUB,s.SUP,s.TABLE,s.TT,s.U,s.UL,s.VAR]);function _l(e){const t=e.tagID;return t===s.FONT&&e.attrs.some(({name:n})=>n===ut.COLOR||n===ut.SIZE||n===ut.FACE)||gl.has(t)}function cs(e){for(let t=0;t<e.attrs.length;t++)if(e.attrs[t].name===ml){e.attrs[t].name=El;break}}function ls(e){for(let t=0;t<e.attrs.length;t++){const a=pl.get(e.attrs[t].name);a!=null&&(e.attrs[t].name=a)}}function gn(e){for(let t=0;t<e.attrs.length;t++){const a=Tl.get(e.attrs[t].name);a&&(e.attrs[t].prefix=a.prefix,e.attrs[t].name=a.name,e.attrs[t].namespace=a.namespace)}}function Al(e){const t=bl.get(e.tagName);t!=null&&(e.tagName=t,e.tagID=Ta(e.tagName))}function Nl(e,t){return t===N.MATHML&&(e===s.MI||e===s.MO||e===s.MN||e===s.MS||e===s.MTEXT)}function Cl(e,t,a){if(t===N.MATHML&&e===s.ANNOTATION_XML){for(let n=0;n<a.length;n++)if(a[n].name===ut.ENCODING){const i=a[n].value.toLowerCase();return i===os.TEXT_HTML||i===os.APPLICATION_XML}}return t===N.SVG&&(e===s.FOREIGN_OBJECT||e===s.DESC||e===s.TITLE)}function Il(e,t,a,n){return(!n||n===N.HTML)&&Cl(e,t,a)||(!n||n===N.MATHML)&&Nl(e,t)}const Sl="hidden",xl=8,Ol=3;var E;(function(e){e[e.INITIAL=0]="INITIAL",e[e.BEFORE_HTML=1]="BEFORE_HTML",e[e.BEFORE_HEAD=2]="BEFORE_HEAD",e[e.IN_HEAD=3]="IN_HEAD",e[e.IN_HEAD_NO_SCRIPT=4]="IN_HEAD_NO_SCRIPT",e[e.AFTER_HEAD=5]="AFTER_HEAD",e[e.IN_BODY=6]="IN_BODY",e[e.TEXT=7]="TEXT",e[e.IN_TABLE=8]="IN_TABLE",e[e.IN_TABLE_TEXT=9]="IN_TABLE_TEXT",e[e.IN_CAPTION=10]="IN_CAPTION",e[e.IN_COLUMN_GROUP=11]="IN_COLUMN_GROUP",e[e.IN_TABLE_BODY=12]="IN_TABLE_BODY",e[e.IN_ROW=13]="IN_ROW",e[e.IN_CELL=14]="IN_CELL",e[e.IN_SELECT=15]="IN_SELECT",e[e.IN_SELECT_IN_TABLE=16]="IN_SELECT_IN_TABLE",e[e.IN_TEMPLATE=17]="IN_TEMPLATE",e[e.AFTER_BODY=18]="AFTER_BODY",e[e.IN_FRAMESET=19]="IN_FRAMESET",e[e.AFTER_FRAMESET=20]="AFTER_FRAMESET",e[e.AFTER_AFTER_BODY=21]="AFTER_AFTER_BODY",e[e.AFTER_AFTER_FRAMESET=22]="AFTER_AFTER_FRAMESET"})(E||(E={}));const Dl={startLine:-1,startCol:-1,startOffset:-1,endLine:-1,endCol:-1,endOffset:-1},ds=new Set([s.TABLE,s.TBODY,s.TFOOT,s.THEAD,s.TR]),hs={scriptingEnabled:!0,sourceCodeLocationInfo:!1,treeAdapter:Ye,onParseError:null};let fs=class{constructor(t,a,n=null,i=null){this.fragmentContext=n,this.scriptHandler=i,this.currentToken=null,this.stopped=!1,this.insertionMode=E.INITIAL,this.originalInsertionMode=E.INITIAL,this.headElement=null,this.formElement=null,this.currentNotInHTML=!1,this.tmplInsertionModeStack=[],this.pendingCharacterTokens=[],this.hasNonWhitespacePendingCharacterToken=!1,this.framesetOk=!0,this.skipNextNewLine=!1,this.fosterParentingEnabled=!1,this.options={...hs,...t},this.treeAdapter=this.options.treeAdapter,this.onParseError=this.options.onParseError,this.onParseError&&(this.options.sourceCodeLocationInfo=!0),this.document=a??this.treeAdapter.createDocument(),this.tokenizer=new Zc(this.options,this),this.activeFormattingElements=new rl(this.treeAdapter),this.fragmentContextID=n?Ta(this.treeAdapter.getTagName(n)):s.UNKNOWN,this._setContextModes(n??this.document,this.fragmentContextID),this.openElements=new sl(this.document,this.treeAdapter,this)}static parse(t,a){const n=new this(a);return n.tokenizer.write(t,!0),n.document}static getFragmentParser(t,a){const n={...hs,...a};t??(t=n.treeAdapter.createElement(b.TEMPLATE,N.HTML,[]));const i=n.treeAdapter.createElement("documentmock",N.HTML,[]),r=new this(n,i,t);return r.fragmentContextID===s.TEMPLATE&&r.tmplInsertionModeStack.unshift(E.IN_TEMPLATE),r._initTokenizerForFragmentParsing(),r._insertFakeRootElement(),r._resetInsertionMode(),r._findFormInFragmentContext(),r}getFragment(){const t=this.treeAdapter.getFirstChild(this.document),a=this.treeAdapter.createDocumentFragment();return this._adoptNodes(t,a),a}_err(t,a,n){var i;if(!this.onParseError)return;const r=(i=t.location)!==null&&i!==void 0?i:Dl,u={code:a,startLine:r.startLine,startCol:r.startCol,startOffset:r.startOffset,endLine:n?r.startLine:r.endLine,endCol:n?r.startCol:r.endCol,endOffset:n?r.startOffset:r.endOffset};this.onParseError(u)}onItemPush(t,a,n){var i,r;(r=(i=this.treeAdapter).onItemPush)===null||r===void 0||r.call(i,t),n&&this.openElements.stackTop>0&&this._setContextModes(t,a)}onItemPop(t,a){var n,i;if(this.options.sourceCodeLocationInfo&&this._setEndLocation(t,this.currentToken),(i=(n=this.treeAdapter).onItemPop)===null||i===void 0||i.call(n,t,this.openElements.current),a){let r,u;this.openElements.stackTop===0&&this.fragmentContext?(r=this.fragmentContext,u=this.fragmentContextID):{current:r,currentTagId:u}=this.openElements,this._setContextModes(r,u)}}_setContextModes(t,a){const n=t===this.document||this.treeAdapter.getNamespaceURI(t)===N.HTML;this.currentNotInHTML=!n,this.tokenizer.inForeignNode=!n&&!this._isIntegrationPoint(a,t)}_switchToTextParsing(t,a){this._insertElement(t,N.HTML),this.tokenizer.state=a,this.originalInsertionMode=this.insertionMode,this.insertionMode=E.TEXT}switchToPlaintextParsing(){this.insertionMode=E.TEXT,this.originalInsertionMode=E.IN_BODY,this.tokenizer.state=Ne.PLAINTEXT}_getAdjustedCurrentElement(){return this.openElements.stackTop===0&&this.fragmentContext?this.fragmentContext:this.openElements.current}_findFormInFragmentContext(){let t=this.fragmentContext;for(;t;){if(this.treeAdapter.getTagName(t)===b.FORM){this.formElement=t;break}t=this.treeAdapter.getParentNode(t)}}_initTokenizerForFragmentParsing(){if(!(!this.fragmentContext||this.treeAdapter.getNamespaceURI(this.fragmentContext)!==N.HTML))switch(this.fragmentContextID){case s.TITLE:case s.TEXTAREA:{this.tokenizer.state=Ne.RCDATA;break}case s.STYLE:case s.XMP:case s.IFRAME:case s.NOEMBED:case s.NOFRAMES:case s.NOSCRIPT:{this.tokenizer.state=Ne.RAWTEXT;break}case s.SCRIPT:{this.tokenizer.state=Ne.SCRIPT_DATA;break}case s.PLAINTEXT:{this.tokenizer.state=Ne.PLAINTEXT;break}}}_setDocumentType(t){const a=t.name||"",n=t.publicId||"",i=t.systemId||"";if(this.treeAdapter.setDocumentType(this.document,a,n,i),t.location){const u=this.treeAdapter.getChildNodes(this.document).find(o=>this.treeAdapter.isDocumentTypeNode(o));u&&this.treeAdapter.setNodeSourceCodeLocation(u,t.location)}}_attachElementToTree(t,a){if(this.options.sourceCodeLocationInfo){const n=a&&{...a,startTag:a};this.treeAdapter.setNodeSourceCodeLocation(t,n)}if(this._shouldFosterParentOnInsertion())this._fosterParentElement(t);else{const n=this.openElements.currentTmplContentOrNode;this.treeAdapter.appendChild(n,t)}}_appendElement(t,a){const n=this.treeAdapter.createElement(t.tagName,a,t.attrs);this._attachElementToTree(n,t.location)}_insertElement(t,a){const n=this.treeAdapter.createElement(t.tagName,a,t.attrs);this._attachElementToTree(n,t.location),this.openElements.push(n,t.tagID)}_insertFakeElement(t,a){const n=this.treeAdapter.createElement(t,N.HTML,[]);this._attachElementToTree(n,null),this.openElements.push(n,a)}_insertTemplate(t){const a=this.treeAdapter.createElement(t.tagName,N.HTML,t.attrs),n=this.treeAdapter.createDocumentFragment();this.treeAdapter.setTemplateContent(a,n),this._attachElementToTree(a,t.location),this.openElements.push(a,t.tagID),this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(n,null)}_insertFakeRootElement(){const t=this.treeAdapter.createElement(b.HTML,N.HTML,[]);this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(t,null),this.treeAdapter.appendChild(this.openElements.current,t),this.openElements.push(t,s.HTML)}_appendCommentNode(t,a){const n=this.treeAdapter.createCommentNode(t.data);this.treeAdapter.appendChild(a,n),this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(n,t.location)}_insertCharacters(t){let a,n;if(this._shouldFosterParentOnInsertion()?({parent:a,beforeElement:n}=this._findFosterParentingLocation(),n?this.treeAdapter.insertTextBefore(a,t.chars,n):this.treeAdapter.insertText(a,t.chars)):(a=this.openElements.currentTmplContentOrNode,this.treeAdapter.insertText(a,t.chars)),!t.location)return;const i=this.treeAdapter.getChildNodes(a),r=n?i.lastIndexOf(n):i.length,u=i[r-1];if(this.treeAdapter.getNodeSourceCodeLocation(u)){const{endLine:l,endCol:h,endOffset:m}=t.location;this.treeAdapter.updateNodeSourceCodeLocation(u,{endLine:l,endCol:h,endOffset:m})}else this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(u,t.location)}_adoptNodes(t,a){for(let n=this.treeAdapter.getFirstChild(t);n;n=this.treeAdapter.getFirstChild(t))this.treeAdapter.detachNode(n),this.treeAdapter.appendChild(a,n)}_setEndLocation(t,a){if(this.treeAdapter.getNodeSourceCodeLocation(t)&&a.location){const n=a.location,i=this.treeAdapter.getTagName(t),r=a.type===$.END_TAG&&i===a.tagName?{endTag:{...n},endLine:n.endLine,endCol:n.endCol,endOffset:n.endOffset}:{endLine:n.startLine,endCol:n.startCol,endOffset:n.startOffset};this.treeAdapter.updateNodeSourceCodeLocation(t,r)}}shouldProcessStartTagTokenInForeignContent(t){if(!this.currentNotInHTML)return!1;let a,n;return this.openElements.stackTop===0&&this.fragmentContext?(a=this.fragmentContext,n=this.fragmentContextID):{current:a,currentTagId:n}=this.openElements,t.tagID===s.SVG&&this.treeAdapter.getTagName(a)===b.ANNOTATION_XML&&this.treeAdapter.getNamespaceURI(a)===N.MATHML?!1:this.tokenizer.inForeignNode||(t.tagID===s.MGLYPH||t.tagID===s.MALIGNMARK)&&!this._isIntegrationPoint(n,a,N.HTML)}_processToken(t){switch(t.type){case $.CHARACTER:{this.onCharacter(t);break}case $.NULL_CHARACTER:{this.onNullCharacter(t);break}case $.COMMENT:{this.onComment(t);break}case $.DOCTYPE:{this.onDoctype(t);break}case $.START_TAG:{this._processStartTag(t);break}case $.END_TAG:{this.onEndTag(t);break}case $.EOF:{this.onEof(t);break}case $.WHITESPACE_CHARACTER:{this.onWhitespaceCharacter(t);break}}}_isIntegrationPoint(t,a,n){const i=this.treeAdapter.getNamespaceURI(a),r=this.treeAdapter.getAttrList(a);return Il(t,i,r,n)}_reconstructActiveFormattingElements(){const t=this.activeFormattingElements.entries.length;if(t){const a=this.activeFormattingElements.entries.findIndex(i=>i.type===we.Marker||this.openElements.contains(i.element)),n=a<0?t-1:a-1;for(let i=n;i>=0;i--){const r=this.activeFormattingElements.entries[i];this._insertElement(r.token,this.treeAdapter.getNamespaceURI(r.element)),r.element=this.openElements.current}}}_closeTableCell(){this.openElements.generateImpliedEndTags(),this.openElements.popUntilTableCellPopped(),this.activeFormattingElements.clearToLastMarker(),this.insertionMode=E.IN_ROW}_closePElement(){this.openElements.generateImpliedEndTagsWithExclusion(s.P),this.openElements.popUntilTagNamePopped(s.P)}_resetInsertionMode(){for(let t=this.openElements.stackTop;t>=0;t--)switch(t===0&&this.fragmentContext?this.fragmentContextID:this.openElements.tagIDs[t]){case s.TR:{this.insertionMode=E.IN_ROW;return}case s.TBODY:case s.THEAD:case s.TFOOT:{this.insertionMode=E.IN_TABLE_BODY;return}case s.CAPTION:{this.insertionMode=E.IN_CAPTION;return}case s.COLGROUP:{this.insertionMode=E.IN_COLUMN_GROUP;return}case s.TABLE:{this.insertionMode=E.IN_TABLE;return}case s.BODY:{this.insertionMode=E.IN_BODY;return}case s.FRAMESET:{this.insertionMode=E.IN_FRAMESET;return}case s.SELECT:{this._resetInsertionModeForSelect(t);return}case s.TEMPLATE:{this.insertionMode=this.tmplInsertionModeStack[0];return}case s.HTML:{this.insertionMode=this.headElement?E.AFTER_HEAD:E.BEFORE_HEAD;return}case s.TD:case s.TH:{if(t>0){this.insertionMode=E.IN_CELL;return}break}case s.HEAD:{if(t>0){this.insertionMode=E.IN_HEAD;return}break}}this.insertionMode=E.IN_BODY}_resetInsertionModeForSelect(t){if(t>0)for(let a=t-1;a>0;a--){const n=this.openElements.tagIDs[a];if(n===s.TEMPLATE)break;if(n===s.TABLE){this.insertionMode=E.IN_SELECT_IN_TABLE;return}}this.insertionMode=E.IN_SELECT}_isElementCausesFosterParenting(t){return ds.has(t)}_shouldFosterParentOnInsertion(){return this.fosterParentingEnabled&&this._isElementCausesFosterParenting(this.openElements.currentTagId)}_findFosterParentingLocation(){for(let t=this.openElements.stackTop;t>=0;t--){const a=this.openElements.items[t];switch(this.openElements.tagIDs[t]){case s.TEMPLATE:{if(this.treeAdapter.getNamespaceURI(a)===N.HTML)return{parent:this.treeAdapter.getTemplateContent(a),beforeElement:null};break}case s.TABLE:{const n=this.treeAdapter.getParentNode(a);return n?{parent:n,beforeElement:a}:{parent:this.openElements.items[t-1],beforeElement:null}}}}return{parent:this.openElements.items[0],beforeElement:null}}_fosterParentElement(t){const a=this._findFosterParentingLocation();a.beforeElement?this.treeAdapter.insertBefore(a.parent,t,a.beforeElement):this.treeAdapter.appendChild(a.parent,t)}_isSpecialElement(t,a){const n=this.treeAdapter.getNamespaceURI(t);return Gc[n].has(a)}onCharacter(t){if(this.skipNextNewLine=!1,this.tokenizer.inForeignNode){id(this,t);return}switch(this.insertionMode){case E.INITIAL:{wt(this,t);break}case E.BEFORE_HTML:{Ut(this,t);break}case E.BEFORE_HEAD:{Ft(this,t);break}case E.IN_HEAD:{Ht(this,t);break}case E.IN_HEAD_NO_SCRIPT:{Vt(this,t);break}case E.AFTER_HEAD:{Yt(this,t);break}case E.IN_BODY:case E.IN_CAPTION:case E.IN_CELL:case E.IN_TEMPLATE:{Es(this,t);break}case E.TEXT:case E.IN_SELECT:case E.IN_SELECT_IN_TABLE:{this._insertCharacters(t);break}case E.IN_TABLE:case E.IN_TABLE_BODY:case E.IN_ROW:{Cn(this,t);break}case E.IN_TABLE_TEXT:{Cs(this,t);break}case E.IN_COLUMN_GROUP:{Na(this,t);break}case E.AFTER_BODY:{Sa(this,t);break}case E.AFTER_AFTER_BODY:{xa(this,t);break}}}onNullCharacter(t){if(this.skipNextNewLine=!1,this.tokenizer.inForeignNode){nd(this,t);return}switch(this.insertionMode){case E.INITIAL:{wt(this,t);break}case E.BEFORE_HTML:{Ut(this,t);break}case E.BEFORE_HEAD:{Ft(this,t);break}case E.IN_HEAD:{Ht(this,t);break}case E.IN_HEAD_NO_SCRIPT:{Vt(this,t);break}case E.AFTER_HEAD:{Yt(this,t);break}case E.TEXT:{this._insertCharacters(t);break}case E.IN_TABLE:case E.IN_TABLE_BODY:case E.IN_ROW:{Cn(this,t);break}case E.IN_COLUMN_GROUP:{Na(this,t);break}case E.AFTER_BODY:{Sa(this,t);break}case E.AFTER_AFTER_BODY:{xa(this,t);break}}}onComment(t){if(this.skipNextNewLine=!1,this.currentNotInHTML){An(this,t);return}switch(this.insertionMode){case E.INITIAL:case E.BEFORE_HTML:case E.BEFORE_HEAD:case E.IN_HEAD:case E.IN_HEAD_NO_SCRIPT:case E.AFTER_HEAD:case E.IN_BODY:case E.IN_TABLE:case E.IN_CAPTION:case E.IN_COLUMN_GROUP:case E.IN_TABLE_BODY:case E.IN_ROW:case E.IN_CELL:case E.IN_SELECT:case E.IN_SELECT_IN_TABLE:case E.IN_TEMPLATE:case E.IN_FRAMESET:case E.AFTER_FRAMESET:{An(this,t);break}case E.IN_TABLE_TEXT:{Wt(this,t);break}case E.AFTER_BODY:{vl(this,t);break}case E.AFTER_AFTER_BODY:case E.AFTER_AFTER_FRAMESET:{Bl(this,t);break}}}onDoctype(t){switch(this.skipNextNewLine=!1,this.insertionMode){case E.INITIAL:{wl(this,t);break}case E.BEFORE_HEAD:case E.IN_HEAD:case E.IN_HEAD_NO_SCRIPT:case E.AFTER_HEAD:{this._err(t,g.misplacedDoctype);break}case E.IN_TABLE_TEXT:{Wt(this,t);break}}}onStartTag(t){this.skipNextNewLine=!1,this.currentToken=t,this._processStartTag(t),t.selfClosing&&!t.ackSelfClosing&&this._err(t,g.nonVoidHtmlElementStartTagWithTrailingSolidus)}_processStartTag(t){this.shouldProcessStartTagTokenInForeignContent(t)?sd(this,t):this._startTagOutsideForeignContent(t)}_startTagOutsideForeignContent(t){switch(this.insertionMode){case E.INITIAL:{wt(this,t);break}case E.BEFORE_HTML:{Ul(this,t);break}case E.BEFORE_HEAD:{Hl(this,t);break}case E.IN_HEAD:{ke(this,t);break}case E.IN_HEAD_NO_SCRIPT:{ql(this,t);break}case E.AFTER_HEAD:{Wl(this,t);break}case E.IN_BODY:{Te(this,t);break}case E.IN_TABLE:{bt(this,t);break}case E.IN_TABLE_TEXT:{Wt(this,t);break}case E.IN_CAPTION:{V0(this,t);break}case E.IN_COLUMN_GROUP:{In(this,t);break}case E.IN_TABLE_BODY:{Ca(this,t);break}case E.IN_ROW:{Ia(this,t);break}case E.IN_CELL:{$0(this,t);break}case E.IN_SELECT:{xs(this,t);break}case E.IN_SELECT_IN_TABLE:{G0(this,t);break}case E.IN_TEMPLATE:{Q0(this,t);break}case E.AFTER_BODY:{z0(this,t);break}case E.IN_FRAMESET:{K0(this,t);break}case E.AFTER_FRAMESET:{J0(this,t);break}case E.AFTER_AFTER_BODY:{td(this,t);break}case E.AFTER_AFTER_FRAMESET:{ad(this,t);break}}}onEndTag(t){this.skipNextNewLine=!1,this.currentToken=t,this.currentNotInHTML?rd(this,t):this._endTagOutsideForeignContent(t)}_endTagOutsideForeignContent(t){switch(this.insertionMode){case E.INITIAL:{wt(this,t);break}case E.BEFORE_HTML:{Fl(this,t);break}case E.BEFORE_HEAD:{Vl(this,t);break}case E.IN_HEAD:{Yl(this,t);break}case E.IN_HEAD_NO_SCRIPT:{$l(this,t);break}case E.AFTER_HEAD:{Gl(this,t);break}case E.IN_BODY:{Aa(this,t);break}case E.TEXT:{R0(this,t);break}case E.IN_TABLE:{qt(this,t);break}case E.IN_TABLE_TEXT:{Wt(this,t);break}case E.IN_CAPTION:{Y0(this,t);break}case E.IN_COLUMN_GROUP:{q0(this,t);break}case E.IN_TABLE_BODY:{Sn(this,t);break}case E.IN_ROW:{Ss(this,t);break}case E.IN_CELL:{W0(this,t);break}case E.IN_SELECT:{Os(this,t);break}case E.IN_SELECT_IN_TABLE:{X0(this,t);break}case E.IN_TEMPLATE:{j0(this,t);break}case E.AFTER_BODY:{Ls(this,t);break}case E.IN_FRAMESET:{Z0(this,t);break}case E.AFTER_FRAMESET:{ed(this,t);break}case E.AFTER_AFTER_BODY:{xa(this,t);break}}}onEof(t){switch(this.insertionMode){case E.INITIAL:{wt(this,t);break}case E.BEFORE_HTML:{Ut(this,t);break}case E.BEFORE_HEAD:{Ft(this,t);break}case E.IN_HEAD:{Ht(this,t);break}case E.IN_HEAD_NO_SCRIPT:{Vt(this,t);break}case E.AFTER_HEAD:{Yt(this,t);break}case E.IN_BODY:case E.IN_TABLE:case E.IN_CAPTION:case E.IN_COLUMN_GROUP:case E.IN_TABLE_BODY:case E.IN_ROW:case E.IN_CELL:case E.IN_SELECT:case E.IN_SELECT_IN_TABLE:{As(this,t);break}case E.TEXT:{k0(this,t);break}case E.IN_TABLE_TEXT:{Wt(this,t);break}case E.IN_TEMPLATE:{Ds(this,t);break}case E.AFTER_BODY:case E.IN_FRAMESET:case E.AFTER_FRAMESET:case E.AFTER_AFTER_BODY:case E.AFTER_AFTER_FRAMESET:{Nn(this,t);break}}}onWhitespaceCharacter(t){if(this.skipNextNewLine&&(this.skipNextNewLine=!1,t.chars.charCodeAt(0)===d.LINE_FEED)){if(t.chars.length===1)return;t.chars=t.chars.substr(1)}if(this.tokenizer.inForeignNode){this._insertCharacters(t);return}switch(this.insertionMode){case E.IN_HEAD:case E.IN_HEAD_NO_SCRIPT:case E.AFTER_HEAD:case E.TEXT:case E.IN_COLUMN_GROUP:case E.IN_SELECT:case E.IN_SELECT_IN_TABLE:case E.IN_FRAMESET:case E.AFTER_FRAMESET:{this._insertCharacters(t);break}case E.IN_BODY:case E.IN_CAPTION:case E.IN_CELL:case E.IN_TEMPLATE:case E.AFTER_BODY:case E.AFTER_AFTER_BODY:case E.AFTER_AFTER_FRAMESET:{ms(this,t);break}case E.IN_TABLE:case E.IN_TABLE_BODY:case E.IN_ROW:{Cn(this,t);break}case E.IN_TABLE_TEXT:{Ns(this,t);break}}}};function Ll(e,t){let a=e.activeFormattingElements.getElementEntryInScopeWithTagName(t.tagName);return a?e.openElements.contains(a.element)?e.openElements.hasInScope(t.tagID)||(a=null):(e.activeFormattingElements.removeEntry(a),a=null):_s(e,t),a}function yl(e,t){let a=null,n=e.openElements.stackTop;for(;n>=0;n--){const i=e.openElements.items[n];if(i===t.element)break;e._isSpecialElement(i,e.openElements.tagIDs[n])&&(a=i)}return a||(e.openElements.shortenToLength(n<0?0:n),e.activeFormattingElements.removeEntry(t)),a}function Rl(e,t,a){let n=t,i=e.openElements.getCommonAncestor(t);for(let r=0,u=i;u!==a;r++,u=i){i=e.openElements.getCommonAncestor(u);const o=e.activeFormattingElements.getElementEntry(u),l=o&&r>=Ol;!o||l?(l&&e.activeFormattingElements.removeEntry(o),e.openElements.remove(u)):(u=kl(e,o),n===t&&(e.activeFormattingElements.bookmark=o),e.treeAdapter.detachNode(n),e.treeAdapter.appendChild(u,n),n=u)}return n}function kl(e,t){const a=e.treeAdapter.getNamespaceURI(t.element),n=e.treeAdapter.createElement(t.token.tagName,a,t.token.attrs);return e.openElements.replace(t.element,n),t.element=n,n}function Ml(e,t,a){const n=e.treeAdapter.getTagName(t),i=Ta(n);if(e._isElementCausesFosterParenting(i))e._fosterParentElement(a);else{const r=e.treeAdapter.getNamespaceURI(t);i===s.TEMPLATE&&r===N.HTML&&(t=e.treeAdapter.getTemplateContent(t)),e.treeAdapter.appendChild(t,a)}}function Pl(e,t,a){const n=e.treeAdapter.getNamespaceURI(a.element),{token:i}=a,r=e.treeAdapter.createElement(i.tagName,n,i.attrs);e._adoptNodes(t,r),e.treeAdapter.appendChild(t,r),e.activeFormattingElements.insertElementAfterBookmark(r,i),e.activeFormattingElements.removeEntry(a),e.openElements.remove(a.element),e.openElements.insertAfter(t,r,i.tagID)}function _n(e,t){for(let a=0;a<xl;a++){const n=Ll(e,t);if(!n)break;const i=yl(e,n);if(!i)break;e.activeFormattingElements.bookmark=n;const r=Rl(e,i,n.element),u=e.openElements.getCommonAncestor(n.element);e.treeAdapter.detachNode(r),u&&Ml(e,u,r),Pl(e,i,n)}}function An(e,t){e._appendCommentNode(t,e.openElements.currentTmplContentOrNode)}function vl(e,t){e._appendCommentNode(t,e.openElements.items[0])}function Bl(e,t){e._appendCommentNode(t,e.document)}function Nn(e,t){if(e.stopped=!0,t.location){const a=e.fragmentContext?0:2;for(let n=e.openElements.stackTop;n>=a;n--)e._setEndLocation(e.openElements.items[n],t);if(!e.fragmentContext&&e.openElements.stackTop>=0){const n=e.openElements.items[0],i=e.treeAdapter.getNodeSourceCodeLocation(n);if(i&&!i.endTag&&(e._setEndLocation(n,t),e.openElements.stackTop>=1)){const r=e.openElements.items[1],u=e.treeAdapter.getNodeSourceCodeLocation(r);u&&!u.endTag&&e._setEndLocation(r,t)}}}}function wl(e,t){e._setDocumentType(t);const a=t.forceQuirks?Se.QUIRKS:fl(t);hl(t)||e._err(t,g.nonConformingDoctype),e.treeAdapter.setDocumentMode(e.document,a),e.insertionMode=E.BEFORE_HTML}function wt(e,t){e._err(t,g.missingDoctype,!0),e.treeAdapter.setDocumentMode(e.document,Se.QUIRKS),e.insertionMode=E.BEFORE_HTML,e._processToken(t)}function Ul(e,t){t.tagID===s.HTML?(e._insertElement(t,N.HTML),e.insertionMode=E.BEFORE_HEAD):Ut(e,t)}function Fl(e,t){const a=t.tagID;(a===s.HTML||a===s.HEAD||a===s.BODY||a===s.BR)&&Ut(e,t)}function Ut(e,t){e._insertFakeRootElement(),e.insertionMode=E.BEFORE_HEAD,e._processToken(t)}function Hl(e,t){switch(t.tagID){case s.HTML:{Te(e,t);break}case s.HEAD:{e._insertElement(t,N.HTML),e.headElement=e.openElements.current,e.insertionMode=E.IN_HEAD;break}default:Ft(e,t)}}function Vl(e,t){const a=t.tagID;a===s.HEAD||a===s.BODY||a===s.HTML||a===s.BR?Ft(e,t):e._err(t,g.endTagWithoutMatchingOpenElement)}function Ft(e,t){e._insertFakeElement(b.HEAD,s.HEAD),e.headElement=e.openElements.current,e.insertionMode=E.IN_HEAD,e._processToken(t)}function ke(e,t){switch(t.tagID){case s.HTML:{Te(e,t);break}case s.BASE:case s.BASEFONT:case s.BGSOUND:case s.LINK:case s.META:{e._appendElement(t,N.HTML),t.ackSelfClosing=!0;break}case s.TITLE:{e._switchToTextParsing(t,Ne.RCDATA);break}case s.NOSCRIPT:{e.options.scriptingEnabled?e._switchToTextParsing(t,Ne.RAWTEXT):(e._insertElement(t,N.HTML),e.insertionMode=E.IN_HEAD_NO_SCRIPT);break}case s.NOFRAMES:case s.STYLE:{e._switchToTextParsing(t,Ne.RAWTEXT);break}case s.SCRIPT:{e._switchToTextParsing(t,Ne.SCRIPT_DATA);break}case s.TEMPLATE:{e._insertTemplate(t),e.activeFormattingElements.insertMarker(),e.framesetOk=!1,e.insertionMode=E.IN_TEMPLATE,e.tmplInsertionModeStack.unshift(E.IN_TEMPLATE);break}case s.HEAD:{e._err(t,g.misplacedStartTagForHeadElement);break}default:Ht(e,t)}}function Yl(e,t){switch(t.tagID){case s.HEAD:{e.openElements.pop(),e.insertionMode=E.AFTER_HEAD;break}case s.BODY:case s.BR:case s.HTML:{Ht(e,t);break}case s.TEMPLATE:{ot(e,t);break}default:e._err(t,g.endTagWithoutMatchingOpenElement)}}function ot(e,t){e.openElements.tmplCount>0?(e.openElements.generateImpliedEndTagsThoroughly(),e.openElements.currentTagId!==s.TEMPLATE&&e._err(t,g.closingOfElementWithOpenChildElements),e.openElements.popUntilTagNamePopped(s.TEMPLATE),e.activeFormattingElements.clearToLastMarker(),e.tmplInsertionModeStack.shift(),e._resetInsertionMode()):e._err(t,g.endTagWithoutMatchingOpenElement)}function Ht(e,t){e.openElements.pop(),e.insertionMode=E.AFTER_HEAD,e._processToken(t)}function ql(e,t){switch(t.tagID){case s.HTML:{Te(e,t);break}case s.BASEFONT:case s.BGSOUND:case s.HEAD:case s.LINK:case s.META:case s.NOFRAMES:case s.STYLE:{ke(e,t);break}case s.NOSCRIPT:{e._err(t,g.nestedNoscriptInHead);break}default:Vt(e,t)}}function $l(e,t){switch(t.tagID){case s.NOSCRIPT:{e.openElements.pop(),e.insertionMode=E.IN_HEAD;break}case s.BR:{Vt(e,t);break}default:e._err(t,g.endTagWithoutMatchingOpenElement)}}function Vt(e,t){const a=t.type===$.EOF?g.openElementsLeftAfterEof:g.disallowedContentInNoscriptInHead;e._err(t,a),e.openElements.pop(),e.insertionMode=E.IN_HEAD,e._processToken(t)}function Wl(e,t){switch(t.tagID){case s.HTML:{Te(e,t);break}case s.BODY:{e._insertElement(t,N.HTML),e.framesetOk=!1,e.insertionMode=E.IN_BODY;break}case s.FRAMESET:{e._insertElement(t,N.HTML),e.insertionMode=E.IN_FRAMESET;break}case s.BASE:case s.BASEFONT:case s.BGSOUND:case s.LINK:case s.META:case s.NOFRAMES:case s.SCRIPT:case s.STYLE:case s.TEMPLATE:case s.TITLE:{e._err(t,g.abandonedHeadElementChild),e.openElements.push(e.headElement,s.HEAD),ke(e,t),e.openElements.remove(e.headElement);break}case s.HEAD:{e._err(t,g.misplacedStartTagForHeadElement);break}default:Yt(e,t)}}function Gl(e,t){switch(t.tagID){case s.BODY:case s.HTML:case s.BR:{Yt(e,t);break}case s.TEMPLATE:{ot(e,t);break}default:e._err(t,g.endTagWithoutMatchingOpenElement)}}function Yt(e,t){e._insertFakeElement(b.BODY,s.BODY),e.insertionMode=E.IN_BODY,_a(e,t)}function _a(e,t){switch(t.type){case $.CHARACTER:{Es(e,t);break}case $.WHITESPACE_CHARACTER:{ms(e,t);break}case $.COMMENT:{An(e,t);break}case $.START_TAG:{Te(e,t);break}case $.END_TAG:{Aa(e,t);break}case $.EOF:{As(e,t);break}}}function ms(e,t){e._reconstructActiveFormattingElements(),e._insertCharacters(t)}function Es(e,t){e._reconstructActiveFormattingElements(),e._insertCharacters(t),e.framesetOk=!1}function Xl(e,t){e.openElements.tmplCount===0&&e.treeAdapter.adoptAttributes(e.openElements.items[0],t.attrs)}function Ql(e,t){const a=e.openElements.tryPeekProperlyNestedBodyElement();a&&e.openElements.tmplCount===0&&(e.framesetOk=!1,e.treeAdapter.adoptAttributes(a,t.attrs))}function jl(e,t){const a=e.openElements.tryPeekProperlyNestedBodyElement();e.framesetOk&&a&&(e.treeAdapter.detachNode(a),e.openElements.popAllUpToHtmlElement(),e._insertElement(t,N.HTML),e.insertionMode=E.IN_FRAMESET)}function zl(e,t){e.openElements.hasInButtonScope(s.P)&&e._closePElement(),e._insertElement(t,N.HTML)}function Kl(e,t){e.openElements.hasInButtonScope(s.P)&&e._closePElement(),Tn.has(e.openElements.currentTagId)&&e.openElements.pop(),e._insertElement(t,N.HTML)}function Zl(e,t){e.openElements.hasInButtonScope(s.P)&&e._closePElement(),e._insertElement(t,N.HTML),e.skipNextNewLine=!0,e.framesetOk=!1}function Jl(e,t){const a=e.openElements.tmplCount>0;(!e.formElement||a)&&(e.openElements.hasInButtonScope(s.P)&&e._closePElement(),e._insertElement(t,N.HTML),a||(e.formElement=e.openElements.current))}function e0(e,t){e.framesetOk=!1;const a=t.tagID;for(let n=e.openElements.stackTop;n>=0;n--){const i=e.openElements.tagIDs[n];if(a===s.LI&&i===s.LI||(a===s.DD||a===s.DT)&&(i===s.DD||i===s.DT)){e.openElements.generateImpliedEndTagsWithExclusion(i),e.openElements.popUntilTagNamePopped(i);break}if(i!==s.ADDRESS&&i!==s.DIV&&i!==s.P&&e._isSpecialElement(e.openElements.items[n],i))break}e.openElements.hasInButtonScope(s.P)&&e._closePElement(),e._insertElement(t,N.HTML)}function t0(e,t){e.openElements.hasInButtonScope(s.P)&&e._closePElement(),e._insertElement(t,N.HTML),e.tokenizer.state=Ne.PLAINTEXT}function a0(e,t){e.openElements.hasInScope(s.BUTTON)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(s.BUTTON)),e._reconstructActiveFormattingElements(),e._insertElement(t,N.HTML),e.framesetOk=!1}function n0(e,t){const a=e.activeFormattingElements.getElementEntryInScopeWithTagName(b.A);a&&(_n(e,t),e.openElements.remove(a.element),e.activeFormattingElements.removeEntry(a)),e._reconstructActiveFormattingElements(),e._insertElement(t,N.HTML),e.activeFormattingElements.pushElement(e.openElements.current,t)}function i0(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,N.HTML),e.activeFormattingElements.pushElement(e.openElements.current,t)}function s0(e,t){e._reconstructActiveFormattingElements(),e.openElements.hasInScope(s.NOBR)&&(_n(e,t),e._reconstructActiveFormattingElements()),e._insertElement(t,N.HTML),e.activeFormattingElements.pushElement(e.openElements.current,t)}function r0(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,N.HTML),e.activeFormattingElements.insertMarker(),e.framesetOk=!1}function u0(e,t){e.treeAdapter.getDocumentMode(e.document)!==Se.QUIRKS&&e.openElements.hasInButtonScope(s.P)&&e._closePElement(),e._insertElement(t,N.HTML),e.framesetOk=!1,e.insertionMode=E.IN_TABLE}function ps(e,t){e._reconstructActiveFormattingElements(),e._appendElement(t,N.HTML),e.framesetOk=!1,t.ackSelfClosing=!0}function Ts(e){const t=ji(e,ut.TYPE);return t!=null&&t.toLowerCase()===Sl}function o0(e,t){e._reconstructActiveFormattingElements(),e._appendElement(t,N.HTML),Ts(t)||(e.framesetOk=!1),t.ackSelfClosing=!0}function c0(e,t){e._appendElement(t,N.HTML),t.ackSelfClosing=!0}function l0(e,t){e.openElements.hasInButtonScope(s.P)&&e._closePElement(),e._appendElement(t,N.HTML),e.framesetOk=!1,t.ackSelfClosing=!0}function d0(e,t){t.tagName=b.IMG,t.tagID=s.IMG,ps(e,t)}function h0(e,t){e._insertElement(t,N.HTML),e.skipNextNewLine=!0,e.tokenizer.state=Ne.RCDATA,e.originalInsertionMode=e.insertionMode,e.framesetOk=!1,e.insertionMode=E.TEXT}function f0(e,t){e.openElements.hasInButtonScope(s.P)&&e._closePElement(),e._reconstructActiveFormattingElements(),e.framesetOk=!1,e._switchToTextParsing(t,Ne.RAWTEXT)}function m0(e,t){e.framesetOk=!1,e._switchToTextParsing(t,Ne.RAWTEXT)}function bs(e,t){e._switchToTextParsing(t,Ne.RAWTEXT)}function E0(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,N.HTML),e.framesetOk=!1,e.insertionMode=e.insertionMode===E.IN_TABLE||e.insertionMode===E.IN_CAPTION||e.insertionMode===E.IN_TABLE_BODY||e.insertionMode===E.IN_ROW||e.insertionMode===E.IN_CELL?E.IN_SELECT_IN_TABLE:E.IN_SELECT}function p0(e,t){e.openElements.currentTagId===s.OPTION&&e.openElements.pop(),e._reconstructActiveFormattingElements(),e._insertElement(t,N.HTML)}function T0(e,t){e.openElements.hasInScope(s.RUBY)&&e.openElements.generateImpliedEndTags(),e._insertElement(t,N.HTML)}function b0(e,t){e.openElements.hasInScope(s.RUBY)&&e.openElements.generateImpliedEndTagsWithExclusion(s.RTC),e._insertElement(t,N.HTML)}function g0(e,t){e._reconstructActiveFormattingElements(),cs(t),gn(t),t.selfClosing?e._appendElement(t,N.MATHML):e._insertElement(t,N.MATHML),t.ackSelfClosing=!0}function _0(e,t){e._reconstructActiveFormattingElements(),ls(t),gn(t),t.selfClosing?e._appendElement(t,N.SVG):e._insertElement(t,N.SVG),t.ackSelfClosing=!0}function gs(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,N.HTML)}function Te(e,t){switch(t.tagID){case s.I:case s.S:case s.B:case s.U:case s.EM:case s.TT:case s.BIG:case s.CODE:case s.FONT:case s.SMALL:case s.STRIKE:case s.STRONG:{i0(e,t);break}case s.A:{n0(e,t);break}case s.H1:case s.H2:case s.H3:case s.H4:case s.H5:case s.H6:{Kl(e,t);break}case s.P:case s.DL:case s.OL:case s.UL:case s.DIV:case s.DIR:case s.NAV:case s.MAIN:case s.MENU:case s.ASIDE:case s.CENTER:case s.FIGURE:case s.FOOTER:case s.HEADER:case s.HGROUP:case s.DIALOG:case s.DETAILS:case s.ADDRESS:case s.ARTICLE:case s.SEARCH:case s.SECTION:case s.SUMMARY:case s.FIELDSET:case s.BLOCKQUOTE:case s.FIGCAPTION:{zl(e,t);break}case s.LI:case s.DD:case s.DT:{e0(e,t);break}case s.BR:case s.IMG:case s.WBR:case s.AREA:case s.EMBED:case s.KEYGEN:{ps(e,t);break}case s.HR:{l0(e,t);break}case s.RB:case s.RTC:{T0(e,t);break}case s.RT:case s.RP:{b0(e,t);break}case s.PRE:case s.LISTING:{Zl(e,t);break}case s.XMP:{f0(e,t);break}case s.SVG:{_0(e,t);break}case s.HTML:{Xl(e,t);break}case s.BASE:case s.LINK:case s.META:case s.STYLE:case s.TITLE:case s.SCRIPT:case s.BGSOUND:case s.BASEFONT:case s.TEMPLATE:{ke(e,t);break}case s.BODY:{Ql(e,t);break}case s.FORM:{Jl(e,t);break}case s.NOBR:{s0(e,t);break}case s.MATH:{g0(e,t);break}case s.TABLE:{u0(e,t);break}case s.INPUT:{o0(e,t);break}case s.PARAM:case s.TRACK:case s.SOURCE:{c0(e,t);break}case s.IMAGE:{d0(e,t);break}case s.BUTTON:{a0(e,t);break}case s.APPLET:case s.OBJECT:case s.MARQUEE:{r0(e,t);break}case s.IFRAME:{m0(e,t);break}case s.SELECT:{E0(e,t);break}case s.OPTION:case s.OPTGROUP:{p0(e,t);break}case s.NOEMBED:case s.NOFRAMES:{bs(e,t);break}case s.FRAMESET:{jl(e,t);break}case s.TEXTAREA:{h0(e,t);break}case s.NOSCRIPT:{e.options.scriptingEnabled?bs(e,t):gs(e,t);break}case s.PLAINTEXT:{t0(e,t);break}case s.COL:case s.TH:case s.TD:case s.TR:case s.HEAD:case s.FRAME:case s.TBODY:case s.TFOOT:case s.THEAD:case s.CAPTION:case s.COLGROUP:break;default:gs(e,t)}}function A0(e,t){if(e.openElements.hasInScope(s.BODY)&&(e.insertionMode=E.AFTER_BODY,e.options.sourceCodeLocationInfo)){const a=e.openElements.tryPeekProperlyNestedBodyElement();a&&e._setEndLocation(a,t)}}function N0(e,t){e.openElements.hasInScope(s.BODY)&&(e.insertionMode=E.AFTER_BODY,Ls(e,t))}function C0(e,t){const a=t.tagID;e.openElements.hasInScope(a)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(a))}function I0(e){const t=e.openElements.tmplCount>0,{formElement:a}=e;t||(e.formElement=null),(a||t)&&e.openElements.hasInScope(s.FORM)&&(e.openElements.generateImpliedEndTags(),t?e.openElements.popUntilTagNamePopped(s.FORM):a&&e.openElements.remove(a))}function S0(e){e.openElements.hasInButtonScope(s.P)||e._insertFakeElement(b.P,s.P),e._closePElement()}function x0(e){e.openElements.hasInListItemScope(s.LI)&&(e.openElements.generateImpliedEndTagsWithExclusion(s.LI),e.openElements.popUntilTagNamePopped(s.LI))}function O0(e,t){const a=t.tagID;e.openElements.hasInScope(a)&&(e.openElements.generateImpliedEndTagsWithExclusion(a),e.openElements.popUntilTagNamePopped(a))}function D0(e){e.openElements.hasNumberedHeaderInScope()&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilNumberedHeaderPopped())}function L0(e,t){const a=t.tagID;e.openElements.hasInScope(a)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(a),e.activeFormattingElements.clearToLastMarker())}function y0(e){e._reconstructActiveFormattingElements(),e._insertFakeElement(b.BR,s.BR),e.openElements.pop(),e.framesetOk=!1}function _s(e,t){const a=t.tagName,n=t.tagID;for(let i=e.openElements.stackTop;i>0;i--){const r=e.openElements.items[i],u=e.openElements.tagIDs[i];if(n===u&&(n!==s.UNKNOWN||e.treeAdapter.getTagName(r)===a)){e.openElements.generateImpliedEndTagsWithExclusion(n),e.openElements.stackTop>=i&&e.openElements.shortenToLength(i);break}if(e._isSpecialElement(r,u))break}}function Aa(e,t){switch(t.tagID){case s.A:case s.B:case s.I:case s.S:case s.U:case s.EM:case s.TT:case s.BIG:case s.CODE:case s.FONT:case s.NOBR:case s.SMALL:case s.STRIKE:case s.STRONG:{_n(e,t);break}case s.P:{S0(e);break}case s.DL:case s.UL:case s.OL:case s.DIR:case s.DIV:case s.NAV:case s.PRE:case s.MAIN:case s.MENU:case s.ASIDE:case s.BUTTON:case s.CENTER:case s.FIGURE:case s.FOOTER:case s.HEADER:case s.HGROUP:case s.DIALOG:case s.ADDRESS:case s.ARTICLE:case s.DETAILS:case s.SEARCH:case s.SECTION:case s.SUMMARY:case s.LISTING:case s.FIELDSET:case s.BLOCKQUOTE:case s.FIGCAPTION:{C0(e,t);break}case s.LI:{x0(e);break}case s.DD:case s.DT:{O0(e,t);break}case s.H1:case s.H2:case s.H3:case s.H4:case s.H5:case s.H6:{D0(e);break}case s.BR:{y0(e);break}case s.BODY:{A0(e,t);break}case s.HTML:{N0(e,t);break}case s.FORM:{I0(e);break}case s.APPLET:case s.OBJECT:case s.MARQUEE:{L0(e,t);break}case s.TEMPLATE:{ot(e,t);break}default:_s(e,t)}}function As(e,t){e.tmplInsertionModeStack.length>0?Ds(e,t):Nn(e,t)}function R0(e,t){var a;t.tagID===s.SCRIPT&&((a=e.scriptHandler)===null||a===void 0||a.call(e,e.openElements.current)),e.openElements.pop(),e.insertionMode=e.originalInsertionMode}function k0(e,t){e._err(t,g.eofInElementThatCanContainOnlyText),e.openElements.pop(),e.insertionMode=e.originalInsertionMode,e.onEof(t)}function Cn(e,t){if(ds.has(e.openElements.currentTagId))switch(e.pendingCharacterTokens.length=0,e.hasNonWhitespacePendingCharacterToken=!1,e.originalInsertionMode=e.insertionMode,e.insertionMode=E.IN_TABLE_TEXT,t.type){case $.CHARACTER:{Cs(e,t);break}case $.WHITESPACE_CHARACTER:{Ns(e,t);break}}else $t(e,t)}function M0(e,t){e.openElements.clearBackToTableContext(),e.activeFormattingElements.insertMarker(),e._insertElement(t,N.HTML),e.insertionMode=E.IN_CAPTION}function P0(e,t){e.openElements.clearBackToTableContext(),e._insertElement(t,N.HTML),e.insertionMode=E.IN_COLUMN_GROUP}function v0(e,t){e.openElements.clearBackToTableContext(),e._insertFakeElement(b.COLGROUP,s.COLGROUP),e.insertionMode=E.IN_COLUMN_GROUP,In(e,t)}function B0(e,t){e.openElements.clearBackToTableContext(),e._insertElement(t,N.HTML),e.insertionMode=E.IN_TABLE_BODY}function w0(e,t){e.openElements.clearBackToTableContext(),e._insertFakeElement(b.TBODY,s.TBODY),e.insertionMode=E.IN_TABLE_BODY,Ca(e,t)}function U0(e,t){e.openElements.hasInTableScope(s.TABLE)&&(e.openElements.popUntilTagNamePopped(s.TABLE),e._resetInsertionMode(),e._processStartTag(t))}function F0(e,t){Ts(t)?e._appendElement(t,N.HTML):$t(e,t),t.ackSelfClosing=!0}function H0(e,t){!e.formElement&&e.openElements.tmplCount===0&&(e._insertElement(t,N.HTML),e.formElement=e.openElements.current,e.openElements.pop())}function bt(e,t){switch(t.tagID){case s.TD:case s.TH:case s.TR:{w0(e,t);break}case s.STYLE:case s.SCRIPT:case s.TEMPLATE:{ke(e,t);break}case s.COL:{v0(e,t);break}case s.FORM:{H0(e,t);break}case s.TABLE:{U0(e,t);break}case s.TBODY:case s.TFOOT:case s.THEAD:{B0(e,t);break}case s.INPUT:{F0(e,t);break}case s.CAPTION:{M0(e,t);break}case s.COLGROUP:{P0(e,t);break}default:$t(e,t)}}function qt(e,t){switch(t.tagID){case s.TABLE:{e.openElements.hasInTableScope(s.TABLE)&&(e.openElements.popUntilTagNamePopped(s.TABLE),e._resetInsertionMode());break}case s.TEMPLATE:{ot(e,t);break}case s.BODY:case s.CAPTION:case s.COL:case s.COLGROUP:case s.HTML:case s.TBODY:case s.TD:case s.TFOOT:case s.TH:case s.THEAD:case s.TR:break;default:$t(e,t)}}function $t(e,t){const a=e.fosterParentingEnabled;e.fosterParentingEnabled=!0,_a(e,t),e.fosterParentingEnabled=a}function Ns(e,t){e.pendingCharacterTokens.push(t)}function Cs(e,t){e.pendingCharacterTokens.push(t),e.hasNonWhitespacePendingCharacterToken=!0}function Wt(e,t){let a=0;if(e.hasNonWhitespacePendingCharacterToken)for(;a<e.pendingCharacterTokens.length;a++)$t(e,e.pendingCharacterTokens[a]);else for(;a<e.pendingCharacterTokens.length;a++)e._insertCharacters(e.pendingCharacterTokens[a]);e.insertionMode=e.originalInsertionMode,e._processToken(t)}const Is=new Set([s.CAPTION,s.COL,s.COLGROUP,s.TBODY,s.TD,s.TFOOT,s.TH,s.THEAD,s.TR]);function V0(e,t){const a=t.tagID;Is.has(a)?e.openElements.hasInTableScope(s.CAPTION)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(s.CAPTION),e.activeFormattingElements.clearToLastMarker(),e.insertionMode=E.IN_TABLE,bt(e,t)):Te(e,t)}function Y0(e,t){const a=t.tagID;switch(a){case s.CAPTION:case s.TABLE:{e.openElements.hasInTableScope(s.CAPTION)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(s.CAPTION),e.activeFormattingElements.clearToLastMarker(),e.insertionMode=E.IN_TABLE,a===s.TABLE&&qt(e,t));break}case s.BODY:case s.COL:case s.COLGROUP:case s.HTML:case s.TBODY:case s.TD:case s.TFOOT:case s.TH:case s.THEAD:case s.TR:break;default:Aa(e,t)}}function In(e,t){switch(t.tagID){case s.HTML:{Te(e,t);break}case s.COL:{e._appendElement(t,N.HTML),t.ackSelfClosing=!0;break}case s.TEMPLATE:{ke(e,t);break}default:Na(e,t)}}function q0(e,t){switch(t.tagID){case s.COLGROUP:{e.openElements.currentTagId===s.COLGROUP&&(e.openElements.pop(),e.insertionMode=E.IN_TABLE);break}case s.TEMPLATE:{ot(e,t);break}case s.COL:break;default:Na(e,t)}}function Na(e,t){e.openElements.currentTagId===s.COLGROUP&&(e.openElements.pop(),e.insertionMode=E.IN_TABLE,e._processToken(t))}function Ca(e,t){switch(t.tagID){case s.TR:{e.openElements.clearBackToTableBodyContext(),e._insertElement(t,N.HTML),e.insertionMode=E.IN_ROW;break}case s.TH:case s.TD:{e.openElements.clearBackToTableBodyContext(),e._insertFakeElement(b.TR,s.TR),e.insertionMode=E.IN_ROW,Ia(e,t);break}case s.CAPTION:case s.COL:case s.COLGROUP:case s.TBODY:case s.TFOOT:case s.THEAD:{e.openElements.hasTableBodyContextInTableScope()&&(e.openElements.clearBackToTableBodyContext(),e.openElements.pop(),e.insertionMode=E.IN_TABLE,bt(e,t));break}default:bt(e,t)}}function Sn(e,t){const a=t.tagID;switch(t.tagID){case s.TBODY:case s.TFOOT:case s.THEAD:{e.openElements.hasInTableScope(a)&&(e.openElements.clearBackToTableBodyContext(),e.openElements.pop(),e.insertionMode=E.IN_TABLE);break}case s.TABLE:{e.openElements.hasTableBodyContextInTableScope()&&(e.openElements.clearBackToTableBodyContext(),e.openElements.pop(),e.insertionMode=E.IN_TABLE,qt(e,t));break}case s.BODY:case s.CAPTION:case s.COL:case s.COLGROUP:case s.HTML:case s.TD:case s.TH:case s.TR:break;default:qt(e,t)}}function Ia(e,t){switch(t.tagID){case s.TH:case s.TD:{e.openElements.clearBackToTableRowContext(),e._insertElement(t,N.HTML),e.insertionMode=E.IN_CELL,e.activeFormattingElements.insertMarker();break}case s.CAPTION:case s.COL:case s.COLGROUP:case s.TBODY:case s.TFOOT:case s.THEAD:case s.TR:{e.openElements.hasInTableScope(s.TR)&&(e.openElements.clearBackToTableRowContext(),e.openElements.pop(),e.insertionMode=E.IN_TABLE_BODY,Ca(e,t));break}default:bt(e,t)}}function Ss(e,t){switch(t.tagID){case s.TR:{e.openElements.hasInTableScope(s.TR)&&(e.openElements.clearBackToTableRowContext(),e.openElements.pop(),e.insertionMode=E.IN_TABLE_BODY);break}case s.TABLE:{e.openElements.hasInTableScope(s.TR)&&(e.openElements.clearBackToTableRowContext(),e.openElements.pop(),e.insertionMode=E.IN_TABLE_BODY,Sn(e,t));break}case s.TBODY:case s.TFOOT:case s.THEAD:{(e.openElements.hasInTableScope(t.tagID)||e.openElements.hasInTableScope(s.TR))&&(e.openElements.clearBackToTableRowContext(),e.openElements.pop(),e.insertionMode=E.IN_TABLE_BODY,Sn(e,t));break}case s.BODY:case s.CAPTION:case s.COL:case s.COLGROUP:case s.HTML:case s.TD:case s.TH:break;default:qt(e,t)}}function $0(e,t){const a=t.tagID;Is.has(a)?(e.openElements.hasInTableScope(s.TD)||e.openElements.hasInTableScope(s.TH))&&(e._closeTableCell(),Ia(e,t)):Te(e,t)}function W0(e,t){const a=t.tagID;switch(a){case s.TD:case s.TH:{e.openElements.hasInTableScope(a)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(a),e.activeFormattingElements.clearToLastMarker(),e.insertionMode=E.IN_ROW);break}case s.TABLE:case s.TBODY:case s.TFOOT:case s.THEAD:case s.TR:{e.openElements.hasInTableScope(a)&&(e._closeTableCell(),Ss(e,t));break}case s.BODY:case s.CAPTION:case s.COL:case s.COLGROUP:case s.HTML:break;default:Aa(e,t)}}function xs(e,t){switch(t.tagID){case s.HTML:{Te(e,t);break}case s.OPTION:{e.openElements.currentTagId===s.OPTION&&e.openElements.pop(),e._insertElement(t,N.HTML);break}case s.OPTGROUP:{e.openElements.currentTagId===s.OPTION&&e.openElements.pop(),e.openElements.currentTagId===s.OPTGROUP&&e.openElements.pop(),e._insertElement(t,N.HTML);break}case s.HR:{e.openElements.currentTagId===s.OPTION&&e.openElements.pop(),e.openElements.currentTagId===s.OPTGROUP&&e.openElements.pop(),e._appendElement(t,N.HTML),t.ackSelfClosing=!0;break}case s.INPUT:case s.KEYGEN:case s.TEXTAREA:case s.SELECT:{e.openElements.hasInSelectScope(s.SELECT)&&(e.openElements.popUntilTagNamePopped(s.SELECT),e._resetInsertionMode(),t.tagID!==s.SELECT&&e._processStartTag(t));break}case s.SCRIPT:case s.TEMPLATE:{ke(e,t);break}}}function Os(e,t){switch(t.tagID){case s.OPTGROUP:{e.openElements.stackTop>0&&e.openElements.currentTagId===s.OPTION&&e.openElements.tagIDs[e.openElements.stackTop-1]===s.OPTGROUP&&e.openElements.pop(),e.openElements.currentTagId===s.OPTGROUP&&e.openElements.pop();break}case s.OPTION:{e.openElements.currentTagId===s.OPTION&&e.openElements.pop();break}case s.SELECT:{e.openElements.hasInSelectScope(s.SELECT)&&(e.openElements.popUntilTagNamePopped(s.SELECT),e._resetInsertionMode());break}case s.TEMPLATE:{ot(e,t);break}}}function G0(e,t){const a=t.tagID;a===s.CAPTION||a===s.TABLE||a===s.TBODY||a===s.TFOOT||a===s.THEAD||a===s.TR||a===s.TD||a===s.TH?(e.openElements.popUntilTagNamePopped(s.SELECT),e._resetInsertionMode(),e._processStartTag(t)):xs(e,t)}function X0(e,t){const a=t.tagID;a===s.CAPTION||a===s.TABLE||a===s.TBODY||a===s.TFOOT||a===s.THEAD||a===s.TR||a===s.TD||a===s.TH?e.openElements.hasInTableScope(a)&&(e.openElements.popUntilTagNamePopped(s.SELECT),e._resetInsertionMode(),e.onEndTag(t)):Os(e,t)}function Q0(e,t){switch(t.tagID){case s.BASE:case s.BASEFONT:case s.BGSOUND:case s.LINK:case s.META:case s.NOFRAMES:case s.SCRIPT:case s.STYLE:case s.TEMPLATE:case s.TITLE:{ke(e,t);break}case s.CAPTION:case s.COLGROUP:case s.TBODY:case s.TFOOT:case s.THEAD:{e.tmplInsertionModeStack[0]=E.IN_TABLE,e.insertionMode=E.IN_TABLE,bt(e,t);break}case s.COL:{e.tmplInsertionModeStack[0]=E.IN_COLUMN_GROUP,e.insertionMode=E.IN_COLUMN_GROUP,In(e,t);break}case s.TR:{e.tmplInsertionModeStack[0]=E.IN_TABLE_BODY,e.insertionMode=E.IN_TABLE_BODY,Ca(e,t);break}case s.TD:case s.TH:{e.tmplInsertionModeStack[0]=E.IN_ROW,e.insertionMode=E.IN_ROW,Ia(e,t);break}default:e.tmplInsertionModeStack[0]=E.IN_BODY,e.insertionMode=E.IN_BODY,Te(e,t)}}function j0(e,t){t.tagID===s.TEMPLATE&&ot(e,t)}function Ds(e,t){e.openElements.tmplCount>0?(e.openElements.popUntilTagNamePopped(s.TEMPLATE),e.activeFormattingElements.clearToLastMarker(),e.tmplInsertionModeStack.shift(),e._resetInsertionMode(),e.onEof(t)):Nn(e,t)}function z0(e,t){t.tagID===s.HTML?Te(e,t):Sa(e,t)}function Ls(e,t){var a;if(t.tagID===s.HTML){if(e.fragmentContext||(e.insertionMode=E.AFTER_AFTER_BODY),e.options.sourceCodeLocationInfo&&e.openElements.tagIDs[0]===s.HTML){e._setEndLocation(e.openElements.items[0],t);const n=e.openElements.items[1];n&&!(!((a=e.treeAdapter.getNodeSourceCodeLocation(n))===null||a===void 0)&&a.endTag)&&e._setEndLocation(n,t)}}else Sa(e,t)}function Sa(e,t){e.insertionMode=E.IN_BODY,_a(e,t)}function K0(e,t){switch(t.tagID){case s.HTML:{Te(e,t);break}case s.FRAMESET:{e._insertElement(t,N.HTML);break}case s.FRAME:{e._appendElement(t,N.HTML),t.ackSelfClosing=!0;break}case s.NOFRAMES:{ke(e,t);break}}}function Z0(e,t){t.tagID===s.FRAMESET&&!e.openElements.isRootHtmlElementCurrent()&&(e.openElements.pop(),!e.fragmentContext&&e.openElements.currentTagId!==s.FRAMESET&&(e.insertionMode=E.AFTER_FRAMESET))}function J0(e,t){switch(t.tagID){case s.HTML:{Te(e,t);break}case s.NOFRAMES:{ke(e,t);break}}}function ed(e,t){t.tagID===s.HTML&&(e.insertionMode=E.AFTER_AFTER_FRAMESET)}function td(e,t){t.tagID===s.HTML?Te(e,t):xa(e,t)}function xa(e,t){e.insertionMode=E.IN_BODY,_a(e,t)}function ad(e,t){switch(t.tagID){case s.HTML:{Te(e,t);break}case s.NOFRAMES:{ke(e,t);break}}}function nd(e,t){t.chars=Z,e._insertCharacters(t)}function id(e,t){e._insertCharacters(t),e.framesetOk=!1}function ys(e){for(;e.treeAdapter.getNamespaceURI(e.openElements.current)!==N.HTML&&!e._isIntegrationPoint(e.openElements.currentTagId,e.openElements.current);)e.openElements.pop()}function sd(e,t){if(_l(t))ys(e),e._startTagOutsideForeignContent(t);else{const a=e._getAdjustedCurrentElement(),n=e.treeAdapter.getNamespaceURI(a);n===N.MATHML?cs(t):n===N.SVG&&(Al(t),ls(t)),gn(t),t.selfClosing?e._appendElement(t,n):e._insertElement(t,n),t.ackSelfClosing=!0}}function rd(e,t){if(t.tagID===s.P||t.tagID===s.BR){ys(e),e._endTagOutsideForeignContent(t);return}for(let a=e.openElements.stackTop;a>0;a--){const n=e.openElements.items[a];if(e.treeAdapter.getNamespaceURI(n)===N.HTML){e._endTagOutsideForeignContent(t);break}const i=e.treeAdapter.getTagName(n);if(i.toLowerCase()===t.tagName){t.tagName=i,e.openElements.shortenToLength(a);break}}}const ud=new Set([b.AREA,b.BASE,b.BASEFONT,b.BGSOUND,b.BR,b.COL,b.EMBED,b.FRAME,b.HR,b.IMG,b.INPUT,b.KEYGEN,b.LINK,b.META,b.PARAM,b.SOURCE,b.TRACK,b.WBR]);function od(e,t){return t.treeAdapter.isElementNode(e)&&t.treeAdapter.getNamespaceURI(e)===N.HTML&&ud.has(t.treeAdapter.getTagName(e))}const cd={treeAdapter:Ye,scriptingEnabled:!0};function ld(e,t){const a={...cd,...t};return Rs(e,a)}function dd(e,t){let a="";const n=t.treeAdapter.isElementNode(e)&&t.treeAdapter.getTagName(e)===b.TEMPLATE&&t.treeAdapter.getNamespaceURI(e)===N.HTML?t.treeAdapter.getTemplateContent(e):e,i=t.treeAdapter.getChildNodes(n);if(i)for(const r of i)a+=Rs(r,t);return a}function Rs(e,t){return t.treeAdapter.isElementNode(e)?hd(e,t):t.treeAdapter.isTextNode(e)?md(e,t):t.treeAdapter.isCommentNode(e)?Ed(e,t):t.treeAdapter.isDocumentTypeNode(e)?pd(e,t):""}function hd(e,t){const a=t.treeAdapter.getTagName(e);return`<${a}${fd(e,t)}>${od(e,t)?"":`${dd(e,t)}</${a}>`}`}function fd(e,{treeAdapter:t}){let a="";for(const n of t.getAttrList(e)){if(a+=" ",n.namespace)switch(n.namespace){case N.XML:{a+=`xml:${n.name}`;break}case N.XMLNS:{n.name!=="xmlns"&&(a+="xmlns:"),a+=n.name;break}case N.XLINK:{a+=`xlink:${n.name}`;break}default:a+=`${n.prefix}:${n.name}`}else a+=n.name;a+=`="${Zn(n.value)}"`}return a}function md(e,t){const{treeAdapter:a}=t,n=a.getTextNodeContent(e),i=a.getParentNode(e),r=i&&a.isElementNode(i)&&a.getTagName(i);return r&&a.getNamespaceURI(i)===N.HTML&&Qc(r,t.scriptingEnabled)?n:Jn(n)}function Ed(e,{treeAdapter:t}){return`<!--${t.getCommentNodeContent(e)}-->`}function pd(e,{treeAdapter:t}){return`<!DOCTYPE ${t.getDocumentTypeNodeName(e)}>`}function Td(e,t){return fs.parse(e,t)}function bd(e,t,a){typeof e=="string"&&(a=t,t=e,e=null);const n=fs.getFragmentParser(e,a);return n.tokenizer.write(t,!0),n.getFragment()}function ks(e){const t=e.includes('"')?"'":'"';return t+e+t}function gd(e,t,a){let n="!DOCTYPE ";return e&&(n+=e),t?n+=` PUBLIC ${ks(t)}`:a&&(n+=" SYSTEM"),a&&(n+=` ${ks(a)}`),n}const ze={isCommentNode:ea,isElementNode:v,isTextNode:Be,createDocument(){const e=new at([]);return e["x-mode"]=Se.NO_QUIRKS,e},createDocumentFragment(){return new at([])},createElement(e,t,a){const n=Object.create(null),i=Object.create(null),r=Object.create(null);for(let o=0;o<a.length;o++){const l=a[o].name;n[l]=a[o].value,i[l]=a[o].namespace,r[l]=a[o].prefix}const u=new wa(e,n,[]);return u.namespace=t,u["x-attribsNamespace"]=i,u["x-attribsPrefix"]=r,u},createCommentNode(e){return new Pa(e)},createTextNode(e){return new xt(e)},appendChild(e,t){const a=e.children[e.children.length-1];a&&(a.next=t,t.prev=a),e.children.push(t),t.parent=e},insertBefore(e,t,a){const n=e.children.indexOf(a),{prev:i}=a;i&&(i.next=t,t.prev=i),a.prev=t,t.next=a,e.children.splice(n,0,t),t.parent=e},setTemplateContent(e,t){ze.appendChild(e,t)},getTemplateContent(e){return e.children[0]},setDocumentType(e,t,a,n){const i=gd(t,a,n);let r=e.children.find(u=>Ua(u)&&u.name==="!doctype");r?r.data=i??null:(r=new va("!doctype",i),ze.appendChild(e,r)),r["x-name"]=t,r["x-publicId"]=a,r["x-systemId"]=n},setDocumentMode(e,t){e["x-mode"]=t},getDocumentMode(e){return e["x-mode"]},detachNode(e){if(e.parent){const t=e.parent.children.indexOf(e),{prev:a,next:n}=e;e.prev=null,e.next=null,a&&(a.next=n),n&&(n.prev=a),e.parent.children.splice(t,1),e.parent=null}},insertText(e,t){const a=e.children[e.children.length-1];a&&Be(a)?a.data+=t:ze.appendChild(e,ze.createTextNode(t))},insertTextBefore(e,t,a){const n=e.children[e.children.indexOf(a)-1];n&&Be(n)?n.data+=t:ze.insertBefore(e,ze.createTextNode(t),a)},adoptAttributes(e,t){for(let a=0;a<t.length;a++){const n=t[a].name;e.attribs[n]===void 0&&(e.attribs[n]=t[a].value,e["x-attribsNamespace"][n]=t[a].namespace,e["x-attribsPrefix"][n]=t[a].prefix)}},getFirstChild(e){return e.children[0]},getChildNodes(e){return e.children},getParentNode(e){return e.parent},getAttrList(e){return e.attributes},getTagName(e){return e.name},getNamespaceURI(e){return e.namespace},getTextNodeContent(e){return e.data},getCommentNodeContent(e){return e.data},getDocumentTypeNodeName(e){var t;return(t=e["x-name"])!==null&&t!==void 0?t:""},getDocumentTypeNodePublicId(e){var t;return(t=e["x-publicId"])!==null&&t!==void 0?t:""},getDocumentTypeNodeSystemId(e){var t;return(t=e["x-systemId"])!==null&&t!==void 0?t:""},isDocumentTypeNode(e){return Ua(e)&&e.name==="!doctype"},setNodeSourceCodeLocation(e,t){t&&(e.startIndex=t.startOffset,e.endIndex=t.endOffset),e.sourceCodeLocation=t},getNodeSourceCodeLocation(e){return e.sourceCodeLocation},updateNodeSourceCodeLocation(e,t){t.endOffset!=null&&(e.endIndex=t.endOffset),e.sourceCodeLocation={...e.sourceCodeLocation,...t}}};function _d(e,t,a,n){var i;return(i=t.treeAdapter)!==null&&i!==void 0||(t.treeAdapter=ze),t.scriptingEnabled!==!1&&(t.scriptingEnabled=!0),a?Td(e,t):bd(n,e,t)}const Ad={treeAdapter:ze};function Nd(e){const t="length"in e?e:[e];for(let n=0;n<t.length;n+=1){const i=t[n];We(i)&&Array.prototype.splice.call(t,n,1,...i.children)}let a="";for(let n=0;n<t.length;n+=1){const i=t[n];a+=ld(i,Ad)}return a}var k;(function(e){e[e.Tab=9]="Tab",e[e.NewLine=10]="NewLine",e[e.FormFeed=12]="FormFeed",e[e.CarriageReturn=13]="CarriageReturn",e[e.Space=32]="Space",e[e.ExclamationMark=33]="ExclamationMark",e[e.Number=35]="Number",e[e.Amp=38]="Amp",e[e.SingleQuote=39]="SingleQuote",e[e.DoubleQuote=34]="DoubleQuote",e[e.Dash=45]="Dash",e[e.Slash=47]="Slash",e[e.Zero=48]="Zero",e[e.Nine=57]="Nine",e[e.Semi=59]="Semi",e[e.Lt=60]="Lt",e[e.Eq=61]="Eq",e[e.Gt=62]="Gt",e[e.Questionmark=63]="Questionmark",e[e.UpperA=65]="UpperA",e[e.LowerA=97]="LowerA",e[e.UpperF=70]="UpperF",e[e.LowerF=102]="LowerF",e[e.UpperZ=90]="UpperZ",e[e.LowerZ=122]="LowerZ",e[e.LowerX=120]="LowerX",e[e.OpeningSquareBracket=91]="OpeningSquareBracket"})(k||(k={}));var S;(function(e){e[e.Text=1]="Text",e[e.BeforeTagName=2]="BeforeTagName",e[e.InTagName=3]="InTagName",e[e.InSelfClosingTag=4]="InSelfClosingTag",e[e.BeforeClosingTagName=5]="BeforeClosingTagName",e[e.InClosingTagName=6]="InClosingTagName",e[e.AfterClosingTagName=7]="AfterClosingTagName",e[e.BeforeAttributeName=8]="BeforeAttributeName",e[e.InAttributeName=9]="InAttributeName",e[e.AfterAttributeName=10]="AfterAttributeName",e[e.BeforeAttributeValue=11]="BeforeAttributeValue",e[e.InAttributeValueDq=12]="InAttributeValueDq",e[e.InAttributeValueSq=13]="InAttributeValueSq",e[e.InAttributeValueNq=14]="InAttributeValueNq",e[e.BeforeDeclaration=15]="BeforeDeclaration",e[e.InDeclaration=16]="InDeclaration",e[e.InProcessingInstruction=17]="InProcessingInstruction",e[e.BeforeComment=18]="BeforeComment",e[e.CDATASequence=19]="CDATASequence",e[e.InSpecialComment=20]="InSpecialComment",e[e.InCommentLike=21]="InCommentLike",e[e.BeforeSpecialS=22]="BeforeSpecialS",e[e.BeforeSpecialT=23]="BeforeSpecialT",e[e.SpecialStartSequence=24]="SpecialStartSequence",e[e.InSpecialTag=25]="InSpecialTag",e[e.InEntity=26]="InEntity"})(S||(S={}));function qe(e){return e===k.Space||e===k.NewLine||e===k.Tab||e===k.FormFeed||e===k.CarriageReturn}function Oa(e){return e===k.Slash||e===k.Gt||qe(e)}function Cd(e){return e>=k.LowerA&&e<=k.LowerZ||e>=k.UpperA&&e<=k.UpperZ}var Ue;(function(e){e[e.NoValue=0]="NoValue",e[e.Unquoted=1]="Unquoted",e[e.Single=2]="Single",e[e.Double=3]="Double"})(Ue||(Ue={}));const fe={Cdata:new Uint8Array([67,68,65,84,65,91]),CdataEnd:new Uint8Array([93,93,62]),CommentEnd:new Uint8Array([45,45,62]),ScriptEnd:new Uint8Array([60,47,115,99,114,105,112,116]),StyleEnd:new Uint8Array([60,47,115,116,121,108,101]),TitleEnd:new Uint8Array([60,47,116,105,116,108,101]),TextareaEnd:new Uint8Array([60,47,116,101,120,116,97,114,101,97])};class Id{constructor({xmlMode:t=!1,decodeEntities:a=!0},n){this.cbs=n,this.state=S.Text,this.buffer="",this.sectionStart=0,this.index=0,this.entityStart=0,this.baseState=S.Text,this.isSpecial=!1,this.running=!0,this.offset=0,this.currentSequence=void 0,this.sequenceIndex=0,this.xmlMode=t,this.decodeEntities=a,this.entityDecoder=new $a(t?Xn:Ha,(i,r)=>this.emitCodePoint(i,r))}reset(){this.state=S.Text,this.buffer="",this.sectionStart=0,this.index=0,this.baseState=S.Text,this.currentSequence=void 0,this.running=!0,this.offset=0}write(t){this.offset+=this.buffer.length,this.buffer=t,this.parse()}end(){this.running&&this.finish()}pause(){this.running=!1}resume(){this.running=!0,this.index<this.buffer.length+this.offset&&this.parse()}stateText(t){t===k.Lt||!this.decodeEntities&&this.fastForwardTo(k.Lt)?(this.index>this.sectionStart&&this.cbs.ontext(this.sectionStart,this.index),this.state=S.BeforeTagName,this.sectionStart=this.index):this.decodeEntities&&t===k.Amp&&this.startEntity()}stateSpecialStartSequence(t){const a=this.sequenceIndex===this.currentSequence.length;if(!(a?Oa(t):(t|32)===this.currentSequence[this.sequenceIndex]))this.isSpecial=!1;else if(!a){this.sequenceIndex++;return}this.sequenceIndex=0,this.state=S.InTagName,this.stateInTagName(t)}stateInSpecialTag(t){if(this.sequenceIndex===this.currentSequence.length){if(t===k.Gt||qe(t)){const a=this.index-this.currentSequence.length;if(this.sectionStart<a){const n=this.index;this.index=a,this.cbs.ontext(this.sectionStart,a),this.index=n}this.isSpecial=!1,this.sectionStart=a+2,this.stateInClosingTagName(t);return}this.sequenceIndex=0}(t|32)===this.currentSequence[this.sequenceIndex]?this.sequenceIndex+=1:this.sequenceIndex===0?this.currentSequence===fe.TitleEnd?this.decodeEntities&&t===k.Amp&&this.startEntity():this.fastForwardTo(k.Lt)&&(this.sequenceIndex=1):this.sequenceIndex=+(t===k.Lt)}stateCDATASequence(t){t===fe.Cdata[this.sequenceIndex]?++this.sequenceIndex===fe.Cdata.length&&(this.state=S.InCommentLike,this.currentSequence=fe.CdataEnd,this.sequenceIndex=0,this.sectionStart=this.index+1):(this.sequenceIndex=0,this.state=S.InDeclaration,this.stateInDeclaration(t))}fastForwardTo(t){for(;++this.index<this.buffer.length+this.offset;)if(this.buffer.charCodeAt(this.index-this.offset)===t)return!0;return this.index=this.buffer.length+this.offset-1,!1}stateInCommentLike(t){t===this.currentSequence[this.sequenceIndex]?++this.sequenceIndex===this.currentSequence.length&&(this.currentSequence===fe.CdataEnd?this.cbs.oncdata(this.sectionStart,this.index,2):this.cbs.oncomment(this.sectionStart,this.index,2),this.sequenceIndex=0,this.sectionStart=this.index+1,this.state=S.Text):this.sequenceIndex===0?this.fastForwardTo(this.currentSequence[0])&&(this.sequenceIndex=1):t!==this.currentSequence[this.sequenceIndex-1]&&(this.sequenceIndex=0)}isTagStartChar(t){return this.xmlMode?!Oa(t):Cd(t)}startSpecial(t,a){this.isSpecial=!0,this.currentSequence=t,this.sequenceIndex=a,this.state=S.SpecialStartSequence}stateBeforeTagName(t){if(t===k.ExclamationMark)this.state=S.BeforeDeclaration,this.sectionStart=this.index+1;else if(t===k.Questionmark)this.state=S.InProcessingInstruction,this.sectionStart=this.index+1;else if(this.isTagStartChar(t)){const a=t|32;this.sectionStart=this.index,this.xmlMode?this.state=S.InTagName:a===fe.ScriptEnd[2]?this.state=S.BeforeSpecialS:a===fe.TitleEnd[2]?this.state=S.BeforeSpecialT:this.state=S.InTagName}else t===k.Slash?this.state=S.BeforeClosingTagName:(this.state=S.Text,this.stateText(t))}stateInTagName(t){Oa(t)&&(this.cbs.onopentagname(this.sectionStart,this.index),this.sectionStart=-1,this.state=S.BeforeAttributeName,this.stateBeforeAttributeName(t))}stateBeforeClosingTagName(t){qe(t)||(t===k.Gt?this.state=S.Text:(this.state=this.isTagStartChar(t)?S.InClosingTagName:S.InSpecialComment,this.sectionStart=this.index))}stateInClosingTagName(t){(t===k.Gt||qe(t))&&(this.cbs.onclosetag(this.sectionStart,this.index),this.sectionStart=-1,this.state=S.AfterClosingTagName,this.stateAfterClosingTagName(t))}stateAfterClosingTagName(t){(t===k.Gt||this.fastForwardTo(k.Gt))&&(this.state=S.Text,this.sectionStart=this.index+1)}stateBeforeAttributeName(t){t===k.Gt?(this.cbs.onopentagend(this.index),this.isSpecial?(this.state=S.InSpecialTag,this.sequenceIndex=0):this.state=S.Text,this.sectionStart=this.index+1):t===k.Slash?this.state=S.InSelfClosingTag:qe(t)||(this.state=S.InAttributeName,this.sectionStart=this.index)}stateInSelfClosingTag(t){t===k.Gt?(this.cbs.onselfclosingtag(this.index),this.state=S.Text,this.sectionStart=this.index+1,this.isSpecial=!1):qe(t)||(this.state=S.BeforeAttributeName,this.stateBeforeAttributeName(t))}stateInAttributeName(t){(t===k.Eq||Oa(t))&&(this.cbs.onattribname(this.sectionStart,this.index),this.sectionStart=this.index,this.state=S.AfterAttributeName,this.stateAfterAttributeName(t))}stateAfterAttributeName(t){t===k.Eq?this.state=S.BeforeAttributeValue:t===k.Slash||t===k.Gt?(this.cbs.onattribend(Ue.NoValue,this.sectionStart),this.sectionStart=-1,this.state=S.BeforeAttributeName,this.stateBeforeAttributeName(t)):qe(t)||(this.cbs.onattribend(Ue.NoValue,this.sectionStart),this.state=S.InAttributeName,this.sectionStart=this.index)}stateBeforeAttributeValue(t){t===k.DoubleQuote?(this.state=S.InAttributeValueDq,this.sectionStart=this.index+1):t===k.SingleQuote?(this.state=S.InAttributeValueSq,this.sectionStart=this.index+1):qe(t)||(this.sectionStart=this.index,this.state=S.InAttributeValueNq,this.stateInAttributeValueNoQuotes(t))}handleInAttributeValue(t,a){t===a||!this.decodeEntities&&this.fastForwardTo(a)?(this.cbs.onattribdata(this.sectionStart,this.index),this.sectionStart=-1,this.cbs.onattribend(a===k.DoubleQuote?Ue.Double:Ue.Single,this.index+1),this.state=S.BeforeAttributeName):this.decodeEntities&&t===k.Amp&&this.startEntity()}stateInAttributeValueDoubleQuotes(t){this.handleInAttributeValue(t,k.DoubleQuote)}stateInAttributeValueSingleQuotes(t){this.handleInAttributeValue(t,k.SingleQuote)}stateInAttributeValueNoQuotes(t){qe(t)||t===k.Gt?(this.cbs.onattribdata(this.sectionStart,this.index),this.sectionStart=-1,this.cbs.onattribend(Ue.Unquoted,this.index),this.state=S.BeforeAttributeName,this.stateBeforeAttributeName(t)):this.decodeEntities&&t===k.Amp&&this.startEntity()}stateBeforeDeclaration(t){t===k.OpeningSquareBracket?(this.state=S.CDATASequence,this.sequenceIndex=0):this.state=t===k.Dash?S.BeforeComment:S.InDeclaration}stateInDeclaration(t){(t===k.Gt||this.fastForwardTo(k.Gt))&&(this.cbs.ondeclaration(this.sectionStart,this.index),this.state=S.Text,this.sectionStart=this.index+1)}stateInProcessingInstruction(t){(t===k.Gt||this.fastForwardTo(k.Gt))&&(this.cbs.onprocessinginstruction(this.sectionStart,this.index),this.state=S.Text,this.sectionStart=this.index+1)}stateBeforeComment(t){t===k.Dash?(this.state=S.InCommentLike,this.currentSequence=fe.CommentEnd,this.sequenceIndex=2,this.sectionStart=this.index+1):this.state=S.InDeclaration}stateInSpecialComment(t){(t===k.Gt||this.fastForwardTo(k.Gt))&&(this.cbs.oncomment(this.sectionStart,this.index,0),this.state=S.Text,this.sectionStart=this.index+1)}stateBeforeSpecialS(t){const a=t|32;a===fe.ScriptEnd[3]?this.startSpecial(fe.ScriptEnd,4):a===fe.StyleEnd[3]?this.startSpecial(fe.StyleEnd,4):(this.state=S.InTagName,this.stateInTagName(t))}stateBeforeSpecialT(t){const a=t|32;a===fe.TitleEnd[3]?this.startSpecial(fe.TitleEnd,4):a===fe.TextareaEnd[3]?this.startSpecial(fe.TextareaEnd,4):(this.state=S.InTagName,this.stateInTagName(t))}startEntity(){this.baseState=this.state,this.state=S.InEntity,this.entityStart=this.index,this.entityDecoder.startEntity(this.xmlMode?Oe.Strict:this.baseState===S.Text||this.baseState===S.InSpecialTag?Oe.Legacy:Oe.Attribute)}stateInEntity(){const t=this.entityDecoder.write(this.buffer,this.index-this.offset);t>=0?(this.state=this.baseState,t===0&&(this.index=this.entityStart)):this.index=this.offset+this.buffer.length-1}cleanup(){this.running&&this.sectionStart!==this.index&&(this.state===S.Text||this.state===S.InSpecialTag&&this.sequenceIndex===0?(this.cbs.ontext(this.sectionStart,this.index),this.sectionStart=this.index):(this.state===S.InAttributeValueDq||this.state===S.InAttributeValueSq||this.state===S.InAttributeValueNq)&&(this.cbs.onattribdata(this.sectionStart,this.index),this.sectionStart=this.index))}shouldContinue(){return this.index<this.buffer.length+this.offset&&this.running}parse(){for(;this.shouldContinue();){const t=this.buffer.charCodeAt(this.index-this.offset);switch(this.state){case S.Text:{this.stateText(t);break}case S.SpecialStartSequence:{this.stateSpecialStartSequence(t);break}case S.InSpecialTag:{this.stateInSpecialTag(t);break}case S.CDATASequence:{this.stateCDATASequence(t);break}case S.InAttributeValueDq:{this.stateInAttributeValueDoubleQuotes(t);break}case S.InAttributeName:{this.stateInAttributeName(t);break}case S.InCommentLike:{this.stateInCommentLike(t);break}case S.InSpecialComment:{this.stateInSpecialComment(t);break}case S.BeforeAttributeName:{this.stateBeforeAttributeName(t);break}case S.InTagName:{this.stateInTagName(t);break}case S.InClosingTagName:{this.stateInClosingTagName(t);break}case S.BeforeTagName:{this.stateBeforeTagName(t);break}case S.AfterAttributeName:{this.stateAfterAttributeName(t);break}case S.InAttributeValueSq:{this.stateInAttributeValueSingleQuotes(t);break}case S.BeforeAttributeValue:{this.stateBeforeAttributeValue(t);break}case S.BeforeClosingTagName:{this.stateBeforeClosingTagName(t);break}case S.AfterClosingTagName:{this.stateAfterClosingTagName(t);break}case S.BeforeSpecialS:{this.stateBeforeSpecialS(t);break}case S.BeforeSpecialT:{this.stateBeforeSpecialT(t);break}case S.InAttributeValueNq:{this.stateInAttributeValueNoQuotes(t);break}case S.InSelfClosingTag:{this.stateInSelfClosingTag(t);break}case S.InDeclaration:{this.stateInDeclaration(t);break}case S.BeforeDeclaration:{this.stateBeforeDeclaration(t);break}case S.BeforeComment:{this.stateBeforeComment(t);break}case S.InProcessingInstruction:{this.stateInProcessingInstruction(t);break}case S.InEntity:{this.stateInEntity();break}}this.index++}this.cleanup()}finish(){this.state===S.InEntity&&(this.entityDecoder.end(),this.state=this.baseState),this.handleTrailingData(),this.cbs.onend()}handleTrailingData(){const t=this.buffer.length+this.offset;this.sectionStart>=t||(this.state===S.InCommentLike?this.currentSequence===fe.CdataEnd?this.cbs.oncdata(this.sectionStart,t,0):this.cbs.oncomment(this.sectionStart,t,0):this.state===S.InTagName||this.state===S.BeforeAttributeName||this.state===S.BeforeAttributeValue||this.state===S.AfterAttributeName||this.state===S.InAttributeName||this.state===S.InAttributeValueSq||this.state===S.InAttributeValueDq||this.state===S.InAttributeValueNq||this.state===S.InClosingTagName||this.cbs.ontext(this.sectionStart,t))}emitCodePoint(t,a){this.baseState!==S.Text&&this.baseState!==S.InSpecialTag?(this.sectionStart<this.entityStart&&this.cbs.onattribdata(this.sectionStart,this.entityStart),this.sectionStart=this.entityStart+a,this.index=this.sectionStart-1,this.cbs.onattribentity(t)):(this.sectionStart<this.entityStart&&this.cbs.ontext(this.sectionStart,this.entityStart),this.sectionStart=this.entityStart+a,this.index=this.sectionStart-1,this.cbs.ontextentity(t,this.sectionStart))}}const gt=new Set(["input","option","optgroup","select","button","datalist","textarea"]),X=new Set(["p"]),Ms=new Set(["thead","tbody"]),Ps=new Set(["dd","dt"]),vs=new Set(["rt","rp"]),Sd=new Map([["tr",new Set(["tr","th","td"])],["th",new Set(["th"])],["td",new Set(["thead","th","td"])],["body",new Set(["head","link","script"])],["li",new Set(["li"])],["p",X],["h1",X],["h2",X],["h3",X],["h4",X],["h5",X],["h6",X],["select",gt],["input",gt],["output",gt],["button",gt],["datalist",gt],["textarea",gt],["option",new Set(["option"])],["optgroup",new Set(["optgroup","option"])],["dd",Ps],["dt",Ps],["address",X],["article",X],["aside",X],["blockquote",X],["details",X],["div",X],["dl",X],["fieldset",X],["figcaption",X],["figure",X],["footer",X],["form",X],["header",X],["hr",X],["main",X],["nav",X],["ol",X],["pre",X],["section",X],["table",X],["ul",X],["rt",vs],["rp",vs],["tbody",Ms],["tfoot",Ms]]),xd=new Set(["area","base","basefont","br","col","command","embed","frame","hr","img","input","isindex","keygen","link","meta","param","source","track","wbr"]),Bs=new Set(["math","svg"]),ws=new Set(["mi","mo","mn","ms","mtext","annotation-xml","foreignobject","desc","title"]),Od=/\s|\//;class Dd{constructor(t,a={}){var n,i,r,u,o,l;this.options=a,this.startIndex=0,this.endIndex=0,this.openTagStart=0,this.tagname="",this.attribname="",this.attribvalue="",this.attribs=null,this.stack=[],this.buffers=[],this.bufferOffset=0,this.writeIndex=0,this.ended=!1,this.cbs=t??{},this.htmlMode=!this.options.xmlMode,this.lowerCaseTagNames=(n=a.lowerCaseTags)!==null&&n!==void 0?n:this.htmlMode,this.lowerCaseAttributeNames=(i=a.lowerCaseAttributeNames)!==null&&i!==void 0?i:this.htmlMode,this.recognizeSelfClosing=(r=a.recognizeSelfClosing)!==null&&r!==void 0?r:!this.htmlMode,this.tokenizer=new((u=a.Tokenizer)!==null&&u!==void 0?u:Id)(this.options,this),this.foreignContext=[!this.htmlMode],(l=(o=this.cbs).onparserinit)===null||l===void 0||l.call(o,this)}ontext(t,a){var n,i;const r=this.getSlice(t,a);this.endIndex=a-1,(i=(n=this.cbs).ontext)===null||i===void 0||i.call(n,r),this.startIndex=a}ontextentity(t,a){var n,i;this.endIndex=a-1,(i=(n=this.cbs).ontext)===null||i===void 0||i.call(n,Ya(t)),this.startIndex=a}isVoidElement(t){return this.htmlMode&&xd.has(t)}onopentagname(t,a){this.endIndex=a;let n=this.getSlice(t,a);this.lowerCaseTagNames&&(n=n.toLowerCase()),this.emitOpenTag(n)}emitOpenTag(t){var a,n,i,r;this.openTagStart=this.startIndex,this.tagname=t;const u=this.htmlMode&&Sd.get(t);if(u)for(;this.stack.length>0&&u.has(this.stack[0]);){const o=this.stack.shift();(n=(a=this.cbs).onclosetag)===null||n===void 0||n.call(a,o,!0)}this.isVoidElement(t)||(this.stack.unshift(t),this.htmlMode&&(Bs.has(t)?this.foreignContext.unshift(!0):ws.has(t)&&this.foreignContext.unshift(!1))),(r=(i=this.cbs).onopentagname)===null||r===void 0||r.call(i,t),this.cbs.onopentag&&(this.attribs={})}endOpenTag(t){var a,n;this.startIndex=this.openTagStart,this.attribs&&((n=(a=this.cbs).onopentag)===null||n===void 0||n.call(a,this.tagname,this.attribs,t),this.attribs=null),this.cbs.onclosetag&&this.isVoidElement(this.tagname)&&this.cbs.onclosetag(this.tagname,!0),this.tagname=""}onopentagend(t){this.endIndex=t,this.endOpenTag(!1),this.startIndex=t+1}onclosetag(t,a){var n,i,r,u,o,l,h,m;this.endIndex=a;let p=this.getSlice(t,a);if(this.lowerCaseTagNames&&(p=p.toLowerCase()),this.htmlMode&&(Bs.has(p)||ws.has(p))&&this.foreignContext.shift(),this.isVoidElement(p))this.htmlMode&&p==="br"&&((u=(r=this.cbs).onopentagname)===null||u===void 0||u.call(r,"br"),(l=(o=this.cbs).onopentag)===null||l===void 0||l.call(o,"br",{},!0),(m=(h=this.cbs).onclosetag)===null||m===void 0||m.call(h,"br",!1));else{const T=this.stack.indexOf(p);if(T!==-1)for(let A=0;A<=T;A++){const I=this.stack.shift();(i=(n=this.cbs).onclosetag)===null||i===void 0||i.call(n,I,A!==T)}else this.htmlMode&&p==="p"&&(this.emitOpenTag("p"),this.closeCurrentTag(!0))}this.startIndex=a+1}onselfclosingtag(t){this.endIndex=t,this.recognizeSelfClosing||this.foreignContext[0]?(this.closeCurrentTag(!1),this.startIndex=t+1):this.onopentagend(t)}closeCurrentTag(t){var a,n;const i=this.tagname;this.endOpenTag(t),this.stack[0]===i&&((n=(a=this.cbs).onclosetag)===null||n===void 0||n.call(a,i,!t),this.stack.shift())}onattribname(t,a){this.startIndex=t;const n=this.getSlice(t,a);this.attribname=this.lowerCaseAttributeNames?n.toLowerCase():n}onattribdata(t,a){this.attribvalue+=this.getSlice(t,a)}onattribentity(t){this.attribvalue+=Ya(t)}onattribend(t,a){var n,i;this.endIndex=a,(i=(n=this.cbs).onattribute)===null||i===void 0||i.call(n,this.attribname,this.attribvalue,t===Ue.Double?'"':t===Ue.Single?"'":t===Ue.NoValue?void 0:null),this.attribs&&!Object.prototype.hasOwnProperty.call(this.attribs,this.attribname)&&(this.attribs[this.attribname]=this.attribvalue),this.attribvalue=""}getInstructionName(t){const a=t.search(Od);let n=a<0?t:t.substr(0,a);return this.lowerCaseTagNames&&(n=n.toLowerCase()),n}ondeclaration(t,a){this.endIndex=a;const n=this.getSlice(t,a);if(this.cbs.onprocessinginstruction){const i=this.getInstructionName(n);this.cbs.onprocessinginstruction(`!${i}`,`!${n}`)}this.startIndex=a+1}onprocessinginstruction(t,a){this.endIndex=a;const n=this.getSlice(t,a);if(this.cbs.onprocessinginstruction){const i=this.getInstructionName(n);this.cbs.onprocessinginstruction(`?${i}`,`?${n}`)}this.startIndex=a+1}oncomment(t,a,n){var i,r,u,o;this.endIndex=a,(r=(i=this.cbs).oncomment)===null||r===void 0||r.call(i,this.getSlice(t,a-n)),(o=(u=this.cbs).oncommentend)===null||o===void 0||o.call(u),this.startIndex=a+1}oncdata(t,a,n){var i,r,u,o,l,h,m,p,T,A;this.endIndex=a;const I=this.getSlice(t,a-n);!this.htmlMode||this.options.recognizeCDATA?((r=(i=this.cbs).oncdatastart)===null||r===void 0||r.call(i),(o=(u=this.cbs).ontext)===null||o===void 0||o.call(u,I),(h=(l=this.cbs).oncdataend)===null||h===void 0||h.call(l)):((p=(m=this.cbs).oncomment)===null||p===void 0||p.call(m,`[CDATA[${I}]]`),(A=(T=this.cbs).oncommentend)===null||A===void 0||A.call(T)),this.startIndex=a+1}onend(){var t,a;if(this.cbs.onclosetag){this.endIndex=this.startIndex;for(let n=0;n<this.stack.length;n++)this.cbs.onclosetag(this.stack[n],!0)}(a=(t=this.cbs).onend)===null||a===void 0||a.call(t)}reset(){var t,a,n,i;(a=(t=this.cbs).onreset)===null||a===void 0||a.call(t),this.tokenizer.reset(),this.tagname="",this.attribname="",this.attribs=null,this.stack.length=0,this.startIndex=0,this.endIndex=0,(i=(n=this.cbs).onparserinit)===null||i===void 0||i.call(n,this),this.buffers.length=0,this.foreignContext.length=0,this.foreignContext.unshift(!this.htmlMode),this.bufferOffset=0,this.writeIndex=0,this.ended=!1}parseComplete(t){this.reset(),this.end(t)}getSlice(t,a){for(;t-this.bufferOffset>=this.buffers[0].length;)this.shiftBuffer();let n=this.buffers[0].slice(t-this.bufferOffset,a-this.bufferOffset);for(;a-this.bufferOffset>this.buffers[0].length;)this.shiftBuffer(),n+=this.buffers[0].slice(0,a-this.bufferOffset);return n}shiftBuffer(){this.bufferOffset+=this.buffers[0].length,this.writeIndex--,this.buffers.shift()}write(t){var a,n;if(this.ended){(n=(a=this.cbs).onerror)===null||n===void 0||n.call(a,new Error(".write() after done!"));return}this.buffers.push(t),this.tokenizer.running&&(this.tokenizer.write(t),this.writeIndex++)}end(t){var a,n;if(this.ended){(n=(a=this.cbs).onerror)===null||n===void 0||n.call(a,new Error(".end() after done!"));return}t&&this.write(t),this.ended=!0,this.tokenizer.end()}pause(){this.tokenizer.pause()}resume(){for(this.tokenizer.resume();this.tokenizer.running&&this.writeIndex<this.buffers.length;)this.tokenizer.write(this.buffers[this.writeIndex++]);this.ended&&this.tokenizer.end()}parseChunk(t){this.write(t)}done(t){this.end(t)}}function Ld(e,t){const a=new yr(void 0,t);return new Dd(a,t).end(e),a.root}const yd=sc((e,t,a,n)=>t._useHtmlParser2?Ld(e,t):_d(e,t,a,n)),Us=Uc(yd,(e,t)=>t._useHtmlParser2?ta(e,t):Nd(e));var Q=(e=>(e[e.None=0]="None",e[e.Text=1]="Text",e[e.Image=2]="Image",e[e.Video=3]="Video",e[e.Icon=4]="Icon",e[e.Link=5]="Link",e[e.Block=10]="Block",e))(Q||{});const Rd=c.defineComponent({name:"GpImageUpload",props:{accept:{type:String,default:"image/*"},multiple:{type:Boolean,default:!1},maxCount:{type:Number,default:1/0},beforeUpload:Function,onChange:Function,showList:{type:Boolean,default:!1}},setup(e,{emit:t}){const a=c.ref(null),n=c.ref([]);return{inputRef:a,fileList:n,triggerInput:()=>{var o;(o=a.value)==null||o.click()},handleChange:async o=>{var p;const h=o.target.files;if(!h)return;const m=[];for(let T=0;T<h.length;T++){const A=h[T];if(e.beforeUpload&&await e.beforeUpload(A)===!1)continue;const I=`${Date.now()}-${A.name}`,R=URL.createObjectURL(A);m.push({uid:I,name:A.name,status:"uploading",thumbUrl:R})}e.maxCount&&n.value.length+m.length>e.maxCount&&m.splice(e.maxCount-n.value.length),e.multiple?n.value=[...n.value,...m]:n.value=m.slice(0,1),(p=e.onChange)==null||p.call(e,n.value),t("update:fileList",n.value),a.value&&(a.value.value="")},removeFile:o=>{var l;n.value=n.value.filter(h=>h.uid!==o),(l=e.onChange)==null||l.call(e,n.value)}}}}),Ke=(e,t)=>{const a=e.__vccOpts||e;for(const[n,i]of t)a[n]=i;return a},kd={class:"upload-wrapper"},Md=["accept","multiple"],Pd={key:0,class:"file-list mt-4"},vd={class:"flex items-center space-x-4"},Bd=["src"],wd=["onClick"];function Ud(e,t,a,n,i,r){return c.openBlock(),c.createElementBlock("div",kd,[c.createElementVNode("div",{class:"",onClick:t[0]||(t[0]=(...u)=>e.triggerInput&&e.triggerInput(...u))},[c.renderSlot(e.$slots,"upload-icon",{},()=>[t[2]||(t[2]=c.createElementVNode("div",{class:"upload-area border-dashed border-2 p-6 rounded cursor-pointer hover:border-blue-500"},[c.createElementVNode("div",{class:"text-gray-400 text-lg text-center"}," 点击或拖拽上传图片 ")],-1))],!0)]),c.createElementVNode("input",{type:"file",ref:"inputRef",class:"hidden",accept:e.accept,multiple:e.multiple,onChange:t[1]||(t[1]=(...u)=>e.handleChange&&e.handleChange(...u))},null,40,Md),e.showList?(c.openBlock(),c.createElementBlock("div",Pd,[(c.openBlock(!0),c.createElementBlock(c.Fragment,null,c.renderList(e.fileList,u=>(c.openBlock(),c.createElementBlock("div",{key:u.uid,class:"file-item flex items-center justify-between p-2 border rounded mb-2"},[c.createElementVNode("div",vd,[u.thumbUrl?(c.openBlock(),c.createElementBlock("img",{key:0,src:u.thumbUrl,alt:"preview",class:"w-12 h-12 object-cover rounded"},null,8,Bd)):c.createCommentVNode("",!0),c.createElementVNode("span",null,c.toDisplayString(u.name),1)]),c.createElementVNode("div",null,[c.createElementVNode("button",{onClick:o=>e.removeFile(u.uid),class:"text-red-500 hover:underline"}," 删除 ",8,wd)])]))),128))])):c.createCommentVNode("",!0)])}const Fd=Ke(Rd,[["render",Ud],["__scopeId","data-v-dcbfe0e5"]]),Hd={key:0,"date-action":"1",class:"text-red-500 text-xs mt-1"},Vd=Ke(c.defineComponent({__name:"ElementRenderer",props:{element:{type:Object,required:!0},selectedElement:Object,hoveredElement:Object,icons:{type:Array,default:()=>[]},mode:{type:String,default:"edit"},cropper:{type:Object,required:!1},icon:{type:Object,required:!1},r:{type:String,required:!1}},emits:["selectElement","hoverElement","updateText","contentUpdated","blockAction","addIcon","upload"],setup(e,{emit:t}){const a=e,n=t,i=c.computed(()=>a.selectedElement===a.element),r=c.computed(()=>a.hoveredElement===a.element),u=c.ref(!1),o=c.ref(!1),l=c.ref(""),h=c.computed(()=>a.element.rule.minText||0),m=c.computed(()=>a.element.rule.maxText||1/0);c.watch(()=>a.r,()=>{n("contentUpdated",B())},{immediate:!0});function p(O){O.xpath!="/div[1]"&&a.mode!=="preview"&&(a.mode==="edit"?O.type===Q.Text&&n("selectElement",O):n("selectElement",O),!O.rule.isReadOnly&&O.type===Q.Text&&(u.value=!0))}function T(O){n("selectElement",O)}function A(O,L){n("hoverElement",O,L)}function I(O){n("hoverElement",O)}function R(O){O.currentTarget.contains(O.relatedTarget)?n("hoverElement",null):a.hoveredElement?n("hoverElement",null,a.hoveredElement.parentxpath):n("hoverElement",null)}function M(){u.value=!1,n("contentUpdated",B())}function B(){function O(L){const ne=Object.entries(L.attrs||{}).map(([P,H])=>`${P}="${H}"`).join(" "),Ee=`<${L.tag}${ne?" "+ne:""}>`,C=`</${L.tag}>`,D=(L.children||[]).map(P=>O(P)).join("");return`${Ee}${L.editText||L.text||""}${D}${C}`}return O(a.element)}c.ref();function W(O){var C;O.stopPropagation();const L=O.target,ne=((C=L.firstChild)==null?void 0:C.nodeType)===Node.TEXT_NODE&&L.firstChild.nodeValue||"";if(ne.length<h.value){o.value=!0,l.value=`最少输入 ${h.value} 个字符`;return}else if(ne.length>m.value){o.value=!0,l.value=`最多输入 ${m.value} 个字符`;return}else o.value=!1,l.value="";n("updateText",{element:a.element,newText:ne}),n("contentUpdated",B());const Ee=c.toRaw(a.element);Ee.editText=ne}function q(O){n("updateText",O),n("contentUpdated",B())}function ae(){const O={...a.element};n("blockAction",{action:"add",element:a.element,newBlock:O})}function U(){_(a.element),n("blockAction",{action:"moveUp",element:a.element})}function _(O){O.children&&O.children.length>0&&O.children.forEach(L=>{L.type==Q.Text&&(L.text!==L.editText&&(L.text=L.editText),_(L))})}function w(){_(a.element),n("blockAction",{action:"moveDown",element:a.element})}function Y(){n("blockAction",{action:"delete",element:a.element})}function se(O){n("blockAction",O),n("contentUpdated",B())}function be(O){me.value.openModal(O)}function Pe(O,L){n("addIcon",O,L),n("contentUpdated",B())}let ye;const Re=c.ref(a.cropper),me=c.ref(a.icon),z=c.ref({});function xe(O,L){console.log("files",O,L);const ne=O[0];L.rule.minImageWidth&&L.rule.maxImageHeight?(z.value.width=L.rule.minImageWidth,z.value.height=L.rule.maxImageHeight,z.value.aspectRatio=L.rule.minImageWidth/L.rule.maxImageHeight):z.value={},ne&&(ne.name,ye=ne.thumbUrl,Re.value.handleOpenCropper(z.value,ye,ne.name,L))}function ve(O,L){if(console.log("event",O,L),console.log(typeof O=="object",O),O)if(typeof O=="object"){L.attrs.alt=O.name;const ne=new FileReader;ne.onload=Ee=>{var D;let C=(D=Ee==null?void 0:Ee.target)==null?void 0:D.result;L.attrs.src=C,n("upload",C,L),n("contentUpdated",B())},ne.readAsDataURL(O)}else L.attrs.src=O,n("upload",O,L),n("contentUpdated",B())}const tt=O=>O.type.startsWith("image/")?!0:(alert("只能上传图片!"),!1);return(O,L)=>{const ne=c.resolveComponent("ElementRenderer",!0);return c.openBlock(),c.createElementBlock(c.Fragment,null,[(c.openBlock(),c.createBlock(c.resolveDynamicComponent(a.element.tag),c.mergeProps({class:["relative",e.mode==="design"?"m-2 p-1 border-dashed border-2":"",r.value?"border-dashed border-blue-500":"",i.value?"border-dashed border-green-500 z-10 border-2":"",o.value?"border-dashed border-red-500":"",(!r.value&&!i.value&&!o.value,""),a.element.rule&&a.element.rule.isReadOnly?"cursor-not-allowed":""]},a.element.attrs,{contenteditable:u.value,onClick:L[2]||(L[2]=c.withModifiers(()=>p(a.element),["stop"])),onMouseenter:L[3]||(L[3]=()=>I(a.element)),onMouseleave:R,onBlur:M,onInput:W}),{default:c.withCtx(()=>[c.createTextVNode(c.toDisplayString(a.element.text),1),a.element.children&&a.element.children.length?(c.openBlock(),c.createElementBlock(c.Fragment,{key:0},[(c.openBlock(!0),c.createElementBlock(c.Fragment,null,c.renderList(a.element.children,(Ee,C)=>(c.openBlock(),c.createBlock(ne,{mode:e.mode,icons:e.icons,r:e.r,key:C,element:Ee,selectedElement:a.selectedElement,hoveredElement:a.hoveredElement,onSelectElement:T,onHoverElement:A,onUpdateText:q,onBlockAction:se,onAddIcon:Pe,onUpload:ve,cropper:e.cropper,icon:e.icon},null,8,["mode","icons","r","element","selectedElement","hoveredElement","cropper","icon"]))),128)),a.element.type===c.unref(Q).Block?(c.openBlock(),c.createElementBlock("div",{key:0,"date-action":"1",contenteditable:"false",onClick:L[0]||(L[0]=c.withModifiers(()=>{},["stop"])),class:"z-10 flex space-x-1 flex-none flex-nowrap overflow-visible absolute top-2"},[c.createElementVNode("button",{class:"flex-none px-2 py-1 bg-blue-500 text-white rounded",onClick:c.withModifiers(ae,["stop"])}," + "),c.createElementVNode("button",{class:"flex-none px-2 py-1 bg-gray-300 text-white rounded",onClick:c.withModifiers(U,["stop"])}," ⬅️ "),c.createElementVNode("button",{class:"flex-none px-2 py-1 bg-gray-300 text-white rounded",onClick:c.withModifiers(w,["stop"])}," ➡️ "),c.createElementVNode("button",{class:"flex-none px-2 py-1 bg-red-500 text-white rounded",onClick:c.withModifiers(Y,["stop"])}," ✖ ")])):c.createCommentVNode("",!0)],64)):c.createCommentVNode("",!0),a.element.type===c.unref(Q).Icon?(c.openBlock(),c.createElementBlock("div",{key:1,class:"cursor-pointer rounded-sm w-5 h-5 flex justify-center items-center absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 text-sm text-gray-50 z-10 bg-black/80",contenteditable:"false",onClick:L[1]||(L[1]=c.withModifiers(()=>be(a.element),["stop"]))}," ↑ ")):c.createCommentVNode("",!0)]),_:1},16,["class","contenteditable"])),a.element.type==c.unref(Q).Text&&o.value?(c.openBlock(),c.createElementBlock("div",Hd,c.toDisplayString(l.value),1)):c.createCommentVNode("",!0),a.element.type===c.unref(Q).Image?(c.openBlock(),c.createElementBlock("div",{key:1,class:"cursor-pointer rounded-sm flex justify-center items-center absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 text-sm text-gray-50 z-10 bg-black/80",onClick:L[5]||(L[5]=c.withModifiers(()=>{},["stop"])),contenteditable:"false"},[c.createVNode(Fd,{multiple:!1,beforeUpload:tt,onChange:L[4]||(L[4]=Ee=>xe(Ee,a.element))},{"upload-icon":c.withCtx(()=>L[6]||(L[6]=[c.createElementVNode("div",{class:"p-2"},"上传",-1)])),_:1})])):c.createCommentVNode("",!0)],64)}}}),[["__scopeId","data-v-7c5fe475"]]),Yd=c.defineComponent({name:"GpCheckbox",props:{modelValue:{type:Boolean,required:!0},label:{type:String,default:""}},emits:["update:modelValue"],setup(e,{emit:t}){return{updateValue:n=>{t("update:modelValue",n.target.checked)}}}}),qd={class:"form-group"},$d={class:"flex items-center space-x-2 cursor-pointer"},Wd=["checked","aria-checked"],Gd={class:"checkbox-label text-sm text-gray-700"};function Xd(e,t,a,n,i,r){return c.openBlock(),c.createElementBlock("div",qd,[c.createElementVNode("label",$d,[c.createElementVNode("input",{type:"checkbox",checked:e.modelValue,onChange:t[0]||(t[0]=(...u)=>e.updateValue&&e.updateValue(...u)),class:"custom-checkbox","aria-checked":e.modelValue},null,40,Wd),c.createElementVNode("span",Gd,c.toDisplayString(e.label),1)])])}const Da=Ke(Yd,[["render",Xd],["__scopeId","data-v-68b8f276"]]),Qd=c.defineComponent({name:"GpMessage",props:{message:{type:String,required:!0},type:{type:String,default:"info"},position:{type:String,default:"top-right"},duration:{type:Number,default:3e3},onClose:{type:Function,required:!0},icon:{type:Boolean,default:!0}},setup(e){const t=c.ref(!1),a=c.computed(()=>({success:"bg-green-100 text-green-800",error:"bg-red-100 text-red-800",info:"bg-blue-100 text-blue-800",warning:"bg-yellow-100 text-yellow-800"})[e.type]),n=()=>{t.value=!1,e.onClose()};return setTimeout(()=>{n()},e.duration),t.value=!0,{visible:t,typeClass:a,closeMessage:n}}}),jd={key:0,class:"gp-message"},zd={key:0,class:"mr-2"},Kd={key:0,class:"text-green-500"},Zd={key:1,class:"text-red-500"},Jd={key:2,class:"text-blue-500"},eh={key:3,class:"text-yellow-500"};function th(e,t,a,n,i,r){return c.openBlock(),c.createBlock(c.Transition,{name:"fade"},{default:c.withCtx(()=>[e.visible?(c.openBlock(),c.createElementBlock("div",jd,[c.createElementVNode("div",{class:c.normalizeClass([e.typeClass,"message-content"])},[e.icon?(c.openBlock(),c.createElementBlock("span",zd,[c.renderSlot(e.$slots,"icon",{},()=>[e.type==="success"?(c.openBlock(),c.createElementBlock("span",Kd,"✔")):c.createCommentVNode("",!0),e.type==="error"?(c.openBlock(),c.createElementBlock("span",Zd,"✖")):c.createCommentVNode("",!0),e.type==="info"?(c.openBlock(),c.createElementBlock("span",Jd,"ℹ")):c.createCommentVNode("",!0),e.type==="warning"?(c.openBlock(),c.createElementBlock("span",eh,"⚠")):c.createCommentVNode("",!0)],!0)])):c.createCommentVNode("",!0),c.createElementVNode("span",null,c.toDisplayString(e.message),1),c.createElementVNode("button",{class:"close-btn hover:text-gray-800 font-bold",onClick:t[0]||(t[0]=(...u)=>e.closeMessage&&e.closeMessage(...u))}," × ")],2)])):c.createCommentVNode("",!0)]),_:3})}const ah=Ke(Qd,[["render",th],["__scopeId","data-v-56476f4c"]]),_t=c.reactive([]);let xn=null;const nh=()=>{const e=document.createElement("div");return e.id="global-message-container",document.body.appendChild(e),e},ih=()=>{if(xn)return;const e=nh();xn=c.createApp({setup(){return{messageQueue:_t}},render(){const t=c.computed(()=>{var n;return{"top-left":"top-4 left-4","top-right":"top-4 right-4","bottom-left":"bottom-4 left-4","bottom-right":"bottom-4 right-4","top-center":"top-4 left-1/2 transform -translate-x-1/2","bottom-center":"bottom-4 left-1/2 transform -translate-x-1/2"}[((n=_t[0])==null?void 0:n.options.position)||"top-right"]});return c.h("div",{class:`fixed flex flex-col gap-2 ${t.value}`},_t.map(a=>c.h(ah,{key:a.id,...a.options,onClose:()=>Fs(a.id)})))}}),xn.mount(e)},Fs=e=>{const t=_t.findIndex(a=>a.id===e);t!==-1&&_t.splice(t,1)};let sh=0;const j=e=>{ih();const t=sh++;_t.push({id:t,options:e}),setTimeout(()=>{Fs(t)},e.duration||3e3)};j.success=(e,t=3e3,a=!0)=>{j(typeof e=="string"?{message:e,type:"success",duration:t,icon:a}:{...e,type:"success"})},j.error=(e,t=3e3,a=!0)=>{j(typeof e=="string"?{message:e,type:"error",duration:t,icon:a}:{...e,type:"error"})},j.info=(e,t=3e3,a=!0)=>{j(typeof e=="string"?{message:e,type:"info",duration:t,icon:a}:{...e,type:"info"})},j.warning=(e,t=3e3,a=!0)=>{j(typeof e=="string"?{message:e,type:"warning",duration:t,icon:a}:{...e,type:"warning"})};const rh={key:0},uh={key:0},oh={class:"text-gray-500 my-2"},ch={class:"text-gray-500 my-2"},lh={key:1},dh={key:2},hh={key:3},fh={key:4},mh={key:5},Eh={key:6},ph={key:7},Th={key:8},bh=Ke(c.defineComponent({__name:"EditorPanel",props:{element:Object},emits:["updateElement"],setup(e,{emit:t}){const a=e,n=t,i=c.ref({rule:{},...a.element});c.watch(()=>a.element,u=>{i.value={rule:{},...u}},{immediate:!0});function r(){if(i.value.type===Q.Icon&&!i.value.attrs.class.includes("iconfont")){j.error("图标仅支持 iconfont 图标");return}if(i.value.type===Q.Image&&i.value.tag!=="img"){j.error("节点类型错误");return}if(i.value.type===Q.Video&&i.value.tag!=="video"){j.error("节点类型错误");return}if(i.value.type===Q.Link&&i.value.tag!=="a"){j.error("节点类型错误");return}if(i.value.type===Q.Text){if(i.value.rule.minText>i.value.rule.maxText){j.error("最小文本长度不能大于最大文本长度");return}if(i.value.tag!=="p"&&i.value.tag!=="div"&&i.value.tag!=="span"&&i.value.tag!=="h1"&&i.value.tag!=="h2"&&i.value.tag!=="h3"&&i.value.tag!=="h4"&&i.value.tag!=="h5"&&i.value.tag!=="h6"){j.error("节点类型错误");return}}if(i.value.type===Q.Block){if(i.value.rule.minBlock>i.value.rule.maxBlock){j.error("最小块数量不能大于最大块数量");return}if(i.value.tag!=="div"&&i.value.tag!=="section"&&i.value.tag!=="article"&&i.value.tag!=="nav"&&i.value.tag!=="header"&&i.value.tag!=="footer"&&i.value.tag!=="span"&&i.value.tag!=="p"&&i.value.tag!=="img"){j.error("节点类型错误");return}if(!i.value.children||i.value.children.length<1){j.error("节点错误,必须包含子元素");return}}n("updateElement",i.value)}return(u,o)=>(c.openBlock(),c.createElementBlock("div",null,[i.value?(c.openBlock(),c.createElementBlock("div",rh,[i.value.text!==void 0?(c.openBlock(),c.createElementBlock("div",uh,[o[11]||(o[11]=c.createElementVNode("label",{class:"block"},"内容",-1)),c.createElementVNode("div",oh,c.toDisplayString(i.value.text||"-"),1)])):c.createCommentVNode("",!0),c.createElementVNode("div",null,[o[12]||(o[12]=c.createElementVNode("label",{class:"block mt-4"},"节点",-1)),c.createElementVNode("div",ch,c.toDisplayString(i.value.xpath),1)]),c.createElementVNode("div",null,[o[14]||(o[14]=c.createElementVNode("label",{class:"block mt-4"},"类型",-1)),c.withDirectives(c.createElementVNode("select",{"onUpdate:modelValue":o[0]||(o[0]=l=>i.value.type=l),class:"border rounded p-1 w-full"},o[13]||(o[13]=[c.createElementVNode("option",{value:0},"无",-1),c.createElementVNode("option",{value:1},"文本",-1),c.createElementVNode("option",{value:2},"图片",-1),c.createElementVNode("option",{value:3},"视频",-1),c.createElementVNode("option",{value:4},"图标",-1),c.createElementVNode("option",{value:5},"链接",-1),c.createElementVNode("option",{value:10},"块",-1)]),512),[[c.vModelSelect,i.value.type]])]),i.value.type==c.unref(Q).Text?(c.openBlock(),c.createElementBlock("div",lh,[o[15]||(o[15]=c.createElementVNode("label",{class:"block mt-4"},"最小文本长度",-1)),c.withDirectives(c.createElementVNode("input",{"onUpdate:modelValue":o[1]||(o[1]=l=>i.value.rule.minText=l),class:"border rounded p-1 w-full"},null,512),[[c.vModelText,i.value.rule.minText]])])):c.createCommentVNode("",!0),i.value.type==c.unref(Q).Text?(c.openBlock(),c.createElementBlock("div",dh,[o[16]||(o[16]=c.createElementVNode("label",{class:"block mt-4"},"最大文本长度",-1)),c.withDirectives(c.createElementVNode("input",{"onUpdate:modelValue":o[2]||(o[2]=l=>i.value.rule.maxText=l),class:"border rounded p-1 w-full"},null,512),[[c.vModelText,i.value.rule.maxText]])])):c.createCommentVNode("",!0),i.value.type==c.unref(Q).Image?(c.openBlock(),c.createElementBlock("div",hh,[o[17]||(o[17]=c.createElementVNode("label",{class:"block mt-4"},"是否裁剪",-1)),c.createVNode(Da,{class:"py-2",modelValue:i.value.rule.crop,"onUpdate:modelValue":o[3]||(o[3]=l=>i.value.rule.crop=l),label:"是"},null,8,["modelValue"])])):c.createCommentVNode("",!0),i.value.type==c.unref(Q).Image?(c.openBlock(),c.createElementBlock("div",fh,[o[18]||(o[18]=c.createElementVNode("label",{class:"block mt-4"},"图片宽度",-1)),c.withDirectives(c.createElementVNode("input",{"onUpdate:modelValue":o[4]||(o[4]=l=>i.value.rule.minImageWidth=l),class:"border rounded p-1 w-full"},null,512),[[c.vModelText,i.value.rule.minImageWidth]])])):c.createCommentVNode("",!0),i.value.type==c.unref(Q).Image?(c.openBlock(),c.createElementBlock("div",mh,[o[19]||(o[19]=c.createElementVNode("label",{class:"block mt-4"},"图片高度",-1)),c.withDirectives(c.createElementVNode("input",{"onUpdate:modelValue":o[5]||(o[5]=l=>i.value.rule.maxImageHeight=l),class:"border rounded p-1 w-full"},null,512),[[c.vModelText,i.value.rule.maxImageHeight]])])):c.createCommentVNode("",!0),i.value.type==c.unref(Q).Block?(c.openBlock(),c.createElementBlock("div",Eh,[o[20]||(o[20]=c.createElementVNode("label",{class:"block mt-4"},"块最小数量",-1)),c.withDirectives(c.createElementVNode("input",{"onUpdate:modelValue":o[6]||(o[6]=l=>i.value.rule.minBlock=l),class:"border rounded p-1 w-full"},null,512),[[c.vModelText,i.value.rule.minBlock]])])):c.createCommentVNode("",!0),i.value.type==c.unref(Q).Block?(c.openBlock(),c.createElementBlock("div",ph,[o[21]||(o[21]=c.createElementVNode("label",{class:"block mt-4"},"块最大数量",-1)),c.withDirectives(c.createElementVNode("input",{"onUpdate:modelValue":o[7]||(o[7]=l=>i.value.rule.maxBlock=l),class:"border rounded p-1 w-full"},null,512),[[c.vModelText,i.value.rule.maxBlock]])])):c.createCommentVNode("",!0),i.value.type==c.unref(Q).Text||i.value.type==c.unref(Q).Icon?(c.openBlock(),c.createElementBlock("div",Th,[o[22]||(o[22]=c.createElementVNode("label",{class:"block mt-4"},"主题色",-1)),c.createVNode(Da,{class:"py-2",modelValue:i.value.rule.isThemeColor,"onUpdate:modelValue":o[8]||(o[8]=l=>i.value.rule.isThemeColor=l),label:"是"},null,8,["modelValue"])])):c.createCommentVNode("",!0),c.createElementVNode("div",null,[o[23]||(o[23]=c.createElementVNode("label",{class:"block mt-4"},"是否必填",-1)),c.createVNode(Da,{class:"py-2",modelValue:i.value.rule.isRequired,"onUpdate:modelValue":o[9]||(o[9]=l=>i.value.rule.isRequired=l),label:"是"},null,8,["modelValue"])]),c.createElementVNode("div",null,[o[24]||(o[24]=c.createElementVNode("label",{class:"block mt-4"},"是否只读",-1)),c.createVNode(Da,{class:"py-2",modelValue:i.value.rule.isReadOnly,"onUpdate:modelValue":o[10]||(o[10]=l=>i.value.rule.isReadOnly=l),label:"是"},null,8,["modelValue"])])])):c.createCommentVNode("",!0),c.createElementVNode("button",{onClick:r,class:"mt-4 p-2 bg-green-500 text-white rounded"}," 保存 ")]))}}),[["__scopeId","data-v-b077a796"]]);/*!
|
8
|
+
`)}}).toArray()}const Pc=Object.freeze(Object.defineProperty({__proto__:null,serialize:kc,serializeArray:Mc},Symbol.toStringTag,{value:"Module"}));function vc(e){var t;return typeof e=="string"?{selector:e,value:"textContent"}:{selector:e.selector,value:(t=e.value)!==null&&t!==void 0?t:"textContent"}}function Bc(e){const t={};for(const a in e){const n=e[a],i=Array.isArray(n),{selector:r,value:u}=vc(i?n[0]:n),o=typeof u=="function"?u:typeof u=="string"?l=>this._make(l).prop(u):l=>this._make(l).extract(u);if(i)t[a]=this._findBySelector(r,Number.POSITIVE_INFINITY).map((l,h)=>o(h,a,t)).get();else{const l=this._findBySelector(r,1);t[a]=l.length>0?o(l[0],a,t):void 0}}return t}const wc=Object.freeze(Object.defineProperty({__proto__:null,extract:Bc},Symbol.toStringTag,{value:"Module"}));class vt{constructor(t,a,n){if(this.length=0,this.options=n,this._root=a,t){for(let i=0;i<t.length;i++)this[i]=t[i];this.length=t.length}}}vt.prototype.cheerio="[cheerio object]",vt.prototype.splice=Array.prototype.splice,vt.prototype[Symbol.iterator]=Array.prototype[Symbol.iterator],Object.assign(vt.prototype,Yu,ic,xc,yc,Pc,wc);function Uc(e,t){return function a(n,i,r=!0){if(n==null)throw new Error("cheerio.load() expects a string");const u=ja(i),o=e(n,u,r,null);class l extends vt{_make(p,T){const A=h(p,T);return A.prevObject=this,A}_parse(p,T,A,I){return e(p,T,A,I)}_render(p){return t(p,this.options)}}function h(m,p,T=o,A){if(m&&Ve(m))return m;const I=ja(A,u),R=typeof T=="string"?[e(T,I,!1,null)]:"length"in T?T:[T],M=Ve(R)?R:new l(R,null,I);if(M._root=M,!m)return new l(void 0,M,I);const B=typeof m=="string"&&za(m)?e(m,I,!1,null).children:Fc(m)?[m]:Array.isArray(m)?m:void 0,W=new l(B,M,I);if(B)return W;if(typeof m!="string")throw new TypeError("Unexpected type of selector");let q=m;const ae=p?typeof p=="string"?za(p)?new l([e(p,I,!1,null)],M,I):(q=`${p} ${q}`,M):Ve(p)?p:new l(Array.isArray(p)?p:[p],M,I):M;return ae?ae.find(q):W}return Object.assign(h,yu,{load:a,_root:o,_options:u,fn:l.prototype,prototype:l.prototype}),h}}function Fc(e){return!!e.name||e.type==="root"||e.type==="text"||e.type==="comment"}const Hc=new Set([65534,65535,131070,131071,196606,196607,262142,262143,327678,327679,393214,393215,458750,458751,524286,524287,589822,589823,655358,655359,720894,720895,786430,786431,851966,851967,917502,917503,983038,983039,1048574,1048575,1114110,1114111]),Z="�";var d;(function(e){e[e.EOF=-1]="EOF",e[e.NULL=0]="NULL",e[e.TABULATION=9]="TABULATION",e[e.CARRIAGE_RETURN=13]="CARRIAGE_RETURN",e[e.LINE_FEED=10]="LINE_FEED",e[e.FORM_FEED=12]="FORM_FEED",e[e.SPACE=32]="SPACE",e[e.EXCLAMATION_MARK=33]="EXCLAMATION_MARK",e[e.QUOTATION_MARK=34]="QUOTATION_MARK",e[e.AMPERSAND=38]="AMPERSAND",e[e.APOSTROPHE=39]="APOSTROPHE",e[e.HYPHEN_MINUS=45]="HYPHEN_MINUS",e[e.SOLIDUS=47]="SOLIDUS",e[e.DIGIT_0=48]="DIGIT_0",e[e.DIGIT_9=57]="DIGIT_9",e[e.SEMICOLON=59]="SEMICOLON",e[e.LESS_THAN_SIGN=60]="LESS_THAN_SIGN",e[e.EQUALS_SIGN=61]="EQUALS_SIGN",e[e.GREATER_THAN_SIGN=62]="GREATER_THAN_SIGN",e[e.QUESTION_MARK=63]="QUESTION_MARK",e[e.LATIN_CAPITAL_A=65]="LATIN_CAPITAL_A",e[e.LATIN_CAPITAL_Z=90]="LATIN_CAPITAL_Z",e[e.RIGHT_SQUARE_BRACKET=93]="RIGHT_SQUARE_BRACKET",e[e.GRAVE_ACCENT=96]="GRAVE_ACCENT",e[e.LATIN_SMALL_A=97]="LATIN_SMALL_A",e[e.LATIN_SMALL_Z=122]="LATIN_SMALL_Z"})(d||(d={}));const Ae={DASH_DASH:"--",CDATA_START:"[CDATA[",DOCTYPE:"doctype",SCRIPT:"script",PUBLIC:"public",SYSTEM:"system"};function Gi(e){return e>=55296&&e<=57343}function Vc(e){return e>=56320&&e<=57343}function Yc(e,t){return(e-55296)*1024+9216+t}function Xi(e){return e!==32&&e!==10&&e!==13&&e!==9&&e!==12&&e>=1&&e<=31||e>=127&&e<=159}function Qi(e){return e>=64976&&e<=65007||Hc.has(e)}var g;(function(e){e.controlCharacterInInputStream="control-character-in-input-stream",e.noncharacterInInputStream="noncharacter-in-input-stream",e.surrogateInInputStream="surrogate-in-input-stream",e.nonVoidHtmlElementStartTagWithTrailingSolidus="non-void-html-element-start-tag-with-trailing-solidus",e.endTagWithAttributes="end-tag-with-attributes",e.endTagWithTrailingSolidus="end-tag-with-trailing-solidus",e.unexpectedSolidusInTag="unexpected-solidus-in-tag",e.unexpectedNullCharacter="unexpected-null-character",e.unexpectedQuestionMarkInsteadOfTagName="unexpected-question-mark-instead-of-tag-name",e.invalidFirstCharacterOfTagName="invalid-first-character-of-tag-name",e.unexpectedEqualsSignBeforeAttributeName="unexpected-equals-sign-before-attribute-name",e.missingEndTagName="missing-end-tag-name",e.unexpectedCharacterInAttributeName="unexpected-character-in-attribute-name",e.unknownNamedCharacterReference="unknown-named-character-reference",e.missingSemicolonAfterCharacterReference="missing-semicolon-after-character-reference",e.unexpectedCharacterAfterDoctypeSystemIdentifier="unexpected-character-after-doctype-system-identifier",e.unexpectedCharacterInUnquotedAttributeValue="unexpected-character-in-unquoted-attribute-value",e.eofBeforeTagName="eof-before-tag-name",e.eofInTag="eof-in-tag",e.missingAttributeValue="missing-attribute-value",e.missingWhitespaceBetweenAttributes="missing-whitespace-between-attributes",e.missingWhitespaceAfterDoctypePublicKeyword="missing-whitespace-after-doctype-public-keyword",e.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers="missing-whitespace-between-doctype-public-and-system-identifiers",e.missingWhitespaceAfterDoctypeSystemKeyword="missing-whitespace-after-doctype-system-keyword",e.missingQuoteBeforeDoctypePublicIdentifier="missing-quote-before-doctype-public-identifier",e.missingQuoteBeforeDoctypeSystemIdentifier="missing-quote-before-doctype-system-identifier",e.missingDoctypePublicIdentifier="missing-doctype-public-identifier",e.missingDoctypeSystemIdentifier="missing-doctype-system-identifier",e.abruptDoctypePublicIdentifier="abrupt-doctype-public-identifier",e.abruptDoctypeSystemIdentifier="abrupt-doctype-system-identifier",e.cdataInHtmlContent="cdata-in-html-content",e.incorrectlyOpenedComment="incorrectly-opened-comment",e.eofInScriptHtmlCommentLikeText="eof-in-script-html-comment-like-text",e.eofInDoctype="eof-in-doctype",e.nestedComment="nested-comment",e.abruptClosingOfEmptyComment="abrupt-closing-of-empty-comment",e.eofInComment="eof-in-comment",e.incorrectlyClosedComment="incorrectly-closed-comment",e.eofInCdata="eof-in-cdata",e.absenceOfDigitsInNumericCharacterReference="absence-of-digits-in-numeric-character-reference",e.nullCharacterReference="null-character-reference",e.surrogateCharacterReference="surrogate-character-reference",e.characterReferenceOutsideUnicodeRange="character-reference-outside-unicode-range",e.controlCharacterReference="control-character-reference",e.noncharacterCharacterReference="noncharacter-character-reference",e.missingWhitespaceBeforeDoctypeName="missing-whitespace-before-doctype-name",e.missingDoctypeName="missing-doctype-name",e.invalidCharacterSequenceAfterDoctypeName="invalid-character-sequence-after-doctype-name",e.duplicateAttribute="duplicate-attribute",e.nonConformingDoctype="non-conforming-doctype",e.missingDoctype="missing-doctype",e.misplacedDoctype="misplaced-doctype",e.endTagWithoutMatchingOpenElement="end-tag-without-matching-open-element",e.closingOfElementWithOpenChildElements="closing-of-element-with-open-child-elements",e.disallowedContentInNoscriptInHead="disallowed-content-in-noscript-in-head",e.openElementsLeftAfterEof="open-elements-left-after-eof",e.abandonedHeadElementChild="abandoned-head-element-child",e.misplacedStartTagForHeadElement="misplaced-start-tag-for-head-element",e.nestedNoscriptInHead="nested-noscript-in-head",e.eofInElementThatCanContainOnlyText="eof-in-element-that-can-contain-only-text"})(g||(g={}));const qc=65536;class $c{constructor(t){this.handler=t,this.html="",this.pos=-1,this.lastGapPos=-2,this.gapStack=[],this.skipNextNewLine=!1,this.lastChunkWritten=!1,this.endOfChunkHit=!1,this.bufferWaterline=qc,this.isEol=!1,this.lineStartPos=0,this.droppedBufferSize=0,this.line=1,this.lastErrOffset=-1}get col(){return this.pos-this.lineStartPos+ +(this.lastGapPos!==this.pos)}get offset(){return this.droppedBufferSize+this.pos}getError(t,a){const{line:n,col:i,offset:r}=this,u=i+a,o=r+a;return{code:t,startLine:n,endLine:n,startCol:u,endCol:u,startOffset:o,endOffset:o}}_err(t){this.handler.onParseError&&this.lastErrOffset!==this.offset&&(this.lastErrOffset=this.offset,this.handler.onParseError(this.getError(t,0)))}_addGap(){this.gapStack.push(this.lastGapPos),this.lastGapPos=this.pos}_processSurrogate(t){if(this.pos!==this.html.length-1){const a=this.html.charCodeAt(this.pos+1);if(Vc(a))return this.pos++,this._addGap(),Yc(t,a)}else if(!this.lastChunkWritten)return this.endOfChunkHit=!0,d.EOF;return this._err(g.surrogateInInputStream),t}willDropParsedChunk(){return this.pos>this.bufferWaterline}dropParsedChunk(){this.willDropParsedChunk()&&(this.html=this.html.substring(this.pos),this.lineStartPos-=this.pos,this.droppedBufferSize+=this.pos,this.pos=0,this.lastGapPos=-2,this.gapStack.length=0)}write(t,a){this.html.length>0?this.html+=t:this.html=t,this.endOfChunkHit=!1,this.lastChunkWritten=a}insertHtmlAtCurrentPos(t){this.html=this.html.substring(0,this.pos+1)+t+this.html.substring(this.pos+1),this.endOfChunkHit=!1}startsWith(t,a){if(this.pos+t.length>this.html.length)return this.endOfChunkHit=!this.lastChunkWritten,!1;if(a)return this.html.startsWith(t,this.pos);for(let n=0;n<t.length;n++)if((this.html.charCodeAt(this.pos+n)|32)!==t.charCodeAt(n))return!1;return!0}peek(t){const a=this.pos+t;if(a>=this.html.length)return this.endOfChunkHit=!this.lastChunkWritten,d.EOF;const n=this.html.charCodeAt(a);return n===d.CARRIAGE_RETURN?d.LINE_FEED:n}advance(){if(this.pos++,this.isEol&&(this.isEol=!1,this.line++,this.lineStartPos=this.pos),this.pos>=this.html.length)return this.endOfChunkHit=!this.lastChunkWritten,d.EOF;let t=this.html.charCodeAt(this.pos);return t===d.CARRIAGE_RETURN?(this.isEol=!0,this.skipNextNewLine=!0,d.LINE_FEED):t===d.LINE_FEED&&(this.isEol=!0,this.skipNextNewLine)?(this.line--,this.skipNextNewLine=!1,this._addGap(),this.advance()):(this.skipNextNewLine=!1,Gi(t)&&(t=this._processSurrogate(t)),this.handler.onParseError===null||t>31&&t<127||t===d.LINE_FEED||t===d.CARRIAGE_RETURN||t>159&&t<64976||this._checkForProblematicCharacters(t),t)}_checkForProblematicCharacters(t){Xi(t)?this._err(g.controlCharacterInInputStream):Qi(t)&&this._err(g.noncharacterInInputStream)}retreat(t){for(this.pos-=t;this.pos<this.lastGapPos;)this.lastGapPos=this.gapStack.pop(),this.pos--;this.isEol=!1}}var $;(function(e){e[e.CHARACTER=0]="CHARACTER",e[e.NULL_CHARACTER=1]="NULL_CHARACTER",e[e.WHITESPACE_CHARACTER=2]="WHITESPACE_CHARACTER",e[e.START_TAG=3]="START_TAG",e[e.END_TAG=4]="END_TAG",e[e.COMMENT=5]="COMMENT",e[e.DOCTYPE=6]="DOCTYPE",e[e.EOF=7]="EOF",e[e.HIBERNATION=8]="HIBERNATION"})($||($={}));function ji(e,t){for(let a=e.attrs.length-1;a>=0;a--)if(e.attrs[a].name===t)return e.attrs[a].value;return null}var N;(function(e){e.HTML="http://www.w3.org/1999/xhtml",e.MATHML="http://www.w3.org/1998/Math/MathML",e.SVG="http://www.w3.org/2000/svg",e.XLINK="http://www.w3.org/1999/xlink",e.XML="http://www.w3.org/XML/1998/namespace",e.XMLNS="http://www.w3.org/2000/xmlns/"})(N||(N={}));var ut;(function(e){e.TYPE="type",e.ACTION="action",e.ENCODING="encoding",e.PROMPT="prompt",e.NAME="name",e.COLOR="color",e.FACE="face",e.SIZE="size"})(ut||(ut={}));var Se;(function(e){e.NO_QUIRKS="no-quirks",e.QUIRKS="quirks",e.LIMITED_QUIRKS="limited-quirks"})(Se||(Se={}));var b;(function(e){e.A="a",e.ADDRESS="address",e.ANNOTATION_XML="annotation-xml",e.APPLET="applet",e.AREA="area",e.ARTICLE="article",e.ASIDE="aside",e.B="b",e.BASE="base",e.BASEFONT="basefont",e.BGSOUND="bgsound",e.BIG="big",e.BLOCKQUOTE="blockquote",e.BODY="body",e.BR="br",e.BUTTON="button",e.CAPTION="caption",e.CENTER="center",e.CODE="code",e.COL="col",e.COLGROUP="colgroup",e.DD="dd",e.DESC="desc",e.DETAILS="details",e.DIALOG="dialog",e.DIR="dir",e.DIV="div",e.DL="dl",e.DT="dt",e.EM="em",e.EMBED="embed",e.FIELDSET="fieldset",e.FIGCAPTION="figcaption",e.FIGURE="figure",e.FONT="font",e.FOOTER="footer",e.FOREIGN_OBJECT="foreignObject",e.FORM="form",e.FRAME="frame",e.FRAMESET="frameset",e.H1="h1",e.H2="h2",e.H3="h3",e.H4="h4",e.H5="h5",e.H6="h6",e.HEAD="head",e.HEADER="header",e.HGROUP="hgroup",e.HR="hr",e.HTML="html",e.I="i",e.IMG="img",e.IMAGE="image",e.INPUT="input",e.IFRAME="iframe",e.KEYGEN="keygen",e.LABEL="label",e.LI="li",e.LINK="link",e.LISTING="listing",e.MAIN="main",e.MALIGNMARK="malignmark",e.MARQUEE="marquee",e.MATH="math",e.MENU="menu",e.META="meta",e.MGLYPH="mglyph",e.MI="mi",e.MO="mo",e.MN="mn",e.MS="ms",e.MTEXT="mtext",e.NAV="nav",e.NOBR="nobr",e.NOFRAMES="noframes",e.NOEMBED="noembed",e.NOSCRIPT="noscript",e.OBJECT="object",e.OL="ol",e.OPTGROUP="optgroup",e.OPTION="option",e.P="p",e.PARAM="param",e.PLAINTEXT="plaintext",e.PRE="pre",e.RB="rb",e.RP="rp",e.RT="rt",e.RTC="rtc",e.RUBY="ruby",e.S="s",e.SCRIPT="script",e.SEARCH="search",e.SECTION="section",e.SELECT="select",e.SOURCE="source",e.SMALL="small",e.SPAN="span",e.STRIKE="strike",e.STRONG="strong",e.STYLE="style",e.SUB="sub",e.SUMMARY="summary",e.SUP="sup",e.TABLE="table",e.TBODY="tbody",e.TEMPLATE="template",e.TEXTAREA="textarea",e.TFOOT="tfoot",e.TD="td",e.TH="th",e.THEAD="thead",e.TITLE="title",e.TR="tr",e.TRACK="track",e.TT="tt",e.U="u",e.UL="ul",e.SVG="svg",e.VAR="var",e.WBR="wbr",e.XMP="xmp"})(b||(b={}));var s;(function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.A=1]="A",e[e.ADDRESS=2]="ADDRESS",e[e.ANNOTATION_XML=3]="ANNOTATION_XML",e[e.APPLET=4]="APPLET",e[e.AREA=5]="AREA",e[e.ARTICLE=6]="ARTICLE",e[e.ASIDE=7]="ASIDE",e[e.B=8]="B",e[e.BASE=9]="BASE",e[e.BASEFONT=10]="BASEFONT",e[e.BGSOUND=11]="BGSOUND",e[e.BIG=12]="BIG",e[e.BLOCKQUOTE=13]="BLOCKQUOTE",e[e.BODY=14]="BODY",e[e.BR=15]="BR",e[e.BUTTON=16]="BUTTON",e[e.CAPTION=17]="CAPTION",e[e.CENTER=18]="CENTER",e[e.CODE=19]="CODE",e[e.COL=20]="COL",e[e.COLGROUP=21]="COLGROUP",e[e.DD=22]="DD",e[e.DESC=23]="DESC",e[e.DETAILS=24]="DETAILS",e[e.DIALOG=25]="DIALOG",e[e.DIR=26]="DIR",e[e.DIV=27]="DIV",e[e.DL=28]="DL",e[e.DT=29]="DT",e[e.EM=30]="EM",e[e.EMBED=31]="EMBED",e[e.FIELDSET=32]="FIELDSET",e[e.FIGCAPTION=33]="FIGCAPTION",e[e.FIGURE=34]="FIGURE",e[e.FONT=35]="FONT",e[e.FOOTER=36]="FOOTER",e[e.FOREIGN_OBJECT=37]="FOREIGN_OBJECT",e[e.FORM=38]="FORM",e[e.FRAME=39]="FRAME",e[e.FRAMESET=40]="FRAMESET",e[e.H1=41]="H1",e[e.H2=42]="H2",e[e.H3=43]="H3",e[e.H4=44]="H4",e[e.H5=45]="H5",e[e.H6=46]="H6",e[e.HEAD=47]="HEAD",e[e.HEADER=48]="HEADER",e[e.HGROUP=49]="HGROUP",e[e.HR=50]="HR",e[e.HTML=51]="HTML",e[e.I=52]="I",e[e.IMG=53]="IMG",e[e.IMAGE=54]="IMAGE",e[e.INPUT=55]="INPUT",e[e.IFRAME=56]="IFRAME",e[e.KEYGEN=57]="KEYGEN",e[e.LABEL=58]="LABEL",e[e.LI=59]="LI",e[e.LINK=60]="LINK",e[e.LISTING=61]="LISTING",e[e.MAIN=62]="MAIN",e[e.MALIGNMARK=63]="MALIGNMARK",e[e.MARQUEE=64]="MARQUEE",e[e.MATH=65]="MATH",e[e.MENU=66]="MENU",e[e.META=67]="META",e[e.MGLYPH=68]="MGLYPH",e[e.MI=69]="MI",e[e.MO=70]="MO",e[e.MN=71]="MN",e[e.MS=72]="MS",e[e.MTEXT=73]="MTEXT",e[e.NAV=74]="NAV",e[e.NOBR=75]="NOBR",e[e.NOFRAMES=76]="NOFRAMES",e[e.NOEMBED=77]="NOEMBED",e[e.NOSCRIPT=78]="NOSCRIPT",e[e.OBJECT=79]="OBJECT",e[e.OL=80]="OL",e[e.OPTGROUP=81]="OPTGROUP",e[e.OPTION=82]="OPTION",e[e.P=83]="P",e[e.PARAM=84]="PARAM",e[e.PLAINTEXT=85]="PLAINTEXT",e[e.PRE=86]="PRE",e[e.RB=87]="RB",e[e.RP=88]="RP",e[e.RT=89]="RT",e[e.RTC=90]="RTC",e[e.RUBY=91]="RUBY",e[e.S=92]="S",e[e.SCRIPT=93]="SCRIPT",e[e.SEARCH=94]="SEARCH",e[e.SECTION=95]="SECTION",e[e.SELECT=96]="SELECT",e[e.SOURCE=97]="SOURCE",e[e.SMALL=98]="SMALL",e[e.SPAN=99]="SPAN",e[e.STRIKE=100]="STRIKE",e[e.STRONG=101]="STRONG",e[e.STYLE=102]="STYLE",e[e.SUB=103]="SUB",e[e.SUMMARY=104]="SUMMARY",e[e.SUP=105]="SUP",e[e.TABLE=106]="TABLE",e[e.TBODY=107]="TBODY",e[e.TEMPLATE=108]="TEMPLATE",e[e.TEXTAREA=109]="TEXTAREA",e[e.TFOOT=110]="TFOOT",e[e.TD=111]="TD",e[e.TH=112]="TH",e[e.THEAD=113]="THEAD",e[e.TITLE=114]="TITLE",e[e.TR=115]="TR",e[e.TRACK=116]="TRACK",e[e.TT=117]="TT",e[e.U=118]="U",e[e.UL=119]="UL",e[e.SVG=120]="SVG",e[e.VAR=121]="VAR",e[e.WBR=122]="WBR",e[e.XMP=123]="XMP"})(s||(s={}));const Wc=new Map([[b.A,s.A],[b.ADDRESS,s.ADDRESS],[b.ANNOTATION_XML,s.ANNOTATION_XML],[b.APPLET,s.APPLET],[b.AREA,s.AREA],[b.ARTICLE,s.ARTICLE],[b.ASIDE,s.ASIDE],[b.B,s.B],[b.BASE,s.BASE],[b.BASEFONT,s.BASEFONT],[b.BGSOUND,s.BGSOUND],[b.BIG,s.BIG],[b.BLOCKQUOTE,s.BLOCKQUOTE],[b.BODY,s.BODY],[b.BR,s.BR],[b.BUTTON,s.BUTTON],[b.CAPTION,s.CAPTION],[b.CENTER,s.CENTER],[b.CODE,s.CODE],[b.COL,s.COL],[b.COLGROUP,s.COLGROUP],[b.DD,s.DD],[b.DESC,s.DESC],[b.DETAILS,s.DETAILS],[b.DIALOG,s.DIALOG],[b.DIR,s.DIR],[b.DIV,s.DIV],[b.DL,s.DL],[b.DT,s.DT],[b.EM,s.EM],[b.EMBED,s.EMBED],[b.FIELDSET,s.FIELDSET],[b.FIGCAPTION,s.FIGCAPTION],[b.FIGURE,s.FIGURE],[b.FONT,s.FONT],[b.FOOTER,s.FOOTER],[b.FOREIGN_OBJECT,s.FOREIGN_OBJECT],[b.FORM,s.FORM],[b.FRAME,s.FRAME],[b.FRAMESET,s.FRAMESET],[b.H1,s.H1],[b.H2,s.H2],[b.H3,s.H3],[b.H4,s.H4],[b.H5,s.H5],[b.H6,s.H6],[b.HEAD,s.HEAD],[b.HEADER,s.HEADER],[b.HGROUP,s.HGROUP],[b.HR,s.HR],[b.HTML,s.HTML],[b.I,s.I],[b.IMG,s.IMG],[b.IMAGE,s.IMAGE],[b.INPUT,s.INPUT],[b.IFRAME,s.IFRAME],[b.KEYGEN,s.KEYGEN],[b.LABEL,s.LABEL],[b.LI,s.LI],[b.LINK,s.LINK],[b.LISTING,s.LISTING],[b.MAIN,s.MAIN],[b.MALIGNMARK,s.MALIGNMARK],[b.MARQUEE,s.MARQUEE],[b.MATH,s.MATH],[b.MENU,s.MENU],[b.META,s.META],[b.MGLYPH,s.MGLYPH],[b.MI,s.MI],[b.MO,s.MO],[b.MN,s.MN],[b.MS,s.MS],[b.MTEXT,s.MTEXT],[b.NAV,s.NAV],[b.NOBR,s.NOBR],[b.NOFRAMES,s.NOFRAMES],[b.NOEMBED,s.NOEMBED],[b.NOSCRIPT,s.NOSCRIPT],[b.OBJECT,s.OBJECT],[b.OL,s.OL],[b.OPTGROUP,s.OPTGROUP],[b.OPTION,s.OPTION],[b.P,s.P],[b.PARAM,s.PARAM],[b.PLAINTEXT,s.PLAINTEXT],[b.PRE,s.PRE],[b.RB,s.RB],[b.RP,s.RP],[b.RT,s.RT],[b.RTC,s.RTC],[b.RUBY,s.RUBY],[b.S,s.S],[b.SCRIPT,s.SCRIPT],[b.SEARCH,s.SEARCH],[b.SECTION,s.SECTION],[b.SELECT,s.SELECT],[b.SOURCE,s.SOURCE],[b.SMALL,s.SMALL],[b.SPAN,s.SPAN],[b.STRIKE,s.STRIKE],[b.STRONG,s.STRONG],[b.STYLE,s.STYLE],[b.SUB,s.SUB],[b.SUMMARY,s.SUMMARY],[b.SUP,s.SUP],[b.TABLE,s.TABLE],[b.TBODY,s.TBODY],[b.TEMPLATE,s.TEMPLATE],[b.TEXTAREA,s.TEXTAREA],[b.TFOOT,s.TFOOT],[b.TD,s.TD],[b.TH,s.TH],[b.THEAD,s.THEAD],[b.TITLE,s.TITLE],[b.TR,s.TR],[b.TRACK,s.TRACK],[b.TT,s.TT],[b.U,s.U],[b.UL,s.UL],[b.SVG,s.SVG],[b.VAR,s.VAR],[b.WBR,s.WBR],[b.XMP,s.XMP]]);function Ta(e){var t;return(t=Wc.get(e))!==null&&t!==void 0?t:s.UNKNOWN}const x=s,Gc={[N.HTML]:new Set([x.ADDRESS,x.APPLET,x.AREA,x.ARTICLE,x.ASIDE,x.BASE,x.BASEFONT,x.BGSOUND,x.BLOCKQUOTE,x.BODY,x.BR,x.BUTTON,x.CAPTION,x.CENTER,x.COL,x.COLGROUP,x.DD,x.DETAILS,x.DIR,x.DIV,x.DL,x.DT,x.EMBED,x.FIELDSET,x.FIGCAPTION,x.FIGURE,x.FOOTER,x.FORM,x.FRAME,x.FRAMESET,x.H1,x.H2,x.H3,x.H4,x.H5,x.H6,x.HEAD,x.HEADER,x.HGROUP,x.HR,x.HTML,x.IFRAME,x.IMG,x.INPUT,x.LI,x.LINK,x.LISTING,x.MAIN,x.MARQUEE,x.MENU,x.META,x.NAV,x.NOEMBED,x.NOFRAMES,x.NOSCRIPT,x.OBJECT,x.OL,x.P,x.PARAM,x.PLAINTEXT,x.PRE,x.SCRIPT,x.SECTION,x.SELECT,x.SOURCE,x.STYLE,x.SUMMARY,x.TABLE,x.TBODY,x.TD,x.TEMPLATE,x.TEXTAREA,x.TFOOT,x.TH,x.THEAD,x.TITLE,x.TR,x.TRACK,x.UL,x.WBR,x.XMP]),[N.MATHML]:new Set([x.MI,x.MO,x.MN,x.MS,x.MTEXT,x.ANNOTATION_XML]),[N.SVG]:new Set([x.TITLE,x.FOREIGN_OBJECT,x.DESC]),[N.XLINK]:new Set,[N.XML]:new Set,[N.XMLNS]:new Set},Tn=new Set([x.H1,x.H2,x.H3,x.H4,x.H5,x.H6]),Xc=new Set([b.STYLE,b.SCRIPT,b.XMP,b.IFRAME,b.NOEMBED,b.NOFRAMES,b.PLAINTEXT]);function Qc(e,t){return Xc.has(e)||t&&e===b.NOSCRIPT}var f;(function(e){e[e.DATA=0]="DATA",e[e.RCDATA=1]="RCDATA",e[e.RAWTEXT=2]="RAWTEXT",e[e.SCRIPT_DATA=3]="SCRIPT_DATA",e[e.PLAINTEXT=4]="PLAINTEXT",e[e.TAG_OPEN=5]="TAG_OPEN",e[e.END_TAG_OPEN=6]="END_TAG_OPEN",e[e.TAG_NAME=7]="TAG_NAME",e[e.RCDATA_LESS_THAN_SIGN=8]="RCDATA_LESS_THAN_SIGN",e[e.RCDATA_END_TAG_OPEN=9]="RCDATA_END_TAG_OPEN",e[e.RCDATA_END_TAG_NAME=10]="RCDATA_END_TAG_NAME",e[e.RAWTEXT_LESS_THAN_SIGN=11]="RAWTEXT_LESS_THAN_SIGN",e[e.RAWTEXT_END_TAG_OPEN=12]="RAWTEXT_END_TAG_OPEN",e[e.RAWTEXT_END_TAG_NAME=13]="RAWTEXT_END_TAG_NAME",e[e.SCRIPT_DATA_LESS_THAN_SIGN=14]="SCRIPT_DATA_LESS_THAN_SIGN",e[e.SCRIPT_DATA_END_TAG_OPEN=15]="SCRIPT_DATA_END_TAG_OPEN",e[e.SCRIPT_DATA_END_TAG_NAME=16]="SCRIPT_DATA_END_TAG_NAME",e[e.SCRIPT_DATA_ESCAPE_START=17]="SCRIPT_DATA_ESCAPE_START",e[e.SCRIPT_DATA_ESCAPE_START_DASH=18]="SCRIPT_DATA_ESCAPE_START_DASH",e[e.SCRIPT_DATA_ESCAPED=19]="SCRIPT_DATA_ESCAPED",e[e.SCRIPT_DATA_ESCAPED_DASH=20]="SCRIPT_DATA_ESCAPED_DASH",e[e.SCRIPT_DATA_ESCAPED_DASH_DASH=21]="SCRIPT_DATA_ESCAPED_DASH_DASH",e[e.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN=22]="SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN",e[e.SCRIPT_DATA_ESCAPED_END_TAG_OPEN=23]="SCRIPT_DATA_ESCAPED_END_TAG_OPEN",e[e.SCRIPT_DATA_ESCAPED_END_TAG_NAME=24]="SCRIPT_DATA_ESCAPED_END_TAG_NAME",e[e.SCRIPT_DATA_DOUBLE_ESCAPE_START=25]="SCRIPT_DATA_DOUBLE_ESCAPE_START",e[e.SCRIPT_DATA_DOUBLE_ESCAPED=26]="SCRIPT_DATA_DOUBLE_ESCAPED",e[e.SCRIPT_DATA_DOUBLE_ESCAPED_DASH=27]="SCRIPT_DATA_DOUBLE_ESCAPED_DASH",e[e.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH=28]="SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH",e[e.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN=29]="SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN",e[e.SCRIPT_DATA_DOUBLE_ESCAPE_END=30]="SCRIPT_DATA_DOUBLE_ESCAPE_END",e[e.BEFORE_ATTRIBUTE_NAME=31]="BEFORE_ATTRIBUTE_NAME",e[e.ATTRIBUTE_NAME=32]="ATTRIBUTE_NAME",e[e.AFTER_ATTRIBUTE_NAME=33]="AFTER_ATTRIBUTE_NAME",e[e.BEFORE_ATTRIBUTE_VALUE=34]="BEFORE_ATTRIBUTE_VALUE",e[e.ATTRIBUTE_VALUE_DOUBLE_QUOTED=35]="ATTRIBUTE_VALUE_DOUBLE_QUOTED",e[e.ATTRIBUTE_VALUE_SINGLE_QUOTED=36]="ATTRIBUTE_VALUE_SINGLE_QUOTED",e[e.ATTRIBUTE_VALUE_UNQUOTED=37]="ATTRIBUTE_VALUE_UNQUOTED",e[e.AFTER_ATTRIBUTE_VALUE_QUOTED=38]="AFTER_ATTRIBUTE_VALUE_QUOTED",e[e.SELF_CLOSING_START_TAG=39]="SELF_CLOSING_START_TAG",e[e.BOGUS_COMMENT=40]="BOGUS_COMMENT",e[e.MARKUP_DECLARATION_OPEN=41]="MARKUP_DECLARATION_OPEN",e[e.COMMENT_START=42]="COMMENT_START",e[e.COMMENT_START_DASH=43]="COMMENT_START_DASH",e[e.COMMENT=44]="COMMENT",e[e.COMMENT_LESS_THAN_SIGN=45]="COMMENT_LESS_THAN_SIGN",e[e.COMMENT_LESS_THAN_SIGN_BANG=46]="COMMENT_LESS_THAN_SIGN_BANG",e[e.COMMENT_LESS_THAN_SIGN_BANG_DASH=47]="COMMENT_LESS_THAN_SIGN_BANG_DASH",e[e.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH=48]="COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH",e[e.COMMENT_END_DASH=49]="COMMENT_END_DASH",e[e.COMMENT_END=50]="COMMENT_END",e[e.COMMENT_END_BANG=51]="COMMENT_END_BANG",e[e.DOCTYPE=52]="DOCTYPE",e[e.BEFORE_DOCTYPE_NAME=53]="BEFORE_DOCTYPE_NAME",e[e.DOCTYPE_NAME=54]="DOCTYPE_NAME",e[e.AFTER_DOCTYPE_NAME=55]="AFTER_DOCTYPE_NAME",e[e.AFTER_DOCTYPE_PUBLIC_KEYWORD=56]="AFTER_DOCTYPE_PUBLIC_KEYWORD",e[e.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER=57]="BEFORE_DOCTYPE_PUBLIC_IDENTIFIER",e[e.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED=58]="DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED",e[e.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED=59]="DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED",e[e.AFTER_DOCTYPE_PUBLIC_IDENTIFIER=60]="AFTER_DOCTYPE_PUBLIC_IDENTIFIER",e[e.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS=61]="BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS",e[e.AFTER_DOCTYPE_SYSTEM_KEYWORD=62]="AFTER_DOCTYPE_SYSTEM_KEYWORD",e[e.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER=63]="BEFORE_DOCTYPE_SYSTEM_IDENTIFIER",e[e.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED=64]="DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED",e[e.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED=65]="DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED",e[e.AFTER_DOCTYPE_SYSTEM_IDENTIFIER=66]="AFTER_DOCTYPE_SYSTEM_IDENTIFIER",e[e.BOGUS_DOCTYPE=67]="BOGUS_DOCTYPE",e[e.CDATA_SECTION=68]="CDATA_SECTION",e[e.CDATA_SECTION_BRACKET=69]="CDATA_SECTION_BRACKET",e[e.CDATA_SECTION_END=70]="CDATA_SECTION_END",e[e.CHARACTER_REFERENCE=71]="CHARACTER_REFERENCE",e[e.AMBIGUOUS_AMPERSAND=72]="AMBIGUOUS_AMPERSAND"})(f||(f={}));const Ne={DATA:f.DATA,RCDATA:f.RCDATA,RAWTEXT:f.RAWTEXT,SCRIPT_DATA:f.SCRIPT_DATA,PLAINTEXT:f.PLAINTEXT,CDATA_SECTION:f.CDATA_SECTION};function jc(e){return e>=d.DIGIT_0&&e<=d.DIGIT_9}function Bt(e){return e>=d.LATIN_CAPITAL_A&&e<=d.LATIN_CAPITAL_Z}function zc(e){return e>=d.LATIN_SMALL_A&&e<=d.LATIN_SMALL_Z}function je(e){return zc(e)||Bt(e)}function zi(e){return je(e)||jc(e)}function ba(e){return e+32}function Ki(e){return e===d.SPACE||e===d.LINE_FEED||e===d.TABULATION||e===d.FORM_FEED}function Zi(e){return Ki(e)||e===d.SOLIDUS||e===d.GREATER_THAN_SIGN}function Kc(e){return e===d.NULL?g.nullCharacterReference:e>1114111?g.characterReferenceOutsideUnicodeRange:Gi(e)?g.surrogateCharacterReference:Qi(e)?g.noncharacterCharacterReference:Xi(e)||e===d.CARRIAGE_RETURN?g.controlCharacterReference:null}let Zc=class{constructor(t,a){this.options=t,this.handler=a,this.paused=!1,this.inLoop=!1,this.inForeignNode=!1,this.lastStartTagName="",this.active=!1,this.state=f.DATA,this.returnState=f.DATA,this.entityStartPos=0,this.consumedAfterSnapshot=-1,this.currentCharacterToken=null,this.currentToken=null,this.currentAttr={name:"",value:""},this.preprocessor=new $c(a),this.currentLocation=this.getCurrentLocation(-1),this.entityDecoder=new $a(Ha,(n,i)=>{this.preprocessor.pos=this.entityStartPos+i-1,this._flushCodePointConsumedAsCharacterReference(n)},a.onParseError?{missingSemicolonAfterCharacterReference:()=>{this._err(g.missingSemicolonAfterCharacterReference,1)},absenceOfDigitsInNumericCharacterReference:n=>{this._err(g.absenceOfDigitsInNumericCharacterReference,this.entityStartPos-this.preprocessor.pos+n)},validateNumericCharacterReference:n=>{const i=Kc(n);i&&this._err(i,1)}}:void 0)}_err(t,a=0){var n,i;(i=(n=this.handler).onParseError)===null||i===void 0||i.call(n,this.preprocessor.getError(t,a))}getCurrentLocation(t){return this.options.sourceCodeLocationInfo?{startLine:this.preprocessor.line,startCol:this.preprocessor.col-t,startOffset:this.preprocessor.offset-t,endLine:-1,endCol:-1,endOffset:-1}:null}_runParsingLoop(){if(!this.inLoop){for(this.inLoop=!0;this.active&&!this.paused;){this.consumedAfterSnapshot=0;const t=this._consume();this._ensureHibernation()||this._callState(t)}this.inLoop=!1}}pause(){this.paused=!0}resume(t){if(!this.paused)throw new Error("Parser was already resumed");this.paused=!1,!this.inLoop&&(this._runParsingLoop(),this.paused||t==null||t())}write(t,a,n){this.active=!0,this.preprocessor.write(t,a),this._runParsingLoop(),this.paused||n==null||n()}insertHtmlAtCurrentPos(t){this.active=!0,this.preprocessor.insertHtmlAtCurrentPos(t),this._runParsingLoop()}_ensureHibernation(){return this.preprocessor.endOfChunkHit?(this.preprocessor.retreat(this.consumedAfterSnapshot),this.consumedAfterSnapshot=0,this.active=!1,!0):!1}_consume(){return this.consumedAfterSnapshot++,this.preprocessor.advance()}_advanceBy(t){this.consumedAfterSnapshot+=t;for(let a=0;a<t;a++)this.preprocessor.advance()}_consumeSequenceIfMatch(t,a){return this.preprocessor.startsWith(t,a)?(this._advanceBy(t.length-1),!0):!1}_createStartTagToken(){this.currentToken={type:$.START_TAG,tagName:"",tagID:s.UNKNOWN,selfClosing:!1,ackSelfClosing:!1,attrs:[],location:this.getCurrentLocation(1)}}_createEndTagToken(){this.currentToken={type:$.END_TAG,tagName:"",tagID:s.UNKNOWN,selfClosing:!1,ackSelfClosing:!1,attrs:[],location:this.getCurrentLocation(2)}}_createCommentToken(t){this.currentToken={type:$.COMMENT,data:"",location:this.getCurrentLocation(t)}}_createDoctypeToken(t){this.currentToken={type:$.DOCTYPE,name:t,forceQuirks:!1,publicId:null,systemId:null,location:this.currentLocation}}_createCharacterToken(t,a){this.currentCharacterToken={type:t,chars:a,location:this.currentLocation}}_createAttr(t){this.currentAttr={name:t,value:""},this.currentLocation=this.getCurrentLocation(0)}_leaveAttrName(){var t,a;const n=this.currentToken;if(ji(n,this.currentAttr.name)===null){if(n.attrs.push(this.currentAttr),n.location&&this.currentLocation){const i=(t=(a=n.location).attrs)!==null&&t!==void 0?t:a.attrs=Object.create(null);i[this.currentAttr.name]=this.currentLocation,this._leaveAttrValue()}}else this._err(g.duplicateAttribute)}_leaveAttrValue(){this.currentLocation&&(this.currentLocation.endLine=this.preprocessor.line,this.currentLocation.endCol=this.preprocessor.col,this.currentLocation.endOffset=this.preprocessor.offset)}prepareToken(t){this._emitCurrentCharacterToken(t.location),this.currentToken=null,t.location&&(t.location.endLine=this.preprocessor.line,t.location.endCol=this.preprocessor.col+1,t.location.endOffset=this.preprocessor.offset+1),this.currentLocation=this.getCurrentLocation(-1)}emitCurrentTagToken(){const t=this.currentToken;this.prepareToken(t),t.tagID=Ta(t.tagName),t.type===$.START_TAG?(this.lastStartTagName=t.tagName,this.handler.onStartTag(t)):(t.attrs.length>0&&this._err(g.endTagWithAttributes),t.selfClosing&&this._err(g.endTagWithTrailingSolidus),this.handler.onEndTag(t)),this.preprocessor.dropParsedChunk()}emitCurrentComment(t){this.prepareToken(t),this.handler.onComment(t),this.preprocessor.dropParsedChunk()}emitCurrentDoctype(t){this.prepareToken(t),this.handler.onDoctype(t),this.preprocessor.dropParsedChunk()}_emitCurrentCharacterToken(t){if(this.currentCharacterToken){switch(t&&this.currentCharacterToken.location&&(this.currentCharacterToken.location.endLine=t.startLine,this.currentCharacterToken.location.endCol=t.startCol,this.currentCharacterToken.location.endOffset=t.startOffset),this.currentCharacterToken.type){case $.CHARACTER:{this.handler.onCharacter(this.currentCharacterToken);break}case $.NULL_CHARACTER:{this.handler.onNullCharacter(this.currentCharacterToken);break}case $.WHITESPACE_CHARACTER:{this.handler.onWhitespaceCharacter(this.currentCharacterToken);break}}this.currentCharacterToken=null}}_emitEOFToken(){const t=this.getCurrentLocation(0);t&&(t.endLine=t.startLine,t.endCol=t.startCol,t.endOffset=t.startOffset),this._emitCurrentCharacterToken(t),this.handler.onEof({type:$.EOF,location:t}),this.active=!1}_appendCharToCurrentCharacterToken(t,a){if(this.currentCharacterToken)if(this.currentCharacterToken.type===t){this.currentCharacterToken.chars+=a;return}else this.currentLocation=this.getCurrentLocation(0),this._emitCurrentCharacterToken(this.currentLocation),this.preprocessor.dropParsedChunk();this._createCharacterToken(t,a)}_emitCodePoint(t){const a=Ki(t)?$.WHITESPACE_CHARACTER:t===d.NULL?$.NULL_CHARACTER:$.CHARACTER;this._appendCharToCurrentCharacterToken(a,String.fromCodePoint(t))}_emitChars(t){this._appendCharToCurrentCharacterToken($.CHARACTER,t)}_startCharacterReference(){this.returnState=this.state,this.state=f.CHARACTER_REFERENCE,this.entityStartPos=this.preprocessor.pos,this.entityDecoder.startEntity(this._isCharacterReferenceInAttribute()?Oe.Attribute:Oe.Legacy)}_isCharacterReferenceInAttribute(){return this.returnState===f.ATTRIBUTE_VALUE_DOUBLE_QUOTED||this.returnState===f.ATTRIBUTE_VALUE_SINGLE_QUOTED||this.returnState===f.ATTRIBUTE_VALUE_UNQUOTED}_flushCodePointConsumedAsCharacterReference(t){this._isCharacterReferenceInAttribute()?this.currentAttr.value+=String.fromCodePoint(t):this._emitCodePoint(t)}_callState(t){switch(this.state){case f.DATA:{this._stateData(t);break}case f.RCDATA:{this._stateRcdata(t);break}case f.RAWTEXT:{this._stateRawtext(t);break}case f.SCRIPT_DATA:{this._stateScriptData(t);break}case f.PLAINTEXT:{this._statePlaintext(t);break}case f.TAG_OPEN:{this._stateTagOpen(t);break}case f.END_TAG_OPEN:{this._stateEndTagOpen(t);break}case f.TAG_NAME:{this._stateTagName(t);break}case f.RCDATA_LESS_THAN_SIGN:{this._stateRcdataLessThanSign(t);break}case f.RCDATA_END_TAG_OPEN:{this._stateRcdataEndTagOpen(t);break}case f.RCDATA_END_TAG_NAME:{this._stateRcdataEndTagName(t);break}case f.RAWTEXT_LESS_THAN_SIGN:{this._stateRawtextLessThanSign(t);break}case f.RAWTEXT_END_TAG_OPEN:{this._stateRawtextEndTagOpen(t);break}case f.RAWTEXT_END_TAG_NAME:{this._stateRawtextEndTagName(t);break}case f.SCRIPT_DATA_LESS_THAN_SIGN:{this._stateScriptDataLessThanSign(t);break}case f.SCRIPT_DATA_END_TAG_OPEN:{this._stateScriptDataEndTagOpen(t);break}case f.SCRIPT_DATA_END_TAG_NAME:{this._stateScriptDataEndTagName(t);break}case f.SCRIPT_DATA_ESCAPE_START:{this._stateScriptDataEscapeStart(t);break}case f.SCRIPT_DATA_ESCAPE_START_DASH:{this._stateScriptDataEscapeStartDash(t);break}case f.SCRIPT_DATA_ESCAPED:{this._stateScriptDataEscaped(t);break}case f.SCRIPT_DATA_ESCAPED_DASH:{this._stateScriptDataEscapedDash(t);break}case f.SCRIPT_DATA_ESCAPED_DASH_DASH:{this._stateScriptDataEscapedDashDash(t);break}case f.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN:{this._stateScriptDataEscapedLessThanSign(t);break}case f.SCRIPT_DATA_ESCAPED_END_TAG_OPEN:{this._stateScriptDataEscapedEndTagOpen(t);break}case f.SCRIPT_DATA_ESCAPED_END_TAG_NAME:{this._stateScriptDataEscapedEndTagName(t);break}case f.SCRIPT_DATA_DOUBLE_ESCAPE_START:{this._stateScriptDataDoubleEscapeStart(t);break}case f.SCRIPT_DATA_DOUBLE_ESCAPED:{this._stateScriptDataDoubleEscaped(t);break}case f.SCRIPT_DATA_DOUBLE_ESCAPED_DASH:{this._stateScriptDataDoubleEscapedDash(t);break}case f.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH:{this._stateScriptDataDoubleEscapedDashDash(t);break}case f.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN:{this._stateScriptDataDoubleEscapedLessThanSign(t);break}case f.SCRIPT_DATA_DOUBLE_ESCAPE_END:{this._stateScriptDataDoubleEscapeEnd(t);break}case f.BEFORE_ATTRIBUTE_NAME:{this._stateBeforeAttributeName(t);break}case f.ATTRIBUTE_NAME:{this._stateAttributeName(t);break}case f.AFTER_ATTRIBUTE_NAME:{this._stateAfterAttributeName(t);break}case f.BEFORE_ATTRIBUTE_VALUE:{this._stateBeforeAttributeValue(t);break}case f.ATTRIBUTE_VALUE_DOUBLE_QUOTED:{this._stateAttributeValueDoubleQuoted(t);break}case f.ATTRIBUTE_VALUE_SINGLE_QUOTED:{this._stateAttributeValueSingleQuoted(t);break}case f.ATTRIBUTE_VALUE_UNQUOTED:{this._stateAttributeValueUnquoted(t);break}case f.AFTER_ATTRIBUTE_VALUE_QUOTED:{this._stateAfterAttributeValueQuoted(t);break}case f.SELF_CLOSING_START_TAG:{this._stateSelfClosingStartTag(t);break}case f.BOGUS_COMMENT:{this._stateBogusComment(t);break}case f.MARKUP_DECLARATION_OPEN:{this._stateMarkupDeclarationOpen(t);break}case f.COMMENT_START:{this._stateCommentStart(t);break}case f.COMMENT_START_DASH:{this._stateCommentStartDash(t);break}case f.COMMENT:{this._stateComment(t);break}case f.COMMENT_LESS_THAN_SIGN:{this._stateCommentLessThanSign(t);break}case f.COMMENT_LESS_THAN_SIGN_BANG:{this._stateCommentLessThanSignBang(t);break}case f.COMMENT_LESS_THAN_SIGN_BANG_DASH:{this._stateCommentLessThanSignBangDash(t);break}case f.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH:{this._stateCommentLessThanSignBangDashDash(t);break}case f.COMMENT_END_DASH:{this._stateCommentEndDash(t);break}case f.COMMENT_END:{this._stateCommentEnd(t);break}case f.COMMENT_END_BANG:{this._stateCommentEndBang(t);break}case f.DOCTYPE:{this._stateDoctype(t);break}case f.BEFORE_DOCTYPE_NAME:{this._stateBeforeDoctypeName(t);break}case f.DOCTYPE_NAME:{this._stateDoctypeName(t);break}case f.AFTER_DOCTYPE_NAME:{this._stateAfterDoctypeName(t);break}case f.AFTER_DOCTYPE_PUBLIC_KEYWORD:{this._stateAfterDoctypePublicKeyword(t);break}case f.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER:{this._stateBeforeDoctypePublicIdentifier(t);break}case f.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED:{this._stateDoctypePublicIdentifierDoubleQuoted(t);break}case f.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED:{this._stateDoctypePublicIdentifierSingleQuoted(t);break}case f.AFTER_DOCTYPE_PUBLIC_IDENTIFIER:{this._stateAfterDoctypePublicIdentifier(t);break}case f.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS:{this._stateBetweenDoctypePublicAndSystemIdentifiers(t);break}case f.AFTER_DOCTYPE_SYSTEM_KEYWORD:{this._stateAfterDoctypeSystemKeyword(t);break}case f.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER:{this._stateBeforeDoctypeSystemIdentifier(t);break}case f.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED:{this._stateDoctypeSystemIdentifierDoubleQuoted(t);break}case f.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED:{this._stateDoctypeSystemIdentifierSingleQuoted(t);break}case f.AFTER_DOCTYPE_SYSTEM_IDENTIFIER:{this._stateAfterDoctypeSystemIdentifier(t);break}case f.BOGUS_DOCTYPE:{this._stateBogusDoctype(t);break}case f.CDATA_SECTION:{this._stateCdataSection(t);break}case f.CDATA_SECTION_BRACKET:{this._stateCdataSectionBracket(t);break}case f.CDATA_SECTION_END:{this._stateCdataSectionEnd(t);break}case f.CHARACTER_REFERENCE:{this._stateCharacterReference();break}case f.AMBIGUOUS_AMPERSAND:{this._stateAmbiguousAmpersand(t);break}default:throw new Error("Unknown state")}}_stateData(t){switch(t){case d.LESS_THAN_SIGN:{this.state=f.TAG_OPEN;break}case d.AMPERSAND:{this._startCharacterReference();break}case d.NULL:{this._err(g.unexpectedNullCharacter),this._emitCodePoint(t);break}case d.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateRcdata(t){switch(t){case d.AMPERSAND:{this._startCharacterReference();break}case d.LESS_THAN_SIGN:{this.state=f.RCDATA_LESS_THAN_SIGN;break}case d.NULL:{this._err(g.unexpectedNullCharacter),this._emitChars(Z);break}case d.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateRawtext(t){switch(t){case d.LESS_THAN_SIGN:{this.state=f.RAWTEXT_LESS_THAN_SIGN;break}case d.NULL:{this._err(g.unexpectedNullCharacter),this._emitChars(Z);break}case d.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateScriptData(t){switch(t){case d.LESS_THAN_SIGN:{this.state=f.SCRIPT_DATA_LESS_THAN_SIGN;break}case d.NULL:{this._err(g.unexpectedNullCharacter),this._emitChars(Z);break}case d.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(t)}}_statePlaintext(t){switch(t){case d.NULL:{this._err(g.unexpectedNullCharacter),this._emitChars(Z);break}case d.EOF:{this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateTagOpen(t){if(je(t))this._createStartTagToken(),this.state=f.TAG_NAME,this._stateTagName(t);else switch(t){case d.EXCLAMATION_MARK:{this.state=f.MARKUP_DECLARATION_OPEN;break}case d.SOLIDUS:{this.state=f.END_TAG_OPEN;break}case d.QUESTION_MARK:{this._err(g.unexpectedQuestionMarkInsteadOfTagName),this._createCommentToken(1),this.state=f.BOGUS_COMMENT,this._stateBogusComment(t);break}case d.EOF:{this._err(g.eofBeforeTagName),this._emitChars("<"),this._emitEOFToken();break}default:this._err(g.invalidFirstCharacterOfTagName),this._emitChars("<"),this.state=f.DATA,this._stateData(t)}}_stateEndTagOpen(t){if(je(t))this._createEndTagToken(),this.state=f.TAG_NAME,this._stateTagName(t);else switch(t){case d.GREATER_THAN_SIGN:{this._err(g.missingEndTagName),this.state=f.DATA;break}case d.EOF:{this._err(g.eofBeforeTagName),this._emitChars("</"),this._emitEOFToken();break}default:this._err(g.invalidFirstCharacterOfTagName),this._createCommentToken(2),this.state=f.BOGUS_COMMENT,this._stateBogusComment(t)}}_stateTagName(t){const a=this.currentToken;switch(t){case d.SPACE:case d.LINE_FEED:case d.TABULATION:case d.FORM_FEED:{this.state=f.BEFORE_ATTRIBUTE_NAME;break}case d.SOLIDUS:{this.state=f.SELF_CLOSING_START_TAG;break}case d.GREATER_THAN_SIGN:{this.state=f.DATA,this.emitCurrentTagToken();break}case d.NULL:{this._err(g.unexpectedNullCharacter),a.tagName+=Z;break}case d.EOF:{this._err(g.eofInTag),this._emitEOFToken();break}default:a.tagName+=String.fromCodePoint(Bt(t)?ba(t):t)}}_stateRcdataLessThanSign(t){t===d.SOLIDUS?this.state=f.RCDATA_END_TAG_OPEN:(this._emitChars("<"),this.state=f.RCDATA,this._stateRcdata(t))}_stateRcdataEndTagOpen(t){je(t)?(this.state=f.RCDATA_END_TAG_NAME,this._stateRcdataEndTagName(t)):(this._emitChars("</"),this.state=f.RCDATA,this._stateRcdata(t))}handleSpecialEndTag(t){if(!this.preprocessor.startsWith(this.lastStartTagName,!1))return!this._ensureHibernation();this._createEndTagToken();const a=this.currentToken;switch(a.tagName=this.lastStartTagName,this.preprocessor.peek(this.lastStartTagName.length)){case d.SPACE:case d.LINE_FEED:case d.TABULATION:case d.FORM_FEED:return this._advanceBy(this.lastStartTagName.length),this.state=f.BEFORE_ATTRIBUTE_NAME,!1;case d.SOLIDUS:return this._advanceBy(this.lastStartTagName.length),this.state=f.SELF_CLOSING_START_TAG,!1;case d.GREATER_THAN_SIGN:return this._advanceBy(this.lastStartTagName.length),this.emitCurrentTagToken(),this.state=f.DATA,!1;default:return!this._ensureHibernation()}}_stateRcdataEndTagName(t){this.handleSpecialEndTag(t)&&(this._emitChars("</"),this.state=f.RCDATA,this._stateRcdata(t))}_stateRawtextLessThanSign(t){t===d.SOLIDUS?this.state=f.RAWTEXT_END_TAG_OPEN:(this._emitChars("<"),this.state=f.RAWTEXT,this._stateRawtext(t))}_stateRawtextEndTagOpen(t){je(t)?(this.state=f.RAWTEXT_END_TAG_NAME,this._stateRawtextEndTagName(t)):(this._emitChars("</"),this.state=f.RAWTEXT,this._stateRawtext(t))}_stateRawtextEndTagName(t){this.handleSpecialEndTag(t)&&(this._emitChars("</"),this.state=f.RAWTEXT,this._stateRawtext(t))}_stateScriptDataLessThanSign(t){switch(t){case d.SOLIDUS:{this.state=f.SCRIPT_DATA_END_TAG_OPEN;break}case d.EXCLAMATION_MARK:{this.state=f.SCRIPT_DATA_ESCAPE_START,this._emitChars("<!");break}default:this._emitChars("<"),this.state=f.SCRIPT_DATA,this._stateScriptData(t)}}_stateScriptDataEndTagOpen(t){je(t)?(this.state=f.SCRIPT_DATA_END_TAG_NAME,this._stateScriptDataEndTagName(t)):(this._emitChars("</"),this.state=f.SCRIPT_DATA,this._stateScriptData(t))}_stateScriptDataEndTagName(t){this.handleSpecialEndTag(t)&&(this._emitChars("</"),this.state=f.SCRIPT_DATA,this._stateScriptData(t))}_stateScriptDataEscapeStart(t){t===d.HYPHEN_MINUS?(this.state=f.SCRIPT_DATA_ESCAPE_START_DASH,this._emitChars("-")):(this.state=f.SCRIPT_DATA,this._stateScriptData(t))}_stateScriptDataEscapeStartDash(t){t===d.HYPHEN_MINUS?(this.state=f.SCRIPT_DATA_ESCAPED_DASH_DASH,this._emitChars("-")):(this.state=f.SCRIPT_DATA,this._stateScriptData(t))}_stateScriptDataEscaped(t){switch(t){case d.HYPHEN_MINUS:{this.state=f.SCRIPT_DATA_ESCAPED_DASH,this._emitChars("-");break}case d.LESS_THAN_SIGN:{this.state=f.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;break}case d.NULL:{this._err(g.unexpectedNullCharacter),this._emitChars(Z);break}case d.EOF:{this._err(g.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateScriptDataEscapedDash(t){switch(t){case d.HYPHEN_MINUS:{this.state=f.SCRIPT_DATA_ESCAPED_DASH_DASH,this._emitChars("-");break}case d.LESS_THAN_SIGN:{this.state=f.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;break}case d.NULL:{this._err(g.unexpectedNullCharacter),this.state=f.SCRIPT_DATA_ESCAPED,this._emitChars(Z);break}case d.EOF:{this._err(g.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this.state=f.SCRIPT_DATA_ESCAPED,this._emitCodePoint(t)}}_stateScriptDataEscapedDashDash(t){switch(t){case d.HYPHEN_MINUS:{this._emitChars("-");break}case d.LESS_THAN_SIGN:{this.state=f.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN;break}case d.GREATER_THAN_SIGN:{this.state=f.SCRIPT_DATA,this._emitChars(">");break}case d.NULL:{this._err(g.unexpectedNullCharacter),this.state=f.SCRIPT_DATA_ESCAPED,this._emitChars(Z);break}case d.EOF:{this._err(g.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this.state=f.SCRIPT_DATA_ESCAPED,this._emitCodePoint(t)}}_stateScriptDataEscapedLessThanSign(t){t===d.SOLIDUS?this.state=f.SCRIPT_DATA_ESCAPED_END_TAG_OPEN:je(t)?(this._emitChars("<"),this.state=f.SCRIPT_DATA_DOUBLE_ESCAPE_START,this._stateScriptDataDoubleEscapeStart(t)):(this._emitChars("<"),this.state=f.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(t))}_stateScriptDataEscapedEndTagOpen(t){je(t)?(this.state=f.SCRIPT_DATA_ESCAPED_END_TAG_NAME,this._stateScriptDataEscapedEndTagName(t)):(this._emitChars("</"),this.state=f.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(t))}_stateScriptDataEscapedEndTagName(t){this.handleSpecialEndTag(t)&&(this._emitChars("</"),this.state=f.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(t))}_stateScriptDataDoubleEscapeStart(t){if(this.preprocessor.startsWith(Ae.SCRIPT,!1)&&Zi(this.preprocessor.peek(Ae.SCRIPT.length))){this._emitCodePoint(t);for(let a=0;a<Ae.SCRIPT.length;a++)this._emitCodePoint(this._consume());this.state=f.SCRIPT_DATA_DOUBLE_ESCAPED}else this._ensureHibernation()||(this.state=f.SCRIPT_DATA_ESCAPED,this._stateScriptDataEscaped(t))}_stateScriptDataDoubleEscaped(t){switch(t){case d.HYPHEN_MINUS:{this.state=f.SCRIPT_DATA_DOUBLE_ESCAPED_DASH,this._emitChars("-");break}case d.LESS_THAN_SIGN:{this.state=f.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN,this._emitChars("<");break}case d.NULL:{this._err(g.unexpectedNullCharacter),this._emitChars(Z);break}case d.EOF:{this._err(g.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateScriptDataDoubleEscapedDash(t){switch(t){case d.HYPHEN_MINUS:{this.state=f.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH,this._emitChars("-");break}case d.LESS_THAN_SIGN:{this.state=f.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN,this._emitChars("<");break}case d.NULL:{this._err(g.unexpectedNullCharacter),this.state=f.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitChars(Z);break}case d.EOF:{this._err(g.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this.state=f.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitCodePoint(t)}}_stateScriptDataDoubleEscapedDashDash(t){switch(t){case d.HYPHEN_MINUS:{this._emitChars("-");break}case d.LESS_THAN_SIGN:{this.state=f.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN,this._emitChars("<");break}case d.GREATER_THAN_SIGN:{this.state=f.SCRIPT_DATA,this._emitChars(">");break}case d.NULL:{this._err(g.unexpectedNullCharacter),this.state=f.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitChars(Z);break}case d.EOF:{this._err(g.eofInScriptHtmlCommentLikeText),this._emitEOFToken();break}default:this.state=f.SCRIPT_DATA_DOUBLE_ESCAPED,this._emitCodePoint(t)}}_stateScriptDataDoubleEscapedLessThanSign(t){t===d.SOLIDUS?(this.state=f.SCRIPT_DATA_DOUBLE_ESCAPE_END,this._emitChars("/")):(this.state=f.SCRIPT_DATA_DOUBLE_ESCAPED,this._stateScriptDataDoubleEscaped(t))}_stateScriptDataDoubleEscapeEnd(t){if(this.preprocessor.startsWith(Ae.SCRIPT,!1)&&Zi(this.preprocessor.peek(Ae.SCRIPT.length))){this._emitCodePoint(t);for(let a=0;a<Ae.SCRIPT.length;a++)this._emitCodePoint(this._consume());this.state=f.SCRIPT_DATA_ESCAPED}else this._ensureHibernation()||(this.state=f.SCRIPT_DATA_DOUBLE_ESCAPED,this._stateScriptDataDoubleEscaped(t))}_stateBeforeAttributeName(t){switch(t){case d.SPACE:case d.LINE_FEED:case d.TABULATION:case d.FORM_FEED:break;case d.SOLIDUS:case d.GREATER_THAN_SIGN:case d.EOF:{this.state=f.AFTER_ATTRIBUTE_NAME,this._stateAfterAttributeName(t);break}case d.EQUALS_SIGN:{this._err(g.unexpectedEqualsSignBeforeAttributeName),this._createAttr("="),this.state=f.ATTRIBUTE_NAME;break}default:this._createAttr(""),this.state=f.ATTRIBUTE_NAME,this._stateAttributeName(t)}}_stateAttributeName(t){switch(t){case d.SPACE:case d.LINE_FEED:case d.TABULATION:case d.FORM_FEED:case d.SOLIDUS:case d.GREATER_THAN_SIGN:case d.EOF:{this._leaveAttrName(),this.state=f.AFTER_ATTRIBUTE_NAME,this._stateAfterAttributeName(t);break}case d.EQUALS_SIGN:{this._leaveAttrName(),this.state=f.BEFORE_ATTRIBUTE_VALUE;break}case d.QUOTATION_MARK:case d.APOSTROPHE:case d.LESS_THAN_SIGN:{this._err(g.unexpectedCharacterInAttributeName),this.currentAttr.name+=String.fromCodePoint(t);break}case d.NULL:{this._err(g.unexpectedNullCharacter),this.currentAttr.name+=Z;break}default:this.currentAttr.name+=String.fromCodePoint(Bt(t)?ba(t):t)}}_stateAfterAttributeName(t){switch(t){case d.SPACE:case d.LINE_FEED:case d.TABULATION:case d.FORM_FEED:break;case d.SOLIDUS:{this.state=f.SELF_CLOSING_START_TAG;break}case d.EQUALS_SIGN:{this.state=f.BEFORE_ATTRIBUTE_VALUE;break}case d.GREATER_THAN_SIGN:{this.state=f.DATA,this.emitCurrentTagToken();break}case d.EOF:{this._err(g.eofInTag),this._emitEOFToken();break}default:this._createAttr(""),this.state=f.ATTRIBUTE_NAME,this._stateAttributeName(t)}}_stateBeforeAttributeValue(t){switch(t){case d.SPACE:case d.LINE_FEED:case d.TABULATION:case d.FORM_FEED:break;case d.QUOTATION_MARK:{this.state=f.ATTRIBUTE_VALUE_DOUBLE_QUOTED;break}case d.APOSTROPHE:{this.state=f.ATTRIBUTE_VALUE_SINGLE_QUOTED;break}case d.GREATER_THAN_SIGN:{this._err(g.missingAttributeValue),this.state=f.DATA,this.emitCurrentTagToken();break}default:this.state=f.ATTRIBUTE_VALUE_UNQUOTED,this._stateAttributeValueUnquoted(t)}}_stateAttributeValueDoubleQuoted(t){switch(t){case d.QUOTATION_MARK:{this.state=f.AFTER_ATTRIBUTE_VALUE_QUOTED;break}case d.AMPERSAND:{this._startCharacterReference();break}case d.NULL:{this._err(g.unexpectedNullCharacter),this.currentAttr.value+=Z;break}case d.EOF:{this._err(g.eofInTag),this._emitEOFToken();break}default:this.currentAttr.value+=String.fromCodePoint(t)}}_stateAttributeValueSingleQuoted(t){switch(t){case d.APOSTROPHE:{this.state=f.AFTER_ATTRIBUTE_VALUE_QUOTED;break}case d.AMPERSAND:{this._startCharacterReference();break}case d.NULL:{this._err(g.unexpectedNullCharacter),this.currentAttr.value+=Z;break}case d.EOF:{this._err(g.eofInTag),this._emitEOFToken();break}default:this.currentAttr.value+=String.fromCodePoint(t)}}_stateAttributeValueUnquoted(t){switch(t){case d.SPACE:case d.LINE_FEED:case d.TABULATION:case d.FORM_FEED:{this._leaveAttrValue(),this.state=f.BEFORE_ATTRIBUTE_NAME;break}case d.AMPERSAND:{this._startCharacterReference();break}case d.GREATER_THAN_SIGN:{this._leaveAttrValue(),this.state=f.DATA,this.emitCurrentTagToken();break}case d.NULL:{this._err(g.unexpectedNullCharacter),this.currentAttr.value+=Z;break}case d.QUOTATION_MARK:case d.APOSTROPHE:case d.LESS_THAN_SIGN:case d.EQUALS_SIGN:case d.GRAVE_ACCENT:{this._err(g.unexpectedCharacterInUnquotedAttributeValue),this.currentAttr.value+=String.fromCodePoint(t);break}case d.EOF:{this._err(g.eofInTag),this._emitEOFToken();break}default:this.currentAttr.value+=String.fromCodePoint(t)}}_stateAfterAttributeValueQuoted(t){switch(t){case d.SPACE:case d.LINE_FEED:case d.TABULATION:case d.FORM_FEED:{this._leaveAttrValue(),this.state=f.BEFORE_ATTRIBUTE_NAME;break}case d.SOLIDUS:{this._leaveAttrValue(),this.state=f.SELF_CLOSING_START_TAG;break}case d.GREATER_THAN_SIGN:{this._leaveAttrValue(),this.state=f.DATA,this.emitCurrentTagToken();break}case d.EOF:{this._err(g.eofInTag),this._emitEOFToken();break}default:this._err(g.missingWhitespaceBetweenAttributes),this.state=f.BEFORE_ATTRIBUTE_NAME,this._stateBeforeAttributeName(t)}}_stateSelfClosingStartTag(t){switch(t){case d.GREATER_THAN_SIGN:{const a=this.currentToken;a.selfClosing=!0,this.state=f.DATA,this.emitCurrentTagToken();break}case d.EOF:{this._err(g.eofInTag),this._emitEOFToken();break}default:this._err(g.unexpectedSolidusInTag),this.state=f.BEFORE_ATTRIBUTE_NAME,this._stateBeforeAttributeName(t)}}_stateBogusComment(t){const a=this.currentToken;switch(t){case d.GREATER_THAN_SIGN:{this.state=f.DATA,this.emitCurrentComment(a);break}case d.EOF:{this.emitCurrentComment(a),this._emitEOFToken();break}case d.NULL:{this._err(g.unexpectedNullCharacter),a.data+=Z;break}default:a.data+=String.fromCodePoint(t)}}_stateMarkupDeclarationOpen(t){this._consumeSequenceIfMatch(Ae.DASH_DASH,!0)?(this._createCommentToken(Ae.DASH_DASH.length+1),this.state=f.COMMENT_START):this._consumeSequenceIfMatch(Ae.DOCTYPE,!1)?(this.currentLocation=this.getCurrentLocation(Ae.DOCTYPE.length+1),this.state=f.DOCTYPE):this._consumeSequenceIfMatch(Ae.CDATA_START,!0)?this.inForeignNode?this.state=f.CDATA_SECTION:(this._err(g.cdataInHtmlContent),this._createCommentToken(Ae.CDATA_START.length+1),this.currentToken.data="[CDATA[",this.state=f.BOGUS_COMMENT):this._ensureHibernation()||(this._err(g.incorrectlyOpenedComment),this._createCommentToken(2),this.state=f.BOGUS_COMMENT,this._stateBogusComment(t))}_stateCommentStart(t){switch(t){case d.HYPHEN_MINUS:{this.state=f.COMMENT_START_DASH;break}case d.GREATER_THAN_SIGN:{this._err(g.abruptClosingOfEmptyComment),this.state=f.DATA;const a=this.currentToken;this.emitCurrentComment(a);break}default:this.state=f.COMMENT,this._stateComment(t)}}_stateCommentStartDash(t){const a=this.currentToken;switch(t){case d.HYPHEN_MINUS:{this.state=f.COMMENT_END;break}case d.GREATER_THAN_SIGN:{this._err(g.abruptClosingOfEmptyComment),this.state=f.DATA,this.emitCurrentComment(a);break}case d.EOF:{this._err(g.eofInComment),this.emitCurrentComment(a),this._emitEOFToken();break}default:a.data+="-",this.state=f.COMMENT,this._stateComment(t)}}_stateComment(t){const a=this.currentToken;switch(t){case d.HYPHEN_MINUS:{this.state=f.COMMENT_END_DASH;break}case d.LESS_THAN_SIGN:{a.data+="<",this.state=f.COMMENT_LESS_THAN_SIGN;break}case d.NULL:{this._err(g.unexpectedNullCharacter),a.data+=Z;break}case d.EOF:{this._err(g.eofInComment),this.emitCurrentComment(a),this._emitEOFToken();break}default:a.data+=String.fromCodePoint(t)}}_stateCommentLessThanSign(t){const a=this.currentToken;switch(t){case d.EXCLAMATION_MARK:{a.data+="!",this.state=f.COMMENT_LESS_THAN_SIGN_BANG;break}case d.LESS_THAN_SIGN:{a.data+="<";break}default:this.state=f.COMMENT,this._stateComment(t)}}_stateCommentLessThanSignBang(t){t===d.HYPHEN_MINUS?this.state=f.COMMENT_LESS_THAN_SIGN_BANG_DASH:(this.state=f.COMMENT,this._stateComment(t))}_stateCommentLessThanSignBangDash(t){t===d.HYPHEN_MINUS?this.state=f.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH:(this.state=f.COMMENT_END_DASH,this._stateCommentEndDash(t))}_stateCommentLessThanSignBangDashDash(t){t!==d.GREATER_THAN_SIGN&&t!==d.EOF&&this._err(g.nestedComment),this.state=f.COMMENT_END,this._stateCommentEnd(t)}_stateCommentEndDash(t){const a=this.currentToken;switch(t){case d.HYPHEN_MINUS:{this.state=f.COMMENT_END;break}case d.EOF:{this._err(g.eofInComment),this.emitCurrentComment(a),this._emitEOFToken();break}default:a.data+="-",this.state=f.COMMENT,this._stateComment(t)}}_stateCommentEnd(t){const a=this.currentToken;switch(t){case d.GREATER_THAN_SIGN:{this.state=f.DATA,this.emitCurrentComment(a);break}case d.EXCLAMATION_MARK:{this.state=f.COMMENT_END_BANG;break}case d.HYPHEN_MINUS:{a.data+="-";break}case d.EOF:{this._err(g.eofInComment),this.emitCurrentComment(a),this._emitEOFToken();break}default:a.data+="--",this.state=f.COMMENT,this._stateComment(t)}}_stateCommentEndBang(t){const a=this.currentToken;switch(t){case d.HYPHEN_MINUS:{a.data+="--!",this.state=f.COMMENT_END_DASH;break}case d.GREATER_THAN_SIGN:{this._err(g.incorrectlyClosedComment),this.state=f.DATA,this.emitCurrentComment(a);break}case d.EOF:{this._err(g.eofInComment),this.emitCurrentComment(a),this._emitEOFToken();break}default:a.data+="--!",this.state=f.COMMENT,this._stateComment(t)}}_stateDoctype(t){switch(t){case d.SPACE:case d.LINE_FEED:case d.TABULATION:case d.FORM_FEED:{this.state=f.BEFORE_DOCTYPE_NAME;break}case d.GREATER_THAN_SIGN:{this.state=f.BEFORE_DOCTYPE_NAME,this._stateBeforeDoctypeName(t);break}case d.EOF:{this._err(g.eofInDoctype),this._createDoctypeToken(null);const a=this.currentToken;a.forceQuirks=!0,this.emitCurrentDoctype(a),this._emitEOFToken();break}default:this._err(g.missingWhitespaceBeforeDoctypeName),this.state=f.BEFORE_DOCTYPE_NAME,this._stateBeforeDoctypeName(t)}}_stateBeforeDoctypeName(t){if(Bt(t))this._createDoctypeToken(String.fromCharCode(ba(t))),this.state=f.DOCTYPE_NAME;else switch(t){case d.SPACE:case d.LINE_FEED:case d.TABULATION:case d.FORM_FEED:break;case d.NULL:{this._err(g.unexpectedNullCharacter),this._createDoctypeToken(Z),this.state=f.DOCTYPE_NAME;break}case d.GREATER_THAN_SIGN:{this._err(g.missingDoctypeName),this._createDoctypeToken(null);const a=this.currentToken;a.forceQuirks=!0,this.emitCurrentDoctype(a),this.state=f.DATA;break}case d.EOF:{this._err(g.eofInDoctype),this._createDoctypeToken(null);const a=this.currentToken;a.forceQuirks=!0,this.emitCurrentDoctype(a),this._emitEOFToken();break}default:this._createDoctypeToken(String.fromCodePoint(t)),this.state=f.DOCTYPE_NAME}}_stateDoctypeName(t){const a=this.currentToken;switch(t){case d.SPACE:case d.LINE_FEED:case d.TABULATION:case d.FORM_FEED:{this.state=f.AFTER_DOCTYPE_NAME;break}case d.GREATER_THAN_SIGN:{this.state=f.DATA,this.emitCurrentDoctype(a);break}case d.NULL:{this._err(g.unexpectedNullCharacter),a.name+=Z;break}case d.EOF:{this._err(g.eofInDoctype),a.forceQuirks=!0,this.emitCurrentDoctype(a),this._emitEOFToken();break}default:a.name+=String.fromCodePoint(Bt(t)?ba(t):t)}}_stateAfterDoctypeName(t){const a=this.currentToken;switch(t){case d.SPACE:case d.LINE_FEED:case d.TABULATION:case d.FORM_FEED:break;case d.GREATER_THAN_SIGN:{this.state=f.DATA,this.emitCurrentDoctype(a);break}case d.EOF:{this._err(g.eofInDoctype),a.forceQuirks=!0,this.emitCurrentDoctype(a),this._emitEOFToken();break}default:this._consumeSequenceIfMatch(Ae.PUBLIC,!1)?this.state=f.AFTER_DOCTYPE_PUBLIC_KEYWORD:this._consumeSequenceIfMatch(Ae.SYSTEM,!1)?this.state=f.AFTER_DOCTYPE_SYSTEM_KEYWORD:this._ensureHibernation()||(this._err(g.invalidCharacterSequenceAfterDoctypeName),a.forceQuirks=!0,this.state=f.BOGUS_DOCTYPE,this._stateBogusDoctype(t))}}_stateAfterDoctypePublicKeyword(t){const a=this.currentToken;switch(t){case d.SPACE:case d.LINE_FEED:case d.TABULATION:case d.FORM_FEED:{this.state=f.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER;break}case d.QUOTATION_MARK:{this._err(g.missingWhitespaceAfterDoctypePublicKeyword),a.publicId="",this.state=f.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED;break}case d.APOSTROPHE:{this._err(g.missingWhitespaceAfterDoctypePublicKeyword),a.publicId="",this.state=f.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED;break}case d.GREATER_THAN_SIGN:{this._err(g.missingDoctypePublicIdentifier),a.forceQuirks=!0,this.state=f.DATA,this.emitCurrentDoctype(a);break}case d.EOF:{this._err(g.eofInDoctype),a.forceQuirks=!0,this.emitCurrentDoctype(a),this._emitEOFToken();break}default:this._err(g.missingQuoteBeforeDoctypePublicIdentifier),a.forceQuirks=!0,this.state=f.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateBeforeDoctypePublicIdentifier(t){const a=this.currentToken;switch(t){case d.SPACE:case d.LINE_FEED:case d.TABULATION:case d.FORM_FEED:break;case d.QUOTATION_MARK:{a.publicId="",this.state=f.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED;break}case d.APOSTROPHE:{a.publicId="",this.state=f.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED;break}case d.GREATER_THAN_SIGN:{this._err(g.missingDoctypePublicIdentifier),a.forceQuirks=!0,this.state=f.DATA,this.emitCurrentDoctype(a);break}case d.EOF:{this._err(g.eofInDoctype),a.forceQuirks=!0,this.emitCurrentDoctype(a),this._emitEOFToken();break}default:this._err(g.missingQuoteBeforeDoctypePublicIdentifier),a.forceQuirks=!0,this.state=f.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateDoctypePublicIdentifierDoubleQuoted(t){const a=this.currentToken;switch(t){case d.QUOTATION_MARK:{this.state=f.AFTER_DOCTYPE_PUBLIC_IDENTIFIER;break}case d.NULL:{this._err(g.unexpectedNullCharacter),a.publicId+=Z;break}case d.GREATER_THAN_SIGN:{this._err(g.abruptDoctypePublicIdentifier),a.forceQuirks=!0,this.emitCurrentDoctype(a),this.state=f.DATA;break}case d.EOF:{this._err(g.eofInDoctype),a.forceQuirks=!0,this.emitCurrentDoctype(a),this._emitEOFToken();break}default:a.publicId+=String.fromCodePoint(t)}}_stateDoctypePublicIdentifierSingleQuoted(t){const a=this.currentToken;switch(t){case d.APOSTROPHE:{this.state=f.AFTER_DOCTYPE_PUBLIC_IDENTIFIER;break}case d.NULL:{this._err(g.unexpectedNullCharacter),a.publicId+=Z;break}case d.GREATER_THAN_SIGN:{this._err(g.abruptDoctypePublicIdentifier),a.forceQuirks=!0,this.emitCurrentDoctype(a),this.state=f.DATA;break}case d.EOF:{this._err(g.eofInDoctype),a.forceQuirks=!0,this.emitCurrentDoctype(a),this._emitEOFToken();break}default:a.publicId+=String.fromCodePoint(t)}}_stateAfterDoctypePublicIdentifier(t){const a=this.currentToken;switch(t){case d.SPACE:case d.LINE_FEED:case d.TABULATION:case d.FORM_FEED:{this.state=f.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS;break}case d.GREATER_THAN_SIGN:{this.state=f.DATA,this.emitCurrentDoctype(a);break}case d.QUOTATION_MARK:{this._err(g.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers),a.systemId="",this.state=f.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break}case d.APOSTROPHE:{this._err(g.missingWhitespaceBetweenDoctypePublicAndSystemIdentifiers),a.systemId="",this.state=f.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break}case d.EOF:{this._err(g.eofInDoctype),a.forceQuirks=!0,this.emitCurrentDoctype(a),this._emitEOFToken();break}default:this._err(g.missingQuoteBeforeDoctypeSystemIdentifier),a.forceQuirks=!0,this.state=f.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateBetweenDoctypePublicAndSystemIdentifiers(t){const a=this.currentToken;switch(t){case d.SPACE:case d.LINE_FEED:case d.TABULATION:case d.FORM_FEED:break;case d.GREATER_THAN_SIGN:{this.emitCurrentDoctype(a),this.state=f.DATA;break}case d.QUOTATION_MARK:{a.systemId="",this.state=f.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break}case d.APOSTROPHE:{a.systemId="",this.state=f.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break}case d.EOF:{this._err(g.eofInDoctype),a.forceQuirks=!0,this.emitCurrentDoctype(a),this._emitEOFToken();break}default:this._err(g.missingQuoteBeforeDoctypeSystemIdentifier),a.forceQuirks=!0,this.state=f.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateAfterDoctypeSystemKeyword(t){const a=this.currentToken;switch(t){case d.SPACE:case d.LINE_FEED:case d.TABULATION:case d.FORM_FEED:{this.state=f.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER;break}case d.QUOTATION_MARK:{this._err(g.missingWhitespaceAfterDoctypeSystemKeyword),a.systemId="",this.state=f.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break}case d.APOSTROPHE:{this._err(g.missingWhitespaceAfterDoctypeSystemKeyword),a.systemId="",this.state=f.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break}case d.GREATER_THAN_SIGN:{this._err(g.missingDoctypeSystemIdentifier),a.forceQuirks=!0,this.state=f.DATA,this.emitCurrentDoctype(a);break}case d.EOF:{this._err(g.eofInDoctype),a.forceQuirks=!0,this.emitCurrentDoctype(a),this._emitEOFToken();break}default:this._err(g.missingQuoteBeforeDoctypeSystemIdentifier),a.forceQuirks=!0,this.state=f.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateBeforeDoctypeSystemIdentifier(t){const a=this.currentToken;switch(t){case d.SPACE:case d.LINE_FEED:case d.TABULATION:case d.FORM_FEED:break;case d.QUOTATION_MARK:{a.systemId="",this.state=f.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED;break}case d.APOSTROPHE:{a.systemId="",this.state=f.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED;break}case d.GREATER_THAN_SIGN:{this._err(g.missingDoctypeSystemIdentifier),a.forceQuirks=!0,this.state=f.DATA,this.emitCurrentDoctype(a);break}case d.EOF:{this._err(g.eofInDoctype),a.forceQuirks=!0,this.emitCurrentDoctype(a),this._emitEOFToken();break}default:this._err(g.missingQuoteBeforeDoctypeSystemIdentifier),a.forceQuirks=!0,this.state=f.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateDoctypeSystemIdentifierDoubleQuoted(t){const a=this.currentToken;switch(t){case d.QUOTATION_MARK:{this.state=f.AFTER_DOCTYPE_SYSTEM_IDENTIFIER;break}case d.NULL:{this._err(g.unexpectedNullCharacter),a.systemId+=Z;break}case d.GREATER_THAN_SIGN:{this._err(g.abruptDoctypeSystemIdentifier),a.forceQuirks=!0,this.emitCurrentDoctype(a),this.state=f.DATA;break}case d.EOF:{this._err(g.eofInDoctype),a.forceQuirks=!0,this.emitCurrentDoctype(a),this._emitEOFToken();break}default:a.systemId+=String.fromCodePoint(t)}}_stateDoctypeSystemIdentifierSingleQuoted(t){const a=this.currentToken;switch(t){case d.APOSTROPHE:{this.state=f.AFTER_DOCTYPE_SYSTEM_IDENTIFIER;break}case d.NULL:{this._err(g.unexpectedNullCharacter),a.systemId+=Z;break}case d.GREATER_THAN_SIGN:{this._err(g.abruptDoctypeSystemIdentifier),a.forceQuirks=!0,this.emitCurrentDoctype(a),this.state=f.DATA;break}case d.EOF:{this._err(g.eofInDoctype),a.forceQuirks=!0,this.emitCurrentDoctype(a),this._emitEOFToken();break}default:a.systemId+=String.fromCodePoint(t)}}_stateAfterDoctypeSystemIdentifier(t){const a=this.currentToken;switch(t){case d.SPACE:case d.LINE_FEED:case d.TABULATION:case d.FORM_FEED:break;case d.GREATER_THAN_SIGN:{this.emitCurrentDoctype(a),this.state=f.DATA;break}case d.EOF:{this._err(g.eofInDoctype),a.forceQuirks=!0,this.emitCurrentDoctype(a),this._emitEOFToken();break}default:this._err(g.unexpectedCharacterAfterDoctypeSystemIdentifier),this.state=f.BOGUS_DOCTYPE,this._stateBogusDoctype(t)}}_stateBogusDoctype(t){const a=this.currentToken;switch(t){case d.GREATER_THAN_SIGN:{this.emitCurrentDoctype(a),this.state=f.DATA;break}case d.NULL:{this._err(g.unexpectedNullCharacter);break}case d.EOF:{this.emitCurrentDoctype(a),this._emitEOFToken();break}}}_stateCdataSection(t){switch(t){case d.RIGHT_SQUARE_BRACKET:{this.state=f.CDATA_SECTION_BRACKET;break}case d.EOF:{this._err(g.eofInCdata),this._emitEOFToken();break}default:this._emitCodePoint(t)}}_stateCdataSectionBracket(t){t===d.RIGHT_SQUARE_BRACKET?this.state=f.CDATA_SECTION_END:(this._emitChars("]"),this.state=f.CDATA_SECTION,this._stateCdataSection(t))}_stateCdataSectionEnd(t){switch(t){case d.GREATER_THAN_SIGN:{this.state=f.DATA;break}case d.RIGHT_SQUARE_BRACKET:{this._emitChars("]");break}default:this._emitChars("]]"),this.state=f.CDATA_SECTION,this._stateCdataSection(t)}}_stateCharacterReference(){let t=this.entityDecoder.write(this.preprocessor.html,this.preprocessor.pos);if(t<0)if(this.preprocessor.lastChunkWritten)t=this.entityDecoder.end();else{this.active=!1,this.preprocessor.pos=this.preprocessor.html.length-1,this.consumedAfterSnapshot=0,this.preprocessor.endOfChunkHit=!0;return}t===0?(this.preprocessor.pos=this.entityStartPos,this._flushCodePointConsumedAsCharacterReference(d.AMPERSAND),this.state=!this._isCharacterReferenceInAttribute()&&zi(this.preprocessor.peek(1))?f.AMBIGUOUS_AMPERSAND:this.returnState):this.state=this.returnState}_stateAmbiguousAmpersand(t){zi(t)?this._flushCodePointConsumedAsCharacterReference(t):(t===d.SEMICOLON&&this._err(g.unknownNamedCharacterReference),this.state=this.returnState,this._callState(t))}};const Ji=new Set([s.DD,s.DT,s.LI,s.OPTGROUP,s.OPTION,s.P,s.RB,s.RP,s.RT,s.RTC]),es=new Set([...Ji,s.CAPTION,s.COLGROUP,s.TBODY,s.TD,s.TFOOT,s.TH,s.THEAD,s.TR]),ga=new Set([s.APPLET,s.CAPTION,s.HTML,s.MARQUEE,s.OBJECT,s.TABLE,s.TD,s.TEMPLATE,s.TH]),Jc=new Set([...ga,s.OL,s.UL]),el=new Set([...ga,s.BUTTON]),ts=new Set([s.ANNOTATION_XML,s.MI,s.MN,s.MO,s.MS,s.MTEXT]),as=new Set([s.DESC,s.FOREIGN_OBJECT,s.TITLE]),tl=new Set([s.TR,s.TEMPLATE,s.HTML]),al=new Set([s.TBODY,s.TFOOT,s.THEAD,s.TEMPLATE,s.HTML]),nl=new Set([s.TABLE,s.TEMPLATE,s.HTML]),il=new Set([s.TD,s.TH]);class sl{get currentTmplContentOrNode(){return this._isInTemplate()?this.treeAdapter.getTemplateContent(this.current):this.current}constructor(t,a,n){this.treeAdapter=a,this.handler=n,this.items=[],this.tagIDs=[],this.stackTop=-1,this.tmplCount=0,this.currentTagId=s.UNKNOWN,this.current=t}_indexOf(t){return this.items.lastIndexOf(t,this.stackTop)}_isInTemplate(){return this.currentTagId===s.TEMPLATE&&this.treeAdapter.getNamespaceURI(this.current)===N.HTML}_updateCurrentElement(){this.current=this.items[this.stackTop],this.currentTagId=this.tagIDs[this.stackTop]}push(t,a){this.stackTop++,this.items[this.stackTop]=t,this.current=t,this.tagIDs[this.stackTop]=a,this.currentTagId=a,this._isInTemplate()&&this.tmplCount++,this.handler.onItemPush(t,a,!0)}pop(){const t=this.current;this.tmplCount>0&&this._isInTemplate()&&this.tmplCount--,this.stackTop--,this._updateCurrentElement(),this.handler.onItemPop(t,!0)}replace(t,a){const n=this._indexOf(t);this.items[n]=a,n===this.stackTop&&(this.current=a)}insertAfter(t,a,n){const i=this._indexOf(t)+1;this.items.splice(i,0,a),this.tagIDs.splice(i,0,n),this.stackTop++,i===this.stackTop&&this._updateCurrentElement(),this.handler.onItemPush(this.current,this.currentTagId,i===this.stackTop)}popUntilTagNamePopped(t){let a=this.stackTop+1;do a=this.tagIDs.lastIndexOf(t,a-1);while(a>0&&this.treeAdapter.getNamespaceURI(this.items[a])!==N.HTML);this.shortenToLength(a<0?0:a)}shortenToLength(t){for(;this.stackTop>=t;){const a=this.current;this.tmplCount>0&&this._isInTemplate()&&(this.tmplCount-=1),this.stackTop--,this._updateCurrentElement(),this.handler.onItemPop(a,this.stackTop<t)}}popUntilElementPopped(t){const a=this._indexOf(t);this.shortenToLength(a<0?0:a)}popUntilPopped(t,a){const n=this._indexOfTagNames(t,a);this.shortenToLength(n<0?0:n)}popUntilNumberedHeaderPopped(){this.popUntilPopped(Tn,N.HTML)}popUntilTableCellPopped(){this.popUntilPopped(il,N.HTML)}popAllUpToHtmlElement(){this.tmplCount=0,this.shortenToLength(1)}_indexOfTagNames(t,a){for(let n=this.stackTop;n>=0;n--)if(t.has(this.tagIDs[n])&&this.treeAdapter.getNamespaceURI(this.items[n])===a)return n;return-1}clearBackTo(t,a){const n=this._indexOfTagNames(t,a);this.shortenToLength(n+1)}clearBackToTableContext(){this.clearBackTo(nl,N.HTML)}clearBackToTableBodyContext(){this.clearBackTo(al,N.HTML)}clearBackToTableRowContext(){this.clearBackTo(tl,N.HTML)}remove(t){const a=this._indexOf(t);a>=0&&(a===this.stackTop?this.pop():(this.items.splice(a,1),this.tagIDs.splice(a,1),this.stackTop--,this._updateCurrentElement(),this.handler.onItemPop(t,!1)))}tryPeekProperlyNestedBodyElement(){return this.stackTop>=1&&this.tagIDs[1]===s.BODY?this.items[1]:null}contains(t){return this._indexOf(t)>-1}getCommonAncestor(t){const a=this._indexOf(t)-1;return a>=0?this.items[a]:null}isRootHtmlElementCurrent(){return this.stackTop===0&&this.tagIDs[0]===s.HTML}hasInDynamicScope(t,a){for(let n=this.stackTop;n>=0;n--){const i=this.tagIDs[n];switch(this.treeAdapter.getNamespaceURI(this.items[n])){case N.HTML:{if(i===t)return!0;if(a.has(i))return!1;break}case N.SVG:{if(as.has(i))return!1;break}case N.MATHML:{if(ts.has(i))return!1;break}}}return!0}hasInScope(t){return this.hasInDynamicScope(t,ga)}hasInListItemScope(t){return this.hasInDynamicScope(t,Jc)}hasInButtonScope(t){return this.hasInDynamicScope(t,el)}hasNumberedHeaderInScope(){for(let t=this.stackTop;t>=0;t--){const a=this.tagIDs[t];switch(this.treeAdapter.getNamespaceURI(this.items[t])){case N.HTML:{if(Tn.has(a))return!0;if(ga.has(a))return!1;break}case N.SVG:{if(as.has(a))return!1;break}case N.MATHML:{if(ts.has(a))return!1;break}}}return!0}hasInTableScope(t){for(let a=this.stackTop;a>=0;a--)if(this.treeAdapter.getNamespaceURI(this.items[a])===N.HTML)switch(this.tagIDs[a]){case t:return!0;case s.TABLE:case s.HTML:return!1}return!0}hasTableBodyContextInTableScope(){for(let t=this.stackTop;t>=0;t--)if(this.treeAdapter.getNamespaceURI(this.items[t])===N.HTML)switch(this.tagIDs[t]){case s.TBODY:case s.THEAD:case s.TFOOT:return!0;case s.TABLE:case s.HTML:return!1}return!0}hasInSelectScope(t){for(let a=this.stackTop;a>=0;a--)if(this.treeAdapter.getNamespaceURI(this.items[a])===N.HTML)switch(this.tagIDs[a]){case t:return!0;case s.OPTION:case s.OPTGROUP:break;default:return!1}return!0}generateImpliedEndTags(){for(;Ji.has(this.currentTagId);)this.pop()}generateImpliedEndTagsThoroughly(){for(;es.has(this.currentTagId);)this.pop()}generateImpliedEndTagsWithExclusion(t){for(;this.currentTagId!==t&&es.has(this.currentTagId);)this.pop()}}const bn=3;var we;(function(e){e[e.Marker=0]="Marker",e[e.Element=1]="Element"})(we||(we={}));const ns={type:we.Marker};class rl{constructor(t){this.treeAdapter=t,this.entries=[],this.bookmark=null}_getNoahArkConditionCandidates(t,a){const n=[],i=a.length,r=this.treeAdapter.getTagName(t),u=this.treeAdapter.getNamespaceURI(t);for(let o=0;o<this.entries.length;o++){const l=this.entries[o];if(l.type===we.Marker)break;const{element:h}=l;if(this.treeAdapter.getTagName(h)===r&&this.treeAdapter.getNamespaceURI(h)===u){const m=this.treeAdapter.getAttrList(h);m.length===i&&n.push({idx:o,attrs:m})}}return n}_ensureNoahArkCondition(t){if(this.entries.length<bn)return;const a=this.treeAdapter.getAttrList(t),n=this._getNoahArkConditionCandidates(t,a);if(n.length<bn)return;const i=new Map(a.map(u=>[u.name,u.value]));let r=0;for(let u=0;u<n.length;u++){const o=n[u];o.attrs.every(l=>i.get(l.name)===l.value)&&(r+=1,r>=bn&&this.entries.splice(o.idx,1))}}insertMarker(){this.entries.unshift(ns)}pushElement(t,a){this._ensureNoahArkCondition(t),this.entries.unshift({type:we.Element,element:t,token:a})}insertElementAfterBookmark(t,a){const n=this.entries.indexOf(this.bookmark);this.entries.splice(n,0,{type:we.Element,element:t,token:a})}removeEntry(t){const a=this.entries.indexOf(t);a>=0&&this.entries.splice(a,1)}clearToLastMarker(){const t=this.entries.indexOf(ns);t>=0?this.entries.splice(0,t+1):this.entries.length=0}getElementEntryInScopeWithTagName(t){const a=this.entries.find(n=>n.type===we.Marker||this.treeAdapter.getTagName(n.element)===t);return a&&a.type===we.Element?a:null}getElementEntry(t){return this.entries.find(a=>a.type===we.Element&&a.element===t)}}const Ye={createDocument(){return{nodeName:"#document",mode:Se.NO_QUIRKS,childNodes:[]}},createDocumentFragment(){return{nodeName:"#document-fragment",childNodes:[]}},createElement(e,t,a){return{nodeName:e,tagName:e,attrs:a,namespaceURI:t,childNodes:[],parentNode:null}},createCommentNode(e){return{nodeName:"#comment",data:e,parentNode:null}},createTextNode(e){return{nodeName:"#text",value:e,parentNode:null}},appendChild(e,t){e.childNodes.push(t),t.parentNode=e},insertBefore(e,t,a){const n=e.childNodes.indexOf(a);e.childNodes.splice(n,0,t),t.parentNode=e},setTemplateContent(e,t){e.content=t},getTemplateContent(e){return e.content},setDocumentType(e,t,a,n){const i=e.childNodes.find(r=>r.nodeName==="#documentType");if(i)i.name=t,i.publicId=a,i.systemId=n;else{const r={nodeName:"#documentType",name:t,publicId:a,systemId:n,parentNode:null};Ye.appendChild(e,r)}},setDocumentMode(e,t){e.mode=t},getDocumentMode(e){return e.mode},detachNode(e){if(e.parentNode){const t=e.parentNode.childNodes.indexOf(e);e.parentNode.childNodes.splice(t,1),e.parentNode=null}},insertText(e,t){if(e.childNodes.length>0){const a=e.childNodes[e.childNodes.length-1];if(Ye.isTextNode(a)){a.value+=t;return}}Ye.appendChild(e,Ye.createTextNode(t))},insertTextBefore(e,t,a){const n=e.childNodes[e.childNodes.indexOf(a)-1];n&&Ye.isTextNode(n)?n.value+=t:Ye.insertBefore(e,Ye.createTextNode(t),a)},adoptAttributes(e,t){const a=new Set(e.attrs.map(n=>n.name));for(let n=0;n<t.length;n++)a.has(t[n].name)||e.attrs.push(t[n])},getFirstChild(e){return e.childNodes[0]},getChildNodes(e){return e.childNodes},getParentNode(e){return e.parentNode},getAttrList(e){return e.attrs},getTagName(e){return e.tagName},getNamespaceURI(e){return e.namespaceURI},getTextNodeContent(e){return e.value},getCommentNodeContent(e){return e.data},getDocumentTypeNodeName(e){return e.name},getDocumentTypeNodePublicId(e){return e.publicId},getDocumentTypeNodeSystemId(e){return e.systemId},isTextNode(e){return e.nodeName==="#text"},isCommentNode(e){return e.nodeName==="#comment"},isDocumentTypeNode(e){return e.nodeName==="#documentType"},isElementNode(e){return Object.prototype.hasOwnProperty.call(e,"tagName")},setNodeSourceCodeLocation(e,t){e.sourceCodeLocation=t},getNodeSourceCodeLocation(e){return e.sourceCodeLocation},updateNodeSourceCodeLocation(e,t){e.sourceCodeLocation={...e.sourceCodeLocation,...t}}},is="html",ul="about:legacy-compat",ol="http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd",ss=["+//silmaril//dtd html pro v0r11 19970101//","-//as//dtd html 3.0 aswedit + extensions//","-//advasoft ltd//dtd html 3.0 aswedit + extensions//","-//ietf//dtd html 2.0 level 1//","-//ietf//dtd html 2.0 level 2//","-//ietf//dtd html 2.0 strict level 1//","-//ietf//dtd html 2.0 strict level 2//","-//ietf//dtd html 2.0 strict//","-//ietf//dtd html 2.0//","-//ietf//dtd html 2.1e//","-//ietf//dtd html 3.0//","-//ietf//dtd html 3.2 final//","-//ietf//dtd html 3.2//","-//ietf//dtd html 3//","-//ietf//dtd html level 0//","-//ietf//dtd html level 1//","-//ietf//dtd html level 2//","-//ietf//dtd html level 3//","-//ietf//dtd html strict level 0//","-//ietf//dtd html strict level 1//","-//ietf//dtd html strict level 2//","-//ietf//dtd html strict level 3//","-//ietf//dtd html strict//","-//ietf//dtd html//","-//metrius//dtd metrius presentational//","-//microsoft//dtd internet explorer 2.0 html strict//","-//microsoft//dtd internet explorer 2.0 html//","-//microsoft//dtd internet explorer 2.0 tables//","-//microsoft//dtd internet explorer 3.0 html strict//","-//microsoft//dtd internet explorer 3.0 html//","-//microsoft//dtd internet explorer 3.0 tables//","-//netscape comm. corp.//dtd html//","-//netscape comm. corp.//dtd strict html//","-//o'reilly and associates//dtd html 2.0//","-//o'reilly and associates//dtd html extended 1.0//","-//o'reilly and associates//dtd html extended relaxed 1.0//","-//sq//dtd html 2.0 hotmetal + extensions//","-//softquad software//dtd hotmetal pro 6.0::19990601::extensions to html 4.0//","-//softquad//dtd hotmetal pro 4.0::19971010::extensions to html 4.0//","-//spyglass//dtd html 2.0 extended//","-//sun microsystems corp.//dtd hotjava html//","-//sun microsystems corp.//dtd hotjava strict html//","-//w3c//dtd html 3 1995-03-24//","-//w3c//dtd html 3.2 draft//","-//w3c//dtd html 3.2 final//","-//w3c//dtd html 3.2//","-//w3c//dtd html 3.2s draft//","-//w3c//dtd html 4.0 frameset//","-//w3c//dtd html 4.0 transitional//","-//w3c//dtd html experimental 19960712//","-//w3c//dtd html experimental 970421//","-//w3c//dtd w3 html//","-//w3o//dtd w3 html 3.0//","-//webtechs//dtd mozilla html 2.0//","-//webtechs//dtd mozilla html//"],cl=[...ss,"-//w3c//dtd html 4.01 frameset//","-//w3c//dtd html 4.01 transitional//"],ll=new Set(["-//w3o//dtd w3 html strict 3.0//en//","-/w3c/dtd html 4.0 transitional/en","html"]),rs=["-//w3c//dtd xhtml 1.0 frameset//","-//w3c//dtd xhtml 1.0 transitional//"],dl=[...rs,"-//w3c//dtd html 4.01 frameset//","-//w3c//dtd html 4.01 transitional//"];function us(e,t){return t.some(a=>e.startsWith(a))}function hl(e){return e.name===is&&e.publicId===null&&(e.systemId===null||e.systemId===ul)}function fl(e){if(e.name!==is)return Se.QUIRKS;const{systemId:t}=e;if(t&&t.toLowerCase()===ol)return Se.QUIRKS;let{publicId:a}=e;if(a!==null){if(a=a.toLowerCase(),ll.has(a))return Se.QUIRKS;let n=t===null?cl:ss;if(us(a,n))return Se.QUIRKS;if(n=t===null?rs:dl,us(a,n))return Se.LIMITED_QUIRKS}return Se.NO_QUIRKS}const os={TEXT_HTML:"text/html",APPLICATION_XML:"application/xhtml+xml"},ml="definitionurl",El="definitionURL",pl=new Map(["attributeName","attributeType","baseFrequency","baseProfile","calcMode","clipPathUnits","diffuseConstant","edgeMode","filterUnits","glyphRef","gradientTransform","gradientUnits","kernelMatrix","kernelUnitLength","keyPoints","keySplines","keyTimes","lengthAdjust","limitingConeAngle","markerHeight","markerUnits","markerWidth","maskContentUnits","maskUnits","numOctaves","pathLength","patternContentUnits","patternTransform","patternUnits","pointsAtX","pointsAtY","pointsAtZ","preserveAlpha","preserveAspectRatio","primitiveUnits","refX","refY","repeatCount","repeatDur","requiredExtensions","requiredFeatures","specularConstant","specularExponent","spreadMethod","startOffset","stdDeviation","stitchTiles","surfaceScale","systemLanguage","tableValues","targetX","targetY","textLength","viewBox","viewTarget","xChannelSelector","yChannelSelector","zoomAndPan"].map(e=>[e.toLowerCase(),e])),Tl=new Map([["xlink:actuate",{prefix:"xlink",name:"actuate",namespace:N.XLINK}],["xlink:arcrole",{prefix:"xlink",name:"arcrole",namespace:N.XLINK}],["xlink:href",{prefix:"xlink",name:"href",namespace:N.XLINK}],["xlink:role",{prefix:"xlink",name:"role",namespace:N.XLINK}],["xlink:show",{prefix:"xlink",name:"show",namespace:N.XLINK}],["xlink:title",{prefix:"xlink",name:"title",namespace:N.XLINK}],["xlink:type",{prefix:"xlink",name:"type",namespace:N.XLINK}],["xml:lang",{prefix:"xml",name:"lang",namespace:N.XML}],["xml:space",{prefix:"xml",name:"space",namespace:N.XML}],["xmlns",{prefix:"",name:"xmlns",namespace:N.XMLNS}],["xmlns:xlink",{prefix:"xmlns",name:"xlink",namespace:N.XMLNS}]]),bl=new Map(["altGlyph","altGlyphDef","altGlyphItem","animateColor","animateMotion","animateTransform","clipPath","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","foreignObject","glyphRef","linearGradient","radialGradient","textPath"].map(e=>[e.toLowerCase(),e])),gl=new Set([s.B,s.BIG,s.BLOCKQUOTE,s.BODY,s.BR,s.CENTER,s.CODE,s.DD,s.DIV,s.DL,s.DT,s.EM,s.EMBED,s.H1,s.H2,s.H3,s.H4,s.H5,s.H6,s.HEAD,s.HR,s.I,s.IMG,s.LI,s.LISTING,s.MENU,s.META,s.NOBR,s.OL,s.P,s.PRE,s.RUBY,s.S,s.SMALL,s.SPAN,s.STRONG,s.STRIKE,s.SUB,s.SUP,s.TABLE,s.TT,s.U,s.UL,s.VAR]);function _l(e){const t=e.tagID;return t===s.FONT&&e.attrs.some(({name:n})=>n===ut.COLOR||n===ut.SIZE||n===ut.FACE)||gl.has(t)}function cs(e){for(let t=0;t<e.attrs.length;t++)if(e.attrs[t].name===ml){e.attrs[t].name=El;break}}function ls(e){for(let t=0;t<e.attrs.length;t++){const a=pl.get(e.attrs[t].name);a!=null&&(e.attrs[t].name=a)}}function gn(e){for(let t=0;t<e.attrs.length;t++){const a=Tl.get(e.attrs[t].name);a&&(e.attrs[t].prefix=a.prefix,e.attrs[t].name=a.name,e.attrs[t].namespace=a.namespace)}}function Al(e){const t=bl.get(e.tagName);t!=null&&(e.tagName=t,e.tagID=Ta(e.tagName))}function Nl(e,t){return t===N.MATHML&&(e===s.MI||e===s.MO||e===s.MN||e===s.MS||e===s.MTEXT)}function Cl(e,t,a){if(t===N.MATHML&&e===s.ANNOTATION_XML){for(let n=0;n<a.length;n++)if(a[n].name===ut.ENCODING){const i=a[n].value.toLowerCase();return i===os.TEXT_HTML||i===os.APPLICATION_XML}}return t===N.SVG&&(e===s.FOREIGN_OBJECT||e===s.DESC||e===s.TITLE)}function Il(e,t,a,n){return(!n||n===N.HTML)&&Cl(e,t,a)||(!n||n===N.MATHML)&&Nl(e,t)}const Sl="hidden",xl=8,Ol=3;var E;(function(e){e[e.INITIAL=0]="INITIAL",e[e.BEFORE_HTML=1]="BEFORE_HTML",e[e.BEFORE_HEAD=2]="BEFORE_HEAD",e[e.IN_HEAD=3]="IN_HEAD",e[e.IN_HEAD_NO_SCRIPT=4]="IN_HEAD_NO_SCRIPT",e[e.AFTER_HEAD=5]="AFTER_HEAD",e[e.IN_BODY=6]="IN_BODY",e[e.TEXT=7]="TEXT",e[e.IN_TABLE=8]="IN_TABLE",e[e.IN_TABLE_TEXT=9]="IN_TABLE_TEXT",e[e.IN_CAPTION=10]="IN_CAPTION",e[e.IN_COLUMN_GROUP=11]="IN_COLUMN_GROUP",e[e.IN_TABLE_BODY=12]="IN_TABLE_BODY",e[e.IN_ROW=13]="IN_ROW",e[e.IN_CELL=14]="IN_CELL",e[e.IN_SELECT=15]="IN_SELECT",e[e.IN_SELECT_IN_TABLE=16]="IN_SELECT_IN_TABLE",e[e.IN_TEMPLATE=17]="IN_TEMPLATE",e[e.AFTER_BODY=18]="AFTER_BODY",e[e.IN_FRAMESET=19]="IN_FRAMESET",e[e.AFTER_FRAMESET=20]="AFTER_FRAMESET",e[e.AFTER_AFTER_BODY=21]="AFTER_AFTER_BODY",e[e.AFTER_AFTER_FRAMESET=22]="AFTER_AFTER_FRAMESET"})(E||(E={}));const Dl={startLine:-1,startCol:-1,startOffset:-1,endLine:-1,endCol:-1,endOffset:-1},ds=new Set([s.TABLE,s.TBODY,s.TFOOT,s.THEAD,s.TR]),hs={scriptingEnabled:!0,sourceCodeLocationInfo:!1,treeAdapter:Ye,onParseError:null};let fs=class{constructor(t,a,n=null,i=null){this.fragmentContext=n,this.scriptHandler=i,this.currentToken=null,this.stopped=!1,this.insertionMode=E.INITIAL,this.originalInsertionMode=E.INITIAL,this.headElement=null,this.formElement=null,this.currentNotInHTML=!1,this.tmplInsertionModeStack=[],this.pendingCharacterTokens=[],this.hasNonWhitespacePendingCharacterToken=!1,this.framesetOk=!0,this.skipNextNewLine=!1,this.fosterParentingEnabled=!1,this.options={...hs,...t},this.treeAdapter=this.options.treeAdapter,this.onParseError=this.options.onParseError,this.onParseError&&(this.options.sourceCodeLocationInfo=!0),this.document=a??this.treeAdapter.createDocument(),this.tokenizer=new Zc(this.options,this),this.activeFormattingElements=new rl(this.treeAdapter),this.fragmentContextID=n?Ta(this.treeAdapter.getTagName(n)):s.UNKNOWN,this._setContextModes(n??this.document,this.fragmentContextID),this.openElements=new sl(this.document,this.treeAdapter,this)}static parse(t,a){const n=new this(a);return n.tokenizer.write(t,!0),n.document}static getFragmentParser(t,a){const n={...hs,...a};t??(t=n.treeAdapter.createElement(b.TEMPLATE,N.HTML,[]));const i=n.treeAdapter.createElement("documentmock",N.HTML,[]),r=new this(n,i,t);return r.fragmentContextID===s.TEMPLATE&&r.tmplInsertionModeStack.unshift(E.IN_TEMPLATE),r._initTokenizerForFragmentParsing(),r._insertFakeRootElement(),r._resetInsertionMode(),r._findFormInFragmentContext(),r}getFragment(){const t=this.treeAdapter.getFirstChild(this.document),a=this.treeAdapter.createDocumentFragment();return this._adoptNodes(t,a),a}_err(t,a,n){var i;if(!this.onParseError)return;const r=(i=t.location)!==null&&i!==void 0?i:Dl,u={code:a,startLine:r.startLine,startCol:r.startCol,startOffset:r.startOffset,endLine:n?r.startLine:r.endLine,endCol:n?r.startCol:r.endCol,endOffset:n?r.startOffset:r.endOffset};this.onParseError(u)}onItemPush(t,a,n){var i,r;(r=(i=this.treeAdapter).onItemPush)===null||r===void 0||r.call(i,t),n&&this.openElements.stackTop>0&&this._setContextModes(t,a)}onItemPop(t,a){var n,i;if(this.options.sourceCodeLocationInfo&&this._setEndLocation(t,this.currentToken),(i=(n=this.treeAdapter).onItemPop)===null||i===void 0||i.call(n,t,this.openElements.current),a){let r,u;this.openElements.stackTop===0&&this.fragmentContext?(r=this.fragmentContext,u=this.fragmentContextID):{current:r,currentTagId:u}=this.openElements,this._setContextModes(r,u)}}_setContextModes(t,a){const n=t===this.document||this.treeAdapter.getNamespaceURI(t)===N.HTML;this.currentNotInHTML=!n,this.tokenizer.inForeignNode=!n&&!this._isIntegrationPoint(a,t)}_switchToTextParsing(t,a){this._insertElement(t,N.HTML),this.tokenizer.state=a,this.originalInsertionMode=this.insertionMode,this.insertionMode=E.TEXT}switchToPlaintextParsing(){this.insertionMode=E.TEXT,this.originalInsertionMode=E.IN_BODY,this.tokenizer.state=Ne.PLAINTEXT}_getAdjustedCurrentElement(){return this.openElements.stackTop===0&&this.fragmentContext?this.fragmentContext:this.openElements.current}_findFormInFragmentContext(){let t=this.fragmentContext;for(;t;){if(this.treeAdapter.getTagName(t)===b.FORM){this.formElement=t;break}t=this.treeAdapter.getParentNode(t)}}_initTokenizerForFragmentParsing(){if(!(!this.fragmentContext||this.treeAdapter.getNamespaceURI(this.fragmentContext)!==N.HTML))switch(this.fragmentContextID){case s.TITLE:case s.TEXTAREA:{this.tokenizer.state=Ne.RCDATA;break}case s.STYLE:case s.XMP:case s.IFRAME:case s.NOEMBED:case s.NOFRAMES:case s.NOSCRIPT:{this.tokenizer.state=Ne.RAWTEXT;break}case s.SCRIPT:{this.tokenizer.state=Ne.SCRIPT_DATA;break}case s.PLAINTEXT:{this.tokenizer.state=Ne.PLAINTEXT;break}}}_setDocumentType(t){const a=t.name||"",n=t.publicId||"",i=t.systemId||"";if(this.treeAdapter.setDocumentType(this.document,a,n,i),t.location){const u=this.treeAdapter.getChildNodes(this.document).find(o=>this.treeAdapter.isDocumentTypeNode(o));u&&this.treeAdapter.setNodeSourceCodeLocation(u,t.location)}}_attachElementToTree(t,a){if(this.options.sourceCodeLocationInfo){const n=a&&{...a,startTag:a};this.treeAdapter.setNodeSourceCodeLocation(t,n)}if(this._shouldFosterParentOnInsertion())this._fosterParentElement(t);else{const n=this.openElements.currentTmplContentOrNode;this.treeAdapter.appendChild(n,t)}}_appendElement(t,a){const n=this.treeAdapter.createElement(t.tagName,a,t.attrs);this._attachElementToTree(n,t.location)}_insertElement(t,a){const n=this.treeAdapter.createElement(t.tagName,a,t.attrs);this._attachElementToTree(n,t.location),this.openElements.push(n,t.tagID)}_insertFakeElement(t,a){const n=this.treeAdapter.createElement(t,N.HTML,[]);this._attachElementToTree(n,null),this.openElements.push(n,a)}_insertTemplate(t){const a=this.treeAdapter.createElement(t.tagName,N.HTML,t.attrs),n=this.treeAdapter.createDocumentFragment();this.treeAdapter.setTemplateContent(a,n),this._attachElementToTree(a,t.location),this.openElements.push(a,t.tagID),this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(n,null)}_insertFakeRootElement(){const t=this.treeAdapter.createElement(b.HTML,N.HTML,[]);this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(t,null),this.treeAdapter.appendChild(this.openElements.current,t),this.openElements.push(t,s.HTML)}_appendCommentNode(t,a){const n=this.treeAdapter.createCommentNode(t.data);this.treeAdapter.appendChild(a,n),this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(n,t.location)}_insertCharacters(t){let a,n;if(this._shouldFosterParentOnInsertion()?({parent:a,beforeElement:n}=this._findFosterParentingLocation(),n?this.treeAdapter.insertTextBefore(a,t.chars,n):this.treeAdapter.insertText(a,t.chars)):(a=this.openElements.currentTmplContentOrNode,this.treeAdapter.insertText(a,t.chars)),!t.location)return;const i=this.treeAdapter.getChildNodes(a),r=n?i.lastIndexOf(n):i.length,u=i[r-1];if(this.treeAdapter.getNodeSourceCodeLocation(u)){const{endLine:l,endCol:h,endOffset:m}=t.location;this.treeAdapter.updateNodeSourceCodeLocation(u,{endLine:l,endCol:h,endOffset:m})}else this.options.sourceCodeLocationInfo&&this.treeAdapter.setNodeSourceCodeLocation(u,t.location)}_adoptNodes(t,a){for(let n=this.treeAdapter.getFirstChild(t);n;n=this.treeAdapter.getFirstChild(t))this.treeAdapter.detachNode(n),this.treeAdapter.appendChild(a,n)}_setEndLocation(t,a){if(this.treeAdapter.getNodeSourceCodeLocation(t)&&a.location){const n=a.location,i=this.treeAdapter.getTagName(t),r=a.type===$.END_TAG&&i===a.tagName?{endTag:{...n},endLine:n.endLine,endCol:n.endCol,endOffset:n.endOffset}:{endLine:n.startLine,endCol:n.startCol,endOffset:n.startOffset};this.treeAdapter.updateNodeSourceCodeLocation(t,r)}}shouldProcessStartTagTokenInForeignContent(t){if(!this.currentNotInHTML)return!1;let a,n;return this.openElements.stackTop===0&&this.fragmentContext?(a=this.fragmentContext,n=this.fragmentContextID):{current:a,currentTagId:n}=this.openElements,t.tagID===s.SVG&&this.treeAdapter.getTagName(a)===b.ANNOTATION_XML&&this.treeAdapter.getNamespaceURI(a)===N.MATHML?!1:this.tokenizer.inForeignNode||(t.tagID===s.MGLYPH||t.tagID===s.MALIGNMARK)&&!this._isIntegrationPoint(n,a,N.HTML)}_processToken(t){switch(t.type){case $.CHARACTER:{this.onCharacter(t);break}case $.NULL_CHARACTER:{this.onNullCharacter(t);break}case $.COMMENT:{this.onComment(t);break}case $.DOCTYPE:{this.onDoctype(t);break}case $.START_TAG:{this._processStartTag(t);break}case $.END_TAG:{this.onEndTag(t);break}case $.EOF:{this.onEof(t);break}case $.WHITESPACE_CHARACTER:{this.onWhitespaceCharacter(t);break}}}_isIntegrationPoint(t,a,n){const i=this.treeAdapter.getNamespaceURI(a),r=this.treeAdapter.getAttrList(a);return Il(t,i,r,n)}_reconstructActiveFormattingElements(){const t=this.activeFormattingElements.entries.length;if(t){const a=this.activeFormattingElements.entries.findIndex(i=>i.type===we.Marker||this.openElements.contains(i.element)),n=a<0?t-1:a-1;for(let i=n;i>=0;i--){const r=this.activeFormattingElements.entries[i];this._insertElement(r.token,this.treeAdapter.getNamespaceURI(r.element)),r.element=this.openElements.current}}}_closeTableCell(){this.openElements.generateImpliedEndTags(),this.openElements.popUntilTableCellPopped(),this.activeFormattingElements.clearToLastMarker(),this.insertionMode=E.IN_ROW}_closePElement(){this.openElements.generateImpliedEndTagsWithExclusion(s.P),this.openElements.popUntilTagNamePopped(s.P)}_resetInsertionMode(){for(let t=this.openElements.stackTop;t>=0;t--)switch(t===0&&this.fragmentContext?this.fragmentContextID:this.openElements.tagIDs[t]){case s.TR:{this.insertionMode=E.IN_ROW;return}case s.TBODY:case s.THEAD:case s.TFOOT:{this.insertionMode=E.IN_TABLE_BODY;return}case s.CAPTION:{this.insertionMode=E.IN_CAPTION;return}case s.COLGROUP:{this.insertionMode=E.IN_COLUMN_GROUP;return}case s.TABLE:{this.insertionMode=E.IN_TABLE;return}case s.BODY:{this.insertionMode=E.IN_BODY;return}case s.FRAMESET:{this.insertionMode=E.IN_FRAMESET;return}case s.SELECT:{this._resetInsertionModeForSelect(t);return}case s.TEMPLATE:{this.insertionMode=this.tmplInsertionModeStack[0];return}case s.HTML:{this.insertionMode=this.headElement?E.AFTER_HEAD:E.BEFORE_HEAD;return}case s.TD:case s.TH:{if(t>0){this.insertionMode=E.IN_CELL;return}break}case s.HEAD:{if(t>0){this.insertionMode=E.IN_HEAD;return}break}}this.insertionMode=E.IN_BODY}_resetInsertionModeForSelect(t){if(t>0)for(let a=t-1;a>0;a--){const n=this.openElements.tagIDs[a];if(n===s.TEMPLATE)break;if(n===s.TABLE){this.insertionMode=E.IN_SELECT_IN_TABLE;return}}this.insertionMode=E.IN_SELECT}_isElementCausesFosterParenting(t){return ds.has(t)}_shouldFosterParentOnInsertion(){return this.fosterParentingEnabled&&this._isElementCausesFosterParenting(this.openElements.currentTagId)}_findFosterParentingLocation(){for(let t=this.openElements.stackTop;t>=0;t--){const a=this.openElements.items[t];switch(this.openElements.tagIDs[t]){case s.TEMPLATE:{if(this.treeAdapter.getNamespaceURI(a)===N.HTML)return{parent:this.treeAdapter.getTemplateContent(a),beforeElement:null};break}case s.TABLE:{const n=this.treeAdapter.getParentNode(a);return n?{parent:n,beforeElement:a}:{parent:this.openElements.items[t-1],beforeElement:null}}}}return{parent:this.openElements.items[0],beforeElement:null}}_fosterParentElement(t){const a=this._findFosterParentingLocation();a.beforeElement?this.treeAdapter.insertBefore(a.parent,t,a.beforeElement):this.treeAdapter.appendChild(a.parent,t)}_isSpecialElement(t,a){const n=this.treeAdapter.getNamespaceURI(t);return Gc[n].has(a)}onCharacter(t){if(this.skipNextNewLine=!1,this.tokenizer.inForeignNode){id(this,t);return}switch(this.insertionMode){case E.INITIAL:{wt(this,t);break}case E.BEFORE_HTML:{Ut(this,t);break}case E.BEFORE_HEAD:{Ft(this,t);break}case E.IN_HEAD:{Ht(this,t);break}case E.IN_HEAD_NO_SCRIPT:{Vt(this,t);break}case E.AFTER_HEAD:{Yt(this,t);break}case E.IN_BODY:case E.IN_CAPTION:case E.IN_CELL:case E.IN_TEMPLATE:{Es(this,t);break}case E.TEXT:case E.IN_SELECT:case E.IN_SELECT_IN_TABLE:{this._insertCharacters(t);break}case E.IN_TABLE:case E.IN_TABLE_BODY:case E.IN_ROW:{Cn(this,t);break}case E.IN_TABLE_TEXT:{Cs(this,t);break}case E.IN_COLUMN_GROUP:{Na(this,t);break}case E.AFTER_BODY:{Sa(this,t);break}case E.AFTER_AFTER_BODY:{xa(this,t);break}}}onNullCharacter(t){if(this.skipNextNewLine=!1,this.tokenizer.inForeignNode){nd(this,t);return}switch(this.insertionMode){case E.INITIAL:{wt(this,t);break}case E.BEFORE_HTML:{Ut(this,t);break}case E.BEFORE_HEAD:{Ft(this,t);break}case E.IN_HEAD:{Ht(this,t);break}case E.IN_HEAD_NO_SCRIPT:{Vt(this,t);break}case E.AFTER_HEAD:{Yt(this,t);break}case E.TEXT:{this._insertCharacters(t);break}case E.IN_TABLE:case E.IN_TABLE_BODY:case E.IN_ROW:{Cn(this,t);break}case E.IN_COLUMN_GROUP:{Na(this,t);break}case E.AFTER_BODY:{Sa(this,t);break}case E.AFTER_AFTER_BODY:{xa(this,t);break}}}onComment(t){if(this.skipNextNewLine=!1,this.currentNotInHTML){An(this,t);return}switch(this.insertionMode){case E.INITIAL:case E.BEFORE_HTML:case E.BEFORE_HEAD:case E.IN_HEAD:case E.IN_HEAD_NO_SCRIPT:case E.AFTER_HEAD:case E.IN_BODY:case E.IN_TABLE:case E.IN_CAPTION:case E.IN_COLUMN_GROUP:case E.IN_TABLE_BODY:case E.IN_ROW:case E.IN_CELL:case E.IN_SELECT:case E.IN_SELECT_IN_TABLE:case E.IN_TEMPLATE:case E.IN_FRAMESET:case E.AFTER_FRAMESET:{An(this,t);break}case E.IN_TABLE_TEXT:{Wt(this,t);break}case E.AFTER_BODY:{vl(this,t);break}case E.AFTER_AFTER_BODY:case E.AFTER_AFTER_FRAMESET:{Bl(this,t);break}}}onDoctype(t){switch(this.skipNextNewLine=!1,this.insertionMode){case E.INITIAL:{wl(this,t);break}case E.BEFORE_HEAD:case E.IN_HEAD:case E.IN_HEAD_NO_SCRIPT:case E.AFTER_HEAD:{this._err(t,g.misplacedDoctype);break}case E.IN_TABLE_TEXT:{Wt(this,t);break}}}onStartTag(t){this.skipNextNewLine=!1,this.currentToken=t,this._processStartTag(t),t.selfClosing&&!t.ackSelfClosing&&this._err(t,g.nonVoidHtmlElementStartTagWithTrailingSolidus)}_processStartTag(t){this.shouldProcessStartTagTokenInForeignContent(t)?sd(this,t):this._startTagOutsideForeignContent(t)}_startTagOutsideForeignContent(t){switch(this.insertionMode){case E.INITIAL:{wt(this,t);break}case E.BEFORE_HTML:{Ul(this,t);break}case E.BEFORE_HEAD:{Hl(this,t);break}case E.IN_HEAD:{ke(this,t);break}case E.IN_HEAD_NO_SCRIPT:{ql(this,t);break}case E.AFTER_HEAD:{Wl(this,t);break}case E.IN_BODY:{Te(this,t);break}case E.IN_TABLE:{bt(this,t);break}case E.IN_TABLE_TEXT:{Wt(this,t);break}case E.IN_CAPTION:{V0(this,t);break}case E.IN_COLUMN_GROUP:{In(this,t);break}case E.IN_TABLE_BODY:{Ca(this,t);break}case E.IN_ROW:{Ia(this,t);break}case E.IN_CELL:{$0(this,t);break}case E.IN_SELECT:{xs(this,t);break}case E.IN_SELECT_IN_TABLE:{G0(this,t);break}case E.IN_TEMPLATE:{Q0(this,t);break}case E.AFTER_BODY:{z0(this,t);break}case E.IN_FRAMESET:{K0(this,t);break}case E.AFTER_FRAMESET:{J0(this,t);break}case E.AFTER_AFTER_BODY:{td(this,t);break}case E.AFTER_AFTER_FRAMESET:{ad(this,t);break}}}onEndTag(t){this.skipNextNewLine=!1,this.currentToken=t,this.currentNotInHTML?rd(this,t):this._endTagOutsideForeignContent(t)}_endTagOutsideForeignContent(t){switch(this.insertionMode){case E.INITIAL:{wt(this,t);break}case E.BEFORE_HTML:{Fl(this,t);break}case E.BEFORE_HEAD:{Vl(this,t);break}case E.IN_HEAD:{Yl(this,t);break}case E.IN_HEAD_NO_SCRIPT:{$l(this,t);break}case E.AFTER_HEAD:{Gl(this,t);break}case E.IN_BODY:{Aa(this,t);break}case E.TEXT:{R0(this,t);break}case E.IN_TABLE:{qt(this,t);break}case E.IN_TABLE_TEXT:{Wt(this,t);break}case E.IN_CAPTION:{Y0(this,t);break}case E.IN_COLUMN_GROUP:{q0(this,t);break}case E.IN_TABLE_BODY:{Sn(this,t);break}case E.IN_ROW:{Ss(this,t);break}case E.IN_CELL:{W0(this,t);break}case E.IN_SELECT:{Os(this,t);break}case E.IN_SELECT_IN_TABLE:{X0(this,t);break}case E.IN_TEMPLATE:{j0(this,t);break}case E.AFTER_BODY:{Ls(this,t);break}case E.IN_FRAMESET:{Z0(this,t);break}case E.AFTER_FRAMESET:{ed(this,t);break}case E.AFTER_AFTER_BODY:{xa(this,t);break}}}onEof(t){switch(this.insertionMode){case E.INITIAL:{wt(this,t);break}case E.BEFORE_HTML:{Ut(this,t);break}case E.BEFORE_HEAD:{Ft(this,t);break}case E.IN_HEAD:{Ht(this,t);break}case E.IN_HEAD_NO_SCRIPT:{Vt(this,t);break}case E.AFTER_HEAD:{Yt(this,t);break}case E.IN_BODY:case E.IN_TABLE:case E.IN_CAPTION:case E.IN_COLUMN_GROUP:case E.IN_TABLE_BODY:case E.IN_ROW:case E.IN_CELL:case E.IN_SELECT:case E.IN_SELECT_IN_TABLE:{As(this,t);break}case E.TEXT:{k0(this,t);break}case E.IN_TABLE_TEXT:{Wt(this,t);break}case E.IN_TEMPLATE:{Ds(this,t);break}case E.AFTER_BODY:case E.IN_FRAMESET:case E.AFTER_FRAMESET:case E.AFTER_AFTER_BODY:case E.AFTER_AFTER_FRAMESET:{Nn(this,t);break}}}onWhitespaceCharacter(t){if(this.skipNextNewLine&&(this.skipNextNewLine=!1,t.chars.charCodeAt(0)===d.LINE_FEED)){if(t.chars.length===1)return;t.chars=t.chars.substr(1)}if(this.tokenizer.inForeignNode){this._insertCharacters(t);return}switch(this.insertionMode){case E.IN_HEAD:case E.IN_HEAD_NO_SCRIPT:case E.AFTER_HEAD:case E.TEXT:case E.IN_COLUMN_GROUP:case E.IN_SELECT:case E.IN_SELECT_IN_TABLE:case E.IN_FRAMESET:case E.AFTER_FRAMESET:{this._insertCharacters(t);break}case E.IN_BODY:case E.IN_CAPTION:case E.IN_CELL:case E.IN_TEMPLATE:case E.AFTER_BODY:case E.AFTER_AFTER_BODY:case E.AFTER_AFTER_FRAMESET:{ms(this,t);break}case E.IN_TABLE:case E.IN_TABLE_BODY:case E.IN_ROW:{Cn(this,t);break}case E.IN_TABLE_TEXT:{Ns(this,t);break}}}};function Ll(e,t){let a=e.activeFormattingElements.getElementEntryInScopeWithTagName(t.tagName);return a?e.openElements.contains(a.element)?e.openElements.hasInScope(t.tagID)||(a=null):(e.activeFormattingElements.removeEntry(a),a=null):_s(e,t),a}function yl(e,t){let a=null,n=e.openElements.stackTop;for(;n>=0;n--){const i=e.openElements.items[n];if(i===t.element)break;e._isSpecialElement(i,e.openElements.tagIDs[n])&&(a=i)}return a||(e.openElements.shortenToLength(n<0?0:n),e.activeFormattingElements.removeEntry(t)),a}function Rl(e,t,a){let n=t,i=e.openElements.getCommonAncestor(t);for(let r=0,u=i;u!==a;r++,u=i){i=e.openElements.getCommonAncestor(u);const o=e.activeFormattingElements.getElementEntry(u),l=o&&r>=Ol;!o||l?(l&&e.activeFormattingElements.removeEntry(o),e.openElements.remove(u)):(u=kl(e,o),n===t&&(e.activeFormattingElements.bookmark=o),e.treeAdapter.detachNode(n),e.treeAdapter.appendChild(u,n),n=u)}return n}function kl(e,t){const a=e.treeAdapter.getNamespaceURI(t.element),n=e.treeAdapter.createElement(t.token.tagName,a,t.token.attrs);return e.openElements.replace(t.element,n),t.element=n,n}function Ml(e,t,a){const n=e.treeAdapter.getTagName(t),i=Ta(n);if(e._isElementCausesFosterParenting(i))e._fosterParentElement(a);else{const r=e.treeAdapter.getNamespaceURI(t);i===s.TEMPLATE&&r===N.HTML&&(t=e.treeAdapter.getTemplateContent(t)),e.treeAdapter.appendChild(t,a)}}function Pl(e,t,a){const n=e.treeAdapter.getNamespaceURI(a.element),{token:i}=a,r=e.treeAdapter.createElement(i.tagName,n,i.attrs);e._adoptNodes(t,r),e.treeAdapter.appendChild(t,r),e.activeFormattingElements.insertElementAfterBookmark(r,i),e.activeFormattingElements.removeEntry(a),e.openElements.remove(a.element),e.openElements.insertAfter(t,r,i.tagID)}function _n(e,t){for(let a=0;a<xl;a++){const n=Ll(e,t);if(!n)break;const i=yl(e,n);if(!i)break;e.activeFormattingElements.bookmark=n;const r=Rl(e,i,n.element),u=e.openElements.getCommonAncestor(n.element);e.treeAdapter.detachNode(r),u&&Ml(e,u,r),Pl(e,i,n)}}function An(e,t){e._appendCommentNode(t,e.openElements.currentTmplContentOrNode)}function vl(e,t){e._appendCommentNode(t,e.openElements.items[0])}function Bl(e,t){e._appendCommentNode(t,e.document)}function Nn(e,t){if(e.stopped=!0,t.location){const a=e.fragmentContext?0:2;for(let n=e.openElements.stackTop;n>=a;n--)e._setEndLocation(e.openElements.items[n],t);if(!e.fragmentContext&&e.openElements.stackTop>=0){const n=e.openElements.items[0],i=e.treeAdapter.getNodeSourceCodeLocation(n);if(i&&!i.endTag&&(e._setEndLocation(n,t),e.openElements.stackTop>=1)){const r=e.openElements.items[1],u=e.treeAdapter.getNodeSourceCodeLocation(r);u&&!u.endTag&&e._setEndLocation(r,t)}}}}function wl(e,t){e._setDocumentType(t);const a=t.forceQuirks?Se.QUIRKS:fl(t);hl(t)||e._err(t,g.nonConformingDoctype),e.treeAdapter.setDocumentMode(e.document,a),e.insertionMode=E.BEFORE_HTML}function wt(e,t){e._err(t,g.missingDoctype,!0),e.treeAdapter.setDocumentMode(e.document,Se.QUIRKS),e.insertionMode=E.BEFORE_HTML,e._processToken(t)}function Ul(e,t){t.tagID===s.HTML?(e._insertElement(t,N.HTML),e.insertionMode=E.BEFORE_HEAD):Ut(e,t)}function Fl(e,t){const a=t.tagID;(a===s.HTML||a===s.HEAD||a===s.BODY||a===s.BR)&&Ut(e,t)}function Ut(e,t){e._insertFakeRootElement(),e.insertionMode=E.BEFORE_HEAD,e._processToken(t)}function Hl(e,t){switch(t.tagID){case s.HTML:{Te(e,t);break}case s.HEAD:{e._insertElement(t,N.HTML),e.headElement=e.openElements.current,e.insertionMode=E.IN_HEAD;break}default:Ft(e,t)}}function Vl(e,t){const a=t.tagID;a===s.HEAD||a===s.BODY||a===s.HTML||a===s.BR?Ft(e,t):e._err(t,g.endTagWithoutMatchingOpenElement)}function Ft(e,t){e._insertFakeElement(b.HEAD,s.HEAD),e.headElement=e.openElements.current,e.insertionMode=E.IN_HEAD,e._processToken(t)}function ke(e,t){switch(t.tagID){case s.HTML:{Te(e,t);break}case s.BASE:case s.BASEFONT:case s.BGSOUND:case s.LINK:case s.META:{e._appendElement(t,N.HTML),t.ackSelfClosing=!0;break}case s.TITLE:{e._switchToTextParsing(t,Ne.RCDATA);break}case s.NOSCRIPT:{e.options.scriptingEnabled?e._switchToTextParsing(t,Ne.RAWTEXT):(e._insertElement(t,N.HTML),e.insertionMode=E.IN_HEAD_NO_SCRIPT);break}case s.NOFRAMES:case s.STYLE:{e._switchToTextParsing(t,Ne.RAWTEXT);break}case s.SCRIPT:{e._switchToTextParsing(t,Ne.SCRIPT_DATA);break}case s.TEMPLATE:{e._insertTemplate(t),e.activeFormattingElements.insertMarker(),e.framesetOk=!1,e.insertionMode=E.IN_TEMPLATE,e.tmplInsertionModeStack.unshift(E.IN_TEMPLATE);break}case s.HEAD:{e._err(t,g.misplacedStartTagForHeadElement);break}default:Ht(e,t)}}function Yl(e,t){switch(t.tagID){case s.HEAD:{e.openElements.pop(),e.insertionMode=E.AFTER_HEAD;break}case s.BODY:case s.BR:case s.HTML:{Ht(e,t);break}case s.TEMPLATE:{ot(e,t);break}default:e._err(t,g.endTagWithoutMatchingOpenElement)}}function ot(e,t){e.openElements.tmplCount>0?(e.openElements.generateImpliedEndTagsThoroughly(),e.openElements.currentTagId!==s.TEMPLATE&&e._err(t,g.closingOfElementWithOpenChildElements),e.openElements.popUntilTagNamePopped(s.TEMPLATE),e.activeFormattingElements.clearToLastMarker(),e.tmplInsertionModeStack.shift(),e._resetInsertionMode()):e._err(t,g.endTagWithoutMatchingOpenElement)}function Ht(e,t){e.openElements.pop(),e.insertionMode=E.AFTER_HEAD,e._processToken(t)}function ql(e,t){switch(t.tagID){case s.HTML:{Te(e,t);break}case s.BASEFONT:case s.BGSOUND:case s.HEAD:case s.LINK:case s.META:case s.NOFRAMES:case s.STYLE:{ke(e,t);break}case s.NOSCRIPT:{e._err(t,g.nestedNoscriptInHead);break}default:Vt(e,t)}}function $l(e,t){switch(t.tagID){case s.NOSCRIPT:{e.openElements.pop(),e.insertionMode=E.IN_HEAD;break}case s.BR:{Vt(e,t);break}default:e._err(t,g.endTagWithoutMatchingOpenElement)}}function Vt(e,t){const a=t.type===$.EOF?g.openElementsLeftAfterEof:g.disallowedContentInNoscriptInHead;e._err(t,a),e.openElements.pop(),e.insertionMode=E.IN_HEAD,e._processToken(t)}function Wl(e,t){switch(t.tagID){case s.HTML:{Te(e,t);break}case s.BODY:{e._insertElement(t,N.HTML),e.framesetOk=!1,e.insertionMode=E.IN_BODY;break}case s.FRAMESET:{e._insertElement(t,N.HTML),e.insertionMode=E.IN_FRAMESET;break}case s.BASE:case s.BASEFONT:case s.BGSOUND:case s.LINK:case s.META:case s.NOFRAMES:case s.SCRIPT:case s.STYLE:case s.TEMPLATE:case s.TITLE:{e._err(t,g.abandonedHeadElementChild),e.openElements.push(e.headElement,s.HEAD),ke(e,t),e.openElements.remove(e.headElement);break}case s.HEAD:{e._err(t,g.misplacedStartTagForHeadElement);break}default:Yt(e,t)}}function Gl(e,t){switch(t.tagID){case s.BODY:case s.HTML:case s.BR:{Yt(e,t);break}case s.TEMPLATE:{ot(e,t);break}default:e._err(t,g.endTagWithoutMatchingOpenElement)}}function Yt(e,t){e._insertFakeElement(b.BODY,s.BODY),e.insertionMode=E.IN_BODY,_a(e,t)}function _a(e,t){switch(t.type){case $.CHARACTER:{Es(e,t);break}case $.WHITESPACE_CHARACTER:{ms(e,t);break}case $.COMMENT:{An(e,t);break}case $.START_TAG:{Te(e,t);break}case $.END_TAG:{Aa(e,t);break}case $.EOF:{As(e,t);break}}}function ms(e,t){e._reconstructActiveFormattingElements(),e._insertCharacters(t)}function Es(e,t){e._reconstructActiveFormattingElements(),e._insertCharacters(t),e.framesetOk=!1}function Xl(e,t){e.openElements.tmplCount===0&&e.treeAdapter.adoptAttributes(e.openElements.items[0],t.attrs)}function Ql(e,t){const a=e.openElements.tryPeekProperlyNestedBodyElement();a&&e.openElements.tmplCount===0&&(e.framesetOk=!1,e.treeAdapter.adoptAttributes(a,t.attrs))}function jl(e,t){const a=e.openElements.tryPeekProperlyNestedBodyElement();e.framesetOk&&a&&(e.treeAdapter.detachNode(a),e.openElements.popAllUpToHtmlElement(),e._insertElement(t,N.HTML),e.insertionMode=E.IN_FRAMESET)}function zl(e,t){e.openElements.hasInButtonScope(s.P)&&e._closePElement(),e._insertElement(t,N.HTML)}function Kl(e,t){e.openElements.hasInButtonScope(s.P)&&e._closePElement(),Tn.has(e.openElements.currentTagId)&&e.openElements.pop(),e._insertElement(t,N.HTML)}function Zl(e,t){e.openElements.hasInButtonScope(s.P)&&e._closePElement(),e._insertElement(t,N.HTML),e.skipNextNewLine=!0,e.framesetOk=!1}function Jl(e,t){const a=e.openElements.tmplCount>0;(!e.formElement||a)&&(e.openElements.hasInButtonScope(s.P)&&e._closePElement(),e._insertElement(t,N.HTML),a||(e.formElement=e.openElements.current))}function e0(e,t){e.framesetOk=!1;const a=t.tagID;for(let n=e.openElements.stackTop;n>=0;n--){const i=e.openElements.tagIDs[n];if(a===s.LI&&i===s.LI||(a===s.DD||a===s.DT)&&(i===s.DD||i===s.DT)){e.openElements.generateImpliedEndTagsWithExclusion(i),e.openElements.popUntilTagNamePopped(i);break}if(i!==s.ADDRESS&&i!==s.DIV&&i!==s.P&&e._isSpecialElement(e.openElements.items[n],i))break}e.openElements.hasInButtonScope(s.P)&&e._closePElement(),e._insertElement(t,N.HTML)}function t0(e,t){e.openElements.hasInButtonScope(s.P)&&e._closePElement(),e._insertElement(t,N.HTML),e.tokenizer.state=Ne.PLAINTEXT}function a0(e,t){e.openElements.hasInScope(s.BUTTON)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(s.BUTTON)),e._reconstructActiveFormattingElements(),e._insertElement(t,N.HTML),e.framesetOk=!1}function n0(e,t){const a=e.activeFormattingElements.getElementEntryInScopeWithTagName(b.A);a&&(_n(e,t),e.openElements.remove(a.element),e.activeFormattingElements.removeEntry(a)),e._reconstructActiveFormattingElements(),e._insertElement(t,N.HTML),e.activeFormattingElements.pushElement(e.openElements.current,t)}function i0(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,N.HTML),e.activeFormattingElements.pushElement(e.openElements.current,t)}function s0(e,t){e._reconstructActiveFormattingElements(),e.openElements.hasInScope(s.NOBR)&&(_n(e,t),e._reconstructActiveFormattingElements()),e._insertElement(t,N.HTML),e.activeFormattingElements.pushElement(e.openElements.current,t)}function r0(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,N.HTML),e.activeFormattingElements.insertMarker(),e.framesetOk=!1}function u0(e,t){e.treeAdapter.getDocumentMode(e.document)!==Se.QUIRKS&&e.openElements.hasInButtonScope(s.P)&&e._closePElement(),e._insertElement(t,N.HTML),e.framesetOk=!1,e.insertionMode=E.IN_TABLE}function ps(e,t){e._reconstructActiveFormattingElements(),e._appendElement(t,N.HTML),e.framesetOk=!1,t.ackSelfClosing=!0}function Ts(e){const t=ji(e,ut.TYPE);return t!=null&&t.toLowerCase()===Sl}function o0(e,t){e._reconstructActiveFormattingElements(),e._appendElement(t,N.HTML),Ts(t)||(e.framesetOk=!1),t.ackSelfClosing=!0}function c0(e,t){e._appendElement(t,N.HTML),t.ackSelfClosing=!0}function l0(e,t){e.openElements.hasInButtonScope(s.P)&&e._closePElement(),e._appendElement(t,N.HTML),e.framesetOk=!1,t.ackSelfClosing=!0}function d0(e,t){t.tagName=b.IMG,t.tagID=s.IMG,ps(e,t)}function h0(e,t){e._insertElement(t,N.HTML),e.skipNextNewLine=!0,e.tokenizer.state=Ne.RCDATA,e.originalInsertionMode=e.insertionMode,e.framesetOk=!1,e.insertionMode=E.TEXT}function f0(e,t){e.openElements.hasInButtonScope(s.P)&&e._closePElement(),e._reconstructActiveFormattingElements(),e.framesetOk=!1,e._switchToTextParsing(t,Ne.RAWTEXT)}function m0(e,t){e.framesetOk=!1,e._switchToTextParsing(t,Ne.RAWTEXT)}function bs(e,t){e._switchToTextParsing(t,Ne.RAWTEXT)}function E0(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,N.HTML),e.framesetOk=!1,e.insertionMode=e.insertionMode===E.IN_TABLE||e.insertionMode===E.IN_CAPTION||e.insertionMode===E.IN_TABLE_BODY||e.insertionMode===E.IN_ROW||e.insertionMode===E.IN_CELL?E.IN_SELECT_IN_TABLE:E.IN_SELECT}function p0(e,t){e.openElements.currentTagId===s.OPTION&&e.openElements.pop(),e._reconstructActiveFormattingElements(),e._insertElement(t,N.HTML)}function T0(e,t){e.openElements.hasInScope(s.RUBY)&&e.openElements.generateImpliedEndTags(),e._insertElement(t,N.HTML)}function b0(e,t){e.openElements.hasInScope(s.RUBY)&&e.openElements.generateImpliedEndTagsWithExclusion(s.RTC),e._insertElement(t,N.HTML)}function g0(e,t){e._reconstructActiveFormattingElements(),cs(t),gn(t),t.selfClosing?e._appendElement(t,N.MATHML):e._insertElement(t,N.MATHML),t.ackSelfClosing=!0}function _0(e,t){e._reconstructActiveFormattingElements(),ls(t),gn(t),t.selfClosing?e._appendElement(t,N.SVG):e._insertElement(t,N.SVG),t.ackSelfClosing=!0}function gs(e,t){e._reconstructActiveFormattingElements(),e._insertElement(t,N.HTML)}function Te(e,t){switch(t.tagID){case s.I:case s.S:case s.B:case s.U:case s.EM:case s.TT:case s.BIG:case s.CODE:case s.FONT:case s.SMALL:case s.STRIKE:case s.STRONG:{i0(e,t);break}case s.A:{n0(e,t);break}case s.H1:case s.H2:case s.H3:case s.H4:case s.H5:case s.H6:{Kl(e,t);break}case s.P:case s.DL:case s.OL:case s.UL:case s.DIV:case s.DIR:case s.NAV:case s.MAIN:case s.MENU:case s.ASIDE:case s.CENTER:case s.FIGURE:case s.FOOTER:case s.HEADER:case s.HGROUP:case s.DIALOG:case s.DETAILS:case s.ADDRESS:case s.ARTICLE:case s.SEARCH:case s.SECTION:case s.SUMMARY:case s.FIELDSET:case s.BLOCKQUOTE:case s.FIGCAPTION:{zl(e,t);break}case s.LI:case s.DD:case s.DT:{e0(e,t);break}case s.BR:case s.IMG:case s.WBR:case s.AREA:case s.EMBED:case s.KEYGEN:{ps(e,t);break}case s.HR:{l0(e,t);break}case s.RB:case s.RTC:{T0(e,t);break}case s.RT:case s.RP:{b0(e,t);break}case s.PRE:case s.LISTING:{Zl(e,t);break}case s.XMP:{f0(e,t);break}case s.SVG:{_0(e,t);break}case s.HTML:{Xl(e,t);break}case s.BASE:case s.LINK:case s.META:case s.STYLE:case s.TITLE:case s.SCRIPT:case s.BGSOUND:case s.BASEFONT:case s.TEMPLATE:{ke(e,t);break}case s.BODY:{Ql(e,t);break}case s.FORM:{Jl(e,t);break}case s.NOBR:{s0(e,t);break}case s.MATH:{g0(e,t);break}case s.TABLE:{u0(e,t);break}case s.INPUT:{o0(e,t);break}case s.PARAM:case s.TRACK:case s.SOURCE:{c0(e,t);break}case s.IMAGE:{d0(e,t);break}case s.BUTTON:{a0(e,t);break}case s.APPLET:case s.OBJECT:case s.MARQUEE:{r0(e,t);break}case s.IFRAME:{m0(e,t);break}case s.SELECT:{E0(e,t);break}case s.OPTION:case s.OPTGROUP:{p0(e,t);break}case s.NOEMBED:case s.NOFRAMES:{bs(e,t);break}case s.FRAMESET:{jl(e,t);break}case s.TEXTAREA:{h0(e,t);break}case s.NOSCRIPT:{e.options.scriptingEnabled?bs(e,t):gs(e,t);break}case s.PLAINTEXT:{t0(e,t);break}case s.COL:case s.TH:case s.TD:case s.TR:case s.HEAD:case s.FRAME:case s.TBODY:case s.TFOOT:case s.THEAD:case s.CAPTION:case s.COLGROUP:break;default:gs(e,t)}}function A0(e,t){if(e.openElements.hasInScope(s.BODY)&&(e.insertionMode=E.AFTER_BODY,e.options.sourceCodeLocationInfo)){const a=e.openElements.tryPeekProperlyNestedBodyElement();a&&e._setEndLocation(a,t)}}function N0(e,t){e.openElements.hasInScope(s.BODY)&&(e.insertionMode=E.AFTER_BODY,Ls(e,t))}function C0(e,t){const a=t.tagID;e.openElements.hasInScope(a)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(a))}function I0(e){const t=e.openElements.tmplCount>0,{formElement:a}=e;t||(e.formElement=null),(a||t)&&e.openElements.hasInScope(s.FORM)&&(e.openElements.generateImpliedEndTags(),t?e.openElements.popUntilTagNamePopped(s.FORM):a&&e.openElements.remove(a))}function S0(e){e.openElements.hasInButtonScope(s.P)||e._insertFakeElement(b.P,s.P),e._closePElement()}function x0(e){e.openElements.hasInListItemScope(s.LI)&&(e.openElements.generateImpliedEndTagsWithExclusion(s.LI),e.openElements.popUntilTagNamePopped(s.LI))}function O0(e,t){const a=t.tagID;e.openElements.hasInScope(a)&&(e.openElements.generateImpliedEndTagsWithExclusion(a),e.openElements.popUntilTagNamePopped(a))}function D0(e){e.openElements.hasNumberedHeaderInScope()&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilNumberedHeaderPopped())}function L0(e,t){const a=t.tagID;e.openElements.hasInScope(a)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(a),e.activeFormattingElements.clearToLastMarker())}function y0(e){e._reconstructActiveFormattingElements(),e._insertFakeElement(b.BR,s.BR),e.openElements.pop(),e.framesetOk=!1}function _s(e,t){const a=t.tagName,n=t.tagID;for(let i=e.openElements.stackTop;i>0;i--){const r=e.openElements.items[i],u=e.openElements.tagIDs[i];if(n===u&&(n!==s.UNKNOWN||e.treeAdapter.getTagName(r)===a)){e.openElements.generateImpliedEndTagsWithExclusion(n),e.openElements.stackTop>=i&&e.openElements.shortenToLength(i);break}if(e._isSpecialElement(r,u))break}}function Aa(e,t){switch(t.tagID){case s.A:case s.B:case s.I:case s.S:case s.U:case s.EM:case s.TT:case s.BIG:case s.CODE:case s.FONT:case s.NOBR:case s.SMALL:case s.STRIKE:case s.STRONG:{_n(e,t);break}case s.P:{S0(e);break}case s.DL:case s.UL:case s.OL:case s.DIR:case s.DIV:case s.NAV:case s.PRE:case s.MAIN:case s.MENU:case s.ASIDE:case s.BUTTON:case s.CENTER:case s.FIGURE:case s.FOOTER:case s.HEADER:case s.HGROUP:case s.DIALOG:case s.ADDRESS:case s.ARTICLE:case s.DETAILS:case s.SEARCH:case s.SECTION:case s.SUMMARY:case s.LISTING:case s.FIELDSET:case s.BLOCKQUOTE:case s.FIGCAPTION:{C0(e,t);break}case s.LI:{x0(e);break}case s.DD:case s.DT:{O0(e,t);break}case s.H1:case s.H2:case s.H3:case s.H4:case s.H5:case s.H6:{D0(e);break}case s.BR:{y0(e);break}case s.BODY:{A0(e,t);break}case s.HTML:{N0(e,t);break}case s.FORM:{I0(e);break}case s.APPLET:case s.OBJECT:case s.MARQUEE:{L0(e,t);break}case s.TEMPLATE:{ot(e,t);break}default:_s(e,t)}}function As(e,t){e.tmplInsertionModeStack.length>0?Ds(e,t):Nn(e,t)}function R0(e,t){var a;t.tagID===s.SCRIPT&&((a=e.scriptHandler)===null||a===void 0||a.call(e,e.openElements.current)),e.openElements.pop(),e.insertionMode=e.originalInsertionMode}function k0(e,t){e._err(t,g.eofInElementThatCanContainOnlyText),e.openElements.pop(),e.insertionMode=e.originalInsertionMode,e.onEof(t)}function Cn(e,t){if(ds.has(e.openElements.currentTagId))switch(e.pendingCharacterTokens.length=0,e.hasNonWhitespacePendingCharacterToken=!1,e.originalInsertionMode=e.insertionMode,e.insertionMode=E.IN_TABLE_TEXT,t.type){case $.CHARACTER:{Cs(e,t);break}case $.WHITESPACE_CHARACTER:{Ns(e,t);break}}else $t(e,t)}function M0(e,t){e.openElements.clearBackToTableContext(),e.activeFormattingElements.insertMarker(),e._insertElement(t,N.HTML),e.insertionMode=E.IN_CAPTION}function P0(e,t){e.openElements.clearBackToTableContext(),e._insertElement(t,N.HTML),e.insertionMode=E.IN_COLUMN_GROUP}function v0(e,t){e.openElements.clearBackToTableContext(),e._insertFakeElement(b.COLGROUP,s.COLGROUP),e.insertionMode=E.IN_COLUMN_GROUP,In(e,t)}function B0(e,t){e.openElements.clearBackToTableContext(),e._insertElement(t,N.HTML),e.insertionMode=E.IN_TABLE_BODY}function w0(e,t){e.openElements.clearBackToTableContext(),e._insertFakeElement(b.TBODY,s.TBODY),e.insertionMode=E.IN_TABLE_BODY,Ca(e,t)}function U0(e,t){e.openElements.hasInTableScope(s.TABLE)&&(e.openElements.popUntilTagNamePopped(s.TABLE),e._resetInsertionMode(),e._processStartTag(t))}function F0(e,t){Ts(t)?e._appendElement(t,N.HTML):$t(e,t),t.ackSelfClosing=!0}function H0(e,t){!e.formElement&&e.openElements.tmplCount===0&&(e._insertElement(t,N.HTML),e.formElement=e.openElements.current,e.openElements.pop())}function bt(e,t){switch(t.tagID){case s.TD:case s.TH:case s.TR:{w0(e,t);break}case s.STYLE:case s.SCRIPT:case s.TEMPLATE:{ke(e,t);break}case s.COL:{v0(e,t);break}case s.FORM:{H0(e,t);break}case s.TABLE:{U0(e,t);break}case s.TBODY:case s.TFOOT:case s.THEAD:{B0(e,t);break}case s.INPUT:{F0(e,t);break}case s.CAPTION:{M0(e,t);break}case s.COLGROUP:{P0(e,t);break}default:$t(e,t)}}function qt(e,t){switch(t.tagID){case s.TABLE:{e.openElements.hasInTableScope(s.TABLE)&&(e.openElements.popUntilTagNamePopped(s.TABLE),e._resetInsertionMode());break}case s.TEMPLATE:{ot(e,t);break}case s.BODY:case s.CAPTION:case s.COL:case s.COLGROUP:case s.HTML:case s.TBODY:case s.TD:case s.TFOOT:case s.TH:case s.THEAD:case s.TR:break;default:$t(e,t)}}function $t(e,t){const a=e.fosterParentingEnabled;e.fosterParentingEnabled=!0,_a(e,t),e.fosterParentingEnabled=a}function Ns(e,t){e.pendingCharacterTokens.push(t)}function Cs(e,t){e.pendingCharacterTokens.push(t),e.hasNonWhitespacePendingCharacterToken=!0}function Wt(e,t){let a=0;if(e.hasNonWhitespacePendingCharacterToken)for(;a<e.pendingCharacterTokens.length;a++)$t(e,e.pendingCharacterTokens[a]);else for(;a<e.pendingCharacterTokens.length;a++)e._insertCharacters(e.pendingCharacterTokens[a]);e.insertionMode=e.originalInsertionMode,e._processToken(t)}const Is=new Set([s.CAPTION,s.COL,s.COLGROUP,s.TBODY,s.TD,s.TFOOT,s.TH,s.THEAD,s.TR]);function V0(e,t){const a=t.tagID;Is.has(a)?e.openElements.hasInTableScope(s.CAPTION)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(s.CAPTION),e.activeFormattingElements.clearToLastMarker(),e.insertionMode=E.IN_TABLE,bt(e,t)):Te(e,t)}function Y0(e,t){const a=t.tagID;switch(a){case s.CAPTION:case s.TABLE:{e.openElements.hasInTableScope(s.CAPTION)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(s.CAPTION),e.activeFormattingElements.clearToLastMarker(),e.insertionMode=E.IN_TABLE,a===s.TABLE&&qt(e,t));break}case s.BODY:case s.COL:case s.COLGROUP:case s.HTML:case s.TBODY:case s.TD:case s.TFOOT:case s.TH:case s.THEAD:case s.TR:break;default:Aa(e,t)}}function In(e,t){switch(t.tagID){case s.HTML:{Te(e,t);break}case s.COL:{e._appendElement(t,N.HTML),t.ackSelfClosing=!0;break}case s.TEMPLATE:{ke(e,t);break}default:Na(e,t)}}function q0(e,t){switch(t.tagID){case s.COLGROUP:{e.openElements.currentTagId===s.COLGROUP&&(e.openElements.pop(),e.insertionMode=E.IN_TABLE);break}case s.TEMPLATE:{ot(e,t);break}case s.COL:break;default:Na(e,t)}}function Na(e,t){e.openElements.currentTagId===s.COLGROUP&&(e.openElements.pop(),e.insertionMode=E.IN_TABLE,e._processToken(t))}function Ca(e,t){switch(t.tagID){case s.TR:{e.openElements.clearBackToTableBodyContext(),e._insertElement(t,N.HTML),e.insertionMode=E.IN_ROW;break}case s.TH:case s.TD:{e.openElements.clearBackToTableBodyContext(),e._insertFakeElement(b.TR,s.TR),e.insertionMode=E.IN_ROW,Ia(e,t);break}case s.CAPTION:case s.COL:case s.COLGROUP:case s.TBODY:case s.TFOOT:case s.THEAD:{e.openElements.hasTableBodyContextInTableScope()&&(e.openElements.clearBackToTableBodyContext(),e.openElements.pop(),e.insertionMode=E.IN_TABLE,bt(e,t));break}default:bt(e,t)}}function Sn(e,t){const a=t.tagID;switch(t.tagID){case s.TBODY:case s.TFOOT:case s.THEAD:{e.openElements.hasInTableScope(a)&&(e.openElements.clearBackToTableBodyContext(),e.openElements.pop(),e.insertionMode=E.IN_TABLE);break}case s.TABLE:{e.openElements.hasTableBodyContextInTableScope()&&(e.openElements.clearBackToTableBodyContext(),e.openElements.pop(),e.insertionMode=E.IN_TABLE,qt(e,t));break}case s.BODY:case s.CAPTION:case s.COL:case s.COLGROUP:case s.HTML:case s.TD:case s.TH:case s.TR:break;default:qt(e,t)}}function Ia(e,t){switch(t.tagID){case s.TH:case s.TD:{e.openElements.clearBackToTableRowContext(),e._insertElement(t,N.HTML),e.insertionMode=E.IN_CELL,e.activeFormattingElements.insertMarker();break}case s.CAPTION:case s.COL:case s.COLGROUP:case s.TBODY:case s.TFOOT:case s.THEAD:case s.TR:{e.openElements.hasInTableScope(s.TR)&&(e.openElements.clearBackToTableRowContext(),e.openElements.pop(),e.insertionMode=E.IN_TABLE_BODY,Ca(e,t));break}default:bt(e,t)}}function Ss(e,t){switch(t.tagID){case s.TR:{e.openElements.hasInTableScope(s.TR)&&(e.openElements.clearBackToTableRowContext(),e.openElements.pop(),e.insertionMode=E.IN_TABLE_BODY);break}case s.TABLE:{e.openElements.hasInTableScope(s.TR)&&(e.openElements.clearBackToTableRowContext(),e.openElements.pop(),e.insertionMode=E.IN_TABLE_BODY,Sn(e,t));break}case s.TBODY:case s.TFOOT:case s.THEAD:{(e.openElements.hasInTableScope(t.tagID)||e.openElements.hasInTableScope(s.TR))&&(e.openElements.clearBackToTableRowContext(),e.openElements.pop(),e.insertionMode=E.IN_TABLE_BODY,Sn(e,t));break}case s.BODY:case s.CAPTION:case s.COL:case s.COLGROUP:case s.HTML:case s.TD:case s.TH:break;default:qt(e,t)}}function $0(e,t){const a=t.tagID;Is.has(a)?(e.openElements.hasInTableScope(s.TD)||e.openElements.hasInTableScope(s.TH))&&(e._closeTableCell(),Ia(e,t)):Te(e,t)}function W0(e,t){const a=t.tagID;switch(a){case s.TD:case s.TH:{e.openElements.hasInTableScope(a)&&(e.openElements.generateImpliedEndTags(),e.openElements.popUntilTagNamePopped(a),e.activeFormattingElements.clearToLastMarker(),e.insertionMode=E.IN_ROW);break}case s.TABLE:case s.TBODY:case s.TFOOT:case s.THEAD:case s.TR:{e.openElements.hasInTableScope(a)&&(e._closeTableCell(),Ss(e,t));break}case s.BODY:case s.CAPTION:case s.COL:case s.COLGROUP:case s.HTML:break;default:Aa(e,t)}}function xs(e,t){switch(t.tagID){case s.HTML:{Te(e,t);break}case s.OPTION:{e.openElements.currentTagId===s.OPTION&&e.openElements.pop(),e._insertElement(t,N.HTML);break}case s.OPTGROUP:{e.openElements.currentTagId===s.OPTION&&e.openElements.pop(),e.openElements.currentTagId===s.OPTGROUP&&e.openElements.pop(),e._insertElement(t,N.HTML);break}case s.HR:{e.openElements.currentTagId===s.OPTION&&e.openElements.pop(),e.openElements.currentTagId===s.OPTGROUP&&e.openElements.pop(),e._appendElement(t,N.HTML),t.ackSelfClosing=!0;break}case s.INPUT:case s.KEYGEN:case s.TEXTAREA:case s.SELECT:{e.openElements.hasInSelectScope(s.SELECT)&&(e.openElements.popUntilTagNamePopped(s.SELECT),e._resetInsertionMode(),t.tagID!==s.SELECT&&e._processStartTag(t));break}case s.SCRIPT:case s.TEMPLATE:{ke(e,t);break}}}function Os(e,t){switch(t.tagID){case s.OPTGROUP:{e.openElements.stackTop>0&&e.openElements.currentTagId===s.OPTION&&e.openElements.tagIDs[e.openElements.stackTop-1]===s.OPTGROUP&&e.openElements.pop(),e.openElements.currentTagId===s.OPTGROUP&&e.openElements.pop();break}case s.OPTION:{e.openElements.currentTagId===s.OPTION&&e.openElements.pop();break}case s.SELECT:{e.openElements.hasInSelectScope(s.SELECT)&&(e.openElements.popUntilTagNamePopped(s.SELECT),e._resetInsertionMode());break}case s.TEMPLATE:{ot(e,t);break}}}function G0(e,t){const a=t.tagID;a===s.CAPTION||a===s.TABLE||a===s.TBODY||a===s.TFOOT||a===s.THEAD||a===s.TR||a===s.TD||a===s.TH?(e.openElements.popUntilTagNamePopped(s.SELECT),e._resetInsertionMode(),e._processStartTag(t)):xs(e,t)}function X0(e,t){const a=t.tagID;a===s.CAPTION||a===s.TABLE||a===s.TBODY||a===s.TFOOT||a===s.THEAD||a===s.TR||a===s.TD||a===s.TH?e.openElements.hasInTableScope(a)&&(e.openElements.popUntilTagNamePopped(s.SELECT),e._resetInsertionMode(),e.onEndTag(t)):Os(e,t)}function Q0(e,t){switch(t.tagID){case s.BASE:case s.BASEFONT:case s.BGSOUND:case s.LINK:case s.META:case s.NOFRAMES:case s.SCRIPT:case s.STYLE:case s.TEMPLATE:case s.TITLE:{ke(e,t);break}case s.CAPTION:case s.COLGROUP:case s.TBODY:case s.TFOOT:case s.THEAD:{e.tmplInsertionModeStack[0]=E.IN_TABLE,e.insertionMode=E.IN_TABLE,bt(e,t);break}case s.COL:{e.tmplInsertionModeStack[0]=E.IN_COLUMN_GROUP,e.insertionMode=E.IN_COLUMN_GROUP,In(e,t);break}case s.TR:{e.tmplInsertionModeStack[0]=E.IN_TABLE_BODY,e.insertionMode=E.IN_TABLE_BODY,Ca(e,t);break}case s.TD:case s.TH:{e.tmplInsertionModeStack[0]=E.IN_ROW,e.insertionMode=E.IN_ROW,Ia(e,t);break}default:e.tmplInsertionModeStack[0]=E.IN_BODY,e.insertionMode=E.IN_BODY,Te(e,t)}}function j0(e,t){t.tagID===s.TEMPLATE&&ot(e,t)}function Ds(e,t){e.openElements.tmplCount>0?(e.openElements.popUntilTagNamePopped(s.TEMPLATE),e.activeFormattingElements.clearToLastMarker(),e.tmplInsertionModeStack.shift(),e._resetInsertionMode(),e.onEof(t)):Nn(e,t)}function z0(e,t){t.tagID===s.HTML?Te(e,t):Sa(e,t)}function Ls(e,t){var a;if(t.tagID===s.HTML){if(e.fragmentContext||(e.insertionMode=E.AFTER_AFTER_BODY),e.options.sourceCodeLocationInfo&&e.openElements.tagIDs[0]===s.HTML){e._setEndLocation(e.openElements.items[0],t);const n=e.openElements.items[1];n&&!(!((a=e.treeAdapter.getNodeSourceCodeLocation(n))===null||a===void 0)&&a.endTag)&&e._setEndLocation(n,t)}}else Sa(e,t)}function Sa(e,t){e.insertionMode=E.IN_BODY,_a(e,t)}function K0(e,t){switch(t.tagID){case s.HTML:{Te(e,t);break}case s.FRAMESET:{e._insertElement(t,N.HTML);break}case s.FRAME:{e._appendElement(t,N.HTML),t.ackSelfClosing=!0;break}case s.NOFRAMES:{ke(e,t);break}}}function Z0(e,t){t.tagID===s.FRAMESET&&!e.openElements.isRootHtmlElementCurrent()&&(e.openElements.pop(),!e.fragmentContext&&e.openElements.currentTagId!==s.FRAMESET&&(e.insertionMode=E.AFTER_FRAMESET))}function J0(e,t){switch(t.tagID){case s.HTML:{Te(e,t);break}case s.NOFRAMES:{ke(e,t);break}}}function ed(e,t){t.tagID===s.HTML&&(e.insertionMode=E.AFTER_AFTER_FRAMESET)}function td(e,t){t.tagID===s.HTML?Te(e,t):xa(e,t)}function xa(e,t){e.insertionMode=E.IN_BODY,_a(e,t)}function ad(e,t){switch(t.tagID){case s.HTML:{Te(e,t);break}case s.NOFRAMES:{ke(e,t);break}}}function nd(e,t){t.chars=Z,e._insertCharacters(t)}function id(e,t){e._insertCharacters(t),e.framesetOk=!1}function ys(e){for(;e.treeAdapter.getNamespaceURI(e.openElements.current)!==N.HTML&&!e._isIntegrationPoint(e.openElements.currentTagId,e.openElements.current);)e.openElements.pop()}function sd(e,t){if(_l(t))ys(e),e._startTagOutsideForeignContent(t);else{const a=e._getAdjustedCurrentElement(),n=e.treeAdapter.getNamespaceURI(a);n===N.MATHML?cs(t):n===N.SVG&&(Al(t),ls(t)),gn(t),t.selfClosing?e._appendElement(t,n):e._insertElement(t,n),t.ackSelfClosing=!0}}function rd(e,t){if(t.tagID===s.P||t.tagID===s.BR){ys(e),e._endTagOutsideForeignContent(t);return}for(let a=e.openElements.stackTop;a>0;a--){const n=e.openElements.items[a];if(e.treeAdapter.getNamespaceURI(n)===N.HTML){e._endTagOutsideForeignContent(t);break}const i=e.treeAdapter.getTagName(n);if(i.toLowerCase()===t.tagName){t.tagName=i,e.openElements.shortenToLength(a);break}}}const ud=new Set([b.AREA,b.BASE,b.BASEFONT,b.BGSOUND,b.BR,b.COL,b.EMBED,b.FRAME,b.HR,b.IMG,b.INPUT,b.KEYGEN,b.LINK,b.META,b.PARAM,b.SOURCE,b.TRACK,b.WBR]);function od(e,t){return t.treeAdapter.isElementNode(e)&&t.treeAdapter.getNamespaceURI(e)===N.HTML&&ud.has(t.treeAdapter.getTagName(e))}const cd={treeAdapter:Ye,scriptingEnabled:!0};function ld(e,t){const a={...cd,...t};return Rs(e,a)}function dd(e,t){let a="";const n=t.treeAdapter.isElementNode(e)&&t.treeAdapter.getTagName(e)===b.TEMPLATE&&t.treeAdapter.getNamespaceURI(e)===N.HTML?t.treeAdapter.getTemplateContent(e):e,i=t.treeAdapter.getChildNodes(n);if(i)for(const r of i)a+=Rs(r,t);return a}function Rs(e,t){return t.treeAdapter.isElementNode(e)?hd(e,t):t.treeAdapter.isTextNode(e)?md(e,t):t.treeAdapter.isCommentNode(e)?Ed(e,t):t.treeAdapter.isDocumentTypeNode(e)?pd(e,t):""}function hd(e,t){const a=t.treeAdapter.getTagName(e);return`<${a}${fd(e,t)}>${od(e,t)?"":`${dd(e,t)}</${a}>`}`}function fd(e,{treeAdapter:t}){let a="";for(const n of t.getAttrList(e)){if(a+=" ",n.namespace)switch(n.namespace){case N.XML:{a+=`xml:${n.name}`;break}case N.XMLNS:{n.name!=="xmlns"&&(a+="xmlns:"),a+=n.name;break}case N.XLINK:{a+=`xlink:${n.name}`;break}default:a+=`${n.prefix}:${n.name}`}else a+=n.name;a+=`="${Zn(n.value)}"`}return a}function md(e,t){const{treeAdapter:a}=t,n=a.getTextNodeContent(e),i=a.getParentNode(e),r=i&&a.isElementNode(i)&&a.getTagName(i);return r&&a.getNamespaceURI(i)===N.HTML&&Qc(r,t.scriptingEnabled)?n:Jn(n)}function Ed(e,{treeAdapter:t}){return`<!--${t.getCommentNodeContent(e)}-->`}function pd(e,{treeAdapter:t}){return`<!DOCTYPE ${t.getDocumentTypeNodeName(e)}>`}function Td(e,t){return fs.parse(e,t)}function bd(e,t,a){typeof e=="string"&&(a=t,t=e,e=null);const n=fs.getFragmentParser(e,a);return n.tokenizer.write(t,!0),n.getFragment()}function ks(e){const t=e.includes('"')?"'":'"';return t+e+t}function gd(e,t,a){let n="!DOCTYPE ";return e&&(n+=e),t?n+=` PUBLIC ${ks(t)}`:a&&(n+=" SYSTEM"),a&&(n+=` ${ks(a)}`),n}const ze={isCommentNode:ea,isElementNode:v,isTextNode:Be,createDocument(){const e=new at([]);return e["x-mode"]=Se.NO_QUIRKS,e},createDocumentFragment(){return new at([])},createElement(e,t,a){const n=Object.create(null),i=Object.create(null),r=Object.create(null);for(let o=0;o<a.length;o++){const l=a[o].name;n[l]=a[o].value,i[l]=a[o].namespace,r[l]=a[o].prefix}const u=new wa(e,n,[]);return u.namespace=t,u["x-attribsNamespace"]=i,u["x-attribsPrefix"]=r,u},createCommentNode(e){return new Pa(e)},createTextNode(e){return new xt(e)},appendChild(e,t){const a=e.children[e.children.length-1];a&&(a.next=t,t.prev=a),e.children.push(t),t.parent=e},insertBefore(e,t,a){const n=e.children.indexOf(a),{prev:i}=a;i&&(i.next=t,t.prev=i),a.prev=t,t.next=a,e.children.splice(n,0,t),t.parent=e},setTemplateContent(e,t){ze.appendChild(e,t)},getTemplateContent(e){return e.children[0]},setDocumentType(e,t,a,n){const i=gd(t,a,n);let r=e.children.find(u=>Ua(u)&&u.name==="!doctype");r?r.data=i??null:(r=new va("!doctype",i),ze.appendChild(e,r)),r["x-name"]=t,r["x-publicId"]=a,r["x-systemId"]=n},setDocumentMode(e,t){e["x-mode"]=t},getDocumentMode(e){return e["x-mode"]},detachNode(e){if(e.parent){const t=e.parent.children.indexOf(e),{prev:a,next:n}=e;e.prev=null,e.next=null,a&&(a.next=n),n&&(n.prev=a),e.parent.children.splice(t,1),e.parent=null}},insertText(e,t){const a=e.children[e.children.length-1];a&&Be(a)?a.data+=t:ze.appendChild(e,ze.createTextNode(t))},insertTextBefore(e,t,a){const n=e.children[e.children.indexOf(a)-1];n&&Be(n)?n.data+=t:ze.insertBefore(e,ze.createTextNode(t),a)},adoptAttributes(e,t){for(let a=0;a<t.length;a++){const n=t[a].name;e.attribs[n]===void 0&&(e.attribs[n]=t[a].value,e["x-attribsNamespace"][n]=t[a].namespace,e["x-attribsPrefix"][n]=t[a].prefix)}},getFirstChild(e){return e.children[0]},getChildNodes(e){return e.children},getParentNode(e){return e.parent},getAttrList(e){return e.attributes},getTagName(e){return e.name},getNamespaceURI(e){return e.namespace},getTextNodeContent(e){return e.data},getCommentNodeContent(e){return e.data},getDocumentTypeNodeName(e){var t;return(t=e["x-name"])!==null&&t!==void 0?t:""},getDocumentTypeNodePublicId(e){var t;return(t=e["x-publicId"])!==null&&t!==void 0?t:""},getDocumentTypeNodeSystemId(e){var t;return(t=e["x-systemId"])!==null&&t!==void 0?t:""},isDocumentTypeNode(e){return Ua(e)&&e.name==="!doctype"},setNodeSourceCodeLocation(e,t){t&&(e.startIndex=t.startOffset,e.endIndex=t.endOffset),e.sourceCodeLocation=t},getNodeSourceCodeLocation(e){return e.sourceCodeLocation},updateNodeSourceCodeLocation(e,t){t.endOffset!=null&&(e.endIndex=t.endOffset),e.sourceCodeLocation={...e.sourceCodeLocation,...t}}};function _d(e,t,a,n){var i;return(i=t.treeAdapter)!==null&&i!==void 0||(t.treeAdapter=ze),t.scriptingEnabled!==!1&&(t.scriptingEnabled=!0),a?Td(e,t):bd(n,e,t)}const Ad={treeAdapter:ze};function Nd(e){const t="length"in e?e:[e];for(let n=0;n<t.length;n+=1){const i=t[n];We(i)&&Array.prototype.splice.call(t,n,1,...i.children)}let a="";for(let n=0;n<t.length;n+=1){const i=t[n];a+=ld(i,Ad)}return a}var k;(function(e){e[e.Tab=9]="Tab",e[e.NewLine=10]="NewLine",e[e.FormFeed=12]="FormFeed",e[e.CarriageReturn=13]="CarriageReturn",e[e.Space=32]="Space",e[e.ExclamationMark=33]="ExclamationMark",e[e.Number=35]="Number",e[e.Amp=38]="Amp",e[e.SingleQuote=39]="SingleQuote",e[e.DoubleQuote=34]="DoubleQuote",e[e.Dash=45]="Dash",e[e.Slash=47]="Slash",e[e.Zero=48]="Zero",e[e.Nine=57]="Nine",e[e.Semi=59]="Semi",e[e.Lt=60]="Lt",e[e.Eq=61]="Eq",e[e.Gt=62]="Gt",e[e.Questionmark=63]="Questionmark",e[e.UpperA=65]="UpperA",e[e.LowerA=97]="LowerA",e[e.UpperF=70]="UpperF",e[e.LowerF=102]="LowerF",e[e.UpperZ=90]="UpperZ",e[e.LowerZ=122]="LowerZ",e[e.LowerX=120]="LowerX",e[e.OpeningSquareBracket=91]="OpeningSquareBracket"})(k||(k={}));var S;(function(e){e[e.Text=1]="Text",e[e.BeforeTagName=2]="BeforeTagName",e[e.InTagName=3]="InTagName",e[e.InSelfClosingTag=4]="InSelfClosingTag",e[e.BeforeClosingTagName=5]="BeforeClosingTagName",e[e.InClosingTagName=6]="InClosingTagName",e[e.AfterClosingTagName=7]="AfterClosingTagName",e[e.BeforeAttributeName=8]="BeforeAttributeName",e[e.InAttributeName=9]="InAttributeName",e[e.AfterAttributeName=10]="AfterAttributeName",e[e.BeforeAttributeValue=11]="BeforeAttributeValue",e[e.InAttributeValueDq=12]="InAttributeValueDq",e[e.InAttributeValueSq=13]="InAttributeValueSq",e[e.InAttributeValueNq=14]="InAttributeValueNq",e[e.BeforeDeclaration=15]="BeforeDeclaration",e[e.InDeclaration=16]="InDeclaration",e[e.InProcessingInstruction=17]="InProcessingInstruction",e[e.BeforeComment=18]="BeforeComment",e[e.CDATASequence=19]="CDATASequence",e[e.InSpecialComment=20]="InSpecialComment",e[e.InCommentLike=21]="InCommentLike",e[e.BeforeSpecialS=22]="BeforeSpecialS",e[e.BeforeSpecialT=23]="BeforeSpecialT",e[e.SpecialStartSequence=24]="SpecialStartSequence",e[e.InSpecialTag=25]="InSpecialTag",e[e.InEntity=26]="InEntity"})(S||(S={}));function qe(e){return e===k.Space||e===k.NewLine||e===k.Tab||e===k.FormFeed||e===k.CarriageReturn}function Oa(e){return e===k.Slash||e===k.Gt||qe(e)}function Cd(e){return e>=k.LowerA&&e<=k.LowerZ||e>=k.UpperA&&e<=k.UpperZ}var Ue;(function(e){e[e.NoValue=0]="NoValue",e[e.Unquoted=1]="Unquoted",e[e.Single=2]="Single",e[e.Double=3]="Double"})(Ue||(Ue={}));const fe={Cdata:new Uint8Array([67,68,65,84,65,91]),CdataEnd:new Uint8Array([93,93,62]),CommentEnd:new Uint8Array([45,45,62]),ScriptEnd:new Uint8Array([60,47,115,99,114,105,112,116]),StyleEnd:new Uint8Array([60,47,115,116,121,108,101]),TitleEnd:new Uint8Array([60,47,116,105,116,108,101]),TextareaEnd:new Uint8Array([60,47,116,101,120,116,97,114,101,97])};class Id{constructor({xmlMode:t=!1,decodeEntities:a=!0},n){this.cbs=n,this.state=S.Text,this.buffer="",this.sectionStart=0,this.index=0,this.entityStart=0,this.baseState=S.Text,this.isSpecial=!1,this.running=!0,this.offset=0,this.currentSequence=void 0,this.sequenceIndex=0,this.xmlMode=t,this.decodeEntities=a,this.entityDecoder=new $a(t?Xn:Ha,(i,r)=>this.emitCodePoint(i,r))}reset(){this.state=S.Text,this.buffer="",this.sectionStart=0,this.index=0,this.baseState=S.Text,this.currentSequence=void 0,this.running=!0,this.offset=0}write(t){this.offset+=this.buffer.length,this.buffer=t,this.parse()}end(){this.running&&this.finish()}pause(){this.running=!1}resume(){this.running=!0,this.index<this.buffer.length+this.offset&&this.parse()}stateText(t){t===k.Lt||!this.decodeEntities&&this.fastForwardTo(k.Lt)?(this.index>this.sectionStart&&this.cbs.ontext(this.sectionStart,this.index),this.state=S.BeforeTagName,this.sectionStart=this.index):this.decodeEntities&&t===k.Amp&&this.startEntity()}stateSpecialStartSequence(t){const a=this.sequenceIndex===this.currentSequence.length;if(!(a?Oa(t):(t|32)===this.currentSequence[this.sequenceIndex]))this.isSpecial=!1;else if(!a){this.sequenceIndex++;return}this.sequenceIndex=0,this.state=S.InTagName,this.stateInTagName(t)}stateInSpecialTag(t){if(this.sequenceIndex===this.currentSequence.length){if(t===k.Gt||qe(t)){const a=this.index-this.currentSequence.length;if(this.sectionStart<a){const n=this.index;this.index=a,this.cbs.ontext(this.sectionStart,a),this.index=n}this.isSpecial=!1,this.sectionStart=a+2,this.stateInClosingTagName(t);return}this.sequenceIndex=0}(t|32)===this.currentSequence[this.sequenceIndex]?this.sequenceIndex+=1:this.sequenceIndex===0?this.currentSequence===fe.TitleEnd?this.decodeEntities&&t===k.Amp&&this.startEntity():this.fastForwardTo(k.Lt)&&(this.sequenceIndex=1):this.sequenceIndex=+(t===k.Lt)}stateCDATASequence(t){t===fe.Cdata[this.sequenceIndex]?++this.sequenceIndex===fe.Cdata.length&&(this.state=S.InCommentLike,this.currentSequence=fe.CdataEnd,this.sequenceIndex=0,this.sectionStart=this.index+1):(this.sequenceIndex=0,this.state=S.InDeclaration,this.stateInDeclaration(t))}fastForwardTo(t){for(;++this.index<this.buffer.length+this.offset;)if(this.buffer.charCodeAt(this.index-this.offset)===t)return!0;return this.index=this.buffer.length+this.offset-1,!1}stateInCommentLike(t){t===this.currentSequence[this.sequenceIndex]?++this.sequenceIndex===this.currentSequence.length&&(this.currentSequence===fe.CdataEnd?this.cbs.oncdata(this.sectionStart,this.index,2):this.cbs.oncomment(this.sectionStart,this.index,2),this.sequenceIndex=0,this.sectionStart=this.index+1,this.state=S.Text):this.sequenceIndex===0?this.fastForwardTo(this.currentSequence[0])&&(this.sequenceIndex=1):t!==this.currentSequence[this.sequenceIndex-1]&&(this.sequenceIndex=0)}isTagStartChar(t){return this.xmlMode?!Oa(t):Cd(t)}startSpecial(t,a){this.isSpecial=!0,this.currentSequence=t,this.sequenceIndex=a,this.state=S.SpecialStartSequence}stateBeforeTagName(t){if(t===k.ExclamationMark)this.state=S.BeforeDeclaration,this.sectionStart=this.index+1;else if(t===k.Questionmark)this.state=S.InProcessingInstruction,this.sectionStart=this.index+1;else if(this.isTagStartChar(t)){const a=t|32;this.sectionStart=this.index,this.xmlMode?this.state=S.InTagName:a===fe.ScriptEnd[2]?this.state=S.BeforeSpecialS:a===fe.TitleEnd[2]?this.state=S.BeforeSpecialT:this.state=S.InTagName}else t===k.Slash?this.state=S.BeforeClosingTagName:(this.state=S.Text,this.stateText(t))}stateInTagName(t){Oa(t)&&(this.cbs.onopentagname(this.sectionStart,this.index),this.sectionStart=-1,this.state=S.BeforeAttributeName,this.stateBeforeAttributeName(t))}stateBeforeClosingTagName(t){qe(t)||(t===k.Gt?this.state=S.Text:(this.state=this.isTagStartChar(t)?S.InClosingTagName:S.InSpecialComment,this.sectionStart=this.index))}stateInClosingTagName(t){(t===k.Gt||qe(t))&&(this.cbs.onclosetag(this.sectionStart,this.index),this.sectionStart=-1,this.state=S.AfterClosingTagName,this.stateAfterClosingTagName(t))}stateAfterClosingTagName(t){(t===k.Gt||this.fastForwardTo(k.Gt))&&(this.state=S.Text,this.sectionStart=this.index+1)}stateBeforeAttributeName(t){t===k.Gt?(this.cbs.onopentagend(this.index),this.isSpecial?(this.state=S.InSpecialTag,this.sequenceIndex=0):this.state=S.Text,this.sectionStart=this.index+1):t===k.Slash?this.state=S.InSelfClosingTag:qe(t)||(this.state=S.InAttributeName,this.sectionStart=this.index)}stateInSelfClosingTag(t){t===k.Gt?(this.cbs.onselfclosingtag(this.index),this.state=S.Text,this.sectionStart=this.index+1,this.isSpecial=!1):qe(t)||(this.state=S.BeforeAttributeName,this.stateBeforeAttributeName(t))}stateInAttributeName(t){(t===k.Eq||Oa(t))&&(this.cbs.onattribname(this.sectionStart,this.index),this.sectionStart=this.index,this.state=S.AfterAttributeName,this.stateAfterAttributeName(t))}stateAfterAttributeName(t){t===k.Eq?this.state=S.BeforeAttributeValue:t===k.Slash||t===k.Gt?(this.cbs.onattribend(Ue.NoValue,this.sectionStart),this.sectionStart=-1,this.state=S.BeforeAttributeName,this.stateBeforeAttributeName(t)):qe(t)||(this.cbs.onattribend(Ue.NoValue,this.sectionStart),this.state=S.InAttributeName,this.sectionStart=this.index)}stateBeforeAttributeValue(t){t===k.DoubleQuote?(this.state=S.InAttributeValueDq,this.sectionStart=this.index+1):t===k.SingleQuote?(this.state=S.InAttributeValueSq,this.sectionStart=this.index+1):qe(t)||(this.sectionStart=this.index,this.state=S.InAttributeValueNq,this.stateInAttributeValueNoQuotes(t))}handleInAttributeValue(t,a){t===a||!this.decodeEntities&&this.fastForwardTo(a)?(this.cbs.onattribdata(this.sectionStart,this.index),this.sectionStart=-1,this.cbs.onattribend(a===k.DoubleQuote?Ue.Double:Ue.Single,this.index+1),this.state=S.BeforeAttributeName):this.decodeEntities&&t===k.Amp&&this.startEntity()}stateInAttributeValueDoubleQuotes(t){this.handleInAttributeValue(t,k.DoubleQuote)}stateInAttributeValueSingleQuotes(t){this.handleInAttributeValue(t,k.SingleQuote)}stateInAttributeValueNoQuotes(t){qe(t)||t===k.Gt?(this.cbs.onattribdata(this.sectionStart,this.index),this.sectionStart=-1,this.cbs.onattribend(Ue.Unquoted,this.index),this.state=S.BeforeAttributeName,this.stateBeforeAttributeName(t)):this.decodeEntities&&t===k.Amp&&this.startEntity()}stateBeforeDeclaration(t){t===k.OpeningSquareBracket?(this.state=S.CDATASequence,this.sequenceIndex=0):this.state=t===k.Dash?S.BeforeComment:S.InDeclaration}stateInDeclaration(t){(t===k.Gt||this.fastForwardTo(k.Gt))&&(this.cbs.ondeclaration(this.sectionStart,this.index),this.state=S.Text,this.sectionStart=this.index+1)}stateInProcessingInstruction(t){(t===k.Gt||this.fastForwardTo(k.Gt))&&(this.cbs.onprocessinginstruction(this.sectionStart,this.index),this.state=S.Text,this.sectionStart=this.index+1)}stateBeforeComment(t){t===k.Dash?(this.state=S.InCommentLike,this.currentSequence=fe.CommentEnd,this.sequenceIndex=2,this.sectionStart=this.index+1):this.state=S.InDeclaration}stateInSpecialComment(t){(t===k.Gt||this.fastForwardTo(k.Gt))&&(this.cbs.oncomment(this.sectionStart,this.index,0),this.state=S.Text,this.sectionStart=this.index+1)}stateBeforeSpecialS(t){const a=t|32;a===fe.ScriptEnd[3]?this.startSpecial(fe.ScriptEnd,4):a===fe.StyleEnd[3]?this.startSpecial(fe.StyleEnd,4):(this.state=S.InTagName,this.stateInTagName(t))}stateBeforeSpecialT(t){const a=t|32;a===fe.TitleEnd[3]?this.startSpecial(fe.TitleEnd,4):a===fe.TextareaEnd[3]?this.startSpecial(fe.TextareaEnd,4):(this.state=S.InTagName,this.stateInTagName(t))}startEntity(){this.baseState=this.state,this.state=S.InEntity,this.entityStart=this.index,this.entityDecoder.startEntity(this.xmlMode?Oe.Strict:this.baseState===S.Text||this.baseState===S.InSpecialTag?Oe.Legacy:Oe.Attribute)}stateInEntity(){const t=this.entityDecoder.write(this.buffer,this.index-this.offset);t>=0?(this.state=this.baseState,t===0&&(this.index=this.entityStart)):this.index=this.offset+this.buffer.length-1}cleanup(){this.running&&this.sectionStart!==this.index&&(this.state===S.Text||this.state===S.InSpecialTag&&this.sequenceIndex===0?(this.cbs.ontext(this.sectionStart,this.index),this.sectionStart=this.index):(this.state===S.InAttributeValueDq||this.state===S.InAttributeValueSq||this.state===S.InAttributeValueNq)&&(this.cbs.onattribdata(this.sectionStart,this.index),this.sectionStart=this.index))}shouldContinue(){return this.index<this.buffer.length+this.offset&&this.running}parse(){for(;this.shouldContinue();){const t=this.buffer.charCodeAt(this.index-this.offset);switch(this.state){case S.Text:{this.stateText(t);break}case S.SpecialStartSequence:{this.stateSpecialStartSequence(t);break}case S.InSpecialTag:{this.stateInSpecialTag(t);break}case S.CDATASequence:{this.stateCDATASequence(t);break}case S.InAttributeValueDq:{this.stateInAttributeValueDoubleQuotes(t);break}case S.InAttributeName:{this.stateInAttributeName(t);break}case S.InCommentLike:{this.stateInCommentLike(t);break}case S.InSpecialComment:{this.stateInSpecialComment(t);break}case S.BeforeAttributeName:{this.stateBeforeAttributeName(t);break}case S.InTagName:{this.stateInTagName(t);break}case S.InClosingTagName:{this.stateInClosingTagName(t);break}case S.BeforeTagName:{this.stateBeforeTagName(t);break}case S.AfterAttributeName:{this.stateAfterAttributeName(t);break}case S.InAttributeValueSq:{this.stateInAttributeValueSingleQuotes(t);break}case S.BeforeAttributeValue:{this.stateBeforeAttributeValue(t);break}case S.BeforeClosingTagName:{this.stateBeforeClosingTagName(t);break}case S.AfterClosingTagName:{this.stateAfterClosingTagName(t);break}case S.BeforeSpecialS:{this.stateBeforeSpecialS(t);break}case S.BeforeSpecialT:{this.stateBeforeSpecialT(t);break}case S.InAttributeValueNq:{this.stateInAttributeValueNoQuotes(t);break}case S.InSelfClosingTag:{this.stateInSelfClosingTag(t);break}case S.InDeclaration:{this.stateInDeclaration(t);break}case S.BeforeDeclaration:{this.stateBeforeDeclaration(t);break}case S.BeforeComment:{this.stateBeforeComment(t);break}case S.InProcessingInstruction:{this.stateInProcessingInstruction(t);break}case S.InEntity:{this.stateInEntity();break}}this.index++}this.cleanup()}finish(){this.state===S.InEntity&&(this.entityDecoder.end(),this.state=this.baseState),this.handleTrailingData(),this.cbs.onend()}handleTrailingData(){const t=this.buffer.length+this.offset;this.sectionStart>=t||(this.state===S.InCommentLike?this.currentSequence===fe.CdataEnd?this.cbs.oncdata(this.sectionStart,t,0):this.cbs.oncomment(this.sectionStart,t,0):this.state===S.InTagName||this.state===S.BeforeAttributeName||this.state===S.BeforeAttributeValue||this.state===S.AfterAttributeName||this.state===S.InAttributeName||this.state===S.InAttributeValueSq||this.state===S.InAttributeValueDq||this.state===S.InAttributeValueNq||this.state===S.InClosingTagName||this.cbs.ontext(this.sectionStart,t))}emitCodePoint(t,a){this.baseState!==S.Text&&this.baseState!==S.InSpecialTag?(this.sectionStart<this.entityStart&&this.cbs.onattribdata(this.sectionStart,this.entityStart),this.sectionStart=this.entityStart+a,this.index=this.sectionStart-1,this.cbs.onattribentity(t)):(this.sectionStart<this.entityStart&&this.cbs.ontext(this.sectionStart,this.entityStart),this.sectionStart=this.entityStart+a,this.index=this.sectionStart-1,this.cbs.ontextentity(t,this.sectionStart))}}const gt=new Set(["input","option","optgroup","select","button","datalist","textarea"]),X=new Set(["p"]),Ms=new Set(["thead","tbody"]),Ps=new Set(["dd","dt"]),vs=new Set(["rt","rp"]),Sd=new Map([["tr",new Set(["tr","th","td"])],["th",new Set(["th"])],["td",new Set(["thead","th","td"])],["body",new Set(["head","link","script"])],["li",new Set(["li"])],["p",X],["h1",X],["h2",X],["h3",X],["h4",X],["h5",X],["h6",X],["select",gt],["input",gt],["output",gt],["button",gt],["datalist",gt],["textarea",gt],["option",new Set(["option"])],["optgroup",new Set(["optgroup","option"])],["dd",Ps],["dt",Ps],["address",X],["article",X],["aside",X],["blockquote",X],["details",X],["div",X],["dl",X],["fieldset",X],["figcaption",X],["figure",X],["footer",X],["form",X],["header",X],["hr",X],["main",X],["nav",X],["ol",X],["pre",X],["section",X],["table",X],["ul",X],["rt",vs],["rp",vs],["tbody",Ms],["tfoot",Ms]]),xd=new Set(["area","base","basefont","br","col","command","embed","frame","hr","img","input","isindex","keygen","link","meta","param","source","track","wbr"]),Bs=new Set(["math","svg"]),ws=new Set(["mi","mo","mn","ms","mtext","annotation-xml","foreignobject","desc","title"]),Od=/\s|\//;class Dd{constructor(t,a={}){var n,i,r,u,o,l;this.options=a,this.startIndex=0,this.endIndex=0,this.openTagStart=0,this.tagname="",this.attribname="",this.attribvalue="",this.attribs=null,this.stack=[],this.buffers=[],this.bufferOffset=0,this.writeIndex=0,this.ended=!1,this.cbs=t??{},this.htmlMode=!this.options.xmlMode,this.lowerCaseTagNames=(n=a.lowerCaseTags)!==null&&n!==void 0?n:this.htmlMode,this.lowerCaseAttributeNames=(i=a.lowerCaseAttributeNames)!==null&&i!==void 0?i:this.htmlMode,this.recognizeSelfClosing=(r=a.recognizeSelfClosing)!==null&&r!==void 0?r:!this.htmlMode,this.tokenizer=new((u=a.Tokenizer)!==null&&u!==void 0?u:Id)(this.options,this),this.foreignContext=[!this.htmlMode],(l=(o=this.cbs).onparserinit)===null||l===void 0||l.call(o,this)}ontext(t,a){var n,i;const r=this.getSlice(t,a);this.endIndex=a-1,(i=(n=this.cbs).ontext)===null||i===void 0||i.call(n,r),this.startIndex=a}ontextentity(t,a){var n,i;this.endIndex=a-1,(i=(n=this.cbs).ontext)===null||i===void 0||i.call(n,Ya(t)),this.startIndex=a}isVoidElement(t){return this.htmlMode&&xd.has(t)}onopentagname(t,a){this.endIndex=a;let n=this.getSlice(t,a);this.lowerCaseTagNames&&(n=n.toLowerCase()),this.emitOpenTag(n)}emitOpenTag(t){var a,n,i,r;this.openTagStart=this.startIndex,this.tagname=t;const u=this.htmlMode&&Sd.get(t);if(u)for(;this.stack.length>0&&u.has(this.stack[0]);){const o=this.stack.shift();(n=(a=this.cbs).onclosetag)===null||n===void 0||n.call(a,o,!0)}this.isVoidElement(t)||(this.stack.unshift(t),this.htmlMode&&(Bs.has(t)?this.foreignContext.unshift(!0):ws.has(t)&&this.foreignContext.unshift(!1))),(r=(i=this.cbs).onopentagname)===null||r===void 0||r.call(i,t),this.cbs.onopentag&&(this.attribs={})}endOpenTag(t){var a,n;this.startIndex=this.openTagStart,this.attribs&&((n=(a=this.cbs).onopentag)===null||n===void 0||n.call(a,this.tagname,this.attribs,t),this.attribs=null),this.cbs.onclosetag&&this.isVoidElement(this.tagname)&&this.cbs.onclosetag(this.tagname,!0),this.tagname=""}onopentagend(t){this.endIndex=t,this.endOpenTag(!1),this.startIndex=t+1}onclosetag(t,a){var n,i,r,u,o,l,h,m;this.endIndex=a;let p=this.getSlice(t,a);if(this.lowerCaseTagNames&&(p=p.toLowerCase()),this.htmlMode&&(Bs.has(p)||ws.has(p))&&this.foreignContext.shift(),this.isVoidElement(p))this.htmlMode&&p==="br"&&((u=(r=this.cbs).onopentagname)===null||u===void 0||u.call(r,"br"),(l=(o=this.cbs).onopentag)===null||l===void 0||l.call(o,"br",{},!0),(m=(h=this.cbs).onclosetag)===null||m===void 0||m.call(h,"br",!1));else{const T=this.stack.indexOf(p);if(T!==-1)for(let A=0;A<=T;A++){const I=this.stack.shift();(i=(n=this.cbs).onclosetag)===null||i===void 0||i.call(n,I,A!==T)}else this.htmlMode&&p==="p"&&(this.emitOpenTag("p"),this.closeCurrentTag(!0))}this.startIndex=a+1}onselfclosingtag(t){this.endIndex=t,this.recognizeSelfClosing||this.foreignContext[0]?(this.closeCurrentTag(!1),this.startIndex=t+1):this.onopentagend(t)}closeCurrentTag(t){var a,n;const i=this.tagname;this.endOpenTag(t),this.stack[0]===i&&((n=(a=this.cbs).onclosetag)===null||n===void 0||n.call(a,i,!t),this.stack.shift())}onattribname(t,a){this.startIndex=t;const n=this.getSlice(t,a);this.attribname=this.lowerCaseAttributeNames?n.toLowerCase():n}onattribdata(t,a){this.attribvalue+=this.getSlice(t,a)}onattribentity(t){this.attribvalue+=Ya(t)}onattribend(t,a){var n,i;this.endIndex=a,(i=(n=this.cbs).onattribute)===null||i===void 0||i.call(n,this.attribname,this.attribvalue,t===Ue.Double?'"':t===Ue.Single?"'":t===Ue.NoValue?void 0:null),this.attribs&&!Object.prototype.hasOwnProperty.call(this.attribs,this.attribname)&&(this.attribs[this.attribname]=this.attribvalue),this.attribvalue=""}getInstructionName(t){const a=t.search(Od);let n=a<0?t:t.substr(0,a);return this.lowerCaseTagNames&&(n=n.toLowerCase()),n}ondeclaration(t,a){this.endIndex=a;const n=this.getSlice(t,a);if(this.cbs.onprocessinginstruction){const i=this.getInstructionName(n);this.cbs.onprocessinginstruction(`!${i}`,`!${n}`)}this.startIndex=a+1}onprocessinginstruction(t,a){this.endIndex=a;const n=this.getSlice(t,a);if(this.cbs.onprocessinginstruction){const i=this.getInstructionName(n);this.cbs.onprocessinginstruction(`?${i}`,`?${n}`)}this.startIndex=a+1}oncomment(t,a,n){var i,r,u,o;this.endIndex=a,(r=(i=this.cbs).oncomment)===null||r===void 0||r.call(i,this.getSlice(t,a-n)),(o=(u=this.cbs).oncommentend)===null||o===void 0||o.call(u),this.startIndex=a+1}oncdata(t,a,n){var i,r,u,o,l,h,m,p,T,A;this.endIndex=a;const I=this.getSlice(t,a-n);!this.htmlMode||this.options.recognizeCDATA?((r=(i=this.cbs).oncdatastart)===null||r===void 0||r.call(i),(o=(u=this.cbs).ontext)===null||o===void 0||o.call(u,I),(h=(l=this.cbs).oncdataend)===null||h===void 0||h.call(l)):((p=(m=this.cbs).oncomment)===null||p===void 0||p.call(m,`[CDATA[${I}]]`),(A=(T=this.cbs).oncommentend)===null||A===void 0||A.call(T)),this.startIndex=a+1}onend(){var t,a;if(this.cbs.onclosetag){this.endIndex=this.startIndex;for(let n=0;n<this.stack.length;n++)this.cbs.onclosetag(this.stack[n],!0)}(a=(t=this.cbs).onend)===null||a===void 0||a.call(t)}reset(){var t,a,n,i;(a=(t=this.cbs).onreset)===null||a===void 0||a.call(t),this.tokenizer.reset(),this.tagname="",this.attribname="",this.attribs=null,this.stack.length=0,this.startIndex=0,this.endIndex=0,(i=(n=this.cbs).onparserinit)===null||i===void 0||i.call(n,this),this.buffers.length=0,this.foreignContext.length=0,this.foreignContext.unshift(!this.htmlMode),this.bufferOffset=0,this.writeIndex=0,this.ended=!1}parseComplete(t){this.reset(),this.end(t)}getSlice(t,a){for(;t-this.bufferOffset>=this.buffers[0].length;)this.shiftBuffer();let n=this.buffers[0].slice(t-this.bufferOffset,a-this.bufferOffset);for(;a-this.bufferOffset>this.buffers[0].length;)this.shiftBuffer(),n+=this.buffers[0].slice(0,a-this.bufferOffset);return n}shiftBuffer(){this.bufferOffset+=this.buffers[0].length,this.writeIndex--,this.buffers.shift()}write(t){var a,n;if(this.ended){(n=(a=this.cbs).onerror)===null||n===void 0||n.call(a,new Error(".write() after done!"));return}this.buffers.push(t),this.tokenizer.running&&(this.tokenizer.write(t),this.writeIndex++)}end(t){var a,n;if(this.ended){(n=(a=this.cbs).onerror)===null||n===void 0||n.call(a,new Error(".end() after done!"));return}t&&this.write(t),this.ended=!0,this.tokenizer.end()}pause(){this.tokenizer.pause()}resume(){for(this.tokenizer.resume();this.tokenizer.running&&this.writeIndex<this.buffers.length;)this.tokenizer.write(this.buffers[this.writeIndex++]);this.ended&&this.tokenizer.end()}parseChunk(t){this.write(t)}done(t){this.end(t)}}function Ld(e,t){const a=new yr(void 0,t);return new Dd(a,t).end(e),a.root}const yd=sc((e,t,a,n)=>t._useHtmlParser2?Ld(e,t):_d(e,t,a,n)),Us=Uc(yd,(e,t)=>t._useHtmlParser2?ta(e,t):Nd(e));var Q=(e=>(e[e.None=0]="None",e[e.Text=1]="Text",e[e.Image=2]="Image",e[e.Video=3]="Video",e[e.Icon=4]="Icon",e[e.Link=5]="Link",e[e.Block=10]="Block",e))(Q||{});const Rd=c.defineComponent({name:"GpImageUpload",props:{accept:{type:String,default:"image/*"},multiple:{type:Boolean,default:!1},maxCount:{type:Number,default:1/0},beforeUpload:Function,onChange:Function,showList:{type:Boolean,default:!1}},setup(e,{emit:t}){const a=c.ref(null),n=c.ref([]);return{inputRef:a,fileList:n,triggerInput:()=>{var o;(o=a.value)==null||o.click()},handleChange:async o=>{var p;const h=o.target.files;if(!h)return;const m=[];for(let T=0;T<h.length;T++){const A=h[T];if(e.beforeUpload&&await e.beforeUpload(A)===!1)continue;const I=`${Date.now()}-${A.name}`,R=URL.createObjectURL(A);m.push({uid:I,name:A.name,status:"uploading",thumbUrl:R})}e.maxCount&&n.value.length+m.length>e.maxCount&&m.splice(e.maxCount-n.value.length),e.multiple?n.value=[...n.value,...m]:n.value=m.slice(0,1),(p=e.onChange)==null||p.call(e,n.value),t("update:fileList",n.value),a.value&&(a.value.value="")},removeFile:o=>{var l;n.value=n.value.filter(h=>h.uid!==o),(l=e.onChange)==null||l.call(e,n.value)}}}}),Ke=(e,t)=>{const a=e.__vccOpts||e;for(const[n,i]of t)a[n]=i;return a},kd={class:"upload-wrapper"},Md=["accept","multiple"],Pd={key:0,class:"file-list mt-4"},vd={class:"flex items-center space-x-4"},Bd=["src"],wd=["onClick"];function Ud(e,t,a,n,i,r){return c.openBlock(),c.createElementBlock("div",kd,[c.createElementVNode("div",{class:"",onClick:t[0]||(t[0]=(...u)=>e.triggerInput&&e.triggerInput(...u))},[c.renderSlot(e.$slots,"upload-icon",{},()=>[t[2]||(t[2]=c.createElementVNode("div",{class:"upload-area border-dashed border-2 p-6 rounded cursor-pointer hover:border-blue-500"},[c.createElementVNode("div",{class:"text-gray-400 text-lg text-center"}," 点击或拖拽上传图片 ")],-1))],!0)]),c.createElementVNode("input",{type:"file",ref:"inputRef",class:"hidden",accept:e.accept,multiple:e.multiple,onChange:t[1]||(t[1]=(...u)=>e.handleChange&&e.handleChange(...u))},null,40,Md),e.showList?(c.openBlock(),c.createElementBlock("div",Pd,[(c.openBlock(!0),c.createElementBlock(c.Fragment,null,c.renderList(e.fileList,u=>(c.openBlock(),c.createElementBlock("div",{key:u.uid,class:"file-item flex items-center justify-between p-2 border rounded mb-2"},[c.createElementVNode("div",vd,[u.thumbUrl?(c.openBlock(),c.createElementBlock("img",{key:0,src:u.thumbUrl,alt:"preview",class:"w-12 h-12 object-cover rounded"},null,8,Bd)):c.createCommentVNode("",!0),c.createElementVNode("span",null,c.toDisplayString(u.name),1)]),c.createElementVNode("div",null,[c.createElementVNode("button",{onClick:o=>e.removeFile(u.uid),class:"text-red-500 hover:underline"}," 删除 ",8,wd)])]))),128))])):c.createCommentVNode("",!0)])}const Fd=Ke(Rd,[["render",Ud],["__scopeId","data-v-dcbfe0e5"]]),Hd={key:0,"date-action":"1",contenteditable:"false",class:"text-red-500 text-xs mt-1"},Vd=Ke(c.defineComponent({__name:"ElementRenderer",props:{element:{type:Object,required:!0},selectedElement:Object,hoveredElement:Object,icons:{type:Array,default:()=>[]},mode:{type:String,default:"edit"},cropper:{type:Object,required:!1},icon:{type:Object,required:!1},r:{type:String,required:!1}},emits:["selectElement","hoverElement","updateText","contentUpdated","blockAction","addIcon","upload"],setup(e,{emit:t}){const a=e,n=t,i=c.computed(()=>a.selectedElement===a.element),r=c.computed(()=>a.hoveredElement===a.element),u=c.ref(!1),o=c.ref(!1),l=c.ref(""),h=c.computed(()=>a.element.rule.minText||0),m=c.computed(()=>a.element.rule.maxText||1/0);c.watch(()=>a.r,()=>{n("contentUpdated",B())},{immediate:!0});function p(O){O.xpath!="/div[1]"&&a.mode!=="preview"&&(a.mode==="edit"?O.type===Q.Text&&n("selectElement",O):n("selectElement",O),!O.rule.isReadOnly&&O.type===Q.Text&&(u.value=!0))}function T(O){n("selectElement",O)}function A(O,L){n("hoverElement",O,L)}function I(O){n("hoverElement",O)}function R(O){O.currentTarget.contains(O.relatedTarget)?n("hoverElement",null):a.hoveredElement?n("hoverElement",null,a.hoveredElement.parentxpath):n("hoverElement",null)}function M(){u.value=!1,n("contentUpdated",B())}function B(){function O(L){const ne=Object.entries(L.attrs||{}).map(([P,H])=>`${P}="${H}"`).join(" "),Ee=`<${L.tag}${ne?" "+ne:""}>`,C=`</${L.tag}>`,D=(L.children||[]).map(P=>O(P)).join("");return`${Ee}${L.editText||L.text||""}${D}${C}`}return O(a.element)}c.ref();function W(O){var C;O.stopPropagation();const L=O.target,ne=((C=L.firstChild)==null?void 0:C.nodeType)===Node.TEXT_NODE&&L.firstChild.nodeValue||"";if(ne.length<h.value){o.value=!0,l.value=`最少输入 ${h.value} 个字符`;return}else if(ne.length>m.value){o.value=!0,l.value=`最多输入 ${m.value} 个字符`;return}else o.value=!1,l.value="";n("updateText",{element:a.element,newText:ne}),n("contentUpdated",B());const Ee=c.toRaw(a.element);Ee.editText=ne}function q(O){n("updateText",O),n("contentUpdated",B())}function ae(){const O={...a.element};n("blockAction",{action:"add",element:a.element,newBlock:O})}function U(){_(a.element),n("blockAction",{action:"moveUp",element:a.element})}function _(O){O.children&&O.children.length>0&&O.children.forEach(L=>{L.type==Q.Text&&(L.text!==L.editText&&(L.text=L.editText),_(L))})}function w(){_(a.element),n("blockAction",{action:"moveDown",element:a.element})}function Y(){n("blockAction",{action:"delete",element:a.element})}function se(O){n("blockAction",O),n("contentUpdated",B())}function be(O){me.value.openModal(O)}function Pe(O,L){n("addIcon",O,L),n("contentUpdated",B())}let ye;const Re=c.ref(a.cropper),me=c.ref(a.icon),z=c.ref({});function xe(O,L){console.log("files",O,L);const ne=O[0];L.rule.minImageWidth&&L.rule.maxImageHeight?(z.value.width=L.rule.minImageWidth,z.value.height=L.rule.maxImageHeight,z.value.aspectRatio=L.rule.minImageWidth/L.rule.maxImageHeight):z.value={},ne&&(ne.name,ye=ne.thumbUrl,Re.value.handleOpenCropper(z.value,ye,ne.name,L))}function ve(O,L){if(console.log("event",O,L),console.log(typeof O=="object",O),O)if(typeof O=="object"){L.attrs.alt=O.name;const ne=new FileReader;ne.onload=Ee=>{var D;let C=(D=Ee==null?void 0:Ee.target)==null?void 0:D.result;L.attrs.src=C,n("upload",C,L),n("contentUpdated",B())},ne.readAsDataURL(O)}else L.attrs.src=O,n("upload",O,L),n("contentUpdated",B())}const tt=O=>O.type.startsWith("image/")?!0:(alert("只能上传图片!"),!1);return(O,L)=>{const ne=c.resolveComponent("ElementRenderer",!0);return c.openBlock(),c.createElementBlock(c.Fragment,null,[(c.openBlock(),c.createBlock(c.resolveDynamicComponent(a.element.tag),c.mergeProps({class:["relative",e.mode==="design"?"m-2 p-1 border-dashed border-2":"",r.value?"border-dashed border-blue-500":"",i.value?"border-dashed border-green-500 z-10 border-2":"",o.value?"border-dashed border-red-500":"",(!r.value&&!i.value&&!o.value,""),a.element.rule&&a.element.rule.isReadOnly?"cursor-not-allowed":""]},a.element.attrs,{contenteditable:u.value,onClick:L[2]||(L[2]=c.withModifiers(()=>p(a.element),["stop"])),onMouseenter:L[3]||(L[3]=()=>I(a.element)),onMouseleave:R,onBlur:M,onInput:W}),{default:c.withCtx(()=>[c.createTextVNode(c.toDisplayString(a.element.text),1),a.element.children&&a.element.children.length?(c.openBlock(),c.createElementBlock(c.Fragment,{key:0},[(c.openBlock(!0),c.createElementBlock(c.Fragment,null,c.renderList(a.element.children,(Ee,C)=>(c.openBlock(),c.createBlock(ne,{mode:e.mode,icons:e.icons,r:e.r,key:C,element:Ee,selectedElement:a.selectedElement,hoveredElement:a.hoveredElement,onSelectElement:T,onHoverElement:A,onUpdateText:q,onBlockAction:se,onAddIcon:Pe,onUpload:ve,cropper:e.cropper,icon:e.icon},null,8,["mode","icons","r","element","selectedElement","hoveredElement","cropper","icon"]))),128)),a.element.type===c.unref(Q).Block?(c.openBlock(),c.createElementBlock("div",{key:0,"date-action":"1",contenteditable:"false",onClick:L[0]||(L[0]=c.withModifiers(()=>{},["stop"])),class:"z-10 flex space-x-1 flex-none flex-nowrap overflow-visible absolute top-2"},[c.createElementVNode("button",{class:"flex-none px-2 py-1 bg-blue-500 text-white rounded",onClick:c.withModifiers(ae,["stop"])}," + "),c.createElementVNode("button",{class:"flex-none px-2 py-1 bg-gray-300 text-white rounded",onClick:c.withModifiers(U,["stop"])}," ⬅️ "),c.createElementVNode("button",{class:"flex-none px-2 py-1 bg-gray-300 text-white rounded",onClick:c.withModifiers(w,["stop"])}," ➡️ "),c.createElementVNode("button",{class:"flex-none px-2 py-1 bg-red-500 text-white rounded",onClick:c.withModifiers(Y,["stop"])}," ✖ ")])):c.createCommentVNode("",!0)],64)):c.createCommentVNode("",!0),a.element.type===c.unref(Q).Icon?(c.openBlock(),c.createElementBlock("div",{key:1,class:"cursor-pointer rounded-sm w-5 h-5 flex justify-center items-center absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 text-sm text-gray-50 z-10 bg-black/80",contenteditable:"false",onClick:L[1]||(L[1]=c.withModifiers(()=>be(a.element),["stop"]))}," ↑ ")):c.createCommentVNode("",!0)]),_:1},16,["class","contenteditable"])),a.element.type==c.unref(Q).Text&&o.value?(c.openBlock(),c.createElementBlock("div",Hd,c.toDisplayString(l.value),1)):c.createCommentVNode("",!0),a.element.type===c.unref(Q).Image?(c.openBlock(),c.createElementBlock("div",{key:1,class:"cursor-pointer rounded-sm flex justify-center items-center absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 text-sm text-gray-50 z-10 bg-black/80",onClick:L[5]||(L[5]=c.withModifiers(()=>{},["stop"])),contenteditable:"false"},[c.createVNode(Fd,{multiple:!1,beforeUpload:tt,onChange:L[4]||(L[4]=Ee=>xe(Ee,a.element))},{"upload-icon":c.withCtx(()=>L[6]||(L[6]=[c.createElementVNode("div",{class:"p-2"},"上传",-1)])),_:1})])):c.createCommentVNode("",!0)],64)}}}),[["__scopeId","data-v-b2d8bc68"]]),Yd=c.defineComponent({name:"GpCheckbox",props:{modelValue:{type:Boolean,required:!0},label:{type:String,default:""}},emits:["update:modelValue"],setup(e,{emit:t}){return{updateValue:n=>{t("update:modelValue",n.target.checked)}}}}),qd={class:"form-group"},$d={class:"flex items-center space-x-2 cursor-pointer"},Wd=["checked","aria-checked"],Gd={class:"checkbox-label text-sm text-gray-700"};function Xd(e,t,a,n,i,r){return c.openBlock(),c.createElementBlock("div",qd,[c.createElementVNode("label",$d,[c.createElementVNode("input",{type:"checkbox",checked:e.modelValue,onChange:t[0]||(t[0]=(...u)=>e.updateValue&&e.updateValue(...u)),class:"custom-checkbox","aria-checked":e.modelValue},null,40,Wd),c.createElementVNode("span",Gd,c.toDisplayString(e.label),1)])])}const Da=Ke(Yd,[["render",Xd],["__scopeId","data-v-68b8f276"]]),Qd=c.defineComponent({name:"GpMessage",props:{message:{type:String,required:!0},type:{type:String,default:"info"},position:{type:String,default:"top-right"},duration:{type:Number,default:3e3},onClose:{type:Function,required:!0},icon:{type:Boolean,default:!0}},setup(e){const t=c.ref(!1),a=c.computed(()=>({success:"bg-green-100 text-green-800",error:"bg-red-100 text-red-800",info:"bg-blue-100 text-blue-800",warning:"bg-yellow-100 text-yellow-800"})[e.type]),n=()=>{t.value=!1,e.onClose()};return setTimeout(()=>{n()},e.duration),t.value=!0,{visible:t,typeClass:a,closeMessage:n}}}),jd={key:0,class:"gp-message"},zd={key:0,class:"mr-2"},Kd={key:0,class:"text-green-500"},Zd={key:1,class:"text-red-500"},Jd={key:2,class:"text-blue-500"},eh={key:3,class:"text-yellow-500"};function th(e,t,a,n,i,r){return c.openBlock(),c.createBlock(c.Transition,{name:"fade"},{default:c.withCtx(()=>[e.visible?(c.openBlock(),c.createElementBlock("div",jd,[c.createElementVNode("div",{class:c.normalizeClass([e.typeClass,"message-content"])},[e.icon?(c.openBlock(),c.createElementBlock("span",zd,[c.renderSlot(e.$slots,"icon",{},()=>[e.type==="success"?(c.openBlock(),c.createElementBlock("span",Kd,"✔")):c.createCommentVNode("",!0),e.type==="error"?(c.openBlock(),c.createElementBlock("span",Zd,"✖")):c.createCommentVNode("",!0),e.type==="info"?(c.openBlock(),c.createElementBlock("span",Jd,"ℹ")):c.createCommentVNode("",!0),e.type==="warning"?(c.openBlock(),c.createElementBlock("span",eh,"⚠")):c.createCommentVNode("",!0)],!0)])):c.createCommentVNode("",!0),c.createElementVNode("span",null,c.toDisplayString(e.message),1),c.createElementVNode("button",{class:"close-btn hover:text-gray-800 font-bold",onClick:t[0]||(t[0]=(...u)=>e.closeMessage&&e.closeMessage(...u))}," × ")],2)])):c.createCommentVNode("",!0)]),_:3})}const ah=Ke(Qd,[["render",th],["__scopeId","data-v-56476f4c"]]),_t=c.reactive([]);let xn=null;const nh=()=>{const e=document.createElement("div");return e.id="global-message-container",document.body.appendChild(e),e},ih=()=>{if(xn)return;const e=nh();xn=c.createApp({setup(){return{messageQueue:_t}},render(){const t=c.computed(()=>{var n;return{"top-left":"top-4 left-4","top-right":"top-4 right-4","bottom-left":"bottom-4 left-4","bottom-right":"bottom-4 right-4","top-center":"top-4 left-1/2 transform -translate-x-1/2","bottom-center":"bottom-4 left-1/2 transform -translate-x-1/2"}[((n=_t[0])==null?void 0:n.options.position)||"top-right"]});return c.h("div",{class:`fixed flex flex-col gap-2 ${t.value}`},_t.map(a=>c.h(ah,{key:a.id,...a.options,onClose:()=>Fs(a.id)})))}}),xn.mount(e)},Fs=e=>{const t=_t.findIndex(a=>a.id===e);t!==-1&&_t.splice(t,1)};let sh=0;const j=e=>{ih();const t=sh++;_t.push({id:t,options:e}),setTimeout(()=>{Fs(t)},e.duration||3e3)};j.success=(e,t=3e3,a=!0)=>{j(typeof e=="string"?{message:e,type:"success",duration:t,icon:a}:{...e,type:"success"})},j.error=(e,t=3e3,a=!0)=>{j(typeof e=="string"?{message:e,type:"error",duration:t,icon:a}:{...e,type:"error"})},j.info=(e,t=3e3,a=!0)=>{j(typeof e=="string"?{message:e,type:"info",duration:t,icon:a}:{...e,type:"info"})},j.warning=(e,t=3e3,a=!0)=>{j(typeof e=="string"?{message:e,type:"warning",duration:t,icon:a}:{...e,type:"warning"})};const rh={key:0},uh={key:0},oh={class:"text-gray-500 my-2"},ch={class:"text-gray-500 my-2"},lh={key:1},dh={key:2},hh={key:3},fh={key:4},mh={key:5},Eh={key:6},ph={key:7},Th={key:8},bh=Ke(c.defineComponent({__name:"EditorPanel",props:{element:Object},emits:["updateElement"],setup(e,{emit:t}){const a=e,n=t,i=c.ref({rule:{},...a.element});c.watch(()=>a.element,u=>{i.value={rule:{},...u}},{immediate:!0});function r(){if(i.value.type===Q.Icon&&!i.value.attrs.class.includes("iconfont")){j.error("图标仅支持 iconfont 图标");return}if(i.value.type===Q.Image&&i.value.tag!=="img"){j.error("节点类型错误");return}if(i.value.type===Q.Video&&i.value.tag!=="video"){j.error("节点类型错误");return}if(i.value.type===Q.Link&&i.value.tag!=="a"){j.error("节点类型错误");return}if(i.value.type===Q.Text){if(i.value.rule.minText>i.value.rule.maxText){j.error("最小文本长度不能大于最大文本长度");return}if(i.value.tag!=="p"&&i.value.tag!=="div"&&i.value.tag!=="span"&&i.value.tag!=="h1"&&i.value.tag!=="h2"&&i.value.tag!=="h3"&&i.value.tag!=="h4"&&i.value.tag!=="h5"&&i.value.tag!=="h6"){j.error("节点类型错误");return}}if(i.value.type===Q.Block){if(i.value.rule.minBlock>i.value.rule.maxBlock){j.error("最小块数量不能大于最大块数量");return}if(i.value.tag!=="div"&&i.value.tag!=="section"&&i.value.tag!=="article"&&i.value.tag!=="nav"&&i.value.tag!=="header"&&i.value.tag!=="footer"&&i.value.tag!=="span"&&i.value.tag!=="p"&&i.value.tag!=="img"){j.error("节点类型错误");return}if(!i.value.children||i.value.children.length<1){j.error("节点错误,必须包含子元素");return}}n("updateElement",i.value)}return(u,o)=>(c.openBlock(),c.createElementBlock("div",null,[i.value?(c.openBlock(),c.createElementBlock("div",rh,[i.value.text!==void 0?(c.openBlock(),c.createElementBlock("div",uh,[o[11]||(o[11]=c.createElementVNode("label",{class:"block"},"内容",-1)),c.createElementVNode("div",oh,c.toDisplayString(i.value.text||"-"),1)])):c.createCommentVNode("",!0),c.createElementVNode("div",null,[o[12]||(o[12]=c.createElementVNode("label",{class:"block mt-4"},"节点",-1)),c.createElementVNode("div",ch,c.toDisplayString(i.value.xpath),1)]),c.createElementVNode("div",null,[o[14]||(o[14]=c.createElementVNode("label",{class:"block mt-4"},"类型",-1)),c.withDirectives(c.createElementVNode("select",{"onUpdate:modelValue":o[0]||(o[0]=l=>i.value.type=l),class:"border rounded p-1 w-full"},o[13]||(o[13]=[c.createElementVNode("option",{value:0},"无",-1),c.createElementVNode("option",{value:1},"文本",-1),c.createElementVNode("option",{value:2},"图片",-1),c.createElementVNode("option",{value:3},"视频",-1),c.createElementVNode("option",{value:4},"图标",-1),c.createElementVNode("option",{value:5},"链接",-1),c.createElementVNode("option",{value:10},"块",-1)]),512),[[c.vModelSelect,i.value.type]])]),i.value.type==c.unref(Q).Text?(c.openBlock(),c.createElementBlock("div",lh,[o[15]||(o[15]=c.createElementVNode("label",{class:"block mt-4"},"最小文本长度",-1)),c.withDirectives(c.createElementVNode("input",{"onUpdate:modelValue":o[1]||(o[1]=l=>i.value.rule.minText=l),class:"border rounded p-1 w-full"},null,512),[[c.vModelText,i.value.rule.minText]])])):c.createCommentVNode("",!0),i.value.type==c.unref(Q).Text?(c.openBlock(),c.createElementBlock("div",dh,[o[16]||(o[16]=c.createElementVNode("label",{class:"block mt-4"},"最大文本长度",-1)),c.withDirectives(c.createElementVNode("input",{"onUpdate:modelValue":o[2]||(o[2]=l=>i.value.rule.maxText=l),class:"border rounded p-1 w-full"},null,512),[[c.vModelText,i.value.rule.maxText]])])):c.createCommentVNode("",!0),i.value.type==c.unref(Q).Image?(c.openBlock(),c.createElementBlock("div",hh,[o[17]||(o[17]=c.createElementVNode("label",{class:"block mt-4"},"是否裁剪",-1)),c.createVNode(Da,{class:"py-2",modelValue:i.value.rule.crop,"onUpdate:modelValue":o[3]||(o[3]=l=>i.value.rule.crop=l),label:"是"},null,8,["modelValue"])])):c.createCommentVNode("",!0),i.value.type==c.unref(Q).Image?(c.openBlock(),c.createElementBlock("div",fh,[o[18]||(o[18]=c.createElementVNode("label",{class:"block mt-4"},"图片宽度",-1)),c.withDirectives(c.createElementVNode("input",{"onUpdate:modelValue":o[4]||(o[4]=l=>i.value.rule.minImageWidth=l),class:"border rounded p-1 w-full"},null,512),[[c.vModelText,i.value.rule.minImageWidth]])])):c.createCommentVNode("",!0),i.value.type==c.unref(Q).Image?(c.openBlock(),c.createElementBlock("div",mh,[o[19]||(o[19]=c.createElementVNode("label",{class:"block mt-4"},"图片高度",-1)),c.withDirectives(c.createElementVNode("input",{"onUpdate:modelValue":o[5]||(o[5]=l=>i.value.rule.maxImageHeight=l),class:"border rounded p-1 w-full"},null,512),[[c.vModelText,i.value.rule.maxImageHeight]])])):c.createCommentVNode("",!0),i.value.type==c.unref(Q).Block?(c.openBlock(),c.createElementBlock("div",Eh,[o[20]||(o[20]=c.createElementVNode("label",{class:"block mt-4"},"块最小数量",-1)),c.withDirectives(c.createElementVNode("input",{"onUpdate:modelValue":o[6]||(o[6]=l=>i.value.rule.minBlock=l),class:"border rounded p-1 w-full"},null,512),[[c.vModelText,i.value.rule.minBlock]])])):c.createCommentVNode("",!0),i.value.type==c.unref(Q).Block?(c.openBlock(),c.createElementBlock("div",ph,[o[21]||(o[21]=c.createElementVNode("label",{class:"block mt-4"},"块最大数量",-1)),c.withDirectives(c.createElementVNode("input",{"onUpdate:modelValue":o[7]||(o[7]=l=>i.value.rule.maxBlock=l),class:"border rounded p-1 w-full"},null,512),[[c.vModelText,i.value.rule.maxBlock]])])):c.createCommentVNode("",!0),i.value.type==c.unref(Q).Text||i.value.type==c.unref(Q).Icon?(c.openBlock(),c.createElementBlock("div",Th,[o[22]||(o[22]=c.createElementVNode("label",{class:"block mt-4"},"主题色",-1)),c.createVNode(Da,{class:"py-2",modelValue:i.value.rule.isThemeColor,"onUpdate:modelValue":o[8]||(o[8]=l=>i.value.rule.isThemeColor=l),label:"是"},null,8,["modelValue"])])):c.createCommentVNode("",!0),c.createElementVNode("div",null,[o[23]||(o[23]=c.createElementVNode("label",{class:"block mt-4"},"是否必填",-1)),c.createVNode(Da,{class:"py-2",modelValue:i.value.rule.isRequired,"onUpdate:modelValue":o[9]||(o[9]=l=>i.value.rule.isRequired=l),label:"是"},null,8,["modelValue"])]),c.createElementVNode("div",null,[o[24]||(o[24]=c.createElementVNode("label",{class:"block mt-4"},"是否只读",-1)),c.createVNode(Da,{class:"py-2",modelValue:i.value.rule.isReadOnly,"onUpdate:modelValue":o[10]||(o[10]=l=>i.value.rule.isReadOnly=l),label:"是"},null,8,["modelValue"])])])):c.createCommentVNode("",!0),c.createElementVNode("button",{onClick:r,class:"mt-4 p-2 bg-green-500 text-white rounded"}," 保存 ")]))}}),[["__scopeId","data-v-b077a796"]]);/*!
|
9
9
|
* Cropper.js v1.6.2
|
10
10
|
* https://fengyuanchen.github.io/cropperjs
|
11
11
|
*
|
@@ -14,4 +14,4 @@
|
|
14
14
|
*
|
15
15
|
* Date: 2024-04-21T07:43:05.335Z
|
16
16
|
*/function Hs(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),a.push.apply(a,n)}return a}function Vs(e){for(var t=1;t<arguments.length;t++){var a=arguments[t]!=null?arguments[t]:{};t%2?Hs(Object(a),!0).forEach(function(n){Nh(e,n,a[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):Hs(Object(a)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(a,n))})}return e}function gh(e,t){if(typeof e!="object"||!e)return e;var a=e[Symbol.toPrimitive];if(a!==void 0){var n=a.call(e,t||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function Ys(e){var t=gh(e,"string");return typeof t=="symbol"?t:t+""}function On(e){"@babel/helpers - typeof";return On=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},On(e)}function _h(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function qs(e,t){for(var a=0;a<t.length;a++){var n=t[a];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,Ys(n.key),n)}}function Ah(e,t,a){return t&&qs(e.prototype,t),a&&qs(e,a),Object.defineProperty(e,"prototype",{writable:!1}),e}function Nh(e,t,a){return t=Ys(t),t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}function $s(e){return Ch(e)||Ih(e)||Sh(e)||xh()}function Ch(e){if(Array.isArray(e))return Dn(e)}function Ih(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function Sh(e,t){if(e){if(typeof e=="string")return Dn(e,t);var a=Object.prototype.toString.call(e).slice(8,-1);if(a==="Object"&&e.constructor&&(a=e.constructor.name),a==="Map"||a==="Set")return Array.from(e);if(a==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a))return Dn(e,t)}}function Dn(e,t){(t==null||t>e.length)&&(t=e.length);for(var a=0,n=new Array(t);a<t;a++)n[a]=e[a];return n}function xh(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
17
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var La=typeof window<"u"&&typeof window.document<"u",Fe=La?window:{},Ln=La&&Fe.document.documentElement?"ontouchstart"in Fe.document.documentElement:!1,yn=La?"PointerEvent"in Fe:!1,J="cropper",Rn="all",Ws="crop",Gs="move",Xs="zoom",ct="e",lt="w",At="s",Ze="n",Gt="ne",Xt="nw",Qt="se",jt="sw",kn="".concat(J,"-crop"),Qs="".concat(J,"-disabled"),Ce="".concat(J,"-hidden"),js="".concat(J,"-hide"),Oh="".concat(J,"-invisible"),ya="".concat(J,"-modal"),Mn="".concat(J,"-move"),zt="".concat(J,"Action"),Ra="".concat(J,"Preview"),Pn="crop",zs="move",Ks="none",vn="crop",Bn="cropend",wn="cropmove",Un="cropstart",Zs="dblclick",Dh=Ln?"touchstart":"mousedown",Lh=Ln?"touchmove":"mousemove",yh=Ln?"touchend touchcancel":"mouseup",Js=yn?"pointerdown":Dh,er=yn?"pointermove":Lh,tr=yn?"pointerup pointercancel":yh,ar="ready",nr="resize",ir="wheel",Fn="zoom",sr="image/jpeg",Rh=/^e|w|s|n|se|sw|ne|nw|all|crop|move|zoom$/,kh=/^data:/,Mh=/^data:image\/jpeg;base64,/,Ph=/^img|canvas$/i,rr=200,ur=100,or={viewMode:0,dragMode:Pn,initialAspectRatio:NaN,aspectRatio:NaN,data:null,preview:"",responsive:!0,restore:!0,checkCrossOrigin:!0,checkOrientation:!0,modal:!0,guides:!0,center:!0,highlight:!0,background:!0,autoCrop:!0,autoCropArea:.8,movable:!0,rotatable:!0,scalable:!0,zoomable:!0,zoomOnTouch:!0,zoomOnWheel:!0,wheelZoomRatio:.1,cropBoxMovable:!0,cropBoxResizable:!0,toggleDragModeOnDblclick:!0,minCanvasWidth:0,minCanvasHeight:0,minCropBoxWidth:0,minCropBoxHeight:0,minContainerWidth:rr,minContainerHeight:ur,ready:null,cropstart:null,cropmove:null,cropend:null,crop:null,zoom:null},vh='<div class="cropper-container" touch-action="none"><div class="cropper-wrap-box"><div class="cropper-canvas"></div></div><div class="cropper-drag-box"></div><div class="cropper-crop-box"><span class="cropper-view-box"></span><span class="cropper-dashed dashed-h"></span><span class="cropper-dashed dashed-v"></span><span class="cropper-center"></span><span class="cropper-face"></span><span class="cropper-line line-e" data-cropper-action="e"></span><span class="cropper-line line-n" data-cropper-action="n"></span><span class="cropper-line line-w" data-cropper-action="w"></span><span class="cropper-line line-s" data-cropper-action="s"></span><span class="cropper-point point-e" data-cropper-action="e"></span><span class="cropper-point point-n" data-cropper-action="n"></span><span class="cropper-point point-w" data-cropper-action="w"></span><span class="cropper-point point-s" data-cropper-action="s"></span><span class="cropper-point point-ne" data-cropper-action="ne"></span><span class="cropper-point point-nw" data-cropper-action="nw"></span><span class="cropper-point point-sw" data-cropper-action="sw"></span><span class="cropper-point point-se" data-cropper-action="se"></span></div></div>',Bh=Number.isNaN||Fe.isNaN;function V(e){return typeof e=="number"&&!Bh(e)}var cr=function(t){return t>0&&t<1/0};function Hn(e){return typeof e>"u"}function dt(e){return On(e)==="object"&&e!==null}var wh=Object.prototype.hasOwnProperty;function Nt(e){if(!dt(e))return!1;try{var t=e.constructor,a=t.prototype;return t&&a&&wh.call(a,"isPrototypeOf")}catch{return!1}}function Ie(e){return typeof e=="function"}var Uh=Array.prototype.slice;function lr(e){return Array.from?Array.from(e):Uh.call(e)}function re(e,t){return e&&Ie(t)&&(Array.isArray(e)||V(e.length)?lr(e).forEach(function(a,n){t.call(e,a,n,e)}):dt(e)&&Object.keys(e).forEach(function(a){t.call(e,e[a],a,e)})),e}var ee=Object.assign||function(t){for(var a=arguments.length,n=new Array(a>1?a-1:0),i=1;i<a;i++)n[i-1]=arguments[i];return dt(t)&&n.length>0&&n.forEach(function(r){dt(r)&&Object.keys(r).forEach(function(u){t[u]=r[u]})}),t},Fh=/\.\d*(?:0|9){12}\d*$/;function Ct(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1e11;return Fh.test(e)?Math.round(e*t)/t:e}var Hh=/^width|height|left|top|marginLeft|marginTop$/;function Je(e,t){var a=e.style;re(t,function(n,i){Hh.test(i)&&V(n)&&(n="".concat(n,"px")),a[i]=n})}function Vh(e,t){return e.classList?e.classList.contains(t):e.className.indexOf(t)>-1}function he(e,t){if(t){if(V(e.length)){re(e,function(n){he(n,t)});return}if(e.classList){e.classList.add(t);return}var a=e.className.trim();a?a.indexOf(t)<0&&(e.className="".concat(a," ").concat(t)):e.className=t}}function He(e,t){if(t){if(V(e.length)){re(e,function(a){He(a,t)});return}if(e.classList){e.classList.remove(t);return}e.className.indexOf(t)>=0&&(e.className=e.className.replace(t,""))}}function It(e,t,a){if(t){if(V(e.length)){re(e,function(n){It(n,t,a)});return}a?he(e,t):He(e,t)}}var Yh=/([a-z\d])([A-Z])/g;function Vn(e){return e.replace(Yh,"$1-$2").toLowerCase()}function Yn(e,t){return dt(e[t])?e[t]:e.dataset?e.dataset[t]:e.getAttribute("data-".concat(Vn(t)))}function Kt(e,t,a){dt(a)?e[t]=a:e.dataset?e.dataset[t]=a:e.setAttribute("data-".concat(Vn(t)),a)}function qh(e,t){if(dt(e[t]))try{delete e[t]}catch{e[t]=void 0}else if(e.dataset)try{delete e.dataset[t]}catch{e.dataset[t]=void 0}else e.removeAttribute("data-".concat(Vn(t)))}var dr=/\s\s*/,hr=function(){var e=!1;if(La){var t=!1,a=function(){},n=Object.defineProperty({},"once",{get:function(){return e=!0,t},set:function(r){t=r}});Fe.addEventListener("test",a,n),Fe.removeEventListener("test",a,n)}return e}();function Me(e,t,a){var n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{},i=a;t.trim().split(dr).forEach(function(r){if(!hr){var u=e.listeners;u&&u[r]&&u[r][a]&&(i=u[r][a],delete u[r][a],Object.keys(u[r]).length===0&&delete u[r],Object.keys(u).length===0&&delete e.listeners)}e.removeEventListener(r,i,n)})}function Le(e,t,a){var n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{},i=a;t.trim().split(dr).forEach(function(r){if(n.once&&!hr){var u=e.listeners,o=u===void 0?{}:u;i=function(){delete o[r][a],e.removeEventListener(r,i,n);for(var h=arguments.length,m=new Array(h),p=0;p<h;p++)m[p]=arguments[p];a.apply(e,m)},o[r]||(o[r]={}),o[r][a]&&e.removeEventListener(r,o[r][a],n),o[r][a]=i,e.listeners=o}e.addEventListener(r,i,n)})}function St(e,t,a){var n;return Ie(Event)&&Ie(CustomEvent)?n=new CustomEvent(t,{detail:a,bubbles:!0,cancelable:!0}):(n=document.createEvent("CustomEvent"),n.initCustomEvent(t,!0,!0,a)),e.dispatchEvent(n)}function fr(e){var t=e.getBoundingClientRect();return{left:t.left+(window.pageXOffset-document.documentElement.clientLeft),top:t.top+(window.pageYOffset-document.documentElement.clientTop)}}var qn=Fe.location,$h=/^(\w+:)\/\/([^:/?#]*):?(\d*)/i;function mr(e){var t=e.match($h);return t!==null&&(t[1]!==qn.protocol||t[2]!==qn.hostname||t[3]!==qn.port)}function Er(e){var t="timestamp=".concat(new Date().getTime());return e+(e.indexOf("?")===-1?"?":"&")+t}function Zt(e){var t=e.rotate,a=e.scaleX,n=e.scaleY,i=e.translateX,r=e.translateY,u=[];V(i)&&i!==0&&u.push("translateX(".concat(i,"px)")),V(r)&&r!==0&&u.push("translateY(".concat(r,"px)")),V(t)&&t!==0&&u.push("rotate(".concat(t,"deg)")),V(a)&&a!==1&&u.push("scaleX(".concat(a,")")),V(n)&&n!==1&&u.push("scaleY(".concat(n,")"));var o=u.length?u.join(" "):"none";return{WebkitTransform:o,msTransform:o,transform:o}}function Wh(e){var t=Vs({},e),a=0;return re(e,function(n,i){delete t[i],re(t,function(r){var u=Math.abs(n.startX-r.startX),o=Math.abs(n.startY-r.startY),l=Math.abs(n.endX-r.endX),h=Math.abs(n.endY-r.endY),m=Math.sqrt(u*u+o*o),p=Math.sqrt(l*l+h*h),T=(p-m)/m;Math.abs(T)>Math.abs(a)&&(a=T)})}),a}function ka(e,t){var a=e.pageX,n=e.pageY,i={endX:a,endY:n};return t?i:Vs({startX:a,startY:n},i)}function Gh(e){var t=0,a=0,n=0;return re(e,function(i){var r=i.startX,u=i.startY;t+=r,a+=u,n+=1}),t/=n,a/=n,{pageX:t,pageY:a}}function et(e){var t=e.aspectRatio,a=e.height,n=e.width,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"contain",r=cr(n),u=cr(a);if(r&&u){var o=a*t;i==="contain"&&o>n||i==="cover"&&o<n?a=n/t:n=a*t}else r?a=n/t:u&&(n=a*t);return{width:n,height:a}}function Xh(e){var t=e.width,a=e.height,n=e.degree;if(n=Math.abs(n)%180,n===90)return{width:a,height:t};var i=n%90*Math.PI/180,r=Math.sin(i),u=Math.cos(i),o=t*u+a*r,l=t*r+a*u;return n>90?{width:l,height:o}:{width:o,height:l}}function Qh(e,t,a,n){var i=t.aspectRatio,r=t.naturalWidth,u=t.naturalHeight,o=t.rotate,l=o===void 0?0:o,h=t.scaleX,m=h===void 0?1:h,p=t.scaleY,T=p===void 0?1:p,A=a.aspectRatio,I=a.naturalWidth,R=a.naturalHeight,M=n.fillColor,B=M===void 0?"transparent":M,W=n.imageSmoothingEnabled,q=W===void 0?!0:W,ae=n.imageSmoothingQuality,U=ae===void 0?"low":ae,_=n.maxWidth,w=_===void 0?1/0:_,Y=n.maxHeight,se=Y===void 0?1/0:Y,be=n.minWidth,Pe=be===void 0?0:be,ye=n.minHeight,Re=ye===void 0?0:ye,me=document.createElement("canvas"),z=me.getContext("2d"),xe=et({aspectRatio:A,width:w,height:se}),ve=et({aspectRatio:A,width:Pe,height:Re},"cover"),tt=Math.min(xe.width,Math.max(ve.width,I)),O=Math.min(xe.height,Math.max(ve.height,R)),L=et({aspectRatio:i,width:w,height:se}),ne=et({aspectRatio:i,width:Pe,height:Re},"cover"),Ee=Math.min(L.width,Math.max(ne.width,r)),C=Math.min(L.height,Math.max(ne.height,u)),D=[-Ee/2,-C/2,Ee,C];return me.width=Ct(tt),me.height=Ct(O),z.fillStyle=B,z.fillRect(0,0,tt,O),z.save(),z.translate(tt/2,O/2),z.rotate(l*Math.PI/180),z.scale(m,T),z.imageSmoothingEnabled=q,z.imageSmoothingQuality=U,z.drawImage.apply(z,[e].concat($s(D.map(function(P){return Math.floor(Ct(P))})))),z.restore(),me}var pr=String.fromCharCode;function jh(e,t,a){var n="";a+=t;for(var i=t;i<a;i+=1)n+=pr(e.getUint8(i));return n}var zh=/^data:.*,/;function Kh(e){var t=e.replace(zh,""),a=atob(t),n=new ArrayBuffer(a.length),i=new Uint8Array(n);return re(i,function(r,u){i[u]=a.charCodeAt(u)}),n}function Zh(e,t){for(var a=[],n=8192,i=new Uint8Array(e);i.length>0;)a.push(pr.apply(null,lr(i.subarray(0,n)))),i=i.subarray(n);return"data:".concat(t,";base64,").concat(btoa(a.join("")))}function Jh(e){var t=new DataView(e),a;try{var n,i,r;if(t.getUint8(0)===255&&t.getUint8(1)===216)for(var u=t.byteLength,o=2;o+1<u;){if(t.getUint8(o)===255&&t.getUint8(o+1)===225){i=o;break}o+=1}if(i){var l=i+4,h=i+10;if(jh(t,l,4)==="Exif"){var m=t.getUint16(h);if(n=m===18761,(n||m===19789)&&t.getUint16(h+2,n)===42){var p=t.getUint32(h+4,n);p>=8&&(r=h+p)}}}if(r){var T=t.getUint16(r,n),A,I;for(I=0;I<T;I+=1)if(A=r+I*12+2,t.getUint16(A,n)===274){A+=8,a=t.getUint16(A,n),t.setUint16(A,1,n);break}}}catch{a=1}return a}function ef(e){var t=0,a=1,n=1;switch(e){case 2:a=-1;break;case 3:t=-180;break;case 4:n=-1;break;case 5:t=90,n=-1;break;case 6:t=90;break;case 7:t=90,a=-1;break;case 8:t=-90;break}return{rotate:t,scaleX:a,scaleY:n}}var tf={render:function(){this.initContainer(),this.initCanvas(),this.initCropBox(),this.renderCanvas(),this.cropped&&this.renderCropBox()},initContainer:function(){var t=this.element,a=this.options,n=this.container,i=this.cropper,r=Number(a.minContainerWidth),u=Number(a.minContainerHeight);he(i,Ce),He(t,Ce);var o={width:Math.max(n.offsetWidth,r>=0?r:rr),height:Math.max(n.offsetHeight,u>=0?u:ur)};this.containerData=o,Je(i,{width:o.width,height:o.height}),he(t,Ce),He(i,Ce)},initCanvas:function(){var t=this.containerData,a=this.imageData,n=this.options.viewMode,i=Math.abs(a.rotate)%180===90,r=i?a.naturalHeight:a.naturalWidth,u=i?a.naturalWidth:a.naturalHeight,o=r/u,l=t.width,h=t.height;t.height*o>t.width?n===3?l=t.height*o:h=t.width/o:n===3?h=t.width/o:l=t.height*o;var m={aspectRatio:o,naturalWidth:r,naturalHeight:u,width:l,height:h};this.canvasData=m,this.limited=n===1||n===2,this.limitCanvas(!0,!0),m.width=Math.min(Math.max(m.width,m.minWidth),m.maxWidth),m.height=Math.min(Math.max(m.height,m.minHeight),m.maxHeight),m.left=(t.width-m.width)/2,m.top=(t.height-m.height)/2,m.oldLeft=m.left,m.oldTop=m.top,this.initialCanvasData=ee({},m)},limitCanvas:function(t,a){var n=this.options,i=this.containerData,r=this.canvasData,u=this.cropBoxData,o=n.viewMode,l=r.aspectRatio,h=this.cropped&&u;if(t){var m=Number(n.minCanvasWidth)||0,p=Number(n.minCanvasHeight)||0;o>1?(m=Math.max(m,i.width),p=Math.max(p,i.height),o===3&&(p*l>m?m=p*l:p=m/l)):o>0&&(m?m=Math.max(m,h?u.width:0):p?p=Math.max(p,h?u.height:0):h&&(m=u.width,p=u.height,p*l>m?m=p*l:p=m/l));var T=et({aspectRatio:l,width:m,height:p});m=T.width,p=T.height,r.minWidth=m,r.minHeight=p,r.maxWidth=1/0,r.maxHeight=1/0}if(a)if(o>(h?0:1)){var A=i.width-r.width,I=i.height-r.height;r.minLeft=Math.min(0,A),r.minTop=Math.min(0,I),r.maxLeft=Math.max(0,A),r.maxTop=Math.max(0,I),h&&this.limited&&(r.minLeft=Math.min(u.left,u.left+(u.width-r.width)),r.minTop=Math.min(u.top,u.top+(u.height-r.height)),r.maxLeft=u.left,r.maxTop=u.top,o===2&&(r.width>=i.width&&(r.minLeft=Math.min(0,A),r.maxLeft=Math.max(0,A)),r.height>=i.height&&(r.minTop=Math.min(0,I),r.maxTop=Math.max(0,I))))}else r.minLeft=-r.width,r.minTop=-r.height,r.maxLeft=i.width,r.maxTop=i.height},renderCanvas:function(t,a){var n=this.canvasData,i=this.imageData;if(a){var r=Xh({width:i.naturalWidth*Math.abs(i.scaleX||1),height:i.naturalHeight*Math.abs(i.scaleY||1),degree:i.rotate||0}),u=r.width,o=r.height,l=n.width*(u/n.naturalWidth),h=n.height*(o/n.naturalHeight);n.left-=(l-n.width)/2,n.top-=(h-n.height)/2,n.width=l,n.height=h,n.aspectRatio=u/o,n.naturalWidth=u,n.naturalHeight=o,this.limitCanvas(!0,!1)}(n.width>n.maxWidth||n.width<n.minWidth)&&(n.left=n.oldLeft),(n.height>n.maxHeight||n.height<n.minHeight)&&(n.top=n.oldTop),n.width=Math.min(Math.max(n.width,n.minWidth),n.maxWidth),n.height=Math.min(Math.max(n.height,n.minHeight),n.maxHeight),this.limitCanvas(!1,!0),n.left=Math.min(Math.max(n.left,n.minLeft),n.maxLeft),n.top=Math.min(Math.max(n.top,n.minTop),n.maxTop),n.oldLeft=n.left,n.oldTop=n.top,Je(this.canvas,ee({width:n.width,height:n.height},Zt({translateX:n.left,translateY:n.top}))),this.renderImage(t),this.cropped&&this.limited&&this.limitCropBox(!0,!0)},renderImage:function(t){var a=this.canvasData,n=this.imageData,i=n.naturalWidth*(a.width/a.naturalWidth),r=n.naturalHeight*(a.height/a.naturalHeight);ee(n,{width:i,height:r,left:(a.width-i)/2,top:(a.height-r)/2}),Je(this.image,ee({width:n.width,height:n.height},Zt(ee({translateX:n.left,translateY:n.top},n)))),t&&this.output()},initCropBox:function(){var t=this.options,a=this.canvasData,n=t.aspectRatio||t.initialAspectRatio,i=Number(t.autoCropArea)||.8,r={width:a.width,height:a.height};n&&(a.height*n>a.width?r.height=r.width/n:r.width=r.height*n),this.cropBoxData=r,this.limitCropBox(!0,!0),r.width=Math.min(Math.max(r.width,r.minWidth),r.maxWidth),r.height=Math.min(Math.max(r.height,r.minHeight),r.maxHeight),r.width=Math.max(r.minWidth,r.width*i),r.height=Math.max(r.minHeight,r.height*i),r.left=a.left+(a.width-r.width)/2,r.top=a.top+(a.height-r.height)/2,r.oldLeft=r.left,r.oldTop=r.top,this.initialCropBoxData=ee({},r)},limitCropBox:function(t,a){var n=this.options,i=this.containerData,r=this.canvasData,u=this.cropBoxData,o=this.limited,l=n.aspectRatio;if(t){var h=Number(n.minCropBoxWidth)||0,m=Number(n.minCropBoxHeight)||0,p=o?Math.min(i.width,r.width,r.width+r.left,i.width-r.left):i.width,T=o?Math.min(i.height,r.height,r.height+r.top,i.height-r.top):i.height;h=Math.min(h,i.width),m=Math.min(m,i.height),l&&(h&&m?m*l>h?m=h/l:h=m*l:h?m=h/l:m&&(h=m*l),T*l>p?T=p/l:p=T*l),u.minWidth=Math.min(h,p),u.minHeight=Math.min(m,T),u.maxWidth=p,u.maxHeight=T}a&&(o?(u.minLeft=Math.max(0,r.left),u.minTop=Math.max(0,r.top),u.maxLeft=Math.min(i.width,r.left+r.width)-u.width,u.maxTop=Math.min(i.height,r.top+r.height)-u.height):(u.minLeft=0,u.minTop=0,u.maxLeft=i.width-u.width,u.maxTop=i.height-u.height))},renderCropBox:function(){var t=this.options,a=this.containerData,n=this.cropBoxData;(n.width>n.maxWidth||n.width<n.minWidth)&&(n.left=n.oldLeft),(n.height>n.maxHeight||n.height<n.minHeight)&&(n.top=n.oldTop),n.width=Math.min(Math.max(n.width,n.minWidth),n.maxWidth),n.height=Math.min(Math.max(n.height,n.minHeight),n.maxHeight),this.limitCropBox(!1,!0),n.left=Math.min(Math.max(n.left,n.minLeft),n.maxLeft),n.top=Math.min(Math.max(n.top,n.minTop),n.maxTop),n.oldLeft=n.left,n.oldTop=n.top,t.movable&&t.cropBoxMovable&&Kt(this.face,zt,n.width>=a.width&&n.height>=a.height?Gs:Rn),Je(this.cropBox,ee({width:n.width,height:n.height},Zt({translateX:n.left,translateY:n.top}))),this.cropped&&this.limited&&this.limitCanvas(!0,!0),this.disabled||this.output()},output:function(){this.preview(),St(this.element,vn,this.getData())}},af={initPreview:function(){var t=this.element,a=this.crossOrigin,n=this.options.preview,i=a?this.crossOriginUrl:this.url,r=t.alt||"The image to preview",u=document.createElement("img");if(a&&(u.crossOrigin=a),u.src=i,u.alt=r,this.viewBox.appendChild(u),this.viewBoxImage=u,!!n){var o=n;typeof n=="string"?o=t.ownerDocument.querySelectorAll(n):n.querySelector&&(o=[n]),this.previews=o,re(o,function(l){var h=document.createElement("img");Kt(l,Ra,{width:l.offsetWidth,height:l.offsetHeight,html:l.innerHTML}),a&&(h.crossOrigin=a),h.src=i,h.alt=r,h.style.cssText='display:block;width:100%;height:auto;min-width:0!important;min-height:0!important;max-width:none!important;max-height:none!important;image-orientation:0deg!important;"',l.innerHTML="",l.appendChild(h)})}},resetPreview:function(){re(this.previews,function(t){var a=Yn(t,Ra);Je(t,{width:a.width,height:a.height}),t.innerHTML=a.html,qh(t,Ra)})},preview:function(){var t=this.imageData,a=this.canvasData,n=this.cropBoxData,i=n.width,r=n.height,u=t.width,o=t.height,l=n.left-a.left-t.left,h=n.top-a.top-t.top;!this.cropped||this.disabled||(Je(this.viewBoxImage,ee({width:u,height:o},Zt(ee({translateX:-l,translateY:-h},t)))),re(this.previews,function(m){var p=Yn(m,Ra),T=p.width,A=p.height,I=T,R=A,M=1;i&&(M=T/i,R=r*M),r&&R>A&&(M=A/r,I=i*M,R=A),Je(m,{width:I,height:R}),Je(m.getElementsByTagName("img")[0],ee({width:u*M,height:o*M},Zt(ee({translateX:-l*M,translateY:-h*M},t))))}))}},nf={bind:function(){var t=this.element,a=this.options,n=this.cropper;Ie(a.cropstart)&&Le(t,Un,a.cropstart),Ie(a.cropmove)&&Le(t,wn,a.cropmove),Ie(a.cropend)&&Le(t,Bn,a.cropend),Ie(a.crop)&&Le(t,vn,a.crop),Ie(a.zoom)&&Le(t,Fn,a.zoom),Le(n,Js,this.onCropStart=this.cropStart.bind(this)),a.zoomable&&a.zoomOnWheel&&Le(n,ir,this.onWheel=this.wheel.bind(this),{passive:!1,capture:!0}),a.toggleDragModeOnDblclick&&Le(n,Zs,this.onDblclick=this.dblclick.bind(this)),Le(t.ownerDocument,er,this.onCropMove=this.cropMove.bind(this)),Le(t.ownerDocument,tr,this.onCropEnd=this.cropEnd.bind(this)),a.responsive&&Le(window,nr,this.onResize=this.resize.bind(this))},unbind:function(){var t=this.element,a=this.options,n=this.cropper;Ie(a.cropstart)&&Me(t,Un,a.cropstart),Ie(a.cropmove)&&Me(t,wn,a.cropmove),Ie(a.cropend)&&Me(t,Bn,a.cropend),Ie(a.crop)&&Me(t,vn,a.crop),Ie(a.zoom)&&Me(t,Fn,a.zoom),Me(n,Js,this.onCropStart),a.zoomable&&a.zoomOnWheel&&Me(n,ir,this.onWheel,{passive:!1,capture:!0}),a.toggleDragModeOnDblclick&&Me(n,Zs,this.onDblclick),Me(t.ownerDocument,er,this.onCropMove),Me(t.ownerDocument,tr,this.onCropEnd),a.responsive&&Me(window,nr,this.onResize)}},sf={resize:function(){if(!this.disabled){var t=this.options,a=this.container,n=this.containerData,i=a.offsetWidth/n.width,r=a.offsetHeight/n.height,u=Math.abs(i-1)>Math.abs(r-1)?i:r;if(u!==1){var o,l;t.restore&&(o=this.getCanvasData(),l=this.getCropBoxData()),this.render(),t.restore&&(this.setCanvasData(re(o,function(h,m){o[m]=h*u})),this.setCropBoxData(re(l,function(h,m){l[m]=h*u})))}}},dblclick:function(){this.disabled||this.options.dragMode===Ks||this.setDragMode(Vh(this.dragBox,kn)?zs:Pn)},wheel:function(t){var a=this,n=Number(this.options.wheelZoomRatio)||.1,i=1;this.disabled||(t.preventDefault(),!this.wheeling&&(this.wheeling=!0,setTimeout(function(){a.wheeling=!1},50),t.deltaY?i=t.deltaY>0?1:-1:t.wheelDelta?i=-t.wheelDelta/120:t.detail&&(i=t.detail>0?1:-1),this.zoom(-i*n,t)))},cropStart:function(t){var a=t.buttons,n=t.button;if(!(this.disabled||(t.type==="mousedown"||t.type==="pointerdown"&&t.pointerType==="mouse")&&(V(a)&&a!==1||V(n)&&n!==0||t.ctrlKey))){var i=this.options,r=this.pointers,u;t.changedTouches?re(t.changedTouches,function(o){r[o.identifier]=ka(o)}):r[t.pointerId||0]=ka(t),Object.keys(r).length>1&&i.zoomable&&i.zoomOnTouch?u=Xs:u=Yn(t.target,zt),Rh.test(u)&&St(this.element,Un,{originalEvent:t,action:u})!==!1&&(t.preventDefault(),this.action=u,this.cropping=!1,u===Ws&&(this.cropping=!0,he(this.dragBox,ya)))}},cropMove:function(t){var a=this.action;if(!(this.disabled||!a)){var n=this.pointers;t.preventDefault(),St(this.element,wn,{originalEvent:t,action:a})!==!1&&(t.changedTouches?re(t.changedTouches,function(i){ee(n[i.identifier]||{},ka(i,!0))}):ee(n[t.pointerId||0]||{},ka(t,!0)),this.change(t))}},cropEnd:function(t){if(!this.disabled){var a=this.action,n=this.pointers;t.changedTouches?re(t.changedTouches,function(i){delete n[i.identifier]}):delete n[t.pointerId||0],a&&(t.preventDefault(),Object.keys(n).length||(this.action=""),this.cropping&&(this.cropping=!1,It(this.dragBox,ya,this.cropped&&this.options.modal)),St(this.element,Bn,{originalEvent:t,action:a}))}}},rf={change:function(t){var a=this.options,n=this.canvasData,i=this.containerData,r=this.cropBoxData,u=this.pointers,o=this.action,l=a.aspectRatio,h=r.left,m=r.top,p=r.width,T=r.height,A=h+p,I=m+T,R=0,M=0,B=i.width,W=i.height,q=!0,ae;!l&&t.shiftKey&&(l=p&&T?p/T:1),this.limited&&(R=r.minLeft,M=r.minTop,B=R+Math.min(i.width,n.width,n.left+n.width),W=M+Math.min(i.height,n.height,n.top+n.height));var U=u[Object.keys(u)[0]],_={x:U.endX-U.startX,y:U.endY-U.startY},w=function(se){switch(se){case ct:A+_.x>B&&(_.x=B-A);break;case lt:h+_.x<R&&(_.x=R-h);break;case Ze:m+_.y<M&&(_.y=M-m);break;case At:I+_.y>W&&(_.y=W-I);break}};switch(o){case Rn:h+=_.x,m+=_.y;break;case ct:if(_.x>=0&&(A>=B||l&&(m<=M||I>=W))){q=!1;break}w(ct),p+=_.x,p<0&&(o=lt,p=-p,h-=p),l&&(T=p/l,m+=(r.height-T)/2);break;case Ze:if(_.y<=0&&(m<=M||l&&(h<=R||A>=B))){q=!1;break}w(Ze),T-=_.y,m+=_.y,T<0&&(o=At,T=-T,m-=T),l&&(p=T*l,h+=(r.width-p)/2);break;case lt:if(_.x<=0&&(h<=R||l&&(m<=M||I>=W))){q=!1;break}w(lt),p-=_.x,h+=_.x,p<0&&(o=ct,p=-p,h-=p),l&&(T=p/l,m+=(r.height-T)/2);break;case At:if(_.y>=0&&(I>=W||l&&(h<=R||A>=B))){q=!1;break}w(At),T+=_.y,T<0&&(o=Ze,T=-T,m-=T),l&&(p=T*l,h+=(r.width-p)/2);break;case Gt:if(l){if(_.y<=0&&(m<=M||A>=B)){q=!1;break}w(Ze),T-=_.y,m+=_.y,p=T*l}else w(Ze),w(ct),_.x>=0?A<B?p+=_.x:_.y<=0&&m<=M&&(q=!1):p+=_.x,_.y<=0?m>M&&(T-=_.y,m+=_.y):(T-=_.y,m+=_.y);p<0&&T<0?(o=jt,T=-T,p=-p,m-=T,h-=p):p<0?(o=Xt,p=-p,h-=p):T<0&&(o=Qt,T=-T,m-=T);break;case Xt:if(l){if(_.y<=0&&(m<=M||h<=R)){q=!1;break}w(Ze),T-=_.y,m+=_.y,p=T*l,h+=r.width-p}else w(Ze),w(lt),_.x<=0?h>R?(p-=_.x,h+=_.x):_.y<=0&&m<=M&&(q=!1):(p-=_.x,h+=_.x),_.y<=0?m>M&&(T-=_.y,m+=_.y):(T-=_.y,m+=_.y);p<0&&T<0?(o=Qt,T=-T,p=-p,m-=T,h-=p):p<0?(o=Gt,p=-p,h-=p):T<0&&(o=jt,T=-T,m-=T);break;case jt:if(l){if(_.x<=0&&(h<=R||I>=W)){q=!1;break}w(lt),p-=_.x,h+=_.x,T=p/l}else w(At),w(lt),_.x<=0?h>R?(p-=_.x,h+=_.x):_.y>=0&&I>=W&&(q=!1):(p-=_.x,h+=_.x),_.y>=0?I<W&&(T+=_.y):T+=_.y;p<0&&T<0?(o=Gt,T=-T,p=-p,m-=T,h-=p):p<0?(o=Qt,p=-p,h-=p):T<0&&(o=Xt,T=-T,m-=T);break;case Qt:if(l){if(_.x>=0&&(A>=B||I>=W)){q=!1;break}w(ct),p+=_.x,T=p/l}else w(At),w(ct),_.x>=0?A<B?p+=_.x:_.y>=0&&I>=W&&(q=!1):p+=_.x,_.y>=0?I<W&&(T+=_.y):T+=_.y;p<0&&T<0?(o=Xt,T=-T,p=-p,m-=T,h-=p):p<0?(o=jt,p=-p,h-=p):T<0&&(o=Gt,T=-T,m-=T);break;case Gs:this.move(_.x,_.y),q=!1;break;case Xs:this.zoom(Wh(u),t),q=!1;break;case Ws:if(!_.x||!_.y){q=!1;break}ae=fr(this.cropper),h=U.startX-ae.left,m=U.startY-ae.top,p=r.minWidth,T=r.minHeight,_.x>0?o=_.y>0?Qt:Gt:_.x<0&&(h-=p,o=_.y>0?jt:Xt),_.y<0&&(m-=T),this.cropped||(He(this.cropBox,Ce),this.cropped=!0,this.limited&&this.limitCropBox(!0,!0));break}q&&(r.width=p,r.height=T,r.left=h,r.top=m,this.action=o,this.renderCropBox()),re(u,function(Y){Y.startX=Y.endX,Y.startY=Y.endY})}},uf={crop:function(){return this.ready&&!this.cropped&&!this.disabled&&(this.cropped=!0,this.limitCropBox(!0,!0),this.options.modal&&he(this.dragBox,ya),He(this.cropBox,Ce),this.setCropBoxData(this.initialCropBoxData)),this},reset:function(){return this.ready&&!this.disabled&&(this.imageData=ee({},this.initialImageData),this.canvasData=ee({},this.initialCanvasData),this.cropBoxData=ee({},this.initialCropBoxData),this.renderCanvas(),this.cropped&&this.renderCropBox()),this},clear:function(){return this.cropped&&!this.disabled&&(ee(this.cropBoxData,{left:0,top:0,width:0,height:0}),this.cropped=!1,this.renderCropBox(),this.limitCanvas(!0,!0),this.renderCanvas(),He(this.dragBox,ya),he(this.cropBox,Ce)),this},replace:function(t){var a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return!this.disabled&&t&&(this.isImg&&(this.element.src=t),a?(this.url=t,this.image.src=t,this.ready&&(this.viewBoxImage.src=t,re(this.previews,function(n){n.getElementsByTagName("img")[0].src=t}))):(this.isImg&&(this.replaced=!0),this.options.data=null,this.uncreate(),this.load(t))),this},enable:function(){return this.ready&&this.disabled&&(this.disabled=!1,He(this.cropper,Qs)),this},disable:function(){return this.ready&&!this.disabled&&(this.disabled=!0,he(this.cropper,Qs)),this},destroy:function(){var t=this.element;return t[J]?(t[J]=void 0,this.isImg&&this.replaced&&(t.src=this.originalUrl),this.uncreate(),this):this},move:function(t){var a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:t,n=this.canvasData,i=n.left,r=n.top;return this.moveTo(Hn(t)?t:i+Number(t),Hn(a)?a:r+Number(a))},moveTo:function(t){var a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:t,n=this.canvasData,i=!1;return t=Number(t),a=Number(a),this.ready&&!this.disabled&&this.options.movable&&(V(t)&&(n.left=t,i=!0),V(a)&&(n.top=a,i=!0),i&&this.renderCanvas(!0)),this},zoom:function(t,a){var n=this.canvasData;return t=Number(t),t<0?t=1/(1-t):t=1+t,this.zoomTo(n.width*t/n.naturalWidth,null,a)},zoomTo:function(t,a,n){var i=this.options,r=this.canvasData,u=r.width,o=r.height,l=r.naturalWidth,h=r.naturalHeight;if(t=Number(t),t>=0&&this.ready&&!this.disabled&&i.zoomable){var m=l*t,p=h*t;if(St(this.element,Fn,{ratio:t,oldRatio:u/l,originalEvent:n})===!1)return this;if(n){var T=this.pointers,A=fr(this.cropper),I=T&&Object.keys(T).length?Gh(T):{pageX:n.pageX,pageY:n.pageY};r.left-=(m-u)*((I.pageX-A.left-r.left)/u),r.top-=(p-o)*((I.pageY-A.top-r.top)/o)}else Nt(a)&&V(a.x)&&V(a.y)?(r.left-=(m-u)*((a.x-r.left)/u),r.top-=(p-o)*((a.y-r.top)/o)):(r.left-=(m-u)/2,r.top-=(p-o)/2);r.width=m,r.height=p,this.renderCanvas(!0)}return this},rotate:function(t){return this.rotateTo((this.imageData.rotate||0)+Number(t))},rotateTo:function(t){return t=Number(t),V(t)&&this.ready&&!this.disabled&&this.options.rotatable&&(this.imageData.rotate=t%360,this.renderCanvas(!0,!0)),this},scaleX:function(t){var a=this.imageData.scaleY;return this.scale(t,V(a)?a:1)},scaleY:function(t){var a=this.imageData.scaleX;return this.scale(V(a)?a:1,t)},scale:function(t){var a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:t,n=this.imageData,i=!1;return t=Number(t),a=Number(a),this.ready&&!this.disabled&&this.options.scalable&&(V(t)&&(n.scaleX=t,i=!0),V(a)&&(n.scaleY=a,i=!0),i&&this.renderCanvas(!0,!0)),this},getData:function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,a=this.options,n=this.imageData,i=this.canvasData,r=this.cropBoxData,u;if(this.ready&&this.cropped){u={x:r.left-i.left,y:r.top-i.top,width:r.width,height:r.height};var o=n.width/n.naturalWidth;if(re(u,function(m,p){u[p]=m/o}),t){var l=Math.round(u.y+u.height),h=Math.round(u.x+u.width);u.x=Math.round(u.x),u.y=Math.round(u.y),u.width=h-u.x,u.height=l-u.y}}else u={x:0,y:0,width:0,height:0};return a.rotatable&&(u.rotate=n.rotate||0),a.scalable&&(u.scaleX=n.scaleX||1,u.scaleY=n.scaleY||1),u},setData:function(t){var a=this.options,n=this.imageData,i=this.canvasData,r={};if(this.ready&&!this.disabled&&Nt(t)){var u=!1;a.rotatable&&V(t.rotate)&&t.rotate!==n.rotate&&(n.rotate=t.rotate,u=!0),a.scalable&&(V(t.scaleX)&&t.scaleX!==n.scaleX&&(n.scaleX=t.scaleX,u=!0),V(t.scaleY)&&t.scaleY!==n.scaleY&&(n.scaleY=t.scaleY,u=!0)),u&&this.renderCanvas(!0,!0);var o=n.width/n.naturalWidth;V(t.x)&&(r.left=t.x*o+i.left),V(t.y)&&(r.top=t.y*o+i.top),V(t.width)&&(r.width=t.width*o),V(t.height)&&(r.height=t.height*o),this.setCropBoxData(r)}return this},getContainerData:function(){return this.ready?ee({},this.containerData):{}},getImageData:function(){return this.sized?ee({},this.imageData):{}},getCanvasData:function(){var t=this.canvasData,a={};return this.ready&&re(["left","top","width","height","naturalWidth","naturalHeight"],function(n){a[n]=t[n]}),a},setCanvasData:function(t){var a=this.canvasData,n=a.aspectRatio;return this.ready&&!this.disabled&&Nt(t)&&(V(t.left)&&(a.left=t.left),V(t.top)&&(a.top=t.top),V(t.width)?(a.width=t.width,a.height=t.width/n):V(t.height)&&(a.height=t.height,a.width=t.height*n),this.renderCanvas(!0)),this},getCropBoxData:function(){var t=this.cropBoxData,a;return this.ready&&this.cropped&&(a={left:t.left,top:t.top,width:t.width,height:t.height}),a||{}},setCropBoxData:function(t){var a=this.cropBoxData,n=this.options.aspectRatio,i,r;return this.ready&&this.cropped&&!this.disabled&&Nt(t)&&(V(t.left)&&(a.left=t.left),V(t.top)&&(a.top=t.top),V(t.width)&&t.width!==a.width&&(i=!0,a.width=t.width),V(t.height)&&t.height!==a.height&&(r=!0,a.height=t.height),n&&(i?a.height=a.width/n:r&&(a.width=a.height*n)),this.renderCropBox()),this},getCroppedCanvas:function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!this.ready||!window.HTMLCanvasElement)return null;var a=this.canvasData,n=Qh(this.image,this.imageData,a,t);if(!this.cropped)return n;var i=this.getData(t.rounded),r=i.x,u=i.y,o=i.width,l=i.height,h=n.width/Math.floor(a.naturalWidth);h!==1&&(r*=h,u*=h,o*=h,l*=h);var m=o/l,p=et({aspectRatio:m,width:t.maxWidth||1/0,height:t.maxHeight||1/0}),T=et({aspectRatio:m,width:t.minWidth||0,height:t.minHeight||0},"cover"),A=et({aspectRatio:m,width:t.width||(h!==1?n.width:o),height:t.height||(h!==1?n.height:l)}),I=A.width,R=A.height;I=Math.min(p.width,Math.max(T.width,I)),R=Math.min(p.height,Math.max(T.height,R));var M=document.createElement("canvas"),B=M.getContext("2d");M.width=Ct(I),M.height=Ct(R),B.fillStyle=t.fillColor||"transparent",B.fillRect(0,0,I,R);var W=t.imageSmoothingEnabled,q=W===void 0?!0:W,ae=t.imageSmoothingQuality;B.imageSmoothingEnabled=q,ae&&(B.imageSmoothingQuality=ae);var U=n.width,_=n.height,w=r,Y=u,se,be,Pe,ye,Re,me;w<=-o||w>U?(w=0,se=0,Pe=0,Re=0):w<=0?(Pe=-w,w=0,se=Math.min(U,o+w),Re=se):w<=U&&(Pe=0,se=Math.min(o,U-w),Re=se),se<=0||Y<=-l||Y>_?(Y=0,be=0,ye=0,me=0):Y<=0?(ye=-Y,Y=0,be=Math.min(_,l+Y),me=be):Y<=_&&(ye=0,be=Math.min(l,_-Y),me=be);var z=[w,Y,se,be];if(Re>0&&me>0){var xe=I/o;z.push(Pe*xe,ye*xe,Re*xe,me*xe)}return B.drawImage.apply(B,[n].concat($s(z.map(function(ve){return Math.floor(Ct(ve))})))),M},setAspectRatio:function(t){var a=this.options;return!this.disabled&&!Hn(t)&&(a.aspectRatio=Math.max(0,t)||NaN,this.ready&&(this.initCropBox(),this.cropped&&this.renderCropBox())),this},setDragMode:function(t){var a=this.options,n=this.dragBox,i=this.face;if(this.ready&&!this.disabled){var r=t===Pn,u=a.movable&&t===zs;t=r||u?t:Ks,a.dragMode=t,Kt(n,zt,t),It(n,kn,r),It(n,Mn,u),a.cropBoxMovable||(Kt(i,zt,t),It(i,kn,r),It(i,Mn,u))}return this}},of=Fe.Cropper,Tr=function(){function e(t){var a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(_h(this,e),!t||!Ph.test(t.tagName))throw new Error("The first argument is required and must be an <img> or <canvas> element.");this.element=t,this.options=ee({},or,Nt(a)&&a),this.cropped=!1,this.disabled=!1,this.pointers={},this.ready=!1,this.reloading=!1,this.replaced=!1,this.sized=!1,this.sizing=!1,this.init()}return Ah(e,[{key:"init",value:function(){var a=this.element,n=a.tagName.toLowerCase(),i;if(!a[J]){if(a[J]=this,n==="img"){if(this.isImg=!0,i=a.getAttribute("src")||"",this.originalUrl=i,!i)return;i=a.src}else n==="canvas"&&window.HTMLCanvasElement&&(i=a.toDataURL());this.load(i)}}},{key:"load",value:function(a){var n=this;if(a){this.url=a,this.imageData={};var i=this.element,r=this.options;if(!r.rotatable&&!r.scalable&&(r.checkOrientation=!1),!r.checkOrientation||!window.ArrayBuffer){this.clone();return}if(kh.test(a)){Mh.test(a)?this.read(Kh(a)):this.clone();return}var u=new XMLHttpRequest,o=this.clone.bind(this);this.reloading=!0,this.xhr=u,u.onabort=o,u.onerror=o,u.ontimeout=o,u.onprogress=function(){u.getResponseHeader("content-type")!==sr&&u.abort()},u.onload=function(){n.read(u.response)},u.onloadend=function(){n.reloading=!1,n.xhr=null},r.checkCrossOrigin&&mr(a)&&i.crossOrigin&&(a=Er(a)),u.open("GET",a,!0),u.responseType="arraybuffer",u.withCredentials=i.crossOrigin==="use-credentials",u.send()}}},{key:"read",value:function(a){var n=this.options,i=this.imageData,r=Jh(a),u=0,o=1,l=1;if(r>1){this.url=Zh(a,sr);var h=ef(r);u=h.rotate,o=h.scaleX,l=h.scaleY}n.rotatable&&(i.rotate=u),n.scalable&&(i.scaleX=o,i.scaleY=l),this.clone()}},{key:"clone",value:function(){var a=this.element,n=this.url,i=a.crossOrigin,r=n;this.options.checkCrossOrigin&&mr(n)&&(i||(i="anonymous"),r=Er(n)),this.crossOrigin=i,this.crossOriginUrl=r;var u=document.createElement("img");i&&(u.crossOrigin=i),u.src=r||n,u.alt=a.alt||"The image to crop",this.image=u,u.onload=this.start.bind(this),u.onerror=this.stop.bind(this),he(u,js),a.parentNode.insertBefore(u,a.nextSibling)}},{key:"start",value:function(){var a=this,n=this.image;n.onload=null,n.onerror=null,this.sizing=!0;var i=Fe.navigator&&/(?:iPad|iPhone|iPod).*?AppleWebKit/i.test(Fe.navigator.userAgent),r=function(h,m){ee(a.imageData,{naturalWidth:h,naturalHeight:m,aspectRatio:h/m}),a.initialImageData=ee({},a.imageData),a.sizing=!1,a.sized=!0,a.build()};if(n.naturalWidth&&!i){r(n.naturalWidth,n.naturalHeight);return}var u=document.createElement("img"),o=document.body||document.documentElement;this.sizingImage=u,u.onload=function(){r(u.width,u.height),i||o.removeChild(u)},u.src=n.src,i||(u.style.cssText="left:0;max-height:none!important;max-width:none!important;min-height:0!important;min-width:0!important;opacity:0;position:absolute;top:0;z-index:-1;",o.appendChild(u))}},{key:"stop",value:function(){var a=this.image;a.onload=null,a.onerror=null,a.parentNode.removeChild(a),this.image=null}},{key:"build",value:function(){if(!(!this.sized||this.ready)){var a=this.element,n=this.options,i=this.image,r=a.parentNode,u=document.createElement("div");u.innerHTML=vh;var o=u.querySelector(".".concat(J,"-container")),l=o.querySelector(".".concat(J,"-canvas")),h=o.querySelector(".".concat(J,"-drag-box")),m=o.querySelector(".".concat(J,"-crop-box")),p=m.querySelector(".".concat(J,"-face"));this.container=r,this.cropper=o,this.canvas=l,this.dragBox=h,this.cropBox=m,this.viewBox=o.querySelector(".".concat(J,"-view-box")),this.face=p,l.appendChild(i),he(a,Ce),r.insertBefore(o,a.nextSibling),He(i,js),this.initPreview(),this.bind(),n.initialAspectRatio=Math.max(0,n.initialAspectRatio)||NaN,n.aspectRatio=Math.max(0,n.aspectRatio)||NaN,n.viewMode=Math.max(0,Math.min(3,Math.round(n.viewMode)))||0,he(m,Ce),n.guides||he(m.getElementsByClassName("".concat(J,"-dashed")),Ce),n.center||he(m.getElementsByClassName("".concat(J,"-center")),Ce),n.background&&he(o,"".concat(J,"-bg")),n.highlight||he(p,Oh),n.cropBoxMovable&&(he(p,Mn),Kt(p,zt,Rn)),n.cropBoxResizable||(he(m.getElementsByClassName("".concat(J,"-line")),Ce),he(m.getElementsByClassName("".concat(J,"-point")),Ce)),this.render(),this.ready=!0,this.setDragMode(n.dragMode),n.autoCrop&&this.crop(),this.setData(n.data),Ie(n.ready)&&Le(a,ar,n.ready,{once:!0}),St(a,ar)}}},{key:"unbuild",value:function(){if(this.ready){this.ready=!1,this.unbind(),this.resetPreview();var a=this.cropper.parentNode;a&&a.removeChild(this.cropper),He(this.element,Ce)}}},{key:"uncreate",value:function(){this.ready?(this.unbuild(),this.ready=!1,this.cropped=!1):this.sizing?(this.sizingImage.onload=null,this.sizing=!1,this.sized=!1):this.reloading?(this.xhr.onabort=null,this.xhr.abort()):this.image&&this.stop()}}],[{key:"noConflict",value:function(){return window.Cropper=of,e}},{key:"setDefaults",value:function(a){ee(or,Nt(a)&&a)}}])}();ee(Tr.prototype,tf,af,nf,sf,rf,uf);function cf(e,t){const a=e.split(",")||[],n=a[0].match(/:(.*?);/)[1],i=a[1]&&atob(a[1]);let r=i&&i.length;const u=new Uint8Array(r);for(;r--;)u[r]=i==null?void 0:i.charCodeAt(r);return new File([u],t,{type:n})}const lf={key:0,contenteditable:"false",class:"z-10 w-[100vw] h-[100vh] bg-[rgba(0,0,0,0.7)] flex flex-col justify-center items-center fixed top-0 left-0 cursor-auto"},df={class:"w-[700px] flex flex-col bg-white rounded pb-8"},hf={class:"flex flex-row items-center justify-between px-6 py-4 bg-[#f4f8ff]"},ff={class:"flex flex-col h-full"},mf={class:"flex flex-row justify-center items-start flex-1"},Ef={class:"flex flex-col items-start flex-1"},pf={class:"flex flex-col w-full px-6 py-4"},Tf={class:"flex flex-col w-full"},bf={class:"flex flex-row items-center"},gf={class:"relative bg-[#474AFF] text-white rounded p-3"},_f={class:"flex flex-row items-start justify-between mt-3"},Af={class:"flex flex-col"},Nf={class:"flex flex-col justify-center items-center border w-[300px] h-[300px]"},Cf={key:0,class:"w-full text-center"},If=["src"],Sf={class:"flex flex-col items-center",style:{width:"300px",height:"300px"}},xf={class:"text-[#999] mt-05 flex justify-center mt-4"},Of={class:"w-full flex justify-end space-x-5 mt-5 px-6"},Df=["loading"],Lf=c.defineComponent({__name:"index",emits:["cancel","ok"],setup(e,{expose:t,emit:a}){const n=a,i=c.ref({coverUrl:"",inputValue:"",uploadType:2,videoHost:"",videoUrl:""}),r=c.ref(),u=c.ref({autoCrop:!0,autoCropArea:1,background:!0,center:!0,cropBoxResizable:!0,dragMode:"move",preview:".before",toggleDragModeOnDblclick:!0,viewMode:1,zoomOnWheel:!0}),o=c.ref(!1),l=c.ref({afterImg:"",image:null,myCropper:null}),h=c.ref("image/jpeg"),m=U=>{console.log(U);const _=U.target.files[0];if(_){_.name&&(i.value.inputValue=_.name);const w=new FileReader;w.onload=Y=>{var se,be;console.log("e?.target?.result",(se=Y==null?void 0:Y.target)==null?void 0:se.result),p((be=Y==null?void 0:Y.target)==null?void 0:be.result)},w.readAsDataURL(_)}};async function p(U){if(!U)return;await ae();const _=U;l.value.image=_,l.value.image&&T()}function T(){const U=document.querySelector("#imgId");U&&U.addEventListener("load",()=>{q(),l.value.myCropper=new Tr(U,u.value)})}const A=c.ref(!1),I=c.ref();function R(U,_,w,Y){I.value=Y,r.value=U,U&&U.aspectRatio&&(u.value.aspectRatio=U.aspectRatio),w&&(i.value.inputValue=w),A.value=!0,_&&p(_)}function M(){A.value=!1}const B=()=>{var _,w;if(!l.value.myCropper)return;o.value=!0,l.value.afterImg=l.value.myCropper.getCroppedCanvas({height:(_=r.value)==null?void 0:_.height,imageSmoothingQuality:"high",width:(w=r.value)==null?void 0:w.width}).toDataURL(h.value);const U=cf(l.value.afterImg,i.value.inputValue);n("ok",{options:U,element:I.value}),o.value=!1,ae(),q(),M()};function W(){ae(),q(),M(),n("cancel")}function q(){l.value.myCropper&&l.value.myCropper.destroy()}function ae(){l.value.image=""}return t({handleCloseCropper:M,handleOpenCropper:R}),(U,_)=>{var w,Y,se;return A.value?(c.openBlock(),c.createElementBlock("div",lf,[c.createElementVNode("div",df,[c.createElementVNode("div",hf,[_[1]||(_[1]=c.createElementVNode("span",{class:"text-base font-semibold text-[#333]"},"图片裁剪",-1)),c.createElementVNode("span",{class:"text-lg cursor-pointer text-[#999] iconfont icon-shanchu2",onClick:c.withModifiers(W,["stop"])})]),c.createElementVNode("div",ff,[c.createElementVNode("div",mf,[c.createElementVNode("div",Ef,[c.createElementVNode("div",pf,[c.createElementVNode("div",Tf,[c.createElementVNode("div",bf,[c.createElementVNode("div",gf,[c.createElementVNode("input",{type:"file",accept:"image/*",onClick:_[0]||(_[0]=c.withModifiers(()=>{},["stop"])),contenteditable:"false",ref:"fileInput",onChange:m,class:"absolute top-0 left-0 w-[110px] h-[40px] opacity-0 cursor-pointer"},null,544),_[2]||(_[2]=c.createElementVNode("span",{id:"uploadHandler",class:"cursor-pointer"}," 选择/更换图片 ",-1))]),_[3]||(_[3]=c.createElementVNode("span",{class:"text-sm text-[#999] ml-3"},"滚动鼠标放大或缩小图片",-1))]),c.createElementVNode("div",_f,[c.createElementVNode("div",Af,[c.createElementVNode("div",Nf,[l.value.image?c.createCommentVNode("",!0):(c.openBlock(),c.createElementBlock("div",Cf," 请上传图片 ")),c.createElementVNode("img",{id:"imgId",src:l.value.image,style:{width:"300px"}},null,8,If)])]),c.createElementVNode("div",Sf,[_[4]||(_[4]=c.createElementVNode("div",{class:"before w-[270px] h-[200px] pr-[70px] border"},null,-1)),c.createElementVNode("div",xf," 预览画像 "+c.toDisplayString(((w=r.value)==null?void 0:w.width)||"")+" "+c.toDisplayString((Y=r.value)!=null&&Y.width?"x":"")+" "+c.toDisplayString(((se=r.value)==null?void 0:se.height)||""),1)])])])])])]),c.createElementVNode("div",Of,[c.createElementVNode("span",{loading:o.value,class:"!w-22 bg-[#474AFF] text-white rounded py-2 px-6 cursor-pointer",type:"primary",onClick:B}," 确认 ",8,Df),c.createElementVNode("span",{class:"!w-22 border border-[#DEDEDE] text-[#666] rounded py-2 px-6 cursor-pointer",onClick:W},"取消")])])])])):c.createCommentVNode("",!0)}}}),yf=c.defineComponent({name:"CustomIcon",props:{iconName:{type:String,required:!0}},setup(e){return{iconClass:c.computed(()=>`${e.iconName}`)}}});function Rf(e,t,a,n,i,r){return c.openBlock(),c.createElementBlock("span",{style:{position:"unset",color:"unset",top:"unset",left:"unset",right:"unset",transform:"unset","font-size":"unset"},class:c.normalizeClass(`iconfont icon-${e.iconClass} text-4xl overflow-hidden flex justify-center items-center`)},null,2)}const kf=Ke(yf,[["render",Rf]]),Mf=c.defineComponent({name:"GpModal",props:{visible:{type:Boolean,required:!0},title:{type:String,default:""},okText:{type:String,default:"确定"},cancelText:{type:String,default:"取消"},showOkButton:{type:Boolean,default:!0},showCancelButton:{type:Boolean,default:!0},showCloseButton:{type:Boolean,default:!0}},emits:["update:visible","ok","cancel"],setup(e,{emit:t}){const{visible:a,okText:n,cancelText:i,showCloseButton:r}=c.toRefs(e);return{visible:a,okText:n,cancelText:i,showCloseButton:r,onClose:()=>{t("cancel"),t("update:visible",!1)},onOk:()=>{t("ok"),t("update:visible",!1)},onCancel:()=>{t("cancel"),t("update:visible",!1)}}}}),Pf={class:"bg-white rounded-lg shadow-xl w-ful"},vf={class:"p-4 border-b border-gray-200 relative flex items-center justify-between"},Bf={key:0,class:"text-lg font-semibold"},wf={class:"p-4"},Uf={key:0,class:"p-4 border-t border-gray-200 flex justify-end space-x-2"};function Ff(e,t,a,n,i,r){return e.visible?(c.openBlock(),c.createElementBlock("div",{key:0,class:"fixed inset-0 z-[99999] flex items-center justify-center bg-gray-900 bg-opacity-50",onClick:t[3]||(t[3]=c.withModifiers((...u)=>e.onClose&&e.onClose(...u),["self"]))},[c.createElementVNode("div",Pf,[c.createElementVNode("div",vf,[e.title?(c.openBlock(),c.createElementBlock("h3",Bf,c.toDisplayString(e.title),1)):c.createCommentVNode("",!0),c.renderSlot(e.$slots,"header"),e.showCloseButton?(c.openBlock(),c.createElementBlock("button",{key:1,class:"text-gray-400 hover:text-gray-600",onClick:t[0]||(t[0]=(...u)=>e.onClose&&e.onClose(...u)),"aria-label":"Close"},t[4]||(t[4]=[c.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor"},[c.createElementVNode("path",{"fill-rule":"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z","clip-rule":"evenodd"})],-1)]))):c.createCommentVNode("",!0)]),c.createElementVNode("div",wf,[c.renderSlot(e.$slots,"default")]),e.showCancelButton||e.showOkButton?(c.openBlock(),c.createElementBlock("div",Uf,[c.renderSlot(e.$slots,"footer",{},()=>[e.showCancelButton?(c.openBlock(),c.createElementBlock("button",{key:0,class:"px-4 py-2 text-sm font-medium text-gray-700 bg-gray-100 rounded hover:bg-gray-200",onClick:t[1]||(t[1]=(...u)=>e.onCancel&&e.onCancel(...u))},c.toDisplayString(e.cancelText),1)):c.createCommentVNode("",!0),e.showOkButton?(c.openBlock(),c.createElementBlock("button",{key:1,class:"px-4 py-2 text-sm font-medium text-white bg-blue-600 rounded hover:bg-blue-700",onClick:t[2]||(t[2]=(...u)=>e.onOk&&e.onOk(...u))},c.toDisplayString(e.okText),1)):c.createCommentVNode("",!0)])])):c.createCommentVNode("",!0)])])):c.createCommentVNode("",!0)}const Hf=Ke(Mf,[["render",Ff]]),Vf={class:"p-4 flex flex-wrap max-h-[500px] overflow-y-auto w-[640px]"},Yf=c.defineComponent({__name:"IconModal",props:{icons:{type:Array,default:()=>[]}},emits:["ok"],setup(e,{expose:t,emit:a}){const n=e,i=c.ref(n.icons||[]);c.watch(()=>n.icons,p=>{i.value=p||[]},{immediate:!0});const r=a,u=c.ref(!1),o=c.ref();function l(p){u.value=!0,o.value=p}function h(p){m(),r("ok",{icon:p,element:o.value})}function m(){u.value=!1}return t({openModal:l,closeModal:m}),(p,T)=>(c.openBlock(),c.createBlock(Hf,{visible:u.value,"onUpdate:visible":T[0]||(T[0]=A=>u.value=A),title:"选择图标",onOk:m,onCancel:m,showCancelButton:!1,showOkButton:!1},{default:c.withCtx(()=>[c.createElementVNode("div",Vf,[(c.openBlock(!0),c.createElementBlock(c.Fragment,null,c.renderList(i.value,A=>(c.openBlock(),c.createBlock(kf,{key:A,class:"w-12 h-12 mx-1 mb-2 border cursor-pointer hover:border-gray-400 hover:bg-gray-200",iconName:A,onClick:c.withModifiers(I=>h(A),["stop"]),title:A},null,8,["iconName","onClick","title"]))),128))])]),_:1},8,["visible"]))}}),qf={class:"flex"},$f={key:0,class:"text-lg font-bold border-b p-2"},Wf={class:"text-sm font-thin text-gray-500"},Gf=["innerHTML"],Xf=["innerHTML"],Qf={class:"flex-1"},jf={key:0,class:"text-lg font-bold border-b p-2"},zf={class:"p-2"},Kf={key:0,class:"text-red-500 text-xs mt-2"},Zf={key:0,class:"text-lg font-bold border-b p-2"},Jf={class:"text-sm font-thin text-gray-500"},em={class:"p-2"},br=Ke(c.defineComponent({__name:"Designer",props:{mode:{default:"design"},template:{},css:{},previewWidth:{default:375},uploadByFile:{},icons:{},rules:{},preview:{type:Boolean,default:!0},showTitle:{type:Boolean,default:!0}},emits:["update:modelValue","update:element"],setup(e,{emit:t}){const a=e,n=t,i=c.ref(a.template),r=c.ref();c.watch(()=>a.template,C=>{i.value=C},{immediate:!0}),c.watch(()=>i.value,C=>{C&&(r.value=U(C))},{immediate:!0}),c.watch(()=>a.css,C=>{C.forEach(D=>{if(document.querySelector(`link[href="${D}"]`))return;const P=document.createElement("link");P.rel="stylesheet",P.href=D,document.head.appendChild(P)})},{immediate:!0});const u=c.ref(a.mode);c.watch(()=>r.value,C=>{C&&n("update:element",C)},{immediate:!0});const o=c.ref(""),l=c.ref("");let h=Us("",{},!1);c.watch(()=>l.value,C=>{n("update:modelValue",C)},{immediate:!0});const m=c.ref(),p=c.ref(),T=c.ref(),A=c.ref(),I=c.ref("");function R(C){console.log("选择",C),T.value=C}function M(C,D=""){if(D){const P=B(r.value,D);P?A.value=P:A.value=C}else A.value=C}function B(C,D){if(C.xpath===D)return C;if(C.children&&C.children.length)for(const P of C.children){const H=B(P,D);if(H)return H}}function W(C,D){var P,H;return C.tag===D.tag&&((P=C.children)==null?void 0:P.length)===((H=D.children)==null?void 0:H.length)}function q(C){var P,H,ie,ge;if(T.value.xpath==C.xpath){if(T.value){if(C.type===Q.Block){var D=!0;const oe=B(r.value,T.value.parentxpath||"");if(oe&&oe.children&&oe.children.forEach(K=>{if(K.tag!=T.value.tag||!W(K,T.value)){D=!1;return}}),!D){j.error("同级结构不一致,错误配置!");return}}if(T.value.rule=C.rule,T.value.type=C.type,(P=C.rule)!=null&&P.isThemeColor?(C.attrs.class+="theme_color",C.attrs.style&&(C.attrs.style=void 0)):(console.log("e111",(H=C.attrs.class)==null?void 0:H.includes("theme_color")),(ie=C.attrs.class)!=null&&ie.includes("theme_color")&&(C.attrs.class=C.attrs.class.replace("theme_color"," "))),T.value.type===Q.Block){const oe=B(r.value,T.value.parentxpath||"");oe&&oe.children&&(oe.children.forEach(K=>{if(K.tag!=T.value.tag||!W(K,T.value)){j.error("同级结构不一致,无法配置为块类型");return}}),oe.children.forEach(K=>{var pe;K.tag===T.value.tag&&(K.rule=C.rule,K.type=C.type,(pe=K.attrs.class)!=null&&pe.includes(" mb40 relative")||(K.attrs.class+=" mb40 relative"))}))}else(ge=T.value.attrs.class)!=null&&ge.includes(" mb40 relative")&&(T.value.attrs.class=T.value.attrs.class.replace(" mb40 relative"," "))}j.success("保存成功")}}function ae(C){l.value=C}function U(C){h=Us(C);const D=h("body").children().toArray().map(P=>_(h(P)));return l.value=h("body").html()||"",D[0]}function _(C,D=""){var oe;function P(K){if(!K||!K[0])return"";const pe=[];let ht=K;for(;ht.length&&ht[0].tagName!=="html";){const gr=ht[0].tagName,am=ht.parent().children(gr).index(ht)+1;pe.unshift(`${gr}[${am}]`),ht=ht.parent()}return"/html/"+pe.join("/")}const H=P(C).replace("/html/body[1]",""),ie=C.children().toArray().map(K=>_(h(K),H)),ge=(oe=a.rules)==null?void 0:oe.find(K=>K.xpath===H);return{tag:C[0].tagName,text:C.contents().not(C.children()).text().trim(),attrs:C[0].attribs,children:ie,xpath:H,parentxpath:D,type:(ge==null?void 0:ge.type)||Q.None,rule:(ge==null?void 0:ge.rule)||{}}}function w(C){console.log("更新子节点的文本",C);const D=B(r.value,C.element.xpath);if(D){const P=c.toRaw(D);P.editText=C.newText}}function Y(C,D=""){function P(H,ie){var K;const oe=(ie?((K=B(r.value,ie))==null?void 0:K.children)||[]:[r.value]).filter(pe=>pe.tag===H.tag).indexOf(H)+1;return`${ie}/${H.tag}[${oe}]`}C.xpath=P(C,D),C.parentxpath=D,(C.children||[]).forEach(H=>Y(H,C.xpath))}function se({action:C,element:D,newBlock:P}){console.log("块操作",C,D,P);const H=B(r.value,D.parentxpath||"");if(!H||!H.children)return;const ie=H.children.findIndex(pe=>pe===D);if(ie===-1)return;const ge=H.children.length,{minBlock:oe,maxBlock:K}=D.rule;if((C==="add"||C==="copy")&&ge>=(K||1/0)){I.value=`无法添加更多块。最大块数量为 ${K}`,j.error(I.value);return}switch(C){case"add":if(P){const pe={...P,xpath:"",children:JSON.parse(JSON.stringify(P.children))};H.children.splice(ie+1,0,pe)}break;case"copy":if(P){const pe={...P,xpath:"",children:JSON.parse(JSON.stringify(P.children))};H.children.splice(ie+1,0,pe)}break;case"moveUp":if(ie>0){const[pe]=H.children.splice(ie,1);H.children.splice(ie-1,0,pe)}break;case"moveDown":if(ie<H.children.length-1){const[pe]=H.children.splice(ie,1);H.children.splice(ie+1,0,pe)}break;case"delete":if(ge<=(oe||0)){I.value=`无法删除更多块。最小块数量为 ${oe}`,j.error(I.value);return}H.children.splice(ie,1);break}I.value="",Y(r.value)}function be(C,D){let P=D.attrs.class.replace(/icon-\S+/g,`icon-${C}`);D.attrs.class=P}function Pe(C,D){console.log("comfireImg",C),D.attrs.src=C}function ye(C){const D=B(r.value,C.element.xpath),P=C.options;if(typeof P=="object"){console.log("e1",C),D.attrs.alt=P.name;const H=new FileReader;H.onload=ie=>{var oe;let ge=(oe=ie==null?void 0:ie.target)==null?void 0:oe.result;D.attrs.src=ge,console.log(" element.attrs",D.attrs),o.value=new Date().getTime().toString()},H.readAsDataURL(P)}else console.log("e2",C),D.attrs.src=P}function Re(C){const{icon:D}=C,P=B(r.value,C.element.xpath);let H=P.attrs.class.replace(/icon-\S+/g,`icon-${D}`);P.attrs.class=H,o.value=new Date().getTime().toString()}const me=c.ref(a.previewWidth),z=c.ref(375);let xe=c.ref(!1),ve=c.ref(""),tt=0,O=0;function L(C){ve.value=C,xe.value=!0,tt=event.clientX,C==="preview"?O=me.value:C==="structure"&&(O=z.value),window.addEventListener("mousemove",ne),window.addEventListener("mouseup",Ee)}function ne(C){if(!xe.value)return;const D=C.clientX-tt;ve.value==="preview"?me.value=Math.max(200,O+D):ve.value==="structure"&&(z.value=Math.max(200,O-D))}function Ee(){xe.value=!1,ve.value="",window.removeEventListener("mousemove",ne),window.removeEventListener("mouseup",Ee)}return(C,D)=>(c.openBlock(),c.createElementBlock("div",qf,[C.preview?(c.openBlock(),c.createElementBlock("div",{key:0,class:"border-l overflow-auto resize-area",style:c.normalizeStyle({width:me.value+"px"})},[C.showTitle?(c.openBlock(),c.createElementBlock("h2",$f,[D[2]||(D[2]=c.createTextVNode(" 实时预览 ")),c.createElementVNode("span",Wf,c.toDisplayString(me.value)+"px",1)])):c.createCommentVNode("",!0),c.createElementVNode("div",null,[l.value?(c.openBlock(),c.createElementBlock("div",{key:0,innerHTML:l.value},null,8,Gf)):(c.openBlock(),c.createElementBlock("div",{key:1,innerHTML:c.unref(h)("body").html()},null,8,Xf))])],4)):c.createCommentVNode("",!0),C.preview?(c.openBlock(),c.createElementBlock("div",{key:1,class:"resizer",onMousedown:D[0]||(D[0]=P=>L("preview"))},null,32)):c.createCommentVNode("",!0),c.createElementVNode("div",Qf,[C.showTitle?(c.openBlock(),c.createElementBlock("h2",jf,"结构渲染")):c.createCommentVNode("",!0),c.createElementVNode("div",zf,[I.value?(c.openBlock(),c.createElementBlock("div",Kf,c.toDisplayString(I.value),1)):c.createCommentVNode("",!0),r.value?(c.openBlock(),c.createBlock(Vd,{key:1,cropper:m.value,icon:p.value,mode:C.mode,icons:C.icons,r:o.value,element:r.value,selectedElement:T.value,hoveredElement:A.value,onSelectElement:R,onHoverElement:M,onContentUpdated:ae,onUpdateText:w,onBlockAction:se,onAddIcon:be,onUpload:Pe},null,8,["cropper","icon","mode","icons","r","element","selectedElement","hoveredElement"])):c.createCommentVNode("",!0)])]),u.value=="design"?(c.openBlock(),c.createElementBlock("div",{key:2,class:"resizer",onMousedown:D[1]||(D[1]=P=>L("structure"))},null,32)):c.createCommentVNode("",!0),u.value=="design"?(c.openBlock(),c.createElementBlock("div",{key:3,class:"resize-area overflow-auto",style:c.normalizeStyle({width:z.value+"px"})},[C.showTitle?(c.openBlock(),c.createElementBlock("h2",Zf,[D[3]||(D[3]=c.createTextVNode(" 节点属性 ")),c.createElementVNode("span",Jf,c.toDisplayString(z.value)+"px",1)])):c.createCommentVNode("",!0),c.createElementVNode("div",em,[T.value?(c.openBlock(),c.createBlock(bh,{key:0,element:T.value,onUpdateElement:q},null,8,["element"])):c.createCommentVNode("",!0)])],4)):c.createCommentVNode("",!0),c.createVNode(Lf,{ref_key:"cropperRef",ref:m,onOk:ye},null,512),c.createVNode(Yf,{icons:C.icons,ref_key:"iconRef",ref:p,onOk:Re},null,8,["icons"])]))}}),[["__scopeId","data-v-1f5b54a3"]]),tm={install(e){e.component("Designer",br)}};$e.Designer=br,$e.default=tm,Object.defineProperties($e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
17
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var La=typeof window<"u"&&typeof window.document<"u",Fe=La?window:{},Ln=La&&Fe.document.documentElement?"ontouchstart"in Fe.document.documentElement:!1,yn=La?"PointerEvent"in Fe:!1,J="cropper",Rn="all",Ws="crop",Gs="move",Xs="zoom",ct="e",lt="w",At="s",Ze="n",Gt="ne",Xt="nw",Qt="se",jt="sw",kn="".concat(J,"-crop"),Qs="".concat(J,"-disabled"),Ce="".concat(J,"-hidden"),js="".concat(J,"-hide"),Oh="".concat(J,"-invisible"),ya="".concat(J,"-modal"),Mn="".concat(J,"-move"),zt="".concat(J,"Action"),Ra="".concat(J,"Preview"),Pn="crop",zs="move",Ks="none",vn="crop",Bn="cropend",wn="cropmove",Un="cropstart",Zs="dblclick",Dh=Ln?"touchstart":"mousedown",Lh=Ln?"touchmove":"mousemove",yh=Ln?"touchend touchcancel":"mouseup",Js=yn?"pointerdown":Dh,er=yn?"pointermove":Lh,tr=yn?"pointerup pointercancel":yh,ar="ready",nr="resize",ir="wheel",Fn="zoom",sr="image/jpeg",Rh=/^e|w|s|n|se|sw|ne|nw|all|crop|move|zoom$/,kh=/^data:/,Mh=/^data:image\/jpeg;base64,/,Ph=/^img|canvas$/i,rr=200,ur=100,or={viewMode:0,dragMode:Pn,initialAspectRatio:NaN,aspectRatio:NaN,data:null,preview:"",responsive:!0,restore:!0,checkCrossOrigin:!0,checkOrientation:!0,modal:!0,guides:!0,center:!0,highlight:!0,background:!0,autoCrop:!0,autoCropArea:.8,movable:!0,rotatable:!0,scalable:!0,zoomable:!0,zoomOnTouch:!0,zoomOnWheel:!0,wheelZoomRatio:.1,cropBoxMovable:!0,cropBoxResizable:!0,toggleDragModeOnDblclick:!0,minCanvasWidth:0,minCanvasHeight:0,minCropBoxWidth:0,minCropBoxHeight:0,minContainerWidth:rr,minContainerHeight:ur,ready:null,cropstart:null,cropmove:null,cropend:null,crop:null,zoom:null},vh='<div class="cropper-container" touch-action="none"><div class="cropper-wrap-box"><div class="cropper-canvas"></div></div><div class="cropper-drag-box"></div><div class="cropper-crop-box"><span class="cropper-view-box"></span><span class="cropper-dashed dashed-h"></span><span class="cropper-dashed dashed-v"></span><span class="cropper-center"></span><span class="cropper-face"></span><span class="cropper-line line-e" data-cropper-action="e"></span><span class="cropper-line line-n" data-cropper-action="n"></span><span class="cropper-line line-w" data-cropper-action="w"></span><span class="cropper-line line-s" data-cropper-action="s"></span><span class="cropper-point point-e" data-cropper-action="e"></span><span class="cropper-point point-n" data-cropper-action="n"></span><span class="cropper-point point-w" data-cropper-action="w"></span><span class="cropper-point point-s" data-cropper-action="s"></span><span class="cropper-point point-ne" data-cropper-action="ne"></span><span class="cropper-point point-nw" data-cropper-action="nw"></span><span class="cropper-point point-sw" data-cropper-action="sw"></span><span class="cropper-point point-se" data-cropper-action="se"></span></div></div>',Bh=Number.isNaN||Fe.isNaN;function V(e){return typeof e=="number"&&!Bh(e)}var cr=function(t){return t>0&&t<1/0};function Hn(e){return typeof e>"u"}function dt(e){return On(e)==="object"&&e!==null}var wh=Object.prototype.hasOwnProperty;function Nt(e){if(!dt(e))return!1;try{var t=e.constructor,a=t.prototype;return t&&a&&wh.call(a,"isPrototypeOf")}catch{return!1}}function Ie(e){return typeof e=="function"}var Uh=Array.prototype.slice;function lr(e){return Array.from?Array.from(e):Uh.call(e)}function re(e,t){return e&&Ie(t)&&(Array.isArray(e)||V(e.length)?lr(e).forEach(function(a,n){t.call(e,a,n,e)}):dt(e)&&Object.keys(e).forEach(function(a){t.call(e,e[a],a,e)})),e}var ee=Object.assign||function(t){for(var a=arguments.length,n=new Array(a>1?a-1:0),i=1;i<a;i++)n[i-1]=arguments[i];return dt(t)&&n.length>0&&n.forEach(function(r){dt(r)&&Object.keys(r).forEach(function(u){t[u]=r[u]})}),t},Fh=/\.\d*(?:0|9){12}\d*$/;function Ct(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1e11;return Fh.test(e)?Math.round(e*t)/t:e}var Hh=/^width|height|left|top|marginLeft|marginTop$/;function Je(e,t){var a=e.style;re(t,function(n,i){Hh.test(i)&&V(n)&&(n="".concat(n,"px")),a[i]=n})}function Vh(e,t){return e.classList?e.classList.contains(t):e.className.indexOf(t)>-1}function he(e,t){if(t){if(V(e.length)){re(e,function(n){he(n,t)});return}if(e.classList){e.classList.add(t);return}var a=e.className.trim();a?a.indexOf(t)<0&&(e.className="".concat(a," ").concat(t)):e.className=t}}function He(e,t){if(t){if(V(e.length)){re(e,function(a){He(a,t)});return}if(e.classList){e.classList.remove(t);return}e.className.indexOf(t)>=0&&(e.className=e.className.replace(t,""))}}function It(e,t,a){if(t){if(V(e.length)){re(e,function(n){It(n,t,a)});return}a?he(e,t):He(e,t)}}var Yh=/([a-z\d])([A-Z])/g;function Vn(e){return e.replace(Yh,"$1-$2").toLowerCase()}function Yn(e,t){return dt(e[t])?e[t]:e.dataset?e.dataset[t]:e.getAttribute("data-".concat(Vn(t)))}function Kt(e,t,a){dt(a)?e[t]=a:e.dataset?e.dataset[t]=a:e.setAttribute("data-".concat(Vn(t)),a)}function qh(e,t){if(dt(e[t]))try{delete e[t]}catch{e[t]=void 0}else if(e.dataset)try{delete e.dataset[t]}catch{e.dataset[t]=void 0}else e.removeAttribute("data-".concat(Vn(t)))}var dr=/\s\s*/,hr=function(){var e=!1;if(La){var t=!1,a=function(){},n=Object.defineProperty({},"once",{get:function(){return e=!0,t},set:function(r){t=r}});Fe.addEventListener("test",a,n),Fe.removeEventListener("test",a,n)}return e}();function Me(e,t,a){var n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{},i=a;t.trim().split(dr).forEach(function(r){if(!hr){var u=e.listeners;u&&u[r]&&u[r][a]&&(i=u[r][a],delete u[r][a],Object.keys(u[r]).length===0&&delete u[r],Object.keys(u).length===0&&delete e.listeners)}e.removeEventListener(r,i,n)})}function Le(e,t,a){var n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{},i=a;t.trim().split(dr).forEach(function(r){if(n.once&&!hr){var u=e.listeners,o=u===void 0?{}:u;i=function(){delete o[r][a],e.removeEventListener(r,i,n);for(var h=arguments.length,m=new Array(h),p=0;p<h;p++)m[p]=arguments[p];a.apply(e,m)},o[r]||(o[r]={}),o[r][a]&&e.removeEventListener(r,o[r][a],n),o[r][a]=i,e.listeners=o}e.addEventListener(r,i,n)})}function St(e,t,a){var n;return Ie(Event)&&Ie(CustomEvent)?n=new CustomEvent(t,{detail:a,bubbles:!0,cancelable:!0}):(n=document.createEvent("CustomEvent"),n.initCustomEvent(t,!0,!0,a)),e.dispatchEvent(n)}function fr(e){var t=e.getBoundingClientRect();return{left:t.left+(window.pageXOffset-document.documentElement.clientLeft),top:t.top+(window.pageYOffset-document.documentElement.clientTop)}}var qn=Fe.location,$h=/^(\w+:)\/\/([^:/?#]*):?(\d*)/i;function mr(e){var t=e.match($h);return t!==null&&(t[1]!==qn.protocol||t[2]!==qn.hostname||t[3]!==qn.port)}function Er(e){var t="timestamp=".concat(new Date().getTime());return e+(e.indexOf("?")===-1?"?":"&")+t}function Zt(e){var t=e.rotate,a=e.scaleX,n=e.scaleY,i=e.translateX,r=e.translateY,u=[];V(i)&&i!==0&&u.push("translateX(".concat(i,"px)")),V(r)&&r!==0&&u.push("translateY(".concat(r,"px)")),V(t)&&t!==0&&u.push("rotate(".concat(t,"deg)")),V(a)&&a!==1&&u.push("scaleX(".concat(a,")")),V(n)&&n!==1&&u.push("scaleY(".concat(n,")"));var o=u.length?u.join(" "):"none";return{WebkitTransform:o,msTransform:o,transform:o}}function Wh(e){var t=Vs({},e),a=0;return re(e,function(n,i){delete t[i],re(t,function(r){var u=Math.abs(n.startX-r.startX),o=Math.abs(n.startY-r.startY),l=Math.abs(n.endX-r.endX),h=Math.abs(n.endY-r.endY),m=Math.sqrt(u*u+o*o),p=Math.sqrt(l*l+h*h),T=(p-m)/m;Math.abs(T)>Math.abs(a)&&(a=T)})}),a}function ka(e,t){var a=e.pageX,n=e.pageY,i={endX:a,endY:n};return t?i:Vs({startX:a,startY:n},i)}function Gh(e){var t=0,a=0,n=0;return re(e,function(i){var r=i.startX,u=i.startY;t+=r,a+=u,n+=1}),t/=n,a/=n,{pageX:t,pageY:a}}function et(e){var t=e.aspectRatio,a=e.height,n=e.width,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"contain",r=cr(n),u=cr(a);if(r&&u){var o=a*t;i==="contain"&&o>n||i==="cover"&&o<n?a=n/t:n=a*t}else r?a=n/t:u&&(n=a*t);return{width:n,height:a}}function Xh(e){var t=e.width,a=e.height,n=e.degree;if(n=Math.abs(n)%180,n===90)return{width:a,height:t};var i=n%90*Math.PI/180,r=Math.sin(i),u=Math.cos(i),o=t*u+a*r,l=t*r+a*u;return n>90?{width:l,height:o}:{width:o,height:l}}function Qh(e,t,a,n){var i=t.aspectRatio,r=t.naturalWidth,u=t.naturalHeight,o=t.rotate,l=o===void 0?0:o,h=t.scaleX,m=h===void 0?1:h,p=t.scaleY,T=p===void 0?1:p,A=a.aspectRatio,I=a.naturalWidth,R=a.naturalHeight,M=n.fillColor,B=M===void 0?"transparent":M,W=n.imageSmoothingEnabled,q=W===void 0?!0:W,ae=n.imageSmoothingQuality,U=ae===void 0?"low":ae,_=n.maxWidth,w=_===void 0?1/0:_,Y=n.maxHeight,se=Y===void 0?1/0:Y,be=n.minWidth,Pe=be===void 0?0:be,ye=n.minHeight,Re=ye===void 0?0:ye,me=document.createElement("canvas"),z=me.getContext("2d"),xe=et({aspectRatio:A,width:w,height:se}),ve=et({aspectRatio:A,width:Pe,height:Re},"cover"),tt=Math.min(xe.width,Math.max(ve.width,I)),O=Math.min(xe.height,Math.max(ve.height,R)),L=et({aspectRatio:i,width:w,height:se}),ne=et({aspectRatio:i,width:Pe,height:Re},"cover"),Ee=Math.min(L.width,Math.max(ne.width,r)),C=Math.min(L.height,Math.max(ne.height,u)),D=[-Ee/2,-C/2,Ee,C];return me.width=Ct(tt),me.height=Ct(O),z.fillStyle=B,z.fillRect(0,0,tt,O),z.save(),z.translate(tt/2,O/2),z.rotate(l*Math.PI/180),z.scale(m,T),z.imageSmoothingEnabled=q,z.imageSmoothingQuality=U,z.drawImage.apply(z,[e].concat($s(D.map(function(P){return Math.floor(Ct(P))})))),z.restore(),me}var pr=String.fromCharCode;function jh(e,t,a){var n="";a+=t;for(var i=t;i<a;i+=1)n+=pr(e.getUint8(i));return n}var zh=/^data:.*,/;function Kh(e){var t=e.replace(zh,""),a=atob(t),n=new ArrayBuffer(a.length),i=new Uint8Array(n);return re(i,function(r,u){i[u]=a.charCodeAt(u)}),n}function Zh(e,t){for(var a=[],n=8192,i=new Uint8Array(e);i.length>0;)a.push(pr.apply(null,lr(i.subarray(0,n)))),i=i.subarray(n);return"data:".concat(t,";base64,").concat(btoa(a.join("")))}function Jh(e){var t=new DataView(e),a;try{var n,i,r;if(t.getUint8(0)===255&&t.getUint8(1)===216)for(var u=t.byteLength,o=2;o+1<u;){if(t.getUint8(o)===255&&t.getUint8(o+1)===225){i=o;break}o+=1}if(i){var l=i+4,h=i+10;if(jh(t,l,4)==="Exif"){var m=t.getUint16(h);if(n=m===18761,(n||m===19789)&&t.getUint16(h+2,n)===42){var p=t.getUint32(h+4,n);p>=8&&(r=h+p)}}}if(r){var T=t.getUint16(r,n),A,I;for(I=0;I<T;I+=1)if(A=r+I*12+2,t.getUint16(A,n)===274){A+=8,a=t.getUint16(A,n),t.setUint16(A,1,n);break}}}catch{a=1}return a}function ef(e){var t=0,a=1,n=1;switch(e){case 2:a=-1;break;case 3:t=-180;break;case 4:n=-1;break;case 5:t=90,n=-1;break;case 6:t=90;break;case 7:t=90,a=-1;break;case 8:t=-90;break}return{rotate:t,scaleX:a,scaleY:n}}var tf={render:function(){this.initContainer(),this.initCanvas(),this.initCropBox(),this.renderCanvas(),this.cropped&&this.renderCropBox()},initContainer:function(){var t=this.element,a=this.options,n=this.container,i=this.cropper,r=Number(a.minContainerWidth),u=Number(a.minContainerHeight);he(i,Ce),He(t,Ce);var o={width:Math.max(n.offsetWidth,r>=0?r:rr),height:Math.max(n.offsetHeight,u>=0?u:ur)};this.containerData=o,Je(i,{width:o.width,height:o.height}),he(t,Ce),He(i,Ce)},initCanvas:function(){var t=this.containerData,a=this.imageData,n=this.options.viewMode,i=Math.abs(a.rotate)%180===90,r=i?a.naturalHeight:a.naturalWidth,u=i?a.naturalWidth:a.naturalHeight,o=r/u,l=t.width,h=t.height;t.height*o>t.width?n===3?l=t.height*o:h=t.width/o:n===3?h=t.width/o:l=t.height*o;var m={aspectRatio:o,naturalWidth:r,naturalHeight:u,width:l,height:h};this.canvasData=m,this.limited=n===1||n===2,this.limitCanvas(!0,!0),m.width=Math.min(Math.max(m.width,m.minWidth),m.maxWidth),m.height=Math.min(Math.max(m.height,m.minHeight),m.maxHeight),m.left=(t.width-m.width)/2,m.top=(t.height-m.height)/2,m.oldLeft=m.left,m.oldTop=m.top,this.initialCanvasData=ee({},m)},limitCanvas:function(t,a){var n=this.options,i=this.containerData,r=this.canvasData,u=this.cropBoxData,o=n.viewMode,l=r.aspectRatio,h=this.cropped&&u;if(t){var m=Number(n.minCanvasWidth)||0,p=Number(n.minCanvasHeight)||0;o>1?(m=Math.max(m,i.width),p=Math.max(p,i.height),o===3&&(p*l>m?m=p*l:p=m/l)):o>0&&(m?m=Math.max(m,h?u.width:0):p?p=Math.max(p,h?u.height:0):h&&(m=u.width,p=u.height,p*l>m?m=p*l:p=m/l));var T=et({aspectRatio:l,width:m,height:p});m=T.width,p=T.height,r.minWidth=m,r.minHeight=p,r.maxWidth=1/0,r.maxHeight=1/0}if(a)if(o>(h?0:1)){var A=i.width-r.width,I=i.height-r.height;r.minLeft=Math.min(0,A),r.minTop=Math.min(0,I),r.maxLeft=Math.max(0,A),r.maxTop=Math.max(0,I),h&&this.limited&&(r.minLeft=Math.min(u.left,u.left+(u.width-r.width)),r.minTop=Math.min(u.top,u.top+(u.height-r.height)),r.maxLeft=u.left,r.maxTop=u.top,o===2&&(r.width>=i.width&&(r.minLeft=Math.min(0,A),r.maxLeft=Math.max(0,A)),r.height>=i.height&&(r.minTop=Math.min(0,I),r.maxTop=Math.max(0,I))))}else r.minLeft=-r.width,r.minTop=-r.height,r.maxLeft=i.width,r.maxTop=i.height},renderCanvas:function(t,a){var n=this.canvasData,i=this.imageData;if(a){var r=Xh({width:i.naturalWidth*Math.abs(i.scaleX||1),height:i.naturalHeight*Math.abs(i.scaleY||1),degree:i.rotate||0}),u=r.width,o=r.height,l=n.width*(u/n.naturalWidth),h=n.height*(o/n.naturalHeight);n.left-=(l-n.width)/2,n.top-=(h-n.height)/2,n.width=l,n.height=h,n.aspectRatio=u/o,n.naturalWidth=u,n.naturalHeight=o,this.limitCanvas(!0,!1)}(n.width>n.maxWidth||n.width<n.minWidth)&&(n.left=n.oldLeft),(n.height>n.maxHeight||n.height<n.minHeight)&&(n.top=n.oldTop),n.width=Math.min(Math.max(n.width,n.minWidth),n.maxWidth),n.height=Math.min(Math.max(n.height,n.minHeight),n.maxHeight),this.limitCanvas(!1,!0),n.left=Math.min(Math.max(n.left,n.minLeft),n.maxLeft),n.top=Math.min(Math.max(n.top,n.minTop),n.maxTop),n.oldLeft=n.left,n.oldTop=n.top,Je(this.canvas,ee({width:n.width,height:n.height},Zt({translateX:n.left,translateY:n.top}))),this.renderImage(t),this.cropped&&this.limited&&this.limitCropBox(!0,!0)},renderImage:function(t){var a=this.canvasData,n=this.imageData,i=n.naturalWidth*(a.width/a.naturalWidth),r=n.naturalHeight*(a.height/a.naturalHeight);ee(n,{width:i,height:r,left:(a.width-i)/2,top:(a.height-r)/2}),Je(this.image,ee({width:n.width,height:n.height},Zt(ee({translateX:n.left,translateY:n.top},n)))),t&&this.output()},initCropBox:function(){var t=this.options,a=this.canvasData,n=t.aspectRatio||t.initialAspectRatio,i=Number(t.autoCropArea)||.8,r={width:a.width,height:a.height};n&&(a.height*n>a.width?r.height=r.width/n:r.width=r.height*n),this.cropBoxData=r,this.limitCropBox(!0,!0),r.width=Math.min(Math.max(r.width,r.minWidth),r.maxWidth),r.height=Math.min(Math.max(r.height,r.minHeight),r.maxHeight),r.width=Math.max(r.minWidth,r.width*i),r.height=Math.max(r.minHeight,r.height*i),r.left=a.left+(a.width-r.width)/2,r.top=a.top+(a.height-r.height)/2,r.oldLeft=r.left,r.oldTop=r.top,this.initialCropBoxData=ee({},r)},limitCropBox:function(t,a){var n=this.options,i=this.containerData,r=this.canvasData,u=this.cropBoxData,o=this.limited,l=n.aspectRatio;if(t){var h=Number(n.minCropBoxWidth)||0,m=Number(n.minCropBoxHeight)||0,p=o?Math.min(i.width,r.width,r.width+r.left,i.width-r.left):i.width,T=o?Math.min(i.height,r.height,r.height+r.top,i.height-r.top):i.height;h=Math.min(h,i.width),m=Math.min(m,i.height),l&&(h&&m?m*l>h?m=h/l:h=m*l:h?m=h/l:m&&(h=m*l),T*l>p?T=p/l:p=T*l),u.minWidth=Math.min(h,p),u.minHeight=Math.min(m,T),u.maxWidth=p,u.maxHeight=T}a&&(o?(u.minLeft=Math.max(0,r.left),u.minTop=Math.max(0,r.top),u.maxLeft=Math.min(i.width,r.left+r.width)-u.width,u.maxTop=Math.min(i.height,r.top+r.height)-u.height):(u.minLeft=0,u.minTop=0,u.maxLeft=i.width-u.width,u.maxTop=i.height-u.height))},renderCropBox:function(){var t=this.options,a=this.containerData,n=this.cropBoxData;(n.width>n.maxWidth||n.width<n.minWidth)&&(n.left=n.oldLeft),(n.height>n.maxHeight||n.height<n.minHeight)&&(n.top=n.oldTop),n.width=Math.min(Math.max(n.width,n.minWidth),n.maxWidth),n.height=Math.min(Math.max(n.height,n.minHeight),n.maxHeight),this.limitCropBox(!1,!0),n.left=Math.min(Math.max(n.left,n.minLeft),n.maxLeft),n.top=Math.min(Math.max(n.top,n.minTop),n.maxTop),n.oldLeft=n.left,n.oldTop=n.top,t.movable&&t.cropBoxMovable&&Kt(this.face,zt,n.width>=a.width&&n.height>=a.height?Gs:Rn),Je(this.cropBox,ee({width:n.width,height:n.height},Zt({translateX:n.left,translateY:n.top}))),this.cropped&&this.limited&&this.limitCanvas(!0,!0),this.disabled||this.output()},output:function(){this.preview(),St(this.element,vn,this.getData())}},af={initPreview:function(){var t=this.element,a=this.crossOrigin,n=this.options.preview,i=a?this.crossOriginUrl:this.url,r=t.alt||"The image to preview",u=document.createElement("img");if(a&&(u.crossOrigin=a),u.src=i,u.alt=r,this.viewBox.appendChild(u),this.viewBoxImage=u,!!n){var o=n;typeof n=="string"?o=t.ownerDocument.querySelectorAll(n):n.querySelector&&(o=[n]),this.previews=o,re(o,function(l){var h=document.createElement("img");Kt(l,Ra,{width:l.offsetWidth,height:l.offsetHeight,html:l.innerHTML}),a&&(h.crossOrigin=a),h.src=i,h.alt=r,h.style.cssText='display:block;width:100%;height:auto;min-width:0!important;min-height:0!important;max-width:none!important;max-height:none!important;image-orientation:0deg!important;"',l.innerHTML="",l.appendChild(h)})}},resetPreview:function(){re(this.previews,function(t){var a=Yn(t,Ra);Je(t,{width:a.width,height:a.height}),t.innerHTML=a.html,qh(t,Ra)})},preview:function(){var t=this.imageData,a=this.canvasData,n=this.cropBoxData,i=n.width,r=n.height,u=t.width,o=t.height,l=n.left-a.left-t.left,h=n.top-a.top-t.top;!this.cropped||this.disabled||(Je(this.viewBoxImage,ee({width:u,height:o},Zt(ee({translateX:-l,translateY:-h},t)))),re(this.previews,function(m){var p=Yn(m,Ra),T=p.width,A=p.height,I=T,R=A,M=1;i&&(M=T/i,R=r*M),r&&R>A&&(M=A/r,I=i*M,R=A),Je(m,{width:I,height:R}),Je(m.getElementsByTagName("img")[0],ee({width:u*M,height:o*M},Zt(ee({translateX:-l*M,translateY:-h*M},t))))}))}},nf={bind:function(){var t=this.element,a=this.options,n=this.cropper;Ie(a.cropstart)&&Le(t,Un,a.cropstart),Ie(a.cropmove)&&Le(t,wn,a.cropmove),Ie(a.cropend)&&Le(t,Bn,a.cropend),Ie(a.crop)&&Le(t,vn,a.crop),Ie(a.zoom)&&Le(t,Fn,a.zoom),Le(n,Js,this.onCropStart=this.cropStart.bind(this)),a.zoomable&&a.zoomOnWheel&&Le(n,ir,this.onWheel=this.wheel.bind(this),{passive:!1,capture:!0}),a.toggleDragModeOnDblclick&&Le(n,Zs,this.onDblclick=this.dblclick.bind(this)),Le(t.ownerDocument,er,this.onCropMove=this.cropMove.bind(this)),Le(t.ownerDocument,tr,this.onCropEnd=this.cropEnd.bind(this)),a.responsive&&Le(window,nr,this.onResize=this.resize.bind(this))},unbind:function(){var t=this.element,a=this.options,n=this.cropper;Ie(a.cropstart)&&Me(t,Un,a.cropstart),Ie(a.cropmove)&&Me(t,wn,a.cropmove),Ie(a.cropend)&&Me(t,Bn,a.cropend),Ie(a.crop)&&Me(t,vn,a.crop),Ie(a.zoom)&&Me(t,Fn,a.zoom),Me(n,Js,this.onCropStart),a.zoomable&&a.zoomOnWheel&&Me(n,ir,this.onWheel,{passive:!1,capture:!0}),a.toggleDragModeOnDblclick&&Me(n,Zs,this.onDblclick),Me(t.ownerDocument,er,this.onCropMove),Me(t.ownerDocument,tr,this.onCropEnd),a.responsive&&Me(window,nr,this.onResize)}},sf={resize:function(){if(!this.disabled){var t=this.options,a=this.container,n=this.containerData,i=a.offsetWidth/n.width,r=a.offsetHeight/n.height,u=Math.abs(i-1)>Math.abs(r-1)?i:r;if(u!==1){var o,l;t.restore&&(o=this.getCanvasData(),l=this.getCropBoxData()),this.render(),t.restore&&(this.setCanvasData(re(o,function(h,m){o[m]=h*u})),this.setCropBoxData(re(l,function(h,m){l[m]=h*u})))}}},dblclick:function(){this.disabled||this.options.dragMode===Ks||this.setDragMode(Vh(this.dragBox,kn)?zs:Pn)},wheel:function(t){var a=this,n=Number(this.options.wheelZoomRatio)||.1,i=1;this.disabled||(t.preventDefault(),!this.wheeling&&(this.wheeling=!0,setTimeout(function(){a.wheeling=!1},50),t.deltaY?i=t.deltaY>0?1:-1:t.wheelDelta?i=-t.wheelDelta/120:t.detail&&(i=t.detail>0?1:-1),this.zoom(-i*n,t)))},cropStart:function(t){var a=t.buttons,n=t.button;if(!(this.disabled||(t.type==="mousedown"||t.type==="pointerdown"&&t.pointerType==="mouse")&&(V(a)&&a!==1||V(n)&&n!==0||t.ctrlKey))){var i=this.options,r=this.pointers,u;t.changedTouches?re(t.changedTouches,function(o){r[o.identifier]=ka(o)}):r[t.pointerId||0]=ka(t),Object.keys(r).length>1&&i.zoomable&&i.zoomOnTouch?u=Xs:u=Yn(t.target,zt),Rh.test(u)&&St(this.element,Un,{originalEvent:t,action:u})!==!1&&(t.preventDefault(),this.action=u,this.cropping=!1,u===Ws&&(this.cropping=!0,he(this.dragBox,ya)))}},cropMove:function(t){var a=this.action;if(!(this.disabled||!a)){var n=this.pointers;t.preventDefault(),St(this.element,wn,{originalEvent:t,action:a})!==!1&&(t.changedTouches?re(t.changedTouches,function(i){ee(n[i.identifier]||{},ka(i,!0))}):ee(n[t.pointerId||0]||{},ka(t,!0)),this.change(t))}},cropEnd:function(t){if(!this.disabled){var a=this.action,n=this.pointers;t.changedTouches?re(t.changedTouches,function(i){delete n[i.identifier]}):delete n[t.pointerId||0],a&&(t.preventDefault(),Object.keys(n).length||(this.action=""),this.cropping&&(this.cropping=!1,It(this.dragBox,ya,this.cropped&&this.options.modal)),St(this.element,Bn,{originalEvent:t,action:a}))}}},rf={change:function(t){var a=this.options,n=this.canvasData,i=this.containerData,r=this.cropBoxData,u=this.pointers,o=this.action,l=a.aspectRatio,h=r.left,m=r.top,p=r.width,T=r.height,A=h+p,I=m+T,R=0,M=0,B=i.width,W=i.height,q=!0,ae;!l&&t.shiftKey&&(l=p&&T?p/T:1),this.limited&&(R=r.minLeft,M=r.minTop,B=R+Math.min(i.width,n.width,n.left+n.width),W=M+Math.min(i.height,n.height,n.top+n.height));var U=u[Object.keys(u)[0]],_={x:U.endX-U.startX,y:U.endY-U.startY},w=function(se){switch(se){case ct:A+_.x>B&&(_.x=B-A);break;case lt:h+_.x<R&&(_.x=R-h);break;case Ze:m+_.y<M&&(_.y=M-m);break;case At:I+_.y>W&&(_.y=W-I);break}};switch(o){case Rn:h+=_.x,m+=_.y;break;case ct:if(_.x>=0&&(A>=B||l&&(m<=M||I>=W))){q=!1;break}w(ct),p+=_.x,p<0&&(o=lt,p=-p,h-=p),l&&(T=p/l,m+=(r.height-T)/2);break;case Ze:if(_.y<=0&&(m<=M||l&&(h<=R||A>=B))){q=!1;break}w(Ze),T-=_.y,m+=_.y,T<0&&(o=At,T=-T,m-=T),l&&(p=T*l,h+=(r.width-p)/2);break;case lt:if(_.x<=0&&(h<=R||l&&(m<=M||I>=W))){q=!1;break}w(lt),p-=_.x,h+=_.x,p<0&&(o=ct,p=-p,h-=p),l&&(T=p/l,m+=(r.height-T)/2);break;case At:if(_.y>=0&&(I>=W||l&&(h<=R||A>=B))){q=!1;break}w(At),T+=_.y,T<0&&(o=Ze,T=-T,m-=T),l&&(p=T*l,h+=(r.width-p)/2);break;case Gt:if(l){if(_.y<=0&&(m<=M||A>=B)){q=!1;break}w(Ze),T-=_.y,m+=_.y,p=T*l}else w(Ze),w(ct),_.x>=0?A<B?p+=_.x:_.y<=0&&m<=M&&(q=!1):p+=_.x,_.y<=0?m>M&&(T-=_.y,m+=_.y):(T-=_.y,m+=_.y);p<0&&T<0?(o=jt,T=-T,p=-p,m-=T,h-=p):p<0?(o=Xt,p=-p,h-=p):T<0&&(o=Qt,T=-T,m-=T);break;case Xt:if(l){if(_.y<=0&&(m<=M||h<=R)){q=!1;break}w(Ze),T-=_.y,m+=_.y,p=T*l,h+=r.width-p}else w(Ze),w(lt),_.x<=0?h>R?(p-=_.x,h+=_.x):_.y<=0&&m<=M&&(q=!1):(p-=_.x,h+=_.x),_.y<=0?m>M&&(T-=_.y,m+=_.y):(T-=_.y,m+=_.y);p<0&&T<0?(o=Qt,T=-T,p=-p,m-=T,h-=p):p<0?(o=Gt,p=-p,h-=p):T<0&&(o=jt,T=-T,m-=T);break;case jt:if(l){if(_.x<=0&&(h<=R||I>=W)){q=!1;break}w(lt),p-=_.x,h+=_.x,T=p/l}else w(At),w(lt),_.x<=0?h>R?(p-=_.x,h+=_.x):_.y>=0&&I>=W&&(q=!1):(p-=_.x,h+=_.x),_.y>=0?I<W&&(T+=_.y):T+=_.y;p<0&&T<0?(o=Gt,T=-T,p=-p,m-=T,h-=p):p<0?(o=Qt,p=-p,h-=p):T<0&&(o=Xt,T=-T,m-=T);break;case Qt:if(l){if(_.x>=0&&(A>=B||I>=W)){q=!1;break}w(ct),p+=_.x,T=p/l}else w(At),w(ct),_.x>=0?A<B?p+=_.x:_.y>=0&&I>=W&&(q=!1):p+=_.x,_.y>=0?I<W&&(T+=_.y):T+=_.y;p<0&&T<0?(o=Xt,T=-T,p=-p,m-=T,h-=p):p<0?(o=jt,p=-p,h-=p):T<0&&(o=Gt,T=-T,m-=T);break;case Gs:this.move(_.x,_.y),q=!1;break;case Xs:this.zoom(Wh(u),t),q=!1;break;case Ws:if(!_.x||!_.y){q=!1;break}ae=fr(this.cropper),h=U.startX-ae.left,m=U.startY-ae.top,p=r.minWidth,T=r.minHeight,_.x>0?o=_.y>0?Qt:Gt:_.x<0&&(h-=p,o=_.y>0?jt:Xt),_.y<0&&(m-=T),this.cropped||(He(this.cropBox,Ce),this.cropped=!0,this.limited&&this.limitCropBox(!0,!0));break}q&&(r.width=p,r.height=T,r.left=h,r.top=m,this.action=o,this.renderCropBox()),re(u,function(Y){Y.startX=Y.endX,Y.startY=Y.endY})}},uf={crop:function(){return this.ready&&!this.cropped&&!this.disabled&&(this.cropped=!0,this.limitCropBox(!0,!0),this.options.modal&&he(this.dragBox,ya),He(this.cropBox,Ce),this.setCropBoxData(this.initialCropBoxData)),this},reset:function(){return this.ready&&!this.disabled&&(this.imageData=ee({},this.initialImageData),this.canvasData=ee({},this.initialCanvasData),this.cropBoxData=ee({},this.initialCropBoxData),this.renderCanvas(),this.cropped&&this.renderCropBox()),this},clear:function(){return this.cropped&&!this.disabled&&(ee(this.cropBoxData,{left:0,top:0,width:0,height:0}),this.cropped=!1,this.renderCropBox(),this.limitCanvas(!0,!0),this.renderCanvas(),He(this.dragBox,ya),he(this.cropBox,Ce)),this},replace:function(t){var a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return!this.disabled&&t&&(this.isImg&&(this.element.src=t),a?(this.url=t,this.image.src=t,this.ready&&(this.viewBoxImage.src=t,re(this.previews,function(n){n.getElementsByTagName("img")[0].src=t}))):(this.isImg&&(this.replaced=!0),this.options.data=null,this.uncreate(),this.load(t))),this},enable:function(){return this.ready&&this.disabled&&(this.disabled=!1,He(this.cropper,Qs)),this},disable:function(){return this.ready&&!this.disabled&&(this.disabled=!0,he(this.cropper,Qs)),this},destroy:function(){var t=this.element;return t[J]?(t[J]=void 0,this.isImg&&this.replaced&&(t.src=this.originalUrl),this.uncreate(),this):this},move:function(t){var a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:t,n=this.canvasData,i=n.left,r=n.top;return this.moveTo(Hn(t)?t:i+Number(t),Hn(a)?a:r+Number(a))},moveTo:function(t){var a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:t,n=this.canvasData,i=!1;return t=Number(t),a=Number(a),this.ready&&!this.disabled&&this.options.movable&&(V(t)&&(n.left=t,i=!0),V(a)&&(n.top=a,i=!0),i&&this.renderCanvas(!0)),this},zoom:function(t,a){var n=this.canvasData;return t=Number(t),t<0?t=1/(1-t):t=1+t,this.zoomTo(n.width*t/n.naturalWidth,null,a)},zoomTo:function(t,a,n){var i=this.options,r=this.canvasData,u=r.width,o=r.height,l=r.naturalWidth,h=r.naturalHeight;if(t=Number(t),t>=0&&this.ready&&!this.disabled&&i.zoomable){var m=l*t,p=h*t;if(St(this.element,Fn,{ratio:t,oldRatio:u/l,originalEvent:n})===!1)return this;if(n){var T=this.pointers,A=fr(this.cropper),I=T&&Object.keys(T).length?Gh(T):{pageX:n.pageX,pageY:n.pageY};r.left-=(m-u)*((I.pageX-A.left-r.left)/u),r.top-=(p-o)*((I.pageY-A.top-r.top)/o)}else Nt(a)&&V(a.x)&&V(a.y)?(r.left-=(m-u)*((a.x-r.left)/u),r.top-=(p-o)*((a.y-r.top)/o)):(r.left-=(m-u)/2,r.top-=(p-o)/2);r.width=m,r.height=p,this.renderCanvas(!0)}return this},rotate:function(t){return this.rotateTo((this.imageData.rotate||0)+Number(t))},rotateTo:function(t){return t=Number(t),V(t)&&this.ready&&!this.disabled&&this.options.rotatable&&(this.imageData.rotate=t%360,this.renderCanvas(!0,!0)),this},scaleX:function(t){var a=this.imageData.scaleY;return this.scale(t,V(a)?a:1)},scaleY:function(t){var a=this.imageData.scaleX;return this.scale(V(a)?a:1,t)},scale:function(t){var a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:t,n=this.imageData,i=!1;return t=Number(t),a=Number(a),this.ready&&!this.disabled&&this.options.scalable&&(V(t)&&(n.scaleX=t,i=!0),V(a)&&(n.scaleY=a,i=!0),i&&this.renderCanvas(!0,!0)),this},getData:function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,a=this.options,n=this.imageData,i=this.canvasData,r=this.cropBoxData,u;if(this.ready&&this.cropped){u={x:r.left-i.left,y:r.top-i.top,width:r.width,height:r.height};var o=n.width/n.naturalWidth;if(re(u,function(m,p){u[p]=m/o}),t){var l=Math.round(u.y+u.height),h=Math.round(u.x+u.width);u.x=Math.round(u.x),u.y=Math.round(u.y),u.width=h-u.x,u.height=l-u.y}}else u={x:0,y:0,width:0,height:0};return a.rotatable&&(u.rotate=n.rotate||0),a.scalable&&(u.scaleX=n.scaleX||1,u.scaleY=n.scaleY||1),u},setData:function(t){var a=this.options,n=this.imageData,i=this.canvasData,r={};if(this.ready&&!this.disabled&&Nt(t)){var u=!1;a.rotatable&&V(t.rotate)&&t.rotate!==n.rotate&&(n.rotate=t.rotate,u=!0),a.scalable&&(V(t.scaleX)&&t.scaleX!==n.scaleX&&(n.scaleX=t.scaleX,u=!0),V(t.scaleY)&&t.scaleY!==n.scaleY&&(n.scaleY=t.scaleY,u=!0)),u&&this.renderCanvas(!0,!0);var o=n.width/n.naturalWidth;V(t.x)&&(r.left=t.x*o+i.left),V(t.y)&&(r.top=t.y*o+i.top),V(t.width)&&(r.width=t.width*o),V(t.height)&&(r.height=t.height*o),this.setCropBoxData(r)}return this},getContainerData:function(){return this.ready?ee({},this.containerData):{}},getImageData:function(){return this.sized?ee({},this.imageData):{}},getCanvasData:function(){var t=this.canvasData,a={};return this.ready&&re(["left","top","width","height","naturalWidth","naturalHeight"],function(n){a[n]=t[n]}),a},setCanvasData:function(t){var a=this.canvasData,n=a.aspectRatio;return this.ready&&!this.disabled&&Nt(t)&&(V(t.left)&&(a.left=t.left),V(t.top)&&(a.top=t.top),V(t.width)?(a.width=t.width,a.height=t.width/n):V(t.height)&&(a.height=t.height,a.width=t.height*n),this.renderCanvas(!0)),this},getCropBoxData:function(){var t=this.cropBoxData,a;return this.ready&&this.cropped&&(a={left:t.left,top:t.top,width:t.width,height:t.height}),a||{}},setCropBoxData:function(t){var a=this.cropBoxData,n=this.options.aspectRatio,i,r;return this.ready&&this.cropped&&!this.disabled&&Nt(t)&&(V(t.left)&&(a.left=t.left),V(t.top)&&(a.top=t.top),V(t.width)&&t.width!==a.width&&(i=!0,a.width=t.width),V(t.height)&&t.height!==a.height&&(r=!0,a.height=t.height),n&&(i?a.height=a.width/n:r&&(a.width=a.height*n)),this.renderCropBox()),this},getCroppedCanvas:function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!this.ready||!window.HTMLCanvasElement)return null;var a=this.canvasData,n=Qh(this.image,this.imageData,a,t);if(!this.cropped)return n;var i=this.getData(t.rounded),r=i.x,u=i.y,o=i.width,l=i.height,h=n.width/Math.floor(a.naturalWidth);h!==1&&(r*=h,u*=h,o*=h,l*=h);var m=o/l,p=et({aspectRatio:m,width:t.maxWidth||1/0,height:t.maxHeight||1/0}),T=et({aspectRatio:m,width:t.minWidth||0,height:t.minHeight||0},"cover"),A=et({aspectRatio:m,width:t.width||(h!==1?n.width:o),height:t.height||(h!==1?n.height:l)}),I=A.width,R=A.height;I=Math.min(p.width,Math.max(T.width,I)),R=Math.min(p.height,Math.max(T.height,R));var M=document.createElement("canvas"),B=M.getContext("2d");M.width=Ct(I),M.height=Ct(R),B.fillStyle=t.fillColor||"transparent",B.fillRect(0,0,I,R);var W=t.imageSmoothingEnabled,q=W===void 0?!0:W,ae=t.imageSmoothingQuality;B.imageSmoothingEnabled=q,ae&&(B.imageSmoothingQuality=ae);var U=n.width,_=n.height,w=r,Y=u,se,be,Pe,ye,Re,me;w<=-o||w>U?(w=0,se=0,Pe=0,Re=0):w<=0?(Pe=-w,w=0,se=Math.min(U,o+w),Re=se):w<=U&&(Pe=0,se=Math.min(o,U-w),Re=se),se<=0||Y<=-l||Y>_?(Y=0,be=0,ye=0,me=0):Y<=0?(ye=-Y,Y=0,be=Math.min(_,l+Y),me=be):Y<=_&&(ye=0,be=Math.min(l,_-Y),me=be);var z=[w,Y,se,be];if(Re>0&&me>0){var xe=I/o;z.push(Pe*xe,ye*xe,Re*xe,me*xe)}return B.drawImage.apply(B,[n].concat($s(z.map(function(ve){return Math.floor(Ct(ve))})))),M},setAspectRatio:function(t){var a=this.options;return!this.disabled&&!Hn(t)&&(a.aspectRatio=Math.max(0,t)||NaN,this.ready&&(this.initCropBox(),this.cropped&&this.renderCropBox())),this},setDragMode:function(t){var a=this.options,n=this.dragBox,i=this.face;if(this.ready&&!this.disabled){var r=t===Pn,u=a.movable&&t===zs;t=r||u?t:Ks,a.dragMode=t,Kt(n,zt,t),It(n,kn,r),It(n,Mn,u),a.cropBoxMovable||(Kt(i,zt,t),It(i,kn,r),It(i,Mn,u))}return this}},of=Fe.Cropper,Tr=function(){function e(t){var a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(_h(this,e),!t||!Ph.test(t.tagName))throw new Error("The first argument is required and must be an <img> or <canvas> element.");this.element=t,this.options=ee({},or,Nt(a)&&a),this.cropped=!1,this.disabled=!1,this.pointers={},this.ready=!1,this.reloading=!1,this.replaced=!1,this.sized=!1,this.sizing=!1,this.init()}return Ah(e,[{key:"init",value:function(){var a=this.element,n=a.tagName.toLowerCase(),i;if(!a[J]){if(a[J]=this,n==="img"){if(this.isImg=!0,i=a.getAttribute("src")||"",this.originalUrl=i,!i)return;i=a.src}else n==="canvas"&&window.HTMLCanvasElement&&(i=a.toDataURL());this.load(i)}}},{key:"load",value:function(a){var n=this;if(a){this.url=a,this.imageData={};var i=this.element,r=this.options;if(!r.rotatable&&!r.scalable&&(r.checkOrientation=!1),!r.checkOrientation||!window.ArrayBuffer){this.clone();return}if(kh.test(a)){Mh.test(a)?this.read(Kh(a)):this.clone();return}var u=new XMLHttpRequest,o=this.clone.bind(this);this.reloading=!0,this.xhr=u,u.onabort=o,u.onerror=o,u.ontimeout=o,u.onprogress=function(){u.getResponseHeader("content-type")!==sr&&u.abort()},u.onload=function(){n.read(u.response)},u.onloadend=function(){n.reloading=!1,n.xhr=null},r.checkCrossOrigin&&mr(a)&&i.crossOrigin&&(a=Er(a)),u.open("GET",a,!0),u.responseType="arraybuffer",u.withCredentials=i.crossOrigin==="use-credentials",u.send()}}},{key:"read",value:function(a){var n=this.options,i=this.imageData,r=Jh(a),u=0,o=1,l=1;if(r>1){this.url=Zh(a,sr);var h=ef(r);u=h.rotate,o=h.scaleX,l=h.scaleY}n.rotatable&&(i.rotate=u),n.scalable&&(i.scaleX=o,i.scaleY=l),this.clone()}},{key:"clone",value:function(){var a=this.element,n=this.url,i=a.crossOrigin,r=n;this.options.checkCrossOrigin&&mr(n)&&(i||(i="anonymous"),r=Er(n)),this.crossOrigin=i,this.crossOriginUrl=r;var u=document.createElement("img");i&&(u.crossOrigin=i),u.src=r||n,u.alt=a.alt||"The image to crop",this.image=u,u.onload=this.start.bind(this),u.onerror=this.stop.bind(this),he(u,js),a.parentNode.insertBefore(u,a.nextSibling)}},{key:"start",value:function(){var a=this,n=this.image;n.onload=null,n.onerror=null,this.sizing=!0;var i=Fe.navigator&&/(?:iPad|iPhone|iPod).*?AppleWebKit/i.test(Fe.navigator.userAgent),r=function(h,m){ee(a.imageData,{naturalWidth:h,naturalHeight:m,aspectRatio:h/m}),a.initialImageData=ee({},a.imageData),a.sizing=!1,a.sized=!0,a.build()};if(n.naturalWidth&&!i){r(n.naturalWidth,n.naturalHeight);return}var u=document.createElement("img"),o=document.body||document.documentElement;this.sizingImage=u,u.onload=function(){r(u.width,u.height),i||o.removeChild(u)},u.src=n.src,i||(u.style.cssText="left:0;max-height:none!important;max-width:none!important;min-height:0!important;min-width:0!important;opacity:0;position:absolute;top:0;z-index:-1;",o.appendChild(u))}},{key:"stop",value:function(){var a=this.image;a.onload=null,a.onerror=null,a.parentNode.removeChild(a),this.image=null}},{key:"build",value:function(){if(!(!this.sized||this.ready)){var a=this.element,n=this.options,i=this.image,r=a.parentNode,u=document.createElement("div");u.innerHTML=vh;var o=u.querySelector(".".concat(J,"-container")),l=o.querySelector(".".concat(J,"-canvas")),h=o.querySelector(".".concat(J,"-drag-box")),m=o.querySelector(".".concat(J,"-crop-box")),p=m.querySelector(".".concat(J,"-face"));this.container=r,this.cropper=o,this.canvas=l,this.dragBox=h,this.cropBox=m,this.viewBox=o.querySelector(".".concat(J,"-view-box")),this.face=p,l.appendChild(i),he(a,Ce),r.insertBefore(o,a.nextSibling),He(i,js),this.initPreview(),this.bind(),n.initialAspectRatio=Math.max(0,n.initialAspectRatio)||NaN,n.aspectRatio=Math.max(0,n.aspectRatio)||NaN,n.viewMode=Math.max(0,Math.min(3,Math.round(n.viewMode)))||0,he(m,Ce),n.guides||he(m.getElementsByClassName("".concat(J,"-dashed")),Ce),n.center||he(m.getElementsByClassName("".concat(J,"-center")),Ce),n.background&&he(o,"".concat(J,"-bg")),n.highlight||he(p,Oh),n.cropBoxMovable&&(he(p,Mn),Kt(p,zt,Rn)),n.cropBoxResizable||(he(m.getElementsByClassName("".concat(J,"-line")),Ce),he(m.getElementsByClassName("".concat(J,"-point")),Ce)),this.render(),this.ready=!0,this.setDragMode(n.dragMode),n.autoCrop&&this.crop(),this.setData(n.data),Ie(n.ready)&&Le(a,ar,n.ready,{once:!0}),St(a,ar)}}},{key:"unbuild",value:function(){if(this.ready){this.ready=!1,this.unbind(),this.resetPreview();var a=this.cropper.parentNode;a&&a.removeChild(this.cropper),He(this.element,Ce)}}},{key:"uncreate",value:function(){this.ready?(this.unbuild(),this.ready=!1,this.cropped=!1):this.sizing?(this.sizingImage.onload=null,this.sizing=!1,this.sized=!1):this.reloading?(this.xhr.onabort=null,this.xhr.abort()):this.image&&this.stop()}}],[{key:"noConflict",value:function(){return window.Cropper=of,e}},{key:"setDefaults",value:function(a){ee(or,Nt(a)&&a)}}])}();ee(Tr.prototype,tf,af,nf,sf,rf,uf);function cf(e,t){const a=e.split(",")||[],n=a[0].match(/:(.*?);/)[1],i=a[1]&&atob(a[1]);let r=i&&i.length;const u=new Uint8Array(r);for(;r--;)u[r]=i==null?void 0:i.charCodeAt(r);return new File([u],t,{type:n})}const lf={key:0,contenteditable:"false",class:"z-10 w-[100vw] h-[100vh] bg-[rgba(0,0,0,0.7)] flex flex-col justify-center items-center fixed top-0 left-0 cursor-auto"},df={class:"w-[700px] flex flex-col bg-white rounded pb-8"},hf={class:"flex flex-row items-center justify-between px-6 py-4 bg-[#f4f8ff]"},ff={class:"flex flex-col h-full"},mf={class:"flex flex-row justify-center items-start flex-1"},Ef={class:"flex flex-col items-start flex-1"},pf={class:"flex flex-col w-full px-6 py-4"},Tf={class:"flex flex-col w-full"},bf={class:"flex flex-row items-center"},gf={class:"relative bg-[#474AFF] text-white rounded p-3"},_f={class:"flex flex-row items-start justify-between mt-3"},Af={class:"flex flex-col"},Nf={class:"flex flex-col justify-center items-center border w-[300px] h-[300px]"},Cf={key:0,class:"w-full text-center"},If=["src"],Sf={class:"flex flex-col items-center",style:{width:"300px",height:"300px"}},xf={class:"text-[#999] mt-05 flex justify-center mt-4"},Of={class:"w-full flex justify-end space-x-5 mt-5 px-6"},Df=["loading"],Lf=c.defineComponent({__name:"index",emits:["cancel","ok"],setup(e,{expose:t,emit:a}){const n=a,i=c.ref({coverUrl:"",inputValue:"",uploadType:2,videoHost:"",videoUrl:""}),r=c.ref(),u=c.ref({autoCrop:!0,autoCropArea:1,background:!0,center:!0,cropBoxResizable:!0,dragMode:"move",preview:".before",toggleDragModeOnDblclick:!0,viewMode:1,zoomOnWheel:!0}),o=c.ref(!1),l=c.ref({afterImg:"",image:null,myCropper:null}),h=c.ref("image/jpeg"),m=U=>{console.log(U);const _=U.target.files[0];if(_){_.name&&(i.value.inputValue=_.name);const w=new FileReader;w.onload=Y=>{var se,be;console.log("e?.target?.result",(se=Y==null?void 0:Y.target)==null?void 0:se.result),p((be=Y==null?void 0:Y.target)==null?void 0:be.result)},w.readAsDataURL(_)}};async function p(U){if(!U)return;await ae();const _=U;l.value.image=_,l.value.image&&T()}function T(){const U=document.querySelector("#imgId");U&&U.addEventListener("load",()=>{q(),l.value.myCropper=new Tr(U,u.value)})}const A=c.ref(!1),I=c.ref();function R(U,_,w,Y){I.value=Y,r.value=U,U&&U.aspectRatio&&(u.value.aspectRatio=U.aspectRatio),w&&(i.value.inputValue=w),A.value=!0,_&&p(_)}function M(){A.value=!1}const B=()=>{var _,w;if(!l.value.myCropper)return;o.value=!0,l.value.afterImg=l.value.myCropper.getCroppedCanvas({height:(_=r.value)==null?void 0:_.height,imageSmoothingQuality:"high",width:(w=r.value)==null?void 0:w.width}).toDataURL(h.value);const U=cf(l.value.afterImg,i.value.inputValue);n("ok",{options:U,element:I.value}),o.value=!1,ae(),q(),M()};function W(){ae(),q(),M(),n("cancel")}function q(){l.value.myCropper&&l.value.myCropper.destroy()}function ae(){l.value.image=""}return t({handleCloseCropper:M,handleOpenCropper:R}),(U,_)=>{var w,Y,se;return A.value?(c.openBlock(),c.createElementBlock("div",lf,[c.createElementVNode("div",df,[c.createElementVNode("div",hf,[_[1]||(_[1]=c.createElementVNode("span",{class:"text-base font-semibold text-[#333]"},"图片裁剪",-1)),c.createElementVNode("span",{class:"text-lg cursor-pointer text-[#999] iconfont icon-shanchu2",onClick:c.withModifiers(W,["stop"])})]),c.createElementVNode("div",ff,[c.createElementVNode("div",mf,[c.createElementVNode("div",Ef,[c.createElementVNode("div",pf,[c.createElementVNode("div",Tf,[c.createElementVNode("div",bf,[c.createElementVNode("div",gf,[c.createElementVNode("input",{type:"file",accept:"image/*",onClick:_[0]||(_[0]=c.withModifiers(()=>{},["stop"])),contenteditable:"false",ref:"fileInput",onChange:m,class:"absolute top-0 left-0 w-[110px] h-[40px] opacity-0 cursor-pointer"},null,544),_[2]||(_[2]=c.createElementVNode("span",{id:"uploadHandler",class:"cursor-pointer"}," 选择/更换图片 ",-1))]),_[3]||(_[3]=c.createElementVNode("span",{class:"text-sm text-[#999] ml-3"},"滚动鼠标放大或缩小图片",-1))]),c.createElementVNode("div",_f,[c.createElementVNode("div",Af,[c.createElementVNode("div",Nf,[l.value.image?c.createCommentVNode("",!0):(c.openBlock(),c.createElementBlock("div",Cf," 请上传图片 ")),c.createElementVNode("img",{id:"imgId",src:l.value.image,style:{width:"300px"}},null,8,If)])]),c.createElementVNode("div",Sf,[_[4]||(_[4]=c.createElementVNode("div",{class:"before w-[270px] h-[200px] pr-[70px] border"},null,-1)),c.createElementVNode("div",xf," 预览画像 "+c.toDisplayString(((w=r.value)==null?void 0:w.width)||"")+" "+c.toDisplayString((Y=r.value)!=null&&Y.width?"x":"")+" "+c.toDisplayString(((se=r.value)==null?void 0:se.height)||""),1)])])])])])]),c.createElementVNode("div",Of,[c.createElementVNode("span",{loading:o.value,class:"!w-22 bg-[#474AFF] text-white rounded py-2 px-6 cursor-pointer",type:"primary",onClick:B}," 确认 ",8,Df),c.createElementVNode("span",{class:"!w-22 border border-[#DEDEDE] text-[#666] rounded py-2 px-6 cursor-pointer",onClick:W},"取消")])])])])):c.createCommentVNode("",!0)}}}),yf=c.defineComponent({name:"CustomIcon",props:{iconName:{type:String,required:!0}},setup(e){return{iconClass:c.computed(()=>`${e.iconName}`)}}});function Rf(e,t,a,n,i,r){return c.openBlock(),c.createElementBlock("span",{style:{position:"unset",color:"unset",top:"unset",left:"unset",right:"unset",transform:"unset","font-size":"unset"},class:c.normalizeClass(`iconfont icon-${e.iconClass} text-4xl overflow-hidden flex justify-center items-center`)},null,2)}const kf=Ke(yf,[["render",Rf]]),Mf=c.defineComponent({name:"GpModal",props:{visible:{type:Boolean,required:!0},title:{type:String,default:""},okText:{type:String,default:"确定"},cancelText:{type:String,default:"取消"},showOkButton:{type:Boolean,default:!0},showCancelButton:{type:Boolean,default:!0},showCloseButton:{type:Boolean,default:!0}},emits:["update:visible","ok","cancel"],setup(e,{emit:t}){const{visible:a,okText:n,cancelText:i,showCloseButton:r}=c.toRefs(e);return{visible:a,okText:n,cancelText:i,showCloseButton:r,onClose:()=>{t("cancel"),t("update:visible",!1)},onOk:()=>{t("ok"),t("update:visible",!1)},onCancel:()=>{t("cancel"),t("update:visible",!1)}}}}),Pf={class:"bg-white rounded-lg shadow-xl w-ful"},vf={class:"p-4 border-b border-gray-200 relative flex items-center justify-between"},Bf={key:0,class:"text-lg font-semibold"},wf={class:"p-4"},Uf={key:0,class:"p-4 border-t border-gray-200 flex justify-end space-x-2"};function Ff(e,t,a,n,i,r){return e.visible?(c.openBlock(),c.createElementBlock("div",{key:0,class:"fixed inset-0 z-[99999] flex items-center justify-center bg-gray-900 bg-opacity-50",onClick:t[3]||(t[3]=c.withModifiers((...u)=>e.onClose&&e.onClose(...u),["self"]))},[c.createElementVNode("div",Pf,[c.createElementVNode("div",vf,[e.title?(c.openBlock(),c.createElementBlock("h3",Bf,c.toDisplayString(e.title),1)):c.createCommentVNode("",!0),c.renderSlot(e.$slots,"header"),e.showCloseButton?(c.openBlock(),c.createElementBlock("button",{key:1,class:"text-gray-400 hover:text-gray-600",onClick:t[0]||(t[0]=(...u)=>e.onClose&&e.onClose(...u)),"aria-label":"Close"},t[4]||(t[4]=[c.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-5 w-5",viewBox:"0 0 20 20",fill:"currentColor"},[c.createElementVNode("path",{"fill-rule":"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z","clip-rule":"evenodd"})],-1)]))):c.createCommentVNode("",!0)]),c.createElementVNode("div",wf,[c.renderSlot(e.$slots,"default")]),e.showCancelButton||e.showOkButton?(c.openBlock(),c.createElementBlock("div",Uf,[c.renderSlot(e.$slots,"footer",{},()=>[e.showCancelButton?(c.openBlock(),c.createElementBlock("button",{key:0,class:"px-4 py-2 text-sm font-medium text-gray-700 bg-gray-100 rounded hover:bg-gray-200",onClick:t[1]||(t[1]=(...u)=>e.onCancel&&e.onCancel(...u))},c.toDisplayString(e.cancelText),1)):c.createCommentVNode("",!0),e.showOkButton?(c.openBlock(),c.createElementBlock("button",{key:1,class:"px-4 py-2 text-sm font-medium text-white bg-blue-600 rounded hover:bg-blue-700",onClick:t[2]||(t[2]=(...u)=>e.onOk&&e.onOk(...u))},c.toDisplayString(e.okText),1)):c.createCommentVNode("",!0)])])):c.createCommentVNode("",!0)])])):c.createCommentVNode("",!0)}const Hf=Ke(Mf,[["render",Ff]]),Vf={class:"p-4 flex flex-wrap max-h-[500px] overflow-y-auto w-[640px]"},Yf=c.defineComponent({__name:"IconModal",props:{icons:{type:Array,default:()=>[]}},emits:["ok"],setup(e,{expose:t,emit:a}){const n=e,i=c.ref(n.icons||[]);c.watch(()=>n.icons,p=>{i.value=p||[]},{immediate:!0});const r=a,u=c.ref(!1),o=c.ref();function l(p){u.value=!0,o.value=p}function h(p){m(),r("ok",{icon:p,element:o.value})}function m(){u.value=!1}return t({openModal:l,closeModal:m}),(p,T)=>(c.openBlock(),c.createBlock(Hf,{visible:u.value,"onUpdate:visible":T[0]||(T[0]=A=>u.value=A),title:"选择图标",onOk:m,onCancel:m,showCancelButton:!1,showOkButton:!1},{default:c.withCtx(()=>[c.createElementVNode("div",Vf,[(c.openBlock(!0),c.createElementBlock(c.Fragment,null,c.renderList(i.value,A=>(c.openBlock(),c.createBlock(kf,{key:A,class:"w-12 h-12 mx-1 mb-2 border cursor-pointer hover:border-gray-400 hover:bg-gray-200",iconName:A,onClick:c.withModifiers(I=>h(A),["stop"]),title:A},null,8,["iconName","onClick","title"]))),128))])]),_:1},8,["visible"]))}}),qf={class:"flex"},$f={key:0,class:"text-lg font-bold border-b p-2"},Wf={class:"text-sm font-thin text-gray-500"},Gf=["innerHTML"],Xf=["innerHTML"],Qf={class:"flex-1"},jf={key:0,class:"text-lg font-bold border-b p-2"},zf={class:"p-2"},Kf={key:0,class:"text-lg font-bold border-b p-2"},Zf={class:"text-sm font-thin text-gray-500"},Jf={class:"p-2"},br=Ke(c.defineComponent({__name:"Designer",props:{mode:{default:"design"},template:{},css:{},previewWidth:{default:375},uploadByFile:{},icons:{},rules:{},preview:{type:Boolean,default:!0},showTitle:{type:Boolean,default:!0}},emits:["update:modelValue","update:element"],setup(e,{emit:t}){const a=e,n=t,i=c.ref(a.template),r=c.ref();c.watch(()=>a.template,C=>{i.value=C},{immediate:!0}),c.watch(()=>i.value,C=>{C&&(r.value=U(C))},{immediate:!0}),c.watch(()=>a.css,C=>{C.forEach(D=>{if(document.querySelector(`link[href="${D}"]`))return;const P=document.createElement("link");P.rel="stylesheet",P.href=D,document.head.appendChild(P)})},{immediate:!0});const u=c.ref(a.mode);c.watch(()=>r.value,C=>{C&&n("update:element",C)},{immediate:!0});const o=c.ref(""),l=c.ref("");let h=Us("",{},!1);c.watch(()=>l.value,C=>{n("update:modelValue",C)},{immediate:!0});const m=c.ref(),p=c.ref(),T=c.ref(),A=c.ref(),I=c.ref("");function R(C){console.log("选择",C),T.value=C}function M(C,D=""){if(D){const P=B(r.value,D);P?A.value=P:A.value=C}else A.value=C}function B(C,D){if(C.xpath===D)return C;if(C.children&&C.children.length)for(const P of C.children){const H=B(P,D);if(H)return H}}function W(C,D){var P,H;return C.tag===D.tag&&((P=C.children)==null?void 0:P.length)===((H=D.children)==null?void 0:H.length)}function q(C){var P,H,ie,ge;if(T.value.xpath==C.xpath){if(T.value){if(C.type===Q.Block){var D=!0;const oe=B(r.value,T.value.parentxpath||"");if(oe&&oe.children&&oe.children.forEach(K=>{if(K.tag!=T.value.tag||!W(K,T.value)){D=!1;return}}),!D){j.error("同级结构不一致,错误配置!");return}}if(T.value.rule=C.rule,T.value.type=C.type,(P=C.rule)!=null&&P.isThemeColor?(C.attrs.class+="theme_color",C.attrs.style&&(C.attrs.style=void 0)):(console.log("e111",(H=C.attrs.class)==null?void 0:H.includes("theme_color")),(ie=C.attrs.class)!=null&&ie.includes("theme_color")&&(C.attrs.class=C.attrs.class.replace("theme_color"," "))),T.value.type===Q.Block){const oe=B(r.value,T.value.parentxpath||"");oe&&oe.children&&(oe.children.forEach(K=>{if(K.tag!=T.value.tag||!W(K,T.value)){j.error("同级结构不一致,无法配置为块类型");return}}),oe.children.forEach(K=>{var pe;K.tag===T.value.tag&&(K.rule=C.rule,K.type=C.type,(pe=K.attrs.class)!=null&&pe.includes(" mb40 relative")||(K.attrs.class+=" mb40 relative"))}))}else(ge=T.value.attrs.class)!=null&&ge.includes(" mb40 relative")&&(T.value.attrs.class=T.value.attrs.class.replace(" mb40 relative"," "))}j.success("保存成功")}}function ae(C){l.value=C}function U(C){h=Us(C);const D=h("body").children().toArray().map(P=>_(h(P)));return l.value=h("body").html()||"",D[0]}function _(C,D=""){var oe;function P(K){if(!K||!K[0])return"";const pe=[];let ht=K;for(;ht.length&&ht[0].tagName!=="html";){const gr=ht[0].tagName,tm=ht.parent().children(gr).index(ht)+1;pe.unshift(`${gr}[${tm}]`),ht=ht.parent()}return"/html/"+pe.join("/")}const H=P(C).replace("/html/body[1]",""),ie=C.children().toArray().map(K=>_(h(K),H)),ge=(oe=a.rules)==null?void 0:oe.find(K=>K.xpath===H);return{tag:C[0].tagName,text:C.contents().not(C.children()).text().trim(),attrs:C[0].attribs,children:ie,xpath:H,parentxpath:D,type:(ge==null?void 0:ge.type)||Q.None,rule:(ge==null?void 0:ge.rule)||{}}}function w(C){console.log("更新子节点的文本",C);const D=B(r.value,C.element.xpath);if(D){const P=c.toRaw(D);P.editText=C.newText}}function Y(C,D=""){function P(H,ie){var K;const oe=(ie?((K=B(r.value,ie))==null?void 0:K.children)||[]:[r.value]).filter(pe=>pe.tag===H.tag).indexOf(H)+1;return`${ie}/${H.tag}[${oe}]`}C.xpath=P(C,D),C.parentxpath=D,(C.children||[]).forEach(H=>Y(H,C.xpath))}function se({action:C,element:D,newBlock:P}){console.log("块操作",C,D,P);const H=B(r.value,D.parentxpath||"");if(!H||!H.children)return;const ie=H.children.findIndex(pe=>pe===D);if(ie===-1)return;const ge=H.children.length,{minBlock:oe,maxBlock:K}=D.rule;if((C==="add"||C==="copy")&&ge>=(K||1/0)){I.value=`无法添加更多块。最大块数量为 ${K}`,j.error(I.value);return}switch(C){case"add":if(P){const pe={...P,xpath:"",children:JSON.parse(JSON.stringify(P.children))};H.children.splice(ie+1,0,pe)}break;case"copy":if(P){const pe={...P,xpath:"",children:JSON.parse(JSON.stringify(P.children))};H.children.splice(ie+1,0,pe)}break;case"moveUp":if(ie>0){const[pe]=H.children.splice(ie,1);H.children.splice(ie-1,0,pe)}break;case"moveDown":if(ie<H.children.length-1){const[pe]=H.children.splice(ie,1);H.children.splice(ie+1,0,pe)}break;case"delete":if(ge<=(oe||0)){I.value=`无法删除更多块。最小块数量为 ${oe}`,j.error(I.value);return}H.children.splice(ie,1);break}I.value="",Y(r.value)}function be(C,D){let P=D.attrs.class.replace(/icon-\S+/g,`icon-${C}`);D.attrs.class=P}function Pe(C,D){console.log("comfireImg",C),D.attrs.src=C}function ye(C){const D=B(r.value,C.element.xpath),P=C.options;if(typeof P=="object"){console.log("e1",C),D.attrs.alt=P.name;const H=new FileReader;H.onload=ie=>{var oe;let ge=(oe=ie==null?void 0:ie.target)==null?void 0:oe.result;D.attrs.src=ge,console.log(" element.attrs",D.attrs),o.value=new Date().getTime().toString()},H.readAsDataURL(P)}else console.log("e2",C),D.attrs.src=P}function Re(C){const{icon:D}=C,P=B(r.value,C.element.xpath);let H=P.attrs.class.replace(/icon-\S+/g,`icon-${D}`);P.attrs.class=H,o.value=new Date().getTime().toString()}const me=c.ref(a.previewWidth),z=c.ref(375);let xe=c.ref(!1),ve=c.ref(""),tt=0,O=0;function L(C){ve.value=C,xe.value=!0,tt=event.clientX,C==="preview"?O=me.value:C==="structure"&&(O=z.value),window.addEventListener("mousemove",ne),window.addEventListener("mouseup",Ee)}function ne(C){if(!xe.value)return;const D=C.clientX-tt;ve.value==="preview"?me.value=Math.max(200,O+D):ve.value==="structure"&&(z.value=Math.max(200,O-D))}function Ee(){xe.value=!1,ve.value="",window.removeEventListener("mousemove",ne),window.removeEventListener("mouseup",Ee)}return(C,D)=>(c.openBlock(),c.createElementBlock("div",qf,[C.preview?(c.openBlock(),c.createElementBlock("div",{key:0,class:"border-l overflow-auto resize-area",style:c.normalizeStyle({width:me.value+"px"})},[C.showTitle?(c.openBlock(),c.createElementBlock("h2",$f,[D[2]||(D[2]=c.createTextVNode(" 实时预览 ")),c.createElementVNode("span",Wf,c.toDisplayString(me.value)+"px",1)])):c.createCommentVNode("",!0),c.createElementVNode("div",null,[l.value?(c.openBlock(),c.createElementBlock("div",{key:0,innerHTML:l.value},null,8,Gf)):(c.openBlock(),c.createElementBlock("div",{key:1,innerHTML:c.unref(h)("body").html()},null,8,Xf))])],4)):c.createCommentVNode("",!0),C.preview?(c.openBlock(),c.createElementBlock("div",{key:1,class:"resizer",onMousedown:D[0]||(D[0]=P=>L("preview"))},null,32)):c.createCommentVNode("",!0),c.createElementVNode("div",Qf,[C.showTitle?(c.openBlock(),c.createElementBlock("h2",jf,"结构渲染")):c.createCommentVNode("",!0),c.createElementVNode("div",zf,[r.value?(c.openBlock(),c.createBlock(Vd,{key:0,cropper:m.value,icon:p.value,mode:C.mode,icons:C.icons,r:o.value,element:r.value,selectedElement:T.value,hoveredElement:A.value,onSelectElement:R,onHoverElement:M,onContentUpdated:ae,onUpdateText:w,onBlockAction:se,onAddIcon:be,onUpload:Pe},null,8,["cropper","icon","mode","icons","r","element","selectedElement","hoveredElement"])):c.createCommentVNode("",!0)])]),u.value=="design"?(c.openBlock(),c.createElementBlock("div",{key:2,class:"resizer",onMousedown:D[1]||(D[1]=P=>L("structure"))},null,32)):c.createCommentVNode("",!0),u.value=="design"?(c.openBlock(),c.createElementBlock("div",{key:3,class:"resize-area overflow-auto",style:c.normalizeStyle({width:z.value+"px"})},[C.showTitle?(c.openBlock(),c.createElementBlock("h2",Kf,[D[3]||(D[3]=c.createTextVNode(" 节点属性 ")),c.createElementVNode("span",Zf,c.toDisplayString(z.value)+"px",1)])):c.createCommentVNode("",!0),c.createElementVNode("div",Jf,[T.value?(c.openBlock(),c.createBlock(bh,{key:0,element:T.value,onUpdateElement:q},null,8,["element"])):c.createCommentVNode("",!0)])],4)):c.createCommentVNode("",!0),c.createVNode(Lf,{ref_key:"cropperRef",ref:m,onOk:ye},null,512),c.createVNode(Yf,{icons:C.icons,ref_key:"iconRef",ref:p,onOk:Re},null,8,["icons"])]))}}),[["__scopeId","data-v-5c6c0628"]]),em={install(e){e.component("Designer",br)}};$e.Designer=br,$e.default=em,Object.defineProperties($e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|