@foxycape/core 1.2.3 → 1.2.4

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.
Files changed (39) hide show
  1. package/dist/kernal/FileLoader.cjs +1 -1
  2. package/dist/kernal/FileLoader.mjs +1 -1
  3. package/dist/kernal/Reader.cjs +1 -1
  4. package/dist/kernal/Reader.mjs +1 -1
  5. package/dist/kernal/html/geometry.cjs +1 -1
  6. package/dist/kernal/html/geometry.d.ts +3 -3
  7. package/dist/kernal/html/geometry.mjs +22 -22
  8. package/dist/mediaTypes/html/DefaultHtmlSymbolMeasure.cjs +1 -1
  9. package/dist/mediaTypes/html/DefaultHtmlSymbolMeasure.mjs +9 -9
  10. package/dist/mediaTypes/html/renderer/HtmlRenderer.cjs +1 -1
  11. package/dist/mediaTypes/html/renderer/HtmlRenderer.mjs +7 -7
  12. package/dist/mediaTypes/html/renderer/document/HtmlDocument.cjs +1 -1
  13. package/dist/mediaTypes/html/renderer/document/HtmlDocument.mjs +22 -22
  14. package/dist/mediaTypes/html/renderer/document/HtmlPageCalculator.cjs +1 -1
  15. package/dist/mediaTypes/html/renderer/document/HtmlPageCalculator.mjs +13 -13
  16. package/dist/mediaTypes/html/renderer/documents/HtmlDocumentsProvider.cjs +1 -1
  17. package/dist/mediaTypes/html/renderer/documents/HtmlDocumentsProvider.mjs +39 -39
  18. package/dist/mediaTypes/html/renderer/html/HtmlContentProcessor.cjs +1 -1
  19. package/dist/mediaTypes/html/renderer/html/HtmlContentProcessor.mjs +8 -8
  20. package/dist/mediaTypes/html/renderer/image/HtmlImageLoader.cjs +1 -1
  21. package/dist/mediaTypes/html/renderer/image/HtmlImageLoader.mjs +8 -8
  22. package/dist/mediaTypes/html/renderer/layout/HtmlRendererViewport.cjs +1 -1
  23. package/dist/mediaTypes/html/renderer/layout/HtmlRendererViewport.mjs +12 -12
  24. package/dist/mediaTypes/html/renderer/layout/pageStripRouteChange.cjs +1 -1
  25. package/dist/mediaTypes/html/renderer/layout/pageStripRouteChange.mjs +10 -10
  26. package/dist/mediaTypes/html/renderer/location/HtmlLayoutStatePreserver.cjs +1 -1
  27. package/dist/mediaTypes/html/renderer/location/HtmlLayoutStatePreserver.mjs +14 -14
  28. package/dist/mediaTypes/html/renderer/style/HtmlStyleProvider.cjs +1 -1
  29. package/dist/mediaTypes/html/renderer/style/HtmlStyleProvider.d.ts +0 -1
  30. package/dist/mediaTypes/html/renderer/style/HtmlStyleProvider.mjs +6 -7
  31. package/dist/mediaTypes/html/renderer/style/html-content.cjs +4 -0
  32. package/dist/mediaTypes/html/renderer/style/html-content.mjs +1 -1
  33. package/dist/mediaTypes/pdf/fileParser/PdfFileParser.cjs +1 -1
  34. package/dist/mediaTypes/pdf/fileParser/PdfFileParser.mjs +7 -7
  35. package/dist/mediaTypes/pdf/renderer/PdfDocument.cjs +1 -1
  36. package/dist/mediaTypes/pdf/renderer/PdfDocument.mjs +6 -6
  37. package/dist/mediaTypes/pdf/renderer/documents/PdfDocumentsProvider.cjs +1 -1
  38. package/dist/mediaTypes/pdf/renderer/documents/PdfDocumentsProvider.mjs +7 -7
  39. package/package.json +2 -2
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../../../kernal/html/injector.cjs"),t=require("../../../../kernal/html/realm.cjs"),n=require("../../HtmlSettings.cjs"),r=require("./ViewportCssVariableNames.cjs"),i=require("./resolveLayoutRoute.cjs"),a=require("./HtmlLayoutMetrics.cjs"),o=require("../documents/HtmlContainerBuilder.cjs"),s=require("./applyLayoutClasses.cjs"),c=require("./resolveContentWrapperMinWidth.cjs");var l=class{constructor(t,r,i,a){this.owner=t,this.readerContainer=r,this.getColumnWidth=()=>this.htmlOptions.maxColumnWidth?Math.abs(this.htmlOptions.maxColumnWidth):768,this.options=this.owner.options,this.device=this.owner.device,this.optionsProvider=i,this.htmlOptions=a,this.containerBuilder=new o.HtmlContainerBuilder(a);let{rendererContainer:s,rendererCss:c,otherCss:l}=this.containerBuilder.createContainers();e.injectCssContent(this.readerContainer.ownerDocument,c+l,!0,`html-renderer-style`),this.readerContainer.appendChild(s),this.rendererContainer=s,this.scrollElement=this.rendererContainer,this.contentsShadowContainer=this.rendererContainer.querySelector(`.`+n.HtmlSettings.ContentsShadowContainerCssName),this.rendererContainer.setAttribute(n.HtmlSettings.HostViewportModeAttribute,this.owner.getHostViewport().mode)}getRendererContainer(){return this.rendererContainer}getScrollElement(){let e=this.owner.getHostViewport();return e.mode==`window`?e.scrollElement:this.rendererContainer}getLayoutMetrics(){return this.layout||=(this.internlApplyCssVariables(),this.buildLayoutMetrics()),this.layout}applyCssVariables(){this.internlApplyCssVariables(),this.layout=this.buildLayoutMetrics()}internlApplyCssVariables(){this.owner.refreshHostViewport();let e=i.getLayoutGeometry(this.htmlOptions),t=this.getScrollElement(),n=e.flipMode==`scroll`&&t?{left:t.scrollLeft,top:t.scrollTop}:void 0;this.applyFlowClasses(e),this.syncPageTransformSign(e);let a=this.prepareRendererCssVariables(),o=this.prepareOtherCssVariables(),s=new Map;a.forEach((e,t)=>{s.set(t,e)}),o.forEach((e,t)=>{s.set(t,e)});let c=this.owner.getRootContainer();c.style.setProperty(`direction`,`var(${r.ViewportCssVariableNames.ReaderViewportDirection})`),s.forEach((e,t)=>{c.style.setProperty(t,e)}),n&&t&&t.scrollTo(n.left,n.top)}syncPageTransformSign(e){let r=this.rendererContainer.querySelector(`.`+n.HtmlSettings.TransformContainerCssName);if(!t.isHtmlElement(r))return;if(e.flipMode!=`page`){r.style.removeProperty(`transition`),r.style.removeProperty(`transform`),r.removeAttribute(`data-target-transform`);return}if(r.hasAttribute(n.HtmlSettings.PageMovingAttributeName))return;let i=r.getAttribute(`data-target-transform`);if(i==null||i===``)return;let a=parseFloat(i);Number.isFinite(a)&&(r.style.removeProperty(`transition`),r.style.transform=e.getPageTranslateCss(a))}prepareRendererCssVariables(){let e=i.getLayoutGeometry(this.htmlOptions),t=e.flipMode;this.rendererContainer.setAttribute(n.HtmlSettings.HostViewportModeAttribute,this.owner.getHostViewport().mode);let a=new Map,o=e.viewport.zeroWrapperMargins?0:this.htmlOptions.contentWrapperMarginBottom??10,s=e.viewport.zeroWrapperMargins?0:this.htmlOptions.contentWrapperMarginTop??10,c=e.viewport.zeroWrapperMargins?0:this.htmlOptions.contentWrapperGap??10;a.set(r.ViewportCssVariableNames.ContentWrapperMarginTop,s+`px`),a.set(r.ViewportCssVariableNames.ContentWrapperMarginBottom,o+`px`),a.set(r.ViewportCssVariableNames.ContentWrapperGap,c+`px`);let l=this.htmlOptions.enableContentWrapperBorderRadius&&t==`scroll`?this.htmlOptions.contentWrapperBorderRadius??0:0;a.set(r.ViewportCssVariableNames.ContentWrapperBorderRadius,l+`px`);let u=this.owner.getHostViewport().mode==`window`&&t==`scroll`;return a.set(r.ViewportCssVariableNames.ScrollElementOverflow,u?`visible`:e.overflowY),a.set(r.ViewportCssVariableNames.ScrollElementOverflowX,u?`visible`:e.overflowX),a.set(r.ViewportCssVariableNames.ReaderViewportDirection,e.direction==`ltr`?`unset`:e.direction),a}applyFlowClasses(e){s.applyRootDirectionClass(this.owner.getRootContainer(),e),s.applyRendererLayoutClass(this.rendererContainer,e)}prepareOtherCssVariables(){let e=this.owner.getRootContainer(),t=i.getLayoutGeometry(this.htmlOptions),n=t.flipMode;n==`page`&&this.scrollElement?.scrollTo(0,0);let a=this.htmlOptions.columnGap??40,o=this.contentsShadowContainer,s=this.rendererContainer.clientWidth||this.owner.getHostViewport().width,l=this.getViewportHeight();this.rendererContainer.setAttribute(`data-client-width`,`${s}`),this.rendererContainer.setAttribute(`data-client-height`,`${l}`);let u=this.getContentsContainerWidth(),d=t.viewport.contentsContainerWidthMode==`max-content`?`max-content`:u+`px`,f=this.rendererContainer.offsetWidth-this.rendererContainer.clientWidth,p=this.rendererContainer.offsetHeight-this.rendererContainer.clientHeight,m=new Map;m.set(r.ViewportCssVariableNames.ScrollElementVerticalScrollBarWidth,f+`px`),m.set(r.ViewportCssVariableNames.ScrollElementHorizontalScrollBarHeight,p+`px`),m.set(r.ViewportCssVariableNames.ReaderViewportWidth,s+`px`),m.set(r.ViewportCssVariableNames.ReaderViewportHeight,l+`px`),e.style.setProperty(r.ViewportCssVariableNames.ContentsContainerWidth,d),m.set(r.ViewportCssVariableNames.ContentsContainerWidth,d);let h=0;n==`page`&&(h=0),s-u-2<2*h&&(h=0);let g=``;g=h>0?``+h+`px 0`:`0`,e.style.setProperty(r.ViewportCssVariableNames.ContentsContainerPadding,g),m.set(r.ViewportCssVariableNames.ContentsContainerPadding,g);let _=t.viewport.forceSingleColumn?1:this.calculateColumns(u);t.viewport.forceSingleColumn||(this.htmlOptions.columns=_);let{marginInline:v,marginBlock:y}=this.getContentsShadowMargin(u),{columnWidth:b}=this.getFinalColumnWidth(u-v*2,_,a),x=v,S=y;n==`scroll`&&(x=0,S=0),o.style=n==`scroll`?`margin: ${S}px ${x}px;`:`margin: ${S}px ${x}px;height: ${l-2*y}px;`;let C=o.getBoundingClientRect().width,w=_*b+Math.max(0,_-1)*a,{contentWrapperPaddingBottomNumber:T,contentWrapperPaddingTopNumber:E,contentWrapperPadding:D,contentWrapperPaddingTopBottom:O}=this.getContentWrapperPadding(u,a),k=l-E-T,A=t.getPageMoveLength(w,k,a);this.rendererContainer.setAttribute(`data-transform-length`,A.toString()),this.rendererContainer.setAttribute(`data-shadow-width`,C.toString()),this.rendererContainer.setAttribute(`data-column-width`,b.toString()),this.rendererContainer.setAttribute(`data-column-gap`,a.toString()),this.rendererContainer.setAttribute(`data-page-width`,`${w}`),this.rendererContainer.setAttribute(`data-page-height`,`${k}`),m.set(r.ViewportCssVariableNames.ContentWrapperWidth,t.viewport.contentWrapperWidthMode==`auto`?`auto`:C+`px`),m.set(r.ViewportCssVariableNames.ContentWrapperMinWidth,c.resolveContentWrapperMinWidth(t.viewport.contentWrapperMinWidthMode,{shadowWidth:C,columnWidth:b,columnGap:a,viewportWidth:s})),m.set(r.ViewportCssVariableNames.ContentWrapperHeight,this.getContentWrapperHeight()),m.set(r.ViewportCssVariableNames.ContentWrapperMinHeight,l+`px`),m.set(r.ViewportCssVariableNames.ContentWrapperMaxHeight,t.viewport.contentWrapperMaxHeightMode==`none`?`none`:l+`px`),m.set(r.ViewportCssVariableNames.ContentWrapperPadding,D),t.viewport.contentContainerWidthMode==`auto`?m.set(r.ViewportCssVariableNames.ContentContainerWidth,`auto`):t.viewport.contentContainerWidthMode==`column`?m.set(r.ViewportCssVariableNames.ContentContainerWidth,b+`px`):m.set(r.ViewportCssVariableNames.ContentContainerWidth,`100%`);let j=t.viewport.contentContainerHeightMode==`page`?k+`px`:`calc(var(${r.ViewportCssVariableNames.ContentWrapperHeight}) - ${O})`;return m.set(r.ViewportCssVariableNames.ContentContainerHeight,j),m.set(r.ViewportCssVariableNames.ContentColumnGap,a+`px`),m}buildLayoutMetrics(){let e=this.getFlipMode(),t=new a.HtmlLayoutMetrics,n=this.rendererContainer,{clientWidth:r}=n,i=parseFloat(n.getAttribute(`data-transform-length`));t.clientWidth=r||this.owner.getHostViewport().width;let o;return o=e==`scroll`?this.getViewportHeight():parseFloat(n.getAttribute(`data-page-height`)),t.clientHeight=this.getViewportHeight(),t.pageHeight=o,t.columnHeight=o,t.columnGap=parseFloat(n.getAttribute(`data-column-gap`)),t.columnWidth=parseFloat(n.getAttribute(`data-column-width`)),t.pageWidth=parseFloat(n.getAttribute(`data-page-width`)),t.pageMoveLength=i,t.shadowWidth=parseFloat(n.getAttribute(`data-shadow-width`)),t}getContentWrapperHeight(){let e=i.getLayoutGeometry(this.htmlOptions);return e.viewport.contentWrapperHeightMode==`auto`?`auto`:e.viewport.contentWrapperHeightMode==`viewport`?`${this.getViewportHeight()}px`:this.owner.inIframe?`100%`:`auto`}getContentsShadowMargin(e){let t=this.htmlOptions.contentsShadowMargin??20,n=this.getContentPaddingFactor(),r=this.device.getDeviceType()==`mobile`?Math.round(t*.6):t;return{marginBlock:r,marginInline:r+Math.min(10,e*n)}}getContentWrapperPadding(e,t){let n=this.getFlipMode(),r=n==`scroll`?30:0,{marginBlock:i,marginInline:a}=this.getContentsShadowMargin(e);n==`page`&&(r+=i);let o=r+`px`,s=n==`scroll`?30:0;n==`page`&&(s+=i);let c=s+`px`;return{contentWrapperPaddingTop:o,contentWrapperPaddingLeft:n==`scroll`?`${a}px`:`0`,contentWrapperPaddingRight:n==`scroll`?`${a}px`:`0`,contentWrapperPaddingBottom:c,contentWrapperPaddingLeftRight:n==`scroll`?`${t}px`:`0`,contentWrapperPaddingTopBottom:`${r+s}px`,contentWrapperPadding:n==`scroll`?`${r}px ${a}px ${s}px ${a}px`:`0px`,contentWrapperPaddingTopNumber:r,contentWrapperPaddingBottomNumber:s}}getContentsContainerWidth(){let e=this.rendererContainer.clientWidth||this.owner.getHostViewport().width;if(this.device.getDeviceType()==`mobile`&&e<=768)return e;if(this.getFlipMode()==`scroll`)return this.htmlOptions.enableAutoFitPageWidth?e:this.htmlOptions.maxScrollContentWidth?Math.min(e,Math.abs(this.htmlOptions.maxScrollContentWidth)):Math.min(e,this.htmlOptions.columnWidth);let t=this.htmlOptions.columns,n=this.getColumnWidth();if(this.htmlOptions.autoColumns){if(!this.htmlOptions.maxColumns)return e;t=e<=n?1:this.htmlOptions.maxColumns}let r=this.getMultiColumnWidthFactor();return t>1?Math.min(e,t*n*r):Math.min(e,n)}calculateColumns(e){let t=this.htmlOptions.columns??1,n=this.getColumnWidth();if(this.htmlOptions.autoColumns){if(e<=n)t=1;else{t=Math.floor(e/n);let r=e%n;(r>n/5||r>t*50)&&(t+=1),this.htmlOptions.maxColumns&&t>this.htmlOptions.maxColumns&&(t=this.htmlOptions.maxColumns)}}return t}getFinalColumnWidth(e,t,n){let r=n*(t-1),i=(e-r)/t,a=0,o=Math.round(i);return o!=i&&(i=o,a=e-(t*o+r)),{columnWidth:i,remainder:a}}getContentPaddingFactor(){return this.device.getDeviceType()==`mobile`?.01:.05}getMultiColumnWidthFactor(){let e=this.htmlOptions.multiColumnWidthFactor;return e||=.8,e=Math.abs(e),e<.5&&(e=.5),e>1&&(e=1),e}getViewportHeight(){let e=this.owner.getHostViewport();if(e.mode==`host`){let e=this.rendererContainer.clientHeight;if(e>=80&&e<33554400)return Math.round(e)}return e.height}getFlipMode(){return i.getLayoutGeometry(this.htmlOptions).flipMode}async dispose(){this.updateCssVariablesTimeoutId&&=(clearTimeout(this.updateCssVariablesTimeoutId),null)}};exports.HtmlRendererViewport=l;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../../../kernal/html/injector.cjs"),t=require("../../HtmlSettings.cjs"),n=require("../../../../kernal/html/realm.cjs"),r=require("./ViewportCssVariableNames.cjs"),i=require("./resolveLayoutRoute.cjs"),a=require("./HtmlLayoutMetrics.cjs"),o=require("../documents/HtmlContainerBuilder.cjs"),s=require("./applyLayoutClasses.cjs"),c=require("./resolveContentWrapperMinWidth.cjs");var l=class{constructor(n,r,i,a){this.owner=n,this.readerContainer=r,this.getColumnWidth=()=>this.htmlOptions.maxColumnWidth?Math.abs(this.htmlOptions.maxColumnWidth):768,this.options=this.owner.options,this.device=this.owner.device,this.optionsProvider=i,this.htmlOptions=a,this.containerBuilder=new o.HtmlContainerBuilder(a);let{rendererContainer:s,rendererCss:c,otherCss:l}=this.containerBuilder.createContainers();e.injectCssContent(this.readerContainer.ownerDocument,c+l,!0,`html-renderer-style`),this.readerContainer.appendChild(s),this.rendererContainer=s,this.scrollElement=this.rendererContainer,this.contentsShadowContainer=this.rendererContainer.querySelector(`.`+t.HtmlSettings.ContentsShadowContainerCssName),this.rendererContainer.setAttribute(t.HtmlSettings.HostViewportModeAttribute,this.owner.getHostViewport().mode)}getRendererContainer(){return this.rendererContainer}getScrollElement(){let e=this.owner.getHostViewport();return e.mode==`window`?e.scrollElement:this.rendererContainer}getLayoutMetrics(){return this.layout||=(this.internlApplyCssVariables(),this.buildLayoutMetrics()),this.layout}applyCssVariables(){this.internlApplyCssVariables(),this.layout=this.buildLayoutMetrics()}internlApplyCssVariables(){this.owner.refreshHostViewport();let e=i.getLayoutGeometry(this.htmlOptions),t=this.getScrollElement(),n=e.flipMode==`scroll`&&t?{left:t.scrollLeft,top:t.scrollTop}:void 0;this.applyFlowClasses(e),this.syncPageTransformSign(e);let a=this.prepareRendererCssVariables(),o=this.prepareOtherCssVariables(),s=new Map;a.forEach((e,t)=>{s.set(t,e)}),o.forEach((e,t)=>{s.set(t,e)});let c=this.owner.getRootContainer();c.style.setProperty(`direction`,`var(${r.ViewportCssVariableNames.ReaderViewportDirection})`),s.forEach((e,t)=>{c.style.setProperty(t,e)}),n&&t&&t.scrollTo(n.left,n.top)}syncPageTransformSign(e){let r=this.rendererContainer.querySelector(`.`+t.HtmlSettings.TransformContainerCssName);if(!n.isHtmlElement(r))return;if(e.flipMode!=`page`){r.style.removeProperty(`transition`),r.style.removeProperty(`transform`),r.removeAttribute(`data-target-transform`);return}if(r.hasAttribute(t.HtmlSettings.PageMovingAttributeName))return;let i=r.getAttribute(`data-target-transform`);if(i==null||i===``)return;let a=parseFloat(i);Number.isFinite(a)&&(r.style.removeProperty(`transition`),r.style.transform=e.getPageTranslateCss(a))}prepareRendererCssVariables(){let e=i.getLayoutGeometry(this.htmlOptions),n=e.flipMode;this.rendererContainer.setAttribute(t.HtmlSettings.HostViewportModeAttribute,this.owner.getHostViewport().mode);let a=new Map,o=e.viewport.zeroWrapperMargins?0:this.htmlOptions.contentWrapperMarginBottom??10,s=e.viewport.zeroWrapperMargins?0:this.htmlOptions.contentWrapperMarginTop??10,c=e.viewport.zeroWrapperMargins?0:this.htmlOptions.contentWrapperGap??10;a.set(r.ViewportCssVariableNames.ContentWrapperMarginTop,s+`px`),a.set(r.ViewportCssVariableNames.ContentWrapperMarginBottom,o+`px`),a.set(r.ViewportCssVariableNames.ContentWrapperGap,c+`px`);let l=this.htmlOptions.enableContentWrapperBorderRadius&&n==`scroll`?this.htmlOptions.contentWrapperBorderRadius??0:0;a.set(r.ViewportCssVariableNames.ContentWrapperBorderRadius,l+`px`);let u=this.owner.getHostViewport().mode==`window`&&n==`scroll`;return a.set(r.ViewportCssVariableNames.ScrollElementOverflow,u?`visible`:e.overflowY),a.set(r.ViewportCssVariableNames.ScrollElementOverflowX,u?`visible`:e.overflowX),a.set(r.ViewportCssVariableNames.ReaderViewportDirection,e.direction==`ltr`?`unset`:e.direction),a}applyFlowClasses(e){s.applyRootDirectionClass(this.owner.getRootContainer(),e),s.applyRendererLayoutClass(this.rendererContainer,e)}prepareOtherCssVariables(){let e=this.owner.getRootContainer(),t=i.getLayoutGeometry(this.htmlOptions),n=t.flipMode;n==`page`&&this.scrollElement?.scrollTo(0,0);let a=this.htmlOptions.columnGap??40,o=this.contentsShadowContainer,s=this.rendererContainer.clientWidth||this.owner.getHostViewport().width,l=this.getViewportHeight();this.rendererContainer.setAttribute(`data-client-width`,`${s}`),this.rendererContainer.setAttribute(`data-client-height`,`${l}`);let u=this.getContentsContainerWidth(),d=t.viewport.contentsContainerWidthMode==`max-content`?`max-content`:u+`px`,f=this.rendererContainer.offsetWidth-this.rendererContainer.clientWidth,p=this.rendererContainer.offsetHeight-this.rendererContainer.clientHeight,m=new Map;m.set(r.ViewportCssVariableNames.ScrollElementVerticalScrollBarWidth,f+`px`),m.set(r.ViewportCssVariableNames.ScrollElementHorizontalScrollBarHeight,p+`px`),m.set(r.ViewportCssVariableNames.ReaderViewportWidth,s+`px`),m.set(r.ViewportCssVariableNames.ReaderViewportHeight,l+`px`),e.style.setProperty(r.ViewportCssVariableNames.ContentsContainerWidth,d),m.set(r.ViewportCssVariableNames.ContentsContainerWidth,d);let h=0;n==`page`&&(h=0),s-u-2<2*h&&(h=0);let g=``;g=h>0?``+h+`px 0`:`0`,e.style.setProperty(r.ViewportCssVariableNames.ContentsContainerPadding,g),m.set(r.ViewportCssVariableNames.ContentsContainerPadding,g);let _=t.viewport.forceSingleColumn?1:this.calculateColumns(u);t.viewport.forceSingleColumn||(this.htmlOptions.columns=_);let{marginInline:v,marginBlock:y}=this.getContentsShadowMargin(u),{columnWidth:b}=this.getFinalColumnWidth(u-v*2,_,a),x=v,S=y;n==`scroll`&&(x=0,S=0),o.style=n==`scroll`?`margin: ${S}px ${x}px;`:`margin: ${S}px ${x}px;height: ${l-2*y}px;`;let C=o.getBoundingClientRect().width,w=_*b+Math.max(0,_-1)*a,{contentWrapperPaddingBottomNumber:T,contentWrapperPaddingTopNumber:E,contentWrapperPadding:D,contentWrapperPaddingTopBottom:O}=this.getContentWrapperPadding(u,a),k=l-E-T,A=t.getPageMoveLength(w,k,a);this.rendererContainer.setAttribute(`data-transform-length`,A.toString()),this.rendererContainer.setAttribute(`data-shadow-width`,C.toString()),this.rendererContainer.setAttribute(`data-column-width`,b.toString()),this.rendererContainer.setAttribute(`data-column-gap`,a.toString()),this.rendererContainer.setAttribute(`data-page-width`,`${w}`),this.rendererContainer.setAttribute(`data-page-height`,`${k}`),m.set(r.ViewportCssVariableNames.ContentWrapperWidth,t.viewport.contentWrapperWidthMode==`auto`?`auto`:C+`px`),m.set(r.ViewportCssVariableNames.ContentWrapperMinWidth,c.resolveContentWrapperMinWidth(t.viewport.contentWrapperMinWidthMode,{shadowWidth:C,columnWidth:b,columnGap:a,viewportWidth:s})),m.set(r.ViewportCssVariableNames.ContentWrapperHeight,this.getContentWrapperHeight()),m.set(r.ViewportCssVariableNames.ContentWrapperMinHeight,l+`px`),m.set(r.ViewportCssVariableNames.ContentWrapperMaxHeight,t.viewport.contentWrapperMaxHeightMode==`none`?`none`:l+`px`),m.set(r.ViewportCssVariableNames.ContentWrapperPadding,D),t.viewport.contentContainerWidthMode==`auto`?m.set(r.ViewportCssVariableNames.ContentContainerWidth,`auto`):t.viewport.contentContainerWidthMode==`column`?m.set(r.ViewportCssVariableNames.ContentContainerWidth,b+`px`):m.set(r.ViewportCssVariableNames.ContentContainerWidth,`100%`);let j=t.viewport.contentContainerHeightMode==`page`?k+`px`:`calc(var(${r.ViewportCssVariableNames.ContentWrapperHeight}) - ${O})`;return m.set(r.ViewportCssVariableNames.ContentContainerHeight,j),m.set(r.ViewportCssVariableNames.ContentColumnGap,a+`px`),m}buildLayoutMetrics(){let e=this.getFlipMode(),t=new a.HtmlLayoutMetrics,n=this.rendererContainer,{clientWidth:r}=n,i=parseFloat(n.getAttribute(`data-transform-length`));t.clientWidth=r||this.owner.getHostViewport().width;let o;return o=e==`scroll`?this.getViewportHeight():parseFloat(n.getAttribute(`data-page-height`)),t.clientHeight=this.getViewportHeight(),t.pageHeight=o,t.columnHeight=o,t.columnGap=parseFloat(n.getAttribute(`data-column-gap`)),t.columnWidth=parseFloat(n.getAttribute(`data-column-width`)),t.pageWidth=parseFloat(n.getAttribute(`data-page-width`)),t.pageMoveLength=i,t.shadowWidth=parseFloat(n.getAttribute(`data-shadow-width`)),t}getContentWrapperHeight(){let e=i.getLayoutGeometry(this.htmlOptions);return e.viewport.contentWrapperHeightMode==`auto`?`auto`:e.viewport.contentWrapperHeightMode==`viewport`?`${this.getViewportHeight()}px`:this.owner.inIframe?`100%`:`auto`}getContentsShadowMargin(e){let t=this.htmlOptions.contentsShadowMargin??20,n=this.getContentPaddingFactor(),r=this.device.getDeviceType()==`mobile`?Math.round(t*.6):t;return{marginBlock:r,marginInline:r+Math.min(10,e*n)}}getContentWrapperPadding(e,t){let n=this.getFlipMode(),r=n==`scroll`?30:0,{marginBlock:i,marginInline:a}=this.getContentsShadowMargin(e);n==`page`&&(r+=i);let o=r+`px`,s=n==`scroll`?30:0;n==`page`&&(s+=i);let c=s+`px`;return{contentWrapperPaddingTop:o,contentWrapperPaddingLeft:n==`scroll`?`${a}px`:`0`,contentWrapperPaddingRight:n==`scroll`?`${a}px`:`0`,contentWrapperPaddingBottom:c,contentWrapperPaddingLeftRight:n==`scroll`?`${t}px`:`0`,contentWrapperPaddingTopBottom:`${r+s}px`,contentWrapperPadding:n==`scroll`?`${r}px ${a}px ${s}px ${a}px`:`0px`,contentWrapperPaddingTopNumber:r,contentWrapperPaddingBottomNumber:s}}getContentsContainerWidth(){let e=this.rendererContainer.clientWidth||this.owner.getHostViewport().width;if(this.device.getDeviceType()==`mobile`&&e<=768)return e;if(this.getFlipMode()==`scroll`)return this.htmlOptions.enableAutoFitPageWidth?e:this.htmlOptions.maxScrollContentWidth?Math.min(e,Math.abs(this.htmlOptions.maxScrollContentWidth)):Math.min(e,this.htmlOptions.columnWidth);let t=this.htmlOptions.columns,n=this.getColumnWidth();if(this.htmlOptions.autoColumns){if(!this.htmlOptions.maxColumns)return e;t=e<=n?1:this.htmlOptions.maxColumns}let r=this.getMultiColumnWidthFactor();return t>1?Math.min(e,t*n*r):Math.min(e,n)}calculateColumns(e){let t=this.htmlOptions.columns??1,n=this.getColumnWidth();if(this.htmlOptions.autoColumns){if(e<=n)t=1;else{t=Math.floor(e/n);let r=e%n;(r>n/5||r>t*50)&&(t+=1),this.htmlOptions.maxColumns&&t>this.htmlOptions.maxColumns&&(t=this.htmlOptions.maxColumns)}}return t}getFinalColumnWidth(e,t,n){let r=n*(t-1),i=(e-r)/t,a=0,o=Math.round(i);return o!=i&&(i=o,a=e-(t*o+r)),{columnWidth:i,remainder:a}}getContentPaddingFactor(){return this.device.getDeviceType()==`mobile`?.01:.05}getMultiColumnWidthFactor(){let e=this.htmlOptions.multiColumnWidthFactor;return e||=.8,e=Math.abs(e),e<.5&&(e=.5),e>1&&(e=1),e}getViewportHeight(){let e=this.owner.getHostViewport();if(e.mode==`host`){let e=this.rendererContainer.clientHeight;if(e>=80&&e<33554400)return Math.round(e)}return e.height}getFlipMode(){return i.getLayoutGeometry(this.htmlOptions).flipMode}async dispose(){this.updateCssVariablesTimeoutId&&=(clearTimeout(this.updateCssVariablesTimeoutId),null)}};exports.HtmlRendererViewport=l;
@@ -1,6 +1,6 @@
1
1
  import { injectCssContent as e } from "../../../../kernal/html/injector.mjs";
