@vivliostyle/core 2.30.6 → 2.30.7
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/lib/vivliostyle.js +1 -1
- package/lib/vivliostyle.js.map +3 -3
- package/package.json +2 -2
package/lib/vivliostyle.js
CHANGED
|
@@ -1475,7 +1475,7 @@ span[data-viv-leader] {
|
|
|
1475
1475
|
text-orientation: mixed;
|
|
1476
1476
|
white-space: pre;
|
|
1477
1477
|
}
|
|
1478
|
-
`;function cs(r,t,e,n,s){let o=k("ajax"),i=new XMLHttpRequest,a=o.suspend(i),l={status:0,statusText:"",url:r,contentType:null,responseText:null,responseXML:null,responseBlob:null};i.open(e||"GET",r,!0),t&&(i.responseType=t),i.onreadystatechange=()=>{if(i.readyState===4){if(l.status=i.status,l.url=i.responseURL,l.statusText=i.statusText||i.status==404&&"Not Found"||"",l.status==200||l.status==0)if((!t||t==="document")&&i.responseXML&&i.responseXML.documentElement.localName!="parsererror")l.responseXML=i.responseXML,l.contentType=i.responseXML.contentType;else if((!t||t==="document")&&i.response instanceof Document)l.responseXML=i.response,l.contentType=i.response.contentType;else{let c=i.response;(!t||t==="text")&&typeof c=="string"?l.responseText=c:c?typeof c=="string"?l.responseBlob=hc([c]):l.responseBlob=c:I.warn("Unexpected empty success response for",r);let u=i.getResponseHeader("Content-Type");u&&(l.contentType=u.replace(/(.*);.*$/,"$1"))}a.schedule(l)}};try{n?(i.setRequestHeader("Content-Type",s||"text/plain; charset=UTF-8"),i.send(n)):(/^file:|^https?:\/\/[^/]+\.githubusercontent\.com|\.(xhtml|xht|opf)$/i.test(r)?/\/aozorabunko\/[^/]+\/cards\/[^/]+\/files\/[^/.]+\.html$/.test(r)?i.overrideMimeType("text/html; charset=Shift_JIS"):/\.(html|htm)$/i.test(r)?i.overrideMimeType("text/html; charset=UTF-8"):/\.(xhtml|xht|xml|opf)$/i.test(r)?i.overrideMimeType("application/xml; charset=UTF-8"):/\.(txt|css)$/i.test(r)?i.overrideMimeType("text/plain; charset=UTF-8"):i.overrideMimeType("text/html; charset=UTF-8"):/^data:,(<|%3c)/i.test(r)?i.overrideMimeType("text/html; charset=UTF-8"):/^data:,/i.test(r)&&i.overrideMimeType("text/plain; charset=UTF-8"),i.send(null))}catch(c){I.warn(c,`Error fetching ${r}`),a.schedule(l)}return o.result()}function hc(r,t){let e=t||"application/octet-stream";return new Blob(r,{type:e})}function Qp(r){let t=k("readBlob"),e=new FileReader,n=t.suspend(e);return e.addEventListener("load",()=>{n.schedule(e.result)},!1),e.readAsArrayBuffer(r),t.result()}function Jp(r){return URL.createObjectURL(r)}var ls=class{constructor(t,e){this.parser=t;this.type=e;d(this,"resources",{});d(this,"fetchers",{})}load(t,e,n){t=wt(t);let s=this.resources[t];return typeof s!="undefined"?v(s):this.fetch(t,e,n).get()}fetchInner(t,e,n){let s=k("fetch"),o=t.endsWith("?viv-toc-box");o&&(t=t.replace("?viv-toc-box",""));let i=J("user-agent.xml",Wt),a=!o&&t===i;return a&&(t=`data:application/xml,${encodeURIComponent(lc)}`),cs(t,this.type).then(l=>{if(l.status>=400&&e)throw new Error((n||`Failed to fetch required resource: ${t}`)+` (${l.status}${l.statusText?" "+l.statusText:""})`);o?(t+="?viv-toc-box",l.url+="?viv-toc-box"):a&&(l.url=t=i),this.parser(l,this).then(c=>{delete this.fetchers[t],this.resources[t]=c,s.finish(c)})}),s.result()}fetch(t,e,n){if(t=wt(t),this.resources[t])return null;let o=this.fetchers[t];return o||(o=new Kt(()=>this.fetchInner(t,e,n),`Fetch ${t}`),this.fetchers[t]=o,o.start()),o}get(t){return this.resources[wt(t)]}delete(t){delete this.resources[wt(t)]}};function mm(r,t){let e=r.responseText;return v(e?Ds(e):null)}function eh(){return new ls(mm,"text")}function Ln(r,t,e){let n=new Kt(()=>{let s=k("loadElement"),o=s.suspend(r),i=!1,a=l=>{i||(i=!0,o.schedule(l?l.type:"timeout"))};return r.addEventListener("load",a,!1),r.addEventListener("error",a,!1),r.addEventListener("abort",a,!1),r.namespaceURI=="http://www.w3.org/2000/svg"?(t&&r.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",t),setTimeout(a,300)):r.localName==="script"?setTimeout(a,3e3):t&&(r.src=t,e&&(r.alt=e)),s.result()},`loadElement ${t||r.localName}`);return n.start(),n}var th=0,Cm=16777216,fc=33554432,Pr=50331648,kr=67108864,bm=83886080,ym=100663296;var $o=class{constructor(t){this.scope=t;d(this,"flavor");this.flavor="Author"}getCurrentToken(){return null}getScope(){return this.scope}error(t,e){}startStylesheet(t){this.flavor=t}tagSelector(t,e){}classSelector(t){}pseudoclassSelector(t,e){}pseudoelementSelector(t,e){}idSelector(t){}attributeSelector(t,e,n,s){}descendantSelector(){}childSelector(){}adjacentSiblingSelector(){}followingSiblingSelector(){}nextSelector(){}startSelectorRule(){}startFontFaceRule(){}startFootnoteRule(t){}startViewportRule(){}startDefineRule(){}startRegionRule(){}startPageRule(){}startPageMarginBoxRule(t){}startWhenRule(t){}startMediaRule(t){this.startWhenRule(t)}startFlowRule(t){}startPageTemplateRule(){}startPageMasterRule(t,e,n){}startPartitionRule(t,e,n){}startPartitionGroupRule(t,e,n){}startRuleBody(){}property(t,e,n){}endRule(){}startFuncWithSelector(t){}endFuncWithSelector(){}pushSelectorText(t){}getImportantSpecificity(){switch(this.flavor){case"UA":return th;case"User":return ym;default:return bm}}getBaseSpecificity(){switch(this.flavor){case"UA":return th;case"User":return Cm;default:return fc}}},vr=class extends $o{constructor(){super(null);d(this,"stack",[]);d(this,"tokenizer",null);d(this,"slave",null)}pushHandler(e){this.stack.push(this.slave),this.slave=e}popHandler(){this.slave=this.stack.pop()}getCurrentToken(){return this.tokenizer?this.tokenizer.token():null}getScope(){return this.slave.getScope()}error(e,n){this.slave.error(e,n)}errorMsg(e,n){var s;I.warn(e,(s=n==null?void 0:n.toString())!=null?s:"")}startStylesheet(e){super.startStylesheet(e),this.stack.length>0&&(this.slave=this.stack[0],this.stack=[]),this.slave.startStylesheet(e)}tagSelector(e,n){this.slave.tagSelector(e,n)}classSelector(e){this.slave.classSelector(e)}pseudoclassSelector(e,n){this.slave.pseudoclassSelector(e,n)}pseudoelementSelector(e,n){this.slave.pseudoelementSelector(e,n)}idSelector(e){this.slave.idSelector(e)}attributeSelector(e,n,s,o){this.slave.attributeSelector(e,n,s,o)}descendantSelector(){this.slave.descendantSelector()}childSelector(){this.slave.childSelector()}adjacentSiblingSelector(){this.slave.adjacentSiblingSelector()}followingSiblingSelector(){this.slave.followingSiblingSelector()}nextSelector(){this.slave.nextSelector()}startSelectorRule(){this.slave.startSelectorRule()}startFontFaceRule(){this.slave.startFontFaceRule()}startFootnoteRule(e){this.slave.startFootnoteRule(e)}startViewportRule(){this.slave.startViewportRule()}startDefineRule(){this.slave.startDefineRule()}startRegionRule(){this.slave.startRegionRule()}startPageRule(){this.slave.startPageRule()}startPageMarginBoxRule(e){this.slave.startPageMarginBoxRule(e)}startWhenRule(e){this.slave.startWhenRule(e)}startFlowRule(e){this.slave.startFlowRule(e)}startPageTemplateRule(){this.slave.startPageTemplateRule()}startPageMasterRule(e,n,s){this.slave.startPageMasterRule(e,n,s)}startPartitionRule(e,n,s){this.slave.startPartitionRule(e,n,s)}startPartitionGroupRule(e,n,s){this.slave.startPartitionGroupRule(e,n,s)}startRuleBody(){this.slave.startRuleBody()}property(e,n,s){this.slave.property(e,n,s)}endRule(){this.slave.endRule()}startFuncWithSelector(e){this.slave.startFuncWithSelector(e)}endFuncWithSelector(){this.slave.endFuncWithSelector()}pushSelectorText(e){this.slave.pushSelectorText(e)}},Tr=class extends $o{constructor(e,n,s){super(e);this.owner=n;this.topLevel=s;d(this,"depth",0);n&&(this.flavor=n.flavor)}getCurrentToken(){var e;return(e=this.owner)==null?void 0:e.getCurrentToken()}error(e,n){var s;(s=this.owner)==null||s.errorMsg(e,n)}startRuleBody(){this.depth++}endRule(){--this.depth==0&&!this.topLevel&&this.owner.popHandler()}},qt=class extends Tr{constructor(t,e,n){super(t,e,n)}report(t){this.error(t,this.getCurrentToken())}reportAndSkip(t){this.report(t),this.owner.pushHandler(new Tr(this.scope,this.owner,!1))}startSelectorRule(){this.reportAndSkip("E_CSS_UNEXPECTED_SELECTOR")}startFontFaceRule(){this.reportAndSkip("E_CSS_UNEXPECTED_FONT_FACE")}startFootnoteRule(t){this.reportAndSkip("E_CSS_UNEXPECTED_FOOTNOTE")}startViewportRule(){this.reportAndSkip("E_CSS_UNEXPECTED_VIEWPORT")}startDefineRule(){this.reportAndSkip("E_CSS_UNEXPECTED_DEFINE")}startRegionRule(){this.reportAndSkip("E_CSS_UNEXPECTED_REGION")}startPageRule(){this.reportAndSkip("E_CSS_UNEXPECTED_PAGE")}startWhenRule(t){this.reportAndSkip("E_CSS_UNEXPECTED_WHEN")}startFlowRule(t){this.reportAndSkip("E_CSS_UNEXPECTED_FLOW")}startPageTemplateRule(){this.reportAndSkip("E_CSS_UNEXPECTED_PAGE_TEMPLATE")}startPageMasterRule(t,e,n){this.reportAndSkip("E_CSS_UNEXPECTED_PAGE_MASTER")}startPartitionRule(t,e,n){this.reportAndSkip("E_CSS_UNEXPECTED_PARTITION")}startPartitionGroupRule(t,e,n){this.reportAndSkip("E_CSS_UNEXPECTED_PARTITION_GROUP")}startFuncWithSelector(t){this.reportAndSkip("E_CSS_UNEXPECTED_SELECTOR_FUNC")}endFuncWithSelector(){this.reportAndSkip("E_CSS_UNEXPECTED_END_SELECTOR_FUNC")}property(t,e,n){this.error("E_CSS_UNEXPECTED_PROPERTY",this.getCurrentToken())}},me=[],wr=[],ie=[],xe=[],kt=[],ut=[],ye=[],ke=[],ne=[],Ie=[],qe=[],Re=[],be=[];var eo=55,to=56,Nr=57;me[1]=28,me[36]=29,me[7]=29,me[9]=29,me[14]=29,me[18]=29,me[50]=29,me[20]=30,me[13]=27,me[0]=200,wr[1]=46,wr[0]=200,ut[1]=2,ut[36]=4,ut[7]=6,ut[9]=8,ut[14]=10,ut[18]=14,ut[50]=42,ie[37]=11,ie[23]=12,ie[35]=56,ie[1]=1,ie[36]=3,ie[7]=5,ie[9]=7,ie[14]=9,ie[12]=13,ie[18]=55,ie[50]=58,ie[16]=41,xe[37]=11,xe[23]=12,xe[35]=56,xe[1]=1,xe[36]=3,xe[7]=5,xe[9]=7,xe[14]=9,xe[18]=55,kt[1]=2,kt[36]=4,kt[7]=6,kt[9]=8,kt[18]=14,kt[50]=42,kt[14]=10,kt[12]=13,ye[1]=15,ye[7]=16,ye[4]=17,ye[5]=18,ye[3]=19,ye[2]=20,ye[8]=21,ye[27]=57,ye[16]=22,ye[19]=23,ye[6]=24,ye[11]=25,ye[17]=26,ye[13]=48,ye[31]=47,ye[23]=54,ye[0]=44,ke[1]=31,ke[4]=32,ke[5]=32,ke[3]=33,ke[2]=34,ke[10]=40,ke[6]=38,ke[31]=36,ke[24]=36,ke[32]=35,ne[1]=45,ne[16]=37,ne[37]=37,ne[38]=37,ne[47]=37,ne[48]=37,ne[39]=37,ne[49]=37,ne[41]=37,ne[26]=37,ne[25]=37,ne[23]=37,ne[24]=37,ne[19]=37,ne[21]=37,ne[36]=37,ne[18]=37,ne[22]=37,ne[11]=39,ne[12]=43,ne[17]=49,Ie[0]=200,Ie[12]=50,Ie[13]=51,Ie[14]=50,Ie[15]=51,Ie[10]=50,Ie[11]=51,Ie[17]=53,qe[0]=200,qe[12]=50,qe[13]=52,qe[14]=50,qe[15]=51,qe[10]=50,qe[11]=51,qe[17]=53,Re[0]=200,Re[12]=50,Re[13]=51,Re[14]=50,Re[15]=51,Re[10]=50,Re[11]=51,be[11]=0,be[16]=0,be[22]=1,be[18]=1,be[26]=2,be[25]=2,be[38]=3,be[37]=3,be[48]=3,be[47]=3,be[39]=3,be[49]=3,be[41]=3,be[23]=4,be[24]=4,be[36]=5,be[19]=5,be[21]=5,be[0]=6,be[eo]=2,be[to]=2;var Rn=class{constructor(t,e,n,s){this.actions=t;this.tokenizer=e;this.handler=n;this.baseURL=s;d(this,"valStack",[]);d(this,"namespacePrefixToURI",{});d(this,"defaultNamespaceURI",null);d(this,"propName",null);d(this,"propImportant",!1);d(this,"exprContext");d(this,"result",null);d(this,"importReady",!1);d(this,"importURL",null);d(this,"importCondition",null);d(this,"errorBrackets",[]);d(this,"ruleStack",[]);d(this,"regionRule",!1);d(this,"pageRule",!1);d(this,"inStyleDeclaration",!1);this.exprContext=2}extractVals(t,e){let n=[],s=this.valStack;for(;e<s.length&&(n.push(s[e++]),e!==s.length);){if(s[e++]!==t)throw new Error("Unexpected state");e===s.length&&n.push(O)}return n}valStackReduce(t,e){let n=this.valStack,s=n.length,o=0,i;do if(i=n[--s],t===")"&&i instanceof kn){if(i.text===")")o++;else if(i.text==="("){if(o===0)return null;o--}}while(typeof i!="undefined"&&typeof i!="string");let a=n.length-(s+1);if(a>1&&n.splice(s+1,a,new q(n.slice(s+1,n.length))),t==",")return null;s++;do i=n[--s];while(typeof i!="undefined"&&(typeof i!="string"||i==","));if(a=n.length-(s+1),i=="("){t!=")"&&e.type!==0&&(this.handler.error("E_CSS_MISMATCHED_C_PAR",e),this.actions=qe);let c=new Pt(n[s-1],this.extractVals(",",s+1));if(n.splice(s-1,a+2,c),c.name==="var"){let u=c.values[0]instanceof Be&&c.values[0].name;(!bt(u)||u===this.propName)&&(this.handler.error(`E_CSS_INVALID_VAR ${c.toString()}`,e),this.actions=qe)}return c}if(t!=";"||s>=0)return this.handler.error("E_CSS_UNEXPECTED_VAL_END",e),this.actions=qe,null;if(a>1)return new ge(this.extractVals(",",s+1));let l=n[0];return l instanceof Se?l:l?new kn(l.toString()):O}exprError(t,e){this.actions=this.propName?qe:Ie,I.warn(t,e.toString())}exprStackReduce(t,e){let n=this.valStack,s=this.handler,o=n.pop(),i;for(;;){let a=n.pop();if(t==11){let l=[o];for(;a==16;)l.unshift(n.pop()),a=n.pop();if(typeof a=="string"){if(a=="{"){for(;l.length>=2;){let c=l.shift(),u=l.shift(),p=new sr(s.getScope(),c,u);l.unshift(p)}return n.push(new F(l[0])),!0}else if(a=="("){let c=n.pop(),u=n.pop();o=new sn(s.getScope(),Uo(u,c),l),t=0;continue}}if(a==10){o.isMediaName()&&(o=new _o(s.getScope(),o,null)),t=0;continue}}else if(typeof a=="string"){n.push(a);break}if(a<0)if(a==-31)o=new mt(s.getScope(),o);else if(a==-24)o=new Fo(s.getScope(),o);else if(a==-Nr)o=new tr(s.getScope(),o);else return this.exprError("F_UNEXPECTED_STATE",e),!1;else{if(be[t]>be[a]){n.push(a);break}switch(i=n.pop(),a){case 26:o=new Us(s.getScope(),i,o);break;case eo:o=new nr(s.getScope(),i,o);break;case to:o=new or(s.getScope(),i,o);break;case 25:o=new Hs(s.getScope(),i,o);break;case 38:o=new ir(s.getScope(),i,o);break;case 37:o=new ar(s.getScope(),i,o);break;case 48:o=new rr(s.getScope(),i,o);break;case 47:o=new ns(s.getScope(),i,o);break;case 39:case 49:o=new Pn(s.getScope(),i,o);break;case 41:o=new lr(s.getScope(),i,o);break;case 23:o=new Bo(s.getScope(),i,o);break;case 24:o=new Oo(s.getScope(),i,o);break;case 36:o=new ss(s.getScope(),i,o);break;case 19:o=new Do(s.getScope(),i,o);break;case 21:o=new zs(s.getScope(),i,o);break;case 18:if(n.length>1)switch(n[n.length-1]){case 22:n.pop(),o=new cr(s.getScope(),n.pop(),i,o);break;case 10:if(i.isMediaName())o=new _o(s.getScope(),i,o);else return this.exprError("E_CSS_MEDIA_TEST",e),!1;break}else return this.exprError("E_CSS_EXPR_COND",e),!1;break;case 22:if(t!=18)return this.exprError("E_CSS_EXPR_COND",e),!1;case 10:return n.push(i),n.push(a),n.push(o),!1;default:return this.exprError("F_UNEXPECTED_STATE",e),!1}}}return n.push(o),!1}readSupportsTest(t){let e=t.type===6,n=this.tokenizer,s,o;if(e)o=t.text,s=t.position+o.length+1;else if(t.type===10){let h=n.nthToken(1),f=n.nthToken(2);if(h.type===1&&f.type===18)n.consume(),n.consume(),o=h.text,s=f.position+1;else{if(h.type===10||h.type===6||h.type===1&&h.text.toLowerCase()==="not"&&(f.type===10||f.type===6))return null;s=t.position+1}}else return null;let i=0,a,l=0;for(;i>=0;)switch(n.consume(),a=n.token(),a.type){case 11:i--;break;case 10:case 6:i++;break;case 16:i===0&&l++;break;case 0:return this.exprError("E_CSS_UNEXPECTED_EOF",a),null}n.consume();let c=a.position,u=e&&o==="selector"&&l>0?"":n.input.substring(s,c).trim();return new ur(this.handler.getScope(),o,u,e)}readPseudoParams(){let t=[];for(;;){let e=this.tokenizer.token();switch(e.type){case 1:t.push(e.text);break;case 23:t.push("+");break;case 4:case 5:t.push(e.num);break;default:return t}this.tokenizer.consume()}}readNthPseudoParams(){let t=!1,e=this.tokenizer.token();if(e.type===23)t=!0,this.tokenizer.consume(),e=this.tokenizer.token();else if(e.type===1&&(e.text==="even"||e.text==="odd"))return this.tokenizer.consume(),[2,e.text==="odd"?1:0];switch(e.type){case 3:if(t&&e.num<0)return null;case 1:if(t&&e.text.charAt(0)==="-")return null;if(e.text==="n"||e.text==="-n"){if(t&&e.precededBySpace)return null;let n=e.text==="-n"?-1:1;e.type===3&&(n=e.num);let s=0;this.tokenizer.consume(),e=this.tokenizer.token();let o=e.type===24,i=e.type===23||o;if(i&&(this.tokenizer.consume(),e=this.tokenizer.token()),e.type===5){if(s=e.num,1/s===-1/0){if(s=0,i)return null}else if(s<0){if(i)return null}else if(s>=0&&!i)return null;this.tokenizer.consume()}else if(i)return null;return[n,o&&s>0?-s:s]}else if(e.text==="n-"||e.text==="-n-"){if(t&&e.precededBySpace)return null;let n=e.text==="-n-"?-1:1;if(e.type===3&&(n=e.num),this.tokenizer.consume(),e=this.tokenizer.token(),e.type===5)return e.num<0||1/e.num===-1/0?null:(this.tokenizer.consume(),[n,e.num])}else{let n=e.text.match(/^n(-[0-9]+)$/);if(n)return t&&e.precededBySpace?null:(this.tokenizer.consume(),[e.type===3?e.num:1,parseInt(n[1],10)]);if(n=e.text.match(/^-n(-[0-9]+)$/),n)return this.tokenizer.consume(),[-1,parseInt(n[1],10)]}return null;case 5:return t&&(e.precededBySpace||e.num<0)?null:(this.tokenizer.consume(),[0,e.num])}return null}makeCondition(t,e){let n=this.handler.getScope();if(!n)return null;if(e=e||n._true,t){let s=t.split(/\s+/);for(let o of s)switch(o){case"vertical":e=Je(n,e,new mt(n,new ae(n,"pref-horizontal")));break;case"horizontal":e=Je(n,e,new ae(n,"pref-horizontal"));break;case"day":e=Je(n,e,new mt(n,new ae(n,"pref-night-mode")));break;case"night":e=Je(n,e,new ae(n,"pref-night-mode"));break;default:e=n._false}}return e===n._true?null:new F(e)}isInsidePropertyOnlyRule(){switch(this.ruleStack[this.ruleStack.length-1]){case"[selector]":case"font-face":case"-epubx-flow":case"-epubx-viewport":case"-epubx-define":case"-adapt-footnote-area":return!0}return!1}runParser(t,e,n,s,o,i){let a=this.handler,l=this.tokenizer,c=this.valStack,u,p,h,f,g,m,E,C=null;for(n&&(this.inStyleDeclaration=!0),s&&(this.exprContext=2,this.valStack.push("{"));t>0;--t){if(u=l.token(),o&&C===null&&(C=u.position-1,l.input[C]==="("&&C++),this.actions===ye&&this.errorBrackets.length>0&&(u.type===this.errorBrackets[this.errorBrackets.length-1]||u.type===17||u.type===31)){if(u.type===this.errorBrackets[this.errorBrackets.length-1]&&(this.errorBrackets.pop(),u.type===11&&this.valStackReduce(")",u))){l.consume();continue}c.push(new kn(u.toString())),l.consume();continue}switch(this.actions[u.type]){case 28:if(!this.inStyleDeclaration||l.nthToken(1).type!=18){this.isInsidePropertyOnlyRule()?(a.error("E_CSS_COLON_EXPECTED",l.nthToken(1)),this.actions=qe):(this.actions=ut,a.startSelectorRule());continue}this.propName=u.text,this.propImportant=!1,l.consume(),l.consume(),this.actions=ye,c.splice(0,c.length);continue;case 46:if(l.nthToken(1).type!=18){this.actions=qe,a.error("E_CSS_COLON_EXPECTED",l.nthToken(1));continue}this.propName=u.text,this.propImportant=!1,l.consume(),l.consume(),this.actions=ye,c.splice(0,c.length);continue;case 29:this.actions=ut,a.startSelectorRule();continue;case 1:if(!u.precededBySpace){this.actions=Re,a.error("E_CSS_SPACE_EXPECTED",u);continue}a.descendantSelector();case 2:if(l.nthToken(1).type==34)if(l.consume(),l.consume(),h=this.namespacePrefixToURI[u.text],h!=null)switch(u=l.token(),u.type){case 1:a.tagSelector(h,u.text),o?this.actions=xe:this.actions=ie,l.consume();break;case 36:a.tagSelector(h,null),o?this.actions=xe:this.actions=ie,l.consume();break;default:this.actions=Ie,a.error("E_CSS_NAMESPACE",u)}else this.actions=Ie,a.error("E_CSS_UNDECLARED_PREFIX",u);else a.tagSelector(this.defaultNamespaceURI,u.text),o?this.actions=xe:this.actions=ie,l.consume();continue;case 3:if(!u.precededBySpace){this.actions=Re,a.error("E_CSS_SPACE_EXPECTED",u);continue}a.descendantSelector();case 4:if(l.nthToken(1).type==34)switch(l.consume(),l.consume(),u=l.token(),u.type){case 1:a.tagSelector(null,u.text),o?this.actions=xe:this.actions=ie,l.consume();break;case 36:a.tagSelector(null,null),o?this.actions=xe:this.actions=ie,l.consume();break;default:this.actions=Ie,a.error("E_CSS_NAMESPACE",u)}else a.tagSelector(this.defaultNamespaceURI,null),o?this.actions=xe:this.actions=ie,l.consume();continue;case 5:u.precededBySpace&&a.descendantSelector();case 6:if(!u.text){a.error("E_CSS_SYNTAX",u),l.consume();continue}a.idSelector(u.text),o?this.actions=xe:this.actions=ie,l.consume();continue;case 7:u.precededBySpace&&a.descendantSelector();case 8:a.classSelector(u.text),o?this.actions=xe:this.actions=ie,l.consume();continue;case 55:u.precededBySpace&&a.descendantSelector();case 14:l.consume(),u=l.token();e:switch(u.type){case 1:a.pseudoclassSelector(u.text,null),l.consume(),o?this.actions=xe:this.actions=ie;continue;case 6:switch(f=u.text,l.consume(),f){case"is":case"not":case"where":case"has":this.actions=ut,a.startFuncWithSelector(f),this.runParser(Number.POSITIVE_INFINITY,!1,!1,!1,!0,f==="has")?this.actions=ie:this.actions=Re;continue;case"lang":case"href-epub-type":if(u=l.token(),u.type===1){E=[u.text],l.consume(),f==="href-epub-type"&&l.token().type===16&&(l.consume(),u=l.token(),u.type===1&&(E.push(u.text),l.consume()));break}else break e;case"nth-child":case"nth-of-type":case"nth-last-child":case"nth-last-of-type":case"nth":if(E=this.readNthPseudoParams(),E)break;break e;default:E=this.readPseudoParams()}if(u=l.token(),u.type==11){a.pseudoclassSelector(f,E),l.consume(),o?this.actions=xe:this.actions=ie;continue}break}a.error("E_CSS_PSEUDOCLASS_SYNTAX",u),this.actions=Ie;continue;case 58:u.precededBySpace&&a.descendantSelector();case 42:switch(l.consume(),u=l.token(),u.type){case 1:a.pseudoelementSelector(u.text,null),o?this.actions=xe:this.actions=ie,l.consume();continue;case 6:if(f=u.text,l.consume(),f=="nth-fragment"){if(E=this.readNthPseudoParams(),E===null)break}else E=this.readPseudoParams();if(u=l.token(),u.type==11){a.pseudoelementSelector(f,E),o?this.actions=xe:this.actions=ie,l.consume();continue}break}a.error("E_CSS_PSEUDOELEM_SYNTAX",u),this.actions=Ie;continue;case 9:u.precededBySpace&&a.descendantSelector();case 10:if(l.consume(),u=l.token(),u.type==1)f=u.text,l.consume();else if(u.type==36)f=null,l.consume();else if(u.type==34)f="";else{this.actions=Re,a.error("E_CSS_ATTR",u),l.consume();continue}if(u=l.token(),u.type==34){if(h=f&&this.namespacePrefixToURI[f],h===void 0){this.actions=Re,a.error("E_CSS_UNDECLARED_PREFIX",u),l.consume();continue}if(l.consume(),u=l.token(),u.type!=1){this.actions=Re,a.error("E_CSS_ATTR_NAME_EXPECTED",u);continue}f=u.text,l.consume(),u=l.token()}else h="";switch(u.type){case 39:case 45:case 44:case 43:case 42:case 46:case 50:g=u.type,l.consume(),u=l.token();break;case 15:a.attributeSelector(h,f,0,null),o?this.actions=xe:this.actions=ie,l.consume();continue;default:this.actions=Re,a.error("E_CSS_ATTR_OP_EXPECTED",u);continue}switch(u.type){case 1:case 2:a.attributeSelector(h,f,g,u.text),l.consume(),u=l.token();break;default:this.actions=Re,a.error("E_CSS_ATTR_VAL_EXPECTED",u);continue}if(u.type!=15){this.actions=Re,a.error("E_CSS_ATTR",u);continue}o?this.actions=xe:this.actions=ie,l.consume();continue;case 11:a.childSelector(),this.actions=kt,l.consume();continue;case 12:a.adjacentSiblingSelector(),this.actions=kt,l.consume();continue;case 56:a.followingSiblingSelector(),this.actions=kt,l.consume();continue;case 13:this.regionRule?(this.ruleStack.push("-epubx-region"),this.regionRule=!1):this.pageRule?(this.ruleStack.push("page"),this.pageRule=!1,this.inStyleDeclaration=!0):(this.ruleStack.push("[selector]"),this.inStyleDeclaration=!0),a.startRuleBody(),this.actions=me,l.consume();continue;case 41:a.nextSelector(),this.actions=ut,l.consume();continue;case 15:c.push(L(u.text)),l.consume();continue;case 16:g=parseInt(u.text,16),c.push(new Xs(u.text)),l.consume();continue;case 17:c.push(new lt(u.num)),l.consume();continue;case 18:c.push(new ct(u.num)),l.consume();continue;case 19:c.push(new P(u.num,u.text)),l.consume();continue;case 20:c.push(new ce(u.text)),l.consume();continue;case 21:c.push(new Ue(J(u.text,this.baseURL))),l.consume();continue;case 57:c.push(new zo(u.text)),l.consume();continue;case 22:this.valStackReduce(",",u),c.push(","),l.consume();continue;case 23:c.push($s),l.consume();continue;case 24:f=u.text.toLowerCase(),f=="-epubx-expr"||f=="env"?(this.actions=ke,this.exprContext=0,c.push("{")):(c.push(f),c.push("("),this.errorBrackets.length>0&&this.errorBrackets.push(11)),l.consume();continue;case 25:this.valStackReduce(")",u),l.consume();continue;case 47:if(l.consume(),u=l.token(),p=l.nthToken(1),u.type==1&&u.text.toLowerCase()=="important"&&(p.type==17||p.type==0||p.type==13)){l.consume(),this.propImportant=!0;continue}this.exprError("E_CSS_SYNTAX",u);continue;case 54:switch(p=l.nthToken(1),p.type){case 4:case 3:case 5:if(!p.precededBySpace){l.consume();continue}}c.push(new kn("+")),l.consume();continue;case 26:l.consume();case 48:m=this.valStackReduce(";",u),m&&this.propName&&a.property(this.propName,m,this.propImportant),this.actions=n?wr:me;continue;case 44:for(l.consume();c.length>0;){let b=c.length;if(m=this.valStackReduce(";",u),!m||c.length===b)break}return e?(this.result=m,!0):(this.propName&&m&&a.property(this.propName,m,this.propImportant),!0);case 31:if(p=l.nthToken(1),p.type==9)l.nthToken(2).type==10&&!l.nthToken(2).precededBySpace?(c.push(u.text,p.text,"("),l.consume()):(c.push(new ae(a.getScope(),Uo(u.text,p.text))),this.actions=ne),l.consume();else{if(this.exprContext==2||this.exprContext==3)u.text.toLowerCase()=="not"?(l.consume(),c.push(new Mo(a.getScope(),!0,p.text))):(u.text.toLowerCase()=="only"&&(l.consume(),u=p),c.push(new Mo(a.getScope(),!1,u.text)));else if(this.exprContext===4&&u.text.toLowerCase()==="not"&&c[c.length-1]!==eo&&c[c.length-1]!==to&&(p.type===10||p.type===6)){c.push(-Nr),l.consume();continue}else c.push(new ae(a.getScope(),u.text));this.actions=ne}l.consume();continue;case 38:if(this.exprContext===4){c.push(this.readSupportsTest(u)),this.actions=ne;continue}c.push(null,u.text,"("),l.consume();continue;case 32:c.push(new se(a.getScope(),u.num)),l.consume(),this.actions=ne;continue;case 33:f=u.text,f=="%"&&(this.propName&&this.propName.match(/height|^(top|bottom)$/)?f="vh":f="vw"),c.push(new rt(a.getScope(),u.num,f)),l.consume(),this.actions=ne;continue;case 34:c.push(new se(a.getScope(),u.text)),l.consume(),this.actions=ne;continue;case 35:l.consume(),u=l.token(),u.type!=5||u.precededBySpace?this.exprError("E_CSS_SYNTAX",u):(c.push(new Gs(a.getScope(),u.num)),l.consume(),this.actions=ne);continue;case 36:c.push(-u.type),l.consume();continue;case 37:this.actions=ke,this.exprStackReduce(u.type,u),c.push(u.type),l.consume();continue;case 45:u.text.toLowerCase()==="and"&&c[c.length-2]!==to&&c[c.length-2]!==-Nr?(this.actions=ke,this.exprStackReduce(eo,u),c.push(eo),l.consume()):u.text.toLowerCase()==="or"&&c[c.length-2]!==eo&&c[c.length-2]!==-Nr?(this.actions=ke,this.exprStackReduce(to,u),c.push(to),l.consume()):this.exprError("E_CSS_SYNTAX",u);continue;case 39:this.exprStackReduce(u.type,u)&&(this.actions=ye),l.consume();continue;case 43:this.exprStackReduce(11,u)&&(this.propName||this.exprContext==3?this.exprError("E_CSS_UNEXPECTED_BRC",u):(this.exprContext==1?a.startWhenRule(c.pop()):a.startMediaRule(c.pop()),this.ruleStack.push("media"),a.startRuleBody(),this.actions=me)),l.consume();continue;case 49:if(this.exprStackReduce(11,u))return this.propName||this.exprContext!=3?(this.exprError("E_CSS_UNEXPECTED_SEMICOL",u),this.actions=me,l.consume(),!1):(this.importCondition=c.pop(),this.importReady=!0,this.actions=me,l.consume(),!1);l.consume();continue;case 40:if(this.exprContext===4){let b=this.readSupportsTest(u);if(b){c.push(b),this.actions=ne;continue}}c.push(u.type),l.consume();continue;case 27:if(this.actions=me,l.consume(),a.endRule(),this.inStyleDeclaration=!1,this.ruleStack.length)switch(this.ruleStack.pop(),this.ruleStack[this.ruleStack.length-1]){case"page":case"-epubx-page-master":case"-epubx-partition-group":this.inStyleDeclaration=!0}continue;case 30:switch(f=u.text.toLowerCase(),f){case"import":if(l.consume(),u=l.token(),u.type==2||u.type==8){if(this.importURL=u.text,l.consume(),u=l.token(),u.type==17||u.type==0)return this.importReady=!0,l.consume(),!1;this.propName=null,this.exprContext=3,this.actions=ke,c.push("{");continue}a.error("E_CSS_IMPORT_SYNTAX",u),this.actions=Ie;continue;case"namespace":switch(l.consume(),u=l.token(),u.type){case 1:if(f=u.text,l.consume(),u=l.token(),(u.type==2||u.type==8)&&l.nthToken(1).type==17){this.namespacePrefixToURI[f]=u.text,l.consume(),l.consume();continue}break;case 2:case 8:if(l.nthToken(1).type==17){this.defaultNamespaceURI=u.text,l.consume(),l.consume();continue}break}a.error("E_CSS_NAMESPACE_SYNTAX",u),this.actions=Ie;continue;case"charset":if(l.consume(),u=l.token(),u.type==2&&l.nthToken(1).type==17){f=u.text.toLowerCase(),f!="utf-8"&&f!="utf-16"&&a.error(`E_CSS_UNEXPECTED_CHARSET ${f}`,u),l.consume(),l.consume();continue}a.error("E_CSS_CHARSET_SYNTAX",u),this.actions=Ie;continue;case"font-face":case"-epubx-page-template":case"-epubx-define":case"-epubx-viewport":if(l.nthToken(1).type==12){switch(l.consume(),l.consume(),f){case"font-face":a.startFontFaceRule(),this.inStyleDeclaration=!0;break;case"-epubx-page-template":a.startPageTemplateRule();break;case"-epubx-define":a.startDefineRule(),this.inStyleDeclaration=!0;break;case"-epubx-viewport":a.startViewportRule(),this.inStyleDeclaration=!0;break}this.ruleStack.push(f),a.startRuleBody();continue}break;case"-adapt-footnote-area":switch(l.consume(),u=l.token(),u.type){case 12:l.consume(),a.startFootnoteRule(null),this.ruleStack.push(f),a.startRuleBody(),this.inStyleDeclaration=!0;continue;case 50:if(l.consume(),u=l.token(),u.type==1&&l.nthToken(1).type==12){f=u.text,l.consume(),l.consume(),a.startFootnoteRule(f),this.ruleStack.push("-adapt-footnote-area"),a.startRuleBody(),this.inStyleDeclaration=!0;continue}break}break;case"-epubx-region":l.consume(),a.startRegionRule(),this.regionRule=!0,this.actions=ut;continue;case"page":l.consume(),a.startPageRule(),this.pageRule=!0,this.actions=kt;continue;case"top-left-corner":case"top-left":case"top-center":case"top-right":case"top-right-corner":case"right-top":case"right-middle":case"right-bottom":case"bottom-right-corner":case"bottom-right":case"bottom-center":case"bottom-left":case"bottom-left-corner":case"left-bottom":case"left-middle":case"left-top":if(l.consume(),u=l.token(),u.type==12){l.consume(),a.startPageMarginBoxRule(f),this.ruleStack.push(f),a.startRuleBody(),this.inStyleDeclaration=!0;continue}break;case"-epubx-when":l.consume(),this.propName=null,this.exprContext=1,this.actions=ke,c.push("{");continue;case"media":l.consume(),this.propName=null,this.exprContext=2,this.actions=ke,c.push("{");continue;case"supports":l.consume(),this.propName=null,this.exprContext=4,this.actions=ke,c.push("{");continue;case"-epubx-flow":if(l.nthToken(1).type==1&&l.nthToken(2).type==12){a.startFlowRule(l.nthToken(1).text),l.consume(),l.consume(),l.consume(),this.ruleStack.push(f),a.startRuleBody(),this.inStyleDeclaration=!0;continue}break;case"-epubx-page-master":case"-epubx-partition":case"-epubx-partition-group":{l.consume(),u=l.token();let b=null,y=null,N=[];for(u.type==1&&(b=u.text,l.consume(),u=l.token()),u.type==18&&l.nthToken(1).type==1&&(y=l.nthToken(1).text,l.consume(),l.consume(),u=l.token());u.type==6&&u.text.toLowerCase()=="class"&&l.nthToken(1).type==1&&l.nthToken(2).type==11;)N.push(l.nthToken(1).text),l.consume(),l.consume(),l.consume(),u=l.token();if(u.type==12){switch(l.consume(),f){case"-epubx-page-master":a.startPageMasterRule(b,y,N);break;case"-epubx-partition":a.startPartitionRule(b,y,N);break;case"-epubx-partition-group":a.startPartitionGroupRule(b,y,N);break}this.ruleStack.push(f),a.startRuleBody(),this.inStyleDeclaration=!0;continue}break}case"":a.error(`E_CSS_UNEXPECTED_AT${f}`,u),this.actions=Re;continue;default:a.error(`E_CSS_AT_UNKNOWN ${f}`,u),this.actions=Ie;continue}a.error(`E_CSS_AT_SYNTAX ${f}`,u),this.actions=Ie;continue;case 50:this.errorBrackets.push(u.type+1),l.consume();continue;case 52:if(this.errorBrackets.length==0){this.actions=me;continue}case 51:if(o&&this.errorBrackets.length==0&&u.type==11)return l.consume(),a.endFuncWithSelector(),!0;this.errorBrackets.length>0&&this.errorBrackets[this.errorBrackets.length-1]==u.type&&this.errorBrackets.pop(),this.errorBrackets.length==0&&u.type==13&&(this.actions=me),l.consume();continue;case 53:this.errorBrackets.length==0&&(this.actions=me),l.consume();continue;case 200:return!0;default:if(s)return this.exprStackReduce(11,u)?(this.result=c.pop(),!0):!1;if(o){switch(u.type){case 16:case 11:if(this.actions===ut)a.error("E_CSS_SYNTAX",u);else{let b=l.input.substring(C,u.position);a.pushSelectorText(b),C=u.position+1}if(u.type===16){a.nextSelector(),this.actions=ut,l.consume();continue}else return a.endFuncWithSelector(),l.consume(),!0;case 37:case 23:case 35:if(i){this.actions=ie;continue}break;case 12:case 14:case 10:this.errorBrackets.push(u.type+1);break}a.error("E_CSS_SYNTAX",u),l.consume(),this.actions=Re;continue}if(this.actions!==Ie&&this.actions!==Re&&this.actions!==qe){if(u.type==54)a.error("E_CSS_SYNTAX",u);else if(this.actions===ye){switch(u.type){case 10:case 12:case 14:this.errorBrackets.push(u.type+1);break}c.push(new kn(u.toString())),l.consume();continue}else if(u.type===12&&this.actions==ke&&c.length>0){a.startMediaRule(c.pop()),this.ruleStack.push("media"),a.startRuleBody(),this.actions=me,l.consume();continue}else{if(u.type===17&&this.actions==ke)return this.actions=me,l.consume(),!1;a.error("E_CSS_SYNTAX",u)}this.isInsidePropertyOnlyRule()?this.actions=qe:this.actions=Re;continue}l.consume();continue}}return!1}},jo=class extends $o{constructor(e){super(null);this.scope=e}error(e,n){I.warn(e,n.toString())}getScope(){return this.scope}};function xm(r,t,e,n,s){let o=k("parseStylesheet"),i=new Rn(me,r,t,e),a=null;return s&&(a=Em(new Oe(s,t),t,e)),a=i.makeCondition(n,a&&a.toExpr()),a&&(t.startMediaRule(a),t.startRuleBody()),o.loop(()=>{for(;!i.runParser(100,!1,!1,!1,!1);){if(i.importReady){let c=J(i.importURL,e);i.importCondition&&(t.startMediaRule(i.importCondition),t.startRuleBody());let u=k("parseStylesheet.import");return gc(c,t,null,null).then(()=>{i.importCondition&&t.endRule(),i.importReady=!1,i.importURL=null,i.importCondition=null,u.finish(!0)}),u.result()}let l=o.timeSlice();if(l.isPending)return l}return v(!1)}).then(()=>{a&&t.endRule(),o.finish(!0)}),o.result()}function Ar(r,t,e,n,s){return ln("parseStylesheetFromText",o=>{let i=new Oe(r,t);xm(i,t,e,n,s).thenFinish(o)},(o,i)=>{I.warn(i,`Failed to parse stylesheet text: ${r}`),o.finish(!1)})}function gc(r,t,e,n){return ln("parseStylesheetFromURL",s=>{cs(r).then(o=>{o.responseText?Ar(o.responseText,t,r,e,n).then(i=>{i||I.warn(`Failed to parse stylesheet from ${r}`),s.finish(!0)}):s.finish(!0)})},(s,o)=>{I.warn(o,"Exception while fetching and parsing:",r),s.finish(!0)})}function Zt(r,t,e){let n=new Rn(ye,t,new jo(r),e);return n.runParser(Number.POSITIVE_INFINITY,!0,!1,!1,!1),n.result}function sh(r,t,e){new Rn(wr,r,t,e).runParser(Number.POSITIVE_INFINITY,!1,!0,!1,!1)}function Em(r,t,e){let n=new Rn(ke,r,t,e);return n.runParser(Number.POSITIVE_INFINITY,!1,!1,!0,!1),n.result}var Sm={"z-index":!0,"column-count":!0,"flow-linger":!0,opacity:!0,page:!0,"flow-priority":!0,utilization:!0};function Nm(r){return!!Sm[r]}function oh(r,t,e){let n=t.evaluate(r);switch(typeof n){case"number":return Nm(e)?n==Math.round(n)?new ct(n):new lt(n):new P(n,"px");case"string":return n?Zt(t.scope,new Oe(n,null),""):O;case"boolean":return n?x._true:x._false;case"undefined":return O}throw new Error("E_UNEXPECTED")}function ih(r,t){let e={};return Object.keys(r).forEach(n=>{let s=e[n]={},o=r[n];Object.keys(o).forEach(i=>{s[i]=o[i].map(a=>{let l=t?a.logical:a.physical,c=t?a.physical:a.logical;return{regexp:new RegExp(`(-?)${l}(-?)`),to:`$1${c}$2`}})})}),e}function rh(r,t,e,n){let s=n[t];if(!s)throw new Error(`unknown writing-mode: ${t}`);let o=s[e||"ltr"];if(!o)throw new Error(`unknown direction: ${e}`);for(let i of o){let a=r.replace(i.regexp,i.to);if(a!==r)return a}return r}var ah={"horizontal-tb":{ltr:[{logical:"inline-start",physical:"left"},{logical:"inline-end",physical:"right"},{logical:"block-start",physical:"top"},{logical:"block-end",physical:"bottom"},{logical:"inline-size",physical:"width"},{logical:"block-size",physical:"height"}],rtl:[{logical:"inline-start",physical:"right"},{logical:"inline-end",physical:"left"},{logical:"block-start",physical:"top"},{logical:"block-end",physical:"bottom"},{logical:"inline-size",physical:"width"},{logical:"block-size",physical:"height"}]},"vertical-rl":{ltr:[{logical:"inline-start",physical:"top"},{logical:"inline-end",physical:"bottom"},{logical:"block-start",physical:"right"},{logical:"block-end",physical:"left"},{logical:"inline-size",physical:"height"},{logical:"block-size",physical:"width"}],rtl:[{logical:"inline-start",physical:"bottom"},{logical:"inline-end",physical:"top"},{logical:"block-start",physical:"right"},{logical:"block-end",physical:"left"},{logical:"inline-size",physical:"height"},{logical:"block-size",physical:"width"}]},"vertical-lr":{ltr:[{logical:"inline-start",physical:"top"},{logical:"inline-end",physical:"bottom"},{logical:"block-start",physical:"left"},{logical:"block-end",physical:"right"},{logical:"inline-size",physical:"height"},{logical:"block-size",physical:"width"}],rtl:[{logical:"inline-start",physical:"bottom"},{logical:"inline-end",physical:"top"},{logical:"block-start",physical:"left"},{logical:"block-end",physical:"right"},{logical:"inline-size",physical:"height"},{logical:"block-size",physical:"width"}]}},vm=ih(ah,!0);function mc(r,t,e){return rh(r,t,e||null,vm)}var Tm=ih(ah,!1);function Cc(r,t,e){return rh(r,t,e||null,Tm)}var wm={"horizontal-tb":[{logical:"line-left",physical:"left"},{logical:"line-right",physical:"right"},{logical:"over",physical:"top"},{logical:"under",physical:"bottom"}],"vertical-rl":[{logical:"line-left",physical:"top"},{logical:"line-right",physical:"bottom"},{logical:"over",physical:"right"},{logical:"under",physical:"left"}],"vertical-lr":[{logical:"line-left",physical:"top"},{logical:"line-right",physical:"bottom"},{logical:"over",physical:"right"},{logical:"under",physical:"left"}]};function lh(r,t){let e=wm[t];if(!e)throw new Error(`unknown writing-mode: ${t}`);for(let n=0;n<e.length;n++)if(e[n].physical===r)return e[n].logical;return r}function no(r,t,e){let n={display:t.style.display,position:t.style.position,width:t.style.width,maxWidth:t.style.maxWidth,minWidth:t.style.minWidth,height:t.style.height,maxHeight:t.style.maxHeight,minHeight:t.style.minHeight},s=t.ownerDocument,o=t.parentNode,i=s.createElement("div");T(i,"position",n.position),o.insertBefore(i,t),i.appendChild(t),T(t,"width","auto"),T(t,"max-width","none"),T(t,"min-width","0"),T(t,"height","auto"),T(t,"max-height","none"),T(t,"min-height","0");function a(N){return r.getElementComputedStyle(t).getPropertyValue(N)}let l=yl("writing-mode"),c=(l?a(l[0]):null)||a("writing-mode"),u=c==="vertical-rl"||c==="tb-rl"||c==="vertical-lr"||c==="tb-lr",p=u?"height":"width",h=u?"width":"height";function f(){return T(t,"display","block"),T(t,"position","static"),a(p)}function g(){T(t,"display","inline-block"),T(i,p,"99999999px");let N=a(p);return T(i,p,""),N}function m(){T(t,"display","inline-block"),T(i,p,"0");let N=a(p);return T(i,p,""),N}function E(){let N=f(),S=m(),w=parseFloat(N);if(w<=parseFloat(S))return S;{let A=g();return w<=parseFloat(A)?N:A}}function C(){return a(h)}function b(){throw new Error("Getting fill-available block size is not implemented")}let y={};return e.forEach(N=>{var w;let S;switch(N){case"fill-available inline size":S=f();break;case"max-content inline size":S=g();break;case"min-content inline size":S=m();break;case"fit-content inline size":S=E();break;case"fill-available block size":S=b();break;case"max-content block size":case"min-content block size":case"fit-content block size":S=C();break;case"fill-available width":S=u?b():f();break;case"fill-available height":S=u?f():b();break;case"max-content width":S=u?C():g();break;case"max-content height":S=u?g():C();break;case"min-content width":S=u?C():m();break;case"min-content height":S=u?m():C();break;case"fit-content width":S=u?C():E();break;case"fit-content height":S=u?E():C();break}S==="0px"&&t.childNodes.length===1&&((w=t.firstElementChild)==null?void 0:w.localName)==="img"&&!t.firstElementChild.complete&&(S="1px"),y[N]=parseFloat(S),T(t,"position",n.position),T(t,"display",n.display)}),T(t,"width",n.width),T(t,"max-width",n.maxWidth),T(t,"min-width",n.minWidth),T(t,"height",n.height),T(t,"max-height",n.maxHeight),T(t,"min-height",n.minHeight),o.insertBefore(t,i),o.removeChild(i),y}function ps(r){var t,e;return((t=r==null?void 0:r.style)==null?void 0:t["box-decoration-break"])==="clone"||((e=r==null?void 0:r.style)==null?void 0:e["-webkit-box-decoration-break"])==="clone"}function yc(r){let t=r.getAttribute("data-viv-box-break");return t?t.split(" "):[]}function xc(r,t){r.setAttribute("data-viv-box-break",t.join(" "))}function dt(r,t){let e=yc(r);e.includes(t)||(e.push(t),xc(r,e))}function km(r){let t=r.getAttribute("data-viv-margin-discard");return t?t.split(" "):[]}function Am(r,t){r.setAttribute("data-viv-margin-discard",t.join(" "))}function Lr(r,t){let e=km(r);e.includes(t)||(e.push(t),Am(r,e))}function Lm(r){let t=r.name,e=r.value;switch(t){case"page-break-before":case"page-break-after":case"page-break-inside":return{name:t.replace(/^page-/,""),value:e===x.always?x.page:e,important:r.important};default:return r}}var Rr={page:!0,left:!0,right:!0,recto:!0,verso:!0,column:!0,region:!0};function De(r){return!!Rr[r]}var Rm={left:!0,right:!0,recto:!0,verso:!0};function In(r){return!!Rm[r]}var Im={avoid:!0,"avoid-page":!0,"avoid-column":!0,"avoid-region":!0};function so(r){return!!Im[r]}function Ve(r,t){if(r)if(t){if(In(t))return t;if(In(r))return r;{let e=De(r),n=De(t);if(e&&n)switch(t){case"column":return r;case"region":return r==="column"?t:r;default:return t}else return n?t:e?r:so(t)?t:so(r)?r:t}}else return r;else return t}function Ec(r){return De(r)?r:"auto"}_e("SIMPLE_PROPERTY",Lm);var oo=Ng(yh());function xh(r,t){return(0,oo.default)(r,t,0)}function Tc(r){return r.reduce((t,e)=>e[0]===oo.default.DELETE?t:t+e[1],"")}function Eh(r,t){return Nh(r,t,1)}function Sh(r,t){return Nh(r,t,-1)}function Nh(r,t,e){let n=0,s=0;return r.some(o=>{for(let i=0;i<o[1].length;i++){switch(o[0]*e){case oo.default.INSERT:n++;break;case oo.default.DELETE:n--,s++;break;case oo.default.EQUAL:s++;break}if(s>t)return!0}return!1}),Math.max(Math.min(t,s-1)+n,0)}var Fr;(t=>{function r(e){return e&&e.formattingContextType==="Block"}t.isInstanceOfBlockFormattingContext=r})(Fr||(Fr={}));var Vn;(t=>{let r;(i=>(i.INLINE="inline",i.COLUMN="column",i.REGION="region",i.PAGE="page"))(r=t.FloatReference||(t.FloatReference={}))})(Vn||(Vn={}));var Ko;(t=>{function r(e){return e&&e.flagmentLayoutConstraintType=="AfterIfContinue"}t.isInstanceOfAfterIfContinuesLayoutConstraint=r})(Ko||(Ko={}));var Qt;(e=>{function r(n){return n?n.formattingContextType==="RepetitiveElementsOwner"||Ot.isInstanceOfTableFormattingContext(n):!1}e.isInstanceOfRepetitiveElementsOwnerFormattingContext=r;function t(n){return n?n.flagmentLayoutConstraintType==="RepetitiveElementsOwner"||Ot.isInstanceOfTableRowLayoutConstraint(n):!1}e.isInstanceOfRepetitiveElementsOwnerLayoutConstraint=t})(Qt||(Qt={}));var Ot;(e=>{function r(n){return n&&n.formattingContextType==="Table"}e.isInstanceOfTableFormattingContext=r;function t(n){return n&&n.flagmentLayoutConstraintType==="TableRow"}e.isInstanceOfTableRowLayoutConstraint=t})(Ot||(Ot={}));var At;(e=>{let r;(i=>(i[i.IGNORE=0]="IGNORE",i[i.NEWLINE=1]="NEWLINE",i[i.PRESERVE=2]="PRESERVE"))(r=e.Whitespace||(e.Whitespace={}));let t;(a=>(a[a.NONE=0]="NONE",a[a.CONTENT=1]="CONTENT",a[a.ROOTLESS=2]="ROOTLESS",a[a.ROOTED=3]="ROOTED"))(t=e.ShadowType||(e.ShadowType={}))})(At||(At={}));var vh={transform:!0,"transform-origin":!0},Th={top:!0,bottom:!0,left:!0,right:!0},Bn=class{constructor(t,e,n){this.target=t;this.name=e;this.value=n}},zm={show:function(r){r.style.visibility="visible"},hide:function(r){r.style.visibility="hidden"},play:function(r){r.currentTime=0,r.play()},pause:function(r){r.pause()},resume:function(r){r.play()},mute:function(r){r.muted=!0},unmute:function(r){r.muted=!1}};function Gm(r,t){let e=zm[t];return e?()=>{for(let n=0;n<r.length;n++)try{e(r[n])}catch(s){}}:null}var Fn=class Fn extends Nn{constructor(e,n){super();this.container=e;this.bleedBox=n;d(this,"pageAreaElement",null);d(this,"delayedItems",[]);d(this,"hrefHandler");d(this,"elementsById",{});d(this,"dimensions",{width:0,height:0});d(this,"isFirstPage",!1);d(this,"isLastPage",!1);d(this,"isBlankPage",!1);d(this,"isAutoPageWidth",!0);d(this,"isAutoPageHeight",!0);d(this,"spineIndex",0);d(this,"position",null);d(this,"offset",-1);d(this,"side",null);d(this,"fetchers",[]);d(this,"marginBoxes",{top:{},bottom:{},left:{},right:{}});d(this,"pageType",null);this.hrefHandler=s=>{let o=s.currentTarget,i=o.getAttribute("href")||o.getAttributeNS("http://www.w3.org/1999/xlink","href");if(i){let a={type:"hyperlink",target:null,currentTarget:null,anchorElement:o,href:i,preventDefault(){s.preventDefault()}};this.dispatchEvent(a)}}}setAutoPageWidth(e){this.isAutoPageWidth=e,e?this.container.setAttribute(Fn.AUTO_PAGE_WIDTH_ATTRIBUTE,"true"):this.container.removeAttribute(Fn.AUTO_PAGE_WIDTH_ATTRIBUTE)}setAutoPageHeight(e){this.isAutoPageHeight=e,e?this.container.setAttribute(Fn.AUTO_PAGE_HEIGHT_ATTRIBUTE,"true"):this.container.removeAttribute(Fn.AUTO_PAGE_HEIGHT_ATTRIBUTE)}registerElementWithId(e,n){let s=this.elementsById[n];s?s.push(e):this.elementsById[n]=[e]}finish(e,n){Object.keys(this.elementsById).forEach(i=>{let a=this.elementsById[i];for(let l=0;l<a.length;)this.container.contains(a[l])?l++:a.splice(l,1);a.length===0&&delete this.elementsById[i]});let s=this.delayedItems;for(let i=0;i<s.length;i++){let a=s[i];a.target===this.container&&a.name==="transform"&&!this.isAutoPageWidth&&!this.isAutoPageHeight||T(a.target,a.name,a.value.toString())}let o=n.getElementClientRect(this.container);this.dimensions.width=o.width,this.dimensions.height=o.height;for(let i=0;i<e.length;i++){let a=e[i],l=this.elementsById[a.ref],c=this.elementsById[a.observer];if(l&&c){let u=Gm(l,a.action);if(u)for(let p=0;p<c.length;p++)c[p].addEventListener(a.event,u,!1)}}}};d(Fn,"AUTO_PAGE_WIDTH_ATTRIBUTE","data-vivliostyle-auto-page-width"),d(Fn,"AUTO_PAGE_HEIGHT_ATTRIBUTE","data-vivliostyle-auto-page-height");var io=Fn,Mt="data-adapt-spec",Ze=At.Whitespace;function Hr(r){switch(r){case"normal":case"nowrap":return Ze.IGNORE;case"pre-line":return Ze.NEWLINE;case"pre":case"pre-wrap":case"break-spaces":return Ze.PRESERVE;default:return null}}function he(r,t){if(!r)return!0;if(r.nodeType==1)return!1;let e=r.textContent;switch(t){case Ze.PRESERVE:return e.length==0;case Ze.NEWLINE:return!!e.match(/^[ \t]*$/);case Ze.IGNORE:default:return!!e.match(/^[ \t\r\n\f]*$/)}}var Br=class{constructor(t,e){this.flowName=t;this.parentFlowName=e;d(this,"forcedBreakOffsets",[]);d(this,"formattingContext",null)}},Or=class{constructor(t,e,n,s,o,i,a,l,c){this.flowName=t;this.element=e;this.startOffset=n;this.priority=s;this.linger=o;this.exclusive=i;this.repeated=a;this.last=l;this.breakBefore=c;d(this,"startPage",-1)}isBetter(t){return this.exclusive?!t.exclusive||this.priority>t.priority?!0:this.last:!1}};function wh(r,t){return r.top-t.top}function Ph(r,t){return t.right-r.right}function kh(r,t){var e,n;return r===t?!0:!r||!t?!1:(r.node===t.node||!!r.shadowContext&&!!t.shadowContext&&r.shadowType===At.ShadowType.ROOTLESS&&t.shadowType===At.ShadowType.ROOTLESS&&((e=r.node)==null?void 0:e.outerHTML)===((n=t.node)==null?void 0:n.outerHTML))&&r.shadowType===t.shadowType&&Pc(r.shadowContext,t.shadowContext)&&Pc(r.nodeShadow,t.nodeShadow)&&kh(r.shadowSibling,t.shadowSibling)}function Dt(r,t){if(r===t)return!0;if(!r||!t||r.offsetInNode!==t.offsetInNode||r.after!==t.after||r.steps.length!==t.steps.length)return!1;for(let e=0;e<r.steps.length;e++)if(!kh(r.steps[e],t.steps[e]))return!1;return!0}function Ah(r){return{steps:[{node:r,shadowType:Et.NONE,shadowContext:null,nodeShadow:null,shadowSibling:null,formattingContext:null,fragmentIndex:0}],offsetInNode:0,after:!1,preprocessedTextContent:null}}function gs(r,t){return{steps:[{node:r.sourceNode,shadowType:Et.NONE,shadowContext:r.shadowContext,nodeShadow:null,shadowSibling:null,formattingContext:null,fragmentIndex:t!=null?t:r.fragmentIndex}],offsetInNode:0,after:!1,preprocessedTextContent:r.preprocessedTextContent}}function ao(r,t){let e=new On(r.node,t,0);return e.shadowType=r.shadowType,e.shadowContext=r.shadowContext,e.nodeShadow=r.nodeShadow,e.shadowSibling=r.shadowSibling?ao(r.shadowSibling,t.copy()):null,e.formattingContext=r.formattingContext,e.fragmentIndex=r.fragmentIndex+1,e}var Et=At.ShadowType,fs=class{constructor(t,e,n,s,o,i,a){this.owner=t;this.root=e;this.xmldoc=n;this.parentShadow=s;this.type=i;this.styler=a;d(this,"subShadow",null);o&&(o.subShadow=this)}equals(t){return t?this.owner===t.owner&&this.xmldoc===t.xmldoc&&this.type===t.type&&Pc(this.parentShadow,t.parentShadow):!1}};function Pc(r,t){return r===t||!!r&&!!t&&r.equals(t)}var Dr=class{constructor(t,e){this.outer=t;this.count=e}},On=class r{constructor(t,e,n){this.sourceNode=t;this.parent=e;this.boxOffset=n;d(this,"offsetInNode",0);d(this,"after",!1);d(this,"shadowType");d(this,"shadowContext");d(this,"nodeShadow",null);d(this,"shadowSibling",null);d(this,"shared",!1);d(this,"inline",!0);d(this,"overflow",!1);d(this,"breakPenalty");d(this,"display",null);d(this,"floatReference");d(this,"floatSide",null);d(this,"clearSide",null);d(this,"floatMinWrapBlock",null);d(this,"columnSpan",null);d(this,"verticalAlign","baseline");d(this,"captionSide","top");d(this,"inlineBorderSpacing",0);d(this,"blockBorderSpacing",0);d(this,"flexContainer",!1);d(this,"whitespace");d(this,"hyphenateCharacter");d(this,"breakWord");d(this,"establishesBFC",!1);d(this,"containingBlockForAbsolute",!1);d(this,"breakBefore",null);d(this,"breakAfter",null);d(this,"viewNode",null);d(this,"clearSpacer",null);d(this,"inheritedProps");d(this,"vertical");d(this,"direction");d(this,"firstPseudo");d(this,"lang",null);d(this,"preprocessedTextContent",null);d(this,"formattingContext");d(this,"repeatOnBreak",null);d(this,"pluginProps",{});d(this,"fragmentIndex",1);d(this,"afterIfContinues",null);d(this,"footnotePolicy",null);d(this,"pageType");this.shadowType=Et.NONE,this.shadowContext=e?e.shadowContext:null,this.breakPenalty=e?e.breakPenalty:0,this.floatReference=Vn.FloatReference.INLINE,this.whitespace=e?e.whitespace:Ze.IGNORE,this.hyphenateCharacter=e?e.hyphenateCharacter:null,this.breakWord=e?e.breakWord:!1,this.inheritedProps=e?e.inheritedProps:{},this.vertical=e?e.vertical:!1,this.direction=e?e.direction:"ltr",this.firstPseudo=e?e.firstPseudo:null,this.formattingContext=e?e.formattingContext:null,this.pageType=e?e.pageType:null}resetView(){this.inline=!0,this.breakPenalty=this.parent?this.parent.breakPenalty:0,this.viewNode=null,this.clearSpacer=null,this.offsetInNode=0,this.after=!1,this.display=null,this.floatReference=Vn.FloatReference.INLINE,this.floatSide=null,this.clearSide=null,this.floatMinWrapBlock=null,this.columnSpan=null,this.verticalAlign="baseline",this.flexContainer=!1,this.whitespace=this.parent?this.parent.whitespace:Ze.IGNORE,this.hyphenateCharacter=this.parent?this.parent.hyphenateCharacter:null,this.breakWord=this.parent?this.parent.breakWord:!1,this.breakBefore=null,this.breakAfter=null,this.nodeShadow=null,this.establishesBFC=!1,this.containingBlockForAbsolute=!1,this.vertical=this.parent?this.parent.vertical:!1,this.nodeShadow=null,this.preprocessedTextContent=null,this.formattingContext=this.parent?this.parent.formattingContext:null,this.repeatOnBreak=null,this.pluginProps={},this.fragmentIndex=1,this.afterIfContinues=null,this.footnotePolicy=null}cloneItem(){let t=new r(this.sourceNode,this.parent,this.boxOffset);return t.offsetInNode=this.offsetInNode,t.after=this.after,t.nodeShadow=this.nodeShadow,t.shadowType=this.shadowType,t.shadowContext=this.shadowContext,t.shadowSibling=this.shadowSibling,t.inline=this.inline,t.breakPenalty=this.breakPenalty,t.display=this.display,t.floatReference=this.floatReference,t.floatSide=this.floatSide,t.clearSide=this.clearSide,t.floatMinWrapBlock=this.floatMinWrapBlock,t.columnSpan=this.columnSpan,t.verticalAlign=this.verticalAlign,t.captionSide=this.captionSide,t.inlineBorderSpacing=this.inlineBorderSpacing,t.blockBorderSpacing=this.blockBorderSpacing,t.establishesBFC=this.establishesBFC,t.containingBlockForAbsolute=this.containingBlockForAbsolute,t.flexContainer=this.flexContainer,t.whitespace=this.whitespace,t.hyphenateCharacter=this.hyphenateCharacter,t.breakWord=this.breakWord,t.breakBefore=this.breakBefore,t.breakAfter=this.breakAfter,t.viewNode=this.viewNode,t.clearSpacer=this.clearSpacer,t.firstPseudo=this.firstPseudo,t.vertical=this.vertical,t.overflow=this.overflow,t.preprocessedTextContent=this.preprocessedTextContent,t.formattingContext=this.formattingContext,t.repeatOnBreak=this.repeatOnBreak,t.pluginProps=Object.create(this.pluginProps),t.fragmentIndex=this.fragmentIndex,t.afterIfContinues=this.afterIfContinues,t.footnotePolicy=this.footnotePolicy,t}modify(){return this.shared?this.cloneItem():this}copy(){let t=this;do{if(t.shared)break;t.shared=!0,t=t.parent}while(t);return this}clone(){let t=this.cloneItem(),e=t,n;for(;(n=e.parent)!=null;)n=n.cloneItem(),e.parent=n,e=n;return t}toNodePositionStep(){return{node:this.sourceNode,shadowType:this.shadowType,shadowContext:this.shadowContext,nodeShadow:this.nodeShadow,shadowSibling:this.shadowSibling?this.shadowSibling.toNodePositionStep():null,formattingContext:this.formattingContext,fragmentIndex:this.fragmentIndex}}toNodePosition(){var s,o,i;let t=this,e=[];t.shadowType===At.ShadowType.ROOTLESS&&(t.floatReference!==Vn.FloatReference.INLINE||t.floatSide==="footnote")&&((i=(o=(s=t.shadowContext)==null?void 0:s.styler)==null?void 0:o.style)!=null&&i._pseudos)&&(t=t.parent);do(!t.firstPseudo||!t.parent||t.parent.firstPseudo===t.firstPseudo)&&e.push(t.toNodePositionStep()),t=t.parent;while(t);let n=this.preprocessedTextContent?Sh(this.preprocessedTextContent,this.offsetInNode):this.offsetInNode;return{steps:e,offsetInNode:n,after:this.after,preprocessedTextContent:this.preprocessedTextContent}}isInsideBFC(){let t=this.parent;for(;t;){if(t.establishesBFC)return!0;t=t.parent}return!1}getContainingBlockForAbsolute(){let t=this.parent;for(;t;){if(t.containingBlockForAbsolute)return t;t=t.parent}return null}belongsTo(t){return this.formattingContext===t&&!!this.parent&&this.parent.formattingContext===t}},pt=class r{constructor(t){this.primary=t;d(this,"floats",null)}clone(){let t=new r(this.primary);if(this.floats){t.floats=[];for(let e=0;e<this.floats.length;++e)t.floats[e]=this.floats[e]}return t}isSamePosition(t){if(!t)return!1;if(this===t)return!0;if(!Dt(this.primary,t.primary))return!1;if(this.floats){if(!t.floats||this.floats.length!==t.floats.length)return!1;for(let e=0;e<this.floats.length;e++)if(!Dt(this.floats[e],t.floats[e]))return!1}else if(t.floats)return!1;return!0}},Mr=class r{constructor(t,e){this.chunkPosition=t;this.flowChunk=e}clone(){return new r(this.chunkPosition.clone(),this.flowChunk)}isSamePosition(t){return!!t&&(this===t||this.chunkPosition.isSamePosition(t.chunkPosition))}},_r=class r{constructor(){d(this,"positions",[]);d(this,"startBreakType",null);d(this,"breakAfter",null)}clone(){let t=new r,e=this.positions,n=t.positions;for(let s=0;s<e.length;s++)n[s]=e[s].clone();return t.startBreakType=this.startBreakType,t.breakAfter=this.breakAfter,t}isSamePosition(t){if(this===t)return!0;if(!t||this.positions.length!==t.positions.length)return!1;for(let e=0;e<this.positions.length;e++)if(!this.positions[e].isSamePosition(t.positions[e]))return!1;return!0}hasContent(t){return this.positions.length>0&&this.positions[0].flowChunk.startOffset<=t}},Ur=class r{constructor(){d(this,"page",0);d(this,"flows",{});d(this,"flowPositions",{});d(this,"isBlankPage",!1);d(this,"highestSeenOffset",0);d(this,"highestSeenNode");d(this,"lookupPositionOffset")}clone(){let t=new r;t.page=this.page,t.isBlankPage=this.isBlankPage,t.highestSeenNode=this.highestSeenNode,t.highestSeenOffset=this.highestSeenOffset,t.lookupPositionOffset=this.lookupPositionOffset,t.flows=this.flows;for(let e in this.flowPositions)t.flowPositions[e]=this.flowPositions[e].clone();return t}isSamePosition(t){if(this===t)return!0;if(!t||this.page!==t.page)return!1;let e=Object.keys(this.flowPositions),n=Object.keys(t.flowPositions);if(e.length!==n.length)return!1;for(let s of e)if(!this.flowPositions[s].isSamePosition(t.flowPositions[s]))return!1;return!0}hasContent(t,e){let n=this.flowPositions[t];return n?n.hasContent(e):!1}startSideOfFlow(t){var n;let e=(n=this.flowPositions[t])==null?void 0:n.startBreakType;return e&&In(e)?e:"any"}firstFlowChunkOfFlow(t){let e=this.flowPositions[t];if(!e)return null;let n=e.positions[0];return n?n.flowChunk:null}},ro=class{constructor(t){this.element=t;d(this,"left",0);d(this,"top",0);d(this,"marginLeft",0);d(this,"marginRight",0);d(this,"marginTop",0);d(this,"marginBottom",0);d(this,"borderLeft",0);d(this,"borderRight",0);d(this,"borderTop",0);d(this,"borderBottom",0);d(this,"paddingLeft",0);d(this,"paddingRight",0);d(this,"paddingTop",0);d(this,"paddingBottom",0);d(this,"width",0);d(this,"height",0);d(this,"originX",0);d(this,"originY",0);d(this,"exclusions",null);d(this,"innerShape",null);d(this,"computedBlockSize",0);d(this,"snapWidth",0);d(this,"snapHeight",0);d(this,"snapOffsetX",0);d(this,"snapOffsetY",0);d(this,"vertical",!1);d(this,"rtl",!1)}getInsetTop(){return this.marginTop+this.borderTop+this.paddingTop}getInsetBottom(){return this.marginBottom+this.borderBottom+this.paddingBottom}getInsetLeft(){return this.marginLeft+this.borderLeft+this.paddingLeft}getInsetRight(){return this.marginRight+this.borderRight+this.paddingRight}getInsetBefore(){return this.vertical?this.getInsetRight():this.getInsetTop()}getInsetAfter(){return this.vertical?this.getInsetLeft():this.getInsetBottom()}getInsetStart(){return this.vertical?this.getInsetTop():this.getInsetLeft()}getInsetEnd(){return this.vertical?this.getInsetBottom():this.getInsetRight()}getBeforeEdge(t){return this.vertical?t.right:t.top}getAfterEdge(t){return this.vertical?t.left:t.bottom}getStartEdge(t){return this.vertical?this.rtl?t.bottom:t.top:this.rtl?t.right:t.left}getEndEdge(t){return this.vertical?this.rtl?t.top:t.bottom:this.rtl?t.left:t.right}getInlineSize(t){return this.vertical?t.bottom-t.top:t.right-t.left}getBoxSize(t){return this.vertical?t.right-t.left:t.bottom-t.top}getBoxDir(){return this.vertical?-1:1}getInlineDir(){return this.rtl?-1:1}copyFrom(t){this.element=t.element,this.left=t.left,this.top=t.top,this.marginLeft=t.marginLeft,this.marginRight=t.marginRight,this.marginTop=t.marginTop,this.marginBottom=t.marginBottom,this.borderLeft=t.borderLeft,this.borderRight=t.borderRight,this.borderTop=t.borderTop,this.borderBottom=t.borderBottom,this.paddingLeft=t.paddingLeft,this.paddingRight=t.paddingRight,this.paddingTop=t.paddingTop,this.paddingBottom=t.paddingBottom,this.width=t.width,this.height=t.height,this.originX=t.originX,this.originY=t.originY,this.innerShape=t.innerShape,this.exclusions=t.exclusions,this.computedBlockSize=t.computedBlockSize,this.snapWidth=t.snapWidth,this.snapHeight=t.snapHeight,this.vertical=t.vertical,this.rtl=t.rtl}setVerticalPosition(t,e){this.top=t,this.height=e,T(this.element,"top",`${t}px`),T(this.element,"height",`${e}px`)}setHorizontalPosition(t,e){this.left=t,this.width=e,T(this.element,"left",`${t}px`),T(this.element,"width",`${e}px`)}setBlockPosition(t,e){if(this.vertical){let n=e+this.marginLeft+this.marginRight+this.paddingLeft+this.paddingRight+this.borderLeft+this.borderRight;this.setHorizontalPosition(t+n*this.getBoxDir(),e)}else this.setVerticalPosition(t,e)}setInlinePosition(t,e){if(this.vertical)if(this.rtl){let n=e+this.marginTop+this.marginBottom+this.paddingTop+this.paddingBottom+this.borderTop+this.borderBottom;this.setVerticalPosition(t+n*this.getInlineDir(),e)}else this.setVerticalPosition(t,e);else if(this.rtl){let n=e+this.marginLeft+this.marginRight+this.paddingLeft+this.paddingRight+this.borderLeft+this.borderRight;this.setHorizontalPosition(t+n*this.getInlineDir(),e)}else this.setHorizontalPosition(t,e)}clear(){let t=this.element,e;for(;e=t.lastChild;)t.removeChild(e)}getInnerShape(){let t=this.getInnerRect();return this.innerShape?this.innerShape.withOffset(t.x1,t.y1):Go(t.x1,t.y1,t.x2,t.y2)}getInnerRect(){let t=this.originX+this.left+this.getInsetLeft(),e=this.originY+this.top+this.getInsetTop();return new He(t,e,t+this.width,e+this.height)}getPaddingRect(){let t=this.originX+this.left+this.marginLeft+this.borderLeft,e=this.originY+this.top+this.marginTop+this.borderTop,n=this.paddingLeft+this.width+this.paddingRight,s=this.paddingTop+this.height+this.paddingBottom;return new He(t,e,t+n,e+s)}getOuterShape(t,e){let n=this.getOuterRect();return xr(t,n.x1,n.y1,n.x2-n.x1,n.y2-n.y1,e)}getOuterRect(){let t=this.originX+this.left,e=this.originY+this.top,n=this.getInsetLeft()+this.width+this.getInsetRight(),s=this.getInsetTop()+this.height+this.getInsetBottom();return new He(t,e,t+n,e+s)}},cn=class extends at{constructor(e,n,s,o){super();this.elem=e;this.context=n;this.rootContentValue=s;this.exprContentListener=o}visitStrInner(e,n){var s;if(!n){if(((s=this.elem.lastChild)==null?void 0:s.nodeType)===3){this.elem.lastChild.textContent+=e;return}n=this.elem.ownerDocument.createTextNode(e)}this.elem.appendChild(n)}visitStr(e){return this.visitStrInner(e.str),null}visitURL(e){if(this.rootContentValue.url)this.elem.setAttribute("src",e.url);else{let n=this.elem.ownerDocument.createElementNS("http://www.w3.org/1999/xhtml","img");n.setAttribute("src",e.url),this.elem.appendChild(n)}return null}visitSpaceList(e){return this.visitValues(e.values),null}visitExpr(e){let n=e.toExpr(),s=n.evaluate(this.context);if(typeof s=="string"){n instanceof ae&&(s=Zt(n.scope,new Oe(s,null),"").stringValue()),this.elem.ownerDocument;let o=this.exprContentListener(n,s,this.elem.ownerDocument);!o&&s&&n instanceof oe&&n.str.startsWith("running-element-")&&(s=""),this.visitStrInner(s,o)}return null}};function St(r){return r!=null&&r!==O&&r!==x.normal&&r!==x.none&&!U(r)}var ue=Vn.FloatReference;function Rh(r){switch(r){case"inline":return ue.INLINE;case"column":return ue.COLUMN;case"region":return ue.REGION;case"page":return ue.PAGE;default:throw new Error(`Unknown float-reference: ${r}`)}}function Dn(r){switch(r){case ue.INLINE:return!1;case ue.COLUMN:case ue.REGION:case ue.PAGE:return!0;default:throw new Error(`Unknown float-reference: ${r}`)}}function Ih(r,t,e){let n=t?"vertical-rl":"horizontal-tb";if((r==="top"||r==="bottom")&&(r=Cc(r,n,e)),r==="block-start"&&(r="inline-start"),r==="block-end"&&(r="inline-end"),r==="inline-start"||r==="inline-end"){let s=mc(r,n,e),o=lh(s,n);o==="line-left"?r="left":o==="line-right"&&(r="right")}return r!=="left"&&r!=="right"&&(I.warn(`Invalid float value: ${r}. Fallback to left.`),r="left"),r}var Zo=class{constructor(t,e,n,s,o,i){this.nodePosition=t;this.floatReference=e;this.floatSide=n;this.clearSide=s;this.flowName=o;this.floatMinWrapBlock=i;d(this,"order",null);d(this,"id",null)}getOrder(){if(this.order===null)throw new Error("The page float is not yet added");return this.order}getId(){if(!this.id)throw new Error("The page float is not yet added");return this.id}isAllowedOnContext(t){return t.isAnchorAlreadyAppeared(this.getId())}isAllowedToPrecede(t){return!1}},kc=class{constructor(){d(this,"floats",[]);d(this,"nextPageFloatIndex",0)}nextOrder(){return this.nextPageFloatIndex++}createPageFloatId(t){return`pf${t}`}addPageFloat(t){if(this.floats.findIndex(n=>Dt(n.nodePosition,t.nodePosition))>=0)throw new Error("A page float with the same source node is already registered");{let n=t.order=this.nextOrder();t.id=this.createPageFloatId(n),this.floats.push(t)}}findPageFloatByNodePosition(t){let e=this.floats.findIndex(n=>Dt(n.nodePosition,t));return e>=0?this.floats[e]:null}findPageFloatById(t){let e=this.floats.findIndex(n=>n.id===t);return e>=0?this.floats[e]:null}},Qo=class{constructor(t,e,n,s,o){this.floatReference=t;this.floatSide=e;this.continuations=n;this.area=s;this.continues=o}hasFloat(t){return this.continuations.some(e=>e.float===t)}findNotAllowedFloat(t){for(let e=this.continuations.length-1;e>=0;e--){let n=this.continuations[e].float;if(!n.isAllowedOnContext(t))return n}return null}getOuterShape(){return this.area.getOuterShape(null,null)}getOuterRect(){return this.area.getOuterRect()}getOrder(){let t=this.continuations.map(e=>e.float);return Math.min.apply(null,t.map(e=>e.getOrder()))}shouldBeStashedBefore(t){return this.getOrder()<t.getOrder()}addContinuations(t){t.forEach(e=>{this.continuations.push(e)})}getFlowName(){let t=this.continuations[0].float.flowName;return this.continuations.every(e=>e.float.flowName===t),t}},Jo=class{constructor(t,e){this.float=t;this.nodePosition=e}equals(t){return t?this===t?!0:this.float===t.float&&Dt(this.nodePosition,t.nodePosition):!1}},un=class{constructor(t,e,n,s,o,i,a){this.parent=t;this.floatReference=e;this.container=n;this.flowName=s;this.generatingNodePosition=o;d(this,"children",[]);d(this,"writingMode");d(this,"direction");d(this,"invalidated",!1);d(this,"floatStore");d(this,"forbiddenFloats",[]);d(this,"floatFragments",[]);d(this,"stashedFloatFragments",[]);d(this,"floatAnchors",{});d(this,"floatsDeferredToNext",[]);d(this,"floatsDeferredFromPrevious");d(this,"layoutConstraints",[]);d(this,"locked",!1);t&&t.children.push(this),this.writingMode=i||t&&t.writingMode||x.horizontal_tb,this.direction=a||t&&t.direction||x.ltr,this.floatStore=t?t.floatStore:new kc;let l=this.getPreviousSibling();this.floatsDeferredFromPrevious=l?[].concat(l.floatsDeferredToNext):[]}getParent(t){if(!this.parent)throw new Error(`No PageFloatLayoutContext for ${t}`);return this.parent}getPreviousSiblingOf(t,e,n,s){let o=this.children.indexOf(t);o<0&&(o=this.children.length);for(let i=o-1;i>=0;i--){let a=this.children[i];if(a.floatReference===e&&a.flowName===n&&Dt(a.generatingNodePosition,s))return a;if(a=a.getPreviousSiblingOf(null,e,n,s),a)return a}return null}getPreviousSibling(){let t=this,e=this.parent,n;for(;e;){if(n=e.getPreviousSiblingOf(t,this.floatReference,this.flowName,this.generatingNodePosition),n)return n;t=e,e=e.parent}return null}getContainer(t){return!t||t===this.floatReference?this.container:this.getParent(t).getContainer(t)}setContainer(t){this.container=t,this.reattachFloatFragments()}addPageFloat(t){this.floatStore.addPageFloat(t)}getPageFloatLayoutContext(t){return t===this.floatReference?this:this.getParent(t).getPageFloatLayoutContext(t)}findPageFloatByNodePosition(t){return this.floatStore.findPageFloatByNodePosition(t)}forbid(t){let e=t.getId(),n=t.floatReference;n===this.floatReference?this.forbiddenFloats.includes(e)||(this.forbiddenFloats.push(e),new _t().findByFloat(t).forbid(t,this)):this.getParent(n).forbid(t)}isForbidden(t){let e=t.getId(),n=t.floatReference;return n===this.floatReference?this.forbiddenFloats.includes(e):this.getParent(n).isForbidden(t)}addPageFloatFragment(t,e){let n=t.floatReference;n!==this.floatReference?this.getParent(n).addPageFloatFragment(t,e):this.floatFragments.includes(t)||(this.floatFragments.push(t),this.floatFragments.sort((s,o)=>s.getOrder()-o.getOrder())),e||this.invalidate()}removePageFloatFragment(t,e){let n=t.floatReference;if(n!==this.floatReference)this.getParent(n).removePageFloatFragment(t,e);else{let s=this.floatFragments.indexOf(t);if(s>=0){let o=this.floatFragments.splice(s,1)[0],i=o.area&&o.area.element;i&&i.parentNode&&i.parentNode.removeChild(i),e||this.invalidate()}}}findPageFloatFragment(t){if(t.floatReference!==this.floatReference)return this.getParent(t.floatReference).findPageFloatFragment(t);let e=this.floatFragments.findIndex(n=>n.hasFloat(t));return e>=0?this.floatFragments[e]:null}hasFloatFragments(t){return this.floatFragments.length>0&&(!t||this.floatFragments.some(t))?!0:this.parent?this.parent.hasFloatFragments(t):!1}hasContinuingFloatFragmentsInFlow(t){return this.hasFloatFragments(e=>e.continues&&e.getFlowName()===t)}registerPageFloatAnchor(t,e){this.floatAnchors[t.getId()]=e}collectPageFloatAnchors(){let t=Object.assign({},this.floatAnchors);return this.children.reduce((e,n)=>Object.assign(e,n.collectPageFloatAnchors()),t)}isAnchorAlreadyAppeared(t){if(this.getDeferredPageFloatContinuations().some(o=>o.float.getId()===t))return!0;let s=this.collectPageFloatAnchors()[t];return s&&this.container&&this.container.element?this.container.element.contains(s):!1}deferPageFloat(t){let e=t.float;if(e.floatReference===this.floatReference){let n=this.floatsDeferredToNext.findIndex(s=>s.float===e);n>=0?this.floatsDeferredToNext.splice(n,1,t):this.floatsDeferredToNext.push(t)}else this.getParent(e.floatReference).deferPageFloat(t)}hasPrecedingFloatsDeferredToNext(t,e){if(!e&&t.floatReference!==this.floatReference)return this.getParent(t.floatReference).hasPrecedingFloatsDeferredToNext(t,!1);let n=t.getOrder();return this.floatsDeferredToNext.some(o=>o.float.getOrder()<n&&!t.isAllowedToPrecede(o.float))?!0:this.parent?this.parent.hasPrecedingFloatsDeferredToNext(t,!0):!1}getLastFollowingFloatInFragments(t){let e=t.getOrder(),n=null;if(this.floatFragments.forEach(s=>{s.continuations.forEach(o=>{let i=o.float,a=i.getOrder();a>e&&(!n||a>n.getOrder())&&(n=i)})}),this.parent){let s=this.parent.getLastFollowingFloatInFragments(t);s&&(!n||s.getOrder()>n.getOrder())&&(n=s)}return n}getDeferredPageFloatContinuations(t){t=t||this.flowName;let e=this.floatsDeferredFromPrevious.filter(n=>!t||n.float.flowName===t);return this.parent&&(e=this.parent.getDeferredPageFloatContinuations(t).concat(e)),e.sort((n,s)=>n.float.getOrder()-s.float.getOrder())}getPageFloatContinuationsDeferredToNext(t){t=t||this.flowName;let e=this.floatsDeferredToNext.filter(n=>!t||n.float.flowName===t);return this.parent?this.parent.getPageFloatContinuationsDeferredToNext(t).concat(e):e}getFloatsDeferredToNextInChildContexts(){let t=[],e=[];for(let n=this.children.length-1;n>=0;n--){let s=this.children[n];e.includes(s.flowName)||(e.push(s.flowName),t=t.concat(s.floatsDeferredToNext.map(o=>o.float)),t=t.concat(s.getFloatsDeferredToNextInChildContexts()))}return t}checkAndForbidNotAllowedFloat(){if(this.checkAndForbidFloatFollowingDeferredFloat())return!0;for(let t=this.floatFragments.length-1;t>=0;t--){let e=this.floatFragments[t],n=e.findNotAllowedFloat(this);if(n)return this.locked?this.invalidate():(this.removePageFloatFragment(e),this.forbid(n),this.removeEndFloatFragments(e.floatSide)),!0}return this.floatReference===ue.REGION&&this.parent.locked?this.parent.checkAndForbidNotAllowedFloat():!1}checkAndForbidFloatFollowingDeferredFloat(){let t=this.getFloatsDeferredToNextInChildContexts(),e=this.floatFragments.reduce((n,s)=>n.concat(s.continuations.map(o=>o.float)),[]);e.sort((n,s)=>s.getOrder()-n.getOrder());for(let n of e){let s=n.getOrder();if(t.some(o=>!n.isAllowedToPrecede(o)&&s>o.getOrder())){if(this.locked)this.invalidate();else{this.forbid(n);let o=this.findPageFloatFragment(n);this.removePageFloatFragment(o)}return!0}}return!1}finish(){if(!this.checkAndForbidNotAllowedFloat()){for(let t=this.floatsDeferredToNext.length-1;t>=0;t--)if(!this.floatsDeferredToNext[t].float.isAllowedOnContext(this)){if(this.locked){this.invalidate();return}this.floatsDeferredToNext.splice(t,1)}this.floatsDeferredFromPrevious.forEach(t=>{this.floatsDeferredToNext.findIndex(e=>t.equals(e))>=0||this.floatFragments.some(e=>e.hasFloat(t.float))||this.floatsDeferredToNext.push(t)})}}hasSameContainerAs(t){return!!this.container&&!!t.container&&this.container.element===t.container.element}invalidate(){this.invalidated=!0,!this.locked&&(this.container&&(this.children.forEach(t=>{this.hasSameContainerAs(t)&&t.floatFragments.forEach(e=>{let n=e.area.element;n&&n.parentNode&&n.parentNode.removeChild(n)})}),this.container.clear()),this.children.forEach(t=>{t.layoutConstraints.splice(0)}),this.children.splice(0),Object.keys(this.floatAnchors).forEach(t=>{delete this.floatAnchors[t]}))}detachChildren(){let t=this.children.splice(0);return t.forEach(e=>{e.floatFragments.forEach(n=>{let s=n.area.element;s&&s.parentNode&&s.parentNode.removeChild(s)})}),t}attachChildren(t){t.forEach(e=>{this.children.push(e),e.reattachFloatFragments()})}isInvalidated(){return this.invalidated||!!this.parent&&this.parent.isInvalidated()}validate(){this.invalidated=!1}toLogical(t){let e=this.writingMode.toString(),n=this.direction.toString();return Cc(t,e,n)}toPhysical(t){let e=this.writingMode.toString(),n=this.direction.toString();return mc(t,e,n)}removeEndFloatFragments(t){let e=this.toLogical(t);if(e==="block-end"||e==="inline-end"){let n=0;for(;n<this.floatFragments.length;){let s=this.floatFragments[n];this.toLogical(s.floatSide)===e?this.removePageFloatFragment(s):n++}}}stashEndFloatFragments(t){let e=t.floatReference;if(e!==this.floatReference){this.getParent(e).stashEndFloatFragments(t);return}let n=this.toLogical(t.floatSide);if(n==="block-end"||n==="snap-block"||n==="inline-end"){let s=0;for(;s<this.floatFragments.length;){let o=this.floatFragments[s],i=this.toLogical(o.floatSide);(i===n||n==="snap-block"&&i==="block-end")&&o.shouldBeStashedBefore(t)?(this.stashedFloatFragments.push(o),this.floatFragments.splice(s,1)):s++}}}restoreStashedFragments(t){if(t!==this.floatReference){this.getParent(t).restoreStashedFragments(t);return}this.stashedFloatFragments.forEach(e=>{this.addPageFloatFragment(e,!0)}),this.stashedFloatFragments.splice(0)}discardStashedFragments(t){if(t!==this.floatReference){this.getParent(t).discardStashedFragments(t);return}this.stashedFloatFragments.splice(0)}getStashedFloatFragments(t){return t===this.floatReference?this.stashedFloatFragments.concat().sort((e,n)=>n.getOrder()-e.getOrder()):this.getParent(t).getStashedFloatFragments(t)}getLimitValue(t,e,n,s){this.container;let o=this.toLogical(t),i=this.toPhysical(t),a=this.getLimitValueInner(o,e,n,s);if(this.parent&&this.parent.container){let l=this.parent.getLimitValue(i,e,n,s);switch(i){case"top":return Math.max(a,l);case"left":return Math.max(a,l);case"bottom":return Math.min(a,l);case"right":return Math.min(a,l);default:}}return a}getLimitValueInner(t,e,n,s){this.container;let o=this.getLimitValuesInner(e,n,s);switch(t){case"block-start":return this.container.vertical?o.right:o.top;case"block-end":return this.container.vertical?o.left:o.bottom;case"inline-start":return this.container.vertical?this.container.rtl?o.bottom:o.top:this.container.rtl?o.right:o.left;case"inline-end":return this.container.vertical?this.container.rtl?o.top:o.bottom:this.container.rtl?o.left:o.right;default:throw new Error(`Unknown logical side: ${t}`)}}getLimitValuesInner(t,e,n){this.container;let s=this.container.originX,o=this.container.originY,i=this.container.getPaddingRect(),a={top:i.y1-o,left:i.x1-s,bottom:i.y2-o,right:i.x2-s,floatMinWrapBlockStart:0,floatMinWrapBlockEnd:0};function l(u,p,h){return u.unit==="%"?h*u.num/100:t.convertLengthToPx(u,p,e)}let c=this.floatFragments;return c.length>0&&(a=c.reduce((u,p)=>{if(n&&!n(p,this))return u;let h=this.toLogical(p.floatSide),f=p.area,g=p.continuations[0].float.floatMinWrapBlock,m=u.top,E=u.left,C=u.bottom,b=u.right,y=u.floatMinWrapBlockStart,N=u.floatMinWrapBlockEnd;switch(h){case"inline-start":f.vertical?m=Math.max(m,f.top+f.height):E=Math.max(E,f.left+f.width);break;case"block-start":f.vertical?(g&&f.left<b&&(y=l(g,f.rootViewNodes[0],i.x2-i.x1)),b=Math.min(b,f.left)):(g&&f.top+f.height>m&&(y=l(g,f.rootViewNodes[0],i.y2-i.y1)),m=Math.max(m,f.top+f.height));break;case"inline-end":f.vertical?C=Math.min(C,f.top):b=Math.min(b,f.left);break;case"block-end":f.vertical?(g&&f.left+f.width>E&&(N=l(g,f.rootViewNodes[0],i.x2-i.x1)),E=Math.max(E,f.left+f.width)):(g&&f.top<C&&(N=l(g,f.rootViewNodes[0],i.y2-i.y1)),C=Math.min(C,f.top));break;default:throw new Error(`Unknown logical float side: ${h}`)}return{top:m,left:E,bottom:C,right:b,floatMinWrapBlockStart:y,floatMinWrapBlockEnd:N}},a)),a.left+=s,a.right+=s,a.top+=o,a.bottom+=o,a}setFloatAreaDimensions(t,e,n,s,o,i,a){if(e!==this.floatReference)return this.getParent(e).setFloatAreaDimensions(t,e,n,s,o,i,a);let l=this.toLogical(n);if(l==="snap-block"){if(!a["block-start"]&&!a["block-end"])return null}else if(!a[l])return null;t.clientLayout;let c=this.getLimitValue("block-start",t.layoutContext,t.clientLayout),u=this.getLimitValue("block-end",t.layoutContext,t.clientLayout),p=this.getLimitValue("inline-start",t.layoutContext,t.clientLayout),h=this.getLimitValue("inline-end",t.layoutContext,t.clientLayout),f=t.vertical?t.originX:t.originY,g=t.vertical?t.originY:t.originX;c=t.vertical?Math.min(c,t.left+t.getInsetLeft()+t.width+t.getInsetRight()+f):Math.max(c,t.top+f),u=t.vertical?Math.max(u,t.left+f):Math.min(u,t.top+t.getInsetTop()+t.height+t.getInsetBottom()+f);function m(N,S){let w=N(t.bands,S);return w?(t.vertical&&(w=Cr(w)),c=t.vertical?Math.min(c,w.x2):Math.max(c,w.y1),u=t.vertical?Math.max(u,w.x1):Math.min(u,w.y2),!0):i}let E,C,b,y;if(o){let N=t.vertical?Ks(new He(u,p,c,h)):new He(p,c,h,u);if((l==="block-start"||l==="snap-block"||l==="inline-start")&&!m(zp,N)||(l==="block-end"||l==="snap-block"||l==="inline-end")&&!m(Gp,N)||(b=(u-c)*t.getBoxDir(),E=b-t.getInsetBefore()-t.getInsetAfter(),y=(h-p)*t.getInlineDir(),C=y-t.getInsetStart()-t.getInsetEnd(),!i&&(E<=0||C<=0)))return null}else{E=t.computedBlockSize,b=E+t.getInsetBefore()+t.getInsetAfter();let N=(u-c)*t.getBoxDir();if(l==="snap-block"){if(s===null)l="block-start";else{let w=this.container.getPaddingRect(),A=this.container.getBoxDir()*(s-(this.container.vertical?w.x2:w.y1)),V=this.container.getBoxDir()*((this.container.vertical?w.x1:w.y2)-s-b);A<=V?l="block-start":l="block-end"}if(!a[l])if(a["block-end"])l="block-end";else return null}if(!i&&N<b)return null;l==="inline-start"||l==="inline-end"?C=no(t.clientLayout,t.element,["fit-content inline size"])["fit-content inline size"]:t.adjustContentRelativeSize?C=t.getContentInlineSize():C=t.vertical?t.height:t.width,y=C+t.getInsetStart()+t.getInsetEnd();let S=(h-p)*t.getInlineDir();if(!i&&S<y)return null}switch(c-=f,u-=f,p-=g,h-=g,l){case"inline-start":case"block-start":case"snap-block":t.setInlinePosition(p,C),t.setBlockPosition(c,E);break;case"inline-end":case"block-end":t.setInlinePosition(h-y*t.getInlineDir(),C),t.setBlockPosition(u-b*t.getBoxDir(),E);break;default:throw new Error(`unknown float direction: ${n}`)}return l}getFloatFragmentExclusions(){let t=this.floatFragments.map(e=>e.getOuterShape());return this.parent?this.parent.getFloatFragmentExclusions().concat(t):t}reattachFloatFragments(){let t=this.container.element&&this.container.element.parentNode;t&&this.floatFragments.forEach(e=>{t.appendChild(e.area.element)})}getMaxReachedAfterEdge(){let t=this.getContainer().vertical;return this.floatFragments.reduce((e,n)=>{let s=n.getOuterRect();return t?Math.min(e,s.x1):Math.max(e,s.y2)},t?1/0:0)}getBlockStartEdgeOfBlockEndFloats(){let t=this.getContainer().vertical;return this.floatFragments.filter(e=>e.floatSide==="block-end").reduce((e,n)=>{let s=n.getOuterRect();return t?Math.max(e,s.x2):Math.min(e,s.y1)},t?0:1/0)}getPageFloatClearEdge(t,e){function n(u){return p=>u.isAnchorAlreadyAppeared(p.float.getId())}function s(u,p){return u.continuations.some(n(p))}let o=e.getPaddingRect(),i=e.vertical?o.x1:o.y2,a=this;for(;a;){if(a.floatsDeferredToNext.some(n(a)))return i;a=a.parent}e.clientLayout;let l=this.getLimitValue("block-start",e.layoutContext,e.clientLayout,s);return this.getLimitValue("block-end",e.layoutContext,e.clientLayout,s)*e.getBoxDir()<i*e.getBoxDir()?i:l}getPageFloatPlacementCondition(t,e,n){if(t.floatReference!==this.floatReference)return this.getParent(t.floatReference).getPageFloatPlacementCondition(t,e,n);let s={"block-start":!0,"block-end":!0,"inline-start":!0,"inline-end":!0};if(!n)return s;let o=this.toLogical(e),i=this.toLogical(n),a;i==="all"?a=["block-start","block-end","inline-start","inline-end"]:i==="both"?a=["inline-start","inline-end"]:i==="same"?o==="snap-block"?a=["block-start","block-end"]:a=[o]:a=[i];let l=t.getOrder();function c(h){return f=>f.floatSide===h&&f.getOrder()<l}function u(h,f){return h.children.some(g=>g.floatFragments.some(c(f))||u(g,f))}function p(h,f){let g=h.parent;return!!g&&(g.floatFragments.some(c(f))||p(g,f))}return a.forEach(h=>{switch(h){case"block-start":case"inline-start":s[h]=!u(this,h);break;case"block-end":case"inline-end":s[h]=!p(this,h);break;default:throw new Error(`Unexpected side: ${h}`)}}),s}getLayoutConstraints(){return(this.parent?this.parent.getLayoutConstraints():[]).concat(this.layoutConstraints)}addLayoutConstraint(t,e){e===this.floatReference?this.layoutConstraints.push(t):this.getParent(e).addLayoutConstraint(t,e)}isColumnFullWithPageFloats(t){let e=t.layoutContext,n=t.clientLayout;let s=this,o=null;for(;s&&s.container;){let l=s.getLimitValuesInner(e,n);o?t.vertical?(l.right<o.right&&(o.right=l.right,o.floatMinWrapBlockStart=l.floatMinWrapBlockStart),l.left>o.left&&(o.left=l.left,o.floatMinWrapBlockEnd=l.floatMinWrapBlockEnd)):(l.top>o.top&&(o.top=l.top,o.floatMinWrapBlockStart=l.floatMinWrapBlockStart),l.bottom<o.bottom&&(o.bottom=l.bottom,o.floatMinWrapBlockEnd=l.floatMinWrapBlockEnd)):o=l,s=s.parent}let i=Math.max(o.floatMinWrapBlockStart,o.floatMinWrapBlockEnd);return(t.vertical?o.right-o.left:o.bottom-o.top)<=i}getMaxBlockSizeOfPageFloats(){let t=this.getContainer().vertical;return this.floatFragments.length?Math.max.apply(null,this.floatFragments.map(e=>{let n=e.area;return t?n.width:n.height})):0}lock(){this.locked=!0}unlock(){this.locked=!1}isLocked(){return this.locked}},qo=[],_t=class{static register(t){qo.push(t)}findByNodeContext(t){for(let e=qo.length-1;e>=0;e--){let n=qo[e];if(n.appliesToNodeContext(t))return n}throw new Error(`No PageFloatLayoutStrategy found for ${t}`)}findByFloat(t){for(let e=qo.length-1;e>=0;e--){let n=qo[e];if(n.appliesToFloat(t))return n}throw new Error(`No PageFloatLayoutStrategy found for ${t}`)}},Ac=class{appliesToNodeContext(t){return Dn(t.floatReference)}appliesToFloat(t){return!0}createPageFloat(t,e,n){let s=t.floatReference;t.floatSide;let o=t.floatSide,i=t.toNodePosition();return n.resolveFloatReferenceFromColumnSpan(s,t.columnSpan,t).thenAsync(a=>{s=a,e.flowName;let l=new Zo(i,s,o,t.clearSide,e.flowName,t.floatMinWrapBlock);return e.addPageFloat(l),v(l)})}createPageFloatFragment(t,e,n,s){let o=t[0].float;return new Qo(o.floatReference,e,t,n,s)}findPageFloatFragment(t,e){return e.findPageFloatFragment(t)}adjustPageFloatArea(t,e,n){}forbid(t,e){}};_t.register(new Ac);var Xm=Qo,ei=class r extends Zo{constructor(e,n,s,o,i){super(e,n,"block-end",null,s,i);this.footnotePolicy=o}isAllowedToPrecede(e){return!(e instanceof r)}},Gr=class extends Xm{constructor(t,e,n,s){super(t,"block-end",e,n,s)}getOrder(){return 1/0}shouldBeStashedBefore(t){return t instanceof ei?!0:this.getOrder()<t.getOrder()}},Lc=class{constructor(t){this.footnote=t}allowLayout(t){let e=t.toNodePosition();return!Dt(e,this.footnote.nodePosition)}},Rc=class{appliesToNodeContext(t){return t.floatSide==="footnote"}appliesToFloat(t){return t instanceof ei}createPageFloat(t,e,n){let s=ue.REGION,o=e.getPageFloatLayoutContext(s);e.getPageFloatLayoutContext(ue.PAGE).hasSameContainerAs(o)&&(s=ue.PAGE);let a=t.toNodePosition();e.flowName;let l=new ei(a,s,e.flowName,t.footnotePolicy,t.floatMinWrapBlock);return e.addPageFloat(l),v(l)}createPageFloatFragment(t,e,n,s){let o=t[0].float;return new Gr(o.floatReference,t,n,s)}findPageFloatFragment(t,e){let s=e.getPageFloatLayoutContext(t.floatReference).floatFragments.filter(o=>o instanceof Gr);return s.length<=1,s[0]||null}adjustPageFloatArea(t,e,n){t.isFootnote=!0,t.adjustContentRelativeSize=!1;let s=t.element;t.vertical=n.layoutContext.applyFootnoteStyle(e.vertical,n.layoutContext.nodeContext&&n.layoutContext.nodeContext.direction==="rtl",s),t.convertPercentageSizesToPx(s),n.setComputedInsets(s,t),n.setComputedWidthAndHeight(s,t)}forbid(t,e){let n=t;switch(n.footnotePolicy){case x.line:{let s=new Lc(n);e.addLayoutConstraint(s,n.floatReference);break}}}};_t.register(new Rc);var $m="data-vivliostyle-flow-root";function Fh(r){return r.getAttribute($m)==="true"}function Vh(r){let t=(r==null?void 0:r.toString())||"block",e;switch(t){case"inline-flex":e="flex";break;case"inline-grid":e="grid";break;case"inline-table":e="table";break;case"inline":case"table-row-group":case"table-column":case"table-column-group":case"table-header-group":case"table-footer-group":case"table-row":case"table-cell":case"table-caption":case"inline-block":e="block";break;default:e=t}return L(e)}function Wr(r){return r===x.absolute||r===x.fixed}function Ic(r){return r instanceof Pt&&r.name==="running"}function Vc(r,t,e,n){return r===x.none||(Wr(t)?(e=x.none,r=Vh(r)):(e&&e!==x.none&&!U(e)||n)&&(r=Vh(r))),{display:r,position:t,float:e}}function Xr(r,t,e,n){return Vc(r,t,e,n).display===x.block}function dn(r){switch(r.toString()){case"inline":case"inline-block":case"inline-list-item":case"inline-flex":case"inline-grid":case"ruby":case"inline-table":return!0;default:return!1}}function $r(r){switch(r.toString()){case"ruby-base":case"ruby-text":case"ruby-base-container":case"ruby-text-container":return!0;default:return!1}}function Bh(r,t,e,n,s,o,i){return s=s||o||x.horizontal_tb,!!i||!!e&&e!==x.none&&!U(e)||Wr(t)||r===x.inline_block||r===x.table_cell||r===x.table_caption||r==x.flex||r==x.grid||r==x.flow_root||(r===x.block||r===x.list_item)&&!!n&&n!==x.visible&&n!==x.clip&&!U(n)||!!o&&s!==o}function Oh(r){return r===x.relative||r===x.absolute||r===x.fixed}function Mn(r,t,e,n){let s=r.viewNode;if(!s)return NaN;let o=s.nodeType===1?s:s.parentElement;if(o&&o.namespaceURI==="http://www.w3.org/1999/xhtml"){let i=o.style;if(i&&dn(i.display)&&/^([\d\.]|super|(text-)?top)/.test(i.verticalAlign))return NaN}if(s===o){if(r.after||!r.inline){if(r.after&&!r.inline&&o.querySelector("ruby")){let a=o.parentNode,l=o.nextSibling;a.removeChild(o),a.insertBefore(o,l)}let i=t.getElementClientRect(o);if(i.left===0&&i.top===0&&i.right===0&&i.bottom===0)return NaN;if(i.right>=i.left&&i.bottom>=i.top)return r.after?n?i.left:i.bottom:n?i.right:i.top}return NaN}else{let i=NaN,a=s.ownerDocument.createRange(),l=s.textContent.length;if(!l)return NaN;r.after&&(e+=l),e>=l&&(e=l-1),a.setStart(s,e),a.setEnd(s,e+1);let c=t.getRangeClientRects(a);return c=c.filter(u=>u.right>u.left&&u.bottom>u.top),c.length?(n?i=Math.min.apply(null,c.map(u=>u.left)):i=Math.max.apply(null,c.map(u=>u.bottom)),i):NaN}}function ti(r,t,e){let n=t.clientLayout.getElementClientRect(r),s=t.getComputedMargin(r);return e?n.width+s.left+s.right:n.height+s.top+s.bottom}function pn(r){for(;r;){if(r.parentNode===r.ownerDocument)return!1;r=r.parentNode}return!0}function Yr(r,t){if(r)for(let e=r.lastChild,n=e;e!==t;e=n)n=e.previousSibling,!(e.nodeType===1&&e.hasAttribute("data-vivliostyle-float-box"))&&r.removeChild(e)}function Kr(r){return!!r.getAttribute(Mt)}function qr(r){var n;if((r==null?void 0:r.nodeType)!==1)return!1;let t=r;if(Kr(t))return!0;let e=(n=t.style)==null?void 0:n.position;return e==="absolute"||e==="fixed"}function hn(r){let t=r==null?void 0:r.viewNode;return(t==null?void 0:t.nodeType)===1&&Kr(t)}function Dh(r){return r!=="inline"&&(dn(r)||$r(r))}function Fc(r){for(let t=r.parent;t;t=t.parent)if(t.display!=="inline"&&dn(t.display))return t;return null}var ms=class{calculateOffset(t){return _n(this.getNodeContext(),t.collectElementsOffset())}breakPositionChosen(t){}getNodeContext(){return null}};function _n(r,t){return{current:t.reduce((e,n)=>e+n.calculateOffset(r),0),minimum:t.reduce((e,n)=>e+n.calculateMinimumOffset(r),0)}}var fn=class extends ms{constructor(e,n,s,o){super();this.position=e;this.breakOnEdge=n;this.overflows=s;this.computedBlockSize=o;d(this,"overflowIfRepetitiveElementsDropped");d(this,"isEdgeUpdated",!1);d(this,"edge",0);this.overflowIfRepetitiveElementsDropped=s}findAcceptableBreak(e,n){return this.updateOverflows(e),n<this.getMinBreakPenalty()?null:e.findEdgeBreakPosition(this)}getMinBreakPenalty(){if(!this.isEdgeUpdated)throw new Error("EdgeBreakPosition.prototype.updateEdge not called");let e=this.isFirstContentOfRepetitiveElementsOwner()&&!this.overflowIfRepetitiveElementsDropped;return(so(this.breakOnEdge)?1:0)+(this.overflows&&!e?3:0)+(this.position.parent?this.position.parent.breakPenalty:0)}updateEdge(e){var s;let n=e.calculateClonedPaddingBorder(this.position);if(this.edge=Mn(this.position,e.clientLayout,0,e.vertical)+n,!this.position.after&&!this.position.inline){let o=e.parseComputedLength(e.clientLayout.getElementComputedStyle(this.position.viewNode).marginBlockStart);this.edge-=(e.vertical?-1:1)*o}else if(this.position.after&&((s=this.position.shadowContext)==null?void 0:s.root.id)==="table-cell"){let o=e.element.parentElement,i=o==null?void 0:o.closest("table, [style*='display: table;']");if(i){let a=i.style.borderCollapse==="collapse",l=0,c=0;for(let u=o;u;u=u.parentElement){let p=e.clientLayout.getElementComputedStyle(u);if((u===o||u===i&&!a)&&(l+=e.parseComputedLength(p.paddingBlockEnd)),u===i&&!a&&(l+=e.parseComputedLength(p.borderSpacing.replace(/^\S+ (\S+)$/,"$1"))),a?c=Math.max(c,e.parseComputedLength(p.borderBlockEndWidth)):(u===o||u===i)&&(c+=e.parseComputedLength(p.borderBlockEndWidth)),u===i)break}this.edge+=(e.vertical?-1:1)*(l+c)}}this.isEdgeUpdated=!0}updateOverflows(e){this.isEdgeUpdated||this.updateEdge(e);let n=this.edge,s=this.calculateOffset(e);this.overflowIfRepetitiveElementsDropped=e.isOverflown(n+(e.vertical?-1:1)*s.minimum),this.overflows=this.position.overflow=e.isOverflown(n+(e.vertical?-1:1)*s.current)}getNodeContext(){return this.position}isFirstContentOfRepetitiveElementsOwner(){let e=this.getNodeContext();if(!e||!e.parent)return!1;let{formattingContext:n}=e.parent;if(!Qt.isInstanceOfRepetitiveElementsOwnerFormattingContext(n))return!1;let s=n.getRepetitiveElements();return s?s.isFirstContentNode(e):!1}};var Un=class{find(t){let e=Xe("RESOLVE_LAYOUT_PROCESSOR");for(let n=0;n<e.length;n++){let s=e[n](t);if(s)return s}throw new Error(`No processor found for a formatting context: ${t.getName()}`)}},Jt=class{layout(t,e,n){return e.isFloatNodeContext(t)?e.layoutFloatOrFootnote(t):e.isBreakable(t)?e.layoutBreakableBlock(t):e.layoutUnbreakable(t)}createEdgeBreakPosition(t,e,n,s){return new fn(t.copy(),e,n,s)}startNonInlineElementNode(t){return!1}afterNonInlineElementNode(t,e){return!1}clearOverflownViewNodes(t,e,n,s){var a;if(!n.viewNode||!n.viewNode.parentNode||n.shadowType===At.ShadowType.ROOTLESS&&hn(n))return;let o=n.viewNode;((a=o.parentElement)==null?void 0:a.localName)==="viv-ts-inner"&&(o=o.parentElement.parentElement);let i=o.parentNode;Yr(i,o),s&&i.removeChild(o)}finishBreak(t,e,n,s){let o=n||e.viewNode!=null&&e.viewNode.nodeType==1&&!e.after;return t.clearOverflownViewNodes(e,o),s&&t.layoutContext.processFragmentedBlockEdge(e),v(!0)}},co=class{constructor(t){this.parent=t;d(this,"formattingContextType","Block")}getName(){return"Block formatting context (BlockFormattingContext)"}isFirstTime(t,e){return e}getParent(){return this.parent}saveState(){}restoreState(t){}},ni=new Jt,Mh=Fr.isInstanceOfBlockFormattingContext;_e("RESOLVE_FORMATTING_CONTEXT",(r,t,e,n,s,o)=>{let i=r.parent;return!i&&r.formattingContext||i&&r.formattingContext!==i.formattingContext?null:r.establishesBFC||!r.formattingContext&&Xr(e,n,s,o)?new co(i?i.formattingContext:null):null});_e("RESOLVE_LAYOUT_PROCESSOR",r=>r instanceof co?ni:null);var Hn=class{constructor(){d(this,"initialBreakPositions",null);d(this,"initialStateOfFormattingContext",null);d(this,"initialPosition");d(this,"initialFragmentLayoutConstraints")}layout(t,e){return this.prepareLayout(t,e),this.tryLayout(t,e)}tryLayout(t,e){let n=k("AbstractLayoutRetryer.tryLayout");this.saveState(t,e);let s=this.resolveLayoutMode(t);return s.doLayout(t,e).then(o=>{let i=s.accept(o,e);i=s.postLayout(o,this.initialPosition,e,i),i?n.finish(o):(this.initialPosition,this.clearNodes(this.initialPosition),this.restoreState(t,e),this.tryLayout(this.initialPosition,e).thenFinish(n))}),n.result()}prepareLayout(t,e){}clearNodes(t){let e=t.viewNode||t.parent.viewNode,n;for(;n=e.lastChild;)e.removeChild(n);let s;for(;s=e.nextSibling;)s.parentNode.removeChild(s)}saveState(t,e){this.initialPosition=t.copy(),this.initialBreakPositions=[].concat(e.breakPositions),this.initialFragmentLayoutConstraints=[].concat(e.fragmentLayoutConstraints),t.formattingContext&&(this.initialStateOfFormattingContext=t.formattingContext.saveState())}restoreState(t,e){e.breakPositions=this.initialBreakPositions,e.fragmentLayoutConstraints=this.initialFragmentLayoutConstraints,t.formattingContext&&t.formattingContext.restoreState(this.initialStateOfFormattingContext)}};var Dc=class{initialState(t){return{nodeContext:t,atUnforcedBreak:!1,break:!1}}startNonDisplayableNode(t){}afterNonDisplayableNode(t){}startIgnoredTextNode(t){}afterIgnoredTextNode(t){}startNonElementNode(t){}afterNonElementNode(t){}startInlineElementNode(t){}afterInlineElementNode(t){}startNonInlineElementNode(t){}afterNonInlineElementNode(t){}finish(t){}},Cs=class{constructor(t,e){this.strategy=t;this.layoutContext=e}iterate(t){let e=this.strategy,n=e.initialState(t),s=k("LayoutIterator");return s.loopWithFrame(o=>{let i;for(;n.nodeContext;){n.nodeContext.viewNode?n.nodeContext.viewNode.nodeType!==1?he(n.nodeContext.viewNode,n.nodeContext.whitespace)?n.nodeContext.after?i=e.afterIgnoredTextNode(n):i=e.startIgnoredTextNode(n):n.nodeContext.after?i=e.afterNonElementNode(n):i=e.startNonElementNode(n):n.nodeContext.inline?n.nodeContext.after?i=e.afterInlineElementNode(n):i=e.startInlineElementNode(n):n.nodeContext.after?i=e.afterNonInlineElementNode(n):i=e.startNonInlineElementNode(n):n.nodeContext.after?i=e.afterNonDisplayableNode(n):i=e.startNonDisplayableNode(n);let l=(i&&i.isPending()?i:v(!0)).thenAsync(()=>n.break?v(null):this.layoutContext.nextInTree(n.nodeContext,n.atUnforcedBreak));if(l.isPending()){l.then(c=>{n.break?o.breakLoop():(n.nodeContext=c,o.continueLoop())});return}else if(n.break){o.breakLoop();return}else n.nodeContext=l.get()}e.finish(n),o.breakLoop()}).then(()=>{s.finish(n.nodeContext)}),s.result()}},gn=class extends Dc{constructor(e){super();this.leadingEdge=e}startNonInlineBox(e){}endEmptyNonInlineBox(e){}endNonInlineBox(e){}initialState(e){return{nodeContext:e,atUnforcedBreak:!!this.leadingEdge&&e.after,break:!1,leadingEdge:this.leadingEdge,breakAtTheEdge:null,onStartEdges:!1,leadingEdgeContexts:[],lastAfterNodeContext:null}}processForcedBreak(e,n){let s=!e.leadingEdge&&De(e.breakAtTheEdge);if(s){let o=e.nodeContext=e.leadingEdgeContexts[0]||e.nodeContext;o.viewNode.parentNode.removeChild(o.viewNode),n.pageBreakType=e.breakAtTheEdge}return s}saveEdgeAndProcessOverflow(e,n){let s=n.checkOverflowAndSaveEdgeAndBreakPosition(e.lastAfterNodeContext,null,!0,e.breakAtTheEdge);return s&&(e.nodeContext=(e.lastAfterNodeContext||e.nodeContext).modify(),e.nodeContext.overflow=!0),s}processLayoutConstraint(e,n,s){let o=e.nodeContext,i=!n.allowLayout(o);return i&&(s.checkOverflowAndSaveEdgeAndBreakPosition(e.lastAfterNodeContext,null,!1,e.breakAtTheEdge),o=e.nodeContext=o.modify(),o.overflow=!0),i}startNonElementNode(e){e.onStartEdges=!1}startNonInlineElementNode(e){return e.leadingEdgeContexts.push(e.nodeContext.copy()),e.breakAtTheEdge=Ve(e.breakAtTheEdge,e.nodeContext.breakBefore),e.onStartEdges=!0,this.startNonInlineBox(e)}afterNonInlineElementNode(e){let n,s;return e.onStartEdges?(n=this.endEmptyNonInlineBox(e),s=n&&n.isPending()?n:v(!0),s=s.thenAsync(()=>(e.break||(e.leadingEdgeContexts=[],e.leadingEdge=!1,e.atUnforcedBreak=!1,e.breakAtTheEdge=null),v(!0)))):(n=this.endNonInlineBox(e),s=n&&n.isPending()?n:v(!0)),s.thenAsync(()=>(e.break||(e.onStartEdges=!1,e.lastAfterNodeContext=e.nodeContext.copy(),e.breakAtTheEdge=Ve(e.breakAtTheEdge,e.nodeContext.breakAfter)),v(!0)))}};var Qr=[];function Uh(){Qr=[]}function Uc(r,t,e){return r-=e,t===0?r===0:r%t===0&&r/t>=0}var Mc=class{constructor(t){this.matchers=t}matches(){return this.matchers.some(t=>t.matches())}},_c=class{constructor(t){this.matchers=t}matches(){return this.matchers.every(t=>t.matches())}},uo=class uo{constructor(t,e,n){this.elementOffset=t;this.a=e;this.b=n}static registerFragmentIndex(t,e,n){let s=uo.fragmentIndices;(!s[t]||s[t].priority<=n)&&(s[t]={fragmentIndex:e,priority:n})}static clearFragmentIndices(){uo.fragmentIndices={}}matches(){let t=uo.fragmentIndices[this.elementOffset];return t!=null&&t.fragmentIndex!=null&&Uc(t.fragmentIndex,this.a,this.b)}};d(uo,"fragmentIndices",{});var zn=uo,bs=class{static buildViewConditionMatcher(t,e){let n=e.split("_");return n[0]=="NFS"?new zn(t,parseInt(n[1],10),parseInt(n[2],10)):(`${e}`,null)}static buildAllMatcher(t){return new _c(t)}static buildAnyMatcher(t){return new Mc(t)}};var wu={"border-collapse":!0,"border-spacing":!0,"caption-side":!0,"clip-rule":!0,color:!0,"color-interpolation":!0,"color-rendering":!0,cursor:!0,direction:!0,"empty-cells":!0,fill:!0,"fill-opacity":!0,"fill-rule":!0,"font-kerning":!0,"font-size":!0,"font-size-adjust":!0,"font-family":!0,"font-feature-settings":!0,"font-style":!0,"font-stretch":!0,"font-variant-ligatures":!0,"font-variant-caps":!0,"font-variant-numeric":!0,"font-variant-east-asian":!0,"font-weight":!0,"glyph-orientation-vertical":!0,"hanging-punctuation":!0,hyphens:!0,"hyphenate-character":!0,"hyphenate-limit-chars":!0,"hyphenate-limit-last":!0,"image-rendering":!0,"image-resolution":!0,"letter-spacing":!0,"line-break":!0,"line-height":!0,"list-style-image":!0,"list-style-position":!0,"list-style-type":!0,marker:!0,"marker-end":!0,"marker-mid":!0,"marker-start":!0,orphans:!0,"overflow-wrap":!0,"paint-order":!0,"pointer-events":!0,quotes:!0,"ruby-align":!0,"ruby-position":!0,"shape-rendering":!0,stroke:!0,"stroke-dasharray":!0,"stroke-dashoffset":!0,"stroke-linecap":!0,"stroke-linejoin":!0,"stroke-miterlimit":!0,"stroke-opacity":!0,"stroke-width":!0,"tab-size":!0,"text-align":!0,"text-align-last":!0,"text-anchor":!0,"text-autospace":!0,"text-decoration-skip":!0,"text-emphasis-color":!0,"text-emphasis-position":!0,"text-emphasis-style":!0,"text-fill-color":!0,"text-combine-upright":!0,"text-indent":!0,"text-justify":!0,"text-orientation":!0,"text-rendering":!0,"text-size-adjust":!0,"text-spacing-trim":!0,"text-stroke-color":!0,"text-stroke-width":!0,"text-transform":!0,"text-underline-position":!0,visibility:!0,"white-space":!0,widows:!0,"word-break":!0,"word-spacing":!0,"writing-mode":!0},jm=["image-resolution","orphans","widows"];function Xh(){return Xe("POLYFILLED_INHERITED_PROPS").reduce((t,e)=>t.concat(e()),[].concat(jm))}var Ym={"http://www.idpf.org/2007/ops":!0,"http://www.w3.org/1999/xhtml":!0,"http://www.w3.org/2000/svg":!0,"http://www.w3.org/1998/Math/MathML":!0},Gc=["margin-%","padding-%","border-%-width","border-%-style","border-%-color","%"],Km=["max-%","min-%","%"],qm=(()=>{let r=["left","right","top","bottom"],t={width:!0,height:!0,"max-width":!0,"max-height":!0,"min-width":!0,"min-height":!0};for(let e=0;e<Gc.length;e++)for(let n=0;n<r.length;n++){let s=Gc[e].replace("%",r[n]);t[s]=!0}return t})();function aa(r,t){let e={};for(let n of Gc)for(let s in r){let o=n.replace("%",s),i=n.replace("%",r[s]);e[o]=i,e[i]=o}for(let n of Km)for(let s in t){let o=n.replace("%",s),i=n.replace("%",t[s]);e[o]=i,e[i]=o}return e}var Pu=aa({"block-start":"right","block-end":"left","inline-start":"top","inline-end":"bottom"},{"block-size":"width","inline-size":"height"}),ku=aa({"block-start":"top","block-end":"bottom","inline-start":"left","inline-end":"right"},{"block-size":"height","inline-size":"width"}),Zm=aa({"block-start":"right","block-end":"left","inline-start":"bottom","inline-end":"top"},{"block-size":"width","inline-size":"height"}),Qm=aa({"block-start":"top","block-end":"bottom","inline-start":"right","inline-end":"left"},{"block-size":"height","inline-size":"width"}),M=class r{constructor(t,e){this.value=t;this.priority=e}getBaseValue(){return this}filterValue(t){let e=this.value.visit(t);return e===this.value?this:new r(e,this.priority)}increaseSpecificity(t){return t==0?this:new r(this.value,this.priority+t)}evaluate(t,e,n,s){return e&&bt(e)?this.value:ui(t,this.value,e,n,s)}isEnabled(t){return!0}},oi=class r extends M{constructor(e,n,s){super(e,n);this.condition=s}getBaseValue(){return new M(this.value,this.priority)}filterValue(e){let n=this.value.visit(e);return n===this.value?this:new r(n,this.priority,this.condition)}increaseSpecificity(e){return e==0?this:new r(this.value,this.priority+e,this.condition)}isEnabled(e){try{return!!this.condition.evaluate(e)}catch(n){I.warn(n)}return!1}};function Wc(r,t,e){return(!t||e.priority>=t.priority)&&e.isEnabled(r)?e.getBaseValue():t}function en(r,t,e,n){if(r)if(!e)delete r[t];else{let s=r[t];(!s||e.priority>=s.priority)&&(n?e.isEnabled(n)&&(r[t]=e.getBaseValue()):r[t]=e)}}var $h={"region-id":!0,"fragment-selector-id":!0};function Jm(r){return!!$h[r]}function Xc(r){return r.charAt(0)==="_"&&r!=="_viewConditionalStyles"}function xs(r){return r.charAt(0)!=="_"&&!$h[r]}function Wn(r){return!!wu[r]||bt(r)}function de(r,t){return r[t]}function mn(r,t,e){e?r[t]=e:delete r[t]}function Nt(r,t){return r[t]}function mo(r,t){let e=r[t];return e||(e={},r[t]=e),e}var jh=r=>{let t=r._viewConditionalStyles;return t||(t=[],r._viewConditionalStyles=t),t};function Au(r,t){return r[t]}function Yh(r,t){let e=r[t];return e||(e=[],r[t]=e),e}function ci(r,t,e,n,s,o,i){var l,c;if([{id:s,styleKey:"_pseudos"},{id:o,styleKey:"_regions"}].forEach(u=>{if(u.id){let p=mo(t,u.styleKey);t=p[u.id],t||(t={},p[u.id]=t)}}),i){let u=jh(t);t={},u.push({styles:t,matcher:i})}for(let u in e)if(!Xc(u))if(Jm(u)){let p=Au(e,u),h=Yh(t,u);Array.prototype.push.apply(h,p)}else{let p=de(e,u);if(!p.isEnabled(r))continue;let h=p.increaseSpecificity(n);en(t,u,h,r);let f=(c=(l=r.style)==null?void 0:l.validatorSet.shorthands[u])==null?void 0:c.propList;if(f)for(let g of f){let m=new M(O,h.priority);en(t,g,m,r)}}}function Kh(r,t){let e={};for(let n=0;n<t.length;n++)ci(r,e,t[n],0,null,null,null);return e}function qh(r,t){if(r.length>0){r.sort((n,s)=>s.getPriority()-n.getPriority());let e=null;for(let n=r.length-1;n>=0;n--)e=r[n],e.chained=t,t=e;return e}return t}var ea=class extends jt{constructor(e,n){super();this.props=e;this.context=n;d(this,"propName","")}setPropName(e){this.propName=e}getFontSize(){let e=de(this.props,"font-size");if(!e.value.isNumeric())return X.em;let n=e.value;if(!Rp(n.unit))throw new Error("Unexpected state");return n.num*X[n.unit]}visitNumeric(e){return this.context,this.propName==="font-size"?Lu(e,this.getFontSize(),this.context):e.unit==="em"||e.unit==="ex"||e.unit==="rem"||e.unit==="lh"||e.unit==="rlh"?la(e,this.getFontSize(),this.context):e}visitExpr(e){return this.propName=="font-size"?ui(this.context,e,this.propName).visit(this):e}};function la(r,t,e){let n=r.unit,s=r.num;if(n==="em"||n==="ex"){let o=X[n]/X.em;return new P(s*o*t,"px")}else return n==="rem"?new P(s*e.fontSize(),"px"):n==="rlh"?new P(s*e.rootLineHeight,"px"):r}function Lu(r,t,e){r=la(r,t,e);let n=r.unit,s=r.num;return n==="px"?r:n==="%"?new P(s/100*t,"px"):new P(s*e.queryUnitSize(n,!1),"px")}var Cn=class{apply(t){}mergeWith(t){return new $c([this,t])}clone(){return this}},ho=class extends Cn{constructor(e){super();this.conditionItem=e}apply(e){e.pushConditionItem(this.conditionItem.fresh(e))}},$c=class r extends Cn{constructor(e){super();this.list=e}apply(e){for(let n=0;n<this.list.length;n++)this.list[n].apply(e)}mergeWith(e){return this.list.push(e),this}clone(){return new r([].concat(this.list))}},Es=class extends Cn{constructor(e,n,s,o,i){super();this.style=e;this.specificity=n;this.pseudoelement=s;this.regionId=o;this.viewConditionId=i}apply(e){ci(e.context,e.currentStyle,this.style,this.specificity,this.pseudoelement,this.regionId,e.buildViewConditionMatcher(this.viewConditionId))}},Z=class extends Cn{constructor(){super();d(this,"chained",null)}apply(e){this.chained.apply(e)}getPriority(){return 0}makePrimary(e){return!1}},jc=class extends Z{constructor(e){super();this.className=e}apply(e){e.currentClassNames.includes(this.className)&&this.chained.apply(e)}getPriority(){return 10}makePrimary(e){return this.chained&&e.insertInTable(e.classes,this.className,this.chained),!0}},Yc=class extends Z{constructor(e){super();this.id=e}apply(e){(e.currentId==this.id||e.currentXmlId==this.id)&&this.chained.apply(e)}getPriority(){return 11}makePrimary(e){return this.chained&&e.insertInTable(e.ids,this.id,this.chained),!0}},ta=class extends Z{constructor(e){super();this.localName=e}apply(e){e.currentLocalName==this.localName&&this.chained.apply(e)}getPriority(){return 8}makePrimary(e){return this.chained&&e.insertInTable(e.tags,this.localName,this.chained),!0}},Kc=class extends Z{constructor(e,n){super();this.ns=e;this.localName=n}apply(e){e.currentLocalName==this.localName&&e.currentNamespace==this.ns&&this.chained.apply(e)}getPriority(){return 8}makePrimary(e){if(this.chained){let n=e.nsPrefix[this.ns];n||(n=`ns${e.nsCount++}:`,e.nsPrefix[this.ns]=n);let s=n+this.localName;e.insertInTable(e.nstags,s,this.chained)}return!0}},qc=class extends Z{constructor(e,n){super();this.epubTypePatt=e;this.targetLocalName=n}apply(e){let n=e.currentElement;if(n instanceof HTMLAnchorElement&&n.hash&&n.href==n.baseURI+n.hash){let s=n.hash.substring(1),o=n.ownerDocument.getElementById(s);if(o&&(!this.targetLocalName||o.localName==this.targetLocalName)){let i=o.getAttributeNS("http://www.idpf.org/2007/ops","type")||o.getAttribute("epub:type");i&&i.match(this.epubTypePatt)&&this.chained.apply(e)}}}},Zc=class extends Z{constructor(e){super();this.ns=e}apply(e){e.currentNamespace==this.ns&&this.chained.apply(e)}};function ca(r,t,e,n){if(!r)return!1;if(t!==null)return n(r,t,e);for(let s of r.getAttributeNames())if((s===e||s.endsWith(`:${e}`))&&n(r,s===e?"":r.lookupNamespaceURI(s.split(":")[0]),e))return!0;return!1}var na=class extends Z{constructor(e,n){super();this.ns=e;this.name=n}apply(e){ca(e.currentElement,this.ns,this.name,(n,s,o)=>n.hasAttributeNS(s,o))&&this.chained.apply(e)}},Qc=class extends Z{constructor(e,n,s){super();this.ns=e;this.name=n;this.value=s}apply(e){ca(e.currentElement,this.ns,this.name,(n,s,o)=>n.getAttributeNS(s,o)==this.value)&&this.chained.apply(e)}getPriority(){return this.name=="type"&&this.ns=="http://www.idpf.org/2007/ops"?9:0}makePrimary(e){return this.name=="type"&&this.ns=="http://www.idpf.org/2007/ops"?(this.chained&&e.insertInTable(e.epubtypes,this.value,this.chained),!0):!1}},Jc=class extends Z{constructor(e,n){super();this.ns=e;this.name=n}apply(e){ca(e.currentElement,this.ns,this.name,(n,s,o)=>!!Ym[n.getAttributeNS(s,o)])&&this.chained.apply(e)}getPriority(){return 0}makePrimary(e){return!1}},ys=class extends Z{constructor(e,n,s){super();this.ns=e;this.name=n;this.regexp=s}apply(e){ca(e.currentElement,this.ns,this.name,(n,s,o)=>{var i;return!!((i=n.getAttributeNS(s,o))!=null&&i.match(this.regexp))})&&this.chained.apply(e)}},eu=class extends Z{constructor(e){super();this.langRegExp=e}apply(e){e.lang.match(this.langRegExp)&&this.chained.apply(e)}},sa=class extends Z{constructor(){super()}apply(t){t.isFirst&&this.chained.apply(t)}getPriority(){return 6}},tu=class extends Z{constructor(){super()}apply(t){t.isRoot&&this.chained.apply(t)}getPriority(){return 12}},Gn=class extends Z{constructor(e,n){super();this.a=e;this.b=n}matchANPlusB(e){return Uc(e,this.a,this.b)}},nu=class extends Gn{constructor(t,e){super(t,e)}apply(t){this.matchANPlusB(t.currentSiblingOrder)&&this.chained.apply(t)}getPriority(){return 5}},ii=class extends Gn{constructor(t,e){super(t,e)}apply(t){let e=t.currentSiblingTypeCounts[t.currentNamespace][t.currentLocalName];this.matchANPlusB(e)&&this.chained.apply(t)}getPriority(){return 5}},ri=class extends Gn{constructor(t,e){super(t,e)}apply(t){let e=t.currentFollowingSiblingOrder;e===null&&(e=t.currentFollowingSiblingOrder=t.currentElement.parentNode.childElementCount-t.currentSiblingOrder+1),this.matchANPlusB(e)&&this.chained.apply(t)}getPriority(){return 4}},ai=class extends Gn{constructor(t,e){super(t,e)}apply(t){let e=t.currentFollowingSiblingTypeCounts;if(!e[t.currentNamespace]){let n=t.currentElement;do{let s=n.namespaceURI,o=n.localName,i=e[s];i||(i=e[s]={}),i[o]=(i[o]||0)+1}while(n=n.nextElementSibling)}this.matchANPlusB(e[t.currentNamespace][t.currentLocalName])&&this.chained.apply(t)}getPriority(){return 4}},su=class extends Z{constructor(){super()}apply(t){let e=t.currentElement.firstChild;for(;e;){switch(e.nodeType){case Node.ELEMENT_NODE:return;case Node.TEXT_NODE:if(e.length>0)return}e=e.nextSibling}this.chained.apply(t)}getPriority(){return 4}},ou=class extends Z{constructor(){super()}apply(t){t.currentElement.disabled===!1&&this.chained.apply(t)}getPriority(){return 5}},iu=class extends Z{constructor(){super()}apply(t){t.currentElement.disabled===!0&&this.chained.apply(t)}getPriority(){return 5}},ru=class extends Z{constructor(){super()}apply(t){let e=t.currentElement;(e.selected===!0||e.checked===!0)&&this.chained.apply(t)}getPriority(){return 5}},ze=class extends Z{constructor(e){super();this.condition=e}apply(e){if(e.conditions[this.condition])try{e.dependentConditions.push(this.condition),this.chained.apply(e)}finally{e.dependentConditions.pop()}}getPriority(){return 5}},au=class r extends Cn{constructor(){super();d(this,"applied",!1)}apply(e){this.applied=!0}clone(){let e=new r;return e.applied=this.applied,e}},li=class extends Z{constructor(e){super();d(this,"checkAppliedAction");d(this,"firstActions",[]);this.checkAppliedAction=new au;for(let n of e)this.firstActions.push(qh(n,this.checkAppliedAction))}apply(e){for(let n of this.firstActions)if(n.apply(e),this.checkAppliedAction.applied)break;this.checkAppliedAction.applied===this.positive()&&this.chained.apply(e),this.checkAppliedAction.applied=!1}getPriority(){return Math.max(...this.firstActions.map(e=>e instanceof Z?e.getPriority():0))}positive(){return!0}relational(){return!1}},lu=class extends li{positive(){return!1}},cu=class extends li{constructor(e){super([]);this.selectorTexts=e}apply(e){for(let n of this.selectorTexts){let s,o;/^\s*[+~]/.test(n)?(o=e.currentElement.parentNode,s=`:scope > :nth-child(${Array.from(o.children).indexOf(e.currentElement)+1}) ${n}`):(o=e.currentElement,s=`:scope ${n}`);try{if(o.querySelector(s)){this.checkAppliedAction.apply(e);break}}catch(i){}}this.checkAppliedAction.applied&&this.chained.apply(e),this.checkAppliedAction.applied=!1}relational(){return!0}},fo=class{constructor(t,e,n){this.condition=t;this.viewConditionId=e;this.viewCondition=n}increment(t){t.increment(this.condition,this.viewCondition)}decrement(t){t.decrement(this.condition,this.viewCondition)}buildViewConditionMatcher(t){return t.buildViewConditionMatcher(this.viewConditionId)}},uu=class r extends fo{constructor(t,e,n){super(t,e,n)}fresh(t){return new r(this.condition,this.viewConditionId,this.buildViewConditionMatcher(t))}push(t,e){return e==0&&this.increment(t),!1}pop(t,e){return e==0?(this.decrement(t),!0):!1}},du=class r extends fo{constructor(t,e,n){super(t,e,n)}fresh(t){return new r(this.condition,this.viewConditionId,this.buildViewConditionMatcher(t))}push(t,e){return e==0?this.increment(t):e==1&&this.decrement(t),!1}pop(t,e){return e==0?(this.decrement(t),!0):(e==1&&this.increment(t),!1)}},pu=class r extends fo{constructor(e,n,s){super(e,n,s);d(this,"fired",!1)}fresh(e){return new r(this.condition,this.viewConditionId,this.buildViewConditionMatcher(e))}push(e,n){return this.fired?(this.decrement(e),!0):!1}pop(e,n){return this.fired?(this.decrement(e),!0):(n==0&&(this.fired=!0,this.increment(e)),!1)}},hu=class r extends fo{constructor(e,n,s){super(e,n,s);d(this,"fired",!1)}fresh(e){return new r(this.condition,this.viewConditionId,this.buildViewConditionMatcher(e))}push(e,n){return this.fired&&(n==-1?this.increment(e):n==0&&this.decrement(e)),!1}pop(e,n){if(this.fired){if(n==-1)return this.decrement(e),!0;n==0&&this.increment(e)}else n==0&&(this.fired=!0,this.increment(e));return!1}},fu=class{constructor(t,e){this.afterprop=t;this.element=e}fresh(t){return this}push(t,e){return!1}pop(t,e){return e==0?(t.processPseudoelementProps(this.afterprop,this.element),!0):!1}},gu=class{constructor(t){this.lang=t}fresh(t){return this}push(t,e){return!1}pop(t,e){return e==0?(t.lang=this.lang,!0):!1}},mu=class{constructor(t){this.oldQuotes=t}fresh(t){return this}push(t,e){return!1}pop(t,e){return e==0?(t.quotes=this.oldQuotes,!0):!1}},Cu=class extends jt{constructor(e){super();this.element=e}createValueFromString(e,n){switch(n){case"url":return e?new Ue(e):new Ue("about:invalid");case"string":default:return e?new ce(e):new ce("")}}visitFunc(e){if(e.name!=="attr")return super.visitFunc(e);let n="string",s=null,o=null;if(e.values[0]instanceof q){let i=e.values[0].values;i.length>=2&&(n=i[1].stringValue()),s=i[0].stringValue()}else s=e.values[0].stringValue();return e.values.length>1?o=this.createValueFromString(e.values[1].stringValue(),n):o=this.createValueFromString(null,n),this.element&&this.element.hasAttribute(s)?this.createValueFromString(this.element.getAttribute(s),n):o}};function si(r){if(St(r)){if(r instanceof ce)return r.stringValue();if(r instanceof q)return r.values.map(t=>si(t)).join("")}return""}var go=class extends jt{constructor(e,n,s){super();this.cascade=e;this.element=n;this.counterResolver=s}visitIdent(e){let n=this.cascade,s=n.quotes,o=Math.floor(s.length/2)-1;switch(e.name){case"open-quote":{let i=s[2*Math.min(o,n.quoteDepth)];return n.quoteDepth++,i}case"close-quote":return n.quoteDepth>0&&n.quoteDepth--,s[2*Math.min(o,n.quoteDepth)+1];case"no-open-quote":return n.quoteDepth++,new ce("");case"no-close-quote":return n.quoteDepth>0&&n.quoteDepth--,new ce("")}return e}format(e,n){let s=!1,o=!1,i;(i=n.match(/^upper-(.*)/))!=null?(s=!0,n=i[1]):(i=n.match(/^lower-(.*)/))!=null&&(o=!0,n=i[1]);let a="";return zh[n]?a=tC(zh[n],e):Gh[n]?a=sC(Gh[n],e):Wh[n]!=null?a=Wh[n]:n=="decimal-leading-zero"?(a=`${e}`,a.length==1&&(a=`0${a}`)):n=="cjk-ideographic"||n=="trad-chinese-informal"?a=iC(e,oC):a=`${e}`,s?a.toUpperCase():o?a.toLowerCase():a}visitFuncCounter(e){let n=e[0].toString(),s=e.length>1?e[1].stringValue():"decimal",o=this.cascade.counters[n];if(o&&o.length){let i=o&&o.length&&o[o.length-1]||0;return new ce(this.format(i,s))}else{let i=new F(this.counterResolver.getPageCounterVal(n,a=>this.format(a||0,s)));return new q([i])}}visitFuncCounters(e){let n=e[0].toString(),s=e[1].stringValue(),o=e.length>2?e[2].stringValue():"decimal",i=this.cascade.counters[n],a=new je;if(i&&i.length)for(let c=0;c<i.length;c++)c>0&&a.append(s),a.append(this.format(i[c],o));let l=new F(this.counterResolver.getPageCountersVal(n,c=>{let u=[];if(c.length)for(let h=0;h<c.length;h++)u.push(this.format(c[h],o));let p=a.toString();return p.length&&u.push(p),u.length?u.join(s):this.format(0,o)}));return new q([l])}visitFuncTargetCounter(e){let n=e[0],s;n instanceof Ue?s=n.url:s=n.stringValue();let o=e[1].toString(),i=e.length>2?e[2].stringValue():"decimal",a=new F(this.counterResolver.getTargetCounterVal(s,o,l=>this.format(l||0,i)));return new q([a])}visitFuncTargetCounters(e){let n=e[0],s;n instanceof Ue?s=n.url:s=n.stringValue();let o=e[1].toString(),i=e[2].stringValue(),a=e.length>3?e[3].stringValue():"decimal",l=new F(this.counterResolver.getTargetCountersVal(s,o,c=>{let u=c.map(p=>this.format(p,a));return u.length?u.join(i):this.format(0,a)}));return new q([l])}visitFuncString(e){let n=e.length>0?e[0].stringValue():"",s=e.length>1?e[1].stringValue():"first";return new F(this.counterResolver.getNamedStringVal(n,s))}visitFuncElement(e){let n=e.length>0?e[0].stringValue():"",s=e.length>1?e[1].stringValue():"first";return new F(this.counterResolver.getRunningElementVal(n,s))}visitFuncContent(e){var o,i,a,l,c,u;let n=e.length>0?e[0].stringValue():"text",s="";switch(n){case"text":s=this.element.textContent;break;case"before":case"after":{let p=Nt(this.cascade.currentStyle,"_pseudos"),h=(i=(o=p==null?void 0:p[n])==null?void 0:o.content)==null?void 0:i.value;s=si(h)}break;case"first-letter":{let p=Nt(this.cascade.currentStyle,"_pseudos"),h=(si((l=(a=p==null?void 0:p.before)==null?void 0:a.content)==null?void 0:l.value)||this.element.textContent||si((u=(c=p==null?void 0:p.after)==null?void 0:c.content)==null?void 0:u.value)).match(Lo);s=h?h[0]:""}break}return new ce(s)}visitFuncLeader(e){let n="";if(e[0]instanceof Be)switch(e[0].stringValue()){case"dotted":n=".";break;case"solid":n="_";break;case"space":n=" ";break}else e[0]instanceof ce&&(n=e[0].stringValue());return n.length==0?new ce(""):new F(new oe(null,()=>n,"viv-leader"))}visitFunc(e){switch(e.name){case"counter":if(e.values.length<=2)return this.visitFuncCounter(e.values);break;case"counters":if(e.values.length<=3)return this.visitFuncCounters(e.values);break;case"target-counter":if(e.values.length<=3)return this.visitFuncTargetCounter(e.values);break;case"target-counters":if(e.values.length<=4)return this.visitFuncTargetCounters(e.values);break;case"string":if(e.values.length<=2)return this.visitFuncString(e.values);break;case"element":if(e.values.length<=2)return this.visitFuncElement(e.values);break;case"content":if(e.values.length<=1)return this.visitFuncContent(e.values);break;case"leader":if(e.values.length<=1)return this.visitFuncLeader(e.values);break}return e}},eC=(r,t,e)=>{let n=t.filter(l=>l.after&&l.viewNode.nodeType===1&&l.viewNode.getAttribute("data-viv-leader"));for(let l of n){let C=function(Q){if(m==="rtl"){let re="\u200F";u.textContent=(Q.startsWith(re)?"":re)+Q+(Q.endsWith(re)?"":re)}else u.textContent=Q},S=function(){let Q=e.clientLayout.getElementClientRect(p);return b.left>Q.left||b.right<Q.right||b.top>Q.top||b.bottom<Q.bottom},w=function(){let Q,re;if(C(f),S())Q=1,re=f.length/h.length;else{Q=f.length/h.length,re=Q;for(let Te=0;Te<16;Te++){let Ge=f;for(let R=0;R<1<<Te;R++)Ge+=h;if(C(Ge),S()){re+=1<<Te;break}}}for(let Te=0;Te<16;Te++){let Ge="",R=Math.floor((Q+re)/2);for(let G=0;G<R;G++)Ge+=h;if(C(Ge),S())re=R;else{if(Q==R)return;Q=R}}C(h)},_=function(Q){let re=0,Te=p.parentElement;for(;Te&&Te!==c.viewNode;)re+=e.getComputedInsets(Te)[Q],Te=Te.parentElement;return re};var s=C,o=S,i=w,a=_;let c=l.parent;for(;c&&c.inline;)c=c.parent;let u=l.viewNode,p=u.parentElement,h=u.getAttribute("data-viv-leader-value"),f=u.textContent||h,{writingMode:g,direction:m,marginInlineEnd:E}=e.clientLayout.getElementComputedStyle(p);u.style.marginInlineStart="1px",C(h),p.style.display="inline-block",p.style.textIndent="0";let b=e.clientLayout.getElementClientRect(c.viewNode),y=e.clientLayout.getElementClientRect(p),N=e.parseComputedLength(E);g==="vertical-rl"||g==="vertical-lr"?(m==="rtl"?b.top+=N:b.bottom-=N,b.left=y.left,b.right=y.right,b.top=Math.min(y.top,b.top),b.bottom=Math.max(y.bottom,b.bottom)):(m==="rtl"?b.left+=N:b.right-=N,b.top=y.top,b.bottom=y.bottom,b.left=Math.min(y.left,b.left),b.right=Math.max(y.right,b.right)),w();let A=e.clientLayout.getElementClientRect(p);m=="rtl"?p.style.float="left":p.style.float="right";let V=e.clientLayout.getElementClientRect(p),Ee=0;m=="rtl"?g=="vertical-rl"||g=="vertical-lr"?Ee=A.top-V.top-_("top"):Ee=A.left-V.left-_("left"):g=="vertical-rl"||g=="vertical-lr"?Ee=V.bottom-A.bottom-_("bottom"):Ee=V.right-A.right-_("right"),Ee=Math.max(0,Ee-.1),p.style.float="",u.style.marginInlineStart=`${Ee}px`}};_e("POST_LAYOUT_BLOCK",eC);var zh={roman:[4999,1e3,"M",900,"CM",500,"D",400,"CD",100,"C",90,"XC",50,"L",40,"XL",10,"X",9,"IX",5,"V",4,"IV",1,"I"],armenian:[9999,9e3,"\u0584",8e3,"\u0583",7e3,"\u0582",6e3,"\u0581",5e3,"\u0580",4e3,"\u057F",3e3,"\u057E",2e3,"\u057D",1e3,"\u057C",900,"\u057B",800,"\u057A",700,"\u0579",600,"\u0578",500,"\u0577",400,"\u0576",300,"\u0575",200,"\u0574",100,"\u0573",90,"\u0572",80,"\u0571",70,"\u0570",60,"\u056F",50,"\u056E",40,"\u056D",30,"\u056C",20,"\u056B",10,"\u056A",9,"\u0569",8,"\u0568",7,"\u0567",6,"\u0566",5,"\u0565",4,"\u0564",3,"\u0563",2,"\u0562",1,"\u0561"],georgian:[19999,1e4,"\u10F5",9e3,"\u10F0",8e3,"\u10EF",7e3,"\u10F4",6e3,"\u10EE",5e3,"\u10ED",4e3,"\u10EC",3e3,"\u10EB",2e3,"\u10EA",1e3,"\u10E9",900,"\u10E8",800,"\u10E7",700,"\u10E6",600,"\u10E5",500,"\u10E4",400,"\u10F3",300,"\u10E2",200,"\u10E1",100,"\u10E0",90,"\u10DF",80,"\u10DE",70,"\u10DD",60,"\u10F2",50,"\u10DC",40,"\u10DB",30,"\u10DA",20,"\u10D9",10,"\u10D8",9,"\u10D7",8,"\u10F1",7,"\u10D6",6,"\u10D5",5,"\u10D4",4,"\u10D3",3,"\u10D2",2,"\u10D1",1,"\u10D0"],hebrew:[999,400,"\u05EA",300,"\u05E9",200,"\u05E8",100,"\u05E7",90,"\u05E6",80,"\u05E4",70,"\u05E2",60,"\u05E1",50,"\u05E0",40,"\u05DE",30,"\u05DC",20,"\u05DB",19,"\u05D9\u05D8",18,"\u05D9\u05D7",17,"\u05D9\u05D6",16,"\u05D8\u05D6",15,"\u05D8\u05D5",10,"\u05D9",9,"\u05D8",8,"\u05D7",7,"\u05D6",6,"\u05D5",5,"\u05D4",4,"\u05D3",3,"\u05D2",2,"\u05D1",1,"\u05D0"]},Gh={latin:"a-z",alpha:"a-z",greek:"\u03B1-\u03C1\u03C3-\u03C9",russian:"\u0430-\u0438\u043A-\u0449\u044D-\u044F"},Wh={square:"\u25A0",disc:"\u2022",circle:"\u25E6",none:""};function tC(r,t){let e=r[0];if(t>e||t<=0||t!=Math.round(t))return"";let n="";for(let s=1;s<r.length;s+=2){let o=r[s],i=Math.floor(t/o);if(i>20)return"";for(t-=i*o;i>0;)n+=r[s+1],i--}return n}function nC(r){let t=[],e=0;for(;e<r.length;)if(r.substr(e+1,1)=="-"){let n=r.charCodeAt(e),s=r.charCodeAt(e+2);e+=3;for(let o=n;o<=s;o++)t.push(String.fromCharCode(o))}else t.push(r.substr(e++,1));return t}function sC(r,t){if(t<=0||t!=Math.round(t))return"";let e=nC(r),n="";do{t--;let s=t%e.length;n=e[s]+n,t=(t-s)/e.length}while(t>0);return n}var oC={formal:!1,digits:"\u96F6\u4E00\u4E8C\u4E09\u56DB\u4E94\u516D\u4E03\u516B\u4E5D",markers:"\u5341\u767E\u5343",negative:"\u8CA0"};function iC(r,t){if(r>9999||r<-9999)return`${r}`;if(r==0)return t.digits.charAt(0);let e=new je;if(r<0&&(e.append(t.negative),r=-r),r<10)e.append(t.digits.charAt(r));else if(!t.formal&&r<=19)e.append(t.markers.charAt(0)),r!=0&&e.append(t.digits.charAt(r-10));else{let n=Math.floor(r/1e3);n&&(e.append(t.digits.charAt(n)),e.append(t.markers.charAt(2)));let s=Math.floor(r/100)%10;s&&(e.append(t.digits.charAt(s)),e.append(t.markers.charAt(1)));let o=Math.floor(r/10)%10;o&&(e.append(t.digits.charAt(o)),e.append(t.markers.charAt(0)));let i=r%10;i&&e.append(t.digits.charAt(i))}return e.toString()}var Ru=1/1048576;function po(r,t){for(let e in r)t[e]=r[e].clone()}var bu=class r{constructor(){d(this,"nsCount",0);d(this,"nsPrefix",{});d(this,"tags",{});d(this,"nstags",{});d(this,"epubtypes",{});d(this,"classes",{});d(this,"ids",{});d(this,"pagetypes",{});d(this,"order",0)}clone(){let t=new r;t.nsCount=this.nsCount;for(let e in this.nsPrefix)t.nsPrefix[e]=this.nsPrefix[e];return po(this.tags,t.tags),po(this.nstags,t.nstags),po(this.epubtypes,t.epubtypes),po(this.classes,t.classes),po(this.ids,t.ids),po(this.pagetypes,t.pagetypes),t.order=this.order,t}insertInTable(t,e,n){let s=t[e];s&&(n=s.mergeWith(n)),t[e]=n}createInstance(t,e,n,s){return new yu(this,t,e,n,s)}nextOrder(){return this.order+=Ru}},yu=class{constructor(t,e,n,s,o){this.context=e;this.counterListener=n;this.counterResolver=s;d(this,"code");d(this,"stack",[[],[]]);d(this,"conditions",{});d(this,"currentElement",null);d(this,"currentElementOffset",null);d(this,"currentStyle",null);d(this,"currentClassNames",null);d(this,"currentLocalName","");d(this,"currentNamespace","");d(this,"currentId","");d(this,"currentXmlId","");d(this,"currentNSTag","");d(this,"currentEpubTypes",null);d(this,"currentPageType",null);d(this,"previousPageType",null);d(this,"firstPageType",null);d(this,"isFirst",!0);d(this,"isRoot",!0);d(this,"counters",{});d(this,"counterScoping",[{}]);d(this,"quotes");d(this,"quoteDepth",0);d(this,"lang","");d(this,"siblingOrderStack",[0]);d(this,"currentSiblingOrder",0);d(this,"siblingTypeCountsStack",[{}]);d(this,"currentSiblingTypeCounts");d(this,"currentFollowingSiblingOrder",null);d(this,"followingSiblingOrderStack");d(this,"followingSiblingTypeCountsStack",[{}]);d(this,"currentFollowingSiblingTypeCounts");d(this,"viewConditions",{});d(this,"dependentConditions",[]);d(this,"elementStack");this.code=t,this.quotes=[new ce("\u201C"),new ce("\u201D"),new ce("\u2018"),new ce("\u2019")],this.currentSiblingTypeCounts=this.siblingTypeCountsStack[0],this.followingSiblingOrderStack=[this.currentFollowingSiblingOrder],this.currentFollowingSiblingTypeCounts=this.siblingTypeCountsStack[0]}pushConditionItem(t){this.stack[this.stack.length-1].push(t)}increment(t,e){this.conditions[t]=(this.conditions[t]||0)+1,e&&(this.viewConditions[t]?this.viewConditions[t].push(e):this.viewConditions[t]=[e])}decrement(t,e){this.conditions[t]--,this.viewConditions[t]&&(this.viewConditions[t]=this.viewConditions[t].filter(n=>n!==e),this.viewConditions[t].length===0&&delete this.viewConditions[t])}buildViewConditionMatcher(t){let e=null;t&&(this.currentElementOffset,e=bs.buildViewConditionMatcher(this.currentElementOffset,t));let n=this.dependentConditions.map(s=>{let o=this.viewConditions[s];return o&&o.length>0?o.length===1?o[0]:bs.buildAnyMatcher([].concat(o)):null}).filter(s=>s);return n.length<=0?e:e===null?n.length===1?n[0]:bs.buildAllMatcher(n):bs.buildAllMatcher([e].concat(n))}applyAction(t,e){let n=t[e];n&&n.apply(this)}pushRule(t,e,n){this.currentElement=null,this.currentElementOffset=null,this.currentStyle=n,this.currentNamespace="",this.currentLocalName="",this.currentId="",this.currentXmlId="",this.currentClassNames=t,this.currentNSTag="",this.currentEpubTypes=zc,this.currentPageType=e,this.applyActions()}defineCounter(t,e){let n=this.counterScoping[this.counterScoping.length-1];n||(n={},this.counterScoping[this.counterScoping.length-1]=n),this.counters[t]?(n[t]&&this.counters[t].pop(),this.counters[t].push(e)):this.counters[t]=[e],n[t]=!0}pushCounters(t){var h,f,g,m,E,C,b;let e=x.inline,n=t.display;if(n&&(e=n.evaluate(this.context)),e===x.none){this.currentElement.setAttribute("data-viv-display-none","true"),this.counterScoping.push(null);return}else if(this.currentElement.closest("[data-viv-display-none]")){this.counterScoping.push(null);return}let s=x.inline,o=t.float;o&&(s=o.evaluate(this.context));let i=null,a=null,l=null,c=t["counter-reset"];if(c){let y=c.evaluate(this.context);y&&(i=is(y,!0))}let u=t["counter-set"];if(u){let y=u.evaluate(this.context);y&&(l=is(y,!1))}let p=t["counter-increment"];if(p){let y=p.evaluate(this.context);y&&(a=is(y,!1))}if((this.currentLocalName=="ol"||this.currentLocalName=="ul")&&this.currentNamespace=="http://www.w3.org/1999/xhtml"&&(i||(i={}),i["list-item"]=((f=(h=this.currentElement)==null?void 0:h.start)!=null?f:1)-1),e===x.list_item&&(a||(a={}),a["list-item"]=(g=a["list-item"])!=null?g:1,/^\s*[-+]?\d/.test((E=(m=this.currentElement)==null?void 0:m.getAttribute("value"))!=null?E:"")&&(l||(l={}),l["list-item"]=this.currentElement.value)),((C=this.currentElement)==null?void 0:C.parentNode.nodeType)===Node.DOCUMENT_NODE&&(i||(i={}),i.footnote===void 0&&(i.footnote=0)),s===x.footnote&&(a||(a={}),a.footnote===void 0)){let y=(b=this.currentStyle["counter-increment"])==null?void 0:b.value;(!y||!(y===x.footnote||y instanceof q&&y.values.includes(x.footnote)))&&(a.footnote=1)}if(i)for(let y in i)this.defineCounter(y,i[y]);if(a)for(let y in a){this.counters[y]||this.defineCounter(y,0);let N=this.counters[y];N[N.length-1]+=a[y]}if(l)for(let y in l)if(!this.counters[y])this.defineCounter(y,l[y]);else{let N=this.counters[y];N[N.length-1]=l[y]}if(e===x.list_item){let y=this.counters["list-item"],N=y[y.length-1];t["ua-list-item-count"]=new M(new lt(N),0)}this.counterScoping.push(null)}popCounters(){let t=this.counterScoping.pop();if(t)for(let e in t){let n=this.counters[e];n&&(n.length==1?delete this.counters[e]:n.pop())}}setNamedStrings(t){let e=t["string-set"];if(!e)return;e=e.filterValue(new go(this,this.currentElement,this.counterResolver));let n=e.value instanceof ge?e.value.values:[e.value];for(let s of n)if(s instanceof q){let o=s.values[0].stringValue(),i=s.values.slice(1).map(a=>si(a)).join("");this.counterResolver.setNamedString(o,i,this.currentElementOffset)}delete t["string-set"]}setRunningElement(t){let e=t.position;if((e==null?void 0:e.value)instanceof Pt&&e.value.name==="running"){let n=e.value.values[0].stringValue();this.counterResolver.setRunningElement(n,this.currentElementOffset)}}processPseudoelementProps(t,e){this.pushCounters(t);let n=t.content;n&&(t.content=n.filterValue(new go(this,e,this.counterResolver))),this.popCounters()}pushElement(t,e,n,s){var S,w;this.currentPageType=null,this.currentElement=e,this.currentElementOffset=s,this.currentStyle=n,this.currentNamespace=e.namespaceURI,this.currentLocalName=e.localName;let o=this.code.nsPrefix[this.currentNamespace];o?this.currentNSTag=o+this.currentLocalName:this.currentNSTag="",this.currentId=e.getAttribute("id"),this.currentXmlId=e.getAttributeNS("http://www.w3.org/XML/1998/namespace","id");let i=e.getAttribute("class");i?this.currentClassNames=i.split(/\s+/):this.currentClassNames=zc;let a=e.getAttributeNS("http://www.idpf.org/2007/ops","type");a?this.currentEpubTypes=a.split(/\s+/):this.currentEpubTypes=zc;let l=Ro(e);l&&(this.stack[this.stack.length-1].push(new gu(this.lang)),this.lang=l.toLowerCase());let c=this.isRoot,u=this.siblingOrderStack;this.currentSiblingOrder=++u[u.length-1],u.push(0);let p=this.siblingTypeCountsStack,h=this.currentSiblingTypeCounts=p[p.length-1],f=h[this.currentNamespace];f||(f=h[this.currentNamespace]={}),f[this.currentLocalName]=(f[this.currentLocalName]||0)+1,p.push({});let g=this.followingSiblingOrderStack;g[g.length-1]!==null?this.currentFollowingSiblingOrder=--g[g.length-1]:this.currentFollowingSiblingOrder=null,g.push(null);let m=this.followingSiblingTypeCountsStack,E=this.currentFollowingSiblingTypeCounts=m[m.length-1];E&&E[this.currentNamespace]&&E[this.currentNamespace][this.currentLocalName]--,m.push({}),this.applyActions(),this.applyVarFilter([this.currentStyle],t,e),this.applyCalcFilter(this.currentStyle,this.context),this.applyAttrFilter(e);let C=n.quotes,b=null;if(C){let A=C.evaluate(this.context);A&&(b=new mu(this.quotes),A===x.none?this.quotes=[new ce(""),new ce("")]:A===x.auto||A===x.initial?this.quotes=[new ce("\u201C"),new ce("\u201D"),new ce("\u2018"),new ce("\u2019")]:A instanceof q&&(this.quotes=A.values))}this.pushCounters(this.currentStyle);let y=this.currentId||this.currentXmlId||e.getAttribute("name")||"";if(c||y){let A={};Object.keys(this.counters).forEach(V=>{A[V]=Array.from(this.counters[V])}),this.counterListener.countersOfId(y,A)}let N=Nt(this.currentStyle,"_pseudos");if(N){let A=!0;for(let V of rC){V||(A=!1);let _=N[V];_&&((V==="before"||V==="after")&&!St((S=_.content)==null?void 0:S.value)||(V==="footnote-call"||V==="footnote-marker")&&((w=de(this.currentStyle,"float"))==null?void 0:w.value)!==x.footnote?delete N[V]:A?this.processPseudoelementProps(_,e):this.stack[this.stack.length-2].push(new fu(_,e)))}}this.setNamedStrings(this.currentStyle),this.setRunningElement(this.currentStyle),b&&this.stack[this.stack.length-2].push(b)}applyAttrFilterInner(t,e){for(let n in e)xs(n)&&!bt(n)&&(e[n]=e[n].filterValue(t))}applyAttrFilter(t){let e=new Cu(t),n=this.currentStyle,s=Nt(n,"_pseudos");for(let o in s)this.applyAttrFilterInner(e,s[o]);this.applyAttrFilterInner(e,n)}applyVarFilter(t,e,n){var l,c,u;let s=t[0],o=new Tu(t,e,n),i=32,a={};for(let p in s)if(Xc(p)){let h=Nt(s,p);for(let f in h)this.applyVarFilter([h[f],...t],e,n)}else if(xs(p)){let h=de(s,p),f=h.value;for(let g=0;;g++){if(g>=i){f=O;break}let m=f.visit(o);if(o.error){f=O,o.error=!1;break}if(m===f)break;f=m}if(f!==h.value){let g=e.validatorSet,m=(l=g==null?void 0:g.shorthands[p])==null?void 0:l.clone();if(m)if(U(f)){for(let E of m.propList){let C=new M(f,h.priority),b=de(s,E);mn(a,E,Wc(this.context,b,C))}delete s[p]}else{let E=Zt(e.scope,new Oe(f.toString(),null),"");if(E&&(E.visit(m),!m.error)){for(let C of m.propList){let b=new M((u=(c=m.values[C])!=null?c:g.defaultValues[C])!=null?u:x.initial,h.priority),y=de(s,C);mn(a,C,Wc(this.context,y,b))}delete s[p]}}else s[p]=new M(f,h.priority)}if(a[p]){let g=de(s,p);g&&g.value!==O&&en(a,p,g,this.context)}}for(let p in a)s[p]=a[p]}applyCalcFilter(t,e){let n=new ra(e);for(let s in t)if(Xc(s)){let o=Nt(t,s);for(let i in o)this.applyCalcFilter(o[i],e)}else if(xs(s)&&!bt(s)){let o=de(t,s),i=o.value.visit(n);i!==o.value&&(t[s]=new M(i,o.priority))}}applyActions(){let t;for(t=0;t<this.currentClassNames.length;t++)this.applyAction(this.code.classes,this.currentClassNames[t]);for(t=0;t<this.currentEpubTypes.length;t++)this.applyAction(this.code.epubtypes,this.currentEpubTypes[t]);this.applyAction(this.code.ids,this.currentId),this.applyAction(this.code.tags,this.currentLocalName),this.currentLocalName!=""&&this.applyAction(this.code.tags,"*"),this.applyAction(this.code.nstags,this.currentNSTag),this.currentPageType!==null&&(this.applyAction(this.code.pagetypes,this.currentPageType),this.applyAction(this.code.pagetypes,"*")),this.stack.push([]);for(let e=1;e>=-1;--e){let n=this.stack[this.stack.length-e-2];for(t=0;t<n.length;)n[t].push(this,e)?n.splice(t,1):t++}this.isFirst=!0,this.isRoot=!1}pop(){for(let t=1;t>=-1;--t){let e=this.stack[this.stack.length-t-2],n=0;for(;n<e.length;)e[n].pop(this,t)?e.splice(n,1):n++}this.stack.pop(),this.isFirst=!1}popRule(){this.pop()}popElement(t){this.siblingOrderStack.pop(),this.siblingTypeCountsStack.pop(),this.followingSiblingOrderStack.pop(),this.followingSiblingTypeCountsStack.pop(),this.pop(),this.popCounters()}},zc=[],rC=["before","transclusion-before","footnote-call","footnote-marker","inner","first-letter","first-line","","transclusion-after","after"];var xu=null;function Zh(r){xu=r}var bn=class extends qt{constructor(e,n,s,o,i,a,l){super(e,n,l);this.condition=s;this.regionId=i;this.validatorSet=a;d(this,"chain",null);d(this,"specificity",0);d(this,"elementStyle",null);d(this,"conditionCount",0);d(this,"pseudoelement",null);d(this,"footnoteContent",!1);d(this,"cascade");d(this,"state");d(this,"viewConditionId",null);d(this,"insideSelectorRule");d(this,"invalid",!1);this.cascade=o?o.cascade:xu?xu.clone():new bu,this.state=0}insertNonPrimary(e){this.cascade.insertInTable(this.cascade.tags,"*",e)}processChain(e){let n=qh(this.chain,e);n!==e&&n.makePrimary(this.cascade)||this.insertNonPrimary(n)}isInsideSelectorRule(e){return this.state!=0?(this.reportAndSkip(e),!0):!1}tagSelector(e,n){!n&&!e||(n&&(this.specificity+=1),n&&e?this.chain.push(new Kc(e,n.toLowerCase())):n?this.chain.push(new ta(n.toLowerCase())):this.chain.push(new Zc(e)))}invalidSelector(e){I.warn(e),this.chain.push(new ze("")),this.setInvalid()}setInvalid(){this.invalid=!0;for(let e=this;e instanceof Ss;e=e.parent)e.parent.invalid=!0}classSelector(e){if(this.pseudoelement){this.invalidSelector(`::${this.pseudoelement} followed by .${e}`);return}this.specificity+=256,this.chain.push(new jc(e))}pseudoclassSelector(e,n){if(this.pseudoelement){this.invalidSelector(`::${this.pseudoelement} followed by :${e}`);return}switch(e.toLowerCase()){case"enabled":this.chain.push(new ou);break;case"disabled":this.chain.push(new iu);break;case"checked":this.chain.push(new ru);break;case"root":case"scope":this.chain.push(new tu);break;case"link":this.chain.push(new ta("a")),this.chain.push(new na("","href"));break;case"-adapt-href-epub-type":case"href-epub-type":if(n&&n.length>=1&&typeof n[0]=="string"){let s=n[0],o=new RegExp(`(^|\\s)${nn(s)}($|\\s)`),i=n[1];this.chain.push(new qc(o,i))}else this.chain.push(new ze(""));break;case"-adapt-footnote-content":case"footnote-content":this.footnoteContent=!0;break;case"visited":case"active":case"hover":case"focus":this.chain.push(new ze(""));break;case"lang":if(n&&n.length==1&&typeof n[0]=="string"){let s=n[0];this.chain.push(new eu(new RegExp(`^${nn(s.toLowerCase())}($|-)`)))}else this.chain.push(new ze(""));break;case"nth-child":case"nth-last-child":case"nth-of-type":case"nth-last-of-type":{let s=aC[e.toLowerCase()];n&&n.length==2?this.chain.push(new s(n[0],n[1])):this.chain.push(new ze(""));break}case"first-child":this.chain.push(new sa);break;case"last-child":this.chain.push(new ri(0,1));break;case"first-of-type":this.chain.push(new ii(0,1));break;case"last-of-type":this.chain.push(new ai(0,1));break;case"only-child":this.chain.push(new sa),this.chain.push(new ri(0,1));break;case"only-of-type":this.chain.push(new ii(0,1)),this.chain.push(new ai(0,1));break;case"empty":this.chain.push(new su);break;case"before":case"after":case"first-line":case"first-letter":this.pseudoelementSelector(e,n);return;default:this.invalidSelector(`Unknown pseudo-class :${e}`);return}this.specificity+=256}pseudoelementSelector(e,n){switch(e){case"before":case"after":case"first-line":case"first-letter":case"footnote-call":case"footnote-marker":case"inner":case"after-if-continues":if(!this.pseudoelement)this.pseudoelement=e;else{this.invalidSelector(`Double pseudo-element ::${this.pseudoelement}::${e}`);return}break;case"first-n-lines":if(n&&n.length==1&&typeof n[0]=="number"){let s=Math.round(n[0]);if(s>0&&s==n[0]){if(!this.pseudoelement)this.pseudoelement=`first-${s}-lines`;else{this.invalidSelector(`Double pseudo-element ::${this.pseudoelement}::${e}`);return}break}}this.chain.push(new ze(""));break;case"nth-fragment":n&&n.length==2?this.viewConditionId=`NFS_${n[0]}_${n[1]}`:this.chain.push(new ze(""));break;default:this.invalidSelector(`Unknown pseudo-element ::${e}`);return}this.specificity+=1}idSelector(e){this.specificity+=65536,this.chain.push(new Yc(e))}attributeSelector(e,n,s,o){this.specificity+=256,n=n.toLowerCase(),o=o||"";let i;switch(s){case 0:i=new na(e,n);break;case 39:i=new Qc(e,n,o);break;case 45:!o||o.match(/\s/)?i=new ze(""):i=new ys(e,n,new RegExp(`(^|\\s)${nn(o)}($|\\s)`));break;case 44:i=new ys(e,n,new RegExp(`^${nn(o)}($|-)`));break;case 43:o?i=new ys(e,n,new RegExp(`^${nn(o)}`)):i=new ze("");break;case 42:o?i=new ys(e,n,new RegExp(`${nn(o)}$`)):i=new ze("");break;case 46:o?i=new ys(e,n,new RegExp(nn(o))):i=new ze("");break;case 50:if(o=="supported")i=new Jc(e,n);else{this.invalidSelector(`Unsupported :: attr selector op: ${o}`);return}break;default:this.invalidSelector(`Unsupported attr selector: ${s}`);return}this.chain.push(i)}descendantSelector(){let e=`d${Jr++}`;this.processChain(new ho(new uu(e,this.viewConditionId,null))),this.chain=[new ze(e)],this.viewConditionId=null}childSelector(){let e=`c${Jr++}`;this.processChain(new ho(new du(e,this.viewConditionId,null))),this.chain=[new ze(e)],this.viewConditionId=null}adjacentSiblingSelector(){let e=`a${Jr++}`;this.processChain(new ho(new pu(e,this.viewConditionId,null))),this.chain=[new ze(e)],this.viewConditionId=null}followingSiblingSelector(){let e=`f${Jr++}`;this.processChain(new ho(new hu(e,this.viewConditionId,null))),this.chain=[new ze(e)],this.viewConditionId=null}nextSelector(){this.finishChain(),this.pseudoelement=null,this.footnoteContent=!1,this.specificity=0,this.chain=[]}startSelectorRule(){this.isInsideSelectorRule("E_CSS_UNEXPECTED_SELECTOR")||(this.state=1,this.elementStyle={},this.pseudoelement=null,this.specificity=0,this.footnoteContent=!1,this.chain=[],this.invalid=!1)}error(e,n){super.error(e,n),this.state==1&&(this.state=0),this.setInvalid()}startStylesheet(e){super.startStylesheet(e),this.state=0}startRuleBody(){this.finishChain(),super.startRuleBody(),this.state==1&&(this.state=0)}endRule(){super.endRule(),this.insideSelectorRule=0}finishChain(){this.chain&&(this.processChain(this.makeApplyRuleAction(this.specificity)),this.chain=null,this.pseudoelement=null,this.viewConditionId=null,this.footnoteContent=!1,this.specificity=0)}makeApplyRuleAction(e){let n=this.regionId;return this.footnoteContent&&(n?n="xxx-bogus-xxx":n="footnote"),new Es(this.elementStyle,e,this.pseudoelement,n,this.viewConditionId)}special(e,n){let s;this.condition?s=new oi(n,0,this.condition):s=new M(n,0),Yh(this.elementStyle,e).push(s)}property(e,n,s){this.validatorSet.validatePropertyAndHandleShorthand(e,n,s,this)}invalidPropertyValue(e,n){this.report(`E_INVALID_PROPERTY_VALUE ${e}: ${n.toString()}`)}unknownProperty(e,n){this.report(`E_INVALID_PROPERTY ${e}: ${n.toString()}`)}simpleProperty(e,n,s){e=="display"&&(n===x.oeb_page_head||n===x.oeb_page_foot)&&(this.simpleProperty("flow-options",new q([x.exclusive,x._static]),s),this.simpleProperty("flow-into",n,s),n=x.block),Xe("SIMPLE_PROPERTY").forEach(c=>{let p=c({name:e,value:n,important:s});e=p.name,n=p.value,s=p.important});let a=(s?this.getImportantSpecificity():this.getBaseSpecificity())+this.cascade.nextOrder(),l=this.condition?new oi(n,a,this.condition):new M(n,a);en(this.elementStyle,e,l)}finish(){return this.cascade}startFuncWithSelector(e){let n;switch(e){case"is":n=new Ss(this);break;case"not":n=new Eu(this);break;case"where":n=new Su(this);break;case"has":n=new Nu(this);break}n&&(n.startSelectorRule(),this.owner.pushHandler(n))}},aC={"nth-child":nu,"nth-of-type":ii,"nth-last-child":ri,"nth-last-of-type":ai},Jr=0,Ss=class r extends bn{constructor(e){super(e.scope,e.owner,e.condition,e,e.regionId,e.validatorSet,!1);this.parent=e;d(this,"parentChain");d(this,"chains",[]);d(this,"maxSpecificity",0);d(this,"selectorTexts",[]);this.parentChain=e.chain}nextSelector(){this.chain&&this.chains.push(this.chain),this.maxSpecificity=Math.max(this.maxSpecificity,this.specificity),this.chain=[],this.pseudoelement=null,this.viewConditionId=null,this.footnoteContent=!1,this.specificity=0}endFuncWithSelector(){this.chain&&this.chains.push(this.chain),this.chains.length>0?(this.maxSpecificity=Math.max(this.maxSpecificity,this.specificity),this.parentChain.push(this.relational()?new cu(this.selectorTexts):this.positive()?new li(this.chains):new lu(this.chains)),this.increasingSpecificity()&&(this.parent.specificity+=this.maxSpecificity)):this.parentChain.push(new ze("")),this.owner.popHandler()}startRuleBody(){this.reportAndSkip("E_CSS_UNEXPECTED_RULE_BODY")}error(e,n){super.error(e,n),this.chain=null,this.pseudoelement=null,this.viewConditionId=null,this.footnoteContent=!1,this.specificity=0;let s=!1;for(let o=this;o instanceof r;o=o.parent)if(o.forgiving()){s=!0;break}s||this.owner.popHandler()}pushSelectorText(e){this.chain&&this.relational()&&this.selectorTexts.push(e)}positive(){return!0}increasingSpecificity(){return!0}forgiving(){return!0}relational(){return!1}},Eu=class extends Ss{positive(){return!1}forgiving(){return!1}},Su=class extends Ss{increasingSpecificity(){return!1}},Nu=class extends Ss{relational(){return!0}},oa=class extends qt{constructor(t,e){super(t,e,!1)}property(t,e,n){if(this.scope.values[t])this.error(`E_CSS_NAME_REDEFINED ${t}`,this.getCurrentToken());else{let s=t.match(/height|^(top|bottom)$/)?"vh":"vw",o=new rt(this.scope,100,s);this.scope.defineName(t,e.toExpr(this.scope,o))}}},Ns=class extends qt{constructor(e,n,s,o,i,a){super(e,n,!1);this.condition=s;this.elementStyle=o;this.validatorSet=i;this.ruleType=a;d(this,"order");this.order=0}property(e,n,s){s?I.warn("E_IMPORTANT_NOT_ALLOWED"):this.validatorSet.validatePropertyAndHandleShorthand(e,n,s,this)}invalidPropertyValue(e,n){I.warn("E_INVALID_PROPERTY_VALUE",`${e}:`,n.toString())}unknownProperty(e,n){I.warn("E_INVALID_PROPERTY",`${e}:`,n.toString())}simpleProperty(e,n,s){let o=s?this.getImportantSpecificity():this.getBaseSpecificity();o+=this.order,this.order+=Ru;let i=this.condition?new oi(n,o,this.condition):new M(n,o);en(this.elementStyle,e,i)}},vu=class extends jo{constructor(e,n){super(e);this.validatorSet=n;d(this,"elementStyle",{});d(this,"order",0)}property(e,n,s){this.validatorSet.validatePropertyAndHandleShorthand(e,n,s,this)}invalidPropertyValue(e,n){I.warn("E_INVALID_PROPERTY_VALUE",`${e}:`,n.toString())}unknownProperty(e,n){I.warn("E_INVALID_PROPERTY",`${e}:`,n.toString())}simpleProperty(e,n,s){let o=s?kr:Pr;o+=this.order,this.order+=Ru;let i=new M(n,o);en(this.elementStyle,e,i)}};function Iu(r,t){let e=jh(r);e&&e.forEach(n=>{n.matcher.matches()&&t(n.styles)})}function ia(r,t,e){Iu(e,n=>{Co(r,n,t)})}function Qh(r,t,e,n){let s=new vu(r,t),o=new Oe(n,s);try{sh(o,s,e)}catch(i){I.warn(i,"Style attribute parse error:")}return s.elementStyle}function ua(r,t,e){let n=r["writing-mode"];if(n){let s=n.evaluate(t,"writing-mode");if(s&&s!==x.inherit&&s!==x.revert&&s!==x.unset)return s===x.vertical_rl}return e}function da(r,t,e){let n=r.direction;if(n){let s=n.evaluate(t,"direction");if(s&&s!==x.inherit&&s!==x.revert&&s!==x.unset)return s===x.rtl}return e}function pa(r,t,e,n,s){let o={};for(let i in r)xs(i)&&(o[i]=de(r,i));return ia(o,t,r),Vu(r,e,n,(i,a)=>{Co(o,a,t),ia(o,t,a)}),o}function Vu(r,t,e,n){let s=Nt(r,"_regions");if((t||e)&&s){if(e){let o=["footnote"];t?t=t.concat(o):t=o}for(let o of t){let i=s[o];i&&n(o,i)}}}function Co(r,t,e){for(let n in t)if(xs(n)){let s=de(t,n),o=r[n];r[n]=Wc(e,o,s)}}var ha=(r,t,e,n,s)=>{let o=e?n?Zm:Pu:n?Qm:ku;for(let i in r)if(r.hasOwnProperty(i)){let a=r[i];if(!a)continue;let l=o[i],c;if(l){let u=r[l];if(u&&u.priority>a.priority)continue;c=qm[l]?l:i}else c=i;t[c]=s(i,a)}},Tu=class extends jt{constructor(e,n,s){super();this.elementStyles=e;this.styler=n;this.element=s}getVarValue(e){var s,o,i,a,l;let n=(s=this.element)!=null?s:this.styler.root;if((o=this.elementStyles)!=null&&o.length){for(let c of this.elementStyles){let u=(i=c[e])==null?void 0:i.value;if(u)return u}this.element&&(n=this.element.parentElement)}for(;n;n=n.parentElement){let c=(l=(a=this.styler.getStyle(n,!1))==null?void 0:a[e])==null?void 0:l.value;if(c)return c}return null}visitFunc(e){if(e.name!=="var")return super.visitFunc(e);let n=e.values[0]instanceof Be&&e.values[0].name;if(!n||!bt(n))return this.error=!0,O;let s=this.getVarValue(n);return s||(e.values.length<2?(this.error=!0,O):e.values.length===2?e.values[1]:new ge(e.values.slice(1)))}},ra=class extends jt{constructor(e,n,s,o){super();this.context=e;this.resolveViewportUnit=n;this.percentRef=s;this.vertical=o}visitFunc(e){let n=super.visitFunc(e);if(e.name!=="calc")return n;let s=n.toString().replace(/^calc\b/,"-epubx-expr");if(/\d(%|em|ex|cap|ch|ic|lh|p?v[whbi]|p?vmin|p?vmax)\W|\Wvar\(\s*--/i.test(s))return n;let o=Zt(this.context.rootScope,new Oe(s,null),"");if(o instanceof F)try{let i=o.expr.evaluate(this.context);typeof i=="number"&&(n=new P(i,"px"))}catch(i){I.warn(i)}return n}visitNumeric(e){return this.resolveViewportUnit&&(kl(e.unit)||Vp(e.unit))?new P(e.num*this.context.queryUnitSize(e.unit,!1,this.vertical),"px"):typeof this.percentRef=="number"&&e.unit==="%"?new P(e.num*this.percentRef/100,"px"):e}};function ui(r,t,e,n,s){try{if(t instanceof F)return t.expr instanceof oe&&(t.expr.str.startsWith("named-string-")||t.expr.str.startsWith("running-element-"))?t:oh(r,t.expr,e);if(t instanceof P||t instanceof Pt||t instanceof q||t instanceof ge)return t.visit(new ra(r,!0,n,s))}catch(o){return I.warn(o),O}return t}var Jh={first:!1,forceEnd:!1,allowEnd:!1,last:!1};function ef(r){let t=r instanceof Se?r:typeof r=="string"?L(r):x.none;if(t===x.none)return Jh;let e=t instanceof q?t.values:[t],n=Object.create(Jh);for(let s of e)if(s instanceof Be)switch(s.name){case"first":n.first=!0;break;case"force-end":n.forceEnd=!0,n.allowEnd=!1;break;case"allow-end":n.forceEnd=!1,n.allowEnd=!0;break;case"last":n.last=!0;break}return n}function tf(r){return!r.first&&!r.last&&!r.forceEnd&&!r.allowEnd}var lC={trimStart:!1,spaceFirst:!1,trimEnd:!1,allowEnd:!1,trimAdjacent:!1},nf={trimStart:!1,spaceFirst:!1,trimEnd:!1,allowEnd:!0,trimAdjacent:!0},sf={trimStart:!0,spaceFirst:!1,trimEnd:!0,allowEnd:!1,trimAdjacent:!0};function of(r){let t=r instanceof Se?r:typeof r=="string"?L(r):x.normal;if(t===x.normal)return nf;if(t===x.auto)return sf;let e=t instanceof q?t.values:[t],n=Object.create(nf);for(let s of e)if(s instanceof Be)switch(s.name){case"trim-both":case"trim-auto":return sf;case"space-all":return lC;case"trim-start":n.trimStart=!0,n.spaceFirst=!1;break;case"space-start":n.trimStart=!1,n.spaceFirst=!1;break;case"space-first":n.trimStart=!1,n.spaceFirst=!0;break;case"trim-end":n.trimEnd=!0,n.allowEnd=!1;break;case"space-end":n.trimEnd=!1,n.allowEnd=!1;break;case"allow-end":n.trimEnd=!1,n.allowEnd=!0;break;case"trim-adjacent":n.trimAdjacent=!0;break;case"space-adjacent":n.trimAdjacent=!1;break}return n}var Fu={ideographAlpha:!1,ideographNumeric:!1},cC={ideographAlpha:!0,ideographNumeric:!0};function rf(r){let t=r instanceof Se?r:typeof r=="string"?L(r):x.normal;if(t===x.normal||t===x.auto)return cC;if(t===x.none)return Fu;let e=t instanceof q?t.values:[t],n=Object.create(Fu);for(let s of e)if(s instanceof Be)switch(s.name){case"no-autospace":return Fu;case"ideograph-alpha":n.ideographAlpha=!0;break;case"ideograph-numeric":n.ideographNumeric=!0;break}return n}function af(r,t){return!r.ideographAlpha&&!r.ideographNumeric&&!t.trimStart&&!t.spaceFirst&&!t.trimEnd&&!t.allowEnd&&!t.trimAdjacent}function lf(r){return r?(r=r.toLowerCase(),/^zh\b.*-(hant|tw|hk)\b/.test(r)?"zh-hant":/^zh\b/.test(r)?"zh-hans":/^ja\b/.test(r)?"ja":/^ko\b/.test(r)?"ko":r):null}var Bu=class{getPolyfilledInheritedProps(){return["hanging-punctuation","text-autospace","text-spacing-trim"]}preprocessSingleDocument(t){t.body&&this.preprocessForTextSpacing(t.body)}preprocessForTextSpacing(t){var n;let e=t.ownerDocument.createNodeIterator(t,NodeFilter.SHOW_TEXT);for(let s=e.nextNode();s;s=e.nextNode()){if(s.parentElement.namespaceURI!=="http://www.w3.org/1999/xhtml"||((n=s.parentElement.dataset)==null?void 0:n.mathTypeset)==="true")continue;let o=s.textContent.replace(/(?![()\[\]{}])[\p{Ps}\p{Pe}\p{Pf}\p{Pi}、。,.:;、。\u3000]\p{M}*(?=\P{M})|.(?=(?![()\[\]{}])[\p{Ps}\p{Pe}\p{Pf}\p{Pi}、。,.:;、。\u3000])|(?!\p{P})[\p{sc=Han}\u3041-\u30FF\u31C0-\u31FF]\p{M}*(?=(?![\p{sc=Han}\u3041-\u30FF\u31C0-\u31FF\uFF01-\uFF60])[\p{L}\p{Nd}])|(?![\p{sc=Han}\u3041-\u30FF\u31C0-\u31FF\uFF01-\uFF60])[\p{L}\p{Nd}]\p{M}*(?=(?!\p{P})[\p{sc=Han}\u3041-\u30FF\u31C0-\u31FF])/gsu,"$&\0").split("\0");if(o.length>1){let i=o.length-1;for(let a=0;a<i;a++)s.parentNode.insertBefore(document.createTextNode(o[a]),s);s.textContent=o[i]}}}processGeneratedContent(t,e,n,s,o,i){o=lf(o);let a=rf(e),l=of(n),c=ef(s);if(tf(c)&&af(a,l))return;this.preprocessForTextSpacing(t);let u=t.style.whiteSpace;(i?t.offsetHeight:t.offsetWidth)===0&&(t.style.whiteSpace="pre");let p=t.ownerDocument.createNodeIterator(t,NodeFilter.SHOW_TEXT),h=null,f=null;for(let g=p.nextNode();g;g=f){f=p.nextNode();let m=!h,E=!h||/\n$/.test(h.textContent),C=!f||/^\n/.test(f.textContent),b=!f;this.processTextSpacing(g,m||E,m,E,C,b,h,f,a,l,c,o,i),h=g}t.style.whiteSpace=u}postLayoutBlock(t,e){var p,h,f,g,m,E,C;let n=!t||t.fragmentIndex===1&&i(),s=n||a();function o(b){var w;if((b==null?void 0:b.nodeType)!==1)return!1;let y=b;if(y.hasAttribute(Mt))return!0;let{position:N,float:S}=(w=y.style)!=null?w:{};return N==="absolute"||N==="fixed"||S&&S!=="none"}function i(){let b=e[0];for(let y=b;;y=y.parent)if(!y||!y.inline){if((y==null?void 0:y.fragmentIndex)!==1)return!1;break}if(!b.inline)return!0;for(let y=b.viewNode.previousSibling;y;y=y.previousSibling)if(!he(y,b.whitespace)&&!o(y))return!1;return!0}function a(){var N,S;let b=e[0],y;for(;b&&b.inline&&(y=(N=b.viewNode)==null?void 0:N.previousSibling,!(y&&(y.nodeType===3&&/^[ \t\r\n\f]*$/.test(y.textContent)&&b.whitespace!==Ze.PRESERVE&&(y=y.previousSibling),y)));)b=b.parent;for(;y;){if(y.nodeType===1){if(y.localName==="br")return!0;let w=(S=y.style)==null?void 0:S.display;if(w&&w!=="inline")return!/^(inline|ruby)\b/.test(w)}else if(y.nodeType===3){if(b.whitespace===Ze.PRESERVE){if(/\n$/.test(y.textContent))return!0}else if(b.whitespace===Ze.NEWLINE&&/\n[ \t\r\n\f]*$/.test(y.textContent))return!0}y=y.lastChild}return!1}let l=-1;for(let b=0;b<e.length;b++){let y=e[b];if(!y.after&&y.inline&&!y.display&&y.parent&&y.viewNode.parentNode&&y.viewNode.nodeType===Node.TEXT_NODE&&!he(y.viewNode,y.whitespace)){let R=function(B){var z,j,fe;if(((z=B.viewNode)==null?void 0:z.nodeType)===1)return B.viewNode.localName==="br";if(((j=B.viewNode)==null?void 0:j.nodeType)===3){if(B.whitespace===Ze.PRESERVE){if(/\n$/.test(B.viewNode.textContent))return!0}else if(B.whitespace===Ze.NEWLINE&&/\n[ \t\r\n\f]*$/.test(B.viewNode.textContent))return!0;if(((fe=B.viewNode.previousElementSibling)==null?void 0:fe.localName)==="br")return he(B.viewNode,B.whitespace)}return!1},G=function(B){var z,j,fe;if(((z=B.viewNode)==null?void 0:z.nodeType)===1)return B.viewNode.localName==="br";if(((j=B.viewNode)==null?void 0:j.nodeType)===3){if(B.whitespace===Ze.PRESERVE){if(/^\n/.test(B.viewNode.textContent))return!0}else if(B.whitespace===Ze.NEWLINE&&/^[ \t\r\n\f]*\n/.test(B.viewNode.textContent))return!0;if(((fe=B.viewNode.nextElementSibling)==null?void 0:fe.localName)==="br")return he(B.viewNode,B.whitespace)}return!1};var c=R,u=G;let N=lf((g=(h=(p=y.lang)!=null?p:y.parent.lang)!=null?h:t==null?void 0:t.lang)!=null?g:(f=t==null?void 0:t.parent)==null?void 0:f.lang),S=rf(y.inheritedProps["text-autospace"]),w=of(y.inheritedProps["text-spacing-trim"]),A=ef(y.inheritedProps["hanging-punctuation"]);if(tf(A)&&af(S,w)||/\b(flex|grid)\b/.test(y.parent.display))continue;l<0&&(l=b);let V=null,_=null,Ee=b===l,Q=b===l&&n,re=b===l&&s,Te=!1,Ge=!1;for(let B=b-1;B>=0;B--){let z=e[B];if(R(z)){re=!0;break}if(!z.display&&z.viewNode.nodeType===Node.TEXT_NODE&&z.viewNode.textContent.length>0){V=z.viewNode;break}if(z.display&&!/^(inline|ruby)\b/.test(z.display)||((m=z.viewNode)==null?void 0:m.nodeType)===1&&(z.viewNode.localName==="br"||$t[z.viewNode.localName]))break;B===0&&(Ee=!0,n&&(Q=!0,re=!0))}for(let B=b+1;B<e.length;B++){let z=e[B];if(G(z)){Te=!0;break}if(z.viewNode!==y.viewNode&&!z.display&&z.viewNode.nodeType===Node.TEXT_NODE&&z.viewNode.textContent.length>0){_=z.viewNode;break}if(z.display&&!/^(inline|ruby)\b/.test(z.display)||((E=z.viewNode)==null?void 0:E.nodeType)===1&&(z.viewNode.localName==="br"||$t[z.viewNode.localName])){B===e.length-1&&o(z.viewNode)&&(Ge=!0);break}if(B===e.length-1){Te=!0,Ge=!0;for(let j=z.viewNode.nextSibling;j;j=j.nextSibling)if(!o(j)){Ge=!1;break}}}if(((C=y.parent)==null?void 0:C.display)==="inline-block"){if(!Q){let B=y.parent.viewNode.firstChild;for(;he(B,y.whitespace);)B=B.nextSibling;y.viewNode===B&&(Q=!0)}if(!Ge){let B=y.parent.viewNode.lastChild;for(;he(B,y.whitespace);)B=B.previousSibling;y.viewNode===B&&(Ge=!0)}}this.processTextSpacing(y.viewNode,Ee,Q,re,Te,Ge,V,_,S,w,A,N,y.vertical)}}}processTextSpacing(t,e,n,s,o,i,a,l,c,u,p,h,f){let g=t.textContent,m=t.ownerDocument,E,C,b;function y(){if(e)return!0;if(!a)return!1;E||(E=m.createRange(),E.selectNode(t));let R=E.getClientRects()[0];C||(C=m.createRange(),C.selectNode(a));let G=C.getClientRects(),B=G[G.length-1];return!R||!B?!1:f?R.top<B.top+B.height-R.width||R.left+R.width<B.left+R.width/10||R.left>B.left+B.width-R.width/10:R.left<B.left+B.width-R.height||R.top>B.top+B.height-R.height/10||R.top+R.height<B.top+R.height/10}function N(){if(!l)return!1;E||(E=m.createRange(),E.selectNode(t));let R=E.getClientRects()[0];b||(b=m.createRange(),b.selectNode(l));let G=b.getClientRects()[0];return!R||!G?!1:f?R.top+R.height>G.top+R.width||R.left>G.left+G.width-R.width/10||R.left+R.width<G.left+R.width/10:R.left+R.width>G.left+R.height||R.top+R.height<G.top+R.height/10||R.top>G.top+G.height-R.height/10}let S=!1,w=!1,A=!1,V=!1,_;if(n&&p.first&&/^[\p{Ps}\p{Pf}\p{Pi}'"\u3000]\p{M}*$/u.test(g)?(_="viv-ts-open",S=!0,w=!0):i&&p.last&&/^[\p{Pe}\p{Pf}\p{Pi}'"]\p{M}*$/u.test(g)?(_="viv-ts-close",S=!0,A=!0):(p.forceEnd||p.allowEnd)&&/^[、。,.、。]\p{M}*$/u.test(g)?(_="viv-ts-close",S=!0,V=!0):(u.trimStart||u.spaceFirst||u.trimAdjacent)&&/^[‘“〝([{⦅〈〈《「『【〔〖〘〚]\p{M}*$/u.test(g)?(_="viv-ts-open",S=!0):(u.trimEnd||u.allowEnd||u.trimAdjacent)&&(/^[’”〞〟)]}⦆〉〉》」』】〕〗〙〛]\p{M}*$/u.test(g)||h==="zh-hans"&&/^[:;]\p{M}*$/u.test(g)||h!=="zh-hant"&&/^[、。,.]\p{M}*$/u.test(g))&&(_="viv-ts-close",S=!0),S){let B=function(fe){let To=parseFloat(m.defaultView.getComputedStyle(fe).fontSize)*.7;return(f?fe.offsetHeight:fe.offsetWidth)>To},j=function(){return f?R.offsetLeft:R.offsetTop};var Te=B,Ge=j;if(t.parentElement.localName==="viv-ts-inner")return;let R=m.createElement(_),G=m.createElement("viv-ts-inner");R.appendChild(G),t.parentNode.insertBefore(R,t),G.appendChild(t);let z=B(G);if(z||w||A||V){if(_==="viv-ts-open"){if(w)R.className="viv-hang-first";else if(n||s)u.trimStart?R.className="viv-ts-trim":R.className="viv-ts-space";else if(!(u.trimStart||u.spaceFirst)&&y())R.className="viv-ts-space";else if(u.trimAdjacent&&a&&/[\p{Ps}\p{Pi}\p{Pe}\p{Pf}\u00B7\u2027\u30FB\u3000:;、。,.]\p{M}*$/u.test(a.textContent)&&(!/[\p{Pe}\p{Pf}]\p{M}*$/u.test(a.textContent)||a.parentElement.localName==="viv-ts-inner"&&B(a.parentElement)))R.className="viv-ts-trim";else if((u.trimStart||u.spaceFirst)&&y()){let fe=j();R.className="viv-ts-auto",fe===j()&&!y()&&(R.className="viv-ts-trim")}}else if(_==="viv-ts-close"){if(A)R.className=z?"viv-hang-last":"viv-hang-last viv-hang-hw";else if(i||o){let fe=j();V?(R.className=z?p.allowEnd&&u.allowEnd?"viv-ts-auto":"viv-hang-end":"viv-hang-end viv-hang-hw",p.allowEnd&&fe===j()&&(u.trimEnd?R.className="viv-ts-trim":u.allowEnd?(R.className="viv-hang-end",fe===j()&&(R.className="")):R.className="viv-ts-space")):u.trimEnd?R.className="viv-ts-trim":u.allowEnd?(R.className="viv-ts-auto",fe===j()&&(R.className="")):R.className="viv-ts-space"}else if(l&&/^[\p{Pe}\p{Pf}\u00B7\u2027\u30FB\u3000:;、。,.]/u.test(l.textContent))z&&u.trimAdjacent&&(R.className="viv-ts-trim");else if(V){let fe=N(),qn=fe&&p.allowEnd;qn||(R.className=z?"viv-hang-end":"viv-hang-end viv-hang-hw"),z?qn&&u.trimEnd?R.className="viv-ts-auto":!qn&&!N()?R.className="":!fe&&p.allowEnd&&(u.trimEnd?(R.className="viv-ts-auto",N()||(R.className="viv-hang-end")):(R.className="viv-ts-space",N()||(u.allowEnd?(R.className="viv-ts-auto",N()||(R.className="viv-hang-end")):R.className="viv-hang-end"))):!fe&&!N()&&(R.className="")}else if(u.trimEnd||u.allowEnd)if(N())u.allowEnd?R.className="viv-ts-space":R.className="viv-ts-auto";else{let fe=j();R.className="viv-ts-auto",fe===j()&&(R.className="")}}}}let Ee=!1;function Q(R){var B;let G=(B=R==null?void 0:R.ownerDocument.defaultView)==null?void 0:B.getComputedStyle(R);return!!G&&(G.textOrientation==="upright"||G.textCombineUpright==="all"||G["-webkit-text-combine"]==="horizontal")}function re(R,G){if(R.nodeType===1){let j=m.defaultView.getComputedStyle(R);if(parseFloat(j.marginInlineEnd)||parseFloat(j.borderInlineEndWidth)||parseFloat(j.paddingInlineEnd))return!0}let B=R.parentElement;if(B&&!B.contains(G))return re(B,G);if(G.nodeType===1){let j=m.defaultView.getComputedStyle(G);if(parseFloat(j.marginInlineStart)||parseFloat(j.borderInlineStartWidth)||parseFloat(j.paddingInlineStart))return!0}let z=G.parentElement;return z&&!z.contains(R)?re(R,z):!1}(c.ideographAlpha||c.ideographNumeric)&&(a&&/^(?!\p{P})[\p{sc=Han}\u3041-\u30FF\u31C0-\u31FF]/u.test(g)&&(c.ideographAlpha&&/(?![\p{sc=Han}\u3041-\u30FF\u31C0-\u31FF\uFF01-\uFF60])\p{L}\p{M}*$/u.test(a.textContent)||c.ideographNumeric&&/(?![\uFF01-\uFF60])\p{Nd}\p{M}*$/u.test(a.textContent))&&!(f&&Q(a.parentElement))&&!re(a,t)&&(t.parentNode.insertBefore(m.createElement("viv-ts-thin-sp"),t),Ee=!0),l&&/(?!\p{P})[\p{sc=Han}\u3041-\u30FF\u31C0-\u31FF]\p{M}*$/u.test(g)&&(c.ideographAlpha&&/^(?![\p{sc=Han}\u3041-\u30FF\u31C0-\u31FF\uFF01-\uFF60])\p{L}/u.test(l.textContent)||c.ideographNumeric&&/^(?![\uFF01-\uFF60])\p{Nd}/u.test(l.textContent))&&!(f&&Q(l.parentElement))&&!re(t,l)&&(t.parentNode.insertBefore(m.createElement("viv-ts-thin-sp"),t.nextSibling),Ee=!0))}registerHooks(){_e("POLYFILLED_INHERITED_PROPS",this.getPolyfilledInheritedProps.bind(this)),_e("PREPROCESS_SINGLE_DOCUMENT",this.preprocessSingleDocument.bind(this)),_e("POST_LAYOUT_BLOCK",this.postLayoutBlock.bind(this),!0)}},Ou=new Bu;Ou.registerHooks();function cf(r){Ou.preprocessForTextSpacing(r)}function uf(r,t,e,n,s,o){Ou.processGeneratedContent(r,t,e,n,s,o)}var bo=new DOMParser().parseFromString('<root xmlns="http://www.pyroxy.com/ns/shadow"/>',"text/xml"),pf=["footnote-marker","first-5-lines","first-4-lines","first-3-lines","first-2-lines","first-line","first-letter","before","","after"],fa="data-adapt-pseudo";function vs(r){return r.getAttribute(fa)||""}function pi(r,t){r.setAttribute(fa,t)}var di=class{constructor(t,e,n,s,o){this.element=t;this.style=e;this.styler=n;this.context=s;this.exprContentListener=o;d(this,"contentProcessed",{})}getStyle(t,e){let n=vs(t);this.styler&&n&&n.match(/after$/)&&(this.style=this.styler.getStyle(this.element,!0),this.styler=null);let o=Nt(this.style,"_pseudos")[n]||{};if(n.match(/^first-/)&&!o["x-first-pseudo"]){let i=1,a;n=="first-letter"?i=0:(a=n.match(/^first-([0-9]+)-lines$/))!=null&&(i=a[1]-0),o["x-first-pseudo"]=new M(new ct(i),0)}return o}processContent(t,e,n){let s=vs(t);if(!this.contentProcessed[s]){this.contentProcessed[s]=!0;let o=e.content;o&&St(o)&&(o.visit(new cn(t,this.context,o,this.exprContentListener)),cf(t))}}};var fy=Ko.isInstanceOfAfterIfContinuesLayoutConstraint,gf=zn.registerFragmentIndex,gy=zn.clearFragmentIndices,ga=class{constructor(t,e){this.sourceNode=t;this.styler=e}createElement(t,e){let s=e.viewNode.ownerDocument.createElement("div"),o=new ws(t,s,e),i=o.getColumn().pageBreakType;return o.getColumn().pageBreakType=null,o.layout(this.createNodePositionForPseudoElement(),!0).thenAsync(()=>{this.styler.contentProcessed["after-if-continues"]=!1,o.getColumn().pageBreakType=i;let a=s.firstChild;return T(a,"display","block"),v(a)})}createNodePositionForPseudoElement(){let t=bo.createElementNS("http://www.w3.org/1999/xhtml","div");pi(t,"after-if-continues");let e=this.createShadowContext(t),s={steps:[{node:t,shadowType:e.type,shadowContext:e,nodeShadow:null,shadowSibling:null}],offsetInNode:0,after:!1,preprocessedTextContent:null};return new pt(s)}createShadowContext(t){return new fs(this.sourceNode,t,null,null,null,At.ShadowType.ROOTED,this.styler)}},Du=class r{constructor(t,e,n){this.nodeContext=t;this.afterIfContinues=e;this.pseudoElementHeight=n;d(this,"flagmentLayoutConstraintType","AfterIfContinue")}allowLayout(t,e,n){return!(e&&!t||t&&t.overflow)}nextCandidate(t){return!1}postLayout(t,e,n,s){}finishBreak(t,e){return this.getRepetitiveElements().affectTo(t)?this.afterIfContinues.createElement(e,this.nodeContext).thenAsync(n=>(this.nodeContext.viewNode.appendChild(n),v(!0))):v(!0)}getRepetitiveElements(){return new Mu(this.nodeContext,this.pseudoElementHeight)}equalsTo(t){return t instanceof r?this.afterIfContinues==t.afterIfContinues:!1}getPriorityOfFinishBreak(){return 9}},Mu=class{constructor(t,e){this.nodeContext=t;this.pseudoElementHeight=e}calculateOffset(t){return this.affectTo(t)?this.pseudoElementHeight:0}calculateMinimumOffset(t){return this.calculateOffset(t)}affectTo(t){if(!t)return!1;let e=t.shadowContext?t.shadowContext.owner:t.sourceNode;if(e===this.nodeContext.sourceNode)return!!t.after;for(let n=e.parentNode;n;n=n.parentNode)if(n===this.nodeContext.sourceNode)return!0;return!1}};function mf(r,t){if(!r||!r.afterIfContinues||r.after||t.isFloatNodeContext(r))return v(r);let e=r.afterIfContinues;return e.createElement(t,r).thenAsync(n=>{let s=dC(r,t,n);return t.fragmentLayoutConstraints.push(new Du(r,e,s)),v(r)})}function zu(r,t){return r.thenAsync(e=>mf(e,t))}function uC(r,t){let e=k("processAfterIfContinuesOfAncestors"),n=r;return e.loop(()=>{if(n!==null){let s=mf(n,t);return n=n.parent,s.thenReturn(!0)}else return v(!1)}).then(()=>{e.finish(!0)}),e.result()}function dC(r,t,e){let n=r.viewNode;n.appendChild(e);let s=ti(e,t,r.vertical);return n.removeChild(e),s}var ma=class{constructor(t){this.constraints=t}allowLayout(t){return this.constraints.every(e=>e.allowLayout(t))}},hi=class extends ms{constructor(e,n){super();this.checkPoints=e;this.penalty=n;d(this,"alreadyEvaluated",!1);d(this,"breakNodeContext",null)}findAcceptableBreak(e,n){return n<this.getMinBreakPenalty()?null:(this.alreadyEvaluated||(this.breakNodeContext=e.findBoxBreakPosition(this,n>0),this.alreadyEvaluated=!!this.breakNodeContext||n>0||!!e.pseudoParent),this.breakNodeContext)}getMinBreakPenalty(){return this.penalty}getNodeContext(){return this.alreadyEvaluated?this.breakNodeContext:this.checkPoints[this.checkPoints.length-1]}};var Ts=class extends ro{constructor(e,n,s,o,i){super(e);this.layoutContext=n;this.clientLayout=s;this.layoutConstraint=o;this.pageFloatLayoutContext=i;d(this,"last");d(this,"viewDocument");d(this,"flowRootFormattingContext",null);d(this,"isFloat",!1);d(this,"isFootnote",!1);d(this,"startEdge",0);d(this,"endEdge",0);d(this,"beforeEdge",0);d(this,"afterEdge",0);d(this,"footnoteEdge",0);d(this,"box",null);d(this,"chunkPositions",null);d(this,"bands",null);d(this,"overflown",!1);d(this,"breakPositions",null);d(this,"pageBreakType",null);d(this,"forceNonfitting",!0);d(this,"leftFloatEdge",0);d(this,"rightFloatEdge",0);d(this,"bottommostFloatTop",0);d(this,"stopAtOverflow",!0);d(this,"lastAfterPosition",null);d(this,"fragmentLayoutConstraints",[]);d(this,"pseudoParent",null);d(this,"nodeContextOverflowingDueToRepetitiveElements",null);d(this,"blockDistanceToBlockEndFloats",NaN);d(this,"breakAtTheEdgeBeforeFloat",null);this.last=e.lastChild,this.viewDocument=e.ownerDocument,i.setContainer(this)}getTopEdge(){return this.vertical?this.rtl?this.endEdge:this.startEdge:this.beforeEdge}getBottomEdge(){return this.vertical?this.rtl?this.startEdge:this.endEdge:this.afterEdge}getLeftEdge(){return this.vertical?this.afterEdge:this.rtl?this.endEdge:this.startEdge}getRightEdge(){return this.vertical?this.beforeEdge:this.rtl?this.startEdge:this.endEdge}isFloatNodeContext(e){return!!e.floatSide&&(!this.isFloat||!!e.parent)}stopByOverflow(e){return this.stopAtOverflow&&!!e&&e.overflow}isOverflown(e){return this.vertical?e<this.footnoteEdge:e>this.footnoteEdge}getExclusions(){let e=this.pageFloatLayoutContext.getFloatFragmentExclusions();return this.exclusions.concat(e)}openAllViews(e){let n=k("openAllViews"),s=e.steps;this.layoutContext.setViewRoot(this.element,this.isFootnote);let o=s.length-1,i=null;return n.loop(()=>{for(;o>=0;){let a=i,l=s[o];if(i=ao(l,a),o===s.length-1&&!i.formattingContext&&(i.formattingContext=this.flowRootFormattingContext),o==0&&(i.offsetInNode=this.calculateOffsetInNodeForNodeContext(e),i.after=e.after,i.preprocessedTextContent=e.preprocessedTextContent,i.after))break;let c=this.layoutContext.setCurrent(i,o==0&&i.offsetInNode==0);if(o--,c.isPending())return c}return v(!1)}).then(()=>{n.finish(i)}),n.result()}calculateOffsetInNodeForNodeContext(e){return e.preprocessedTextContent?Eh(e.preprocessedTextContent,e.offsetInNode):e.offsetInNode}maybePeelOff(e,n){var s,o;if(e.firstPseudo&&e.inline&&!e.after&&e.firstPseudo.count==0&&e.viewNode.nodeType!=1){let i=e.viewNode.textContent,a=i.match(Lo),l=a?a[0].length:0;if(!a&&((s=e.sourceNode)==null?void 0:s.nodeType)===3&&((o=e.sourceNode.nextSibling)==null?void 0:o.nodeType)===3&&i===e.sourceNode.textContent){let c=i+e.sourceNode.nextSibling.textContent,u=c.match(Lo);if(u){let p=u[0];l=p.length,e.sourceNode.textContent=p,e.viewNode.textContent=p,e.sourceNode.nextSibling.textContent=c.substr(l)}}return this.layoutContext.peelOff(e,l)}return v(e)}buildViewToNextBlockEdge(e,n){let s=!1,o=k("buildViewToNextBlockEdge");return o.loopWithFrame(i=>{e.viewNode&&!hn(e)&&n.push(e.copy()),this.maybePeelOff(e,0).then(a=>{let l=a;l!==e&&(e=l,hn(e)||n.push(e.copy())),this.nextInTree(e).then(c=>{if(e=c,!e){i.breakLoop();return}(s||!this.layoutConstraint.allowLayout(e))&&(s=!0,e=e.modify(),e.overflow=!0),this.isFloatNodeContext(e)&&(Dn(e.floatReference)||e.floatSide==="footnote")?this.layoutFloatOrFootnote(e).then(u=>{if(e=u,this.pageFloatLayoutContext.isInvalidated()&&(e=null),!e){i.breakLoop();return}i.continueLoop()}):e.inline?i.continueLoop():i.breakLoop()})})}).then(()=>{o.finish(e)}),o.result()}nextInTree(e,n){let s=this.layoutContext.nextInTree(e,n);return zu(s,this)}buildDeepElementView(e){if(!e.viewNode)return v(e);let n=[],s=e.sourceNode,o=k("buildDeepElementView");return o.loopWithFrame(i=>{e.viewNode&&e.inline&&!hn(e)?n.push(e.copy()):(n.length>0&&this.postLayoutBlock(e,n),n=[]),this.maybePeelOff(e,0).then(a=>{let l=a;if(l!==e){let c=l;for(;c&&c.sourceNode!=s;)c=c.parent;if(c==null){e=l,i.breakLoop();return}hn(l)||n.push(l.copy())}this.nextInTree(l).then(c=>{e=c,!e||e.sourceNode==s?i.breakLoop():this.layoutConstraint.allowLayout(e)?i.continueLoop():(e=e.modify(),e.overflow=!0,this.stopAtOverflow?i.breakLoop():i.continueLoop())})})}).then(()=>{n.length>0&&this.postLayoutBlock(e,n),o.finish(e)}),o.result()}createFloat(e,n,s,o){let i=this.viewDocument.createElement("div");return this.vertical?(o>=this.height&&(o-=.1),o<1&&(o=0),T(i,"height",`${s}px`),T(i,"width",`${o}px`)):(s>=this.width&&(s-=.1),s<1&&(s=0),T(i,"width",`${s}px`),T(i,"height",`${o}px`)),T(i,"float",n),T(i,"clear",n),this.element.insertBefore(i,e),i}killFloats(){let e=this.element.firstChild;for(;e;){let n=e.nextSibling;if(e.nodeType==1){let s=e,o=s.style.cssFloat;if(o=="left"||o=="right"||o==="none")this.element.removeChild(s);else break}e=n}}createFloats(){let e=this.element.firstChild,n=this.bands,s=this.vertical?this.getTopEdge():this.getLeftEdge(),o=this.vertical?this.getBottomEdge():this.getRightEdge(),i=null;for(let a of n){let l=a.y2-a.y1;a.left=this.createFloat(e,"left",a.x1-s,l),a.right=this.createFloat(e,"right",o-a.x2,l),a.x1<o&&a.x2>s?i=a:i||T(a.right,"float","none")}if(i){let a=n[n.length-1],l=this.vertical?-this.getLeftEdge():this.getBottomEdge();i!==a&&a.y2>=l&&(this.footnoteEdge=this.vertical?-i.y2:i.y2)}}calculateEdge(e,n,s,o){let i;if(e&&pn(e.viewNode))return NaN;if(e&&e.after&&!e.inline&&(i=Mn(e,this.clientLayout,0,this.vertical),!isNaN(i)))return i;e=n[s];let a=o-e.boxOffset;for(;;){if(i=Mn(e,this.clientLayout,a,this.vertical),!isNaN(i))return i;if(a>0){a--;continue}if(s--,s<0)return this.beforeEdge;e=n[s],e.viewNode.nodeType!=1&&(a=e.viewNode.textContent.length)}}parseComputedLength(e){let n=e.match(/^(-?[0-9]*(\.[0-9]*)?)px$/);return n?this.clientLayout.adjustLengthValue(parseFloat(n[0])):0}getComputedMargin(e){let n=this.clientLayout.getElementComputedStyle(e),s=new Ys(0,0,0,0);return n&&(s.left=this.parseComputedLength(n.marginLeft),s.top=this.parseComputedLength(n.marginTop),s.right=this.parseComputedLength(n.marginRight),s.bottom=this.parseComputedLength(n.marginBottom)),s}getComputedPaddingBorder(e){let n=this.clientLayout.getElementComputedStyle(e),s=new Ys(0,0,0,0);return n&&(s.left=this.parseComputedLength(n.borderLeftWidth)+this.parseComputedLength(n.paddingLeft),s.top=this.parseComputedLength(n.borderTopWidth)+this.parseComputedLength(n.paddingTop),s.right=this.parseComputedLength(n.borderRightWidth)+this.parseComputedLength(n.paddingRight),s.bottom=this.parseComputedLength(n.borderBottomWidth)+this.parseComputedLength(n.paddingBottom)),s}getComputedInsets(e){let n=this.clientLayout.getElementComputedStyle(e),s=new Ys(0,0,0,0);if(n){if(n.boxSizing=="border-box")return this.getComputedMargin(e);s.left=this.parseComputedLength(n.marginLeft)+this.parseComputedLength(n.borderLeftWidth)+this.parseComputedLength(n.paddingLeft),s.top=this.parseComputedLength(n.marginTop)+this.parseComputedLength(n.borderTopWidth)+this.parseComputedLength(n.paddingTop),s.right=this.parseComputedLength(n.marginRight)+this.parseComputedLength(n.borderRightWidth)+this.parseComputedLength(n.paddingRight),s.bottom=this.parseComputedLength(n.marginBottom)+this.parseComputedLength(n.borderBottomWidth)+this.parseComputedLength(n.paddingBottom)}return s}setComputedInsets(e,n){let s=this.clientLayout.getElementComputedStyle(e);s&&(n.marginLeft=this.parseComputedLength(s.marginLeft),n.borderLeft=this.parseComputedLength(s.borderLeftWidth),n.paddingLeft=this.parseComputedLength(s.paddingLeft),n.marginTop=this.parseComputedLength(s.marginTop),n.borderTop=this.parseComputedLength(s.borderTopWidth),n.paddingTop=this.parseComputedLength(s.paddingTop),n.marginRight=this.parseComputedLength(s.marginRight),n.borderRight=this.parseComputedLength(s.borderRightWidth),n.paddingRight=this.parseComputedLength(s.paddingRight),n.marginBottom=this.parseComputedLength(s.marginBottom),n.borderBottom=this.parseComputedLength(s.borderBottomWidth),n.paddingBottom=this.parseComputedLength(s.paddingBottom))}setComputedWidthAndHeight(e,n){let s=this.clientLayout.getElementComputedStyle(e);s&&(n.width=this.parseComputedLength(s.width),n.height=this.parseComputedLength(s.height))}layoutUnbreakable(e){return this.buildDeepElementView(e)}layoutFloat(e){let n=k("layoutFloat"),s=e.viewNode,o=Ih(e.floatSide,e.vertical,e.direction);return s.setAttribute("data-vivliostyle-float-box","true"),T(s,"float","none"),T(s,"display","inline-block"),T(s,"vertical-align","top"),this.buildDeepElementView(e).then(i=>{let a=this.clientLayout.getElementClientRect(s),l=this.getComputedMargin(s),c=new He(a.left-l.left,a.top-l.top,a.right+l.right,a.bottom+l.bottom),u=this.rtl?this.endEdge:this.startEdge,p=this.rtl?this.startEdge:this.endEdge,h=e.parent;for(;h&&h.inline;)h=h.parent;if(h){let S=h.viewNode.ownerDocument.createElement("div");S.style.left="0px",S.style.top="0px",this.vertical?(S.style.bottom="0px",S.style.width="1px"):(S.style.right="0px",S.style.height="1px"),h.viewNode.appendChild(S);let w=this.clientLayout.getElementClientRect(S);u=Math.max(this.rtl?this.getEndEdge(w):this.getStartEdge(w),u),p=Math.min(this.rtl?this.getStartEdge(w):this.getEndEdge(w),p),h.viewNode.removeChild(S);let A=this.vertical?c.y2-c.y1:c.x2-c.x1;o=="left"?p=Math.max(p,u+A):u=Math.min(u,p-A),e.firstPseudo||h.viewNode.appendChild(e.viewNode)}let f=new He(u,this.getBoxDir()*this.beforeEdge,p,this.getBoxDir()*this.afterEdge),g=c;this.vertical&&(g=Ks(c));let m=this.getBoxDir();if(g.y1<this.bottommostFloatTop*m){let S=g.y2-g.y1;g.y1=this.bottommostFloatTop*m,g.y2=g.y1+S}Wp(f,this.bands,g,o),this.vertical&&(c=Cr(g));let E=this.getComputedInsets(s);T(s,"width",`${c.x2-c.x1-E.left-E.right}px`),T(s,"height",`${c.y2-c.y1-E.top-E.bottom}px`),T(s,"position","absolute"),e.display,T(s,"display",e.display);let C,b=null;if(h&&(h.containingBlockForAbsolute?b=h:b=h.getContainingBlockForAbsolute()),b){let S=b.viewNode.ownerDocument.createElement("div");S.style.position="absolute",b.vertical?S.style.right="0":S.style.left="0",S.style.top="0",b.viewNode.appendChild(S),C=this.clientLayout.getElementClientRect(S),b.viewNode.removeChild(S)}else C={left:this.getLeftEdge()-this.paddingLeft,right:this.getRightEdge()+this.paddingRight,top:this.getTopEdge()-this.paddingTop};(b?b.vertical:this.vertical)?T(s,"right",`${C.right-c.x2}px`):T(s,"left",`${c.x1-C.left}px`),T(s,"top",`${c.y1-C.top}px`),e.clearSpacer&&(e.clearSpacer.parentNode.removeChild(e.clearSpacer),e.clearSpacer=null);let y=this.vertical?c.x1:c.y2,N=this.vertical?c.x2:c.y1;!this.isOverflown(y)||this.breakPositions.length==0?(this.killFloats(),f=new He(this.getLeftEdge(),this.getTopEdge(),this.getRightEdge(),this.getBottomEdge()),this.vertical&&(f=Ks(f)),Xp(f,this.bands,g,null,o),this.createFloats(),o=="left"?this.leftFloatEdge=y:this.rightFloatEdge=y,this.bottommostFloatTop=N,this.updateMaxReachedAfterEdge(y),n.finish(i)):(e=e.modify(),e.overflow=!0,n.finish(e))}),n.result()}setupFloatArea(e,n,s,o,i,a){let l=this.pageFloatLayoutContext,c=l.getContainer(n),u=e.element;c.element.parentNode.appendChild(u),e.isFloat=!0,e.originX=c.originX,e.originY=c.originY,e.vertical=c.vertical,e.rtl=c.rtl,e.marginLeft=e.marginRight=e.marginTop=e.marginBottom=0,e.borderLeft=e.borderRight=e.borderTop=e.borderBottom=0,e.paddingLeft=e.paddingRight=e.paddingTop=e.paddingBottom=0,e.exclusions=(c.exclusions||[]).concat(),e.forceNonfitting=!l.hasFloatFragments(),e.innerShape=null;let p=c.getPaddingRect();e.setHorizontalPosition(p.x1-c.originX,p.x2-p.x1),e.setVerticalPosition(p.y1-c.originY,p.y2-p.y1),i.adjustPageFloatArea(e,c,this),e.init();let h=!!l.setFloatAreaDimensions(e,n,s,o,!0,!l.hasFloatFragments(),a);return h?(e.killFloats(),e.init()):c.element.parentNode.removeChild(u),h}createPageFloatArea(e,n,s,o,i){let a=this.element.ownerDocument.createElement("div");T(a,"position","absolute");let l=this.pageFloatLayoutContext.getPageFloatLayoutContext(e.floatReference),c=new un(null,ue.COLUMN,null,this.pageFloatLayoutContext.flowName,e.nodePosition,null,null),u=l.getContainer(),p=new Hu(n,a,this.layoutContext.clone(),this.clientLayout,this.layoutConstraint,c,u);return c.setContainer(p),this.setupFloatArea(p,e.floatReference,n,s,o,i)?p:null}layoutSinglePageFloatFragment(e,n,s,o,i,a,l){let c=this.pageFloatLayoutContext;e=(l?l.continuations:[]).concat(e);let p=e[0].float,h=c.getPageFloatPlacementCondition(p,n,s),f=this.createPageFloatArea(p,n,a,i,h),g={floatArea:f,pageFloatFragment:null,newPosition:null};if(!f)return v(g);let m=k("layoutSinglePageFloatFragment"),E=!1,C=0;return m.loopWithFrame(b=>{if(C>=e.length){b.breakLoop();return}let y=e[C],N=new pt(y.nodePosition);f.layout(N,!0).then(S=>{g.newPosition=S,!S||o?(C++,b.continueLoop()):(E=!0,b.breakLoop())})}).then(()=>{if(!E){let b=c.setFloatAreaDimensions(f,p.floatReference,n,a,!1,o,h);if(!b)E=!0;else{let y=i.createPageFloatFragment(e,b,f,!!g.newPosition);c.addPageFloatFragment(y,!0),g.pageFloatFragment=y}}m.finish(g)}),m.result()}layoutPageFloatInner(e,n,s,o){let i=this.pageFloatLayoutContext,a=e.float;i.stashEndFloatFragments(a);function l(u,p){p?i.removePageFloatFragment(p,!0):u&&u.element.parentNode.removeChild(u.element),i.restoreStashedFragments(a.floatReference),i.deferPageFloat(e)}let c=k("layoutPageFloatInner");return this.layoutSinglePageFloatFragment([e],a.floatSide,a.clearSide,!i.hasFloatFragments(),n,s,o).then(u=>{let p=u.floatArea,h=u.pageFloatFragment,f=u.newPosition;h?this.layoutStashedPageFloats(a.floatReference,[o]).then(g=>{if(g){if(i.addPageFloatFragment(h),i.discardStashedFragments(a.floatReference),f){let m=new Jo(a,f.primary);i.deferPageFloat(m)}c.finish(!0)}else l(p,h),c.finish(!1)}):(l(p,h),c.finish(!1))}),c.result()}layoutStashedPageFloats(e,n){let s=this.pageFloatLayoutContext,o=s.getStashedFloatFragments(e),i=[],a=[],l=!1,c=k("layoutStashedPageFloats"),u=0;return c.loopWithFrame(p=>{if(u>=o.length){p.breakLoop();return}let h=o[u];if(n.includes(h)){u++,p.continueLoop();return}let f=new _t().findByFloat(h.continuations[0].float);this.layoutSinglePageFloatFragment(h.continuations,h.floatSide,null,!1,f,null).then(g=>{let m=g.floatArea;m&&i.push(m);let E=g.pageFloatFragment;E?(a.push(E),u++,p.continueLoop()):(l=!0,p.breakLoop())})}).then(()=>{l?(a.forEach(p=>{s.removePageFloatFragment(p,!0)}),i.forEach(p=>{let h=p.element;h&&h.parentNode&&h.parentNode.removeChild(h)})):o.forEach(p=>{let h=p.area.element;h&&h.parentNode&&h.parentNode.removeChild(h)}),c.finish(!l)}),c.result()}setFloatAnchorViewNode(e){let n=e.viewNode.parentNode,s=n.ownerDocument.createElement("span");s.setAttribute(Mt,"1"),e.floatSide==="footnote"&&this.layoutContext.applyPseudoelementStyle(e,"footnote-call",s),n.appendChild(s),n.removeChild(e.viewNode);let o=e.modify();return o.after=!0,o.viewNode=s,o}resolveFloatReferenceFromColumnSpan(e,n,s){let o=k("resolveFloatReferenceFromColumnSpan"),i=this.pageFloatLayoutContext,a=i.getPageFloatLayoutContext(ue.REGION);return i.getContainer().width<a.getContainer().width&&e===ue.COLUMN?n===x.auto?this.buildDeepElementView(s.copy()).then(c=>{let u=c.viewNode,p=no(this.clientLayout,u,["min-content inline size"])["min-content inline size"],h=this.getComputedMargin(u);this.vertical?p+=h.top+h.bottom:p+=h.left+h.right,p>this.width?o.finish(ue.REGION):o.finish(e)}):n===x.all?o.finish(ue.REGION):o.finish(e):o.finish(e),o.result()}layoutPageFloat(e){let n=this.pageFloatLayoutContext,s=new _t().findByNodeContext(e),o,i=n.findPageFloatByNodePosition(e.toNodePosition());return i?o=v(i):o=s.createPageFloat(e,n,this),o.thenAsync(a=>{let l=gs(e,0),c=this.setFloatAnchorViewNode(e),u=s.findPageFloatFragment(a,n),p=new Jo(a,l);if(u&&u.hasFloat(a))return n.registerPageFloatAnchor(a,c.viewNode),v(c);if(n.isForbidden(a)||n.hasPrecedingFloatsDeferredToNext(a))return n.deferPageFloat(p),n.registerPageFloatAnchor(a,c.viewNode),v(c);if(this.nodeContextOverflowingDueToRepetitiveElements)return v(null);{let h=Mn(c,this.clientLayout,0,this.vertical);return this.isOverflown(h)?v(c):this.layoutPageFloatInner(p,s,h,u).thenAsync(f=>f?v(null):(n.registerPageFloatAnchor(a,c.viewNode),v(c)))}})}processLineStyling(e,n,s){let o=k("processLineStyling"),i=s.concat([]);s.splice(0,s.length);let a=0,l=e.firstPseudo;return l.count==0&&(l=l.outer),o.loopWithFrame(c=>{if(!l){c.breakLoop();return}let u=this.findLinePositions(i),p=l.count-a;if(u.length<=p){c.breakLoop();return}let h=this.findAcceptableBreakInside(i,u[p-1],!0);if(h==null){c.breakLoop();return}this.finishBreak(h,!1,!1).then(()=>{a+=p,this.layoutContext.peelOff(h,0).then(f=>{e=f,l=e.firstPseudo,i=[],this.buildViewToNextBlockEdge(e,i).then(g=>{n=g,c.continueLoop()})})})}).then(()=>{Array.prototype.push.apply(s,i),o.finish(n)}),o.result()}isLoneImage(e){return e.length!=2&&this.breakPositions.length>0?!1:e[0].sourceNode==e[1].sourceNode&&$t[e[0].sourceNode.localName]}getTrailingMarginEdgeAdjustment(e){let n=0,s=0;for(let o=e.length-1;o>=0;o--){let i=e[o];if(!i.after||!i.viewNode||i.viewNode.nodeType!=1)break;let a=this.getComputedMargin(i.viewNode),l=this.vertical?-a.left:a.bottom;l>0?n=Math.max(n,l):s=Math.min(s,l)}return n+s}layoutBreakableBlock(e){let n=k("layoutBreakableBlock"),s=[];return this.buildViewToNextBlockEdge(e,s).then(o=>{let i=s.length-1;if(i<0){n.finish(o);return}this.postLayoutBlock(o,s);let a=this.calculateEdge(o,s,i,s[i].boxOffset),l=!1;if(!o||!pn(o.viewNode)){let u=_n(o,this.collectElementsOffset());l=this.isOverflown(a+(this.vertical?-1:1)*u.minimum),this.isOverflown(a+(this.vertical?-1:1)*u.current)&&!this.nodeContextOverflowingDueToRepetitiveElements&&(this.nodeContextOverflowingDueToRepetitiveElements=o)}o==null&&(a+=this.getTrailingMarginEdgeAdjustment(s)),this.updateMaxReachedAfterEdge(a);let c;e.firstPseudo?c=this.processLineStyling(e,o,s):c=v(o),c.then(u=>{s.length>0&&(this.saveBoxBreakPosition(s),l&&!this.isLoneImage(s)&&u&&(u=u.modify(),u.overflow=!0)),n.finish(u)})}),n.result()}postLayoutBlock(e,n){Xe("POST_LAYOUT_BLOCK").forEach(o=>{o(e,n,this)})}findEndOfLine(e,n,s){let o=this.vertical?e-1:e+1,i=0,a=n[0].boxOffset,l=i,c=n.length-1,u=n[c].boxOffset,p;for(;a<u;){p=a+Math.ceil((u-a)/2),l=i;let h=c;for(;l<h;){let g=l+Math.ceil((h-l)/2);n[g].boxOffset>p?h=g-1:l=g}let f=this.calculateEdge(null,n,l,p);if(this.vertical?f<=o:f>=o){for(u=p-1;n[l].boxOffset==p;)l--;c=l}else s&&this.updateMaxReachedAfterEdge(f),a=p,i=l}return{nodeContext:n[l],index:a,checkPointIndex:l}}findAcceptableBreakInside(e,n,s){var l,c;let o=this.findEndOfLine(n,e,!0),i=o.nodeContext,a=i.viewNode;if(a.nodeType!=1&&((l=a.parentElement)==null?void 0:l.localName)!=="viv-ts-inner"){let u=a;i=this.resolveTextNodeBreaker(i).breakTextNode(u,i,o.index,e,o.checkPointIndex,s)}else{let u=Fc(i);if(u){if(((c=this.breakPositions)==null?void 0:c[0])instanceof hi&&(u!=null&&u.viewNode.contains(this.breakPositions[0].checkPoints[0].viewNode)))return null;i=u}}return this.clearOverflownViewNodes(i,!1),i}resolveTextNodeBreaker(e){return Xe("RESOLVE_TEXT_NODE_BREAKER").reduce((s,o)=>o(e)||s,yo.instance)}getRangeBoxes(e,n){let s=[],o=e.ownerDocument.createRange(),i=!1,a=e,l=null,c=!1,u=!0;for(;u;){let p=!0;do{let h=null;a==n&&(n.nodeType===1?u=!(!n.firstChild||i):u=!1);let f=a.nodeType===1?a:null;f?i?i=!1:Kr(f)?p=!c:!f.firstChild||$t[f.localName]||/^r(uby|[bt]c?)$/.test(f.localName)||Dh(this.clientLayout.getElementComputedStyle(f).display)?(p=!c,p?(f.localName==="ruby"&&a.firstChild&&(a=a.firstChild),o.setStartBefore(a),c=!0,l=a):f.localName!=="ruby"&&(l=a),a.contains(n)&&(u=!1)):h=a.firstChild:(c||(a.parentNode==null?u=!1:(o.setStartBefore(a),c=!0)),l=a),h||(h=a.nextSibling,h||(i=!0,h=a.parentNode)),a=h}while(p&&u);if(c){o.setEndAfter(l);let h=this.clientLayout.getRangeClientRects(o);for(let f=0;f<h.length;f++)s.push(h[f]);c=!1}}return s}findLinePositions(e){let o=[],i=this.getRangeBoxes(e[0].viewNode,e[e.length-1].viewNode);i.sort(this.vertical?Ph:wh);let a=0,l=0,c=0,u=0,p=0,h=this.getBoxDir();for(;;){if(p<i.length){let f=i[p],g=1;if(u>0){let m=Math.max(this.getBoxSize(f),1);h*this.getBeforeEdge(f)<h*a?g=h*(this.getAfterEdge(f)-a)/m:h*this.getAfterEdge(f)>h*l?g=h*(l-this.getBeforeEdge(f))/m:g=1}if(u==0||g>=.6||g>=.2&&this.getStartEdge(f)>=c-1){c=this.getEndEdge(f),this.vertical?(a=u==0?f.right:Math.max(a,f.right),l=u==0?f.left:Math.min(l,f.left)):(a=u==0?f.top:Math.min(a,f.top),l=u==0?f.bottom:Math.max(l,f.bottom)),u++,p++;continue}}if(u>0&&(o.push(l),u=0),p>=i.length)break}return o.sort(ji),this.vertical&&o.reverse(),o}calculateClonedPaddingBorder(e){let n=0;for(let s=e;s;s=s.parent)if(!s.inline&&ps(s.viewNode)){let o=this.getComputedPaddingBorder(s.viewNode);n+=s.vertical?-o.left:o.bottom,s.display==="table"&&(n+=(s.vertical?-1:1)*s.blockBorderSpacing)}return n}getOffsetByRepetitiveElements(e){let n;return e?n=e.calculateOffset(this):n=_n(null,this.collectElementsOffset()),n.current}findBoxBreakPosition(e,n){let s=this.element.parentNode,o=this.element.nextSibling;s.removeChild(this.element),s.insertBefore(this.element,o);let i=e.checkPoints,a=i[0];for(;a.parent&&a.inline;)a=a.parent;let l,c;n?(l=1,c=1):(l=Math.max((a.inheritedProps.widows||2)-0,1),c=Math.max((a.inheritedProps.orphans||2)-0,1));let u=this.calculateClonedPaddingBorder(a),p=this.findLinePositions(i),h=this.footnoteEdge-u,f=this.getBoxDir(),g=this.getOffsetByRepetitiveElements(e);h-=f*g;let m=this.findFirstOverflowingEdgeAndCheckPoint(i);isNaN(m.edge)&&(m.edge=f*(1/0));let E=gt(p.length,N=>{let S=p[N];return this.vertical?S<h||S<=m.edge:S>h||S>=m.edge}),C=E<=0;C&&(E=gt(p.length,N=>this.vertical?p[N]<h:p[N]>h));let b=i[i.length-1].viewNode;if((b==null?void 0:b.parentElement.localName)==="viv-ts-inner"&&(b=b.parentElement.parentElement),(E===p.length&&b.nextSibling||E>=p.length-1&&b.parentElement.querySelector(".MJXc-display"))&&(l=0),E=Math.min(p.length-l,E),E<c)return null;h=p[E-1];let y;if(C?y=m.checkPoint:y=this.findAcceptableBreakInside(e.checkPoints,h,n),y){let N=this.getAfterEdgeOfBlockContainer(y);!isNaN(N)&&N<h&&(h=N),this.computedBlockSize=f*(h-this.beforeEdge)+g}return y}getAfterEdgeOfBlockContainer(e){let n=e;do n=n.parent;while(n&&n.inline);return n?(n=n.copy().modify(),n.after=!0,Mn(n,this.clientLayout,0,this.vertical)):NaN}findFirstOverflowingEdgeAndCheckPoint(e){let n=e.findIndex(o=>o.overflow);if(n<0)return{edge:NaN,checkPoint:null};let s=e[n];return{edge:this.calculateEdge(null,e,n,s.boxOffset),checkPoint:s}}findEdgeBreakPosition(e){return this.computedBlockSize=e.computedBlockSize+this.getOffsetByRepetitiveElements(e),e.position}finishBreak(e,n,s){e.formattingContext;let i=new Un().find(e.formattingContext).finishBreak(this,e,n,s);return i||(i=ni.finishBreak(this,e,n,s)),i}findAcceptableBreakPosition(){let e=null,n=null,s=0,o=0;do{s=o,o=Number.MAX_VALUE;for(let i=this.breakPositions.length-1;i>=0&&!n;--i){e=this.breakPositions[i],n=e.findAcceptableBreak(this,s);let a=e.getMinBreakPenalty();a>s&&(o=Math.min(o,a))}}while(o>s&&!n&&this.forceNonfitting);return{breakPosition:n?e:null,nodeContext:n}}doFinishBreak(e,n,s,o){if(this.pageFloatLayoutContext.isInvalidated()||this.pageBreakType||!n)return v(e);let i=k("doFinishBreak"),a=!1;if(!e){if(this.forceNonfitting)return I.warn("Could not find any page breaks?!!"),this.skipTailEdges(n).then(l=>{l?(l=l.modify(),l.overflow=!1,this.finishBreak(l,a,!0).then(()=>{i.finish(l)})):i.finish(l)}),i.result();e=s,a=!0,this.computedBlockSize=o}return this.finishBreak(e,a,!0).then(()=>{i.finish(e)}),i.result()}isBreakable(e){if(e.after)return!0;switch(e.sourceNode.namespaceURI){case"http://www.w3.org/2000/svg":return!1}return!e.flexContainer}zeroIndent(e){let n=e.toString();return n==""||n=="auto"||!!n.match(/^0+(.0*)?[^0-9]/)}checkOverflowAndSaveEdge(e,n){if(!e||pn(e.viewNode))return!1;let s=Mn(e,this.clientLayout,0,this.vertical),o=_n(e,this.collectElementsOffset()),i=this.isOverflown(s+(this.vertical?-1:1)*o.minimum);if(this.isOverflown(s+(this.vertical?-1:1)*o.current)&&!this.nodeContextOverflowingDueToRepetitiveElements)this.nodeContextOverflowingDueToRepetitiveElements=e;else if(n){let a=s+this.getTrailingMarginEdgeAdjustment(n),l=this.footnoteEdge-this.getBoxDir()*o.current;s=this.vertical?Math.min(s,Math.max(a,l)):Math.max(s,Math.min(a,l))}return this.updateMaxReachedAfterEdge(s),i}checkOverflowAndSaveEdgeAndBreakPosition(e,n,s,o){if(!e||pn(e.viewNode))return!1;let i=this.checkOverflowAndSaveEdge(e,n);return(s||!i)&&this.saveEdgeBreakPosition(e,o,i),i}applyClearance(e){if(!e.viewNode.parentNode)return!1;let n=this.getComputedMargin(e.viewNode),s=e.viewNode.ownerDocument.createElement("div");this.vertical?(s.style.bottom="0px",s.style.width="1px",s.style.marginRight=`${n.right}px`):(s.style.right="0px",s.style.height="1px",s.style.marginTop=`${n.top}px`),e.viewNode.parentNode.insertBefore(s,e.viewNode);let o=this.clientLayout.getElementClientRect(s),i=this.getBeforeEdge(o),a=this.getBoxDir(),l=e.clearSide,c=-this.getBoxDir()*(1/0);switch(l==="all"&&(c=this.pageFloatLayoutContext.getPageFloatClearEdge(l,this)),l){case"left":c=a*Math.max(c*a,this.leftFloatEdge*a);break;case"right":c=a*Math.max(c*a,this.rightFloatEdge*a);break;default:c=a*Math.max(c*a,Math.max(this.rightFloatEdge*a,this.leftFloatEdge*a))}if(i*a>=c*a)return e.viewNode.parentNode.removeChild(s),!1;{let u=Math.max(1,(c-i)*a);this.vertical?s.style.width=`${u}px`:s.style.height=`${u}px`,o=this.clientLayout.getElementClientRect(s);let p=this.getAfterEdge(o);if(!e.floatSide)if(this.vertical){let h=p+n.right-c;h>0==n.right>=0&&(h+=n.right),s.style.marginLeft=`${h}px`}else{let h=c-(p+n.top);h>0==n.top>=0&&(h+=n.top),s.style.marginBottom=`${h}px`}return e.clearSpacer=s,!0}}isBFC(e){return!!(Mh(e)||Qt.isInstanceOfRepetitiveElementsOwnerFormattingContext(e))}skipEdges(e,n,s){var E;let o=e.after?(E=e.parent)==null?void 0:E.formattingContext:e.formattingContext;if(o&&!this.isBFC(o))return v(e);let i=k("skipEdges"),a=!s&&n&&e&&e.after,l=s,c=null,u=[],p=[],h=!1;function f(){return!!s||!n&&De(l)&&!g()}function g(){var C;if(!c||e.floatSide)return!1;for(let b=c;b!=null&&b.parent;b=b.parent){let y=b.after?b.viewNode:(C=b.viewNode)==null?void 0:C.previousSibling;for(;y&&(he(y,b.parent.whitespace)||qr(y));)y=y.previousSibling;if(y)return!1}return!0}let m=()=>{e=u[0]||e,e.viewNode.parentNode.removeChild(e.viewNode),this.pageBreakType=l};return i.loopWithFrame(C=>{var b;for(;e;){e.formattingContext;let y=new Un().find(e.formattingContext);do{if(!e.viewNode)break;if(e.inline&&e.viewNode.nodeType!=1){if(he(e.viewNode,e.whitespace))break;if(!e.after){f()?m():this.checkOverflowAndSaveEdgeAndBreakPosition(c,null,!0,l)?(e=(this.stopAtOverflow&&c||e).modify(),e.overflow=!0):(e=e.modify(),e.breakBefore=l),C.breakLoop();return}}if(!e.after){if(e.floatSide&&(this.breakAtTheEdgeBeforeFloat=so(l)?l:null),y&&y.startNonInlineElementNode(e))break;if(e.clearSide&&this.applyClearance(e)&&n&&this.breakPositions.length===0&&this.saveEdgeBreakPosition(e.copy(),l,!1),!e.inline&&!e.repeatOnBreak&&(c?Fc(c):this.breakPositions[this.breakPositions.length-1]instanceof hi)&&this.saveEdgeBreakPosition(e.copy(),l,!1),!this.isBFC(e.formattingContext)||Qt.isInstanceOfRepetitiveElementsOwnerFormattingContext(e.formattingContext)||this.isFloatNodeContext(e)||e.flexContainer||!e.nodeShadow&&!e.sourceNode.firstElementChild&&he(e.sourceNode.firstChild,e.whitespace)){u.push(e.copy()),l=Ve(l,e.breakBefore),f()?m():(this.checkOverflowAndSaveEdgeAndBreakPosition(c,null,!0,l)||!this.layoutConstraint.allowLayout(e))&&(e=(this.stopAtOverflow&&c||e).modify(),e.overflow=!0),C.breakLoop();return}}if(e.viewNode.nodeType!=1)break;let S=e.viewNode.style;if(e.after){e.floatSide&&(l=l!=null?l:this.breakAtTheEdgeBeforeFloat,this.breakAtTheEdgeBeforeFloat=null);let w=e.sourceNode;if(w.localName==="svg"||w.localName==="math"||w.getAttribute("data-math-typeset")==="true"){h=!1,c=e.copy(),p.push(c),l=Ve(null,e.breakAfter),this.checkOverflowAndSaveEdgeAndBreakPosition(c,null,!this.stopAtOverflow,l);break}if(e.inline||y&&y.afterNonInlineElementNode(e,this.stopAtOverflow))break;if(h){if(f()){m(),C.breakLoop();return}u=[],n=!1,a=!1,l=null}h=!1,c=e.copy(),p.push(c),l=Ve(l,e.breakAfter),S&&!(this.zeroIndent(S.paddingBottom)&&this.zeroIndent(S.borderBottomWidth))&&(p=[c])}else{if(u.push(e.copy()),l=Ve(l,e.breakBefore),(e.pageType!=((b=e.parent)==null?void 0:b.pageType)||!De(l))&&!this.layoutConstraint.allowLayout(e)&&(this.checkOverflowAndSaveEdgeAndBreakPosition(c,null,!this.stopAtOverflow,l),e=e.modify(),e.overflow=!0,this.stopAtOverflow)){C.breakLoop();return}let w=e.viewNode.localName;if($t[w]){f()?m():this.checkOverflowAndSaveEdgeAndBreakPosition(c,null,!0,l)&&(e=(this.stopAtOverflow&&c||e).modify(),e.overflow=!0),C.breakLoop();return}S&&!(this.zeroIndent(S.paddingTop)&&this.zeroIndent(S.borderTopWidth))&&(a=!1,p=[]),h=!0}}while(!1);let N=this.nextInTree(e,a);if(N.isPending()){N.then(S=>{e=S,C.continueLoop()});return}else e=N.get()}this.checkOverflowAndSaveEdgeAndBreakPosition(c,p,!this.stopAtOverflow,l)?c&&this.stopAtOverflow&&(e=c.modify(),e.overflow=!0):De(l)&&(this.pageBreakType=l),C.breakLoop()}).then(()=>{c&&(this.lastAfterPosition=c.toNodePosition()),i.finish(e)}),i.result()}skipTailEdges(e){let n=e.copy(),s=k("skipEdges"),o=null,i=!1;return s.loopWithFrame(a=>{for(;e;){do{if(!e.viewNode)break;if(e.inline&&e.viewNode.nodeType!=1){if(he(e.viewNode,e.whitespace))break;if(!e.after){De(o)&&(this.pageBreakType=o),a.breakLoop();return}}if(!e.after&&(this.isFloatNodeContext(e)||e.flexContainer)){o=Ve(o,e.breakBefore),De(o)&&(this.pageBreakType=o),a.breakLoop();return}if(e.viewNode.nodeType!=1)break;let c=e.viewNode.style;if(e.after){if(i){if(De(o)){this.pageBreakType=o,a.breakLoop();return}o=null}i=!1,o=Ve(o,e.breakAfter)}else{o=Ve(o,e.breakBefore);let u=e.viewNode.localName;if($t[u]){De(o)&&(this.pageBreakType=o),a.breakLoop();return}if(c&&!(this.zeroIndent(c.paddingTop)&&this.zeroIndent(c.borderTopWidth))){a.breakLoop();return}}i=!0}while(!1);let l=this.layoutContext.nextInTree(e);if(l.isPending()){l.then(c=>{e=c,a.continueLoop()});return}else e=l.get()}n=null,a.breakLoop()}).then(()=>{s.finish(n)}),s.result()}layoutFloatOrFootnote(e){return Dn(e.floatReference)||e.floatSide==="footnote"?this.layoutPageFloat(e):this.layoutFloat(e)}layoutNext(e,n,s){let o=k("layoutNext");return this.skipEdges(e,n,s||null).then(i=>{if(e=i,!e||this.pageBreakType||this.stopByOverflow(e))o.finish(e);else{let a=e.formattingContext;new Un().find(a).layout(e,this,n).thenFinish(o)}}),o.result()}clearOverflownViewNodes(e,n){if(e)for(let s=e.parent;e;e=s,s=s?s.parent:null){let o=(s||e).formattingContext;new Un().find(o).clearOverflownViewNodes(this,s,e,n),n=!1}}initGeom(){let e=this.element.ownerDocument.createElement("div");e.style.position="absolute",e.style.top=`${this.paddingTop}px`,e.style.right=`${this.paddingRight}px`,e.style.bottom=`${this.paddingBottom}px`,e.style.left=`${this.paddingLeft}px`,this.element.appendChild(e);let n=this.clientLayout.getElementClientRect(e);this.element.removeChild(e);let s=this.originX+this.left+this.getInsetLeft(),o=this.originY+this.top+this.getInsetTop();this.box=new He(s,o,s+this.width,o+this.height),this.startEdge=n?this.vertical?this.rtl?n.bottom:n.top:this.rtl?n.right:n.left:0,this.endEdge=n?this.vertical?this.rtl?n.top:n.bottom:this.rtl?n.left:n.right:0,this.beforeEdge=n?this.vertical?n.right:n.top:0,this.afterEdge=n?this.vertical?n.left:n.bottom:0,this.leftFloatEdge=this.beforeEdge,this.rightFloatEdge=this.beforeEdge,this.bottommostFloatTop=this.beforeEdge,this.footnoteEdge=this.afterEdge,this.bands=_p(this.box,[this.getInnerShape()],this.getExclusions(),8,this.snapHeight,this.vertical),this.createFloats()}init(){this.chunkPositions=[],T(this.element,"width",`${this.width}px`),T(this.element,"height",`${this.height}px`),this.initGeom(),this.computedBlockSize=0,this.overflown=!1,this.pageBreakType=null,this.lastAfterPosition=null}saveEdgeBreakPosition(e,n,s){e.formattingContext;let o=e.copy(),i=new Un().find(e.formattingContext),a=this.calculateClonedPaddingBorder(o),l=i.createEdgeBreakPosition(o,n,s,this.computedBlockSize+a);this.breakPositions.push(l)}saveBoxBreakPosition(e){let n=e[0].breakPenalty;if(n){let o=e[0];for(;o.parent&&o.inline;)o=o.parent;n=o.breakPenalty}let s=new hi(e,n);this.breakPositions.push(s)}updateMaxReachedAfterEdge(e){if(!isNaN(e)){let n=this.getBoxDir()*(e-this.beforeEdge);this.computedBlockSize=Math.max(n,this.computedBlockSize)}}layout(e,n,s){if(this.chunkPositions.push(e),e.primary.after&&(this.lastAfterPosition=e.primary),this.stopAtOverflow&&this.overflown)return v(e);if(this.isFullWithPageFloats())return e.primary.after&&e.primary.steps.length===1?v(null):v(e);let o=k("layout");return this.openAllViews(e.primary).then(i=>{let a=null;if(i.viewNode)a=i.copy();else{let c=u=>{u.nodeContext.viewNode&&(a=u.nodeContext,this.layoutContext.removeEventListener("nextInTree",c))};this.layoutContext.addEventListener("nextInTree",c)}let l=new _u(n,s);l.layout(i,this).then(c=>{this.doFinishBreak(c,l.context.overflownNodeContext,a,l.initialComputedBlockSize).then(u=>{let p=null;this.pseudoParent?p=v(null):p=this.doFinishBreakOfFragmentLayoutConstraints(u),p.then(()=>{if(this.pageFloatLayoutContext.isInvalidated()){o.finish(null);return}if(!u)o.finish(null);else{this.overflown=!0;let h=new pt(u.toNodePosition());o.finish(h)}})})})}),o.result()}isFullWithPageFloats(){return this.pageFloatLayoutContext.isColumnFullWithPageFloats(this)}getMaxBlockSizeOfPageFloats(){return this.pageFloatLayoutContext.getMaxBlockSizeOfPageFloats()}doFinishBreakOfFragmentLayoutConstraints(e){let n=k("doFinishBreakOfFragmentLayoutConstraints"),s=[].concat(this.fragmentLayoutConstraints);s.sort((i,a)=>i.getPriorityOfFinishBreak()-a.getPriorityOfFinishBreak());let o=0;return n.loop(()=>o<s.length?s[o++].finishBreak(e,this).thenReturn(!0):v(!1)).then(()=>{n.finish(!0)}),n.result()}doLayout(e,n,s){let o=k("doLayout"),i=null;return this.breakPositions=[],this.nodeContextOverflowingDueToRepetitiveElements=null,o.loopWithFrame(a=>{for(;e;){let l=!0;if(this.layoutNext(e,n,s||null).then(c=>{if(n=!1,s=null,this.nodeContextOverflowingDueToRepetitiveElements&&this.stopAtOverflow?(this.pageBreakType=null,e=this.nodeContextOverflowingDueToRepetitiveElements,e.overflow=!0):e=c,this.pageFloatLayoutContext.isInvalidated())a.breakLoop();else if(this.pageBreakType)a.breakLoop();else if(e&&this.stopByOverflow(e)){i=e;let u=this.findAcceptableBreakPosition();e=u.nodeContext,u.breakPosition&&u.breakPosition.breakPositionChosen(this),a.breakLoop()}else l?l=!1:a.continueLoop()}),l){l=!1;return}}this.computedBlockSize+=this.getOffsetByRepetitiveElements(),a.breakLoop()}).then(()=>{o.finish({nodeContext:e,overflownNodeContext:i})}),o.result()}redoLayout(){let e=this.chunkPositions,n=this.element.lastChild;for(;n!=this.last;){let l=n.previousSibling;this.element===n.parentNode&&this.layoutContext.isPseudoelement(n)||this.element.removeChild(n),n=l}this.killFloats(),this.init();let s=k("redoLayout"),o=0,i=null,a=!0;return s.loopWithFrame(l=>{if(o<e.length){let c=e[o++];this.layout(c,a).then(u=>{a=!1,u?(i=u,l.breakLoop()):l.continueLoop()});return}l.breakLoop()}).then(()=>{s.finish(i)}),s.result()}saveDistanceToBlockEndFloats(){let e=this.pageFloatLayoutContext.getBlockStartEdgeOfBlockEndFloats();e>0&&isFinite(e)&&(this.blockDistanceToBlockEndFloats=this.getBoxDir()*(e-this.beforeEdge-this.computedBlockSize))}collectElementsOffset(){let e=[];for(let n=this;n;n=n.pseudoParent)n.fragmentLayoutConstraints.forEach(s=>{if(Qt.isInstanceOfRepetitiveElementsOwnerLayoutConstraint(s)){let o=s.getRepetitiveElements();e.push(o)}if(Ko.isInstanceOfAfterIfContinuesLayoutConstraint(s)){let o=s.getRepetitiveElements();e.push(o)}Ot.isInstanceOfTableRowLayoutConstraint(s)&&s.getElementsOffsetsForTableCell(this).forEach(o=>{e.push(o)})});return e}},ws=class{constructor(t,e,n){d(this,"startNodeContexts",[]);d(this,"column");this.column=Object.create(t),this.column.element=e,this.column.layoutContext=t.layoutContext.clone(),this.column.stopAtOverflow=!1,this.column.flowRootFormattingContext=n.formattingContext,this.column.pseudoParent=t;let s=this.column.calculateClonedPaddingBorder(n);this.column.footnoteEdge=this.column.footnoteEdge-s;let o=this;this.column.openAllViews=function(i){return Ts.prototype.openAllViews.call(this,i).thenAsync(a=>(o.startNodeContexts.push(a.copy()),v(a)))}}layout(t,e){return this.column.layout(t,e)}findAcceptableBreakPosition(t){let e=this.column.findAcceptableBreakPosition();if(t){let n=this.startNodeContexts[0].copy(),s=new fn(n,null,n.overflow,0);if(s.findAcceptableBreak(this.column,0),!e.nodeContext)return{breakPosition:s,nodeContext:n}}return e}finishBreak(t,e,n){return this.column.finishBreak(t,e,n)}doFinishBreakOfFragmentLayoutConstraints(t){this.column.doFinishBreakOfFragmentLayoutConstraints(t)}isStartNodeContext(t){let e=this.startNodeContexts[0];return e.viewNode===t.viewNode&&e.after===t.after&&e.offsetInNode===t.offsetInNode}isLastAfterNodeContext(t){return Dt(t.toNodePosition(),this.column.lastAfterPosition)}getColumnElement(){return this.column.element}getColumn(){return this.column}},yo=class{breakTextNode(t,e,n,s,o,i){if(e.after)e.offsetInNode=t.length;else{let a=n-e.boxOffset,l=t.data;l.charCodeAt(a)==173?a=this.breakAfterSoftHyphen(t,l,a,e):a=this.breakAfterOtherCharacter(t,l,a,e),a>0&&(e=this.updateNodeContext(e,a,t))}return e}breakAfterSoftHyphen(t,e,n,s){let i=/[\u0620\u0626\u0628\u062A-\u062E\u0633-\u0647\u0649\u064A\u066E\u066F\u0678-\u0687\u069A-\u06BF\u06C1\u06C2\u06CC\u06CE\u06D0\u06D1\u06FA-\u06FC\u06FF\u0712-\u0714\u071A-\u071D\u071F-\u0727\u0729\u072B\u072D\u072E\u074E-\u0758\u075C-\u076A\u076D-\u0770\u0772\u0775-\u0777\u077A-\u077F\u07CA-\u07EA\u07FA\u0841-\u0845\u0848\u084A-\u0853\u0855\u0860\u0862-\u0865\u0868\u0883-\u0886\u0889-\u088D\u08A0-\u08A9\u08AF\u08B0\u08B3-\u08B8\u08BA-\u08C8\u1807\u180A\u1820-\u1878\u1887-\u18A8\u18AA\u200D\uA840-\uA871\u{10AC0}-\u{10AC4}\u{10AD3}-\u{10AD6}\u{10AD8}-\u{10ADC}\u{10ADE}-\u{10AE0}\u{10AEB}-\u{10AEE}\u{10B80}\u{10B82}\u{10B86}-\u{10B88}\u{10B8A}\u{10B8B}\u{10B8D}\u{10B90}\u{10BAD}\u{10BAE}\u{10D01}-\u{10D21}\u{10D23}\u{10EC3}\u{10EC4}\u{10F30}-\u{10F32}\u{10F34}-\u{10F44}\u{10F51}-\u{10F53}\u{10F70}-\u{10F73}\u{10F76}-\u{10F81}\u{10FB0}\u{10FB2}\u{10FB3}\u{10FB8}\u{10FBB}\u{10FBC}\u{10FBE}\u{10FBF}\u{10FC1}\u{10FC4}\u{10FCA}\u{1E900}-\u{1E943}]\p{Mn}*$/u.test(e.slice(0,n))?"\u200D":"";if(t.replaceData(n,e.length-n,s.breakWord?"":i+ff(s)),i){let a=s.preprocessedTextContent[0][1];s.preprocessedTextContent[0][1]=a.slice(0,n+1)+i+a.slice(n+1)}return n+1}breakAfterOtherCharacter(t,e,n,s){let o=e.charAt(n);n++;let i=e.charAt(n);return t.replaceData(n,e.length-n,!s.breakWord&&El(o)&&El(i)?ff(s):""),n}updateNodeContext(t,e,n){return t=t.modify(),t.offsetInNode+=e,t.breakBefore=null,t}};d(yo,"instance");yo.instance=new yo;function ff(r){return r.hyphenateCharacter||r.parent&&r.parent.hyphenateCharacter||"-"}var _u=class extends Hn{constructor(e,n){super();this.leadingEdge=e;d(this,"breakAfter");d(this,"initialPageBreakType",null);d(this,"initialComputedBlockSize",0);d(this,"initialOverflown",!1);d(this,"context",{overflownNodeContext:null});this.breakAfter=n||null}resolveLayoutMode(e){return new Uu(this.leadingEdge,this.breakAfter,this.context)}prepareLayout(e,n){n.fragmentLayoutConstraints=[],n.pseudoParent||Uh()}clearNodes(e){super.clearNodes(e);let n=e;for(;n;){let s=n.viewNode;s&&Yr(s.parentNode,s),n=n.parent}}saveState(e,n){super.saveState(e,n),this.initialPageBreakType=n.pageBreakType,this.initialComputedBlockSize=n.computedBlockSize,this.initialOverflown=n.overflown}restoreState(e,n){super.restoreState(e,n),n.pageBreakType=this.initialPageBreakType,n.computedBlockSize=this.initialComputedBlockSize,n.overflown=this.initialOverflown}},Uu=class{constructor(t,e,n){this.leadingEdge=t;this.breakAfter=e;this.context=n}doLayout(t,e){let n=k("DefaultLayoutMode.doLayout");return uC(t,e).then(()=>{e.doLayout(t,this.leadingEdge,this.breakAfter).then(s=>{this.context.overflownNodeContext=s.overflownNodeContext,n.finish(s.nodeContext)})}),n.result()}accept(t,e){return e.pageFloatLayoutContext.isInvalidated()||e.pageBreakType||e.fragmentLayoutConstraints.length<=0?!0:e.fragmentLayoutConstraints.every(n=>n.allowLayout(t,this.context.overflownNodeContext,e))}postLayout(t,e,n,s){return s||(s=!n.fragmentLayoutConstraints.some(i=>i.nextCandidate(t))),n.fragmentLayoutConstraints.forEach(o=>{o.postLayout(s,t,e,n)}),s}},Hu=class extends Ts{constructor(e,n,s,o,i,a,l){super(n,s,o,i,a);this.floatSide=e;this.parentContainer=l;d(this,"rootViewNodes",[]);d(this,"floatMargins",[]);d(this,"adjustContentRelativeSize",!0)}openAllViews(e){return super.openAllViews(e).thenAsync(n=>(n&&this.fixFloatSizeAndPosition(n),v(n)))}convertPercentageSizesToPx(e){let n=this.parentContainer.getPaddingRect(),s=n.x2-n.x1,o=n.y2-n.y1;function i(a,l){a.forEach(c=>{let u=Tn(e,c);if(u&&u.charAt(u.length-1)==="%"){let p=parseFloat(u),h=l*p/100;T(e,c,`${h}px`)}})}i(["width","max-width","min-width"],s),i(["height","max-height","min-height"],o),i(["margin-top","margin-right","margin-bottom","margin-left","padding-top","padding-right","padding-bottom","padding-left"],this.vertical?o:s),["margin-top","margin-right","margin-bottom","margin-left"].forEach(a=>{Tn(e,a)==="auto"&&T(e,a,"0")})}fixFloatSizeAndPosition(e){for(;e.parent;)e=e.parent;e.viewNode.nodeType;let n=e.viewNode;if(this.rootViewNodes.push(n),this.adjustContentRelativeSize&&this.convertPercentageSizesToPx(n),this.floatMargins.push(this.getComputedMargin(n)),this.adjustContentRelativeSize){let s=this.floatSide;if(this.parentContainer.vertical){if(s==="block-end"||s==="left"){let i=Tn(n,"height");i!==""&&i!=="auto"&&T(n,"margin-top","auto")}}else if(s==="block-end"||s==="bottom"){let i=Tn(n,"width");i!==""&&i!=="auto"&&T(n,"margin-left","auto")}}}getContentInlineSize(){return Math.max.apply(null,this.rootViewNodes.map((e,n)=>{let s=this.clientLayout.getElementClientRect(e),o=this.floatMargins[n];return this.vertical?o.top+s.height+o.bottom:o.left+s.width+o.right}))}};var Ut=class{constructor(t,e){this.parent=t;this.rootSourceNode=e;d(this,"formattingContextType","RepetitiveElementsOwner");d(this,"isRoot",!1);d(this,"repetitiveElements",null)}getName(){return"Repetitive elements owner formatting context (RepetitiveElementsOwnerFormattingContext)"}isFirstTime(t,e){return e}getParent(){return this.parent}getRepetitiveElements(){return this.repetitiveElements}getRootViewNode(t){let e=this.getRootNodeContext(t);return e?e.viewNode:null}getRootNodeContext(t){do if(!t.belongsTo(this)&&t.sourceNode===this.rootSourceNode)return t;while(t=t.parent);return null}initializeRepetitiveElements(t){if(this.repetitiveElements)return;Qr.some(n=>n.root===this.rootSourceNode?(this.repetitiveElements=n.elements,!0):!1)||(this.repetitiveElements=new Gu(t,this.rootSourceNode),Qr.push({root:this.rootSourceNode,elements:this.repetitiveElements}))}saveState(){}restoreState(t){}},Gu=class{constructor(t,e){this.vertical=t;this.ownerSourceNode=e;d(this,"headerSourceNode",null);d(this,"footerSourceNode",null);d(this,"headerViewNode",null);d(this,"footerViewNode",null);d(this,"headerNodePosition",null);d(this,"footerNodePosition",null);d(this,"headerHeight",0);d(this,"footerHeight",0);d(this,"isSkipHeader",!1);d(this,"isSkipFooter",!1);d(this,"enableSkippingFooter",!0);d(this,"enableSkippingHeader",!0);d(this,"doneInitialLayout",!1);d(this,"firstContentSourceNode",null);d(this,"lastContentSourceNode",null);d(this,"affectedNodeCache",[]);d(this,"afterLastContentNodeCache",[]);d(this,"allowInsert",!1);d(this,"allowInsertRepeatitiveElements")}setHeaderNodeContext(t){this.headerNodePosition||(this.headerNodePosition=gs(t,0),this.headerSourceNode=t.sourceNode,this.headerViewNode=t.viewNode)}setFooterNodeContext(t){this.footerNodePosition||(this.footerNodePosition=gs(t,0),this.footerSourceNode=t.sourceNode,this.footerViewNode=t.viewNode)}updateHeight(t){this.headerViewNode&&(this.headerHeight=ti(this.headerViewNode,t,this.vertical),this.headerViewNode=null),this.footerViewNode&&(this.footerHeight=ti(this.footerViewNode,t,this.vertical),this.footerViewNode=null)}prepareLayoutFragment(){this.isSkipHeader=this.isSkipFooter=!1,this.enableSkippingFooter=!0,this.enableSkippingHeader=!0}appendHeaderToFragment(t,e,n){return!this.headerNodePosition||this.isSkipHeader?v(!0):this.appendElementToFragment(this.headerNodePosition,t,e,n)}appendFooterToFragment(t,e,n){return!this.footerNodePosition||this.isSkipFooter?v(!0):this.appendElementToFragment(this.footerNodePosition,t,e,n)}appendElementToFragment(t,e,n,s){let o=e.viewNode.ownerDocument,i=e.viewNode,a=o.createElement("div");i.appendChild(a);let l=new ws(s,a,e),c=l.getColumn().pageBreakType;return l.getColumn().pageBreakType=null,this.allowInsertRepeatitiveElements=!0,l.layout(new pt(t),!0).thenAsync(()=>(this.allowInsertRepeatitiveElements=!1,i.removeChild(a),this.moveChildren(a,i,n),l.getColumn().pageBreakType=c,v(!0)))}moveChildren(t,e,n){if(e)for(;t.firstChild;){let s=t.firstChild;t.removeChild(s),s.setAttribute(Mt,"1"),n?e.insertBefore(s,n):e.appendChild(s)}}calculateOffset(t){let e=0;return t&&!this.affectTo(t)||((!this.isSkipFooter||t&&this.isAfterLastContent(t))&&(e+=this.footerHeight),this.isSkipHeader||(e+=this.headerHeight)),e}calculateMinimumOffset(t){let e=0;return t&&!this.affectTo(t)||(t&&this.isAfterLastContent(t)&&(e+=this.footerHeight),this.enableSkippingHeader||(e+=this.headerHeight)),e}isAfterLastContent(t){return this.findResultFromCache(t,this.afterLastContentNodeCache,e=>this.isAfterNodeContextOf(this.lastContentSourceNode,t,!1))}affectTo(t){return this.findResultFromCache(t,this.affectedNodeCache,e=>this.isAfterNodeContextOf(this.ownerSourceNode,t,!0))}findResultFromCache(t,e,n){let s=e.filter(o=>o.nodeContext.sourceNode===t.sourceNode&&o.nodeContext.after===t.after);if(s.length>0)return s[0].result;{let o=n(t);return e.push({nodeContext:t,result:o}),o}}isAfterNodeContextOf(t,e,n){let s=[];for(let o=t;o;o=o.parentNode){if(e.sourceNode===o)return e.after;s.push(o)}for(let o=e.sourceNode;o;o=o.parentNode){let i=s.indexOf(o);if(i>=0)return n?i===0:!1;for(let a=o;a;a=a.previousElementSibling)if(s.includes(a))return!0}return e.after}isFirstContentNode(t){return t&&this.firstContentSourceNode===t.sourceNode}isEnableToUpdateState(){return!!(!this.isSkipFooter&&this.enableSkippingFooter&&this.footerNodePosition||!this.isSkipHeader&&this.enableSkippingHeader&&this.headerNodePosition)}updateState(){!this.isSkipFooter&&this.enableSkippingFooter&&this.footerNodePosition?this.isSkipFooter=!0:!this.isSkipHeader&&this.enableSkippingHeader&&this.headerNodePosition&&(this.isSkipHeader=!0)}preventSkippingHeader(){this.isSkipHeader=!1,this.enableSkippingHeader=!1}preventSkippingFooter(){this.isSkipFooter=!1,this.enableSkippingFooter=!1}isHeaderRegistered(){return!!this.headerNodePosition}isFooterRegistered(){return!!this.footerNodePosition}isHeaderSourceNode(t){return this.headerSourceNode===t}isFooterSourceNode(t){return this.footerSourceNode===t}},fi=class{constructor(t){this.formattingContext=t}accept(t,e){return!!t}postLayout(t,e,n,s){let o=this.formattingContext.getRepetitiveElements();return o&&(n.clientLayout,o.doneInitialLayout||(o.updateHeight(n),o.doneInitialLayout=!0)),s}},gi=class{constructor(t){this.formattingContext=t}accept(t,e){return!0}postLayout(t,e,n,s){return s}},Wu=class extends fi{constructor(e,n){super(e);this.processor=n}doLayout(e,n){return this.processor.doInitialLayout(e,n)}accept(e,n){return!1}},Xu=class extends gi{constructor(e,n){super(e);this.processor=n}doLayout(e,n){return!e.belongsTo(this.formattingContext)&&!e.after&&n.fragmentLayoutConstraints.unshift(new xo(e)),this.processor.doLayout(e,n)}},xo=class r{constructor(t){d(this,"flagmentLayoutConstraintType","RepetitiveElementsOwner");d(this,"nodeContext");let e=yn(t.formattingContext);this.nodeContext=e.getRootNodeContext(t)}allowLayout(t,e,n){let s=this.getRepetitiveElements();return!s||pn(this.nodeContext.viewNode)||!s.isEnableToUpdateState()?!0:!(e&&!t||t&&t.overflow)}nextCandidate(t){let e=this.getRepetitiveElements();return e&&e.isEnableToUpdateState()?(e.updateState(),!0):!1}postLayout(t,e,n,s){let o=this.getRepetitiveElements();o&&t&&s.stopAtOverflow&&(e==null||o.isAfterLastContent(e))&&o.preventSkippingFooter()}finishBreak(t,e){let n=yn(this.nodeContext.formattingContext),s=this.getRepetitiveElements();if(!s)return v(!0);let o=this.nodeContext;return hC(n,o,e).thenAsync(()=>fC(n,o,e).thenAsync(()=>(s.prepareLayoutFragment(),v(!0))))}getRepetitiveElements(){return yn(this.nodeContext.formattingContext).getRepetitiveElements()}equalsTo(t){return t instanceof r?yn(this.nodeContext.formattingContext)===yn(t.nodeContext.formattingContext):!1}getPriorityOfFinishBreak(){return 10}},$u=class extends Hn{constructor(e,n){super();this.formattingContext=e;this.processor=n}resolveLayoutMode(e){let n=this.formattingContext.getRepetitiveElements();return!e.belongsTo(this.formattingContext)&&!n.doneInitialLayout?new Wu(this.formattingContext,this.processor):(!e.belongsTo(this.formattingContext)&&!e.after&&n&&n.preventSkippingHeader(),new Xu(this.formattingContext,this.processor))}},ju=class extends gn{constructor(e,n){super();this.formattingContext=e;this.column=n}startNonInlineElementNode(e){let n=this.formattingContext,s=e.nodeContext,o=n.getRepetitiveElements();if(s.parent&&n.rootSourceNode===s.parent.sourceNode){switch(s.repeatOnBreak){case"header":if(o.isHeaderRegistered())s.repeatOnBreak="none";else return o.setHeaderNodeContext(s),v(!0);break;case"footer":if(o.isFooterRegistered())s.repeatOnBreak="none";else return o.setFooterNodeContext(s),v(!0);break}o.firstContentSourceNode||(o.firstContentSourceNode=s.sourceNode)}return gn.prototype.startNonInlineElementNode.call(this,e)}afterNonInlineElementNode(e){let n=this.formattingContext,s=e.nodeContext;return s.sourceNode===n.rootSourceNode&&(n.getRepetitiveElements().lastContentSourceNode=e.lastAfterNodeContext&&e.lastAfterNodeContext.sourceNode,e.break=!0),s.repeatOnBreak==="header"||s.repeatOnBreak==="footer"?v(!0):gn.prototype.afterNonInlineElementNode.call(this,e)}};var Yu=class extends Jt{layout(t,e,n){if(e.isFloatNodeContext(t))return e.layoutFloatOrFootnote(t);let s=yn(t.formattingContext);return s.getRootViewNode(t)?(n&&Ku(t.parent,e),t.belongsTo(s)?Jt.prototype.layout.call(this,t,e,n):new $u(s,this).layout(t,e)):e.buildDeepElementView(t)}startNonInlineElementNode(t){let n=gC(t).getRepetitiveElements();return n&&!n.allowInsertRepeatitiveElements&&(n.isHeaderSourceNode(t.sourceNode)||n.isFooterSourceNode(t.sourceNode))&&t.viewNode.parentNode.removeChild(t.viewNode),!1}doInitialLayout(t,e){let n=yn(t.formattingContext),s=k("BlockLayoutProcessor.doInitialLayout");return this.layoutEntireBlock(t,e).thenFinish(s),s.result()}layoutEntireBlock(t,e){let n=yn(t.formattingContext),s=new ju(n,e);return new Cs(s,e.layoutContext).iterate(t)}doLayout(t,e){let n=yn(t.formattingContext),s=k("doLayout"),o=e.layoutContext.nextInTree(t,!1);return zu(o,e).then(i=>{let a=i;s.loopWithFrame(l=>{for(;a;){let c=!0;if(e.layoutNext(a,!1).then(u=>{a=u,e.pageFloatLayoutContext.isInvalidated()||e.pageBreakType||a&&e.stopByOverflow(a)||a&&a.after&&a.sourceNode==n.rootSourceNode?l.breakLoop():c?c=!1:l.continueLoop()}),c){c=!1;return}}l.breakLoop()}).then(()=>{s.finish(a)})}),s.result()}finishBreak(t,e,n,s){return Jt.prototype.finishBreak.call(this,t,e,n,s)}clearOverflownViewNodes(t,e,n,s){Jt.prototype.clearOverflownViewNodes(t,e,n,s)}};function pC(r,t){for(let e=r;e;e=e.parent){let n=e.formattingContext;n&&n instanceof Ut&&!e.belongsTo(n)&&t(n,e)}}function Ku(r,t){r&&pC(r.after?r.parent:r,(e,n)=>{Ot.isInstanceOfTableFormattingContext(e)||t.fragmentLayoutConstraints.push(new xo(n))})}function hC(r,t,e){let n=r.getRepetitiveElements();if(n){let s=r.getRootNodeContext(t);if(s.viewNode){let o=s.viewNode.firstChild;return n.appendHeaderToFragment(s,o,e)}}return v(!0)}function fC(r,t,e){let n=r.getRepetitiveElements();if(n&&!n.isSkipFooter){let s=r.getRootNodeContext(t);if(s.viewNode)return n.appendFooterToFragment(s,null,e)}return v(!0)}function gC(r){let t=r.formattingContext;return!t||!(t instanceof Ut)?null:t}function yn(r){return r instanceof Ut,r}var mC=new Yu;_e("RESOLVE_LAYOUT_PROCESSOR",r=>r instanceof Ut&&!Ot.isInstanceOfTableFormattingContext(r)?mC:null);var ba=class{constructor(t,e){this.rowIndex=t;this.sourceNode=e;d(this,"cells",[])}addCell(t){this.cells.push(t)}getMinimumHeight(){return Math.min.apply(null,this.cells.map(t=>t.height))}},qu=class{constructor(t,e,n){this.rowIndex=t;this.columnIndex=e;d(this,"viewElement");d(this,"colSpan");d(this,"rowSpan");d(this,"height",0);d(this,"anchorSlot",null);this.viewElement=n,this.colSpan=n.colSpan||1,this.rowSpan=n.rowSpan||1}setHeight(t){this.height=t}setAnchorSlot(t){this.anchorSlot=t}},Zu=class{constructor(t,e,n){this.rowIndex=t;this.columnIndex=e;this.cell=n}},Qu=class{constructor(t,e,n){this.column=t;this.cellNodeContext=n;d(this,"pseudoColumn");d(this,"empty",!1);this.pseudoColumn=new ws(t,e,n)}findAcceptableBreakPosition(){let t=this.cellNodeContext.viewNode,{verticalAlign:e,alignContent:n}=t.style;e!=="top"&&e!=="baseline"&&T(t,"vertical-align","top"),n&&n!=="normal"&&T(t,"align-content","normal");let s=this.pseudoColumn.findAcceptableBreakPosition(!0);return T(t,"vertical-align",e),n&&n!=="normal"&&T(t,"align-content",n),s}},Ju=class{constructor(t,e){this.viewNode=t;this.side=e}},ed=class extends fn{constructor(e,n,s,o){super(e,n,s,o);d(this,"formattingContext");d(this,"acceptableCellBreakPositions",null);d(this,"rowIndex",null);this.formattingContext=e.formattingContext}findAcceptableBreak(e,n){let s=super.findAcceptableBreak(e,n);return n<this.getMinBreakPenalty()?null:this.getAcceptableCellBreakPositions().every(i=>!!i.nodeContext)?s:null}getMinBreakPenalty(){let e=super.getMinBreakPenalty();return this.getAcceptableCellBreakPositions().forEach(n=>{e+=n.breakPosition.getMinBreakPenalty()}),e}getAcceptableCellBreakPositions(){if(!this.acceptableCellBreakPositions){let e=this.formattingContext,n=this.getCellFragments();this.acceptableCellBreakPositions=n.map(s=>s.findAcceptableBreakPosition())}return this.acceptableCellBreakPositions}getRowIndex(){return this.rowIndex!=null?this.rowIndex:this.rowIndex=this.formattingContext.findRowIndexBySourceNode(this.position.sourceNode)}getCellFragments(){return this.formattingContext.getRowSpanningCellsOverflowingTheRow(this.getRowIndex()).map(this.formattingContext.getCellFragmentOfCell,this.formattingContext)}},td=class extends ms{constructor(e,n,s){super();this.rowIndex=e;this.beforeNodeContext=n;this.formattingContext=s;d(this,"acceptableCellBreakPositions",null)}findAcceptableBreak(e,n){if(n<this.getMinBreakPenalty())return null;let s=this.getCellFragments(),o=this.getAcceptableCellBreakPositions(),i=o.every(a=>!!a.nodeContext)&&o.some((a,l)=>{let c=s[l].pseudoColumn,u=a.nodeContext;return!c.isStartNodeContext(u)&&!c.isLastAfterNodeContext(u)});return this.beforeNodeContext.overflow=o.some(a=>a.nodeContext&&a.nodeContext.overflow),i?this.beforeNodeContext:null}getMinBreakPenalty(){let e=this.formattingContext,n=e.getRowByIndex(this.rowIndex),s=0;return e.isFreelyFragmentableRow(n)||(s+=10),this.getAcceptableCellBreakPositions().forEach(o=>{s+=o.breakPosition.getMinBreakPenalty()}),s}getAcceptableCellBreakPositions(){if(!this.acceptableCellBreakPositions){let e=this.getCellFragments();this.acceptableCellBreakPositions=e.map(n=>n.findAcceptableBreakPosition())}return this.acceptableCellBreakPositions}getCellFragments(){return this.formattingContext.getCellsFallingOnRow(this.rowIndex).map(this.formattingContext.getCellFragmentOfCell,this.formattingContext)}},$n=class extends Ut{constructor(e,n){super(e,n);this.tableSourceNode=n;d(this,"formattingContextType","Table");d(this,"vertical",!1);d(this,"columnCount",-1);d(this,"tableWidth",0);d(this,"captions",[]);d(this,"colGroups",null);d(this,"colWidths",null);d(this,"inlineBorderSpacing",0);d(this,"rows",[]);d(this,"slots",[]);d(this,"cellFragments",[]);d(this,"lastRowViewNode",null);d(this,"cellBreakPositions",[]);d(this,"repetitiveElements",null)}getName(){return"Table formatting context (Table.TableFormattingContext)"}isFirstTime(e,n){if(!n)return n;switch(e.display){case"table-row":return this.cellBreakPositions.length===0;case"table-cell":return!this.cellBreakPositions.some(s=>s.cellNodePosition.steps[0].node===e.sourceNode);default:return n}}getParent(){return this.parent}finishFragment(){this.cellFragments=[]}addRow(e,n){this.rows[e]=n}getRowSlots(e){let n=this.slots[e];return n||(n=this.slots[e]=[]),n}addCell(e,n){let s=this.rows[e];s||(this.addRow(e,new ba(e,null)),s=this.rows[e]),s.addCell(n);let o=e+n.rowSpan,i=this.getRowSlots(e),a=0;for(;i[a];)a++;for(;e<o;e++){i=this.getRowSlots(e);for(let l=a;l<a+n.colSpan;l++){let c=i[l]=new Zu(e,l,n);n.anchorSlot||n.setAnchorSlot(c)}}}getRowByIndex(e){let n=this.rows[e];return n}findRowIndexBySourceNode(e){return this.rows.findIndex(n=>e===n.sourceNode)}addCellFragment(e,n,s){let o=this.cellFragments[e];o||(o=this.cellFragments[e]=[]),o[n]=s}getCellsFallingOnRow(e){return this.getRowSlots(e).reduce((s,o)=>o.cell!==s[s.length-1]?s.concat(o.cell):s,[])}getRowSpanningCellsOverflowingTheRow(e){return this.getCellsFallingOnRow(e).filter(n=>n.rowIndex+n.rowSpan-1>e)}getCellFragmentOfCell(e){return this.cellFragments[e.rowIndex]&&this.cellFragments[e.rowIndex][e.columnIndex]}isFreelyFragmentableRow(e){return e.getMinimumHeight()>this.tableWidth/2}getColumnCount(){return this.columnCount<0&&(this.columnCount=Math.max.apply(null,this.rows.map(e=>e.cells.reduce((n,s)=>n+s.colSpan,0)))),this.columnCount}updateCellSizes(e){this.rows.forEach(n=>{n.cells.forEach(s=>{let o=e.getElementClientRect(s.viewElement);s.viewElement=null,s.setHeight(this.vertical?o.width:o.height)})})}findCellFromColumn(e){if(!e)return null;let n=null,s=0,o=0;e:for(s=0;s<this.cellFragments.length;s++)if(this.cellFragments[s]){for(o=0;o<this.cellFragments[s].length;o++)if(this.cellFragments[s][o]&&e===this.cellFragments[s][o].pseudoColumn.getColumn()){n=this.rows[s].cells[o];break e}}if(!n)return null;for(;s<this.slots.length;s++)for(;o<this.slots[s].length;o++){let i=this.slots[s][o];if(i.cell===n)return{rowIndex:i.rowIndex,columnIndex:i.columnIndex}}return null}collectElementsOffsetOfUpperCells(e){let n=[];return this.slots.reduce((s,o,i)=>{if(i>=e.rowIndex)return s;let a=o[e.columnIndex]&&this.getCellFragmentOfCell(o[e.columnIndex].cell);return!a||n.includes(a)||(this.collectElementsOffsetFromColumn(a.pseudoColumn.getColumn(),s),n.push(a)),s},[])}collectElementsOffsetOfHighestColumn(){let e=[];return this.rows.forEach(n=>{n.cells.forEach((s,o)=>{e[o]||(e[o]={collected:[],elements:[]});let i=e[o],a=this.getCellFragmentOfCell(s);!a||i.collected.includes(a)||(this.collectElementsOffsetFromColumn(a.pseudoColumn.getColumn(),i.elements),i.collected.push(a))})}),[new nd(e.map(n=>n.elements))]}collectElementsOffsetFromColumn(e,n){e.fragmentLayoutConstraints.forEach(s=>{if(Qt.isInstanceOfRepetitiveElementsOwnerLayoutConstraint(s)){let o=s.getRepetitiveElements();n.push(o)}Ot.isInstanceOfTableRowLayoutConstraint(s)&&s.getElementsOffsetsForTableCell(null).forEach(o=>{n.push(o)})})}saveState(){return[].concat(this.cellBreakPositions)}restoreState(e){this.cellBreakPositions=e}},nd=class{constructor(t){this.repeatitiveElementsInColumns=t}calculateOffset(t){return this.calculateMaxOffsetOfColumn(t,e=>e.current)}calculateMinimumOffset(t){return this.calculateMaxOffsetOfColumn(t,e=>e.minimum)}calculateMaxOffsetOfColumn(t,e){let n=0;return this.repeatitiveElementsInColumns.forEach(s=>{let o=_n(t,s);n=Math.max(n,e(o))}),n}};function Lt(r){return r instanceof $n,r}function CC(r){return r==="table-row-group"||r==="table-header-group"||r==="table-footer-group"}function bC(r){return r==="table"||r==="inline-table"}function bf(r){return CC(r)||bC(r)}function yf(r,t,e){let n=r.nodeContext,s=n.display,o=n.parent?n.parent.display:null,i=!1;if(o==="inline-table"&&!(n.formattingContext instanceof $n)){for(let l=n.parent;l;l=l.parent)if(l.formattingContext instanceof $n){i=l.formattingContext===t;break}}return i||s==="table-row"&&!bf(o)||s==="table-cell"&&o!=="table-row"&&!bf(o)||n.formattingContext instanceof $n&&n.formattingContext!==t?e.buildDeepElementView(n).thenAsync(l=>(r.nodeContext=l,v(!0))):null}var sd=class extends gn{constructor(e,n){super();this.formattingContext=e;this.column=n;d(this,"rowIndex",-1);d(this,"columnIndex",0);d(this,"inRow",!1);d(this,"checkPoints",[]);d(this,"inHeaderOrFooter",!1)}startNonInlineElementNode(e){let n=this.formattingContext,s=yf(e,n,this.column);if(s)return s;this.postLayoutBlockContents(e);let o=e.nodeContext,i=o.display,a=n.getRepetitiveElements();switch(i){case"table":n.inlineBorderSpacing=o.inlineBorderSpacing;break;case"table-caption":{let l=new Ju(o.viewNode,o.captionSide);n.captions.push(l);break}case"table-header-group":return a.isHeaderRegistered()||(this.inHeaderOrFooter=!0,a.setHeaderNodeContext(o)),v(!0);case"table-footer-group":return a.isFooterRegistered()||(this.inHeaderOrFooter=!0,a.setFooterNodeContext(o)),v(!0);case"table-row":this.inHeaderOrFooter||(this.inRow=!0,this.rowIndex++,o.sourceNode,this.columnIndex=0,n.addRow(this.rowIndex,new ba(this.rowIndex,o.sourceNode)),a.firstContentSourceNode||(a.firstContentSourceNode=o.sourceNode));break}return super.startNonInlineElementNode(e)}afterNonInlineElementNode(e){let n=this.formattingContext,s=e.nodeContext,o=s.display,i=this.column.clientLayout;if(this.postLayoutBlockContents(e),s.sourceNode===n.tableSourceNode){let a=i.getElementComputedStyle(n.getRootViewNode(s));n.tableWidth=parseFloat(a[n.vertical?"height":"width"]),n.getRepetitiveElements().lastContentSourceNode=e.lastAfterNodeContext&&e.lastAfterNodeContext.sourceNode,e.break=!0}else switch(o){case"table-header-group":case"table-footer-group":if(this.inHeaderOrFooter)return this.inHeaderOrFooter=!1,v(!0);break;case"table-row":this.inHeaderOrFooter||(n.lastRowViewNode=s.viewNode,this.inRow=!1);break;case"table-cell":if(!this.inHeaderOrFooter){this.inRow||(this.rowIndex++,this.columnIndex=0,this.inRow=!0);let a=s.viewNode;n.addCell(this.rowIndex,new qu(this.rowIndex,this.columnIndex,a)),this.columnIndex++}break}return super.afterNonInlineElementNode(e)}startNonElementNode(e){this.registerCheckPoint(e)}afterNonElementNode(e){this.registerCheckPoint(e)}startInlineElementNode(e){this.registerCheckPoint(e)}afterInlineElementNode(e){this.registerCheckPoint(e)}registerCheckPoint(e){let n=e.nodeContext;n&&n.viewNode&&!hn(n)&&this.checkPoints.push(n.clone())}postLayoutBlockContents(e){this.checkPoints.length>0&&this.column.postLayoutBlock(e.nodeContext,this.checkPoints),this.checkPoints=[]}},xa=class xa extends gn{constructor(e,n){super(!0);this.formattingContext=e;this.column=n;d(this,"inRow",!1);d(this,"currentRowIndex",-1);d(this,"currentColumnIndex",0);d(this,"originalStopAtOverflow");d(this,"inHeader");d(this,"inFooter");this.originalStopAtOverflow=n.stopAtOverflow,n.stopAtOverflow=!1}resetColumn(){this.column.stopAtOverflow=this.originalStopAtOverflow}getColSpanningCellWidth(e){let n=this.formattingContext.colWidths;let s=0;for(let o=0;o<e.colSpan;o++)s+=n[e.anchorSlot.columnIndex+o];return s+=this.formattingContext.inlineBorderSpacing*(e.colSpan-1),s}layoutCell(e,n,s){let o=e.rowIndex,i=e.columnIndex,a=e.colSpan,l=n.viewNode,c=n.verticalAlign;a>1&&(T(l,"box-sizing","border-box"),T(l,this.formattingContext.vertical?"height":"width",`${this.getColSpanningCellWidth(e)}px`));let u=l.ownerDocument.createElement("div");l.appendChild(u);let p=new Qu(this.column,u,n);return this.formattingContext.addCellFragment(o,i,p),s.primary.steps.length===1&&s.primary.after&&(p.empty=!0),p.pseudoColumn.layout(s,!0).thenReturn(!0)}hasBrokenCellAtSlot(e){let n=this.formattingContext.cellBreakPositions[0];return n?n.cell.anchorSlot.columnIndex===e:!1}extractRowSpanningCellBreakPositions(){let e=this.formattingContext.cellBreakPositions;if(e.length===0)return[];let n=[],s=0;do{let o=e[s],i=o.cell.rowIndex;if(i<this.currentRowIndex){let a=n[i];a||(a=n[i]=[]),a.push(o),e.splice(s,1)}else s++}while(s<e.length);return n}layoutRowSpanningCellsFromPreviousFragment(e){let n=this.formattingContext,s=this.extractRowSpanningCellBreakPositions(),o=s.reduce(h=>h+1,0);if(o===0)return v(!0);let i=this.column.layoutContext,a=e.nodeContext;a.viewNode.parentNode.removeChild(a.viewNode);let l=k("layoutRowSpanningCellsFromPreviousFragment"),c=v(!0),u=0,p=[];return s.forEach(h=>{c=c.thenAsync(()=>{let f=ao(h[0].cellNodePosition.steps[1],a.parent);return i.setCurrent(f,!1).thenAsync(()=>{let g=v(!0),m=0;function E(C){for(;m<C;){if(!p.includes(m)){let b=f.viewNode.ownerDocument.createElement("td");T(b,"padding","0"),f.viewNode.appendChild(b)}m++}}return h.forEach(C=>{g=g.thenAsync(()=>{let b=C.cell;E(b.anchorSlot.columnIndex);let y=C.cellNodePosition,N=ao(y.steps[0],f);return N.offsetInNode=y.offsetInNode,N.after=y.after,N.fragmentIndex=y.steps[0].fragmentIndex+1,i.setCurrent(N,!1).thenAsync(()=>{let S=C.breakChunkPosition;for(let w=0;w<b.colSpan;w++)p.push(m+w);return m+=b.colSpan,this.layoutCell(b,N,S).thenAsync(()=>(N.viewNode.rowSpan=b.rowIndex+b.rowSpan-this.currentRowIndex+o-u,v(!0)))})})}),g.thenAsync(()=>(E(n.getColumnCount()),u++,v(!0)))})})}),c.then(()=>{i.setCurrent(a,!0,e.atUnforcedBreak).then(()=>{l.finish(!0)})}),l.result()}startTableRow(e){if(this.inHeader||this.inFooter)return v(!0);let n=e.nodeContext,s=this.formattingContext;return this.currentRowIndex<0?(n.sourceNode,this.currentRowIndex=s.findRowIndexBySourceNode(n.sourceNode)):this.currentRowIndex++,this.currentColumnIndex=0,this.inRow=!0,this.layoutRowSpanningCellsFromPreviousFragment(e).thenAsync(()=>(this.registerCellFragmentIndex(),this.column.checkOverflowAndSaveEdgeAndBreakPosition(e.lastAfterNodeContext,null,!0,e.breakAtTheEdge)&&s.getRowSpanningCellsOverflowingTheRow(this.currentRowIndex-1).length===0&&(this.resetColumn(),n.overflow=!0,e.break=!0),v(!0)))}registerCellFragmentIndex(){this.formattingContext.getRowByIndex(this.currentRowIndex).cells.forEach(n=>{let s=this.formattingContext.cellBreakPositions[n.columnIndex];if(s&&s.cell.anchorSlot.columnIndex==n.anchorSlot.columnIndex){let o=s.cellNodePosition.steps[0],i=this.column.layoutContext.xmldoc.getElementOffset(o.node);gf(i,o.fragmentIndex+1,1)}})}startTableCell(e){if(this.inHeader||this.inFooter)return v(!0);let n=e.nodeContext;this.inRow||(this.currentRowIndex<0?this.currentRowIndex=0:this.currentRowIndex++,this.currentColumnIndex=0,this.inRow=!0);let s=this.formattingContext.getRowByIndex(this.currentRowIndex).cells[this.currentColumnIndex];if(!s)return e.break=!0,v(!0);let o=n.copy().modify();o.after=!0,e.nodeContext=o;let i=k("startTableCell"),a;if(this.hasBrokenCellAtSlot(s.anchorSlot.columnIndex)){let l=this.formattingContext.cellBreakPositions.shift();n.fragmentIndex=l.cellNodePosition.steps[0].fragmentIndex+1,a=v(l.breakChunkPosition)}else a=this.column.nextInTree(n,e.atUnforcedBreak).thenAsync(l=>{l.viewNode&&n.viewNode.removeChild(l.viewNode);let c=gs(l,0);return v(new pt(c))});return a.then(l=>{this.layoutCell(s,n,l).then(()=>{this.afterNonInlineElementNode(e),this.currentColumnIndex++,i.finish(!0)})}),i.result()}startNonInlineBox(e){let n=yf(e,Lt(this.formattingContext),this.column);if(n)return n;let s=e.nodeContext,o=this.formattingContext.getRepetitiveElements(),i=s.display;return i==="table-header-group"&&o&&o.isHeaderSourceNode(s.sourceNode)?(this.inHeader=!0,v(!0)):i==="table-footer-group"&&o&&o.isFooterSourceNode(s.sourceNode)?(this.inFooter=!0,v(!0)):i==="table-row"?this.startTableRow(e):i==="table-cell"?this.startTableCell(e):v(!0)}endNonInlineBox(e){let n=e.nodeContext;if(n.display==="table-row"&&(this.inRow=!1,!this.inHeader&&!this.inFooter)){let o=n.copy().modify();o.after=!1;let i=new td(this.currentRowIndex,o,this.formattingContext);this.column.breakPositions.push(i)}return v(!0)}afterNonInlineElementNode(e){let n=e.nodeContext,s=this.formattingContext.getRepetitiveElements(),o=n.display;if(o==="table-header-group"?s&&!s.allowInsertRepeatitiveElements&&s.isHeaderSourceNode(n.sourceNode)?(this.inHeader=!1,n.viewNode.parentNode.removeChild(n.viewNode)):T(n.viewNode,"display","table-row-group"):o==="table-footer-group"&&(s&&!s.allowInsertRepeatitiveElements&&s.isFooterSourceNode(n.sourceNode)?(this.inFooter=!1,n.viewNode.parentNode.removeChild(n.viewNode)):T(n.viewNode,"display","table-row-group")),o&&xa.ignoreList[o])n.viewNode.parentNode.removeChild(n.viewNode);else if(n.sourceNode===this.formattingContext.tableSourceNode)n.overflow=this.column.checkOverflowAndSaveEdge(n,null),this.resetColumn(),e.break=!0;else return super.afterNonInlineElementNode(e);return v(!0)}};d(xa,"ignoreList",{"table-caption":!0,"table-column-group":!0,"table-column":!0});var od=xa,mi=[];function yC(r){let t=mi.findIndex(n=>n.root===r),e=mi[t];return e?e.tableLayoutOption:null}function xC(r){let t=mi.findIndex(e=>e.root===r);t>=0&&mi.splice(t,1)}var ya=class{layoutEntireTable(t,e){let n=Lt(t.formattingContext),s=new sd(n,e);return new Cs(s,e.layoutContext).iterate(t)}getColumnWidths(t,e,n,s){let o=t.ownerDocument,i=o.createElement("tr"),a=[];for(let c=0;c<e;c++){let u=o.createElement("td");i.appendChild(u),a.push(u)}t.parentNode.insertBefore(i,t.nextSibling);let l=a.map(c=>{let u=s.getElementClientRect(c),p=n?u.height:u.width;return Math.ceil(p)});return t.parentNode.removeChild(i),l}getColGroupElements(t){let e=[],n=t.firstElementChild;for(;n;)n.localName==="colgroup"&&e.push(n),n=n.nextElementSibling;return e}normalizeAndGetColElements(t){let e=[];return t.forEach(n=>{let s=n.span;n.removeAttribute("span");let o=n.firstElementChild;for(;o;){if(o.localName==="col"){let i=o.span;for(o.removeAttribute("span"),s-=i;i-- >1;){let a=o.cloneNode(!0);n.insertBefore(a,o),e.push(a)}e.push(o)}o=o.nextElementSibling}for(;s-- >0;)o=n.ownerDocument.createElement("col"),n.appendChild(o),e.push(o)}),e}addMissingColElements(t,e,n,s){if(t.length<n){let o=s.ownerDocument.createElement("colgroup");e.push(o);for(let i=t.length;i<n;i++){let a=s.ownerDocument.createElement("col");o.appendChild(a),t.push(a)}}}normalizeColGroups(t,e,n){let s=t.vertical,o=t.lastRowViewNode;if(!o)return;t.lastRowViewNode=null;let a=o.ownerDocument.createDocumentFragment(),l=t.getColumnCount();if(!(l>0)){t.colGroups=a;return}let c=t.colWidths=this.getColumnWidths(o,l,s,n.clientLayout),u=this.getColGroupElements(e),p=this.normalizeAndGetColElements(u);this.addMissingColElements(p,u,l,e),p.forEach((h,f)=>{T(h,s?"height":"width",`${c[f]}px`)}),u.forEach(h=>{a.appendChild(h.cloneNode(!0))}),t.colGroups=a}doInitialLayout(t,e){let n=Lt(t.formattingContext);n.vertical=t.vertical,n.initializeRepetitiveElements(t.vertical),t.sourceNode;let s=yC(t.sourceNode);xC(t.sourceNode);let o=k("TableLayoutProcessor.doInitialLayout"),i=t.copy();return this.layoutEntireTable(t,e).then(a=>{let l=a.viewNode,c=e.clientLayout.getElementClientRect(l),u=e.vertical?c.left:c.bottom;if(u+=(e.vertical?-1:1)*_n(t,e.collectElementsOffset()).current,!e.isOverflown(u)&&(!s||!s.calculateBreakPositionsInside)){e.breakPositions.push(new ad(i)),o.finish(a);return}this.normalizeColGroups(n,l,e),n.updateCellSizes(e.clientLayout),o.finish(null)}),o.result()}addCaptions(t,e,n){let s=t.captions;s.forEach((o,i)=>{o&&(e.insertBefore(o.viewNode,n),o.side==="top"&&(s[i]=null))})}addColGroups(t,e,n){t.colGroups&&this.getColGroupElements(e).length===0&&e.insertBefore(t.colGroups.cloneNode(!0),n)}removeColGroups(t,e){if(t.colGroups&&e){let n=this.getColGroupElements(e);n&&n.forEach(s=>{e.removeChild(s)})}}doLayout(t,e){let n=Lt(t.formattingContext),s=n.getRootViewNode(t),o=s.firstChild;this.addCaptions(n,s,o),this.addColGroups(n,s,o);let i=new od(n,e),a=new Cs(i,e.layoutContext),l=k("TableFormattingContext.doLayout");return a.iterate(t).thenFinish(l),l.result()}layout(t,e,n){let s=Lt(t.formattingContext);return s.getRootViewNode(t)?(n&&Ku(t.parent,e),new id(s,this).layout(t,e)):e.buildDeepElementView(t)}createEdgeBreakPosition(t,e,n,s){return new ed(t,e,n,s)}startNonInlineElementNode(t){return!1}afterNonInlineElementNode(t,e){return!1}finishBreak(t,e,n,s){let o=Lt(e.formattingContext);if(e.display==="table-row"){e.sourceNode;let i=o.findRowIndexBySourceNode(e.sourceNode);o.cellBreakPositions=[];let a;if(e.after?a=o.getRowSpanningCellsOverflowingTheRow(i):a=o.getCellsFallingOnRow(i),a.length){let l=k("TableLayoutProcessor.finishBreak"),c=0;return l.loopWithFrame(u=>{if(c===a.length){u.breakLoop();return}let p=a[c++],h=o.getCellFragmentOfCell(p),f=h.findAcceptableBreakPosition().nodeContext;let g=h.cellNodeContext,m=g.toNodePosition(),E=new pt(f.toNodePosition());o.cellBreakPositions.push({cellNodePosition:m,breakChunkPosition:E,cell:p});let C=g.viewNode;h.column.layoutContext.processFragmentedBlockEdge(h.cellNodeContext),i<p.rowIndex+p.rowSpan-1&&(C.rowSpan=i-p.rowIndex+1),h.empty?u.continueLoop():h.pseudoColumn.finishBreak(f,!1,!0).then(()=>{EC(h,o,f),u.continueLoop()})}).then(()=>{t.clearOverflownViewNodes(e,!1),t.layoutContext.processFragmentedBlockEdge(e),o.finishFragment(),l.finish(!0)}),l.result()}}return o.finishFragment(),ni.finishBreak(t,e,n,s)}clearOverflownViewNodes(t,e,n,s){Jt.prototype.clearOverflownViewNodes(t,e,n,s)}};function EC(r,t,e){let n=t.getRepetitiveElements();if(!n)return;let s=t.vertical,o=r.column,i=r.pseudoColumn.getColumnElement(),a=r.cellNodeContext.viewNode,l=o.clientLayout.getElementClientRect(a),c=o.getComputedPaddingBorder(a);if(s){let u=l.right-o.footnoteEdge-n.calculateOffset(e)-c.right;T(i,"max-width",`${u}px`)}else{let u=o.footnoteEdge-n.calculateOffset(e)-l.top-c.top;T(i,"max-height",`${u}px`)}T(i,"overflow","hidden")}var id=class extends Hn{constructor(e,n){super();this.tableFormattingContext=e;this.processor=n}resolveLayoutMode(e){let n=this.tableFormattingContext.getRepetitiveElements();return!n||!n.doneInitialLayout?new rd(this.tableFormattingContext,this.processor):(e.sourceNode===this.tableFormattingContext.tableSourceNode&&!e.after&&n&&n.preventSkippingHeader(),new cd(this.tableFormattingContext,this.processor))}clearNodes(e){super.clearNodes(e);let n=this.tableFormattingContext.getRootViewNode(e);this.processor.removeColGroups(this.tableFormattingContext,n)}restoreState(e,n){super.restoreState(e,n),this.tableFormattingContext.finishFragment()}},rd=class extends fi{constructor(e,n){super(e);this.processor=n}doLayout(e,n){return this.processor.doInitialLayout(e,n)}},ad=class extends fn{constructor(t){super(t,null,t.overflow,0)}getMinBreakPenalty(){if(!this.isEdgeUpdated)throw new Error("EdgeBreakPosition.prototype.updateEdge not called");return(this.overflows?3:0)+(this.position.parent?this.position.parent.breakPenalty:0)}breakPositionChosen(t){t.fragmentLayoutConstraints.push(new ld(this.position.sourceNode))}},ld=class r{constructor(t){this.tableRootNode=t;d(this,"flagmentLayoutConstraintType","EntireTable")}allowLayout(t,e,n){return t.overflow,!1}nextCandidate(t){return!0}postLayout(t,e,n,s){e.sourceNode,mi.push({root:e.sourceNode,tableLayoutOption:{calculateBreakPositionsInside:!0}})}finishBreak(t,e){return v(!0)}equalsTo(t){return t instanceof r&&t.tableRootNode===this.tableRootNode}getPriorityOfFinishBreak(){return 0}},cd=class extends gi{constructor(e,n){super(e);this.processor=n}doLayout(e,n){let s=this.formattingContext.getRepetitiveElements();if(s&&!s.isAfterLastContent(e)){let o=new ud(e);n.fragmentLayoutConstraints.some(i=>o.equalsTo(i))||n.fragmentLayoutConstraints.unshift(o)}return this.processor.doLayout(e,n)}},ud=class r extends xo{constructor(e){super(e);d(this,"flagmentLayoutConstraintType","TableRow");d(this,"cellFragmentLayoutConstraints",[])}allowLayout(e,n,s){let o=this.getRepetitiveElements();return!o||s.pseudoParent||pn(this.nodeContext.viewNode)||!o.isEnableToUpdateState()?!0:!(n&&!e||e&&e.overflow)}nextCandidate(e){let n=Lt(this.nodeContext.formattingContext);return this.collectCellFragmentLayoutConstraints(e,n).some(o=>o.constraints.some(i=>i.nextCandidate(e)))?!0:super.nextCandidate(e)}postLayout(e,n,s,o){let i=Lt(this.nodeContext.formattingContext);if(this.cellFragmentLayoutConstraints=this.collectCellFragmentLayoutConstraints(n,i),this.cellFragmentLayoutConstraints.forEach(a=>{a.constraints.forEach(l=>{l.postLayout(e,a.breakPosition,s,o)})}),!e){let a=i.getRootViewNode(this.nodeContext);new ya().removeColGroups(i,a),this.removeDummyRowNodes(s)}super.postLayout(e,n,s,o)}finishBreak(e,n){let s=Lt(this.nodeContext.formattingContext),o=k("finishBreak"),i=this.cellFragmentLayoutConstraints.reduce((l,c)=>l.concat(c.constraints.map(u=>({constraint:u,breakPosition:c.breakPosition}))),[]),a=0;return o.loop(()=>{if(a<i.length){let l=i[a++];return l.constraint.finishBreak(l.breakPosition,n).thenReturn(!0)}else return v(!1)}).then(()=>{o.finish(!0)}),o.result().thenAsync(()=>super.finishBreak(e,n))}removeDummyRowNodes(e){if(!(!e||e.display!=="table-row"||!e.viewNode))for(;e.viewNode.previousElementSibling;){let n=e.viewNode.previousElementSibling;n.parentNode&&n.parentNode.removeChild(n)}}collectCellFragmentLayoutConstraints(e,n){return this.getCellFragemnts(e,n).map(s=>({constraints:s.fragment.pseudoColumn.getColumn().fragmentLayoutConstraints,breakPosition:s.breakPosition}))}getCellFragemnts(e,n){let s=Number.MAX_VALUE;e&&e.display==="table-row"&&(e.sourceNode,s=n.findRowIndexBySourceNode(e.sourceNode)+1),s=Math.min(n.cellFragments.length,s);let o=[];for(let i=0;i<s;i++)n.cellFragments[i]&&n.cellFragments[i].forEach(a=>{a&&o.push({fragment:a,breakPosition:a.findAcceptableBreakPosition().nodeContext})});return o}getElementsOffsetsForTableCell(e){let n=Lt(this.nodeContext.formattingContext),s=n.findCellFromColumn(e);return s?n.collectElementsOffsetOfUpperCells(s):n.collectElementsOffsetOfHighestColumn()}equalsTo(e){return e instanceof r?Lt(this.nodeContext.formattingContext)===Lt(e.nodeContext.formattingContext):!1}},SC=new ya;function NC(r,t,e,n,s,o){if(!t)return null;if(e===x.table){let i=r.parent;return new $n(i?i.formattingContext:null,r.sourceNode)}return null}function vC(r){return r instanceof $n?SC:null}_e("RESOLVE_FORMATTING_CONTEXT",NC);_e("RESOLVE_LAYOUT_PROCESSOR",vC);function xf(r){return r.reduce((t,e)=>t+e,0)/r.length}function Ef(r){let t=xf(r);return xf(r.map(e=>{let n=e-t;return n*n}))}var dd=class{constructor(t,e){this.layoutResult=t;this.penalty=e}};function Ci(r){return r.vertical?r.width:r.height}function bi(r,t){r.vertical?r.width=t:r.height=t}var Ea=class{constructor(t,e,n){this.layoutContainer=t;this.columnGenerator=e;this.regionPageFloatLayoutContext=n;d(this,"originalContainerBlockSize");this.originalContainerBlockSize=Ci(t)}balanceColumns(t){let e=k("ColumnBalancer#balanceColumns");this.preBalance(t),this.savePageFloatLayoutContexts(t),this.layoutContainer.clear();let n=[this.createTrialResult(t)];return e.loopWithFrame(s=>{if(!this.hasNextCandidate(n)){s.breakLoop();return}this.updateCondition(n),this.columnGenerator().then(o=>{if(this.savePageFloatLayoutContexts(o),this.layoutContainer.clear(),!o){s.breakLoop();return}n.push(this.createTrialResult(o)),s.continueLoop()})}).then(()=>{let s=n.reduce((o,i)=>i.penalty<o.penalty?i:o,n[0]);this.restoreContents(s.layoutResult),this.postBalance(),e.finish(s.layoutResult)}),e.result()}createTrialResult(t){let e=this.calculatePenalty(t);return new dd(t,e)}preBalance(t){}postBalance(){bi(this.layoutContainer,this.originalContainerBlockSize)}savePageFloatLayoutContexts(t){let e=this.regionPageFloatLayoutContext.detachChildren();t&&(t.columnPageFloatLayoutContexts=e)}restoreContents(t){let e=this.layoutContainer.element;t.columns.forEach(n=>{e.appendChild(n.element)}),t.columnPageFloatLayoutContexts,this.regionPageFloatLayoutContext.attachChildren(t.columnPageFloatLayoutContexts)}},pd=1;function Nf(r){let t=r[r.length-1];if(t.penalty===0)return!1;let e=r[r.length-2];if(e&&t.penalty>=e.penalty)return!1;let n=t.layoutResult.columns,s=Math.max.apply(null,n.map(i=>i.computedBlockSize)),o=Math.max.apply(null,n.map(i=>i.getMaxBlockSizeOfPageFloats()));return s>o+pd}function vf(r,t){let e=r[r.length-1].layoutResult.columns,s=Math.max.apply(null,e.map(o=>isNaN(o.blockDistanceToBlockEndFloats)?o.computedBlockSize:o.computedBlockSize-o.blockDistanceToBlockEndFloats+pd))-pd;s<Ci(t)?bi(t,s):bi(t,Ci(t)-1)}var hd=class extends Ea{constructor(e,n,s,o){super(s,e,n);this.columnCount=o;d(this,"originalPosition",null);d(this,"foundUpperBound",!1)}preBalance(e){let s=e.columns.reduce((o,i)=>o+i.computedBlockSize,0);bi(this.layoutContainer,s/this.columnCount),this.originalPosition=e.position}checkPosition(e){return this.originalPosition?this.originalPosition.isSamePosition(e):e===null}calculatePenalty(e){if(!this.checkPosition(e.position))return 1/0;let n=e.columns;return Sf(n)?1/0:Math.max.apply(null,n.map(s=>s.computedBlockSize))}hasNextCandidate(e){if(e.length===1)return!0;if(this.foundUpperBound)return Nf(e);{let n=e[e.length-1];return this.checkPosition(n.layoutResult.position)&&!Sf(n.layoutResult.columns)?(this.foundUpperBound=!0,!0):Ci(this.layoutContainer)<this.originalContainerBlockSize}}updateCondition(e){if(this.foundUpperBound)vf(e,this.layoutContainer);else{let n=Math.min(this.originalContainerBlockSize,Ci(this.layoutContainer)+this.originalContainerBlockSize*.1);bi(this.layoutContainer,n)}}};function Sf(r){if(r.length<=1)return!1;let t=r[r.length-1].computedBlockSize;return r.slice(0,r.length-1).every(n=>t>n.computedBlockSize)}var fd=class extends Ea{constructor(t,e,n){super(n,t,e)}calculatePenalty(t){if(t.columns.every(n=>n.computedBlockSize===0))return 1/0;let e=t.columns.filter(n=>!n.pageBreakType).map(n=>n.computedBlockSize);return Ef(e)}hasNextCandidate(t){return Nf(t)}updateCondition(t){vf(t,this.layoutContainer)}};function Tf(r,t,e,n,s,o,i){if(t===x.auto)return null;{let a=i.positions.length===0,l=o[o.length-1],c=!!(l&&l.pageBreakType);return a||c?new hd(e,n,s,r):t===x.balance_all?new fd(e,n,s):(x.balance,null)}}var yi=class{constructor(t,e,n){d(this,"endStuckFixed");d(this,"endFixed");d(this,"endSlipped");this.endStuckFixed=t,this.endFixed=e,this.endSlipped=n}},gd=class{constructor(){d(this,"map",[])}getMaxFixed(){return this.map.length==0?0:this.map[this.map.length-1].endFixed}getMaxSlipped(){return this.map.length==0?0:this.map[this.map.length-1].endSlipped}addStuckRange(t){if(this.map.length==0)this.map.push(new yi(t,t,t));else{let e=this.map[this.map.length-1],n=e.endSlipped+t-e.endFixed;e.endFixed==e.endStuckFixed?(e.endFixed=t,e.endStuckFixed=t,e.endSlipped=n):this.map.push(new yi(t,t,n))}}addSlippedRange(t){this.map.length==0?this.map.push(new yi(t,0,0)):this.map[this.map.length-1].endFixed=t}slippedByFixed(t){let e=gt(this.map.length,s=>t<=this.map[s].endFixed),n=this.map[e];return n.endSlipped-Math.max(0,n.endStuckFixed-t)}fixedBySlipped(t){let e=gt(this.map.length,s=>t<=this.map[s].endSlipped),n=this.map[e];return n.endStuckFixed-(n.endSlipped-t)}},md=class r{constructor(t,e,n,s,o,i,a,l){this.context=t;this.style=e;this.offset=n;this.isRoot=s;this.flowChunk=o;this.atBlockStart=i;this.atFlowStart=a;this.isParentBoxDisplayed=l;d(this,"flowName");d(this,"isBlockValue",null);d(this,"hasBoxValue",null);d(this,"styleValues",{});d(this,"beforeBox",null);d(this,"afterBox",null);d(this,"breakBefore",null);if(this.flowName=o.flowName,this.hasBox()){let c=e._pseudos;if(c&&c.before){let u=new r(t,c.before,n,!1,o,this.isBlock(),a,!0),p=u.styleValue("content");St(p)&&(this.beforeBox=u,this.breakBefore=u.breakBefore)}}this.breakBefore=Ve(this.getBreakValue("before"),this.breakBefore),this.atFlowStart&&De(this.breakBefore)&&(o.breakBefore=Ve(o.breakBefore,this.breakBefore))}buildAfterPseudoElementBox(t,e,n){if(this.hasBox()){let s=this.style._pseudos;if(s&&s.after){let o=new r(this.context,s.after,t,!1,this.flowChunk,e,n,!0),i=o.styleValue("content");St(i)&&(this.afterBox=o)}}}styleValue(t,e){if(!(t in this.styleValues)){let n=this.style[t];this.styleValues[t]=n?n.evaluate(this.context,t):e||null}return this.styleValues[t]}displayValue(){return this.styleValue("display",x.inline)}isBlock(){if(this.isBlockValue===null){let t=this.displayValue(),e=this.styleValue("position"),n=this.styleValue("float");this.isBlockValue=Xr(t,e,n,this.isRoot)}return this.isBlockValue}hasBox(){return this.hasBoxValue===null&&(this.hasBoxValue=this.isParentBoxDisplayed&&this.displayValue()!==x.none),this.hasBoxValue}getBreakValue(t){let e=null;if(this.isBlock()){let n=this.styleValue(`break-${t}`);n&&(e=n.toString())}return e}},Cd=class{constructor(t){this.context=t;d(this,"stack",[]);d(this,"atBlockStart",!0);d(this,"atFlowStart",!0);d(this,"atStartStack",[])}empty(){return this.stack.length===0}lastBox(){return this.stack[this.stack.length-1]}lastFlowName(){let t=this.lastBox();return t?t.flowChunk.flowName:null}isCurrentBoxDisplayed(){return this.stack.every(t=>t.displayValue()!==x.none)}push(t,e,n,s){let o=this.lastBox();s&&o&&s.flowName!==o.flowName&&this.atStartStack.push({atBlockStart:this.atBlockStart,atFlowStart:this.atFlowStart});let i=s||o.flowChunk,a=this.atFlowStart||!!s,l=this.isCurrentBoxDisplayed(),c=new md(this.context,t,e,n,i,a||this.atBlockStart,a,l);return this.stack.push(c),this.atBlockStart=c.hasBox()?!c.beforeBox&&c.isBlock():this.atBlockStart,this.atFlowStart=c.hasBox()?!c.beforeBox&&a:this.atFlowStart,c}encounteredTextNode(t){let e=this.lastBox();if((t.nodeType===Node.TEXT_NODE||t.nodeType===Node.CDATA_SECTION_NODE)&&(this.atBlockStart||this.atFlowStart)&&e.hasBox()){let n=e.styleValue("white-space",x.normal).toString(),s=Hr(n);s&&!he(t,s)&&(this.atBlockStart=!1,this.atFlowStart=!1)}}pop(t){let e=this.stack.pop();if(e.buildAfterPseudoElementBox(t,this.atBlockStart,this.atFlowStart),this.atFlowStart&&e.afterBox){let s=e.afterBox.getBreakValue("before");e.flowChunk.breakBefore=Ve(e.flowChunk.breakBefore,s)}let n=this.lastBox();if(n)if(n.flowName===e.flowName)e.hasBox()&&(this.atBlockStart=this.atFlowStart=!1);else{let s=this.atStartStack.pop();this.atBlockStart=s.atBlockStart,this.atFlowStart=s.atFlowStart}return e}nearestBlockStartOffset(t){if(!t.atBlockStart)return t.offset;let e=this.stack.length-1,n=this.stack[e];for(n===t&&(e--,n=this.stack[e]);e>=0;){if(n.flowName!==t.flowName)return t.offset;if(!n.atBlockStart||n.isRoot)return n.offset;t=n,n=this.stack[--e]}throw new Error("No block start offset found!")}},xi=class{constructor(t,e,n,s,o,i,a,l){this.xmldoc=t;this.scope=n;this.context=s;this.primaryFlows=o;this.validatorSet=i;this.counterListener=a;d(this,"root");d(this,"cascadeHolder");d(this,"last");d(this,"rootStyle",{});d(this,"styleMap",{});d(this,"flows",{});d(this,"flowChunks",[]);d(this,"flowListener",null);d(this,"flowToReach",null);d(this,"idToReach",null);d(this,"cascade");d(this,"offsetMap");d(this,"primary",!0);d(this,"primaryStack",[]);d(this,"rootBackgroundAssigned",!1);d(this,"rootLayoutAssigned",!1);d(this,"lastOffset");d(this,"breakBeforeValues",{});d(this,"boxStack");d(this,"bodyReached",!0);this.root=t.root,this.cascadeHolder=e,this.last=this.root,this.cascade=e.createInstance(s,a,l,t.lang),this.offsetMap=new gd;let c=t.getElementOffset(this.root);this.lastOffset=c,this.boxStack=new Cd(s),this.offsetMap.addStuckRange(c);let u=this.getAttrStyle(this.root);switch(this.cascade.pushElement(this,this.root,u,c),this.postprocessTopStyle(u,!1),this.root.namespaceURI){case"http://www.w3.org/1999/xhtml":this.bodyReached=!1;break}this.primaryStack.push(!0),this.styleMap={},this.styleMap[`e${c}`]=u,this.lastOffset++,this.replayFlowElementsFromOffset(-1)}hasProp(t,e,n){let s=t[n];return s&&s.evaluate(this.context)!==e[n]}transferPropsToRoot(t,e){for(let n in e){let s=t[n];if(s)this.rootStyle[n]=s,delete t[n];else{let o=e[n];o&&(this.rootStyle[n]=new M(o,fc))}}}postprocessTopStyle(t,e){var n;if(e)for(let s of["writing-mode","direction"])t[s]&&!(e&&this.rootStyle[s])&&(this.rootStyle[s]=t[s]);else for(let s in t)Wn(s)&&(this.rootStyle[s]=t[s]);if(!this.rootBackgroundAssigned){let s=this.hasProp(t,this.validatorSet.backgroundProps,"background-color")?t["background-color"].evaluate(this.context):null,o=this.hasProp(t,this.validatorSet.backgroundProps,"background-image")?t["background-image"].evaluate(this.context):null;(s&&!U(s)||o&&!U(o))&&(this.transferPropsToRoot(t,this.validatorSet.backgroundProps),this.rootBackgroundAssigned=!0)}if(!this.rootLayoutAssigned){for(let s=0;s<wf.length;s++)if(this.hasProp(t,this.validatorSet.layoutProps,wf[s])){this.transferPropsToRoot(t,this.validatorSet.layoutProps),this.rootLayoutAssigned=!0;break}}if(!e){let s=t["font-size"],o=!0;if(s&&!U(s.value)){let l=s.evaluate(this.context);if(l instanceof P){let c=l.num;switch(l.unit){case"em":case"rem":c*=this.context.initialFontSize;break;case"ex":c*=this.context.initialFontSize*X.ex/X.em;break;case"%":c*=this.context.initialFontSize/100;break;case"lh":case"rlh":c*=this.context.initialFontSize*X.lh/X.em;break;default:{let u=X[l.unit];u&&(c*=u),o=!1}}this.context.rootFontSize=c,this.context.isRelativeRootFontSize=o}}let i=(n=this.context.rootFontSize)!=null?n:this.context.initialFontSize,a=t["line-height"];if(a&&!U(a.value)){let l=a.evaluate(this.context);if(l instanceof lt)this.context.rootLineHeight=l.num*i;else if(l instanceof P){let c=l.num;switch(l.unit){case"em":case"rem":c*=i;break;case"ex":c*=i*X.ex/X.em;break;case"%":c*=i/100;break;case"lh":case"rlh":c*=this.context.initialFontSize*X.lh/X.em;break;default:{let u=X[l.unit];u&&(c*=u)}}this.context.rootLineHeight=c}}else this.context.rootLineHeight=this.context.fontSize()*X.lh/X.em}}getTopContainerStyle(){let t=0;for(;!this.bodyReached&&(t+=5e3,this.styleUntil(t,0)!=Number.POSITIVE_INFINITY););return this.rootStyle}getAttrStyle(t){if(t.style instanceof CSSStyleDeclaration){let e=t.getAttribute("style");if(e)return Qh(this.scope,this.validatorSet,this.xmldoc.url,e)}return{}}getReachedOffset(){return this.lastOffset}replayFlowElementsFromOffset(t){if(t>=this.lastOffset)return;let e=this.context,n=this.xmldoc.getElementOffset(this.root);if(t<n){let i=this.getStyle(this.root,!1);let a=de(i,"flow-into"),l=a?a.evaluate(e,"flow-into").toString():"body",c=this.encounteredFlowElement(l,i,this.root,n);this.boxStack.empty()&&this.boxStack.push(i,n,!0,c)}let s=this.xmldoc.getNodeByOffset(t),o=this.xmldoc.getNodeOffset(s,0,!1);if(!(o>=this.lastOffset))for(;;){if(s.nodeType!=1)o+=s.textContent.length;else{let a=s,l=this.getStyle(a,!1),c=l["flow-into"];if(c){let u=c.evaluate(e,"flow-into").toString();this.encounteredFlowElement(u,l,a,o)}o++}if(o>=this.lastOffset)break;let i=s.firstChild;if(i==null){for(;i=s.nextSibling,!i;)if(s=s.parentNode,s===this.root)return}s=i}}resetFlowChunkStream(t){this.flowListener=t;for(let e=0;e<this.flowChunks.length;e++)this.flowListener.encounteredFlowChunk(this.flowChunks[e],this.flows[this.flowChunks[e].flowName])}styleUntilFlowIsReached(t){this.flowToReach=t;let e=0;for(;!(this.flowToReach==null||(e+=5e3,this.styleUntil(e,0)==Number.POSITIVE_INFINITY)););}styleUntilIdIsReached(t){if(!t)return;this.idToReach=t;let e=0;for(;!(!this.idToReach||(e+=5e3,this.styleUntil(e,0)===Number.POSITIVE_INFINITY)););this.idToReach=null}encounteredFlowElement(t,e,n,s){let o=0,i=Number.POSITIVE_INFINITY,a=!1,l=!1,c=!1,u=e["flow-options"];if(u){let E=$p(u.evaluate(this.context,"flow-options"));a=!!E.exclusive,l=!!E.static,c=!!E.last}let p=e["flow-linger"];p&&(i=Ul(p.evaluate(this.context,"flow-linger"),Number.POSITIVE_INFINITY));let h=e["flow-priority"];h&&(o=Ul(h.evaluate(this.context,"flow-priority"),0));let f=this.breakBeforeValues[s]||null,g=this.flows[t];if(!g){let E=this.boxStack.lastFlowName();g=this.flows[t]=new Br(t,E)}let m=new Or(t,n,s,o,i,a,l,c,f);return this.flowChunks.push(m),this.flowToReach==t&&(this.flowToReach=null),this.flowListener&&this.flowListener.encounteredFlowChunk(m,g),m}registerForcedBreakOffset(t,e,n){if(De(t)){let o=this.flows[n].forcedBreakOffsets;(o.length===0||o[o.length-1]<e)&&o.push(e)}let s=this.breakBeforeValues[e];this.breakBeforeValues[e]=Ve(s,t)}styleUntil(t,e){let n=-1,s;if(t<=this.lastOffset&&(s=this.offsetMap.slippedByFixed(t),n=s+e,n<this.offsetMap.getMaxSlipped()))return this.offsetMap.fixedBySlipped(n);if(this.last==null)return Number.POSITIVE_INFINITY;let o=this.context;for(;;){let i=this.last.firstChild;if(i==null)for(;;){if(this.last.nodeType==1){this.cascade.popElement(this.last),this.primary=this.primaryStack.pop();let a=this.boxStack.pop(this.lastOffset),l=null;if(a.afterBox){let c=a.afterBox.getBreakValue("before");this.registerForcedBreakOffset(c,a.afterBox.atBlockStart?this.boxStack.nearestBlockStartOffset(a):a.afterBox.offset,a.flowName),l=a.afterBox.getBreakValue("after")}l=Ve(l,a.getBreakValue("after")),this.registerForcedBreakOffset(l,this.lastOffset,a.flowName)}if(i=this.last.nextSibling,i)break;if(this.last=this.last.parentNode,this.last===this.root)return this.last=null,t<this.lastOffset&&(n<0&&(s=this.offsetMap.slippedByFixed(t),n=s+e),n<=this.offsetMap.getMaxSlipped())?this.offsetMap.fixedBySlipped(n):Number.POSITIVE_INFINITY}if(this.last=i,this.last.nodeType!=1)this.lastOffset+=this.last.textContent.length,this.boxStack.encounteredTextNode(this.last),this.primary?this.offsetMap.addStuckRange(this.lastOffset):this.offsetMap.addSlippedRange(this.lastOffset);else{let a=this.last,l=this.getAttrStyle(a);this.primaryStack.push(this.primary),this.cascade.pushElement(this,a,l,this.lastOffset);let c=a.getAttribute("id")||a.getAttributeNS("http://www.w3.org/XML/1998/namespace","id");c&&c===this.idToReach&&(this.idToReach=null),!this.bodyReached&&a.localName=="body"&&a.parentNode==this.root&&(this.postprocessTopStyle(l,!0),this.bodyReached=!0);let u,p=l["flow-into"];if(p){let f=p.evaluate(o,"flow-into").toString(),g=this.encounteredFlowElement(f,l,a,this.lastOffset);this.primary=!!this.primaryFlows[f],u=this.boxStack.push(l,this.lastOffset,a===this.root,g)}else u=this.boxStack.push(l,this.lastOffset,a===this.root),a===this.xmldoc.body&&(u.breakBefore=Ve(u.flowChunk.breakBefore,u.breakBefore));let h=this.boxStack.nearestBlockStartOffset(u);if(h===0){let f=l.page,g=f&&!U(f.value)&&f.value.toString();g&&g.toLowerCase()!=="auto"&&(this.cascade.firstPageType=g)}if(this.registerForcedBreakOffset(u.breakBefore,h,u.flowName),u.beforeBox){let f=u.beforeBox.getBreakValue("after");this.registerForcedBreakOffset(f,u.beforeBox.atBlockStart?h:u.offset,u.flowName)}if(this.primary&&u.displayValue()===x.none&&(this.primary=!1),this.styleMap[`e${this.lastOffset}`]=l,this.lastOffset++,this.primary?this.offsetMap.addStuckRange(this.lastOffset):this.offsetMap.addSlippedRange(this.lastOffset),this.bodyReached&&h===0)continue;if(t<this.lastOffset&&(n<0&&(s=this.offsetMap.slippedByFixed(t),n=s+e),n<=this.offsetMap.getMaxSlipped()))return this.offsetMap.fixedBySlipped(n)}}}getStyle(t,e){let n=this.xmldoc.getElementOffset(t),s=`e${n}`;return e&&(n=this.xmldoc.getNodeOffset(t,0,!0)),this.lastOffset<=n&&this.styleUntil(n,0),this.styleMap[s]}processContent(t,e,n){}},wf=["column-count","column-width","column-fill"];var jn=class{constructor(t){this.validator=t;d(this,"success",null);d(this,"failure",null);d(this,"code",0)}isSpecial(){return this.code!=0}markAsStartGroup(){this.code=-1}isStartGroup(){return this.code==-1}markAsEndGroup(){this.code=-2}isEndGroup(){return this.code==-2}markAsStartAlternate(t){this.code=2*t+1}isStartAlternate(){return this.code>0&&this.code%2!=0}markAsEndAlternate(t){this.code=2*t+2}isEndAlternate(){return this.code>0&&this.code%2==0}getAlternate(){return Math.floor((this.code-1)/2)}},xn=class{constructor(t,e){this.where=t;this.success=e;d(this,"what",-1)}};var ks=class r{constructor(){d(this,"nodes",[]);d(this,"connections",[]);d(this,"match",[]);d(this,"nomatch",[]);d(this,"error",[]);d(this,"emptyHead",!0)}connect(t,e){for(let n=0;n<t.length;n++)this.connections[t[n]].what=e;t.splice(0,t.length)}clone(){let t=new r;for(let e=0;e<this.nodes.length;e++){let n=this.nodes[e],s=new jn(n.validator);s.code=n.code,t.nodes.push(s)}for(let e=0;e<this.connections.length;e++){let n=this.connections[e],s=new xn(n.where,n.success);s.what=n.what,t.connections.push(s)}return t.match.push(...this.match),t.nomatch.push(...this.nomatch),t.error.push(...this.error),t}addSpecialToArr(t,e,n){let s=this.nodes.length,o=new jn(Pf);n>=0?e?o.markAsStartAlternate(n):o.markAsEndAlternate(n):e?o.markAsStartGroup():o.markAsEndGroup(),this.nodes.push(o),this.connect(t,s);let i=new xn(s,!0),a=new xn(s,!1);t.push(this.connections.length),this.connections.push(a),t.push(this.connections.length),this.connections.push(i)}endSpecialGroup(){let t=[this.match,this.nomatch,this.error];for(let e=0;e<t.length;e++)this.addSpecialToArr(t[e],!1,-1)}startSpecialGroup(){if(this.nodes.length)throw new Error("invalid call");this.addSpecialToArr(this.match,!0,-1)}endClause(t){this.addSpecialToArr(this.match,!1,t)}startClause(t){if(this.nodes.length)throw new Error("invalid call");let e=new jn(Pf);e.markAsStartAlternate(t),this.nodes.push(e);let n=new xn(0,!0),s=new xn(0,!1);this.nomatch.push(this.connections.length),this.connections.push(s),this.match.push(this.connections.length),this.connections.push(n)}addPrimitive(t){let e=this.nodes.length;this.nodes.push(new jn(t));let n=new xn(e,!0),s=new xn(e,!1);this.connect(this.match,e),this.emptyHead?(this.nomatch.push(this.connections.length),this.emptyHead=!1):this.error.push(this.connections.length),this.connections.push(s),this.match.push(this.connections.length),this.connections.push(n)}isSimple(){return this.nodes.length==1&&!this.nodes[0].isSpecial()}isPrimitive(){return this.isSimple()&&this.nodes[0].validator instanceof Ce}addGroup(t,e){if(t.nodes.length==0)return;let n=this.nodes.length;if(e==4&&n==1&&t.isPrimitive()&&this.isPrimitive()){this.nodes[0].validator=this.nodes[0].validator.combine(t.nodes[0].validator);return}for(let o=0;o<t.nodes.length;o++)this.nodes.push(t.nodes[o]);e==4?(this.emptyHead=!0,this.connect(this.nomatch,n)):this.connect(this.match,n);let s=this.connections.length;for(let o=0;o<t.connections.length;o++){let i=t.connections[o];i.where+=n,i.what>=0&&(i.what+=n),this.connections.push(i)}for(let o=0;o<t.match.length;o++)this.match.push(t.match[o]+s);if(e==3&&this.connect(this.match,n),e==2||e==3)for(let o=0;o<t.nomatch.length;o++)this.match.push(t.nomatch[o]+s);else if(this.emptyHead){for(let o=0;o<t.nomatch.length;o++)this.nomatch.push(t.nomatch[o]+s);this.emptyHead=t.emptyHead}else for(let o=0;o<t.nomatch.length;o++)this.error.push(t.nomatch[o]+s);for(let o=0;o<t.error.length;o++)this.error.push(t.error[o]+s);t.nodes=null,t.connections=null}finish(t,e){let n=this.nodes.length;this.nodes.push(t),this.nodes.push(e),this.connect(this.match,n),this.connect(this.nomatch,n+1),this.connect(this.error,n+1);for(let s of this.connections)s.success?this.nodes[s.where].success=this.nodes[s.what]:this.nodes[s.where].failure=this.nodes[s.what];for(let s=0;s<n;s++)if(this.nodes[s].failure==null||this.nodes[s].success==null)throw new Error("Invalid validator state");return this.nodes[0]}},kC=1,Af=2,Lf=4,Ps=8,Sa=16,bd=32,Na=64,Rf=128,Ei=256,Si=512,yd=1024,If=2048,Vf=4096,Ff=8192,va=class extends at{constructor(){super()}validateForShorthand(t,e){let n=t[e].visit(this);return n?[n]:null}},Ce=class r extends va{constructor(e,n,s){super();this.allowed=e;this.idents=n;this.units=s}visitEmpty(e){return this.allowed&kC?e:null}visitSlash(e){return this.allowed&If?e:null}visitStr(e){return this.allowed&Af?e:null}visitIdent(e){let n=this.idents[e.name.toLowerCase()];return n||(this.allowed&Lf||this.allowed&Na&&CSS.supports("color",e.name)?e:null)}visitNumeric(e){return e.num==0&&!(this.allowed&Si)?e.unit=="%"&&this.allowed&yd?e:null:e.num<0&&!(this.allowed&Ei)?null:this.units[e.unit]?e:null}visitNum(e){return e.num==0?this.allowed&Si?e:null:e.num<=0&&!(this.allowed&Ei)?null:this.allowed&Sa?e:null}visitInt(e){if(e.num==0)return this.allowed&Si?e:null;if(e.num<=0&&!(this.allowed&Ei))return null;if(this.allowed&(bd|Sa))return e;let n=this.idents[`${e.num}`];return n||null}visitHexColor(e){return this.allowed&Na&&/^([0-9A-F]{3,4}|([0-9A-F]{2}){3,4})$/i.test(e.hex)?e:null}visitURL(e){return this.allowed&Rf?e:null}visitURange(e){return this.allowed&Vf?e:null}visitSpaceList(e){return null}visitCommaList(e){return null}visitFunc(e){return this.allowed&Na&&CSS.supports("color",e.toString())||this.allowed&Ff&&CSS.supports("background-image",e.toString())||e.name==="calc"&&this.allowed&(Ps|Sa|bd|Ei|Si|yd)?e:null}visitExpr(e){return this.allowed&2046?e:null}combine(e){let n={},s={};for(let o in this.idents)n[o]=this.idents[o];for(let o in e.idents)n[o]=e.idents[o];for(let o in this.units)s[o]=this.units[o];for(let o in e.units)s[o]=e.units[o];return new r(this.allowed|e.allowed,n,s)}},W={},Pf=new Ce(0,W,W),Ni=class extends va{constructor(e){super();d(this,"successTerminal");d(this,"failureTerminal");d(this,"first");this.successTerminal=new jn(null),this.failureTerminal=new jn(null),this.first=e.finish(this.successTerminal,this.failureTerminal)}validateList(e,n,s){let o=n?[]:e,i=this.first,a=s,l=null,c=null;for(;i!==this.successTerminal&&i!==this.failureTerminal;){if(a>=e.length){i=i.failure;continue}let u=e[a],p=u;if(i.isSpecial()){let h=!0;i.isStartGroup()?(l?l.push(c):l=[c],c=[]):i.isEndGroup()?l.length>0?c=l.pop():c=null:i.isEndAlternate()?c[i.getAlternate()]="taken":h=c[i.getAlternate()]==null,i=h?i.success:i.failure}else{if(a==0&&!n&&i.validator instanceof As&&this instanceof As){if(p=new q(e).visit(i.validator),p){a=e.length,i=i.success;continue}}else if(a==0&&!n&&i.validator instanceof vi&&this instanceof As){if(p=new ge(e).visit(i.validator),p){a=e.length,i=i.success;continue}}else p=u.visit(i.validator);if(!p){i=i.failure;continue}if(p!==u&&e===o){o=[];for(let h=0;h<a;h++)o[h]=e[h]}e!==o&&(o[a-s]=p),a++,i=i.success}}return i===this.successTerminal&&(n?o.length>0:a==e.length)?o:null}validateSingle(e){let n=null,s=this.first;for(;s!==this.successTerminal&&s!==this.failureTerminal;){if(!e){s=s.failure;continue}if(s.isSpecial()){s=s.success;continue}if(n=e.visit(s.validator),!n){s=s.failure;continue}e=null,s=s.success}return s===this.successTerminal?n:null}visitEmpty(e){return this.validateSingle(e)}visitSlash(e){return this.validateSingle(e)}visitStr(e){return this.validateSingle(e)}visitIdent(e){return this.validateSingle(e)}visitNumeric(e){return this.validateSingle(e)}visitNum(e){return this.validateSingle(e)}visitInt(e){return this.validateSingle(e)}visitHexColor(e){return this.validateSingle(e)}visitURL(e){return this.validateSingle(e)}visitURange(e){return this.validateSingle(e)}visitSpaceList(e){return null}visitCommaList(e){return null}visitFunc(e){return this.validateSingle(e)}visitExpr(e){return null}},As=class extends Ni{constructor(t){super(t)}visitSpaceList(t){let e=this.validateList(t.values,!1,0);return e===t.values?t:e?new q(e):null}visitCommaList(t){let e=this.first,n=!1;for(;e;){if(e.validator instanceof vi){n=!0;break}e=e.failure}if(n){let s=this.validateList(t.values,!1,0);return s===t.values?t:s?new ge(s):null}return null}validateForShorthand(t,e){return this.validateList(t,!0,e)}},vi=class extends Ni{constructor(t){super(t)}visitSpaceList(t){return this.validateSingle(t)}visitCommaList(t){let e=this.validateList(t.values,!1,0);return e===t.values?t:e?new ge(e):null}validateForShorthand(t,e){let n=this.first,s;for(;n!==this.failureTerminal;){if(s=n.validator.validateForShorthand(t,e),s)return s;n=n.failure}return null}},xd=class extends Ni{constructor(e,n){super(n);this.name=e}validateSingle(e){return null}visitFunc(e){if(e.name.toLowerCase()!=this.name)return null;let n=this.validateList(e.values,!1,0);return n===e.values?e:n?new Pt(e.name,n):null}},Ta=class{tryParse(t,e,n){return e}success(t,e){}},wa=class extends Ta{constructor(e,n){super();this.name=n;d(this,"validator");this.validator=e.validators[this.name]}tryParse(e,n,s){if(s.values[this.name])return n;let o=this.validator.validateForShorthand(e,n);if(o){let i=o.length,a=i>1?new q(o):o[0];return this.success(a,s),n+i}return n}success(e,n){n.values[this.name]=e}},Ed=class extends wa{constructor(e,n){super(e,n[0]);this.names=n}success(e,n){for(let s=0;s<this.names.length;s++)n.values[this.names[s]]=e}},Sd=class extends Ta{constructor(e,n){super();this.nodes=e;this.slash=n}tryParse(e,n,s){let o=n;if(this.slash)if(e[n]==$s){if(++n==e.length)return o}else return o;let i=this.nodes[0].tryParse(e,n,s);if(i==n)return o;n=i;for(let a=1;a<this.nodes.length&&n<e.length&&(i=this.nodes[a].tryParse(e,n,s),i!=n);a++)n=i;return n}},Ti=class extends at{constructor(){super(...arguments);d(this,"syntax",null);d(this,"propList",null);d(this,"error",!1);d(this,"values",{});d(this,"validatorSet",null)}setOwner(e){this.validatorSet=e}syntaxNodeForProperty(e){return new wa(this.validatorSet,e)}clone(){let e=new this.constructor;return e.syntax=this.syntax,e.propList=this.propList,e.validatorSet=this.validatorSet,e}init(e,n){this.syntax=e,this.propList=n}finish(e,n){var s,o;if(!this.error){for(let i of this.propList)n.simpleProperty(i,(o=(s=this.values[i])!=null?s:this.validatorSet.defaultValues[i])!=null?o:x.initial,e);return!0}return!1}propagateDefaultingValue(e,n,s){for(let o of this.propList)s.simpleProperty(o,e,n)}validateList(e){return this.error=!0,0}validateSingle(e){return this.validateList([e]),null}visitEmpty(e){return this.validateSingle(e)}visitStr(e){return this.validateSingle(e)}visitIdent(e){return this.validateSingle(e)}visitNumeric(e){return this.validateSingle(e)}visitNum(e){return this.validateSingle(e)}visitInt(e){return this.validateSingle(e)}visitHexColor(e){return this.validateSingle(e)}visitURL(e){return this.validateSingle(e)}visitSpaceList(e){return this.validateList(e.values),null}visitCommaList(e){return this.error=!0,null}visitFunc(e){return this.validateSingle(e)}visitExpr(e){return this.validateSingle(e)}},Yn=class extends Ti{constructor(){super()}validateList(t){let e=0,n=0;for(;e<t.length;){let s=this.syntax[n].tryParse(t,e,this);if(s>e){e=s,n=0;continue}if(++n==this.syntax.length){this.error=!0;break}}return e}},Pa=class extends Ti{constructor(){super()}validateList(t){if(t.length>this.syntax.length||t.length==0)return this.error=!0,0;for(let e=0;e<this.syntax.length;e++){let n=e;for(;n>=t.length;)n=n==1?0:n-2;if(this.syntax[e].tryParse(t,n,this)!=n+1)return this.error=!0,0}return t.length}createSyntaxNode(){return new Ed(this.validatorSet,this.propList)}},Nd=class extends Ti{constructor(){super()}validateList(t){let e=t.length;for(let n=0;n<t.length;n++)if(t[n]===$s){e=n;break}if(e>this.syntax.length||t.length==0)return this.error=!0,0;for(let n=0;n<this.syntax.length;n++){let s=n;for(;s>=e;)s=s==1?0:s-2;let o;if(e+1<t.length)for(o=e+n+1;o>=t.length;)o=o-(o==e+2?1:2);else o=s;let i=[t[s],t[o]];if(this.syntax[n].tryParse(i,0,this)!=2)return this.error=!0,0}return t.length}},vd=class extends Yn{constructor(){super()}mergeIn(t,e){var n,s;for(let o of this.propList){let i=(s=(n=e[o])!=null?n:this.validatorSet.defaultValues[o])!=null?s:x.initial,a=t[o];a||(a=[],t[o]=a),a.push(i)}}visitCommaList(t){let e={};for(let n=0;n<t.values.length;n++)if(this.values={},t.values[n]instanceof ge?this.error=!0:(t.values[n].visit(this),this.mergeIn(e,this.values),this.values["background-color"]&&n!=t.values.length-1&&(this.error=!0)),this.error)return null;this.values={};for(let n in e)n=="background-color"?this.values[n]=e[n].pop():this.values[n]=new ge(e[n]);return null}},Td=class extends Yn{constructor(){super()}init(t,e){super.init(t,e),this.propList.push("font-family","line-height","font-size","font-stretch","font-variant-ligatures","font-variant-caps","font-variant-numeric","font-variant-east-asian")}validateList(t){let e=super.validateList(t),n=this.values["font-variant_css2"];n&&(delete this.values["font-variant_css2"],this.values["font-variant-caps"]=n);let s=this.values["font-stretch_css3"];if(s&&(delete this.values["font-stretch_css3"],this.values["font-stretch"]=s),e+2>t.length)return this.error=!0,e;this.error=!1;let o=this.validatorSet.validators;if(!t[e].visit(o["font-size"]))return this.error=!0,e;if(this.values["font-size"]=t[e++],t[e]===$s){if(e++,e+2>t.length)return this.error=!0,e;if(!t[e].visit(o["line-height"]))return this.error=!0,e;this.values["line-height"]=t[e++]}let i=e==t.length-1?t[e]:new q(t.slice(e,t.length));return i.visit(o["font-family"])?(this.values["font-family"]=i,t.length):(this.error=!0,e)}visitCommaList(t){if(t.values[0].visit(this),this.error)return null;let e=[this.values["font-family"]];for(let s=1;s<t.values.length;s++)e.push(t.values[s]);let n=new ge(e);return n.visit(this.validatorSet.validators["font-family"])?this.values["font-family"]=n:this.error=!0,null}visitIdent(t){let e=this.validatorSet.systemFonts[t.name];if(e)for(let n in e)this.values[n]=e[n];else this.error=!0;return null}},wd=class extends Yn{validateList(t){if(t.length===1&&t[0]instanceof Be)switch(t[0].name.toLowerCase()){case"normal":t=[this.validatorSet.defaultValues["text-autospace"],this.validatorSet.defaultValues["text-spacing-trim"]];break;case"auto":t=[x.auto,x.auto];break;case"none":t=[L("no-autospace"),L("space-all")];break}return super.validateList(t)}},AC=["unicode-bidi","direction","margin-block-start","margin-block-end","margin-inline-start","margin-inline-end","padding-block-start","padding-block-end","padding-inline-start","padding-inline-end","border-block-start-color","border-block-end-color","border-inline-start-color","border-inline-end-color","border-block-start-style","border-block-end-style","border-inline-start-style","border-inline-end-style","border-block-start-width","border-block-end-width","border-inline-start-width","border-inline-end-width","block-start","block-end","inline-start","inline-end","block-size","inline-size","max-block-size","max-inline-size","min-block-size","min-inline-size","behavior","bleed","conflicting-partitions","crop-offset","enabled","flow-consume","flow-from","flow-into","flow-linger","flow-options","flow-priority","font-display","font-size-adjust","font-stretch_css3","font-variant_css2","glyph-orientation-vertical","marks","min-page-height","min-page-width","repeat-on-break","required","required-partitions","ruby-align","shape-inside","snap-height","snap-width","template","text-decoration-skip","text-justify","text-zoom","unicode-range","utilization","wrap-flow"],Pd=class extends Yn{constructor(){super()}init(t,e){super.init(t,e);for(let n in this.validatorSet.validators)AC.includes(n)||this.propList.push(n)}validateList(t){return this.error=!0,0}},kf={SIMPLE:Yn,INSETS:Pa,INSETS_SLASH:Nd,COMMA:vd,FONT:Td,TEXT_SPACING:wd,ALL:Pd},kd=class{constructor(){d(this,"validators",{});d(this,"prefixes",{});d(this,"defaultValues",{});d(this,"namedValidators",{});d(this,"systemFonts",{});d(this,"shorthands",{});d(this,"layoutProps",{});d(this,"backgroundProps",{})}addReplacement(t,e){let n;if(e.type==3)n=new P(e.num,e.text);else if(e.type==7)n=new Xs(e.text);else if(e.type==1)n=L(e.text);else throw new Error("unexpected replacement");if(t.isPrimitive()){let o=t.nodes[0].validator.idents;for(let i in o)o[i]=n;return t}throw new Error("unexpected replacement")}newGroup(t,e){let n=new ks;if(t=="||"){for(let o=0;o<e.length;o++){let i=new ks;i.startClause(o),i.addGroup(e[o],1),i.endClause(o),n.addGroup(i,o==0?1:4)}let s=new ks;return s.startSpecialGroup(),s.addGroup(n,3),s.endSpecialGroup(),s}else{let s;switch(t){case" ":s=1;break;case"|":case"||":s=4;break;default:throw new Error("unexpected op")}for(let o=0;o<e.length;o++)n.addGroup(e[o],o==0?1:s);return n}}addCounts(t,e,n){let s=new ks;for(let o=0;o<e;o++)s.addGroup(t.clone(),1);if(n==Number.POSITIVE_INFINITY)s.addGroup(t,3);else for(let o=e;o<n;o++)s.addGroup(t.clone(),2);return s}primitive(t){let e=new ks;return e.addPrimitive(t),e}newFunc(t,e){let n;switch(t){case"COMMA":n=new vi(e);break;case"SPACE":n=new As(e);break;default:n=new xd(t.toLowerCase(),e);break}return this.primitive(n)}initBuiltInValidators(){this.namedValidators.COLOR=this.primitive(new Ce(Na,W,W)),this.namedValidators.IMAGE_FUNCTION=this.primitive(new Ce(Ff,W,W)),this.namedValidators.POS_INT=this.primitive(new Ce(bd,W,W)),this.namedValidators.POS_NUM=this.primitive(new Ce(Sa,W,W)),this.namedValidators.POS_PERCENTAGE=this.primitive(new Ce(Ps,W,{"%":O})),this.namedValidators.NEGATIVE=this.primitive(new Ce(Ei,W,W)),this.namedValidators.ZERO=this.primitive(new Ce(Si,W,W)),this.namedValidators.ZERO_PERCENTAGE=this.primitive(new Ce(yd,W,W)),this.namedValidators.POS_LENGTH=this.primitive(new Ce(Ps,W,{em:O,ex:O,ch:O,rem:O,lh:O,rlh:O,vw:O,vh:O,vi:O,vb:O,vmin:O,vmax:O,pvw:O,pvh:O,pvi:O,pvb:O,pvmin:O,pvmax:O,cm:O,mm:O,in:O,px:O,pt:O,pc:O,q:O})),this.namedValidators.POS_ANGLE=this.primitive(new Ce(Ps,W,{deg:O,grad:O,rad:O,turn:O})),this.namedValidators.POS_TIME=this.primitive(new Ce(Ps,W,{s:O,ms:O})),this.namedValidators.FREQUENCY=this.primitive(new Ce(Ps,W,{Hz:O,kHz:O})),this.namedValidators.RESOLUTION=this.primitive(new Ce(Ps,W,{dpi:O,dpcm:O,dppx:O})),this.namedValidators.URI=this.primitive(new Ce(Rf,W,W)),this.namedValidators.URANGE=this.primitive(new Ce(Vf,W,W)),this.namedValidators.IDENT=this.primitive(new Ce(Lf,W,W)),this.namedValidators.STRING=this.primitive(new Ce(Af,W,W)),this.namedValidators.SLASH=this.primitive(new Ce(If,W,W));let t={"font-family":L("sans-serif")};this.systemFonts.caption=t,this.systemFonts.icon=t,this.systemFonts.menu=t,this.systemFonts["message-box"]=t,this.systemFonts["small-caption"]=t,this.systemFonts["status-bar"]=t}isBuiltIn(t){return!!t.match(/^[A-Z_0-9]+$/)}readNameAndPrefixes(t,e){let n=t.token();if(n.type==0)return null;let s={"":!0};if(n.type==14){do{if(t.consume(),n=t.token(),n.type!=1)throw new Error("Prefix name expected");s[n.text]=!0,t.consume(),n=t.token()}while(n.type==16);if(n.type!=15)throw new Error("']' expected");t.consume(),n=t.token()}if(n.type!=1)throw new Error("Property name expected");if(e==2?n.text=="SHORTHANDS":n.text=="DEFAULTS")return t.consume(),null;let o=n.text;if(t.consume(),e!=2){if(t.token().type!=39)throw new Error("'=' expected");this.isBuiltIn(o)||(this.prefixes[o]=s)}else if(t.token().type!=18)throw new Error("':' expected");return o}parseValidators(t){for(;;){let e=this.readNameAndPrefixes(t,1);if(!e)return;let n=[],s=[],o="",i,a=!0,l=()=>{if(n.length==0)throw new Error("No values");return n.length==1?n[0]:this.newGroup(o,n)},c=p=>{if(a)throw new Error(`'${p}': unexpected`);if(o&&o!=p)throw new Error(`mixed operators: '${p}' and '${o}'`);o=p,a=!0},u=null;for(;!u;){t.consume();let p=t.token();switch(p.type){case 1:if(a||c(" "),this.isBuiltIn(p.text)){let h=this.namedValidators[p.text];if(!h)throw new Error(`'${p.text}' unexpected`);n.push(h.clone())}else{let h={};h[p.text.toLowerCase()]=L(p.text),n.push(this.primitive(new Ce(0,h,W)))}a=!1;break;case 5:{let h={};h[`${p.num}`]=new ct(p.num),n.push(this.primitive(new Ce(0,h,W))),a=!1;break}case 34:c("|");break;case 25:c("||");break;case 14:a||c(" "),s.push({vals:n,op:o,b:"["}),o="",n=[],a=!0;break;case 6:a||c(" "),s.push({vals:n,op:o,b:"(",fn:p.text}),o="",n=[],a=!0;break;case 15:{i=l();let h=s.pop();if(h.b!="[")throw new Error("']' unexpected");n=h.vals,n.push(i),o=h.op,a=!1;break}case 11:{i=l();let h=s.pop();if(h.b!="(")throw new Error("')' unexpected");n=h.vals,n.push(this.newFunc(h.fn,i)),o=h.op,a=!1;break}case 18:if(a)throw new Error("':' unexpected");t.consume(),n.push(this.addReplacement(n.pop(),t.token()));break;case 22:if(a)throw new Error("'?' unexpected");n.push(this.addCounts(n.pop(),0,1));break;case 36:if(a)throw new Error("'*' unexpected");n.push(this.addCounts(n.pop(),0,Number.POSITIVE_INFINITY));break;case 23:if(a)throw new Error("'+' unexpected");n.push(this.addCounts(n.pop(),1,Number.POSITIVE_INFINITY));break;case 12:{if(t.consume(),p=t.token(),p.type!=5)throw new Error("<int> expected");let h=p.num,f=h;if(t.consume(),p=t.token(),p.type==16){if(t.consume(),p=t.token(),p.type!=5)throw new Error("<int> expected");f=p.num,t.consume(),p=t.token()}if(p.type!=13)throw new Error("'}' expected");n.push(this.addCounts(n.pop(),h,f));break}case 17:if(u=l(),s.length>0)throw new Error(`unclosed '${s.pop().b}'`);break;default:throw new Error("unexpected token")}}t.consume(),this.isBuiltIn(e)?this.namedValidators[e]=u:u.isSimple()?this.validators[e]=u.nodes[0].validator:this.validators[e]=new As(u)}}parseDefaults(t){for(;;){let e=this.readNameAndPrefixes(t,2);if(!e)return;let n=[];for(;;){t.consume();let s=t.token();if(s.type==17){t.consume();break}switch(s.type){case 1:n.push(L(s.text));break;case 4:n.push(new lt(s.num));break;case 5:n.push(new ct(s.num));break;case 3:n.push(new P(s.num,s.text));break;default:throw new Error("unexpected token")}}this.defaultValues[e]=n.length>1?new q(n):n[0]}}parseShorthands(t){for(;;){let e=this.readNameAndPrefixes(t,3);if(!e)return;let n=t.nthToken(1),s;n.type==1&&kf[n.text]?(s=new kf[n.text],t.consume()):s=new Yn,s.setOwner(this);let o=!1,i=[],a=!1,l=[],c=[];for(;!o;)switch(t.consume(),n=t.token(),n.type){case 1:if(this.validators[n.text])i.push(s.syntaxNodeForProperty(n.text)),n.text.includes("_")||c.push(n.text);else if(this.shorthands[n.text]instanceof Pa){let u=this.shorthands[n.text];i.push(u.createSyntaxNode()),c.push(...u.propList)}else throw new Error(`'${n.text}' is neither a simple property nor an inset shorthand`);break;case 19:if(i.length>0||a)throw new Error("unexpected slash");a=!0;break;case 14:l.push({slash:a,syntax:i}),i=[],a=!1;break;case 15:{let u=new Sd(i,a),p=l.pop();i=p.syntax,a=p.slash,i.push(u);break}case 17:o=!0,t.consume();break;default:throw new Error("unexpected token")}s.init(i,c),this.shorthands[e]=s}}parse(t){let e=new Oe(t,null);this.parseValidators(e),this.parseDefaults(e),this.parseShorthands(e),this.backgroundProps=this.makePropSet(["background"]),this.layoutProps=this.makePropSet(["margin","border","padding","columns","column-gap","column-rule","column-fill"])}makePropSet(t){var n;let e={};for(let s of t){let o=this.shorthands[s],i=o?o.propList:[s];for(let a of i)e[a]=(n=this.defaultValues[a])!=null?n:x.initial}return e}validatePropertyAndHandleShorthand(t,e,n,s){if(bt(t)||s.ruleType==="font-face"||LC(e)){s.simpleProperty(t,e,n);return}let o="",i=t;t=t.toLowerCase();let a=t.match(/^-([a-z]+)-([-a-z0-9]+)$/);a&&(o=a[1],t=a[2]);let l=this.prefixes[t];if(!l||!l[o]){CSS.supports(t,e.toString())?s.simpleProperty(i,e,n):s.unknownProperty(i,e);return}let c=this.validators[t];if(c){let u=U(e)||e.isExpr()?e:e.visit(c);u?s.simpleProperty(t,u,n):!o&&CSS.supports(t,e.toString())?s.simpleProperty(t,e,n):s.invalidPropertyValue(i,e)}else{let u=this.shorthands[t].clone();U(e)?u.propagateDefaultingValue(e,n,s):(e.visit(u),u.finish(n,s)||s.invalidPropertyValue(i,e))}}};function Ld(){let r=new kd;return r.initBuiltInValidators(),r.parse(ac),r}var Ad=class extends at{constructor(){super(...arguments);d(this,"varFound",!1)}visitFunc(e){return e.name==="var"?this.varFound=!0:this.varFound||this.visitValues(e.values),null}};function LC(r){let t=new Ad;return r.visit(t),t.varFound}var wi={"font-style":x.auto,"font-stretch":x.auto,"font-weight":x.auto,"unicode-range":Bp},Oy=`OTTO${new Date().valueOf()}`;function IC(r){let t=new je;for(let e in wi)t.append(" "),t.append(r[e].toString());return t.toString()}function VC(r){for(let t in wi)r[t]||(r[t]=wi[t])}function Of(r,t){let e={};for(let n in r)e[n]=de(r,n).evaluate(t,n);return VC(e),e}var Pi=class{constructor(t){this.properties=t;d(this,"fontTraitKey");d(this,"src");d(this,"blobURLs",[]);d(this,"blobs",[]);d(this,"family");this.fontTraitKey=IC(this.properties),this.src=this.properties.src?this.properties.src.toString():null;let e=this.properties["font-family"];this.family=e?e.stringValue():null}traitsEqual(t){return this.fontTraitKey==t.fontTraitKey}makeAtRule(t,e){let n=new je;n.append(`@font-face {
|
|
1478
|
+
`;function cs(r,t,e,n,s){let o=k("ajax"),i=new XMLHttpRequest,a=o.suspend(i),l={status:0,statusText:"",url:r,contentType:null,responseText:null,responseXML:null,responseBlob:null};i.open(e||"GET",r,!0),t&&(i.responseType=t),i.onreadystatechange=()=>{if(i.readyState===4){if(l.status=i.status,l.url=i.responseURL,l.statusText=i.statusText||i.status==404&&"Not Found"||"",l.status==200||l.status==0)if((!t||t==="document")&&i.responseXML&&i.responseXML.documentElement.localName!="parsererror")l.responseXML=i.responseXML,l.contentType=i.responseXML.contentType;else if((!t||t==="document")&&i.response instanceof Document)l.responseXML=i.response,l.contentType=i.response.contentType;else{let c=i.response;(!t||t==="text")&&typeof c=="string"?l.responseText=c:c?typeof c=="string"?l.responseBlob=hc([c]):l.responseBlob=c:I.warn("Unexpected empty success response for",r);let u=i.getResponseHeader("Content-Type");u&&(l.contentType=u.replace(/(.*);.*$/,"$1"))}a.schedule(l)}};try{n?(i.setRequestHeader("Content-Type",s||"text/plain; charset=UTF-8"),i.send(n)):(/^file:|^https?:\/\/[^/]+\.githubusercontent\.com|\.(xhtml|xht|opf)$/i.test(r)?/\/aozorabunko\/[^/]+\/cards\/[^/]+\/files\/[^/.]+\.html$/.test(r)?i.overrideMimeType("text/html; charset=Shift_JIS"):/\.(html|htm)$/i.test(r)?i.overrideMimeType("text/html; charset=UTF-8"):/\.(xhtml|xht|xml|opf)$/i.test(r)?i.overrideMimeType("application/xml; charset=UTF-8"):/\.(txt|css)$/i.test(r)?i.overrideMimeType("text/plain; charset=UTF-8"):i.overrideMimeType("text/html; charset=UTF-8"):/^data:,(<|%3c)/i.test(r)?i.overrideMimeType("text/html; charset=UTF-8"):/^data:,/i.test(r)&&i.overrideMimeType("text/plain; charset=UTF-8"),i.send(null))}catch(c){I.warn(c,`Error fetching ${r}`),a.schedule(l)}return o.result()}function hc(r,t){let e=t||"application/octet-stream";return new Blob(r,{type:e})}function Qp(r){let t=k("readBlob"),e=new FileReader,n=t.suspend(e);return e.addEventListener("load",()=>{n.schedule(e.result)},!1),e.readAsArrayBuffer(r),t.result()}function Jp(r){return URL.createObjectURL(r)}var ls=class{constructor(t,e){this.parser=t;this.type=e;d(this,"resources",{});d(this,"fetchers",{})}load(t,e,n){t=wt(t);let s=this.resources[t];return typeof s!="undefined"?v(s):this.fetch(t,e,n).get()}fetchInner(t,e,n){let s=k("fetch"),o=t.endsWith("?viv-toc-box");o&&(t=t.replace("?viv-toc-box",""));let i=J("user-agent.xml",Wt),a=!o&&t===i;return a&&(t=`data:application/xml,${encodeURIComponent(lc)}`),cs(t,this.type).then(l=>{if(l.status>=400&&e)throw new Error((n||`Failed to fetch required resource: ${t}`)+` (${l.status}${l.statusText?" "+l.statusText:""})`);o?(t+="?viv-toc-box",l.url+="?viv-toc-box"):a&&(l.url=t=i),this.parser(l,this).then(c=>{delete this.fetchers[t],this.resources[t]=c,s.finish(c)})}),s.result()}fetch(t,e,n){if(t=wt(t),this.resources[t])return null;let o=this.fetchers[t];return o||(o=new Kt(()=>this.fetchInner(t,e,n),`Fetch ${t}`),this.fetchers[t]=o,o.start()),o}get(t){return this.resources[wt(t)]}delete(t){delete this.resources[wt(t)]}};function mm(r,t){let e=r.responseText;return v(e?Ds(e):null)}function eh(){return new ls(mm,"text")}function Ln(r,t,e){let n=new Kt(()=>{let s=k("loadElement"),o=s.suspend(r),i=!1,a=l=>{i||(i=!0,o.schedule(l?l.type:"timeout"))};return r.addEventListener("load",a,!1),r.addEventListener("error",a,!1),r.addEventListener("abort",a,!1),r.namespaceURI=="http://www.w3.org/2000/svg"?(t&&r.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",t),setTimeout(a,300)):r.localName==="script"?setTimeout(a,3e3):t&&(r.src=t,e&&(r.alt=e)),s.result()},`loadElement ${t||r.localName}`);return n.start(),n}var th=0,Cm=16777216,fc=33554432,Pr=50331648,kr=67108864,bm=83886080,ym=100663296;var $o=class{constructor(t){this.scope=t;d(this,"flavor");this.flavor="Author"}getCurrentToken(){return null}getScope(){return this.scope}error(t,e){}startStylesheet(t){this.flavor=t}tagSelector(t,e){}classSelector(t){}pseudoclassSelector(t,e){}pseudoelementSelector(t,e){}idSelector(t){}attributeSelector(t,e,n,s){}descendantSelector(){}childSelector(){}adjacentSiblingSelector(){}followingSiblingSelector(){}nextSelector(){}startSelectorRule(){}startFontFaceRule(){}startFootnoteRule(t){}startViewportRule(){}startDefineRule(){}startRegionRule(){}startPageRule(){}startPageMarginBoxRule(t){}startWhenRule(t){}startMediaRule(t){this.startWhenRule(t)}startFlowRule(t){}startPageTemplateRule(){}startPageMasterRule(t,e,n){}startPartitionRule(t,e,n){}startPartitionGroupRule(t,e,n){}startRuleBody(){}property(t,e,n){}endRule(){}startFuncWithSelector(t){}endFuncWithSelector(){}pushSelectorText(t){}getImportantSpecificity(){switch(this.flavor){case"UA":return th;case"User":return ym;default:return bm}}getBaseSpecificity(){switch(this.flavor){case"UA":return th;case"User":return Cm;default:return fc}}},vr=class extends $o{constructor(){super(null);d(this,"stack",[]);d(this,"tokenizer",null);d(this,"slave",null)}pushHandler(e){this.stack.push(this.slave),this.slave=e}popHandler(){this.slave=this.stack.pop()}getCurrentToken(){return this.tokenizer?this.tokenizer.token():null}getScope(){return this.slave.getScope()}error(e,n){this.slave.error(e,n)}errorMsg(e,n){var s;I.warn(e,(s=n==null?void 0:n.toString())!=null?s:"")}startStylesheet(e){super.startStylesheet(e),this.stack.length>0&&(this.slave=this.stack[0],this.stack=[]),this.slave.startStylesheet(e)}tagSelector(e,n){this.slave.tagSelector(e,n)}classSelector(e){this.slave.classSelector(e)}pseudoclassSelector(e,n){this.slave.pseudoclassSelector(e,n)}pseudoelementSelector(e,n){this.slave.pseudoelementSelector(e,n)}idSelector(e){this.slave.idSelector(e)}attributeSelector(e,n,s,o){this.slave.attributeSelector(e,n,s,o)}descendantSelector(){this.slave.descendantSelector()}childSelector(){this.slave.childSelector()}adjacentSiblingSelector(){this.slave.adjacentSiblingSelector()}followingSiblingSelector(){this.slave.followingSiblingSelector()}nextSelector(){this.slave.nextSelector()}startSelectorRule(){this.slave.startSelectorRule()}startFontFaceRule(){this.slave.startFontFaceRule()}startFootnoteRule(e){this.slave.startFootnoteRule(e)}startViewportRule(){this.slave.startViewportRule()}startDefineRule(){this.slave.startDefineRule()}startRegionRule(){this.slave.startRegionRule()}startPageRule(){this.slave.startPageRule()}startPageMarginBoxRule(e){this.slave.startPageMarginBoxRule(e)}startWhenRule(e){this.slave.startWhenRule(e)}startFlowRule(e){this.slave.startFlowRule(e)}startPageTemplateRule(){this.slave.startPageTemplateRule()}startPageMasterRule(e,n,s){this.slave.startPageMasterRule(e,n,s)}startPartitionRule(e,n,s){this.slave.startPartitionRule(e,n,s)}startPartitionGroupRule(e,n,s){this.slave.startPartitionGroupRule(e,n,s)}startRuleBody(){this.slave.startRuleBody()}property(e,n,s){this.slave.property(e,n,s)}endRule(){this.slave.endRule()}startFuncWithSelector(e){this.slave.startFuncWithSelector(e)}endFuncWithSelector(){this.slave.endFuncWithSelector()}pushSelectorText(e){this.slave.pushSelectorText(e)}},Tr=class extends $o{constructor(e,n,s){super(e);this.owner=n;this.topLevel=s;d(this,"depth",0);n&&(this.flavor=n.flavor)}getCurrentToken(){var e;return(e=this.owner)==null?void 0:e.getCurrentToken()}error(e,n){var s;(s=this.owner)==null||s.errorMsg(e,n)}startRuleBody(){this.depth++}endRule(){--this.depth==0&&!this.topLevel&&this.owner.popHandler()}},qt=class extends Tr{constructor(t,e,n){super(t,e,n)}report(t){this.error(t,this.getCurrentToken())}reportAndSkip(t){this.report(t),this.owner.pushHandler(new Tr(this.scope,this.owner,!1))}startSelectorRule(){this.reportAndSkip("E_CSS_UNEXPECTED_SELECTOR")}startFontFaceRule(){this.reportAndSkip("E_CSS_UNEXPECTED_FONT_FACE")}startFootnoteRule(t){this.reportAndSkip("E_CSS_UNEXPECTED_FOOTNOTE")}startViewportRule(){this.reportAndSkip("E_CSS_UNEXPECTED_VIEWPORT")}startDefineRule(){this.reportAndSkip("E_CSS_UNEXPECTED_DEFINE")}startRegionRule(){this.reportAndSkip("E_CSS_UNEXPECTED_REGION")}startPageRule(){this.reportAndSkip("E_CSS_UNEXPECTED_PAGE")}startWhenRule(t){this.reportAndSkip("E_CSS_UNEXPECTED_WHEN")}startFlowRule(t){this.reportAndSkip("E_CSS_UNEXPECTED_FLOW")}startPageTemplateRule(){this.reportAndSkip("E_CSS_UNEXPECTED_PAGE_TEMPLATE")}startPageMasterRule(t,e,n){this.reportAndSkip("E_CSS_UNEXPECTED_PAGE_MASTER")}startPartitionRule(t,e,n){this.reportAndSkip("E_CSS_UNEXPECTED_PARTITION")}startPartitionGroupRule(t,e,n){this.reportAndSkip("E_CSS_UNEXPECTED_PARTITION_GROUP")}startFuncWithSelector(t){this.reportAndSkip("E_CSS_UNEXPECTED_SELECTOR_FUNC")}endFuncWithSelector(){this.reportAndSkip("E_CSS_UNEXPECTED_END_SELECTOR_FUNC")}property(t,e,n){this.error("E_CSS_UNEXPECTED_PROPERTY",this.getCurrentToken())}},me=[],wr=[],ie=[],xe=[],kt=[],ut=[],ye=[],ke=[],ne=[],Ie=[],qe=[],Re=[],be=[];var eo=55,to=56,Nr=57;me[1]=28,me[36]=29,me[7]=29,me[9]=29,me[14]=29,me[18]=29,me[50]=29,me[20]=30,me[13]=27,me[0]=200,wr[1]=46,wr[0]=200,ut[1]=2,ut[36]=4,ut[7]=6,ut[9]=8,ut[14]=10,ut[18]=14,ut[50]=42,ie[37]=11,ie[23]=12,ie[35]=56,ie[1]=1,ie[36]=3,ie[7]=5,ie[9]=7,ie[14]=9,ie[12]=13,ie[18]=55,ie[50]=58,ie[16]=41,xe[37]=11,xe[23]=12,xe[35]=56,xe[1]=1,xe[36]=3,xe[7]=5,xe[9]=7,xe[14]=9,xe[18]=55,kt[1]=2,kt[36]=4,kt[7]=6,kt[9]=8,kt[18]=14,kt[50]=42,kt[14]=10,kt[12]=13,ye[1]=15,ye[7]=16,ye[4]=17,ye[5]=18,ye[3]=19,ye[2]=20,ye[8]=21,ye[27]=57,ye[16]=22,ye[19]=23,ye[6]=24,ye[11]=25,ye[17]=26,ye[13]=48,ye[31]=47,ye[23]=54,ye[0]=44,ke[1]=31,ke[4]=32,ke[5]=32,ke[3]=33,ke[2]=34,ke[10]=40,ke[6]=38,ke[31]=36,ke[24]=36,ke[32]=35,ne[1]=45,ne[16]=37,ne[37]=37,ne[38]=37,ne[47]=37,ne[48]=37,ne[39]=37,ne[49]=37,ne[41]=37,ne[26]=37,ne[25]=37,ne[23]=37,ne[24]=37,ne[19]=37,ne[21]=37,ne[36]=37,ne[18]=37,ne[22]=37,ne[11]=39,ne[12]=43,ne[17]=49,Ie[0]=200,Ie[12]=50,Ie[13]=51,Ie[14]=50,Ie[15]=51,Ie[10]=50,Ie[11]=51,Ie[17]=53,qe[0]=200,qe[12]=50,qe[13]=52,qe[14]=50,qe[15]=51,qe[10]=50,qe[11]=51,qe[17]=53,Re[0]=200,Re[12]=50,Re[13]=51,Re[14]=50,Re[15]=51,Re[10]=50,Re[11]=51,be[11]=0,be[16]=0,be[22]=1,be[18]=1,be[26]=2,be[25]=2,be[38]=3,be[37]=3,be[48]=3,be[47]=3,be[39]=3,be[49]=3,be[41]=3,be[23]=4,be[24]=4,be[36]=5,be[19]=5,be[21]=5,be[0]=6,be[eo]=2,be[to]=2;var Rn=class{constructor(t,e,n,s){this.actions=t;this.tokenizer=e;this.handler=n;this.baseURL=s;d(this,"valStack",[]);d(this,"namespacePrefixToURI",{});d(this,"defaultNamespaceURI",null);d(this,"propName",null);d(this,"propImportant",!1);d(this,"exprContext");d(this,"result",null);d(this,"importReady",!1);d(this,"importURL",null);d(this,"importCondition",null);d(this,"errorBrackets",[]);d(this,"ruleStack",[]);d(this,"regionRule",!1);d(this,"pageRule",!1);d(this,"inStyleDeclaration",!1);this.exprContext=2}extractVals(t,e){let n=[],s=this.valStack;for(;e<s.length&&(n.push(s[e++]),e!==s.length);){if(s[e++]!==t)throw new Error("Unexpected state");e===s.length&&n.push(O)}return n}valStackReduce(t,e){let n=this.valStack,s=n.length,o=0,i;do if(i=n[--s],t===")"&&i instanceof kn){if(i.text===")")o++;else if(i.text==="("){if(o===0)return null;o--}}while(typeof i!="undefined"&&typeof i!="string");let a=n.length-(s+1);if(a>1&&n.splice(s+1,a,new q(n.slice(s+1,n.length))),t==",")return null;s++;do i=n[--s];while(typeof i!="undefined"&&(typeof i!="string"||i==","));if(a=n.length-(s+1),i=="("){t!=")"&&e.type!==0&&(this.handler.error("E_CSS_MISMATCHED_C_PAR",e),this.actions=qe);let c=new Pt(n[s-1],this.extractVals(",",s+1));if(n.splice(s-1,a+2,c),c.name==="var"){let u=c.values[0]instanceof Be&&c.values[0].name;(!bt(u)||u===this.propName)&&(this.handler.error(`E_CSS_INVALID_VAR ${c.toString()}`,e),this.actions=qe)}return c}if(t!=";"||s>=0)return this.handler.error("E_CSS_UNEXPECTED_VAL_END",e),this.actions=qe,null;if(a>1)return new ge(this.extractVals(",",s+1));let l=n[0];return l instanceof Se?l:l?new kn(l.toString()):O}exprError(t,e){this.actions=this.propName?qe:Ie,I.warn(t,e.toString())}exprStackReduce(t,e){let n=this.valStack,s=this.handler,o=n.pop(),i;for(;;){let a=n.pop();if(t==11){let l=[o];for(;a==16;)l.unshift(n.pop()),a=n.pop();if(typeof a=="string"){if(a=="{"){for(;l.length>=2;){let c=l.shift(),u=l.shift(),p=new sr(s.getScope(),c,u);l.unshift(p)}return n.push(new F(l[0])),!0}else if(a=="("){let c=n.pop(),u=n.pop();o=new sn(s.getScope(),Uo(u,c),l),t=0;continue}}if(a==10){o.isMediaName()&&(o=new _o(s.getScope(),o,null)),t=0;continue}}else if(typeof a=="string"){n.push(a);break}if(a<0)if(a==-31)o=new mt(s.getScope(),o);else if(a==-24)o=new Fo(s.getScope(),o);else if(a==-Nr)o=new tr(s.getScope(),o);else return this.exprError("F_UNEXPECTED_STATE",e),!1;else{if(be[t]>be[a]){n.push(a);break}switch(i=n.pop(),a){case 26:o=new Us(s.getScope(),i,o);break;case eo:o=new nr(s.getScope(),i,o);break;case to:o=new or(s.getScope(),i,o);break;case 25:o=new Hs(s.getScope(),i,o);break;case 38:o=new ir(s.getScope(),i,o);break;case 37:o=new ar(s.getScope(),i,o);break;case 48:o=new rr(s.getScope(),i,o);break;case 47:o=new ns(s.getScope(),i,o);break;case 39:case 49:o=new Pn(s.getScope(),i,o);break;case 41:o=new lr(s.getScope(),i,o);break;case 23:o=new Bo(s.getScope(),i,o);break;case 24:o=new Oo(s.getScope(),i,o);break;case 36:o=new ss(s.getScope(),i,o);break;case 19:o=new Do(s.getScope(),i,o);break;case 21:o=new zs(s.getScope(),i,o);break;case 18:if(n.length>1)switch(n[n.length-1]){case 22:n.pop(),o=new cr(s.getScope(),n.pop(),i,o);break;case 10:if(i.isMediaName())o=new _o(s.getScope(),i,o);else return this.exprError("E_CSS_MEDIA_TEST",e),!1;break}else return this.exprError("E_CSS_EXPR_COND",e),!1;break;case 22:if(t!=18)return this.exprError("E_CSS_EXPR_COND",e),!1;case 10:return n.push(i),n.push(a),n.push(o),!1;default:return this.exprError("F_UNEXPECTED_STATE",e),!1}}}return n.push(o),!1}readSupportsTest(t){let e=t.type===6,n=this.tokenizer,s,o;if(e)o=t.text,s=t.position+o.length+1;else if(t.type===10){let h=n.nthToken(1),f=n.nthToken(2);if(h.type===1&&f.type===18)n.consume(),n.consume(),o=h.text,s=f.position+1;else{if(h.type===10||h.type===6||h.type===1&&h.text.toLowerCase()==="not"&&(f.type===10||f.type===6))return null;s=t.position+1}}else return null;let i=0,a,l=0;for(;i>=0;)switch(n.consume(),a=n.token(),a.type){case 11:i--;break;case 10:case 6:i++;break;case 16:i===0&&l++;break;case 0:return this.exprError("E_CSS_UNEXPECTED_EOF",a),null}n.consume();let c=a.position,u=e&&o==="selector"&&l>0?"":n.input.substring(s,c).trim();return new ur(this.handler.getScope(),o,u,e)}readPseudoParams(){let t=[];for(;;){let e=this.tokenizer.token();switch(e.type){case 1:t.push(e.text);break;case 23:t.push("+");break;case 4:case 5:t.push(e.num);break;default:return t}this.tokenizer.consume()}}readNthPseudoParams(){let t=!1,e=this.tokenizer.token();if(e.type===23)t=!0,this.tokenizer.consume(),e=this.tokenizer.token();else if(e.type===1&&(e.text==="even"||e.text==="odd"))return this.tokenizer.consume(),[2,e.text==="odd"?1:0];switch(e.type){case 3:if(t&&e.num<0)return null;case 1:if(t&&e.text.charAt(0)==="-")return null;if(e.text==="n"||e.text==="-n"){if(t&&e.precededBySpace)return null;let n=e.text==="-n"?-1:1;e.type===3&&(n=e.num);let s=0;this.tokenizer.consume(),e=this.tokenizer.token();let o=e.type===24,i=e.type===23||o;if(i&&(this.tokenizer.consume(),e=this.tokenizer.token()),e.type===5){if(s=e.num,1/s===-1/0){if(s=0,i)return null}else if(s<0){if(i)return null}else if(s>=0&&!i)return null;this.tokenizer.consume()}else if(i)return null;return[n,o&&s>0?-s:s]}else if(e.text==="n-"||e.text==="-n-"){if(t&&e.precededBySpace)return null;let n=e.text==="-n-"?-1:1;if(e.type===3&&(n=e.num),this.tokenizer.consume(),e=this.tokenizer.token(),e.type===5)return e.num<0||1/e.num===-1/0?null:(this.tokenizer.consume(),[n,e.num])}else{let n=e.text.match(/^n(-[0-9]+)$/);if(n)return t&&e.precededBySpace?null:(this.tokenizer.consume(),[e.type===3?e.num:1,parseInt(n[1],10)]);if(n=e.text.match(/^-n(-[0-9]+)$/),n)return this.tokenizer.consume(),[-1,parseInt(n[1],10)]}return null;case 5:return t&&(e.precededBySpace||e.num<0)?null:(this.tokenizer.consume(),[0,e.num])}return null}makeCondition(t,e){let n=this.handler.getScope();if(!n)return null;if(e=e||n._true,t){let s=t.split(/\s+/);for(let o of s)switch(o){case"vertical":e=Je(n,e,new mt(n,new ae(n,"pref-horizontal")));break;case"horizontal":e=Je(n,e,new ae(n,"pref-horizontal"));break;case"day":e=Je(n,e,new mt(n,new ae(n,"pref-night-mode")));break;case"night":e=Je(n,e,new ae(n,"pref-night-mode"));break;default:e=n._false}}return e===n._true?null:new F(e)}isInsidePropertyOnlyRule(){switch(this.ruleStack[this.ruleStack.length-1]){case"[selector]":case"font-face":case"-epubx-flow":case"-epubx-viewport":case"-epubx-define":case"-adapt-footnote-area":return!0}return!1}runParser(t,e,n,s,o,i){let a=this.handler,l=this.tokenizer,c=this.valStack,u,p,h,f,g,m,E,C=null;for(n&&(this.inStyleDeclaration=!0),s&&(this.exprContext=2,this.valStack.push("{"));t>0;--t){if(u=l.token(),o&&C===null&&(C=u.position-1,l.input[C]==="("&&C++),this.actions===ye&&this.errorBrackets.length>0&&(u.type===this.errorBrackets[this.errorBrackets.length-1]||u.type===17||u.type===31)){if(u.type===this.errorBrackets[this.errorBrackets.length-1]&&(this.errorBrackets.pop(),u.type===11&&this.valStackReduce(")",u))){l.consume();continue}c.push(new kn(u.toString())),l.consume();continue}switch(this.actions[u.type]){case 28:if(!this.inStyleDeclaration||l.nthToken(1).type!=18){this.isInsidePropertyOnlyRule()?(a.error("E_CSS_COLON_EXPECTED",l.nthToken(1)),this.actions=qe):(this.actions=ut,a.startSelectorRule());continue}this.propName=u.text,this.propImportant=!1,l.consume(),l.consume(),this.actions=ye,c.splice(0,c.length);continue;case 46:if(l.nthToken(1).type!=18){this.actions=qe,a.error("E_CSS_COLON_EXPECTED",l.nthToken(1));continue}this.propName=u.text,this.propImportant=!1,l.consume(),l.consume(),this.actions=ye,c.splice(0,c.length);continue;case 29:this.actions=ut,a.startSelectorRule();continue;case 1:if(!u.precededBySpace){this.actions=Re,a.error("E_CSS_SPACE_EXPECTED",u);continue}a.descendantSelector();case 2:if(l.nthToken(1).type==34)if(l.consume(),l.consume(),h=this.namespacePrefixToURI[u.text],h!=null)switch(u=l.token(),u.type){case 1:a.tagSelector(h,u.text),o?this.actions=xe:this.actions=ie,l.consume();break;case 36:a.tagSelector(h,null),o?this.actions=xe:this.actions=ie,l.consume();break;default:this.actions=Ie,a.error("E_CSS_NAMESPACE",u)}else this.actions=Ie,a.error("E_CSS_UNDECLARED_PREFIX",u);else a.tagSelector(this.defaultNamespaceURI,u.text),o?this.actions=xe:this.actions=ie,l.consume();continue;case 3:if(!u.precededBySpace){this.actions=Re,a.error("E_CSS_SPACE_EXPECTED",u);continue}a.descendantSelector();case 4:if(l.nthToken(1).type==34)switch(l.consume(),l.consume(),u=l.token(),u.type){case 1:a.tagSelector(null,u.text),o?this.actions=xe:this.actions=ie,l.consume();break;case 36:a.tagSelector(null,null),o?this.actions=xe:this.actions=ie,l.consume();break;default:this.actions=Ie,a.error("E_CSS_NAMESPACE",u)}else a.tagSelector(this.defaultNamespaceURI,null),o?this.actions=xe:this.actions=ie,l.consume();continue;case 5:u.precededBySpace&&a.descendantSelector();case 6:if(!u.text){a.error("E_CSS_SYNTAX",u),l.consume();continue}a.idSelector(u.text),o?this.actions=xe:this.actions=ie,l.consume();continue;case 7:u.precededBySpace&&a.descendantSelector();case 8:a.classSelector(u.text),o?this.actions=xe:this.actions=ie,l.consume();continue;case 55:u.precededBySpace&&a.descendantSelector();case 14:l.consume(),u=l.token();e:switch(u.type){case 1:a.pseudoclassSelector(u.text,null),l.consume(),o?this.actions=xe:this.actions=ie;continue;case 6:switch(f=u.text,l.consume(),f){case"is":case"not":case"where":case"has":this.actions=ut,a.startFuncWithSelector(f),this.runParser(Number.POSITIVE_INFINITY,!1,!1,!1,!0,f==="has")?this.actions=ie:this.actions=Re;continue;case"lang":case"href-epub-type":if(u=l.token(),u.type===1){E=[u.text],l.consume(),f==="href-epub-type"&&l.token().type===16&&(l.consume(),u=l.token(),u.type===1&&(E.push(u.text),l.consume()));break}else break e;case"nth-child":case"nth-of-type":case"nth-last-child":case"nth-last-of-type":case"nth":if(E=this.readNthPseudoParams(),E)break;break e;default:E=this.readPseudoParams()}if(u=l.token(),u.type==11){a.pseudoclassSelector(f,E),l.consume(),o?this.actions=xe:this.actions=ie;continue}break}a.error("E_CSS_PSEUDOCLASS_SYNTAX",u),this.actions=Ie;continue;case 58:u.precededBySpace&&a.descendantSelector();case 42:switch(l.consume(),u=l.token(),u.type){case 1:a.pseudoelementSelector(u.text,null),o?this.actions=xe:this.actions=ie,l.consume();continue;case 6:if(f=u.text,l.consume(),f=="nth-fragment"){if(E=this.readNthPseudoParams(),E===null)break}else E=this.readPseudoParams();if(u=l.token(),u.type==11){a.pseudoelementSelector(f,E),o?this.actions=xe:this.actions=ie,l.consume();continue}break}a.error("E_CSS_PSEUDOELEM_SYNTAX",u),this.actions=Ie;continue;case 9:u.precededBySpace&&a.descendantSelector();case 10:if(l.consume(),u=l.token(),u.type==1)f=u.text,l.consume();else if(u.type==36)f=null,l.consume();else if(u.type==34)f="";else{this.actions=Re,a.error("E_CSS_ATTR",u),l.consume();continue}if(u=l.token(),u.type==34){if(h=f&&this.namespacePrefixToURI[f],h===void 0){this.actions=Re,a.error("E_CSS_UNDECLARED_PREFIX",u),l.consume();continue}if(l.consume(),u=l.token(),u.type!=1){this.actions=Re,a.error("E_CSS_ATTR_NAME_EXPECTED",u);continue}f=u.text,l.consume(),u=l.token()}else h="";switch(u.type){case 39:case 45:case 44:case 43:case 42:case 46:case 50:g=u.type,l.consume(),u=l.token();break;case 15:a.attributeSelector(h,f,0,null),o?this.actions=xe:this.actions=ie,l.consume();continue;default:this.actions=Re,a.error("E_CSS_ATTR_OP_EXPECTED",u);continue}switch(u.type){case 1:case 2:a.attributeSelector(h,f,g,u.text),l.consume(),u=l.token();break;default:this.actions=Re,a.error("E_CSS_ATTR_VAL_EXPECTED",u);continue}if(u.type!=15){this.actions=Re,a.error("E_CSS_ATTR",u);continue}o?this.actions=xe:this.actions=ie,l.consume();continue;case 11:a.childSelector(),this.actions=kt,l.consume();continue;case 12:a.adjacentSiblingSelector(),this.actions=kt,l.consume();continue;case 56:a.followingSiblingSelector(),this.actions=kt,l.consume();continue;case 13:this.regionRule?(this.ruleStack.push("-epubx-region"),this.regionRule=!1):this.pageRule?(this.ruleStack.push("page"),this.pageRule=!1,this.inStyleDeclaration=!0):(this.ruleStack.push("[selector]"),this.inStyleDeclaration=!0),a.startRuleBody(),this.actions=me,l.consume();continue;case 41:a.nextSelector(),this.actions=ut,l.consume();continue;case 15:c.push(L(u.text)),l.consume();continue;case 16:g=parseInt(u.text,16),c.push(new Xs(u.text)),l.consume();continue;case 17:c.push(new lt(u.num)),l.consume();continue;case 18:c.push(new ct(u.num)),l.consume();continue;case 19:c.push(new P(u.num,u.text)),l.consume();continue;case 20:c.push(new ce(u.text)),l.consume();continue;case 21:c.push(new Ue(J(u.text,this.baseURL))),l.consume();continue;case 57:c.push(new zo(u.text)),l.consume();continue;case 22:this.valStackReduce(",",u),c.push(","),l.consume();continue;case 23:c.push($s),l.consume();continue;case 24:f=u.text.toLowerCase(),f=="-epubx-expr"||f=="env"?(this.actions=ke,this.exprContext=0,c.push("{")):(c.push(f),c.push("("),this.errorBrackets.length>0&&this.errorBrackets.push(11)),l.consume();continue;case 25:this.valStackReduce(")",u),l.consume();continue;case 47:if(l.consume(),u=l.token(),p=l.nthToken(1),u.type==1&&u.text.toLowerCase()=="important"&&(p.type==17||p.type==0||p.type==13)){l.consume(),this.propImportant=!0;continue}this.exprError("E_CSS_SYNTAX",u);continue;case 54:switch(p=l.nthToken(1),p.type){case 4:case 3:case 5:if(!p.precededBySpace){l.consume();continue}}c.push(new kn("+")),l.consume();continue;case 26:l.consume();case 48:m=this.valStackReduce(";",u),m&&this.propName&&a.property(this.propName,m,this.propImportant),this.actions=n?wr:me;continue;case 44:for(l.consume();c.length>0;){let b=c.length;if(m=this.valStackReduce(";",u),!m||c.length===b)break}return e?(this.result=m,!0):(this.propName&&m&&a.property(this.propName,m,this.propImportant),!0);case 31:if(p=l.nthToken(1),p.type==9)l.nthToken(2).type==10&&!l.nthToken(2).precededBySpace?(c.push(u.text,p.text,"("),l.consume()):(c.push(new ae(a.getScope(),Uo(u.text,p.text))),this.actions=ne),l.consume();else{if(this.exprContext==2||this.exprContext==3)u.text.toLowerCase()=="not"?(l.consume(),c.push(new Mo(a.getScope(),!0,p.text))):(u.text.toLowerCase()=="only"&&(l.consume(),u=p),c.push(new Mo(a.getScope(),!1,u.text)));else if(this.exprContext===4&&u.text.toLowerCase()==="not"&&c[c.length-1]!==eo&&c[c.length-1]!==to&&(p.type===10||p.type===6)){c.push(-Nr),l.consume();continue}else c.push(new ae(a.getScope(),u.text));this.actions=ne}l.consume();continue;case 38:if(this.exprContext===4){c.push(this.readSupportsTest(u)),this.actions=ne;continue}c.push(null,u.text,"("),l.consume();continue;case 32:c.push(new se(a.getScope(),u.num)),l.consume(),this.actions=ne;continue;case 33:f=u.text,f=="%"&&(this.propName&&this.propName.match(/height|^(top|bottom)$/)?f="vh":f="vw"),c.push(new rt(a.getScope(),u.num,f)),l.consume(),this.actions=ne;continue;case 34:c.push(new se(a.getScope(),u.text)),l.consume(),this.actions=ne;continue;case 35:l.consume(),u=l.token(),u.type!=5||u.precededBySpace?this.exprError("E_CSS_SYNTAX",u):(c.push(new Gs(a.getScope(),u.num)),l.consume(),this.actions=ne);continue;case 36:c.push(-u.type),l.consume();continue;case 37:this.actions=ke,this.exprStackReduce(u.type,u),c.push(u.type),l.consume();continue;case 45:u.text.toLowerCase()==="and"&&c[c.length-2]!==to&&c[c.length-2]!==-Nr?(this.actions=ke,this.exprStackReduce(eo,u),c.push(eo),l.consume()):u.text.toLowerCase()==="or"&&c[c.length-2]!==eo&&c[c.length-2]!==-Nr?(this.actions=ke,this.exprStackReduce(to,u),c.push(to),l.consume()):this.exprError("E_CSS_SYNTAX",u);continue;case 39:this.exprStackReduce(u.type,u)&&(this.actions=ye),l.consume();continue;case 43:this.exprStackReduce(11,u)&&(this.propName||this.exprContext==3?this.exprError("E_CSS_UNEXPECTED_BRC",u):(this.exprContext==1?a.startWhenRule(c.pop()):a.startMediaRule(c.pop()),this.ruleStack.push("media"),a.startRuleBody(),this.actions=me)),l.consume();continue;case 49:if(this.exprStackReduce(11,u))return this.propName||this.exprContext!=3?(this.exprError("E_CSS_UNEXPECTED_SEMICOL",u),this.actions=me,l.consume(),!1):(this.importCondition=c.pop(),this.importReady=!0,this.actions=me,l.consume(),!1);l.consume();continue;case 40:if(this.exprContext===4){let b=this.readSupportsTest(u);if(b){c.push(b),this.actions=ne;continue}}c.push(u.type),l.consume();continue;case 27:if(this.actions=me,l.consume(),a.endRule(),this.inStyleDeclaration=!1,this.ruleStack.length)switch(this.ruleStack.pop(),this.ruleStack[this.ruleStack.length-1]){case"page":case"-epubx-page-master":case"-epubx-partition-group":this.inStyleDeclaration=!0}continue;case 30:switch(f=u.text.toLowerCase(),f){case"import":if(l.consume(),u=l.token(),u.type==2||u.type==8){if(this.importURL=u.text,l.consume(),u=l.token(),u.type==17||u.type==0)return this.importReady=!0,l.consume(),!1;this.propName=null,this.exprContext=3,this.actions=ke,c.push("{");continue}a.error("E_CSS_IMPORT_SYNTAX",u),this.actions=Ie;continue;case"namespace":switch(l.consume(),u=l.token(),u.type){case 1:if(f=u.text,l.consume(),u=l.token(),(u.type==2||u.type==8)&&l.nthToken(1).type==17){this.namespacePrefixToURI[f]=u.text,l.consume(),l.consume();continue}break;case 2:case 8:if(l.nthToken(1).type==17){this.defaultNamespaceURI=u.text,l.consume(),l.consume();continue}break}a.error("E_CSS_NAMESPACE_SYNTAX",u),this.actions=Ie;continue;case"charset":if(l.consume(),u=l.token(),u.type==2&&l.nthToken(1).type==17){f=u.text.toLowerCase(),f!="utf-8"&&f!="utf-16"&&a.error(`E_CSS_UNEXPECTED_CHARSET ${f}`,u),l.consume(),l.consume();continue}a.error("E_CSS_CHARSET_SYNTAX",u),this.actions=Ie;continue;case"font-face":case"-epubx-page-template":case"-epubx-define":case"-epubx-viewport":if(l.nthToken(1).type==12){switch(l.consume(),l.consume(),f){case"font-face":a.startFontFaceRule(),this.inStyleDeclaration=!0;break;case"-epubx-page-template":a.startPageTemplateRule();break;case"-epubx-define":a.startDefineRule(),this.inStyleDeclaration=!0;break;case"-epubx-viewport":a.startViewportRule(),this.inStyleDeclaration=!0;break}this.ruleStack.push(f),a.startRuleBody();continue}break;case"-adapt-footnote-area":switch(l.consume(),u=l.token(),u.type){case 12:l.consume(),a.startFootnoteRule(null),this.ruleStack.push(f),a.startRuleBody(),this.inStyleDeclaration=!0;continue;case 50:if(l.consume(),u=l.token(),u.type==1&&l.nthToken(1).type==12){f=u.text,l.consume(),l.consume(),a.startFootnoteRule(f),this.ruleStack.push("-adapt-footnote-area"),a.startRuleBody(),this.inStyleDeclaration=!0;continue}break}break;case"-epubx-region":l.consume(),a.startRegionRule(),this.regionRule=!0,this.actions=ut;continue;case"page":l.consume(),a.startPageRule(),this.pageRule=!0,this.actions=kt;continue;case"top-left-corner":case"top-left":case"top-center":case"top-right":case"top-right-corner":case"right-top":case"right-middle":case"right-bottom":case"bottom-right-corner":case"bottom-right":case"bottom-center":case"bottom-left":case"bottom-left-corner":case"left-bottom":case"left-middle":case"left-top":if(l.consume(),u=l.token(),u.type==12){l.consume(),a.startPageMarginBoxRule(f),this.ruleStack.push(f),a.startRuleBody(),this.inStyleDeclaration=!0;continue}break;case"-epubx-when":l.consume(),this.propName=null,this.exprContext=1,this.actions=ke,c.push("{");continue;case"media":l.consume(),this.propName=null,this.exprContext=2,this.actions=ke,c.push("{");continue;case"supports":l.consume(),this.propName=null,this.exprContext=4,this.actions=ke,c.push("{");continue;case"-epubx-flow":if(l.nthToken(1).type==1&&l.nthToken(2).type==12){a.startFlowRule(l.nthToken(1).text),l.consume(),l.consume(),l.consume(),this.ruleStack.push(f),a.startRuleBody(),this.inStyleDeclaration=!0;continue}break;case"-epubx-page-master":case"-epubx-partition":case"-epubx-partition-group":{l.consume(),u=l.token();let b=null,y=null,N=[];for(u.type==1&&(b=u.text,l.consume(),u=l.token()),u.type==18&&l.nthToken(1).type==1&&(y=l.nthToken(1).text,l.consume(),l.consume(),u=l.token());u.type==6&&u.text.toLowerCase()=="class"&&l.nthToken(1).type==1&&l.nthToken(2).type==11;)N.push(l.nthToken(1).text),l.consume(),l.consume(),l.consume(),u=l.token();if(u.type==12){switch(l.consume(),f){case"-epubx-page-master":a.startPageMasterRule(b,y,N);break;case"-epubx-partition":a.startPartitionRule(b,y,N);break;case"-epubx-partition-group":a.startPartitionGroupRule(b,y,N);break}this.ruleStack.push(f),a.startRuleBody(),this.inStyleDeclaration=!0;continue}break}case"":a.error(`E_CSS_UNEXPECTED_AT${f}`,u),this.actions=Re;continue;default:a.error(`E_CSS_AT_UNKNOWN ${f}`,u),this.actions=Ie;continue}a.error(`E_CSS_AT_SYNTAX ${f}`,u),this.actions=Ie;continue;case 50:this.errorBrackets.push(u.type+1),l.consume();continue;case 52:if(this.errorBrackets.length==0){this.actions=me;continue}case 51:if(o&&this.errorBrackets.length==0&&u.type==11)return l.consume(),a.endFuncWithSelector(),!0;this.errorBrackets.length>0&&this.errorBrackets[this.errorBrackets.length-1]==u.type&&this.errorBrackets.pop(),this.errorBrackets.length==0&&u.type==13&&(this.actions=me),l.consume();continue;case 53:this.errorBrackets.length==0&&(this.actions=me),l.consume();continue;case 200:return!0;default:if(s)return this.exprStackReduce(11,u)?(this.result=c.pop(),!0):!1;if(o){switch(u.type){case 16:case 11:if(this.actions===ut)a.error("E_CSS_SYNTAX",u);else{let b=l.input.substring(C,u.position);a.pushSelectorText(b),C=u.position+1}if(u.type===16){a.nextSelector(),this.actions=ut,l.consume();continue}else return a.endFuncWithSelector(),l.consume(),!0;case 37:case 23:case 35:if(i){this.actions=ie;continue}break;case 12:case 14:case 10:this.errorBrackets.push(u.type+1);break}a.error("E_CSS_SYNTAX",u),l.consume(),this.actions=Re;continue}if(this.actions!==Ie&&this.actions!==Re&&this.actions!==qe){if(u.type==54)a.error("E_CSS_SYNTAX",u);else if(this.actions===ye){switch(u.type){case 10:case 12:case 14:this.errorBrackets.push(u.type+1);break}c.push(new kn(u.toString())),l.consume();continue}else if(u.type===12&&this.actions==ke&&c.length>0){a.startMediaRule(c.pop()),this.ruleStack.push("media"),a.startRuleBody(),this.actions=me,l.consume();continue}else{if(u.type===17&&this.actions==ke)return this.actions=me,l.consume(),!1;a.error("E_CSS_SYNTAX",u)}this.isInsidePropertyOnlyRule()?this.actions=qe:this.actions=Re;continue}l.consume();continue}}return!1}},jo=class extends $o{constructor(e){super(null);this.scope=e}error(e,n){I.warn(e,n.toString())}getScope(){return this.scope}};function xm(r,t,e,n,s){let o=k("parseStylesheet"),i=new Rn(me,r,t,e),a=null;return s&&(a=Em(new Oe(s,t),t,e)),a=i.makeCondition(n,a&&a.toExpr()),a&&(t.startMediaRule(a),t.startRuleBody()),o.loop(()=>{for(;!i.runParser(100,!1,!1,!1,!1);){if(i.importReady){let c=J(i.importURL,e);i.importCondition&&(t.startMediaRule(i.importCondition),t.startRuleBody());let u=k("parseStylesheet.import");return gc(c,t,null,null).then(()=>{i.importCondition&&t.endRule(),i.importReady=!1,i.importURL=null,i.importCondition=null,u.finish(!0)}),u.result()}let l=o.timeSlice();if(l.isPending)return l}return v(!1)}).then(()=>{a&&t.endRule(),o.finish(!0)}),o.result()}function Ar(r,t,e,n,s){return ln("parseStylesheetFromText",o=>{let i=new Oe(r,t);xm(i,t,e,n,s).thenFinish(o)},(o,i)=>{I.warn(i,`Failed to parse stylesheet text: ${r}`),o.finish(!1)})}function gc(r,t,e,n){return ln("parseStylesheetFromURL",s=>{cs(r).then(o=>{o.responseText?Ar(o.responseText,t,r,e,n).then(i=>{i||I.warn(`Failed to parse stylesheet from ${r}`),s.finish(!0)}):s.finish(!0)})},(s,o)=>{I.warn(o,"Exception while fetching and parsing:",r),s.finish(!0)})}function Zt(r,t,e){let n=new Rn(ye,t,new jo(r),e);return n.runParser(Number.POSITIVE_INFINITY,!0,!1,!1,!1),n.result}function sh(r,t,e){new Rn(wr,r,t,e).runParser(Number.POSITIVE_INFINITY,!1,!0,!1,!1)}function Em(r,t,e){let n=new Rn(ke,r,t,e);return n.runParser(Number.POSITIVE_INFINITY,!1,!1,!0,!1),n.result}var Sm={"z-index":!0,"column-count":!0,"flow-linger":!0,opacity:!0,page:!0,"flow-priority":!0,utilization:!0};function Nm(r){return!!Sm[r]}function oh(r,t,e){let n=t.evaluate(r);switch(typeof n){case"number":return Nm(e)?n==Math.round(n)?new ct(n):new lt(n):new P(n,"px");case"string":return n?Zt(t.scope,new Oe(n,null),""):O;case"boolean":return n?x._true:x._false;case"undefined":return O}throw new Error("E_UNEXPECTED")}function ih(r,t){let e={};return Object.keys(r).forEach(n=>{let s=e[n]={},o=r[n];Object.keys(o).forEach(i=>{s[i]=o[i].map(a=>{let l=t?a.logical:a.physical,c=t?a.physical:a.logical;return{regexp:new RegExp(`(-?)${l}(-?)`),to:`$1${c}$2`}})})}),e}function rh(r,t,e,n){let s=n[t];if(!s)throw new Error(`unknown writing-mode: ${t}`);let o=s[e||"ltr"];if(!o)throw new Error(`unknown direction: ${e}`);for(let i of o){let a=r.replace(i.regexp,i.to);if(a!==r)return a}return r}var ah={"horizontal-tb":{ltr:[{logical:"inline-start",physical:"left"},{logical:"inline-end",physical:"right"},{logical:"block-start",physical:"top"},{logical:"block-end",physical:"bottom"},{logical:"inline-size",physical:"width"},{logical:"block-size",physical:"height"}],rtl:[{logical:"inline-start",physical:"right"},{logical:"inline-end",physical:"left"},{logical:"block-start",physical:"top"},{logical:"block-end",physical:"bottom"},{logical:"inline-size",physical:"width"},{logical:"block-size",physical:"height"}]},"vertical-rl":{ltr:[{logical:"inline-start",physical:"top"},{logical:"inline-end",physical:"bottom"},{logical:"block-start",physical:"right"},{logical:"block-end",physical:"left"},{logical:"inline-size",physical:"height"},{logical:"block-size",physical:"width"}],rtl:[{logical:"inline-start",physical:"bottom"},{logical:"inline-end",physical:"top"},{logical:"block-start",physical:"right"},{logical:"block-end",physical:"left"},{logical:"inline-size",physical:"height"},{logical:"block-size",physical:"width"}]},"vertical-lr":{ltr:[{logical:"inline-start",physical:"top"},{logical:"inline-end",physical:"bottom"},{logical:"block-start",physical:"left"},{logical:"block-end",physical:"right"},{logical:"inline-size",physical:"height"},{logical:"block-size",physical:"width"}],rtl:[{logical:"inline-start",physical:"bottom"},{logical:"inline-end",physical:"top"},{logical:"block-start",physical:"left"},{logical:"block-end",physical:"right"},{logical:"inline-size",physical:"height"},{logical:"block-size",physical:"width"}]}},vm=ih(ah,!0);function mc(r,t,e){return rh(r,t,e||null,vm)}var Tm=ih(ah,!1);function Cc(r,t,e){return rh(r,t,e||null,Tm)}var wm={"horizontal-tb":[{logical:"line-left",physical:"left"},{logical:"line-right",physical:"right"},{logical:"over",physical:"top"},{logical:"under",physical:"bottom"}],"vertical-rl":[{logical:"line-left",physical:"top"},{logical:"line-right",physical:"bottom"},{logical:"over",physical:"right"},{logical:"under",physical:"left"}],"vertical-lr":[{logical:"line-left",physical:"top"},{logical:"line-right",physical:"bottom"},{logical:"over",physical:"right"},{logical:"under",physical:"left"}]};function lh(r,t){let e=wm[t];if(!e)throw new Error(`unknown writing-mode: ${t}`);for(let n=0;n<e.length;n++)if(e[n].physical===r)return e[n].logical;return r}function no(r,t,e){let n={display:t.style.display,position:t.style.position,width:t.style.width,maxWidth:t.style.maxWidth,minWidth:t.style.minWidth,height:t.style.height,maxHeight:t.style.maxHeight,minHeight:t.style.minHeight},s=t.ownerDocument,o=t.parentNode,i=s.createElement("div");T(i,"position",n.position),o.insertBefore(i,t),i.appendChild(t),T(t,"width","auto"),T(t,"max-width","none"),T(t,"min-width","0"),T(t,"height","auto"),T(t,"max-height","none"),T(t,"min-height","0");function a(N){return r.getElementComputedStyle(t).getPropertyValue(N)}let l=yl("writing-mode"),c=(l?a(l[0]):null)||a("writing-mode"),u=c==="vertical-rl"||c==="tb-rl"||c==="vertical-lr"||c==="tb-lr",p=u?"height":"width",h=u?"width":"height";function f(){return T(t,"display","block"),T(t,"position","static"),a(p)}function g(){T(t,"display","inline-block"),T(i,p,"99999999px");let N=a(p);return T(i,p,""),N}function m(){T(t,"display","inline-block"),T(i,p,"0");let N=a(p);return T(i,p,""),N}function E(){let N=f(),S=m(),w=parseFloat(N);if(w<=parseFloat(S))return S;{let A=g();return w<=parseFloat(A)?N:A}}function C(){return a(h)}function b(){throw new Error("Getting fill-available block size is not implemented")}let y={};return e.forEach(N=>{var w;let S;switch(N){case"fill-available inline size":S=f();break;case"max-content inline size":S=g();break;case"min-content inline size":S=m();break;case"fit-content inline size":S=E();break;case"fill-available block size":S=b();break;case"max-content block size":case"min-content block size":case"fit-content block size":S=C();break;case"fill-available width":S=u?b():f();break;case"fill-available height":S=u?f():b();break;case"max-content width":S=u?C():g();break;case"max-content height":S=u?g():C();break;case"min-content width":S=u?C():m();break;case"min-content height":S=u?m():C();break;case"fit-content width":S=u?C():E();break;case"fit-content height":S=u?E():C();break}S==="0px"&&t.childNodes.length===1&&((w=t.firstElementChild)==null?void 0:w.localName)==="img"&&!t.firstElementChild.complete&&(S="1px"),y[N]=parseFloat(S),T(t,"position",n.position),T(t,"display",n.display)}),T(t,"width",n.width),T(t,"max-width",n.maxWidth),T(t,"min-width",n.minWidth),T(t,"height",n.height),T(t,"max-height",n.maxHeight),T(t,"min-height",n.minHeight),o.insertBefore(t,i),o.removeChild(i),y}function ps(r){var t,e;return((t=r==null?void 0:r.style)==null?void 0:t["box-decoration-break"])==="clone"||((e=r==null?void 0:r.style)==null?void 0:e["-webkit-box-decoration-break"])==="clone"}function yc(r){let t=r.getAttribute("data-viv-box-break");return t?t.split(" "):[]}function xc(r,t){r.setAttribute("data-viv-box-break",t.join(" "))}function dt(r,t){let e=yc(r);e.includes(t)||(e.push(t),xc(r,e))}function km(r){let t=r.getAttribute("data-viv-margin-discard");return t?t.split(" "):[]}function Am(r,t){r.setAttribute("data-viv-margin-discard",t.join(" "))}function Lr(r,t){let e=km(r);e.includes(t)||(e.push(t),Am(r,e))}function Lm(r){let t=r.name,e=r.value;switch(t){case"page-break-before":case"page-break-after":case"page-break-inside":return{name:t.replace(/^page-/,""),value:e===x.always?x.page:e,important:r.important};default:return r}}var Rr={page:!0,left:!0,right:!0,recto:!0,verso:!0,column:!0,region:!0};function De(r){return!!Rr[r]}var Rm={left:!0,right:!0,recto:!0,verso:!0};function In(r){return!!Rm[r]}var Im={avoid:!0,"avoid-page":!0,"avoid-column":!0,"avoid-region":!0};function so(r){return!!Im[r]}function Ve(r,t){if(r)if(t){if(In(t))return t;if(In(r))return r;{let e=De(r),n=De(t);if(e&&n)switch(t){case"column":return r;case"region":return r==="column"?t:r;default:return t}else return n?t:e?r:so(t)?t:so(r)?r:t}}else return r;else return t}function Ec(r){return De(r)?r:"auto"}_e("SIMPLE_PROPERTY",Lm);var oo=Ng(yh());function xh(r,t){return(0,oo.default)(r,t,0)}function Tc(r){return r.reduce((t,e)=>e[0]===oo.default.DELETE?t:t+e[1],"")}function Eh(r,t){return Nh(r,t,1)}function Sh(r,t){return Nh(r,t,-1)}function Nh(r,t,e){let n=0,s=0;return r.some(o=>{for(let i=0;i<o[1].length;i++){switch(o[0]*e){case oo.default.INSERT:n++;break;case oo.default.DELETE:n--,s++;break;case oo.default.EQUAL:s++;break}if(s>t)return!0}return!1}),Math.max(Math.min(t,s-1)+n,0)}var Fr;(t=>{function r(e){return e&&e.formattingContextType==="Block"}t.isInstanceOfBlockFormattingContext=r})(Fr||(Fr={}));var Vn;(t=>{let r;(i=>(i.INLINE="inline",i.COLUMN="column",i.REGION="region",i.PAGE="page"))(r=t.FloatReference||(t.FloatReference={}))})(Vn||(Vn={}));var Ko;(t=>{function r(e){return e&&e.flagmentLayoutConstraintType=="AfterIfContinue"}t.isInstanceOfAfterIfContinuesLayoutConstraint=r})(Ko||(Ko={}));var Qt;(e=>{function r(n){return n?n.formattingContextType==="RepetitiveElementsOwner"||Ot.isInstanceOfTableFormattingContext(n):!1}e.isInstanceOfRepetitiveElementsOwnerFormattingContext=r;function t(n){return n?n.flagmentLayoutConstraintType==="RepetitiveElementsOwner"||Ot.isInstanceOfTableRowLayoutConstraint(n):!1}e.isInstanceOfRepetitiveElementsOwnerLayoutConstraint=t})(Qt||(Qt={}));var Ot;(e=>{function r(n){return n&&n.formattingContextType==="Table"}e.isInstanceOfTableFormattingContext=r;function t(n){return n&&n.flagmentLayoutConstraintType==="TableRow"}e.isInstanceOfTableRowLayoutConstraint=t})(Ot||(Ot={}));var At;(e=>{let r;(i=>(i[i.IGNORE=0]="IGNORE",i[i.NEWLINE=1]="NEWLINE",i[i.PRESERVE=2]="PRESERVE"))(r=e.Whitespace||(e.Whitespace={}));let t;(a=>(a[a.NONE=0]="NONE",a[a.CONTENT=1]="CONTENT",a[a.ROOTLESS=2]="ROOTLESS",a[a.ROOTED=3]="ROOTED"))(t=e.ShadowType||(e.ShadowType={}))})(At||(At={}));var vh={transform:!0,"transform-origin":!0},Th={top:!0,bottom:!0,left:!0,right:!0},Bn=class{constructor(t,e,n){this.target=t;this.name=e;this.value=n}},zm={show:function(r){r.style.visibility="visible"},hide:function(r){r.style.visibility="hidden"},play:function(r){r.currentTime=0,r.play()},pause:function(r){r.pause()},resume:function(r){r.play()},mute:function(r){r.muted=!0},unmute:function(r){r.muted=!1}};function Gm(r,t){let e=zm[t];return e?()=>{for(let n=0;n<r.length;n++)try{e(r[n])}catch(s){}}:null}var Fn=class Fn extends Nn{constructor(e,n){super();this.container=e;this.bleedBox=n;d(this,"pageAreaElement",null);d(this,"delayedItems",[]);d(this,"hrefHandler");d(this,"elementsById",{});d(this,"dimensions",{width:0,height:0});d(this,"isFirstPage",!1);d(this,"isLastPage",!1);d(this,"isBlankPage",!1);d(this,"isAutoPageWidth",!0);d(this,"isAutoPageHeight",!0);d(this,"spineIndex",0);d(this,"position",null);d(this,"offset",-1);d(this,"side",null);d(this,"fetchers",[]);d(this,"marginBoxes",{top:{},bottom:{},left:{},right:{}});d(this,"pageType",null);this.hrefHandler=s=>{let o=s.currentTarget,i=o.getAttribute("href")||o.getAttributeNS("http://www.w3.org/1999/xlink","href");if(i){let a={type:"hyperlink",target:null,currentTarget:null,anchorElement:o,href:i,preventDefault(){s.preventDefault()}};this.dispatchEvent(a)}}}setAutoPageWidth(e){this.isAutoPageWidth=e,e?this.container.setAttribute(Fn.AUTO_PAGE_WIDTH_ATTRIBUTE,"true"):this.container.removeAttribute(Fn.AUTO_PAGE_WIDTH_ATTRIBUTE)}setAutoPageHeight(e){this.isAutoPageHeight=e,e?this.container.setAttribute(Fn.AUTO_PAGE_HEIGHT_ATTRIBUTE,"true"):this.container.removeAttribute(Fn.AUTO_PAGE_HEIGHT_ATTRIBUTE)}registerElementWithId(e,n){let s=this.elementsById[n];s?s.push(e):this.elementsById[n]=[e]}finish(e,n){Object.keys(this.elementsById).forEach(i=>{let a=this.elementsById[i];for(let l=0;l<a.length;)this.container.contains(a[l])?l++:a.splice(l,1);a.length===0&&delete this.elementsById[i]});let s=this.delayedItems;for(let i=0;i<s.length;i++){let a=s[i];a.target===this.container&&a.name==="transform"&&!this.isAutoPageWidth&&!this.isAutoPageHeight||T(a.target,a.name,a.value.toString())}let o=n.getElementClientRect(this.container);this.dimensions.width=o.width,this.dimensions.height=o.height;for(let i=0;i<e.length;i++){let a=e[i],l=this.elementsById[a.ref],c=this.elementsById[a.observer];if(l&&c){let u=Gm(l,a.action);if(u)for(let p=0;p<c.length;p++)c[p].addEventListener(a.event,u,!1)}}}};d(Fn,"AUTO_PAGE_WIDTH_ATTRIBUTE","data-vivliostyle-auto-page-width"),d(Fn,"AUTO_PAGE_HEIGHT_ATTRIBUTE","data-vivliostyle-auto-page-height");var io=Fn,Mt="data-adapt-spec",Ze=At.Whitespace;function Hr(r){switch(r){case"normal":case"nowrap":return Ze.IGNORE;case"pre-line":return Ze.NEWLINE;case"pre":case"pre-wrap":case"break-spaces":return Ze.PRESERVE;default:return null}}function he(r,t){if(!r)return!0;if(r.nodeType==1)return!1;let e=r.textContent;switch(t){case Ze.PRESERVE:return e.length==0;case Ze.NEWLINE:return!!e.match(/^[ \t]*$/);case Ze.IGNORE:default:return!!e.match(/^[ \t\r\n\f]*$/)}}var Br=class{constructor(t,e){this.flowName=t;this.parentFlowName=e;d(this,"forcedBreakOffsets",[]);d(this,"formattingContext",null)}},Or=class{constructor(t,e,n,s,o,i,a,l,c){this.flowName=t;this.element=e;this.startOffset=n;this.priority=s;this.linger=o;this.exclusive=i;this.repeated=a;this.last=l;this.breakBefore=c;d(this,"startPage",-1)}isBetter(t){return this.exclusive?!t.exclusive||this.priority>t.priority?!0:this.last:!1}};function wh(r,t){return r.top-t.top}function Ph(r,t){return t.right-r.right}function kh(r,t){var e,n;return r===t?!0:!r||!t?!1:(r.node===t.node||!!r.shadowContext&&!!t.shadowContext&&r.shadowType===At.ShadowType.ROOTLESS&&t.shadowType===At.ShadowType.ROOTLESS&&((e=r.node)==null?void 0:e.outerHTML)===((n=t.node)==null?void 0:n.outerHTML))&&r.shadowType===t.shadowType&&Pc(r.shadowContext,t.shadowContext)&&Pc(r.nodeShadow,t.nodeShadow)&&kh(r.shadowSibling,t.shadowSibling)}function Dt(r,t){if(r===t)return!0;if(!r||!t||r.offsetInNode!==t.offsetInNode||r.after!==t.after||r.steps.length!==t.steps.length)return!1;for(let e=0;e<r.steps.length;e++)if(!kh(r.steps[e],t.steps[e]))return!1;return!0}function Ah(r){return{steps:[{node:r,shadowType:Et.NONE,shadowContext:null,nodeShadow:null,shadowSibling:null,formattingContext:null,fragmentIndex:0}],offsetInNode:0,after:!1,preprocessedTextContent:null}}function gs(r,t){return{steps:[{node:r.sourceNode,shadowType:Et.NONE,shadowContext:r.shadowContext,nodeShadow:null,shadowSibling:null,formattingContext:null,fragmentIndex:t!=null?t:r.fragmentIndex}],offsetInNode:0,after:!1,preprocessedTextContent:r.preprocessedTextContent}}function ao(r,t){let e=new On(r.node,t,0);return e.shadowType=r.shadowType,e.shadowContext=r.shadowContext,e.nodeShadow=r.nodeShadow,e.shadowSibling=r.shadowSibling?ao(r.shadowSibling,t.copy()):null,e.formattingContext=r.formattingContext,e.fragmentIndex=r.fragmentIndex+1,e}var Et=At.ShadowType,fs=class{constructor(t,e,n,s,o,i,a){this.owner=t;this.root=e;this.xmldoc=n;this.parentShadow=s;this.type=i;this.styler=a;d(this,"subShadow",null);o&&(o.subShadow=this)}equals(t){return t?this.owner===t.owner&&this.xmldoc===t.xmldoc&&this.type===t.type&&Pc(this.parentShadow,t.parentShadow):!1}};function Pc(r,t){return r===t||!!r&&!!t&&r.equals(t)}var Dr=class{constructor(t,e){this.outer=t;this.count=e}},On=class r{constructor(t,e,n){this.sourceNode=t;this.parent=e;this.boxOffset=n;d(this,"offsetInNode",0);d(this,"after",!1);d(this,"shadowType");d(this,"shadowContext");d(this,"nodeShadow",null);d(this,"shadowSibling",null);d(this,"shared",!1);d(this,"inline",!0);d(this,"overflow",!1);d(this,"breakPenalty");d(this,"display",null);d(this,"floatReference");d(this,"floatSide",null);d(this,"clearSide",null);d(this,"floatMinWrapBlock",null);d(this,"columnSpan",null);d(this,"verticalAlign","baseline");d(this,"captionSide","top");d(this,"inlineBorderSpacing",0);d(this,"blockBorderSpacing",0);d(this,"flexContainer",!1);d(this,"whitespace");d(this,"hyphenateCharacter");d(this,"breakWord");d(this,"establishesBFC",!1);d(this,"containingBlockForAbsolute",!1);d(this,"breakBefore",null);d(this,"breakAfter",null);d(this,"viewNode",null);d(this,"clearSpacer",null);d(this,"inheritedProps");d(this,"vertical");d(this,"direction");d(this,"firstPseudo");d(this,"lang",null);d(this,"preprocessedTextContent",null);d(this,"formattingContext");d(this,"repeatOnBreak",null);d(this,"pluginProps",{});d(this,"fragmentIndex",1);d(this,"afterIfContinues",null);d(this,"footnotePolicy",null);d(this,"pageType");this.shadowType=Et.NONE,this.shadowContext=e?e.shadowContext:null,this.breakPenalty=e?e.breakPenalty:0,this.floatReference=Vn.FloatReference.INLINE,this.whitespace=e?e.whitespace:Ze.IGNORE,this.hyphenateCharacter=e?e.hyphenateCharacter:null,this.breakWord=e?e.breakWord:!1,this.inheritedProps=e?e.inheritedProps:{},this.vertical=e?e.vertical:!1,this.direction=e?e.direction:"ltr",this.firstPseudo=e?e.firstPseudo:null,this.formattingContext=e?e.formattingContext:null,this.pageType=e?e.pageType:null}resetView(){this.inline=!0,this.breakPenalty=this.parent?this.parent.breakPenalty:0,this.viewNode=null,this.clearSpacer=null,this.offsetInNode=0,this.after=!1,this.display=null,this.floatReference=Vn.FloatReference.INLINE,this.floatSide=null,this.clearSide=null,this.floatMinWrapBlock=null,this.columnSpan=null,this.verticalAlign="baseline",this.flexContainer=!1,this.whitespace=this.parent?this.parent.whitespace:Ze.IGNORE,this.hyphenateCharacter=this.parent?this.parent.hyphenateCharacter:null,this.breakWord=this.parent?this.parent.breakWord:!1,this.breakBefore=null,this.breakAfter=null,this.nodeShadow=null,this.establishesBFC=!1,this.containingBlockForAbsolute=!1,this.vertical=this.parent?this.parent.vertical:!1,this.nodeShadow=null,this.preprocessedTextContent=null,this.formattingContext=this.parent?this.parent.formattingContext:null,this.repeatOnBreak=null,this.pluginProps={},this.fragmentIndex=1,this.afterIfContinues=null,this.footnotePolicy=null}cloneItem(){let t=new r(this.sourceNode,this.parent,this.boxOffset);return t.offsetInNode=this.offsetInNode,t.after=this.after,t.nodeShadow=this.nodeShadow,t.shadowType=this.shadowType,t.shadowContext=this.shadowContext,t.shadowSibling=this.shadowSibling,t.inline=this.inline,t.breakPenalty=this.breakPenalty,t.display=this.display,t.floatReference=this.floatReference,t.floatSide=this.floatSide,t.clearSide=this.clearSide,t.floatMinWrapBlock=this.floatMinWrapBlock,t.columnSpan=this.columnSpan,t.verticalAlign=this.verticalAlign,t.captionSide=this.captionSide,t.inlineBorderSpacing=this.inlineBorderSpacing,t.blockBorderSpacing=this.blockBorderSpacing,t.establishesBFC=this.establishesBFC,t.containingBlockForAbsolute=this.containingBlockForAbsolute,t.flexContainer=this.flexContainer,t.whitespace=this.whitespace,t.hyphenateCharacter=this.hyphenateCharacter,t.breakWord=this.breakWord,t.breakBefore=this.breakBefore,t.breakAfter=this.breakAfter,t.viewNode=this.viewNode,t.clearSpacer=this.clearSpacer,t.firstPseudo=this.firstPseudo,t.vertical=this.vertical,t.overflow=this.overflow,t.preprocessedTextContent=this.preprocessedTextContent,t.formattingContext=this.formattingContext,t.repeatOnBreak=this.repeatOnBreak,t.pluginProps=Object.create(this.pluginProps),t.fragmentIndex=this.fragmentIndex,t.afterIfContinues=this.afterIfContinues,t.footnotePolicy=this.footnotePolicy,t}modify(){return this.shared?this.cloneItem():this}copy(){let t=this;do{if(t.shared)break;t.shared=!0,t=t.parent}while(t);return this}clone(){let t=this.cloneItem(),e=t,n;for(;(n=e.parent)!=null;)n=n.cloneItem(),e.parent=n,e=n;return t}toNodePositionStep(){return{node:this.sourceNode,shadowType:this.shadowType,shadowContext:this.shadowContext,nodeShadow:this.nodeShadow,shadowSibling:this.shadowSibling?this.shadowSibling.toNodePositionStep():null,formattingContext:this.formattingContext,fragmentIndex:this.fragmentIndex}}toNodePosition(){var s,o,i;let t=this,e=[];t.shadowType===At.ShadowType.ROOTLESS&&(t.floatReference!==Vn.FloatReference.INLINE||t.floatSide==="footnote")&&((i=(o=(s=t.shadowContext)==null?void 0:s.styler)==null?void 0:o.style)!=null&&i._pseudos)&&(t=t.parent);do(!t.firstPseudo||!t.parent||t.parent.firstPseudo===t.firstPseudo)&&e.push(t.toNodePositionStep()),t=t.parent;while(t);let n=this.preprocessedTextContent?Sh(this.preprocessedTextContent,this.offsetInNode):this.offsetInNode;return{steps:e,offsetInNode:n,after:this.after,preprocessedTextContent:this.preprocessedTextContent}}isInsideBFC(){let t=this.parent;for(;t;){if(t.establishesBFC)return!0;t=t.parent}return!1}getContainingBlockForAbsolute(){let t=this.parent;for(;t;){if(t.containingBlockForAbsolute)return t;t=t.parent}return null}belongsTo(t){return this.formattingContext===t&&!!this.parent&&this.parent.formattingContext===t}},pt=class r{constructor(t){this.primary=t;d(this,"floats",null)}clone(){let t=new r(this.primary);if(this.floats){t.floats=[];for(let e=0;e<this.floats.length;++e)t.floats[e]=this.floats[e]}return t}isSamePosition(t){if(!t)return!1;if(this===t)return!0;if(!Dt(this.primary,t.primary))return!1;if(this.floats){if(!t.floats||this.floats.length!==t.floats.length)return!1;for(let e=0;e<this.floats.length;e++)if(!Dt(this.floats[e],t.floats[e]))return!1}else if(t.floats)return!1;return!0}},Mr=class r{constructor(t,e){this.chunkPosition=t;this.flowChunk=e}clone(){return new r(this.chunkPosition.clone(),this.flowChunk)}isSamePosition(t){return!!t&&(this===t||this.chunkPosition.isSamePosition(t.chunkPosition))}},_r=class r{constructor(){d(this,"positions",[]);d(this,"startBreakType",null);d(this,"breakAfter",null)}clone(){let t=new r,e=this.positions,n=t.positions;for(let s=0;s<e.length;s++)n[s]=e[s].clone();return t.startBreakType=this.startBreakType,t.breakAfter=this.breakAfter,t}isSamePosition(t){if(this===t)return!0;if(!t||this.positions.length!==t.positions.length)return!1;for(let e=0;e<this.positions.length;e++)if(!this.positions[e].isSamePosition(t.positions[e]))return!1;return!0}hasContent(t){return this.positions.length>0&&this.positions[0].flowChunk.startOffset<=t}},Ur=class r{constructor(){d(this,"page",0);d(this,"flows",{});d(this,"flowPositions",{});d(this,"isBlankPage",!1);d(this,"highestSeenOffset",0);d(this,"highestSeenNode");d(this,"lookupPositionOffset")}clone(){let t=new r;t.page=this.page,t.isBlankPage=this.isBlankPage,t.highestSeenNode=this.highestSeenNode,t.highestSeenOffset=this.highestSeenOffset,t.lookupPositionOffset=this.lookupPositionOffset,t.flows=this.flows;for(let e in this.flowPositions)t.flowPositions[e]=this.flowPositions[e].clone();return t}isSamePosition(t){if(this===t)return!0;if(!t||this.page!==t.page)return!1;let e=Object.keys(this.flowPositions),n=Object.keys(t.flowPositions);if(e.length!==n.length)return!1;for(let s of e)if(!this.flowPositions[s].isSamePosition(t.flowPositions[s]))return!1;return!0}hasContent(t,e){let n=this.flowPositions[t];return n?n.hasContent(e):!1}startSideOfFlow(t){var n;let e=(n=this.flowPositions[t])==null?void 0:n.startBreakType;return e&&In(e)?e:"any"}firstFlowChunkOfFlow(t){let e=this.flowPositions[t];if(!e)return null;let n=e.positions[0];return n?n.flowChunk:null}},ro=class{constructor(t){this.element=t;d(this,"left",0);d(this,"top",0);d(this,"marginLeft",0);d(this,"marginRight",0);d(this,"marginTop",0);d(this,"marginBottom",0);d(this,"borderLeft",0);d(this,"borderRight",0);d(this,"borderTop",0);d(this,"borderBottom",0);d(this,"paddingLeft",0);d(this,"paddingRight",0);d(this,"paddingTop",0);d(this,"paddingBottom",0);d(this,"width",0);d(this,"height",0);d(this,"originX",0);d(this,"originY",0);d(this,"exclusions",null);d(this,"innerShape",null);d(this,"computedBlockSize",0);d(this,"snapWidth",0);d(this,"snapHeight",0);d(this,"snapOffsetX",0);d(this,"snapOffsetY",0);d(this,"vertical",!1);d(this,"rtl",!1)}getInsetTop(){return this.marginTop+this.borderTop+this.paddingTop}getInsetBottom(){return this.marginBottom+this.borderBottom+this.paddingBottom}getInsetLeft(){return this.marginLeft+this.borderLeft+this.paddingLeft}getInsetRight(){return this.marginRight+this.borderRight+this.paddingRight}getInsetBefore(){return this.vertical?this.getInsetRight():this.getInsetTop()}getInsetAfter(){return this.vertical?this.getInsetLeft():this.getInsetBottom()}getInsetStart(){return this.vertical?this.getInsetTop():this.getInsetLeft()}getInsetEnd(){return this.vertical?this.getInsetBottom():this.getInsetRight()}getBeforeEdge(t){return this.vertical?t.right:t.top}getAfterEdge(t){return this.vertical?t.left:t.bottom}getStartEdge(t){return this.vertical?this.rtl?t.bottom:t.top:this.rtl?t.right:t.left}getEndEdge(t){return this.vertical?this.rtl?t.top:t.bottom:this.rtl?t.left:t.right}getInlineSize(t){return this.vertical?t.bottom-t.top:t.right-t.left}getBoxSize(t){return this.vertical?t.right-t.left:t.bottom-t.top}getBoxDir(){return this.vertical?-1:1}getInlineDir(){return this.rtl?-1:1}copyFrom(t){this.element=t.element,this.left=t.left,this.top=t.top,this.marginLeft=t.marginLeft,this.marginRight=t.marginRight,this.marginTop=t.marginTop,this.marginBottom=t.marginBottom,this.borderLeft=t.borderLeft,this.borderRight=t.borderRight,this.borderTop=t.borderTop,this.borderBottom=t.borderBottom,this.paddingLeft=t.paddingLeft,this.paddingRight=t.paddingRight,this.paddingTop=t.paddingTop,this.paddingBottom=t.paddingBottom,this.width=t.width,this.height=t.height,this.originX=t.originX,this.originY=t.originY,this.innerShape=t.innerShape,this.exclusions=t.exclusions,this.computedBlockSize=t.computedBlockSize,this.snapWidth=t.snapWidth,this.snapHeight=t.snapHeight,this.vertical=t.vertical,this.rtl=t.rtl}setVerticalPosition(t,e){this.top=t,this.height=e,T(this.element,"top",`${t}px`),T(this.element,"height",`${e}px`)}setHorizontalPosition(t,e){this.left=t,this.width=e,T(this.element,"left",`${t}px`),T(this.element,"width",`${e}px`)}setBlockPosition(t,e){if(this.vertical){let n=e+this.marginLeft+this.marginRight+this.paddingLeft+this.paddingRight+this.borderLeft+this.borderRight;this.setHorizontalPosition(t+n*this.getBoxDir(),e)}else this.setVerticalPosition(t,e)}setInlinePosition(t,e){if(this.vertical)if(this.rtl){let n=e+this.marginTop+this.marginBottom+this.paddingTop+this.paddingBottom+this.borderTop+this.borderBottom;this.setVerticalPosition(t+n*this.getInlineDir(),e)}else this.setVerticalPosition(t,e);else if(this.rtl){let n=e+this.marginLeft+this.marginRight+this.paddingLeft+this.paddingRight+this.borderLeft+this.borderRight;this.setHorizontalPosition(t+n*this.getInlineDir(),e)}else this.setHorizontalPosition(t,e)}clear(){let t=this.element,e;for(;e=t.lastChild;)t.removeChild(e)}getInnerShape(){let t=this.getInnerRect();return this.innerShape?this.innerShape.withOffset(t.x1,t.y1):Go(t.x1,t.y1,t.x2,t.y2)}getInnerRect(){let t=this.originX+this.left+this.getInsetLeft(),e=this.originY+this.top+this.getInsetTop();return new He(t,e,t+this.width,e+this.height)}getPaddingRect(){let t=this.originX+this.left+this.marginLeft+this.borderLeft,e=this.originY+this.top+this.marginTop+this.borderTop,n=this.paddingLeft+this.width+this.paddingRight,s=this.paddingTop+this.height+this.paddingBottom;return new He(t,e,t+n,e+s)}getOuterShape(t,e){let n=this.getOuterRect();return xr(t,n.x1,n.y1,n.x2-n.x1,n.y2-n.y1,e)}getOuterRect(){let t=this.originX+this.left,e=this.originY+this.top,n=this.getInsetLeft()+this.width+this.getInsetRight(),s=this.getInsetTop()+this.height+this.getInsetBottom();return new He(t,e,t+n,e+s)}},cn=class extends at{constructor(e,n,s,o){super();this.elem=e;this.context=n;this.rootContentValue=s;this.exprContentListener=o}visitStrInner(e,n){var s;if(!n){if(((s=this.elem.lastChild)==null?void 0:s.nodeType)===3){this.elem.lastChild.textContent+=e;return}n=this.elem.ownerDocument.createTextNode(e)}this.elem.appendChild(n)}visitStr(e){return this.visitStrInner(e.str),null}visitURL(e){if(this.rootContentValue.url)this.elem.setAttribute("src",e.url);else{let n=this.elem.ownerDocument.createElementNS("http://www.w3.org/1999/xhtml","img");n.setAttribute("src",e.url),this.elem.appendChild(n)}return null}visitSpaceList(e){return this.visitValues(e.values),null}visitExpr(e){let n=e.toExpr(),s=n.evaluate(this.context);if(typeof s=="string"){n instanceof ae&&(s=Zt(n.scope,new Oe(s,null),"").stringValue()),this.elem.ownerDocument;let o=this.exprContentListener(n,s,this.elem.ownerDocument);!o&&s&&n instanceof oe&&n.str.startsWith("running-element-")&&(s=""),this.visitStrInner(s,o)}return null}};function St(r){return r!=null&&r!==O&&r!==x.normal&&r!==x.none&&!U(r)}var ue=Vn.FloatReference;function Rh(r){switch(r){case"inline":return ue.INLINE;case"column":return ue.COLUMN;case"region":return ue.REGION;case"page":return ue.PAGE;default:throw new Error(`Unknown float-reference: ${r}`)}}function Dn(r){switch(r){case ue.INLINE:return!1;case ue.COLUMN:case ue.REGION:case ue.PAGE:return!0;default:throw new Error(`Unknown float-reference: ${r}`)}}function Ih(r,t,e){let n=t?"vertical-rl":"horizontal-tb";if((r==="top"||r==="bottom")&&(r=Cc(r,n,e)),r==="block-start"&&(r="inline-start"),r==="block-end"&&(r="inline-end"),r==="inline-start"||r==="inline-end"){let s=mc(r,n,e),o=lh(s,n);o==="line-left"?r="left":o==="line-right"&&(r="right")}return r!=="left"&&r!=="right"&&(I.warn(`Invalid float value: ${r}. Fallback to left.`),r="left"),r}var Zo=class{constructor(t,e,n,s,o,i){this.nodePosition=t;this.floatReference=e;this.floatSide=n;this.clearSide=s;this.flowName=o;this.floatMinWrapBlock=i;d(this,"order",null);d(this,"id",null)}getOrder(){if(this.order===null)throw new Error("The page float is not yet added");return this.order}getId(){if(!this.id)throw new Error("The page float is not yet added");return this.id}isAllowedOnContext(t){return t.isAnchorAlreadyAppeared(this.getId())}isAllowedToPrecede(t){return!1}},kc=class{constructor(){d(this,"floats",[]);d(this,"nextPageFloatIndex",0)}nextOrder(){return this.nextPageFloatIndex++}createPageFloatId(t){return`pf${t}`}addPageFloat(t){if(this.floats.findIndex(n=>Dt(n.nodePosition,t.nodePosition))>=0)throw new Error("A page float with the same source node is already registered");{let n=t.order=this.nextOrder();t.id=this.createPageFloatId(n),this.floats.push(t)}}findPageFloatByNodePosition(t){let e=this.floats.findIndex(n=>Dt(n.nodePosition,t));return e>=0?this.floats[e]:null}findPageFloatById(t){let e=this.floats.findIndex(n=>n.id===t);return e>=0?this.floats[e]:null}},Qo=class{constructor(t,e,n,s,o){this.floatReference=t;this.floatSide=e;this.continuations=n;this.area=s;this.continues=o}hasFloat(t){return this.continuations.some(e=>e.float===t)}findNotAllowedFloat(t){for(let e=this.continuations.length-1;e>=0;e--){let n=this.continuations[e].float;if(!n.isAllowedOnContext(t))return n}return null}getOuterShape(){return this.area.getOuterShape(null,null)}getOuterRect(){return this.area.getOuterRect()}getOrder(){let t=this.continuations.map(e=>e.float);return Math.min.apply(null,t.map(e=>e.getOrder()))}shouldBeStashedBefore(t){return this.getOrder()<t.getOrder()}addContinuations(t){t.forEach(e=>{this.continuations.push(e)})}getFlowName(){let t=this.continuations[0].float.flowName;return this.continuations.every(e=>e.float.flowName===t),t}},Jo=class{constructor(t,e){this.float=t;this.nodePosition=e}equals(t){return t?this===t?!0:this.float===t.float&&Dt(this.nodePosition,t.nodePosition):!1}},un=class{constructor(t,e,n,s,o,i,a){this.parent=t;this.floatReference=e;this.container=n;this.flowName=s;this.generatingNodePosition=o;d(this,"children",[]);d(this,"writingMode");d(this,"direction");d(this,"invalidated",!1);d(this,"floatStore");d(this,"forbiddenFloats",[]);d(this,"floatFragments",[]);d(this,"stashedFloatFragments",[]);d(this,"floatAnchors",{});d(this,"floatsDeferredToNext",[]);d(this,"floatsDeferredFromPrevious");d(this,"layoutConstraints",[]);d(this,"locked",!1);t&&t.children.push(this),this.writingMode=i||t&&t.writingMode||x.horizontal_tb,this.direction=a||t&&t.direction||x.ltr,this.floatStore=t?t.floatStore:new kc;let l=this.getPreviousSibling();this.floatsDeferredFromPrevious=l?[].concat(l.floatsDeferredToNext):[]}getParent(t){if(!this.parent)throw new Error(`No PageFloatLayoutContext for ${t}`);return this.parent}getPreviousSiblingOf(t,e,n,s){let o=this.children.indexOf(t);o<0&&(o=this.children.length);for(let i=o-1;i>=0;i--){let a=this.children[i];if(a.floatReference===e&&a.flowName===n&&Dt(a.generatingNodePosition,s))return a;if(a=a.getPreviousSiblingOf(null,e,n,s),a)return a}return null}getPreviousSibling(){let t=this,e=this.parent,n;for(;e;){if(n=e.getPreviousSiblingOf(t,this.floatReference,this.flowName,this.generatingNodePosition),n)return n;t=e,e=e.parent}return null}getContainer(t){return!t||t===this.floatReference?this.container:this.getParent(t).getContainer(t)}setContainer(t){this.container=t,this.reattachFloatFragments()}addPageFloat(t){this.floatStore.addPageFloat(t)}getPageFloatLayoutContext(t){return t===this.floatReference?this:this.getParent(t).getPageFloatLayoutContext(t)}findPageFloatByNodePosition(t){return this.floatStore.findPageFloatByNodePosition(t)}forbid(t){let e=t.getId(),n=t.floatReference;n===this.floatReference?this.forbiddenFloats.includes(e)||(this.forbiddenFloats.push(e),new _t().findByFloat(t).forbid(t,this)):this.getParent(n).forbid(t)}isForbidden(t){let e=t.getId(),n=t.floatReference;return n===this.floatReference?this.forbiddenFloats.includes(e):this.getParent(n).isForbidden(t)}addPageFloatFragment(t,e){let n=t.floatReference;n!==this.floatReference?this.getParent(n).addPageFloatFragment(t,e):this.floatFragments.includes(t)||(this.floatFragments.push(t),this.floatFragments.sort((s,o)=>s.getOrder()-o.getOrder())),e||this.invalidate()}removePageFloatFragment(t,e){let n=t.floatReference;if(n!==this.floatReference)this.getParent(n).removePageFloatFragment(t,e);else{let s=this.floatFragments.indexOf(t);if(s>=0){let o=this.floatFragments.splice(s,1)[0],i=o.area&&o.area.element;i&&i.parentNode&&i.parentNode.removeChild(i),e||this.invalidate()}}}findPageFloatFragment(t){if(t.floatReference!==this.floatReference)return this.getParent(t.floatReference).findPageFloatFragment(t);let e=this.floatFragments.findIndex(n=>n.hasFloat(t));return e>=0?this.floatFragments[e]:null}hasFloatFragments(t){return this.floatFragments.length>0&&(!t||this.floatFragments.some(t))?!0:this.parent?this.parent.hasFloatFragments(t):!1}hasContinuingFloatFragmentsInFlow(t){return this.hasFloatFragments(e=>e.continues&&e.getFlowName()===t)}registerPageFloatAnchor(t,e){this.floatAnchors[t.getId()]=e}collectPageFloatAnchors(){let t=Object.assign({},this.floatAnchors);return this.children.reduce((e,n)=>Object.assign(e,n.collectPageFloatAnchors()),t)}isAnchorAlreadyAppeared(t){if(this.getDeferredPageFloatContinuations().some(o=>o.float.getId()===t))return!0;let s=this.collectPageFloatAnchors()[t];return s&&this.container&&this.container.element?this.container.element.contains(s):!1}deferPageFloat(t){let e=t.float;if(e.floatReference===this.floatReference){let n=this.floatsDeferredToNext.findIndex(s=>s.float===e);n>=0?this.floatsDeferredToNext.splice(n,1,t):this.floatsDeferredToNext.push(t)}else this.getParent(e.floatReference).deferPageFloat(t)}hasPrecedingFloatsDeferredToNext(t,e){if(!e&&t.floatReference!==this.floatReference)return this.getParent(t.floatReference).hasPrecedingFloatsDeferredToNext(t,!1);let n=t.getOrder();return this.floatsDeferredToNext.some(o=>o.float.getOrder()<n&&!t.isAllowedToPrecede(o.float))?!0:this.parent?this.parent.hasPrecedingFloatsDeferredToNext(t,!0):!1}getLastFollowingFloatInFragments(t){let e=t.getOrder(),n=null;if(this.floatFragments.forEach(s=>{s.continuations.forEach(o=>{let i=o.float,a=i.getOrder();a>e&&(!n||a>n.getOrder())&&(n=i)})}),this.parent){let s=this.parent.getLastFollowingFloatInFragments(t);s&&(!n||s.getOrder()>n.getOrder())&&(n=s)}return n}getDeferredPageFloatContinuations(t){t=t||this.flowName;let e=this.floatsDeferredFromPrevious.filter(n=>!t||n.float.flowName===t);return this.parent&&(e=this.parent.getDeferredPageFloatContinuations(t).concat(e)),e.sort((n,s)=>n.float.getOrder()-s.float.getOrder())}getPageFloatContinuationsDeferredToNext(t){t=t||this.flowName;let e=this.floatsDeferredToNext.filter(n=>!t||n.float.flowName===t);return this.parent?this.parent.getPageFloatContinuationsDeferredToNext(t).concat(e):e}getFloatsDeferredToNextInChildContexts(){let t=[],e=[];for(let n=this.children.length-1;n>=0;n--){let s=this.children[n];e.includes(s.flowName)||(e.push(s.flowName),t=t.concat(s.floatsDeferredToNext.map(o=>o.float)),t=t.concat(s.getFloatsDeferredToNextInChildContexts()))}return t}checkAndForbidNotAllowedFloat(){if(this.checkAndForbidFloatFollowingDeferredFloat())return!0;for(let t=this.floatFragments.length-1;t>=0;t--){let e=this.floatFragments[t],n=e.findNotAllowedFloat(this);if(n)return this.locked?this.invalidate():(this.removePageFloatFragment(e),this.forbid(n),this.removeEndFloatFragments(e.floatSide)),!0}return this.floatReference===ue.REGION&&this.parent.locked?this.parent.checkAndForbidNotAllowedFloat():!1}checkAndForbidFloatFollowingDeferredFloat(){let t=this.getFloatsDeferredToNextInChildContexts(),e=this.floatFragments.reduce((n,s)=>n.concat(s.continuations.map(o=>o.float)),[]);e.sort((n,s)=>s.getOrder()-n.getOrder());for(let n of e){let s=n.getOrder();if(t.some(o=>!n.isAllowedToPrecede(o)&&s>o.getOrder())){if(this.locked)this.invalidate();else{this.forbid(n);let o=this.findPageFloatFragment(n);this.removePageFloatFragment(o)}return!0}}return!1}finish(){if(!this.checkAndForbidNotAllowedFloat()){for(let t=this.floatsDeferredToNext.length-1;t>=0;t--)if(!this.floatsDeferredToNext[t].float.isAllowedOnContext(this)){if(this.locked){this.invalidate();return}this.floatsDeferredToNext.splice(t,1)}this.floatsDeferredFromPrevious.forEach(t=>{this.floatsDeferredToNext.findIndex(e=>t.equals(e))>=0||this.floatFragments.some(e=>e.hasFloat(t.float))||this.floatsDeferredToNext.push(t)})}}hasSameContainerAs(t){return!!this.container&&!!t.container&&this.container.element===t.container.element}invalidate(){this.invalidated=!0,!this.locked&&(this.container&&(this.children.forEach(t=>{this.hasSameContainerAs(t)&&t.floatFragments.forEach(e=>{let n=e.area.element;n&&n.parentNode&&n.parentNode.removeChild(n)})}),this.container.clear()),this.children.forEach(t=>{t.layoutConstraints.splice(0)}),this.children.splice(0),Object.keys(this.floatAnchors).forEach(t=>{delete this.floatAnchors[t]}))}detachChildren(){let t=this.children.splice(0);return t.forEach(e=>{e.floatFragments.forEach(n=>{let s=n.area.element;s&&s.parentNode&&s.parentNode.removeChild(s)})}),t}attachChildren(t){t.forEach(e=>{this.children.push(e),e.reattachFloatFragments()})}isInvalidated(){return this.invalidated||!!this.parent&&this.parent.isInvalidated()}validate(){this.invalidated=!1}toLogical(t){let e=this.writingMode.toString(),n=this.direction.toString();return Cc(t,e,n)}toPhysical(t){let e=this.writingMode.toString(),n=this.direction.toString();return mc(t,e,n)}removeEndFloatFragments(t){let e=this.toLogical(t);if(e==="block-end"||e==="inline-end"){let n=0;for(;n<this.floatFragments.length;){let s=this.floatFragments[n];this.toLogical(s.floatSide)===e?this.removePageFloatFragment(s):n++}}}stashEndFloatFragments(t){let e=t.floatReference;if(e!==this.floatReference){this.getParent(e).stashEndFloatFragments(t);return}let n=this.toLogical(t.floatSide);if(n==="block-end"||n==="snap-block"||n==="inline-end"){let s=0;for(;s<this.floatFragments.length;){let o=this.floatFragments[s],i=this.toLogical(o.floatSide);(i===n||n==="snap-block"&&i==="block-end")&&o.shouldBeStashedBefore(t)?(this.stashedFloatFragments.push(o),this.floatFragments.splice(s,1)):s++}}}restoreStashedFragments(t){if(t!==this.floatReference){this.getParent(t).restoreStashedFragments(t);return}this.stashedFloatFragments.forEach(e=>{this.addPageFloatFragment(e,!0)}),this.stashedFloatFragments.splice(0)}discardStashedFragments(t){if(t!==this.floatReference){this.getParent(t).discardStashedFragments(t);return}this.stashedFloatFragments.splice(0)}getStashedFloatFragments(t){return t===this.floatReference?this.stashedFloatFragments.concat().sort((e,n)=>n.getOrder()-e.getOrder()):this.getParent(t).getStashedFloatFragments(t)}getLimitValue(t,e,n,s){this.container;let o=this.toLogical(t),i=this.toPhysical(t),a=this.getLimitValueInner(o,e,n,s);if(this.parent&&this.parent.container){let l=this.parent.getLimitValue(i,e,n,s);switch(i){case"top":return Math.max(a,l);case"left":return Math.max(a,l);case"bottom":return Math.min(a,l);case"right":return Math.min(a,l);default:}}return a}getLimitValueInner(t,e,n,s){this.container;let o=this.getLimitValuesInner(e,n,s);switch(t){case"block-start":return this.container.vertical?o.right:o.top;case"block-end":return this.container.vertical?o.left:o.bottom;case"inline-start":return this.container.vertical?this.container.rtl?o.bottom:o.top:this.container.rtl?o.right:o.left;case"inline-end":return this.container.vertical?this.container.rtl?o.top:o.bottom:this.container.rtl?o.left:o.right;default:throw new Error(`Unknown logical side: ${t}`)}}getLimitValuesInner(t,e,n){this.container;let s=this.container.originX,o=this.container.originY,i=this.container.getPaddingRect(),a={top:i.y1-o,left:i.x1-s,bottom:i.y2-o,right:i.x2-s,floatMinWrapBlockStart:0,floatMinWrapBlockEnd:0};function l(u,p,h){return u.unit==="%"?h*u.num/100:t.convertLengthToPx(u,p,e)}let c=this.floatFragments;return c.length>0&&(a=c.reduce((u,p)=>{if(n&&!n(p,this))return u;let h=this.toLogical(p.floatSide),f=p.area,g=p.continuations[0].float.floatMinWrapBlock,m=u.top,E=u.left,C=u.bottom,b=u.right,y=u.floatMinWrapBlockStart,N=u.floatMinWrapBlockEnd;switch(h){case"inline-start":f.vertical?m=Math.max(m,f.top+f.height):E=Math.max(E,f.left+f.width);break;case"block-start":f.vertical?(g&&f.left<b&&(y=l(g,f.rootViewNodes[0],i.x2-i.x1)),b=Math.min(b,f.left)):(g&&f.top+f.height>m&&(y=l(g,f.rootViewNodes[0],i.y2-i.y1)),m=Math.max(m,f.top+f.height));break;case"inline-end":f.vertical?C=Math.min(C,f.top):b=Math.min(b,f.left);break;case"block-end":f.vertical?(g&&f.left+f.width>E&&(N=l(g,f.rootViewNodes[0],i.x2-i.x1)),E=Math.max(E,f.left+f.width)):(g&&f.top<C&&(N=l(g,f.rootViewNodes[0],i.y2-i.y1)),C=Math.min(C,f.top));break;default:throw new Error(`Unknown logical float side: ${h}`)}return{top:m,left:E,bottom:C,right:b,floatMinWrapBlockStart:y,floatMinWrapBlockEnd:N}},a)),a.left+=s,a.right+=s,a.top+=o,a.bottom+=o,a}setFloatAreaDimensions(t,e,n,s,o,i,a){if(e!==this.floatReference)return this.getParent(e).setFloatAreaDimensions(t,e,n,s,o,i,a);let l=this.toLogical(n);if(l==="snap-block"){if(!a["block-start"]&&!a["block-end"])return null}else if(!a[l])return null;t.clientLayout;let c=this.getLimitValue("block-start",t.layoutContext,t.clientLayout),u=this.getLimitValue("block-end",t.layoutContext,t.clientLayout),p=this.getLimitValue("inline-start",t.layoutContext,t.clientLayout),h=this.getLimitValue("inline-end",t.layoutContext,t.clientLayout),f=t.vertical?t.originX:t.originY,g=t.vertical?t.originY:t.originX;c=t.vertical?Math.min(c,t.left+t.getInsetLeft()+t.width+t.getInsetRight()+f):Math.max(c,t.top+f),u=t.vertical?Math.max(u,t.left+f):Math.min(u,t.top+t.getInsetTop()+t.height+t.getInsetBottom()+f);function m(N,S){let w=N(t.bands,S);return w?(t.vertical&&(w=Cr(w)),c=t.vertical?Math.min(c,w.x2):Math.max(c,w.y1),u=t.vertical?Math.max(u,w.x1):Math.min(u,w.y2),!0):i}let E,C,b,y;if(o){let N=t.vertical?Ks(new He(u,p,c,h)):new He(p,c,h,u);if((l==="block-start"||l==="snap-block"||l==="inline-start")&&!m(zp,N)||(l==="block-end"||l==="snap-block"||l==="inline-end")&&!m(Gp,N)||(b=(u-c)*t.getBoxDir(),E=b-t.getInsetBefore()-t.getInsetAfter(),y=(h-p)*t.getInlineDir(),C=y-t.getInsetStart()-t.getInsetEnd(),!i&&(E<=0||C<=0)))return null}else{E=t.computedBlockSize,b=E+t.getInsetBefore()+t.getInsetAfter();let N=(u-c)*t.getBoxDir();if(l==="snap-block"){if(s===null)l="block-start";else{let w=this.container.getPaddingRect(),A=this.container.getBoxDir()*(s-(this.container.vertical?w.x2:w.y1)),V=this.container.getBoxDir()*((this.container.vertical?w.x1:w.y2)-s-b);A<=V?l="block-start":l="block-end"}if(!a[l])if(a["block-end"])l="block-end";else return null}if(!i&&N<b)return null;l==="inline-start"||l==="inline-end"?C=no(t.clientLayout,t.element,["fit-content inline size"])["fit-content inline size"]:t.adjustContentRelativeSize?C=t.getContentInlineSize():C=t.vertical?t.height:t.width,y=C+t.getInsetStart()+t.getInsetEnd();let S=(h-p)*t.getInlineDir();if(!i&&S<y)return null}switch(c-=f,u-=f,p-=g,h-=g,l){case"inline-start":case"block-start":case"snap-block":t.setInlinePosition(p,C),t.setBlockPosition(c,E);break;case"inline-end":case"block-end":t.setInlinePosition(h-y*t.getInlineDir(),C),t.setBlockPosition(u-b*t.getBoxDir(),E);break;default:throw new Error(`unknown float direction: ${n}`)}return l}getFloatFragmentExclusions(){let t=this.floatFragments.map(e=>e.getOuterShape());return this.parent?this.parent.getFloatFragmentExclusions().concat(t):t}reattachFloatFragments(){let t=this.container.element&&this.container.element.parentNode;t&&this.floatFragments.forEach(e=>{t.appendChild(e.area.element)})}getMaxReachedAfterEdge(){let t=this.getContainer().vertical;return this.floatFragments.reduce((e,n)=>{let s=n.getOuterRect();return t?Math.min(e,s.x1):Math.max(e,s.y2)},t?1/0:0)}getBlockStartEdgeOfBlockEndFloats(){let t=this.getContainer().vertical;return this.floatFragments.filter(e=>e.floatSide==="block-end").reduce((e,n)=>{let s=n.getOuterRect();return t?Math.max(e,s.x2):Math.min(e,s.y1)},t?0:1/0)}getPageFloatClearEdge(t,e){function n(u){return p=>u.isAnchorAlreadyAppeared(p.float.getId())}function s(u,p){return u.continuations.some(n(p))}let o=e.getPaddingRect(),i=e.vertical?o.x1:o.y2,a=this;for(;a;){if(a.floatsDeferredToNext.some(n(a)))return i;a=a.parent}e.clientLayout;let l=this.getLimitValue("block-start",e.layoutContext,e.clientLayout,s);return this.getLimitValue("block-end",e.layoutContext,e.clientLayout,s)*e.getBoxDir()<i*e.getBoxDir()?i:l}getPageFloatPlacementCondition(t,e,n){if(t.floatReference!==this.floatReference)return this.getParent(t.floatReference).getPageFloatPlacementCondition(t,e,n);let s={"block-start":!0,"block-end":!0,"inline-start":!0,"inline-end":!0};if(!n)return s;let o=this.toLogical(e),i=this.toLogical(n),a;i==="all"?a=["block-start","block-end","inline-start","inline-end"]:i==="both"?a=["inline-start","inline-end"]:i==="same"?o==="snap-block"?a=["block-start","block-end"]:a=[o]:a=[i];let l=t.getOrder();function c(h){return f=>f.floatSide===h&&f.getOrder()<l}function u(h,f){return h.children.some(g=>g.floatFragments.some(c(f))||u(g,f))}function p(h,f){let g=h.parent;return!!g&&(g.floatFragments.some(c(f))||p(g,f))}return a.forEach(h=>{switch(h){case"block-start":case"inline-start":s[h]=!u(this,h);break;case"block-end":case"inline-end":s[h]=!p(this,h);break;default:throw new Error(`Unexpected side: ${h}`)}}),s}getLayoutConstraints(){return(this.parent?this.parent.getLayoutConstraints():[]).concat(this.layoutConstraints)}addLayoutConstraint(t,e){e===this.floatReference?this.layoutConstraints.push(t):this.getParent(e).addLayoutConstraint(t,e)}isColumnFullWithPageFloats(t){let e=t.layoutContext,n=t.clientLayout;let s=this,o=null;for(;s&&s.container;){let l=s.getLimitValuesInner(e,n);o?t.vertical?(l.right<o.right&&(o.right=l.right,o.floatMinWrapBlockStart=l.floatMinWrapBlockStart),l.left>o.left&&(o.left=l.left,o.floatMinWrapBlockEnd=l.floatMinWrapBlockEnd)):(l.top>o.top&&(o.top=l.top,o.floatMinWrapBlockStart=l.floatMinWrapBlockStart),l.bottom<o.bottom&&(o.bottom=l.bottom,o.floatMinWrapBlockEnd=l.floatMinWrapBlockEnd)):o=l,s=s.parent}let i=Math.max(o.floatMinWrapBlockStart,o.floatMinWrapBlockEnd);return(t.vertical?o.right-o.left:o.bottom-o.top)<=i}getMaxBlockSizeOfPageFloats(){let t=this.getContainer().vertical;return this.floatFragments.length?Math.max.apply(null,this.floatFragments.map(e=>{let n=e.area;return t?n.width:n.height})):0}lock(){this.locked=!0}unlock(){this.locked=!1}isLocked(){return this.locked}},qo=[],_t=class{static register(t){qo.push(t)}findByNodeContext(t){for(let e=qo.length-1;e>=0;e--){let n=qo[e];if(n.appliesToNodeContext(t))return n}throw new Error(`No PageFloatLayoutStrategy found for ${t}`)}findByFloat(t){for(let e=qo.length-1;e>=0;e--){let n=qo[e];if(n.appliesToFloat(t))return n}throw new Error(`No PageFloatLayoutStrategy found for ${t}`)}},Ac=class{appliesToNodeContext(t){return Dn(t.floatReference)}appliesToFloat(t){return!0}createPageFloat(t,e,n){let s=t.floatReference;t.floatSide;let o=t.floatSide,i=t.toNodePosition();return n.resolveFloatReferenceFromColumnSpan(s,t.columnSpan,t).thenAsync(a=>{s=a,e.flowName;let l=new Zo(i,s,o,t.clearSide,e.flowName,t.floatMinWrapBlock);return e.addPageFloat(l),v(l)})}createPageFloatFragment(t,e,n,s){let o=t[0].float;return new Qo(o.floatReference,e,t,n,s)}findPageFloatFragment(t,e){return e.findPageFloatFragment(t)}adjustPageFloatArea(t,e,n){}forbid(t,e){}};_t.register(new Ac);var Xm=Qo,ei=class r extends Zo{constructor(e,n,s,o,i){super(e,n,"block-end",null,s,i);this.footnotePolicy=o}isAllowedToPrecede(e){return!(e instanceof r)}},Gr=class extends Xm{constructor(t,e,n,s){super(t,"block-end",e,n,s)}getOrder(){return 1/0}shouldBeStashedBefore(t){return t instanceof ei?!0:this.getOrder()<t.getOrder()}},Lc=class{constructor(t){this.footnote=t}allowLayout(t){let e=t.toNodePosition();return!Dt(e,this.footnote.nodePosition)}},Rc=class{appliesToNodeContext(t){return t.floatSide==="footnote"}appliesToFloat(t){return t instanceof ei}createPageFloat(t,e,n){let s=ue.REGION,o=e.getPageFloatLayoutContext(s);e.getPageFloatLayoutContext(ue.PAGE).hasSameContainerAs(o)&&(s=ue.PAGE);let a=t.toNodePosition();e.flowName;let l=new ei(a,s,e.flowName,t.footnotePolicy,t.floatMinWrapBlock);return e.addPageFloat(l),v(l)}createPageFloatFragment(t,e,n,s){let o=t[0].float;return new Gr(o.floatReference,t,n,s)}findPageFloatFragment(t,e){let s=e.getPageFloatLayoutContext(t.floatReference).floatFragments.filter(o=>o instanceof Gr);return s.length<=1,s[0]||null}adjustPageFloatArea(t,e,n){t.isFootnote=!0,t.adjustContentRelativeSize=!1;let s=t.element;t.vertical=n.layoutContext.applyFootnoteStyle(e.vertical,n.layoutContext.nodeContext&&n.layoutContext.nodeContext.direction==="rtl",s),t.convertPercentageSizesToPx(s),n.setComputedInsets(s,t),n.setComputedWidthAndHeight(s,t)}forbid(t,e){let n=t;switch(n.footnotePolicy){case x.line:{let s=new Lc(n);e.addLayoutConstraint(s,n.floatReference);break}}}};_t.register(new Rc);var $m="data-vivliostyle-flow-root";function Fh(r){return r.getAttribute($m)==="true"}function Vh(r){let t=(r==null?void 0:r.toString())||"block",e;switch(t){case"inline-flex":e="flex";break;case"inline-grid":e="grid";break;case"inline-table":e="table";break;case"inline":case"table-row-group":case"table-column":case"table-column-group":case"table-header-group":case"table-footer-group":case"table-row":case"table-cell":case"table-caption":case"inline-block":e="block";break;default:e=t}return L(e)}function Wr(r){return r===x.absolute||r===x.fixed}function Ic(r){return r instanceof Pt&&r.name==="running"}function Vc(r,t,e,n){return r===x.none||(Wr(t)?(e=x.none,r=Vh(r)):(e&&e!==x.none&&!U(e)||n)&&(r=Vh(r))),{display:r,position:t,float:e}}function Xr(r,t,e,n){return Vc(r,t,e,n).display===x.block}function dn(r){switch(r.toString()){case"inline":case"inline-block":case"inline-list-item":case"inline-flex":case"inline-grid":case"ruby":case"inline-table":return!0;default:return!1}}function $r(r){switch(r.toString()){case"ruby-base":case"ruby-text":case"ruby-base-container":case"ruby-text-container":return!0;default:return!1}}function Bh(r,t,e,n,s,o,i){return s=s||o||x.horizontal_tb,!!i||!!e&&e!==x.none&&!U(e)||Wr(t)||r===x.inline_block||r===x.table_cell||r===x.table_caption||r==x.flex||r==x.grid||r==x.flow_root||(r===x.block||r===x.list_item)&&!!n&&n!==x.visible&&n!==x.clip&&!U(n)||!!o&&s!==o}function Oh(r){return r===x.relative||r===x.absolute||r===x.fixed}function Mn(r,t,e,n){let s=r.viewNode;if(!s)return NaN;let o=s.nodeType===1?s:s.parentElement;if(o&&o.namespaceURI==="http://www.w3.org/1999/xhtml"){let i=o.style;if(i&&dn(i.display)&&/^([\d\.]|super|(text-)?top)/.test(i.verticalAlign))return NaN}if(s===o){if(r.after||!r.inline){if(r.after&&!r.inline&&o.querySelector("ruby")){let a=o.parentNode,l=o.nextSibling;a.removeChild(o),a.insertBefore(o,l)}let i=t.getElementClientRect(o);if(i.left===0&&i.top===0&&i.right===0&&i.bottom===0)return NaN;if(i.right>=i.left&&i.bottom>=i.top)return r.after?n?i.left:i.bottom:n?i.right:i.top}return NaN}else{let i=NaN,a=s.ownerDocument.createRange(),l=s.textContent.length;if(!l)return NaN;r.after&&(e+=l),e>=l&&(e=l-1),a.setStart(s,e),a.setEnd(s,e+1);let c=t.getRangeClientRects(a);return c=c.filter(u=>u.right>u.left&&u.bottom>u.top),c.length?(n?i=Math.min.apply(null,c.map(u=>u.left)):i=Math.max.apply(null,c.map(u=>u.bottom)),i):NaN}}function ti(r,t,e){let n=t.clientLayout.getElementClientRect(r),s=t.getComputedMargin(r);return e?n.width+s.left+s.right:n.height+s.top+s.bottom}function pn(r){for(;r;){if(r.parentNode===r.ownerDocument)return!1;r=r.parentNode}return!0}function Yr(r,t){var e;if(r)for(let n=r.lastChild,s=n;n!==t;n=s)s=n.previousSibling,!(n.nodeType===1&&n.hasAttribute("data-vivliostyle-float-box-moved")&&((e=t.style)==null?void 0:e.display)==="inline")&&r.removeChild(n)}function Kr(r){return!!r.getAttribute(Mt)}function qr(r){var n;if((r==null?void 0:r.nodeType)!==1)return!1;let t=r;if(Kr(t))return!0;let e=(n=t.style)==null?void 0:n.position;return e==="absolute"||e==="fixed"}function hn(r){let t=r==null?void 0:r.viewNode;return(t==null?void 0:t.nodeType)===1&&Kr(t)}function Dh(r){return r!=="inline"&&(dn(r)||$r(r))}function Fc(r){for(let t=r.parent;t;t=t.parent)if(t.display!=="inline"&&dn(t.display))return t;return null}var ms=class{calculateOffset(t){return _n(this.getNodeContext(),t.collectElementsOffset())}breakPositionChosen(t){}getNodeContext(){return null}};function _n(r,t){return{current:t.reduce((e,n)=>e+n.calculateOffset(r),0),minimum:t.reduce((e,n)=>e+n.calculateMinimumOffset(r),0)}}var fn=class extends ms{constructor(e,n,s,o){super();this.position=e;this.breakOnEdge=n;this.overflows=s;this.computedBlockSize=o;d(this,"overflowIfRepetitiveElementsDropped");d(this,"isEdgeUpdated",!1);d(this,"edge",0);this.overflowIfRepetitiveElementsDropped=s}findAcceptableBreak(e,n){return this.updateOverflows(e),n<this.getMinBreakPenalty()?null:e.findEdgeBreakPosition(this)}getMinBreakPenalty(){if(!this.isEdgeUpdated)throw new Error("EdgeBreakPosition.prototype.updateEdge not called");let e=this.isFirstContentOfRepetitiveElementsOwner()&&!this.overflowIfRepetitiveElementsDropped;return(so(this.breakOnEdge)?1:0)+(this.overflows&&!e?3:0)+(this.position.parent?this.position.parent.breakPenalty:0)}updateEdge(e){var s;let n=e.calculateClonedPaddingBorder(this.position);if(this.edge=Mn(this.position,e.clientLayout,0,e.vertical)+n,!this.position.after&&!this.position.inline){let o=e.parseComputedLength(e.clientLayout.getElementComputedStyle(this.position.viewNode).marginBlockStart);this.edge-=(e.vertical?-1:1)*o}else if(this.position.after&&((s=this.position.shadowContext)==null?void 0:s.root.id)==="table-cell"){let o=e.element.parentElement,i=o==null?void 0:o.closest("table, [style*='display: table;']");if(i){let a=i.style.borderCollapse==="collapse",l=0,c=0;for(let u=o;u;u=u.parentElement){let p=e.clientLayout.getElementComputedStyle(u);if((u===o||u===i&&!a)&&(l+=e.parseComputedLength(p.paddingBlockEnd)),u===i&&!a&&(l+=e.parseComputedLength(p.borderSpacing.replace(/^\S+ (\S+)$/,"$1"))),a?c=Math.max(c,e.parseComputedLength(p.borderBlockEndWidth)):(u===o||u===i)&&(c+=e.parseComputedLength(p.borderBlockEndWidth)),u===i)break}this.edge+=(e.vertical?-1:1)*(l+c)}}this.isEdgeUpdated=!0}updateOverflows(e){this.isEdgeUpdated||this.updateEdge(e);let n=this.edge,s=this.calculateOffset(e);this.overflowIfRepetitiveElementsDropped=e.isOverflown(n+(e.vertical?-1:1)*s.minimum),this.overflows=this.position.overflow=e.isOverflown(n+(e.vertical?-1:1)*s.current)}getNodeContext(){return this.position}isFirstContentOfRepetitiveElementsOwner(){let e=this.getNodeContext();if(!e||!e.parent)return!1;let{formattingContext:n}=e.parent;if(!Qt.isInstanceOfRepetitiveElementsOwnerFormattingContext(n))return!1;let s=n.getRepetitiveElements();return s?s.isFirstContentNode(e):!1}};var Un=class{find(t){let e=Xe("RESOLVE_LAYOUT_PROCESSOR");for(let n=0;n<e.length;n++){let s=e[n](t);if(s)return s}throw new Error(`No processor found for a formatting context: ${t.getName()}`)}},Jt=class{layout(t,e,n){return e.isFloatNodeContext(t)?e.layoutFloatOrFootnote(t):e.isBreakable(t)?e.layoutBreakableBlock(t):e.layoutUnbreakable(t)}createEdgeBreakPosition(t,e,n,s){return new fn(t.copy(),e,n,s)}startNonInlineElementNode(t){return!1}afterNonInlineElementNode(t,e){return!1}clearOverflownViewNodes(t,e,n,s){var a;if(!n.viewNode||!n.viewNode.parentNode||n.shadowType===At.ShadowType.ROOTLESS&&hn(n))return;let o=n.viewNode;((a=o.parentElement)==null?void 0:a.localName)==="viv-ts-inner"&&(o=o.parentElement.parentElement);let i=o.parentNode;Yr(i,o),s&&i.removeChild(o)}finishBreak(t,e,n,s){let o=n||e.viewNode!=null&&e.viewNode.nodeType==1&&!e.after;return t.clearOverflownViewNodes(e,o),s&&t.layoutContext.processFragmentedBlockEdge(e),v(!0)}},co=class{constructor(t){this.parent=t;d(this,"formattingContextType","Block")}getName(){return"Block formatting context (BlockFormattingContext)"}isFirstTime(t,e){return e}getParent(){return this.parent}saveState(){}restoreState(t){}},ni=new Jt,Mh=Fr.isInstanceOfBlockFormattingContext;_e("RESOLVE_FORMATTING_CONTEXT",(r,t,e,n,s,o)=>{let i=r.parent;return!i&&r.formattingContext||i&&r.formattingContext!==i.formattingContext?null:r.establishesBFC||!r.formattingContext&&Xr(e,n,s,o)?new co(i?i.formattingContext:null):null});_e("RESOLVE_LAYOUT_PROCESSOR",r=>r instanceof co?ni:null);var Hn=class{constructor(){d(this,"initialBreakPositions",null);d(this,"initialStateOfFormattingContext",null);d(this,"initialPosition");d(this,"initialFragmentLayoutConstraints")}layout(t,e){return this.prepareLayout(t,e),this.tryLayout(t,e)}tryLayout(t,e){let n=k("AbstractLayoutRetryer.tryLayout");this.saveState(t,e);let s=this.resolveLayoutMode(t);return s.doLayout(t,e).then(o=>{let i=s.accept(o,e);i=s.postLayout(o,this.initialPosition,e,i),i?n.finish(o):(this.initialPosition,this.clearNodes(this.initialPosition),this.restoreState(t,e),this.tryLayout(this.initialPosition,e).thenFinish(n))}),n.result()}prepareLayout(t,e){}clearNodes(t){let e=t.viewNode||t.parent.viewNode,n;for(;n=e.lastChild;)e.removeChild(n);let s;for(;s=e.nextSibling;)s.parentNode.removeChild(s)}saveState(t,e){this.initialPosition=t.copy(),this.initialBreakPositions=[].concat(e.breakPositions),this.initialFragmentLayoutConstraints=[].concat(e.fragmentLayoutConstraints),t.formattingContext&&(this.initialStateOfFormattingContext=t.formattingContext.saveState())}restoreState(t,e){e.breakPositions=this.initialBreakPositions,e.fragmentLayoutConstraints=this.initialFragmentLayoutConstraints,t.formattingContext&&t.formattingContext.restoreState(this.initialStateOfFormattingContext)}};var Dc=class{initialState(t){return{nodeContext:t,atUnforcedBreak:!1,break:!1}}startNonDisplayableNode(t){}afterNonDisplayableNode(t){}startIgnoredTextNode(t){}afterIgnoredTextNode(t){}startNonElementNode(t){}afterNonElementNode(t){}startInlineElementNode(t){}afterInlineElementNode(t){}startNonInlineElementNode(t){}afterNonInlineElementNode(t){}finish(t){}},Cs=class{constructor(t,e){this.strategy=t;this.layoutContext=e}iterate(t){let e=this.strategy,n=e.initialState(t),s=k("LayoutIterator");return s.loopWithFrame(o=>{let i;for(;n.nodeContext;){n.nodeContext.viewNode?n.nodeContext.viewNode.nodeType!==1?he(n.nodeContext.viewNode,n.nodeContext.whitespace)?n.nodeContext.after?i=e.afterIgnoredTextNode(n):i=e.startIgnoredTextNode(n):n.nodeContext.after?i=e.afterNonElementNode(n):i=e.startNonElementNode(n):n.nodeContext.inline?n.nodeContext.after?i=e.afterInlineElementNode(n):i=e.startInlineElementNode(n):n.nodeContext.after?i=e.afterNonInlineElementNode(n):i=e.startNonInlineElementNode(n):n.nodeContext.after?i=e.afterNonDisplayableNode(n):i=e.startNonDisplayableNode(n);let l=(i&&i.isPending()?i:v(!0)).thenAsync(()=>n.break?v(null):this.layoutContext.nextInTree(n.nodeContext,n.atUnforcedBreak));if(l.isPending()){l.then(c=>{n.break?o.breakLoop():(n.nodeContext=c,o.continueLoop())});return}else if(n.break){o.breakLoop();return}else n.nodeContext=l.get()}e.finish(n),o.breakLoop()}).then(()=>{s.finish(n.nodeContext)}),s.result()}},gn=class extends Dc{constructor(e){super();this.leadingEdge=e}startNonInlineBox(e){}endEmptyNonInlineBox(e){}endNonInlineBox(e){}initialState(e){return{nodeContext:e,atUnforcedBreak:!!this.leadingEdge&&e.after,break:!1,leadingEdge:this.leadingEdge,breakAtTheEdge:null,onStartEdges:!1,leadingEdgeContexts:[],lastAfterNodeContext:null}}processForcedBreak(e,n){let s=!e.leadingEdge&&De(e.breakAtTheEdge);if(s){let o=e.nodeContext=e.leadingEdgeContexts[0]||e.nodeContext;o.viewNode.parentNode.removeChild(o.viewNode),n.pageBreakType=e.breakAtTheEdge}return s}saveEdgeAndProcessOverflow(e,n){let s=n.checkOverflowAndSaveEdgeAndBreakPosition(e.lastAfterNodeContext,null,!0,e.breakAtTheEdge);return s&&(e.nodeContext=(e.lastAfterNodeContext||e.nodeContext).modify(),e.nodeContext.overflow=!0),s}processLayoutConstraint(e,n,s){let o=e.nodeContext,i=!n.allowLayout(o);return i&&(s.checkOverflowAndSaveEdgeAndBreakPosition(e.lastAfterNodeContext,null,!1,e.breakAtTheEdge),o=e.nodeContext=o.modify(),o.overflow=!0),i}startNonElementNode(e){e.onStartEdges=!1}startNonInlineElementNode(e){return e.leadingEdgeContexts.push(e.nodeContext.copy()),e.breakAtTheEdge=Ve(e.breakAtTheEdge,e.nodeContext.breakBefore),e.onStartEdges=!0,this.startNonInlineBox(e)}afterNonInlineElementNode(e){let n,s;return e.onStartEdges?(n=this.endEmptyNonInlineBox(e),s=n&&n.isPending()?n:v(!0),s=s.thenAsync(()=>(e.break||(e.leadingEdgeContexts=[],e.leadingEdge=!1,e.atUnforcedBreak=!1,e.breakAtTheEdge=null),v(!0)))):(n=this.endNonInlineBox(e),s=n&&n.isPending()?n:v(!0)),s.thenAsync(()=>(e.break||(e.onStartEdges=!1,e.lastAfterNodeContext=e.nodeContext.copy(),e.breakAtTheEdge=Ve(e.breakAtTheEdge,e.nodeContext.breakAfter)),v(!0)))}};var Qr=[];function Uh(){Qr=[]}function Uc(r,t,e){return r-=e,t===0?r===0:r%t===0&&r/t>=0}var Mc=class{constructor(t){this.matchers=t}matches(){return this.matchers.some(t=>t.matches())}},_c=class{constructor(t){this.matchers=t}matches(){return this.matchers.every(t=>t.matches())}},uo=class uo{constructor(t,e,n){this.elementOffset=t;this.a=e;this.b=n}static registerFragmentIndex(t,e,n){let s=uo.fragmentIndices;(!s[t]||s[t].priority<=n)&&(s[t]={fragmentIndex:e,priority:n})}static clearFragmentIndices(){uo.fragmentIndices={}}matches(){let t=uo.fragmentIndices[this.elementOffset];return t!=null&&t.fragmentIndex!=null&&Uc(t.fragmentIndex,this.a,this.b)}};d(uo,"fragmentIndices",{});var zn=uo,bs=class{static buildViewConditionMatcher(t,e){let n=e.split("_");return n[0]=="NFS"?new zn(t,parseInt(n[1],10),parseInt(n[2],10)):(`${e}`,null)}static buildAllMatcher(t){return new _c(t)}static buildAnyMatcher(t){return new Mc(t)}};var wu={"border-collapse":!0,"border-spacing":!0,"caption-side":!0,"clip-rule":!0,color:!0,"color-interpolation":!0,"color-rendering":!0,cursor:!0,direction:!0,"empty-cells":!0,fill:!0,"fill-opacity":!0,"fill-rule":!0,"font-kerning":!0,"font-size":!0,"font-size-adjust":!0,"font-family":!0,"font-feature-settings":!0,"font-style":!0,"font-stretch":!0,"font-variant-ligatures":!0,"font-variant-caps":!0,"font-variant-numeric":!0,"font-variant-east-asian":!0,"font-weight":!0,"glyph-orientation-vertical":!0,"hanging-punctuation":!0,hyphens:!0,"hyphenate-character":!0,"hyphenate-limit-chars":!0,"hyphenate-limit-last":!0,"image-rendering":!0,"image-resolution":!0,"letter-spacing":!0,"line-break":!0,"line-height":!0,"list-style-image":!0,"list-style-position":!0,"list-style-type":!0,marker:!0,"marker-end":!0,"marker-mid":!0,"marker-start":!0,orphans:!0,"overflow-wrap":!0,"paint-order":!0,"pointer-events":!0,quotes:!0,"ruby-align":!0,"ruby-position":!0,"shape-rendering":!0,stroke:!0,"stroke-dasharray":!0,"stroke-dashoffset":!0,"stroke-linecap":!0,"stroke-linejoin":!0,"stroke-miterlimit":!0,"stroke-opacity":!0,"stroke-width":!0,"tab-size":!0,"text-align":!0,"text-align-last":!0,"text-anchor":!0,"text-autospace":!0,"text-decoration-skip":!0,"text-emphasis-color":!0,"text-emphasis-position":!0,"text-emphasis-style":!0,"text-fill-color":!0,"text-combine-upright":!0,"text-indent":!0,"text-justify":!0,"text-orientation":!0,"text-rendering":!0,"text-size-adjust":!0,"text-spacing-trim":!0,"text-stroke-color":!0,"text-stroke-width":!0,"text-transform":!0,"text-underline-position":!0,visibility:!0,"white-space":!0,widows:!0,"word-break":!0,"word-spacing":!0,"writing-mode":!0},jm=["image-resolution","orphans","widows"];function Xh(){return Xe("POLYFILLED_INHERITED_PROPS").reduce((t,e)=>t.concat(e()),[].concat(jm))}var Ym={"http://www.idpf.org/2007/ops":!0,"http://www.w3.org/1999/xhtml":!0,"http://www.w3.org/2000/svg":!0,"http://www.w3.org/1998/Math/MathML":!0},Gc=["margin-%","padding-%","border-%-width","border-%-style","border-%-color","%"],Km=["max-%","min-%","%"],qm=(()=>{let r=["left","right","top","bottom"],t={width:!0,height:!0,"max-width":!0,"max-height":!0,"min-width":!0,"min-height":!0};for(let e=0;e<Gc.length;e++)for(let n=0;n<r.length;n++){let s=Gc[e].replace("%",r[n]);t[s]=!0}return t})();function aa(r,t){let e={};for(let n of Gc)for(let s in r){let o=n.replace("%",s),i=n.replace("%",r[s]);e[o]=i,e[i]=o}for(let n of Km)for(let s in t){let o=n.replace("%",s),i=n.replace("%",t[s]);e[o]=i,e[i]=o}return e}var Pu=aa({"block-start":"right","block-end":"left","inline-start":"top","inline-end":"bottom"},{"block-size":"width","inline-size":"height"}),ku=aa({"block-start":"top","block-end":"bottom","inline-start":"left","inline-end":"right"},{"block-size":"height","inline-size":"width"}),Zm=aa({"block-start":"right","block-end":"left","inline-start":"bottom","inline-end":"top"},{"block-size":"width","inline-size":"height"}),Qm=aa({"block-start":"top","block-end":"bottom","inline-start":"right","inline-end":"left"},{"block-size":"height","inline-size":"width"}),M=class r{constructor(t,e){this.value=t;this.priority=e}getBaseValue(){return this}filterValue(t){let e=this.value.visit(t);return e===this.value?this:new r(e,this.priority)}increaseSpecificity(t){return t==0?this:new r(this.value,this.priority+t)}evaluate(t,e,n,s){return e&&bt(e)?this.value:ui(t,this.value,e,n,s)}isEnabled(t){return!0}},oi=class r extends M{constructor(e,n,s){super(e,n);this.condition=s}getBaseValue(){return new M(this.value,this.priority)}filterValue(e){let n=this.value.visit(e);return n===this.value?this:new r(n,this.priority,this.condition)}increaseSpecificity(e){return e==0?this:new r(this.value,this.priority+e,this.condition)}isEnabled(e){try{return!!this.condition.evaluate(e)}catch(n){I.warn(n)}return!1}};function Wc(r,t,e){return(!t||e.priority>=t.priority)&&e.isEnabled(r)?e.getBaseValue():t}function en(r,t,e,n){if(r)if(!e)delete r[t];else{let s=r[t];(!s||e.priority>=s.priority)&&(n?e.isEnabled(n)&&(r[t]=e.getBaseValue()):r[t]=e)}}var $h={"region-id":!0,"fragment-selector-id":!0};function Jm(r){return!!$h[r]}function Xc(r){return r.charAt(0)==="_"&&r!=="_viewConditionalStyles"}function xs(r){return r.charAt(0)!=="_"&&!$h[r]}function Wn(r){return!!wu[r]||bt(r)}function de(r,t){return r[t]}function mn(r,t,e){e?r[t]=e:delete r[t]}function Nt(r,t){return r[t]}function mo(r,t){let e=r[t];return e||(e={},r[t]=e),e}var jh=r=>{let t=r._viewConditionalStyles;return t||(t=[],r._viewConditionalStyles=t),t};function Au(r,t){return r[t]}function Yh(r,t){let e=r[t];return e||(e=[],r[t]=e),e}function ci(r,t,e,n,s,o,i){var l,c;if([{id:s,styleKey:"_pseudos"},{id:o,styleKey:"_regions"}].forEach(u=>{if(u.id){let p=mo(t,u.styleKey);t=p[u.id],t||(t={},p[u.id]=t)}}),i){let u=jh(t);t={},u.push({styles:t,matcher:i})}for(let u in e)if(!Xc(u))if(Jm(u)){let p=Au(e,u),h=Yh(t,u);Array.prototype.push.apply(h,p)}else{let p=de(e,u);if(!p.isEnabled(r))continue;let h=p.increaseSpecificity(n);en(t,u,h,r);let f=(c=(l=r.style)==null?void 0:l.validatorSet.shorthands[u])==null?void 0:c.propList;if(f)for(let g of f){let m=new M(O,h.priority);en(t,g,m,r)}}}function Kh(r,t){let e={};for(let n=0;n<t.length;n++)ci(r,e,t[n],0,null,null,null);return e}function qh(r,t){if(r.length>0){r.sort((n,s)=>s.getPriority()-n.getPriority());let e=null;for(let n=r.length-1;n>=0;n--)e=r[n],e.chained=t,t=e;return e}return t}var ea=class extends jt{constructor(e,n){super();this.props=e;this.context=n;d(this,"propName","")}setPropName(e){this.propName=e}getFontSize(){let e=de(this.props,"font-size");if(!e.value.isNumeric())return X.em;let n=e.value;if(!Rp(n.unit))throw new Error("Unexpected state");return n.num*X[n.unit]}visitNumeric(e){return this.context,this.propName==="font-size"?Lu(e,this.getFontSize(),this.context):e.unit==="em"||e.unit==="ex"||e.unit==="rem"||e.unit==="lh"||e.unit==="rlh"?la(e,this.getFontSize(),this.context):e}visitExpr(e){return this.propName=="font-size"?ui(this.context,e,this.propName).visit(this):e}};function la(r,t,e){let n=r.unit,s=r.num;if(n==="em"||n==="ex"){let o=X[n]/X.em;return new P(s*o*t,"px")}else return n==="rem"?new P(s*e.fontSize(),"px"):n==="rlh"?new P(s*e.rootLineHeight,"px"):r}function Lu(r,t,e){r=la(r,t,e);let n=r.unit,s=r.num;return n==="px"?r:n==="%"?new P(s/100*t,"px"):new P(s*e.queryUnitSize(n,!1),"px")}var Cn=class{apply(t){}mergeWith(t){return new $c([this,t])}clone(){return this}},ho=class extends Cn{constructor(e){super();this.conditionItem=e}apply(e){e.pushConditionItem(this.conditionItem.fresh(e))}},$c=class r extends Cn{constructor(e){super();this.list=e}apply(e){for(let n=0;n<this.list.length;n++)this.list[n].apply(e)}mergeWith(e){return this.list.push(e),this}clone(){return new r([].concat(this.list))}},Es=class extends Cn{constructor(e,n,s,o,i){super();this.style=e;this.specificity=n;this.pseudoelement=s;this.regionId=o;this.viewConditionId=i}apply(e){ci(e.context,e.currentStyle,this.style,this.specificity,this.pseudoelement,this.regionId,e.buildViewConditionMatcher(this.viewConditionId))}},Z=class extends Cn{constructor(){super();d(this,"chained",null)}apply(e){this.chained.apply(e)}getPriority(){return 0}makePrimary(e){return!1}},jc=class extends Z{constructor(e){super();this.className=e}apply(e){e.currentClassNames.includes(this.className)&&this.chained.apply(e)}getPriority(){return 10}makePrimary(e){return this.chained&&e.insertInTable(e.classes,this.className,this.chained),!0}},Yc=class extends Z{constructor(e){super();this.id=e}apply(e){(e.currentId==this.id||e.currentXmlId==this.id)&&this.chained.apply(e)}getPriority(){return 11}makePrimary(e){return this.chained&&e.insertInTable(e.ids,this.id,this.chained),!0}},ta=class extends Z{constructor(e){super();this.localName=e}apply(e){e.currentLocalName==this.localName&&this.chained.apply(e)}getPriority(){return 8}makePrimary(e){return this.chained&&e.insertInTable(e.tags,this.localName,this.chained),!0}},Kc=class extends Z{constructor(e,n){super();this.ns=e;this.localName=n}apply(e){e.currentLocalName==this.localName&&e.currentNamespace==this.ns&&this.chained.apply(e)}getPriority(){return 8}makePrimary(e){if(this.chained){let n=e.nsPrefix[this.ns];n||(n=`ns${e.nsCount++}:`,e.nsPrefix[this.ns]=n);let s=n+this.localName;e.insertInTable(e.nstags,s,this.chained)}return!0}},qc=class extends Z{constructor(e,n){super();this.epubTypePatt=e;this.targetLocalName=n}apply(e){let n=e.currentElement;if(n instanceof HTMLAnchorElement&&n.hash&&n.href==n.baseURI+n.hash){let s=n.hash.substring(1),o=n.ownerDocument.getElementById(s);if(o&&(!this.targetLocalName||o.localName==this.targetLocalName)){let i=o.getAttributeNS("http://www.idpf.org/2007/ops","type")||o.getAttribute("epub:type");i&&i.match(this.epubTypePatt)&&this.chained.apply(e)}}}},Zc=class extends Z{constructor(e){super();this.ns=e}apply(e){e.currentNamespace==this.ns&&this.chained.apply(e)}};function ca(r,t,e,n){if(!r)return!1;if(t!==null)return n(r,t,e);for(let s of r.getAttributeNames())if((s===e||s.endsWith(`:${e}`))&&n(r,s===e?"":r.lookupNamespaceURI(s.split(":")[0]),e))return!0;return!1}var na=class extends Z{constructor(e,n){super();this.ns=e;this.name=n}apply(e){ca(e.currentElement,this.ns,this.name,(n,s,o)=>n.hasAttributeNS(s,o))&&this.chained.apply(e)}},Qc=class extends Z{constructor(e,n,s){super();this.ns=e;this.name=n;this.value=s}apply(e){ca(e.currentElement,this.ns,this.name,(n,s,o)=>n.getAttributeNS(s,o)==this.value)&&this.chained.apply(e)}getPriority(){return this.name=="type"&&this.ns=="http://www.idpf.org/2007/ops"?9:0}makePrimary(e){return this.name=="type"&&this.ns=="http://www.idpf.org/2007/ops"?(this.chained&&e.insertInTable(e.epubtypes,this.value,this.chained),!0):!1}},Jc=class extends Z{constructor(e,n){super();this.ns=e;this.name=n}apply(e){ca(e.currentElement,this.ns,this.name,(n,s,o)=>!!Ym[n.getAttributeNS(s,o)])&&this.chained.apply(e)}getPriority(){return 0}makePrimary(e){return!1}},ys=class extends Z{constructor(e,n,s){super();this.ns=e;this.name=n;this.regexp=s}apply(e){ca(e.currentElement,this.ns,this.name,(n,s,o)=>{var i;return!!((i=n.getAttributeNS(s,o))!=null&&i.match(this.regexp))})&&this.chained.apply(e)}},eu=class extends Z{constructor(e){super();this.langRegExp=e}apply(e){e.lang.match(this.langRegExp)&&this.chained.apply(e)}},sa=class extends Z{constructor(){super()}apply(t){t.isFirst&&this.chained.apply(t)}getPriority(){return 6}},tu=class extends Z{constructor(){super()}apply(t){t.isRoot&&this.chained.apply(t)}getPriority(){return 12}},Gn=class extends Z{constructor(e,n){super();this.a=e;this.b=n}matchANPlusB(e){return Uc(e,this.a,this.b)}},nu=class extends Gn{constructor(t,e){super(t,e)}apply(t){this.matchANPlusB(t.currentSiblingOrder)&&this.chained.apply(t)}getPriority(){return 5}},ii=class extends Gn{constructor(t,e){super(t,e)}apply(t){let e=t.currentSiblingTypeCounts[t.currentNamespace][t.currentLocalName];this.matchANPlusB(e)&&this.chained.apply(t)}getPriority(){return 5}},ri=class extends Gn{constructor(t,e){super(t,e)}apply(t){let e=t.currentFollowingSiblingOrder;e===null&&(e=t.currentFollowingSiblingOrder=t.currentElement.parentNode.childElementCount-t.currentSiblingOrder+1),this.matchANPlusB(e)&&this.chained.apply(t)}getPriority(){return 4}},ai=class extends Gn{constructor(t,e){super(t,e)}apply(t){let e=t.currentFollowingSiblingTypeCounts;if(!e[t.currentNamespace]){let n=t.currentElement;do{let s=n.namespaceURI,o=n.localName,i=e[s];i||(i=e[s]={}),i[o]=(i[o]||0)+1}while(n=n.nextElementSibling)}this.matchANPlusB(e[t.currentNamespace][t.currentLocalName])&&this.chained.apply(t)}getPriority(){return 4}},su=class extends Z{constructor(){super()}apply(t){let e=t.currentElement.firstChild;for(;e;){switch(e.nodeType){case Node.ELEMENT_NODE:return;case Node.TEXT_NODE:if(e.length>0)return}e=e.nextSibling}this.chained.apply(t)}getPriority(){return 4}},ou=class extends Z{constructor(){super()}apply(t){t.currentElement.disabled===!1&&this.chained.apply(t)}getPriority(){return 5}},iu=class extends Z{constructor(){super()}apply(t){t.currentElement.disabled===!0&&this.chained.apply(t)}getPriority(){return 5}},ru=class extends Z{constructor(){super()}apply(t){let e=t.currentElement;(e.selected===!0||e.checked===!0)&&this.chained.apply(t)}getPriority(){return 5}},ze=class extends Z{constructor(e){super();this.condition=e}apply(e){if(e.conditions[this.condition])try{e.dependentConditions.push(this.condition),this.chained.apply(e)}finally{e.dependentConditions.pop()}}getPriority(){return 5}},au=class r extends Cn{constructor(){super();d(this,"applied",!1)}apply(e){this.applied=!0}clone(){let e=new r;return e.applied=this.applied,e}},li=class extends Z{constructor(e){super();d(this,"checkAppliedAction");d(this,"firstActions",[]);this.checkAppliedAction=new au;for(let n of e)this.firstActions.push(qh(n,this.checkAppliedAction))}apply(e){for(let n of this.firstActions)if(n.apply(e),this.checkAppliedAction.applied)break;this.checkAppliedAction.applied===this.positive()&&this.chained.apply(e),this.checkAppliedAction.applied=!1}getPriority(){return Math.max(...this.firstActions.map(e=>e instanceof Z?e.getPriority():0))}positive(){return!0}relational(){return!1}},lu=class extends li{positive(){return!1}},cu=class extends li{constructor(e){super([]);this.selectorTexts=e}apply(e){for(let n of this.selectorTexts){let s,o;/^\s*[+~]/.test(n)?(o=e.currentElement.parentNode,s=`:scope > :nth-child(${Array.from(o.children).indexOf(e.currentElement)+1}) ${n}`):(o=e.currentElement,s=`:scope ${n}`);try{if(o.querySelector(s)){this.checkAppliedAction.apply(e);break}}catch(i){}}this.checkAppliedAction.applied&&this.chained.apply(e),this.checkAppliedAction.applied=!1}relational(){return!0}},fo=class{constructor(t,e,n){this.condition=t;this.viewConditionId=e;this.viewCondition=n}increment(t){t.increment(this.condition,this.viewCondition)}decrement(t){t.decrement(this.condition,this.viewCondition)}buildViewConditionMatcher(t){return t.buildViewConditionMatcher(this.viewConditionId)}},uu=class r extends fo{constructor(t,e,n){super(t,e,n)}fresh(t){return new r(this.condition,this.viewConditionId,this.buildViewConditionMatcher(t))}push(t,e){return e==0&&this.increment(t),!1}pop(t,e){return e==0?(this.decrement(t),!0):!1}},du=class r extends fo{constructor(t,e,n){super(t,e,n)}fresh(t){return new r(this.condition,this.viewConditionId,this.buildViewConditionMatcher(t))}push(t,e){return e==0?this.increment(t):e==1&&this.decrement(t),!1}pop(t,e){return e==0?(this.decrement(t),!0):(e==1&&this.increment(t),!1)}},pu=class r extends fo{constructor(e,n,s){super(e,n,s);d(this,"fired",!1)}fresh(e){return new r(this.condition,this.viewConditionId,this.buildViewConditionMatcher(e))}push(e,n){return this.fired?(this.decrement(e),!0):!1}pop(e,n){return this.fired?(this.decrement(e),!0):(n==0&&(this.fired=!0,this.increment(e)),!1)}},hu=class r extends fo{constructor(e,n,s){super(e,n,s);d(this,"fired",!1)}fresh(e){return new r(this.condition,this.viewConditionId,this.buildViewConditionMatcher(e))}push(e,n){return this.fired&&(n==-1?this.increment(e):n==0&&this.decrement(e)),!1}pop(e,n){if(this.fired){if(n==-1)return this.decrement(e),!0;n==0&&this.increment(e)}else n==0&&(this.fired=!0,this.increment(e));return!1}},fu=class{constructor(t,e){this.afterprop=t;this.element=e}fresh(t){return this}push(t,e){return!1}pop(t,e){return e==0?(t.processPseudoelementProps(this.afterprop,this.element),!0):!1}},gu=class{constructor(t){this.lang=t}fresh(t){return this}push(t,e){return!1}pop(t,e){return e==0?(t.lang=this.lang,!0):!1}},mu=class{constructor(t){this.oldQuotes=t}fresh(t){return this}push(t,e){return!1}pop(t,e){return e==0?(t.quotes=this.oldQuotes,!0):!1}},Cu=class extends jt{constructor(e){super();this.element=e}createValueFromString(e,n){switch(n){case"url":return e?new Ue(e):new Ue("about:invalid");case"string":default:return e?new ce(e):new ce("")}}visitFunc(e){if(e.name!=="attr")return super.visitFunc(e);let n="string",s=null,o=null;if(e.values[0]instanceof q){let i=e.values[0].values;i.length>=2&&(n=i[1].stringValue()),s=i[0].stringValue()}else s=e.values[0].stringValue();return e.values.length>1?o=this.createValueFromString(e.values[1].stringValue(),n):o=this.createValueFromString(null,n),this.element&&this.element.hasAttribute(s)?this.createValueFromString(this.element.getAttribute(s),n):o}};function si(r){if(St(r)){if(r instanceof ce)return r.stringValue();if(r instanceof q)return r.values.map(t=>si(t)).join("")}return""}var go=class extends jt{constructor(e,n,s){super();this.cascade=e;this.element=n;this.counterResolver=s}visitIdent(e){let n=this.cascade,s=n.quotes,o=Math.floor(s.length/2)-1;switch(e.name){case"open-quote":{let i=s[2*Math.min(o,n.quoteDepth)];return n.quoteDepth++,i}case"close-quote":return n.quoteDepth>0&&n.quoteDepth--,s[2*Math.min(o,n.quoteDepth)+1];case"no-open-quote":return n.quoteDepth++,new ce("");case"no-close-quote":return n.quoteDepth>0&&n.quoteDepth--,new ce("")}return e}format(e,n){let s=!1,o=!1,i;(i=n.match(/^upper-(.*)/))!=null?(s=!0,n=i[1]):(i=n.match(/^lower-(.*)/))!=null&&(o=!0,n=i[1]);let a="";return zh[n]?a=tC(zh[n],e):Gh[n]?a=sC(Gh[n],e):Wh[n]!=null?a=Wh[n]:n=="decimal-leading-zero"?(a=`${e}`,a.length==1&&(a=`0${a}`)):n=="cjk-ideographic"||n=="trad-chinese-informal"?a=iC(e,oC):a=`${e}`,s?a.toUpperCase():o?a.toLowerCase():a}visitFuncCounter(e){let n=e[0].toString(),s=e.length>1?e[1].stringValue():"decimal",o=this.cascade.counters[n];if(o&&o.length){let i=o&&o.length&&o[o.length-1]||0;return new ce(this.format(i,s))}else{let i=new F(this.counterResolver.getPageCounterVal(n,a=>this.format(a||0,s)));return new q([i])}}visitFuncCounters(e){let n=e[0].toString(),s=e[1].stringValue(),o=e.length>2?e[2].stringValue():"decimal",i=this.cascade.counters[n],a=new je;if(i&&i.length)for(let c=0;c<i.length;c++)c>0&&a.append(s),a.append(this.format(i[c],o));let l=new F(this.counterResolver.getPageCountersVal(n,c=>{let u=[];if(c.length)for(let h=0;h<c.length;h++)u.push(this.format(c[h],o));let p=a.toString();return p.length&&u.push(p),u.length?u.join(s):this.format(0,o)}));return new q([l])}visitFuncTargetCounter(e){let n=e[0],s;n instanceof Ue?s=n.url:s=n.stringValue();let o=e[1].toString(),i=e.length>2?e[2].stringValue():"decimal",a=new F(this.counterResolver.getTargetCounterVal(s,o,l=>this.format(l||0,i)));return new q([a])}visitFuncTargetCounters(e){let n=e[0],s;n instanceof Ue?s=n.url:s=n.stringValue();let o=e[1].toString(),i=e[2].stringValue(),a=e.length>3?e[3].stringValue():"decimal",l=new F(this.counterResolver.getTargetCountersVal(s,o,c=>{let u=c.map(p=>this.format(p,a));return u.length?u.join(i):this.format(0,a)}));return new q([l])}visitFuncString(e){let n=e.length>0?e[0].stringValue():"",s=e.length>1?e[1].stringValue():"first";return new F(this.counterResolver.getNamedStringVal(n,s))}visitFuncElement(e){let n=e.length>0?e[0].stringValue():"",s=e.length>1?e[1].stringValue():"first";return new F(this.counterResolver.getRunningElementVal(n,s))}visitFuncContent(e){var o,i,a,l,c,u;let n=e.length>0?e[0].stringValue():"text",s="";switch(n){case"text":s=this.element.textContent;break;case"before":case"after":{let p=Nt(this.cascade.currentStyle,"_pseudos"),h=(i=(o=p==null?void 0:p[n])==null?void 0:o.content)==null?void 0:i.value;s=si(h)}break;case"first-letter":{let p=Nt(this.cascade.currentStyle,"_pseudos"),h=(si((l=(a=p==null?void 0:p.before)==null?void 0:a.content)==null?void 0:l.value)||this.element.textContent||si((u=(c=p==null?void 0:p.after)==null?void 0:c.content)==null?void 0:u.value)).match(Lo);s=h?h[0]:""}break}return new ce(s)}visitFuncLeader(e){let n="";if(e[0]instanceof Be)switch(e[0].stringValue()){case"dotted":n=".";break;case"solid":n="_";break;case"space":n=" ";break}else e[0]instanceof ce&&(n=e[0].stringValue());return n.length==0?new ce(""):new F(new oe(null,()=>n,"viv-leader"))}visitFunc(e){switch(e.name){case"counter":if(e.values.length<=2)return this.visitFuncCounter(e.values);break;case"counters":if(e.values.length<=3)return this.visitFuncCounters(e.values);break;case"target-counter":if(e.values.length<=3)return this.visitFuncTargetCounter(e.values);break;case"target-counters":if(e.values.length<=4)return this.visitFuncTargetCounters(e.values);break;case"string":if(e.values.length<=2)return this.visitFuncString(e.values);break;case"element":if(e.values.length<=2)return this.visitFuncElement(e.values);break;case"content":if(e.values.length<=1)return this.visitFuncContent(e.values);break;case"leader":if(e.values.length<=1)return this.visitFuncLeader(e.values);break}return e}},eC=(r,t,e)=>{let n=t.filter(l=>l.after&&l.viewNode.nodeType===1&&l.viewNode.getAttribute("data-viv-leader"));for(let l of n){let C=function(Q){if(m==="rtl"){let re="\u200F";u.textContent=(Q.startsWith(re)?"":re)+Q+(Q.endsWith(re)?"":re)}else u.textContent=Q},S=function(){let Q=e.clientLayout.getElementClientRect(p);return b.left>Q.left||b.right<Q.right||b.top>Q.top||b.bottom<Q.bottom},w=function(){let Q,re;if(C(f),S())Q=1,re=f.length/h.length;else{Q=f.length/h.length,re=Q;for(let Te=0;Te<16;Te++){let Ge=f;for(let R=0;R<1<<Te;R++)Ge+=h;if(C(Ge),S()){re+=1<<Te;break}}}for(let Te=0;Te<16;Te++){let Ge="",R=Math.floor((Q+re)/2);for(let G=0;G<R;G++)Ge+=h;if(C(Ge),S())re=R;else{if(Q==R)return;Q=R}}C(h)},_=function(Q){let re=0,Te=p.parentElement;for(;Te&&Te!==c.viewNode;)re+=e.getComputedInsets(Te)[Q],Te=Te.parentElement;return re};var s=C,o=S,i=w,a=_;let c=l.parent;for(;c&&c.inline;)c=c.parent;let u=l.viewNode,p=u.parentElement,h=u.getAttribute("data-viv-leader-value"),f=u.textContent||h,{writingMode:g,direction:m,marginInlineEnd:E}=e.clientLayout.getElementComputedStyle(p);u.style.marginInlineStart="1px",C(h),p.style.display="inline-block",p.style.textIndent="0";let b=e.clientLayout.getElementClientRect(c.viewNode),y=e.clientLayout.getElementClientRect(p),N=e.parseComputedLength(E);g==="vertical-rl"||g==="vertical-lr"?(m==="rtl"?b.top+=N:b.bottom-=N,b.left=y.left,b.right=y.right,b.top=Math.min(y.top,b.top),b.bottom=Math.max(y.bottom,b.bottom)):(m==="rtl"?b.left+=N:b.right-=N,b.top=y.top,b.bottom=y.bottom,b.left=Math.min(y.left,b.left),b.right=Math.max(y.right,b.right)),w();let A=e.clientLayout.getElementClientRect(p);m=="rtl"?p.style.float="left":p.style.float="right";let V=e.clientLayout.getElementClientRect(p),Ee=0;m=="rtl"?g=="vertical-rl"||g=="vertical-lr"?Ee=A.top-V.top-_("top"):Ee=A.left-V.left-_("left"):g=="vertical-rl"||g=="vertical-lr"?Ee=V.bottom-A.bottom-_("bottom"):Ee=V.right-A.right-_("right"),Ee=Math.max(0,Ee-.1),p.style.float="",u.style.marginInlineStart=`${Ee}px`}};_e("POST_LAYOUT_BLOCK",eC);var zh={roman:[4999,1e3,"M",900,"CM",500,"D",400,"CD",100,"C",90,"XC",50,"L",40,"XL",10,"X",9,"IX",5,"V",4,"IV",1,"I"],armenian:[9999,9e3,"\u0584",8e3,"\u0583",7e3,"\u0582",6e3,"\u0581",5e3,"\u0580",4e3,"\u057F",3e3,"\u057E",2e3,"\u057D",1e3,"\u057C",900,"\u057B",800,"\u057A",700,"\u0579",600,"\u0578",500,"\u0577",400,"\u0576",300,"\u0575",200,"\u0574",100,"\u0573",90,"\u0572",80,"\u0571",70,"\u0570",60,"\u056F",50,"\u056E",40,"\u056D",30,"\u056C",20,"\u056B",10,"\u056A",9,"\u0569",8,"\u0568",7,"\u0567",6,"\u0566",5,"\u0565",4,"\u0564",3,"\u0563",2,"\u0562",1,"\u0561"],georgian:[19999,1e4,"\u10F5",9e3,"\u10F0",8e3,"\u10EF",7e3,"\u10F4",6e3,"\u10EE",5e3,"\u10ED",4e3,"\u10EC",3e3,"\u10EB",2e3,"\u10EA",1e3,"\u10E9",900,"\u10E8",800,"\u10E7",700,"\u10E6",600,"\u10E5",500,"\u10E4",400,"\u10F3",300,"\u10E2",200,"\u10E1",100,"\u10E0",90,"\u10DF",80,"\u10DE",70,"\u10DD",60,"\u10F2",50,"\u10DC",40,"\u10DB",30,"\u10DA",20,"\u10D9",10,"\u10D8",9,"\u10D7",8,"\u10F1",7,"\u10D6",6,"\u10D5",5,"\u10D4",4,"\u10D3",3,"\u10D2",2,"\u10D1",1,"\u10D0"],hebrew:[999,400,"\u05EA",300,"\u05E9",200,"\u05E8",100,"\u05E7",90,"\u05E6",80,"\u05E4",70,"\u05E2",60,"\u05E1",50,"\u05E0",40,"\u05DE",30,"\u05DC",20,"\u05DB",19,"\u05D9\u05D8",18,"\u05D9\u05D7",17,"\u05D9\u05D6",16,"\u05D8\u05D6",15,"\u05D8\u05D5",10,"\u05D9",9,"\u05D8",8,"\u05D7",7,"\u05D6",6,"\u05D5",5,"\u05D4",4,"\u05D3",3,"\u05D2",2,"\u05D1",1,"\u05D0"]},Gh={latin:"a-z",alpha:"a-z",greek:"\u03B1-\u03C1\u03C3-\u03C9",russian:"\u0430-\u0438\u043A-\u0449\u044D-\u044F"},Wh={square:"\u25A0",disc:"\u2022",circle:"\u25E6",none:""};function tC(r,t){let e=r[0];if(t>e||t<=0||t!=Math.round(t))return"";let n="";for(let s=1;s<r.length;s+=2){let o=r[s],i=Math.floor(t/o);if(i>20)return"";for(t-=i*o;i>0;)n+=r[s+1],i--}return n}function nC(r){let t=[],e=0;for(;e<r.length;)if(r.substr(e+1,1)=="-"){let n=r.charCodeAt(e),s=r.charCodeAt(e+2);e+=3;for(let o=n;o<=s;o++)t.push(String.fromCharCode(o))}else t.push(r.substr(e++,1));return t}function sC(r,t){if(t<=0||t!=Math.round(t))return"";let e=nC(r),n="";do{t--;let s=t%e.length;n=e[s]+n,t=(t-s)/e.length}while(t>0);return n}var oC={formal:!1,digits:"\u96F6\u4E00\u4E8C\u4E09\u56DB\u4E94\u516D\u4E03\u516B\u4E5D",markers:"\u5341\u767E\u5343",negative:"\u8CA0"};function iC(r,t){if(r>9999||r<-9999)return`${r}`;if(r==0)return t.digits.charAt(0);let e=new je;if(r<0&&(e.append(t.negative),r=-r),r<10)e.append(t.digits.charAt(r));else if(!t.formal&&r<=19)e.append(t.markers.charAt(0)),r!=0&&e.append(t.digits.charAt(r-10));else{let n=Math.floor(r/1e3);n&&(e.append(t.digits.charAt(n)),e.append(t.markers.charAt(2)));let s=Math.floor(r/100)%10;s&&(e.append(t.digits.charAt(s)),e.append(t.markers.charAt(1)));let o=Math.floor(r/10)%10;o&&(e.append(t.digits.charAt(o)),e.append(t.markers.charAt(0)));let i=r%10;i&&e.append(t.digits.charAt(i))}return e.toString()}var Ru=1/1048576;function po(r,t){for(let e in r)t[e]=r[e].clone()}var bu=class r{constructor(){d(this,"nsCount",0);d(this,"nsPrefix",{});d(this,"tags",{});d(this,"nstags",{});d(this,"epubtypes",{});d(this,"classes",{});d(this,"ids",{});d(this,"pagetypes",{});d(this,"order",0)}clone(){let t=new r;t.nsCount=this.nsCount;for(let e in this.nsPrefix)t.nsPrefix[e]=this.nsPrefix[e];return po(this.tags,t.tags),po(this.nstags,t.nstags),po(this.epubtypes,t.epubtypes),po(this.classes,t.classes),po(this.ids,t.ids),po(this.pagetypes,t.pagetypes),t.order=this.order,t}insertInTable(t,e,n){let s=t[e];s&&(n=s.mergeWith(n)),t[e]=n}createInstance(t,e,n,s){return new yu(this,t,e,n,s)}nextOrder(){return this.order+=Ru}},yu=class{constructor(t,e,n,s,o){this.context=e;this.counterListener=n;this.counterResolver=s;d(this,"code");d(this,"stack",[[],[]]);d(this,"conditions",{});d(this,"currentElement",null);d(this,"currentElementOffset",null);d(this,"currentStyle",null);d(this,"currentClassNames",null);d(this,"currentLocalName","");d(this,"currentNamespace","");d(this,"currentId","");d(this,"currentXmlId","");d(this,"currentNSTag","");d(this,"currentEpubTypes",null);d(this,"currentPageType",null);d(this,"previousPageType",null);d(this,"firstPageType",null);d(this,"isFirst",!0);d(this,"isRoot",!0);d(this,"counters",{});d(this,"counterScoping",[{}]);d(this,"quotes");d(this,"quoteDepth",0);d(this,"lang","");d(this,"siblingOrderStack",[0]);d(this,"currentSiblingOrder",0);d(this,"siblingTypeCountsStack",[{}]);d(this,"currentSiblingTypeCounts");d(this,"currentFollowingSiblingOrder",null);d(this,"followingSiblingOrderStack");d(this,"followingSiblingTypeCountsStack",[{}]);d(this,"currentFollowingSiblingTypeCounts");d(this,"viewConditions",{});d(this,"dependentConditions",[]);d(this,"elementStack");this.code=t,this.quotes=[new ce("\u201C"),new ce("\u201D"),new ce("\u2018"),new ce("\u2019")],this.currentSiblingTypeCounts=this.siblingTypeCountsStack[0],this.followingSiblingOrderStack=[this.currentFollowingSiblingOrder],this.currentFollowingSiblingTypeCounts=this.siblingTypeCountsStack[0]}pushConditionItem(t){this.stack[this.stack.length-1].push(t)}increment(t,e){this.conditions[t]=(this.conditions[t]||0)+1,e&&(this.viewConditions[t]?this.viewConditions[t].push(e):this.viewConditions[t]=[e])}decrement(t,e){this.conditions[t]--,this.viewConditions[t]&&(this.viewConditions[t]=this.viewConditions[t].filter(n=>n!==e),this.viewConditions[t].length===0&&delete this.viewConditions[t])}buildViewConditionMatcher(t){let e=null;t&&(this.currentElementOffset,e=bs.buildViewConditionMatcher(this.currentElementOffset,t));let n=this.dependentConditions.map(s=>{let o=this.viewConditions[s];return o&&o.length>0?o.length===1?o[0]:bs.buildAnyMatcher([].concat(o)):null}).filter(s=>s);return n.length<=0?e:e===null?n.length===1?n[0]:bs.buildAllMatcher(n):bs.buildAllMatcher([e].concat(n))}applyAction(t,e){let n=t[e];n&&n.apply(this)}pushRule(t,e,n){this.currentElement=null,this.currentElementOffset=null,this.currentStyle=n,this.currentNamespace="",this.currentLocalName="",this.currentId="",this.currentXmlId="",this.currentClassNames=t,this.currentNSTag="",this.currentEpubTypes=zc,this.currentPageType=e,this.applyActions()}defineCounter(t,e){let n=this.counterScoping[this.counterScoping.length-1];n||(n={},this.counterScoping[this.counterScoping.length-1]=n),this.counters[t]?(n[t]&&this.counters[t].pop(),this.counters[t].push(e)):this.counters[t]=[e],n[t]=!0}pushCounters(t){var h,f,g,m,E,C,b;let e=x.inline,n=t.display;if(n&&(e=n.evaluate(this.context)),e===x.none){this.currentElement.setAttribute("data-viv-display-none","true"),this.counterScoping.push(null);return}else if(this.currentElement.closest("[data-viv-display-none]")){this.counterScoping.push(null);return}let s=x.inline,o=t.float;o&&(s=o.evaluate(this.context));let i=null,a=null,l=null,c=t["counter-reset"];if(c){let y=c.evaluate(this.context);y&&(i=is(y,!0))}let u=t["counter-set"];if(u){let y=u.evaluate(this.context);y&&(l=is(y,!1))}let p=t["counter-increment"];if(p){let y=p.evaluate(this.context);y&&(a=is(y,!1))}if((this.currentLocalName=="ol"||this.currentLocalName=="ul")&&this.currentNamespace=="http://www.w3.org/1999/xhtml"&&(i||(i={}),i["list-item"]=((f=(h=this.currentElement)==null?void 0:h.start)!=null?f:1)-1),e===x.list_item&&(a||(a={}),a["list-item"]=(g=a["list-item"])!=null?g:1,/^\s*[-+]?\d/.test((E=(m=this.currentElement)==null?void 0:m.getAttribute("value"))!=null?E:"")&&(l||(l={}),l["list-item"]=this.currentElement.value)),((C=this.currentElement)==null?void 0:C.parentNode.nodeType)===Node.DOCUMENT_NODE&&(i||(i={}),i.footnote===void 0&&(i.footnote=0)),s===x.footnote&&(a||(a={}),a.footnote===void 0)){let y=(b=this.currentStyle["counter-increment"])==null?void 0:b.value;(!y||!(y===x.footnote||y instanceof q&&y.values.includes(x.footnote)))&&(a.footnote=1)}if(i)for(let y in i)this.defineCounter(y,i[y]);if(a)for(let y in a){this.counters[y]||this.defineCounter(y,0);let N=this.counters[y];N[N.length-1]+=a[y]}if(l)for(let y in l)if(!this.counters[y])this.defineCounter(y,l[y]);else{let N=this.counters[y];N[N.length-1]=l[y]}if(e===x.list_item){let y=this.counters["list-item"],N=y[y.length-1];t["ua-list-item-count"]=new M(new lt(N),0)}this.counterScoping.push(null)}popCounters(){let t=this.counterScoping.pop();if(t)for(let e in t){let n=this.counters[e];n&&(n.length==1?delete this.counters[e]:n.pop())}}setNamedStrings(t){let e=t["string-set"];if(!e)return;e=e.filterValue(new go(this,this.currentElement,this.counterResolver));let n=e.value instanceof ge?e.value.values:[e.value];for(let s of n)if(s instanceof q){let o=s.values[0].stringValue(),i=s.values.slice(1).map(a=>si(a)).join("");this.counterResolver.setNamedString(o,i,this.currentElementOffset)}delete t["string-set"]}setRunningElement(t){let e=t.position;if((e==null?void 0:e.value)instanceof Pt&&e.value.name==="running"){let n=e.value.values[0].stringValue();this.counterResolver.setRunningElement(n,this.currentElementOffset)}}processPseudoelementProps(t,e){this.pushCounters(t);let n=t.content;n&&(t.content=n.filterValue(new go(this,e,this.counterResolver))),this.popCounters()}pushElement(t,e,n,s){var S,w;this.currentPageType=null,this.currentElement=e,this.currentElementOffset=s,this.currentStyle=n,this.currentNamespace=e.namespaceURI,this.currentLocalName=e.localName;let o=this.code.nsPrefix[this.currentNamespace];o?this.currentNSTag=o+this.currentLocalName:this.currentNSTag="",this.currentId=e.getAttribute("id"),this.currentXmlId=e.getAttributeNS("http://www.w3.org/XML/1998/namespace","id");let i=e.getAttribute("class");i?this.currentClassNames=i.split(/\s+/):this.currentClassNames=zc;let a=e.getAttributeNS("http://www.idpf.org/2007/ops","type");a?this.currentEpubTypes=a.split(/\s+/):this.currentEpubTypes=zc;let l=Ro(e);l&&(this.stack[this.stack.length-1].push(new gu(this.lang)),this.lang=l.toLowerCase());let c=this.isRoot,u=this.siblingOrderStack;this.currentSiblingOrder=++u[u.length-1],u.push(0);let p=this.siblingTypeCountsStack,h=this.currentSiblingTypeCounts=p[p.length-1],f=h[this.currentNamespace];f||(f=h[this.currentNamespace]={}),f[this.currentLocalName]=(f[this.currentLocalName]||0)+1,p.push({});let g=this.followingSiblingOrderStack;g[g.length-1]!==null?this.currentFollowingSiblingOrder=--g[g.length-1]:this.currentFollowingSiblingOrder=null,g.push(null);let m=this.followingSiblingTypeCountsStack,E=this.currentFollowingSiblingTypeCounts=m[m.length-1];E&&E[this.currentNamespace]&&E[this.currentNamespace][this.currentLocalName]--,m.push({}),this.applyActions(),this.applyVarFilter([this.currentStyle],t,e),this.applyCalcFilter(this.currentStyle,this.context),this.applyAttrFilter(e);let C=n.quotes,b=null;if(C){let A=C.evaluate(this.context);A&&(b=new mu(this.quotes),A===x.none?this.quotes=[new ce(""),new ce("")]:A===x.auto||A===x.initial?this.quotes=[new ce("\u201C"),new ce("\u201D"),new ce("\u2018"),new ce("\u2019")]:A instanceof q&&(this.quotes=A.values))}this.pushCounters(this.currentStyle);let y=this.currentId||this.currentXmlId||e.getAttribute("name")||"";if(c||y){let A={};Object.keys(this.counters).forEach(V=>{A[V]=Array.from(this.counters[V])}),this.counterListener.countersOfId(y,A)}let N=Nt(this.currentStyle,"_pseudos");if(N){let A=!0;for(let V of rC){V||(A=!1);let _=N[V];_&&((V==="before"||V==="after")&&!St((S=_.content)==null?void 0:S.value)||(V==="footnote-call"||V==="footnote-marker")&&((w=de(this.currentStyle,"float"))==null?void 0:w.value)!==x.footnote?delete N[V]:A?this.processPseudoelementProps(_,e):this.stack[this.stack.length-2].push(new fu(_,e)))}}this.setNamedStrings(this.currentStyle),this.setRunningElement(this.currentStyle),b&&this.stack[this.stack.length-2].push(b)}applyAttrFilterInner(t,e){for(let n in e)xs(n)&&!bt(n)&&(e[n]=e[n].filterValue(t))}applyAttrFilter(t){let e=new Cu(t),n=this.currentStyle,s=Nt(n,"_pseudos");for(let o in s)this.applyAttrFilterInner(e,s[o]);this.applyAttrFilterInner(e,n)}applyVarFilter(t,e,n){var l,c,u;let s=t[0],o=new Tu(t,e,n),i=32,a={};for(let p in s)if(Xc(p)){let h=Nt(s,p);for(let f in h)this.applyVarFilter([h[f],...t],e,n)}else if(xs(p)){let h=de(s,p),f=h.value;for(let g=0;;g++){if(g>=i){f=O;break}let m=f.visit(o);if(o.error){f=O,o.error=!1;break}if(m===f)break;f=m}if(f!==h.value){let g=e.validatorSet,m=(l=g==null?void 0:g.shorthands[p])==null?void 0:l.clone();if(m)if(U(f)){for(let E of m.propList){let C=new M(f,h.priority),b=de(s,E);mn(a,E,Wc(this.context,b,C))}delete s[p]}else{let E=Zt(e.scope,new Oe(f.toString(),null),"");if(E&&(E.visit(m),!m.error)){for(let C of m.propList){let b=new M((u=(c=m.values[C])!=null?c:g.defaultValues[C])!=null?u:x.initial,h.priority),y=de(s,C);mn(a,C,Wc(this.context,y,b))}delete s[p]}}else s[p]=new M(f,h.priority)}if(a[p]){let g=de(s,p);g&&g.value!==O&&en(a,p,g,this.context)}}for(let p in a)s[p]=a[p]}applyCalcFilter(t,e){let n=new ra(e);for(let s in t)if(Xc(s)){let o=Nt(t,s);for(let i in o)this.applyCalcFilter(o[i],e)}else if(xs(s)&&!bt(s)){let o=de(t,s),i=o.value.visit(n);i!==o.value&&(t[s]=new M(i,o.priority))}}applyActions(){let t;for(t=0;t<this.currentClassNames.length;t++)this.applyAction(this.code.classes,this.currentClassNames[t]);for(t=0;t<this.currentEpubTypes.length;t++)this.applyAction(this.code.epubtypes,this.currentEpubTypes[t]);this.applyAction(this.code.ids,this.currentId),this.applyAction(this.code.tags,this.currentLocalName),this.currentLocalName!=""&&this.applyAction(this.code.tags,"*"),this.applyAction(this.code.nstags,this.currentNSTag),this.currentPageType!==null&&(this.applyAction(this.code.pagetypes,this.currentPageType),this.applyAction(this.code.pagetypes,"*")),this.stack.push([]);for(let e=1;e>=-1;--e){let n=this.stack[this.stack.length-e-2];for(t=0;t<n.length;)n[t].push(this,e)?n.splice(t,1):t++}this.isFirst=!0,this.isRoot=!1}pop(){for(let t=1;t>=-1;--t){let e=this.stack[this.stack.length-t-2],n=0;for(;n<e.length;)e[n].pop(this,t)?e.splice(n,1):n++}this.stack.pop(),this.isFirst=!1}popRule(){this.pop()}popElement(t){this.siblingOrderStack.pop(),this.siblingTypeCountsStack.pop(),this.followingSiblingOrderStack.pop(),this.followingSiblingTypeCountsStack.pop(),this.pop(),this.popCounters()}},zc=[],rC=["before","transclusion-before","footnote-call","footnote-marker","inner","first-letter","first-line","","transclusion-after","after"];var xu=null;function Zh(r){xu=r}var bn=class extends qt{constructor(e,n,s,o,i,a,l){super(e,n,l);this.condition=s;this.regionId=i;this.validatorSet=a;d(this,"chain",null);d(this,"specificity",0);d(this,"elementStyle",null);d(this,"conditionCount",0);d(this,"pseudoelement",null);d(this,"footnoteContent",!1);d(this,"cascade");d(this,"state");d(this,"viewConditionId",null);d(this,"insideSelectorRule");d(this,"invalid",!1);this.cascade=o?o.cascade:xu?xu.clone():new bu,this.state=0}insertNonPrimary(e){this.cascade.insertInTable(this.cascade.tags,"*",e)}processChain(e){let n=qh(this.chain,e);n!==e&&n.makePrimary(this.cascade)||this.insertNonPrimary(n)}isInsideSelectorRule(e){return this.state!=0?(this.reportAndSkip(e),!0):!1}tagSelector(e,n){!n&&!e||(n&&(this.specificity+=1),n&&e?this.chain.push(new Kc(e,n.toLowerCase())):n?this.chain.push(new ta(n.toLowerCase())):this.chain.push(new Zc(e)))}invalidSelector(e){I.warn(e),this.chain.push(new ze("")),this.setInvalid()}setInvalid(){this.invalid=!0;for(let e=this;e instanceof Ss;e=e.parent)e.parent.invalid=!0}classSelector(e){if(this.pseudoelement){this.invalidSelector(`::${this.pseudoelement} followed by .${e}`);return}this.specificity+=256,this.chain.push(new jc(e))}pseudoclassSelector(e,n){if(this.pseudoelement){this.invalidSelector(`::${this.pseudoelement} followed by :${e}`);return}switch(e.toLowerCase()){case"enabled":this.chain.push(new ou);break;case"disabled":this.chain.push(new iu);break;case"checked":this.chain.push(new ru);break;case"root":case"scope":this.chain.push(new tu);break;case"link":this.chain.push(new ta("a")),this.chain.push(new na("","href"));break;case"-adapt-href-epub-type":case"href-epub-type":if(n&&n.length>=1&&typeof n[0]=="string"){let s=n[0],o=new RegExp(`(^|\\s)${nn(s)}($|\\s)`),i=n[1];this.chain.push(new qc(o,i))}else this.chain.push(new ze(""));break;case"-adapt-footnote-content":case"footnote-content":this.footnoteContent=!0;break;case"visited":case"active":case"hover":case"focus":this.chain.push(new ze(""));break;case"lang":if(n&&n.length==1&&typeof n[0]=="string"){let s=n[0];this.chain.push(new eu(new RegExp(`^${nn(s.toLowerCase())}($|-)`)))}else this.chain.push(new ze(""));break;case"nth-child":case"nth-last-child":case"nth-of-type":case"nth-last-of-type":{let s=aC[e.toLowerCase()];n&&n.length==2?this.chain.push(new s(n[0],n[1])):this.chain.push(new ze(""));break}case"first-child":this.chain.push(new sa);break;case"last-child":this.chain.push(new ri(0,1));break;case"first-of-type":this.chain.push(new ii(0,1));break;case"last-of-type":this.chain.push(new ai(0,1));break;case"only-child":this.chain.push(new sa),this.chain.push(new ri(0,1));break;case"only-of-type":this.chain.push(new ii(0,1)),this.chain.push(new ai(0,1));break;case"empty":this.chain.push(new su);break;case"before":case"after":case"first-line":case"first-letter":this.pseudoelementSelector(e,n);return;default:this.invalidSelector(`Unknown pseudo-class :${e}`);return}this.specificity+=256}pseudoelementSelector(e,n){switch(e){case"before":case"after":case"first-line":case"first-letter":case"footnote-call":case"footnote-marker":case"inner":case"after-if-continues":if(!this.pseudoelement)this.pseudoelement=e;else{this.invalidSelector(`Double pseudo-element ::${this.pseudoelement}::${e}`);return}break;case"first-n-lines":if(n&&n.length==1&&typeof n[0]=="number"){let s=Math.round(n[0]);if(s>0&&s==n[0]){if(!this.pseudoelement)this.pseudoelement=`first-${s}-lines`;else{this.invalidSelector(`Double pseudo-element ::${this.pseudoelement}::${e}`);return}break}}this.chain.push(new ze(""));break;case"nth-fragment":n&&n.length==2?this.viewConditionId=`NFS_${n[0]}_${n[1]}`:this.chain.push(new ze(""));break;default:this.invalidSelector(`Unknown pseudo-element ::${e}`);return}this.specificity+=1}idSelector(e){this.specificity+=65536,this.chain.push(new Yc(e))}attributeSelector(e,n,s,o){this.specificity+=256,n=n.toLowerCase(),o=o||"";let i;switch(s){case 0:i=new na(e,n);break;case 39:i=new Qc(e,n,o);break;case 45:!o||o.match(/\s/)?i=new ze(""):i=new ys(e,n,new RegExp(`(^|\\s)${nn(o)}($|\\s)`));break;case 44:i=new ys(e,n,new RegExp(`^${nn(o)}($|-)`));break;case 43:o?i=new ys(e,n,new RegExp(`^${nn(o)}`)):i=new ze("");break;case 42:o?i=new ys(e,n,new RegExp(`${nn(o)}$`)):i=new ze("");break;case 46:o?i=new ys(e,n,new RegExp(nn(o))):i=new ze("");break;case 50:if(o=="supported")i=new Jc(e,n);else{this.invalidSelector(`Unsupported :: attr selector op: ${o}`);return}break;default:this.invalidSelector(`Unsupported attr selector: ${s}`);return}this.chain.push(i)}descendantSelector(){let e=`d${Jr++}`;this.processChain(new ho(new uu(e,this.viewConditionId,null))),this.chain=[new ze(e)],this.viewConditionId=null}childSelector(){let e=`c${Jr++}`;this.processChain(new ho(new du(e,this.viewConditionId,null))),this.chain=[new ze(e)],this.viewConditionId=null}adjacentSiblingSelector(){let e=`a${Jr++}`;this.processChain(new ho(new pu(e,this.viewConditionId,null))),this.chain=[new ze(e)],this.viewConditionId=null}followingSiblingSelector(){let e=`f${Jr++}`;this.processChain(new ho(new hu(e,this.viewConditionId,null))),this.chain=[new ze(e)],this.viewConditionId=null}nextSelector(){this.finishChain(),this.pseudoelement=null,this.footnoteContent=!1,this.specificity=0,this.chain=[]}startSelectorRule(){this.isInsideSelectorRule("E_CSS_UNEXPECTED_SELECTOR")||(this.state=1,this.elementStyle={},this.pseudoelement=null,this.specificity=0,this.footnoteContent=!1,this.chain=[],this.invalid=!1)}error(e,n){super.error(e,n),this.state==1&&(this.state=0),this.setInvalid()}startStylesheet(e){super.startStylesheet(e),this.state=0}startRuleBody(){this.finishChain(),super.startRuleBody(),this.state==1&&(this.state=0)}endRule(){super.endRule(),this.insideSelectorRule=0}finishChain(){this.chain&&(this.processChain(this.makeApplyRuleAction(this.specificity)),this.chain=null,this.pseudoelement=null,this.viewConditionId=null,this.footnoteContent=!1,this.specificity=0)}makeApplyRuleAction(e){let n=this.regionId;return this.footnoteContent&&(n?n="xxx-bogus-xxx":n="footnote"),new Es(this.elementStyle,e,this.pseudoelement,n,this.viewConditionId)}special(e,n){let s;this.condition?s=new oi(n,0,this.condition):s=new M(n,0),Yh(this.elementStyle,e).push(s)}property(e,n,s){this.validatorSet.validatePropertyAndHandleShorthand(e,n,s,this)}invalidPropertyValue(e,n){this.report(`E_INVALID_PROPERTY_VALUE ${e}: ${n.toString()}`)}unknownProperty(e,n){this.report(`E_INVALID_PROPERTY ${e}: ${n.toString()}`)}simpleProperty(e,n,s){e=="display"&&(n===x.oeb_page_head||n===x.oeb_page_foot)&&(this.simpleProperty("flow-options",new q([x.exclusive,x._static]),s),this.simpleProperty("flow-into",n,s),n=x.block),Xe("SIMPLE_PROPERTY").forEach(c=>{let p=c({name:e,value:n,important:s});e=p.name,n=p.value,s=p.important});let a=(s?this.getImportantSpecificity():this.getBaseSpecificity())+this.cascade.nextOrder(),l=this.condition?new oi(n,a,this.condition):new M(n,a);en(this.elementStyle,e,l)}finish(){return this.cascade}startFuncWithSelector(e){let n;switch(e){case"is":n=new Ss(this);break;case"not":n=new Eu(this);break;case"where":n=new Su(this);break;case"has":n=new Nu(this);break}n&&(n.startSelectorRule(),this.owner.pushHandler(n))}},aC={"nth-child":nu,"nth-of-type":ii,"nth-last-child":ri,"nth-last-of-type":ai},Jr=0,Ss=class r extends bn{constructor(e){super(e.scope,e.owner,e.condition,e,e.regionId,e.validatorSet,!1);this.parent=e;d(this,"parentChain");d(this,"chains",[]);d(this,"maxSpecificity",0);d(this,"selectorTexts",[]);this.parentChain=e.chain}nextSelector(){this.chain&&this.chains.push(this.chain),this.maxSpecificity=Math.max(this.maxSpecificity,this.specificity),this.chain=[],this.pseudoelement=null,this.viewConditionId=null,this.footnoteContent=!1,this.specificity=0}endFuncWithSelector(){this.chain&&this.chains.push(this.chain),this.chains.length>0?(this.maxSpecificity=Math.max(this.maxSpecificity,this.specificity),this.parentChain.push(this.relational()?new cu(this.selectorTexts):this.positive()?new li(this.chains):new lu(this.chains)),this.increasingSpecificity()&&(this.parent.specificity+=this.maxSpecificity)):this.parentChain.push(new ze("")),this.owner.popHandler()}startRuleBody(){this.reportAndSkip("E_CSS_UNEXPECTED_RULE_BODY")}error(e,n){super.error(e,n),this.chain=null,this.pseudoelement=null,this.viewConditionId=null,this.footnoteContent=!1,this.specificity=0;let s=!1;for(let o=this;o instanceof r;o=o.parent)if(o.forgiving()){s=!0;break}s||this.owner.popHandler()}pushSelectorText(e){this.chain&&this.relational()&&this.selectorTexts.push(e)}positive(){return!0}increasingSpecificity(){return!0}forgiving(){return!0}relational(){return!1}},Eu=class extends Ss{positive(){return!1}forgiving(){return!1}},Su=class extends Ss{increasingSpecificity(){return!1}},Nu=class extends Ss{relational(){return!0}},oa=class extends qt{constructor(t,e){super(t,e,!1)}property(t,e,n){if(this.scope.values[t])this.error(`E_CSS_NAME_REDEFINED ${t}`,this.getCurrentToken());else{let s=t.match(/height|^(top|bottom)$/)?"vh":"vw",o=new rt(this.scope,100,s);this.scope.defineName(t,e.toExpr(this.scope,o))}}},Ns=class extends qt{constructor(e,n,s,o,i,a){super(e,n,!1);this.condition=s;this.elementStyle=o;this.validatorSet=i;this.ruleType=a;d(this,"order");this.order=0}property(e,n,s){s?I.warn("E_IMPORTANT_NOT_ALLOWED"):this.validatorSet.validatePropertyAndHandleShorthand(e,n,s,this)}invalidPropertyValue(e,n){I.warn("E_INVALID_PROPERTY_VALUE",`${e}:`,n.toString())}unknownProperty(e,n){I.warn("E_INVALID_PROPERTY",`${e}:`,n.toString())}simpleProperty(e,n,s){let o=s?this.getImportantSpecificity():this.getBaseSpecificity();o+=this.order,this.order+=Ru;let i=this.condition?new oi(n,o,this.condition):new M(n,o);en(this.elementStyle,e,i)}},vu=class extends jo{constructor(e,n){super(e);this.validatorSet=n;d(this,"elementStyle",{});d(this,"order",0)}property(e,n,s){this.validatorSet.validatePropertyAndHandleShorthand(e,n,s,this)}invalidPropertyValue(e,n){I.warn("E_INVALID_PROPERTY_VALUE",`${e}:`,n.toString())}unknownProperty(e,n){I.warn("E_INVALID_PROPERTY",`${e}:`,n.toString())}simpleProperty(e,n,s){let o=s?kr:Pr;o+=this.order,this.order+=Ru;let i=new M(n,o);en(this.elementStyle,e,i)}};function Iu(r,t){let e=jh(r);e&&e.forEach(n=>{n.matcher.matches()&&t(n.styles)})}function ia(r,t,e){Iu(e,n=>{Co(r,n,t)})}function Qh(r,t,e,n){let s=new vu(r,t),o=new Oe(n,s);try{sh(o,s,e)}catch(i){I.warn(i,"Style attribute parse error:")}return s.elementStyle}function ua(r,t,e){let n=r["writing-mode"];if(n){let s=n.evaluate(t,"writing-mode");if(s&&s!==x.inherit&&s!==x.revert&&s!==x.unset)return s===x.vertical_rl}return e}function da(r,t,e){let n=r.direction;if(n){let s=n.evaluate(t,"direction");if(s&&s!==x.inherit&&s!==x.revert&&s!==x.unset)return s===x.rtl}return e}function pa(r,t,e,n,s){let o={};for(let i in r)xs(i)&&(o[i]=de(r,i));return ia(o,t,r),Vu(r,e,n,(i,a)=>{Co(o,a,t),ia(o,t,a)}),o}function Vu(r,t,e,n){let s=Nt(r,"_regions");if((t||e)&&s){if(e){let o=["footnote"];t?t=t.concat(o):t=o}for(let o of t){let i=s[o];i&&n(o,i)}}}function Co(r,t,e){for(let n in t)if(xs(n)){let s=de(t,n),o=r[n];r[n]=Wc(e,o,s)}}var ha=(r,t,e,n,s)=>{let o=e?n?Zm:Pu:n?Qm:ku;for(let i in r)if(r.hasOwnProperty(i)){let a=r[i];if(!a)continue;let l=o[i],c;if(l){let u=r[l];if(u&&u.priority>a.priority)continue;c=qm[l]?l:i}else c=i;t[c]=s(i,a)}},Tu=class extends jt{constructor(e,n,s){super();this.elementStyles=e;this.styler=n;this.element=s}getVarValue(e){var s,o,i,a,l;let n=(s=this.element)!=null?s:this.styler.root;if((o=this.elementStyles)!=null&&o.length){for(let c of this.elementStyles){let u=(i=c[e])==null?void 0:i.value;if(u)return u}this.element&&(n=this.element.parentElement)}for(;n;n=n.parentElement){let c=(l=(a=this.styler.getStyle(n,!1))==null?void 0:a[e])==null?void 0:l.value;if(c)return c}return null}visitFunc(e){if(e.name!=="var")return super.visitFunc(e);let n=e.values[0]instanceof Be&&e.values[0].name;if(!n||!bt(n))return this.error=!0,O;let s=this.getVarValue(n);return s||(e.values.length<2?(this.error=!0,O):e.values.length===2?e.values[1]:new ge(e.values.slice(1)))}},ra=class extends jt{constructor(e,n,s,o){super();this.context=e;this.resolveViewportUnit=n;this.percentRef=s;this.vertical=o}visitFunc(e){let n=super.visitFunc(e);if(e.name!=="calc")return n;let s=n.toString().replace(/^calc\b/,"-epubx-expr");if(/\d(%|em|ex|cap|ch|ic|lh|p?v[whbi]|p?vmin|p?vmax)\W|\Wvar\(\s*--/i.test(s))return n;let o=Zt(this.context.rootScope,new Oe(s,null),"");if(o instanceof F)try{let i=o.expr.evaluate(this.context);typeof i=="number"&&(n=new P(i,"px"))}catch(i){I.warn(i)}return n}visitNumeric(e){return this.resolveViewportUnit&&(kl(e.unit)||Vp(e.unit))?new P(e.num*this.context.queryUnitSize(e.unit,!1,this.vertical),"px"):typeof this.percentRef=="number"&&e.unit==="%"?new P(e.num*this.percentRef/100,"px"):e}};function ui(r,t,e,n,s){try{if(t instanceof F)return t.expr instanceof oe&&(t.expr.str.startsWith("named-string-")||t.expr.str.startsWith("running-element-"))?t:oh(r,t.expr,e);if(t instanceof P||t instanceof Pt||t instanceof q||t instanceof ge)return t.visit(new ra(r,!0,n,s))}catch(o){return I.warn(o),O}return t}var Jh={first:!1,forceEnd:!1,allowEnd:!1,last:!1};function ef(r){let t=r instanceof Se?r:typeof r=="string"?L(r):x.none;if(t===x.none)return Jh;let e=t instanceof q?t.values:[t],n=Object.create(Jh);for(let s of e)if(s instanceof Be)switch(s.name){case"first":n.first=!0;break;case"force-end":n.forceEnd=!0,n.allowEnd=!1;break;case"allow-end":n.forceEnd=!1,n.allowEnd=!0;break;case"last":n.last=!0;break}return n}function tf(r){return!r.first&&!r.last&&!r.forceEnd&&!r.allowEnd}var lC={trimStart:!1,spaceFirst:!1,trimEnd:!1,allowEnd:!1,trimAdjacent:!1},nf={trimStart:!1,spaceFirst:!1,trimEnd:!1,allowEnd:!0,trimAdjacent:!0},sf={trimStart:!0,spaceFirst:!1,trimEnd:!0,allowEnd:!1,trimAdjacent:!0};function of(r){let t=r instanceof Se?r:typeof r=="string"?L(r):x.normal;if(t===x.normal)return nf;if(t===x.auto)return sf;let e=t instanceof q?t.values:[t],n=Object.create(nf);for(let s of e)if(s instanceof Be)switch(s.name){case"trim-both":case"trim-auto":return sf;case"space-all":return lC;case"trim-start":n.trimStart=!0,n.spaceFirst=!1;break;case"space-start":n.trimStart=!1,n.spaceFirst=!1;break;case"space-first":n.trimStart=!1,n.spaceFirst=!0;break;case"trim-end":n.trimEnd=!0,n.allowEnd=!1;break;case"space-end":n.trimEnd=!1,n.allowEnd=!1;break;case"allow-end":n.trimEnd=!1,n.allowEnd=!0;break;case"trim-adjacent":n.trimAdjacent=!0;break;case"space-adjacent":n.trimAdjacent=!1;break}return n}var Fu={ideographAlpha:!1,ideographNumeric:!1},cC={ideographAlpha:!0,ideographNumeric:!0};function rf(r){let t=r instanceof Se?r:typeof r=="string"?L(r):x.normal;if(t===x.normal||t===x.auto)return cC;if(t===x.none)return Fu;let e=t instanceof q?t.values:[t],n=Object.create(Fu);for(let s of e)if(s instanceof Be)switch(s.name){case"no-autospace":return Fu;case"ideograph-alpha":n.ideographAlpha=!0;break;case"ideograph-numeric":n.ideographNumeric=!0;break}return n}function af(r,t){return!r.ideographAlpha&&!r.ideographNumeric&&!t.trimStart&&!t.spaceFirst&&!t.trimEnd&&!t.allowEnd&&!t.trimAdjacent}function lf(r){return r?(r=r.toLowerCase(),/^zh\b.*-(hant|tw|hk)\b/.test(r)?"zh-hant":/^zh\b/.test(r)?"zh-hans":/^ja\b/.test(r)?"ja":/^ko\b/.test(r)?"ko":r):null}var Bu=class{getPolyfilledInheritedProps(){return["hanging-punctuation","text-autospace","text-spacing-trim"]}preprocessSingleDocument(t){t.body&&this.preprocessForTextSpacing(t.body)}preprocessForTextSpacing(t){var n;let e=t.ownerDocument.createNodeIterator(t,NodeFilter.SHOW_TEXT);for(let s=e.nextNode();s;s=e.nextNode()){if(s.parentElement.namespaceURI!=="http://www.w3.org/1999/xhtml"||((n=s.parentElement.dataset)==null?void 0:n.mathTypeset)==="true")continue;let o=s.textContent.replace(/(?![()\[\]{}])[\p{Ps}\p{Pe}\p{Pf}\p{Pi}、。,.:;、。\u3000]\p{M}*(?=\P{M})|.(?=(?![()\[\]{}])[\p{Ps}\p{Pe}\p{Pf}\p{Pi}、。,.:;、。\u3000])|(?!\p{P})[\p{sc=Han}\u3041-\u30FF\u31C0-\u31FF]\p{M}*(?=(?![\p{sc=Han}\u3041-\u30FF\u31C0-\u31FF\uFF01-\uFF60])[\p{L}\p{Nd}])|(?![\p{sc=Han}\u3041-\u30FF\u31C0-\u31FF\uFF01-\uFF60])[\p{L}\p{Nd}]\p{M}*(?=(?!\p{P})[\p{sc=Han}\u3041-\u30FF\u31C0-\u31FF])/gsu,"$&\0").split("\0");if(o.length>1){let i=o.length-1;for(let a=0;a<i;a++)s.parentNode.insertBefore(document.createTextNode(o[a]),s);s.textContent=o[i]}}}processGeneratedContent(t,e,n,s,o,i){o=lf(o);let a=rf(e),l=of(n),c=ef(s);if(tf(c)&&af(a,l))return;this.preprocessForTextSpacing(t);let u=t.style.whiteSpace;(i?t.offsetHeight:t.offsetWidth)===0&&(t.style.whiteSpace="pre");let p=t.ownerDocument.createNodeIterator(t,NodeFilter.SHOW_TEXT),h=null,f=null;for(let g=p.nextNode();g;g=f){f=p.nextNode();let m=!h,E=!h||/\n$/.test(h.textContent),C=!f||/^\n/.test(f.textContent),b=!f;this.processTextSpacing(g,m||E,m,E,C,b,h,f,a,l,c,o,i),h=g}t.style.whiteSpace=u}postLayoutBlock(t,e){var p,h,f,g,m,E,C;let n=!t||t.fragmentIndex===1&&i(),s=n||a();function o(b){var w;if((b==null?void 0:b.nodeType)!==1)return!1;let y=b;if(y.hasAttribute(Mt))return!0;let{position:N,float:S}=(w=y.style)!=null?w:{};return N==="absolute"||N==="fixed"||S&&S!=="none"}function i(){let b=e[0];for(let y=b;;y=y.parent)if(!y||!y.inline){if((y==null?void 0:y.fragmentIndex)!==1)return!1;break}if(!b.inline)return!0;for(let y=b.viewNode.previousSibling;y;y=y.previousSibling)if(!he(y,b.whitespace)&&!o(y))return!1;return!0}function a(){var N,S;let b=e[0],y;for(;b&&b.inline&&(y=(N=b.viewNode)==null?void 0:N.previousSibling,!(y&&(y.nodeType===3&&/^[ \t\r\n\f]*$/.test(y.textContent)&&b.whitespace!==Ze.PRESERVE&&(y=y.previousSibling),y)));)b=b.parent;for(;y;){if(y.nodeType===1){if(y.localName==="br")return!0;let w=(S=y.style)==null?void 0:S.display;if(w&&w!=="inline")return!/^(inline|ruby)\b/.test(w)}else if(y.nodeType===3){if(b.whitespace===Ze.PRESERVE){if(/\n$/.test(y.textContent))return!0}else if(b.whitespace===Ze.NEWLINE&&/\n[ \t\r\n\f]*$/.test(y.textContent))return!0}y=y.lastChild}return!1}let l=-1;for(let b=0;b<e.length;b++){let y=e[b];if(!y.after&&y.inline&&!y.display&&y.parent&&y.viewNode.parentNode&&y.viewNode.nodeType===Node.TEXT_NODE&&!he(y.viewNode,y.whitespace)){let R=function(B){var z,j,fe;if(((z=B.viewNode)==null?void 0:z.nodeType)===1)return B.viewNode.localName==="br";if(((j=B.viewNode)==null?void 0:j.nodeType)===3){if(B.whitespace===Ze.PRESERVE){if(/\n$/.test(B.viewNode.textContent))return!0}else if(B.whitespace===Ze.NEWLINE&&/\n[ \t\r\n\f]*$/.test(B.viewNode.textContent))return!0;if(((fe=B.viewNode.previousElementSibling)==null?void 0:fe.localName)==="br")return he(B.viewNode,B.whitespace)}return!1},G=function(B){var z,j,fe;if(((z=B.viewNode)==null?void 0:z.nodeType)===1)return B.viewNode.localName==="br";if(((j=B.viewNode)==null?void 0:j.nodeType)===3){if(B.whitespace===Ze.PRESERVE){if(/^\n/.test(B.viewNode.textContent))return!0}else if(B.whitespace===Ze.NEWLINE&&/^[ \t\r\n\f]*\n/.test(B.viewNode.textContent))return!0;if(((fe=B.viewNode.nextElementSibling)==null?void 0:fe.localName)==="br")return he(B.viewNode,B.whitespace)}return!1};var c=R,u=G;let N=lf((g=(h=(p=y.lang)!=null?p:y.parent.lang)!=null?h:t==null?void 0:t.lang)!=null?g:(f=t==null?void 0:t.parent)==null?void 0:f.lang),S=rf(y.inheritedProps["text-autospace"]),w=of(y.inheritedProps["text-spacing-trim"]),A=ef(y.inheritedProps["hanging-punctuation"]);if(tf(A)&&af(S,w)||/\b(flex|grid)\b/.test(y.parent.display))continue;l<0&&(l=b);let V=null,_=null,Ee=b===l,Q=b===l&&n,re=b===l&&s,Te=!1,Ge=!1;for(let B=b-1;B>=0;B--){let z=e[B];if(R(z)){re=!0;break}if(!z.display&&z.viewNode.nodeType===Node.TEXT_NODE&&z.viewNode.textContent.length>0){V=z.viewNode;break}if(z.display&&!/^(inline|ruby)\b/.test(z.display)||((m=z.viewNode)==null?void 0:m.nodeType)===1&&(z.viewNode.localName==="br"||$t[z.viewNode.localName]))break;B===0&&(Ee=!0,n&&(Q=!0,re=!0))}for(let B=b+1;B<e.length;B++){let z=e[B];if(G(z)){Te=!0;break}if(z.viewNode!==y.viewNode&&!z.display&&z.viewNode.nodeType===Node.TEXT_NODE&&z.viewNode.textContent.length>0){_=z.viewNode;break}if(z.display&&!/^(inline|ruby)\b/.test(z.display)||((E=z.viewNode)==null?void 0:E.nodeType)===1&&(z.viewNode.localName==="br"||$t[z.viewNode.localName])){B===e.length-1&&o(z.viewNode)&&(Ge=!0);break}if(B===e.length-1){Te=!0,Ge=!0;for(let j=z.viewNode.nextSibling;j;j=j.nextSibling)if(!o(j)){Ge=!1;break}}}if(((C=y.parent)==null?void 0:C.display)==="inline-block"){if(!Q){let B=y.parent.viewNode.firstChild;for(;he(B,y.whitespace);)B=B.nextSibling;y.viewNode===B&&(Q=!0)}if(!Ge){let B=y.parent.viewNode.lastChild;for(;he(B,y.whitespace);)B=B.previousSibling;y.viewNode===B&&(Ge=!0)}}this.processTextSpacing(y.viewNode,Ee,Q,re,Te,Ge,V,_,S,w,A,N,y.vertical)}}}processTextSpacing(t,e,n,s,o,i,a,l,c,u,p,h,f){let g=t.textContent,m=t.ownerDocument,E,C,b;function y(){if(e)return!0;if(!a)return!1;E||(E=m.createRange(),E.selectNode(t));let R=E.getClientRects()[0];C||(C=m.createRange(),C.selectNode(a));let G=C.getClientRects(),B=G[G.length-1];return!R||!B?!1:f?R.top<B.top+B.height-R.width||R.left+R.width<B.left+R.width/10||R.left>B.left+B.width-R.width/10:R.left<B.left+B.width-R.height||R.top>B.top+B.height-R.height/10||R.top+R.height<B.top+R.height/10}function N(){if(!l)return!1;E||(E=m.createRange(),E.selectNode(t));let R=E.getClientRects()[0];b||(b=m.createRange(),b.selectNode(l));let G=b.getClientRects()[0];return!R||!G?!1:f?R.top+R.height>G.top+R.width||R.left>G.left+G.width-R.width/10||R.left+R.width<G.left+R.width/10:R.left+R.width>G.left+R.height||R.top+R.height<G.top+R.height/10||R.top>G.top+G.height-R.height/10}let S=!1,w=!1,A=!1,V=!1,_;if(n&&p.first&&/^[\p{Ps}\p{Pf}\p{Pi}'"\u3000]\p{M}*$/u.test(g)?(_="viv-ts-open",S=!0,w=!0):i&&p.last&&/^[\p{Pe}\p{Pf}\p{Pi}'"]\p{M}*$/u.test(g)?(_="viv-ts-close",S=!0,A=!0):(p.forceEnd||p.allowEnd)&&/^[、。,.、。]\p{M}*$/u.test(g)?(_="viv-ts-close",S=!0,V=!0):(u.trimStart||u.spaceFirst||u.trimAdjacent)&&/^[‘“〝([{⦅〈〈《「『【〔〖〘〚]\p{M}*$/u.test(g)?(_="viv-ts-open",S=!0):(u.trimEnd||u.allowEnd||u.trimAdjacent)&&(/^[’”〞〟)]}⦆〉〉》」』】〕〗〙〛]\p{M}*$/u.test(g)||h==="zh-hans"&&/^[:;]\p{M}*$/u.test(g)||h!=="zh-hant"&&/^[、。,.]\p{M}*$/u.test(g))&&(_="viv-ts-close",S=!0),S){let B=function(fe){let To=parseFloat(m.defaultView.getComputedStyle(fe).fontSize)*.7;return(f?fe.offsetHeight:fe.offsetWidth)>To},j=function(){return f?R.offsetLeft:R.offsetTop};var Te=B,Ge=j;if(t.parentElement.localName==="viv-ts-inner")return;let R=m.createElement(_),G=m.createElement("viv-ts-inner");R.appendChild(G),t.parentNode.insertBefore(R,t),G.appendChild(t);let z=B(G);if(z||w||A||V){if(_==="viv-ts-open"){if(w)R.className="viv-hang-first";else if(n||s)u.trimStart?R.className="viv-ts-trim":R.className="viv-ts-space";else if(!(u.trimStart||u.spaceFirst)&&y())R.className="viv-ts-space";else if(u.trimAdjacent&&a&&/[\p{Ps}\p{Pi}\p{Pe}\p{Pf}\u00B7\u2027\u30FB\u3000:;、。,.]\p{M}*$/u.test(a.textContent)&&(!/[\p{Pe}\p{Pf}]\p{M}*$/u.test(a.textContent)||a.parentElement.localName==="viv-ts-inner"&&B(a.parentElement)))R.className="viv-ts-trim";else if((u.trimStart||u.spaceFirst)&&y()){let fe=j();R.className="viv-ts-auto",fe===j()&&!y()&&(R.className="viv-ts-trim")}}else if(_==="viv-ts-close"){if(A)R.className=z?"viv-hang-last":"viv-hang-last viv-hang-hw";else if(i||o){let fe=j();V?(R.className=z?p.allowEnd&&u.allowEnd?"viv-ts-auto":"viv-hang-end":"viv-hang-end viv-hang-hw",p.allowEnd&&fe===j()&&(u.trimEnd?R.className="viv-ts-trim":u.allowEnd?(R.className="viv-hang-end",fe===j()&&(R.className="")):R.className="viv-ts-space")):u.trimEnd?R.className="viv-ts-trim":u.allowEnd?(R.className="viv-ts-auto",fe===j()&&(R.className="")):R.className="viv-ts-space"}else if(l&&/^[\p{Pe}\p{Pf}\u00B7\u2027\u30FB\u3000:;、。,.]/u.test(l.textContent))z&&u.trimAdjacent&&(R.className="viv-ts-trim");else if(V){let fe=N(),qn=fe&&p.allowEnd;qn||(R.className=z?"viv-hang-end":"viv-hang-end viv-hang-hw"),z?qn&&u.trimEnd?R.className="viv-ts-auto":!qn&&!N()?R.className="":!fe&&p.allowEnd&&(u.trimEnd?(R.className="viv-ts-auto",N()||(R.className="viv-hang-end")):(R.className="viv-ts-space",N()||(u.allowEnd?(R.className="viv-ts-auto",N()||(R.className="viv-hang-end")):R.className="viv-hang-end"))):!fe&&!N()&&(R.className="")}else if(u.trimEnd||u.allowEnd)if(N())u.allowEnd?R.className="viv-ts-space":R.className="viv-ts-auto";else{let fe=j();R.className="viv-ts-auto",fe===j()&&(R.className="")}}}}let Ee=!1;function Q(R){var B;let G=(B=R==null?void 0:R.ownerDocument.defaultView)==null?void 0:B.getComputedStyle(R);return!!G&&(G.textOrientation==="upright"||G.textCombineUpright==="all"||G["-webkit-text-combine"]==="horizontal")}function re(R,G){if(R.nodeType===1){let j=m.defaultView.getComputedStyle(R);if(parseFloat(j.marginInlineEnd)||parseFloat(j.borderInlineEndWidth)||parseFloat(j.paddingInlineEnd))return!0}let B=R.parentElement;if(B&&!B.contains(G))return re(B,G);if(G.nodeType===1){let j=m.defaultView.getComputedStyle(G);if(parseFloat(j.marginInlineStart)||parseFloat(j.borderInlineStartWidth)||parseFloat(j.paddingInlineStart))return!0}let z=G.parentElement;return z&&!z.contains(R)?re(R,z):!1}(c.ideographAlpha||c.ideographNumeric)&&(a&&/^(?!\p{P})[\p{sc=Han}\u3041-\u30FF\u31C0-\u31FF]/u.test(g)&&(c.ideographAlpha&&/(?![\p{sc=Han}\u3041-\u30FF\u31C0-\u31FF\uFF01-\uFF60])\p{L}\p{M}*$/u.test(a.textContent)||c.ideographNumeric&&/(?![\uFF01-\uFF60])\p{Nd}\p{M}*$/u.test(a.textContent))&&!(f&&Q(a.parentElement))&&!re(a,t)&&(t.parentNode.insertBefore(m.createElement("viv-ts-thin-sp"),t),Ee=!0),l&&/(?!\p{P})[\p{sc=Han}\u3041-\u30FF\u31C0-\u31FF]\p{M}*$/u.test(g)&&(c.ideographAlpha&&/^(?![\p{sc=Han}\u3041-\u30FF\u31C0-\u31FF\uFF01-\uFF60])\p{L}/u.test(l.textContent)||c.ideographNumeric&&/^(?![\uFF01-\uFF60])\p{Nd}/u.test(l.textContent))&&!(f&&Q(l.parentElement))&&!re(t,l)&&(t.parentNode.insertBefore(m.createElement("viv-ts-thin-sp"),t.nextSibling),Ee=!0))}registerHooks(){_e("POLYFILLED_INHERITED_PROPS",this.getPolyfilledInheritedProps.bind(this)),_e("PREPROCESS_SINGLE_DOCUMENT",this.preprocessSingleDocument.bind(this)),_e("POST_LAYOUT_BLOCK",this.postLayoutBlock.bind(this),!0)}},Ou=new Bu;Ou.registerHooks();function cf(r){Ou.preprocessForTextSpacing(r)}function uf(r,t,e,n,s,o){Ou.processGeneratedContent(r,t,e,n,s,o)}var bo=new DOMParser().parseFromString('<root xmlns="http://www.pyroxy.com/ns/shadow"/>',"text/xml"),pf=["footnote-marker","first-5-lines","first-4-lines","first-3-lines","first-2-lines","first-line","first-letter","before","","after"],fa="data-adapt-pseudo";function vs(r){return r.getAttribute(fa)||""}function pi(r,t){r.setAttribute(fa,t)}var di=class{constructor(t,e,n,s,o){this.element=t;this.style=e;this.styler=n;this.context=s;this.exprContentListener=o;d(this,"contentProcessed",{})}getStyle(t,e){let n=vs(t);this.styler&&n&&n.match(/after$/)&&(this.style=this.styler.getStyle(this.element,!0),this.styler=null);let o=Nt(this.style,"_pseudos")[n]||{};if(n.match(/^first-/)&&!o["x-first-pseudo"]){let i=1,a;n=="first-letter"?i=0:(a=n.match(/^first-([0-9]+)-lines$/))!=null&&(i=a[1]-0),o["x-first-pseudo"]=new M(new ct(i),0)}return o}processContent(t,e,n){let s=vs(t);if(!this.contentProcessed[s]){this.contentProcessed[s]=!0;let o=e.content;o&&St(o)&&(o.visit(new cn(t,this.context,o,this.exprContentListener)),cf(t))}}};var fy=Ko.isInstanceOfAfterIfContinuesLayoutConstraint,gf=zn.registerFragmentIndex,gy=zn.clearFragmentIndices,ga=class{constructor(t,e){this.sourceNode=t;this.styler=e}createElement(t,e){let s=e.viewNode.ownerDocument.createElement("div"),o=new ws(t,s,e),i=o.getColumn().pageBreakType;return o.getColumn().pageBreakType=null,o.layout(this.createNodePositionForPseudoElement(),!0).thenAsync(()=>{this.styler.contentProcessed["after-if-continues"]=!1,o.getColumn().pageBreakType=i;let a=s.firstChild;return T(a,"display","block"),v(a)})}createNodePositionForPseudoElement(){let t=bo.createElementNS("http://www.w3.org/1999/xhtml","div");pi(t,"after-if-continues");let e=this.createShadowContext(t),s={steps:[{node:t,shadowType:e.type,shadowContext:e,nodeShadow:null,shadowSibling:null}],offsetInNode:0,after:!1,preprocessedTextContent:null};return new pt(s)}createShadowContext(t){return new fs(this.sourceNode,t,null,null,null,At.ShadowType.ROOTED,this.styler)}},Du=class r{constructor(t,e,n){this.nodeContext=t;this.afterIfContinues=e;this.pseudoElementHeight=n;d(this,"flagmentLayoutConstraintType","AfterIfContinue")}allowLayout(t,e,n){return!(e&&!t||t&&t.overflow)}nextCandidate(t){return!1}postLayout(t,e,n,s){}finishBreak(t,e){return this.getRepetitiveElements().affectTo(t)?this.afterIfContinues.createElement(e,this.nodeContext).thenAsync(n=>(this.nodeContext.viewNode.appendChild(n),v(!0))):v(!0)}getRepetitiveElements(){return new Mu(this.nodeContext,this.pseudoElementHeight)}equalsTo(t){return t instanceof r?this.afterIfContinues==t.afterIfContinues:!1}getPriorityOfFinishBreak(){return 9}},Mu=class{constructor(t,e){this.nodeContext=t;this.pseudoElementHeight=e}calculateOffset(t){return this.affectTo(t)?this.pseudoElementHeight:0}calculateMinimumOffset(t){return this.calculateOffset(t)}affectTo(t){if(!t)return!1;let e=t.shadowContext?t.shadowContext.owner:t.sourceNode;if(e===this.nodeContext.sourceNode)return!!t.after;for(let n=e.parentNode;n;n=n.parentNode)if(n===this.nodeContext.sourceNode)return!0;return!1}};function mf(r,t){if(!r||!r.afterIfContinues||r.after||t.isFloatNodeContext(r))return v(r);let e=r.afterIfContinues;return e.createElement(t,r).thenAsync(n=>{let s=dC(r,t,n);return t.fragmentLayoutConstraints.push(new Du(r,e,s)),v(r)})}function zu(r,t){return r.thenAsync(e=>mf(e,t))}function uC(r,t){let e=k("processAfterIfContinuesOfAncestors"),n=r;return e.loop(()=>{if(n!==null){let s=mf(n,t);return n=n.parent,s.thenReturn(!0)}else return v(!1)}).then(()=>{e.finish(!0)}),e.result()}function dC(r,t,e){let n=r.viewNode;n.appendChild(e);let s=ti(e,t,r.vertical);return n.removeChild(e),s}var ma=class{constructor(t){this.constraints=t}allowLayout(t){return this.constraints.every(e=>e.allowLayout(t))}},hi=class extends ms{constructor(e,n){super();this.checkPoints=e;this.penalty=n;d(this,"alreadyEvaluated",!1);d(this,"breakNodeContext",null)}findAcceptableBreak(e,n){return n<this.getMinBreakPenalty()?null:(this.alreadyEvaluated||(this.breakNodeContext=e.findBoxBreakPosition(this,n>0),this.alreadyEvaluated=!!this.breakNodeContext||n>0||!!e.pseudoParent),this.breakNodeContext)}getMinBreakPenalty(){return this.penalty}getNodeContext(){return this.alreadyEvaluated?this.breakNodeContext:this.checkPoints[this.checkPoints.length-1]}};var Ts=class extends ro{constructor(e,n,s,o,i){super(e);this.layoutContext=n;this.clientLayout=s;this.layoutConstraint=o;this.pageFloatLayoutContext=i;d(this,"last");d(this,"viewDocument");d(this,"flowRootFormattingContext",null);d(this,"isFloat",!1);d(this,"isFootnote",!1);d(this,"startEdge",0);d(this,"endEdge",0);d(this,"beforeEdge",0);d(this,"afterEdge",0);d(this,"footnoteEdge",0);d(this,"box",null);d(this,"chunkPositions",null);d(this,"bands",null);d(this,"overflown",!1);d(this,"breakPositions",null);d(this,"pageBreakType",null);d(this,"forceNonfitting",!0);d(this,"leftFloatEdge",0);d(this,"rightFloatEdge",0);d(this,"bottommostFloatTop",0);d(this,"stopAtOverflow",!0);d(this,"lastAfterPosition",null);d(this,"fragmentLayoutConstraints",[]);d(this,"pseudoParent",null);d(this,"nodeContextOverflowingDueToRepetitiveElements",null);d(this,"blockDistanceToBlockEndFloats",NaN);d(this,"breakAtTheEdgeBeforeFloat",null);this.last=e.lastChild,this.viewDocument=e.ownerDocument,i.setContainer(this)}getTopEdge(){return this.vertical?this.rtl?this.endEdge:this.startEdge:this.beforeEdge}getBottomEdge(){return this.vertical?this.rtl?this.startEdge:this.endEdge:this.afterEdge}getLeftEdge(){return this.vertical?this.afterEdge:this.rtl?this.endEdge:this.startEdge}getRightEdge(){return this.vertical?this.beforeEdge:this.rtl?this.startEdge:this.endEdge}isFloatNodeContext(e){return!!e.floatSide&&(!this.isFloat||!!e.parent)}stopByOverflow(e){return this.stopAtOverflow&&!!e&&e.overflow}isOverflown(e){return this.vertical?e<this.footnoteEdge:e>this.footnoteEdge}getExclusions(){let e=this.pageFloatLayoutContext.getFloatFragmentExclusions();return this.exclusions.concat(e)}openAllViews(e){let n=k("openAllViews"),s=e.steps;this.layoutContext.setViewRoot(this.element,this.isFootnote);let o=s.length-1,i=null;return n.loop(()=>{for(;o>=0;){let a=i,l=s[o];if(i=ao(l,a),o===s.length-1&&!i.formattingContext&&(i.formattingContext=this.flowRootFormattingContext),o==0&&(i.offsetInNode=this.calculateOffsetInNodeForNodeContext(e),i.after=e.after,i.preprocessedTextContent=e.preprocessedTextContent,i.after))break;let c=this.layoutContext.setCurrent(i,o==0&&i.offsetInNode==0);if(o--,c.isPending())return c}return v(!1)}).then(()=>{n.finish(i)}),n.result()}calculateOffsetInNodeForNodeContext(e){return e.preprocessedTextContent?Eh(e.preprocessedTextContent,e.offsetInNode):e.offsetInNode}maybePeelOff(e,n){var s,o;if(e.firstPseudo&&e.inline&&!e.after&&e.firstPseudo.count==0&&e.viewNode.nodeType!=1){let i=e.viewNode.textContent,a=i.match(Lo),l=a?a[0].length:0;if(!a&&((s=e.sourceNode)==null?void 0:s.nodeType)===3&&((o=e.sourceNode.nextSibling)==null?void 0:o.nodeType)===3&&i===e.sourceNode.textContent){let c=i+e.sourceNode.nextSibling.textContent,u=c.match(Lo);if(u){let p=u[0];l=p.length,e.sourceNode.textContent=p,e.viewNode.textContent=p,e.sourceNode.nextSibling.textContent=c.substr(l)}}return this.layoutContext.peelOff(e,l)}return v(e)}buildViewToNextBlockEdge(e,n){let s=!1,o=k("buildViewToNextBlockEdge");return o.loopWithFrame(i=>{var a;e.viewNode&&!hn(e)&&((a=e.viewNode.parentElement)==null?void 0:a.namespaceURI)==="http://www.w3.org/1999/xhtml"&&n.push(e.copy()),this.maybePeelOff(e,0).then(l=>{let c=l;c!==e&&(e=c,hn(e)||n.push(e.copy())),this.nextInTree(e).then(u=>{if(e=u,!e){i.breakLoop();return}(s||!this.layoutConstraint.allowLayout(e))&&(s=!0,e=e.modify(),e.overflow=!0),this.isFloatNodeContext(e)&&(Dn(e.floatReference)||e.floatSide==="footnote")?this.layoutFloatOrFootnote(e).then(p=>{if(e=p,this.pageFloatLayoutContext.isInvalidated()&&(e=null),!e){i.breakLoop();return}i.continueLoop()}):e.inline?i.continueLoop():i.breakLoop()})})}).then(()=>{o.finish(e)}),o.result()}nextInTree(e,n){let s=this.layoutContext.nextInTree(e,n);return zu(s,this)}buildDeepElementView(e){if(!e.viewNode)return v(e);let n=[],s=e.sourceNode,o=k("buildDeepElementView");return o.loopWithFrame(i=>{e.viewNode&&e.inline&&!hn(e)?n.push(e.copy()):(n.length>0&&this.postLayoutBlock(e,n),n=[]),this.maybePeelOff(e,0).then(a=>{let l=a;if(l!==e){let c=l;for(;c&&c.sourceNode!=s;)c=c.parent;if(c==null){e=l,i.breakLoop();return}hn(l)||n.push(l.copy())}this.nextInTree(l).then(c=>{e=c,!e||e.sourceNode==s?i.breakLoop():this.layoutConstraint.allowLayout(e)?i.continueLoop():(e=e.modify(),e.overflow=!0,this.stopAtOverflow?i.breakLoop():i.continueLoop())})})}).then(()=>{n.length>0&&this.postLayoutBlock(e,n),o.finish(e)}),o.result()}createFloat(e,n,s,o){let i=this.viewDocument.createElement("div");return this.vertical?(o>=this.height&&(o-=.1),o<1&&(o=0),T(i,"height",`${s}px`),T(i,"width",`${o}px`)):(s>=this.width&&(s-=.1),s<1&&(s=0),T(i,"width",`${s}px`),T(i,"height",`${o}px`)),T(i,"float",n),T(i,"clear",n),this.element.insertBefore(i,e),i}killFloats(){let e=this.element.firstChild;for(;e;){let n=e.nextSibling;if(e.nodeType==1){let s=e,o=s.style.cssFloat;if(o=="left"||o=="right"||o==="none")this.element.removeChild(s);else break}e=n}}createFloats(){let e=this.element.firstChild,n=this.bands,s=this.vertical?this.getTopEdge():this.getLeftEdge(),o=this.vertical?this.getBottomEdge():this.getRightEdge(),i=null;for(let a of n){let l=a.y2-a.y1;a.left=this.createFloat(e,"left",a.x1-s,l),a.right=this.createFloat(e,"right",o-a.x2,l),a.x1<o&&a.x2>s?i=a:i||T(a.right,"float","none")}if(i){let a=n[n.length-1],l=this.vertical?-this.getLeftEdge():this.getBottomEdge();i!==a&&a.y2>=l&&(this.footnoteEdge=this.vertical?-i.y2:i.y2)}}calculateEdge(e,n,s,o){let i;if(e&&pn(e.viewNode))return NaN;if(e&&e.after&&!e.inline&&(i=Mn(e,this.clientLayout,0,this.vertical),!isNaN(i)))return i;e=n[s];let a=o-e.boxOffset;for(;;){if(i=Mn(e,this.clientLayout,a,this.vertical),!isNaN(i))return i;if(a>0){a--;continue}if(s--,s<0)return this.beforeEdge;e=n[s],e.viewNode.nodeType!=1&&(a=e.viewNode.textContent.length)}}parseComputedLength(e){let n=e.match(/^(-?[0-9]*(\.[0-9]*)?)px$/);return n?this.clientLayout.adjustLengthValue(parseFloat(n[0])):0}getComputedMargin(e){let n=this.clientLayout.getElementComputedStyle(e),s=new Ys(0,0,0,0);return n&&(s.left=this.parseComputedLength(n.marginLeft),s.top=this.parseComputedLength(n.marginTop),s.right=this.parseComputedLength(n.marginRight),s.bottom=this.parseComputedLength(n.marginBottom)),s}getComputedPaddingBorder(e){let n=this.clientLayout.getElementComputedStyle(e),s=new Ys(0,0,0,0);return n&&(s.left=this.parseComputedLength(n.borderLeftWidth)+this.parseComputedLength(n.paddingLeft),s.top=this.parseComputedLength(n.borderTopWidth)+this.parseComputedLength(n.paddingTop),s.right=this.parseComputedLength(n.borderRightWidth)+this.parseComputedLength(n.paddingRight),s.bottom=this.parseComputedLength(n.borderBottomWidth)+this.parseComputedLength(n.paddingBottom)),s}getComputedInsets(e){let n=this.clientLayout.getElementComputedStyle(e),s=new Ys(0,0,0,0);if(n){if(n.boxSizing=="border-box")return this.getComputedMargin(e);s.left=this.parseComputedLength(n.marginLeft)+this.parseComputedLength(n.borderLeftWidth)+this.parseComputedLength(n.paddingLeft),s.top=this.parseComputedLength(n.marginTop)+this.parseComputedLength(n.borderTopWidth)+this.parseComputedLength(n.paddingTop),s.right=this.parseComputedLength(n.marginRight)+this.parseComputedLength(n.borderRightWidth)+this.parseComputedLength(n.paddingRight),s.bottom=this.parseComputedLength(n.marginBottom)+this.parseComputedLength(n.borderBottomWidth)+this.parseComputedLength(n.paddingBottom)}return s}setComputedInsets(e,n){let s=this.clientLayout.getElementComputedStyle(e);s&&(n.marginLeft=this.parseComputedLength(s.marginLeft),n.borderLeft=this.parseComputedLength(s.borderLeftWidth),n.paddingLeft=this.parseComputedLength(s.paddingLeft),n.marginTop=this.parseComputedLength(s.marginTop),n.borderTop=this.parseComputedLength(s.borderTopWidth),n.paddingTop=this.parseComputedLength(s.paddingTop),n.marginRight=this.parseComputedLength(s.marginRight),n.borderRight=this.parseComputedLength(s.borderRightWidth),n.paddingRight=this.parseComputedLength(s.paddingRight),n.marginBottom=this.parseComputedLength(s.marginBottom),n.borderBottom=this.parseComputedLength(s.borderBottomWidth),n.paddingBottom=this.parseComputedLength(s.paddingBottom))}setComputedWidthAndHeight(e,n){let s=this.clientLayout.getElementComputedStyle(e);s&&(n.width=this.parseComputedLength(s.width),n.height=this.parseComputedLength(s.height))}layoutUnbreakable(e){return this.buildDeepElementView(e)}layoutFloat(e){let n=k("layoutFloat"),s=e.viewNode,o=Ih(e.floatSide,e.vertical,e.direction);return T(s,"float","none"),T(s,"display","inline-block"),T(s,"vertical-align","top"),this.buildDeepElementView(e).then(i=>{let a=this.clientLayout.getElementClientRect(s),l=this.getComputedMargin(s),c=new He(a.left-l.left,a.top-l.top,a.right+l.right,a.bottom+l.bottom),u=this.rtl?this.endEdge:this.startEdge,p=this.rtl?this.startEdge:this.endEdge,h=e.parent;for(;h&&h.inline;)h=h.parent;if(h){let S=h.viewNode.ownerDocument.createElement("div");S.style.left="0px",S.style.top="0px",this.vertical?(S.style.bottom="0px",S.style.width="1px"):(S.style.right="0px",S.style.height="1px"),h.viewNode.appendChild(S);let w=this.clientLayout.getElementClientRect(S);u=Math.max(this.rtl?this.getEndEdge(w):this.getStartEdge(w),u),p=Math.min(this.rtl?this.getStartEdge(w):this.getEndEdge(w),p),h.viewNode.removeChild(S);let A=this.vertical?c.y2-c.y1:c.x2-c.x1;o=="left"?p=Math.max(p,u+A):u=Math.min(u,p-A),h!==e.parent&&!e.firstPseudo&&(h.viewNode.appendChild(s),s.setAttribute("data-vivliostyle-float-box-moved","true"))}let f=new He(u,this.getBoxDir()*this.beforeEdge,p,this.getBoxDir()*this.afterEdge),g=c;this.vertical&&(g=Ks(c));let m=this.getBoxDir();if(g.y1<this.bottommostFloatTop*m){let S=g.y2-g.y1;g.y1=this.bottommostFloatTop*m,g.y2=g.y1+S}Wp(f,this.bands,g,o),this.vertical&&(c=Cr(g));let E=this.getComputedInsets(s);T(s,"width",`${c.x2-c.x1-E.left-E.right}px`),T(s,"height",`${c.y2-c.y1-E.top-E.bottom}px`),T(s,"position","absolute"),e.display,T(s,"display",e.display);let C,b=null;if(h&&(h.containingBlockForAbsolute?b=h:b=h.getContainingBlockForAbsolute()),b){let S=b.viewNode.ownerDocument.createElement("div");S.style.position="absolute",b.vertical?S.style.right="0":S.style.left="0",S.style.top="0",b.viewNode.appendChild(S),C=this.clientLayout.getElementClientRect(S),b.viewNode.removeChild(S)}else C={left:this.getLeftEdge()-this.paddingLeft,right:this.getRightEdge()+this.paddingRight,top:this.getTopEdge()-this.paddingTop};(b?b.vertical:this.vertical)?T(s,"right",`${C.right-c.x2}px`):T(s,"left",`${c.x1-C.left}px`),T(s,"top",`${c.y1-C.top}px`),e.clearSpacer&&(e.clearSpacer.parentNode.removeChild(e.clearSpacer),e.clearSpacer=null);let y=this.vertical?c.x1:c.y2,N=this.vertical?c.x2:c.y1;!this.isOverflown(y)||this.breakPositions.length==0?(this.killFloats(),f=new He(this.getLeftEdge(),this.getTopEdge(),this.getRightEdge(),this.getBottomEdge()),this.vertical&&(f=Ks(f)),Xp(f,this.bands,g,null,o),this.createFloats(),o=="left"?this.leftFloatEdge=y:this.rightFloatEdge=y,this.bottommostFloatTop=N,this.updateMaxReachedAfterEdge(y),n.finish(i)):(e=e.modify(),e.overflow=!0,n.finish(e))}),n.result()}setupFloatArea(e,n,s,o,i,a){let l=this.pageFloatLayoutContext,c=l.getContainer(n),u=e.element;c.element.parentNode.appendChild(u),e.isFloat=!0,e.originX=c.originX,e.originY=c.originY,e.vertical=c.vertical,e.rtl=c.rtl,e.marginLeft=e.marginRight=e.marginTop=e.marginBottom=0,e.borderLeft=e.borderRight=e.borderTop=e.borderBottom=0,e.paddingLeft=e.paddingRight=e.paddingTop=e.paddingBottom=0,e.exclusions=(c.exclusions||[]).concat(),e.forceNonfitting=!l.hasFloatFragments(),e.innerShape=null;let p=c.getPaddingRect();e.setHorizontalPosition(p.x1-c.originX,p.x2-p.x1),e.setVerticalPosition(p.y1-c.originY,p.y2-p.y1),i.adjustPageFloatArea(e,c,this),e.init();let h=!!l.setFloatAreaDimensions(e,n,s,o,!0,!l.hasFloatFragments(),a);return h?(e.killFloats(),e.init()):c.element.parentNode.removeChild(u),h}createPageFloatArea(e,n,s,o,i){let a=this.element.ownerDocument.createElement("div");T(a,"position","absolute");let l=this.pageFloatLayoutContext.getPageFloatLayoutContext(e.floatReference),c=new un(null,ue.COLUMN,null,this.pageFloatLayoutContext.flowName,e.nodePosition,null,null),u=l.getContainer(),p=new Hu(n,a,this.layoutContext.clone(),this.clientLayout,this.layoutConstraint,c,u);return c.setContainer(p),this.setupFloatArea(p,e.floatReference,n,s,o,i)?p:null}layoutSinglePageFloatFragment(e,n,s,o,i,a,l){let c=this.pageFloatLayoutContext;e=(l?l.continuations:[]).concat(e);let p=e[0].float,h=c.getPageFloatPlacementCondition(p,n,s),f=this.createPageFloatArea(p,n,a,i,h),g={floatArea:f,pageFloatFragment:null,newPosition:null};if(!f)return v(g);let m=k("layoutSinglePageFloatFragment"),E=!1,C=0;return m.loopWithFrame(b=>{if(C>=e.length){b.breakLoop();return}let y=e[C],N=new pt(y.nodePosition);f.layout(N,!0).then(S=>{g.newPosition=S,!S||o?(C++,b.continueLoop()):(E=!0,b.breakLoop())})}).then(()=>{if(!E){let b=c.setFloatAreaDimensions(f,p.floatReference,n,a,!1,o,h);if(!b)E=!0;else{let y=i.createPageFloatFragment(e,b,f,!!g.newPosition);c.addPageFloatFragment(y,!0),g.pageFloatFragment=y}}m.finish(g)}),m.result()}layoutPageFloatInner(e,n,s,o){let i=this.pageFloatLayoutContext,a=e.float;i.stashEndFloatFragments(a);function l(u,p){p?i.removePageFloatFragment(p,!0):u&&u.element.parentNode.removeChild(u.element),i.restoreStashedFragments(a.floatReference),i.deferPageFloat(e)}let c=k("layoutPageFloatInner");return this.layoutSinglePageFloatFragment([e],a.floatSide,a.clearSide,!i.hasFloatFragments(),n,s,o).then(u=>{let p=u.floatArea,h=u.pageFloatFragment,f=u.newPosition;h?this.layoutStashedPageFloats(a.floatReference,[o]).then(g=>{if(g){if(i.addPageFloatFragment(h),i.discardStashedFragments(a.floatReference),f){let m=new Jo(a,f.primary);i.deferPageFloat(m)}c.finish(!0)}else l(p,h),c.finish(!1)}):(l(p,h),c.finish(!1))}),c.result()}layoutStashedPageFloats(e,n){let s=this.pageFloatLayoutContext,o=s.getStashedFloatFragments(e),i=[],a=[],l=!1,c=k("layoutStashedPageFloats"),u=0;return c.loopWithFrame(p=>{if(u>=o.length){p.breakLoop();return}let h=o[u];if(n.includes(h)){u++,p.continueLoop();return}let f=new _t().findByFloat(h.continuations[0].float);this.layoutSinglePageFloatFragment(h.continuations,h.floatSide,null,!1,f,null).then(g=>{let m=g.floatArea;m&&i.push(m);let E=g.pageFloatFragment;E?(a.push(E),u++,p.continueLoop()):(l=!0,p.breakLoop())})}).then(()=>{l?(a.forEach(p=>{s.removePageFloatFragment(p,!0)}),i.forEach(p=>{let h=p.element;h&&h.parentNode&&h.parentNode.removeChild(h)})):o.forEach(p=>{let h=p.area.element;h&&h.parentNode&&h.parentNode.removeChild(h)}),c.finish(!l)}),c.result()}setFloatAnchorViewNode(e){let n=e.viewNode.parentNode,s=n.ownerDocument.createElement("span");s.setAttribute(Mt,"1"),e.floatSide==="footnote"&&this.layoutContext.applyPseudoelementStyle(e,"footnote-call",s),n.appendChild(s),n.removeChild(e.viewNode);let o=e.modify();return o.after=!0,o.viewNode=s,o}resolveFloatReferenceFromColumnSpan(e,n,s){let o=k("resolveFloatReferenceFromColumnSpan"),i=this.pageFloatLayoutContext,a=i.getPageFloatLayoutContext(ue.REGION);return i.getContainer().width<a.getContainer().width&&e===ue.COLUMN?n===x.auto?this.buildDeepElementView(s.copy()).then(c=>{let u=c.viewNode,p=no(this.clientLayout,u,["min-content inline size"])["min-content inline size"],h=this.getComputedMargin(u);this.vertical?p+=h.top+h.bottom:p+=h.left+h.right,p>this.width?o.finish(ue.REGION):o.finish(e)}):n===x.all?o.finish(ue.REGION):o.finish(e):o.finish(e),o.result()}layoutPageFloat(e){let n=this.pageFloatLayoutContext,s=new _t().findByNodeContext(e),o,i=n.findPageFloatByNodePosition(e.toNodePosition());return i?o=v(i):o=s.createPageFloat(e,n,this),o.thenAsync(a=>{let l=gs(e,0),c=this.setFloatAnchorViewNode(e),u=s.findPageFloatFragment(a,n),p=new Jo(a,l);if(u&&u.hasFloat(a))return n.registerPageFloatAnchor(a,c.viewNode),v(c);if(n.isForbidden(a)||n.hasPrecedingFloatsDeferredToNext(a))return n.deferPageFloat(p),n.registerPageFloatAnchor(a,c.viewNode),v(c);if(this.nodeContextOverflowingDueToRepetitiveElements)return v(null);{let h=Mn(c,this.clientLayout,0,this.vertical);return this.isOverflown(h)?v(c):this.layoutPageFloatInner(p,s,h,u).thenAsync(f=>f?v(null):(n.registerPageFloatAnchor(a,c.viewNode),v(c)))}})}processLineStyling(e,n,s){let o=k("processLineStyling"),i=s.concat([]);s.splice(0,s.length);let a=0,l=e.firstPseudo;return l.count==0&&(l=l.outer),o.loopWithFrame(c=>{if(!l){c.breakLoop();return}let u=this.findLinePositions(i),p=l.count-a;if(u.length<=p){c.breakLoop();return}let h=this.findAcceptableBreakInside(i,u[p-1],!0);if(h==null){c.breakLoop();return}this.finishBreak(h,!1,!1).then(()=>{a+=p,this.layoutContext.peelOff(h,0).then(f=>{e=f,l=e.firstPseudo,i=[],this.buildViewToNextBlockEdge(e,i).then(g=>{n=g,c.continueLoop()})})})}).then(()=>{Array.prototype.push.apply(s,i),o.finish(n)}),o.result()}isLoneImage(e){return e.length!=2&&this.breakPositions.length>0?!1:e[0].sourceNode==e[1].sourceNode&&$t[e[0].sourceNode.localName]}getTrailingMarginEdgeAdjustment(e){let n=0,s=0;for(let o=e.length-1;o>=0;o--){let i=e[o];if(!i.after||!i.viewNode||i.viewNode.nodeType!=1)break;let a=this.getComputedMargin(i.viewNode),l=this.vertical?-a.left:a.bottom;l>0?n=Math.max(n,l):s=Math.min(s,l)}return n+s}layoutBreakableBlock(e){let n=k("layoutBreakableBlock"),s=[];return this.buildViewToNextBlockEdge(e,s).then(o=>{let i=s.length-1;if(i<0){n.finish(o);return}this.postLayoutBlock(o,s);let a=this.calculateEdge(o,s,i,s[i].boxOffset),l=!1;if(!o||!pn(o.viewNode)){let u=_n(o,this.collectElementsOffset());l=this.isOverflown(a+(this.vertical?-1:1)*u.minimum),this.isOverflown(a+(this.vertical?-1:1)*u.current)&&!this.nodeContextOverflowingDueToRepetitiveElements&&(this.nodeContextOverflowingDueToRepetitiveElements=o)}o==null&&(a+=this.getTrailingMarginEdgeAdjustment(s)),this.updateMaxReachedAfterEdge(a);let c;e.firstPseudo?c=this.processLineStyling(e,o,s):c=v(o),c.then(u=>{s.length>0&&(this.saveBoxBreakPosition(s),l&&!this.isLoneImage(s)&&u&&(u=u.modify(),u.overflow=!0)),n.finish(u)})}),n.result()}postLayoutBlock(e,n){Xe("POST_LAYOUT_BLOCK").forEach(o=>{o(e,n,this)})}findEndOfLine(e,n,s){let o=this.vertical?e-1:e+1,i=0,a=n[0].boxOffset,l=i,c=n.length-1,u=n[c].boxOffset,p;for(;a<u;){p=a+Math.ceil((u-a)/2),l=i;let h=c;for(;l<h;){let g=l+Math.ceil((h-l)/2);n[g].boxOffset>p?h=g-1:l=g}let f=this.calculateEdge(null,n,l,p);if(this.vertical?f<=o:f>=o){for(u=p-1;n[l].boxOffset==p;)l--;c=l}else s&&this.updateMaxReachedAfterEdge(f),a=p,i=l}return{nodeContext:n[l],index:a,checkPointIndex:l}}findAcceptableBreakInside(e,n,s){var l,c;let o=this.findEndOfLine(n,e,!0),i=o.nodeContext;if(o.checkPointIndex===0&&o.index===i.boxOffset)return null;let a=i.viewNode;if(a.nodeType!=1&&((l=a.parentElement)==null?void 0:l.localName)!=="viv-ts-inner"){let u=a;i=this.resolveTextNodeBreaker(i).breakTextNode(u,i,o.index,e,o.checkPointIndex,s)}else{let u=Fc(i);if(u){if(((c=this.breakPositions)==null?void 0:c[0])instanceof hi&&(u!=null&&u.viewNode.contains(this.breakPositions[0].checkPoints[0].viewNode)))return null;i=u}}return this.clearOverflownViewNodes(i,!1),i}resolveTextNodeBreaker(e){return Xe("RESOLVE_TEXT_NODE_BREAKER").reduce((s,o)=>o(e)||s,yo.instance)}getRangeBoxes(e,n){let s=[],o=e.ownerDocument.createRange(),i=!1,a=e,l=null,c=!1,u=!0;for(;u;){let p=!0;do{let h=null;a==n&&(n.nodeType===1?u=!(!n.firstChild||i):u=!1);let f=a.nodeType===1?a:null;f?i?i=!1:Kr(f)?p=!c:!f.firstChild||$t[f.localName]||/^r(uby|[bt]c?)$/.test(f.localName)||Dh(this.clientLayout.getElementComputedStyle(f).display)?(p=!c,p?(f.localName==="ruby"&&a.firstChild&&(a=a.firstChild),o.setStartBefore(a),c=!0,l=a):f.localName!=="ruby"&&(l=a),a.contains(n)&&(u=!1)):h=a.firstChild:(c||(a.parentNode==null?u=!1:(o.setStartBefore(a),c=!0)),l=a),h||(h=a.nextSibling,h||(i=!0,h=a.parentNode)),a=h}while(p&&u);if(c){o.setEndAfter(l);let h=this.clientLayout.getRangeClientRects(o);for(let f=0;f<h.length;f++)s.push(h[f]);c=!1}}return s}findLinePositions(e){let o=[],i=this.getRangeBoxes(e[0].viewNode,e[e.length-1].viewNode);i.sort(this.vertical?Ph:wh);let a=0,l=0,c=0,u=0,p=0,h=this.getBoxDir();for(;;){if(p<i.length){let f=i[p],g=1;if(u>0){let m=Math.max(this.getBoxSize(f),1);h*this.getBeforeEdge(f)<h*a?g=h*(this.getAfterEdge(f)-a)/m:h*this.getAfterEdge(f)>h*l?g=h*(l-this.getBeforeEdge(f))/m:g=1}if(u==0||g>=.6||g>=.2&&this.getStartEdge(f)>=c-1){c=this.getEndEdge(f),this.vertical?(a=u==0?f.right:Math.max(a,f.right),l=u==0?f.left:Math.min(l,f.left)):(a=u==0?f.top:Math.min(a,f.top),l=u==0?f.bottom:Math.max(l,f.bottom)),u++,p++;continue}}if(u>0&&(o.push(l),u=0),p>=i.length)break}return o.sort(ji),this.vertical&&o.reverse(),o}calculateClonedPaddingBorder(e){let n=0;for(let s=e;s;s=s.parent)if(!s.inline&&ps(s.viewNode)){let o=this.getComputedPaddingBorder(s.viewNode);n+=s.vertical?-o.left:o.bottom,s.display==="table"&&(n+=(s.vertical?-1:1)*s.blockBorderSpacing)}return n}getOffsetByRepetitiveElements(e){let n;return e?n=e.calculateOffset(this):n=_n(null,this.collectElementsOffset()),n.current}findBoxBreakPosition(e,n){let s=this.element.parentNode,o=this.element.nextSibling;s.removeChild(this.element),s.insertBefore(this.element,o);let i=e.checkPoints,a=i[0];for(;a.parent&&a.inline;)a=a.parent;let l,c;n?(l=1,c=1):(l=Math.max((a.inheritedProps.widows||2)-0,1),c=Math.max((a.inheritedProps.orphans||2)-0,1));let u=this.calculateClonedPaddingBorder(a),p=this.findLinePositions(i),h=this.footnoteEdge-u,f=this.getBoxDir(),g=this.getOffsetByRepetitiveElements(e);h-=f*g;let m=this.findFirstOverflowingEdgeAndCheckPoint(i);isNaN(m.edge)&&(m.edge=f*(1/0));let E=gt(p.length,N=>{let S=p[N];return this.vertical?S<h||S<=m.edge:S>h||S>=m.edge}),C=E<=0;C&&(E=gt(p.length,N=>this.vertical?p[N]<h:p[N]>h));let b=i[i.length-1].viewNode;if((b==null?void 0:b.parentElement.localName)==="viv-ts-inner"&&(b=b.parentElement.parentElement),(E===p.length&&b.nextSibling||E>=p.length-1&&b.parentElement.querySelector(".MJXc-display"))&&(l=0),E=Math.min(p.length-l,E),E<c)return null;h=p[E-1];let y;if(C?y=m.checkPoint:y=this.findAcceptableBreakInside(e.checkPoints,h,n),y){let N=this.getAfterEdgeOfBlockContainer(y);!isNaN(N)&&N<h&&(h=N),this.computedBlockSize=f*(h-this.beforeEdge)+g}return y}getAfterEdgeOfBlockContainer(e){let n=e;do n=n.parent;while(n&&n.inline);return n?(n=n.copy().modify(),n.after=!0,Mn(n,this.clientLayout,0,this.vertical)):NaN}findFirstOverflowingEdgeAndCheckPoint(e){let n=e.findIndex(o=>o.overflow);if(n<0)return{edge:NaN,checkPoint:null};let s=e[n];return{edge:this.calculateEdge(null,e,n,s.boxOffset),checkPoint:s}}findEdgeBreakPosition(e){return this.computedBlockSize=e.computedBlockSize+this.getOffsetByRepetitiveElements(e),e.position}finishBreak(e,n,s){e.formattingContext;let i=new Un().find(e.formattingContext).finishBreak(this,e,n,s);return i||(i=ni.finishBreak(this,e,n,s)),i}findAcceptableBreakPosition(){let e=null,n=null,s=0,o=0;do{s=o,o=Number.MAX_VALUE;for(let i=this.breakPositions.length-1;i>=0&&!n;--i){e=this.breakPositions[i],n=e.findAcceptableBreak(this,s);let a=e.getMinBreakPenalty();a>s&&(o=Math.min(o,a))}}while(o>s&&!n&&this.forceNonfitting);return{breakPosition:n?e:null,nodeContext:n}}doFinishBreak(e,n,s,o){if(this.pageFloatLayoutContext.isInvalidated()||this.pageBreakType||!n)return v(e);let i=k("doFinishBreak"),a=!1;if(!e){if(this.forceNonfitting)return I.warn("Could not find any page breaks?!!"),this.skipTailEdges(n).then(l=>{l?(l=l.modify(),l.overflow=!1,this.finishBreak(l,a,!0).then(()=>{i.finish(l)})):i.finish(l)}),i.result();e=s,a=!0,this.computedBlockSize=o}return this.finishBreak(e,a,!0).then(()=>{i.finish(e)}),i.result()}isBreakable(e){if(e.after)return!0;switch(e.sourceNode.namespaceURI){case"http://www.w3.org/2000/svg":return!1}return!e.flexContainer}zeroIndent(e){let n=e.toString();return n==""||n=="auto"||!!n.match(/^0+(.0*)?[^0-9]/)}checkOverflowAndSaveEdge(e,n){if(!e||pn(e.viewNode))return!1;let s=Mn(e,this.clientLayout,0,this.vertical),o=_n(e,this.collectElementsOffset()),i=this.isOverflown(s+(this.vertical?-1:1)*o.minimum);if(this.isOverflown(s+(this.vertical?-1:1)*o.current)&&!this.nodeContextOverflowingDueToRepetitiveElements)this.nodeContextOverflowingDueToRepetitiveElements=e;else if(n){let a=s+this.getTrailingMarginEdgeAdjustment(n),l=this.footnoteEdge-this.getBoxDir()*o.current;s=this.vertical?Math.min(s,Math.max(a,l)):Math.max(s,Math.min(a,l))}return this.updateMaxReachedAfterEdge(s),i}checkOverflowAndSaveEdgeAndBreakPosition(e,n,s,o){if(!e||pn(e.viewNode))return!1;let i=this.checkOverflowAndSaveEdge(e,n);return(s||!i)&&this.saveEdgeBreakPosition(e,o,i),i}applyClearance(e){if(!e.viewNode.parentNode)return!1;let n=this.getComputedMargin(e.viewNode),s=e.viewNode.ownerDocument.createElement("div");this.vertical?(s.style.bottom="0px",s.style.width="1px",s.style.marginRight=`${n.right}px`):(s.style.right="0px",s.style.height="1px",s.style.marginTop=`${n.top}px`),e.viewNode.parentNode.insertBefore(s,e.viewNode);let o=this.clientLayout.getElementClientRect(s),i=this.getBeforeEdge(o),a=this.getBoxDir(),l=e.clearSide,c=-this.getBoxDir()*(1/0);switch(l==="all"&&(c=this.pageFloatLayoutContext.getPageFloatClearEdge(l,this)),l){case"left":c=a*Math.max(c*a,this.leftFloatEdge*a);break;case"right":c=a*Math.max(c*a,this.rightFloatEdge*a);break;default:c=a*Math.max(c*a,Math.max(this.rightFloatEdge*a,this.leftFloatEdge*a))}if(i*a>=c*a)return e.viewNode.parentNode.removeChild(s),!1;{let u=Math.max(1,(c-i)*a);this.vertical?s.style.width=`${u}px`:s.style.height=`${u}px`,o=this.clientLayout.getElementClientRect(s);let p=this.getAfterEdge(o);if(!e.floatSide)if(this.vertical){let h=p+n.right-c;h>0==n.right>=0&&(h+=n.right),s.style.marginLeft=`${h}px`}else{let h=c-(p+n.top);h>0==n.top>=0&&(h+=n.top),s.style.marginBottom=`${h}px`}return e.clearSpacer=s,!0}}isBFC(e){return!!(Mh(e)||Qt.isInstanceOfRepetitiveElementsOwnerFormattingContext(e))}skipEdges(e,n,s){var E;let o=e.after?(E=e.parent)==null?void 0:E.formattingContext:e.formattingContext;if(o&&!this.isBFC(o))return v(e);let i=k("skipEdges"),a=!s&&n&&e&&e.after,l=s,c=null,u=[],p=[],h=!1;function f(){return!!s||!n&&De(l)&&!g()}function g(){var C;if(!c||e.floatSide)return!1;for(let b=c;b!=null&&b.parent;b=b.parent){let y=b.after?b.viewNode:(C=b.viewNode)==null?void 0:C.previousSibling;for(;y&&(he(y,b.parent.whitespace)||qr(y));)y=y.previousSibling;if(y)return!1}return!0}let m=()=>{e=u[0]||e,e.viewNode.parentNode.removeChild(e.viewNode),this.pageBreakType=l};return i.loopWithFrame(C=>{var b;for(;e;){e.formattingContext;let y=new Un().find(e.formattingContext);do{if(!e.viewNode)break;if(e.inline&&e.viewNode.nodeType!=1){if(he(e.viewNode,e.whitespace))break;if(!e.after){f()?m():this.checkOverflowAndSaveEdgeAndBreakPosition(c,null,!0,l)?(e=(this.stopAtOverflow&&c||e).modify(),e.overflow=!0):(e=e.modify(),e.breakBefore=l),C.breakLoop();return}}if(!e.after){if(e.floatSide&&(this.breakAtTheEdgeBeforeFloat=so(l)?l:null),y&&y.startNonInlineElementNode(e))break;if(e.clearSide&&this.applyClearance(e)&&n&&this.breakPositions.length===0&&this.saveEdgeBreakPosition(e.copy(),l,!1),!e.inline&&!e.repeatOnBreak&&(c?Fc(c):this.breakPositions[this.breakPositions.length-1]instanceof hi)&&this.saveEdgeBreakPosition(e.copy(),l,!1),!this.isBFC(e.formattingContext)||Qt.isInstanceOfRepetitiveElementsOwnerFormattingContext(e.formattingContext)||this.isFloatNodeContext(e)||e.flexContainer||!e.nodeShadow&&!e.sourceNode.firstElementChild&&he(e.sourceNode.firstChild,e.whitespace)){u.push(e.copy()),l=Ve(l,e.breakBefore),f()?m():(this.checkOverflowAndSaveEdgeAndBreakPosition(c,null,!0,l)||!this.layoutConstraint.allowLayout(e))&&(e=(this.stopAtOverflow&&c||e).modify(),e.overflow=!0),C.breakLoop();return}}if(e.viewNode.nodeType!=1)break;let S=e.viewNode.style;if(e.after){e.floatSide&&(l=l!=null?l:this.breakAtTheEdgeBeforeFloat,this.breakAtTheEdgeBeforeFloat=null);let w=e.sourceNode;if(w.localName==="svg"||w.localName==="math"||w.getAttribute("data-math-typeset")==="true"){h=!1,c=e.copy(),p.push(c),l=Ve(null,e.breakAfter),this.checkOverflowAndSaveEdgeAndBreakPosition(c,null,!this.stopAtOverflow,l);break}if(e.inline||y&&y.afterNonInlineElementNode(e,this.stopAtOverflow))break;if(h){if(f()){m(),C.breakLoop();return}u=[],n=!1,a=!1,l=null}h=!1,c=e.copy(),p.push(c),l=Ve(l,e.breakAfter),S&&!(this.zeroIndent(S.paddingBottom)&&this.zeroIndent(S.borderBottomWidth))&&(p=[c])}else{if(u.push(e.copy()),l=Ve(l,e.breakBefore),(e.pageType!=((b=e.parent)==null?void 0:b.pageType)||!De(l))&&!this.layoutConstraint.allowLayout(e)&&(this.checkOverflowAndSaveEdgeAndBreakPosition(c,null,!this.stopAtOverflow,l),e=e.modify(),e.overflow=!0,this.stopAtOverflow)){C.breakLoop();return}let w=e.viewNode.localName;if($t[w]){f()?m():this.checkOverflowAndSaveEdgeAndBreakPosition(c,null,!0,l)&&(e=(this.stopAtOverflow&&c||e).modify(),e.overflow=!0),C.breakLoop();return}S&&!(this.zeroIndent(S.paddingTop)&&this.zeroIndent(S.borderTopWidth))&&(a=!1,p=[]),h=!0}}while(!1);let N=this.nextInTree(e,a);if(N.isPending()){N.then(S=>{e=S,C.continueLoop()});return}else e=N.get()}this.checkOverflowAndSaveEdgeAndBreakPosition(c,p,!this.stopAtOverflow,l)?c&&this.stopAtOverflow&&(e=c.modify(),e.overflow=!0):De(l)&&(this.pageBreakType=l),C.breakLoop()}).then(()=>{c&&(this.lastAfterPosition=c.toNodePosition()),i.finish(e)}),i.result()}skipTailEdges(e){let n=e.copy(),s=k("skipEdges"),o=null,i=!1;return s.loopWithFrame(a=>{for(;e;){do{if(!e.viewNode)break;if(e.inline&&e.viewNode.nodeType!=1){if(he(e.viewNode,e.whitespace))break;if(!e.after){De(o)&&(this.pageBreakType=o),a.breakLoop();return}}if(!e.after&&(this.isFloatNodeContext(e)||e.flexContainer)){o=Ve(o,e.breakBefore),De(o)&&(this.pageBreakType=o),a.breakLoop();return}if(e.viewNode.nodeType!=1)break;let c=e.viewNode.style;if(e.after){if(i){if(De(o)){this.pageBreakType=o,a.breakLoop();return}o=null}i=!1,o=Ve(o,e.breakAfter)}else{o=Ve(o,e.breakBefore);let u=e.viewNode.localName;if($t[u]){De(o)&&(this.pageBreakType=o),a.breakLoop();return}if(c&&!(this.zeroIndent(c.paddingTop)&&this.zeroIndent(c.borderTopWidth))){a.breakLoop();return}}i=!0}while(!1);let l=this.layoutContext.nextInTree(e);if(l.isPending()){l.then(c=>{e=c,a.continueLoop()});return}else e=l.get()}n=null,a.breakLoop()}).then(()=>{s.finish(n)}),s.result()}layoutFloatOrFootnote(e){return Dn(e.floatReference)||e.floatSide==="footnote"?this.layoutPageFloat(e):this.layoutFloat(e)}layoutNext(e,n,s){let o=k("layoutNext");return this.skipEdges(e,n,s||null).then(i=>{if(e=i,!e||this.pageBreakType||this.stopByOverflow(e))o.finish(e);else{let a=e.formattingContext;new Un().find(a).layout(e,this,n).thenFinish(o)}}),o.result()}clearOverflownViewNodes(e,n){if(e)for(let s=e.parent;e;e=s,s=s?s.parent:null){let o=(s||e).formattingContext;new Un().find(o).clearOverflownViewNodes(this,s,e,n),n=!1}}initGeom(){let e=this.element.ownerDocument.createElement("div");e.style.position="absolute",e.style.top=`${this.paddingTop}px`,e.style.right=`${this.paddingRight}px`,e.style.bottom=`${this.paddingBottom}px`,e.style.left=`${this.paddingLeft}px`,this.element.appendChild(e);let n=this.clientLayout.getElementClientRect(e);this.element.removeChild(e);let s=this.originX+this.left+this.getInsetLeft(),o=this.originY+this.top+this.getInsetTop();this.box=new He(s,o,s+this.width,o+this.height),this.startEdge=n?this.vertical?this.rtl?n.bottom:n.top:this.rtl?n.right:n.left:0,this.endEdge=n?this.vertical?this.rtl?n.top:n.bottom:this.rtl?n.left:n.right:0,this.beforeEdge=n?this.vertical?n.right:n.top:0,this.afterEdge=n?this.vertical?n.left:n.bottom:0,this.leftFloatEdge=this.beforeEdge,this.rightFloatEdge=this.beforeEdge,this.bottommostFloatTop=this.beforeEdge,this.footnoteEdge=this.afterEdge,this.bands=_p(this.box,[this.getInnerShape()],this.getExclusions(),8,this.snapHeight,this.vertical),this.createFloats()}init(){this.chunkPositions=[],T(this.element,"width",`${this.width}px`),T(this.element,"height",`${this.height}px`),this.initGeom(),this.computedBlockSize=0,this.overflown=!1,this.pageBreakType=null,this.lastAfterPosition=null}saveEdgeBreakPosition(e,n,s){e.formattingContext;let o=e.copy(),i=new Un().find(e.formattingContext),a=this.calculateClonedPaddingBorder(o),l=i.createEdgeBreakPosition(o,n,s,this.computedBlockSize+a);this.breakPositions.push(l)}saveBoxBreakPosition(e){let n=e[0].breakPenalty;if(n){let o=e[0];for(;o.parent&&o.inline;)o=o.parent;n=o.breakPenalty}let s=new hi(e,n);this.breakPositions.push(s)}updateMaxReachedAfterEdge(e){if(!isNaN(e)){let n=this.getBoxDir()*(e-this.beforeEdge);this.computedBlockSize=Math.max(n,this.computedBlockSize)}}layout(e,n,s){if(this.chunkPositions.push(e),e.primary.after&&(this.lastAfterPosition=e.primary),this.stopAtOverflow&&this.overflown)return v(e);if(this.isFullWithPageFloats())return e.primary.after&&e.primary.steps.length===1?v(null):v(e);let o=k("layout");return this.openAllViews(e.primary).then(i=>{let a=null;if(i.viewNode)a=i.copy();else{let c=u=>{u.nodeContext.viewNode&&(a=u.nodeContext,this.layoutContext.removeEventListener("nextInTree",c))};this.layoutContext.addEventListener("nextInTree",c)}let l=new _u(n,s);l.layout(i,this).then(c=>{this.doFinishBreak(c,l.context.overflownNodeContext,a,l.initialComputedBlockSize).then(u=>{let p=null;this.pseudoParent?p=v(null):p=this.doFinishBreakOfFragmentLayoutConstraints(u),p.then(()=>{if(this.pageFloatLayoutContext.isInvalidated()){o.finish(null);return}if(!u)o.finish(null);else{this.overflown=!0;let h=new pt(u.toNodePosition());o.finish(h)}})})})}),o.result()}isFullWithPageFloats(){return this.pageFloatLayoutContext.isColumnFullWithPageFloats(this)}getMaxBlockSizeOfPageFloats(){return this.pageFloatLayoutContext.getMaxBlockSizeOfPageFloats()}doFinishBreakOfFragmentLayoutConstraints(e){let n=k("doFinishBreakOfFragmentLayoutConstraints"),s=[].concat(this.fragmentLayoutConstraints);s.sort((i,a)=>i.getPriorityOfFinishBreak()-a.getPriorityOfFinishBreak());let o=0;return n.loop(()=>o<s.length?s[o++].finishBreak(e,this).thenReturn(!0):v(!1)).then(()=>{n.finish(!0)}),n.result()}doLayout(e,n,s){let o=k("doLayout"),i=null;return this.breakPositions=[],this.nodeContextOverflowingDueToRepetitiveElements=null,o.loopWithFrame(a=>{for(;e;){let l=!0;if(this.layoutNext(e,n,s||null).then(c=>{if(n=!1,s=null,this.nodeContextOverflowingDueToRepetitiveElements&&this.stopAtOverflow?(this.pageBreakType=null,e=this.nodeContextOverflowingDueToRepetitiveElements,e.overflow=!0):e=c,this.pageFloatLayoutContext.isInvalidated())a.breakLoop();else if(this.pageBreakType)a.breakLoop();else if(e&&this.stopByOverflow(e)){i=e;let u=this.findAcceptableBreakPosition();e=u.nodeContext,u.breakPosition&&u.breakPosition.breakPositionChosen(this),a.breakLoop()}else l?l=!1:a.continueLoop()}),l){l=!1;return}}this.computedBlockSize+=this.getOffsetByRepetitiveElements(),a.breakLoop()}).then(()=>{o.finish({nodeContext:e,overflownNodeContext:i})}),o.result()}redoLayout(){let e=this.chunkPositions,n=this.element.lastChild;for(;n!=this.last;){let l=n.previousSibling;this.element===n.parentNode&&this.layoutContext.isPseudoelement(n)||this.element.removeChild(n),n=l}this.killFloats(),this.init();let s=k("redoLayout"),o=0,i=null,a=!0;return s.loopWithFrame(l=>{if(o<e.length){let c=e[o++];this.layout(c,a).then(u=>{a=!1,u?(i=u,l.breakLoop()):l.continueLoop()});return}l.breakLoop()}).then(()=>{s.finish(i)}),s.result()}saveDistanceToBlockEndFloats(){let e=this.pageFloatLayoutContext.getBlockStartEdgeOfBlockEndFloats();e>0&&isFinite(e)&&(this.blockDistanceToBlockEndFloats=this.getBoxDir()*(e-this.beforeEdge-this.computedBlockSize))}collectElementsOffset(){let e=[];for(let n=this;n;n=n.pseudoParent)n.fragmentLayoutConstraints.forEach(s=>{if(Qt.isInstanceOfRepetitiveElementsOwnerLayoutConstraint(s)){let o=s.getRepetitiveElements();e.push(o)}if(Ko.isInstanceOfAfterIfContinuesLayoutConstraint(s)){let o=s.getRepetitiveElements();e.push(o)}Ot.isInstanceOfTableRowLayoutConstraint(s)&&s.getElementsOffsetsForTableCell(this).forEach(o=>{e.push(o)})});return e}},ws=class{constructor(t,e,n){d(this,"startNodeContexts",[]);d(this,"column");this.column=Object.create(t),this.column.element=e,this.column.layoutContext=t.layoutContext.clone(),this.column.stopAtOverflow=!1,this.column.flowRootFormattingContext=n.formattingContext,this.column.pseudoParent=t;let s=this.column.calculateClonedPaddingBorder(n);this.column.footnoteEdge=this.column.footnoteEdge-s;let o=this;this.column.openAllViews=function(i){return Ts.prototype.openAllViews.call(this,i).thenAsync(a=>(o.startNodeContexts.push(a.copy()),v(a)))}}layout(t,e){return this.column.layout(t,e)}findAcceptableBreakPosition(t){let e=this.column.findAcceptableBreakPosition();if(t){let n=this.startNodeContexts[0].copy(),s=new fn(n,null,n.overflow,0);if(s.findAcceptableBreak(this.column,0),!e.nodeContext)return{breakPosition:s,nodeContext:n}}return e}finishBreak(t,e,n){return this.column.finishBreak(t,e,n)}doFinishBreakOfFragmentLayoutConstraints(t){this.column.doFinishBreakOfFragmentLayoutConstraints(t)}isStartNodeContext(t){let e=this.startNodeContexts[0];return e.viewNode===t.viewNode&&e.after===t.after&&e.offsetInNode===t.offsetInNode}isLastAfterNodeContext(t){return Dt(t.toNodePosition(),this.column.lastAfterPosition)}getColumnElement(){return this.column.element}getColumn(){return this.column}},yo=class{breakTextNode(t,e,n,s,o,i){if(e.after)e.offsetInNode=t.length;else{let a=n-e.boxOffset,l=t.data;l.charCodeAt(a)==173?a=this.breakAfterSoftHyphen(t,l,a,e):a=this.breakAfterOtherCharacter(t,l,a,e),a>0&&(e=this.updateNodeContext(e,a,t))}return e}breakAfterSoftHyphen(t,e,n,s){let i=/[\u0620\u0626\u0628\u062A-\u062E\u0633-\u0647\u0649\u064A\u066E\u066F\u0678-\u0687\u069A-\u06BF\u06C1\u06C2\u06CC\u06CE\u06D0\u06D1\u06FA-\u06FC\u06FF\u0712-\u0714\u071A-\u071D\u071F-\u0727\u0729\u072B\u072D\u072E\u074E-\u0758\u075C-\u076A\u076D-\u0770\u0772\u0775-\u0777\u077A-\u077F\u07CA-\u07EA\u07FA\u0841-\u0845\u0848\u084A-\u0853\u0855\u0860\u0862-\u0865\u0868\u0883-\u0886\u0889-\u088D\u08A0-\u08A9\u08AF\u08B0\u08B3-\u08B8\u08BA-\u08C8\u1807\u180A\u1820-\u1878\u1887-\u18A8\u18AA\u200D\uA840-\uA871\u{10AC0}-\u{10AC4}\u{10AD3}-\u{10AD6}\u{10AD8}-\u{10ADC}\u{10ADE}-\u{10AE0}\u{10AEB}-\u{10AEE}\u{10B80}\u{10B82}\u{10B86}-\u{10B88}\u{10B8A}\u{10B8B}\u{10B8D}\u{10B90}\u{10BAD}\u{10BAE}\u{10D01}-\u{10D21}\u{10D23}\u{10EC3}\u{10EC4}\u{10F30}-\u{10F32}\u{10F34}-\u{10F44}\u{10F51}-\u{10F53}\u{10F70}-\u{10F73}\u{10F76}-\u{10F81}\u{10FB0}\u{10FB2}\u{10FB3}\u{10FB8}\u{10FBB}\u{10FBC}\u{10FBE}\u{10FBF}\u{10FC1}\u{10FC4}\u{10FCA}\u{1E900}-\u{1E943}]\p{Mn}*$/u.test(e.slice(0,n))?"\u200D":"";if(t.replaceData(n,e.length-n,s.breakWord?"":i+ff(s)),i){let a=s.preprocessedTextContent[0][1];s.preprocessedTextContent[0][1]=a.slice(0,n+1)+i+a.slice(n+1)}return n+1}breakAfterOtherCharacter(t,e,n,s){let o=e.charAt(n);n++;let i=e.charAt(n);return t.replaceData(n,e.length-n,!s.breakWord&&El(o)&&El(i)?ff(s):""),n}updateNodeContext(t,e,n){return t=t.modify(),t.offsetInNode+=e,t.breakBefore=null,t}};d(yo,"instance");yo.instance=new yo;function ff(r){return r.hyphenateCharacter||r.parent&&r.parent.hyphenateCharacter||"-"}var _u=class extends Hn{constructor(e,n){super();this.leadingEdge=e;d(this,"breakAfter");d(this,"initialPageBreakType",null);d(this,"initialComputedBlockSize",0);d(this,"initialOverflown",!1);d(this,"context",{overflownNodeContext:null});this.breakAfter=n||null}resolveLayoutMode(e){return new Uu(this.leadingEdge,this.breakAfter,this.context)}prepareLayout(e,n){n.fragmentLayoutConstraints=[],n.pseudoParent||Uh()}clearNodes(e){super.clearNodes(e);let n=e;for(;n;){let s=n.viewNode;s&&Yr(s.parentNode,s),n=n.parent}}saveState(e,n){super.saveState(e,n),this.initialPageBreakType=n.pageBreakType,this.initialComputedBlockSize=n.computedBlockSize,this.initialOverflown=n.overflown}restoreState(e,n){super.restoreState(e,n),n.pageBreakType=this.initialPageBreakType,n.computedBlockSize=this.initialComputedBlockSize,n.overflown=this.initialOverflown}},Uu=class{constructor(t,e,n){this.leadingEdge=t;this.breakAfter=e;this.context=n}doLayout(t,e){let n=k("DefaultLayoutMode.doLayout");return uC(t,e).then(()=>{e.doLayout(t,this.leadingEdge,this.breakAfter).then(s=>{this.context.overflownNodeContext=s.overflownNodeContext,n.finish(s.nodeContext)})}),n.result()}accept(t,e){return e.pageFloatLayoutContext.isInvalidated()||e.pageBreakType||e.fragmentLayoutConstraints.length<=0?!0:e.fragmentLayoutConstraints.every(n=>n.allowLayout(t,this.context.overflownNodeContext,e))}postLayout(t,e,n,s){return s||(s=!n.fragmentLayoutConstraints.some(i=>i.nextCandidate(t))),n.fragmentLayoutConstraints.forEach(o=>{o.postLayout(s,t,e,n)}),s}},Hu=class extends Ts{constructor(e,n,s,o,i,a,l){super(n,s,o,i,a);this.floatSide=e;this.parentContainer=l;d(this,"rootViewNodes",[]);d(this,"floatMargins",[]);d(this,"adjustContentRelativeSize",!0)}openAllViews(e){return super.openAllViews(e).thenAsync(n=>(n&&this.fixFloatSizeAndPosition(n),v(n)))}convertPercentageSizesToPx(e){let n=this.parentContainer.getPaddingRect(),s=n.x2-n.x1,o=n.y2-n.y1;function i(a,l){a.forEach(c=>{let u=Tn(e,c);if(u&&u.charAt(u.length-1)==="%"){let p=parseFloat(u),h=l*p/100;T(e,c,`${h}px`)}})}i(["width","max-width","min-width"],s),i(["height","max-height","min-height"],o),i(["margin-top","margin-right","margin-bottom","margin-left","padding-top","padding-right","padding-bottom","padding-left"],this.vertical?o:s),["margin-top","margin-right","margin-bottom","margin-left"].forEach(a=>{Tn(e,a)==="auto"&&T(e,a,"0")})}fixFloatSizeAndPosition(e){for(;e.parent;)e=e.parent;e.viewNode.nodeType;let n=e.viewNode;if(this.rootViewNodes.push(n),this.adjustContentRelativeSize&&this.convertPercentageSizesToPx(n),this.floatMargins.push(this.getComputedMargin(n)),this.adjustContentRelativeSize){let s=this.floatSide;if(this.parentContainer.vertical){if(s==="block-end"||s==="left"){let i=Tn(n,"height");i!==""&&i!=="auto"&&T(n,"margin-top","auto")}}else if(s==="block-end"||s==="bottom"){let i=Tn(n,"width");i!==""&&i!=="auto"&&T(n,"margin-left","auto")}}}getContentInlineSize(){return Math.max.apply(null,this.rootViewNodes.map((e,n)=>{let s=this.clientLayout.getElementClientRect(e),o=this.floatMargins[n];return this.vertical?o.top+s.height+o.bottom:o.left+s.width+o.right}))}};var Ut=class{constructor(t,e){this.parent=t;this.rootSourceNode=e;d(this,"formattingContextType","RepetitiveElementsOwner");d(this,"isRoot",!1);d(this,"repetitiveElements",null)}getName(){return"Repetitive elements owner formatting context (RepetitiveElementsOwnerFormattingContext)"}isFirstTime(t,e){return e}getParent(){return this.parent}getRepetitiveElements(){return this.repetitiveElements}getRootViewNode(t){let e=this.getRootNodeContext(t);return e?e.viewNode:null}getRootNodeContext(t){do if(!t.belongsTo(this)&&t.sourceNode===this.rootSourceNode)return t;while(t=t.parent);return null}initializeRepetitiveElements(t){if(this.repetitiveElements)return;Qr.some(n=>n.root===this.rootSourceNode?(this.repetitiveElements=n.elements,!0):!1)||(this.repetitiveElements=new Gu(t,this.rootSourceNode),Qr.push({root:this.rootSourceNode,elements:this.repetitiveElements}))}saveState(){}restoreState(t){}},Gu=class{constructor(t,e){this.vertical=t;this.ownerSourceNode=e;d(this,"headerSourceNode",null);d(this,"footerSourceNode",null);d(this,"headerViewNode",null);d(this,"footerViewNode",null);d(this,"headerNodePosition",null);d(this,"footerNodePosition",null);d(this,"headerHeight",0);d(this,"footerHeight",0);d(this,"isSkipHeader",!1);d(this,"isSkipFooter",!1);d(this,"enableSkippingFooter",!0);d(this,"enableSkippingHeader",!0);d(this,"doneInitialLayout",!1);d(this,"firstContentSourceNode",null);d(this,"lastContentSourceNode",null);d(this,"affectedNodeCache",[]);d(this,"afterLastContentNodeCache",[]);d(this,"allowInsert",!1);d(this,"allowInsertRepeatitiveElements")}setHeaderNodeContext(t){this.headerNodePosition||(this.headerNodePosition=gs(t,0),this.headerSourceNode=t.sourceNode,this.headerViewNode=t.viewNode)}setFooterNodeContext(t){this.footerNodePosition||(this.footerNodePosition=gs(t,0),this.footerSourceNode=t.sourceNode,this.footerViewNode=t.viewNode)}updateHeight(t){this.headerViewNode&&(this.headerHeight=ti(this.headerViewNode,t,this.vertical),this.headerViewNode=null),this.footerViewNode&&(this.footerHeight=ti(this.footerViewNode,t,this.vertical),this.footerViewNode=null)}prepareLayoutFragment(){this.isSkipHeader=this.isSkipFooter=!1,this.enableSkippingFooter=!0,this.enableSkippingHeader=!0}appendHeaderToFragment(t,e,n){return!this.headerNodePosition||this.isSkipHeader?v(!0):this.appendElementToFragment(this.headerNodePosition,t,e,n)}appendFooterToFragment(t,e,n){return!this.footerNodePosition||this.isSkipFooter?v(!0):this.appendElementToFragment(this.footerNodePosition,t,e,n)}appendElementToFragment(t,e,n,s){let o=e.viewNode.ownerDocument,i=e.viewNode,a=o.createElement("div");i.appendChild(a);let l=new ws(s,a,e),c=l.getColumn().pageBreakType;return l.getColumn().pageBreakType=null,this.allowInsertRepeatitiveElements=!0,l.layout(new pt(t),!0).thenAsync(()=>(this.allowInsertRepeatitiveElements=!1,i.removeChild(a),this.moveChildren(a,i,n),l.getColumn().pageBreakType=c,v(!0)))}moveChildren(t,e,n){if(e)for(;t.firstChild;){let s=t.firstChild;t.removeChild(s),s.setAttribute(Mt,"1"),n?e.insertBefore(s,n):e.appendChild(s)}}calculateOffset(t){let e=0;return t&&!this.affectTo(t)||((!this.isSkipFooter||t&&this.isAfterLastContent(t))&&(e+=this.footerHeight),this.isSkipHeader||(e+=this.headerHeight)),e}calculateMinimumOffset(t){let e=0;return t&&!this.affectTo(t)||(t&&this.isAfterLastContent(t)&&(e+=this.footerHeight),this.enableSkippingHeader||(e+=this.headerHeight)),e}isAfterLastContent(t){return this.findResultFromCache(t,this.afterLastContentNodeCache,e=>this.isAfterNodeContextOf(this.lastContentSourceNode,t,!1))}affectTo(t){return this.findResultFromCache(t,this.affectedNodeCache,e=>this.isAfterNodeContextOf(this.ownerSourceNode,t,!0))}findResultFromCache(t,e,n){let s=e.filter(o=>o.nodeContext.sourceNode===t.sourceNode&&o.nodeContext.after===t.after);if(s.length>0)return s[0].result;{let o=n(t);return e.push({nodeContext:t,result:o}),o}}isAfterNodeContextOf(t,e,n){let s=[];for(let o=t;o;o=o.parentNode){if(e.sourceNode===o)return e.after;s.push(o)}for(let o=e.sourceNode;o;o=o.parentNode){let i=s.indexOf(o);if(i>=0)return n?i===0:!1;for(let a=o;a;a=a.previousElementSibling)if(s.includes(a))return!0}return e.after}isFirstContentNode(t){return t&&this.firstContentSourceNode===t.sourceNode}isEnableToUpdateState(){return!!(!this.isSkipFooter&&this.enableSkippingFooter&&this.footerNodePosition||!this.isSkipHeader&&this.enableSkippingHeader&&this.headerNodePosition)}updateState(){!this.isSkipFooter&&this.enableSkippingFooter&&this.footerNodePosition?this.isSkipFooter=!0:!this.isSkipHeader&&this.enableSkippingHeader&&this.headerNodePosition&&(this.isSkipHeader=!0)}preventSkippingHeader(){this.isSkipHeader=!1,this.enableSkippingHeader=!1}preventSkippingFooter(){this.isSkipFooter=!1,this.enableSkippingFooter=!1}isHeaderRegistered(){return!!this.headerNodePosition}isFooterRegistered(){return!!this.footerNodePosition}isHeaderSourceNode(t){return this.headerSourceNode===t}isFooterSourceNode(t){return this.footerSourceNode===t}},fi=class{constructor(t){this.formattingContext=t}accept(t,e){return!!t}postLayout(t,e,n,s){let o=this.formattingContext.getRepetitiveElements();return o&&(n.clientLayout,o.doneInitialLayout||(o.updateHeight(n),o.doneInitialLayout=!0)),s}},gi=class{constructor(t){this.formattingContext=t}accept(t,e){return!0}postLayout(t,e,n,s){return s}},Wu=class extends fi{constructor(e,n){super(e);this.processor=n}doLayout(e,n){return this.processor.doInitialLayout(e,n)}accept(e,n){return!1}},Xu=class extends gi{constructor(e,n){super(e);this.processor=n}doLayout(e,n){return!e.belongsTo(this.formattingContext)&&!e.after&&n.fragmentLayoutConstraints.unshift(new xo(e)),this.processor.doLayout(e,n)}},xo=class r{constructor(t){d(this,"flagmentLayoutConstraintType","RepetitiveElementsOwner");d(this,"nodeContext");let e=yn(t.formattingContext);this.nodeContext=e.getRootNodeContext(t)}allowLayout(t,e,n){let s=this.getRepetitiveElements();return!s||pn(this.nodeContext.viewNode)||!s.isEnableToUpdateState()?!0:!(e&&!t||t&&t.overflow)}nextCandidate(t){let e=this.getRepetitiveElements();return e&&e.isEnableToUpdateState()?(e.updateState(),!0):!1}postLayout(t,e,n,s){let o=this.getRepetitiveElements();o&&t&&s.stopAtOverflow&&(e==null||o.isAfterLastContent(e))&&o.preventSkippingFooter()}finishBreak(t,e){let n=yn(this.nodeContext.formattingContext),s=this.getRepetitiveElements();if(!s)return v(!0);let o=this.nodeContext;return hC(n,o,e).thenAsync(()=>fC(n,o,e).thenAsync(()=>(s.prepareLayoutFragment(),v(!0))))}getRepetitiveElements(){return yn(this.nodeContext.formattingContext).getRepetitiveElements()}equalsTo(t){return t instanceof r?yn(this.nodeContext.formattingContext)===yn(t.nodeContext.formattingContext):!1}getPriorityOfFinishBreak(){return 10}},$u=class extends Hn{constructor(e,n){super();this.formattingContext=e;this.processor=n}resolveLayoutMode(e){let n=this.formattingContext.getRepetitiveElements();return!e.belongsTo(this.formattingContext)&&!n.doneInitialLayout?new Wu(this.formattingContext,this.processor):(!e.belongsTo(this.formattingContext)&&!e.after&&n&&n.preventSkippingHeader(),new Xu(this.formattingContext,this.processor))}},ju=class extends gn{constructor(e,n){super();this.formattingContext=e;this.column=n}startNonInlineElementNode(e){let n=this.formattingContext,s=e.nodeContext,o=n.getRepetitiveElements();if(s.parent&&n.rootSourceNode===s.parent.sourceNode){switch(s.repeatOnBreak){case"header":if(o.isHeaderRegistered())s.repeatOnBreak="none";else return o.setHeaderNodeContext(s),v(!0);break;case"footer":if(o.isFooterRegistered())s.repeatOnBreak="none";else return o.setFooterNodeContext(s),v(!0);break}o.firstContentSourceNode||(o.firstContentSourceNode=s.sourceNode)}return gn.prototype.startNonInlineElementNode.call(this,e)}afterNonInlineElementNode(e){let n=this.formattingContext,s=e.nodeContext;return s.sourceNode===n.rootSourceNode&&(n.getRepetitiveElements().lastContentSourceNode=e.lastAfterNodeContext&&e.lastAfterNodeContext.sourceNode,e.break=!0),s.repeatOnBreak==="header"||s.repeatOnBreak==="footer"?v(!0):gn.prototype.afterNonInlineElementNode.call(this,e)}};var Yu=class extends Jt{layout(t,e,n){if(e.isFloatNodeContext(t))return e.layoutFloatOrFootnote(t);let s=yn(t.formattingContext);return s.getRootViewNode(t)?(n&&Ku(t.parent,e),t.belongsTo(s)?Jt.prototype.layout.call(this,t,e,n):new $u(s,this).layout(t,e)):e.buildDeepElementView(t)}startNonInlineElementNode(t){let n=gC(t).getRepetitiveElements();return n&&!n.allowInsertRepeatitiveElements&&(n.isHeaderSourceNode(t.sourceNode)||n.isFooterSourceNode(t.sourceNode))&&t.viewNode.parentNode.removeChild(t.viewNode),!1}doInitialLayout(t,e){let n=yn(t.formattingContext),s=k("BlockLayoutProcessor.doInitialLayout");return this.layoutEntireBlock(t,e).thenFinish(s),s.result()}layoutEntireBlock(t,e){let n=yn(t.formattingContext),s=new ju(n,e);return new Cs(s,e.layoutContext).iterate(t)}doLayout(t,e){let n=yn(t.formattingContext),s=k("doLayout"),o=e.layoutContext.nextInTree(t,!1);return zu(o,e).then(i=>{let a=i;s.loopWithFrame(l=>{for(;a;){let c=!0;if(e.layoutNext(a,!1).then(u=>{a=u,e.pageFloatLayoutContext.isInvalidated()||e.pageBreakType||a&&e.stopByOverflow(a)||a&&a.after&&a.sourceNode==n.rootSourceNode?l.breakLoop():c?c=!1:l.continueLoop()}),c){c=!1;return}}l.breakLoop()}).then(()=>{s.finish(a)})}),s.result()}finishBreak(t,e,n,s){return Jt.prototype.finishBreak.call(this,t,e,n,s)}clearOverflownViewNodes(t,e,n,s){Jt.prototype.clearOverflownViewNodes(t,e,n,s)}};function pC(r,t){for(let e=r;e;e=e.parent){let n=e.formattingContext;n&&n instanceof Ut&&!e.belongsTo(n)&&t(n,e)}}function Ku(r,t){r&&pC(r.after?r.parent:r,(e,n)=>{Ot.isInstanceOfTableFormattingContext(e)||t.fragmentLayoutConstraints.push(new xo(n))})}function hC(r,t,e){let n=r.getRepetitiveElements();if(n){let s=r.getRootNodeContext(t);if(s.viewNode){let o=s.viewNode.firstChild;return n.appendHeaderToFragment(s,o,e)}}return v(!0)}function fC(r,t,e){let n=r.getRepetitiveElements();if(n&&!n.isSkipFooter){let s=r.getRootNodeContext(t);if(s.viewNode)return n.appendFooterToFragment(s,null,e)}return v(!0)}function gC(r){let t=r.formattingContext;return!t||!(t instanceof Ut)?null:t}function yn(r){return r instanceof Ut,r}var mC=new Yu;_e("RESOLVE_LAYOUT_PROCESSOR",r=>r instanceof Ut&&!Ot.isInstanceOfTableFormattingContext(r)?mC:null);var ba=class{constructor(t,e){this.rowIndex=t;this.sourceNode=e;d(this,"cells",[])}addCell(t){this.cells.push(t)}getMinimumHeight(){return Math.min.apply(null,this.cells.map(t=>t.height))}},qu=class{constructor(t,e,n){this.rowIndex=t;this.columnIndex=e;d(this,"viewElement");d(this,"colSpan");d(this,"rowSpan");d(this,"height",0);d(this,"anchorSlot",null);this.viewElement=n,this.colSpan=n.colSpan||1,this.rowSpan=n.rowSpan||1}setHeight(t){this.height=t}setAnchorSlot(t){this.anchorSlot=t}},Zu=class{constructor(t,e,n){this.rowIndex=t;this.columnIndex=e;this.cell=n}},Qu=class{constructor(t,e,n){this.column=t;this.cellNodeContext=n;d(this,"pseudoColumn");d(this,"empty",!1);this.pseudoColumn=new ws(t,e,n)}findAcceptableBreakPosition(){let t=this.cellNodeContext.viewNode,{verticalAlign:e,alignContent:n}=t.style;e!=="top"&&e!=="baseline"&&T(t,"vertical-align","top"),n&&n!=="normal"&&T(t,"align-content","normal");let s=this.pseudoColumn.findAcceptableBreakPosition(!0);return T(t,"vertical-align",e),n&&n!=="normal"&&T(t,"align-content",n),s}},Ju=class{constructor(t,e){this.viewNode=t;this.side=e}},ed=class extends fn{constructor(e,n,s,o){super(e,n,s,o);d(this,"formattingContext");d(this,"acceptableCellBreakPositions",null);d(this,"rowIndex",null);this.formattingContext=e.formattingContext}findAcceptableBreak(e,n){let s=super.findAcceptableBreak(e,n);return n<this.getMinBreakPenalty()?null:this.getAcceptableCellBreakPositions().every(i=>!!i.nodeContext)?s:null}getMinBreakPenalty(){let e=super.getMinBreakPenalty();return this.getAcceptableCellBreakPositions().forEach(n=>{e+=n.breakPosition.getMinBreakPenalty()}),e}getAcceptableCellBreakPositions(){if(!this.acceptableCellBreakPositions){let e=this.formattingContext,n=this.getCellFragments();this.acceptableCellBreakPositions=n.map(s=>s.findAcceptableBreakPosition())}return this.acceptableCellBreakPositions}getRowIndex(){return this.rowIndex!=null?this.rowIndex:this.rowIndex=this.formattingContext.findRowIndexBySourceNode(this.position.sourceNode)}getCellFragments(){return this.formattingContext.getRowSpanningCellsOverflowingTheRow(this.getRowIndex()).map(this.formattingContext.getCellFragmentOfCell,this.formattingContext)}},td=class extends ms{constructor(e,n,s){super();this.rowIndex=e;this.beforeNodeContext=n;this.formattingContext=s;d(this,"acceptableCellBreakPositions",null)}findAcceptableBreak(e,n){if(n<this.getMinBreakPenalty())return null;let s=this.getCellFragments(),o=this.getAcceptableCellBreakPositions(),i=o.every(a=>!!a.nodeContext)&&o.some((a,l)=>{let c=s[l].pseudoColumn,u=a.nodeContext;return!c.isStartNodeContext(u)&&!c.isLastAfterNodeContext(u)});return this.beforeNodeContext.overflow=o.some(a=>a.nodeContext&&a.nodeContext.overflow),i?this.beforeNodeContext:null}getMinBreakPenalty(){let e=this.formattingContext,n=e.getRowByIndex(this.rowIndex),s=0;return e.isFreelyFragmentableRow(n)||(s+=10),this.getAcceptableCellBreakPositions().forEach(o=>{s+=o.breakPosition.getMinBreakPenalty()}),s}getAcceptableCellBreakPositions(){if(!this.acceptableCellBreakPositions){let e=this.getCellFragments();this.acceptableCellBreakPositions=e.map(n=>n.findAcceptableBreakPosition())}return this.acceptableCellBreakPositions}getCellFragments(){return this.formattingContext.getCellsFallingOnRow(this.rowIndex).map(this.formattingContext.getCellFragmentOfCell,this.formattingContext)}},$n=class extends Ut{constructor(e,n){super(e,n);this.tableSourceNode=n;d(this,"formattingContextType","Table");d(this,"vertical",!1);d(this,"columnCount",-1);d(this,"tableWidth",0);d(this,"captions",[]);d(this,"colGroups",null);d(this,"colWidths",null);d(this,"inlineBorderSpacing",0);d(this,"rows",[]);d(this,"slots",[]);d(this,"cellFragments",[]);d(this,"lastRowViewNode",null);d(this,"cellBreakPositions",[]);d(this,"repetitiveElements",null)}getName(){return"Table formatting context (Table.TableFormattingContext)"}isFirstTime(e,n){if(!n)return n;switch(e.display){case"table-row":return this.cellBreakPositions.length===0;case"table-cell":return!this.cellBreakPositions.some(s=>s.cellNodePosition.steps[0].node===e.sourceNode);default:return n}}getParent(){return this.parent}finishFragment(){this.cellFragments=[]}addRow(e,n){this.rows[e]=n}getRowSlots(e){let n=this.slots[e];return n||(n=this.slots[e]=[]),n}addCell(e,n){let s=this.rows[e];s||(this.addRow(e,new ba(e,null)),s=this.rows[e]),s.addCell(n);let o=e+n.rowSpan,i=this.getRowSlots(e),a=0;for(;i[a];)a++;for(;e<o;e++){i=this.getRowSlots(e);for(let l=a;l<a+n.colSpan;l++){let c=i[l]=new Zu(e,l,n);n.anchorSlot||n.setAnchorSlot(c)}}}getRowByIndex(e){let n=this.rows[e];return n}findRowIndexBySourceNode(e){return this.rows.findIndex(n=>e===n.sourceNode)}addCellFragment(e,n,s){let o=this.cellFragments[e];o||(o=this.cellFragments[e]=[]),o[n]=s}getCellsFallingOnRow(e){return this.getRowSlots(e).reduce((s,o)=>o.cell!==s[s.length-1]?s.concat(o.cell):s,[])}getRowSpanningCellsOverflowingTheRow(e){return this.getCellsFallingOnRow(e).filter(n=>n.rowIndex+n.rowSpan-1>e)}getCellFragmentOfCell(e){return this.cellFragments[e.rowIndex]&&this.cellFragments[e.rowIndex][e.columnIndex]}isFreelyFragmentableRow(e){return e.getMinimumHeight()>this.tableWidth/2}getColumnCount(){return this.columnCount<0&&(this.columnCount=Math.max.apply(null,this.rows.map(e=>e.cells.reduce((n,s)=>n+s.colSpan,0)))),this.columnCount}updateCellSizes(e){this.rows.forEach(n=>{n.cells.forEach(s=>{let o=e.getElementClientRect(s.viewElement);s.viewElement=null,s.setHeight(this.vertical?o.width:o.height)})})}findCellFromColumn(e){if(!e)return null;let n=null,s=0,o=0;e:for(s=0;s<this.cellFragments.length;s++)if(this.cellFragments[s]){for(o=0;o<this.cellFragments[s].length;o++)if(this.cellFragments[s][o]&&e===this.cellFragments[s][o].pseudoColumn.getColumn()){n=this.rows[s].cells[o];break e}}if(!n)return null;for(;s<this.slots.length;s++)for(;o<this.slots[s].length;o++){let i=this.slots[s][o];if(i.cell===n)return{rowIndex:i.rowIndex,columnIndex:i.columnIndex}}return null}collectElementsOffsetOfUpperCells(e){let n=[];return this.slots.reduce((s,o,i)=>{if(i>=e.rowIndex)return s;let a=o[e.columnIndex]&&this.getCellFragmentOfCell(o[e.columnIndex].cell);return!a||n.includes(a)||(this.collectElementsOffsetFromColumn(a.pseudoColumn.getColumn(),s),n.push(a)),s},[])}collectElementsOffsetOfHighestColumn(){let e=[];return this.rows.forEach(n=>{n.cells.forEach((s,o)=>{e[o]||(e[o]={collected:[],elements:[]});let i=e[o],a=this.getCellFragmentOfCell(s);!a||i.collected.includes(a)||(this.collectElementsOffsetFromColumn(a.pseudoColumn.getColumn(),i.elements),i.collected.push(a))})}),[new nd(e.map(n=>n.elements))]}collectElementsOffsetFromColumn(e,n){e.fragmentLayoutConstraints.forEach(s=>{if(Qt.isInstanceOfRepetitiveElementsOwnerLayoutConstraint(s)){let o=s.getRepetitiveElements();n.push(o)}Ot.isInstanceOfTableRowLayoutConstraint(s)&&s.getElementsOffsetsForTableCell(null).forEach(o=>{n.push(o)})})}saveState(){return[].concat(this.cellBreakPositions)}restoreState(e){this.cellBreakPositions=e}},nd=class{constructor(t){this.repeatitiveElementsInColumns=t}calculateOffset(t){return this.calculateMaxOffsetOfColumn(t,e=>e.current)}calculateMinimumOffset(t){return this.calculateMaxOffsetOfColumn(t,e=>e.minimum)}calculateMaxOffsetOfColumn(t,e){let n=0;return this.repeatitiveElementsInColumns.forEach(s=>{let o=_n(t,s);n=Math.max(n,e(o))}),n}};function Lt(r){return r instanceof $n,r}function CC(r){return r==="table-row-group"||r==="table-header-group"||r==="table-footer-group"}function bC(r){return r==="table"||r==="inline-table"}function bf(r){return CC(r)||bC(r)}function yf(r,t,e){let n=r.nodeContext,s=n.display,o=n.parent?n.parent.display:null,i=!1;if(o==="inline-table"&&!(n.formattingContext instanceof $n)){for(let l=n.parent;l;l=l.parent)if(l.formattingContext instanceof $n){i=l.formattingContext===t;break}}return i||s==="table-row"&&!bf(o)||s==="table-cell"&&o!=="table-row"&&!bf(o)||n.formattingContext instanceof $n&&n.formattingContext!==t?e.buildDeepElementView(n).thenAsync(l=>(r.nodeContext=l,v(!0))):null}var sd=class extends gn{constructor(e,n){super();this.formattingContext=e;this.column=n;d(this,"rowIndex",-1);d(this,"columnIndex",0);d(this,"inRow",!1);d(this,"checkPoints",[]);d(this,"inHeaderOrFooter",!1)}startNonInlineElementNode(e){let n=this.formattingContext,s=yf(e,n,this.column);if(s)return s;this.postLayoutBlockContents(e);let o=e.nodeContext,i=o.display,a=n.getRepetitiveElements();switch(i){case"table":n.inlineBorderSpacing=o.inlineBorderSpacing;break;case"table-caption":{let l=new Ju(o.viewNode,o.captionSide);n.captions.push(l);break}case"table-header-group":return a.isHeaderRegistered()||(this.inHeaderOrFooter=!0,a.setHeaderNodeContext(o)),v(!0);case"table-footer-group":return a.isFooterRegistered()||(this.inHeaderOrFooter=!0,a.setFooterNodeContext(o)),v(!0);case"table-row":this.inHeaderOrFooter||(this.inRow=!0,this.rowIndex++,o.sourceNode,this.columnIndex=0,n.addRow(this.rowIndex,new ba(this.rowIndex,o.sourceNode)),a.firstContentSourceNode||(a.firstContentSourceNode=o.sourceNode));break}return super.startNonInlineElementNode(e)}afterNonInlineElementNode(e){let n=this.formattingContext,s=e.nodeContext,o=s.display,i=this.column.clientLayout;if(this.postLayoutBlockContents(e),s.sourceNode===n.tableSourceNode){let a=i.getElementComputedStyle(n.getRootViewNode(s));n.tableWidth=parseFloat(a[n.vertical?"height":"width"]),n.getRepetitiveElements().lastContentSourceNode=e.lastAfterNodeContext&&e.lastAfterNodeContext.sourceNode,e.break=!0}else switch(o){case"table-header-group":case"table-footer-group":if(this.inHeaderOrFooter)return this.inHeaderOrFooter=!1,v(!0);break;case"table-row":this.inHeaderOrFooter||(n.lastRowViewNode=s.viewNode,this.inRow=!1);break;case"table-cell":if(!this.inHeaderOrFooter){this.inRow||(this.rowIndex++,this.columnIndex=0,this.inRow=!0);let a=s.viewNode;n.addCell(this.rowIndex,new qu(this.rowIndex,this.columnIndex,a)),this.columnIndex++}break}return super.afterNonInlineElementNode(e)}startNonElementNode(e){this.registerCheckPoint(e)}afterNonElementNode(e){this.registerCheckPoint(e)}startInlineElementNode(e){this.registerCheckPoint(e)}afterInlineElementNode(e){this.registerCheckPoint(e)}registerCheckPoint(e){let n=e.nodeContext;n&&n.viewNode&&!hn(n)&&this.checkPoints.push(n.clone())}postLayoutBlockContents(e){this.checkPoints.length>0&&this.column.postLayoutBlock(e.nodeContext,this.checkPoints),this.checkPoints=[]}},xa=class xa extends gn{constructor(e,n){super(!0);this.formattingContext=e;this.column=n;d(this,"inRow",!1);d(this,"currentRowIndex",-1);d(this,"currentColumnIndex",0);d(this,"originalStopAtOverflow");d(this,"inHeader");d(this,"inFooter");this.originalStopAtOverflow=n.stopAtOverflow,n.stopAtOverflow=!1}resetColumn(){this.column.stopAtOverflow=this.originalStopAtOverflow}getColSpanningCellWidth(e){let n=this.formattingContext.colWidths;let s=0;for(let o=0;o<e.colSpan;o++)s+=n[e.anchorSlot.columnIndex+o];return s+=this.formattingContext.inlineBorderSpacing*(e.colSpan-1),s}layoutCell(e,n,s){let o=e.rowIndex,i=e.columnIndex,a=e.colSpan,l=n.viewNode,c=n.verticalAlign;a>1&&(T(l,"box-sizing","border-box"),T(l,this.formattingContext.vertical?"height":"width",`${this.getColSpanningCellWidth(e)}px`));let u=l.ownerDocument.createElement("div");l.appendChild(u);let p=new Qu(this.column,u,n);return this.formattingContext.addCellFragment(o,i,p),s.primary.steps.length===1&&s.primary.after&&(p.empty=!0),p.pseudoColumn.layout(s,!0).thenReturn(!0)}hasBrokenCellAtSlot(e){let n=this.formattingContext.cellBreakPositions[0];return n?n.cell.anchorSlot.columnIndex===e:!1}extractRowSpanningCellBreakPositions(){let e=this.formattingContext.cellBreakPositions;if(e.length===0)return[];let n=[],s=0;do{let o=e[s],i=o.cell.rowIndex;if(i<this.currentRowIndex){let a=n[i];a||(a=n[i]=[]),a.push(o),e.splice(s,1)}else s++}while(s<e.length);return n}layoutRowSpanningCellsFromPreviousFragment(e){let n=this.formattingContext,s=this.extractRowSpanningCellBreakPositions(),o=s.reduce(h=>h+1,0);if(o===0)return v(!0);let i=this.column.layoutContext,a=e.nodeContext;a.viewNode.parentNode.removeChild(a.viewNode);let l=k("layoutRowSpanningCellsFromPreviousFragment"),c=v(!0),u=0,p=[];return s.forEach(h=>{c=c.thenAsync(()=>{let f=ao(h[0].cellNodePosition.steps[1],a.parent);return i.setCurrent(f,!1).thenAsync(()=>{let g=v(!0),m=0;function E(C){for(;m<C;){if(!p.includes(m)){let b=f.viewNode.ownerDocument.createElement("td");T(b,"padding","0"),f.viewNode.appendChild(b)}m++}}return h.forEach(C=>{g=g.thenAsync(()=>{let b=C.cell;E(b.anchorSlot.columnIndex);let y=C.cellNodePosition,N=ao(y.steps[0],f);return N.offsetInNode=y.offsetInNode,N.after=y.after,N.fragmentIndex=y.steps[0].fragmentIndex+1,i.setCurrent(N,!1).thenAsync(()=>{let S=C.breakChunkPosition;for(let w=0;w<b.colSpan;w++)p.push(m+w);return m+=b.colSpan,this.layoutCell(b,N,S).thenAsync(()=>(N.viewNode.rowSpan=b.rowIndex+b.rowSpan-this.currentRowIndex+o-u,v(!0)))})})}),g.thenAsync(()=>(E(n.getColumnCount()),u++,v(!0)))})})}),c.then(()=>{i.setCurrent(a,!0,e.atUnforcedBreak).then(()=>{l.finish(!0)})}),l.result()}startTableRow(e){if(this.inHeader||this.inFooter)return v(!0);let n=e.nodeContext,s=this.formattingContext;return this.currentRowIndex<0?(n.sourceNode,this.currentRowIndex=s.findRowIndexBySourceNode(n.sourceNode)):this.currentRowIndex++,this.currentColumnIndex=0,this.inRow=!0,this.layoutRowSpanningCellsFromPreviousFragment(e).thenAsync(()=>(this.registerCellFragmentIndex(),this.column.checkOverflowAndSaveEdgeAndBreakPosition(e.lastAfterNodeContext,null,!0,e.breakAtTheEdge)&&s.getRowSpanningCellsOverflowingTheRow(this.currentRowIndex-1).length===0&&(this.resetColumn(),n.overflow=!0,e.break=!0),v(!0)))}registerCellFragmentIndex(){this.formattingContext.getRowByIndex(this.currentRowIndex).cells.forEach(n=>{let s=this.formattingContext.cellBreakPositions[n.columnIndex];if(s&&s.cell.anchorSlot.columnIndex==n.anchorSlot.columnIndex){let o=s.cellNodePosition.steps[0],i=this.column.layoutContext.xmldoc.getElementOffset(o.node);gf(i,o.fragmentIndex+1,1)}})}startTableCell(e){if(this.inHeader||this.inFooter)return v(!0);let n=e.nodeContext;this.inRow||(this.currentRowIndex<0?this.currentRowIndex=0:this.currentRowIndex++,this.currentColumnIndex=0,this.inRow=!0);let s=this.formattingContext.getRowByIndex(this.currentRowIndex).cells[this.currentColumnIndex];if(!s)return e.break=!0,v(!0);let o=n.copy().modify();o.after=!0,e.nodeContext=o;let i=k("startTableCell"),a;if(this.hasBrokenCellAtSlot(s.anchorSlot.columnIndex)){let l=this.formattingContext.cellBreakPositions.shift();n.fragmentIndex=l.cellNodePosition.steps[0].fragmentIndex+1,a=v(l.breakChunkPosition)}else a=this.column.nextInTree(n,e.atUnforcedBreak).thenAsync(l=>{l.viewNode&&n.viewNode.removeChild(l.viewNode);let c=gs(l,0);return v(new pt(c))});return a.then(l=>{this.layoutCell(s,n,l).then(()=>{this.afterNonInlineElementNode(e),this.currentColumnIndex++,i.finish(!0)})}),i.result()}startNonInlineBox(e){let n=yf(e,Lt(this.formattingContext),this.column);if(n)return n;let s=e.nodeContext,o=this.formattingContext.getRepetitiveElements(),i=s.display;return i==="table-header-group"&&o&&o.isHeaderSourceNode(s.sourceNode)?(this.inHeader=!0,v(!0)):i==="table-footer-group"&&o&&o.isFooterSourceNode(s.sourceNode)?(this.inFooter=!0,v(!0)):i==="table-row"?this.startTableRow(e):i==="table-cell"?this.startTableCell(e):v(!0)}endNonInlineBox(e){let n=e.nodeContext;if(n.display==="table-row"&&(this.inRow=!1,!this.inHeader&&!this.inFooter)){let o=n.copy().modify();o.after=!1;let i=new td(this.currentRowIndex,o,this.formattingContext);this.column.breakPositions.push(i)}return v(!0)}afterNonInlineElementNode(e){let n=e.nodeContext,s=this.formattingContext.getRepetitiveElements(),o=n.display;if(o==="table-header-group"?s&&!s.allowInsertRepeatitiveElements&&s.isHeaderSourceNode(n.sourceNode)?(this.inHeader=!1,n.viewNode.parentNode.removeChild(n.viewNode)):T(n.viewNode,"display","table-row-group"):o==="table-footer-group"&&(s&&!s.allowInsertRepeatitiveElements&&s.isFooterSourceNode(n.sourceNode)?(this.inFooter=!1,n.viewNode.parentNode.removeChild(n.viewNode)):T(n.viewNode,"display","table-row-group")),o&&xa.ignoreList[o])n.viewNode.parentNode.removeChild(n.viewNode);else if(n.sourceNode===this.formattingContext.tableSourceNode)n.overflow=this.column.checkOverflowAndSaveEdge(n,null),this.resetColumn(),e.break=!0;else return super.afterNonInlineElementNode(e);return v(!0)}};d(xa,"ignoreList",{"table-caption":!0,"table-column-group":!0,"table-column":!0});var od=xa,mi=[];function yC(r){let t=mi.findIndex(n=>n.root===r),e=mi[t];return e?e.tableLayoutOption:null}function xC(r){let t=mi.findIndex(e=>e.root===r);t>=0&&mi.splice(t,1)}var ya=class{layoutEntireTable(t,e){let n=Lt(t.formattingContext),s=new sd(n,e);return new Cs(s,e.layoutContext).iterate(t)}getColumnWidths(t,e,n,s){let o=t.ownerDocument,i=o.createElement("tr"),a=[];for(let c=0;c<e;c++){let u=o.createElement("td");i.appendChild(u),a.push(u)}t.parentNode.insertBefore(i,t.nextSibling);let l=a.map(c=>{let u=s.getElementClientRect(c),p=n?u.height:u.width;return Math.ceil(p)});return t.parentNode.removeChild(i),l}getColGroupElements(t){let e=[],n=t.firstElementChild;for(;n;)n.localName==="colgroup"&&e.push(n),n=n.nextElementSibling;return e}normalizeAndGetColElements(t){let e=[];return t.forEach(n=>{let s=n.span;n.removeAttribute("span");let o=n.firstElementChild;for(;o;){if(o.localName==="col"){let i=o.span;for(o.removeAttribute("span"),s-=i;i-- >1;){let a=o.cloneNode(!0);n.insertBefore(a,o),e.push(a)}e.push(o)}o=o.nextElementSibling}for(;s-- >0;)o=n.ownerDocument.createElement("col"),n.appendChild(o),e.push(o)}),e}addMissingColElements(t,e,n,s){if(t.length<n){let o=s.ownerDocument.createElement("colgroup");e.push(o);for(let i=t.length;i<n;i++){let a=s.ownerDocument.createElement("col");o.appendChild(a),t.push(a)}}}normalizeColGroups(t,e,n){let s=t.vertical,o=t.lastRowViewNode;if(!o)return;t.lastRowViewNode=null;let a=o.ownerDocument.createDocumentFragment(),l=t.getColumnCount();if(!(l>0)){t.colGroups=a;return}let c=t.colWidths=this.getColumnWidths(o,l,s,n.clientLayout),u=this.getColGroupElements(e),p=this.normalizeAndGetColElements(u);this.addMissingColElements(p,u,l,e),p.forEach((h,f)=>{T(h,s?"height":"width",`${c[f]}px`)}),u.forEach(h=>{a.appendChild(h.cloneNode(!0))}),t.colGroups=a}doInitialLayout(t,e){let n=Lt(t.formattingContext);n.vertical=t.vertical,n.initializeRepetitiveElements(t.vertical),t.sourceNode;let s=yC(t.sourceNode);xC(t.sourceNode);let o=k("TableLayoutProcessor.doInitialLayout"),i=t.copy();return this.layoutEntireTable(t,e).then(a=>{let l=a.viewNode,c=e.clientLayout.getElementClientRect(l),u=e.vertical?c.left:c.bottom;if(u+=(e.vertical?-1:1)*_n(t,e.collectElementsOffset()).current,!e.isOverflown(u)&&(!s||!s.calculateBreakPositionsInside)){e.breakPositions.push(new ad(i)),o.finish(a);return}this.normalizeColGroups(n,l,e),n.updateCellSizes(e.clientLayout),o.finish(null)}),o.result()}addCaptions(t,e,n){let s=t.captions;s.forEach((o,i)=>{o&&(e.insertBefore(o.viewNode,n),o.side==="top"&&(s[i]=null))})}addColGroups(t,e,n){t.colGroups&&this.getColGroupElements(e).length===0&&e.insertBefore(t.colGroups.cloneNode(!0),n)}removeColGroups(t,e){if(t.colGroups&&e){let n=this.getColGroupElements(e);n&&n.forEach(s=>{e.removeChild(s)})}}doLayout(t,e){let n=Lt(t.formattingContext),s=n.getRootViewNode(t),o=s.firstChild;this.addCaptions(n,s,o),this.addColGroups(n,s,o);let i=new od(n,e),a=new Cs(i,e.layoutContext),l=k("TableFormattingContext.doLayout");return a.iterate(t).thenFinish(l),l.result()}layout(t,e,n){let s=Lt(t.formattingContext);return s.getRootViewNode(t)?(n&&Ku(t.parent,e),new id(s,this).layout(t,e)):e.buildDeepElementView(t)}createEdgeBreakPosition(t,e,n,s){return new ed(t,e,n,s)}startNonInlineElementNode(t){return!1}afterNonInlineElementNode(t,e){return!1}finishBreak(t,e,n,s){let o=Lt(e.formattingContext);if(e.display==="table-row"){e.sourceNode;let i=o.findRowIndexBySourceNode(e.sourceNode);o.cellBreakPositions=[];let a;if(e.after?a=o.getRowSpanningCellsOverflowingTheRow(i):a=o.getCellsFallingOnRow(i),a.length){let l=k("TableLayoutProcessor.finishBreak"),c=0;return l.loopWithFrame(u=>{if(c===a.length){u.breakLoop();return}let p=a[c++],h=o.getCellFragmentOfCell(p),f=h.findAcceptableBreakPosition().nodeContext;let g=h.cellNodeContext,m=g.toNodePosition(),E=new pt(f.toNodePosition());o.cellBreakPositions.push({cellNodePosition:m,breakChunkPosition:E,cell:p});let C=g.viewNode;h.column.layoutContext.processFragmentedBlockEdge(h.cellNodeContext),i<p.rowIndex+p.rowSpan-1&&(C.rowSpan=i-p.rowIndex+1),h.empty?u.continueLoop():h.pseudoColumn.finishBreak(f,!1,!0).then(()=>{EC(h,o,f),u.continueLoop()})}).then(()=>{t.clearOverflownViewNodes(e,!1),t.layoutContext.processFragmentedBlockEdge(e),o.finishFragment(),l.finish(!0)}),l.result()}}return o.finishFragment(),ni.finishBreak(t,e,n,s)}clearOverflownViewNodes(t,e,n,s){Jt.prototype.clearOverflownViewNodes(t,e,n,s)}};function EC(r,t,e){let n=t.getRepetitiveElements();if(!n)return;let s=t.vertical,o=r.column,i=r.pseudoColumn.getColumnElement(),a=r.cellNodeContext.viewNode,l=o.clientLayout.getElementClientRect(a),c=o.getComputedPaddingBorder(a);if(s){let u=l.right-o.footnoteEdge-n.calculateOffset(e)-c.right;T(i,"max-width",`${u}px`)}else{let u=o.footnoteEdge-n.calculateOffset(e)-l.top-c.top;T(i,"max-height",`${u}px`)}T(i,"overflow","hidden")}var id=class extends Hn{constructor(e,n){super();this.tableFormattingContext=e;this.processor=n}resolveLayoutMode(e){let n=this.tableFormattingContext.getRepetitiveElements();return!n||!n.doneInitialLayout?new rd(this.tableFormattingContext,this.processor):(e.sourceNode===this.tableFormattingContext.tableSourceNode&&!e.after&&n&&n.preventSkippingHeader(),new cd(this.tableFormattingContext,this.processor))}clearNodes(e){super.clearNodes(e);let n=this.tableFormattingContext.getRootViewNode(e);this.processor.removeColGroups(this.tableFormattingContext,n)}restoreState(e,n){super.restoreState(e,n),this.tableFormattingContext.finishFragment()}},rd=class extends fi{constructor(e,n){super(e);this.processor=n}doLayout(e,n){return this.processor.doInitialLayout(e,n)}},ad=class extends fn{constructor(t){super(t,null,t.overflow,0)}getMinBreakPenalty(){if(!this.isEdgeUpdated)throw new Error("EdgeBreakPosition.prototype.updateEdge not called");return(this.overflows?3:0)+(this.position.parent?this.position.parent.breakPenalty:0)}breakPositionChosen(t){t.fragmentLayoutConstraints.push(new ld(this.position.sourceNode))}},ld=class r{constructor(t){this.tableRootNode=t;d(this,"flagmentLayoutConstraintType","EntireTable")}allowLayout(t,e,n){return t.overflow,!1}nextCandidate(t){return!0}postLayout(t,e,n,s){e.sourceNode,mi.push({root:e.sourceNode,tableLayoutOption:{calculateBreakPositionsInside:!0}})}finishBreak(t,e){return v(!0)}equalsTo(t){return t instanceof r&&t.tableRootNode===this.tableRootNode}getPriorityOfFinishBreak(){return 0}},cd=class extends gi{constructor(e,n){super(e);this.processor=n}doLayout(e,n){let s=this.formattingContext.getRepetitiveElements();if(s&&!s.isAfterLastContent(e)){let o=new ud(e);n.fragmentLayoutConstraints.some(i=>o.equalsTo(i))||n.fragmentLayoutConstraints.unshift(o)}return this.processor.doLayout(e,n)}},ud=class r extends xo{constructor(e){super(e);d(this,"flagmentLayoutConstraintType","TableRow");d(this,"cellFragmentLayoutConstraints",[])}allowLayout(e,n,s){let o=this.getRepetitiveElements();return!o||s.pseudoParent||pn(this.nodeContext.viewNode)||!o.isEnableToUpdateState()?!0:!(n&&!e||e&&e.overflow)}nextCandidate(e){let n=Lt(this.nodeContext.formattingContext);return this.collectCellFragmentLayoutConstraints(e,n).some(o=>o.constraints.some(i=>i.nextCandidate(e)))?!0:super.nextCandidate(e)}postLayout(e,n,s,o){let i=Lt(this.nodeContext.formattingContext);if(this.cellFragmentLayoutConstraints=this.collectCellFragmentLayoutConstraints(n,i),this.cellFragmentLayoutConstraints.forEach(a=>{a.constraints.forEach(l=>{l.postLayout(e,a.breakPosition,s,o)})}),!e){let a=i.getRootViewNode(this.nodeContext);new ya().removeColGroups(i,a),this.removeDummyRowNodes(s)}super.postLayout(e,n,s,o)}finishBreak(e,n){let s=Lt(this.nodeContext.formattingContext),o=k("finishBreak"),i=this.cellFragmentLayoutConstraints.reduce((l,c)=>l.concat(c.constraints.map(u=>({constraint:u,breakPosition:c.breakPosition}))),[]),a=0;return o.loop(()=>{if(a<i.length){let l=i[a++];return l.constraint.finishBreak(l.breakPosition,n).thenReturn(!0)}else return v(!1)}).then(()=>{o.finish(!0)}),o.result().thenAsync(()=>super.finishBreak(e,n))}removeDummyRowNodes(e){if(!(!e||e.display!=="table-row"||!e.viewNode))for(;e.viewNode.previousElementSibling;){let n=e.viewNode.previousElementSibling;n.parentNode&&n.parentNode.removeChild(n)}}collectCellFragmentLayoutConstraints(e,n){return this.getCellFragemnts(e,n).map(s=>({constraints:s.fragment.pseudoColumn.getColumn().fragmentLayoutConstraints,breakPosition:s.breakPosition}))}getCellFragemnts(e,n){let s=Number.MAX_VALUE;e&&e.display==="table-row"&&(e.sourceNode,s=n.findRowIndexBySourceNode(e.sourceNode)+1),s=Math.min(n.cellFragments.length,s);let o=[];for(let i=0;i<s;i++)n.cellFragments[i]&&n.cellFragments[i].forEach(a=>{a&&o.push({fragment:a,breakPosition:a.findAcceptableBreakPosition().nodeContext})});return o}getElementsOffsetsForTableCell(e){let n=Lt(this.nodeContext.formattingContext),s=n.findCellFromColumn(e);return s?n.collectElementsOffsetOfUpperCells(s):n.collectElementsOffsetOfHighestColumn()}equalsTo(e){return e instanceof r?Lt(this.nodeContext.formattingContext)===Lt(e.nodeContext.formattingContext):!1}},SC=new ya;function NC(r,t,e,n,s,o){if(!t)return null;if(e===x.table){let i=r.parent;return new $n(i?i.formattingContext:null,r.sourceNode)}return null}function vC(r){return r instanceof $n?SC:null}_e("RESOLVE_FORMATTING_CONTEXT",NC);_e("RESOLVE_LAYOUT_PROCESSOR",vC);function xf(r){return r.reduce((t,e)=>t+e,0)/r.length}function Ef(r){let t=xf(r);return xf(r.map(e=>{let n=e-t;return n*n}))}var dd=class{constructor(t,e){this.layoutResult=t;this.penalty=e}};function Ci(r){return r.vertical?r.width:r.height}function bi(r,t){r.vertical?r.width=t:r.height=t}var Ea=class{constructor(t,e,n){this.layoutContainer=t;this.columnGenerator=e;this.regionPageFloatLayoutContext=n;d(this,"originalContainerBlockSize");this.originalContainerBlockSize=Ci(t)}balanceColumns(t){let e=k("ColumnBalancer#balanceColumns");this.preBalance(t),this.savePageFloatLayoutContexts(t),this.layoutContainer.clear();let n=[this.createTrialResult(t)];return e.loopWithFrame(s=>{if(!this.hasNextCandidate(n)){s.breakLoop();return}this.updateCondition(n),this.columnGenerator().then(o=>{if(this.savePageFloatLayoutContexts(o),this.layoutContainer.clear(),!o){s.breakLoop();return}n.push(this.createTrialResult(o)),s.continueLoop()})}).then(()=>{let s=n.reduce((o,i)=>i.penalty<o.penalty?i:o,n[0]);this.restoreContents(s.layoutResult),this.postBalance(),e.finish(s.layoutResult)}),e.result()}createTrialResult(t){let e=this.calculatePenalty(t);return new dd(t,e)}preBalance(t){}postBalance(){bi(this.layoutContainer,this.originalContainerBlockSize)}savePageFloatLayoutContexts(t){let e=this.regionPageFloatLayoutContext.detachChildren();t&&(t.columnPageFloatLayoutContexts=e)}restoreContents(t){let e=this.layoutContainer.element;t.columns.forEach(n=>{e.appendChild(n.element)}),t.columnPageFloatLayoutContexts,this.regionPageFloatLayoutContext.attachChildren(t.columnPageFloatLayoutContexts)}},pd=1;function Nf(r){let t=r[r.length-1];if(t.penalty===0)return!1;let e=r[r.length-2];if(e&&t.penalty>=e.penalty)return!1;let n=t.layoutResult.columns,s=Math.max.apply(null,n.map(i=>i.computedBlockSize)),o=Math.max.apply(null,n.map(i=>i.getMaxBlockSizeOfPageFloats()));return s>o+pd}function vf(r,t){let e=r[r.length-1].layoutResult.columns,s=Math.max.apply(null,e.map(o=>isNaN(o.blockDistanceToBlockEndFloats)?o.computedBlockSize:o.computedBlockSize-o.blockDistanceToBlockEndFloats+pd))-pd;s<Ci(t)?bi(t,s):bi(t,Ci(t)-1)}var hd=class extends Ea{constructor(e,n,s,o){super(s,e,n);this.columnCount=o;d(this,"originalPosition",null);d(this,"foundUpperBound",!1)}preBalance(e){let s=e.columns.reduce((o,i)=>o+i.computedBlockSize,0);bi(this.layoutContainer,s/this.columnCount),this.originalPosition=e.position}checkPosition(e){return this.originalPosition?this.originalPosition.isSamePosition(e):e===null}calculatePenalty(e){if(!this.checkPosition(e.position))return 1/0;let n=e.columns;return Sf(n)?1/0:Math.max.apply(null,n.map(s=>s.computedBlockSize))}hasNextCandidate(e){if(e.length===1)return!0;if(this.foundUpperBound)return Nf(e);{let n=e[e.length-1];return this.checkPosition(n.layoutResult.position)&&!Sf(n.layoutResult.columns)?(this.foundUpperBound=!0,!0):Ci(this.layoutContainer)<this.originalContainerBlockSize}}updateCondition(e){if(this.foundUpperBound)vf(e,this.layoutContainer);else{let n=Math.min(this.originalContainerBlockSize,Ci(this.layoutContainer)+this.originalContainerBlockSize*.1);bi(this.layoutContainer,n)}}};function Sf(r){if(r.length<=1)return!1;let t=r[r.length-1].computedBlockSize;return r.slice(0,r.length-1).every(n=>t>n.computedBlockSize)}var fd=class extends Ea{constructor(t,e,n){super(n,t,e)}calculatePenalty(t){if(t.columns.every(n=>n.computedBlockSize===0))return 1/0;let e=t.columns.filter(n=>!n.pageBreakType).map(n=>n.computedBlockSize);return Ef(e)}hasNextCandidate(t){return Nf(t)}updateCondition(t){vf(t,this.layoutContainer)}};function Tf(r,t,e,n,s,o,i){if(t===x.auto)return null;{let a=i.positions.length===0,l=o[o.length-1],c=!!(l&&l.pageBreakType);return a||c?new hd(e,n,s,r):t===x.balance_all?new fd(e,n,s):(x.balance,null)}}var yi=class{constructor(t,e,n){d(this,"endStuckFixed");d(this,"endFixed");d(this,"endSlipped");this.endStuckFixed=t,this.endFixed=e,this.endSlipped=n}},gd=class{constructor(){d(this,"map",[])}getMaxFixed(){return this.map.length==0?0:this.map[this.map.length-1].endFixed}getMaxSlipped(){return this.map.length==0?0:this.map[this.map.length-1].endSlipped}addStuckRange(t){if(this.map.length==0)this.map.push(new yi(t,t,t));else{let e=this.map[this.map.length-1],n=e.endSlipped+t-e.endFixed;e.endFixed==e.endStuckFixed?(e.endFixed=t,e.endStuckFixed=t,e.endSlipped=n):this.map.push(new yi(t,t,n))}}addSlippedRange(t){this.map.length==0?this.map.push(new yi(t,0,0)):this.map[this.map.length-1].endFixed=t}slippedByFixed(t){let e=gt(this.map.length,s=>t<=this.map[s].endFixed),n=this.map[e];return n.endSlipped-Math.max(0,n.endStuckFixed-t)}fixedBySlipped(t){let e=gt(this.map.length,s=>t<=this.map[s].endSlipped),n=this.map[e];return n.endStuckFixed-(n.endSlipped-t)}},md=class r{constructor(t,e,n,s,o,i,a,l){this.context=t;this.style=e;this.offset=n;this.isRoot=s;this.flowChunk=o;this.atBlockStart=i;this.atFlowStart=a;this.isParentBoxDisplayed=l;d(this,"flowName");d(this,"isBlockValue",null);d(this,"hasBoxValue",null);d(this,"styleValues",{});d(this,"beforeBox",null);d(this,"afterBox",null);d(this,"breakBefore",null);if(this.flowName=o.flowName,this.hasBox()){let c=e._pseudos;if(c&&c.before){let u=new r(t,c.before,n,!1,o,this.isBlock(),a,!0),p=u.styleValue("content");St(p)&&(this.beforeBox=u,this.breakBefore=u.breakBefore)}}this.breakBefore=Ve(this.getBreakValue("before"),this.breakBefore),this.atFlowStart&&De(this.breakBefore)&&(o.breakBefore=Ve(o.breakBefore,this.breakBefore))}buildAfterPseudoElementBox(t,e,n){if(this.hasBox()){let s=this.style._pseudos;if(s&&s.after){let o=new r(this.context,s.after,t,!1,this.flowChunk,e,n,!0),i=o.styleValue("content");St(i)&&(this.afterBox=o)}}}styleValue(t,e){if(!(t in this.styleValues)){let n=this.style[t];this.styleValues[t]=n?n.evaluate(this.context,t):e||null}return this.styleValues[t]}displayValue(){return this.styleValue("display",x.inline)}isBlock(){if(this.isBlockValue===null){let t=this.displayValue(),e=this.styleValue("position"),n=this.styleValue("float");this.isBlockValue=Xr(t,e,n,this.isRoot)}return this.isBlockValue}hasBox(){return this.hasBoxValue===null&&(this.hasBoxValue=this.isParentBoxDisplayed&&this.displayValue()!==x.none),this.hasBoxValue}getBreakValue(t){let e=null;if(this.isBlock()){let n=this.styleValue(`break-${t}`);n&&(e=n.toString())}return e}},Cd=class{constructor(t){this.context=t;d(this,"stack",[]);d(this,"atBlockStart",!0);d(this,"atFlowStart",!0);d(this,"atStartStack",[])}empty(){return this.stack.length===0}lastBox(){return this.stack[this.stack.length-1]}lastFlowName(){let t=this.lastBox();return t?t.flowChunk.flowName:null}isCurrentBoxDisplayed(){return this.stack.every(t=>t.displayValue()!==x.none)}push(t,e,n,s){let o=this.lastBox();s&&o&&s.flowName!==o.flowName&&this.atStartStack.push({atBlockStart:this.atBlockStart,atFlowStart:this.atFlowStart});let i=s||o.flowChunk,a=this.atFlowStart||!!s,l=this.isCurrentBoxDisplayed(),c=new md(this.context,t,e,n,i,a||this.atBlockStart,a,l);return this.stack.push(c),this.atBlockStart=c.hasBox()?!c.beforeBox&&c.isBlock():this.atBlockStart,this.atFlowStart=c.hasBox()?!c.beforeBox&&a:this.atFlowStart,c}encounteredTextNode(t){let e=this.lastBox();if((t.nodeType===Node.TEXT_NODE||t.nodeType===Node.CDATA_SECTION_NODE)&&(this.atBlockStart||this.atFlowStart)&&e.hasBox()){let n=e.styleValue("white-space",x.normal).toString(),s=Hr(n);s&&!he(t,s)&&(this.atBlockStart=!1,this.atFlowStart=!1)}}pop(t){let e=this.stack.pop();if(e.buildAfterPseudoElementBox(t,this.atBlockStart,this.atFlowStart),this.atFlowStart&&e.afterBox){let s=e.afterBox.getBreakValue("before");e.flowChunk.breakBefore=Ve(e.flowChunk.breakBefore,s)}let n=this.lastBox();if(n)if(n.flowName===e.flowName)e.hasBox()&&(this.atBlockStart=this.atFlowStart=!1);else{let s=this.atStartStack.pop();this.atBlockStart=s.atBlockStart,this.atFlowStart=s.atFlowStart}return e}nearestBlockStartOffset(t){if(!t.atBlockStart)return t.offset;let e=this.stack.length-1,n=this.stack[e];for(n===t&&(e--,n=this.stack[e]);e>=0;){if(n.flowName!==t.flowName)return t.offset;if(!n.atBlockStart||n.isRoot)return n.offset;t=n,n=this.stack[--e]}throw new Error("No block start offset found!")}},xi=class{constructor(t,e,n,s,o,i,a,l){this.xmldoc=t;this.scope=n;this.context=s;this.primaryFlows=o;this.validatorSet=i;this.counterListener=a;d(this,"root");d(this,"cascadeHolder");d(this,"last");d(this,"rootStyle",{});d(this,"styleMap",{});d(this,"flows",{});d(this,"flowChunks",[]);d(this,"flowListener",null);d(this,"flowToReach",null);d(this,"idToReach",null);d(this,"cascade");d(this,"offsetMap");d(this,"primary",!0);d(this,"primaryStack",[]);d(this,"rootBackgroundAssigned",!1);d(this,"rootLayoutAssigned",!1);d(this,"lastOffset");d(this,"breakBeforeValues",{});d(this,"boxStack");d(this,"bodyReached",!0);this.root=t.root,this.cascadeHolder=e,this.last=this.root,this.cascade=e.createInstance(s,a,l,t.lang),this.offsetMap=new gd;let c=t.getElementOffset(this.root);this.lastOffset=c,this.boxStack=new Cd(s),this.offsetMap.addStuckRange(c);let u=this.getAttrStyle(this.root);switch(this.cascade.pushElement(this,this.root,u,c),this.postprocessTopStyle(u,!1),this.root.namespaceURI){case"http://www.w3.org/1999/xhtml":this.bodyReached=!1;break}this.primaryStack.push(!0),this.styleMap={},this.styleMap[`e${c}`]=u,this.lastOffset++,this.replayFlowElementsFromOffset(-1)}hasProp(t,e,n){let s=t[n];return s&&s.evaluate(this.context)!==e[n]}transferPropsToRoot(t,e){for(let n in e){let s=t[n];if(s)this.rootStyle[n]=s,delete t[n];else{let o=e[n];o&&(this.rootStyle[n]=new M(o,fc))}}}postprocessTopStyle(t,e){var n;if(e)for(let s of["writing-mode","direction"])t[s]&&!(e&&this.rootStyle[s])&&(this.rootStyle[s]=t[s]);else for(let s in t)Wn(s)&&(this.rootStyle[s]=t[s]);if(!this.rootBackgroundAssigned){let s=this.hasProp(t,this.validatorSet.backgroundProps,"background-color")?t["background-color"].evaluate(this.context):null,o=this.hasProp(t,this.validatorSet.backgroundProps,"background-image")?t["background-image"].evaluate(this.context):null;(s&&!U(s)||o&&!U(o))&&(this.transferPropsToRoot(t,this.validatorSet.backgroundProps),this.rootBackgroundAssigned=!0)}if(!this.rootLayoutAssigned){for(let s=0;s<wf.length;s++)if(this.hasProp(t,this.validatorSet.layoutProps,wf[s])){this.transferPropsToRoot(t,this.validatorSet.layoutProps),this.rootLayoutAssigned=!0;break}}if(!e){let s=t["font-size"],o=!0;if(s&&!U(s.value)){let l=s.evaluate(this.context);if(l instanceof P){let c=l.num;switch(l.unit){case"em":case"rem":c*=this.context.initialFontSize;break;case"ex":c*=this.context.initialFontSize*X.ex/X.em;break;case"%":c*=this.context.initialFontSize/100;break;case"lh":case"rlh":c*=this.context.initialFontSize*X.lh/X.em;break;default:{let u=X[l.unit];u&&(c*=u),o=!1}}this.context.rootFontSize=c,this.context.isRelativeRootFontSize=o}}let i=(n=this.context.rootFontSize)!=null?n:this.context.initialFontSize,a=t["line-height"];if(a&&!U(a.value)){let l=a.evaluate(this.context);if(l instanceof lt)this.context.rootLineHeight=l.num*i;else if(l instanceof P){let c=l.num;switch(l.unit){case"em":case"rem":c*=i;break;case"ex":c*=i*X.ex/X.em;break;case"%":c*=i/100;break;case"lh":case"rlh":c*=this.context.initialFontSize*X.lh/X.em;break;default:{let u=X[l.unit];u&&(c*=u)}}this.context.rootLineHeight=c}}else this.context.rootLineHeight=this.context.fontSize()*X.lh/X.em}}getTopContainerStyle(){let t=0;for(;!this.bodyReached&&(t+=5e3,this.styleUntil(t,0)!=Number.POSITIVE_INFINITY););return this.rootStyle}getAttrStyle(t){if(t.style instanceof CSSStyleDeclaration){let e=t.getAttribute("style");if(e)return Qh(this.scope,this.validatorSet,this.xmldoc.url,e)}return{}}getReachedOffset(){return this.lastOffset}replayFlowElementsFromOffset(t){if(t>=this.lastOffset)return;let e=this.context,n=this.xmldoc.getElementOffset(this.root);if(t<n){let i=this.getStyle(this.root,!1);let a=de(i,"flow-into"),l=a?a.evaluate(e,"flow-into").toString():"body",c=this.encounteredFlowElement(l,i,this.root,n);this.boxStack.empty()&&this.boxStack.push(i,n,!0,c)}let s=this.xmldoc.getNodeByOffset(t),o=this.xmldoc.getNodeOffset(s,0,!1);if(!(o>=this.lastOffset))for(;;){if(s.nodeType!=1)o+=s.textContent.length;else{let a=s,l=this.getStyle(a,!1),c=l["flow-into"];if(c){let u=c.evaluate(e,"flow-into").toString();this.encounteredFlowElement(u,l,a,o)}o++}if(o>=this.lastOffset)break;let i=s.firstChild;if(i==null){for(;i=s.nextSibling,!i;)if(s=s.parentNode,s===this.root)return}s=i}}resetFlowChunkStream(t){this.flowListener=t;for(let e=0;e<this.flowChunks.length;e++)this.flowListener.encounteredFlowChunk(this.flowChunks[e],this.flows[this.flowChunks[e].flowName])}styleUntilFlowIsReached(t){this.flowToReach=t;let e=0;for(;!(this.flowToReach==null||(e+=5e3,this.styleUntil(e,0)==Number.POSITIVE_INFINITY)););}styleUntilIdIsReached(t){if(!t)return;this.idToReach=t;let e=0;for(;!(!this.idToReach||(e+=5e3,this.styleUntil(e,0)===Number.POSITIVE_INFINITY)););this.idToReach=null}encounteredFlowElement(t,e,n,s){let o=0,i=Number.POSITIVE_INFINITY,a=!1,l=!1,c=!1,u=e["flow-options"];if(u){let E=$p(u.evaluate(this.context,"flow-options"));a=!!E.exclusive,l=!!E.static,c=!!E.last}let p=e["flow-linger"];p&&(i=Ul(p.evaluate(this.context,"flow-linger"),Number.POSITIVE_INFINITY));let h=e["flow-priority"];h&&(o=Ul(h.evaluate(this.context,"flow-priority"),0));let f=this.breakBeforeValues[s]||null,g=this.flows[t];if(!g){let E=this.boxStack.lastFlowName();g=this.flows[t]=new Br(t,E)}let m=new Or(t,n,s,o,i,a,l,c,f);return this.flowChunks.push(m),this.flowToReach==t&&(this.flowToReach=null),this.flowListener&&this.flowListener.encounteredFlowChunk(m,g),m}registerForcedBreakOffset(t,e,n){if(De(t)){let o=this.flows[n].forcedBreakOffsets;(o.length===0||o[o.length-1]<e)&&o.push(e)}let s=this.breakBeforeValues[e];this.breakBeforeValues[e]=Ve(s,t)}styleUntil(t,e){let n=-1,s;if(t<=this.lastOffset&&(s=this.offsetMap.slippedByFixed(t),n=s+e,n<this.offsetMap.getMaxSlipped()))return this.offsetMap.fixedBySlipped(n);if(this.last==null)return Number.POSITIVE_INFINITY;let o=this.context;for(;;){let i=this.last.firstChild;if(i==null)for(;;){if(this.last.nodeType==1){this.cascade.popElement(this.last),this.primary=this.primaryStack.pop();let a=this.boxStack.pop(this.lastOffset),l=null;if(a.afterBox){let c=a.afterBox.getBreakValue("before");this.registerForcedBreakOffset(c,a.afterBox.atBlockStart?this.boxStack.nearestBlockStartOffset(a):a.afterBox.offset,a.flowName),l=a.afterBox.getBreakValue("after")}l=Ve(l,a.getBreakValue("after")),this.registerForcedBreakOffset(l,this.lastOffset,a.flowName)}if(i=this.last.nextSibling,i)break;if(this.last=this.last.parentNode,this.last===this.root)return this.last=null,t<this.lastOffset&&(n<0&&(s=this.offsetMap.slippedByFixed(t),n=s+e),n<=this.offsetMap.getMaxSlipped())?this.offsetMap.fixedBySlipped(n):Number.POSITIVE_INFINITY}if(this.last=i,this.last.nodeType!=1)this.lastOffset+=this.last.textContent.length,this.boxStack.encounteredTextNode(this.last),this.primary?this.offsetMap.addStuckRange(this.lastOffset):this.offsetMap.addSlippedRange(this.lastOffset);else{let a=this.last,l=this.getAttrStyle(a);this.primaryStack.push(this.primary),this.cascade.pushElement(this,a,l,this.lastOffset);let c=a.getAttribute("id")||a.getAttributeNS("http://www.w3.org/XML/1998/namespace","id");c&&c===this.idToReach&&(this.idToReach=null),!this.bodyReached&&a.localName=="body"&&a.parentNode==this.root&&(this.postprocessTopStyle(l,!0),this.bodyReached=!0);let u,p=l["flow-into"];if(p){let f=p.evaluate(o,"flow-into").toString(),g=this.encounteredFlowElement(f,l,a,this.lastOffset);this.primary=!!this.primaryFlows[f],u=this.boxStack.push(l,this.lastOffset,a===this.root,g)}else u=this.boxStack.push(l,this.lastOffset,a===this.root),a===this.xmldoc.body&&(u.breakBefore=Ve(u.flowChunk.breakBefore,u.breakBefore));let h=this.boxStack.nearestBlockStartOffset(u);if(h===0){let f=l.page,g=f&&!U(f.value)&&f.value.toString();g&&g.toLowerCase()!=="auto"&&(this.cascade.firstPageType=g)}if(this.registerForcedBreakOffset(u.breakBefore,h,u.flowName),u.beforeBox){let f=u.beforeBox.getBreakValue("after");this.registerForcedBreakOffset(f,u.beforeBox.atBlockStart?h:u.offset,u.flowName)}if(this.primary&&u.displayValue()===x.none&&(this.primary=!1),this.styleMap[`e${this.lastOffset}`]=l,this.lastOffset++,this.primary?this.offsetMap.addStuckRange(this.lastOffset):this.offsetMap.addSlippedRange(this.lastOffset),this.bodyReached&&h===0)continue;if(t<this.lastOffset&&(n<0&&(s=this.offsetMap.slippedByFixed(t),n=s+e),n<=this.offsetMap.getMaxSlipped()))return this.offsetMap.fixedBySlipped(n)}}}getStyle(t,e){let n=this.xmldoc.getElementOffset(t),s=`e${n}`;return e&&(n=this.xmldoc.getNodeOffset(t,0,!0)),this.lastOffset<=n&&this.styleUntil(n,0),this.styleMap[s]}processContent(t,e,n){}},wf=["column-count","column-width","column-fill"];var jn=class{constructor(t){this.validator=t;d(this,"success",null);d(this,"failure",null);d(this,"code",0)}isSpecial(){return this.code!=0}markAsStartGroup(){this.code=-1}isStartGroup(){return this.code==-1}markAsEndGroup(){this.code=-2}isEndGroup(){return this.code==-2}markAsStartAlternate(t){this.code=2*t+1}isStartAlternate(){return this.code>0&&this.code%2!=0}markAsEndAlternate(t){this.code=2*t+2}isEndAlternate(){return this.code>0&&this.code%2==0}getAlternate(){return Math.floor((this.code-1)/2)}},xn=class{constructor(t,e){this.where=t;this.success=e;d(this,"what",-1)}};var ks=class r{constructor(){d(this,"nodes",[]);d(this,"connections",[]);d(this,"match",[]);d(this,"nomatch",[]);d(this,"error",[]);d(this,"emptyHead",!0)}connect(t,e){for(let n=0;n<t.length;n++)this.connections[t[n]].what=e;t.splice(0,t.length)}clone(){let t=new r;for(let e=0;e<this.nodes.length;e++){let n=this.nodes[e],s=new jn(n.validator);s.code=n.code,t.nodes.push(s)}for(let e=0;e<this.connections.length;e++){let n=this.connections[e],s=new xn(n.where,n.success);s.what=n.what,t.connections.push(s)}return t.match.push(...this.match),t.nomatch.push(...this.nomatch),t.error.push(...this.error),t}addSpecialToArr(t,e,n){let s=this.nodes.length,o=new jn(Pf);n>=0?e?o.markAsStartAlternate(n):o.markAsEndAlternate(n):e?o.markAsStartGroup():o.markAsEndGroup(),this.nodes.push(o),this.connect(t,s);let i=new xn(s,!0),a=new xn(s,!1);t.push(this.connections.length),this.connections.push(a),t.push(this.connections.length),this.connections.push(i)}endSpecialGroup(){let t=[this.match,this.nomatch,this.error];for(let e=0;e<t.length;e++)this.addSpecialToArr(t[e],!1,-1)}startSpecialGroup(){if(this.nodes.length)throw new Error("invalid call");this.addSpecialToArr(this.match,!0,-1)}endClause(t){this.addSpecialToArr(this.match,!1,t)}startClause(t){if(this.nodes.length)throw new Error("invalid call");let e=new jn(Pf);e.markAsStartAlternate(t),this.nodes.push(e);let n=new xn(0,!0),s=new xn(0,!1);this.nomatch.push(this.connections.length),this.connections.push(s),this.match.push(this.connections.length),this.connections.push(n)}addPrimitive(t){let e=this.nodes.length;this.nodes.push(new jn(t));let n=new xn(e,!0),s=new xn(e,!1);this.connect(this.match,e),this.emptyHead?(this.nomatch.push(this.connections.length),this.emptyHead=!1):this.error.push(this.connections.length),this.connections.push(s),this.match.push(this.connections.length),this.connections.push(n)}isSimple(){return this.nodes.length==1&&!this.nodes[0].isSpecial()}isPrimitive(){return this.isSimple()&&this.nodes[0].validator instanceof Ce}addGroup(t,e){if(t.nodes.length==0)return;let n=this.nodes.length;if(e==4&&n==1&&t.isPrimitive()&&this.isPrimitive()){this.nodes[0].validator=this.nodes[0].validator.combine(t.nodes[0].validator);return}for(let o=0;o<t.nodes.length;o++)this.nodes.push(t.nodes[o]);e==4?(this.emptyHead=!0,this.connect(this.nomatch,n)):this.connect(this.match,n);let s=this.connections.length;for(let o=0;o<t.connections.length;o++){let i=t.connections[o];i.where+=n,i.what>=0&&(i.what+=n),this.connections.push(i)}for(let o=0;o<t.match.length;o++)this.match.push(t.match[o]+s);if(e==3&&this.connect(this.match,n),e==2||e==3)for(let o=0;o<t.nomatch.length;o++)this.match.push(t.nomatch[o]+s);else if(this.emptyHead){for(let o=0;o<t.nomatch.length;o++)this.nomatch.push(t.nomatch[o]+s);this.emptyHead=t.emptyHead}else for(let o=0;o<t.nomatch.length;o++)this.error.push(t.nomatch[o]+s);for(let o=0;o<t.error.length;o++)this.error.push(t.error[o]+s);t.nodes=null,t.connections=null}finish(t,e){let n=this.nodes.length;this.nodes.push(t),this.nodes.push(e),this.connect(this.match,n),this.connect(this.nomatch,n+1),this.connect(this.error,n+1);for(let s of this.connections)s.success?this.nodes[s.where].success=this.nodes[s.what]:this.nodes[s.where].failure=this.nodes[s.what];for(let s=0;s<n;s++)if(this.nodes[s].failure==null||this.nodes[s].success==null)throw new Error("Invalid validator state");return this.nodes[0]}},kC=1,Af=2,Lf=4,Ps=8,Sa=16,bd=32,Na=64,Rf=128,Ei=256,Si=512,yd=1024,If=2048,Vf=4096,Ff=8192,va=class extends at{constructor(){super()}validateForShorthand(t,e){let n=t[e].visit(this);return n?[n]:null}},Ce=class r extends va{constructor(e,n,s){super();this.allowed=e;this.idents=n;this.units=s}visitEmpty(e){return this.allowed&kC?e:null}visitSlash(e){return this.allowed&If?e:null}visitStr(e){return this.allowed&Af?e:null}visitIdent(e){let n=this.idents[e.name.toLowerCase()];return n||(this.allowed&Lf||this.allowed&Na&&CSS.supports("color",e.name)?e:null)}visitNumeric(e){return e.num==0&&!(this.allowed&Si)?e.unit=="%"&&this.allowed&yd?e:null:e.num<0&&!(this.allowed&Ei)?null:this.units[e.unit]?e:null}visitNum(e){return e.num==0?this.allowed&Si?e:null:e.num<=0&&!(this.allowed&Ei)?null:this.allowed&Sa?e:null}visitInt(e){if(e.num==0)return this.allowed&Si?e:null;if(e.num<=0&&!(this.allowed&Ei))return null;if(this.allowed&(bd|Sa))return e;let n=this.idents[`${e.num}`];return n||null}visitHexColor(e){return this.allowed&Na&&/^([0-9A-F]{3,4}|([0-9A-F]{2}){3,4})$/i.test(e.hex)?e:null}visitURL(e){return this.allowed&Rf?e:null}visitURange(e){return this.allowed&Vf?e:null}visitSpaceList(e){return null}visitCommaList(e){return null}visitFunc(e){return this.allowed&Na&&CSS.supports("color",e.toString())||this.allowed&Ff&&CSS.supports("background-image",e.toString())||e.name==="calc"&&this.allowed&(Ps|Sa|bd|Ei|Si|yd)?e:null}visitExpr(e){return this.allowed&2046?e:null}combine(e){let n={},s={};for(let o in this.idents)n[o]=this.idents[o];for(let o in e.idents)n[o]=e.idents[o];for(let o in this.units)s[o]=this.units[o];for(let o in e.units)s[o]=e.units[o];return new r(this.allowed|e.allowed,n,s)}},W={},Pf=new Ce(0,W,W),Ni=class extends va{constructor(e){super();d(this,"successTerminal");d(this,"failureTerminal");d(this,"first");this.successTerminal=new jn(null),this.failureTerminal=new jn(null),this.first=e.finish(this.successTerminal,this.failureTerminal)}validateList(e,n,s){let o=n?[]:e,i=this.first,a=s,l=null,c=null;for(;i!==this.successTerminal&&i!==this.failureTerminal;){if(a>=e.length){i=i.failure;continue}let u=e[a],p=u;if(i.isSpecial()){let h=!0;i.isStartGroup()?(l?l.push(c):l=[c],c=[]):i.isEndGroup()?l.length>0?c=l.pop():c=null:i.isEndAlternate()?c[i.getAlternate()]="taken":h=c[i.getAlternate()]==null,i=h?i.success:i.failure}else{if(a==0&&!n&&i.validator instanceof As&&this instanceof As){if(p=new q(e).visit(i.validator),p){a=e.length,i=i.success;continue}}else if(a==0&&!n&&i.validator instanceof vi&&this instanceof As){if(p=new ge(e).visit(i.validator),p){a=e.length,i=i.success;continue}}else p=u.visit(i.validator);if(!p){i=i.failure;continue}if(p!==u&&e===o){o=[];for(let h=0;h<a;h++)o[h]=e[h]}e!==o&&(o[a-s]=p),a++,i=i.success}}return i===this.successTerminal&&(n?o.length>0:a==e.length)?o:null}validateSingle(e){let n=null,s=this.first;for(;s!==this.successTerminal&&s!==this.failureTerminal;){if(!e){s=s.failure;continue}if(s.isSpecial()){s=s.success;continue}if(n=e.visit(s.validator),!n){s=s.failure;continue}e=null,s=s.success}return s===this.successTerminal?n:null}visitEmpty(e){return this.validateSingle(e)}visitSlash(e){return this.validateSingle(e)}visitStr(e){return this.validateSingle(e)}visitIdent(e){return this.validateSingle(e)}visitNumeric(e){return this.validateSingle(e)}visitNum(e){return this.validateSingle(e)}visitInt(e){return this.validateSingle(e)}visitHexColor(e){return this.validateSingle(e)}visitURL(e){return this.validateSingle(e)}visitURange(e){return this.validateSingle(e)}visitSpaceList(e){return null}visitCommaList(e){return null}visitFunc(e){return this.validateSingle(e)}visitExpr(e){return null}},As=class extends Ni{constructor(t){super(t)}visitSpaceList(t){let e=this.validateList(t.values,!1,0);return e===t.values?t:e?new q(e):null}visitCommaList(t){let e=this.first,n=!1;for(;e;){if(e.validator instanceof vi){n=!0;break}e=e.failure}if(n){let s=this.validateList(t.values,!1,0);return s===t.values?t:s?new ge(s):null}return null}validateForShorthand(t,e){return this.validateList(t,!0,e)}},vi=class extends Ni{constructor(t){super(t)}visitSpaceList(t){return this.validateSingle(t)}visitCommaList(t){let e=this.validateList(t.values,!1,0);return e===t.values?t:e?new ge(e):null}validateForShorthand(t,e){let n=this.first,s;for(;n!==this.failureTerminal;){if(s=n.validator.validateForShorthand(t,e),s)return s;n=n.failure}return null}},xd=class extends Ni{constructor(e,n){super(n);this.name=e}validateSingle(e){return null}visitFunc(e){if(e.name.toLowerCase()!=this.name)return null;let n=this.validateList(e.values,!1,0);return n===e.values?e:n?new Pt(e.name,n):null}},Ta=class{tryParse(t,e,n){return e}success(t,e){}},wa=class extends Ta{constructor(e,n){super();this.name=n;d(this,"validator");this.validator=e.validators[this.name]}tryParse(e,n,s){if(s.values[this.name])return n;let o=this.validator.validateForShorthand(e,n);if(o){let i=o.length,a=i>1?new q(o):o[0];return this.success(a,s),n+i}return n}success(e,n){n.values[this.name]=e}},Ed=class extends wa{constructor(e,n){super(e,n[0]);this.names=n}success(e,n){for(let s=0;s<this.names.length;s++)n.values[this.names[s]]=e}},Sd=class extends Ta{constructor(e,n){super();this.nodes=e;this.slash=n}tryParse(e,n,s){let o=n;if(this.slash)if(e[n]==$s){if(++n==e.length)return o}else return o;let i=this.nodes[0].tryParse(e,n,s);if(i==n)return o;n=i;for(let a=1;a<this.nodes.length&&n<e.length&&(i=this.nodes[a].tryParse(e,n,s),i!=n);a++)n=i;return n}},Ti=class extends at{constructor(){super(...arguments);d(this,"syntax",null);d(this,"propList",null);d(this,"error",!1);d(this,"values",{});d(this,"validatorSet",null)}setOwner(e){this.validatorSet=e}syntaxNodeForProperty(e){return new wa(this.validatorSet,e)}clone(){let e=new this.constructor;return e.syntax=this.syntax,e.propList=this.propList,e.validatorSet=this.validatorSet,e}init(e,n){this.syntax=e,this.propList=n}finish(e,n){var s,o;if(!this.error){for(let i of this.propList)n.simpleProperty(i,(o=(s=this.values[i])!=null?s:this.validatorSet.defaultValues[i])!=null?o:x.initial,e);return!0}return!1}propagateDefaultingValue(e,n,s){for(let o of this.propList)s.simpleProperty(o,e,n)}validateList(e){return this.error=!0,0}validateSingle(e){return this.validateList([e]),null}visitEmpty(e){return this.validateSingle(e)}visitStr(e){return this.validateSingle(e)}visitIdent(e){return this.validateSingle(e)}visitNumeric(e){return this.validateSingle(e)}visitNum(e){return this.validateSingle(e)}visitInt(e){return this.validateSingle(e)}visitHexColor(e){return this.validateSingle(e)}visitURL(e){return this.validateSingle(e)}visitSpaceList(e){return this.validateList(e.values),null}visitCommaList(e){return this.error=!0,null}visitFunc(e){return this.validateSingle(e)}visitExpr(e){return this.validateSingle(e)}},Yn=class extends Ti{constructor(){super()}validateList(t){let e=0,n=0;for(;e<t.length;){let s=this.syntax[n].tryParse(t,e,this);if(s>e){e=s,n=0;continue}if(++n==this.syntax.length){this.error=!0;break}}return e}},Pa=class extends Ti{constructor(){super()}validateList(t){if(t.length>this.syntax.length||t.length==0)return this.error=!0,0;for(let e=0;e<this.syntax.length;e++){let n=e;for(;n>=t.length;)n=n==1?0:n-2;if(this.syntax[e].tryParse(t,n,this)!=n+1)return this.error=!0,0}return t.length}createSyntaxNode(){return new Ed(this.validatorSet,this.propList)}},Nd=class extends Ti{constructor(){super()}validateList(t){let e=t.length;for(let n=0;n<t.length;n++)if(t[n]===$s){e=n;break}if(e>this.syntax.length||t.length==0)return this.error=!0,0;for(let n=0;n<this.syntax.length;n++){let s=n;for(;s>=e;)s=s==1?0:s-2;let o;if(e+1<t.length)for(o=e+n+1;o>=t.length;)o=o-(o==e+2?1:2);else o=s;let i=[t[s],t[o]];if(this.syntax[n].tryParse(i,0,this)!=2)return this.error=!0,0}return t.length}},vd=class extends Yn{constructor(){super()}mergeIn(t,e){var n,s;for(let o of this.propList){let i=(s=(n=e[o])!=null?n:this.validatorSet.defaultValues[o])!=null?s:x.initial,a=t[o];a||(a=[],t[o]=a),a.push(i)}}visitCommaList(t){let e={};for(let n=0;n<t.values.length;n++)if(this.values={},t.values[n]instanceof ge?this.error=!0:(t.values[n].visit(this),this.mergeIn(e,this.values),this.values["background-color"]&&n!=t.values.length-1&&(this.error=!0)),this.error)return null;this.values={};for(let n in e)n=="background-color"?this.values[n]=e[n].pop():this.values[n]=new ge(e[n]);return null}},Td=class extends Yn{constructor(){super()}init(t,e){super.init(t,e),this.propList.push("font-family","line-height","font-size","font-stretch","font-variant-ligatures","font-variant-caps","font-variant-numeric","font-variant-east-asian")}validateList(t){let e=super.validateList(t),n=this.values["font-variant_css2"];n&&(delete this.values["font-variant_css2"],this.values["font-variant-caps"]=n);let s=this.values["font-stretch_css3"];if(s&&(delete this.values["font-stretch_css3"],this.values["font-stretch"]=s),e+2>t.length)return this.error=!0,e;this.error=!1;let o=this.validatorSet.validators;if(!t[e].visit(o["font-size"]))return this.error=!0,e;if(this.values["font-size"]=t[e++],t[e]===$s){if(e++,e+2>t.length)return this.error=!0,e;if(!t[e].visit(o["line-height"]))return this.error=!0,e;this.values["line-height"]=t[e++]}let i=e==t.length-1?t[e]:new q(t.slice(e,t.length));return i.visit(o["font-family"])?(this.values["font-family"]=i,t.length):(this.error=!0,e)}visitCommaList(t){if(t.values[0].visit(this),this.error)return null;let e=[this.values["font-family"]];for(let s=1;s<t.values.length;s++)e.push(t.values[s]);let n=new ge(e);return n.visit(this.validatorSet.validators["font-family"])?this.values["font-family"]=n:this.error=!0,null}visitIdent(t){let e=this.validatorSet.systemFonts[t.name];if(e)for(let n in e)this.values[n]=e[n];else this.error=!0;return null}},wd=class extends Yn{validateList(t){if(t.length===1&&t[0]instanceof Be)switch(t[0].name.toLowerCase()){case"normal":t=[this.validatorSet.defaultValues["text-autospace"],this.validatorSet.defaultValues["text-spacing-trim"]];break;case"auto":t=[x.auto,x.auto];break;case"none":t=[L("no-autospace"),L("space-all")];break}return super.validateList(t)}},AC=["unicode-bidi","direction","margin-block-start","margin-block-end","margin-inline-start","margin-inline-end","padding-block-start","padding-block-end","padding-inline-start","padding-inline-end","border-block-start-color","border-block-end-color","border-inline-start-color","border-inline-end-color","border-block-start-style","border-block-end-style","border-inline-start-style","border-inline-end-style","border-block-start-width","border-block-end-width","border-inline-start-width","border-inline-end-width","block-start","block-end","inline-start","inline-end","block-size","inline-size","max-block-size","max-inline-size","min-block-size","min-inline-size","behavior","bleed","conflicting-partitions","crop-offset","enabled","flow-consume","flow-from","flow-into","flow-linger","flow-options","flow-priority","font-display","font-size-adjust","font-stretch_css3","font-variant_css2","glyph-orientation-vertical","marks","min-page-height","min-page-width","repeat-on-break","required","required-partitions","ruby-align","shape-inside","snap-height","snap-width","template","text-decoration-skip","text-justify","text-zoom","unicode-range","utilization","wrap-flow"],Pd=class extends Yn{constructor(){super()}init(t,e){super.init(t,e);for(let n in this.validatorSet.validators)AC.includes(n)||this.propList.push(n)}validateList(t){return this.error=!0,0}},kf={SIMPLE:Yn,INSETS:Pa,INSETS_SLASH:Nd,COMMA:vd,FONT:Td,TEXT_SPACING:wd,ALL:Pd},kd=class{constructor(){d(this,"validators",{});d(this,"prefixes",{});d(this,"defaultValues",{});d(this,"namedValidators",{});d(this,"systemFonts",{});d(this,"shorthands",{});d(this,"layoutProps",{});d(this,"backgroundProps",{})}addReplacement(t,e){let n;if(e.type==3)n=new P(e.num,e.text);else if(e.type==7)n=new Xs(e.text);else if(e.type==1)n=L(e.text);else throw new Error("unexpected replacement");if(t.isPrimitive()){let o=t.nodes[0].validator.idents;for(let i in o)o[i]=n;return t}throw new Error("unexpected replacement")}newGroup(t,e){let n=new ks;if(t=="||"){for(let o=0;o<e.length;o++){let i=new ks;i.startClause(o),i.addGroup(e[o],1),i.endClause(o),n.addGroup(i,o==0?1:4)}let s=new ks;return s.startSpecialGroup(),s.addGroup(n,3),s.endSpecialGroup(),s}else{let s;switch(t){case" ":s=1;break;case"|":case"||":s=4;break;default:throw new Error("unexpected op")}for(let o=0;o<e.length;o++)n.addGroup(e[o],o==0?1:s);return n}}addCounts(t,e,n){let s=new ks;for(let o=0;o<e;o++)s.addGroup(t.clone(),1);if(n==Number.POSITIVE_INFINITY)s.addGroup(t,3);else for(let o=e;o<n;o++)s.addGroup(t.clone(),2);return s}primitive(t){let e=new ks;return e.addPrimitive(t),e}newFunc(t,e){let n;switch(t){case"COMMA":n=new vi(e);break;case"SPACE":n=new As(e);break;default:n=new xd(t.toLowerCase(),e);break}return this.primitive(n)}initBuiltInValidators(){this.namedValidators.COLOR=this.primitive(new Ce(Na,W,W)),this.namedValidators.IMAGE_FUNCTION=this.primitive(new Ce(Ff,W,W)),this.namedValidators.POS_INT=this.primitive(new Ce(bd,W,W)),this.namedValidators.POS_NUM=this.primitive(new Ce(Sa,W,W)),this.namedValidators.POS_PERCENTAGE=this.primitive(new Ce(Ps,W,{"%":O})),this.namedValidators.NEGATIVE=this.primitive(new Ce(Ei,W,W)),this.namedValidators.ZERO=this.primitive(new Ce(Si,W,W)),this.namedValidators.ZERO_PERCENTAGE=this.primitive(new Ce(yd,W,W)),this.namedValidators.POS_LENGTH=this.primitive(new Ce(Ps,W,{em:O,ex:O,ch:O,rem:O,lh:O,rlh:O,vw:O,vh:O,vi:O,vb:O,vmin:O,vmax:O,pvw:O,pvh:O,pvi:O,pvb:O,pvmin:O,pvmax:O,cm:O,mm:O,in:O,px:O,pt:O,pc:O,q:O})),this.namedValidators.POS_ANGLE=this.primitive(new Ce(Ps,W,{deg:O,grad:O,rad:O,turn:O})),this.namedValidators.POS_TIME=this.primitive(new Ce(Ps,W,{s:O,ms:O})),this.namedValidators.FREQUENCY=this.primitive(new Ce(Ps,W,{Hz:O,kHz:O})),this.namedValidators.RESOLUTION=this.primitive(new Ce(Ps,W,{dpi:O,dpcm:O,dppx:O})),this.namedValidators.URI=this.primitive(new Ce(Rf,W,W)),this.namedValidators.URANGE=this.primitive(new Ce(Vf,W,W)),this.namedValidators.IDENT=this.primitive(new Ce(Lf,W,W)),this.namedValidators.STRING=this.primitive(new Ce(Af,W,W)),this.namedValidators.SLASH=this.primitive(new Ce(If,W,W));let t={"font-family":L("sans-serif")};this.systemFonts.caption=t,this.systemFonts.icon=t,this.systemFonts.menu=t,this.systemFonts["message-box"]=t,this.systemFonts["small-caption"]=t,this.systemFonts["status-bar"]=t}isBuiltIn(t){return!!t.match(/^[A-Z_0-9]+$/)}readNameAndPrefixes(t,e){let n=t.token();if(n.type==0)return null;let s={"":!0};if(n.type==14){do{if(t.consume(),n=t.token(),n.type!=1)throw new Error("Prefix name expected");s[n.text]=!0,t.consume(),n=t.token()}while(n.type==16);if(n.type!=15)throw new Error("']' expected");t.consume(),n=t.token()}if(n.type!=1)throw new Error("Property name expected");if(e==2?n.text=="SHORTHANDS":n.text=="DEFAULTS")return t.consume(),null;let o=n.text;if(t.consume(),e!=2){if(t.token().type!=39)throw new Error("'=' expected");this.isBuiltIn(o)||(this.prefixes[o]=s)}else if(t.token().type!=18)throw new Error("':' expected");return o}parseValidators(t){for(;;){let e=this.readNameAndPrefixes(t,1);if(!e)return;let n=[],s=[],o="",i,a=!0,l=()=>{if(n.length==0)throw new Error("No values");return n.length==1?n[0]:this.newGroup(o,n)},c=p=>{if(a)throw new Error(`'${p}': unexpected`);if(o&&o!=p)throw new Error(`mixed operators: '${p}' and '${o}'`);o=p,a=!0},u=null;for(;!u;){t.consume();let p=t.token();switch(p.type){case 1:if(a||c(" "),this.isBuiltIn(p.text)){let h=this.namedValidators[p.text];if(!h)throw new Error(`'${p.text}' unexpected`);n.push(h.clone())}else{let h={};h[p.text.toLowerCase()]=L(p.text),n.push(this.primitive(new Ce(0,h,W)))}a=!1;break;case 5:{let h={};h[`${p.num}`]=new ct(p.num),n.push(this.primitive(new Ce(0,h,W))),a=!1;break}case 34:c("|");break;case 25:c("||");break;case 14:a||c(" "),s.push({vals:n,op:o,b:"["}),o="",n=[],a=!0;break;case 6:a||c(" "),s.push({vals:n,op:o,b:"(",fn:p.text}),o="",n=[],a=!0;break;case 15:{i=l();let h=s.pop();if(h.b!="[")throw new Error("']' unexpected");n=h.vals,n.push(i),o=h.op,a=!1;break}case 11:{i=l();let h=s.pop();if(h.b!="(")throw new Error("')' unexpected");n=h.vals,n.push(this.newFunc(h.fn,i)),o=h.op,a=!1;break}case 18:if(a)throw new Error("':' unexpected");t.consume(),n.push(this.addReplacement(n.pop(),t.token()));break;case 22:if(a)throw new Error("'?' unexpected");n.push(this.addCounts(n.pop(),0,1));break;case 36:if(a)throw new Error("'*' unexpected");n.push(this.addCounts(n.pop(),0,Number.POSITIVE_INFINITY));break;case 23:if(a)throw new Error("'+' unexpected");n.push(this.addCounts(n.pop(),1,Number.POSITIVE_INFINITY));break;case 12:{if(t.consume(),p=t.token(),p.type!=5)throw new Error("<int> expected");let h=p.num,f=h;if(t.consume(),p=t.token(),p.type==16){if(t.consume(),p=t.token(),p.type!=5)throw new Error("<int> expected");f=p.num,t.consume(),p=t.token()}if(p.type!=13)throw new Error("'}' expected");n.push(this.addCounts(n.pop(),h,f));break}case 17:if(u=l(),s.length>0)throw new Error(`unclosed '${s.pop().b}'`);break;default:throw new Error("unexpected token")}}t.consume(),this.isBuiltIn(e)?this.namedValidators[e]=u:u.isSimple()?this.validators[e]=u.nodes[0].validator:this.validators[e]=new As(u)}}parseDefaults(t){for(;;){let e=this.readNameAndPrefixes(t,2);if(!e)return;let n=[];for(;;){t.consume();let s=t.token();if(s.type==17){t.consume();break}switch(s.type){case 1:n.push(L(s.text));break;case 4:n.push(new lt(s.num));break;case 5:n.push(new ct(s.num));break;case 3:n.push(new P(s.num,s.text));break;default:throw new Error("unexpected token")}}this.defaultValues[e]=n.length>1?new q(n):n[0]}}parseShorthands(t){for(;;){let e=this.readNameAndPrefixes(t,3);if(!e)return;let n=t.nthToken(1),s;n.type==1&&kf[n.text]?(s=new kf[n.text],t.consume()):s=new Yn,s.setOwner(this);let o=!1,i=[],a=!1,l=[],c=[];for(;!o;)switch(t.consume(),n=t.token(),n.type){case 1:if(this.validators[n.text])i.push(s.syntaxNodeForProperty(n.text)),n.text.includes("_")||c.push(n.text);else if(this.shorthands[n.text]instanceof Pa){let u=this.shorthands[n.text];i.push(u.createSyntaxNode()),c.push(...u.propList)}else throw new Error(`'${n.text}' is neither a simple property nor an inset shorthand`);break;case 19:if(i.length>0||a)throw new Error("unexpected slash");a=!0;break;case 14:l.push({slash:a,syntax:i}),i=[],a=!1;break;case 15:{let u=new Sd(i,a),p=l.pop();i=p.syntax,a=p.slash,i.push(u);break}case 17:o=!0,t.consume();break;default:throw new Error("unexpected token")}s.init(i,c),this.shorthands[e]=s}}parse(t){let e=new Oe(t,null);this.parseValidators(e),this.parseDefaults(e),this.parseShorthands(e),this.backgroundProps=this.makePropSet(["background"]),this.layoutProps=this.makePropSet(["margin","border","padding","columns","column-gap","column-rule","column-fill"])}makePropSet(t){var n;let e={};for(let s of t){let o=this.shorthands[s],i=o?o.propList:[s];for(let a of i)e[a]=(n=this.defaultValues[a])!=null?n:x.initial}return e}validatePropertyAndHandleShorthand(t,e,n,s){if(bt(t)||s.ruleType==="font-face"||LC(e)){s.simpleProperty(t,e,n);return}let o="",i=t;t=t.toLowerCase();let a=t.match(/^-([a-z]+)-([-a-z0-9]+)$/);a&&(o=a[1],t=a[2]);let l=this.prefixes[t];if(!l||!l[o]){CSS.supports(t,e.toString())?s.simpleProperty(i,e,n):s.unknownProperty(i,e);return}let c=this.validators[t];if(c){let u=U(e)||e.isExpr()?e:e.visit(c);u?s.simpleProperty(t,u,n):!o&&CSS.supports(t,e.toString())?s.simpleProperty(t,e,n):s.invalidPropertyValue(i,e)}else{let u=this.shorthands[t].clone();U(e)?u.propagateDefaultingValue(e,n,s):(e.visit(u),u.finish(n,s)||s.invalidPropertyValue(i,e))}}};function Ld(){let r=new kd;return r.initBuiltInValidators(),r.parse(ac),r}var Ad=class extends at{constructor(){super(...arguments);d(this,"varFound",!1)}visitFunc(e){return e.name==="var"?this.varFound=!0:this.varFound||this.visitValues(e.values),null}};function LC(r){let t=new Ad;return r.visit(t),t.varFound}var wi={"font-style":x.auto,"font-stretch":x.auto,"font-weight":x.auto,"unicode-range":Bp},Oy=`OTTO${new Date().valueOf()}`;function IC(r){let t=new je;for(let e in wi)t.append(" "),t.append(r[e].toString());return t.toString()}function VC(r){for(let t in wi)r[t]||(r[t]=wi[t])}function Of(r,t){let e={};for(let n in r)e[n]=de(r,n).evaluate(t,n);return VC(e),e}var Pi=class{constructor(t){this.properties=t;d(this,"fontTraitKey");d(this,"src");d(this,"blobURLs",[]);d(this,"blobs",[]);d(this,"family");this.fontTraitKey=IC(this.properties),this.src=this.properties.src?this.properties.src.toString():null;let e=this.properties["font-family"];this.family=e?e.stringValue():null}traitsEqual(t){return this.fontTraitKey==t.fontTraitKey}makeAtRule(t,e){let n=new je;n.append(`@font-face {
|
|
1479
1479
|
font-family: `),n.append(this.family),n.append(`;
|
|
1480
1480
|
`);for(let s in wi)n.append(s),n.append(": "),this.properties[s].appendTo(n,!0),n.append(`;
|
|
1481
1481
|
`);if(e){n.append('src: url("');let s=Jp(e);n.append(s),this.blobURLs.push(s),this.blobs.push(e),n.append('")')}else n.append("src: "),n.append(t);return n.append(`;
|