@aceshooting/lyra-ui 30.8.0 → 30.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/components/charts/chart/box-plot-loader.js +1 -1
  3. package/dist/components/charts/chart/chart-core-loader.js +1 -1
  4. package/dist/components/charts/chart/chart-feature-loader.js +1 -1
  5. package/dist/components/charts/chart-3d/chart-3d-engine.js +1 -1
  6. package/dist/components/conversation/code-block/code-loader.js +1 -1
  7. package/dist/components/conversation/code-block/shiki-oniguruma.js +1 -1
  8. package/dist/components/conversation/code-block/shiki-types.js +1 -1
  9. package/dist/components/conversation/markdown/katex-loader.js +1 -1
  10. package/dist/components/conversation/markdown/markdown-loader.js +1 -1
  11. package/dist/components/forms/emoji-picker/emoji-data-loader.js +1 -1
  12. package/dist/components/media/flag/flag-peer-bulk-standard.js +1 -1
  13. package/dist/components/media/flag/flag-peer-bulk.js +1 -1
  14. package/dist/components/media/flag/flag-peer.js +1 -1
  15. package/dist/components/media/map/map-feature-loader.js +1 -1
  16. package/dist/components/media/map/map-loader.js +1 -1
  17. package/dist/components/media/qr-code/qr-code-loader.js +1 -1
  18. package/dist/components/retrieval/embedding-explorer/embedding-explorer-engine.js +1 -1
  19. package/dist/components/retrieval/graph/graph-engine-adapter.js +1 -1
  20. package/dist/components/retrieval/graph/graph-loader.js +1 -1
  21. package/dist/components/utility/icon/dompurify-loader.js +1 -1
  22. package/dist/components/viewers/calendar-viewer/calendar-loader.js +1 -1
  23. package/dist/components/viewers/docx-viewer/docx-loader.js +1 -1
  24. package/dist/components/viewers/ebook-viewer/ebook-loader.js +1 -1
  25. package/dist/components/viewers/ebook-viewer/ebook-viewer.class.js +1 -1
  26. package/dist/components/viewers/ebook-viewer/epub-unload-guard.js +1 -0
  27. package/dist/components/viewers/email-viewer/email-loader.js +1 -1
  28. package/dist/components/viewers/html-viewer/dompurify-loader.js +1 -1
  29. package/dist/components/viewers/model-viewer/model-viewer-loader.js +1 -1
  30. package/dist/components/viewers/notebook-viewer/dompurify-loader.js +1 -1
  31. package/dist/components/viewers/pdf-viewer/pdf-loader.js +1 -1
  32. package/dist/components/viewers/pptx-viewer/pptx-loader.js +1 -1
  33. package/dist/components/viewers/spreadsheet-viewer/spreadsheet-loader.js +1 -1
  34. package/dist/components/viewers/svg-viewer/dompurify-loader.js +1 -1
  35. package/dist/internal/dompurify-loader.js +1 -1
  36. package/dist/internal/locale-loaders.generated.js +1 -1
  37. package/dist/internal/map-scene-layer-runtime.js +1 -1
  38. package/dist/internal/media-panorama.js +1 -1
  39. package/dist/internal/package-metadata.js +1 -1
  40. package/dist/internal/papaparse-loader.js +1 -1
  41. package/dist/theme/theme.js +1 -1
  42. package/dist/theme-core.css +1 -0
  43. package/dist/utilities/scoped-registry.js +1 -1
  44. package/llms/peers.md +1 -1
  45. package/llms/shared/ai-and-peers.md +34 -0
  46. package/llms/shared/imports-and-registration.md +2 -0
  47. package/llms/shared/styles-and-tokens.md +47 -1
  48. package/llms/shared.md +83 -1
  49. package/package.json +10 -7