2
- import { isHtmlElement as t } from "../../../../kernal/html/realm.mjs";
3
- import { HtmlSettings as n } from "../../HtmlSettings.mjs";
2
+ import { HtmlSettings as t } from "../../HtmlSettings.mjs";
3
+ import { isHtmlElement as n } from "../../../../kernal/html/realm.mjs";
4
4
  import { ViewportCssVariableNames as r } from "./ViewportCssVariableNames.mjs";
5
5
  import { getLayoutGeometry as i } from "./resolveLayoutRoute.mjs";
6
6
  import { HtmlLayoutMetrics as a } from "./HtmlLayoutMetrics.mjs";
@@ -9,10 +9,10 @@ import { applyRendererLayoutClass as s, applyRootDirectionClass as c } from "./a
9
9
  import { resolveContentWrapperMinWidth as l } from "./resolveContentWrapperMinWidth.mjs";
10
10
  //#region mediaTypes/html/renderer/layout/HtmlRendererViewport.ts
11
11
  var u = class {
12
- constructor(t, r, i, a) {
13
- this.owner = t, this.readerContainer = r, this.getColumnWidth = () => this.htmlOptions.maxColumnWidth ? Math.abs(this.htmlOptions.maxColumnWidth) : 768, this.options = this.owner.options, this.device = this.owner.device, this.optionsProvider = i, this.htmlOptions = a, this.containerBuilder = new o(a);
12
+ constructor(n, r, i, a) {
13
+ this.owner = n, this.readerContainer = r, this.getColumnWidth = () => this.htmlOptions.maxColumnWidth ? Math.abs(this.htmlOptions.maxColumnWidth) : 768, this.options = this.owner.options, this.device = this.owner.device, this.optionsProvider = i, this.htmlOptions = a, this.containerBuilder = new o(a);
14
14
  let { rendererContainer: s, rendererCss: c, otherCss: l } = this.containerBuilder.createContainers();
15
- e(this.readerContainer.ownerDocument, c + l, !0, "html-renderer-style"), this.readerContainer.appendChild(s), this.rendererContainer = s, this.scrollElement = this.rendererContainer, this.contentsShadowContainer = this.rendererContainer.querySelector("." + n.ContentsShadowContainerCssName), this.rendererContainer.setAttribute(n.HostViewportModeAttribute, this.owner.getHostViewport().mode);
15
+ e(this.readerContainer.ownerDocument, c + l, !0, "html-renderer-style"), this.readerContainer.appendChild(s), this.rendererContainer = s, this.scrollElement = this.rendererContainer, this.contentsShadowContainer = this.rendererContainer.querySelector("." + t.ContentsShadowContainerCssName), this.rendererContainer.setAttribute(t.HostViewportModeAttribute, this.owner.getHostViewport().mode);
16
16
  }
17
17
  getRendererContainer() {
18
18
  return this.rendererContainer;
@@ -46,26 +46,26 @@ var u = class {
46
46
  }), n && t && t.scrollTo(n.left, n.top);
47
47
  }
48
48
  syncPageTransformSign(e) {
49
- let r = this.rendererContainer.querySelector("." + n.TransformContainerCssName);
50
- if (!t(r)) return;
49
+ let r = this.rendererContainer.querySelector("." + t.TransformContainerCssName);
50
+ if (!n(r)) return;
51
51
  if (e.flipMode != "page") {
52
52
  r.style.removeProperty("transition"), r.style.removeProperty("transform"), r.removeAttribute("data-target-transform");
53
53
  return;
54
54
  }
55
- if (r.hasAttribute(n.PageMovingAttributeName)) return;
55
+ if (r.hasAttribute(t.PageMovingAttributeName)) return;
56
56
  let i = r.getAttribute("data-target-transform");
57
57
  if (i == null || i === "") return;
58
58
  let a = parseFloat(i);
59
59
  Number.isFinite(a) && (r.style.removeProperty("transition"), r.style.transform = e.getPageTranslateCss(a));
60
60
  }
61
61
  prepareRendererCssVariables() {
62
- let e = i(this.htmlOptions), t = e.flipMode;
63
- this.rendererContainer.setAttribute(n.HostViewportModeAttribute, this.owner.getHostViewport().mode);
62
+ let e = i(this.htmlOptions), n = e.flipMode;
63
+ this.rendererContainer.setAttribute(t.HostViewportModeAttribute, this.owner.getHostViewport().mode);
64
64
  let a = /* @__PURE__ */ new Map(), o = e.viewport.zeroWrapperMargins ? 0 : this.htmlOptions.contentWrapperMarginBottom ?? 10, s = e.viewport.zeroWrapperMargins ? 0 : this.htmlOptions.contentWrapperMarginTop ?? 10, c = e.viewport.zeroWrapperMargins ? 0 : this.htmlOptions.contentWrapperGap ?? 10;
65
65
  a.set(r.ContentWrapperMarginTop, s + "px"), a.set(r.ContentWrapperMarginBottom, o + "px"), a.set(r.ContentWrapperGap, c + "px");
66
- let l = this.htmlOptions.enableContentWrapperBorderRadius && t == "scroll" ? this.htmlOptions.contentWrapperBorderRadius ?? 0 : 0;
66
+ let l = this.htmlOptions.enableContentWrapperBorderRadius && n == "scroll" ? this.htmlOptions.contentWrapperBorderRadius ?? 0 : 0;
67
67
  a.set(r.ContentWrapperBorderRadius, l + "px");
68
- let u = this.owner.getHostViewport().mode == "window" && t == "scroll";
68
+ let u = this.owner.getHostViewport().mode == "window" && n == "scroll";
69
69
  return a.set(r.ScrollElementOverflow, u ? "visible" : e.overflowY), a.set(r.ScrollElementOverflowX, u ? "visible" : e.overflowX), a.set(r.ReaderViewportDirection, e.direction == "ltr" ? "unset" : e.direction), a;
70
70
  }
71
71
  applyFlowClasses(e) {
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../../../kernal/html/realm.cjs"),t=require("../../HtmlSettings.cjs");var n=500,r=`data-layout-route-quiet-until`,i=n=>{let r=n.querySelector(`.`+t.HtmlSettings.TransformContainerCssName);return e.isHtmlElement(r)?r:null},a=(e,t=500)=>{e.setAttribute(r,`${Date.now()+t}`)},o=e=>{let t=Number.parseInt(e.getAttribute(r)??``,10);return Number.isFinite(t)&&Date.now()<t},s=()=>typeof requestAnimationFrame==`function`?new Promise(e=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>e())})}):Promise.resolve(),c=e=>{let n=i(e);n&&(a(e),n.style.transition=`none`,n.style.removeProperty(`will-change`),n.removeAttribute(t.HtmlSettings.PageMovingAttributeName),n.setAttribute(t.HtmlSettings.LayoutSwitchingAttributeName,`true`),n.style.transform=`translate3d(0px,0,0)`,n.setAttribute(`data-target-transform`,`0`))},l=e=>{let n=i(e);n&&(n.removeAttribute(t.HtmlSettings.LayoutSwitchingAttributeName),n.style.removeProperty(`transition`),a(e))};exports.LAYOUT_ROUTE_RESIZE_QUIET_MS=n,exports.freezePageStripForRouteChange=c,exports.markLayoutRouteChangeQuiet=a,exports.shouldIgnoreResizeAfterRouteChange=o,exports.unfreezePageStripForRouteChange=l,exports.waitForPageStripPaint=s;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../HtmlSettings.cjs"),t=require("../../../../kernal/html/realm.cjs");var n=500,r=`data-layout-route-quiet-until`,i=n=>{let r=n.querySelector(`.`+e.HtmlSettings.TransformContainerCssName);return t.isHtmlElement(r)?r:null},a=(e,t=500)=>{e.setAttribute(r,`${Date.now()+t}`)},o=e=>{let t=Number.parseInt(e.getAttribute(r)??``,10);return Number.isFinite(t)&&Date.now()<t},s=()=>typeof requestAnimationFrame==`function`?new Promise(e=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>e())})}):Promise.resolve(),c=t=>{let n=i(t);n&&(a(t),n.style.transition=`none`,n.style.removeProperty(`will-change`),n.removeAttribute(e.HtmlSettings.PageMovingAttributeName),n.setAttribute(e.HtmlSettings.LayoutSwitchingAttributeName,`true`),n.style.transform=`translate3d(0px,0,0)`,n.setAttribute(`data-target-transform`,`0`))},l=t=>{let n=i(t);n&&(n.removeAttribute(e.HtmlSettings.LayoutSwitchingAttributeName),n.style.removeProperty(`transition`),a(t))};exports.LAYOUT_ROUTE_RESIZE_QUIET_MS=n,exports.freezePageStripForRouteChange=c,exports.markLayoutRouteChangeQuiet=a,exports.shouldIgnoreResizeAfterRouteChange=o,exports.unfreezePageStripForRouteChange=l,exports.waitForPageStripPaint=s;
@@ -1,9 +1,9 @@
1
- import { isHtmlElement as e } from "../../../../kernal/html/realm.mjs";
2
- import { HtmlSettings as t } from "../../HtmlSettings.mjs";
1
+ import { HtmlSettings as e } from "../../HtmlSettings.mjs";
2
+ import { isHtmlElement as t } from "../../../../kernal/html/realm.mjs";
3
3
  //#region mediaTypes/html/renderer/layout/pageStripRouteChange.ts
