orz-paged-browser 0.1.0 → 0.3.0

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.
@@ -1521,4 +1521,4 @@ ${M.join(`
1521
1521
  height: 100% !important;
1522
1522
  }
1523
1523
  }
1524
- `;b();async function Lo(e,t={}){return new Promise(function(r,a){let n=new XMLHttpRequest;n.open(t.method||"get",e,!0);for(let i in t.headers)n.setRequestHeader(i,t.headers[i]);n.withCredentials=t.credentials==="include",n.onload=()=>{let i=n.status===0&&e.startsWith("file://")?200:n.status;r(new Response(n.responseText,{status:i}))},n.onerror=a,n.send(t.body||null)})}var Sd=class{constructor(t){this.sheets=[],this.inserted=[],this.hooks={},this.hooks.onUrl=new ue(this),this.hooks.onAtPage=new ue(this),this.hooks.onAtMedia=new ue(this),this.hooks.onRule=new ue(this),this.hooks.onDeclaration=new ue(this),this.hooks.onContent=new ue(this),this.hooks.onSelector=new ue(this),this.hooks.onPseudoSelector=new ue(this),this.hooks.onImport=new ue(this),this.hooks.beforeTreeParse=new ue(this),this.hooks.beforeTreeWalk=new ue(this),this.hooks.afterTreeWalk=new ue(this),t!==!1&&this.setup()}setup(){return this.base=this.insert(t3),this.styleEl=document.createElement("style"),document.head.appendChild(this.styleEl),this.styleSheet=this.styleEl.sheet,this.styleSheet}async add(){let t=[],r=[];for(var a=0;a<arguments.length;a++){let n;if(typeof arguments[a]=="object")for(let i in arguments[a]){let l=arguments[a];n=new Promise(function(c,d){r.push(i),c(l[i])})}else r.push(arguments[a]),n=Lo(arguments[a]).then(i=>i.text());t.push(n)}return await Promise.all(t).then(async n=>{let i="";for(let l=0;l<n.length;l++)i=await this.convertViaSheet(n[l],r[l]),this.insert(i);return i})}async convertViaSheet(t,r){let a=new e3(r,this.hooks);await a.parse(t);for(let n of a.imported){let i=await Lo(n).then(c=>c.text()),l=await this.convertViaSheet(i,n);this.insert(l)}return this.sheets.push(a),typeof a.width<"u"&&(this.width=a.width),typeof a.height<"u"&&(this.height=a.height),typeof a.orientation<"u"&&(this.orientation=a.orientation),a.toString()}insert(t){let r=document.querySelector("head"),a=document.createElement("style");return a.setAttribute("data-pagedjs-inserted-styles","true"),a.appendChild(document.createTextNode(t)),r.appendChild(a),this.inserted.push(a),a}destroy(){this.styleEl.remove(),this.inserted.forEach(t=>{t.remove()}),this.sheets=[]}},zd=Sd;b();var r6=He(aa(),1);b();b();b();b();var r3=He(aa(),1),Po=class{constructor(t,r,a){let n=Object.assign({},t&&t.hooks,r&&r.hooks,a&&a.hooks);this.chunker=t,this.polisher=r,this.caller=a;for(let i in n)i in this&&n[i].register(this[i].bind(this))}};(0,r3.default)(Po.prototype);var xe=Po;var ce=He(bt(),1);b();var Cd={A0:{width:{value:841,unit:"mm"},height:{value:1189,unit:"mm"}},A1:{width:{value:594,unit:"mm"},height:{value:841,unit:"mm"}},A2:{width:{value:420,unit:"mm"},height:{value:594,unit:"mm"}},A3:{width:{value:297,unit:"mm"},height:{value:420,unit:"mm"}},A4:{width:{value:210,unit:"mm"},height:{value:297,unit:"mm"}},A5:{width:{value:148,unit:"mm"},height:{value:210,unit:"mm"}},A6:{width:{value:105,unit:"mm"},height:{value:148,unit:"mm"}},A7:{width:{value:74,unit:"mm"},height:{value:105,unit:"mm"}},A8:{width:{value:52,unit:"mm"},height:{value:74,unit:"mm"}},A9:{width:{value:37,unit:"mm"},height:{value:52,unit:"mm"}},A10:{width:{value:26,unit:"mm"},height:{value:37,unit:"mm"}},B4:{width:{value:250,unit:"mm"},height:{value:353,unit:"mm"}},B5:{width:{value:176,unit:"mm"},height:{value:250,unit:"mm"}},letter:{width:{value:8.5,unit:"in"},height:{value:11,unit:"in"}},legal:{width:{value:8.5,unit:"in"},height:{value:14,unit:"in"}},ledger:{width:{value:11,unit:"in"},height:{value:17,unit:"in"}}};var Ad=class extends xe{constructor(t,r,a){super(t,r,a),this.pages={},this.width=void 0,this.height=void 0,this.orientation=void 0,this.marginalia={}}pageModel(t){return{selector:t,name:void 0,psuedo:void 0,nth:void 0,marginalia:{},width:void 0,height:void 0,orientation:void 0,margin:{top:{},right:{},left:{},bottom:{}},padding:{top:{},right:{},left:{},bottom:{}},border:{top:{},right:{},left:{},bottom:{}},backgroundOrigin:void 0,block:{},marks:void 0,notes:void 0,added:!1}}onAtPage(t,r,a){let n,i,l="",c,d,h,k=!1;t.prelude?(c=this.getTypeSelector(t),d=this.getPsuedoSelector(t),h=this.getNthSelector(t),l=ce.default.generate(t.prelude)):l="*",l in this.pages?(n=this.pages[l],i=this.replaceMarginalia(t),k=!0,n.added=!1):(n=this.pageModel(l),i=this.replaceMarginalia(t),this.pages[l]=n),n.name=c,n.psuedo=d,n.nth=h,k?n.marginalia=Object.assign(n.marginalia,i):n.marginalia=i;let x=this.replaceNotes(t);n.notes=x;let p=this.replaceDeclarations(t);if(p.size&&(n.size=p.size,n.width=p.size.width,n.height=p.size.height,n.orientation=p.size.orientation,n.format=p.size.format),p.bleed&&p.bleed[0]!="auto")switch(p.bleed.length){case 4:n.bleed={top:p.bleed[0],right:p.bleed[1],bottom:p.bleed[2],left:p.bleed[3]};break;case 3:n.bleed={top:p.bleed[0],right:p.bleed[1],bottom:p.bleed[2],left:p.bleed[1]};break;case 2:n.bleed={top:p.bleed[0],right:p.bleed[1],bottom:p.bleed[0],left:p.bleed[1]};break;default:n.bleed={top:p.bleed[0],right:p.bleed[0],bottom:p.bleed[0],left:p.bleed[0]}}p.marks&&((!p.bleed||p.bleed&&p.bleed[0]==="auto")&&(n.bleed={top:{value:6,unit:"mm"},right:{value:6,unit:"mm"},bottom:{value:6,unit:"mm"},left:{value:6,unit:"mm"}}),n.marks=p.marks),p.margin&&(n.margin=p.margin),p.padding&&(n.padding=p.padding),p.border&&(n.border=p.border),p.marks&&(n.marks=p.marks),k?n.block.children.appendList(t.block.children):n.block=t.block,a.remove(r)}afterTreeWalk(t,r){let a="*"in this.pages&&this.pages["*"].added===!1;if(this.addPageClasses(this.pages,t,r),a){let n=this.pages["*"].width,i=this.pages["*"].height,l=this.pages["*"].format,c=this.pages["*"].orientation,d=this.pages["*"].bleed,h=this.pages["*"].marks,k,x;":left"in this.pages&&(k=this.pages[":left"].bleed),":right"in this.pages&&(x=this.pages[":right"].bleed),n&&i&&(this.width!==n||this.height!==i)&&(this.width=n,this.height=i,this.format=l,this.orientation=c,this.addRootVars(t,n,i,c,d,x,k,h),this.addRootPage(t,this.pages["*"].size,d,x,k),this.emit("size",{width:n,height:i,orientation:c,format:l,bleed:d}),this.emit("atpages",this.pages))}}getTypeSelector(t){let r;return ce.default.walk(t,{visit:"TypeSelector",enter:(a,n,i)=>{r=a.name}}),r}getPsuedoSelector(t){let r;return ce.default.walk(t,{visit:"PseudoClassSelector",enter:(a,n,i)=>{a.name!=="nth"&&(r=a.name)}}),r}getNthSelector(t){let r;return ce.default.walk(t,{visit:"PseudoClassSelector",enter:(a,n,i)=>{a.name==="nth"&&a.children&&(r=a.children.first().value)}}),r}replaceMarginalia(t){let r={},a=["top-left-corner","top-left","top","top-center","top-right","top-right-corner","bottom-left-corner","bottom-left","bottom","bottom-center","bottom-right","bottom-right-corner","left-top","left-middle","left","left-bottom","top-right-corner","right-top","right-middle","right","right-bottom","right-right-corner"];return ce.default.walk(t.block,{visit:"Atrule",enter:(n,i,l)=>{let c=n.name;a.includes(c)&&(c==="top"&&(c="top-center"),c==="right"&&(c="right-middle"),c==="left"&&(c="left-middle"),c==="bottom"&&(c="bottom-center"),r[c]=n.block,l.remove(i))}}),r}replaceNotes(t){let r={};return ce.default.walk(t.block,{visit:"Atrule",enter:(a,n,i)=>{let l=a.name;l==="footnote"&&(r[l]=a.block,i.remove(n))}}),r}replaceDeclarations(t){let r={};return ce.default.walk(t.block,{visit:"Declaration",enter:(a,n,i)=>{let l=ce.default.property(a.property).name;if(l==="marks")r.marks=[],ce.default.walk(a,{visit:"Identifier",enter:c=>{r.marks.push(c.name)}}),i.remove(n);else if(l==="margin")r.margin=this.getMargins(a),i.remove(n);else if(l.indexOf("margin-")===0){let c=l.substring(7);r.margin||(r.margin={top:{},right:{},left:{},bottom:{}}),r.margin[c]=a.value.children.first(),i.remove(n)}else if(l==="padding")r.padding=this.getPaddings(a.value),i.remove(n);else if(l.indexOf("padding-")===0){let c=l.substring(8);r.padding||(r.padding={top:{},right:{},left:{},bottom:{}}),r.padding[c]=a.value.children.first(),i.remove(n)}else if(l==="border")r.border||(r.border={top:{},right:{},left:{},bottom:{}}),r.border.top=ce.default.generate(a.value),r.border.right=ce.default.generate(a.value),r.border.left=ce.default.generate(a.value),r.border.bottom=ce.default.generate(a.value),i.remove(n);else if(l.indexOf("border-")===0){r.border||(r.border={top:{},right:{},left:{},bottom:{}});let c=l.substring(7);r.border[c]=ce.default.generate(a.value),i.remove(n)}else l==="size"?(r.size=this.getSize(a),i.remove(n)):l==="bleed"&&(r.bleed=[],ce.default.walk(a,{enter:c=>{switch(c.type){case"String":c.value.indexOf("auto")>-1&&r.bleed.push("auto");break;case"Dimension":r.bleed.push({value:c.value,unit:c.unit});break;case"Number":r.bleed.push({value:c.value,unit:"px"});break;default:}}}),i.remove(n))}}),r}getSize(t){let r,a,n,i;return ce.default.walk(t,{visit:"Dimension",enter:(l,c,d)=>{let{value:h,unit:k}=l;typeof r>"u"?r={value:h,unit:k}:typeof a>"u"&&(a={value:h,unit:k})}}),ce.default.walk(t,{visit:"String",enter:(l,c,d)=>{let h=l.value.replace(/["|']/g,""),k=Cd[h];k&&(r=k.width,a=k.height)}}),ce.default.walk(t,{visit:"Identifier",enter:(l,c,d)=>{let h=l.name;if(h==="landscape"||h==="portrait")n=l.name;else if(h!=="auto"){let k=Cd[h];k&&(r=k.width,a=k.height),i=h}}}),{width:r,height:a,orientation:n,format:i}}getMargins(t){let r=[],a={top:{},right:{},left:{},bottom:{}};if(ce.default.walk(t,{enter:n=>{switch(n.type){case"Dimension":r.push(n);break;case"Number":r.push({value:n.value,unit:"px"});break;default:}}}),r.length===1)for(let n in a)a[n]=r[0];else r.length===2?(a.top=r[0],a.right=r[1],a.bottom=r[0],a.left=r[1]):r.length===3?(a.top=r[0],a.right=r[1],a.bottom=r[2],a.left=r[1]):r.length===4&&(a.top=r[0],a.right=r[1],a.bottom=r[2],a.left=r[3]);return a}getPaddings(t){let r=[],a={top:{},right:{},left:{},bottom:{}};if(ce.default.walk(t,{enter:n=>{switch(n.type){case"Dimension":r.push(n);break;case"Number":r.push({value:n.value,unit:"px"});break;default:}}}),r.length===1)for(let n in a)a[n]=r[0];else r.length===2?(a.top=r[0],a.right=r[1],a.bottom=r[0],a.left=r[1]):r.length===3?(a.top=r[0],a.right=r[1],a.bottom=r[2],a.left=r[1]):r.length===4&&(a.top=r[0],a.right=r[1],a.bottom=r[2],a.left=r[3]);return a}getBorders(t){let r={top:{},right:{},left:{},bottom:{}};return t.prop=="border"?(r.top=ce.default.generate(t.value),r.right=ce.default.generate(t.value),r.bottom=ce.default.generate(t.value),r.left=ce.default.generate(t.value)):t.prop=="border-top"?r.top=ce.default.generate(t.value):t.prop=="border-right"?r.right=ce.default.generate(t.value):t.prop=="border-bottom"?r.bottom=ce.default.generate(t.value):t.prop=="border-left"&&(r.left=ce.default.generate(t.value)),r}addPageClasses(t,r,a){if("*"in t&&t["*"].added===!1){let n=this.createPage(t["*"],r.children,a);a.insertRule(n),t["*"].added=!0}if(":left"in t&&t[":left"].added===!1){let n=this.createPage(t[":left"],r.children,a);a.insertRule(n),t[":left"].added=!0}if(":right"in t&&t[":right"].added===!1){let n=this.createPage(t[":right"],r.children,a);a.insertRule(n),t[":right"].added=!0}if(":first"in t&&t[":first"].added===!1){let n=this.createPage(t[":first"],r.children,a);a.insertRule(n),t[":first"].added=!0}if(":blank"in t&&t[":blank"].added===!1){let n=this.createPage(t[":blank"],r.children,a);a.insertRule(n),t[":blank"].added=!0}for(let n in t)if(t[n].nth&&t[n].added===!1){let i=this.createPage(t[n],r.children,a);a.insertRule(i),t[n].added=!0}for(let n in t)if(t[n].name&&t[n].added===!1){let i=this.createPage(t[n],r.children,a);a.insertRule(i),t[n].added=!0}}createPage(t,r,a){let n=this.selectorsForPage(t),i=t.block.children.copy(),l={type:"Block",loc:0,children:i},c=this.createRule(n,l);return this.addMarginVars(t.margin,i,i.first()),this.addPaddingVars(t.padding,i,i.first()),this.addBorderVars(t.border,i,i.first()),t.width&&this.addDimensions(t.width,t.height,t.orientation,i,i.first()),t.marginalia&&(this.addMarginaliaStyles(t,r,c,a),this.addMarginaliaContent(t,r,c,a)),t.notes&&this.addNotesStyles(t.notes,t,r,c,a),c}addMarginVars(t,r,a){for(let n in t)if(typeof t[n].value<"u"){let i=t[n].value+(t[n].unit||""),l=r.createItem({type:"Declaration",property:"--pagedjs-margin-"+n,value:{type:"Raw",value:i}});r.append(l,a)}}addPaddingVars(t,r,a){for(let n in t)if(typeof t[n].value<"u"){let i=t[n].value+(t[n].unit||""),l=r.createItem({type:"Declaration",property:"--pagedjs-padding-"+n,value:{type:"Raw",value:i}});r.append(l,a)}}addBorderVars(t,r,a){for(let n of Object.keys(t)){let i=t[n];if(typeof i=="string"){let l=r.createItem({type:"Declaration",property:"--pagedjs-border-"+n,value:{type:"Raw",value:i}});r.append(l,a)}}}addDimensions(t,r,a,n,i){let l,c;l=le(t),c=le(r),a&&a!=="portrait"&&([l,c]=[c,l]);let d=this.createVariable("--pagedjs-pagebox-width",l);n.appendData(d);let h=this.createVariable("--pagedjs-pagebox-height",c);n.appendData(h)}addMarginaliaStyles(t,r,a,n){for(let i in t.marginalia){let l=ce.default.clone(t.marginalia[i]),c=!1;if(l.children.isEmpty())continue;ce.default.walk(l,{visit:"Declaration",enter:(x,p,g)=>{if(x.property==="content"&&(x.value.children&&x.value.children.first().name==="none"?c=!1:c=!0,g.remove(p)),x.property==="vertical-align"&&(ce.default.walk(x,{visit:"Identifier",enter:(v,q,L)=>{let O=v.name;O==="top"?v.name="flex-start":O==="middle"?v.name="center":O==="bottom"&&(v.name="flex-end")}}),x.property="align-items"),x.property==="width"&&(i==="top-left"||i==="top-center"||i==="top-right"||i==="bottom-left"||i==="bottom-center"||i==="bottom-right")){let v=ce.default.clone(x);v.property="max-width",g.appendData(v)}if(x.property==="height"&&(i==="left-top"||i==="left-middle"||i==="left-bottom"||i==="right-top"||i==="right-middle"||i==="right-bottom")){let v=ce.default.clone(x);v.property="max-height",g.appendData(v)}}});let d=this.selectorsForPageMargin(t,i),h=this.createRule(d,l);r.appendData(h);let k=ce.default.generate({type:"Selector",children:d});this.marginalia[k]={page:t,selector:k,block:t.marginalia[i],hasContent:c}}}addMarginaliaContent(t,r,a,n){let i;for(let l in t.marginalia){let c=ce.default.clone(t.marginalia[l]);if(ce.default.walk(c,{visit:"Declaration",enter:(g,v,q)=>{g.property!=="content"&&q.remove(v),g.value.children&&g.value.children.first().name==="none"&&(i=!0)}}),c.children.isEmpty())continue;let d=this.selectorsForPageMargin(t,l),h;d.insertData({type:"Combinator",name:">"}),d.insertData({type:"ClassSelector",name:"pagedjs_margin-content"}),d.insertData({type:"Combinator",name:">"}),d.insertData({type:"TypeSelector",name:"*"}),i?h=this.createDeclaration("display","none"):h=this.createDeclaration("display","block");let k=this.createRule(d,[h]);n.insertRule(k);let x=this.selectorsForPageMargin(t,l);x.insertData({type:"Combinator",name:">"}),x.insertData({type:"ClassSelector",name:"pagedjs_margin-content"}),x.insertData({type:"PseudoElementSelector",name:"after",children:null});let p=this.createRule(x,c);n.insertRule(p)}}addRootVars(t,r,a,n,i,l,c,d){let h=[],k=new ce.default.List;k.insertData({type:"PseudoClassSelector",name:"root",children:null});let x,p,g,v,q,L;if(!i)x=le(r),p=le(a),g=le(r),v=le(a),q=le(r),L=le(a);else{x=`calc( ${le(r)} + ${le(i.left)} + ${le(i.right)} )`,p=`calc( ${le(a)} + ${le(i.top)} + ${le(i.bottom)} )`,g=`calc( ${le(r)} + ${le(i.left)} + ${le(i.right)} )`,v=`calc( ${le(a)} + ${le(i.top)} + ${le(i.bottom)} )`,q=`calc( ${le(r)} + ${le(i.left)} + ${le(i.right)} )`,L=`calc( ${le(a)} + ${le(i.top)} + ${le(i.bottom)} )`;let X=this.createVariable("--pagedjs-bleed-top",le(i.top)),ne=this.createVariable("--pagedjs-bleed-right",le(i.right)),ve=this.createVariable("--pagedjs-bleed-bottom",le(i.bottom)),be=this.createVariable("--pagedjs-bleed-left",le(i.left)),Le=this.createVariable("--pagedjs-bleed-right-top",le(i.top)),Ne=this.createVariable("--pagedjs-bleed-right-right",le(i.right)),Ae=this.createVariable("--pagedjs-bleed-right-bottom",le(i.bottom)),Te=this.createVariable("--pagedjs-bleed-right-left",le(i.left)),ie=this.createVariable("--pagedjs-bleed-left-top",le(i.top)),Yt=this.createVariable("--pagedjs-bleed-left-right",le(i.right)),da=this.createVariable("--pagedjs-bleed-left-bottom",le(i.bottom)),pa=this.createVariable("--pagedjs-bleed-left-left",le(i.left));l&&(Le=this.createVariable("--pagedjs-bleed-right-top",le(l.top)),Ne=this.createVariable("--pagedjs-bleed-right-right",le(l.right)),Ae=this.createVariable("--pagedjs-bleed-right-bottom",le(l.bottom)),Te=this.createVariable("--pagedjs-bleed-right-left",le(l.left)),g=`calc( ${le(r)} + ${le(l.left)} + ${le(l.right)} )`,v=`calc( ${le(a)} + ${le(l.top)} + ${le(l.bottom)} )`),c&&(ie=this.createVariable("--pagedjs-bleed-left-top",le(c.top)),Yt=this.createVariable("--pagedjs-bleed-left-right",le(c.right)),da=this.createVariable("--pagedjs-bleed-left-bottom",le(c.bottom)),pa=this.createVariable("--pagedjs-bleed-left-left",le(c.left)),q=`calc( ${le(r)} + ${le(c.left)} + ${le(c.right)} )`,L=`calc( ${le(a)} + ${le(c.top)} + ${le(c.bottom)} )`);let zi=this.createVariable("--pagedjs-width",le(r)),Nr=this.createVariable("--pagedjs-height",le(a));h.push(X,ne,ve,be,Le,Ne,Ae,Te,ie,Yt,da,pa,zi,Nr)}if(d&&d.forEach(X=>{let ne=this.createVariable("--pagedjs-mark-"+X+"-display","block");h.push(ne)}),n){let X=this.createVariable("--pagedjs-orientation",n);h.push(X),n!=="portrait"&&([x,p]=[p,x],[g,v]=[v,g],[q,L]=[L,q])}let O=this.createVariable("--pagedjs-width",x),M=this.createVariable("--pagedjs-height",p),H=this.createVariable("--pagedjs-width-right",g),F=this.createVariable("--pagedjs-height-right",v),U=this.createVariable("--pagedjs-width-left",q),G=this.createVariable("--pagedjs-height-left",L);h.push(O,M,H,F,U,G);let Y=this.createRule(k,h);t.children.appendData(Y)}addNotesStyles(t,r,a,n,i){for(let l in t){let c=this.selectorsForPage(r);c.insertData({type:"Combinator",name:" "}),c.insertData({type:"ClassSelector",name:"pagedjs_"+l+"_content"});let d=this.createRule(c,t[l]);a.appendData(d)}}addRootPage(t,r,a,n,i){let{width:l,height:c,orientation:d,format:h}=r,k=new ce.default.List,x=new ce.default.List,p=new ce.default.List,g=new ce.default.List,v=new ce.default.List,q=new ce.default.List;if(a){let O=new ce.default.List,M=new ce.default.List;O.appendData({type:"Dimension",unit:l.unit,value:l.value}),O.appendData({type:"WhiteSpace",value:" "}),O.appendData({type:"Operator",value:"+"}),O.appendData({type:"WhiteSpace",value:" "}),O.appendData({type:"Dimension",unit:a.left.unit,value:a.left.value}),O.appendData({type:"WhiteSpace",value:" "}),O.appendData({type:"Operator",value:"+"}),O.appendData({type:"WhiteSpace",value:" "}),O.appendData({type:"Dimension",unit:a.right.unit,value:a.right.value}),M.appendData({type:"Dimension",unit:c.unit,value:c.value}),M.appendData({type:"WhiteSpace",value:" "}),M.appendData({type:"Operator",value:"+"}),M.appendData({type:"WhiteSpace",value:" "}),M.appendData({type:"Dimension",unit:a.top.unit,value:a.top.value}),M.appendData({type:"WhiteSpace",value:" "}),M.appendData({type:"Operator",value:"+"}),M.appendData({type:"WhiteSpace",value:" "}),M.appendData({type:"Dimension",unit:a.bottom.unit,value:a.bottom.value}),g.appendData({type:"Function",name:"calc",children:O}),g.appendData({type:"WhiteSpace",value:" "}),g.appendData({type:"Function",name:"calc",children:M})}else h?(g.appendData({type:"Identifier",name:h}),d&&(g.appendData({type:"WhiteSpace",value:" "}),g.appendData({type:"Identifier",name:d}))):(g.appendData({type:"Dimension",unit:l.unit,value:l.value}),g.appendData({type:"WhiteSpace",value:" "}),g.appendData({type:"Dimension",unit:c.unit,value:c.value}));k.appendData({type:"Declaration",property:"size",loc:null,value:{type:"Value",children:g}}),k.appendData({type:"Declaration",property:"margin",loc:null,value:{type:"Value",children:[{type:"Dimension",unit:"px",value:0}]}}),k.appendData({type:"Declaration",property:"padding",loc:null,value:{type:"Value",children:[{type:"Dimension",unit:"px",value:0}]}}),k.appendData({type:"Declaration",property:"padding",loc:null,value:{type:"Value",children:[{type:"Dimension",unit:"px",value:0}]}});let L=t.children.createItem({type:"Atrule",prelude:null,name:"page",block:{type:"Block",loc:null,children:k}});if(t.children.append(L),i){let O=new ce.default.List,M=new ce.default.List;O.appendData({type:"Dimension",unit:l.unit,value:l.value}),O.appendData({type:"WhiteSpace",value:" "}),O.appendData({type:"Operator",value:"+"}),O.appendData({type:"WhiteSpace",value:" "}),O.appendData({type:"Dimension",unit:i.left.unit,value:i.left.value}),O.appendData({type:"WhiteSpace",value:" "}),O.appendData({type:"Operator",value:"+"}),O.appendData({type:"WhiteSpace",value:" "}),O.appendData({type:"Dimension",unit:i.right.unit,value:i.right.value}),M.appendData({type:"Dimension",unit:c.unit,value:c.value}),M.appendData({type:"WhiteSpace",value:" "}),M.appendData({type:"Operator",value:"+"}),M.appendData({type:"WhiteSpace",value:" "}),M.appendData({type:"Dimension",unit:i.top.unit,value:i.top.value}),M.appendData({type:"WhiteSpace",value:" "}),M.appendData({type:"Operator",value:"+"}),M.appendData({type:"WhiteSpace",value:" "}),M.appendData({type:"Dimension",unit:i.bottom.unit,value:i.bottom.value}),v.appendData({type:"Function",name:"calc",children:O}),v.appendData({type:"WhiteSpace",value:" "}),v.appendData({type:"Function",name:"calc",children:M}),x.appendData({type:"Declaration",property:"size",loc:null,value:{type:"Value",children:v}});let H=t.children.createItem({type:"Atrule",prelude:null,name:"page :left",block:{type:"Block",loc:null,children:x}});t.children.append(H)}if(n){let O=new ce.default.List,M=new ce.default.List;O.appendData({type:"Dimension",unit:l.unit,value:l.value}),O.appendData({type:"WhiteSpace",value:" "}),O.appendData({type:"Operator",value:"+"}),O.appendData({type:"WhiteSpace",value:" "}),O.appendData({type:"Dimension",unit:n.left.unit,value:n.left.value}),O.appendData({type:"WhiteSpace",value:" "}),O.appendData({type:"Operator",value:"+"}),O.appendData({type:"WhiteSpace",value:" "}),O.appendData({type:"Dimension",unit:n.right.unit,value:n.right.value}),M.appendData({type:"Dimension",unit:c.unit,value:c.value}),M.appendData({type:"WhiteSpace",value:" "}),M.appendData({type:"Operator",value:"+"}),M.appendData({type:"WhiteSpace",value:" "}),M.appendData({type:"Dimension",unit:n.top.unit,value:n.top.value}),M.appendData({type:"WhiteSpace",value:" "}),M.appendData({type:"Operator",value:"+"}),M.appendData({type:"WhiteSpace",value:" "}),M.appendData({type:"Dimension",unit:n.bottom.unit,value:n.bottom.value}),q.appendData({type:"Function",name:"calc",children:O}),q.appendData({type:"WhiteSpace",value:" "}),q.appendData({type:"Function",name:"calc",children:M}),p.appendData({type:"Declaration",property:"size",loc:null,value:{type:"Value",children:q}});let H=t.children.createItem({type:"Atrule",prelude:null,name:"page :right",block:{type:"Block",loc:null,children:p}});t.children.append(H)}}getNth(t){let r=t.indexOf("n"),a=t.indexOf("+"),n=t.split("n"),i=t.split("+"),l=null,c=null;return r>-1?(l=n[0],a>-1&&(c=i[1])):c=t,{type:"Nth",loc:null,selector:null,nth:{type:"AnPlusB",loc:null,a:l,b:c}}}addPageAttributes(t,r,a){let n=[r.dataset.page];if(n&&n.length)for(let i of n)i&&(t.name=i,t.element.classList.add("pagedjs_named_page"),t.element.classList.add("pagedjs_"+i+"_page"),r.dataset.splitFrom||t.element.classList.add("pagedjs_"+i+"_first_page"))}getStartElement(t,r){let a=r&&r.node;if(!t&&!r)return;if(!a)return t.children[0];if(a.nodeType===1&&a.parentNode.nodeType===11||a.nodeType===1&&a.dataset.page)return a;let n=qs(a),i=n.querySelectorAll("[data-page]");return i.length?i[i.length-1]:n.children[0]}beforePageLayout(t,r,a,n){let i=this.getStartElement(r,a);i&&this.addPageAttributes(t,i,n.pages)}finalizePage(t,r,a,n){for(let i in this.marginalia){let l=this.marginalia[i],c=i.split(" "),d;r.element.matches(c[0])&&l.hasContent&&(d=r.element.querySelector(c[1]),d.classList.add("hasContent"))}["top","bottom"].forEach(i=>{let l=r.element.querySelector(".pagedjs_margin-"+i),c=r.element.querySelector(".pagedjs_margin-"+i+"-center"),d=r.element.querySelector(".pagedjs_margin-"+i+"-left"),h=r.element.querySelector(".pagedjs_margin-"+i+"-right"),k=c.classList.contains("hasContent"),x=d.classList.contains("hasContent"),p=h.classList.contains("hasContent"),g,v,q;if(x&&(v=window.getComputedStyle(d)["max-width"]),p&&(q=window.getComputedStyle(h)["max-width"]),k)if(g=window.getComputedStyle(c)["max-width"],g==="none"||g==="auto")if(!x&&!p)l.style["grid-template-columns"]="0 1fr 0";else if(x)if(p)if(v!=="none"&&v!=="auto")q!=="none"&&q!=="auto"?l.style["grid-template-columns"]=v+" 1fr "+q:l.style["grid-template-columns"]=v+" 1fr "+v;else if(q!=="none"&&q!=="auto")l.style["grid-template-columns"]=q+" 1fr "+q;else{l.style["grid-template-columns"]="auto auto 1fr",d.style["white-space"]="nowrap",c.style["white-space"]="nowrap",h.style["white-space"]="nowrap";let L=d.offsetWidth,O=c.offsetWidth,M=h.offsetWidth,H=L+O+M,F=O*100/H;F>40?l.style["grid-template-columns"]="minmax(16.66%, 1fr) minmax(33%, "+F+"%) minmax(16.66%, 1fr)":l.style["grid-template-columns"]="repeat(3, 1fr)",d.style["white-space"]="normal",c.style["white-space"]="normal",h.style["white-space"]="normal"}else if(v!=="none"&&v!=="auto")l.style["grid-template-columns"]=v+" 1fr "+v;else{l.style["grid-template-columns"]="auto auto 1fr",d.style["white-space"]="nowrap",c.style["white-space"]="nowrap";let L=d.offsetWidth,O=c.offsetWidth,M=L+O,H=O*100/M;l.style["grid-template-columns"]="minmax(16.66%, 1fr) minmax(33%, "+H+"%) minmax(16.66%, 1fr)",d.style["white-space"]="normal",c.style["white-space"]="normal"}else if(q!=="none"&&q!=="auto")l.style["grid-template-columns"]=q+" 1fr "+q;else{l.style["grid-template-columns"]="auto auto 1fr",h.style["white-space"]="nowrap",c.style["white-space"]="nowrap";let L=h.offsetWidth,O=c.offsetWidth,M=L+O,H=O*100/M;l.style["grid-template-columns"]="minmax(16.66%, 1fr) minmax(33%, "+H+"%) minmax(16.66%, 1fr)",h.style["white-space"]="normal",c.style["white-space"]="normal"}else g!=="none"&&g!=="auto"&&(x&&v!=="none"&&v!=="auto"?l.style["grid-template-columns"]=v+" "+g+" 1fr":p&&q!=="none"&&q!=="auto"?l.style["grid-template-columns"]="1fr "+g+" "+q:l.style["grid-template-columns"]="1fr "+g+" 1fr");else if(x)if(!p)l.style["grid-template-columns"]="1fr 0 0";else if(v!=="none"&&v!=="auto")q!=="none"&&q!=="auto"?l.style["grid-template-columns"]=v+" 1fr "+q:l.style["grid-template-columns"]=v+" 0 1fr";else if(q!=="none"&&q!=="auto")l.style["grid-template-columns"]="1fr 0 "+q;else{l.style["grid-template-columns"]="auto 1fr auto",d.style["white-space"]="nowrap",h.style["white-space"]="nowrap";let L=d.offsetWidth,O=h.offsetWidth,M=L+O,H=L*100/M;l.style["grid-template-columns"]="minmax(16.66%, "+H+"%) 0 1fr",d.style["white-space"]="normal",h.style["white-space"]="normal"}else q!=="none"&&q!=="auto"?l.style["grid-template-columns"]="1fr 0 "+q:l.style["grid-template-columns"]="0 0 1fr"}),["left","right"].forEach(i=>{let l=r.element.querySelector(".pagedjs_margin-"+i+"-middle.hasContent"),c=r.element.querySelector(".pagedjs_margin-"+i),d=r.element.querySelector(".pagedjs_margin-"+i+"-top"),h=r.element.querySelector(".pagedjs_margin-"+i+"-bottom"),k=d.classList.contains("hasContent"),x=h.classList.contains("hasContent"),p,g,v;k&&(g=window.getComputedStyle(d)["max-height"]),x&&(v=window.getComputedStyle(h)["max-height"]),l?(p=window.getComputedStyle(l)["max-height"],p==="none"||p==="auto"?!k&&!x?c.style["grid-template-rows"]="0 1fr 0":k?x?g!=="none"&&g!=="auto"?v!=="none"&&v!=="auto"?c.style["grid-template-rows"]=g+" calc(100% - "+g+" - "+v+") "+v:c.style["grid-template-rows"]=g+" calc(100% - "+g+"*2) "+g:v!=="none"&&v!=="auto"&&(c.style["grid-template-rows"]=v+" calc(100% - "+v+"*2) "+v):g!=="none"&&g!=="auto"&&(c.style["grid-template-rows"]=g+" calc(100% - "+g+"*2) "+g):v!=="none"&&v!=="auto"&&(c.style["grid-template-rows"]=v+" calc(100% - "+v+"*2) "+v):k&&g!=="none"&&g!=="auto"?c.style["grid-template-rows"]=g+" "+p+" calc(100% - ("+g+" + "+p+"))":x&&v!=="none"&&v!=="auto"?c.style["grid-template-rows"]="1fr "+p+" "+v:c.style["grid-template-rows"]="calc((100% - "+p+")/2) "+p+" calc((100% - "+p+")/2)"):k?x?g!=="none"&&g!=="auto"?v!=="none"&&v!=="auto"?c.style["grid-template-rows"]=g+" 1fr "+v:c.style["grid-template-rows"]=g+" 0 1fr":v!=="none"&&v!=="auto"?c.style["grid-template-rows"]="1fr 0 "+v:c.style["grid-template-rows"]="1fr 0 1fr":c.style["grid-template-rows"]="1fr 0 0":v!=="none"&&v!=="auto"?c.style["grid-template-rows"]="1fr 0 "+v:c.style["grid-template-rows"]="0 0 1fr"})}selectorsForPage(t){let r,a,n=new ce.default.List;return n.insertData({type:"ClassSelector",name:"pagedjs_page"}),t.name&&(n.insertData({type:"ClassSelector",name:"pagedjs_named_page"}),n.insertData({type:"ClassSelector",name:"pagedjs_"+t.name+"_page"})),t.psuedo&&!(t.name&&t.psuedo==="first")&&n.insertData({type:"ClassSelector",name:"pagedjs_"+t.psuedo+"_page"}),t.name&&t.psuedo==="first"&&n.insertData({type:"ClassSelector",name:"pagedjs_"+t.name+"_"+t.psuedo+"_page"}),t.nth&&(r=new ce.default.List,a=this.getNth(t.nth),r.insertData(a),n.insertData({type:"PseudoClassSelector",name:"nth-of-type",children:r})),n}selectorsForPageMargin(t,r){let a=this.selectorsForPage(t);return a.insertData({type:"Combinator",name:" "}),a.insertData({type:"ClassSelector",name:"pagedjs_margin-"+r}),a}createDeclaration(t,r,a){let n=new ce.default.List;return n.insertData({type:"Identifier",loc:null,name:r}),{type:"Declaration",loc:null,important:a,property:t,value:{type:"Value",loc:null,children:n}}}createVariable(t,r){return{type:"Declaration",loc:null,property:t,value:{type:"Raw",value:r}}}createCalculatedDimension(t,r,a,n="+"){let i=new ce.default.List,l=new ce.default.List;return r.forEach((c,d)=>{l.appendData({type:"Dimension",unit:c.unit,value:c.value}),l.appendData({type:"WhiteSpace",value:" "}),d+1<r.length&&(l.appendData({type:"Operator",value:n}),l.appendData({type:"WhiteSpace",value:" "}))}),i.insertData({type:"Function",loc:null,name:"calc",children:l}),{type:"Declaration",loc:null,important:a,property:t,value:{type:"Value",loc:null,children:i}}}createDimension(t,r,a){let n=new ce.default.List;return n.insertData({type:"Dimension",loc:null,value:r.value,unit:r.unit}),{type:"Declaration",loc:null,important:a,property:t,value:{type:"Value",loc:null,children:n}}}createBlock(t){let r=new ce.default.List;return t.forEach(a=>{r.insertData(a)}),{type:"Block",loc:null,children:r}}createRule(t,r){let a=new ce.default.List;return a.insertData({type:"Selector",children:t}),Array.isArray(r)&&(r=this.createBlock(r)),{type:"Rule",prelude:{type:"SelectorList",children:a},block:r}}},a3=Ad;b();var Td=He(bt(),1);var Ed=class extends xe{constructor(t,r,a){super(t,r,a),this.breaks={}}onDeclaration(t,r,a,n){let i=t.property;if(i==="page"){let c=t.value.children.first().name,d=Td.default.generate(n.ruleNode.prelude),k={property:i,value:c,selector:d,name:c};d.split(",").forEach(x=>{this.breaks[x]?this.breaks[x].push(k):this.breaks[x]=[k]}),a.remove(r)}if(i==="break-before"||i==="break-after"||i==="page-break-before"||i==="page-break-after"){let c=t.value.children.first().name,d=Td.default.generate(n.ruleNode.prelude);i==="page-break-before"?i="break-before":i==="page-break-after"&&(i="break-after");let h={property:i,value:c,selector:d};d.split(",").forEach(k=>{this.breaks[k]?this.breaks[k].push(h):this.breaks[k]=[h]}),a.remove(r)}}afterParsed(t){this.processBreaks(t,this.breaks)}processBreaks(t,r){for(let n in r){let i=t.querySelectorAll(n);for(var a=0;a<i.length;a++)for(let l of r[n])if(l.property==="break-after"){let c=jc(i[a],t);i[a].setAttribute("data-break-after",l.value),c&&c.setAttribute("data-previous-break-after",l.value)}else if(l.property==="break-before"){let c=cg(i[a],t);if(c){if(l.value==="page"&&Ds(i[a],c))continue;i[a].setAttribute("data-break-before",l.value),c.setAttribute("data-next-break-before",l.value)}}else if(l.property==="page"){i[a].setAttribute("data-page",l.value);let c=jc(i[a],t);c&&c.setAttribute("data-after-page",l.value)}else i[a].setAttribute("data-"+l.property,l.value)}}mergeBreaks(t,r){for(let a in r)a in t?t[a]=t[a].concat(r[a]):t[a]=r[a];return t}addBreakAttributes(t,r){let a=t.querySelector("[data-break-before]"),n=t.querySelector("[data-break-after]"),i=t.querySelector("[data-previous-break-after]");a&&(a.dataset.splitFrom?(r.splitFrom=a.dataset.splitFrom,t.setAttribute("data-split-from",a.dataset.splitFrom)):a.dataset.breakBefore&&a.dataset.breakBefore!=="avoid"&&(r.breakBefore=a.dataset.breakBefore,t.setAttribute("data-break-before",a.dataset.breakBefore))),n&&n.dataset&&(n.dataset.splitTo?(r.splitTo=n.dataset.splitTo,t.setAttribute("data-split-to",n.dataset.splitTo)):n.dataset.breakAfter&&n.dataset.breakAfter!=="avoid"&&(r.breakAfter=n.dataset.breakAfter,t.setAttribute("data-break-after",n.dataset.breakAfter))),i&&i.dataset&&i.dataset.previousBreakAfter&&i.dataset.previousBreakAfter!=="avoid"&&(r.previousBreakAfter=i.dataset.previousBreakAfter)}afterPageLayout(t,r){this.addBreakAttributes(t,r)}},n3=Ed;b();var i3=He(bt(),1),qd=class extends xe{constructor(t,r,a){super(t,r,a)}onAtMedia(t,r,a){let n=this.getMediaName(t),i;n.includes("print")?(i=t.block.children,a.appendList(i),a.remove(r)):!n.includes("all")&&!n.includes("pagedjs-ignore")&&a.remove(r)}getMediaName(t){let r=[];if(!(typeof t.prelude>"u"||t.prelude.type!=="AtrulePrelude"))return i3.default.walk(t.prelude,{visit:"Identifier",enter:(a,n,i)=>{r.push(a.name)}}),r}},s3=qd;b();var Od=class extends xe{constructor(t,r,a){super(t,r,a)}afterPageLayout(t,r,a,n){let i=Array.from(t.querySelectorAll("[data-split-from]")),l=t.parentNode,c=Array.prototype.indexOf.call(l.children,t),d;if(c===0)return;d=l.children[c-1];let h;i.forEach(k=>{let x=k.dataset.ref;h=d.querySelector("[data-ref='"+x+"']:not([data-split-to])"),h&&(h.dataset.splitTo=x,h.dataset.splitFrom||(h.dataset.splitOriginal=!0))}),h&&this.handleAlignment(h)}handleAlignment(t){let r=window.getComputedStyle(t),a=r["text-align"],n=r["text-align-last"];t.dataset.lastSplitElement="true",a==="justify"&&n==="auto"?t.dataset.alignLastSplitElement="justify":t.dataset.alignLastSplitElement=n}},o3=Od;b();var Io=He(bt(),1),Dd=class extends xe{constructor(t,r,a){super(t,r,a),this.styleSheet=r.styleSheet,this.counters={},this.resetCountersMap=new Map}onDeclaration(t,r,a,n){let i=t.property;if(i==="counter-increment"){this.handleIncrement(t,n);let l=!1;t.value.children.forEach(c=>{c.type&&c.type!=="WhiteSpace"&&(l=!0)}),l||a.remove(r)}else if(i==="counter-reset"){this.handleReset(t,n);let l=!1;t.value.children.forEach(c=>{c.type&&c.type!=="WhiteSpace"&&(l=!0)}),l||a.remove(r)}}afterParsed(t){this.processCounters(t,this.counters),this.scopeCounters(this.counters)}addCounter(t){return t in this.counters?this.counters[t]:(this.counters[t]={name:t,increments:{},resets:{}},this.counters[t])}handleIncrement(t,r){let a=[],n=t.value.children;return n.forEach((i,l)=>{if(i.type&&i.type==="Identifier"){let c=i.name;if(c==="page"||c.indexOf("target-counter-")===0)return;let d,h,k;l.next&&l.next.data.type==="WhiteSpace"&&(d=l.next),d&&d.next&&d.next.data.type==="Number"&&(h=d.next,k=parseInt(h.data.value));let x=Io.default.generate(r.ruleNode.prelude),p;c in this.counters?p=this.counters[c]:p=this.addCounter(c);let g={selector:x,number:k||1};p.increments[x]=g,a.push(g),n.remove(l),d&&n.remove(d),h&&n.remove(h)}}),a}handleReset(t,r){let a=t.value.children;a.forEach((n,i)=>{if(n.type&&n.type==="Identifier"){let l=n.name,c,d,h;i.next&&i.next.data.type==="WhiteSpace"&&(c=i.next),c&&c.next&&(c.next.data.type==="Number"?(d=c.next,h=parseInt(d.data.value)):c.next.data.type==="Function"&&c.next.data.name==="var"&&(d=c.next,h=c.next.data.children.head.data.name));let k,x,p=r.ruleNode.prelude;r.ruleNode.type==="Atrule"&&r.ruleNode.name==="page"?x=".pagedjs_page":x=Io.default.generate(p||r.ruleNode),l==="footnote"&&this.addFootnoteMarkerCounter(t.value.children),l in this.counters?k=this.counters[l]:k=this.addCounter(l);let g={selector:x,number:h||0};k.resets[x]=g,x!==".pagedjs_page"&&(a.remove(i),c&&a.remove(c),d&&a.remove(d))}})}processCounters(t,r){let a;for(let n in r)a=this.counters[n],this.processCounterIncrements(t,a),this.processCounterResets(t,a),n!=="page"&&this.addCounterValues(t,a)}scopeCounters(t){let r=[];for(let a in t)a!=="page"&&r.push(`${t[a].name} 0`);this.insertRule(`.pagedjs_pages { counter-reset: ${r.join(" ")} page 0 pages var(--pagedjs-page-count) footnote var(--pagedjs-footnotes-count) footnote-marker var(--pagedjs-footnotes-count)}`)}insertRule(t){this.styleSheet.insertRule(t,this.styleSheet.cssRules.length)}processCounterIncrements(t,r){let a;for(let n in r.increments){a=r.increments[n];let i=t.querySelectorAll(a.selector);for(let l=0;l<i.length;l++)i[l].setAttribute("data-counter-"+r.name+"-increment",a.number),i[l].getAttribute("data-counter-increment")?i[l].setAttribute("data-counter-increment",i[l].getAttribute("data-counter-increment")+" "+r.name):i[l].setAttribute("data-counter-increment",r.name)}}processCounterResets(t,r){let a;for(let i in r.resets){a=r.resets[i];let l=t.querySelectorAll(a.selector);for(var n=0;n<l.length;n++){let c=a.number;typeof c=="string"&&c.startsWith("--")&&(c=l[n].style.getPropertyValue(c)||0),l[n].setAttribute("data-counter-"+r.name+"-reset",c),l[n].getAttribute("data-counter-reset")?l[n].setAttribute("data-counter-reset",l[n].getAttribute("data-counter-reset")+" "+r.name):l[n].setAttribute("data-counter-reset",r.name)}}}addCounterValues(t,r){let a=r.name;if(a==="page"||a==="footnote")return;let n=t.querySelectorAll("[data-counter-"+a+"-reset], [data-counter-"+a+"-increment]"),i=0,l,c,d,h,k,x,p;for(let g=0;g<n.length;g++)l=n[g],x=0,p=[],l.hasAttribute("data-counter-"+a+"-reset")&&(d=l.getAttribute("data-counter-"+a+"-reset"),h=parseInt(d),x=h-i,p.push(`${a} ${x}`),i=h),l.hasAttribute("data-counter-"+a+"-increment")&&(c=l.getAttribute("data-counter-"+a+"-increment"),k=parseInt(c),i+=k,l.setAttribute("data-counter-"+a+"-value",i),p.push(`${a} ${k}`)),p.length>0&&this.incrementCounterForElement(l,p)}addFootnoteMarkerCounter(t){let r=[];Io.default.walk(t,{visit:"Identifier",enter:(a,n,i)=>{r.push(a.name)}}),!r.includes("footnote-maker")&&(t.insertData({type:"WhiteSpace",value:" "}),t.insertData({type:"Identifier",name:"footnote-marker"}),t.insertData({type:"WhiteSpace",value:" "}),t.insertData({type:"Number",value:0}))}incrementCounterForElement(t,r){if(!t||!r||r.length===0)return;let a=t.dataset.ref,n=Array.from(this.styleSheet.cssRules).filter(l=>l.selectorText===`[data-ref="${t.dataset.ref}"]:not([data-split-from])`&&l.style[0]==="counter-increment").map(l=>l.style.counterIncrement);n.push(this.mergeIncrements(r,(l,c)=>(parseInt(l)||0)+(parseInt(c)||0)));let i=this.mergeIncrements(n,(l,c)=>c);this.insertRule(`[data-ref="${a}"]:not([data-split-from]) { counter-increment: ${i} }`)}mergeIncrements(t,r){let a={};return t.forEach(n=>{let i=n.split(" ");for(let l=0;l<i.length;l+=2)a[i[l]]=r(a[i[l]],i[l+1])}),Object.entries(a).map(([n,i])=>`${n} ${i}`).join(" ")}afterPageLayout(t,r){let a=[];t.querySelectorAll("[data-counter-page-reset]:not([data-split-from])").forEach(l=>{let c=l.dataset&&l.dataset.ref;if(!(c&&this.resetCountersMap.has(c))){c&&this.resetCountersMap.set(c,"");let d=l.dataset.counterPageReset;a.push(`page ${d}`)}}),t.querySelectorAll("[data-counter-footnote-reset]:not([data-split-from])").forEach(l=>{let c=l.dataset.counterFootnoteReset;a.push(`footnote ${c}`),a.push(`footnote-marker ${c}`)}),a.length&&this.styleSheet.insertRule(`[data-page-number="${t.dataset.pageNumber}"] { counter-increment: none; counter-reset: ${a.join(" ")} }`,this.styleSheet.cssRules.length)}},l3=Dd;b();var Md=class extends xe{constructor(t,r,a){super(t,r,a)}afterParsed(t){let r=t.querySelectorAll("ol");for(var a of r)this.addDataNumbers(a)}afterPageLayout(t,r,a,n){var i=t.getElementsByTagName("ol");for(var l of i)l.firstElementChild&&(l.start=l.firstElementChild.dataset.itemNum)}addDataNumbers(t){let r=1;t.hasAttribute("start")&&(r=parseInt(t.getAttribute("start"),10),isNaN(r)&&(r=1));let a=t.children;for(var n=0;n<a.length;n++)a[n].setAttribute("data-item-num",n+r)}},c3=Md;b();var u3=He(bt(),1),jd=class extends xe{constructor(t,r,a){super(t,r,a),this.styleSheet=r.styleSheet,this.fixedElementsSelector=[],this.fixedElements=[]}onDeclaration(t,r,a,n){if(t.property==="position"&&t.value.children.first().name==="fixed"){let i=u3.default.generate(n.ruleNode.prelude);this.fixedElementsSelector.push(i),a.remove(r)}}afterParsed(t){this.fixedElementsSelector.forEach(r=>{t.querySelectorAll(`${r}`).forEach(a=>{a.style.setProperty("position","absolute"),this.fixedElements.push(a),a.remove()})})}afterPageLayout(t,r,a){this.fixedElements.forEach(n=>{let i=n.cloneNode(!0);t.querySelector(".pagedjs_pagebox").insertAdjacentElement("afterbegin",i)})}},d3=jd;b();var p3=He(bt(),1),Bd=class extends xe{constructor(t,r,a){super(t,r,a),this.styleSheet=r.styleSheet,this.pageCounter={name:"page",increments:{},resets:{}}}onDeclaration(t,r,a,n){t.property==="counter-increment"&&this.handleIncrement(t,n)&&a.remove(r)}afterParsed(t){for(let r in this.pageCounter.increments){let a=this.pageCounter.increments[r];this.insertRule(`${a.selector} { --pagedjs-page-counter-increment: ${a.number} }`)}}handleIncrement(t,r){let a=t.value.children.first(),n=t.value.children.getSize()>1?t.value.children.last().value:1,i=a&&a.name;if(i&&i.indexOf("target-counter-")===0||i!=="page"||r.ruleNode.name==="page"&&r.ruleNode.type==="Atrule")return;let l=p3.default.generate(r.ruleNode.prelude);return this.pageCounter.increments[l]={selector:l,number:n}}insertRule(t){this.styleSheet.insertRule(t,this.styleSheet.cssRules.length)}},f3=Bd;b();var Ld=He(bt(),1);var Pd=class extends xe{constructor(t,r,a){super(t,r,a),this.styleSheet=r.styleSheet,this.selectors={}}onRule(t,r,a){let n=Ld.default.generate(t.prelude);if(n.match(/:(first|last|nth)-of-type/)){let i=Ld.default.generate(t.block);i=i.replace(/[{}]/g,"");let l="nth-of-type-"+xt();n.split(",").forEach(c=>{this.selectors[c]?this.selectors[c][1]=`${this.selectors[c][1]};${i}`:this.selectors[c]=[l,i]}),a.remove(r)}}afterParsed(t){this.processSelectors(t,this.selectors)}processSelectors(t,r){for(let n in r){let i=t.querySelectorAll(n);for(var a=0;a<i.length;a++){let c=i[a].getAttribute("data-nth-of-type");c&&c!=""?(c=`${c},${r[n][0]}`,i[a].setAttribute("data-nth-of-type",c)):i[a].setAttribute("data-nth-of-type",r[n][0])}let l=`*[data-nth-of-type*='${r[n][0]}'] { ${r[n][1]}; }`;this.styleSheet.insertRule(l,this.styleSheet.cssRules.length)}}},h3=Pd;b();var Id=He(bt(),1);var Rd=class extends xe{constructor(t,r,a){super(t,r,a),this.styleSheet=r.styleSheet,this.selectors={}}onRule(t,r,a){let n=Id.default.generate(t.prelude);if(n.match(/\+/)){let i=Id.default.generate(t.block);i=i.replace(/[{}]/g,"");let l="following-"+xt();n.split(",").forEach(c=>{this.selectors[c]?this.selectors[c][1]=`${this.selectors[c][1]};${i}`:this.selectors[c]=[l,i]}),a.remove(r)}}afterParsed(t){this.processSelectors(t,this.selectors)}processSelectors(t,r){for(let n in r){let i=t.querySelectorAll(n);for(var a=0;a<i.length;a++){let c=i[a].getAttribute("data-following");c&&c!=""?(c=`${c},${r[n][0]}`,i[a].setAttribute("data-following",c)):i[a].setAttribute("data-following",r[n][0])}let l=`*[data-following*='${r[n][0]}'] { ${r[n][1]}; }`;this.styleSheet.insertRule(l,this.styleSheet.cssRules.length)}}},m3=Rd;b();var gn=He(bt(),1),Nd=class extends xe{constructor(t,r,a){super(t,r,a),this.footnotes={},this.needsLayout=[]}onDeclaration(t,r,a,n){let i=t.property;if(i==="float"){let l=t.value.children&&t.value.children.first();if((l&&l.name)==="footnote"){let d=gn.default.generate(n.ruleNode.prelude);this.footnotes[d]={selector:d,policy:"auto",display:"block"},a.remove(r)}}if(i==="footnote-policy"){let l=t.value.children&&t.value.children.first(),c=l&&l.name;if(c){let d=gn.default.generate(n.ruleNode.prelude),h=this.footnotes[d];h&&(h.policy=c)}}if(i==="footnote-display"){let l=t.value.children&&t.value.children.first(),c=l&&l.name,d=gn.default.generate(n.ruleNode.prelude);if(c&&this.footnotes[d]){let h=this.footnotes[d];h&&(h.display=c)}}}onPseudoSelector(t,r,a,n,i){let l=t.name;if(l==="footnote-marker"){let c=i.ruleNode.prelude,d=new gn.default.List;c.children.first().children.each(h=>{h.type!=="PseudoElementSelector"&&d.appendData(h)}),d.appendData({type:"AttributeSelector",name:{type:"Identifier",name:"data-footnote-marker"},flags:null,loc:null,matcher:null,value:null}),d.appendData({type:"PseudoElementSelector",name:"marker",loc:null,children:null}),c.children.first().children=d}if(l==="footnote-call"){let c=i.ruleNode.prelude,d=new gn.default.List;c.children.first().children.each(h=>{h.type!=="PseudoElementSelector"&&d.appendData(h)}),d.appendData({type:"AttributeSelector",name:{type:"Identifier",name:"data-footnote-call"},flags:null,loc:null,matcher:null,value:null}),d.appendData({type:"PseudoElementSelector",name:"after",loc:null,children:null}),c.children.first().children=d}}afterParsed(t){this.processFootnotes(t,this.footnotes)}processFootnotes(t,r){for(let n in r){let i=t.querySelectorAll(n),l,c=r[n];for(var a=0;a<i.length;a++)l=i[a],l.setAttribute("data-note","footnote"),l.setAttribute("data-break-before","avoid"),l.setAttribute("data-note-policy",c.policy||"auto"),l.setAttribute("data-note-display",c.display||"block"),this.processFootnoteContainer(l)}}processFootnoteContainer(t){let r=t.parentElement,a=r;for(;r;){if(Ms(r)){a.setAttribute("data-has-notes","true");break}a=r,r=r.parentElement,r||a.setAttribute("data-has-notes","true")}}renderNode(t){if(t.nodeType==1){let r;if(!t.dataset)return;t.dataset.note==="footnote"?r=[t]:(t.dataset.hasNotes||t.querySelectorAll("[data-note='footnote']"))&&(r=t.querySelectorAll("[data-note='footnote']")),r&&r.length&&this.findVisibleFootnotes(r,t)}}findVisibleFootnotes(t,r){let a,n,i;a=r.closest(".pagedjs_page_content"),n=a.getBoundingClientRect(),i=n.left+n.width;for(let l=0;l<t.length;++l){let c=t[l];c.getBoundingClientRect().left<i&&this.moveFootnote(c,r.closest(".pagedjs_area"),!0)}}moveFootnote(t,r,a){let n=r.querySelector(".pagedjs_footnote_area"),i=n.querySelector(".pagedjs_footnote_content"),l=i.querySelector(".pagedjs_footnote_inner_content");if(!ft(t))return;let c;if(a&&(c=this.createFootnoteCall(t)),t.removeAttribute("data-break-before"),l.querySelector(`[data-ref="${t.dataset.ref}"]`)){t.remove();return}l.appendChild(t),i.classList.contains("pagedjs_footnote_empty")&&i.classList.remove("pagedjs_footnote_empty"),t.dataset.footnoteMarker=t.dataset.ref,t.id=`note-${t.dataset.ref}`;let h=i.scrollHeight,x=r.querySelector(".pagedjs_page_content").getBoundingClientRect(),p=x.left+x.width,g=c&&c.getBoundingClientRect(),v=n.getBoundingClientRect(),q=this.marginsHeight(i),L=this.paddingHeight(i),O=this.borderHeight(i),M=q+L+O,H=Math.floor(v.top);v.height===0&&(H-=this.marginsHeight(i,!1),H-=this.paddingHeight(i,!1),H-=this.borderHeight(i,!1));let F=t.dataset.notePolicy,U=0,G=0;if(c){let be=c.previousSibling,Le=new Range;be?Le.setStartBefore(be):Le.setStartBefore(c),Le.setEndAfter(c);let Ne=Le.getBoundingClientRect();if(U=Ne.bottom,!F||F==="auto")G=Math.ceil(Ne.bottom);else if(F==="line")G=Math.ceil(Ne.top);else if(F==="block"){let Ae=c.closest("p").previousElementSibling;Ae?G=Math.ceil(Ae.getBoundingClientRect().bottom):G=Math.ceil(Ne.bottom)}}let Y=h+M-v.height,X=U?H-U:0,ne=U?Math.floor(v.top)-G:0,ve=n.querySelector("[data-note='footnote']");if(a&&g.left>p)t.remove();else if(!ve&&a&&M>X){r.style.setProperty("--pagedjs-footnotes-height","0px");let be=document.createElement("div");be.appendChild(t),this.needsLayout.push(be)}else a?U<v.top-Y?r.style.setProperty("--pagedjs-footnotes-height",`${h+q+O}px`):(r.style.setProperty("--pagedjs-footnotes-height",`${v.height+ne}px`),l.style.height=v.height+ne-M+"px"):r.style.setProperty("--pagedjs-footnotes-height",`${h+M}px`)}createFootnoteCall(t){let r=t.parentElement,a=document.createElement("a");for(let n of t.classList)a.classList.add(`${n}`);return a.dataset.footnoteCall=t.dataset.ref,a.dataset.ref=t.dataset.ref,a.dataset.dataCounterFootnoteIncrement=1,a.href=`#note-${t.dataset.ref}`,r.insertBefore(a,t),a}afterPageLayout(t,r,a,n){let i=t.querySelector(".pagedjs_area"),l=r.footnotesArea,c=l.querySelector(".pagedjs_footnote_content"),d=l.querySelector(".pagedjs_footnote_inner_content"),h=c.getBoundingClientRect(),{width:k}=h;d.style.columnWidth=Math.round(k)+"px",d.style.columnGap="calc(var(--pagedjs-margin-right) + var(--pagedjs-margin-left))";let p=new $s(l,void 0,n.settings).findOverflow(d,h);if(p){let{startContainer:g,startOffset:v}=p,q;if(ft(g)){let G=g.childNodes[v];q=ft(G)&&G.hasAttribute("data-footnote-marker")}let L=p.extractContents();if(!q){let G=L.firstElementChild;G.dataset.splitFrom=G.dataset.ref,this.handleAlignment(d.lastElementChild)}this.needsLayout.push(L),c.style.removeProperty("height"),d.style.removeProperty("height");let O=d.getBoundingClientRect(),{height:M}=O,H=this.marginsHeight(c),F=this.paddingHeight(c),U=this.borderHeight(c);if(i.style.setProperty("--pagedjs-footnotes-height",`${M+H+U+F}px`),d.childNodes.length===0&&c.classList.add("pagedjs_footnote_empty"),!a)n.clonePage(r);else{let G,Y;a.node&&typeof a.node.dataset<"u"&&typeof a.node.dataset.previousBreakAfter<"u"&&(Y=a.node.dataset.previousBreakAfter),a.node&&typeof a.node.dataset<"u"&&typeof a.node.dataset.breakBefore<"u"&&(G=a.node.dataset.breakBefore),(G||Y)&&n.clonePage(r)}}d.style.height="auto"}handleAlignment(t){let a=window.getComputedStyle(t)["text-align-last"];t.dataset.lastSplitElement="true",a==="auto"?t.dataset.alignLastSplitElement="justify":t.dataset.alignLastSplitElement=a}beforePageLayout(t){for(;this.needsLayout.length;){let r=this.needsLayout.shift();Array.from(r.childNodes).forEach(a=>{this.moveFootnote(a,t.element.querySelector(".pagedjs_area"),!1)})}}afterOverflowRemoved(t,r){let a=r.closest(".pagedjs_area"),n=a.querySelectorAll(".pagedjs_footnote_area [data-note='footnote']");for(let l=0;l<n.length;l++){let c=n[l];t.querySelector(`[data-footnote-call="${c.dataset.ref}"]`)&&c.remove()}let i=a.querySelector(".pagedjs_footnote_inner_content");i&&i.childNodes.length===0&&i.parentElement.classList.add("pagedjs_footnote_empty")}marginsHeight(t,r=!0){let a=window.getComputedStyle(t),n=parseInt(a.marginTop),i=parseInt(a.marginBottom),l=0;return n&&(l+=n),i&&r&&(l+=i),l}paddingHeight(t,r=!0){let a=window.getComputedStyle(t),n=parseInt(a.paddingTop),i=parseInt(a.paddingBottom),l=0;return n&&(l+=n),i&&r&&(l+=i),l}borderHeight(t,r=!0){let a=window.getComputedStyle(t),n=parseInt(a.borderTop),i=parseInt(a.borderBottom),l=0;return n&&(l+=n),i&&r&&(l+=i),l}},g3=Nd;var y3=[s3,a3,n3,o3,l3,c3,d3,f3,h3,m3,g3];b();b();var ki=He(bt(),1),Fd=class extends xe{constructor(t,r,a){super(t,r,a),this.runningSelectors={},this.elements={}}onDeclaration(t,r,a,n){if(t.property==="position"){let i=ki.default.generate(n.ruleNode.prelude),l=t.value.children.first().name;if(l==="running"){let c;ki.default.walk(t,{visit:"Function",enter:(d,h,k)=>{c=d.children.first().name}}),this.runningSelectors[c]={identifier:l,value:c,selector:i}}}t.property==="content"&&ki.default.walk(t,{visit:"Function",enter:(i,l,c)=>{if(i.name.indexOf("element")>-1){let d=ki.default.generate(n.ruleNode.prelude),h=i.name,k=i.children.first().name,x=[k],p="first";d.split(",").forEach(g=>{g=g.replace(/::after|::before/,""),this.elements[g]={func:h,args:x,value:k,style:p||"first",selector:g,fullSelector:d}})}}})}afterParsed(t){for(let r of Object.keys(this.runningSelectors)){let a=this.runningSelectors[r],n=Array.from(t.querySelectorAll(a.selector));if(a.identifier==="running")for(let i of n)i.style.display="none"}}afterPageLayout(t){for(let r of Object.keys(this.runningSelectors)){let a=this.runningSelectors[r],n=t.querySelector(a.selector);n&&(a.identifier==="running"?a.first=n:console.warn(a.value+"needs css replacement"))}this.orderedSelectors||(this.orderedSelectors=this.orderSelectors(this.elements));for(let r of this.orderedSelectors)if(r){let a=this.elements[r],n=t.querySelector(r);if(n){let i=this.runningSelectors[a.args[0]];if(i&&i.first){n.innerHTML="";let l=i.first.cloneNode(!0);l.style.display=null,n.appendChild(l)}}}}pageWeight(t){let r=1,a=t.split(" "),n=a.length&&a[0].split(".");switch(n.shift(),n.length){case 4:/^pagedjs_[\w-]+_first_page$/.test(n[3])?r=7:(n[3]==="pagedjs_left_page"||n[3]==="pagedjs_right_page")&&(r=6);break;case 3:n[1]==="pagedjs_named_page"&&(n[2].indexOf(":nth-of-type")>-1?r=7:r=5);break;case 2:n[1]==="pagedjs_first_page"?r=4:n[1]==="pagedjs_blank_page"?r=3:(n[1]==="pagedjs_left_page"||n[1]==="pagedjs_right_page")&&(r=2);break;default:n[0].indexOf(":nth-of-type")>-1?r=4:r=1}return r}orderSelectors(t){let r=Object.keys(t),a={1:[],2:[],3:[],4:[],5:[],6:[],7:[]},n=[];for(let l of r){let c=this.pageWeight(l);a[c].unshift(l)}for(var i=1;i<=7;i++)n=n.concat(a[i]);return n}beforeTreeParse(t,r){r.text=t.replace(/element[\s]*\(([^|^#)]*)\)/g,"element-ident($1)")}},b3=Fd;b();var Wd=He(bt(),1);b();function ua(e,t=`"' `){if(e!=null)return e.replace(new RegExp(`^[${t}]+`),"").replace(new RegExp(`[${t}]+$`),"").replace(/["']/g,r=>"\\"+r).replace(/[\n]/g,r=>"\\00000A")}function k3(e){if(e!=null)return e.replace(new RegExp("::footnote-call","g"),"").replace(new RegExp("::footnote-marker","g"),"")}var Hd=class extends xe{constructor(t,r,a){super(t,r,a),this.stringSetSelectors={},this.type,this.pageLastString}onDeclaration(t,r,a,n){if(t.property==="string-set"){let i=Wd.default.generate(n.ruleNode.prelude),l=[],c=[],d=[];t.value.children.forEach(h=>{h.type==="Identifier"&&l.push(h.name),h.type==="Function"&&(c.push(h.name),h.children.forEach(k=>{k.type==="Identifier"&&d.push(k.name)}))}),l.forEach((h,k)=>{let x=c[k],p=d[k];this.stringSetSelectors[h]={identifier:h,func:x,value:p,selector:i}})}}onContent(t,r,a,n,i){if(t.name==="string"){let l=t.children&&t.children.first().name;this.type=t.children.last().name,t.name="var",t.children=new Wd.default.List,this.type==="first"||this.type==="last"||this.type==="start"||this.type==="first-except"?t.children.append(t.children.createItem({type:"Identifier",loc:null,name:"--pagedjs-string-"+this.type+"-"+l})):t.children.append(t.children.createItem({type:"Identifier",loc:null,name:"--pagedjs-string-first-"+l}))}}afterPageLayout(t){this.pageLastString===void 0&&(this.pageLastString={});for(let r of Object.keys(this.stringSetSelectors)){let a=this.stringSetSelectors[r],n=a.value,i=a.func,l=t.querySelectorAll(a.selector),c=r in this.pageLastString?this.pageLastString[r]:"",d,h,k,x;if(l.length==0)d=c,h=c,k=c,x=c;else{l.forEach(q=>{i==="content"&&(this.pageLastString[r]=l[l.length-1].textContent),i==="attr"&&(this.pageLastString[r]=l[l.length-1].getAttribute(n)||"")}),i==="content"&&(d=l[0].textContent),i==="attr"&&(d=l[0].getAttribute(n)||""),i==="content"&&(h=l[l.length-1].textContent),i==="attr"&&(h=l[l.length-1].getAttribute(n)||"");let p=l[0].getBoundingClientRect().top,v=l[0].closest(".pagedjs_page_content").getBoundingClientRect().top;p==v?k=d:k=c,x=""}t.style.setProperty(`--pagedjs-string-first-${r}`,`"${ua(d)}`),t.style.setProperty(`--pagedjs-string-last-${r}`,`"${ua(h)}`),t.style.setProperty(`--pagedjs-string-start-${r}`,`"${ua(k)}`),t.style.setProperty(`--pagedjs-string-first-except-${r}`,`"${ua(x)}`)}}},_3=Hd;b();var _i=He(bt(),1),$d=class extends xe{constructor(t,r,a){super(t,r,a),this.styleSheet=r.styleSheet,this.counterTargets={}}onContent(t,r,a,n,i){if(t.name==="target-counter"){let l=_i.default.generate(i.ruleNode.prelude),c=t.children.first(),d=c.name,h=_i.default.generate(t),k=[];c.children.forEach(q=>{q.type==="Identifier"&&k.push(q.name)});let x,p,g;t.children.forEach(q=>{q.type==="Identifier"&&(x?p||(g=_i.default.clone(q),p=q.name):x=q.name)});let v="target-counter-"+xt();l.split(",").forEach(q=>{this.counterTargets[q]={func:d,args:k,value:h,counter:x,style:p,selector:q,fullSelector:l,variable:v}}),t.name="counter",t.children=new _i.default.List,t.children.appendData({type:"Identifier",loc:0,name:v}),g&&(t.children.appendData({type:"Operator",loc:null,value:","}),t.children.appendData(g))}}afterPageLayout(t,r,a,n){Object.keys(this.counterTargets).forEach(i=>{let l=this.counterTargets[i],c=l.selector.split(/::?/g),d=c[0];n.pagesArea.querySelectorAll(d+":not([data-"+l.variable+"])").forEach((k,x)=>{if(l.func!=="attr")return;let p=zs(k,l.args),g=n.pagesArea.querySelector(Cs(p));if(g){let v=xt();k.setAttribute("data-"+l.variable,v);let q="";if(c.length>1&&(q+="::"+c[1]),l.counter==="page"){let O=n.pagesArea.querySelectorAll(".pagedjs_page"),M=0;for(let H=0;H<O.length;H++){let F=O[H],U=window.getComputedStyle(F),G=U["counter-reset"].replace("page","").trim(),Y=U["counter-increment"].replace("page","").trim();if(G!=="none"&&(M=parseInt(G)),Y!=="none"&&(M+=parseInt(Y)),F.contains(g))break}this.styleSheet.insertRule(`[data-${l.variable}="${v}"]${q} { counter-reset: ${l.variable} ${M}; }`,this.styleSheet.cssRules.length)}else{let O=g.getAttribute(`data-counter-${l.counter}-value`);O&&this.styleSheet.insertRule(`[data-${l.variable}="${v}"]${q} { counter-reset: ${l.variable} ${l.variable} ${parseInt(O)}; }`,this.styleSheet.cssRules.length)}let L=document.querySelector(`[data-${l.variable}="${v}"]`);L&&(L.style.display="none",L.clientHeight,L.style.removeProperty("display"))}})})}},w3=$d;b();var Ro=He(bt(),1),Gd=class extends xe{constructor(t,r,a){super(t,r,a),this.styleSheet=r.styleSheet,this.textTargets={},this.beforeContent="",this.afterContent="",this.selector={}}onContent(t,r,a,n,i){if(t.name==="target-text"){this.selector=Ro.default.generate(i.ruleNode.prelude);let l=t.children.first(),c=t.children.last(),d=l.name,h=Ro.default.generate(t),k=[];l.children.forEach(g=>{g.type==="Identifier"&&k.push(g.name)});let x;c!==l&&(x=c.name);let p="--pagedjs-"+xt();this.selector.split(",").forEach(g=>{this.textTargets[g]={func:d,args:k,value:h,style:x||"content",selector:g,fullSelector:this.selector,variable:p}}),t.name="var",t.children=new Ro.default.List,t.children.appendData({type:"Identifier",loc:0,name:p})}}onPseudoSelector(t,r,a,n,i){i.ruleNode.block.children.forEach(l=>{t.name==="before"&&l.property==="content"?l.value.children.forEach(d=>{d.type==="String"&&(this.beforeContent=d.value)}):t.name==="after"&&l.property==="content"&&l.value.children.forEach(c=>{c.type==="String"&&(this.afterContent=c.value)})})}afterParsed(t){Object.keys(this.textTargets).forEach(r=>{let a=this.textTargets[r],n=a.selector.split("::"),i=n[0],l=t.querySelectorAll(i),c;l.forEach((d,h)=>{let k=zs(d,a.args),x=t.querySelector(Cs(k));if(x)if(a.style){this.selector=xt(),d.setAttribute("data-target-text",this.selector);let p="";if(n.length>1&&(p+="::"+n[1]),a.style==="before"||a.style==="after"){let g=`${a.style}Content`;c=ua(this[g])}else c=ua(x.textContent," ");c=a.style==="first-letter"?c.charAt(0):c,this.styleSheet.insertRule(`[data-target-text="${this.selector}"]${p} { ${a.variable}: "${c}" }`)}else console.warn("missed target",k)})})}},v3=Gd;var x3=[b3,_3,w3,v3];b();b();var Ud=class extends xe{constructor(t,r,a){super(t,r,a)}filter(t){Ps(t,r=>this.filterEmpty(r),NodeFilter.SHOW_TEXT)}filterEmpty(t){if(t.textContent.length>1&&Un(t)){let r=t.parentNode;if(ft(r)&&r.closest("pre"))return NodeFilter.FILTER_REJECT;let n=Ts(t),i=Es(t);return i===null&&n===null?(t.textContent=" ",NodeFilter.FILTER_REJECT):i===null||n===null?NodeFilter.FILTER_ACCEPT:(t.textContent=" ",NodeFilter.FILTER_REJECT)}else return NodeFilter.FILTER_REJECT}},S3=Ud;b();var Vd=class extends xe{constructor(t,r,a){super(t,r,a)}filter(t){Ps(t,null,NodeFilter.SHOW_COMMENT)}},z3=Vd;b();var Yd=class extends xe{constructor(t,r,a){super(t,r,a)}filter(t){t.querySelectorAll("script").forEach(r=>{r.remove()})}},C3=Yd;b();var q3=He(bt(),1),O3=He(E3(),1);var Kd=class extends xe{constructor(t,r,a){super(t,r,a),this.displayRules={}}onDeclaration(t,r,a,n){if(t.property==="display"){let i=q3.default.generate(n.ruleNode.prelude),l=t.value.children.first().name;i.split(",").forEach(c=>{this.displayRules[c]={value:l,selector:c,specificity:(0,O3.calculateSpecificity)(c),important:t.important}})}}filter(t){let{matches:r,selectors:a}=this.sortDisplayedSelectors(t,this.displayRules);for(let i=0;i<r.length;i++){let l=r[i],c=a[i],d=c[c.length-1].value;this.removable(l)&&d==="none"&&(l.dataset.undisplayed="undisplayed")}let n=t.querySelectorAll("[style]");for(let i=0;i<n.length;i++){let l=n[i];this.removable(l)&&(l.dataset.undisplayed="undisplayed")}}sorter(t,r){return t.important&&!r.important?1:r.important&&!t.important?-1:t.specificity-r.specificity}sortDisplayedSelectors(t,r=[]){let a=[],n=[];for(let i in r){let l=r[i],c=l.selector,d=[];try{try{d=t.querySelectorAll(c)}catch{d=t.querySelectorAll(k3(c))}}catch{d=[]}let h=Array.from(d);for(let k of h)if(a.includes(k)){let x=a.indexOf(k);n[x].push(l),n[x]=n[x].sort(this.sorter)}else a.push(k),n.push([l])}return{matches:a,selectors:n}}removable(t){return!(t.style&&t.style.display!==""&&t.style.display!=="none")}},D3=Kd;var M3=[S3,z3,C3,D3];var e6=He(aa(),1),t6=He(Jw(),1),n0=[...y3,...x3,...M3],Wo=class{constructor(t,r,a){let n=[];n0.forEach(i=>{let l=new i(t,r,a);n.push(l),(0,t6.default)(l,this)})}};(0,e6.default)(Wo.prototype);function Ho(){for(var e=0;e<arguments.length;e++)n0.push(arguments[e])}function i0(e,t,r){return new Wo(e,t,r)}var $o=class{constructor(t){this.settings=t||{},this.polisher=new zd(!1),this.chunker=new eu(void 0,void 0,this.settings),this.hooks={},this.hooks.beforePreview=new ue(this),this.hooks.afterPreview=new ue(this),this.size={width:{value:8.5,unit:"in"},height:{value:11,unit:"in"},format:void 0,orientation:void 0},this.chunker.on("page",r=>{this.emit("page",r)}),this.chunker.on("rendering",()=>{this.emit("rendering",this.chunker)})}initializeHandlers(){let t=i0(this.chunker,this.polisher,this);return t.on("size",r=>{this.size=r,this.emit("size",r)}),t.on("atpages",r=>{this.atpages=r,this.emit("atpages",r)}),t}registerHandlers(){return Ho.apply(Ho,arguments)}getParams(t){let r,a=new URL(window.location),n=new URLSearchParams(a.search);for(var i of n.entries())i[0]===t&&(r=i[1]);return r}wrapContent(){let t=document.querySelector("body"),r;return r=t.querySelector(":scope > template[data-ref='pagedjs-content']"),r||(r=document.createElement("template"),r.dataset.ref="pagedjs-content",r.innerHTML=t.innerHTML,t.innerHTML="",t.appendChild(r)),r.content}removeStyles(t=document){let r=Array.from(t.querySelectorAll("link[rel='stylesheet']:not([data-pagedjs-ignore], [media~='screen'])")),a=Array.from(t.querySelectorAll("style:not([data-pagedjs-inserted-styles], [data-pagedjs-ignore], [media~='screen'])"));return[...r,...a].sort(function(i,l){let c=i.compareDocumentPosition(l);return c===Node.DOCUMENT_POSITION_PRECEDING?1:c===Node.DOCUMENT_POSITION_FOLLOWING?-1:0}).map(i=>{if(i.nodeName==="STYLE"){let l={};return l[window.location.href]=i.textContent,i.remove(),l}if(i.nodeName==="LINK")return i.remove(),i.href;console.warn(`Unable to process: ${i}, ignoring.`)})}async preview(t,r,a){await this.hooks.beforePreview.trigger(t,a),t||(t=this.wrapContent()),r||(r=this.removeStyles()),this.polisher.setup(),this.handlers=this.initializeHandlers(),await this.polisher.add(...r);let n=performance.now(),i=await this.chunker.flow(t,a),l=performance.now();return i.performance=l-n,i.size=this.size,this.emit("rendered",i),await this.hooks.afterPreview.trigger(i.pages),i}};(0,r6.default)($o.prototype);var s0=$o;async function a6(e,t,r){r.innerHTML="",document.querySelectorAll("style[data-pagedjs-inserted-styles]").forEach(n=>n.remove()),await new s0().preview(e,t,r)}function n6(){window.print()}b();var i6={none:{body:"system-serif",heading:"system-serif"},"light-neat-1":{body:"inter",heading:"inter"},"light-neat-2":{body:"ibm-plex-sans",heading:"ibm-plex-sans"},"light-neat-3":{body:"raleway",heading:"raleway"},"light-academic-1":{body:"source-serif-4",heading:"source-serif-4"},"light-academic-2":{body:"crimson-pro",heading:"inter"},"beige-decent-1":{body:"lora",heading:"lora"},"beige-decent-2":{body:"noto-serif",heading:"noto-serif"}};b();function s6(e){return e.trim().toLowerCase().replace(/-/g,"_")}function o0(e){let t=e.indexOf("=");return t<0?{key:s6(e),value:""}:{key:s6(e.slice(0,t)),value:e.slice(t+1).trim()}}function o6(e,t){Array.prototype.forEach.call(e.querySelectorAll("[data-show-when]"),r=>{let{key:a,value:n}=o0(r.getAttribute("data-show-when")||"");t[a]===n?r.removeAttribute("data-show-when"):r.remove()}),Array.prototype.forEach.call(e.querySelectorAll("[data-hide-when]"),r=>{let{key:a,value:n}=o0(r.getAttribute("data-hide-when")||"");t[a]===n?r.remove():r.removeAttribute("data-hide-when")})}function l6(e){let t={};for(let a of["data-show-when","data-hide-when"])Array.prototype.forEach.call(e.querySelectorAll("["+a+"]"),n=>{let{key:i,value:l}=o0(n.getAttribute(a)||"");(t[i]=t[i]||new Set).add(l)});let r={};for(let a of Object.keys(t))r[a]=Array.from(t[a]).sort();return r}var xM="0.1.0";function kn(){return window.__ORZ_PAGED__||{}}function Uo(){let e=document.getElementById("orz-src");return(e&&e.textContent||"").replace(/^\n/,"").replace(/\n\s*$/,"")}function u6(){let e=document.getElementById("orz-pages");return e||(e=document.createElement("div"),e.id="orz-pages",e.setAttribute("data-orz-copy",""),document.body.appendChild(e)),e}function Go(e){return new Promise((t,r)=>{if(!e||document.querySelector(`script[data-lib="${e}"]`))return t();let a=document.createElement("script");a.src=e,a.async=!0,a.setAttribute("data-lib",e),a.setAttribute("data-orz-runtime","1"),a.onload=()=>t(),a.onerror=()=>r(new Error("failed to load "+e)),document.head.appendChild(a)})}function Si(e,t){if(!e||t&&document.getElementById(t)||!t&&document.querySelector(`link[href="${e}"]`))return;let r=document.createElement("link");r.rel="stylesheet",r.href=e,t&&(r.id=t),r.setAttribute("data-orz-runtime","1"),document.head.appendChild(r)}function SM(e){try{let t=document.createElement("img");t.src=e.toDataURL("image/png"),t.className=e.className,t.style.maxWidth="100%";let r=e.getAttribute("data-md");r!=null&&t.setAttribute("data-md",r),e.replaceWith(t)}catch{}}async function zM(e){let t=kn().enhancers||{},r=window,a=[];t.hljsJs&&e.querySelector("pre code")&&(await Go(t.hljsJs),r.hljs&&e.querySelectorAll("pre code:not(.hljs)").forEach(n=>{try{r.hljs.highlightElement(n)}catch{}})),t.mermaidJs&&e.querySelector(".mermaid")&&(await Go(t.mermaidJs),r.mermaid&&(r.mermaid.initialize({startOnLoad:!1}),a.push(Promise.resolve(r.mermaid.run({nodes:e.querySelectorAll(".mermaid")})).catch(()=>{})))),t.smilesJs&&e.querySelector("canvas[data-smiles]")&&(await Go(t.smilesJs),r.SmilesDrawer&&e.querySelectorAll("canvas[data-smiles]").forEach(n=>{let i=new r.SmilesDrawer.Drawer({width:n.width,height:n.height});a.push(new Promise(l=>{r.SmilesDrawer.parse(n.getAttribute("data-smiles"),c=>{try{i.draw(c,n,"light",!1)}catch{}l()},()=>l())}))})),t.chartJs&&e.querySelector("canvas.orz-chart[data-chart]")&&(await Go(t.chartJs),r.Chart&&e.querySelectorAll("canvas.orz-chart[data-chart]").forEach(n=>{try{let i=JSON.parse(n.getAttribute("data-chart")||"{}");i.options={...i.options||{},responsive:!1,animation:!1},new r.Chart(n,i)}catch{}})),await Promise.all(a),e.querySelectorAll("canvas").forEach(n=>SM(n))}var Vo=null,Zo=null,l0={},d6={};function CM(e){let t=kn(),r=Zo||e.theme,a=[];return t.mode==="cdn"?(t.baseUrl&&a.push(t.baseUrl),r!=="none"&&t.themeUrls&&t.themeUrls[r]&&a.push(t.themeUrls[r])):(t.baseCss&&a.push({"orz-base.css":t.baseCss}),r!=="none"&&t.themes&&t.themes[r]&&a.push({"orz-theme.css":t.themes[r]})),a.push({"orz-page.css":e.css}),a}async function Yo(e){let t=Mc(e);Vo=t;let r=Zo||t.theme,a=i6[r];a&&(Si(Or(a.body).cssUrl),Si(Or(a.heading).cssUrl)),t.fontCssUrls.forEach(l=>Si(l)),kn().katexCss&&Si(kn().katexCss,"orz-katex"),kn().hljsCss&&Si(kn().hljsCss,"orz-hljs");let n=document.createElement("div");n.className="orz-stage",n.style.cssText="position:absolute;left:-99999px;top:0;width:680px;",n.innerHTML=t.bodyHtml,document.body.appendChild(n),d6=l6(n),l0={...t.settings.dynamicChoices},o6(n,l0);let i=document.createElement("div");i.style.cssText="position:absolute;left:-99999px;top:0;width:900px;",document.body.appendChild(i);try{if(await zM(n.querySelector(".orz-doc")||n),document.fonts&&document.fonts.ready)try{await document.fonts.ready}catch{}await a6(n.innerHTML,CM(t),i);let l=u6(),c=l.scrollTop;if(l.replaceChildren(...Array.prototype.slice.call(i.childNodes)),l.scrollTop=c,t.settings.frontMatterClean){let k=Array.prototype.slice.call(l.querySelectorAll(".pagedjs_page")).filter(x=>!x.classList.contains("pagedjs_orz-front_page"));document.documentElement.style.setProperty("--orz-body-pages",`"${k.length}"`),k.forEach((x,p)=>x.style.setProperty("--orz-pageno",`"${p+1}"`))}AM();let d=window.__orzPagedAfterRender;if(d)try{d()}catch{}}finally{n.remove(),i.remove()}}function AM(){let e=u6(),t=e.querySelector(".orz-toc");if(!t)return;let r=Number(t.getAttribute("data-max-level")||"3"),a=[];e.querySelectorAll(".pagedjs_page h1, .pagedjs_page h2, .pagedjs_page h3, .pagedjs_page h4").forEach(n=>{let i=Number(n.tagName.slice(1));if(i>r)return;let l=n.closest(".pagedjs_page"),c=l&&l.getAttribute("data-page-number")||"";a.push(`<li class="orz-toc-item orz-toc-l${i}"><span class="orz-toc-text">${n.textContent||""}</span><span class="orz-toc-page">${c}</span></li>`)}),a.length&&(t.innerHTML=`<ol class="orz-toc-list">${a.join("")}</ol>`)}var TM={version:xM,assemble:Mc,render:e=>Yo(e),refresh:()=>Yo(Uo()),exportPdf:()=>n6(),setTheme:e=>(Zo=e&&e!=="none"?e:null,Yo(Uo())),getTheme:()=>Zo||(Vo?Vo.theme:null),getDynamicState:()=>({options:d6,choices:l0}),get assembly(){return Vo},source:Uo};window.orzpaged=TM;function c6(){Yo(Uo()).catch(e=>console.error("[orz-paged]",e))}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",c6):c6();})();
1524
+ `;b();async function Lo(e,t={}){return new Promise(function(r,a){let n=new XMLHttpRequest;n.open(t.method||"get",e,!0);for(let i in t.headers)n.setRequestHeader(i,t.headers[i]);n.withCredentials=t.credentials==="include",n.onload=()=>{let i=n.status===0&&e.startsWith("file://")?200:n.status;r(new Response(n.responseText,{status:i}))},n.onerror=a,n.send(t.body||null)})}var Sd=class{constructor(t){this.sheets=[],this.inserted=[],this.hooks={},this.hooks.onUrl=new ue(this),this.hooks.onAtPage=new ue(this),this.hooks.onAtMedia=new ue(this),this.hooks.onRule=new ue(this),this.hooks.onDeclaration=new ue(this),this.hooks.onContent=new ue(this),this.hooks.onSelector=new ue(this),this.hooks.onPseudoSelector=new ue(this),this.hooks.onImport=new ue(this),this.hooks.beforeTreeParse=new ue(this),this.hooks.beforeTreeWalk=new ue(this),this.hooks.afterTreeWalk=new ue(this),t!==!1&&this.setup()}setup(){return this.base=this.insert(t3),this.styleEl=document.createElement("style"),document.head.appendChild(this.styleEl),this.styleSheet=this.styleEl.sheet,this.styleSheet}async add(){let t=[],r=[];for(var a=0;a<arguments.length;a++){let n;if(typeof arguments[a]=="object")for(let i in arguments[a]){let l=arguments[a];n=new Promise(function(c,d){r.push(i),c(l[i])})}else r.push(arguments[a]),n=Lo(arguments[a]).then(i=>i.text());t.push(n)}return await Promise.all(t).then(async n=>{let i="";for(let l=0;l<n.length;l++)i=await this.convertViaSheet(n[l],r[l]),this.insert(i);return i})}async convertViaSheet(t,r){let a=new e3(r,this.hooks);await a.parse(t);for(let n of a.imported){let i=await Lo(n).then(c=>c.text()),l=await this.convertViaSheet(i,n);this.insert(l)}return this.sheets.push(a),typeof a.width<"u"&&(this.width=a.width),typeof a.height<"u"&&(this.height=a.height),typeof a.orientation<"u"&&(this.orientation=a.orientation),a.toString()}insert(t){let r=document.querySelector("head"),a=document.createElement("style");return a.setAttribute("data-pagedjs-inserted-styles","true"),a.appendChild(document.createTextNode(t)),r.appendChild(a),this.inserted.push(a),a}destroy(){this.styleEl.remove(),this.inserted.forEach(t=>{t.remove()}),this.sheets=[]}},zd=Sd;b();var r6=He(aa(),1);b();b();b();b();var r3=He(aa(),1),Po=class{constructor(t,r,a){let n=Object.assign({},t&&t.hooks,r&&r.hooks,a&&a.hooks);this.chunker=t,this.polisher=r,this.caller=a;for(let i in n)i in this&&n[i].register(this[i].bind(this))}};(0,r3.default)(Po.prototype);var xe=Po;var ce=He(bt(),1);b();var Cd={A0:{width:{value:841,unit:"mm"},height:{value:1189,unit:"mm"}},A1:{width:{value:594,unit:"mm"},height:{value:841,unit:"mm"}},A2:{width:{value:420,unit:"mm"},height:{value:594,unit:"mm"}},A3:{width:{value:297,unit:"mm"},height:{value:420,unit:"mm"}},A4:{width:{value:210,unit:"mm"},height:{value:297,unit:"mm"}},A5:{width:{value:148,unit:"mm"},height:{value:210,unit:"mm"}},A6:{width:{value:105,unit:"mm"},height:{value:148,unit:"mm"}},A7:{width:{value:74,unit:"mm"},height:{value:105,unit:"mm"}},A8:{width:{value:52,unit:"mm"},height:{value:74,unit:"mm"}},A9:{width:{value:37,unit:"mm"},height:{value:52,unit:"mm"}},A10:{width:{value:26,unit:"mm"},height:{value:37,unit:"mm"}},B4:{width:{value:250,unit:"mm"},height:{value:353,unit:"mm"}},B5:{width:{value:176,unit:"mm"},height:{value:250,unit:"mm"}},letter:{width:{value:8.5,unit:"in"},height:{value:11,unit:"in"}},legal:{width:{value:8.5,unit:"in"},height:{value:14,unit:"in"}},ledger:{width:{value:11,unit:"in"},height:{value:17,unit:"in"}}};var Ad=class extends xe{constructor(t,r,a){super(t,r,a),this.pages={},this.width=void 0,this.height=void 0,this.orientation=void 0,this.marginalia={}}pageModel(t){return{selector:t,name:void 0,psuedo:void 0,nth:void 0,marginalia:{},width:void 0,height:void 0,orientation:void 0,margin:{top:{},right:{},left:{},bottom:{}},padding:{top:{},right:{},left:{},bottom:{}},border:{top:{},right:{},left:{},bottom:{}},backgroundOrigin:void 0,block:{},marks:void 0,notes:void 0,added:!1}}onAtPage(t,r,a){let n,i,l="",c,d,h,k=!1;t.prelude?(c=this.getTypeSelector(t),d=this.getPsuedoSelector(t),h=this.getNthSelector(t),l=ce.default.generate(t.prelude)):l="*",l in this.pages?(n=this.pages[l],i=this.replaceMarginalia(t),k=!0,n.added=!1):(n=this.pageModel(l),i=this.replaceMarginalia(t),this.pages[l]=n),n.name=c,n.psuedo=d,n.nth=h,k?n.marginalia=Object.assign(n.marginalia,i):n.marginalia=i;let x=this.replaceNotes(t);n.notes=x;let p=this.replaceDeclarations(t);if(p.size&&(n.size=p.size,n.width=p.size.width,n.height=p.size.height,n.orientation=p.size.orientation,n.format=p.size.format),p.bleed&&p.bleed[0]!="auto")switch(p.bleed.length){case 4:n.bleed={top:p.bleed[0],right:p.bleed[1],bottom:p.bleed[2],left:p.bleed[3]};break;case 3:n.bleed={top:p.bleed[0],right:p.bleed[1],bottom:p.bleed[2],left:p.bleed[1]};break;case 2:n.bleed={top:p.bleed[0],right:p.bleed[1],bottom:p.bleed[0],left:p.bleed[1]};break;default:n.bleed={top:p.bleed[0],right:p.bleed[0],bottom:p.bleed[0],left:p.bleed[0]}}p.marks&&((!p.bleed||p.bleed&&p.bleed[0]==="auto")&&(n.bleed={top:{value:6,unit:"mm"},right:{value:6,unit:"mm"},bottom:{value:6,unit:"mm"},left:{value:6,unit:"mm"}}),n.marks=p.marks),p.margin&&(n.margin=p.margin),p.padding&&(n.padding=p.padding),p.border&&(n.border=p.border),p.marks&&(n.marks=p.marks),k?n.block.children.appendList(t.block.children):n.block=t.block,a.remove(r)}afterTreeWalk(t,r){let a="*"in this.pages&&this.pages["*"].added===!1;if(this.addPageClasses(this.pages,t,r),a){let n=this.pages["*"].width,i=this.pages["*"].height,l=this.pages["*"].format,c=this.pages["*"].orientation,d=this.pages["*"].bleed,h=this.pages["*"].marks,k,x;":left"in this.pages&&(k=this.pages[":left"].bleed),":right"in this.pages&&(x=this.pages[":right"].bleed),n&&i&&(this.width!==n||this.height!==i)&&(this.width=n,this.height=i,this.format=l,this.orientation=c,this.addRootVars(t,n,i,c,d,x,k,h),this.addRootPage(t,this.pages["*"].size,d,x,k),this.emit("size",{width:n,height:i,orientation:c,format:l,bleed:d}),this.emit("atpages",this.pages))}}getTypeSelector(t){let r;return ce.default.walk(t,{visit:"TypeSelector",enter:(a,n,i)=>{r=a.name}}),r}getPsuedoSelector(t){let r;return ce.default.walk(t,{visit:"PseudoClassSelector",enter:(a,n,i)=>{a.name!=="nth"&&(r=a.name)}}),r}getNthSelector(t){let r;return ce.default.walk(t,{visit:"PseudoClassSelector",enter:(a,n,i)=>{a.name==="nth"&&a.children&&(r=a.children.first().value)}}),r}replaceMarginalia(t){let r={},a=["top-left-corner","top-left","top","top-center","top-right","top-right-corner","bottom-left-corner","bottom-left","bottom","bottom-center","bottom-right","bottom-right-corner","left-top","left-middle","left","left-bottom","top-right-corner","right-top","right-middle","right","right-bottom","right-right-corner"];return ce.default.walk(t.block,{visit:"Atrule",enter:(n,i,l)=>{let c=n.name;a.includes(c)&&(c==="top"&&(c="top-center"),c==="right"&&(c="right-middle"),c==="left"&&(c="left-middle"),c==="bottom"&&(c="bottom-center"),r[c]=n.block,l.remove(i))}}),r}replaceNotes(t){let r={};return ce.default.walk(t.block,{visit:"Atrule",enter:(a,n,i)=>{let l=a.name;l==="footnote"&&(r[l]=a.block,i.remove(n))}}),r}replaceDeclarations(t){let r={};return ce.default.walk(t.block,{visit:"Declaration",enter:(a,n,i)=>{let l=ce.default.property(a.property).name;if(l==="marks")r.marks=[],ce.default.walk(a,{visit:"Identifier",enter:c=>{r.marks.push(c.name)}}),i.remove(n);else if(l==="margin")r.margin=this.getMargins(a),i.remove(n);else if(l.indexOf("margin-")===0){let c=l.substring(7);r.margin||(r.margin={top:{},right:{},left:{},bottom:{}}),r.margin[c]=a.value.children.first(),i.remove(n)}else if(l==="padding")r.padding=this.getPaddings(a.value),i.remove(n);else if(l.indexOf("padding-")===0){let c=l.substring(8);r.padding||(r.padding={top:{},right:{},left:{},bottom:{}}),r.padding[c]=a.value.children.first(),i.remove(n)}else if(l==="border")r.border||(r.border={top:{},right:{},left:{},bottom:{}}),r.border.top=ce.default.generate(a.value),r.border.right=ce.default.generate(a.value),r.border.left=ce.default.generate(a.value),r.border.bottom=ce.default.generate(a.value),i.remove(n);else if(l.indexOf("border-")===0){r.border||(r.border={top:{},right:{},left:{},bottom:{}});let c=l.substring(7);r.border[c]=ce.default.generate(a.value),i.remove(n)}else l==="size"?(r.size=this.getSize(a),i.remove(n)):l==="bleed"&&(r.bleed=[],ce.default.walk(a,{enter:c=>{switch(c.type){case"String":c.value.indexOf("auto")>-1&&r.bleed.push("auto");break;case"Dimension":r.bleed.push({value:c.value,unit:c.unit});break;case"Number":r.bleed.push({value:c.value,unit:"px"});break;default:}}}),i.remove(n))}}),r}getSize(t){let r,a,n,i;return ce.default.walk(t,{visit:"Dimension",enter:(l,c,d)=>{let{value:h,unit:k}=l;typeof r>"u"?r={value:h,unit:k}:typeof a>"u"&&(a={value:h,unit:k})}}),ce.default.walk(t,{visit:"String",enter:(l,c,d)=>{let h=l.value.replace(/["|']/g,""),k=Cd[h];k&&(r=k.width,a=k.height)}}),ce.default.walk(t,{visit:"Identifier",enter:(l,c,d)=>{let h=l.name;if(h==="landscape"||h==="portrait")n=l.name;else if(h!=="auto"){let k=Cd[h];k&&(r=k.width,a=k.height),i=h}}}),{width:r,height:a,orientation:n,format:i}}getMargins(t){let r=[],a={top:{},right:{},left:{},bottom:{}};if(ce.default.walk(t,{enter:n=>{switch(n.type){case"Dimension":r.push(n);break;case"Number":r.push({value:n.value,unit:"px"});break;default:}}}),r.length===1)for(let n in a)a[n]=r[0];else r.length===2?(a.top=r[0],a.right=r[1],a.bottom=r[0],a.left=r[1]):r.length===3?(a.top=r[0],a.right=r[1],a.bottom=r[2],a.left=r[1]):r.length===4&&(a.top=r[0],a.right=r[1],a.bottom=r[2],a.left=r[3]);return a}getPaddings(t){let r=[],a={top:{},right:{},left:{},bottom:{}};if(ce.default.walk(t,{enter:n=>{switch(n.type){case"Dimension":r.push(n);break;case"Number":r.push({value:n.value,unit:"px"});break;default:}}}),r.length===1)for(let n in a)a[n]=r[0];else r.length===2?(a.top=r[0],a.right=r[1],a.bottom=r[0],a.left=r[1]):r.length===3?(a.top=r[0],a.right=r[1],a.bottom=r[2],a.left=r[1]):r.length===4&&(a.top=r[0],a.right=r[1],a.bottom=r[2],a.left=r[3]);return a}getBorders(t){let r={top:{},right:{},left:{},bottom:{}};return t.prop=="border"?(r.top=ce.default.generate(t.value),r.right=ce.default.generate(t.value),r.bottom=ce.default.generate(t.value),r.left=ce.default.generate(t.value)):t.prop=="border-top"?r.top=ce.default.generate(t.value):t.prop=="border-right"?r.right=ce.default.generate(t.value):t.prop=="border-bottom"?r.bottom=ce.default.generate(t.value):t.prop=="border-left"&&(r.left=ce.default.generate(t.value)),r}addPageClasses(t,r,a){if("*"in t&&t["*"].added===!1){let n=this.createPage(t["*"],r.children,a);a.insertRule(n),t["*"].added=!0}if(":left"in t&&t[":left"].added===!1){let n=this.createPage(t[":left"],r.children,a);a.insertRule(n),t[":left"].added=!0}if(":right"in t&&t[":right"].added===!1){let n=this.createPage(t[":right"],r.children,a);a.insertRule(n),t[":right"].added=!0}if(":first"in t&&t[":first"].added===!1){let n=this.createPage(t[":first"],r.children,a);a.insertRule(n),t[":first"].added=!0}if(":blank"in t&&t[":blank"].added===!1){let n=this.createPage(t[":blank"],r.children,a);a.insertRule(n),t[":blank"].added=!0}for(let n in t)if(t[n].nth&&t[n].added===!1){let i=this.createPage(t[n],r.children,a);a.insertRule(i),t[n].added=!0}for(let n in t)if(t[n].name&&t[n].added===!1){let i=this.createPage(t[n],r.children,a);a.insertRule(i),t[n].added=!0}}createPage(t,r,a){let n=this.selectorsForPage(t),i=t.block.children.copy(),l={type:"Block",loc:0,children:i},c=this.createRule(n,l);return this.addMarginVars(t.margin,i,i.first()),this.addPaddingVars(t.padding,i,i.first()),this.addBorderVars(t.border,i,i.first()),t.width&&this.addDimensions(t.width,t.height,t.orientation,i,i.first()),t.marginalia&&(this.addMarginaliaStyles(t,r,c,a),this.addMarginaliaContent(t,r,c,a)),t.notes&&this.addNotesStyles(t.notes,t,r,c,a),c}addMarginVars(t,r,a){for(let n in t)if(typeof t[n].value<"u"){let i=t[n].value+(t[n].unit||""),l=r.createItem({type:"Declaration",property:"--pagedjs-margin-"+n,value:{type:"Raw",value:i}});r.append(l,a)}}addPaddingVars(t,r,a){for(let n in t)if(typeof t[n].value<"u"){let i=t[n].value+(t[n].unit||""),l=r.createItem({type:"Declaration",property:"--pagedjs-padding-"+n,value:{type:"Raw",value:i}});r.append(l,a)}}addBorderVars(t,r,a){for(let n of Object.keys(t)){let i=t[n];if(typeof i=="string"){let l=r.createItem({type:"Declaration",property:"--pagedjs-border-"+n,value:{type:"Raw",value:i}});r.append(l,a)}}}addDimensions(t,r,a,n,i){let l,c;l=le(t),c=le(r),a&&a!=="portrait"&&([l,c]=[c,l]);let d=this.createVariable("--pagedjs-pagebox-width",l);n.appendData(d);let h=this.createVariable("--pagedjs-pagebox-height",c);n.appendData(h)}addMarginaliaStyles(t,r,a,n){for(let i in t.marginalia){let l=ce.default.clone(t.marginalia[i]),c=!1;if(l.children.isEmpty())continue;ce.default.walk(l,{visit:"Declaration",enter:(x,p,g)=>{if(x.property==="content"&&(x.value.children&&x.value.children.first().name==="none"?c=!1:c=!0,g.remove(p)),x.property==="vertical-align"&&(ce.default.walk(x,{visit:"Identifier",enter:(v,q,L)=>{let O=v.name;O==="top"?v.name="flex-start":O==="middle"?v.name="center":O==="bottom"&&(v.name="flex-end")}}),x.property="align-items"),x.property==="width"&&(i==="top-left"||i==="top-center"||i==="top-right"||i==="bottom-left"||i==="bottom-center"||i==="bottom-right")){let v=ce.default.clone(x);v.property="max-width",g.appendData(v)}if(x.property==="height"&&(i==="left-top"||i==="left-middle"||i==="left-bottom"||i==="right-top"||i==="right-middle"||i==="right-bottom")){let v=ce.default.clone(x);v.property="max-height",g.appendData(v)}}});let d=this.selectorsForPageMargin(t,i),h=this.createRule(d,l);r.appendData(h);let k=ce.default.generate({type:"Selector",children:d});this.marginalia[k]={page:t,selector:k,block:t.marginalia[i],hasContent:c}}}addMarginaliaContent(t,r,a,n){let i;for(let l in t.marginalia){let c=ce.default.clone(t.marginalia[l]);if(ce.default.walk(c,{visit:"Declaration",enter:(g,v,q)=>{g.property!=="content"&&q.remove(v),g.value.children&&g.value.children.first().name==="none"&&(i=!0)}}),c.children.isEmpty())continue;let d=this.selectorsForPageMargin(t,l),h;d.insertData({type:"Combinator",name:">"}),d.insertData({type:"ClassSelector",name:"pagedjs_margin-content"}),d.insertData({type:"Combinator",name:">"}),d.insertData({type:"TypeSelector",name:"*"}),i?h=this.createDeclaration("display","none"):h=this.createDeclaration("display","block");let k=this.createRule(d,[h]);n.insertRule(k);let x=this.selectorsForPageMargin(t,l);x.insertData({type:"Combinator",name:">"}),x.insertData({type:"ClassSelector",name:"pagedjs_margin-content"}),x.insertData({type:"PseudoElementSelector",name:"after",children:null});let p=this.createRule(x,c);n.insertRule(p)}}addRootVars(t,r,a,n,i,l,c,d){let h=[],k=new ce.default.List;k.insertData({type:"PseudoClassSelector",name:"root",children:null});let x,p,g,v,q,L;if(!i)x=le(r),p=le(a),g=le(r),v=le(a),q=le(r),L=le(a);else{x=`calc( ${le(r)} + ${le(i.left)} + ${le(i.right)} )`,p=`calc( ${le(a)} + ${le(i.top)} + ${le(i.bottom)} )`,g=`calc( ${le(r)} + ${le(i.left)} + ${le(i.right)} )`,v=`calc( ${le(a)} + ${le(i.top)} + ${le(i.bottom)} )`,q=`calc( ${le(r)} + ${le(i.left)} + ${le(i.right)} )`,L=`calc( ${le(a)} + ${le(i.top)} + ${le(i.bottom)} )`;let X=this.createVariable("--pagedjs-bleed-top",le(i.top)),ne=this.createVariable("--pagedjs-bleed-right",le(i.right)),ve=this.createVariable("--pagedjs-bleed-bottom",le(i.bottom)),be=this.createVariable("--pagedjs-bleed-left",le(i.left)),Le=this.createVariable("--pagedjs-bleed-right-top",le(i.top)),Ne=this.createVariable("--pagedjs-bleed-right-right",le(i.right)),Ae=this.createVariable("--pagedjs-bleed-right-bottom",le(i.bottom)),Te=this.createVariable("--pagedjs-bleed-right-left",le(i.left)),ie=this.createVariable("--pagedjs-bleed-left-top",le(i.top)),Yt=this.createVariable("--pagedjs-bleed-left-right",le(i.right)),da=this.createVariable("--pagedjs-bleed-left-bottom",le(i.bottom)),pa=this.createVariable("--pagedjs-bleed-left-left",le(i.left));l&&(Le=this.createVariable("--pagedjs-bleed-right-top",le(l.top)),Ne=this.createVariable("--pagedjs-bleed-right-right",le(l.right)),Ae=this.createVariable("--pagedjs-bleed-right-bottom",le(l.bottom)),Te=this.createVariable("--pagedjs-bleed-right-left",le(l.left)),g=`calc( ${le(r)} + ${le(l.left)} + ${le(l.right)} )`,v=`calc( ${le(a)} + ${le(l.top)} + ${le(l.bottom)} )`),c&&(ie=this.createVariable("--pagedjs-bleed-left-top",le(c.top)),Yt=this.createVariable("--pagedjs-bleed-left-right",le(c.right)),da=this.createVariable("--pagedjs-bleed-left-bottom",le(c.bottom)),pa=this.createVariable("--pagedjs-bleed-left-left",le(c.left)),q=`calc( ${le(r)} + ${le(c.left)} + ${le(c.right)} )`,L=`calc( ${le(a)} + ${le(c.top)} + ${le(c.bottom)} )`);let zi=this.createVariable("--pagedjs-width",le(r)),Nr=this.createVariable("--pagedjs-height",le(a));h.push(X,ne,ve,be,Le,Ne,Ae,Te,ie,Yt,da,pa,zi,Nr)}if(d&&d.forEach(X=>{let ne=this.createVariable("--pagedjs-mark-"+X+"-display","block");h.push(ne)}),n){let X=this.createVariable("--pagedjs-orientation",n);h.push(X),n!=="portrait"&&([x,p]=[p,x],[g,v]=[v,g],[q,L]=[L,q])}let O=this.createVariable("--pagedjs-width",x),M=this.createVariable("--pagedjs-height",p),H=this.createVariable("--pagedjs-width-right",g),F=this.createVariable("--pagedjs-height-right",v),U=this.createVariable("--pagedjs-width-left",q),G=this.createVariable("--pagedjs-height-left",L);h.push(O,M,H,F,U,G);let Y=this.createRule(k,h);t.children.appendData(Y)}addNotesStyles(t,r,a,n,i){for(let l in t){let c=this.selectorsForPage(r);c.insertData({type:"Combinator",name:" "}),c.insertData({type:"ClassSelector",name:"pagedjs_"+l+"_content"});let d=this.createRule(c,t[l]);a.appendData(d)}}addRootPage(t,r,a,n,i){let{width:l,height:c,orientation:d,format:h}=r,k=new ce.default.List,x=new ce.default.List,p=new ce.default.List,g=new ce.default.List,v=new ce.default.List,q=new ce.default.List;if(a){let O=new ce.default.List,M=new ce.default.List;O.appendData({type:"Dimension",unit:l.unit,value:l.value}),O.appendData({type:"WhiteSpace",value:" "}),O.appendData({type:"Operator",value:"+"}),O.appendData({type:"WhiteSpace",value:" "}),O.appendData({type:"Dimension",unit:a.left.unit,value:a.left.value}),O.appendData({type:"WhiteSpace",value:" "}),O.appendData({type:"Operator",value:"+"}),O.appendData({type:"WhiteSpace",value:" "}),O.appendData({type:"Dimension",unit:a.right.unit,value:a.right.value}),M.appendData({type:"Dimension",unit:c.unit,value:c.value}),M.appendData({type:"WhiteSpace",value:" "}),M.appendData({type:"Operator",value:"+"}),M.appendData({type:"WhiteSpace",value:" "}),M.appendData({type:"Dimension",unit:a.top.unit,value:a.top.value}),M.appendData({type:"WhiteSpace",value:" "}),M.appendData({type:"Operator",value:"+"}),M.appendData({type:"WhiteSpace",value:" "}),M.appendData({type:"Dimension",unit:a.bottom.unit,value:a.bottom.value}),g.appendData({type:"Function",name:"calc",children:O}),g.appendData({type:"WhiteSpace",value:" "}),g.appendData({type:"Function",name:"calc",children:M})}else h?(g.appendData({type:"Identifier",name:h}),d&&(g.appendData({type:"WhiteSpace",value:" "}),g.appendData({type:"Identifier",name:d}))):(g.appendData({type:"Dimension",unit:l.unit,value:l.value}),g.appendData({type:"WhiteSpace",value:" "}),g.appendData({type:"Dimension",unit:c.unit,value:c.value}));k.appendData({type:"Declaration",property:"size",loc:null,value:{type:"Value",children:g}}),k.appendData({type:"Declaration",property:"margin",loc:null,value:{type:"Value",children:[{type:"Dimension",unit:"px",value:0}]}}),k.appendData({type:"Declaration",property:"padding",loc:null,value:{type:"Value",children:[{type:"Dimension",unit:"px",value:0}]}}),k.appendData({type:"Declaration",property:"padding",loc:null,value:{type:"Value",children:[{type:"Dimension",unit:"px",value:0}]}});let L=t.children.createItem({type:"Atrule",prelude:null,name:"page",block:{type:"Block",loc:null,children:k}});if(t.children.append(L),i){let O=new ce.default.List,M=new ce.default.List;O.appendData({type:"Dimension",unit:l.unit,value:l.value}),O.appendData({type:"WhiteSpace",value:" "}),O.appendData({type:"Operator",value:"+"}),O.appendData({type:"WhiteSpace",value:" "}),O.appendData({type:"Dimension",unit:i.left.unit,value:i.left.value}),O.appendData({type:"WhiteSpace",value:" "}),O.appendData({type:"Operator",value:"+"}),O.appendData({type:"WhiteSpace",value:" "}),O.appendData({type:"Dimension",unit:i.right.unit,value:i.right.value}),M.appendData({type:"Dimension",unit:c.unit,value:c.value}),M.appendData({type:"WhiteSpace",value:" "}),M.appendData({type:"Operator",value:"+"}),M.appendData({type:"WhiteSpace",value:" "}),M.appendData({type:"Dimension",unit:i.top.unit,value:i.top.value}),M.appendData({type:"WhiteSpace",value:" "}),M.appendData({type:"Operator",value:"+"}),M.appendData({type:"WhiteSpace",value:" "}),M.appendData({type:"Dimension",unit:i.bottom.unit,value:i.bottom.value}),v.appendData({type:"Function",name:"calc",children:O}),v.appendData({type:"WhiteSpace",value:" "}),v.appendData({type:"Function",name:"calc",children:M}),x.appendData({type:"Declaration",property:"size",loc:null,value:{type:"Value",children:v}});let H=t.children.createItem({type:"Atrule",prelude:null,name:"page :left",block:{type:"Block",loc:null,children:x}});t.children.append(H)}if(n){let O=new ce.default.List,M=new ce.default.List;O.appendData({type:"Dimension",unit:l.unit,value:l.value}),O.appendData({type:"WhiteSpace",value:" "}),O.appendData({type:"Operator",value:"+"}),O.appendData({type:"WhiteSpace",value:" "}),O.appendData({type:"Dimension",unit:n.left.unit,value:n.left.value}),O.appendData({type:"WhiteSpace",value:" "}),O.appendData({type:"Operator",value:"+"}),O.appendData({type:"WhiteSpace",value:" "}),O.appendData({type:"Dimension",unit:n.right.unit,value:n.right.value}),M.appendData({type:"Dimension",unit:c.unit,value:c.value}),M.appendData({type:"WhiteSpace",value:" "}),M.appendData({type:"Operator",value:"+"}),M.appendData({type:"WhiteSpace",value:" "}),M.appendData({type:"Dimension",unit:n.top.unit,value:n.top.value}),M.appendData({type:"WhiteSpace",value:" "}),M.appendData({type:"Operator",value:"+"}),M.appendData({type:"WhiteSpace",value:" "}),M.appendData({type:"Dimension",unit:n.bottom.unit,value:n.bottom.value}),q.appendData({type:"Function",name:"calc",children:O}),q.appendData({type:"WhiteSpace",value:" "}),q.appendData({type:"Function",name:"calc",children:M}),p.appendData({type:"Declaration",property:"size",loc:null,value:{type:"Value",children:q}});let H=t.children.createItem({type:"Atrule",prelude:null,name:"page :right",block:{type:"Block",loc:null,children:p}});t.children.append(H)}}getNth(t){let r=t.indexOf("n"),a=t.indexOf("+"),n=t.split("n"),i=t.split("+"),l=null,c=null;return r>-1?(l=n[0],a>-1&&(c=i[1])):c=t,{type:"Nth",loc:null,selector:null,nth:{type:"AnPlusB",loc:null,a:l,b:c}}}addPageAttributes(t,r,a){let n=[r.dataset.page];if(n&&n.length)for(let i of n)i&&(t.name=i,t.element.classList.add("pagedjs_named_page"),t.element.classList.add("pagedjs_"+i+"_page"),r.dataset.splitFrom||t.element.classList.add("pagedjs_"+i+"_first_page"))}getStartElement(t,r){let a=r&&r.node;if(!t&&!r)return;if(!a)return t.children[0];if(a.nodeType===1&&a.parentNode.nodeType===11||a.nodeType===1&&a.dataset.page)return a;let n=qs(a),i=n.querySelectorAll("[data-page]");return i.length?i[i.length-1]:n.children[0]}beforePageLayout(t,r,a,n){let i=this.getStartElement(r,a);i&&this.addPageAttributes(t,i,n.pages)}finalizePage(t,r,a,n){for(let i in this.marginalia){let l=this.marginalia[i],c=i.split(" "),d;r.element.matches(c[0])&&l.hasContent&&(d=r.element.querySelector(c[1]),d.classList.add("hasContent"))}["top","bottom"].forEach(i=>{let l=r.element.querySelector(".pagedjs_margin-"+i),c=r.element.querySelector(".pagedjs_margin-"+i+"-center"),d=r.element.querySelector(".pagedjs_margin-"+i+"-left"),h=r.element.querySelector(".pagedjs_margin-"+i+"-right"),k=c.classList.contains("hasContent"),x=d.classList.contains("hasContent"),p=h.classList.contains("hasContent"),g,v,q;if(x&&(v=window.getComputedStyle(d)["max-width"]),p&&(q=window.getComputedStyle(h)["max-width"]),k)if(g=window.getComputedStyle(c)["max-width"],g==="none"||g==="auto")if(!x&&!p)l.style["grid-template-columns"]="0 1fr 0";else if(x)if(p)if(v!=="none"&&v!=="auto")q!=="none"&&q!=="auto"?l.style["grid-template-columns"]=v+" 1fr "+q:l.style["grid-template-columns"]=v+" 1fr "+v;else if(q!=="none"&&q!=="auto")l.style["grid-template-columns"]=q+" 1fr "+q;else{l.style["grid-template-columns"]="auto auto 1fr",d.style["white-space"]="nowrap",c.style["white-space"]="nowrap",h.style["white-space"]="nowrap";let L=d.offsetWidth,O=c.offsetWidth,M=h.offsetWidth,H=L+O+M,F=O*100/H;F>40?l.style["grid-template-columns"]="minmax(16.66%, 1fr) minmax(33%, "+F+"%) minmax(16.66%, 1fr)":l.style["grid-template-columns"]="repeat(3, 1fr)",d.style["white-space"]="normal",c.style["white-space"]="normal",h.style["white-space"]="normal"}else if(v!=="none"&&v!=="auto")l.style["grid-template-columns"]=v+" 1fr "+v;else{l.style["grid-template-columns"]="auto auto 1fr",d.style["white-space"]="nowrap",c.style["white-space"]="nowrap";let L=d.offsetWidth,O=c.offsetWidth,M=L+O,H=O*100/M;l.style["grid-template-columns"]="minmax(16.66%, 1fr) minmax(33%, "+H+"%) minmax(16.66%, 1fr)",d.style["white-space"]="normal",c.style["white-space"]="normal"}else if(q!=="none"&&q!=="auto")l.style["grid-template-columns"]=q+" 1fr "+q;else{l.style["grid-template-columns"]="auto auto 1fr",h.style["white-space"]="nowrap",c.style["white-space"]="nowrap";let L=h.offsetWidth,O=c.offsetWidth,M=L+O,H=O*100/M;l.style["grid-template-columns"]="minmax(16.66%, 1fr) minmax(33%, "+H+"%) minmax(16.66%, 1fr)",h.style["white-space"]="normal",c.style["white-space"]="normal"}else g!=="none"&&g!=="auto"&&(x&&v!=="none"&&v!=="auto"?l.style["grid-template-columns"]=v+" "+g+" 1fr":p&&q!=="none"&&q!=="auto"?l.style["grid-template-columns"]="1fr "+g+" "+q:l.style["grid-template-columns"]="1fr "+g+" 1fr");else if(x)if(!p)l.style["grid-template-columns"]="1fr 0 0";else if(v!=="none"&&v!=="auto")q!=="none"&&q!=="auto"?l.style["grid-template-columns"]=v+" 1fr "+q:l.style["grid-template-columns"]=v+" 0 1fr";else if(q!=="none"&&q!=="auto")l.style["grid-template-columns"]="1fr 0 "+q;else{l.style["grid-template-columns"]="auto 1fr auto",d.style["white-space"]="nowrap",h.style["white-space"]="nowrap";let L=d.offsetWidth,O=h.offsetWidth,M=L+O,H=L*100/M;l.style["grid-template-columns"]="minmax(16.66%, "+H+"%) 0 1fr",d.style["white-space"]="normal",h.style["white-space"]="normal"}else q!=="none"&&q!=="auto"?l.style["grid-template-columns"]="1fr 0 "+q:l.style["grid-template-columns"]="0 0 1fr"}),["left","right"].forEach(i=>{let l=r.element.querySelector(".pagedjs_margin-"+i+"-middle.hasContent"),c=r.element.querySelector(".pagedjs_margin-"+i),d=r.element.querySelector(".pagedjs_margin-"+i+"-top"),h=r.element.querySelector(".pagedjs_margin-"+i+"-bottom"),k=d.classList.contains("hasContent"),x=h.classList.contains("hasContent"),p,g,v;k&&(g=window.getComputedStyle(d)["max-height"]),x&&(v=window.getComputedStyle(h)["max-height"]),l?(p=window.getComputedStyle(l)["max-height"],p==="none"||p==="auto"?!k&&!x?c.style["grid-template-rows"]="0 1fr 0":k?x?g!=="none"&&g!=="auto"?v!=="none"&&v!=="auto"?c.style["grid-template-rows"]=g+" calc(100% - "+g+" - "+v+") "+v:c.style["grid-template-rows"]=g+" calc(100% - "+g+"*2) "+g:v!=="none"&&v!=="auto"&&(c.style["grid-template-rows"]=v+" calc(100% - "+v+"*2) "+v):g!=="none"&&g!=="auto"&&(c.style["grid-template-rows"]=g+" calc(100% - "+g+"*2) "+g):v!=="none"&&v!=="auto"&&(c.style["grid-template-rows"]=v+" calc(100% - "+v+"*2) "+v):k&&g!=="none"&&g!=="auto"?c.style["grid-template-rows"]=g+" "+p+" calc(100% - ("+g+" + "+p+"))":x&&v!=="none"&&v!=="auto"?c.style["grid-template-rows"]="1fr "+p+" "+v:c.style["grid-template-rows"]="calc((100% - "+p+")/2) "+p+" calc((100% - "+p+")/2)"):k?x?g!=="none"&&g!=="auto"?v!=="none"&&v!=="auto"?c.style["grid-template-rows"]=g+" 1fr "+v:c.style["grid-template-rows"]=g+" 0 1fr":v!=="none"&&v!=="auto"?c.style["grid-template-rows"]="1fr 0 "+v:c.style["grid-template-rows"]="1fr 0 1fr":c.style["grid-template-rows"]="1fr 0 0":v!=="none"&&v!=="auto"?c.style["grid-template-rows"]="1fr 0 "+v:c.style["grid-template-rows"]="0 0 1fr"})}selectorsForPage(t){let r,a,n=new ce.default.List;return n.insertData({type:"ClassSelector",name:"pagedjs_page"}),t.name&&(n.insertData({type:"ClassSelector",name:"pagedjs_named_page"}),n.insertData({type:"ClassSelector",name:"pagedjs_"+t.name+"_page"})),t.psuedo&&!(t.name&&t.psuedo==="first")&&n.insertData({type:"ClassSelector",name:"pagedjs_"+t.psuedo+"_page"}),t.name&&t.psuedo==="first"&&n.insertData({type:"ClassSelector",name:"pagedjs_"+t.name+"_"+t.psuedo+"_page"}),t.nth&&(r=new ce.default.List,a=this.getNth(t.nth),r.insertData(a),n.insertData({type:"PseudoClassSelector",name:"nth-of-type",children:r})),n}selectorsForPageMargin(t,r){let a=this.selectorsForPage(t);return a.insertData({type:"Combinator",name:" "}),a.insertData({type:"ClassSelector",name:"pagedjs_margin-"+r}),a}createDeclaration(t,r,a){let n=new ce.default.List;return n.insertData({type:"Identifier",loc:null,name:r}),{type:"Declaration",loc:null,important:a,property:t,value:{type:"Value",loc:null,children:n}}}createVariable(t,r){return{type:"Declaration",loc:null,property:t,value:{type:"Raw",value:r}}}createCalculatedDimension(t,r,a,n="+"){let i=new ce.default.List,l=new ce.default.List;return r.forEach((c,d)=>{l.appendData({type:"Dimension",unit:c.unit,value:c.value}),l.appendData({type:"WhiteSpace",value:" "}),d+1<r.length&&(l.appendData({type:"Operator",value:n}),l.appendData({type:"WhiteSpace",value:" "}))}),i.insertData({type:"Function",loc:null,name:"calc",children:l}),{type:"Declaration",loc:null,important:a,property:t,value:{type:"Value",loc:null,children:i}}}createDimension(t,r,a){let n=new ce.default.List;return n.insertData({type:"Dimension",loc:null,value:r.value,unit:r.unit}),{type:"Declaration",loc:null,important:a,property:t,value:{type:"Value",loc:null,children:n}}}createBlock(t){let r=new ce.default.List;return t.forEach(a=>{r.insertData(a)}),{type:"Block",loc:null,children:r}}createRule(t,r){let a=new ce.default.List;return a.insertData({type:"Selector",children:t}),Array.isArray(r)&&(r=this.createBlock(r)),{type:"Rule",prelude:{type:"SelectorList",children:a},block:r}}},a3=Ad;b();var Td=He(bt(),1);var Ed=class extends xe{constructor(t,r,a){super(t,r,a),this.breaks={}}onDeclaration(t,r,a,n){let i=t.property;if(i==="page"){let c=t.value.children.first().name,d=Td.default.generate(n.ruleNode.prelude),k={property:i,value:c,selector:d,name:c};d.split(",").forEach(x=>{this.breaks[x]?this.breaks[x].push(k):this.breaks[x]=[k]}),a.remove(r)}if(i==="break-before"||i==="break-after"||i==="page-break-before"||i==="page-break-after"){let c=t.value.children.first().name,d=Td.default.generate(n.ruleNode.prelude);i==="page-break-before"?i="break-before":i==="page-break-after"&&(i="break-after");let h={property:i,value:c,selector:d};d.split(",").forEach(k=>{this.breaks[k]?this.breaks[k].push(h):this.breaks[k]=[h]}),a.remove(r)}}afterParsed(t){this.processBreaks(t,this.breaks)}processBreaks(t,r){for(let n in r){let i=t.querySelectorAll(n);for(var a=0;a<i.length;a++)for(let l of r[n])if(l.property==="break-after"){let c=jc(i[a],t);i[a].setAttribute("data-break-after",l.value),c&&c.setAttribute("data-previous-break-after",l.value)}else if(l.property==="break-before"){let c=cg(i[a],t);if(c){if(l.value==="page"&&Ds(i[a],c))continue;i[a].setAttribute("data-break-before",l.value),c.setAttribute("data-next-break-before",l.value)}}else if(l.property==="page"){i[a].setAttribute("data-page",l.value);let c=jc(i[a],t);c&&c.setAttribute("data-after-page",l.value)}else i[a].setAttribute("data-"+l.property,l.value)}}mergeBreaks(t,r){for(let a in r)a in t?t[a]=t[a].concat(r[a]):t[a]=r[a];return t}addBreakAttributes(t,r){let a=t.querySelector("[data-break-before]"),n=t.querySelector("[data-break-after]"),i=t.querySelector("[data-previous-break-after]");a&&(a.dataset.splitFrom?(r.splitFrom=a.dataset.splitFrom,t.setAttribute("data-split-from",a.dataset.splitFrom)):a.dataset.breakBefore&&a.dataset.breakBefore!=="avoid"&&(r.breakBefore=a.dataset.breakBefore,t.setAttribute("data-break-before",a.dataset.breakBefore))),n&&n.dataset&&(n.dataset.splitTo?(r.splitTo=n.dataset.splitTo,t.setAttribute("data-split-to",n.dataset.splitTo)):n.dataset.breakAfter&&n.dataset.breakAfter!=="avoid"&&(r.breakAfter=n.dataset.breakAfter,t.setAttribute("data-break-after",n.dataset.breakAfter))),i&&i.dataset&&i.dataset.previousBreakAfter&&i.dataset.previousBreakAfter!=="avoid"&&(r.previousBreakAfter=i.dataset.previousBreakAfter)}afterPageLayout(t,r){this.addBreakAttributes(t,r)}},n3=Ed;b();var i3=He(bt(),1),qd=class extends xe{constructor(t,r,a){super(t,r,a)}onAtMedia(t,r,a){let n=this.getMediaName(t),i;n.includes("print")?(i=t.block.children,a.appendList(i),a.remove(r)):!n.includes("all")&&!n.includes("pagedjs-ignore")&&a.remove(r)}getMediaName(t){let r=[];if(!(typeof t.prelude>"u"||t.prelude.type!=="AtrulePrelude"))return i3.default.walk(t.prelude,{visit:"Identifier",enter:(a,n,i)=>{r.push(a.name)}}),r}},s3=qd;b();var Od=class extends xe{constructor(t,r,a){super(t,r,a)}afterPageLayout(t,r,a,n){let i=Array.from(t.querySelectorAll("[data-split-from]")),l=t.parentNode,c=Array.prototype.indexOf.call(l.children,t),d;if(c===0)return;d=l.children[c-1];let h;i.forEach(k=>{let x=k.dataset.ref;h=d.querySelector("[data-ref='"+x+"']:not([data-split-to])"),h&&(h.dataset.splitTo=x,h.dataset.splitFrom||(h.dataset.splitOriginal=!0))}),h&&this.handleAlignment(h)}handleAlignment(t){let r=window.getComputedStyle(t),a=r["text-align"],n=r["text-align-last"];t.dataset.lastSplitElement="true",a==="justify"&&n==="auto"?t.dataset.alignLastSplitElement="justify":t.dataset.alignLastSplitElement=n}},o3=Od;b();var Io=He(bt(),1),Dd=class extends xe{constructor(t,r,a){super(t,r,a),this.styleSheet=r.styleSheet,this.counters={},this.resetCountersMap=new Map}onDeclaration(t,r,a,n){let i=t.property;if(i==="counter-increment"){this.handleIncrement(t,n);let l=!1;t.value.children.forEach(c=>{c.type&&c.type!=="WhiteSpace"&&(l=!0)}),l||a.remove(r)}else if(i==="counter-reset"){this.handleReset(t,n);let l=!1;t.value.children.forEach(c=>{c.type&&c.type!=="WhiteSpace"&&(l=!0)}),l||a.remove(r)}}afterParsed(t){this.processCounters(t,this.counters),this.scopeCounters(this.counters)}addCounter(t){return t in this.counters?this.counters[t]:(this.counters[t]={name:t,increments:{},resets:{}},this.counters[t])}handleIncrement(t,r){let a=[],n=t.value.children;return n.forEach((i,l)=>{if(i.type&&i.type==="Identifier"){let c=i.name;if(c==="page"||c.indexOf("target-counter-")===0)return;let d,h,k;l.next&&l.next.data.type==="WhiteSpace"&&(d=l.next),d&&d.next&&d.next.data.type==="Number"&&(h=d.next,k=parseInt(h.data.value));let x=Io.default.generate(r.ruleNode.prelude),p;c in this.counters?p=this.counters[c]:p=this.addCounter(c);let g={selector:x,number:k||1};p.increments[x]=g,a.push(g),n.remove(l),d&&n.remove(d),h&&n.remove(h)}}),a}handleReset(t,r){let a=t.value.children;a.forEach((n,i)=>{if(n.type&&n.type==="Identifier"){let l=n.name,c,d,h;i.next&&i.next.data.type==="WhiteSpace"&&(c=i.next),c&&c.next&&(c.next.data.type==="Number"?(d=c.next,h=parseInt(d.data.value)):c.next.data.type==="Function"&&c.next.data.name==="var"&&(d=c.next,h=c.next.data.children.head.data.name));let k,x,p=r.ruleNode.prelude;r.ruleNode.type==="Atrule"&&r.ruleNode.name==="page"?x=".pagedjs_page":x=Io.default.generate(p||r.ruleNode),l==="footnote"&&this.addFootnoteMarkerCounter(t.value.children),l in this.counters?k=this.counters[l]:k=this.addCounter(l);let g={selector:x,number:h||0};k.resets[x]=g,x!==".pagedjs_page"&&(a.remove(i),c&&a.remove(c),d&&a.remove(d))}})}processCounters(t,r){let a;for(let n in r)a=this.counters[n],this.processCounterIncrements(t,a),this.processCounterResets(t,a),n!=="page"&&this.addCounterValues(t,a)}scopeCounters(t){let r=[];for(let a in t)a!=="page"&&r.push(`${t[a].name} 0`);this.insertRule(`.pagedjs_pages { counter-reset: ${r.join(" ")} page 0 pages var(--pagedjs-page-count) footnote var(--pagedjs-footnotes-count) footnote-marker var(--pagedjs-footnotes-count)}`)}insertRule(t){this.styleSheet.insertRule(t,this.styleSheet.cssRules.length)}processCounterIncrements(t,r){let a;for(let n in r.increments){a=r.increments[n];let i=t.querySelectorAll(a.selector);for(let l=0;l<i.length;l++)i[l].setAttribute("data-counter-"+r.name+"-increment",a.number),i[l].getAttribute("data-counter-increment")?i[l].setAttribute("data-counter-increment",i[l].getAttribute("data-counter-increment")+" "+r.name):i[l].setAttribute("data-counter-increment",r.name)}}processCounterResets(t,r){let a;for(let i in r.resets){a=r.resets[i];let l=t.querySelectorAll(a.selector);for(var n=0;n<l.length;n++){let c=a.number;typeof c=="string"&&c.startsWith("--")&&(c=l[n].style.getPropertyValue(c)||0),l[n].setAttribute("data-counter-"+r.name+"-reset",c),l[n].getAttribute("data-counter-reset")?l[n].setAttribute("data-counter-reset",l[n].getAttribute("data-counter-reset")+" "+r.name):l[n].setAttribute("data-counter-reset",r.name)}}}addCounterValues(t,r){let a=r.name;if(a==="page"||a==="footnote")return;let n=t.querySelectorAll("[data-counter-"+a+"-reset], [data-counter-"+a+"-increment]"),i=0,l,c,d,h,k,x,p;for(let g=0;g<n.length;g++)l=n[g],x=0,p=[],l.hasAttribute("data-counter-"+a+"-reset")&&(d=l.getAttribute("data-counter-"+a+"-reset"),h=parseInt(d),x=h-i,p.push(`${a} ${x}`),i=h),l.hasAttribute("data-counter-"+a+"-increment")&&(c=l.getAttribute("data-counter-"+a+"-increment"),k=parseInt(c),i+=k,l.setAttribute("data-counter-"+a+"-value",i),p.push(`${a} ${k}`)),p.length>0&&this.incrementCounterForElement(l,p)}addFootnoteMarkerCounter(t){let r=[];Io.default.walk(t,{visit:"Identifier",enter:(a,n,i)=>{r.push(a.name)}}),!r.includes("footnote-maker")&&(t.insertData({type:"WhiteSpace",value:" "}),t.insertData({type:"Identifier",name:"footnote-marker"}),t.insertData({type:"WhiteSpace",value:" "}),t.insertData({type:"Number",value:0}))}incrementCounterForElement(t,r){if(!t||!r||r.length===0)return;let a=t.dataset.ref,n=Array.from(this.styleSheet.cssRules).filter(l=>l.selectorText===`[data-ref="${t.dataset.ref}"]:not([data-split-from])`&&l.style[0]==="counter-increment").map(l=>l.style.counterIncrement);n.push(this.mergeIncrements(r,(l,c)=>(parseInt(l)||0)+(parseInt(c)||0)));let i=this.mergeIncrements(n,(l,c)=>c);this.insertRule(`[data-ref="${a}"]:not([data-split-from]) { counter-increment: ${i} }`)}mergeIncrements(t,r){let a={};return t.forEach(n=>{let i=n.split(" ");for(let l=0;l<i.length;l+=2)a[i[l]]=r(a[i[l]],i[l+1])}),Object.entries(a).map(([n,i])=>`${n} ${i}`).join(" ")}afterPageLayout(t,r){let a=[];t.querySelectorAll("[data-counter-page-reset]:not([data-split-from])").forEach(l=>{let c=l.dataset&&l.dataset.ref;if(!(c&&this.resetCountersMap.has(c))){c&&this.resetCountersMap.set(c,"");let d=l.dataset.counterPageReset;a.push(`page ${d}`)}}),t.querySelectorAll("[data-counter-footnote-reset]:not([data-split-from])").forEach(l=>{let c=l.dataset.counterFootnoteReset;a.push(`footnote ${c}`),a.push(`footnote-marker ${c}`)}),a.length&&this.styleSheet.insertRule(`[data-page-number="${t.dataset.pageNumber}"] { counter-increment: none; counter-reset: ${a.join(" ")} }`,this.styleSheet.cssRules.length)}},l3=Dd;b();var Md=class extends xe{constructor(t,r,a){super(t,r,a)}afterParsed(t){let r=t.querySelectorAll("ol");for(var a of r)this.addDataNumbers(a)}afterPageLayout(t,r,a,n){var i=t.getElementsByTagName("ol");for(var l of i)l.firstElementChild&&(l.start=l.firstElementChild.dataset.itemNum)}addDataNumbers(t){let r=1;t.hasAttribute("start")&&(r=parseInt(t.getAttribute("start"),10),isNaN(r)&&(r=1));let a=t.children;for(var n=0;n<a.length;n++)a[n].setAttribute("data-item-num",n+r)}},c3=Md;b();var u3=He(bt(),1),jd=class extends xe{constructor(t,r,a){super(t,r,a),this.styleSheet=r.styleSheet,this.fixedElementsSelector=[],this.fixedElements=[]}onDeclaration(t,r,a,n){if(t.property==="position"&&t.value.children.first().name==="fixed"){let i=u3.default.generate(n.ruleNode.prelude);this.fixedElementsSelector.push(i),a.remove(r)}}afterParsed(t){this.fixedElementsSelector.forEach(r=>{t.querySelectorAll(`${r}`).forEach(a=>{a.style.setProperty("position","absolute"),this.fixedElements.push(a),a.remove()})})}afterPageLayout(t,r,a){this.fixedElements.forEach(n=>{let i=n.cloneNode(!0);t.querySelector(".pagedjs_pagebox").insertAdjacentElement("afterbegin",i)})}},d3=jd;b();var p3=He(bt(),1),Bd=class extends xe{constructor(t,r,a){super(t,r,a),this.styleSheet=r.styleSheet,this.pageCounter={name:"page",increments:{},resets:{}}}onDeclaration(t,r,a,n){t.property==="counter-increment"&&this.handleIncrement(t,n)&&a.remove(r)}afterParsed(t){for(let r in this.pageCounter.increments){let a=this.pageCounter.increments[r];this.insertRule(`${a.selector} { --pagedjs-page-counter-increment: ${a.number} }`)}}handleIncrement(t,r){let a=t.value.children.first(),n=t.value.children.getSize()>1?t.value.children.last().value:1,i=a&&a.name;if(i&&i.indexOf("target-counter-")===0||i!=="page"||r.ruleNode.name==="page"&&r.ruleNode.type==="Atrule")return;let l=p3.default.generate(r.ruleNode.prelude);return this.pageCounter.increments[l]={selector:l,number:n}}insertRule(t){this.styleSheet.insertRule(t,this.styleSheet.cssRules.length)}},f3=Bd;b();var Ld=He(bt(),1);var Pd=class extends xe{constructor(t,r,a){super(t,r,a),this.styleSheet=r.styleSheet,this.selectors={}}onRule(t,r,a){let n=Ld.default.generate(t.prelude);if(n.match(/:(first|last|nth)-of-type/)){let i=Ld.default.generate(t.block);i=i.replace(/[{}]/g,"");let l="nth-of-type-"+xt();n.split(",").forEach(c=>{this.selectors[c]?this.selectors[c][1]=`${this.selectors[c][1]};${i}`:this.selectors[c]=[l,i]}),a.remove(r)}}afterParsed(t){this.processSelectors(t,this.selectors)}processSelectors(t,r){for(let n in r){let i=t.querySelectorAll(n);for(var a=0;a<i.length;a++){let c=i[a].getAttribute("data-nth-of-type");c&&c!=""?(c=`${c},${r[n][0]}`,i[a].setAttribute("data-nth-of-type",c)):i[a].setAttribute("data-nth-of-type",r[n][0])}let l=`*[data-nth-of-type*='${r[n][0]}'] { ${r[n][1]}; }`;this.styleSheet.insertRule(l,this.styleSheet.cssRules.length)}}},h3=Pd;b();var Id=He(bt(),1);var Rd=class extends xe{constructor(t,r,a){super(t,r,a),this.styleSheet=r.styleSheet,this.selectors={}}onRule(t,r,a){let n=Id.default.generate(t.prelude);if(n.match(/\+/)){let i=Id.default.generate(t.block);i=i.replace(/[{}]/g,"");let l="following-"+xt();n.split(",").forEach(c=>{this.selectors[c]?this.selectors[c][1]=`${this.selectors[c][1]};${i}`:this.selectors[c]=[l,i]}),a.remove(r)}}afterParsed(t){this.processSelectors(t,this.selectors)}processSelectors(t,r){for(let n in r){let i=t.querySelectorAll(n);for(var a=0;a<i.length;a++){let c=i[a].getAttribute("data-following");c&&c!=""?(c=`${c},${r[n][0]}`,i[a].setAttribute("data-following",c)):i[a].setAttribute("data-following",r[n][0])}let l=`*[data-following*='${r[n][0]}'] { ${r[n][1]}; }`;this.styleSheet.insertRule(l,this.styleSheet.cssRules.length)}}},m3=Rd;b();var gn=He(bt(),1),Nd=class extends xe{constructor(t,r,a){super(t,r,a),this.footnotes={},this.needsLayout=[]}onDeclaration(t,r,a,n){let i=t.property;if(i==="float"){let l=t.value.children&&t.value.children.first();if((l&&l.name)==="footnote"){let d=gn.default.generate(n.ruleNode.prelude);this.footnotes[d]={selector:d,policy:"auto",display:"block"},a.remove(r)}}if(i==="footnote-policy"){let l=t.value.children&&t.value.children.first(),c=l&&l.name;if(c){let d=gn.default.generate(n.ruleNode.prelude),h=this.footnotes[d];h&&(h.policy=c)}}if(i==="footnote-display"){let l=t.value.children&&t.value.children.first(),c=l&&l.name,d=gn.default.generate(n.ruleNode.prelude);if(c&&this.footnotes[d]){let h=this.footnotes[d];h&&(h.display=c)}}}onPseudoSelector(t,r,a,n,i){let l=t.name;if(l==="footnote-marker"){let c=i.ruleNode.prelude,d=new gn.default.List;c.children.first().children.each(h=>{h.type!=="PseudoElementSelector"&&d.appendData(h)}),d.appendData({type:"AttributeSelector",name:{type:"Identifier",name:"data-footnote-marker"},flags:null,loc:null,matcher:null,value:null}),d.appendData({type:"PseudoElementSelector",name:"marker",loc:null,children:null}),c.children.first().children=d}if(l==="footnote-call"){let c=i.ruleNode.prelude,d=new gn.default.List;c.children.first().children.each(h=>{h.type!=="PseudoElementSelector"&&d.appendData(h)}),d.appendData({type:"AttributeSelector",name:{type:"Identifier",name:"data-footnote-call"},flags:null,loc:null,matcher:null,value:null}),d.appendData({type:"PseudoElementSelector",name:"after",loc:null,children:null}),c.children.first().children=d}}afterParsed(t){this.processFootnotes(t,this.footnotes)}processFootnotes(t,r){for(let n in r){let i=t.querySelectorAll(n),l,c=r[n];for(var a=0;a<i.length;a++)l=i[a],l.setAttribute("data-note","footnote"),l.setAttribute("data-break-before","avoid"),l.setAttribute("data-note-policy",c.policy||"auto"),l.setAttribute("data-note-display",c.display||"block"),this.processFootnoteContainer(l)}}processFootnoteContainer(t){let r=t.parentElement,a=r;for(;r;){if(Ms(r)){a.setAttribute("data-has-notes","true");break}a=r,r=r.parentElement,r||a.setAttribute("data-has-notes","true")}}renderNode(t){if(t.nodeType==1){let r;if(!t.dataset)return;t.dataset.note==="footnote"?r=[t]:(t.dataset.hasNotes||t.querySelectorAll("[data-note='footnote']"))&&(r=t.querySelectorAll("[data-note='footnote']")),r&&r.length&&this.findVisibleFootnotes(r,t)}}findVisibleFootnotes(t,r){let a,n,i;a=r.closest(".pagedjs_page_content"),n=a.getBoundingClientRect(),i=n.left+n.width;for(let l=0;l<t.length;++l){let c=t[l];c.getBoundingClientRect().left<i&&this.moveFootnote(c,r.closest(".pagedjs_area"),!0)}}moveFootnote(t,r,a){let n=r.querySelector(".pagedjs_footnote_area"),i=n.querySelector(".pagedjs_footnote_content"),l=i.querySelector(".pagedjs_footnote_inner_content");if(!ft(t))return;let c;if(a&&(c=this.createFootnoteCall(t)),t.removeAttribute("data-break-before"),l.querySelector(`[data-ref="${t.dataset.ref}"]`)){t.remove();return}l.appendChild(t),i.classList.contains("pagedjs_footnote_empty")&&i.classList.remove("pagedjs_footnote_empty"),t.dataset.footnoteMarker=t.dataset.ref,t.id=`note-${t.dataset.ref}`;let h=i.scrollHeight,x=r.querySelector(".pagedjs_page_content").getBoundingClientRect(),p=x.left+x.width,g=c&&c.getBoundingClientRect(),v=n.getBoundingClientRect(),q=this.marginsHeight(i),L=this.paddingHeight(i),O=this.borderHeight(i),M=q+L+O,H=Math.floor(v.top);v.height===0&&(H-=this.marginsHeight(i,!1),H-=this.paddingHeight(i,!1),H-=this.borderHeight(i,!1));let F=t.dataset.notePolicy,U=0,G=0;if(c){let be=c.previousSibling,Le=new Range;be?Le.setStartBefore(be):Le.setStartBefore(c),Le.setEndAfter(c);let Ne=Le.getBoundingClientRect();if(U=Ne.bottom,!F||F==="auto")G=Math.ceil(Ne.bottom);else if(F==="line")G=Math.ceil(Ne.top);else if(F==="block"){let Ae=c.closest("p").previousElementSibling;Ae?G=Math.ceil(Ae.getBoundingClientRect().bottom):G=Math.ceil(Ne.bottom)}}let Y=h+M-v.height,X=U?H-U:0,ne=U?Math.floor(v.top)-G:0,ve=n.querySelector("[data-note='footnote']");if(a&&g.left>p)t.remove();else if(!ve&&a&&M>X){r.style.setProperty("--pagedjs-footnotes-height","0px");let be=document.createElement("div");be.appendChild(t),this.needsLayout.push(be)}else a?U<v.top-Y?r.style.setProperty("--pagedjs-footnotes-height",`${h+q+O}px`):(r.style.setProperty("--pagedjs-footnotes-height",`${v.height+ne}px`),l.style.height=v.height+ne-M+"px"):r.style.setProperty("--pagedjs-footnotes-height",`${h+M}px`)}createFootnoteCall(t){let r=t.parentElement,a=document.createElement("a");for(let n of t.classList)a.classList.add(`${n}`);return a.dataset.footnoteCall=t.dataset.ref,a.dataset.ref=t.dataset.ref,a.dataset.dataCounterFootnoteIncrement=1,a.href=`#note-${t.dataset.ref}`,r.insertBefore(a,t),a}afterPageLayout(t,r,a,n){let i=t.querySelector(".pagedjs_area"),l=r.footnotesArea,c=l.querySelector(".pagedjs_footnote_content"),d=l.querySelector(".pagedjs_footnote_inner_content"),h=c.getBoundingClientRect(),{width:k}=h;d.style.columnWidth=Math.round(k)+"px",d.style.columnGap="calc(var(--pagedjs-margin-right) + var(--pagedjs-margin-left))";let p=new $s(l,void 0,n.settings).findOverflow(d,h);if(p){let{startContainer:g,startOffset:v}=p,q;if(ft(g)){let G=g.childNodes[v];q=ft(G)&&G.hasAttribute("data-footnote-marker")}let L=p.extractContents();if(!q){let G=L.firstElementChild;G.dataset.splitFrom=G.dataset.ref,this.handleAlignment(d.lastElementChild)}this.needsLayout.push(L),c.style.removeProperty("height"),d.style.removeProperty("height");let O=d.getBoundingClientRect(),{height:M}=O,H=this.marginsHeight(c),F=this.paddingHeight(c),U=this.borderHeight(c);if(i.style.setProperty("--pagedjs-footnotes-height",`${M+H+U+F}px`),d.childNodes.length===0&&c.classList.add("pagedjs_footnote_empty"),!a)n.clonePage(r);else{let G,Y;a.node&&typeof a.node.dataset<"u"&&typeof a.node.dataset.previousBreakAfter<"u"&&(Y=a.node.dataset.previousBreakAfter),a.node&&typeof a.node.dataset<"u"&&typeof a.node.dataset.breakBefore<"u"&&(G=a.node.dataset.breakBefore),(G||Y)&&n.clonePage(r)}}d.style.height="auto"}handleAlignment(t){let a=window.getComputedStyle(t)["text-align-last"];t.dataset.lastSplitElement="true",a==="auto"?t.dataset.alignLastSplitElement="justify":t.dataset.alignLastSplitElement=a}beforePageLayout(t){for(;this.needsLayout.length;){let r=this.needsLayout.shift();Array.from(r.childNodes).forEach(a=>{this.moveFootnote(a,t.element.querySelector(".pagedjs_area"),!1)})}}afterOverflowRemoved(t,r){let a=r.closest(".pagedjs_area"),n=a.querySelectorAll(".pagedjs_footnote_area [data-note='footnote']");for(let l=0;l<n.length;l++){let c=n[l];t.querySelector(`[data-footnote-call="${c.dataset.ref}"]`)&&c.remove()}let i=a.querySelector(".pagedjs_footnote_inner_content");i&&i.childNodes.length===0&&i.parentElement.classList.add("pagedjs_footnote_empty")}marginsHeight(t,r=!0){let a=window.getComputedStyle(t),n=parseInt(a.marginTop),i=parseInt(a.marginBottom),l=0;return n&&(l+=n),i&&r&&(l+=i),l}paddingHeight(t,r=!0){let a=window.getComputedStyle(t),n=parseInt(a.paddingTop),i=parseInt(a.paddingBottom),l=0;return n&&(l+=n),i&&r&&(l+=i),l}borderHeight(t,r=!0){let a=window.getComputedStyle(t),n=parseInt(a.borderTop),i=parseInt(a.borderBottom),l=0;return n&&(l+=n),i&&r&&(l+=i),l}},g3=Nd;var y3=[s3,a3,n3,o3,l3,c3,d3,f3,h3,m3,g3];b();b();var ki=He(bt(),1),Fd=class extends xe{constructor(t,r,a){super(t,r,a),this.runningSelectors={},this.elements={}}onDeclaration(t,r,a,n){if(t.property==="position"){let i=ki.default.generate(n.ruleNode.prelude),l=t.value.children.first().name;if(l==="running"){let c;ki.default.walk(t,{visit:"Function",enter:(d,h,k)=>{c=d.children.first().name}}),this.runningSelectors[c]={identifier:l,value:c,selector:i}}}t.property==="content"&&ki.default.walk(t,{visit:"Function",enter:(i,l,c)=>{if(i.name.indexOf("element")>-1){let d=ki.default.generate(n.ruleNode.prelude),h=i.name,k=i.children.first().name,x=[k],p="first";d.split(",").forEach(g=>{g=g.replace(/::after|::before/,""),this.elements[g]={func:h,args:x,value:k,style:p||"first",selector:g,fullSelector:d}})}}})}afterParsed(t){for(let r of Object.keys(this.runningSelectors)){let a=this.runningSelectors[r],n=Array.from(t.querySelectorAll(a.selector));if(a.identifier==="running")for(let i of n)i.style.display="none"}}afterPageLayout(t){for(let r of Object.keys(this.runningSelectors)){let a=this.runningSelectors[r],n=t.querySelector(a.selector);n&&(a.identifier==="running"?a.first=n:console.warn(a.value+"needs css replacement"))}this.orderedSelectors||(this.orderedSelectors=this.orderSelectors(this.elements));for(let r of this.orderedSelectors)if(r){let a=this.elements[r],n=t.querySelector(r);if(n){let i=this.runningSelectors[a.args[0]];if(i&&i.first){n.innerHTML="";let l=i.first.cloneNode(!0);l.style.display=null,n.appendChild(l)}}}}pageWeight(t){let r=1,a=t.split(" "),n=a.length&&a[0].split(".");switch(n.shift(),n.length){case 4:/^pagedjs_[\w-]+_first_page$/.test(n[3])?r=7:(n[3]==="pagedjs_left_page"||n[3]==="pagedjs_right_page")&&(r=6);break;case 3:n[1]==="pagedjs_named_page"&&(n[2].indexOf(":nth-of-type")>-1?r=7:r=5);break;case 2:n[1]==="pagedjs_first_page"?r=4:n[1]==="pagedjs_blank_page"?r=3:(n[1]==="pagedjs_left_page"||n[1]==="pagedjs_right_page")&&(r=2);break;default:n[0].indexOf(":nth-of-type")>-1?r=4:r=1}return r}orderSelectors(t){let r=Object.keys(t),a={1:[],2:[],3:[],4:[],5:[],6:[],7:[]},n=[];for(let l of r){let c=this.pageWeight(l);a[c].unshift(l)}for(var i=1;i<=7;i++)n=n.concat(a[i]);return n}beforeTreeParse(t,r){r.text=t.replace(/element[\s]*\(([^|^#)]*)\)/g,"element-ident($1)")}},b3=Fd;b();var Wd=He(bt(),1);b();function ua(e,t=`"' `){if(e!=null)return e.replace(new RegExp(`^[${t}]+`),"").replace(new RegExp(`[${t}]+$`),"").replace(/["']/g,r=>"\\"+r).replace(/[\n]/g,r=>"\\00000A")}function k3(e){if(e!=null)return e.replace(new RegExp("::footnote-call","g"),"").replace(new RegExp("::footnote-marker","g"),"")}var Hd=class extends xe{constructor(t,r,a){super(t,r,a),this.stringSetSelectors={},this.type,this.pageLastString}onDeclaration(t,r,a,n){if(t.property==="string-set"){let i=Wd.default.generate(n.ruleNode.prelude),l=[],c=[],d=[];t.value.children.forEach(h=>{h.type==="Identifier"&&l.push(h.name),h.type==="Function"&&(c.push(h.name),h.children.forEach(k=>{k.type==="Identifier"&&d.push(k.name)}))}),l.forEach((h,k)=>{let x=c[k],p=d[k];this.stringSetSelectors[h]={identifier:h,func:x,value:p,selector:i}})}}onContent(t,r,a,n,i){if(t.name==="string"){let l=t.children&&t.children.first().name;this.type=t.children.last().name,t.name="var",t.children=new Wd.default.List,this.type==="first"||this.type==="last"||this.type==="start"||this.type==="first-except"?t.children.append(t.children.createItem({type:"Identifier",loc:null,name:"--pagedjs-string-"+this.type+"-"+l})):t.children.append(t.children.createItem({type:"Identifier",loc:null,name:"--pagedjs-string-first-"+l}))}}afterPageLayout(t){this.pageLastString===void 0&&(this.pageLastString={});for(let r of Object.keys(this.stringSetSelectors)){let a=this.stringSetSelectors[r],n=a.value,i=a.func,l=t.querySelectorAll(a.selector),c=r in this.pageLastString?this.pageLastString[r]:"",d,h,k,x;if(l.length==0)d=c,h=c,k=c,x=c;else{l.forEach(q=>{i==="content"&&(this.pageLastString[r]=l[l.length-1].textContent),i==="attr"&&(this.pageLastString[r]=l[l.length-1].getAttribute(n)||"")}),i==="content"&&(d=l[0].textContent),i==="attr"&&(d=l[0].getAttribute(n)||""),i==="content"&&(h=l[l.length-1].textContent),i==="attr"&&(h=l[l.length-1].getAttribute(n)||"");let p=l[0].getBoundingClientRect().top,v=l[0].closest(".pagedjs_page_content").getBoundingClientRect().top;p==v?k=d:k=c,x=""}t.style.setProperty(`--pagedjs-string-first-${r}`,`"${ua(d)}`),t.style.setProperty(`--pagedjs-string-last-${r}`,`"${ua(h)}`),t.style.setProperty(`--pagedjs-string-start-${r}`,`"${ua(k)}`),t.style.setProperty(`--pagedjs-string-first-except-${r}`,`"${ua(x)}`)}}},_3=Hd;b();var _i=He(bt(),1),$d=class extends xe{constructor(t,r,a){super(t,r,a),this.styleSheet=r.styleSheet,this.counterTargets={}}onContent(t,r,a,n,i){if(t.name==="target-counter"){let l=_i.default.generate(i.ruleNode.prelude),c=t.children.first(),d=c.name,h=_i.default.generate(t),k=[];c.children.forEach(q=>{q.type==="Identifier"&&k.push(q.name)});let x,p,g;t.children.forEach(q=>{q.type==="Identifier"&&(x?p||(g=_i.default.clone(q),p=q.name):x=q.name)});let v="target-counter-"+xt();l.split(",").forEach(q=>{this.counterTargets[q]={func:d,args:k,value:h,counter:x,style:p,selector:q,fullSelector:l,variable:v}}),t.name="counter",t.children=new _i.default.List,t.children.appendData({type:"Identifier",loc:0,name:v}),g&&(t.children.appendData({type:"Operator",loc:null,value:","}),t.children.appendData(g))}}afterPageLayout(t,r,a,n){Object.keys(this.counterTargets).forEach(i=>{let l=this.counterTargets[i],c=l.selector.split(/::?/g),d=c[0];n.pagesArea.querySelectorAll(d+":not([data-"+l.variable+"])").forEach((k,x)=>{if(l.func!=="attr")return;let p=zs(k,l.args),g=n.pagesArea.querySelector(Cs(p));if(g){let v=xt();k.setAttribute("data-"+l.variable,v);let q="";if(c.length>1&&(q+="::"+c[1]),l.counter==="page"){let O=n.pagesArea.querySelectorAll(".pagedjs_page"),M=0;for(let H=0;H<O.length;H++){let F=O[H],U=window.getComputedStyle(F),G=U["counter-reset"].replace("page","").trim(),Y=U["counter-increment"].replace("page","").trim();if(G!=="none"&&(M=parseInt(G)),Y!=="none"&&(M+=parseInt(Y)),F.contains(g))break}this.styleSheet.insertRule(`[data-${l.variable}="${v}"]${q} { counter-reset: ${l.variable} ${M}; }`,this.styleSheet.cssRules.length)}else{let O=g.getAttribute(`data-counter-${l.counter}-value`);O&&this.styleSheet.insertRule(`[data-${l.variable}="${v}"]${q} { counter-reset: ${l.variable} ${l.variable} ${parseInt(O)}; }`,this.styleSheet.cssRules.length)}let L=document.querySelector(`[data-${l.variable}="${v}"]`);L&&(L.style.display="none",L.clientHeight,L.style.removeProperty("display"))}})})}},w3=$d;b();var Ro=He(bt(),1),Gd=class extends xe{constructor(t,r,a){super(t,r,a),this.styleSheet=r.styleSheet,this.textTargets={},this.beforeContent="",this.afterContent="",this.selector={}}onContent(t,r,a,n,i){if(t.name==="target-text"){this.selector=Ro.default.generate(i.ruleNode.prelude);let l=t.children.first(),c=t.children.last(),d=l.name,h=Ro.default.generate(t),k=[];l.children.forEach(g=>{g.type==="Identifier"&&k.push(g.name)});let x;c!==l&&(x=c.name);let p="--pagedjs-"+xt();this.selector.split(",").forEach(g=>{this.textTargets[g]={func:d,args:k,value:h,style:x||"content",selector:g,fullSelector:this.selector,variable:p}}),t.name="var",t.children=new Ro.default.List,t.children.appendData({type:"Identifier",loc:0,name:p})}}onPseudoSelector(t,r,a,n,i){i.ruleNode.block.children.forEach(l=>{t.name==="before"&&l.property==="content"?l.value.children.forEach(d=>{d.type==="String"&&(this.beforeContent=d.value)}):t.name==="after"&&l.property==="content"&&l.value.children.forEach(c=>{c.type==="String"&&(this.afterContent=c.value)})})}afterParsed(t){Object.keys(this.textTargets).forEach(r=>{let a=this.textTargets[r],n=a.selector.split("::"),i=n[0],l=t.querySelectorAll(i),c;l.forEach((d,h)=>{let k=zs(d,a.args),x=t.querySelector(Cs(k));if(x)if(a.style){this.selector=xt(),d.setAttribute("data-target-text",this.selector);let p="";if(n.length>1&&(p+="::"+n[1]),a.style==="before"||a.style==="after"){let g=`${a.style}Content`;c=ua(this[g])}else c=ua(x.textContent," ");c=a.style==="first-letter"?c.charAt(0):c,this.styleSheet.insertRule(`[data-target-text="${this.selector}"]${p} { ${a.variable}: "${c}" }`)}else console.warn("missed target",k)})})}},v3=Gd;var x3=[b3,_3,w3,v3];b();b();var Ud=class extends xe{constructor(t,r,a){super(t,r,a)}filter(t){Ps(t,r=>this.filterEmpty(r),NodeFilter.SHOW_TEXT)}filterEmpty(t){if(t.textContent.length>1&&Un(t)){let r=t.parentNode;if(ft(r)&&r.closest("pre"))return NodeFilter.FILTER_REJECT;let n=Ts(t),i=Es(t);return i===null&&n===null?(t.textContent=" ",NodeFilter.FILTER_REJECT):i===null||n===null?NodeFilter.FILTER_ACCEPT:(t.textContent=" ",NodeFilter.FILTER_REJECT)}else return NodeFilter.FILTER_REJECT}},S3=Ud;b();var Vd=class extends xe{constructor(t,r,a){super(t,r,a)}filter(t){Ps(t,null,NodeFilter.SHOW_COMMENT)}},z3=Vd;b();var Yd=class extends xe{constructor(t,r,a){super(t,r,a)}filter(t){t.querySelectorAll("script").forEach(r=>{r.remove()})}},C3=Yd;b();var q3=He(bt(),1),O3=He(E3(),1);var Kd=class extends xe{constructor(t,r,a){super(t,r,a),this.displayRules={}}onDeclaration(t,r,a,n){if(t.property==="display"){let i=q3.default.generate(n.ruleNode.prelude),l=t.value.children.first().name;i.split(",").forEach(c=>{this.displayRules[c]={value:l,selector:c,specificity:(0,O3.calculateSpecificity)(c),important:t.important}})}}filter(t){let{matches:r,selectors:a}=this.sortDisplayedSelectors(t,this.displayRules);for(let i=0;i<r.length;i++){let l=r[i],c=a[i],d=c[c.length-1].value;this.removable(l)&&d==="none"&&(l.dataset.undisplayed="undisplayed")}let n=t.querySelectorAll("[style]");for(let i=0;i<n.length;i++){let l=n[i];this.removable(l)&&(l.dataset.undisplayed="undisplayed")}}sorter(t,r){return t.important&&!r.important?1:r.important&&!t.important?-1:t.specificity-r.specificity}sortDisplayedSelectors(t,r=[]){let a=[],n=[];for(let i in r){let l=r[i],c=l.selector,d=[];try{try{d=t.querySelectorAll(c)}catch{d=t.querySelectorAll(k3(c))}}catch{d=[]}let h=Array.from(d);for(let k of h)if(a.includes(k)){let x=a.indexOf(k);n[x].push(l),n[x]=n[x].sort(this.sorter)}else a.push(k),n.push([l])}return{matches:a,selectors:n}}removable(t){return!(t.style&&t.style.display!==""&&t.style.display!=="none")}},D3=Kd;var M3=[S3,z3,C3,D3];var e6=He(aa(),1),t6=He(Jw(),1),n0=[...y3,...x3,...M3],Wo=class{constructor(t,r,a){let n=[];n0.forEach(i=>{let l=new i(t,r,a);n.push(l),(0,t6.default)(l,this)})}};(0,e6.default)(Wo.prototype);function Ho(){for(var e=0;e<arguments.length;e++)n0.push(arguments[e])}function i0(e,t,r){return new Wo(e,t,r)}var $o=class{constructor(t){this.settings=t||{},this.polisher=new zd(!1),this.chunker=new eu(void 0,void 0,this.settings),this.hooks={},this.hooks.beforePreview=new ue(this),this.hooks.afterPreview=new ue(this),this.size={width:{value:8.5,unit:"in"},height:{value:11,unit:"in"},format:void 0,orientation:void 0},this.chunker.on("page",r=>{this.emit("page",r)}),this.chunker.on("rendering",()=>{this.emit("rendering",this.chunker)})}initializeHandlers(){let t=i0(this.chunker,this.polisher,this);return t.on("size",r=>{this.size=r,this.emit("size",r)}),t.on("atpages",r=>{this.atpages=r,this.emit("atpages",r)}),t}registerHandlers(){return Ho.apply(Ho,arguments)}getParams(t){let r,a=new URL(window.location),n=new URLSearchParams(a.search);for(var i of n.entries())i[0]===t&&(r=i[1]);return r}wrapContent(){let t=document.querySelector("body"),r;return r=t.querySelector(":scope > template[data-ref='pagedjs-content']"),r||(r=document.createElement("template"),r.dataset.ref="pagedjs-content",r.innerHTML=t.innerHTML,t.innerHTML="",t.appendChild(r)),r.content}removeStyles(t=document){let r=Array.from(t.querySelectorAll("link[rel='stylesheet']:not([data-pagedjs-ignore], [media~='screen'])")),a=Array.from(t.querySelectorAll("style:not([data-pagedjs-inserted-styles], [data-pagedjs-ignore], [media~='screen'])"));return[...r,...a].sort(function(i,l){let c=i.compareDocumentPosition(l);return c===Node.DOCUMENT_POSITION_PRECEDING?1:c===Node.DOCUMENT_POSITION_FOLLOWING?-1:0}).map(i=>{if(i.nodeName==="STYLE"){let l={};return l[window.location.href]=i.textContent,i.remove(),l}if(i.nodeName==="LINK")return i.remove(),i.href;console.warn(`Unable to process: ${i}, ignoring.`)})}async preview(t,r,a){await this.hooks.beforePreview.trigger(t,a),t||(t=this.wrapContent()),r||(r=this.removeStyles()),this.polisher.setup(),this.handlers=this.initializeHandlers(),await this.polisher.add(...r);let n=performance.now(),i=await this.chunker.flow(t,a),l=performance.now();return i.performance=l-n,i.size=this.size,this.emit("rendered",i),await this.hooks.afterPreview.trigger(i.pages),i}};(0,r6.default)($o.prototype);var s0=$o;async function a6(e,t,r){r.innerHTML="",document.querySelectorAll("style[data-pagedjs-inserted-styles]").forEach(n=>n.remove()),await new s0().preview(e,t,r)}function n6(){window.print()}b();var i6={none:{body:"system-serif",heading:"system-serif"},"light-neat-1":{body:"inter",heading:"inter"},"light-neat-2":{body:"ibm-plex-sans",heading:"ibm-plex-sans"},"light-neat-3":{body:"raleway",heading:"raleway"},"light-academic-1":{body:"source-serif-4",heading:"source-serif-4"},"light-academic-2":{body:"crimson-pro",heading:"inter"},"beige-decent-1":{body:"lora",heading:"lora"},"beige-decent-2":{body:"noto-serif",heading:"noto-serif"}};b();function s6(e){return e.trim().toLowerCase().replace(/-/g,"_")}function o0(e){let t=e.indexOf("=");return t<0?{key:s6(e),value:""}:{key:s6(e.slice(0,t)),value:e.slice(t+1).trim()}}function o6(e,t){Array.prototype.forEach.call(e.querySelectorAll("[data-show-when]"),r=>{let{key:a,value:n}=o0(r.getAttribute("data-show-when")||"");t[a]===n?r.removeAttribute("data-show-when"):r.remove()}),Array.prototype.forEach.call(e.querySelectorAll("[data-hide-when]"),r=>{let{key:a,value:n}=o0(r.getAttribute("data-hide-when")||"");t[a]===n?r.remove():r.removeAttribute("data-hide-when")})}function l6(e){let t={};for(let a of["data-show-when","data-hide-when"])Array.prototype.forEach.call(e.querySelectorAll("["+a+"]"),n=>{let{key:i,value:l}=o0(n.getAttribute(a)||"");(t[i]=t[i]||new Set).add(l)});let r={};for(let a of Object.keys(t))r[a]=Array.from(t[a]).sort();return r}var xM="0.3.0";function kn(){return window.__ORZ_PAGED__||{}}function Uo(){let e=document.getElementById("orz-src");return(e&&e.textContent||"").replace(/^\n/,"").replace(/\n\s*$/,"")}function u6(){let e=document.getElementById("orz-pages");return e||(e=document.createElement("div"),e.id="orz-pages",e.setAttribute("data-orz-copy",""),document.body.appendChild(e)),e}function Go(e){return new Promise((t,r)=>{if(!e||document.querySelector(`script[data-lib="${e}"]`))return t();let a=document.createElement("script");a.src=e,a.async=!0,a.setAttribute("data-lib",e),a.setAttribute("data-orz-runtime","1"),a.onload=()=>t(),a.onerror=()=>r(new Error("failed to load "+e)),document.head.appendChild(a)})}function Si(e,t){if(!e||t&&document.getElementById(t)||!t&&document.querySelector(`link[href="${e}"]`))return;let r=document.createElement("link");r.rel="stylesheet",r.href=e,t&&(r.id=t),r.setAttribute("data-orz-runtime","1"),document.head.appendChild(r)}function SM(e){try{let t=document.createElement("img");t.src=e.toDataURL("image/png"),t.className=e.className,t.style.maxWidth="100%";let r=e.getAttribute("data-md");r!=null&&t.setAttribute("data-md",r),e.replaceWith(t)}catch{}}async function zM(e){let t=kn().enhancers||{},r=window,a=[];t.hljsJs&&e.querySelector("pre code")&&(await Go(t.hljsJs),r.hljs&&e.querySelectorAll("pre code:not(.hljs)").forEach(n=>{try{r.hljs.highlightElement(n)}catch{}})),t.mermaidJs&&e.querySelector(".mermaid")&&(await Go(t.mermaidJs),r.mermaid&&(r.mermaid.initialize({startOnLoad:!1}),a.push(Promise.resolve(r.mermaid.run({nodes:e.querySelectorAll(".mermaid")})).catch(()=>{})))),t.smilesJs&&e.querySelector("canvas[data-smiles]")&&(await Go(t.smilesJs),r.SmilesDrawer&&e.querySelectorAll("canvas[data-smiles]").forEach(n=>{let i=new r.SmilesDrawer.Drawer({width:n.width,height:n.height});a.push(new Promise(l=>{r.SmilesDrawer.parse(n.getAttribute("data-smiles"),c=>{try{i.draw(c,n,"light",!1)}catch{}l()},()=>l())}))})),t.chartJs&&e.querySelector("canvas.orz-chart[data-chart]")&&(await Go(t.chartJs),r.Chart&&e.querySelectorAll("canvas.orz-chart[data-chart]").forEach(n=>{try{let i=JSON.parse(n.getAttribute("data-chart")||"{}");i.options={...i.options||{},responsive:!1,animation:!1},new r.Chart(n,i)}catch{}})),await Promise.all(a),e.querySelectorAll("canvas").forEach(n=>SM(n))}var Vo=null,Zo=null,l0={},d6={};function CM(e){let t=kn(),r=Zo||e.theme,a=[];return t.mode==="cdn"?(t.baseUrl&&a.push(t.baseUrl),r!=="none"&&t.themeUrls&&t.themeUrls[r]&&a.push(t.themeUrls[r])):(t.baseCss&&a.push({"orz-base.css":t.baseCss}),r!=="none"&&t.themes&&t.themes[r]&&a.push({"orz-theme.css":t.themes[r]})),a.push({"orz-page.css":e.css}),a}async function Yo(e){let t=Mc(e);Vo=t;let r=Zo||t.theme,a=i6[r];a&&(Si(Or(a.body).cssUrl),Si(Or(a.heading).cssUrl)),t.fontCssUrls.forEach(l=>Si(l)),kn().katexCss&&Si(kn().katexCss,"orz-katex"),kn().hljsCss&&Si(kn().hljsCss,"orz-hljs");let n=document.createElement("div");n.className="orz-stage",n.style.cssText="position:absolute;left:-99999px;top:0;width:680px;",n.innerHTML=t.bodyHtml,document.body.appendChild(n),d6=l6(n),l0={...t.settings.dynamicChoices},o6(n,l0);let i=document.createElement("div");i.style.cssText="position:absolute;left:-99999px;top:0;width:900px;",document.body.appendChild(i);try{if(await zM(n.querySelector(".orz-doc")||n),document.fonts&&document.fonts.ready)try{await document.fonts.ready}catch{}await a6(n.innerHTML,CM(t),i);let l=u6(),c=l.scrollTop;if(l.replaceChildren(...Array.prototype.slice.call(i.childNodes)),l.scrollTop=c,t.settings.frontMatterClean){let k=Array.prototype.slice.call(l.querySelectorAll(".pagedjs_page")).filter(x=>!x.classList.contains("pagedjs_orz-front_page"));document.documentElement.style.setProperty("--orz-body-pages",`"${k.length}"`),k.forEach((x,p)=>x.style.setProperty("--orz-pageno",`"${p+1}"`))}AM();let d=window.__orzPagedAfterRender;if(d)try{d()}catch{}}finally{n.remove(),i.remove()}}function AM(){let e=u6(),t=e.querySelector(".orz-toc");if(!t)return;let r=Number(t.getAttribute("data-max-level")||"3"),a=[];e.querySelectorAll(".pagedjs_page h1, .pagedjs_page h2, .pagedjs_page h3, .pagedjs_page h4").forEach(n=>{let i=Number(n.tagName.slice(1));if(i>r)return;let l=n.closest(".pagedjs_page"),c=l&&l.getAttribute("data-page-number")||"";a.push(`<li class="orz-toc-item orz-toc-l${i}"><span class="orz-toc-text">${n.textContent||""}</span><span class="orz-toc-page">${c}</span></li>`)}),a.length&&(t.innerHTML=`<ol class="orz-toc-list">${a.join("")}</ol>`)}var TM={version:xM,assemble:Mc,render:e=>Yo(e),refresh:()=>Yo(Uo()),exportPdf:()=>n6(),setTheme:e=>(Zo=e&&e!=="none"?e:null,Yo(Uo())),getTheme:()=>Zo||(Vo?Vo.theme:null),getDynamicState:()=>({options:d6,choices:l0}),get assembly(){return Vo},source:Uo};window.orzpaged=TM;function c6(){Yo(Uo()).catch(e=>console.error("[orz-paged]",e))}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",c6):c6();})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "orz-paged-browser",
3
- "version": "0.1.0",
3
+ "version": "0.3.0",
4
4
  "description": "Prebuilt in-browser paged-document engine for orz-paged .paged.html files (paged.js + orz-markdown + the orz-paged document layer/assembler)",
5
5
  "main": "orz-paged.browser.js",
6
6
  "files": [