@@ -1,4 +1,4 @@
1
- import{__decorate}from"tslib";import{html,nothing}from"lit";import{property,state}from"lit/decorators.js";import{createRef,ref}from"lit/directives/ref.js";import{styleMap}from"lit/directives/style-map.js";import{LyraElement}from"../../../internal/lyra-element.js";import{DEFAULT_CANVAS_COLOR}from"../../../internal/canvas-color.js";import{isAbortError,isResourceLimitError,LyraUserFacingError,readResponseArrayBuffer,resolveOwnerFetchTarget}from"../../../internal/resource-loader.js";import{srOnly}from"../../../internal/a11y.js";import{shadowFocusTarget}from"../../../internal/active-element.js";import{sanitizeCssLength}from"../../../internal/safe-css.js";import{getOwnDataDescriptor,isObjectValue,MISSING_OWN_DATA_DESCRIPTOR,UNSAFE_OWN_DATA_DESCRIPTOR}from"../../../internal/data-descriptors.js";import{DocumentAnchorTarget,prioritizedHighlightCandidates}from"../../../internal/anchor-target.js";import{textQuoteContextScore}from"../document-viewer/anchors.js";import{getEpubJs}from"./ebook-loader.js";import{assertEpubArchiveWithinLimits}from"./epub-resource-guard.js";import{styles}from"./ebook-viewer.styles.js";import{ViewerAnnouncementController}from"../viewer-announcements.js";import{viewerSemanticLabel,viewerSemanticRole}from"../viewer-semantic-owner.js";import{renderViewerLoading,viewerLoadingStyles}from"../viewer-loading.js";import{renderViewerPagerButton,viewerPagerStyles}from"../viewer-pager.js";import{ThemeWatcher}from"../../../internal/theme-watcher.js";import{boundedViewerSearchQuery,ViewerSearchWorkBudget,VIEWER_SEARCH_QUERY_LIMIT}from"../viewer-search-limits.js";import{boundedSelectionRects,boundedSelectionText}from"../../../internal/text-quote.js";import{LYRA_DEFAULT_anchorJumped,LYRA_DEFAULT_anchorJumpedToPage,LYRA_DEFAULT_anchorNotFound,LYRA_DEFAULT_documentPreviewEmpty}from"../../../internal/default-strings/shared.generated.js";import{LYRA_DEFAULT_documentPreviewResourceTooLarge,LYRA_DEFAULT_documentPreviewTypeDocument,LYRA_DEFAULT_documentPreviewUrlNotAllowed,LYRA_DEFAULT_ebookViewerLoadError,LYRA_DEFAULT_ebookViewerMissingLibrary,LYRA_DEFAULT_ebookViewerNextChapter,LYRA_DEFAULT_ebookViewerPreviousChapter,LYRA_DEFAULT_ebookViewerRegionLabel,LYRA_DEFAULT_loadingDocument}from"../../../internal/default-strings/viewers.generated.js";const MAX_TOC_ITEMS=1e4,MAX_TOC_DEPTH=100,MAX_SEARCH_MATCHES=1e4,MAX_SEARCH_SPINE_ITEMS=1e3,MAX_FIND_RESULTS=1e4,MAX_PAINTED_HIGHLIGHTS=100,MAX_PEER_PROTOTYPES=100;function isArrayValue(value){try{return Array.isArray(value)}catch{return!1}}function inheritedDataDescriptor(value,key){let current=value;for(let depth=0;current&&depth<MAX_PEER_PROTOTYPES;depth+=1){let descriptor;try{descriptor=Object.getOwnPropertyDescriptor(current,key)}catch{return}if(descriptor)return"value"in descriptor?descriptor:void 0;try{current=Object.getPrototypeOf(current)}catch{return}}}function inheritedDataValue(value,key){return isObjectValue(value)?inheritedDataDescriptor(value,key)?.value:void 0}function savedCallable(value,key){if(!isObjectValue(value))return;const candidate=inheritedDataDescriptor(value,key)?.value;if(typeof candidate=="function")return(...args)=>Reflect.apply(candidate,value,args)}function savedThenable(value){const then=savedCallable(value,"then");if(then)return new Promise((resolve,reject)=>{try{then(()=>resolve(),reject)}catch(error){reject(error)}})}function taskFrom(call,...args){try{return savedThenable(call(...args))??Promise.resolve()}catch(error){return Promise.reject(error)}}function awaitPeerResult(value){const then=savedCallable(value,"then"),wrap=resolved=>Object.freeze({value:resolved});return then?new Promise((resolve,reject)=>{try{then(resolved=>resolve(wrap(resolved)),reject)}catch(error){reject(error)}}):Promise.resolve(wrap(value))}function quoteContextScore(excerpt,quote,prefix,suffix){const text=excerpt.replace(/\s+/g," ").toLowerCase(),needle=quote.replace(/\s+/g," ").toLowerCase();let best=0;for(let at=text.indexOf(needle);at>=0;at=text.indexOf(needle,at+1))best=Math.max(best,textQuoteContextScore(text,at,at+needle.length,prefix,suffix));return best}const EPUB_CHAPTER_CONTENT_SECURITY_POLICY="default-src 'none'; img-src blob: data:; media-src blob: data:; font-src blob: data:; style-src blob: 'unsafe-inline'";function silenceChapterNetwork(chapter){const root=chapter.documentElement;if(!root)return;for(const node of[...chapter.childNodes])node.nodeType===Node.PROCESSING_INSTRUCTION_NODE&&chapter.removeChild(node);for(const element of[...chapter.querySelectorAll("link, meta")]){const rel=` ${(element.getAttribute("rel")??"").toLowerCase()} `;(/ (?:dns-prefetch|preconnect) /.test(rel)||(element.getAttribute("http-equiv")??"").trim().toLowerCase()==="refresh")&&element.remove()}const namespace=root.namespaceURI??"http://www.w3.org/1999/xhtml";let head=chapter.querySelector("head");head||(head=chapter.createElementNS(namespace,"head"),root.insertBefore(head,root.firstChild));const policy=chapter.createElementNS(namespace,"meta");policy.setAttribute("http-equiv","Content-Security-Policy"),policy.setAttribute("content",EPUB_CHAPTER_CONTENT_SECURITY_POLICY),head.insertBefore(policy,head.firstChild)}function registerNetworkSilentChapters(book){const contentHooks=inheritedDataValue(inheritedDataValue(book.spine,"hooks"),"content");savedCallable(contentHooks,"register")?.(silenceChapterNetwork)}function normalizeBook(value){if(!isObjectValue(value))return;const ready=savedThenable(inheritedDataValue(value,"ready")),renderTo=savedCallable(value,"renderTo"),destroy=savedCallable(value,"destroy");if(!ready||!renderTo||!destroy)return;let navigationCaptured=!1,navigation;const getNavigation=()=>(navigationCaptured||(navigationCaptured=!0,navigation=inheritedDataValue(value,"navigation")),navigation),spine=inheritedDataValue(value,"spine"),load=savedCallable(value,"load");return Object.freeze({ready,...spine===void 0?{}:{spine},...load===void 0?{}:{load},getNavigation,renderTo:(element,options)=>renderTo(element,options),destroy:()=>{destroy()}})}function normalizeRendition(value){if(!isObjectValue(value))return;const display=savedCallable(value,"display"),prev=savedCallable(value,"prev"),next=savedCallable(value,"next"),on=savedCallable(value,"on"),annotationsValue=inheritedDataValue(value,"annotations"),highlight=savedCallable(annotationsValue,"highlight"),remove=savedCallable(annotationsValue,"remove");if(!(!display||!prev||!next||!on||!highlight||!remove))return Object.freeze({display:target=>taskFrom(display,target),prev:()=>taskFrom(prev),next:()=>taskFrom(next),on:(type,callback)=>{on(type,callback)},annotations:Object.freeze({highlight:(cfi,data,callback,className,styles2)=>highlight(cfi,data,callback,className,styles2),remove:(cfi,type)=>{remove(cfi,type)}})})}function normalizeSpineItem(value){const load=savedCallable(value,"load"),find=savedCallable(value,"find"),unload=savedCallable(value,"unload");if(!(!load||!find||!unload))return Object.freeze({load:request=>load(request),find:query=>find(query),unload:()=>{unload()}})}function projectSpineItems(book){const spineItems=inheritedDataValue(book.spine,"spineItems");if(!isArrayValue(spineItems))return Object.freeze({items:Object.freeze([]),exact:spineItems===void 0});const length=getOwnDataDescriptor(spineItems,"length");if(length===MISSING_OWN_DATA_DESCRIPTOR||length===UNSAFE_OWN_DATA_DESCRIPTOR||typeof length.value!="number"||!Number.isSafeInteger(length.value)||length.value<0)return Object.freeze({items:Object.freeze([]),exact:!1});const items=[];let exact=length.value<=MAX_SEARCH_SPINE_ITEMS;const count=Math.min(length.value,MAX_SEARCH_SPINE_ITEMS);for(let index=0;index<count;index+=1){const descriptor=getOwnDataDescriptor(spineItems,String(index));if(descriptor===MISSING_OWN_DATA_DESCRIPTOR||descriptor===UNSAFE_OWN_DATA_DESCRIPTOR){exact=!1;continue}const item=normalizeSpineItem(descriptor.value);if(!item){exact=!1;continue}items.push(item)}return Object.freeze({items:Object.freeze(items),exact})}function projectFindResults(value,work){if(!isArrayValue(value))return Object.freeze({matches:Object.freeze([]),exact:!1});const length=getOwnDataDescriptor(value,"length");if(length===MISSING_OWN_DATA_DESCRIPTOR||length===UNSAFE_OWN_DATA_DESCRIPTOR||typeof length.value!="number"||!Number.isSafeInteger(length.value)||length.value<0)return Object.freeze({matches:Object.freeze([]),exact:!1});const matches=[];let exact=length.value<=MAX_FIND_RESULTS;const count=Math.min(length.value,MAX_FIND_RESULTS);for(let index=0;index<count;index+=1){const descriptor=getOwnDataDescriptor(value,String(index));if(descriptor===MISSING_OWN_DATA_DESCRIPTOR||descriptor===UNSAFE_OWN_DATA_DESCRIPTOR||!isObjectValue(descriptor.value)){exact=!1;continue}const cfi=getOwnDataDescriptor(descriptor.value,"cfi"),excerpt=getOwnDataDescriptor(descriptor.value,"excerpt");if(cfi===MISSING_OWN_DATA_DESCRIPTOR||cfi===UNSAFE_OWN_DATA_DESCRIPTOR||typeof cfi.value!="string"){exact=!1;continue}if(!work.canConsume(cfi.value)||!work.consume(cfi.value)||cfi.value.trim()===""){exact=!1;continue}let excerptValue="";excerpt!==MISSING_OWN_DATA_DESCRIPTOR&&(excerpt===UNSAFE_OWN_DATA_DESCRIPTOR||typeof excerpt.value!="string"||!work.canConsume(excerpt.value)||!work.consume(excerpt.value)?exact=!1:excerptValue=excerpt.value),matches.push({cfi:cfi.value,excerpt:excerptValue})}return Object.freeze({matches:Object.freeze(matches),exact})}function pushTocEntries(value,level,budget,stack){if(!isArrayValue(value)||budget.positions>=MAX_TOC_ITEMS)return;const length=getOwnDataDescriptor(value,"length");if(length===MISSING_OWN_DATA_DESCRIPTOR||length===UNSAFE_OWN_DATA_DESCRIPTOR||typeof length.value!="number"||!Number.isSafeInteger(length.value)||length.value<0)return;const count=Math.min(length.value,MAX_TOC_ITEMS-budget.positions);for(let index=count-1;index>=0;index-=1){budget.positions+=1;const descriptor=getOwnDataDescriptor(value,String(index));descriptor===MISSING_OWN_DATA_DESCRIPTOR||descriptor===UNSAFE_OWN_DATA_DESCRIPTOR||stack.push({value:descriptor.value,level})}}function projectToc(value){const budget={positions:0,nodes:0,seen:new WeakSet},stack=[];pushTocEntries(value,1,budget,stack);const items=[];for(;stack.length>0&&budget.nodes<MAX_TOC_ITEMS;){const current=stack.pop();if(!isObjectValue(current.value)||budget.seen.has(current.value))continue;budget.seen.add(current.value),budget.nodes+=1;const href=getOwnDataDescriptor(current.value,"href"),id=getOwnDataDescriptor(current.value,"id"),label=getOwnDataDescriptor(current.value,"label"),children=getOwnDataDescriptor(current.value,"subitems");if(href!==MISSING_OWN_DATA_DESCRIPTOR&&href!==UNSAFE_OWN_DATA_DESCRIPTOR&&typeof href.value=="string"){const idValue=id!==MISSING_OWN_DATA_DESCRIPTOR&&id!==UNSAFE_OWN_DATA_DESCRIPTOR&&typeof id.value=="string"&&id.value!==""?id.value:href.value,labelValue=label!==MISSING_OWN_DATA_DESCRIPTOR&&label!==UNSAFE_OWN_DATA_DESCRIPTOR&&typeof label.value=="string"?label.value.trim():"";items.push({id:idValue,label:labelValue,href:href.value,level:current.level})}current.level<MAX_TOC_DEPTH&&children!==MISSING_OWN_DATA_DESCRIPTOR&&children!==UNSAFE_OWN_DATA_DESCRIPTOR&&pushTocEntries(children.value,current.level+1,budget,stack)}return Object.freeze(items)}const TONE_FILL_TOKEN={accent:{token:"--lr-color-brand-quiet",fallback:"#ddf4ff"},success:{token:"--lr-color-success-quiet",fallback:"#dafbe1"},warning:{token:"--lr-color-warning-quiet",fallback:"#fff8c5"},danger:{token:"--lr-color-danger-quiet",fallback:"#ffebe9"},neutral:{token:"--lr-color-surface-raised",fallback:"#f6f8fa"}},SEARCH_MATCH_FILL_TOKEN={token:"--lr-color-warning",fallback:"#9a6700"},ACTIVE_HIGHLIGHT_STROKE_TOKEN={token:"--lr-focus-ring-color",fallback:DEFAULT_CANVAS_COLOR};class LyraEbookViewerBase extends LyraElement{}class LyraEbookViewer extends DocumentAnchorTarget(LyraEbookViewerBase){static{this.defaultStrings={...super.defaultStrings,anchorJumped:LYRA_DEFAULT_anchorJumped,anchorJumpedToPage:LYRA_DEFAULT_anchorJumpedToPage,anchorNotFound:LYRA_DEFAULT_anchorNotFound,documentPreviewEmpty:LYRA_DEFAULT_documentPreviewEmpty,documentPreviewResourceTooLarge:LYRA_DEFAULT_documentPreviewResourceTooLarge,documentPreviewTypeDocument:LYRA_DEFAULT_documentPreviewTypeDocument,documentPreviewUrlNotAllowed:LYRA_DEFAULT_documentPreviewUrlNotAllowed,ebookViewerLoadError:LYRA_DEFAULT_ebookViewerLoadError,ebookViewerMissingLibrary:LYRA_DEFAULT_ebookViewerMissingLibrary,ebookViewerNextChapter:LYRA_DEFAULT_ebookViewerNextChapter,ebookViewerPreviousChapter:LYRA_DEFAULT_ebookViewerPreviousChapter,ebookViewerRegionLabel:LYRA_DEFAULT_ebookViewerRegionLabel,loadingDocument:LYRA_DEFAULT_loadingDocument}}static{this.styles=[LyraElement.styles,styles,viewerPagerStyles,srOnly,viewerLoadingStyles]}constructor(){super(),this.src="",this.name="",this.maxHeight="",this.location="",this.anchorKinds=["cfi","text-quote"],this.ebookState={kind:"idle"},this.searchMatches=[],this.searchMatchCountExact=!0,this.searchActiveIndex=-1,this.mountRef=createRef(),this.generation=0,this.failedGeneration=-1,this.searchQuery="",this.lastSearchLocale="",this.searchGeneration=0,this.pendingSearchResetEvent=!1,this.anchorOperationGeneration=0,this.paintedHighlightCfis=[],this.announcements=new ViewerAnnouncementController(this),this.chapterButtonFocused=!1,this.previous=()=>{this.runRenditionNavigation("previous")},this.next=()=>{this.runRenditionNavigation("next")},new ThemeWatcher(this,()=>this.repaintAnnotations())}updated(changed){if(super.updated(changed),this.chapterButtonFocused&&this.ebookState.kind!=="ready"&&this.shadowRoot?.querySelector('[part="mount"]')?.focus(),this.chapterButtonFocused=!1,this.announcements.transition("load",this.ebookState.kind,this.ebookState.kind==="error"?this.ebookState.message:this.localize("loadingDocument")),changed.has("src")&&this.scheduleAfterUpdate(()=>{this.load()}),changed.has("src")&&this.pendingSearchResetEvent&&(this.pendingSearchResetEvent=!1,this.emitSearchChange()),changed.has("location")){const fromRelocated=this.relocatedLocation===this.location;this.relocatedLocation=void 0,!fromRelocated&&this.rendition&&this.location&&this.displayLocation(this.location)}(changed.has("highlights")||changed.has("activeHighlightId"))&&this.rendition&&this.repaintAnnotations();const locale=this.effectiveLocale;if(locale!==this.lastSearchLocale){const shouldRecompute=this.searchQuery!=="";this.lastSearchLocale=locale,shouldRecompute&&this.scheduleAfterUpdate(()=>{this.search(this.searchQuery)},"search")}}willUpdate(changed){super.willUpdate(changed);const active=shadowFocusTarget(this);this.chapterButtonFocused=active?.localName==="button"&&!active.disabled&&active.getAttribute("part")?.endsWith("-button")===!0,changed.has("src")&&(this.pendingSearchResetEvent||=this.hasSearchState(),this.resetSearchState())}connectedCallback(){super.connectedCallback(),this.announcements.connect(),this.hasUpdated&&this.src.trim()&&this.scheduleAfterUpdate(()=>{this.load()})}disconnectedCallback(){this.generation++,this.anchorOperationGeneration++,this.announcements.disconnect(),this.teardown(),this.ebookState={kind:"idle"},super.disconnectedCallback()}connectedMoveCallback(){}adoptedCallback(){super.adoptedCallback(),this.announcements.adopted()}teardown(){const shouldEmitSearchReset=this.hasSearchState();this.destroyBook(this.book),this.book=void 0,this.rendition=void 0,this.resetSearchState(),this.paintedHighlightCfis=[],shouldEmitSearchReset&&this.isConnected&&this.emitSearchChange()}destroyBook(book){try{book?.destroy()}catch{}}isCurrentLoad(generation,ownerView){return this.isConnected&&generation===this.generation&&this.ownerDocument.defaultView===ownerView}isCurrentBookRendition(generation,ownerView,book,rendition){return this.isConnected&&generation===this.generation&&this.ownerDocument.defaultView===ownerView&&this.book===book&&this.rendition===rendition}failCurrentLoad(error,message=this.localize("ebookViewerLoadError")){this.failedGeneration!==this.generation&&(this.failedGeneration=this.generation,this.ebookState={kind:"error",message},this.emit("lr-render-error",{error}))}hasSearchState(){return this.searchQuery!==""||this.searchMatches.length>0||!this.searchMatchCountExact||this.searchActiveIndex!==-1}resetSearchState(){this.searchGeneration++,this.searchQuery="",this.searchMatches=[],this.searchMatchCountExact=!0,this.searchActiveIndex=-1,this.searchAnnotationCfi=void 0}async load(){const generation=++this.generation,signal=this.beginAbortableLoad();if(this.teardown(),!this.src.trim()){this.ebookState={kind:"idle"};return}const fetchTarget=resolveOwnerFetchTarget(this,this.src);if(!fetchTarget){this.failWithLocalizedMessage(this.localize("documentPreviewUrlNotAllowed"));return}this.ebookState={kind:"loading"};let data,factory;try{if([data,factory]=await Promise.all([fetchTarget.view.fetch(fetchTarget.url,signal?{signal}:void 0).then(response=>{if(!response.ok)throw new Error(`${response.status} ${response.statusText}`);return readResponseArrayBuffer(response)}),getEpubJs()]),!this.isCurrentLoad(generation,fetchTarget.view)||(await assertEpubArchiveWithinLimits(data,void 0,void 0,{signal}),!this.isCurrentLoad(generation,fetchTarget.view)))return}catch(error){if(isAbortError(error)||!this.isCurrentLoad(generation,fetchTarget.view))return;this.failCurrentLoad(error,this.localize(isResourceLimitError(error)?"documentPreviewResourceTooLarge":"ebookViewerLoadError"));return}if(!factory){this.failWithLocalizedMessage(this.localize("ebookViewerMissingLibrary"));return}const mount=this.mountRef.value;if(!mount){this.failWithLocalizedMessage(this.localize("ebookViewerLoadError"));return}let candidateBook;try{const book=normalizeBook(factory(data));if(!book)throw new Error("EPUB peer returned an unusable book.");candidateBook=book,registerNetworkSilentChapters(book);const rendition=normalizeRendition(book.renderTo(mount,{width:"100%",height:"100%"}));if(!rendition)throw new Error("EPUB peer returned an unusable rendition.");if(await book.ready,!this.isCurrentLoad(generation,fetchTarget.view)){this.destroyBook(book),candidateBook=void 0;return}if(book.getNavigation(),await rendition.display(this.location||void 0),!this.isCurrentLoad(generation,fetchTarget.view)){this.destroyBook(book),candidateBook=void 0;return}rendition.on("relocated",loc=>{if(!this.isCurrentBookRendition(generation,fetchTarget.view,book,rendition))return;const start=inheritedDataValue(loc,"start"),cfi=inheritedDataValue(start,"cfi"),href=inheritedDataValue(start,"href");typeof cfi!="string"||cfi.trim()===""||!cfi||cfi===this.location||(this.relocatedLocation=cfi,this.location=cfi,this.emit("lr-location-change",{cfi,href:typeof href=="string"?href:""}))}),rendition.on("selected",(cfiRange,contents)=>{if(!(!this.isCurrentBookRendition(generation,fetchTarget.view,book,rendition)||typeof cfiRange!="string"))try{const contentsWindow=inheritedDataValue(contents,"window"),selection=savedCallable(contentsWindow,"getSelection")?.(),range=this.selectedRange(selection);if(!range)return;const text=boundedSelectionText(range);if(!text)return;const rects=this.translateSelectionRects(boundedSelectionRects(range),contentsWindow);this.emit("lr-text-select",{text,anchor:{kind:"cfi",cfi:cfiRange},rects})}catch{}}),this.book=book,this.rendition=rendition,candidateBook=void 0,this.ebookState={kind:"ready"},this.repaintAnnotations()}catch(error){if(this.destroyBook(candidateBook),isAbortError(error)||!this.isCurrentLoad(generation,fetchTarget.view))return;this.failCurrentLoad(error)}}selectedRange(selection){const prototype=this.ownerDocument.defaultView?.Selection.prototype;if(prototype)try{const count2=Object.getOwnPropertyDescriptor(prototype,"rangeCount")?.get?.call(selection);if(typeof count2=="number")return count2>0?prototype.getRangeAt.call(selection,0):null}catch{}const count=inheritedDataValue(selection,"rangeCount"),getRangeAt=savedCallable(selection,"getRangeAt");return typeof count=="number"&&count>0&&getRangeAt?getRangeAt(0):null}failWithLocalizedMessage(message){const error=new LyraUserFacingError(message);this.failCurrentLoad(error,message)}reportRenditionFailure(error,rendition,generation,ownerView=this.ownerDocument.defaultView){!this.isConnected||generation!==this.generation||this.ownerDocument.defaultView!==ownerView||rendition!==this.rendition||this.failCurrentLoad(error)}translateSelectionRects(rects,sourceWindow){const ownerWindow=this.ownerDocument.defaultView;if(!ownerWindow||!sourceWindow)return[];const translated=[];for(const rect of rects){let x=Number(rect.x??rect.left),y=Number(rect.y??rect.top),width=Number(rect.width),height=Number(rect.height);if(![x,y,width,height].every(Number.isFinite))continue;let current=sourceWindow,valid=!0;for(;current&&current!==ownerWindow;){if(!("frameElement"in current)){current=ownerWindow;break}let frameElement;try{frameElement=current.frameElement}catch{valid=!1;break}const frameWindow=frameElement?.ownerDocument.defaultView;if(!frameElement||!frameWindow||!(frameElement instanceof frameWindow.HTMLElement)){valid=!1;break}const frame=frameElement,frameRect=frame.getBoundingClientRect(),borderBoxWidth=frame.offsetWidth||frame.clientWidth,borderBoxHeight=frame.offsetHeight||frame.clientHeight,viewportWidth=current.innerWidth||frame.clientWidth,viewportHeight=current.innerHeight||frame.clientHeight;if(borderBoxWidth<=0||borderBoxHeight<=0||viewportWidth<=0||viewportHeight<=0){valid=!1;break}const borderScaleX=frameRect.width/borderBoxWidth,borderScaleY=frameRect.height/borderBoxHeight,contentScaleX=frame.clientWidth*borderScaleX/viewportWidth,contentScaleY=frame.clientHeight*borderScaleY/viewportHeight;x=frameRect.left+frame.clientLeft*borderScaleX+x*contentScaleX,y=frameRect.top+frame.clientTop*borderScaleY+y*contentScaleY,width*=contentScaleX,height*=contentScaleY,current=frame.ownerDocument.defaultView}!valid||current!==ownerWindow||translated.push(Object.freeze({x,y,width,height,top:y,right:x+width,bottom:y+height,left:x}))}return translated}displayLocation(location){const rendition=this.rendition;if(!rendition)return;const generation=this.generation,ownerView=this.ownerDocument.defaultView;if(ownerView)try{Promise.resolve(rendition.display(location)).catch(error=>{this.reportRenditionFailure(error,rendition,generation,ownerView)})}catch(error){this.reportRenditionFailure(error,rendition,generation,ownerView)}}runRenditionNavigation(action){const rendition=this.rendition;if(!rendition)return;const generation=this.generation,ownerView=this.ownerDocument.defaultView;if(ownerView)try{const task=action==="previous"?rendition.prev():rendition.next();Promise.resolve(task).catch(error=>{this.reportRenditionFailure(error,rendition,generation,ownerView)})}catch(error){this.reportRenditionFailure(error,rendition,generation,ownerView)}}async getToc(){const book=this.book,generation=this.generation,ownerView=this.ownerDocument.defaultView;if(!book||!ownerView)return[];try{await book.ready}catch{return[]}return!this.isCurrentLoad(generation,ownerView)||this.book!==book?[]:[...projectToc(inheritedDataValue(book.getNavigation(),"toc"))]}async scrollToAnchor(target){const operation=++this.anchorOperationGeneration,generation=this.generation,ownerView=this.ownerDocument.defaultView,book=this.book,rendition=this.rendition;try{return await Object.getPrototypeOf(LyraEbookViewer.prototype).performScrollToAnchor.call(this,target)}catch(error){return operation!==this.anchorOperationGeneration||!ownerView||!this.isCurrentLoad(generation,ownerView)||this.book!==book||this.rendition!==rendition||(rendition&&this.reportRenditionFailure(error,rendition,generation,ownerView),this.emit("lr-anchor-result",{found:!1})),!1}}async applyAnchor(anchor){const rendition=this.rendition,operation=this.anchorOperationGeneration,generation=this.generation,ownerView=this.ownerDocument.defaultView;if(!rendition||!ownerView)return!1;if(anchor.kind==="cfi")return operation!==this.anchorOperationGeneration||!this.isCurrentLoad(generation,ownerView)||rendition!==this.rendition?!1:(await rendition.display(anchor.cfi),operation===this.anchorOperationGeneration&&this.isCurrentLoad(generation,ownerView)&&rendition===this.rendition);if(anchor.kind==="text-quote"){const cfi=await this.findTextQuoteCfi(anchor);return!cfi||operation!==this.anchorOperationGeneration||!this.isCurrentLoad(generation,ownerView)||rendition!==this.rendition?!1:(await rendition.display(cfi),operation===this.anchorOperationGeneration&&this.isCurrentLoad(generation,ownerView)&&rendition===this.rendition)}return!1}async findTextQuoteCfi(anchor){const book=this.book,generation=this.generation,ownerView=this.ownerDocument.defaultView,quote=anchor.quote.trim(),boundedQuery=boundedViewerSearchQuery(quote,this.effectiveLocale);if(!book||!ownerView||!boundedQuery.accepted||!boundedQuery.needle)return null;const fullContextScore=(anchor.prefix?.trim()?1:0)+(anchor.suffix?.trim()?1:0);let bestMatch=null,bestScore=-1;const work=new ViewerSearchWorkBudget,spine=projectSpineItems(book);for(const item of spine.items){if(!work.consume(""))return bestMatch;let loaded=!1;try{if(await awaitPeerResult(item.load(book.load)),loaded=!0,!this.isCurrentLoad(generation,ownerView)||this.book!==book)return null;const{value:rawResults}=await awaitPeerResult(item.find(quote)),results=projectFindResults(rawResults,work);if(!this.isCurrentLoad(generation,ownerView)||this.book!==book)return null;for(const result of results.matches){if(!work.consume(""))return bestMatch;const score=fullContextScore===0?0:quoteContextScore(result.excerpt,quote,anchor.prefix,anchor.suffix);if(score===fullContextScore)return result.cfi;score>bestScore&&(bestMatch=result.cfi,bestScore=score)}}catch{continue}finally{if(loaded)try{item.unload()}catch{}}}return bestMatch}repaintHighlights(){const rendition=this.rendition;if(!rendition)return;const book=this.book,generation=this.generation,ownerView=this.ownerDocument.defaultView,work=new ViewerSearchWorkBudget;for(const cfi of this.paintedHighlightCfis){if(!work.consume(cfi))break;rendition.annotations.remove(cfi,"highlight")}this.paintedHighlightCfis=[];let painted=0;const fillCache=new Map,resolveFill=pair=>{let value=fillCache.get(pair.token);return value===void 0&&(value=this.resolveHighlightFill(pair).fill,fillCache.set(pair.token,value)),value};for(const highlight of prioritizedHighlightCandidates(this.highlights,this.activeHighlightId)){if(highlight.anchor.kind!=="cfi")continue;if(painted>=MAX_PAINTED_HIGHLIGHTS)break;const cfi=highlight.anchor.cfi.trim();if(!cfi||cfi.length>VIEWER_SEARCH_QUERY_LIMIT||!work.consume(cfi))continue;const tone=highlight.tone??"accent",active=highlight.id===this.activeHighlightId,styles2={fill:resolveFill(TONE_FILL_TOKEN[tone])};if(active){const forcedColors=this.ownerDocument.defaultView?.matchMedia?.("(forced-colors: active)").matches??!1;styles2.stroke=forcedColors?"CanvasText":resolveFill(ACTIVE_HIGHLIGHT_STROKE_TOKEN),styles2["stroke-width"]="3",styles2["stroke-dasharray"]="2 1"}rendition.annotations.highlight(cfi,{id:highlight.id},()=>{!book||!ownerView||!this.isCurrentBookRendition(generation,ownerView,book,rendition)||this.emit("lr-highlight-activate",{highlightId:highlight.id})},active?`lr-hl-${tone} lr-ebook-highlight-active`:`lr-hl-${tone}`,styles2),this.paintedHighlightCfis.push(cfi),painted++}}repaintSearchAnnotation(){const rendition=this.rendition,cfi=this.searchAnnotationCfi;!rendition||!cfi||(rendition.annotations.remove(cfi,"highlight"),rendition.annotations.highlight(cfi,{},void 0,"lr-ebook-search",this.resolveHighlightFill(SEARCH_MATCH_FILL_TOKEN)))}repaintAnnotations(){const rendition=this.rendition;if(rendition)try{this.repaintHighlights(),this.repaintSearchAnnotation()}catch(error){this.reportRenditionFailure(error,rendition,this.generation)}}async search(query){const generation=++this.searchGeneration,ownerView=this.ownerDocument.defaultView,boundedQuery=boundedViewerSearchQuery(query,this.effectiveLocale);if(this.searchQuery=query,this.lastSearchLocale=this.effectiveLocale,this.clearSearchAnnotation(),!boundedQuery.accepted)return this.searchMatches=[],this.searchMatchCountExact=!1,this.searchActiveIndex=-1,this.emitSearchChange(),0;if(!this.book||!ownerView||!boundedQuery.needle)return this.searchMatches=[],this.searchMatchCountExact=!0,this.searchActiveIndex=-1,this.emitSearchChange(),0;const matches=[];let matchCountExact=!0,matchCeilingExceeded=!1;const book=this.book,work=new ViewerSearchWorkBudget,spine=projectSpineItems(book);spine.exact||(matchCountExact=!1);for(const item of spine.items){if(generation!==this.searchGeneration||this.ownerDocument.defaultView!==ownerView||!this.isConnected)return this.searchMatches.length;if(!work.consume("")){matchCountExact=!1;break}let loaded=!1;try{if(await awaitPeerResult(item.load(book.load)),loaded=!0,generation!==this.searchGeneration||this.ownerDocument.defaultView!==ownerView||!this.isConnected||this.book!==book)return this.searchMatches.length;const{value:rawResults}=await awaitPeerResult(item.find(query.trim())),results=projectFindResults(rawResults,work);if(generation!==this.searchGeneration||this.ownerDocument.defaultView!==ownerView||!this.isConnected||this.book!==book)return this.searchMatches.length;results.exact||(matchCountExact=!1);for(const r of results.matches){if(!work.consume("")){matchCountExact=!1,matchCeilingExceeded=!0;break}if(matches.length===MAX_SEARCH_MATCHES){matchCountExact=!1,matchCeilingExceeded=!0;break}matches.push(r)}}catch{matchCountExact=!1;continue}finally{if(loaded)try{item.unload()}catch{matchCountExact=!1}}if(matchCeilingExceeded)break}return generation!==this.searchGeneration||this.ownerDocument.defaultView!==ownerView||!this.isConnected||this.book!==book?this.searchMatches.length:(this.searchMatches=matches,this.searchMatchCountExact=matchCountExact,this.searchActiveIndex=matches.length>0?0:-1,this.emitSearchChange(),this.searchActiveIndex>=0&&await this.showSearchMatch(this.searchActiveIndex,generation,ownerView),matches.length)}async searchNext(){if(!this.searchMatches.length)return!1;const generation=++this.searchGeneration;return this.searchActiveIndex=(this.searchActiveIndex+1)%this.searchMatches.length,this.emitSearchChange(),this.showSearchMatch(this.searchActiveIndex,generation)}async searchPrevious(){if(!this.searchMatches.length)return!1;const generation=++this.searchGeneration;return this.searchActiveIndex=(this.searchActiveIndex-1+this.searchMatches.length)%this.searchMatches.length,this.emitSearchChange(),this.showSearchMatch(this.searchActiveIndex,generation)}clearSearch(){this.searchGeneration++,this.searchQuery="",this.searchMatches=[],this.searchMatchCountExact=!0,this.searchActiveIndex=-1,this.clearSearchAnnotation(),this.emit("lr-search-change",{query:"",matchCount:0,matchCountExact:!0,activeIndex:-1})}clearSearchAnnotation(){const cfi=this.searchAnnotationCfi;this.searchAnnotationCfi=void 0;const rendition=this.rendition,generation=this.generation,ownerView=this.ownerDocument.defaultView;if(!(!cfi||!rendition||!ownerView))try{rendition.annotations.remove(cfi,"highlight")}catch(error){this.reportRenditionFailure(error,rendition,generation,ownerView)}}async showSearchMatch(index,generation=this.searchGeneration,ownerView=this.ownerDocument.defaultView){const match=this.searchMatches[index],rendition=this.rendition;if(!match||!rendition||generation!==this.searchGeneration||!ownerView||!this.isConnected||this.ownerDocument.defaultView!==ownerView)return!1;this.clearSearchAnnotation();try{await rendition.display(match.cfi)}catch(error){return generation===this.searchGeneration&&rendition===this.rendition&&this.ownerDocument.defaultView===ownerView&&this.reportRenditionFailure(error,rendition,this.generation,ownerView),!1}if(generation!==this.searchGeneration||rendition!==this.rendition||this.searchMatches[index]!==match||!this.isConnected||this.ownerDocument.defaultView!==ownerView)return!1;try{rendition.annotations.highlight(match.cfi,{},void 0,"lr-ebook-search",this.resolveHighlightFill(SEARCH_MATCH_FILL_TOKEN))}catch(error){return this.reportRenditionFailure(error,rendition,this.generation,ownerView),!1}return this.searchAnnotationCfi=match.cfi,!0}emitSearchChange(){this.emit("lr-search-change",{query:this.searchQuery,matchCount:this.searchMatches.length,matchCountExact:this.searchMatchCountExact,activeIndex:this.searchActiveIndex})}resolveHighlightFill({token,fallback}){return{fill:(this.ownerDocument.defaultView?.getComputedStyle(this).getPropertyValue(token).trim()??"")||fallback}}renderStatus(){return this.ebookState.kind==="loading"?renderViewerLoading(this.localize("loadingDocument")):this.ebookState.kind==="error"?html`<div part="error">${this.ebookState.message}</div>`:this.ebookState.kind==="idle"?html`<p class="status-note">${this.localize("documentPreviewEmpty",void 0,{type:this.localize("documentPreviewTypeDocument")})}</p>`:nothing}render(){const maxHeight=sanitizeCssLength(this.maxHeight),disabled=this.ebookState.kind!=="ready";return html`
1
+ import{__decorate}from"tslib";import{html,nothing}from"lit";import{property,state}from"lit/decorators.js";import{createRef,ref}from"lit/directives/ref.js";import{styleMap}from"lit/directives/style-map.js";import{LyraElement}from"../../../internal/lyra-element.js";import{DEFAULT_CANVAS_COLOR}from"../../../internal/canvas-color.js";import{isAbortError,isResourceLimitError,LyraUserFacingError,readResponseArrayBuffer,resolveOwnerFetchTarget}from"../../../internal/resource-loader.js";import{srOnly}from"../../../internal/a11y.js";import{shadowFocusTarget}from"../../../internal/active-element.js";import{sanitizeCssLength}from"../../../internal/safe-css.js";import{getOwnDataDescriptor,isObjectValue,MISSING_OWN_DATA_DESCRIPTOR,UNSAFE_OWN_DATA_DESCRIPTOR}from"../../../internal/data-descriptors.js";import{DocumentAnchorTarget,prioritizedHighlightCandidates}from"../../../internal/anchor-target.js";import{textQuoteContextScore}from"../document-viewer/anchors.js";import{getEpubJs}from"./ebook-loader.js";import{assertEpubArchiveWithinLimits}from"./epub-resource-guard.js";import{guardEpubUnloadListener}from"./epub-unload-guard.js";import{styles}from"./ebook-viewer.styles.js";import{ViewerAnnouncementController}from"../viewer-announcements.js";import{viewerSemanticLabel,viewerSemanticRole}from"../viewer-semantic-owner.js";import{renderViewerLoading,viewerLoadingStyles}from"../viewer-loading.js";import{renderViewerPagerButton,viewerPagerStyles}from"../viewer-pager.js";import{ThemeWatcher}from"../../../internal/theme-watcher.js";import{boundedViewerSearchQuery,ViewerSearchWorkBudget,VIEWER_SEARCH_QUERY_LIMIT}from"../viewer-search-limits.js";import{boundedSelectionRects,boundedSelectionText}from"../../../internal/text-quote.js";import{LYRA_DEFAULT_anchorJumped,LYRA_DEFAULT_anchorJumpedToPage,LYRA_DEFAULT_anchorNotFound,LYRA_DEFAULT_documentPreviewEmpty}from"../../../internal/default-strings/shared.generated.js";import{LYRA_DEFAULT_documentPreviewResourceTooLarge,LYRA_DEFAULT_documentPreviewTypeDocument,LYRA_DEFAULT_documentPreviewUrlNotAllowed,LYRA_DEFAULT_ebookViewerLoadError,LYRA_DEFAULT_ebookViewerMissingLibrary,LYRA_DEFAULT_ebookViewerNextChapter,LYRA_DEFAULT_ebookViewerPreviousChapter,LYRA_DEFAULT_ebookViewerRegionLabel,LYRA_DEFAULT_loadingDocument}from"../../../internal/default-strings/viewers.generated.js";const MAX_TOC_ITEMS=1e4,MAX_TOC_DEPTH=100,MAX_SEARCH_MATCHES=1e4,MAX_SEARCH_SPINE_ITEMS=1e3,MAX_FIND_RESULTS=1e4,MAX_PAINTED_HIGHLIGHTS=100,MAX_PEER_PROTOTYPES=100;function isArrayValue(value){try{return Array.isArray(value)}catch{return!1}}function inheritedDataDescriptor(value,key){let current=value;for(let depth=0;current&&depth<MAX_PEER_PROTOTYPES;depth+=1){let descriptor;try{descriptor=Object.getOwnPropertyDescriptor(current,key)}catch{return}if(descriptor)return"value"in descriptor?descriptor:void 0;try{current=Object.getPrototypeOf(current)}catch{return}}}function inheritedDataValue(value,key){return isObjectValue(value)?inheritedDataDescriptor(value,key)?.value:void 0}function savedCallable(value,key){if(!isObjectValue(value))return;const candidate=inheritedDataDescriptor(value,key)?.value;if(typeof candidate=="function")return(...args)=>Reflect.apply(candidate,value,args)}function savedThenable(value){const then=savedCallable(value,"then");if(then)return new Promise((resolve,reject)=>{try{then(()=>resolve(),reject)}catch(error){reject(error)}})}function taskFrom(call,...args){try{return savedThenable(call(...args))??Promise.resolve()}catch(error){return Promise.reject(error)}}function awaitPeerResult(value){const then=savedCallable(value,"then"),wrap=resolved=>Object.freeze({value:resolved});return then?new Promise((resolve,reject)=>{try{then(resolved=>resolve(wrap(resolved)),reject)}catch(error){reject(error)}}):Promise.resolve(wrap(value))}function quoteContextScore(excerpt,quote,prefix,suffix){const text=excerpt.replace(/\s+/g," ").toLowerCase(),needle=quote.replace(/\s+/g," ").toLowerCase();let best=0;for(let at=text.indexOf(needle);at>=0;at=text.indexOf(needle,at+1))best=Math.max(best,textQuoteContextScore(text,at,at+needle.length,prefix,suffix));return best}const EPUB_CHAPTER_CONTENT_SECURITY_POLICY="default-src 'none'; img-src blob: data:; media-src blob: data:; font-src blob: data:; style-src blob: 'unsafe-inline'";function silenceChapterNetwork(chapter){const root=chapter.documentElement;if(!root)return;for(const node of[...chapter.childNodes])node.nodeType===Node.PROCESSING_INSTRUCTION_NODE&&chapter.removeChild(node);for(const element of[...chapter.querySelectorAll("link, meta")]){const rel=` ${(element.getAttribute("rel")??"").toLowerCase()} `;(/ (?:dns-prefetch|preconnect) /.test(rel)||(element.getAttribute("http-equiv")??"").trim().toLowerCase()==="refresh")&&element.remove()}const namespace=root.namespaceURI??"http://www.w3.org/1999/xhtml";let head=chapter.querySelector("head");head||(head=chapter.createElementNS(namespace,"head"),root.insertBefore(head,root.firstChild));const policy=chapter.createElementNS(namespace,"meta");policy.setAttribute("http-equiv","Content-Security-Policy"),policy.setAttribute("content",EPUB_CHAPTER_CONTENT_SECURITY_POLICY),head.insertBefore(policy,head.firstChild)}function registerNetworkSilentChapters(book){const contentHooks=inheritedDataValue(inheritedDataValue(book.spine,"hooks"),"content");savedCallable(contentHooks,"register")?.(silenceChapterNetwork)}function normalizeBook(value){if(!isObjectValue(value))return;const ready=savedThenable(inheritedDataValue(value,"ready")),renderTo=savedCallable(value,"renderTo"),destroy=savedCallable(value,"destroy");if(!ready||!renderTo||!destroy)return;let navigationCaptured=!1,navigation;const getNavigation=()=>(navigationCaptured||(navigationCaptured=!0,navigation=inheritedDataValue(value,"navigation")),navigation),spine=inheritedDataValue(value,"spine"),load=savedCallable(value,"load");return Object.freeze({ready,...spine===void 0?{}:{spine},...load===void 0?{}:{load},getNavigation,renderTo:(element,options)=>renderTo(element,options),destroy:()=>{destroy()}})}function normalizeRendition(value){if(!isObjectValue(value))return;const display=savedCallable(value,"display"),prev=savedCallable(value,"prev"),next=savedCallable(value,"next"),on=savedCallable(value,"on"),annotationsValue=inheritedDataValue(value,"annotations"),highlight=savedCallable(annotationsValue,"highlight"),remove=savedCallable(annotationsValue,"remove");if(!(!display||!prev||!next||!on||!highlight||!remove))return Object.freeze({display:target=>taskFrom(display,target),prev:()=>taskFrom(prev),next:()=>taskFrom(next),on:(type,callback)=>{on(type,callback)},annotations:Object.freeze({highlight:(cfi,data,callback,className,styles2)=>highlight(cfi,data,callback,className,styles2),remove:(cfi,type)=>{remove(cfi,type)}})})}function normalizeSpineItem(value){const load=savedCallable(value,"load"),find=savedCallable(value,"find"),unload=savedCallable(value,"unload");if(!(!load||!find||!unload))return Object.freeze({load:request=>load(request),find:query=>find(query),unload:()=>{unload()}})}function projectSpineItems(book){const spineItems=inheritedDataValue(book.spine,"spineItems");if(!isArrayValue(spineItems))return Object.freeze({items:Object.freeze([]),exact:spineItems===void 0});const length=getOwnDataDescriptor(spineItems,"length");if(length===MISSING_OWN_DATA_DESCRIPTOR||length===UNSAFE_OWN_DATA_DESCRIPTOR||typeof length.value!="number"||!Number.isSafeInteger(length.value)||length.value<0)return Object.freeze({items:Object.freeze([]),exact:!1});const items=[];let exact=length.value<=MAX_SEARCH_SPINE_ITEMS;const count=Math.min(length.value,MAX_SEARCH_SPINE_ITEMS);for(let index=0;index<count;index+=1){const descriptor=getOwnDataDescriptor(spineItems,String(index));if(descriptor===MISSING_OWN_DATA_DESCRIPTOR||descriptor===UNSAFE_OWN_DATA_DESCRIPTOR){exact=!1;continue}const item=normalizeSpineItem(descriptor.value);if(!item){exact=!1;continue}items.push(item)}return Object.freeze({items:Object.freeze(items),exact})}function projectFindResults(value,work){if(!isArrayValue(value))return Object.freeze({matches:Object.freeze([]),exact:!1});const length=getOwnDataDescriptor(value,"length");if(length===MISSING_OWN_DATA_DESCRIPTOR||length===UNSAFE_OWN_DATA_DESCRIPTOR||typeof length.value!="number"||!Number.isSafeInteger(length.value)||length.value<0)return Object.freeze({matches:Object.freeze([]),exact:!1});const matches=[];let exact=length.value<=MAX_FIND_RESULTS;const count=Math.min(length.value,MAX_FIND_RESULTS);for(let index=0;index<count;index+=1){const descriptor=getOwnDataDescriptor(value,String(index));if(descriptor===MISSING_OWN_DATA_DESCRIPTOR||descriptor===UNSAFE_OWN_DATA_DESCRIPTOR||!isObjectValue(descriptor.value)){exact=!1;continue}const cfi=getOwnDataDescriptor(descriptor.value,"cfi"),excerpt=getOwnDataDescriptor(descriptor.value,"excerpt");if(cfi===MISSING_OWN_DATA_DESCRIPTOR||cfi===UNSAFE_OWN_DATA_DESCRIPTOR||typeof cfi.value!="string"){exact=!1;continue}if(!work.canConsume(cfi.value)||!work.consume(cfi.value)||cfi.value.trim()===""){exact=!1;continue}let excerptValue="";excerpt!==MISSING_OWN_DATA_DESCRIPTOR&&(excerpt===UNSAFE_OWN_DATA_DESCRIPTOR||typeof excerpt.value!="string"||!work.canConsume(excerpt.value)||!work.consume(excerpt.value)?exact=!1:excerptValue=excerpt.value),matches.push({cfi:cfi.value,excerpt:excerptValue})}return Object.freeze({matches:Object.freeze(matches),exact})}function pushTocEntries(value,level,budget,stack){if(!isArrayValue(value)||budget.positions>=MAX_TOC_ITEMS)return;const length=getOwnDataDescriptor(value,"length");if(length===MISSING_OWN_DATA_DESCRIPTOR||length===UNSAFE_OWN_DATA_DESCRIPTOR||typeof length.value!="number"||!Number.isSafeInteger(length.value)||length.value<0)return;const count=Math.min(length.value,MAX_TOC_ITEMS-budget.positions);for(let index=count-1;index>=0;index-=1){budget.positions+=1;const descriptor=getOwnDataDescriptor(value,String(index));descriptor===MISSING_OWN_DATA_DESCRIPTOR||descriptor===UNSAFE_OWN_DATA_DESCRIPTOR||stack.push({value:descriptor.value,level})}}function projectToc(value){const budget={positions:0,nodes:0,seen:new WeakSet},stack=[];pushTocEntries(value,1,budget,stack);const items=[];for(;stack.length>0&&budget.nodes<MAX_TOC_ITEMS;){const current=stack.pop();if(!isObjectValue(current.value)||budget.seen.has(current.value))continue;budget.seen.add(current.value),budget.nodes+=1;const href=getOwnDataDescriptor(current.value,"href"),id=getOwnDataDescriptor(current.value,"id"),label=getOwnDataDescriptor(current.value,"label"),children=getOwnDataDescriptor(current.value,"subitems");if(href!==MISSING_OWN_DATA_DESCRIPTOR&&href!==UNSAFE_OWN_DATA_DESCRIPTOR&&typeof href.value=="string"){const idValue=id!==MISSING_OWN_DATA_DESCRIPTOR&&id!==UNSAFE_OWN_DATA_DESCRIPTOR&&typeof id.value=="string"&&id.value!==""?id.value:href.value,labelValue=label!==MISSING_OWN_DATA_DESCRIPTOR&&label!==UNSAFE_OWN_DATA_DESCRIPTOR&&typeof label.value=="string"?label.value.trim():"";items.push({id:idValue,label:labelValue,href:href.value,level:current.level})}current.level<MAX_TOC_DEPTH&&children!==MISSING_OWN_DATA_DESCRIPTOR&&children!==UNSAFE_OWN_DATA_DESCRIPTOR&&pushTocEntries(children.value,current.level+1,budget,stack)}return Object.freeze(items)}const TONE_FILL_TOKEN={accent:{token:"--lr-color-brand-quiet",fallback:"#ddf4ff"},success:{token:"--lr-color-success-quiet",fallback:"#dafbe1"},warning:{token:"--lr-color-warning-quiet",fallback:"#fff8c5"},danger:{token:"--lr-color-danger-quiet",fallback:"#ffebe9"},neutral:{token:"--lr-color-surface-raised",fallback:"#f6f8fa"}},SEARCH_MATCH_FILL_TOKEN={token:"--lr-color-warning",fallback:"#9a6700"},ACTIVE_HIGHLIGHT_STROKE_TOKEN={token:"--lr-focus-ring-color",fallback:DEFAULT_CANVAS_COLOR};class LyraEbookViewerBase extends LyraElement{}class LyraEbookViewer extends DocumentAnchorTarget(LyraEbookViewerBase){static{this.defaultStrings={...super.defaultStrings,anchorJumped:LYRA_DEFAULT_anchorJumped,anchorJumpedToPage:LYRA_DEFAULT_anchorJumpedToPage,anchorNotFound:LYRA_DEFAULT_anchorNotFound,documentPreviewEmpty:LYRA_DEFAULT_documentPreviewEmpty,documentPreviewResourceTooLarge:LYRA_DEFAULT_documentPreviewResourceTooLarge,documentPreviewTypeDocument:LYRA_DEFAULT_documentPreviewTypeDocument,documentPreviewUrlNotAllowed:LYRA_DEFAULT_documentPreviewUrlNotAllowed,ebookViewerLoadError:LYRA_DEFAULT_ebookViewerLoadError,ebookViewerMissingLibrary:LYRA_DEFAULT_ebookViewerMissingLibrary,ebookViewerNextChapter:LYRA_DEFAULT_ebookViewerNextChapter,ebookViewerPreviousChapter:LYRA_DEFAULT_ebookViewerPreviousChapter,ebookViewerRegionLabel:LYRA_DEFAULT_ebookViewerRegionLabel,loadingDocument:LYRA_DEFAULT_loadingDocument}}static{this.styles=[LyraElement.styles,styles,viewerPagerStyles,srOnly,viewerLoadingStyles]}constructor(){super(),this.src="",this.name="",this.maxHeight="",this.location="",this.anchorKinds=["cfi","text-quote"],this.ebookState={kind:"idle"},this.searchMatches=[],this.searchMatchCountExact=!0,this.searchActiveIndex=-1,this.mountRef=createRef(),this.generation=0,this.failedGeneration=-1,this.searchQuery="",this.lastSearchLocale="",this.searchGeneration=0,this.pendingSearchResetEvent=!1,this.anchorOperationGeneration=0,this.paintedHighlightCfis=[],this.announcements=new ViewerAnnouncementController(this),this.chapterButtonFocused=!1,this.previous=()=>{this.runRenditionNavigation("previous")},this.next=()=>{this.runRenditionNavigation("next")},new ThemeWatcher(this,()=>this.repaintAnnotations())}updated(changed){if(super.updated(changed),this.chapterButtonFocused&&this.ebookState.kind!=="ready"&&this.shadowRoot?.querySelector('[part="mount"]')?.focus(),this.chapterButtonFocused=!1,this.announcements.transition("load",this.ebookState.kind,this.ebookState.kind==="error"?this.ebookState.message:this.localize("loadingDocument")),changed.has("src")&&this.scheduleAfterUpdate(()=>{this.load()}),changed.has("src")&&this.pendingSearchResetEvent&&(this.pendingSearchResetEvent=!1,this.emitSearchChange()),changed.has("location")){const fromRelocated=this.relocatedLocation===this.location;this.relocatedLocation=void 0,!fromRelocated&&this.rendition&&this.location&&this.displayLocation(this.location)}(changed.has("highlights")||changed.has("activeHighlightId"))&&this.rendition&&this.repaintAnnotations();const locale=this.effectiveLocale;if(locale!==this.lastSearchLocale){const shouldRecompute=this.searchQuery!=="";this.lastSearchLocale=locale,shouldRecompute&&this.scheduleAfterUpdate(()=>{this.search(this.searchQuery)},"search")}}willUpdate(changed){super.willUpdate(changed);const active=shadowFocusTarget(this);this.chapterButtonFocused=active?.localName==="button"&&!active.disabled&&active.getAttribute("part")?.endsWith("-button")===!0,changed.has("src")&&(this.pendingSearchResetEvent||=this.hasSearchState(),this.resetSearchState())}connectedCallback(){super.connectedCallback(),this.announcements.connect(),this.hasUpdated&&this.src.trim()&&this.scheduleAfterUpdate(()=>{this.load()})}disconnectedCallback(){this.generation++,this.anchorOperationGeneration++,this.announcements.disconnect(),this.teardown(),this.ebookState={kind:"idle"},super.disconnectedCallback()}connectedMoveCallback(){}adoptedCallback(){super.adoptedCallback(),this.announcements.adopted()}teardown(){const shouldEmitSearchReset=this.hasSearchState();this.destroyBook(this.book),this.book=void 0,this.rendition=void 0,this.resetSearchState(),this.paintedHighlightCfis=[],shouldEmitSearchReset&&this.isConnected&&this.emitSearchChange()}destroyBook(book){try{book?.destroy()}catch{}}isCurrentLoad(generation,ownerView){return this.isConnected&&generation===this.generation&&this.ownerDocument.defaultView===ownerView}isCurrentBookRendition(generation,ownerView,book,rendition){return this.isConnected&&generation===this.generation&&this.ownerDocument.defaultView===ownerView&&this.book===book&&this.rendition===rendition}failCurrentLoad(error,message=this.localize("ebookViewerLoadError")){this.failedGeneration!==this.generation&&(this.failedGeneration=this.generation,this.ebookState={kind:"error",message},this.emit("lr-render-error",{error}))}hasSearchState(){return this.searchQuery!==""||this.searchMatches.length>0||!this.searchMatchCountExact||this.searchActiveIndex!==-1}resetSearchState(){this.searchGeneration++,this.searchQuery="",this.searchMatches=[],this.searchMatchCountExact=!0,this.searchActiveIndex=-1,this.searchAnnotationCfi=void 0}async load(){const generation=++this.generation,signal=this.beginAbortableLoad();if(this.teardown(),!this.src.trim()){this.ebookState={kind:"idle"};return}const fetchTarget=resolveOwnerFetchTarget(this,this.src);if(!fetchTarget){this.failWithLocalizedMessage(this.localize("documentPreviewUrlNotAllowed"));return}this.ebookState={kind:"loading"};let data,factory;try{if([data,factory]=await Promise.all([fetchTarget.view.fetch(fetchTarget.url,signal?{signal}:void 0).then(response=>{if(!response.ok)throw new Error(`${response.status} ${response.statusText}`);return readResponseArrayBuffer(response)}),getEpubJs()]),!this.isCurrentLoad(generation,fetchTarget.view)||(await assertEpubArchiveWithinLimits(data,void 0,void 0,{signal}),!this.isCurrentLoad(generation,fetchTarget.view)))return}catch(error){if(isAbortError(error)||!this.isCurrentLoad(generation,fetchTarget.view))return;this.failCurrentLoad(error,this.localize(isResourceLimitError(error)?"documentPreviewResourceTooLarge":"ebookViewerLoadError"));return}if(!factory){this.failWithLocalizedMessage(this.localize("ebookViewerMissingLibrary"));return}const mount=this.mountRef.value;if(!mount){this.failWithLocalizedMessage(this.localize("ebookViewerLoadError"));return}let candidateBook;try{const book=normalizeBook(factory(data));if(!book)throw new Error("EPUB peer returned an unusable book.");candidateBook=book,registerNetworkSilentChapters(book);const rawRendition=book.renderTo(mount,{width:"100%",height:"100%"});guardEpubUnloadListener({settings:inheritedDataValue(rawRendition,"settings"),requireManager:savedCallable(rawRendition,"requireManager")});const rendition=normalizeRendition(rawRendition);if(!rendition)throw new Error("EPUB peer returned an unusable rendition.");if(await book.ready,!this.isCurrentLoad(generation,fetchTarget.view)){this.destroyBook(book),candidateBook=void 0;return}if(book.getNavigation(),await rendition.display(this.location||void 0),!this.isCurrentLoad(generation,fetchTarget.view)){this.destroyBook(book),candidateBook=void 0;return}rendition.on("relocated",loc=>{if(!this.isCurrentBookRendition(generation,fetchTarget.view,book,rendition))return;const start=inheritedDataValue(loc,"start"),cfi=inheritedDataValue(start,"cfi"),href=inheritedDataValue(start,"href");typeof cfi!="string"||cfi.trim()===""||!cfi||cfi===this.location||(this.relocatedLocation=cfi,this.location=cfi,this.emit("lr-location-change",{cfi,href:typeof href=="string"?href:""}))}),rendition.on("selected",(cfiRange,contents)=>{if(!(!this.isCurrentBookRendition(generation,fetchTarget.view,book,rendition)||typeof cfiRange!="string"))try{const contentsWindow=inheritedDataValue(contents,"window"),selection=savedCallable(contentsWindow,"getSelection")?.(),range=this.selectedRange(selection);if(!range)return;const text=boundedSelectionText(range);if(!text)return;const rects=this.translateSelectionRects(boundedSelectionRects(range),contentsWindow);this.emit("lr-text-select",{text,anchor:{kind:"cfi",cfi:cfiRange},rects})}catch{}}),this.book=book,this.rendition=rendition,candidateBook=void 0,this.ebookState={kind:"ready"},this.repaintAnnotations()}catch(error){if(this.destroyBook(candidateBook),isAbortError(error)||!this.isCurrentLoad(generation,fetchTarget.view))return;this.failCurrentLoad(error)}}selectedRange(selection){const prototype=this.ownerDocument.defaultView?.Selection.prototype;if(prototype)try{const count2=Object.getOwnPropertyDescriptor(prototype,"rangeCount")?.get?.call(selection);if(typeof count2=="number")return count2>0?prototype.getRangeAt.call(selection,0):null}catch{}const count=inheritedDataValue(selection,"rangeCount"),getRangeAt=savedCallable(selection,"getRangeAt");return typeof count=="number"&&count>0&&getRangeAt?getRangeAt(0):null}failWithLocalizedMessage(message){const error=new LyraUserFacingError(message);this.failCurrentLoad(error,message)}reportRenditionFailure(error,rendition,generation,ownerView=this.ownerDocument.defaultView){!this.isConnected||generation!==this.generation||this.ownerDocument.defaultView!==ownerView||rendition!==this.rendition||this.failCurrentLoad(error)}translateSelectionRects(rects,sourceWindow){const ownerWindow=this.ownerDocument.defaultView;if(!ownerWindow||!sourceWindow)return[];const translated=[];for(const rect of rects){let x=Number(rect.x??rect.left),y=Number(rect.y??rect.top),width=Number(rect.width),height=Number(rect.height);if(![x,y,width,height].every(Number.isFinite))continue;let current=sourceWindow,valid=!0;for(;current&&current!==ownerWindow;){if(!("frameElement"in current)){current=ownerWindow;break}let frameElement;try{frameElement=current.frameElement}catch{valid=!1;break}const frameWindow=frameElement?.ownerDocument.defaultView;if(!frameElement||!frameWindow||!(frameElement instanceof frameWindow.HTMLElement)){valid=!1;break}const frame=frameElement,frameRect=frame.getBoundingClientRect(),borderBoxWidth=frame.offsetWidth||frame.clientWidth,borderBoxHeight=frame.offsetHeight||frame.clientHeight,viewportWidth=current.innerWidth||frame.clientWidth,viewportHeight=current.innerHeight||frame.clientHeight;if(borderBoxWidth<=0||borderBoxHeight<=0||viewportWidth<=0||viewportHeight<=0){valid=!1;break}const borderScaleX=frameRect.width/borderBoxWidth,borderScaleY=frameRect.height/borderBoxHeight,contentScaleX=frame.clientWidth*borderScaleX/viewportWidth,contentScaleY=frame.clientHeight*borderScaleY/viewportHeight;x=frameRect.left+frame.clientLeft*borderScaleX+x*contentScaleX,y=frameRect.top+frame.clientTop*borderScaleY+y*contentScaleY,width*=contentScaleX,height*=contentScaleY,current=frame.ownerDocument.defaultView}!valid||current!==ownerWindow||translated.push(Object.freeze({x,y,width,height,top:y,right:x+width,bottom:y+height,left:x}))}return translated}displayLocation(location){const rendition=this.rendition;if(!rendition)return;const generation=this.generation,ownerView=this.ownerDocument.defaultView;if(ownerView)try{Promise.resolve(rendition.display(location)).catch(error=>{this.reportRenditionFailure(error,rendition,generation,ownerView)})}catch(error){this.reportRenditionFailure(error,rendition,generation,ownerView)}}runRenditionNavigation(action){const rendition=this.rendition;if(!rendition)return;const generation=this.generation,ownerView=this.ownerDocument.defaultView;if(ownerView)try{const task=action==="previous"?rendition.prev():rendition.next();Promise.resolve(task).catch(error=>{this.reportRenditionFailure(error,rendition,generation,ownerView)})}catch(error){this.reportRenditionFailure(error,rendition,generation,ownerView)}}async getToc(){const book=this.book,generation=this.generation,ownerView=this.ownerDocument.defaultView;if(!book||!ownerView)return[];try{await book.ready}catch{return[]}return!this.isCurrentLoad(generation,ownerView)||this.book!==book?[]:[...projectToc(inheritedDataValue(book.getNavigation(),"toc"))]}async scrollToAnchor(target){const operation=++this.anchorOperationGeneration,generation=this.generation,ownerView=this.ownerDocument.defaultView,book=this.book,rendition=this.rendition;try{return await Object.getPrototypeOf(LyraEbookViewer.prototype).performScrollToAnchor.call(this,target)}catch(error){return operation!==this.anchorOperationGeneration||!ownerView||!this.isCurrentLoad(generation,ownerView)||this.book!==book||this.rendition!==rendition||(rendition&&this.reportRenditionFailure(error,rendition,generation,ownerView),this.emit("lr-anchor-result",{found:!1})),!1}}async applyAnchor(anchor){const rendition=this.rendition,operation=this.anchorOperationGeneration,generation=this.generation,ownerView=this.ownerDocument.defaultView;if(!rendition||!ownerView)return!1;if(anchor.kind==="cfi")return operation!==this.anchorOperationGeneration||!this.isCurrentLoad(generation,ownerView)||rendition!==this.rendition?!1:(await rendition.display(anchor.cfi),operation===this.anchorOperationGeneration&&this.isCurrentLoad(generation,ownerView)&&rendition===this.rendition);if(anchor.kind==="text-quote"){const cfi=await this.findTextQuoteCfi(anchor);return!cfi||operation!==this.anchorOperationGeneration||!this.isCurrentLoad(generation,ownerView)||rendition!==this.rendition?!1:(await rendition.display(cfi),operation===this.anchorOperationGeneration&&this.isCurrentLoad(generation,ownerView)&&rendition===this.rendition)}return!1}async findTextQuoteCfi(anchor){const book=this.book,generation=this.generation,ownerView=this.ownerDocument.defaultView,quote=anchor.quote.trim(),boundedQuery=boundedViewerSearchQuery(quote,this.effectiveLocale);if(!book||!ownerView||!boundedQuery.accepted||!boundedQuery.needle)return null;const fullContextScore=(anchor.prefix?.trim()?1:0)+(anchor.suffix?.trim()?1:0);let bestMatch=null,bestScore=-1;const work=new ViewerSearchWorkBudget,spine=projectSpineItems(book);for(const item of spine.items){if(!work.consume(""))return bestMatch;let loaded=!1;try{if(await awaitPeerResult(item.load(book.load)),loaded=!0,!this.isCurrentLoad(generation,ownerView)||this.book!==book)return null;const{value:rawResults}=await awaitPeerResult(item.find(quote)),results=projectFindResults(rawResults,work);if(!this.isCurrentLoad(generation,ownerView)||this.book!==book)return null;for(const result of results.matches){if(!work.consume(""))return bestMatch;const score=fullContextScore===0?0:quoteContextScore(result.excerpt,quote,anchor.prefix,anchor.suffix);if(score===fullContextScore)return result.cfi;score>bestScore&&(bestMatch=result.cfi,bestScore=score)}}catch{continue}finally{if(loaded)try{item.unload()}catch{}}}return bestMatch}repaintHighlights(){const rendition=this.rendition;if(!rendition)return;const book=this.book,generation=this.generation,ownerView=this.ownerDocument.defaultView,work=new ViewerSearchWorkBudget;for(const cfi of this.paintedHighlightCfis){if(!work.consume(cfi))break;rendition.annotations.remove(cfi,"highlight")}this.paintedHighlightCfis=[];let painted=0;const fillCache=new Map,resolveFill=pair=>{let value=fillCache.get(pair.token);return value===void 0&&(value=this.resolveHighlightFill(pair).fill,fillCache.set(pair.token,value)),value};for(const highlight of prioritizedHighlightCandidates(this.highlights,this.activeHighlightId)){if(highlight.anchor.kind!=="cfi")continue;if(painted>=MAX_PAINTED_HIGHLIGHTS)break;const cfi=highlight.anchor.cfi.trim();if(!cfi||cfi.length>VIEWER_SEARCH_QUERY_LIMIT||!work.consume(cfi))continue;const tone=highlight.tone??"accent",active=highlight.id===this.activeHighlightId,styles2={fill:resolveFill(TONE_FILL_TOKEN[tone])};if(active){const forcedColors=this.ownerDocument.defaultView?.matchMedia?.("(forced-colors: active)").matches??!1;styles2.stroke=forcedColors?"CanvasText":resolveFill(ACTIVE_HIGHLIGHT_STROKE_TOKEN),styles2["stroke-width"]="3",styles2["stroke-dasharray"]="2 1"}rendition.annotations.highlight(cfi,{id:highlight.id},()=>{!book||!ownerView||!this.isCurrentBookRendition(generation,ownerView,book,rendition)||this.emit("lr-highlight-activate",{highlightId:highlight.id})},active?`lr-hl-${tone} lr-ebook-highlight-active`:`lr-hl-${tone}`,styles2),this.paintedHighlightCfis.push(cfi),painted++}}repaintSearchAnnotation(){const rendition=this.rendition,cfi=this.searchAnnotationCfi;!rendition||!cfi||(rendition.annotations.remove(cfi,"highlight"),rendition.annotations.highlight(cfi,{},void 0,"lr-ebook-search",this.resolveHighlightFill(SEARCH_MATCH_FILL_TOKEN)))}repaintAnnotations(){const rendition=this.rendition;if(rendition)try{this.repaintHighlights(),this.repaintSearchAnnotation()}catch(error){this.reportRenditionFailure(error,rendition,this.generation)}}async search(query){const generation=++this.searchGeneration,ownerView=this.ownerDocument.defaultView,boundedQuery=boundedViewerSearchQuery(query,this.effectiveLocale);if(this.searchQuery=query,this.lastSearchLocale=this.effectiveLocale,this.clearSearchAnnotation(),!boundedQuery.accepted)return this.searchMatches=[],this.searchMatchCountExact=!1,this.searchActiveIndex=-1,this.emitSearchChange(),0;if(!this.book||!ownerView||!boundedQuery.needle)return this.searchMatches=[],this.searchMatchCountExact=!0,this.searchActiveIndex=-1,this.emitSearchChange(),0;const matches=[];let matchCountExact=!0,matchCeilingExceeded=!1;const book=this.book,work=new ViewerSearchWorkBudget,spine=projectSpineItems(book);spine.exact||(matchCountExact=!1);for(const item of spine.items){if(generation!==this.searchGeneration||this.ownerDocument.defaultView!==ownerView||!this.isConnected)return this.searchMatches.length;if(!work.consume("")){matchCountExact=!1;break}let loaded=!1;try{if(await awaitPeerResult(item.load(book.load)),loaded=!0,generation!==this.searchGeneration||this.ownerDocument.defaultView!==ownerView||!this.isConnected||this.book!==book)return this.searchMatches.length;const{value:rawResults}=await awaitPeerResult(item.find(query.trim())),results=projectFindResults(rawResults,work);if(generation!==this.searchGeneration||this.ownerDocument.defaultView!==ownerView||!this.isConnected||this.book!==book)return this.searchMatches.length;results.exact||(matchCountExact=!1);for(const r of results.matches){if(!work.consume("")){matchCountExact=!1,matchCeilingExceeded=!0;break}if(matches.length===MAX_SEARCH_MATCHES){matchCountExact=!1,matchCeilingExceeded=!0;break}matches.push(r)}}catch{matchCountExact=!1;continue}finally{if(loaded)try{item.unload()}catch{matchCountExact=!1}}if(matchCeilingExceeded)break}return generation!==this.searchGeneration||this.ownerDocument.defaultView!==ownerView||!this.isConnected||this.book!==book?this.searchMatches.length:(this.searchMatches=matches,this.searchMatchCountExact=matchCountExact,this.searchActiveIndex=matches.length>0?0:-1,this.emitSearchChange(),this.searchActiveIndex>=0&&await this.showSearchMatch(this.searchActiveIndex,generation,ownerView),matches.length)}async searchNext(){if(!this.searchMatches.length)return!1;const generation=++this.searchGeneration;return this.searchActiveIndex=(this.searchActiveIndex+1)%this.searchMatches.length,this.emitSearchChange(),this.showSearchMatch(this.searchActiveIndex,generation)}async searchPrevious(){if(!this.searchMatches.length)return!1;const generation=++this.searchGeneration;return this.searchActiveIndex=(this.searchActiveIndex-1+this.searchMatches.length)%this.searchMatches.length,this.emitSearchChange(),this.showSearchMatch(this.searchActiveIndex,generation)}clearSearch(){this.searchGeneration++,this.searchQuery="",this.searchMatches=[],this.searchMatchCountExact=!0,this.searchActiveIndex=-1,this.clearSearchAnnotation(),this.emit("lr-search-change",{query:"",matchCount:0,matchCountExact:!0,activeIndex:-1})}clearSearchAnnotation(){const cfi=this.searchAnnotationCfi;this.searchAnnotationCfi=void 0;const rendition=this.rendition,generation=this.generation,ownerView=this.ownerDocument.defaultView;if(!(!cfi||!rendition||!ownerView))try{rendition.annotations.remove(cfi,"highlight")}catch(error){this.reportRenditionFailure(error,rendition,generation,ownerView)}}async showSearchMatch(index,generation=this.searchGeneration,ownerView=this.ownerDocument.defaultView){const match=this.searchMatches[index],rendition=this.rendition;if(!match||!rendition||generation!==this.searchGeneration||!ownerView||!this.isConnected||this.ownerDocument.defaultView!==ownerView)return!1;this.clearSearchAnnotation();try{await rendition.display(match.cfi)}catch(error){return generation===this.searchGeneration&&rendition===this.rendition&&this.ownerDocument.defaultView===ownerView&&this.reportRenditionFailure(error,rendition,this.generation,ownerView),!1}if(generation!==this.searchGeneration||rendition!==this.rendition||this.searchMatches[index]!==match||!this.isConnected||this.ownerDocument.defaultView!==ownerView)return!1;try{rendition.annotations.highlight(match.cfi,{},void 0,"lr-ebook-search",this.resolveHighlightFill(SEARCH_MATCH_FILL_TOKEN))}catch(error){return this.reportRenditionFailure(error,rendition,this.generation,ownerView),!1}return this.searchAnnotationCfi=match.cfi,!0}emitSearchChange(){this.emit("lr-search-change",{query:this.searchQuery,matchCount:this.searchMatches.length,matchCountExact:this.searchMatchCountExact,activeIndex:this.searchActiveIndex})}resolveHighlightFill({token,fallback}){return{fill:(this.ownerDocument.defaultView?.getComputedStyle(this).getPropertyValue(token).trim()??"")||fallback}}renderStatus(){return this.ebookState.kind==="loading"?renderViewerLoading(this.localize("loadingDocument")):this.ebookState.kind==="error"?html`<div part="error">${this.ebookState.message}</div>`:this.ebookState.kind==="idle"?html`<p class="status-note">${this.localize("documentPreviewEmpty",void 0,{type:this.localize("documentPreviewTypeDocument")})}</p>`:nothing}render(){const maxHeight=sanitizeCssLength(this.maxHeight),disabled=this.ebookState.kind!=="ready";return html`
2
2
  <div
3
3
  part="base"
4
4
  aria-busy=${this.ebookState.kind==="loading"?"true":"false"}
@@ -0,0 +1 @@
1
+ function isManagerClass(value){if(typeof value!="function")return!1;const prototype=Object.getOwnPropertyDescriptor(value,"prototype")?.value;if(typeof prototype!="object"||prototype===null)return!1;let current=prototype;for(let depth=0;current&&depth<8;depth+=1){const descriptor=Object.getOwnPropertyDescriptor(current,"addEventListeners");if(descriptor)return typeof descriptor.value=="function";current=Object.getPrototypeOf(current)}return!1}function guardEpubUnloadListener({settings,requireManager}){if(typeof settings!="object"||settings===null||!requireManager)return;const descriptor=Object.getOwnPropertyDescriptor(settings,"manager");if(!descriptor||!("value"in descriptor)||!descriptor.writable)return;const Manager=requireManager(descriptor.value);if(!isManagerClass(Manager))return;class UnloadFreeManager extends Manager{addEventListeners(...args){const ownListener=Object.hasOwn(window,"addEventListener"),previous=window.addEventListener;window.addEventListener=function(type,...rest){if(type!=="unload")return previous.call(this,type,...rest)};try{return super.addEventListeners(...args)}finally{ownListener?window.addEventListener=previous:delete window.addEventListener}}}Object.defineProperty(settings,"manager",{...descriptor,value:UnloadFreeManager})}export{guardEpubUnloadListener};
@@ -1 +1 @@
1
- import{loadDompurify}from"../../../internal/dompurify-loader.js";import{createOptionalPeerLoader}from"../../../internal/optional-peer-capabilities.js";function isPostalMimeApi(value){return(typeof value=="object"||typeof value=="function")&&value!==null&&"parse"in value&&typeof value.parse=="function"}const postalMime=createOptionalPeerLoader({load:()=>import("postal-mime"),isCapability:isPostalMimeApi,warningKey:"lyra-email-viewer-postal-mime-unavailable",warning:"<lr-email-viewer> could not load its optional postal-mime peer."});let depsPromise,resolvedDeps;async function loadEmailAndSanitizer(importPostalMime,importDompurify){const[PostalMime,DOMPurify]=await Promise.all([importPostalMime?postalMime.loadWith(importPostalMime):postalMime.get(),loadDompurify(importDompurify)]);return{PostalMime:PostalMime??void 0,DOMPurify:DOMPurify??void 0}}function loadEmailDeps(){return depsPromise??=loadEmailAndSanitizer().then(result=>((!result.PostalMime||!result.DOMPurify)&&(depsPromise=void 0),resolvedDeps=result,result)),depsPromise}function getEmailDepsIfLoaded(){return resolvedDeps}function clearEmailDepsCache(){depsPromise=void 0,resolvedDeps=void 0,postalMime.clear()}function __setEmailDepsForTesting(deps){depsPromise=deps===void 0?void 0:Promise.resolve(deps),resolvedDeps=deps}export{__setEmailDepsForTesting,clearEmailDepsCache,getEmailDepsIfLoaded,loadEmailAndSanitizer,loadEmailDeps};
1
+ import{loadDompurify}from"../../../internal/dompurify-loader.js";import{createOptionalPeerLoader}from"../../../internal/optional-peer-capabilities.js";function isPostalMimeApi(value){return(typeof value=="object"||typeof value=="function")&&value!==null&&"parse"in value&&typeof value.parse=="function"}const postalMime=createOptionalPeerLoader({load:()=>(async()=>{try{return await import("postal-mime")}catch(e){throw e}})(),isCapability:isPostalMimeApi,warningKey:"lyra-email-viewer-postal-mime-unavailable",warning:"<lr-email-viewer> could not load its optional postal-mime peer."});let depsPromise,resolvedDeps;async function loadEmailAndSanitizer(importPostalMime,importDompurify){const[PostalMime,DOMPurify]=await Promise.all([importPostalMime?postalMime.loadWith(importPostalMime):postalMime.get(),loadDompurify(importDompurify)]);return{PostalMime:PostalMime??void 0,DOMPurify:DOMPurify??void 0}}function loadEmailDeps(){return depsPromise??=loadEmailAndSanitizer().then(result=>((!result.PostalMime||!result.DOMPurify)&&(depsPromise=void 0),resolvedDeps=result,result)),depsPromise}function getEmailDepsIfLoaded(){return resolvedDeps}function clearEmailDepsCache(){depsPromise=void 0,resolvedDeps=void 0,postalMime.clear()}function __setEmailDepsForTesting(deps){depsPromise=deps===void 0?void 0:Promise.resolve(deps),resolvedDeps=deps}export{__setEmailDepsForTesting,clearEmailDepsCache,getEmailDepsIfLoaded,loadEmailAndSanitizer,loadEmailDeps};
@@ -1 +1 @@
1
- import{clearDompurifyCache,loadDompurify}from"../../../internal/dompurify-loader.js";let override;function loadHtmlSanitizerDeps(importDompurify=()=>import("dompurify")){return loadDompurify(importDompurify)}function loadHtmlSanitizer(){return override??loadDompurify()}function clearHtmlSanitizerCache(){override=void 0,clearDompurifyCache()}function __setHtmlSanitizerForTesting(value){override=value===void 0?void 0:Promise.resolve(value)}export{__setHtmlSanitizerForTesting,clearHtmlSanitizerCache,loadHtmlSanitizer,loadHtmlSanitizerDeps};
1
+ import{clearDompurifyCache,loadDompurify}from"../../../internal/dompurify-loader.js";let override;function loadHtmlSanitizerDeps(importDompurify=()=>(async()=>{try{return await import("dompurify")}catch(e){throw e}})()){return loadDompurify(importDompurify)}function loadHtmlSanitizer(){return override??loadDompurify()}function clearHtmlSanitizerCache(){override=void 0,clearDompurifyCache()}function __setHtmlSanitizerForTesting(value){override=value===void 0?void 0:Promise.resolve(value)}export{__setHtmlSanitizerForTesting,clearHtmlSanitizerCache,loadHtmlSanitizer,loadHtmlSanitizerDeps};
@@ -1 +1 @@
1
- import{createEngine3dLoader}from"../../../internal/engine-3d-loader.js";import{webgl2Available}from"../../../internal/engine-3d.js";import{tag}from"../../../internal/prefix.js";const modelEngineLoader=createEngine3dLoader({entry:"model",tag:tag("model-viewer"),load:()=>import("@aceshooting/lyra-3d/model")}),modelEngineEnvironment={available:document=>webgl2Available(()=>document.createElement("canvas"))};function supportsAsyncModelData(engine){return"setDataAsync"in engine&&typeof engine.setDataAsync=="function"}export{modelEngineEnvironment,modelEngineLoader,supportsAsyncModelData};
1
+ import{createEngine3dLoader}from"../../../internal/engine-3d-loader.js";import{webgl2Available}from"../../../internal/engine-3d.js";import{tag}from"../../../internal/prefix.js";const modelEngineLoader=createEngine3dLoader({entry:"model",tag:tag("model-viewer"),load:()=>(async()=>{try{return await import("@aceshooting/lyra-3d/model")}catch(e){throw e}})()}),modelEngineEnvironment={available:document=>webgl2Available(()=>document.createElement("canvas"))};function supportsAsyncModelData(engine){return"setDataAsync"in engine&&typeof engine.setDataAsync=="function"}export{modelEngineEnvironment,modelEngineLoader,supportsAsyncModelData};
@@ -1 +1 @@
1
- import{clearDompurifyCache,loadDompurify}from"../../../internal/dompurify-loader.js";let override;function loadNotebookSanitizerDeps(importDompurify=()=>import("dompurify")){return loadDompurify(importDompurify)}function loadNotebookSanitizer(){return override??loadDompurify()}function clearNotebookSanitizerCache(){override=void 0,clearDompurifyCache()}function __setNotebookSanitizerForTesting(value){override=value===void 0?void 0:Promise.resolve(value)}export{__setNotebookSanitizerForTesting,clearNotebookSanitizerCache,loadNotebookSanitizer,loadNotebookSanitizerDeps};
1
+ import{clearDompurifyCache,loadDompurify}from"../../../internal/dompurify-loader.js";let override;function loadNotebookSanitizerDeps(importDompurify=()=>(async()=>{try{return await import("dompurify")}catch(e){throw e}})()){return loadDompurify(importDompurify)}function loadNotebookSanitizer(){return override??loadDompurify()}function clearNotebookSanitizerCache(){override=void 0,clearDompurifyCache()}function __setNotebookSanitizerForTesting(value){override=value===void 0?void 0:Promise.resolve(value)}export{__setNotebookSanitizerForTesting,clearNotebookSanitizerCache,loadNotebookSanitizer,loadNotebookSanitizerDeps};
@@ -1 +1 @@
1
- import{createOptionalPeerLoader}from"../../../internal/optional-peer-capabilities.js";const PDF_JS_WARNING_KEY="lyra-pdf-viewer-pdfjs-unavailable",PDF_JS_WARNING="<lr-pdf-viewer> could not load its optional pdfjs-dist peer.";function isPdfJsApi(value){return(typeof value=="object"||typeof value=="function")&&value!==null&&"getDocument"in value&&typeof value.getDocument=="function"&&"GlobalWorkerOptions"in value&&(typeof value.GlobalWorkerOptions=="object"||typeof value.GlobalWorkerOptions=="function")&&value.GlobalWorkerOptions!==null}const pdfjs=createOptionalPeerLoader({load:()=>import("pdfjs-dist"),isCapability:isPdfJsApi,warningKey:PDF_JS_WARNING_KEY,warning:PDF_JS_WARNING}),PDF_WORKER_MODULE_SPECIFIER="pdfjs-dist/build/pdf.worker.min.mjs",ALLOWED_WORKER_PROTOCOLS=["http:","https:","blob:","file:"];function defaultWorkerModuleResolver(specifier){const resolver=import.meta.resolve;if(!resolver)return null;try{return resolver(specifier)}catch{return null}}function safeWorkerModuleUrl(value){if(!value)return null;try{const url=new URL(value);return ALLOWED_WORKER_PROTOCOLS.includes(url.protocol)?url.href:null}catch{return null}}function safeAuthoredWorkerUrl(value){if(!value)return null;try{const url=new URL(value,typeof document>"u"?void 0:document.baseURI);return ALLOWED_WORKER_PROTOCOLS.includes(url.protocol)?url.href:null}catch{return null}}function configurePdfJsWorker(pdfjsLib,authoredWorkerSrc,resolveWorkerModule){if(pdfjsLib.GlobalWorkerOptions.workerSrc)return;const workerSrc=safeAuthoredWorkerUrl(authoredWorkerSrc)??safeWorkerModuleUrl(resolveWorkerModule(PDF_WORKER_MODULE_SPECIFIER));workerSrc&&(pdfjsLib.GlobalWorkerOptions.workerSrc=workerSrc)}async function loadPdfJsDeps(importPdfjs,resolveWorkerModule=defaultWorkerModuleResolver,workerSrc){const pdfjsLib=await pdfjs.loadWith(importPdfjs);return pdfjsLib&&configurePdfJsWorker(pdfjsLib,workerSrc,resolveWorkerModule),pdfjsLib}async function loadPdfJs(workerSrc){const pdfjsLib=await pdfjs.get();return pdfjsLib&&configurePdfJsWorker(pdfjsLib,workerSrc,defaultWorkerModuleResolver),pdfjsLib}function clearPdfJsCache(){pdfjs.clear()}export{clearPdfJsCache,loadPdfJs,loadPdfJsDeps};
1
+ import{createOptionalPeerLoader}from"../../../internal/optional-peer-capabilities.js";const PDF_JS_WARNING_KEY="lyra-pdf-viewer-pdfjs-unavailable",PDF_JS_WARNING="<lr-pdf-viewer> could not load its optional pdfjs-dist peer.";function isPdfJsApi(value){return(typeof value=="object"||typeof value=="function")&&value!==null&&"getDocument"in value&&typeof value.getDocument=="function"&&"GlobalWorkerOptions"in value&&(typeof value.GlobalWorkerOptions=="object"||typeof value.GlobalWorkerOptions=="function")&&value.GlobalWorkerOptions!==null}const pdfjs=createOptionalPeerLoader({load:()=>(async()=>{try{return await import("pdfjs-dist")}catch(e){throw e}})(),isCapability:isPdfJsApi,warningKey:PDF_JS_WARNING_KEY,warning:PDF_JS_WARNING}),PDF_WORKER_MODULE_SPECIFIER="pdfjs-dist/build/pdf.worker.min.mjs",ALLOWED_WORKER_PROTOCOLS=["http:","https:","blob:","file:"];function defaultWorkerModuleResolver(specifier){const resolver=import.meta.resolve;if(!resolver)return null;try{return resolver(specifier)}catch{return null}}function safeWorkerModuleUrl(value){if(!value)return null;try{const url=new URL(value);return ALLOWED_WORKER_PROTOCOLS.includes(url.protocol)?url.href:null}catch{return null}}function safeAuthoredWorkerUrl(value){if(!value)return null;try{const url=new URL(value,typeof document>"u"?void 0:document.baseURI);return ALLOWED_WORKER_PROTOCOLS.includes(url.protocol)?url.href:null}catch{return null}}function configurePdfJsWorker(pdfjsLib,authoredWorkerSrc,resolveWorkerModule){if(pdfjsLib.GlobalWorkerOptions.workerSrc)return;const workerSrc=safeAuthoredWorkerUrl(authoredWorkerSrc)??safeWorkerModuleUrl(resolveWorkerModule(PDF_WORKER_MODULE_SPECIFIER));workerSrc&&(pdfjsLib.GlobalWorkerOptions.workerSrc=workerSrc)}async function loadPdfJsDeps(importPdfjs,resolveWorkerModule=defaultWorkerModuleResolver,workerSrc){const pdfjsLib=await pdfjs.loadWith(importPdfjs);return pdfjsLib&&configurePdfJsWorker(pdfjsLib,workerSrc,resolveWorkerModule),pdfjsLib}async function loadPdfJs(workerSrc){const pdfjsLib=await pdfjs.get();return pdfjsLib&&configurePdfJsWorker(pdfjsLib,workerSrc,defaultWorkerModuleResolver),pdfjsLib}function clearPdfJsCache(){pdfjs.clear()}export{clearPdfJsCache,loadPdfJs,loadPdfJsDeps};
@@ -1 +1 @@
1
- import{createOptionalPeerLoader}from"../../../internal/optional-peer-capabilities.js";const PPTX_RENDERER_WARNING_KEY="lyra-pptx-viewer-renderer-unavailable",PPTX_RENDERER_WARNING="<lr-pptx-viewer> could not load its optional @aiden0z/pptx-renderer peer.",MAX_SAFE_PPTX_ZIP_LIMITS={maxEntries:4e3,maxEntryUncompressedBytes:32*1024*1024,maxTotalUncompressedBytes:256*1024*1024,maxMediaBytes:192*1024*1024,maxConcurrency:8};let override;function hasPptxOpenCapability(value){if(typeof value!="object"&&typeof value!="function"||value===null)return!1;const viewer=value.PptxViewer;if(typeof viewer!="object"&&typeof viewer!="function"||viewer===null||typeof viewer.open!="function")return!1;const limits=value.RECOMMENDED_ZIP_LIMITS;return typeof limits!="object"||limits===null?!1:Object.keys(MAX_SAFE_PPTX_ZIP_LIMITS).every(key=>{const candidate=limits[key];return Number.isSafeInteger(candidate)&&candidate>0&&candidate<=MAX_SAFE_PPTX_ZIP_LIMITS[key]})}function adaptPptxViewer(value){if(typeof value!="object"&&typeof value!="function"||value===null)return null;const candidate=value;if(!Number.isSafeInteger(candidate.slideCount)||candidate.slideCount<0||!Number.isSafeInteger(candidate.currentSlideIndex)||typeof candidate.goToSlide!="function"||typeof candidate.searchText!="function"||typeof candidate.highlightSearchResult!="function"||typeof candidate.renderThumbnailToContainer!="function"||typeof candidate.clearSearchHighlights!="function"||typeof candidate.destroy!="function"||typeof candidate.addEventListener!="function"||typeof candidate.removeEventListener!="function")return null;const viewer=candidate,listeners=new Set;let destroyed=!1;const emit=event=>{for(const listener of listeners)listener(event)},onSlideChange=event=>{const index=event.detail?.index;typeof index=="number"&&Number.isSafeInteger(index)&&index>=0&&index<viewer.slideCount&&emit(Object.freeze({kind:"slide-change",index}))},onSlideError=event=>{const detail=event.detail,page=typeof detail?.index=="number"&&Number.isSafeInteger(detail.index)&&detail.index>=0&&detail.index<viewer.slideCount?detail.index+1:void 0,normalized={kind:"diagnostic",code:"pptx-slide-render-error",cause:detail?.error,fatal:detail?.fatal===!0,...page===void 0?{}:{page}};emit(Object.freeze(normalized))},onNodeError=event=>{const detail=event.detail,nodeId=typeof detail?.nodeId=="string"&&detail.nodeId.length<=1024?detail.nodeId:void 0,normalized={kind:"diagnostic",code:"pptx-node-render-error",cause:detail?.error,fatal:detail?.fatal===!0,...nodeId===void 0?{}:{nodeId}};emit(Object.freeze(normalized))};return viewer.addEventListener("slidechange",onSlideChange),viewer.addEventListener("slideerror",onSlideError),viewer.addEventListener("nodeerror",onNodeError),Object.freeze({get slideCount(){return viewer.slideCount},get currentSlideIndex(){return viewer.currentSlideIndex},goToSlide:async index=>{await viewer.goToSlide(index)},searchText:(query,options)=>viewer.searchText(query,options),highlightSearchResult:async(result,options)=>viewer.highlightSearchResult(result,options),renderThumbnailToContainer(index,container,options){if(!Number.isSafeInteger(index)||index<0||index>=viewer.slideCount)return null;const width=options?.width;if(width!==void 0&&(!Number.isFinite(width)||width<=0))return null;const raw=viewer.renderThumbnailToContainer(index,container,options);if(!raw||typeof raw.dispose!="function"||typeof raw.ready?.then!="function")return null;let disposed=!1;return Object.freeze({ready:Promise.resolve(raw.ready),dispose(){disposed||(disposed=!0,raw.dispose())}})},clearSearchHighlights:()=>viewer.clearSearchHighlights(),subscribe(listener){return destroyed?()=>{}:(listeners.add(listener),()=>listeners.delete(listener))},destroy(){destroyed||(destroyed=!0,viewer.removeEventListener("slidechange",onSlideChange),viewer.removeEventListener("slideerror",onSlideError),viewer.removeEventListener("nodeerror",onNodeError),listeners.clear(),viewer.destroy())}})}const pptxRenderer=createOptionalPeerLoader({load:()=>import("@aiden0z/pptx-renderer"),isCapability:hasPptxOpenCapability,warningKey:PPTX_RENDERER_WARNING_KEY,warning:PPTX_RENDERER_WARNING});function loadPptxRenderer(importer){return pptxRenderer.loadWith(importer)}function getPptxRenderer(){return override??pptxRenderer.get()}function __setPptxRendererForTesting(module){override=module===void 0?void 0:Promise.resolve(module),pptxRenderer.clear()}export{__setPptxRendererForTesting,adaptPptxViewer,getPptxRenderer,loadPptxRenderer};
1
+ import{createOptionalPeerLoader}from"../../../internal/optional-peer-capabilities.js";const PPTX_RENDERER_WARNING_KEY="lyra-pptx-viewer-renderer-unavailable",PPTX_RENDERER_WARNING="<lr-pptx-viewer> could not load its optional @aiden0z/pptx-renderer peer.",MAX_SAFE_PPTX_ZIP_LIMITS={maxEntries:4e3,maxEntryUncompressedBytes:32*1024*1024,maxTotalUncompressedBytes:256*1024*1024,maxMediaBytes:192*1024*1024,maxConcurrency:8};let override;function hasPptxOpenCapability(value){if(typeof value!="object"&&typeof value!="function"||value===null)return!1;const viewer=value.PptxViewer;if(typeof viewer!="object"&&typeof viewer!="function"||viewer===null||typeof viewer.open!="function")return!1;const limits=value.RECOMMENDED_ZIP_LIMITS;return typeof limits!="object"||limits===null?!1:Object.keys(MAX_SAFE_PPTX_ZIP_LIMITS).every(key=>{const candidate=limits[key];return Number.isSafeInteger(candidate)&&candidate>0&&candidate<=MAX_SAFE_PPTX_ZIP_LIMITS[key]})}function adaptPptxViewer(value){if(typeof value!="object"&&typeof value!="function"||value===null)return null;const candidate=value;if(!Number.isSafeInteger(candidate.slideCount)||candidate.slideCount<0||!Number.isSafeInteger(candidate.currentSlideIndex)||typeof candidate.goToSlide!="function"||typeof candidate.searchText!="function"||typeof candidate.highlightSearchResult!="function"||typeof candidate.renderThumbnailToContainer!="function"||typeof candidate.clearSearchHighlights!="function"||typeof candidate.destroy!="function"||typeof candidate.addEventListener!="function"||typeof candidate.removeEventListener!="function")return null;const viewer=candidate,listeners=new Set;let destroyed=!1;const emit=event=>{for(const listener of listeners)listener(event)},onSlideChange=event=>{const index=event.detail?.index;typeof index=="number"&&Number.isSafeInteger(index)&&index>=0&&index<viewer.slideCount&&emit(Object.freeze({kind:"slide-change",index}))},onSlideError=event=>{const detail=event.detail,page=typeof detail?.index=="number"&&Number.isSafeInteger(detail.index)&&detail.index>=0&&detail.index<viewer.slideCount?detail.index+1:void 0,normalized={kind:"diagnostic",code:"pptx-slide-render-error",cause:detail?.error,fatal:detail?.fatal===!0,...page===void 0?{}:{page}};emit(Object.freeze(normalized))},onNodeError=event=>{const detail=event.detail,nodeId=typeof detail?.nodeId=="string"&&detail.nodeId.length<=1024?detail.nodeId:void 0,normalized={kind:"diagnostic",code:"pptx-node-render-error",cause:detail?.error,fatal:detail?.fatal===!0,...nodeId===void 0?{}:{nodeId}};emit(Object.freeze(normalized))};return viewer.addEventListener("slidechange",onSlideChange),viewer.addEventListener("slideerror",onSlideError),viewer.addEventListener("nodeerror",onNodeError),Object.freeze({get slideCount(){return viewer.slideCount},get currentSlideIndex(){return viewer.currentSlideIndex},goToSlide:async index=>{await viewer.goToSlide(index)},searchText:(query,options)=>viewer.searchText(query,options),highlightSearchResult:async(result,options)=>viewer.highlightSearchResult(result,options),renderThumbnailToContainer(index,container,options){if(!Number.isSafeInteger(index)||index<0||index>=viewer.slideCount)return null;const width=options?.width;if(width!==void 0&&(!Number.isFinite(width)||width<=0))return null;const raw=viewer.renderThumbnailToContainer(index,container,options);if(!raw||typeof raw.dispose!="function"||typeof raw.ready?.then!="function")return null;let disposed=!1;return Object.freeze({ready:Promise.resolve(raw.ready),dispose(){disposed||(disposed=!0,raw.dispose())}})},clearSearchHighlights:()=>viewer.clearSearchHighlights(),subscribe(listener){return destroyed?()=>{}:(listeners.add(listener),()=>listeners.delete(listener))},destroy(){destroyed||(destroyed=!0,viewer.removeEventListener("slidechange",onSlideChange),viewer.removeEventListener("slideerror",onSlideError),viewer.removeEventListener("nodeerror",onNodeError),listeners.clear(),viewer.destroy())}})}const pptxRenderer=createOptionalPeerLoader({load:()=>(async()=>{try{return await import("@aiden0z/pptx-renderer")}catch(e){throw e}})(),isCapability:hasPptxOpenCapability,warningKey:PPTX_RENDERER_WARNING_KEY,warning:PPTX_RENDERER_WARNING});function loadPptxRenderer(importer){return pptxRenderer.loadWith(importer)}function getPptxRenderer(){return override??pptxRenderer.get()}function __setPptxRendererForTesting(module){override=module===void 0?void 0:Promise.resolve(module),pptxRenderer.clear()}export{__setPptxRendererForTesting,adaptPptxViewer,getPptxRenderer,loadPptxRenderer};
@@ -1 +1 @@
1
- import{createOptionalPeerLoader}from"../../../internal/optional-peer-capabilities.js";const SPREADSHEET_WARNING_KEY="lyra-spreadsheet-viewer-xlsx-unavailable",SPREADSHEET_WARNING="<lr-spreadsheet-viewer> could not load its optional xlsx peer.";function isSheetJsApi(candidate){const api=candidate;return!!(api&&typeof api.read=="function"&&typeof api.utils?.sheet_to_json=="function")}const sheetJs=createOptionalPeerLoader({load:()=>import("xlsx"),isCapability:isSheetJsApi,warningKey:SPREADSHEET_WARNING_KEY,warning:SPREADSHEET_WARNING});function loadSheetJs(importXlsx){return sheetJs.loadWith(importXlsx)}function loadSheetJsCached(){return sheetJs.get()}function clearSheetJsCache(){sheetJs.clear()}export{clearSheetJsCache,loadSheetJs,loadSheetJsCached};
1
+ import{createOptionalPeerLoader}from"../../../internal/optional-peer-capabilities.js";const SPREADSHEET_WARNING_KEY="lyra-spreadsheet-viewer-xlsx-unavailable",SPREADSHEET_WARNING="<lr-spreadsheet-viewer> could not load its optional xlsx peer.";function isSheetJsApi(candidate){const api=candidate;return!!(api&&typeof api.read=="function"&&typeof api.utils?.sheet_to_json=="function")}const sheetJs=createOptionalPeerLoader({load:()=>(async()=>{try{return await import("xlsx")}catch(e){throw e}})(),isCapability:isSheetJsApi,warningKey:SPREADSHEET_WARNING_KEY,warning:SPREADSHEET_WARNING});function loadSheetJs(importXlsx){return sheetJs.loadWith(importXlsx)}function loadSheetJsCached(){return sheetJs.get()}function clearSheetJsCache(){sheetJs.clear()}export{clearSheetJsCache,loadSheetJs,loadSheetJsCached};
@@ -1 +1 @@
1
- import{clearDompurifyCache,loadDompurify}from"../../../internal/dompurify-loader.js";function loadSvgSanitizerDeps(importDompurify=()=>import("dompurify")){return loadDompurify(importDompurify)}function loadSvgSanitizer(){return loadDompurify()}function clearSvgSanitizerCache(){clearDompurifyCache()}export{clearSvgSanitizerCache,loadSvgSanitizer,loadSvgSanitizerDeps};
1
+ import{clearDompurifyCache,loadDompurify}from"../../../internal/dompurify-loader.js";function loadSvgSanitizerDeps(importDompurify=()=>(async()=>{try{return await import("dompurify")}catch(e){throw e}})()){return loadDompurify(importDompurify)}function loadSvgSanitizer(){return loadDompurify()}function clearSvgSanitizerCache(){clearDompurifyCache()}export{clearSvgSanitizerCache,loadSvgSanitizer,loadSvgSanitizerDeps};
@@ -1 +1 @@
1
- import{createOptionalPeerLoader,isHtmlSanitizer}from"./optional-peer-capabilities.js";const dompurify=createOptionalPeerLoader({load:()=>import("dompurify"),isCapability:isHtmlSanitizer,warningKey:"lyra-dompurify-unavailable",warning:"A lyra-ui component could not load its optional dompurify peer."});function loadDompurify(importer){return importer?dompurify.loadWith(importer):dompurify.get()}function clearDompurifyCache(){dompurify.clear()}export{clearDompurifyCache,loadDompurify};
1
+ import{createOptionalPeerLoader,isHtmlSanitizer}from"./optional-peer-capabilities.js";const dompurify=createOptionalPeerLoader({load:()=>(async()=>{try{return await import("dompurify")}catch(e){throw e}})(),isCapability:isHtmlSanitizer,warningKey:"lyra-dompurify-unavailable",warning:"A lyra-ui component could not load its optional dompurify peer."});function loadDompurify(importer){return importer?dompurify.loadWith(importer):dompurify.get()}function clearDompurifyCache(){dompurify.clear()}export{clearDompurifyCache,loadDompurify};
@@ -1 +1 @@
1
- const localeLoaders=Object.freeze({am:()=>import("@aceshooting/lyra-translations/am.js"),ar:()=>import("@aceshooting/lyra-translations/ar.js"),bg:()=>import("@aceshooting/lyra-translations/bg.js"),bho:()=>import("@aceshooting/lyra-translations/bho.js"),bn:()=>import("@aceshooting/lyra-translations/bn.js"),ca:()=>import("@aceshooting/lyra-translations/ca.js"),cs:()=>import("@aceshooting/lyra-translations/cs.js"),da:()=>import("@aceshooting/lyra-translations/da.js"),de:()=>import("@aceshooting/lyra-translations/de.js"),"de-CH":()=>import("@aceshooting/lyra-translations/de-CH.js"),el:()=>import("@aceshooting/lyra-translations/el.js"),"en-GB":()=>import("@aceshooting/lyra-translations/en-GB.js"),es:()=>import("@aceshooting/lyra-translations/es.js"),"es-419":()=>import("@aceshooting/lyra-translations/es-419.js"),et:()=>import("@aceshooting/lyra-translations/et.js"),fa:()=>import("@aceshooting/lyra-translations/fa.js"),"fa-AF":()=>import("@aceshooting/lyra-translations/fa-AF.js"),fi:()=>import("@aceshooting/lyra-translations/fi.js"),fil:()=>import("@aceshooting/lyra-translations/tl.js"),fr:()=>import("@aceshooting/lyra-translations/fr.js"),"fr-CA":()=>import("@aceshooting/lyra-translations/fr-CA.js"),ga:()=>import("@aceshooting/lyra-translations/ga.js"),gu:()=>import("@aceshooting/lyra-translations/gu.js"),ha:()=>import("@aceshooting/lyra-translations/ha.js"),he:()=>import("@aceshooting/lyra-translations/he.js"),hi:()=>import("@aceshooting/lyra-translations/hi.js"),hr:()=>import("@aceshooting/lyra-translations/hr.js"),hu:()=>import("@aceshooting/lyra-translations/hu.js"),id:()=>import("@aceshooting/lyra-translations/id.js"),ig:()=>import("@aceshooting/lyra-translations/ig.js"),it:()=>import("@aceshooting/lyra-translations/it.js"),ja:()=>import("@aceshooting/lyra-translations/ja.js"),jv:()=>import("@aceshooting/lyra-translations/jv.js"),kk:()=>import("@aceshooting/lyra-translations/kk.js"),kn:()=>import("@aceshooting/lyra-translations/kn.js"),ko:()=>import("@aceshooting/lyra-translations/ko.js"),lah:()=>import("@aceshooting/lyra-translations/pnb.js"),ln:()=>import("@aceshooting/lyra-translations/ln.js"),lt:()=>import("@aceshooting/lyra-translations/lt.js"),lv:()=>import("@aceshooting/lyra-translations/lv.js"),ml:()=>import("@aceshooting/lyra-translations/ml.js"),mr:()=>import("@aceshooting/lyra-translations/mr.js"),ms:()=>import("@aceshooting/lyra-translations/ms.js"),mt:()=>import("@aceshooting/lyra-translations/mt.js"),my:()=>import("@aceshooting/lyra-translations/my.js"),nb:()=>import("@aceshooting/lyra-translations/nb.js"),ne:()=>import("@aceshooting/lyra-translations/ne.js"),nl:()=>import("@aceshooting/lyra-translations/nl.js"),nn:()=>import("@aceshooting/lyra-translations/nn.js"),om:()=>import("@aceshooting/lyra-translations/om.js"),or:()=>import("@aceshooting/lyra-translations/or.js"),pa:()=>import("@aceshooting/lyra-translations/pa.js"),pcm:()=>import("@aceshooting/lyra-translations/pcm.js"),pl:()=>import("@aceshooting/lyra-translations/pl.js"),ps:()=>import("@aceshooting/lyra-translations/ps.js"),"pt-BR":()=>import("@aceshooting/lyra-translations/pt-BR.js"),"pt-PT":()=>import("@aceshooting/lyra-translations/pt-PT.js"),ro:()=>import("@aceshooting/lyra-translations/ro.js"),ru:()=>import("@aceshooting/lyra-translations/ru.js"),sd:()=>import("@aceshooting/lyra-translations/sd.js"),sk:()=>import("@aceshooting/lyra-translations/sk.js"),sl:()=>import("@aceshooting/lyra-translations/sl.js"),sr:()=>import("@aceshooting/lyra-translations/sr.js"),"sr-Latn":()=>import("@aceshooting/lyra-translations/sr-Latn.js"),su:()=>import("@aceshooting/lyra-translations/su.js"),sv:()=>import("@aceshooting/lyra-translations/sv.js"),sw:()=>import("@aceshooting/lyra-translations/sw.js"),ta:()=>import("@aceshooting/lyra-translations/ta.js"),te:()=>import("@aceshooting/lyra-translations/te.js"),th:()=>import("@aceshooting/lyra-translations/th.js"),tr:()=>import("@aceshooting/lyra-translations/tr.js"),uk:()=>import("@aceshooting/lyra-translations/uk.js"),ur:()=>import("@aceshooting/lyra-translations/ur.js"),uz:()=>import("@aceshooting/lyra-translations/uz.js"),vi:()=>import("@aceshooting/lyra-translations/vi.js"),yo:()=>import("@aceshooting/lyra-translations/yo.js"),"zh-CN":()=>import("@aceshooting/lyra-translations/zh-CN.js"),"zh-HK":()=>import("@aceshooting/lyra-translations/zh-HK.js"),"zh-TW":()=>import("@aceshooting/lyra-translations/zh-TW.js"),zu:()=>import("@aceshooting/lyra-translations/zu.js")});export{localeLoaders};
1
+ const localeLoaders=Object.freeze({am:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/am.js")}catch(e){throw e}})(),ar:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/ar.js")}catch(e){throw e}})(),bg:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/bg.js")}catch(e){throw e}})(),bho:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/bho.js")}catch(e){throw e}})(),bn:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/bn.js")}catch(e){throw e}})(),ca:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/ca.js")}catch(e){throw e}})(),cs:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/cs.js")}catch(e){throw e}})(),da:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/da.js")}catch(e){throw e}})(),de:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/de.js")}catch(e){throw e}})(),"de-CH":()=>(async()=>{try{return await import("@aceshooting/lyra-translations/de-CH.js")}catch(e){throw e}})(),el:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/el.js")}catch(e){throw e}})(),"en-GB":()=>(async()=>{try{return await import("@aceshooting/lyra-translations/en-GB.js")}catch(e){throw e}})(),es:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/es.js")}catch(e){throw e}})(),"es-419":()=>(async()=>{try{return await import("@aceshooting/lyra-translations/es-419.js")}catch(e){throw e}})(),et:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/et.js")}catch(e){throw e}})(),fa:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/fa.js")}catch(e){throw e}})(),"fa-AF":()=>(async()=>{try{return await import("@aceshooting/lyra-translations/fa-AF.js")}catch(e){throw e}})(),fi:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/fi.js")}catch(e){throw e}})(),fil:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/tl.js")}catch(e){throw e}})(),fr:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/fr.js")}catch(e){throw e}})(),"fr-CA":()=>(async()=>{try{return await import("@aceshooting/lyra-translations/fr-CA.js")}catch(e){throw e}})(),ga:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/ga.js")}catch(e){throw e}})(),gu:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/gu.js")}catch(e){throw e}})(),ha:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/ha.js")}catch(e){throw e}})(),he:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/he.js")}catch(e){throw e}})(),hi:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/hi.js")}catch(e){throw e}})(),hr:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/hr.js")}catch(e){throw e}})(),hu:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/hu.js")}catch(e){throw e}})(),id:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/id.js")}catch(e){throw e}})(),ig:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/ig.js")}catch(e){throw e}})(),it:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/it.js")}catch(e){throw e}})(),ja:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/ja.js")}catch(e){throw e}})(),jv:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/jv.js")}catch(e){throw e}})(),kk:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/kk.js")}catch(e){throw e}})(),kn:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/kn.js")}catch(e){throw e}})(),ko:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/ko.js")}catch(e){throw e}})(),lah:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/pnb.js")}catch(e){throw e}})(),ln:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/ln.js")}catch(e){throw e}})(),lt:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/lt.js")}catch(e){throw e}})(),lv:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/lv.js")}catch(e){throw e}})(),ml:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/ml.js")}catch(e){throw e}})(),mr:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/mr.js")}catch(e){throw e}})(),ms:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/ms.js")}catch(e){throw e}})(),mt:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/mt.js")}catch(e){throw e}})(),my:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/my.js")}catch(e){throw e}})(),nb:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/nb.js")}catch(e){throw e}})(),ne:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/ne.js")}catch(e){throw e}})(),nl:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/nl.js")}catch(e){throw e}})(),nn:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/nn.js")}catch(e){throw e}})(),om:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/om.js")}catch(e){throw e}})(),or:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/or.js")}catch(e){throw e}})(),pa:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/pa.js")}catch(e){throw e}})(),pcm:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/pcm.js")}catch(e){throw e}})(),pl:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/pl.js")}catch(e){throw e}})(),ps:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/ps.js")}catch(e){throw e}})(),"pt-BR":()=>(async()=>{try{return await import("@aceshooting/lyra-translations/pt-BR.js")}catch(e){throw e}})(),"pt-PT":()=>(async()=>{try{return await import("@aceshooting/lyra-translations/pt-PT.js")}catch(e){throw e}})(),ro:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/ro.js")}catch(e){throw e}})(),ru:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/ru.js")}catch(e){throw e}})(),sd:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/sd.js")}catch(e){throw e}})(),sk:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/sk.js")}catch(e){throw e}})(),sl:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/sl.js")}catch(e){throw e}})(),sr:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/sr.js")}catch(e){throw e}})(),"sr-Latn":()=>(async()=>{try{return await import("@aceshooting/lyra-translations/sr-Latn.js")}catch(e){throw e}})(),su:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/su.js")}catch(e){throw e}})(),sv:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/sv.js")}catch(e){throw e}})(),sw:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/sw.js")}catch(e){throw e}})(),ta:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/ta.js")}catch(e){throw e}})(),te:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/te.js")}catch(e){throw e}})(),th:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/th.js")}catch(e){throw e}})(),tr:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/tr.js")}catch(e){throw e}})(),uk:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/uk.js")}catch(e){throw e}})(),ur:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/ur.js")}catch(e){throw e}})(),uz:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/uz.js")}catch(e){throw e}})(),vi:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/vi.js")}catch(e){throw e}})(),yo:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/yo.js")}catch(e){throw e}})(),"zh-CN":()=>(async()=>{try{return await import("@aceshooting/lyra-translations/zh-CN.js")}catch(e){throw e}})(),"zh-HK":()=>(async()=>{try{return await import("@aceshooting/lyra-translations/zh-HK.js")}catch(e){throw e}})(),"zh-TW":()=>(async()=>{try{return await import("@aceshooting/lyra-translations/zh-TW.js")}catch(e){throw e}})(),zu:()=>(async()=>{try{return await import("@aceshooting/lyra-translations/zu.js")}catch(e){throw e}})()});export{localeLoaders};
@@ -1 +1 @@
1
- import{resolveOptionalPeerCapability}from"./optional-peer-capabilities.js";const handleMethods=["invalidateStyle","styleReady","requestFrame","setVisible","pick","dispose"];function isMapSceneLayerRuntime(value){return typeof value=="object"&&value!==null&&"createSceneLayer"in value&&typeof value.createSceneLayer=="function"}function isMapSceneLayerHandle(value){return typeof value=="object"&&value!==null&&handleMethods.every(name=>typeof Reflect.get(value,name)=="function")}const defaultImporter=()=>import("@aceshooting/lyra-map/scene");let importer=defaultImporter,pending;function loadMapSceneLayerRuntime(){if(pending)return pending;const attempt=importer().then(module=>{const runtime=resolveOptionalPeerCapability(module,isMapSceneLayerRuntime);if(!runtime)throw new TypeError("Map custom layers are unavailable");return runtime});return pending=attempt,attempt.catch(()=>{pending===attempt&&(pending=void 0)}),attempt}function __setMapSceneLayerImporterForTesting(next){importer=next??defaultImporter,pending=void 0}export{__setMapSceneLayerImporterForTesting,isMapSceneLayerHandle,loadMapSceneLayerRuntime};
1
+ import{resolveOptionalPeerCapability}from"./optional-peer-capabilities.js";const handleMethods=["invalidateStyle","styleReady","requestFrame","setVisible","pick","dispose"];function isMapSceneLayerRuntime(value){return typeof value=="object"&&value!==null&&"createSceneLayer"in value&&typeof value.createSceneLayer=="function"}function isMapSceneLayerHandle(value){return typeof value=="object"&&value!==null&&handleMethods.every(name=>typeof Reflect.get(value,name)=="function")}const defaultImporter=()=>(async()=>{try{return await import("@aceshooting/lyra-map/scene")}catch(e){throw e}})();let importer=defaultImporter,pending;function loadMapSceneLayerRuntime(){if(pending)return pending;const attempt=importer().then(module=>{const runtime=resolveOptionalPeerCapability(module,isMapSceneLayerRuntime);if(!runtime)throw new TypeError("Map custom layers are unavailable");return runtime});return pending=attempt,attempt.catch(()=>{pending===attempt&&(pending=void 0)}),attempt}function __setMapSceneLayerImporterForTesting(next){importer=next??defaultImporter,pending=void 0}export{__setMapSceneLayerImporterForTesting,isMapSceneLayerHandle,loadMapSceneLayerRuntime};
@@ -1,4 +1,4 @@
1
- import{html,nothing}from"lit";import{literalSetConverter}from"./converters.js";import{snapshotPublicCollection}from"./collection-snapshot.js";import{isObjectValue,readOwnDataValue}from"./data-descriptors.js";import{finiteRange}from"./numbers.js";import{createEngine3dLoader}from"./engine-3d-loader.js";import{Engine3dSelection,ENGINE_3D_REASON_MESSAGE,ENGINE_3D_SHOWING_MESSAGE,engine3dFailureReason,webgl2Available}from"./engine-3d.js";import{AnnouncementSinkController}from"./announcer.js";import{isAccessibilityVisible}from"./accessibility-visibility.js";import{resolveCanvasColor}from"./canvas-color.js";import{tag}from"./prefix.js";const PANORAMA_PROJECTION=literalSetConverter(["flat","equirectangular"],"flat"),PANORAMA_DEFAULT_CAMERA=Object.freeze({yaw:0,pitch:0,fieldOfView:75}),panoramaLoader=createEngine3dLoader({entry:"panorama",tag:tag("image-viewer"),load:()=>import("@aceshooting/lyra-3d/panorama")}),panoramaEnvironment={available:owner=>webgl2Available(()=>owner.createElement("canvas"))};function normalizePanoramaCamera(value){if(!isObjectValue(value))return PANORAMA_DEFAULT_CAMERA;const number=key=>{const entry=readOwnDataValue(value,key);return typeof entry=="number"?entry:NaN},yaw=finiteRange(number("yaw"),0);return Object.freeze({yaw:((yaw+Math.PI)%(Math.PI*2)+Math.PI*2)%(Math.PI*2)-Math.PI,pitch:finiteRange(number("pitch"),0,-Math.PI/2+.01,Math.PI/2-.01),fieldOfView:finiteRange(number("fieldOfView"),75,20,100)})}function snapshotPanoramaHotspots(value,owner){const source=snapshotPublicCollection(value,owner);if(!Array.isArray(source))return Object.freeze([]);const seen=new Set,result=[];for(const item of source){const id=readOwnDataValue(item,"id"),yaw=readOwnDataValue(item,"yaw"),pitch=readOwnDataValue(item,"pitch"),label=readOwnDataValue(item,"label");typeof id!="string"||!id.trim()||seen.has(id)||typeof yaw!="number"||!Number.isFinite(yaw)||typeof pitch!="number"||!Number.isFinite(pitch)||Math.abs(pitch)>Math.PI/2||(seen.add(id),result.push(Object.freeze({id,yaw:normalizePanoramaCamera({yaw}).yaw,pitch,...typeof label=="string"?{label}:{}})))}return Object.freeze(result)}class PanoramaController{constructor(host,options){this.host=host,this.options=options,this.selection=new Engine3dSelection(!0),this.ready=!1,this.loading=!1,this.notice=null,this.software=!1,this.enabled=!1,this.media=null,this.mediaRevision=-1,this.hotspots=[],this.camera=PANORAMA_DEFAULT_CAMERA,this.container=null,this.generation=0,this.revision=0,this.attempted=!1,this.pending=!1,this.intersecting=!1,this.cleanups=[],this.cursor=0,this.announcements=new AnnouncementSinkController(host,{eager:["assertive"]})}release(){this.generation++,this.intersection?.disconnect(),this.intersection=void 0,this.eligibility?.disconnect(),this.eligibility=void 0,this.intersecting=!1,this.resize?.disconnect(),this.resize=void 0,this.theme?.disconnect(),this.theme=void 0;for(const cleanup of this.cleanups)cleanup();this.cleanups=[];const engine=this.engine;this.engine=void 0,this.ready=this.loading=this.pending=!1,engine?.dispose()}invalidate(){this.release(),this.attempted=!1,this.notice=null,this.software=!1,this.selection.prefer(this.enabled?"webgl":"builtin")}disconnect(){this.invalidate(),this.media=null,this.container=null}adopted(){this.disconnect(),this.announcements.adopted()}update(enabled,media,mediaRevision,hotspots,camera,container){(enabled!==this.enabled||media!==this.media||mediaRevision!==this.mediaRevision||hotspots!==this.hotspots||container!==this.container)&&(this.invalidate(),this.enabled=enabled,this.media=media,this.mediaRevision=mediaRevision,this.hotspots=hotspots,this.container=container,this.cursor=Math.min(this.cursor,Math.max(0,hotspots.length-1)),this.selection.prefer(enabled?"webgl":"builtin"),this.options.changed());const cameraChanged=camera!==this.camera;if(this.camera=camera,!enabled||!media||!container||!this.host.isConnected)return;if(this.ready){cameraChanged&&this.command(()=>this.engine?.setCamera(camera));return}if(this.pending||this.attempted||this.intersection||this.eligibility)return;const view=this.host.ownerDocument.defaultView,generation=this.generation;this.intersecting=view?.IntersectionObserver===void 0;const admit=()=>{generation!==this.generation||this.pending||this.attempted||!this.intersecting||!isAccessibilityVisible(this.host)||(this.intersection?.disconnect(),this.intersection=void 0,this.eligibility?.disconnect(),this.eligibility=void 0,this.start())};if(view?.IntersectionObserver&&(this.intersection=new view.IntersectionObserver(entries=>{if(generation===this.generation){for(const entry of entries)entry.target===container&&(this.intersecting=entry.isIntersecting);admit()}}),this.intersection.observe(container)),view?.MutationObserver){this.eligibility=new view.MutationObserver(admit);let ancestor=this.host,depth=0;for(;ancestor&&depth++<=256;){this.eligibility.observe(ancestor,{attributes:!0,attributeFilter:["aria-hidden","inert","hidden","style","class","open"]});const root=ancestor.getRootNode();ancestor=ancestor.assignedSlot??ancestor.parentElement??(root instanceof view.ShadowRoot?root.host:null)}}admit()}fail(reason){const detail=this.selection.renderer==="webgl"?this.selection.fail(reason):null;this.ready=this.loading=!1,reason!=="context-lost"&&(this.release(),this.attempted=!0),detail&&(this.notice=detail,this.options.changed(),this.announcements.announceAssertive(this.options.localize(ENGINE_3D_REASON_MESSAGE[detail.reason])),this.announcements.announcePolite(this.options.localize(ENGINE_3D_SHOWING_MESSAGE[detail.to])),this.options.fallback(detail))}command(run){const generation=this.generation,engine=this.engine;try{run()}catch{generation===this.generation&&engine===this.engine&&this.fail("error")}}async start(){const owner=this.host.ownerDocument,container=this.container,media=this.media,hotspots=this.hotspots;if(!this.enabled||!container||!media||!this.host.isConnected)return;const generation=this.generation,current=()=>generation===this.generation&&this.host.isConnected&&this.host.ownerDocument===owner;if(this.pending=this.attempted=!0,!panoramaEnvironment.available(owner)){this.fail("unsupported");return}this.loading=!0,this.options.changed();let engine=null,owned=!1;try{if(engine=await panoramaLoader.create(),!current()){engine?.dispose();return}if(!engine){this.fail("unavailable");return}if(this.engine=engine,owned=!0,await engine.mount(container,{hover:index=>{current()&&this.ready&&this.command(()=>engine.setState?.({selected:new Set,dimmed:new Set,hover:index??-1,focus:this.cursor}))},pick:index=>{current()&&this.ready&&index!==null&&this.activate(index)},camera:value=>{current()&&this.ready&&(this.camera=normalizePanoramaCamera(value),this.options.camera(this.camera))},lost:reason=>{current()&&this.fail(reason)},restored:()=>{!current()||!this.engine||!this.selection.restore()||this.command(()=>{engine.setStyle(this.style()),current()&&(engine.setCamera(this.camera),current()&&(engine.setState?.({selected:new Set,dimmed:new Set,hover:-1,focus:this.cursor}),current()&&(this.ready=!0,this.notice=null,this.options.changed())))})},rendering:value=>{current()&&(this.software=value.software,this.options.changed())}}),!current()||(engine.setStyle(this.style()),!current()))return;const angles=new Float32Array(hotspots.length*2);if(hotspots.forEach((hotspot,index)=>{angles[index*2]=hotspot.yaw,angles[index*2+1]=hotspot.pitch}),engine.setData({source:media.localName==="video"?{kind:"video",video:media}:{kind:"image",image:media},hotspotAngles:angles},++this.revision),!current()||(engine.setCamera(this.camera),!current()))return;const resize=()=>{if(!current())return;const box=container.getBoundingClientRect();engine.resize(Math.max(1,box.width),Math.max(1,box.height))};if(resize(),!current())return;const view=owner.defaultView;view?.ResizeObserver&&(this.resize=new view.ResizeObserver(()=>{current()&&this.ready&&this.command(resize)}),this.resize.observe(container));const restyle=()=>{current()&&this.ready&&this.command(()=>engine.setStyle(this.style()))};if(view?.MutationObserver){this.theme=new view.MutationObserver(restyle);let ancestor=this.host;for(;ancestor;){this.theme.observe(ancestor,{attributes:!0});const root=ancestor.getRootNode();ancestor=ancestor.parentElement??(root instanceof view.ShadowRoot?root.host:null)}}for(const query of["(prefers-reduced-motion: reduce)","(forced-colors: active)","(prefers-color-scheme: dark)"]){const mediaQuery=view?.matchMedia(query);mediaQuery?.addEventListener("change",restyle),mediaQuery&&this.cleanups.push(()=>mediaQuery.removeEventListener("change",restyle))}this.pending=this.loading=!1,this.ready=this.selection.renderer==="webgl",this.options.changed()}catch(error){if(!current()){owned||engine?.dispose();return}this.fail(engine3dFailureReason(error))}}style(){const view=this.host.ownerDocument.defaultView,computed=view.getComputedStyle(this.host),canvas=this.host.ownerDocument.createElement("canvas");canvas.width=canvas.height=1;const context=canvas.getContext("2d",{willReadFrequently:!0}),color=name=>{const value=resolveCanvasColor(this.host,`var(${name})`,computed.color);if(!context)return value;context.clearRect(0,0,1,1),context.fillStyle=value,context.fillRect(0,0,1,1);const rgba=context.getImageData(0,0,1,1).data;return`rgba(${rgba[0]}, ${rgba[1]}, ${rgba[2]}, ${rgba[3]/255})`};return{background:color("--lr-color-surface"),foreground:color("--lr-color-text"),muted:color("--lr-color-text-quiet"),accent:color("--lr-color-brand"),focus:color("--lr-focus-ring-color"),palette:[color("--lr-color-brand")],fontFamily:computed.fontFamily,fontSize:finiteRange(Number.parseFloat(computed.fontSize),14,1,128),pointSize:24,lineWidth:1,devicePixelRatio:finiteRange(view.devicePixelRatio,1,.25,4),reducedMotion:view.matchMedia("(prefers-reduced-motion: reduce)").matches,forcedColors:view.matchMedia("(forced-colors: active)").matches}}activate(index){const hotspot=this.hotspots[index];!hotspot||!Number.isSafeInteger(index)||(this.cursor=index,this.options.changed(),this.options.pick({hotspot,id:hotspot.id,index}))}keydown(event,direction){if(!this.ready||event.target!==event.currentTarget)return;const sign=direction==="rtl"?-1:1;let{yaw,pitch,fieldOfView}=this.camera;switch(event.key){case"ArrowLeft":yaw-=sign*Math.PI/18;break;case"ArrowRight":yaw+=sign*Math.PI/18;break;case"ArrowUp":pitch+=Math.PI/18;break;case"ArrowDown":pitch-=Math.PI/18;break;case"+":case"=":fieldOfView-=5;break;case"-":case"_":fieldOfView+=5;break;case"Home":yaw=pitch=0,fieldOfView=75;break;default:return}event.preventDefault(),event.stopPropagation(),this.camera=normalizePanoramaCamera({yaw,pitch,fieldOfView});const generation=this.generation;this.command(()=>this.engine?.setCamera(this.camera)),generation===this.generation&&this.ready&&this.options.camera(this.camera)}renderViewport(label,enabled){return enabled?html`<div part="panorama" role="group" aria-label=${label} aria-description=${this.options.localize("panoramaInstructions")}
1
+ import{html,nothing}from"lit";import{literalSetConverter}from"./converters.js";import{snapshotPublicCollection}from"./collection-snapshot.js";import{isObjectValue,readOwnDataValue}from"./data-descriptors.js";import{finiteRange}from"./numbers.js";import{createEngine3dLoader}from"./engine-3d-loader.js";import{Engine3dSelection,ENGINE_3D_REASON_MESSAGE,ENGINE_3D_SHOWING_MESSAGE,engine3dFailureReason,webgl2Available}from"./engine-3d.js";import{AnnouncementSinkController}from"./announcer.js";import{isAccessibilityVisible}from"./accessibility-visibility.js";import{resolveCanvasColor}from"./canvas-color.js";import{tag}from"./prefix.js";const PANORAMA_PROJECTION=literalSetConverter(["flat","equirectangular"],"flat"),PANORAMA_DEFAULT_CAMERA=Object.freeze({yaw:0,pitch:0,fieldOfView:75}),panoramaLoader=createEngine3dLoader({entry:"panorama",tag:tag("image-viewer"),load:()=>(async()=>{try{return await import("@aceshooting/lyra-3d/panorama")}catch(e){throw e}})()}),panoramaEnvironment={available:owner=>webgl2Available(()=>owner.createElement("canvas"))};function normalizePanoramaCamera(value){if(!isObjectValue(value))return PANORAMA_DEFAULT_CAMERA;const number=key=>{const entry=readOwnDataValue(value,key);return typeof entry=="number"?entry:NaN},yaw=finiteRange(number("yaw"),0);return Object.freeze({yaw:((yaw+Math.PI)%(Math.PI*2)+Math.PI*2)%(Math.PI*2)-Math.PI,pitch:finiteRange(number("pitch"),0,-Math.PI/2+.01,Math.PI/2-.01),fieldOfView:finiteRange(number("fieldOfView"),75,20,100)})}function snapshotPanoramaHotspots(value,owner){const source=snapshotPublicCollection(value,owner);if(!Array.isArray(source))return Object.freeze([]);const seen=new Set,result=[];for(const item of source){const id=readOwnDataValue(item,"id"),yaw=readOwnDataValue(item,"yaw"),pitch=readOwnDataValue(item,"pitch"),label=readOwnDataValue(item,"label");typeof id!="string"||!id.trim()||seen.has(id)||typeof yaw!="number"||!Number.isFinite(yaw)||typeof pitch!="number"||!Number.isFinite(pitch)||Math.abs(pitch)>Math.PI/2||(seen.add(id),result.push(Object.freeze({id,yaw:normalizePanoramaCamera({yaw}).yaw,pitch,...typeof label=="string"?{label}:{}})))}return Object.freeze(result)}class PanoramaController{constructor(host,options){this.host=host,this.options=options,this.selection=new Engine3dSelection(!0),this.ready=!1,this.loading=!1,this.notice=null,this.software=!1,this.enabled=!1,this.media=null,this.mediaRevision=-1,this.hotspots=[],this.camera=PANORAMA_DEFAULT_CAMERA,this.container=null,this.generation=0,this.revision=0,this.attempted=!1,this.pending=!1,this.intersecting=!1,this.cleanups=[],this.cursor=0,this.announcements=new AnnouncementSinkController(host,{eager:["assertive"]})}release(){this.generation++,this.intersection?.disconnect(),this.intersection=void 0,this.eligibility?.disconnect(),this.eligibility=void 0,this.intersecting=!1,this.resize?.disconnect(),this.resize=void 0,this.theme?.disconnect(),this.theme=void 0;for(const cleanup of this.cleanups)cleanup();this.cleanups=[];const engine=this.engine;this.engine=void 0,this.ready=this.loading=this.pending=!1,engine?.dispose()}invalidate(){this.release(),this.attempted=!1,this.notice=null,this.software=!1,this.selection.prefer(this.enabled?"webgl":"builtin")}disconnect(){this.invalidate(),this.media=null,this.container=null}adopted(){this.disconnect(),this.announcements.adopted()}update(enabled,media,mediaRevision,hotspots,camera,container){(enabled!==this.enabled||media!==this.media||mediaRevision!==this.mediaRevision||hotspots!==this.hotspots||container!==this.container)&&(this.invalidate(),this.enabled=enabled,this.media=media,this.mediaRevision=mediaRevision,this.hotspots=hotspots,this.container=container,this.cursor=Math.min(this.cursor,Math.max(0,hotspots.length-1)),this.selection.prefer(enabled?"webgl":"builtin"),this.options.changed());const cameraChanged=camera!==this.camera;if(this.camera=camera,!enabled||!media||!container||!this.host.isConnected)return;if(this.ready){cameraChanged&&this.command(()=>this.engine?.setCamera(camera));return}if(this.pending||this.attempted||this.intersection||this.eligibility)return;const view=this.host.ownerDocument.defaultView,generation=this.generation;this.intersecting=view?.IntersectionObserver===void 0;const admit=()=>{generation!==this.generation||this.pending||this.attempted||!this.intersecting||!isAccessibilityVisible(this.host)||(this.intersection?.disconnect(),this.intersection=void 0,this.eligibility?.disconnect(),this.eligibility=void 0,this.start())};if(view?.IntersectionObserver&&(this.intersection=new view.IntersectionObserver(entries=>{if(generation===this.generation){for(const entry of entries)entry.target===container&&(this.intersecting=entry.isIntersecting);admit()}}),this.intersection.observe(container)),view?.MutationObserver){this.eligibility=new view.MutationObserver(admit);let ancestor=this.host,depth=0;for(;ancestor&&depth++<=256;){this.eligibility.observe(ancestor,{attributes:!0,attributeFilter:["aria-hidden","inert","hidden","style","class","open"]});const root=ancestor.getRootNode();ancestor=ancestor.assignedSlot??ancestor.parentElement??(root instanceof view.ShadowRoot?root.host:null)}}admit()}fail(reason){const detail=this.selection.renderer==="webgl"?this.selection.fail(reason):null;this.ready=this.loading=!1,reason!=="context-lost"&&(this.release(),this.attempted=!0),detail&&(this.notice=detail,this.options.changed(),this.announcements.announceAssertive(this.options.localize(ENGINE_3D_REASON_MESSAGE[detail.reason])),this.announcements.announcePolite(this.options.localize(ENGINE_3D_SHOWING_MESSAGE[detail.to])),this.options.fallback(detail))}command(run){const generation=this.generation,engine=this.engine;try{run()}catch{generation===this.generation&&engine===this.engine&&this.fail("error")}}async start(){const owner=this.host.ownerDocument,container=this.container,media=this.media,hotspots=this.hotspots;if(!this.enabled||!container||!media||!this.host.isConnected)return;const generation=this.generation,current=()=>generation===this.generation&&this.host.isConnected&&this.host.ownerDocument===owner;if(this.pending=this.attempted=!0,!panoramaEnvironment.available(owner)){this.fail("unsupported");return}this.loading=!0,this.options.changed();let engine=null,owned=!1;try{if(engine=await panoramaLoader.create(),!current()){engine?.dispose();return}if(!engine){this.fail("unavailable");return}if(this.engine=engine,owned=!0,await engine.mount(container,{hover:index=>{current()&&this.ready&&this.command(()=>engine.setState?.({selected:new Set,dimmed:new Set,hover:index??-1,focus:this.cursor}))},pick:index=>{current()&&this.ready&&index!==null&&this.activate(index)},camera:value=>{current()&&this.ready&&(this.camera=normalizePanoramaCamera(value),this.options.camera(this.camera))},lost:reason=>{current()&&this.fail(reason)},restored:()=>{!current()||!this.engine||!this.selection.restore()||this.command(()=>{engine.setStyle(this.style()),current()&&(engine.setCamera(this.camera),current()&&(engine.setState?.({selected:new Set,dimmed:new Set,hover:-1,focus:this.cursor}),current()&&(this.ready=!0,this.notice=null,this.options.changed())))})},rendering:value=>{current()&&(this.software=value.software,this.options.changed())}}),!current()||(engine.setStyle(this.style()),!current()))return;const angles=new Float32Array(hotspots.length*2);if(hotspots.forEach((hotspot,index)=>{angles[index*2]=hotspot.yaw,angles[index*2+1]=hotspot.pitch}),engine.setData({source:media.localName==="video"?{kind:"video",video:media}:{kind:"image",image:media},hotspotAngles:angles},++this.revision),!current()||(engine.setCamera(this.camera),!current()))return;const resize=()=>{if(!current())return;const box=container.getBoundingClientRect();engine.resize(Math.max(1,box.width),Math.max(1,box.height))};if(resize(),!current())return;const view=owner.defaultView;view?.ResizeObserver&&(this.resize=new view.ResizeObserver(()=>{current()&&this.ready&&this.command(resize)}),this.resize.observe(container));const restyle=()=>{current()&&this.ready&&this.command(()=>engine.setStyle(this.style()))};if(view?.MutationObserver){this.theme=new view.MutationObserver(restyle);let ancestor=this.host;for(;ancestor;){this.theme.observe(ancestor,{attributes:!0});const root=ancestor.getRootNode();ancestor=ancestor.parentElement??(root instanceof view.ShadowRoot?root.host:null)}}for(const query of["(prefers-reduced-motion: reduce)","(forced-colors: active)","(prefers-color-scheme: dark)"]){const mediaQuery=view?.matchMedia(query);mediaQuery?.addEventListener("change",restyle),mediaQuery&&this.cleanups.push(()=>mediaQuery.removeEventListener("change",restyle))}this.pending=this.loading=!1,this.ready=this.selection.renderer==="webgl",this.options.changed()}catch(error){if(!current()){owned||engine?.dispose();return}this.fail(engine3dFailureReason(error))}}style(){const view=this.host.ownerDocument.defaultView,computed=view.getComputedStyle(this.host),canvas=this.host.ownerDocument.createElement("canvas");canvas.width=canvas.height=1;const context=canvas.getContext("2d",{willReadFrequently:!0}),color=name=>{const value=resolveCanvasColor(this.host,`var(${name})`,computed.color);if(!context)return value;context.clearRect(0,0,1,1),context.fillStyle=value,context.fillRect(0,0,1,1);const rgba=context.getImageData(0,0,1,1).data;return`rgba(${rgba[0]}, ${rgba[1]}, ${rgba[2]}, ${rgba[3]/255})`};return{background:color("--lr-color-surface"),foreground:color("--lr-color-text"),muted:color("--lr-color-text-quiet"),accent:color("--lr-color-brand"),focus:color("--lr-focus-ring-color"),palette:[color("--lr-color-brand")],fontFamily:computed.fontFamily,fontSize:finiteRange(Number.parseFloat(computed.fontSize),14,1,128),pointSize:24,lineWidth:1,devicePixelRatio:finiteRange(view.devicePixelRatio,1,.25,4),reducedMotion:view.matchMedia("(prefers-reduced-motion: reduce)").matches,forcedColors:view.matchMedia("(forced-colors: active)").matches}}activate(index){const hotspot=this.hotspots[index];!hotspot||!Number.isSafeInteger(index)||(this.cursor=index,this.options.changed(),this.options.pick({hotspot,id:hotspot.id,index}))}keydown(event,direction){if(!this.ready||event.target!==event.currentTarget)return;const sign=direction==="rtl"?-1:1;let{yaw,pitch,fieldOfView}=this.camera;switch(event.key){case"ArrowLeft":yaw-=sign*Math.PI/18;break;case"ArrowRight":yaw+=sign*Math.PI/18;break;case"ArrowUp":pitch+=Math.PI/18;break;case"ArrowDown":pitch-=Math.PI/18;break;case"+":case"=":fieldOfView-=5;break;case"-":case"_":fieldOfView+=5;break;case"Home":yaw=pitch=0,fieldOfView=75;break;default:return}event.preventDefault(),event.stopPropagation(),this.camera=normalizePanoramaCamera({yaw,pitch,fieldOfView});const generation=this.generation;this.command(()=>this.engine?.setCamera(this.camera)),generation===this.generation&&this.ready&&this.options.camera(this.camera)}renderViewport(label,enabled){return enabled?html`<div part="panorama" role="group" aria-label=${label} aria-description=${this.options.localize("panoramaInstructions")}
2
2
  tabindex=${this.ready?"0":"-1"} ?data-ready=${this.ready} ?hidden=${this.notice!==null}
3
3
  @keydown=${event=>this.keydown(event,this.options.direction())}><div part="panorama-engine" aria-hidden="true"></div></div>`:nothing}renderNotice(){const notice=this.notice;return notice?html`<div part="panorama-notice"><p>${this.options.localize(ENGINE_3D_REASON_MESSAGE[notice.reason])}</p><p>${this.options.localize(ENGINE_3D_SHOWING_MESSAGE[notice.to])}</p></div>`:!this.loading&&!this.software?nothing:html`<p part="panorama-notice">${this.options.localize(this.loading?"engine3dLoading":"engine3dSoftwareRendering")}</p>`}renderHotspots(enabled){if(!enabled||!this.hotspots.length)return nothing;const start=Math.floor(this.cursor/200)*200,end=Math.min(this.hotspots.length,start+200),generation=this.generation,current=()=>this.host.isConnected&&generation===this.generation,move=(index,focus=!1)=>{current()&&(this.cursor=Math.max(0,Math.min(this.hotspots.length-1,index)),this.options.changed(),this.ready&&this.command(()=>this.engine?.setState?.({selected:new Set,dimmed:new Set,hover:-1,focus:this.cursor})),focus&&this.options.updated().then(()=>{current()&&this.host.shadowRoot?.querySelector(`[data-panorama-index="${this.cursor}"]`)?.focus()}))};return html`<div part="panorama-hotspots" role="group" aria-label=${this.options.localize("panoramaHotspotsLabel")}>
4
4
  ${this.hotspots.slice(start,end).map((hotspot,offset)=>{const index=start+offset;return html`<button part="panorama-hotspot" type="button" data-panorama-index=${index} tabindex=${index===this.cursor?"0":"-1"}
@@ -1 +1 @@
1
- const LYRA_PACKAGE_NAME="@aceshooting/lyra-ui",LYRA_PACKAGE_VERSION="30.8.0";export{LYRA_PACKAGE_NAME,LYRA_PACKAGE_VERSION};
1
+ const LYRA_PACKAGE_NAME="@aceshooting/lyra-ui",LYRA_PACKAGE_VERSION="30.9.0";export{LYRA_PACKAGE_NAME,LYRA_PACKAGE_VERSION};
@@ -1 +1 @@
1
- import{createOptionalPeerLoader}from"./optional-peer-capabilities.js";const PAPAPARSE_WARNING_KEY="lyra-papaparse-unavailable",PAPAPARSE_WARNING="A lyra-ui component could not load its optional papaparse peer.";function isPapaParseApi(value){return(typeof value=="object"||typeof value=="function")&&value!==null&&"parse"in value&&typeof value.parse=="function"}const papaParse=createOptionalPeerLoader({load:()=>import("papaparse"),isCapability:isPapaParseApi,warningKey:PAPAPARSE_WARNING_KEY,warning:PAPAPARSE_WARNING});function loadPapaParse(importPapaParse){return papaParse.loadWith(importPapaParse)}function loadPapaParseCached(){return papaParse.get()}export{loadPapaParse,loadPapaParseCached};
1
+ import{createOptionalPeerLoader}from"./optional-peer-capabilities.js";const PAPAPARSE_WARNING_KEY="lyra-papaparse-unavailable",PAPAPARSE_WARNING="A lyra-ui component could not load its optional papaparse peer.";function isPapaParseApi(value){return(typeof value=="object"||typeof value=="function")&&value!==null&&"parse"in value&&typeof value.parse=="function"}const papaParse=createOptionalPeerLoader({load:()=>(async()=>{try{return await import("papaparse")}catch(e){throw e}})(),isCapability:isPapaParseApi,warningKey:PAPAPARSE_WARNING_KEY,warning:PAPAPARSE_WARNING});function loadPapaParse(importPapaParse){return papaParse.loadWith(importPapaParse)}function loadPapaParseCached(){return papaParse.get()}export{loadPapaParse,loadPapaParseCached};