4
4
  var n = 500, r = "data-layout-route-quiet-until", i = (n) => {
5
- let r = n.querySelector("." + t.TransformContainerCssName);
6
- return e(r) ? r : null;
5
+ let r = n.querySelector("." + e.TransformContainerCssName);
6
+ return t(r) ? r : null;
7
7
  }, a = (e, t = 500) => {
8
8
  e.setAttribute(r, `${Date.now() + t}`);
9
9
  }, o = (e) => {
@@ -13,12 +13,12 @@ var n = 500, r = "data-layout-route-quiet-until", i = (n) => {
13
13
  requestAnimationFrame(() => {
14
14
  requestAnimationFrame(() => e());
15
15
  });
16
- }) : Promise.resolve(), c = (e) => {
17
- let n = i(e);
18
- n && (a(e), n.style.transition = "none", n.style.removeProperty("will-change"), n.removeAttribute(t.PageMovingAttributeName), n.setAttribute(t.LayoutSwitchingAttributeName, "true"), n.style.transform = "translate3d(0px,0,0)", n.setAttribute("data-target-transform", "0"));
19
- }, l = (e) => {
20
- let n = i(e);
21
- n && (n.removeAttribute(t.LayoutSwitchingAttributeName), n.style.removeProperty("transition"), a(e));
16
+ }) : Promise.resolve(), c = (t) => {
17
+ let n = i(t);
18
+ n && (a(t), n.style.transition = "none", n.style.removeProperty("will-change"), n.removeAttribute(e.PageMovingAttributeName), n.setAttribute(e.LayoutSwitchingAttributeName, "true"), n.style.transform = "translate3d(0px,0,0)", n.setAttribute("data-target-transform", "0"));
19
+ }, l = (t) => {
20
+ let n = i(t);
21
+ n && (n.removeAttribute(e.LayoutSwitchingAttributeName), n.style.removeProperty("transition"), a(t));
22
22
  };
23
23
  //#endregion
24
24
  export { n as LAYOUT_ROUTE_RESIZE_QUIET_MS, c as freezePageStripForRouteChange, a as markLayoutRouteChangeQuiet, o as shouldIgnoreResizeAfterRouteChange, l as unfreezePageStripForRouteChange, s as waitForPageStripPaint };
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../../../kernal/web/BrowserCapabilities.cjs"),t=require("../../../../kernal/html/finder.cjs"),n=require("../../../../kernal/html/realm.cjs"),r=require("../../../../kernal/html/translationAnchor.cjs"),i=require("../../../../kernal/html/style.cjs"),a=require("../../HtmlSettings.cjs"),o=require("../layout/geometry/restoreLayoutState.cjs"),s=require("../layout/resolveLayoutRoute.cjs"),c=require("./scrollActivity.cjs");var l=1,u=class{constructor(e,t,n){this.doc=e,this.viewport=t,this.options=n}capture(){let e=this.doc.owner.getRenderer(),t=this.viewport.getScrollElement()??e?.getScrollElement(),n=this.getTransformContainer(),r=this.doc.getWrapperContainer(),a=s.getLayoutGeometry(this.options),o=this.findLocationAnchor(),c=r?a.getCaptureExtent(r):{width:0,height:0};return{scrollLeft:t?.scrollLeft??0,scrollTop:t?.scrollTop??0,width:c.width,height:c.height,transformLeft:n?i.getTransformLength(n,`x`):0,transformTop:n?i.getTransformLength(n,`y`):0,firstVisibleDocument:a.documentOrderAnchor==`last`?e?.getLastVisibleDocument():e?.getFirstVisibleDocument(),offsetLeft:o?.offsetLeft??0,offsetTop:o?.offsetTop??0,foundElement:!!o}}concealPageStrip(){this.getTransformContainer()?.setAttribute(a.HtmlSettings.LayoutSwitchingAttributeName,`true`)}revealPageStrip(){this.getTransformContainer()?.removeAttribute(a.HtmlSettings.LayoutSwitchingAttributeName)}async restore(t){let n=this.doc.owner.getRenderer();if(!n||!t)return;let r=n.getDocuments(),i=r.indexOf(this.doc);if(i<0)return;let a=s.getLayoutGeometry(this.options),o=r.indexOf(t.firstVisibleDocument);if(!(o<0)){if(a.flipMode==`page`){if(i>o)return;e.BrowserCapabilities.isSafari()||await this.waitUntilPageTransformStable(),this.restorePageTransform(t,i===o);return}this.clearPageTransformIfNeeded(),this.restoreScroll(t,i,o)}}async waitUntilPageTransformStable(){if(s.getLayoutGeometry(this.options).flipMode!=`page`)return;let e=this.getTransformContainer();if(!e)return;let t=Date.now()+400;for(;this.hasActiveTransformTransition(e)&&!(Date.now()>=t);)await new Promise(t=>{let n=()=>{e.removeEventListener(`transitionend`,r),clearTimeout(i)},r=r=>{r.target===e&&(n(),t())};e.addEventListener(`transitionend`,r);let i=setTimeout(()=>{n(),t()},120)})}restorePageTransform(e,t){let n=this.getTransformContainer();if(!n)return;let r=s.getLayoutGeometry(this.options),i=r.readPageTransform(n),a=this.doc.getWrapperContainer(),o=r.measurePageSizeDelta(a,e),c=0,l=t?this.findLocationAnchor():null;l&&e.foundElement&&(c=r.measurePageOffsetDelta(l,e));let u=r.restorePageTransform({currentTransform:i,sizeDelta:o,offsetDelta:c,isFirstVisible:t,foundElement:!!(l&&e.foundElement)});n.style.removeProperty(`transition`),n.setAttribute(`data-target-transform`,`${u}`),n.style.transform=r.getPageTranslateCss(u)}restoreScroll(e,t,n){let r=this.doc.owner.getRenderer(),i=this.viewport.getScrollElement()??r?.getScrollElement();if(!i)return;let a=this.doc.getWrapperContainer(),u=s.getLayoutGeometry(this.options);if(u.shouldSkipSizeRestore({userScrollSettling:c.isUserScrollSettling(),holdingAbsoluteLocate:c.isHoldingAbsoluteAnchor()}))return;let d=u.readLogicalScroll(i),f=u.readCapturedLogicalScroll(i,e),p=u.blockAxis==`x`?i.scrollWidth:i.scrollHeight,m=u.blockAxis==`x`?i.clientWidth:i.clientHeight,h=u.measureBlockSizeDelta(a,e),g=0,_=t===n?this.findLocationAnchor():null,v=!!(_&&e.foundElement);v&&_&&(g=u.measureBlockOffsetDelta(_,e));let y=u.restoreScroll({liveScroll:d,capturedScroll:f,sizeDelta:h,offsetDelta:g,foundElement:v,currentIndex:t,anchorIndex:n,atReadingStart:o.isAtReadingStartScroll({liveScroll:d,scrollExtent:p,clientLength:m,initialScroll:u.initialScroll})});if(!(Math.abs(y-d)<=l)&&u.shouldApplyRestoredScroll(y,d)){c.beginProgrammaticScroll();try{u.writeLogicalScroll(i,y)}finally{c.endProgrammaticScroll()}}}findLocationAnchor(){let e=this.doc.owner.context.currentLocation,n=this.doc.getContentContainer();if(!n||!e?.precise||!e.tagName||e.tagIndex==null)return null;let i=t.getElementByNameAndIndex(n,e.tagName,e.tagIndex);return r.resolveVisibleTranslationAnchor(i)}clearPageTransformIfNeeded(){let e=this.getTransformContainer();e&&(e.style.removeProperty(`transition`),e.style.removeProperty(`transform`),e.removeAttribute(`data-target-transform`))}getTransformContainer(){try{let e=this.viewport.getRendererContainer()?.querySelector(`.`+a.HtmlSettings.TransformContainerCssName);return n.isHtmlElement(e)?e:null}catch{return null}}hasActiveTransformTransition(e){let t=e.getAnimations;if(typeof t!=`function`)return!1;for(let n of t.call(e,{subtree:!1}))if(n.playState===`running`||n.playState===`pending`)return!0;return!1}};exports.HtmlLayoutStatePreserver=u;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../../../kernal/web/BrowserCapabilities.cjs"),t=require("../../../../kernal/html/finder.cjs"),n=require("../../HtmlSettings.cjs"),r=require("../../../../kernal/html/realm.cjs"),i=require("../../../../kernal/html/translationAnchor.cjs"),a=require("../../../../kernal/html/style.cjs"),o=require("../layout/geometry/restoreLayoutState.cjs"),s=require("../layout/resolveLayoutRoute.cjs"),c=require("./scrollActivity.cjs");var l=1,u=class{constructor(e,t,n){this.doc=e,this.viewport=t,this.options=n}capture(){let e=this.doc.owner.getRenderer(),t=this.viewport.getScrollElement()??e?.getScrollElement(),n=this.getTransformContainer(),r=this.doc.getWrapperContainer(),i=s.getLayoutGeometry(this.options),o=this.findLocationAnchor(),c=r?i.getCaptureExtent(r):{width:0,height:0};return{scrollLeft:t?.scrollLeft??0,scrollTop:t?.scrollTop??0,width:c.width,height:c.height,transformLeft:n?a.getTransformLength(n,`x`):0,transformTop:n?a.getTransformLength(n,`y`):0,firstVisibleDocument:i.documentOrderAnchor==`last`?e?.getLastVisibleDocument():e?.getFirstVisibleDocument(),offsetLeft:o?.offsetLeft??0,offsetTop:o?.offsetTop??0,foundElement:!!o}}concealPageStrip(){this.getTransformContainer()?.setAttribute(n.HtmlSettings.LayoutSwitchingAttributeName,`true`)}revealPageStrip(){this.getTransformContainer()?.removeAttribute(n.HtmlSettings.LayoutSwitchingAttributeName)}async restore(t){let n=this.doc.owner.getRenderer();if(!n||!t)return;let r=n.getDocuments(),i=r.indexOf(this.doc);if(i<0)return;let a=s.getLayoutGeometry(this.options),o=r.indexOf(t.firstVisibleDocument);if(!(o<0)){if(a.flipMode==`page`){if(i>o)return;e.BrowserCapabilities.isSafari()||await this.waitUntilPageTransformStable(),this.restorePageTransform(t,i===o);return}this.clearPageTransformIfNeeded(),this.restoreScroll(t,i,o)}}async waitUntilPageTransformStable(){if(s.getLayoutGeometry(this.options).flipMode!=`page`)return;let e=this.getTransformContainer();if(!e)return;let t=Date.now()+400;for(;this.hasActiveTransformTransition(e)&&!(Date.now()>=t);)await new Promise(t=>{let n=()=>{e.removeEventListener(`transitionend`,r),clearTimeout(i)},r=r=>{r.target===e&&(n(),t())};e.addEventListener(`transitionend`,r);let i=setTimeout(()=>{n(),t()},120)})}restorePageTransform(e,t){let n=this.getTransformContainer();if(!n)return;let r=s.getLayoutGeometry(this.options),i=r.readPageTransform(n),a=this.doc.getWrapperContainer(),o=r.measurePageSizeDelta(a,e),c=0,l=t?this.findLocationAnchor():null;l&&e.foundElement&&(c=r.measurePageOffsetDelta(l,e));let u=r.restorePageTransform({currentTransform:i,sizeDelta:o,offsetDelta:c,isFirstVisible:t,foundElement:!!(l&&e.foundElement)});n.style.removeProperty(`transition`),n.setAttribute(`data-target-transform`,`${u}`),n.style.transform=r.getPageTranslateCss(u)}restoreScroll(e,t,n){let r=this.doc.owner.getRenderer(),i=this.viewport.getScrollElement()??r?.getScrollElement();if(!i)return;let a=this.doc.getWrapperContainer(),u=s.getLayoutGeometry(this.options);if(u.shouldSkipSizeRestore({userScrollSettling:c.isUserScrollSettling(),holdingAbsoluteLocate:c.isHoldingAbsoluteAnchor()}))return;let d=u.readLogicalScroll(i),f=u.readCapturedLogicalScroll(i,e),p=u.blockAxis==`x`?i.scrollWidth:i.scrollHeight,m=u.blockAxis==`x`?i.clientWidth:i.clientHeight,h=u.measureBlockSizeDelta(a,e),g=0,_=t===n?this.findLocationAnchor():null,v=!!(_&&e.foundElement);v&&_&&(g=u.measureBlockOffsetDelta(_,e));let y=u.restoreScroll({liveScroll:d,capturedScroll:f,sizeDelta:h,offsetDelta:g,foundElement:v,currentIndex:t,anchorIndex:n,atReadingStart:o.isAtReadingStartScroll({liveScroll:d,scrollExtent:p,clientLength:m,initialScroll:u.initialScroll})});if(!(Math.abs(y-d)<=l)&&u.shouldApplyRestoredScroll(y,d)){c.beginProgrammaticScroll();try{u.writeLogicalScroll(i,y)}finally{c.endProgrammaticScroll()}}}findLocationAnchor(){let e=this.doc.owner.context.currentLocation,n=this.doc.getContentContainer();if(!n||!e?.precise||!e.tagName||e.tagIndex==null)return null;let r=t.getElementByNameAndIndex(n,e.tagName,e.tagIndex);return i.resolveVisibleTranslationAnchor(r)}clearPageTransformIfNeeded(){let e=this.getTransformContainer();e&&(e.style.removeProperty(`transition`),e.style.removeProperty(`transform`),e.removeAttribute(`data-target-transform`))}getTransformContainer(){try{let e=this.viewport.getRendererContainer()?.querySelector(`.`+n.HtmlSettings.TransformContainerCssName);return r.isHtmlElement(e)?e:null}catch{return null}}hasActiveTransformTransition(e){let t=e.getAnimations;if(typeof t!=`function`)return!1;for(let n of t.call(e,{subtree:!1}))if(n.playState===`running`||n.playState===`pending`)return!0;return!1}};exports.HtmlLayoutStatePreserver=u;
@@ -1,9 +1,9 @@
1
1
  import { BrowserCapabilities as e } from "../../../../kernal/web/BrowserCapabilities.mjs";
