MediaWiki:Bindery.min.js

var Bindery=function{"use strict";var e,t,r,n;!function(e){e.PAGES="pages",e.SPREADS="spreads",e.BOOKLET="booklet"}(e||(e={})),function(e){e[e.NONE=0]="NONE",e[e.CROP=1]="CROP",e[e.BLEED=2]="BLEED",e[e.BOTH=3]="BOTH"}(t||(t={})),function(e){e.AUTO="auto",e.AUTO_BLEED="auto-bleed",e.AUTO_MARKS="auto-marks",e.LETTER_PORTRAIT="letter-portrait",e.LETTER_LANDSCAPE="letter-landscape",e.A4_PORTRAIT="a4-portrait",e.A4_LANDSCAPE="a4-landscape"}(r||(r={})),function(e){e.FLIPBOOK="flipbook",e.PREVIEW="preview",e.PRINT="print"}(n||(n={}));const o=e=>"."===e[0]?".📖-"+e.substr(1):"📖-"+e,i={showBleed:"show-bleed",showCrop:"show-crop",showBleedMarks:"show-bleed-marks",isViewing:"viewing",viewPreview:"view-preview",viewPrint:"view-print",viewFlip:"view-flip",inProgress:"in-progress",leftPage:"left",rightPage:"right",isOverflowing:"is-overflowing",printSheet:"print-sheet",sheetSpread:"print-sheet-spread",sheetLeft:"print-sheet-left",sheetRight:"print-sheet-right",toNext:"continues",fromPrev:"continuation"};Object.keys(i).forEach(e=>{const t=e,r=i[t];i[t]=o(r)});const s=[i.viewPreview,i.viewPrint,i.viewFlip],a=e=>(null==e?void 0:e.element)&&e.element.nodeType===Node.ELEMENT_NODE,l=(e,t,r,...n)=>{const i=document.createElement(e);if(t&&(i.className=t.split(".").filter(e=>""!==e).map(o).join(" ")),r)for(const e in r){const t=r[e];"function"==typeof t?i[e]=t:i.setAttribute(e,t)}return n&&i.append(...n.map(e=>a(e)?e.element:e)),i},d=(e,...t)=>l("div",e,{},...t),c=(e,t)=>{if(e.parentNode)return t;let r=document.querySelector(o(".measure-area"));r||(r=document.body.appendChild(d(".measure-area"))),r.firstElementChild!==e&&(r.innerHTML="",r.append(e));return t},h=e=>{var t;return null!==(t=window.document.querySelector("#"+e))&&void 0!==t?t:(e=>{const t=window.document.createElement("style");return t.id=e,window.document.head.appendChild(t),t})(e)},p=e=>{let t,r=!1;const n=o=>{r?t=o:(r=!0,o,setTimeout(=>{if(r=!1,t){const e=t;t=void 0,n(e)}},e))};return n},u=e=>{let t="",r=e[0],n=!1;const o=e=>{n=!1,t+="–"+e},i=e=>{t+=", "+e},s=(e,t)=>{o(e),i(t)};return e.forEach((a,l)=>{const d=l===e.length-1,c=a===r+1;0===l?(e=>{t+=""+e})(a):d?((e,t)=>{t?o(e):n&&!t?s(r,e):i(e)})(a,c):c?n=!0:n&&!c?s(r,a):i(a),r=a}),t},g=/^([+-]?[0-9]+(.?[0-9]+)?)(px|in|cm|mm|pt|pc)$/,m=e=>g.test(e);var f={bleed:"12pt",size:{width:"4in",height:"6in"},margin:{inner:"24pt",outer:"24pt",bottom:"40pt",top:"48pt"}};const b=Object.freeze({width:"8.5in",height:"11in"}),w=Object.freeze({width:"210mm",height:"297mm"});class v{constructor(t={},n={}){var o,i,s;this.size=null!==(o=t.size)&&void 0!==o?o:f.size,this.margin=null!==(i=t.margin)&&void 0!==i?i:f.margin,this.markLength="12pt",this.paper=window.hasOwnProperty("chrome")?n.paper||r.AUTO:r.AUTO_MARKS,this.bleed=null!==(s=n.bleed)&&void 0!==s?s:f.bleed,this.printTwoUp=!!n.layout&&n.layout!==e.PAGES}get displaySize{return{width:this.printTwoUp?this.spreadSize.width:this.size.width,height:this.size.height,bleed:this.bleed}}get sheetSize{const e=this.printTwoUp?this.spreadSize.width:this.size.width,t=this.size.height,n="2 * "+this.bleed,o=`${n} + 2 * ${this.markLength}`,i=`${this.bleed} + ${this.markLength}`;switch(this.paper){case r.AUTO:return{width:e,height:t};case r.AUTO_BLEED:return{width:`calc(${e} + ${this.printTwoUp?n:this.bleed})`,height:`calc(${t} + ${n})`};case r.AUTO_MARKS:return{width:`calc(${e} + ${this.printTwoUp?o:i})`,height:`calc(${t} + ${o})`};case r.LETTER_LANDSCAPE:return{width:b.height,height:b.width};case r.LETTER_PORTRAIT:return b;case r.A4_PORTRAIT:return w;case r.A4_LANDSCAPE:return{width:w.height,height:w.width};default:throw Error("Can't get dimensions for unknown paper size: "+this.paper)}}get spreadSize{const e=(e=>{if(!m(e))throw Error(`Cannot parse css length from "${e}"`);const t=e.match(g);if(!t)throw Error(`Failed to parse css length from "${e}"`);return{val:Number(t[1]),unit:t[3]}})(this.size.width);return{height:this.size.height,width:`${2*e.val}${e.unit}`}}updateStyleVars{const e=this.size,t=this.sheetSize,r={"spread-width":this.spreadSize.width,"page-width":e.width,"page-height":e.height,"sheet-width":t.width,"sheet-height":t.height,"margin-inner":this.margin.inner,"margin-outer":this.margin.outer,"margin-top":this.margin.top,"margin-bottom":this.margin.bottom,bleed:this.bleed,"mark-length":this.markLength},n=`:root { ${Object.entries(r).map(([e,t])=>`--bindery-${e}: ${t};`).join("")} }`,o=`@page { size: ${t.width} ${t.height}; }`;h("binderyPage").innerHTML=`${n} ${o}`}}class y{constructor(e){var t;this.name=null!==(t=null==e?void 0:e.name)&&void 0!==t?t:"Unnamed Bindery Rule",this.selector="",Object.keys(e).forEach(t=>{this[t]=e[t]})}setup{}}const k=(e,t)=>{if(!t)throw Error("Valid options not specified");return Object.keys(e).forEach(r=>{var n;if(!t[r]){const e=null!==(n=t.name)&&void 0!==n?n:"This option";throw Error(`Unknown option in ${e}: '${r}'`)}const o=e[r],i=t[r];if(!i.check(o)){const e=t.name?`${t.name}.${r}`:r,n=JSON.stringify(o);throw Error(`Invalid value for '${e}': ${n} is not a ${i.name}.`)}}),!0},E=e=>"object"==typeof e,P=(e,t)=>!Object.keys(t).filter(e=>"name"!==e).some(t=>!((e,t)=>Object.prototype.hasOwnProperty.call(e,t))(e,t)),x=e=>t=>E(t)&&k(t,e),S=e=>t=>E(t)&&P(t,e)&&k(t,e),T=e=>t=>e.includes(t),R={name:"length (string with absolute units)",check:m},O={any:{name:"any",check:=>!0},enum:(...e)=>({name:`(${e.map(e=>`"${e}"`).join(" | ")})`,check:T(e)}),shapeExact:e=>({name:`exactly ({${Object.keys(e).join(", ")}})`,check:S(e)}),shape:e=>({name:`shape ({${Object.keys(e).join(", ")}})`,check:x(e)}),string:{name:"string",check:e=>"string"==typeof e},length:R,number:{name:"number",check:e=>"number"==typeof e},bool:{name:"bool",check:e=>"boolean"==typeof e},func:{name:"func",check:e=>"function"==typeof e},obj:{name:"object",check:E},array:{name:"array",check:e=>Array.isArray(e)},margin:{name:"margin ({ top, inner, outer, bottom })",check:S({name:"margin",top:R,inner:R,outer:R,bottom:R})},size:{name:"size ({ width, height })",check:S({name:"size",width:R,height:R})}};class L extends y{constructor(e){var t,r,n;super(e),this.selector="*",this.counterValue=0,this.incrementEl=null!==(t=e.incrementEl)&&void 0!==t?t:"",this.resetEl=null!==(r=e.resetEl)&&void 0!==r?r:"",this.replaceEl=null!==(n=e.replaceEl)&&void 0!==n?n:"",k(e,{name:"Counter",replaceEl:O.string,resetEl:O.string,incrementEl:O.string,replace:O.func})}setup{this.counterValue=0}beforeAdd(e){return this.incrementEl.length&&e.matches(this.incrementEl)&&(this.counterValue+=1),this.resetEl.length&&e.matches(this.resetEl)&&(this.counterValue=0),this.replaceEl.length&&e.matches(this.replaceEl)?this.createReplacement(e):e}createReplacement(e){return this.replace(e,this.counterValue)}replace(e,t){return e.textContent=""+t,e}}class A extends y{constructor(e){super(e),this.name="Out of Flow"}createOutOfFlowPages(e,t,r){throw Error("createOutOfFlowPages must be overridden")}beforeAdd(e){return e.setAttribute("data-ignore-overflow","true"),e}afterAdd(e,t,r,n){return this.createOutOfFlowPages(e,t,n),("same"!==this.continue||t.currentPage.hasOutOfFlowContent)&&(r,"left"!==this.continue&&"right"!==this.continue||t.currentPage.setPreference(this.continue)),e}}class C extends A{constructor(e){var t,r;e.continue=null!==(t=e.continue)&&void 0!==t?t:"same",e.rotate=null!==(r=e.rotate)&&void 0!==r?r:"none",super(e),k(e,{name:"FullBleedSpread",selector:O.string,continue:O.enum("next","same","left","right"),rotate:O.enum("none","clockwise","counterclockwise")})}createOutOfFlowPages(e,t,r){let n;e.parentNode&&e.parentNode.removeChild(e),t.currentPage.isEmpty?n=t.currentPage:(n=r,t.addPage(n));const i=r;t.addPage(i),"none"!==this.rotate&&[n,i].forEach(e=>{const t=d(".rotate-container.spread-size-rotated.rotate-spread-"+this.rotate);t.append(e.background),e.element.append(t)}),n.background.append(e),n.element.classList.add(o("spread")),n.setPreference("left"),n.isOutOfFlow="same"===this.continue,n.avoidReorder=!0,n.hasOutOfFlowContent=!0,i.background.append(e.cloneNode(!0)),i.element.classList.add(o("spread")),i.setPreference("right"),i.isOutOfFlow="same"===this.continue,i.avoidReorder=!0,i.hasOutOfFlowContent=!0}}class z extends A{constructor(e){var t,r;e.continue=null!==(t=e.continue)&&void 0!==t?t:"same",e.rotate=null!==(r=e.rotate)&&void 0!==r?r:"none",super(e),k(e,{name:"FullBleedPage",selector:O.string,continue:O.enum("next","same","left","right"),rotate:O.enum("none","inward","outward","clockwise","counterclockwise")})}createOutOfFlowPages(e,t,r){let n;if(e.parentNode&&e.parentNode.removeChild(e),t.currentPage.isEmpty?n=t.currentPage:(n=r,t.addPage(n)),"none"!==this.rotate){const e=d(".rotate-container.page-size-rotated.rotate-"+this.rotate);e.appendChild(n.background),n.element.appendChild(e)}n.background.appendChild(e),n.hasOutOfFlowContent=!0}}class N extends y{constructor(e){super(e),this.name="Replace"}afterAdd(e,t,r,n,o){const i=e.parentNode;if(!i)throw console.error(e),Error(`Bindery.Replace({ selector: '${this.selector}' }).afterAdd called on element that hasn't been added.`);const s=e.cloneNode(!0),a=this.createReplacement(t,s);return i.replaceChild(a,e),t.currentPage.hasOverflowed?(i.replaceChild(e,a),o(e)):a}createReplacement(e,t){return this.replace(t)}replace(e,t){return e.insertAdjacentHTML("beforeend",'Default Replacement '),e}}class B extends N{constructor(e){super(e),k(e,{name:"Footnote",selector:O.string,replace:O.func,render:O.func})}afterAdd(e,t,r,n,o){const i=t.currentPage.footer.children.length+1,s=d(".footnote"),a=this.render(e,i);return a instanceof HTMLElement?s.appendChild(a):s.innerHTML=a,t.currentPage.footer.appendChild(s),super.afterAdd(e,t,r,n,e=>(t.currentPage.footer.removeChild(s),o(e)))}createReplacement(e,t){const r=e.currentPage.footer.children.length;return this.replace(t,r)}replace(e,t){return e.insertAdjacentHTML("beforeend",`${t} `),e}render(e,t){return`${t} Default footnote (Learn how to change it)`}}class F{constructor(e){this.suppressErrors=!1,this.element=e,this.content=(e=>{const t=document.createElement("div");return t.classList.add(e),t})("region-content"),this.content.style.position="relative",this.element.appendChild(this.content),this.path=[]}setPath(e){this.path=e,e.length>0&&this.content.appendChild(e[0])}get currentElement{const e=this.path.length;return e>0?this.path[e-1]:this.content}isEmpty{const e=this.content;return null===e.textContent||""===e.textContent.trim&&e.offsetHeight<2}isReasonableSize{const e=this.element.getBoundingClientRect;return e.height>100&&e.width>100}overflowAmount{const e=this.content.offsetHeight,t=this.element.offsetHeight;if(0===t)throw Error("Regionizer: Trying to flow into an element with zero height.");return e-t}hasOverflowed{return this.overflowAmount>-5}}const M=e=>(e=>e.nodeType===Node.ELEMENT_NODE)(e)&&!(e=>"SCRIPT"===e.tagName)(e);let $=0;const I=async=>{performance.now-$>30&&($=await new Promise(e=>{requestAnimationFrame(t=>e(t))}))},H=e=>!!e.hasAttribute("data-ignore-overflow")||!!e.parentElement&&H(e.parentElement),V=(e,t)=>{let r=t+1;for(r{t.appendChild(e);const n=!r;return n||t.removeChild(e),await I,{completed:n}},j=async(e,t,r,n)=>{const o=await(async(e,t,r)=>{const n=e.nodeValue||"";if(t.appendChild(e),!r||H(t))return{completed:!0};let o=0;for(e.nodeValue=n.substr(0,o);!r&&o{let r=t;for(" "===e.charAt(r)&&(r-=1);" "!==e.charAt(r)&&r>0;)r-=1;return r})(n,o);if(i<1)return e.nodeValue=n,t.removeChild(e),{completed:!1};const s=n.substr(0,i),a=n.substr(i);return e.nodeValue=s,{completed:!0,remainder:(l=a,document.createTextNode(l))};var l})(e,t,n);if(o.remainder){const e=r;return j(o.remainder,e,r,n)}return o},U=(e,t,r)=>{if(e.path.length<=1)throw Error("Regionize: Attempting to move the top-level element");const n=e.path.length,o=e.path.pop;let i=o;const s=[];for(e.path.length>1&&!r(e.currentElement);)i=e.path.pop,s.unshift(i);i.setAttribute("data-regionize-did-move","true");const a=i.parentNode;let l;if(a.removeChild(i),e.path.length>1&&""===e.currentElement.textContent.trim&&(a.appendChild(i),i=e.path.pop,s.unshift(i),i.parentNode.removeChild(i)),e.isEmpty?l=e:(e.hasOverflowed&&(e.suppressErrors=!0),l=t),l.currentElement.appendChild(i),s.forEach(e=>l.path.push(e)),l.path.push(o),n!==l.path.length)throw Error("Regionize: Restored path depth does not match original path depth")},_=(e,t)=>e.cloneNode(t),W=e=>_(e,!1),q=e=>_(e,!0),K==>{},G==>!0,Y==>!1,X=async e=>{var t,r,n,o,i,s;const a=e.content,l=e.createRegion;if(!a)throw Error("content not specified");if(!l)throw Error("createRegion not specified");const d=null!==(t=e.applySplit)&&void 0!==t?t:K,c=null!==(r=e.canSplit)&&void 0!==r?r:G,h=null!==(n=e.beforeAdd)&&void 0!==n?n:K,p=null!==(o=e.afterAdd)&&void 0!==o?o:K,u=null!==(i=e.didWaitFor)&&void 0!==i?i:K,g=null!==(s=e.shouldTraverse)&&void 0!==s?s:Y;let m=l;const f==>m.hasOverflowed,b==>c(m.currentElement),w==>H(m.currentElement),v=(e,t,r,n)=>{"OL"===e.tagName&&((e,t,r)=>{let n=1;e.hasAttribute("start")&&(n=parseInt(e.getAttribute("start")||"",10)),r&&"LI"===r.tagName&&(n-=1);const o=n+e.children.length;t.setAttribute("start",""+o)})(e,t,r),"TR"===e.tagName&&r&&n&&((e,t,r,n)=>{const o=[...e.children],i=o.indexOf(r);for(let e=0;e{const e=m;m=l;const t=((e,t)=>{const r=[],n=e=>{const r=q(e);return t(e,r),r};for(let o=e.length-1;o>=0;o-=1){const i=e[o],s=W(i),a=e[o+1];s.innerHTML="",t(i,s,a,n),o(y,m.currentElement),E=async(e,t)=>{const r=m.currentElement;let n;t?(n=await j(e,r,k,f),!n.completed&&m.path.length>1&&(U(m,y,c),n=await j(e,r,k,f))):(n=await D(e,m.currentElement,f),n.completed||w||(U(m,y,c),n=await D(e,m.currentElement,f))),n.completed||(m.currentElement.appendChild(e),!w&&b&&(m.suppressErrors=!0,y))},P=async e=>{if((e=>"IMG"===e.tagName)(t=e)&&!t.naturalWidth){const t=await(async e=>{const t=performance.now;let r=!1;for(e.addEventListener("error",=>{r=!0}),e.src=e.src;!e.naturalWidth&&!r;)await new Promise(e=>{setTimeout(=>{e},10)});return performance.now-t})(e);u(t)}var t;await h(e,y),m.currentElement.appendChild(e),m.path.push(e),(e=>!!f||(!!e.querySelector("img")||!!g(e)))(e)&&await x(e);const r=m.path.pop;await p(r,y)},x=async e=>{const t=[...e.childNodes];e.innerHTML="",f&&!w&&b&&U(m,y,c);const r=c(e)&&!H(e);for(const e of t)e.nodeType===Node.TEXT_NODE?await E(e,r):M(e)&&await P(e)};return P(a)};class J{constructor(e){this.getHierarchy=e}textFor(e){var t,r;return null===(r=null===(t=this.getHierarchy)||void 0===t?void 0:t.find(t=>(null==t?void 0:t.selector)===e))||void 0===r?void 0:r.text}get h1{return this.textFor("h1")}get h2{return this.textFor("h2")}get h3{return this.textFor("h3")}get h4{return this.textFor("h4")}get h5{return this.textFor("h5")}get h6{return this.textFor("h6")}}class Q{constructor{this.hierarchy=[],this.suppress=!1,this.hasOutOfFlowContent=!1,this.alwaysLeft=!1,this.alwaysRight=!1,this.isOutOfFlow=!1,this.avoidReorder=!1,this.flow=new F(d("flow-box")),this.footer=d("footer"),this.background=d("page-background"),this.element=d("page",this.background,this.flow.element,this.footer),this.heading=new J(=>this.hierarchy)}static isSizeValid{const e=new Q;return c(e.element,=>e.flow.isReasonableSize)}setLeftRight(e){this.side=e,this.element.classList.toggle(i.leftPage,this.isLeft),this.element.classList.toggle(i.rightPage,!this.isLeft)}get isLeft{return"left"===this.side}get isRight{return"right"===this.side}setPreference(e){const t="left"===e;this.alwaysLeft=t,this.alwaysRight=!t}get suppressErrors{var e;return null!==(e=this.suppress)&&void 0!==e&&e}set suppressErrors(e){this.suppress=e,this.element.classList.toggle(i.isOverflowing,e)}get isEmpty{return!this.hasOutOfFlowContent&&this.flow.isEmpty}validate{if(!this.hasOverflowed)return;const e=this.flow.currentElement;e?(console.warn("Bindery: Content overflows, probably due to a style set on:",e),e.parentNode&&e.parentNode.removeChild(e)):console.warn("Bindery: Content overflows.")}validateEnd(e){if(this.hasOverflowed&&(console.warn(`Bindery: Page ~${this.number} is overflowing`,this.element),!this.suppressErrors&&!this.flow.suppressErrors&&!e))throw Error("Bindery: Moved to new page when last one is still overflowing")}hasOverflowed{return c(this.element,=>this.flow.hasOverflowed)}}const Z=(e,t)=>{for(let r=t;r{const r=e.slice;for(let e=0;enew Q)}validate{if(this.pageCount>2e3)throw Error("Bindery: Maximum page count exceeded. Suspected runaway layout.")}}const te=(e,t)=>{((e,t)=>{e.forEach((e,r)=>{e.number=t+r+1,e.setLeftRight(r%2==0?"right":"left")})})(e,t),((e,t)=>{let r=[];e.forEach(e=>{const n=[];t.forEach((t,o)=>{var i;const s=e.element.querySelector(t);s&&(r[o]={selector:t,text:null!==(i=s.textContent)&&void 0!==i?i:"",el:s},r=r.slice(0,o+1)),r[o]&&(n[o]=r[o])}),e.hierarchy=n})})(e,["h1","h2","h3","h4","h5","h6"])},re=(e,t)=>e.filter(e=>!!e.number).filter(e=>t(e.element)).map(e=>e.number);class ne extends N{constructor(e){super(e),k(e,{name:"PageReference",selector:O.string,replace:O.func,createTest:O.func}),this.references=[];const t=p(10);this.throttledUpdate=e=>{t(=>this.updatePageReferences(e.pages))}}eachPage(e,t){this.throttledUpdate(t)}afterAdd(e,t){const r=this.createTest(e);if(!r)return e;return this.createReference(t,r,e).element}createReference(e,t,r){const n={testFunction:t,template:r,element:r,previousMatches:void 0};this.references.push(n);const o=re(e.pages,t);return this.render(n,o),n}render(e,t){if(e.previousMatches&&((e,t)=>{if(e===t)return!0;if(!e||!t)return!1;const r=e.length;if(t.length!==r)return!1;for(let n=0;n0,n=r?u(t):"⌧",i=e.template.cloneNode(!0),s=this.replace(i,n);r||s.classList.add(o("placeholder-num")),e.element.parentNode.replaceChild(s,e.element),e.element=s,e.previousMatches=t}createTest(e){const t=e.getAttribute("href");if(!t)return null;const r=(e=>e.length>2&&"#"===e[0]&&/^\d+$/.test(e[1]))(n=t)?`[id="${n.replace("#","")}"]`:n;var n;return e=>!!e.querySelector(r)}updatePageReferences(e){this.references.map(t=>({ref:t,matchingPageNumbers:re(e,t.testFunction)})).forEach(({ref:e,matchingPageNumbers:t})=>this.render(e,t))}replace(e,t){return e.insertAdjacentHTML("beforeend",`, ${t} `),e}}class oe extends y{constructor(e){var t,r;if(super(e),"same"==e.continue)throw Error("Can't continue on the same pager after a Page Break ");this.continue=null!==(t=e.continue)&&void 0!==t?t:"next",this.position=null!==(r=e.position)&&void 0!==r?r:"before",k(e,{name:"PageBreak",selector:O.string,continue:O.enum("next","left","right"),position:O.enum("before","after","both","avoid")})}get avoidSplit{return"avoid"===this.position}beforeAdd(e,t,r){return"before"!==this.position&&"both"!==this.position||(t.currentPage.isEmpty||r,"next"!==this.continue&&t.currentPage.setPreference(this.continue)),e}afterAdd(e,t,r){return"after"!==this.position&&"both"!==this.position||(r,"next"!==this.continue&&t.currentPage.setPreference(this.continue)),e}}class ie extends y{constructor(e={}){super(e),k(e,{name:"RunningHeader",render:O.func})}eachPage(e){if(!e.runningHeader){const t=d(".running-header");e.element.appendChild(t),e.runningHeader=t}e.runningHeader.innerHTML=this.render(e)}render(e){return""+e.number}}class se extends y{constructor(e){super(e),this.toNext=e.toNext,this.fromPrevious=e.fromPrevious,k(e,{name:"Split",selector:O.string,toNext:O.string,fromPrevious:O.string,didSplit:O.func})}didSplit(e,t){this.toNext&&e.classList.add(this.toNext),this.fromPrevious&&t.classList.add(this.fromPrevious)}}var ae={Rule:y,Split:e=>new se(e),Counter:e=>new L(e),FullBleedPage:e=>new z(e),Footnote:e=>new B(e),RunningHeader:e=>new ie(e),Replace:e=>new N(e),FullBleedSpread:e=>new C(e),PageBreak:e=>new oe(e),PageReference:e=>new ne(e),createRule:e=>new y(e)};const{PageBreak:le,PageReference:de,Footnote:ce,FullBleedPage:he,FullBleedSpread:pe}=ae,ue=(e,t)=>(e.textContent=""+t,e);var ge=[le({selector:'[book-page-break="both"]',position:"both"}),le({selector:'[book-page-break="avoid"]',position:"avoid"}),le({selector:'[book-page-break="after"][book-page-continue="right"]',position:"after",continue:"right"}),le({selector:'[book-page-break="after"][book-page-continue="left"]',position:"after",continue:"left"}),le({selector:'[book-page-break="after"][book-page-continue="next"]',position:"after",continue:"next"}),le({selector:'[book-page-break="before"][book-page-continue="right"]',position:"before",continue:"right"}),le({selector:'[book-page-break="before"][book-page-continue="left"]',position:"before",continue:"left"}),le({selector:'[book-page-break="before"][book-page-continue="next"]',position:"before",continue:"next"}),he({selector:'[book-full-bleed="page"]'}),pe({selector:'[book-full-bleed="spread"]'}),ce({selector:"[book-footnote-text]",render:(e,t)=>`${t}${e.getAttribute("book-footnote-text")}`}),de({selector:"[book-pages-with-text]",replace:ue,createTest:e=>{var t;const r=(null!==(t=e.getAttribute("book-pages-with-text"))&&void 0!==t?t:"").toLowerCase.trim;return e=>(e.textContent||"").toLowerCase.includes(r)}}),de({selector:"[book-pages-with-selector]",replace:ue,createTest:e=>{var t;const r=(null!==(t=e.getAttribute("book-pages-with-selector"))&&void 0!==t?t:"").trim;return e=>!!e.querySelector(r)}}),de({selector:"[book-pages-with]",replace:ue,createTest:e=>{var t;const r=(null!==(t=e.textContent)&&void 0!==t?t:"").toLowerCase.trim;return e=>{var t;return(null!==(t=e.textContent)&&void 0!==t?t:"").toLowerCase.includes(r)}}})];const me=e=>e instanceof C,fe=e=>e instanceof z,be=e=>me(e)||fe(e)||(e=>e instanceof oe)(e);function we(e){return e.eachPage}function ve(e){return!!e.selector&&e.beforeAdd}function ye(e){return!!e.selector&&e.afterAdd}function ke(e){return e.pageNumberOffset}function Ee(e){return!!e.selector&&e.didSplit}function Pe(e){return!!e.selector&&e.avoidSplit}class xe{constructor(e){var t;const r=e.find(ke);this.pageNumberOffset=null!==(t=null==r?void 0:r.pageNumberOffset)&&void 0!==t?t:0,this.pageRules=e.filter(we),this.beforeAddRules=e.filter(ve),this.afterAddRules=e.filter(ye),this.selectorsNotToSplit=e.filter(Pe).map(e=>e.selector),this.didSplitRules=e.filter(Ee),e.filter(e=>e.setup).forEach(e=>e.setup),this.applySplitRules=this.applySplitRules.bind(this);const n=e.map(e=>e.selector).filter(e=>!!e).join(", ");if(n){const e=e=>!!e.querySelector(n);this.shouldTraverse=e.bind(this)}else this.shouldTraverse==>!1}applySplitRules(e,t){e.classList.add(i.toNext),t.classList.add(i.fromPrev),this.didSplitRules.filter(t=>e.matches(t.selector)).forEach(r=>{r.didSplit(e,t)})}applyPageDoneRules(e,t){this.pageRules.forEach(r=>r.eachPage(e,t))}finishEveryPage(e){this.pageRules.forEach(t=>e.pages.forEach(r=>t.eachPage(r,e)))}applyBeforeAddRules(e,t,r,n){let o=e;return this.beforeAddRules.filter(e=>o.matches(e.selector)).forEach(e=>{o=e.beforeAdd(o,t,r,n)}),o}applyAfterAddRules(e,t,r,n){let o=e;const i=e=>((e,t,r)=>{let n=e;const o=e.parentNode;if(!o)throw Error("Can't recoverFromRule when element is unparented");let i;if(o.removeChild(n),t.currentPage.hasOverflowed){if(o.appendChild(e),n=o,!n.parentNode)throw Error("Can't recoverFromRule when element is unparented");n.parentNode.removeChild(n),i=t.currentPage.flow.path.pop,t.currentPage.hasOverflowed&&console.error("Trying again didnt fix it")}const s=r;s.currentElement.appendChild(n),i&&s.path.push(i)})(e,t,r);return(e=>{const t=e.filter(be),r=e.filter(e=>!t.includes(e)),n=t.find(me),o=t.find(fe);return n?r.push(n):o?r.push(o):r.push(...t),r})(this.afterAddRules.filter(e=>o.matches(e.selector))).forEach(e=>{o=e.afterAdd(o,t,r,n,o=>(i(o),e.afterAdd(o,t,r,n,=>((e,t)=>{console.warn(`Couldn't apply ${e.name}, caused overflows twice when adding: `,t)})(e,o))))}),o}}const Se=e=>(e/1e3).toFixed(2),Te=async(e,t,r)=>{if(!Q.isSizeValid)throw Error("Page is too small");const n=(e=>{const t=window.performance.now,r=e.querySelectorAll("*").length;let n=0,o=0;return{increment:=>{o+=1},addWaitTime:e=>{n+=e},get progress{return o/r},end:=>{const e=window.performance.now-t-n;console.log(`📖 Layout ready in ${Se(e)}s (plus ${Se(n)}s waiting for images)`)}}})(e),o=new xe(t),i=new ee,s=o.pageNumberOffset,a==>new Q,l=(e=!1)=>{const t=i.currentPage;t&&((e,t)=>{i.updatePageOrder,te(i.pages,s),o.applyPageDoneRules(e,i),e.validateEnd(t),i.validate})(t,e);const l=a;return i.currentPage=l,i.addPage(l),r(i,n.progress),l.validate,l},d=o.applySplitRules,c=o.selectorsNotToSplit,h=e=>!c.some(t=>e.matches(t))&&(!e.parentElement||h(e.parentElement));return e.style.margin="0",e.style.padding="0",await X({content:e,createRegion:=>l.flow,applySplit:d,canSplit:h,beforeAdd:async(e,t)=>{o.applyBeforeAddRules(e,i,t,a)},afterAdd:async(e,t)=>(n.increment,o.applyAfterAddRules(e,i,t,a)),shouldTraverse:o.shouldTraverse,didWaitFor:e=>n.addWaitTime(e)}),i.updatePageOrder,te(i.pages,s),o.finishEveryPage(i),n.end,i},Re=async(e,t)=>{const r=await fetch(e);if(200!==r.status)throw Error(`Response ${r.status}: Could not load file at "${e}"`);const n=((e,t)=>{const r=window.document.createElement("div");return r.innerHTML=e,t?r.querySelector(t):r})(await r.text,t);if(!(n instanceof HTMLElement))throw Error(`Could not find element that matches selector "${t}" in response from ${e}`);return n},Oe=e=>{const t=`${e.width} × ${e.height}`;return window.hasOwnProperty("chrome")?r.AUTO,""+t],[r.AUTO_BLEED,t+" + Bleed"],[r.AUTO_MARKS,t+" + Marks"],[r.LETTER_PORTRAIT,"Letter Portrait"],[r.LETTER_LANDSCAPE,"Letter Landscape"],[r.A4_PORTRAIT,"A4 Portrait"],[r.A4_LANDSCAPE,"A4 Landscape":r.LETTER_PORTRAIT,"Default Page Size *"],[r.LETTER_PORTRAIT,"Only Chrome supports custom page sizes. Set in your browser's print dialog instead."},Le=t.NONE,"No Marks"],[t.CROP,"Crop Marks"],[t.BLEED,"Bleed Marks"],[t.BOTH,"Crop and Bleed",Ae=n.PREVIEW,"Grid"],[n.FLIPBOOK,"Flipbook"],[n.PRINT,"Print Preview",Ce=e.PAGES,"1 Page / Sheet"],[e.SPREADS,"1 Spread / Sheet"],[e.BOOKLET,"Booklet Sheets",ze=(e,...t)=>d(e+".row",...t),Ne=(e,t,r)=>((e,t,r)=>l("button",e,t,r))(".control.btn"+e,t,r),Be=(e,t)=>{const r=d(".select-val","Value"),n=((e,t,...r)=>l("select",e,t,...r))(".select",e,...t);return r.textContent=n.options[n.selectedIndex].text,d(".select-wrap.control",r,n)},Fe=(e,t,r,n)=>Be({onchange:e=>{const r=e.target.value,o=t.filter(e=>e[0].toString===r)[0];if(!o)throw Error("Selected unknown value");n(o[0])},id:e},t.map(e=>{const t=(n={value:e[0]},o=e[1],l("option",null,n,o));var n,o;return e[0]===r&&(t.selected=!0),t}));class Me{constructor{this.element=d(".controls")}update(e,t){var r,n;const o=this.element,i=this.render(e,t),s=document.hasFocus?null===(r=document.activeElement)||void 0===r?void 0:r.id:void 0;o.replaceWith(i),s&&(null===(n=document.getElementById(s))||void 0===n||n.focus),this.element=i}render(e,t){const o=e.mode===n.PRINT;return d(".controls",ze(".view-row",Fe("bindery-choose-view",Ae,e.mode,t.setMode)),o?((e,t)=>{const n=e.paper!==r.AUTO&&e.paper!==r.AUTO_BLEED,o=Oe(e.pageSize);return ze(".print-options",ze(null,Fe("bindery-choose-layout",Ce,e.layout,t.setLayout)),ze(null,Fe("bindery-choose-paper",o,e.paper,t.setPaper)),n?ze(null,Fe("bindery-choose-marks",Le,e.marks,t.setMarks)):"")})(e,t):"",Ne(".btn-print.btn-main",{onclick:=>{t.setMode(n.PRINT),setTimeout(window.print,10)}},"Print"))}}const $e=(e,t)=>{if(e.length%2!=0){const r=t;e.push(r)}const r=t,n=t;return r.element.style.visibility="hidden",n.element.style.visibility="hidden",e.unshift(r),e.push(n),e},Ie=(...e)=>d(".spread-wrapper.spread-centered.spread-size",...e),He=(e,t)=>{const r=t?$e(e,=>new Q):e,n=document.createDocumentFragment;if(t)for(let e=0;e{const t=((...e)=>d(".spread-wrapper.spread-centered.page-size",...e))(e.element);n.appendChild(t)});return{element:n}},Ve=["top","bottom","left","right"],De==>Ve.map(e=>d(".mark-bleed-"+e)),je==>Ve.map(e=>d(".mark-crop-"+e)),Ue==>d(".page-size.print-mark-wrap",...je,...De),_e==>d(".spread-size.print-mark-wrap",d(".mark-crop-fold"),...je,...De),We=(e,t)=>{const r=e%4==0,n=Math.round((e+1)/4)+1;return d(".print-meta",`Sheet ${n} of ${t/4}: ${r?"Outside":"Inside"}`)},qe=(...e)=>d(".spread-wrapper",...e),Ke=(...e)=>d(".spread-wrapper",...e),Ge==>{if(!document||!document.scrollingElement)return 0;const e=document.scrollingElement;return e.scrollTop/e.scrollHeight},Ye=e=>{if(!document.scrollingElement)return;const t=document.scrollingElement;t.scrollTop=t.scrollHeight*e};const Xe=(=>{let e,t=!1;const r=n=>{t?e=n:(t=!0,n,requestAnimationFrame(=>{if(t=!1,e){const t=e;e=void 0,r(t)}}))};return r}),Je=p(100),Qe=p(50);class Ze{constructor({pageSetup:e,mode:t,layout:r,marks:o}){this.hasRendered=!1,this.pageSetup=e,this.controls=new Me,this.updateControls,this.progressBar=d(".progress-bar"),this.content=d(".zoom-content"),this.scaler=d(".zoom-scaler",this.content),this.element=d(".root",this.progressBar,this.controls.element,this.scaler),this.isDoubleSided=!0,this.sheetLayout=r,this.marks=o,this.mode=t,this.element.classList.add(i.viewPreview),this.currentLeaf=0,(e=>{if(window.matchMedia){window.matchMedia("print").addListener(t=>{t.matches&&e})}document.body.addEventListener("keydown",t=>{(e=>(e.ctrlKey||e.metaKey)&&80===e.keyCode)(t)&&(t.preventDefault,e,setTimeout(=>window.print,200))})})(=>{this.mode=n.PRINT,this.render}),document.body.addEventListener("keydown",e=>{var t,r;switch(e.key){case"ArrowLeft":const e=null===(t=this.currentResult)||void 0===t?void 0:t.previous;e&&e;break;case"ArrowRight":const n=null===(r=this.currentResult)||void 0===r?void 0:r.next;n&&n}}),window.addEventListener("resize",=>{Qe(=>this.scaleToFit)}),this.setInProgress(!0),this.setMarks(o),this.show}updateControls{this.controls.update({paper:this.pageSetup.paper,layout:this.sheetLayout,mode:this.mode,marks:this.marks,pageSize:this.pageSetup.displaySize},{setMode:this.setMode.bind(this),setPaper:this.setSheetSize.bind(this),setLayout:this.setLayout.bind(this),setMarks:this.setMarks.bind(this)})}setMode(e){e!==this.mode&&(this.mode=e,this.updateControls,this.render)}get isInProgress{return this.element.classList.contains(i.inProgress)}setInProgress(e){this.element.classList.toggle(i.inProgress,e)}get isTwoUp{return this.sheetLayout!==e.PAGES}setShowingCropMarks(e){this.element.classList.toggle(i.showCrop,e)}setShowingBleedMarks(e){this.element.classList.toggle(i.showBleedMarks,e)}setShowingBleed(e){this.element.classList.toggle(i.showBleed,e)}get isViewing{return window.document.body.classList.contains(i.isViewing)}set isViewing(e){window.document.body.classList.toggle(i.isViewing,e)}setSheetSize(e){this.pageSetup.paper=e,this.pageSetup.updateStyleVars,this.mode=n.PRINT,this.render,this.scaleToFit,setTimeout(=>{this.scaleToFit},300)}setLayout(e){e!==this.sheetLayout&&(this.sheetLayout=e,this.pageSetup.printTwoUp=this.isTwoUp,this.pageSetup.updateStyleVars,this.mode=n.PRINT,this.render)}setMarks(e){this.marks=e,this.updateControls,this.setShowingCropMarks(e===t.CROP||e===t.BOTH),this.setShowingBleedMarks(e===t.BLEED||e===t.BOTH)}displayError(e,t){if(this.show,!this.error&&(this.error=((e,t)=>d(".error",d(".error-title",e),d(".error-text",t),d(".error-footer","Bindery v2.3.6")))(e,t),this.element.append(this.error),(=>{const e=document.scrollingElement;if(!e)return;const t=e.scrollHeight-e.offsetHeight;e.scrollTop=t}),this.book)){const e=this.book.currentPage.flow;e&&(e.currentElement.style.outline="3px solid red")}}clear{this.book=void 0,this.lastSpreadInProgress=void 0,this.content.innerHTML=""}show{this.element.parentNode||(window.document.body.appendChild(this.element),this.isViewing=!0)}hide{var e;null===(e=this.element.parentNode)||void 0===e||e.removeChild(this.element),this.isViewing=!1}render(e){if(e&&(this.book=e),!this.book)return;this.show,this.updateControls,this.element.classList.remove(...s),this.element.classList.add((e=>{switch(e){case n.PREVIEW:return i.viewPreview;case n.PRINT:return i.viewPrint;case n.FLIPBOOK:return i.viewFlip;default:throw Error("Getting class for unknown mode: "+e)}})(this.mode)),this.setShowingBleed(this.mode===n.PRINT);const t=Ge;this.setProgressAmount(1),window.requestAnimationFrame(=>{const e=this.renderViewMode;this.currentResult=e,this.content.innerHTML="",this.content.append(e.element),this.hasRendered?Ye(t):this.hasRendered=!0,this.scaleToFit})}renderViewMode{if(!this.book)throw Error("Book missing");const t=this.book.pages.slice;switch(this.mode){case n.PREVIEW:return He(t,this.isDoubleSided);case n.FLIPBOOK:return((e,t)=>{const r=$e(e,=>new Q),n=document.createDocumentFragment,i=d(".flipbook-sizer"),s=d(".spread-size.flap-holder");i.append(s),n.append(i);const a=[];let l=-1,c=4;r.length*c>60&&(c=60/r.length),s.style.width=r.length*c+"px";const h=e=>{let t=e;t===l&&(t+=1);const r=Math.min(Math.max(0,t),a.length);let n=4;a.length*n>200&&(n=200/a.length),a.forEach((e,t,o)=>{const i=(o.length-Math.abs(t-r+.5))*n;e.style.transform=`translate3d(${t{h(n-1)});const l=r[e].element;let u;l.classList.add(o("page3d-front")),i.append(l),t?(i.classList.add(o("doubleSided")),u=r[e+1].element):u=d(".page"),u.classList.add(o("page3d-back")),i.append(u),i.style.left=e*c+"px",a.push(i),s.append(i)}return h(0),{element:n,contentSizer:i,next:=>h(l+1),previous:=>h(l-1)}})(t,this.isDoubleSided);case n.PRINT:return((t,r,n)=>{const o=n!==e.PAGES,s=n===e.SPREADS,a=n===e.BOOKLET;let l=t;s?l=$e(l,=>new Q):a&&(l=((e,t)=>{for(e.length%4!=0;){const r=t;r.element.style.visibility="hidden",e.push(r)}const r=[],n=e.length;for(let t=0;tnew Q));const c=document.createDocumentFragment,h=o?_e:Ue,p=o?qe:Ke,u=(...e)=>d(".print-sheet",p(...e));if(o)for(let e=0;e{const t=e,r=u(t.element,h);r.classList.add(t.isLeft?i.sheetLeft:i.sheetRight),c.appendChild(r)});return{element:c}})(t,this.isDoubleSided,this.sheetLayout);default:throw Error(`Invalid layout mode: ${this.mode} (type ${typeof this.mode})`)}}setProgressAmount(e){e<1?Xe(=>{this.progressBar.style.transform=`scaleX(${e})`}):this.progressBar.style.transform=""}updateProgress(e,t){if(this.book=e,this.setProgressAmount(t),!window.document.scrollingElement)return;const r=window.document.scrollingElement,n=r.scrollTop,o=r.scrollHeight,i=r.offsetHeight;o>3*i&&nthis.renderProgress(e,t))}renderProgress(t,r){const o=!this.content.firstElementChild,i=this.mode===n.PREVIEW||this.mode===n.PRINT&&this.sheetLayout!==e.PAGES,s=i?2:1;t.pages.forEach((e,t)=>{if(!this.content.contains(e.element)||e.element.parentNode===this.content)if(this.lastSpreadInProgress&&this.lastSpreadInProgress.children.length<s)this.lastSpreadInProgress.append(e.element);else{if(this.lastSpreadInProgress=((...e)=>d(".spread-wrapper.spread-centered.spread-size",...e))(e.element),0===t&&i){const e=new Q;e.element.style.visibility="hidden",this.lastSpreadInProgress.insertBefore(e.element,this.lastSpreadInProgress.firstElementChild)}this.content.append(this.lastSpreadInProgress)}}),o&&this.scaleToFit}scaleToFit{if(!this.content.firstElementChild)return;const e=Ge,{xScale:t,yScale:r}=this.scaleThatFits,o=this.mode===n.FLIPBOOK?Math.min(1,t,r):Math.min(1,t);this.scaler.style.transform=`scale(${o})`,Ye(e)}scaleThatFits{var e,t;const r=null!==(t=null===(e=this.currentResult)||void 0===e?void 0:e.contentSizer)&&void 0!==t?t:this.content,n=window.innerWidth,o=window.innerHeight-40;return{xScale:n/r.offsetWidth,yScale:o/r.offsetHeight}}}const et=e=>Object.keys(e).map(t=>e[t]);class tt{constructor(o){var i,s,a,l,d,c,h,p,u;console.log("📖 Bindery v2.3.6"),k(o,{name:"makeBook",autorun:O.bool,content:O.any,view:O.enum(...et(n)),pageNumberOffset:O.number,pageSetup:O.shape({name:"pageSetup",margin:O.margin,size:O.size}),printSetup:O.shape({name:"printSetup",bleed:O.length,layout:O.enum(...et(e)),marks:O.enum(...et(t)),paper:O.enum(...et(r))}),rules:O.array}),this.autorun=null===(i=o.autorun)||void 0===i||i,this.autoupdate=null!==(s=o.autoupdate)&&void 0!==s&&s,this.pageSetup=new v(o.pageSetup,o.printSetup);const g=null!==(l=null===(a=o.printSetup)||void 0===a?void 0:a.layout)&&void 0!==l?l:e.PAGES,m=null!==(c=null===(d=o.printSetup)||void 0===d?void 0:d.marks)&&void 0!==c?c:t.CROP;if(this.viewer=new Ze({pageSetup:this.pageSetup,mode:null!==(h=o.view)&&void 0!==h?h:n.PREVIEW,marks:m,layout:g}),!o.content)throw this.viewer.displayError("Content not specified","You must include a source element, selector, or url"),Error("Bindery: You must include a source element or selector");if(o.hasOwnProperty("ControlsComponent"))throw this.viewer.displayError("Controls are now included","Please remove the controls component"),Error("Bindery: controls are now included");this.rules=ge,this.rules.push(new y({pageNumberOffset:null!==(p=o.pageNumberOffset)&&void 0!==p?p:0})),null===(u=o.rules)||void 0===u||u.forEach(e=>{if(!(e instanceof ae.Rule))throw Error("Bindery: The following is not an instance of Bindery.Rule and will be ignored: "+e);this.rules.push(e)}),this.autorun&&this.makeBook(o.content)}static makeBook(e){var t;return e.autorun=null===(t=e.autorun)||void 0===t||t,new tt(e)}cancel{this.viewer.hide,this.content&&(this.content.style.display="")}async makeBook(e){try{this.content=await(async e=>{if(e instanceof HTMLElement)return e;if("string"==typeof e){const t=document.querySelector(e);if(!(t instanceof HTMLElement))throw Error(`Could not find element that matches selector "${e}"`);return t}if("object"==typeof e&&e.url)return Re(e.url,e.selector);throw Error("Content source must be an element or selector")})(e)}catch(e){return this.viewer.show,void this.viewer.displayError("",e.message)}this.content.style.display="";const t=this.content.cloneNode(!0);this.content.style.display="none",this.viewer.clear,this.viewer.show,this.pageSetup.updateStyleVars,this.viewer.setInProgress(!0);const r=(e,t)=>{this.viewer.updateProgress(e,t)};try{const e=await Te(t,this.rules,r);return this.viewer.setProgressAmount(1),await new Promise(e=>{requestAnimationFrame(t=>e(t))}),this.viewer.render(e),this.viewer.setInProgress(!1),e}catch(e){return this.viewer.setInProgress(!1),void this.viewer.displayError("Layout couldn't complete",e.message)}}}!function(e){if(e&&"undefined"!=typeof window){var t=document.createElement("style");t.setAttribute("type","text/css"),t.innerHTML=e,document.head.appendChild(t)}}('.📖-page{width:var(--bindery-page-width);height:var(--bindery-page-height);position:relative;display:flex;flex-direction:column;flex-wrap:nowrap}.📖-continuation{text-indent:unset!important}li.continuation{list-style:none!important}.📖-flow-box{position:relative;margin-top:var(--bindery-margin-top);flex:1 1 auto;min-height:0}.📖-footer{margin-top:8pt;margin-bottom:var(--bindery-margin-bottom);flex:0 1 auto;z-index:2}.📖-flow-box,.📖-footer{margin-left:var(--bindery-margin-inner);margin-right:var(--bindery-margin-outer)}.📖-left .📖-flow-box,.📖-left .📖-footer{margin-left:var(--bindery-margin-outer);margin-right:var(--bindery-margin-inner)}.📖-page-background{position:absolute;z-index:0;overflow:hidden;top:calc(-1*var(--bindery-bleed));bottom:calc(-1*var(--bindery-bleed));left:calc(-1*var(--bindery-bleed));right:calc(-1*var(--bindery-bleed))}.📖-left>.📖-page-background{right:0}.📖-right>.📖-page-background{left:0}.📖-sup{font-size:.667em}.📖-footer,.📖-running-header{font-size:10pt}.📖-running-header{position:absolute;text-align:center;top:.25in}.📖-left .📖-running-header{text-align:left;left:var(--bindery-margin-outer)}.📖-right .📖-running-header{right:var(--bindery-margin-outer);text-align:right}.📖-page-size-rotated{height:var(--bindery-page-width);width:var(--bindery-page-height)}.📖-spread-size{height:var(--bindery-page-height);width:calc(var(--bindery-page-width)*2)}.📖-spread-size-rotated{width:var(--bindery-page-height);height:calc(var(--bindery-page-width)*2)}.📖-spread.📖-right>.📖-page-background{left:calc(-100% - var(--bindery-bleed))}.📖-spread.📖-left>.📖-page-background{right:calc(-100% - var(--bindery-bleed))}@media screen{.📖-viewing .📖-controls{display:flex!important}}.📖-controls{font:14px/1.4 -apple-system,BlinkMacSystemFont,Roboto,sans-serif;display:none;flex-direction:row;align-items:start;position:sticky;top:0;left:0;right:0;z-index:99;margin:auto;color:var(--bindery-ui-text);padding:8px;overflow:hidden;-webkit-font-smoothing:antialiased}.📖-controls *{font:inherit;color:inherit;margin:0;padding:0;box-sizing:border-box}.📖-controls a{color:var(--bindery-ui-accent);text-decoration:none}.📖-row{position:relative;display:flex;flex-wrap:wrap;align-items:start;cursor:default;user-select:none}.📖-controls .📖-btn{-webkit-appearance:none;cursor:pointer;display:inline-block;margin-right:8px;text-decoration:none}.📖-controls .📖-btn:hover{background:rgba(0,0,0,.04)}.📖-controls .📖-btn:active{background:rgba(0,0,0,.08)}.📖-controls .📖-btn:last-child{margin-right:0}.📖-control{border-radius:6px;color:var(--bindery-ui-text);padding:4px 8px;border:1px solid #ddd;margin-right:12px}.📖-controls .📖-btn-main{position:absolute;top:8px;right:8px;background:var(--bindery-ui-accent);border-color:var(--bindery-ui-accent);color:#fff}.📖-controls .📖-btn-main:hover{background:var(--bindery-ui-accent);opacity:.7}.📖-controls .📖-btn-main:active{background:#000;opacity:1}.📖-controls .📖-btn-main:focus{outline:0;box-shadow:0 0 0 1px var(--bindery-ui-bg),0 0 0 3px rgba(0,0,0,.3)}.📖-view-row{transition:all .3s}.📖-in-progress .📖-view-row{opacity:0;pointer-events:none}.📖-debug .📖-view-row{display:none}.📖-btn-print{margin-left:auto;transition:all .3s}.📖-in-progress .📖-btn-print{opacity:0;pointer-events:none}.📖-controls .📖-select-wrap{padding-right:24px;transition:all .2s;white-space:nowrap;width:100%;position:relative}.📖-controls .📖-select-wrap:after{content:"";position:absolute;right:9px;top:12px;padding:0;border:4px solid transparent;border-top-color:currentcolor}.📖-controls .📖-select-wrap:hover{background:rgba(0,0,0,.04)}.📖-controls .📖-select-wrap:active{background:rgba(0,0,0,.08)}.📖-controls .📖-select-wrap:focus-within{outline:0;box-shadow:0 0 0 1px var(--bindery-ui-bg),0 0 0 3px rgba(0,0,0,.3)}.📖-select{cursor:pointer;position:absolute;top:0;left:0;opacity:0;-webkit-appearance:none;-moz-appearance:none;padding:4px 8px;color:#000;border:transparent;width:100%;font-size:18px}.📖-view-print .📖-controls{background:var(--bindery-ui-bg)}@media screen and (max-width:960px){.📖-view-preview .📖-controls,.📖-view-print .📖-controls{background:var(--bindery-ui-bg);flex-direction:column}}@media screen and (max-width:500px){.📖-view-print .📖-controls{background:var(--bindery-ui-bg)}.📖-view-row{margin-bottom:8px}.📖-print-options{flex-direction:column;align-items:stretch;width:100%}.📖-print-options .📖-row+.📖-row{margin-top:8px}.📖-print-options .📖-select-wrap{margin:0}}.📖-left .📖-rotate-container.📖-rotate-outward,.📖-left .📖-rotate-container.📖-rotate-spread-clockwise,.📖-right .📖-rotate-container.📖-rotate-inward,.📖-rotate-container.📖-rotate-clockwise{transform:rotate(90deg) translate3d(0,-100%,0);transform-origin:top left}.📖-left .📖-rotate-container.📖-rotate-inward,.📖-left .📖-rotate-container.📖-rotate-spread-counterclockwise,.📖-right .📖-rotate-container.📖-rotate-outward,.📖-rotate-container.📖-rotate-counterclockwise{transform:rotate(-90deg) translate3d(-100%,0,0);transform-origin:top left}.📖-rotate-container{position:absolute}.📖-left .📖-rotate-container.📖-rotate-clockwise .📖-page-background{top:0}.📖-left .📖-rotate-container.📖-rotate-counterclockwise .📖-page-background,.📖-right .📖-rotate-container.📖-rotate-clockwise .📖-page-background{bottom:0}.📖-right .📖-rotate-container.📖-rotate-counterclockwise .📖-page-background{top:0}.📖-rotate-container.📖-rotate-inward .📖-page-background{bottom:0}.📖-rotate-container.📖-rotate-outward .📖-page-background{top:0}.📖-right .📖-rotate-container.📖-rotate-spread-clockwise{transform:rotate(90deg) translate3d(0,-50%,0);transform-origin:top left}.📖-right .📖-rotate-container.📖-rotate-spread-counterclockwise{transform:rotate(-90deg) translate3d(-100%,-50%,0);transform-origin:top left}:root{--bindery-ui-bg:#f4f4f4;--bindery-ui-accent:#000;--bindery-ui-text:#000}@media screen{.📖-root{transition:opacity .2s;opacity:1;background:var(--bindery-ui-bg);z-index:99;position:relative;min-height:100vh}.📖-progress-bar{transform-origin:top left;transform:scaleY(0);position:fixed;left:0;top:0;right:0;background:var(--bindery-ui-accent);transition:transform .2s;height:2px;z-index:99}.📖-in-progress .📖-progress-bar{transform:scaleX(0)}.📖-zoom-content{padding:10px;background:var(--bindery-ui-bg);margin:auto}.📖-view-preview .📖-zoom-content{min-width:calc(20px + var(--bindery-spread-width))}.📖-view-print .📖-zoom-content{min-width:calc(20px + var(--bindery-sheet-width))}.📖-zoom-content>.📖-page{margin:auto}.📖-measure-area{position:fixed;padding:50px 20px;z-index:99;visibility:hidden;top:0;left:0;width:0;height:0;overflow:hidden}.📖-is-overflowing{border-bottom:1px solid #f0f}.📖-print-sheet{margin:0 auto}.📖-error{font:16px/1.4 -apple-system,BlinkMacSystemFont,Roboto,sans-serif;padding:15vh 15vw;z-index:999;position:fixed;top:0;left:0;right:0;bottom:0;background:hsla(0,0%,95.7%,.7)}.📖-error-title{font-size:1.5em;margin-bottom:16px}.📖-error-text{margin-bottom:16px;white-space:pre-line}.📖-error-footer{opacity:.5;font-size:.66em;text-transform:uppercase;letter-spacing:.02em}.📖-show-bleed .📖-print-sheet{background:#fff;outline:1px solid rgba(0,0,0,.1);box-shadow:0 1px 3px rgba(0,0,0,.2);margin:20px auto}}@media screen{.📖-page{background:#fff;box-shadow:0 0 0 .5px rgba(0,0,0,.3);overflow:hidden}.📖-show-bleed .📖-page{box-shadow:none;overflow:visible}.📖-show-bleed .📖-page:after{content:"";outline:1px dotted rgba(0,255,255,.7);position:absolute;left:0;right:0;bottom:0;top:0;z-index:99}.📖-placeholder-num{visibility:hidden!important}}.📖-print-sheet{width:var(--bindery-sheet-width);height:var(--bindery-sheet-height)}.📖-page-bleed-clip{overflow:hidden}.📖-page-bleed-clip-left{padding-left:calc(var(--bindery-bleed) + 12pt)}.📖-page-bleed-clip-right{padding-right:calc(var(--bindery-bleed) + 12pt)}.📖-show-bleed-marks .📖-print-sheet .📖-page-bleed-clip,.📖-show-crop .📖-print-sheet .📖-page-bleed-clip{padding-top:calc(var(--bindery-bleed) + 12pt);padding-bottom:calc(var(--bindery-bleed) + 12pt)}.📖-print-sheet-spread .📖-spread-wrapper{margin-left:auto;margin-right:auto}.📖-viewing{margin:0}.📖-zoom-scaler{transform-origin:top left;transform-style:preserve-3d}.📖-print-sheet{position:relative;overflow:hidden;display:flex;align-items:center;justify-content:center;transition:all .2s}.📖-print-sheet-left{justify-content:left}.📖-print-sheet-right{justify-content:right}.📖-spread-wrapper{position:relative;display:flex;justify-content:center;margin:auto}.📖-spread-centered{margin:0 auto 32px}@page{margin:0}@media print{.📖-root *{-webkit-print-color-adjust:exact;color-adjust:exact}.📖-controls{display:none!important}.📖-print-sheet{contain:layout;margin:0 auto;page-break-after:always}.📖-zoom-scaler[style]{transform:none!important}}.📖-print-mark-wrap{display:none;position:absolute;pointer-events:none;top:0;bottom:0;left:0;right:0;z-index:999;margin:auto}.📖-show-bleed-marks .📖-print-mark-wrap,.📖-show-crop .📖-print-mark-wrap{display:block}.📖-show-crop .📖-print-mark-wrap>[class*=crop]{display:block}.📖-show-bleed-marks .📖-print-mark-wrap>[class*=bleed]{display:block}.📖-print-mark-wrap>div{display:none;position:absolute;overflow:hidden}.📖-print-mark-wrap>div:after,.📖-print-mark-wrap>div:before{content:"";display:block;position:absolute}.📖-print-mark-wrap>div:before{top:0;left:0}.📖-print-mark-wrap>div:after{bottom:0;right:0}.📖-mark-bleed-left,.📖-mark-bleed-right,.📖-mark-crop-fold,.📖-mark-crop-left,.📖-mark-crop-right{width:1px;margin:auto}.📖-mark-bleed-left:after,.📖-mark-bleed-left:before,.📖-mark-bleed-right:after,.📖-mark-bleed-right:before,.📖-mark-crop-fold:after,.📖-mark-crop-fold:before,.📖-mark-crop-left:after,.📖-mark-crop-left:before,.📖-mark-crop-right:after,.📖-mark-crop-right:before{width:1px;height:var(--bindery-mark-length);background-image:linear-gradient(90deg,#000 0,#000 51%,transparent 0);background-size:1px 100%}.📖-mark-bleed-bottom,.📖-mark-bleed-top,.📖-mark-crop-bottom,.📖-mark-crop-top{height:1px}.📖-mark-bleed-bottom:after,.📖-mark-bleed-bottom:before,.📖-mark-bleed-top:after,.📖-mark-bleed-top:before,.📖-mark-crop-bottom:after,.📖-mark-crop-bottom:before,.📖-mark-crop-top:after,.📖-mark-crop-top:before{width:var(--bindery-mark-length);height:1px;background-image:linear-gradient(180deg,#000 0,#000 51%,transparent 0);background-size:100% 1px}.📖-mark-crop-fold{right:0;left:0}.📖-mark-crop-left{left:0}.📖-mark-crop-right{right:0}.📖-mark-crop-top{top:0}.📖-mark-crop-bottom{bottom:0}.📖-print-meta{padding:var(--bindery-mark-length);text-align:center;font-family:-apple-system,BlinkMacSystemFont,Roboto,sans-serif;font-size:8pt;display:block!important;position:absolute;bottom:-60pt;left:0;right:0}.📖-mark-bleed-left,.📖-mark-bleed-right,.📖-mark-crop-fold,.📖-mark-crop-left,.📖-mark-crop-right{top:calc(-1*var(--bindery-mark-length) - var(--bindery-bleed));bottom:calc(-1*var(--bindery-mark-length) - var(--bindery-bleed))}.📖-mark-bleed-bottom,.📖-mark-bleed-top,.📖-mark-crop-bottom,.📖-mark-crop-top{left:calc(-12pt - var(--bindery-bleed));right:calc(-12pt - var(--bindery-bleed))}.📖-mark-bleed-left{left:calc(-1*var(--bindery-bleed))}.📖-mark-bleed-right{right:calc(-1*var(--bindery-bleed))}.📖-mark-bleed-top{top:calc(-1*var(--bindery-bleed))}.📖-mark-bleed-bottom{bottom:calc(-1*var(--bindery-bleed))}.📖-root.📖-view-flip{max-height:100vh}.📖-view-flip .📖-zoom-holder{position:absolute;top:0;left:0;bottom:0;right:0;margin:auto;display:block}.📖-view-flip .📖-zoom-scaler{position:absolute;top:0;left:0;bottom:0;right:0;margin:auto;transform-origin:center;width:0;height:0}.📖-view-flip .📖-zoom-content{min-width:0}.📖-flap-holder{perspective:5000px;transform-style:preserve-3d;position:absolute;top:0;left:0;bottom:0;right:0;margin:auto}.📖-flipbook-sizer{--bindery-flipbook-width:calc(var(--bindery-spread-width)*1.15);--bindery-flipbook-height:calc(var(--bindery-page-height)*1.05);position:absolute;width:var(--bindery-flipbook-width);height:var(--bindery-flipbook-height);top:calc(var(--bindery-flipbook-height)*-0.5);left:calc(var(--bindery-flipbook-width)*-0.5)}.📖-page3d{margin:auto;width:var(--bindery-page-width);height:var(--bindery-page-height);transform:rotateY(0);transform-style:preserve-3d;transform-origin:left;transition:transform .5s,box-shadow .1s;position:absolute;left:0;right:0;top:0;bottom:0}.📖-page3d:hover{box-shadow:2px 0 4px rgba(0,0,0,.2)}.📖-page3d.📖-flipped{transform:rotateY(-180deg)}.📖-page3d .📖-page{position:absolute;backface-visibility:hidden;-webkit-backface-visibility:hidden;box-shadow:0 0 2px rgba(0,0,0,.1)}.📖-page3d .📖-page3d-front{transform:rotateY(0)}.📖-page3d .📖-page3d-back{transform:rotateY(-180deg)}');const rt={View:n,Paper:r,Layout:e,Marks:t,version:"v2.3.6"};return Object.assign(tt,ae,rt)}; //# sourceMappingURL=bindery.min.js.map