2
2
  import { getElementByNameAndIndex as t } from "../../../../kernal/html/finder.mjs";
3
- import { isHtmlElement as n } from "../../../../kernal/html/realm.mjs";
4
- import { resolveVisibleTranslationAnchor as r } from "../../../../kernal/html/translationAnchor.mjs";
5
- import { getTransformLength as i } from "../../../../kernal/html/style.mjs";
6
- import { HtmlSettings as a } from "../../HtmlSettings.mjs";
3
+ import { HtmlSettings as n } from "../../HtmlSettings.mjs";
4
+ import { isHtmlElement as r } from "../../../../kernal/html/realm.mjs";
5
+ import { resolveVisibleTranslationAnchor as i } from "../../../../kernal/html/translationAnchor.mjs";
6
+ import { getTransformLength as a } from "../../../../kernal/html/style.mjs";
7
7
  import { isAtReadingStartScroll as o } from "../layout/geometry/restoreLayoutState.mjs";
8
8
  import { getLayoutGeometry as s } from "../layout/resolveLayoutRoute.mjs";
9
9
  import { beginProgrammaticScroll as c, endProgrammaticScroll as l, isHoldingAbsoluteAnchor as u, isUserScrollSettling as d } from "./scrollActivity.mjs";
@@ -13,7 +13,7 @@ var f = 1, p = class {
13
13
  this.doc = e, this.viewport = t, this.options = n;
14
14
  }
15
15
  capture() {
16
- let e = this.doc.owner.getRenderer(), t = this.viewport.getScrollElement() ?? e?.getScrollElement(), n = this.getTransformContainer(), r = this.doc.getWrapperContainer(), a = s(this.options), o = this.findLocationAnchor(), c = r ? a.getCaptureExtent(r) : {
16
+ let e = this.doc.owner.getRenderer(), t = this.viewport.getScrollElement() ?? e?.getScrollElement(), n = this.getTransformContainer(), r = this.doc.getWrapperContainer(), i = s(this.options), o = this.findLocationAnchor(), c = r ? i.getCaptureExtent(r) : {
17
17
  width: 0,
18
18
  height: 0
19
19
  };
@@ -22,19 +22,19 @@ var f = 1, p = class {
22
22
  scrollTop: t?.scrollTop ?? 0,
23
23
  width: c.width,
24
24
  height: c.height,
25
- transformLeft: n ? i(n, "x") : 0,
26
- transformTop: n ? i(n, "y") : 0,
27
- firstVisibleDocument: a.documentOrderAnchor == "last" ? e?.getLastVisibleDocument() : e?.getFirstVisibleDocument(),
25
+ transformLeft: n ? a(n, "x") : 0,
26
+ transformTop: n ? a(n, "y") : 0,
27
+ firstVisibleDocument: i.documentOrderAnchor == "last" ? e?.getLastVisibleDocument() : e?.getFirstVisibleDocument(),
28
28
  offsetLeft: o?.offsetLeft ?? 0,
29
29
  offsetTop: o?.offsetTop ?? 0,
30
30
  foundElement: !!o
31
31
  };
32
32
  }
33
33
  concealPageStrip() {
34
- this.getTransformContainer()?.setAttribute(a.LayoutSwitchingAttributeName, "true");
34
+ this.getTransformContainer()?.setAttribute(n.LayoutSwitchingAttributeName, "true");
35
35
  }
36
36
  revealPageStrip() {
37
- this.getTransformContainer()?.removeAttribute(a.LayoutSwitchingAttributeName);
37
+ this.getTransformContainer()?.removeAttribute(n.LayoutSwitchingAttributeName);
38
38
  }
39
39
  async restore(t) {
40
40
  let n = this.doc.owner.getRenderer();
@@ -119,8 +119,8 @@ var f = 1, p = class {
119
119
  findLocationAnchor() {
120
120
  let e = this.doc.owner.context.currentLocation, n = this.doc.getContentContainer();
121
121
  if (!n || !e?.precise || !e.tagName || e.tagIndex == null) return null;
122
- let i = t(n, e.tagName, e.tagIndex);
123
- return r(i);
122
+ let r = t(n, e.tagName, e.tagIndex);
123
+ return i(r);
124
124
  }
125
125
  clearPageTransformIfNeeded() {
126
126
  let e = this.getTransformContainer();
@@ -128,8 +128,8 @@ var f = 1, p = class {
128
128
  }
129
129
  getTransformContainer() {
130
130
  try {
131
- let e = this.viewport.getRendererContainer()?.querySelector("." + a.TransformContainerCssName);
132
- return n(e) ? e : null;
131
+ let e = this.viewport.getRendererContainer()?.querySelector("." + n.TransformContainerCssName);
132
+ return r(e) ? e : null;
133
133
  } catch {
134
134
  return null;
135
135
  }
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../../../kernal/Constants.cjs"),t=require("../../../../kernal/html/injector.cjs"),n=require("../../HtmlSettings.cjs"),r=require("./ContentCssVariables.cjs");var i=class{constructor(t){this.documentsProvider=t,this.defaultVariables=new Map,this.currentVariables=new Map,this.contentStyleId=`html-content-css-variables-style`,this.holderClassName=e.readerPrefixName+`t`,this.allElementSelectorPrefix=`html body *.${this.holderClassName}.${this.holderClassName}.${this.holderClassName}`,this.specialTextAlignCssId=e.readerPrefixName+`reader-special-variables-text-align-css`,this.defaultVariables.clear();for(let[e,t]of r.ContentCssVariables.getDefaultVariables())this.defaultVariables.set(e,t)}initialize(e){if(this.currentVariables.clear(),e)for(let[t,n]of e)this.currentVariables.set(t,n)}async getCss(){let{default:e}=await Promise.resolve().then(()=>require("./html-content.cjs"));return e.toString()}getDefaultVariables(){return this.defaultVariables}getCurrentVariables(){return this.currentVariables}getDefaultVariableValue(e){return this.defaultVariables.get(e)??``}getVariableValue(e){return this.currentVariables.get(e)??this.defaultVariables.get(e)??``}async injectStyles(e){let n=e.getContentContainer();if(n||=await e.getVirtualContentContainer(),!n?.ownerDocument)return;let r=n.ownerDocument,i=r.documentElement;for(let[e,t]of this.defaultVariables)this.currentVariables.has(e)||i.style.setProperty(e,t);for(let[e,t]of this.currentVariables)i.style.setProperty(e,this.normalizeVariableValue(e,t));this.syncUserSpecifiedFontClass(i);let a=await this.getCss();t.injectCssContent(r,a,!0,this.contentStyleId),this.syncTextAlignStyle(r)}syncTextAlignStyle(e){let n=this.getVariableValue(r.ContentCssVariables.TextAlign).trim();if(!n||n===`start`||n===`auto`){t.removeElement(e,this.specialTextAlignCssId);return}let i=`${this.allElementSelectorPrefix}{text-align:var(${r.ContentCssVariables.TextAlign}) !important;`;(n===`center`||n===`right`)&&(i+=`text-indent:0 !important;`),i+=`}`,t.injectCssContent(e,i,!0,this.specialTextAlignCssId)}syncUserSpecifiedFontClass(e){let t=this.normalizeVariableValue(r.ContentCssVariables.FontFamily,this.getVariableValue(r.ContentCssVariables.FontFamily));e.classList.toggle(n.HtmlSettings.UserSpecifiedFontClassName,r.ContentCssVariables.isUserSpecifiedFontFamily(t))}normalizeVariableValue(e,t){return e===r.ContentCssVariables.FontFamily&&t.trim()===`inherit`?r.ContentCssVariables.FallbackFontFamily:t}async changeStyles(e){for(let[t,n]of e)this.currentVariables.set(t,this.normalizeVariableValue(t,n));let t=this.documentsProvider.getLoadedDocuments(),n=t.filter(e=>e.getWrapperContainer()?.isVisible),r=t.filter(e=>!e.getWrapperContainer()?.isVisible);for(let t of n)this.applyVariablesToDocument(t,e);for(let t of r)this.applyVariablesToDocument(t,e);for(let e of t)e.resetLayoutSizes();let i=this.documentsProvider.restoreReadingPosition;i&&await i()}async changeStyle(e,t){await this.changeStyles(new Map([[e,t]]))}applyVariablesToDocument(e,t){let n=e.getContentContainer()?.ownerDocument?.documentElement;if(n){for(let[e,r]of t)n.style.setProperty(e,this.normalizeVariableValue(e,r));this.syncUserSpecifiedFontClass(n),this.syncTextAlignStyle(n.ownerDocument)}}async resetStyles(){this.currentVariables.clear();let e=this.documentsProvider.getLoadedDocuments();for(let t of e)await this.injectStyles(t)}async dispose(){this.defaultVariables.clear(),this.currentVariables.clear()}};exports.HtmlStyleProvider=i;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../../../kernal/Constants.cjs"),t=require("../../../../kernal/html/injector.cjs"),n=require("../../HtmlSettings.cjs"),r=require("./ContentCssVariables.cjs");var i=class{constructor(t){this.documentsProvider=t,this.currentVariables=new Map,this.contentStyleId=`html-content-css-variables-style`,this.holderClassName=e.readerPrefixName+`t`,this.allElementSelectorPrefix=`html body *.${this.holderClassName}.${this.holderClassName}.${this.holderClassName}`,this.specialTextAlignCssId=e.readerPrefixName+`reader-special-variables-text-align-css`}initialize(e){if(this.currentVariables.clear(),e)for(let[t,n]of e)this.currentVariables.set(t,n)}async getCss(){let{default:e}=await Promise.resolve().then(()=>require("./html-content.cjs"));return e.toString()}getDefaultVariables(){return r.ContentCssVariables.getDefaultVariables()}getCurrentVariables(){return this.currentVariables}getDefaultVariableValue(e){return this.getDefaultVariables().get(e)??``}getVariableValue(e){return this.currentVariables.get(e)??this.getDefaultVariableValue(e)}async injectStyles(e){let n=e.getContentContainer();if(n||=await e.getVirtualContentContainer(),!n?.ownerDocument)return;let r=n.ownerDocument,i=r.documentElement;for(let[e,t]of this.getDefaultVariables())this.currentVariables.has(e)||i.style.setProperty(e,t);for(let[e,t]of this.currentVariables)i.style.setProperty(e,this.normalizeVariableValue(e,t));this.syncUserSpecifiedFontClass(i);let a=await this.getCss();t.injectCssContent(r,a,!0,this.contentStyleId),this.syncTextAlignStyle(r)}syncTextAlignStyle(e){let n=this.getVariableValue(r.ContentCssVariables.TextAlign).trim();if(!n||n===`start`||n===`auto`){t.removeElement(e,this.specialTextAlignCssId);return}let i=`${this.allElementSelectorPrefix}{text-align:var(${r.ContentCssVariables.TextAlign}) !important;`;(n===`center`||n===`right`)&&(i+=`text-indent:0 !important;`),i+=`}`,t.injectCssContent(e,i,!0,this.specialTextAlignCssId)}syncUserSpecifiedFontClass(e){let t=this.normalizeVariableValue(r.ContentCssVariables.FontFamily,this.getVariableValue(r.ContentCssVariables.FontFamily));e.classList.toggle(n.HtmlSettings.UserSpecifiedFontClassName,r.ContentCssVariables.isUserSpecifiedFontFamily(t))}normalizeVariableValue(e,t){return e===r.ContentCssVariables.FontFamily&&t.trim()===`inherit`?r.ContentCssVariables.FallbackFontFamily:t}async changeStyles(e){for(let[t,n]of e)this.currentVariables.set(t,this.normalizeVariableValue(t,n));let t=this.documentsProvider.getLoadedDocuments(),n=t.filter(e=>e.getWrapperContainer()?.isVisible),r=t.filter(e=>!e.getWrapperContainer()?.isVisible);for(let t of n)this.applyVariablesToDocument(t,e);for(let t of r)this.applyVariablesToDocument(t,e);for(let e of t)e.resetLayoutSizes();let i=this.documentsProvider.restoreReadingPosition;i&&await i()}async changeStyle(e,t){await this.changeStyles(new Map([[e,t]]))}applyVariablesToDocument(e,t){let n=e.getContentContainer()?.ownerDocument?.documentElement;if(n){for(let[e,r]of t)n.style.setProperty(e,this.normalizeVariableValue(e,r));this.syncUserSpecifiedFontClass(n),this.syncTextAlignStyle(n.ownerDocument)}}async resetStyles(){this.currentVariables.clear();let e=this.documentsProvider.getLoadedDocuments();for(let t of e)await this.injectStyles(t)}async dispose(){this.currentVariables.clear()}};exports.HtmlStyleProvider=i;
@@ -3,7 +3,6 @@ import { IHtmlDocument } from '../IHtmlDocument';
3
3
 
4
4
  export declare class HtmlStyleProvider implements IStyleProvider {
5
5
  private readonly documentsProvider;
6
- readonly defaultVariables: Map<string, string>;
7
6
  readonly currentVariables: Map<string, string>;
8
7
  private readonly contentStyleId;
9
8
  private readonly holderClassName;
@@ -5,8 +5,7 @@ import { ContentCssVariables as i } from "./ContentCssVariables.mjs";
5
5
  //#region mediaTypes/html/renderer/style/HtmlStyleProvider.ts
6
6
  var a = class {
7
7
  constructor(t) {
8
- this.documentsProvider = t, this.defaultVariables = /* @__PURE__ */ new Map(), this.currentVariables = /* @__PURE__ */ new Map(), this.contentStyleId = "html-content-css-variables-style", this.holderClassName = e + "t", this.allElementSelectorPrefix = `html body *.${this.holderClassName}.${this.holderClassName}.${this.holderClassName}`, this.specialTextAlignCssId = e + "reader-special-variables-text-align-css", this.defaultVariables.clear();
9
- for (let [e, t] of i.getDefaultVariables()) this.defaultVariables.set(e, t);
8
+ this.documentsProvider = t, this.currentVariables = /* @__PURE__ */ new Map(), this.contentStyleId = "html-content-css-variables-style", this.holderClassName = e + "t", this.allElementSelectorPrefix = `html body *.${this.holderClassName}.${this.holderClassName}.${this.holderClassName}`, this.specialTextAlignCssId = e + "reader-special-variables-text-align-css";
10
9
  }
11
10
  initialize(e) {
12
11
  if (this.currentVariables.clear(), e) for (let [t, n] of e) this.currentVariables.set(t, n);
@@ -16,22 +15,22 @@ var a = class {
16
15
  return e.toString();
17
16
  }
18
17
  getDefaultVariables() {
19
- return this.defaultVariables;
18
+ return i.getDefaultVariables();
20
19
  }
21
20
  getCurrentVariables() {
22
21
  return this.currentVariables;
23
22
  }
24
23
  getDefaultVariableValue(e) {
25
- return this.defaultVariables.get(e) ?? "";
24
+ return this.getDefaultVariables().get(e) ?? "";
26
25
  }
27
26
  getVariableValue(e) {
28
- return this.currentVariables.get(e) ?? this.defaultVariables.get(e) ?? "";
27
+ return this.currentVariables.get(e) ?? this.getDefaultVariableValue(e);
29
28
  }
30
29
  async injectStyles(e) {
31
30
  let n = e.getContentContainer();
32
31
  if (n ||= await e.getVirtualContentContainer(), !n?.ownerDocument) return;
33
32
  let r = n.ownerDocument, i = r.documentElement;
34
- for (let [e, t] of this.defaultVariables) this.currentVariables.has(e) || i.style.setProperty(e, t);
33
+ for (let [e, t] of this.getDefaultVariables()) this.currentVariables.has(e) || i.style.setProperty(e, t);
35
34
  for (let [e, t] of this.currentVariables) i.style.setProperty(e, this.normalizeVariableValue(e, t));
36
35
  this.syncUserSpecifiedFontClass(i);
37
36
  let a = await this.getCss();
@@ -78,7 +77,7 @@ var a = class {
78
77
  for (let t of e) await this.injectStyles(t);
79
78
  }
80
79
  async dispose() {
81
- this.defaultVariables.clear(), this.currentVariables.clear();
80
+ this.currentVariables.clear();
82
81
  }
83
82
  };
84
83
  //#endregion
@@ -13,6 +13,10 @@ html,\r
13
13
  html body * {\r
14
14
  font-weight: var(--font-weight) !important;\r
15
15
  }\r
16
+ html[class*="content-page-horizontal-"] body {\r
17
+ /* Keep 1px so drag handles stay visible on mobile when selecting text close to the edge */\r
18
+ padding-inline: 1px !important;\r
19
+ }\r
16
20
  \r
17
21
  html.foxycape-user-font,\r
18
22
  html.foxycape-user-font body * {\r
@@ -1,4 +1,4 @@
1
1
  //#region mediaTypes/html/renderer/style/html-content.css?raw
2
- var e = "html {\r\n margin: 0 !important;\r\n padding: 0 !important;\r\n -webkit-tap-highlight-color: transparent !important;\r\n width: 100% !important;\r\n height: auto !important;\r\n font-size: var(--font-size) !important;\r\n color: var(--content-text-color);\r\n --fallback-font-family: -apple-system, \"Segoe UI\", Roboto, \"Helvetica Neue\", \"Noto Sans\", \"Liberation Sans\", Arial, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\", \"Noto Color Emoji\";\r\n}\r\n\r\nhtml,\r\nhtml body * {\r\n font-weight: var(--font-weight) !important;\r\n}\r\n\r\nhtml.foxycape-user-font,\r\nhtml.foxycape-user-font body * {\r\n font-family: var(--font-family), var(--fallback-font-family) !important;\r\n}\r\n\r\nbody {\r\n margin: 0 !important;\r\n padding: 0 !important;\r\n height: auto !important;\r\n font-size: 1rem;\r\n line-height: var(--text-line-height);\r\n}\r\n\r\ndiv,\r\nspan,\r\napplet,\r\nobject,\r\niframe,\r\nh1,\r\nh2,\r\nh3,\r\nh4,\r\nh5,\r\nh6,\r\np,\r\nblockquote,\r\npre,\r\na,\r\nabbr,\r\nacronym,\r\naddress,\r\nbig,\r\ncite,\r\ncode,\r\ndel,\r\ndfn,\r\nem,\r\nimg,\r\nins,\r\nkbd,\r\nq,\r\ns,\r\nsamp,\r\nsmall,\r\nstrike,\r\nstrong,\r\nsub,\r\nsup,\r\ntt,\r\nvar,\r\nb,\r\nu,\r\ni,\r\ncenter,\r\ndl,\r\ndt,\r\ndd,\r\nol,\r\nul,\r\nli,\r\nfieldset,\r\nform,\r\nlabel,\r\nlegend,\r\ntable,\r\ncaption,\r\ntbody,\r\ntfoot,\r\nthead,\r\ntr,\r\nth,\r\ntd,\r\narticle,\r\naside,\r\ncanvas,\r\ndetails,\r\nembed,\r\nfigure,\r\nfigcaption,\r\nfooter,\r\nheader,\r\nhgroup,\r\nmenu,\r\nnav,\r\noutput,\r\nruby,\r\nsection,\r\nsummary,\r\ntime,\r\nmark,\r\naudio,\r\nvideo {\r\n margin: 0;\r\n padding: 0;\r\n border: 0;\r\n box-sizing: border-box;\r\n /* all elements max width is 100% */\r\n max-width: 100%;\r\n}\r\n\r\narticle,\r\naside,\r\ndetails,\r\nfigcaption,\r\nfigure,\r\nfooter,\r\nheader,\r\nhgroup,\r\nmenu,\r\nnav,\r\nsection {\r\n display: block;\r\n /* all elements max width is 100% */\r\n max-width: 100%;\r\n}\r\n\r\n/* Physical column box, not CSS column-width (vertical page remaps that to page height). */\r\n.columns-layout>body * {\r\n max-width: var(--column-box-width, var(--column-width, 100%));\r\n}\r\n\r\n/* remove body margin, for some old mobile columns layout is not correct */\r\n.columns-layout>body {\r\n max-height: none !important;\r\n max-width: none !important;\r\n margin: 0px !important;\r\n position: static !important;\r\n}\r\n\r\n.columns-layout :lang(zh),\r\n.columns-layout :lang(ja),\r\n.columns-layout :lang(ko) {\r\n widows: 1;\r\n orphans: 1;\r\n}\r\n\r\nh1 {\r\n font-size: 1.8rem;\r\n}\r\n\r\nh2 {\r\n font-size: 1.6rem;\r\n}\r\n\r\nh3 {\r\n font-size: 1.2rem;\r\n}\r\n\r\nh4,\r\nh5,\r\nh6 {\r\n font-size: 1rem;\r\n}\r\n\r\nh1,\r\nh2,\r\nh3,\r\nh4,\r\nh5,\r\nh6 {\r\n word-break: normal;\r\n word-wrap: break-word;\r\n margin-block-start: var(--head-margin-top) !important;\r\n margin-block-end: var(--head-margin-bottom) !important;\r\n line-height: var(--head-line-height, 1.5em);\r\n text-align: start;\r\n text-indent: 0;\r\n}\r\n\r\n/* Page columns only. Book `margin-top/-left: -N` maps to inline-start in\r\n vertical/horizontal writing and leaks the box into the previous page. */\r\nhtml[class*=\"content-page-\"] :is(\r\n h1, h2, h3, h4, h5, h6,\r\n div, p, section, article, header, footer, aside, nav, main,\r\n table, figure, blockquote,\r\n ul, ol\r\n) {\r\n margin-inline-start: 0 !important;\r\n}\r\n\r\na {\r\n text-decoration: none;\r\n}\r\n\r\nmt {\r\n display: block;\r\n border-radius: 8px;\r\n font-family: 'Roboto', 'Helvetica Neue', 'Helvetica', 'Arial', 'Microsoft YaHei', 'PingFang SC', 'sans-serif';\r\n}\r\n\r\nst mt,\r\ndiv mt,\r\np mt,\r\np+mt,\r\ndiv+mt {\r\n word-wrap: break-word;\r\n margin-block-start: var(--paragraph-margin-top) !important;\r\n margin-block-end: var(--paragraph-margin-bottom) !important;\r\n line-height: var(--text-line-height) !important;\r\n text-justify: inter-ideograph;\r\n}\r\n\r\ndiv,\r\np {\r\n word-wrap: break-word;\r\n margin-block-start: var(--paragraph-margin-top) !important;\r\n margin-block-end: var(--paragraph-margin-bottom) !important;\r\n line-height: var(--text-line-height) !important;\r\n text-align: justify;\r\n text-indent: var(--text-indent);\r\n text-justify: inter-ideograph;\r\n}\r\n\r\ndiv>span,\r\np>span {\r\n line-height: normal;\r\n}\r\n\r\ntd * {\r\n text-indent: 0 !important;\r\n}\r\n\r\npre,\r\ncode {\r\n text-align: start;\r\n}\r\n\r\nul {\r\n margin-block-start: var(--head-margin-top) !important;\r\n margin-block-end: var(--head-margin-bottom) !important;\r\n line-height: var(--head-line-height, 1.5em);\r\n}\r\n\r\nli {\r\n margin-block-start: var(--paragraph-margin-top) !important;\r\n margin-block-end: var(--paragraph-margin-bottom) !important;\r\n line-height: var(--text-line-height) !important;\r\n}\r\n\r\nli>p {\r\n text-indent: 0;\r\n}\r\n\r\nfont {\r\n font-size: var(--font-size) !important;\r\n}\r\n\r\nhtml body p[text-align='end'] {\r\n text-indent: 0 !important;\r\n}\r\n\r\nli,\r\nol,\r\nul {\r\n text-indent: 0;\r\n}\r\n\r\nimg,\r\nsvg,\r\nvideo,\r\ncanvas {\r\n max-width: var(--column-box-width, var(--page-width, 100%));\r\n max-height: var(--column-box-height, var(--page-height, none));\r\n object-fit: contain;\r\n}\r\n\r\nimg[data-preset-preview-url=\"true\"]:not([data-load-state=\"loaded\"]) {\r\n background-color: var(--content-background);\r\n background-color: var(--image-placeholder-color);\r\n}\r\n\r\npre {\r\n overflow: auto;\r\n text-indent: 0;\r\n white-space: pre;\r\n padding-left: 1em;\r\n padding-right: 1em;\r\n padding-top: 0.5em;\r\n padding-bottom: 0.5em;\r\n}\r\n\r\n.no-text-intent {\r\n text-indent: 0 !important;\r\n}\r\n\r\n/** center image */\r\n.lhx-text-empty:has(> img:only-child),\r\n.lhx-text-empty:has(> img:only-of-type, > img:only-of-type + a),\r\n:not(.lhx-text-empty):has(> img:first-child) {\r\n text-align: center;\r\n}\r\n\r\n/** only one image and image has a tag after it */\r\n.lhx-text-empty:has(> img:only-of-type + a) {\r\n text-align: center;\r\n text-indent: 0 !important;\r\n}\r\n\r\n/** only one child div, p or img, then no text indent */\r\n.lhx-text-empty:has(> div:only-child, > p:only-child, > canvas:only-child, > object:only-child, > svg:only-child, > audio:only-child, > video:only-child, > iframe:only-child, > img:only-child),\r\n:not(.lhx-text-empty):has(> div:first-child, > p:first-child, > canvas:first-child, > object:first-child, > svg:first-child, > audio:first-child, > video:first-child, > iframe:first-child, > img:first-child),\r\nimg:only-child,\r\ncanvas:only-child,\r\nsvg:only-child,\r\nvideo:only-child,\r\naudio:only-child,\r\niframe:only-child,\r\nembed:only-child,\r\n*:has(> br) {\r\n text-indent: 0 !important;\r\n}\r\n\r\n/** enumerate known formats */\r\n.poem,\r\n.SubHed,\r\n.bodycontent-text_center,\r\n.center,\r\n.center-content {\r\n text-indent: 0 !important;\r\n}\r\n\r\n.lazy-load-image {\r\n /* initial transparent */\r\n opacity: 0;\r\n /* add transition effect */\r\n transition: opacity 0.3s;\r\n}\r\n\r\n.lazy-load-image.loaded {\r\n opacity: 1;\r\n}";
2
+ var e = "html {\r\n margin: 0 !important;\r\n padding: 0 !important;\r\n -webkit-tap-highlight-color: transparent !important;\r\n width: 100% !important;\r\n height: auto !important;\r\n font-size: var(--font-size) !important;\r\n color: var(--content-text-color);\r\n --fallback-font-family: -apple-system, \"Segoe UI\", Roboto, \"Helvetica Neue\", \"Noto Sans\", \"Liberation Sans\", Arial, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\", \"Noto Color Emoji\";\r\n}\r\n\r\nhtml,\r\nhtml body * {\r\n font-weight: var(--font-weight) !important;\r\n}\r\nhtml[class*=\"content-page-horizontal-\"] body {\r\n /* Keep 1px so drag handles stay visible on mobile when selecting text close to the edge */\r\n padding-inline: 1px !important;\r\n}\r\n\r\nhtml.foxycape-user-font,\r\nhtml.foxycape-user-font body * {\r\n font-family: var(--font-family), var(--fallback-font-family) !important;\r\n}\r\n\r\nbody {\r\n margin: 0 !important;\r\n padding: 0 !important;\r\n height: auto !important;\r\n font-size: 1rem;\r\n line-height: var(--text-line-height);\r\n}\r\n\r\ndiv,\r\nspan,\r\napplet,\r\nobject,\r\niframe,\r\nh1,\r\nh2,\r\nh3,\r\nh4,\r\nh5,\r\nh6,\r\np,\r\nblockquote,\r\npre,\r\na,\r\nabbr,\r\nacronym,\r\naddress,\r\nbig,\r\ncite,\r\ncode,\r\ndel,\r\ndfn,\r\nem,\r\nimg,\r\nins,\r\nkbd,\r\nq,\r\ns,\r\nsamp,\r\nsmall,\r\nstrike,\r\nstrong,\r\nsub,\r\nsup,\r\ntt,\r\nvar,\r\nb,\r\nu,\r\ni,\r\ncenter,\r\ndl,\r\ndt,\r\ndd,\r\nol,\r\nul,\r\nli,\r\nfieldset,\r\nform,\r\nlabel,\r\nlegend,\r\ntable,\r\ncaption,\r\ntbody,\r\ntfoot,\r\nthead,\r\ntr,\r\nth,\r\ntd,\r\narticle,\r\naside,\r\ncanvas,\r\ndetails,\r\nembed,\r\nfigure,\r\nfigcaption,\r\nfooter,\r\nheader,\r\nhgroup,\r\nmenu,\r\nnav,\r\noutput,\r\nruby,\r\nsection,\r\nsummary,\r\ntime,\r\nmark,\r\naudio,\r\nvideo {\r\n margin: 0;\r\n padding: 0;\r\n border: 0;\r\n box-sizing: border-box;\r\n /* all elements max width is 100% */\r\n max-width: 100%;\r\n}\r\n\r\narticle,\r\naside,\r\ndetails,\r\nfigcaption,\r\nfigure,\r\nfooter,\r\nheader,\r\nhgroup,\r\nmenu,\r\nnav,\r\nsection {\r\n display: block;\r\n /* all elements max width is 100% */\r\n max-width: 100%;\r\n}\r\n\r\n/* Physical column box, not CSS column-width (vertical page remaps that to page height). */\r\n.columns-layout>body * {\r\n max-width: var(--column-box-width, var(--column-width, 100%));\r\n}\r\n\r\n/* remove body margin, for some old mobile columns layout is not correct */\r\n.columns-layout>body {\r\n max-height: none !important;\r\n max-width: none !important;\r\n margin: 0px !important;\r\n position: static !important;\r\n}\r\n\r\n.columns-layout :lang(zh),\r\n.columns-layout :lang(ja),\r\n.columns-layout :lang(ko) {\r\n widows: 1;\r\n orphans: 1;\r\n}\r\n\r\nh1 {\r\n font-size: 1.8rem;\r\n}\r\n\r\nh2 {\r\n font-size: 1.6rem;\r\n}\r\n\r\nh3 {\r\n font-size: 1.2rem;\r\n}\r\n\r\nh4,\r\nh5,\r\nh6 {\r\n font-size: 1rem;\r\n}\r\n\r\nh1,\r\nh2,\r\nh3,\r\nh4,\r\nh5,\r\nh6 {\r\n word-break: normal;\r\n word-wrap: break-word;\r\n margin-block-start: var(--head-margin-top) !important;\r\n margin-block-end: var(--head-margin-bottom) !important;\r\n line-height: var(--head-line-height, 1.5em);\r\n text-align: start;\r\n text-indent: 0;\r\n}\r\n\r\n/* Page columns only. Book `margin-top/-left: -N` maps to inline-start in\r\n vertical/horizontal writing and leaks the box into the previous page. */\r\nhtml[class*=\"content-page-\"] :is(\r\n h1, h2, h3, h4, h5, h6,\r\n div, p, section, article, header, footer, aside, nav, main,\r\n table, figure, blockquote,\r\n ul, ol\r\n) {\r\n margin-inline-start: 0 !important;\r\n}\r\n\r\na {\r\n text-decoration: none;\r\n}\r\n\r\nmt {\r\n display: block;\r\n border-radius: 8px;\r\n font-family: 'Roboto', 'Helvetica Neue', 'Helvetica', 'Arial', 'Microsoft YaHei', 'PingFang SC', 'sans-serif';\r\n}\r\n\r\nst mt,\r\ndiv mt,\r\np mt,\r\np+mt,\r\ndiv+mt {\r\n word-wrap: break-word;\r\n margin-block-start: var(--paragraph-margin-top) !important;\r\n margin-block-end: var(--paragraph-margin-bottom) !important;\r\n line-height: var(--text-line-height) !important;\r\n text-justify: inter-ideograph;\r\n}\r\n\r\ndiv,\r\np {\r\n word-wrap: break-word;\r\n margin-block-start: var(--paragraph-margin-top) !important;\r\n margin-block-end: var(--paragraph-margin-bottom) !important;\r\n line-height: var(--text-line-height) !important;\r\n text-align: justify;\r\n text-indent: var(--text-indent);\r\n text-justify: inter-ideograph;\r\n}\r\n\r\ndiv>span,\r\np>span {\r\n line-height: normal;\r\n}\r\n\r\ntd * {\r\n text-indent: 0 !important;\r\n}\r\n\r\npre,\r\ncode {\r\n text-align: start;\r\n}\r\n\r\nul {\r\n margin-block-start: var(--head-margin-top) !important;\r\n margin-block-end: var(--head-margin-bottom) !important;\r\n line-height: var(--head-line-height, 1.5em);\r\n}\r\n\r\nli {\r\n margin-block-start: var(--paragraph-margin-top) !important;\r\n margin-block-end: var(--paragraph-margin-bottom) !important;\r\n line-height: var(--text-line-height) !important;\r\n}\r\n\r\nli>p {\r\n text-indent: 0;\r\n}\r\n\r\nfont {\r\n font-size: var(--font-size) !important;\r\n}\r\n\r\nhtml body p[text-align='end'] {\r\n text-indent: 0 !important;\r\n}\r\n\r\nli,\r\nol,\r\nul {\r\n text-indent: 0;\r\n}\r\n\r\nimg,\r\nsvg,\r\nvideo,\r\ncanvas {\r\n max-width: var(--column-box-width, var(--page-width, 100%));\r\n max-height: var(--column-box-height, var(--page-height, none));\r\n object-fit: contain;\r\n}\r\n\r\nimg[data-preset-preview-url=\"true\"]:not([data-load-state=\"loaded\"]) {\r\n background-color: var(--content-background);\r\n background-color: var(--image-placeholder-color);\r\n}\r\n\r\npre {\r\n overflow: auto;\r\n text-indent: 0;\r\n white-space: pre;\r\n padding-left: 1em;\r\n padding-right: 1em;\r\n padding-top: 0.5em;\r\n padding-bottom: 0.5em;\r\n}\r\n\r\n.no-text-intent {\r\n text-indent: 0 !important;\r\n}\r\n\r\n/** center image */\r\n.lhx-text-empty:has(> img:only-child),\r\n.lhx-text-empty:has(> img:only-of-type, > img:only-of-type + a),\r\n:not(.lhx-text-empty):has(> img:first-child) {\r\n text-align: center;\r\n}\r\n\r\n/** only one image and image has a tag after it */\r\n.lhx-text-empty:has(> img:only-of-type + a) {\r\n text-align: center;\r\n text-indent: 0 !important;\r\n}\r\n\r\n/** only one child div, p or img, then no text indent */\r\n.lhx-text-empty:has(> div:only-child, > p:only-child, > canvas:only-child, > object:only-child, > svg:only-child, > audio:only-child, > video:only-child, > iframe:only-child, > img:only-child),\r\n:not(.lhx-text-empty):has(> div:first-child, > p:first-child, > canvas:first-child, > object:first-child, > svg:first-child, > audio:first-child, > video:first-child, > iframe:first-child, > img:first-child),\r\nimg:only-child,\r\ncanvas:only-child,\r\nsvg:only-child,\r\nvideo:only-child,\r\naudio:only-child,\r\niframe:only-child,\r\nembed:only-child,\r\n*:has(> br) {\r\n text-indent: 0 !important;\r\n}\r\n\r\n/** enumerate known formats */\r\n.poem,\r\n.SubHed,\r\n.bodycontent-text_center,\r\n.center,\r\n.center-content {\r\n text-indent: 0 !important;\r\n}\r\n\r\n.lazy-load-image {\r\n /* initial transparent */\r\n opacity: 0;\r\n /* add transition effect */\r\n transition: opacity 0.3s;\r\n}\r\n\r\n.lazy-load-image.loaded {\r\n opacity: 1;\r\n}";
3
3
  //#endregion
4
4
  export { e as default };
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../../kernal/common/text.cjs"),t=require("../../../kernal/IFileParser.cjs"),n=require("../../../kernal/nav/Nav.cjs"),r=require("../../../kernal/io/IByteSource.cjs"),i=require("../../../kernal/io/BlobByteSource.cjs"),a=require("../../../kernal/io/MemoryByteSource.cjs"),o=require("../../base/fileParser/BaseFileParser.cjs"),s=require("../loadPdfDocument.cjs"),c=require("../ensurePdfWebWorker.cjs"),l=require("./PdfTextDocument.cjs"),u=require("./PdfPasswordProvider.cjs");var d=class extends o.BaseFileParser{constructor(e,t,n,r,i,a,o,s,c,l){super(e,t,n,r,s,c),this.events=i,this.locale=a,this.context=o,this.url=s,this.extension=c,this.options=l,this.ownedSources=[],this.pdfDocs=new Map,this.passwordProvider=new u.PdfPasswordProvider(i,a,o),this.bindDefaultPasswordFlow()}bindDefaultPasswordFlow(){this.options.standardPasswordProvider||(this.options.standardPasswordProvider=this.passwordProvider.getPassword)}async buildLocation(t,r){let i=typeof t==`string`?new n.NavPoint(``,t):t,a=await super.buildLocation(t,r);return(i.startPageNumber??0)>0&&(a.current=i.startPageNumber,a.unit=`page`),e.isNullOrWhiteSpace(i.pdfDest)||(a.pdfDest=i.pdfDest),a}async getCover(e,t){return null}async getTextDocuments(){if(this.textDocuments)return this.textDocuments;this.textDocuments=[];let e=await this.getSpineFiles();for(let t=0;t<e.length;t++){let n=e[t],r=new l.PdfTextDocument(this,n);this.textDocuments.push(r)}return this.textDocuments}async captureInitialSource(e){if(e.data&&e.data.byteLength>0){let t=e.byteSource;e.byteSource=void 0,await t?.close();return}if(e.byteSource){if(e.byteSource instanceof a.MemoryByteSource){e.data=await r.materialize(e.byteSource);let t=e.byteSource;e.byteSource=void 0,await t.close();return}this.sharedSource=e.byteSource,this.ownedSources.push(e.byteSource),e.byteSource=void 0}}trackSource(e){return this.ownedSources.push(e),e}async resolveSpineInput(e){if(e.data instanceof ArrayBuffer&&e.data.byteLength>0)return new Uint8Array(e.data);if(e.data instanceof Blob&&e.data.size>0)return this.trackSource(new i.BlobByteSource(e.data));if(this.sharedSource)return this.sharedSource;if(!e.url)return new Uint8Array;let t=await this.fileUrlParser.parse(e.url,{requireFullFile:!1});if(t.data&&t.data.byteLength>0){let e=t.byteSource;return t.byteSource=void 0,await e?.close(),new Uint8Array(t.data)}if(t.byteSource instanceof a.MemoryByteSource){let e=new Uint8Array(await r.materialize(t.byteSource));return await t.byteSource.close(),e}return t.byteSource?this.trackSource(t.byteSource):new Uint8Array}async getPdfDocument(e){let t=this.pdfDocs.get(e.url);return t&&!t.loadingTask.destroyed?t:(t=await this.internalGetPdfDocumentProxy(e),this.pdfDocs.set(e.url,t),t)}async internalGetPdfDocumentProxy(e){let t;this.options.standardPasswordProvider&&(t=await this.options.standardPasswordProvider(this,e));let n=await this.resolveSpineInput(e);return await s.loadPdfDocument(n,{password:t,cMapUrl:this.options.cMapUrl,standardFontDataUrl:this.options.standardFontDataUrl,wasmUrl:this.options.wasmUrl,iccUrl:this.options.iccUrl,showPasswordPrompt:this.options.showPasswordPrompt,passwordPrompt:this.passwordProvider.onPasswordPrompt,internalUrlBuilder:this.options.internalUrlBuilder,documentInitParametersCallback:this.options.documentInitParametersCallback})}async load(e){let t=await this.parseUrl(this.url,{requireFullFile:!1});await this.initializeDatas(t),e?.measureFilePercentage&&await this.measureFilePercentage(t.spineFiles??[],t.requireCalculateFileSymbolCount)}async parseUrl(e,n){let r=await super.parseUrl(e,n);if(r.spineFiles||=[],!r.isMultiFiles){await this.captureInitialSource(r);let e=new t.SpineFile(r.data,r.mainUrl,this.extension),n=await this.internalGetPdfDocumentProxy(e);r.data=void 0,e.data=void 0;for(let e=0;e<n.numPages;e++){let i=`${e+1}.pdf`,a=new t.SpineFile(null,i,this.extension);r.spineFiles.push(a),this.pdfDocs.set(i,n)}r.nav=await this.initNav(n)}return r}async measureFilePercentage(e,t){if(!e)return;if(!e.find(e=>e.symbolCount==null)){e[0]?.ratio!=null&&this.applyProgressRanges(e);return}let n=0;e.forEach(e=>{(e.symbolCount==null||e.symbolCount<=0)&&(e.symbolCount=1),n+=e.symbolCount}),n<=0&&(n=1),e.forEach(e=>{e.ratio??=e.symbolCount/n}),this.applyProgressRanges(e)}async getNav(){return await super.getNav()||null}async dispose(){await super.dispose();for(let[,e]of this.pdfDocs.entries())try{await e.cleanup(),await c.destroyPdfLoadingTask(e.loadingTask),await e.destroy()}catch{await c.destroyPdfLoadingTask(e.loadingTask)}this.pdfDocs.clear(),this.sharedSource=void 0;let e=this.ownedSources.splice(0);for(let t of e)try{await t.close()}catch{}if(this.textDocuments){for(let e of this.textDocuments)await e.dispose();this.textDocuments.splice(0)}}async initNav(e){let t=new n.Nav;if(!e)return t;let r=await e.getOutline();if(r==null||r.length==0)return t;for(let n=0;n<r.length;n++){let i=r[n],a=await this.getPageNumber(e,i.dest),o=await this.formatPdfDest(e,i.dest),s=await this.getNavPoint(e,i.title,a,o,i.items);t.navPoints.push(s)}return t}async getNavPoint(e,t,r,i,a){t=t?.trim().replace(/[\x00-\x1f]/gi,``);let o=r.toString()+`.pdf`,s=new n.NavPoint(t,o,r,i);if(a!=null&&a.length>0)for(let t=0;t<a.length;t++){let n=await this.getPageNumber(e,a[t].dest),r=await this.formatPdfDest(e,a[t].dest),i=await this.getNavPoint(e,a[t].title,n,r,a[t].items);s.children.push(i)}return s}async formatPdfDest(e,t){let n;return n=typeof t==`string`?await e.getDestination(t):t,JSON.stringify(n)}async getPageNumber(e,t){let n,r=0;try{if(n=typeof t==`string`?await e.getDestination(t):t,Array.isArray(n)){let[t]=n;typeof t==`object`&&t?r=await e.getPageIndex(t)+1:Number.isInteger(t)&&(r=t+1)}}catch{}return r}};exports.PdfFileParser=d;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../../kernal/common/text.cjs"),t=require("../../../kernal/IFileParser.cjs"),n=require("../../../kernal/nav/Nav.cjs"),r=require("../../../kernal/io/IByteSource.cjs"),i=require("../../../kernal/io/BlobByteSource.cjs"),a=require("../../../kernal/io/MemoryByteSource.cjs"),o=require("../loadPdfDocument.cjs"),s=require("../ensurePdfWebWorker.cjs"),c=require("../../base/fileParser/BaseFileParser.cjs"),l=require("./PdfTextDocument.cjs"),u=require("./PdfPasswordProvider.cjs");var d=class extends c.BaseFileParser{constructor(e,t,n,r,i,a,o,s,c,l){super(e,t,n,r,s,c),this.events=i,this.locale=a,this.context=o,this.url=s,this.extension=c,this.options=l,this.ownedSources=[],this.pdfDocs=new Map,this.passwordProvider=new u.PdfPasswordProvider(i,a,o),this.bindDefaultPasswordFlow()}bindDefaultPasswordFlow(){this.options.standardPasswordProvider||(this.options.standardPasswordProvider=this.passwordProvider.getPassword)}async buildLocation(t,r){let i=typeof t==`string`?new n.NavPoint(``,t):t,a=await super.buildLocation(t,r);return(i.startPageNumber??0)>0&&(a.current=i.startPageNumber,a.unit=`page`),e.isNullOrWhiteSpace(i.pdfDest)||(a.pdfDest=i.pdfDest),a}async getCover(e,t){return null}async getTextDocuments(){if(this.textDocuments)return this.textDocuments;this.textDocuments=[];let e=await this.getSpineFiles();for(let t=0;t<e.length;t++){let n=e[t],r=new l.PdfTextDocument(this,n);this.textDocuments.push(r)}return this.textDocuments}async captureInitialSource(e){if(e.data&&e.data.byteLength>0){let t=e.byteSource;e.byteSource=void 0,await t?.close();return}if(e.byteSource){if(e.byteSource instanceof a.MemoryByteSource){e.data=await r.materialize(e.byteSource);let t=e.byteSource;e.byteSource=void 0,await t.close();return}this.sharedSource=e.byteSource,this.ownedSources.push(e.byteSource),e.byteSource=void 0}}trackSource(e){return this.ownedSources.push(e),e}async resolveSpineInput(e){if(e.data instanceof ArrayBuffer&&e.data.byteLength>0)return new Uint8Array(e.data);if(e.data instanceof Blob&&e.data.size>0)return this.trackSource(new i.BlobByteSource(e.data));if(this.sharedSource)return this.sharedSource;if(!e.url)return new Uint8Array;let t=await this.fileUrlParser.parse(e.url,{requireFullFile:!1});if(t.data&&t.data.byteLength>0){let e=t.byteSource;return t.byteSource=void 0,await e?.close(),new Uint8Array(t.data)}if(t.byteSource instanceof a.MemoryByteSource){let e=new Uint8Array(await r.materialize(t.byteSource));return await t.byteSource.close(),e}return t.byteSource?this.trackSource(t.byteSource):new Uint8Array}async getPdfDocument(e){let t=this.pdfDocs.get(e.url);return t&&!t.loadingTask.destroyed?t:(t=await this.internalGetPdfDocumentProxy(e),this.pdfDocs.set(e.url,t),t)}async internalGetPdfDocumentProxy(e){let t;this.options.standardPasswordProvider&&(t=await this.options.standardPasswordProvider(this,e));let n=await this.resolveSpineInput(e);return await o.loadPdfDocument(n,{password:t,cMapUrl:this.options.cMapUrl,standardFontDataUrl:this.options.standardFontDataUrl,wasmUrl:this.options.wasmUrl,iccUrl:this.options.iccUrl,showPasswordPrompt:this.options.showPasswordPrompt,passwordPrompt:this.passwordProvider.onPasswordPrompt,internalUrlBuilder:this.options.internalUrlBuilder,documentInitParametersCallback:this.options.documentInitParametersCallback})}async load(e){let t=await this.parseUrl(this.url,{requireFullFile:!1});await this.initializeDatas(t),e?.measureFilePercentage&&await this.measureFilePercentage(t.spineFiles??[],t.requireCalculateFileSymbolCount)}async parseUrl(e,n){let r=await super.parseUrl(e,n);if(r.spineFiles||=[],!r.isMultiFiles){await this.captureInitialSource(r);let e=new t.SpineFile(r.data,r.mainUrl,this.extension),n=await this.internalGetPdfDocumentProxy(e);r.data=void 0,e.data=void 0;for(let e=0;e<n.numPages;e++){let i=`${e+1}.pdf`,a=new t.SpineFile(null,i,this.extension);r.spineFiles.push(a),this.pdfDocs.set(i,n)}r.nav=await this.initNav(n)}return r}async measureFilePercentage(e,t){if(!e)return;if(!e.find(e=>e.symbolCount==null)){e[0]?.ratio!=null&&this.applyProgressRanges(e);return}let n=0;e.forEach(e=>{(e.symbolCount==null||e.symbolCount<=0)&&(e.symbolCount=1),n+=e.symbolCount}),n<=0&&(n=1),e.forEach(e=>{e.ratio??=e.symbolCount/n}),this.applyProgressRanges(e)}async getNav(){return await super.getNav()||null}async dispose(){await super.dispose();for(let[,e]of this.pdfDocs.entries())try{await e.cleanup(),await s.destroyPdfLoadingTask(e.loadingTask),await e.destroy()}catch{await s.destroyPdfLoadingTask(e.loadingTask)}this.pdfDocs.clear(),this.sharedSource=void 0;let e=this.ownedSources.splice(0);for(let t of e)try{await t.close()}catch{}if(this.textDocuments){for(let e of this.textDocuments)await e.dispose();this.textDocuments.splice(0)}}async initNav(e){let t=new n.Nav;if(!e)return t;let r=await e.getOutline();if(r==null||r.length==0)return t;for(let n=0;n<r.length;n++){let i=r[n],a=await this.getPageNumber(e,i.dest),o=await this.formatPdfDest(e,i.dest),s=await this.getNavPoint(e,i.title,a,o,i.items);t.navPoints.push(s)}return t}async getNavPoint(e,t,r,i,a){t=t?.trim().replace(/[\x00-\x1f]/gi,``);let o=r.toString()+`.pdf`,s=new n.NavPoint(t,o,r,i);if(a!=null&&a.length>0)for(let t=0;t<a.length;t++){let n=await this.getPageNumber(e,a[t].dest),r=await this.formatPdfDest(e,a[t].dest),i=await this.getNavPoint(e,a[t].title,n,r,a[t].items);s.children.push(i)}return s}async formatPdfDest(e,t){let n;return n=typeof t==`string`?await e.getDestination(t):t,JSON.stringify(n)}async getPageNumber(e,t){let n,r=0;try{if(n=typeof t==`string`?await e.getDestination(t):t,Array.isArray(n)){let[t]=n;typeof t==`object`&&t?r=await e.getPageIndex(t)+1:Number.isInteger(t)&&(r=t+1)}}catch{}return r}};exports.PdfFileParser=d;
@@ -4,13 +4,13 @@ import { Nav as n, NavPoint as r } from "../../../kernal/nav/Nav.mjs";
4
4
  import { materialize as i } from "../../../kernal/io/IByteSource.mjs";
5
5
  import { BlobByteSource as a } from "../../../kernal/io/BlobByteSource.mjs";
6
6
  import { MemoryByteSource as o } from "../../../kernal/io/MemoryByteSource.mjs";
7
- import { BaseFileParser as s } from "../../base/fileParser/BaseFileParser.mjs";
8
- import { loadPdfDocument as c } from "../loadPdfDocument.mjs";
9
- import { destroyPdfLoadingTask as l } from "../ensurePdfWebWorker.mjs";
7
+ import { loadPdfDocument as s } from "../loadPdfDocument.mjs";
8
+ import { destroyPdfLoadingTask as c } from "../ensurePdfWebWorker.mjs";
9
+ import { BaseFileParser as l } from "../../base/fileParser/BaseFileParser.mjs";
10
10
  import { PdfTextDocument as u } from "./PdfTextDocument.mjs";
11
11
  import { PdfPasswordProvider as d } from "./PdfPasswordProvider.mjs";
12
12
  //#region mediaTypes/pdf/fileParser/PdfFileParser.ts
13
- var f = class extends s {
13
+ var f = class extends l {
14
14
  constructor(e, t, n, r, i, a, o, s, c, l) {
15
15
  super(e, t, n, r, s, c), this.events = i, this.locale = a, this.context = o, this.url = s, this.extension = c, this.options = l, this.ownedSources = [], this.pdfDocs = /* @__PURE__ */ new Map(), this.passwordProvider = new d(i, a, o), this.bindDefaultPasswordFlow();
16
16
  }
@@ -77,7 +77,7 @@ var f = class extends s {
77
77
  let t;
78
78
  this.options.standardPasswordProvider && (t = await this.options.standardPasswordProvider(this, e));
79
79
  let n = await this.resolveSpineInput(e);
80
- return await c(n, {
80
+ return await s(n, {
81
81
  password: t,
82
82
  cMapUrl: this.options.cMapUrl,
83
83
  standardFontDataUrl: this.options.standardFontDataUrl,
@@ -126,9 +126,9 @@ var f = class extends s {
126
126
  async dispose() {
127
127
  await super.dispose();
128
128
  for (let [, e] of this.pdfDocs.entries()) try {
129
- await e.cleanup(), await l(e.loadingTask), await e.destroy();
129
+ await e.cleanup(), await c(e.loadingTask), await e.destroy();
130
130
  } catch {
131
- await l(e.loadingTask);
131
+ await c(e.loadingTask);
132
132
  }
133
133
  this.pdfDocs.clear(), this.sharedSource = void 0;
134
134
  let e = this.ownedSources.splice(0);
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../../kernal/common/uuid.cjs"),t=require("../../../kernal/IFileParser.cjs"),n=require("../../../kernal/html/geometry.cjs"),r=require("../../base/renderer/BaseDocument.cjs");var i=`custom-text-layer`,a=class extends r.BaseDocument{constructor(e,n,r,i,a,o){super(e,r,i,new t.SpineFile(null,a||`${o}.pdf`,`.pdf`)),this.pdfViewer=n,this.texts=new Map,this.currentPageNumber=o,this.loadStatus=`success`}get pageNumber(){return this.currentPageNumber}getPageGeometry(){let e=this.resolvePageView(),t=e?.pdfPage?.ref;if(!(!e?.viewport||!e.div||!t))return{rawWidth:e.viewport.viewBox[2],rawHeight:e.viewport.viewBox[3],rotation:Math.abs(e.viewport.rotation)%360,displayWidth:e.width,displayHeight:e.height,pageRect:e.div.getBoundingClientRect(),ref:t}}getVisibleElements(e){if(this.loadStatus!=`success`)return[];let t=this.getContentContainer();if(!t)return[];let r=this.collectTextLayerElements(t);if(r.length===0)return[];let i=this.owner.getRenderer()?.getScrollElement()??this.owner.getReaderContainer();if(!i)return[];let a=i.getBoundingClientRect(),o={left:a.left,top:a.top,right:a.right,bottom:a.bottom};return o.right<=o.left||o.bottom<=o.top?[]:n.getOrderedElementsIntersectingRect(r,o,{fullVisible:e})}collectTextLayerElements(e){let t=e.querySelectorAll(`svg.${i} text`);return t.length>0?Array.from(t):Array.from(e.querySelectorAll(`.textLayer span`))}resolvePageView(){return this.pdfViewer._pages.find(e=>e.id==this.pageNumber)}async load(){this.loadStatus=`success`}async getText(t){let n=e.computeUniqueId(JSON.stringify(t??{}));if(this.texts.has(n))return this.texts.get(n);let r=await this.pdfViewer.getPageText(this.pageNumber,t);return this.texts.set(n,r),r}async dispose(){this.texts.clear(),await super.dispose()}};exports.PdfDocument=a;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../../kernal/common/uuid.cjs"),t=require("../../../kernal/IFileParser.cjs"),n=require("../../base/renderer/BaseDocument.cjs"),r=require("../../../kernal/html/geometry.cjs");var i=`custom-text-layer`,a=class extends n.BaseDocument{constructor(e,n,r,i,a,o){super(e,r,i,new t.SpineFile(null,a||`${o}.pdf`,`.pdf`)),this.pdfViewer=n,this.texts=new Map,this.currentPageNumber=o,this.loadStatus=`success`}get pageNumber(){return this.currentPageNumber}getPageGeometry(){let e=this.resolvePageView(),t=e?.pdfPage?.ref;if(!(!e?.viewport||!e.div||!t))return{rawWidth:e.viewport.viewBox[2],rawHeight:e.viewport.viewBox[3],rotation:Math.abs(e.viewport.rotation)%360,displayWidth:e.width,displayHeight:e.height,pageRect:e.div.getBoundingClientRect(),ref:t}}getVisibleElements(e){if(this.loadStatus!=`success`)return[];let t=this.getContentContainer();if(!t)return[];let n=this.collectTextLayerElements(t);if(n.length===0)return[];let i=this.owner.getRenderer()?.getScrollElement()??this.owner.getReaderContainer();if(!i)return[];let a=i.getBoundingClientRect(),o={left:a.left,top:a.top,right:a.right,bottom:a.bottom};return o.right<=o.left||o.bottom<=o.top?[]:r.getOrderedElementsIntersectingRect(n,o,{fullVisible:e})}collectTextLayerElements(e){let t=e.querySelectorAll(`svg.${i} text`);return t.length>0?Array.from(t):Array.from(e.querySelectorAll(`.textLayer span`))}resolvePageView(){return this.pdfViewer._pages.find(e=>e.id==this.pageNumber)}async load(){this.loadStatus=`success`}async getText(t){let n=e.computeUniqueId(JSON.stringify(t??{}));if(this.texts.has(n))return this.texts.get(n);let r=await this.pdfViewer.getPageText(this.pageNumber,t);return this.texts.set(n,r),r}async dispose(){this.texts.clear(),await super.dispose()}};exports.PdfDocument=a;
@@ -1,9 +1,9 @@
1
1
  import { computeUniqueId as e } from "../../../kernal/common/uuid.mjs";
2
2
  import { SpineFile as t } from "../../../kernal/IFileParser.mjs";
3
- import { getOrderedElementsIntersectingRect as n } from "../../../kernal/html/geometry.mjs";
4
- import { BaseDocument as r } from "../../base/renderer/BaseDocument.mjs";
3
+ import { BaseDocument as n } from "../../base/renderer/BaseDocument.mjs";
4
+ import { getOrderedElementsIntersectingRect as r } from "../../../kernal/html/geometry.mjs";
5
5
  //#region mediaTypes/pdf/renderer/PdfDocument.ts
6
- var i = "custom-text-layer", a = class extends r {
6
+ var i = "custom-text-layer", a = class extends n {
7
7
  constructor(e, n, r, i, a, o) {
8
8
  super(e, r, i, new t(null, a || `${o}.pdf`, ".pdf")), this.pdfViewer = n, this.texts = /* @__PURE__ */ new Map(), this.currentPageNumber = o, this.loadStatus = "success";
9
9
  }
@@ -26,8 +26,8 @@ var i = "custom-text-layer", a = class extends r {
26
26
  if (this.loadStatus != "success") return [];
27
27
  let t = this.getContentContainer();
28
28
  if (!t) return [];
29
- let r = this.collectTextLayerElements(t);
30
- if (r.length === 0) return [];
29
+ let n = this.collectTextLayerElements(t);
30
+ if (n.length === 0) return [];
31
31
  let i = this.owner.getRenderer()?.getScrollElement() ?? this.owner.getReaderContainer();
32
32
  if (!i) return [];
33
33
  let a = i.getBoundingClientRect(), o = {
@@ -36,7 +36,7 @@ var i = "custom-text-layer", a = class extends r {
36
36
  right: a.right,
37
37
  bottom: a.bottom
38
38
  };
39
- return o.right <= o.left || o.bottom <= o.top ? [] : n(r, o, { fullVisible: e });
39
+ return o.right <= o.left || o.bottom <= o.top ? [] : r(n, o, { fullVisible: e });
40
40
  }
41
41
  collectTextLayerElements(e) {
42
42
  let t = e.querySelectorAll(`svg.${i} text`);
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../../kernal/EventNames.cjs"),n=require("../../../../kernal/common/text.cjs"),r=require("../../../../kernal/html/finder.cjs"),i=require("../../../../kernal/html/injector.cjs"),a=require("../../../../kernal/Theme.cjs"),o=require("../../../../kernal/html/style.cjs"),s=require("../../../base/renderer/BaseDocumentsProvider.cjs"),c=require("../PdfViewerBuilder.cjs"),l=require("./resolvePdfLocationPageNumber.cjs"),u=require("../PdfDocument.cjs"),d=require("../layout/PdfRendererViewport.cjs");let f=require("../../../../pdfjs/legacy/build/pdf.mjs");f=e.__toESM(f,1);let p=require("../../../../pdfjs/legacy/web/pdf_viewer.mjs");p=e.__toESM(p,1),require("../../../../pdfjs/legacy/web/pdf_viewer.css");let m=require("perfect-debounce");var h=class extends s.BaseDocumentsProvider{constructor(e,i,a,s){super(e,i),this.readerContainer=a,this.options=s,this.isInit=!1,this.isFirstLoad=!0,this.pdfDocument=null,this.isEngineInitialized=!1,this.delayOnAutoScaleResize=(0,m.debounce)(async()=>{await this.onAutoScaleResize()},100),this.resize=async()=>{this.eventBus.dispatch(`resize`,{source:this.readerContainer.ownerDocument.defaultView})},this.fillDocuments=()=>{this.documentItems=[],this.pdfViewer._pages.forEach(e=>{let t=e.spineFile?.url,n=new u.PdfDocument(this.owner,this.pdfViewer,this.fileParser,e.div,t,e.id);this.documentItems.push(n)})},this.reload=async()=>{let e=this.owner.context.currentLocation;n.isNullOrWhiteSpace(e?.url)||await this.load(e,!0)},this.getSinglePdfPage=async(e,t)=>{let n=await this.fileParser.getPdfDocument(e);return{doc:n,page:await n.getPage(t)}},this.delayRedirect=async()=>{let e=this.owner.context.currentLocation;await this.redirect(e),this.isFirstLoad=!1,this.owner.events.off(t.EventNames.PdfPagesInit,this.delayRedirect)},this.redirect=async e=>{if(!e?.current)return;let t=e.current<1?Math.floor(e.current*this.numberOfPages):e.current;await this.gotoPageInternal(t,e.pdfDest,e.offsetTop,e?.ignoreOverlayHeader)},this.pageLoaded=(e,n)=>{let i=this.owner.context.currentLocation,a=r.getElementByNameAndIndex(e.getContentContainer(),i.tagName,i.tagIndex);this.gotoTargetElement(a,i),this.owner.events.off(t.EventNames.PdfPageTextRendered,this.pageLoaded),this.owner.events.emit(t.EventNames.PdfLoadFinished,{reader:this.owner})},this.gotoTargetElement=(e,t)=>{if(!e)return;o.scrollElementIntoView(e,void 0,void 0,this.owner.getRootContainer()?.ownerDocument);let n=0;if(t?.offsetTop&&(n+=t.offsetTop),n<=0)return;let r=this.getScrollElement();r.scrollHeight-r.scrollTop-r.clientHeight>0&&r.scrollTo(0,r.scrollTop-n)},this.setCurrentPageNumber=e=>{let t=this.pdfViewer,n=t.currentPageNumber;t.currentPageNumber=e;let r=t.currentScaleValue;this.options.resetScaleAfterPageChanged&&n!=e&&(r==`auto`||r==`page-fit`||r==`page-width`)&&(t.hasEqualPageSizes||t.rescrollIntoView(e))},this.logger=this.owner.loggerFactory.getLogger(this.constructor.name),this.rendererViewport=new d.PdfRendererViewport(e.getRootContainer(),a,this.options,()=>this.currentPage,()=>this.removePageBorders);let l=this.rendererViewport.getRendererContainer(),{pdfViewer:f,eventBus:p,linkService:h,findController:g,maxCanvasPixels:_,removePageBorders:v}=new c.PdfViewerBuilder(this.options).build(l);this.pdfViewer=f,this.eventBus=p,this.linkService=h,this.findController=g,this.maxCanvasPixels=_,this.removePageBorders=v}getViewerContainer(){return this.rendererViewport.getViewerContainer()}getEventBus(){return this.eventBus}getFindController(){return this.findController}getRendererContainer(){return this.rendererViewport.getRendererContainer()}getScrollElement(){return this.rendererViewport.getScrollElement()}hasPdfDocument(){return!!this.pdfDocument}async getProgress(e){}registerContainerResizeObserver(){this.containerResizeObserver||(this.containerResizeObserver&&=(this.containerResizeObserver.disconnect(),void 0),this.containerResizeObserver=new ResizeObserver(async e=>{if(this.owner.context){if(this.readerContainer.clientWidth==0||this.readerContainer.clientHeight==0){this.readerContainer.foxycape_document_hidden&&(this.readerContainer.foxycape_document_require_resize=`true`),this.readerContainer.foxycape_document_hidden=`true`;return}if(this.readerContainer.clientWidth>0&&this.readerContainer.clientHeight>0&&this.readerContainer.foxycape_document_hidden){if(this.readerContainer.foxycape_document_hidden=void 0,!this.readerContainer.foxycape_document_require_resize)return;this.readerContainer.foxycape_document_require_resize=void 0}this.owner.context.setUserChangedProgress(!1),(this.pdfViewer.currentScaleValue==`auto`||this.pdfViewer.currentScaleValue==`page-fit`||this.pdfViewer.currentScaleValue==`page-width`)&&!this.isFirstLoad&&await this.delayOnAutoScaleResize(),this.rendererViewport.applyCssVariables(),this.owner.context&&this.owner.events.emit(t.EventNames.RendererContainerSizeChange,this.getRendererContainer(),this.owner.context.userChangedProgress)}}),this.containerResizeObserver.observe(this.readerContainer))}async onAutoScaleResize(){let e=this.getRendererContainer();this.owner.resourceIsUnload||e.clientWidth==0||e.clientHeight==0||await this.resize()}async createDocument(e,t,n){let r=n+1;return new u.PdfDocument(this.owner,this.pdfViewer,this.fileParser,e,t.url,r)}async load(e,n){let r=this.owner.context;if(!r||this.owner.disposed)return;let i=!0;try{if(r.setUserChangedProgress(!n,e?.from),r.currentLocation=e,e?.storeCurrent&&await this.owner.onBeforeRedirect?.(this),!this.isInit){this.owner.events.on(t.EventNames.PdfPagesInit,this.delayRedirect),await this.loadEngine(async()=>{this.fillDocuments(),this.isInit=!0,this.registerContainerResizeObserver()}),this.getRendererContainer().focus();return}if(!this.owner.context||this.owner.disposed){i=!1;return}i=await this.navigateToLocation(e)}finally{i&&this.owner.context&&!this.owner.disposed&&this.owner.events.emit(t.EventNames.PdfLoadFinished,{reader:this.owner})}}async navigateToLocation(e){if(e?.url&&e.tagName&&e.tagIndex!=null){let n=this.getDocument(e.url),i=r.getElementByNameAndIndex(n.getContentContainer(),e.tagName,e.tagIndex);return i?(this.gotoTargetElement(i,e),!0):(this.owner.events.on(t.EventNames.PdfPageTextRendered,this.pageLoaded),!1)}let n=this.resolvePageNumber(e);return n==null||await this.gotoPageInternal(n,e?.pdfDest,e?.offsetTop,e?.ignoreOverlayHeader),!0}resolvePageNumber(e){return l.resolvePdfLocationPageNumber(e,this.numberOfPages,e=>{let t=this.getDocument(e);return t?this.getDocuments().indexOf(t)+1:null})}async initializeEngine(){if(this.isEngineInitialized)return;let e=`.pdfViewer .canvasWrapper{position:absolute;left:0;top:0}
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../../kernal/EventNames.cjs"),n=require("../../../../kernal/common/text.cjs"),r=require("../../../../kernal/html/finder.cjs"),i=require("../../../../kernal/html/injector.cjs"),a=require("../../../../kernal/Theme.cjs"),o=require("../../../base/renderer/BaseDocumentsProvider.cjs"),s=require("../../../../kernal/html/style.cjs"),c=require("../PdfViewerBuilder.cjs"),l=require("./resolvePdfLocationPageNumber.cjs"),u=require("../PdfDocument.cjs"),d=require("../layout/PdfRendererViewport.cjs");let f=require("../../../../pdfjs/legacy/build/pdf.mjs");f=e.__toESM(f,1);let p=require("../../../../pdfjs/legacy/web/pdf_viewer.mjs");p=e.__toESM(p,1),require("../../../../pdfjs/legacy/web/pdf_viewer.css");let m=require("perfect-debounce");var h=class extends o.BaseDocumentsProvider{constructor(e,i,a,o){super(e,i),this.readerContainer=a,this.options=o,this.isInit=!1,this.isFirstLoad=!0,this.pdfDocument=null,this.isEngineInitialized=!1,this.delayOnAutoScaleResize=(0,m.debounce)(async()=>{await this.onAutoScaleResize()},100),this.resize=async()=>{this.eventBus.dispatch(`resize`,{source:this.readerContainer.ownerDocument.defaultView})},this.fillDocuments=()=>{this.documentItems=[],this.pdfViewer._pages.forEach(e=>{let t=e.spineFile?.url,n=new u.PdfDocument(this.owner,this.pdfViewer,this.fileParser,e.div,t,e.id);this.documentItems.push(n)})},this.reload=async()=>{let e=this.owner.context.currentLocation;n.isNullOrWhiteSpace(e?.url)||await this.load(e,!0)},this.getSinglePdfPage=async(e,t)=>{let n=await this.fileParser.getPdfDocument(e);return{doc:n,page:await n.getPage(t)}},this.delayRedirect=async()=>{let e=this.owner.context.currentLocation;await this.redirect(e),this.isFirstLoad=!1,this.owner.events.off(t.EventNames.PdfPagesInit,this.delayRedirect)},this.redirect=async e=>{if(!e?.current)return;let t=e.current<1?Math.floor(e.current*this.numberOfPages):e.current;await this.gotoPageInternal(t,e.pdfDest,e.offsetTop,e?.ignoreOverlayHeader)},this.pageLoaded=(e,n)=>{let i=this.owner.context.currentLocation,a=r.getElementByNameAndIndex(e.getContentContainer(),i.tagName,i.tagIndex);this.gotoTargetElement(a,i),this.owner.events.off(t.EventNames.PdfPageTextRendered,this.pageLoaded),this.owner.events.emit(t.EventNames.PdfLoadFinished,{reader:this.owner})},this.gotoTargetElement=(e,t)=>{if(!e)return;s.scrollElementIntoView(e,void 0,void 0,this.owner.getRootContainer()?.ownerDocument);let n=0;if(t?.offsetTop&&(n+=t.offsetTop),n<=0)return;let r=this.getScrollElement();r.scrollHeight-r.scrollTop-r.clientHeight>0&&r.scrollTo(0,r.scrollTop-n)},this.setCurrentPageNumber=e=>{let t=this.pdfViewer,n=t.currentPageNumber;t.currentPageNumber=e;let r=t.currentScaleValue;this.options.resetScaleAfterPageChanged&&n!=e&&(r==`auto`||r==`page-fit`||r==`page-width`)&&(t.hasEqualPageSizes||t.rescrollIntoView(e))},this.logger=this.owner.loggerFactory.getLogger(this.constructor.name),this.rendererViewport=new d.PdfRendererViewport(e.getRootContainer(),a,this.options,()=>this.currentPage,()=>this.removePageBorders);let l=this.rendererViewport.getRendererContainer(),{pdfViewer:f,eventBus:p,linkService:h,findController:g,maxCanvasPixels:_,removePageBorders:v}=new c.PdfViewerBuilder(this.options).build(l);this.pdfViewer=f,this.eventBus=p,this.linkService=h,this.findController=g,this.maxCanvasPixels=_,this.removePageBorders=v}getViewerContainer(){return this.rendererViewport.getViewerContainer()}getEventBus(){return this.eventBus}getFindController(){return this.findController}getRendererContainer(){return this.rendererViewport.getRendererContainer()}getScrollElement(){return this.rendererViewport.getScrollElement()}hasPdfDocument(){return!!this.pdfDocument}async getProgress(e){}registerContainerResizeObserver(){this.containerResizeObserver||(this.containerResizeObserver&&=(this.containerResizeObserver.disconnect(),void 0),this.containerResizeObserver=new ResizeObserver(async e=>{if(this.owner.context){if(this.readerContainer.clientWidth==0||this.readerContainer.clientHeight==0){this.readerContainer.foxycape_document_hidden&&(this.readerContainer.foxycape_document_require_resize=`true`),this.readerContainer.foxycape_document_hidden=`true`;return}if(this.readerContainer.clientWidth>0&&this.readerContainer.clientHeight>0&&this.readerContainer.foxycape_document_hidden){if(this.readerContainer.foxycape_document_hidden=void 0,!this.readerContainer.foxycape_document_require_resize)return;this.readerContainer.foxycape_document_require_resize=void 0}this.owner.context.setUserChangedProgress(!1),(this.pdfViewer.currentScaleValue==`auto`||this.pdfViewer.currentScaleValue==`page-fit`||this.pdfViewer.currentScaleValue==`page-width`)&&!this.isFirstLoad&&await this.delayOnAutoScaleResize(),this.rendererViewport.applyCssVariables(),this.owner.context&&this.owner.events.emit(t.EventNames.RendererContainerSizeChange,this.getRendererContainer(),this.owner.context.userChangedProgress)}}),this.containerResizeObserver.observe(this.readerContainer))}async onAutoScaleResize(){let e=this.getRendererContainer();this.owner.resourceIsUnload||e.clientWidth==0||e.clientHeight==0||await this.resize()}async createDocument(e,t,n){let r=n+1;return new u.PdfDocument(this.owner,this.pdfViewer,this.fileParser,e,t.url,r)}async load(e,n){let r=this.owner.context;if(!r||this.owner.disposed)return;let i=!0;try{if(r.setUserChangedProgress(!n,e?.from),r.currentLocation=e,e?.storeCurrent&&await this.owner.onBeforeRedirect?.(this),!this.isInit){this.owner.events.on(t.EventNames.PdfPagesInit,this.delayRedirect),await this.loadEngine(async()=>{this.fillDocuments(),this.isInit=!0,this.registerContainerResizeObserver()}),this.getRendererContainer().focus();return}if(!this.owner.context||this.owner.disposed){i=!1;return}i=await this.navigateToLocation(e)}finally{i&&this.owner.context&&!this.owner.disposed&&this.owner.events.emit(t.EventNames.PdfLoadFinished,{reader:this.owner})}}async navigateToLocation(e){if(e?.url&&e.tagName&&e.tagIndex!=null){let n=this.getDocument(e.url),i=r.getElementByNameAndIndex(n.getContentContainer(),e.tagName,e.tagIndex);return i?(this.gotoTargetElement(i,e),!0):(this.owner.events.on(t.EventNames.PdfPageTextRendered,this.pageLoaded),!1)}let n=this.resolvePageNumber(e);return n==null||await this.gotoPageInternal(n,e?.pdfDest,e?.offsetTop,e?.ignoreOverlayHeader),!0}resolvePageNumber(e){return l.resolvePdfLocationPageNumber(e,this.numberOfPages,e=>{let t=this.getDocument(e);return t?this.getDocuments().indexOf(t)+1:null})}async initializeEngine(){if(this.isEngineInitialized)return;let e=`.pdfViewer .canvasWrapper{position:absolute;left:0;top:0}
2
2
  .pdfViewer .page {background-color:var(${a.Theme.ContentBackground}) !important}`;i.injectCssContent(this.getRendererContainer().ownerDocument,e,!1,`custom-pdf-viewer-page-css`),this.eventBus.on(`pagesinit`,async()=>{!this.pdfViewer.currentScaleValue&&this.options.scaleValue&&(this.pdfViewer.currentScaleValue=this.options.scaleValue)}),this.isEngineInitialized=!0}async loadEngine(e){await this.closeEngine(),await this.initializeEngine();let n=await this.fileParser.getEntryFile(),r=await this.fileParser.getPdfDocument(n);if(this.pdfDocument=r,!this.fileParser.isMultiFiles){this.setPdfDocument(this.pdfDocument),await this.pdfDocument.getPage(1),this.pdfViewer.firstPagePromise&&await this.pdfViewer.firstPagePromise,e&&await e(),this.owner.events.emit(t.EventNames.PdfPagesInit,this);return}let i=await this.fileParser.getSpineFiles();if(this.setPdfDocument(this.pdfDocument,!1),this.pdfViewer.firstPagePromise){let e=await this.pdfViewer.firstPagePromise,t=this.pdfViewer._pages[0];if(t&&(t.spineFile=n),i.length>0){let t=e.getViewport({scale:this.pdfViewer.currentScale*f.PixelsPerInch.PDF_TO_CSS_UNITS}),n=this.createSpinePageViews(this.getViewerContainer(),i,t);await this.pdfViewer.setOtherPages(n,this.getSinglePdfPage)}}e&&await e(),this.owner.events.emit(t.EventNames.PdfPagesInit,this)}setPdfDocument(e,t=!0){this.pdfViewer.setDocument(e),t&&(e?(this.linkService.setDocument(e),this.findController.setDocument(e)):(this.linkService.setDocument(null,null),this.findController.setDocument(null)))}createSpinePageViews(e,t,n){let r=[];for(let i=2;i<t.length+1;i++){let a=new p.PDFPageView({container:e,eventBus:this.eventBus,id:i,scale:this.pdfViewer.currentScale,defaultViewport:n.clone(),renderingQueue:this.pdfViewer.renderingQueue,textLayerMode:+(this.options.textLayerMode==1),annotationMode:this.options.annotationMode,maxCanvasPixels:this.maxCanvasPixels});a.spineFile=t[i-1],r.push(a)}return r}async closeEngine(){this.pdfDocument&&(this.pdfDocument=null,this.setPdfDocument(null))}get numberOfPages(){return this.pdfViewer.pagesCount}get currentPage(){return this.pdfViewer?.currentPageNumber}set currentPage(e){this.setCurrentPageNumber(e)}setCurrentPage(e,t=!0){if(!t){this.pdfViewer._setCurrentPageNumber?.(e,!1);return}this.setCurrentPageNumber(e)}get isSpreadMode(){return this.pdfViewer?.spreadMode!==p.SpreadMode.NONE}async scrollToPage(e,t,n,r){if(t){let i=JSON.parse(t);if(this.pdfViewer.scrollPageIntoView({pageNumber:e,destArray:i,allowNegativeOffset:!0,ignoreDestinationZoom:!0}),this.getRendererContainer().scrollHeight>this.getRendererContainer().clientHeight+10){let e=0;if(r||(e+=this.owner.options.redirectPositionOffset),n&&(e+=n),e>0){let t=this.getScrollElement();t.scrollTo(0,t.scrollTop-e)}}}else this.setCurrentPageNumber(e)}async gotoPageInternal(e,t,n,r){let i=this.owner.locale;return e<=0?(this.owner.notifier.info(i.getText(`navigotor_alreadyisfirstpage`,`Already at the first page`)),!1):e>this.numberOfPages?(this.owner.notifier.info(i.getText(`navigotor_alreadyislastpage`,`You have reached the end of the book.`)),!1):(t?.indexOf(`Fit`)>=0?await this.scrollToPage(e,null,n,r):await this.scrollToPage(e,t,n,r),!0)}getLoadedDocuments(){let e=Array.from(this.pdfViewer.getCachedPageViews().values()).map(e=>e.id);return this.documentItems.filter(t=>e.includes(t.pageNumber))}getVisibleDocuments(){let e=this.pdfViewer._getVisiblePages(),t=Array.from(e.views.map(e=>e.id));return this.documentItems.filter(e=>t.includes(e.pageNumber))}getPageViews(){return this.pdfViewer._pages}getPageView(e){if(!(e<1))return this.pdfViewer.getPageView(e-1)}async getPdfPage(e){return!this.pdfDocument||e<1||e>this.numberOfPages?void 0:this.getPageView(e)?.pdfPage||this.pdfDocument.getPage(e)}async dispose(){this.owner.events.off(t.EventNames.PdfPagesInit,this.delayRedirect),this.owner.events.off(t.EventNames.PdfPageTextRendered,this.pageLoaded),this.containerResizeObserver?.disconnect(),this.containerResizeObserver=void 0,await this.closeEngine(),await this.pdfViewer.dispose(),await super.dispose()}};exports.PdfDocumentsProvider=h;
@@ -4,8 +4,8 @@ import { getElementByNameAndIndex as n } from "../../../../kernal/html/finder.mj
4
4
  import { injectCssContent as r } from "../../../../kernal/html/injector.mjs";
5
5
  import { Theme as i } from "../../../../kernal/Theme.mjs";
6
6
  import { asyncDebounce as a } from "../../../../kernal/web/debounce.mjs";
7
- import { scrollElementIntoView as o } from "../../../../kernal/html/style.mjs";
8
- import { BaseDocumentsProvider as s } from "../../../base/renderer/BaseDocumentsProvider.mjs";
7
+ import { BaseDocumentsProvider as o } from "../../../base/renderer/BaseDocumentsProvider.mjs";
8
+ import { scrollElementIntoView as s } from "../../../../kernal/html/style.mjs";
9
9
  import { PdfViewerBuilder as c } from "../PdfViewerBuilder.mjs";
10
10
  import { resolvePdfLocationPageNumber as l } from "./resolvePdfLocationPageNumber.mjs";
11
11
  import { PdfDocument as u } from "../PdfDocument.mjs";
@@ -14,9 +14,9 @@ import * as f from "../../../../pdfjs/legacy/build/pdf.mjs";
14
14
  import * as p from "../../../../pdfjs/legacy/web/pdf_viewer.mjs";
15
15
  import "../../../../pdfjs/legacy/web/pdf_viewer.css";
16
16
  //#region mediaTypes/pdf/renderer/documents/PdfDocumentsProvider.ts
17
- var m = class extends s {
18
- constructor(r, i, s, l) {
19
- super(r, i), this.readerContainer = s, this.options = l, this.isInit = !1, this.isFirstLoad = !0, this.pdfDocument = null, this.isEngineInitialized = !1, this.delayOnAutoScaleResize = a(async () => {
17
+ var m = class extends o {
18
+ constructor(r, i, o, l) {
19
+ super(r, i), this.readerContainer = o, this.options = l, this.isInit = !1, this.isFirstLoad = !0, this.pdfDocument = null, this.isEngineInitialized = !1, this.delayOnAutoScaleResize = a(async () => {
20
20
  await this.onAutoScaleResize();
21
21
  }, 100), this.resize = async () => {
22
22
  this.eventBus.dispatch("resize", { source: this.readerContainer.ownerDocument.defaultView });
@@ -46,7 +46,7 @@ var m = class extends s {
46
46
  this.gotoTargetElement(a, i), this.owner.events.off(e.PdfPageTextRendered, this.pageLoaded), this.owner.events.emit(e.PdfLoadFinished, { reader: this.owner });
47
47
  }, this.gotoTargetElement = (e, t) => {
48
48
  if (!e) return;
49
- o(e, void 0, void 0, this.owner.getRootContainer()?.ownerDocument);
49
+ s(e, void 0, void 0, this.owner.getRootContainer()?.ownerDocument);
50
50
  let n = 0;
51
51
  if (t?.offsetTop && (n += t.offsetTop), n <= 0) return;
52
52
  let r = this.getScrollElement();
@@ -56,7 +56,7 @@ var m = class extends s {
56
56
  t.currentPageNumber = e;
57
57
  let r = t.currentScaleValue;
58
58
  this.options.resetScaleAfterPageChanged && n != e && (r == "auto" || r == "page-fit" || r == "page-width") && (t.hasEqualPageSizes || t.rescrollIntoView(e));
59
- }, this.logger = this.owner.loggerFactory.getLogger(this.constructor.name), this.rendererViewport = new d(r.getRootContainer(), s, this.options, () => this.currentPage, () => this.removePageBorders);
59
+ }, this.logger = this.owner.loggerFactory.getLogger(this.constructor.name), this.rendererViewport = new d(r.getRootContainer(), o, this.options, () => this.currentPage, () => this.removePageBorders);
60
60
  let f = this.rendererViewport.getRendererContainer(), { pdfViewer: p, eventBus: m, linkService: h, findController: g, maxCanvasPixels: _, removePageBorders: v } = new c(this.options).build(f);
61
61
  this.pdfViewer = p, this.eventBus = m, this.linkService = h, this.findController = g, this.maxCanvasPixels = _, this.removePageBorders = v;
62
62
  }