@tindtechnologies/universalviewer
Version:
The Universal Viewer is a community-developed open source project on a mission to help you share your 📚📜📰📽️📻🗿 with the 🌎
1 lines • 39.8 kB
JavaScript
"use strict";(self.webpackChunkUV=self.webpackChunkUV||[]).push([[6104],{8307(t,e,i){i.d(e,{K:()=>n});var n=function(){function t(t){this.value=t}return t.prototype.toString=function(){return this.value},t.image=new t("image"),t.page=new t("page"),t}()},1973(t,e,i){i.d(e,{H:()=>D});var n=i(6540),s=i(5338),o=i(5903),a=i(6942),r=i.n(a),l=i(5692),h=function(t){var e=t.first,i=t.onClick,s=t.onKeyDown,a=t.paged,h=t.selected,d=t.thumb,u=t.truncateThumbnailLabels,c=t.viewingDirection,p=(0,l.Wx)({threshold:0,rootMargin:"0px 0px 0px 0px",triggerOnce:!0}),g=p[0],b=p[1];return n.createElement("div",{onClick:function(){return i(d)},onKeyDown:function(t){"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),s(d))},className:r()("thumb",{first:e,placeholder:!d.uri,twoCol:a&&(c===o.T5.LEFT_TO_RIGHT||c===o.T5.RIGHT_TO_LEFT),oneCol:!a,selected:h,"truncate-labels":u}),tabIndex:0,role:"option","aria-selected":h,"aria-label":d.label},n.createElement("div",{ref:g,className:"wrap",style:{height:d.height+8+"px"}},b&&n.createElement("img",{src:d.uri,alt:d.label})),n.createElement("div",{className:"info"},n.createElement("span",{className:"label",title:d.label},d.label),d.data.searchResults&&n.createElement("span",{className:"searchResults"},d.data.searchResults)))};const d=function(t){var e=t.onClick,i=t.onKeyDown,s=t.paged,a=t.selected,l=t.thumbs,d=t.thumbnailsLabel,u=t.viewingDirection,c=t.truncateThumbnailLabels,p=(0,n.useRef)(null);(0,n.useEffect)((function(){var t,e,i=null===(t=p.current)||void 0===t?void 0:t.querySelector("#thumb-".concat(a[0])),n=null==i?void 0:i.offsetTop;null===(e=p.current)||void 0===e||e.parentElement.scrollTo({top:n,left:0,behavior:"smooth"})}),[a]);var g=l.findIndex((function(t){return t.viewingHint!==o.LX.NON_PAGED}));return n.createElement("div",{ref:p,className:r()("thumbs",{"left-to-right":u===o.T5.LEFT_TO_RIGHT,"right-to-left":u===o.T5.RIGHT_TO_LEFT,paged:s,"truncate-labels":c}),role:"listbox","aria-label":d},l.map((function(t,r){return n.createElement("span",{key:"thumb-".concat(r),id:"thumb-".concat(r),className:"thumb-container"},n.createElement(h,{first:r===g,onClick:e,onKeyDown:i,paged:s,selected:a.includes(r),thumb:t,truncateThumbnailLabels:c,viewingDirection:u}),function(t,e,i){return!(e!==o.LX.NON_PAGED&&t&&(i-1)%2==0)}(s,t.viewingHint,r)&&n.createElement("div",{className:"separator"}))})))};var u,c=i(2949),p=i(3957),g=i(4194),b=i(4598),f=i(7584),_=(u=function(t,e){return u=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])},u(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function i(){this.constructor=t}u(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}),m=window.$,T=function(t){function e(e,i,n){void 0===i&&(i=!0),void 0===n&&(n=!0);var s=t.call(this,e,i,n)||this;return s.isOpen=!1,s}return _(e,t),e.prototype.create=function(){this.setConfig("contentLeftPanel"),t.prototype.create.call(this),this.$gallery=m('<div class="iiif-gallery-component"></div>'),this.$element.append(this.$gallery)},e.prototype.setup=function(){var t=this;this.galleryComponent=new f.A({target:this.$gallery[0]}),this.galleryComponent.on("thumbSelected",(function(e){t.extensionHost.publish(g.b.GALLERY_THUMB_SELECTED,e),t.extensionHost.publish(g.b.THUMB_SELECTED,e)}),!1),this.galleryComponent.on("decreaseSize",(function(){t.extensionHost.publish(g.b.GALLERY_DECREASE_SIZE)}),!1),this.galleryComponent.on("increaseSize",(function(){t.extensionHost.publish(g.b.GALLERY_INCREASE_SIZE)}),!1)},e.prototype.databind=function(){this.galleryComponent.options.data=this.galleryData,this.galleryComponent.set(this.galleryData),this.resize()},e.prototype.show=function(){var t=this;this.isOpen=!0,this.$element.show(),setTimeout((function(){t.galleryComponent.selectIndex(t.extension.helper.canvasIndex),t.applyExtendedLabelsStyles()}),10)},e.prototype.hide=function(){this.isOpen=!1,this.$element.hide()},e.prototype.resize=function(){t.prototype.resize.call(this);var e=this.$gallery.find(".main"),i=this.$gallery.find(".header");e.height(this.$element.height()-i.height())},e.prototype.applyExtendedLabelsStyles=function(){this.$gallery.addClass("label-extended")},e}(b.P),y=i(2668),v=i(8307),E=i(6346),S=i(1539),N=i(3664),w=i(4692),$=function(){var t=function(e,i){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])},t(e,i)};return function(e,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");function n(){this.constructor=e}t(e,i),e.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}}(),x=function(t){function e(e){var i=t.call(this,e)||this;return i._data=i.data(),i._data=i.options.data,i._init(),i._resize(),i}return $(e,t),e.prototype._init=function(){t.prototype._init.call(this),this._$element=w(this.el);var e=this;return this._$tree=w('<ul class="tree"></ul>'),this._$element.append(this._$tree),w.templates({pageTemplate:"{^{for nodes}}\t\t\t\t\t{^{tree/}}\t\t\t\t{{/for}}",treeTemplate:'<li dir={{>dir}}>\t\t\t\t\t\t{^{if nodes && nodes.length}}\t\t\t\t\t\t\t<div class="toggle" data-link="class{merge:expanded toggle=\'expanded\'}"></div>\t\t\t\t\t\t{{else}}\t\t\t\t\t\t<div class="spacer"></div>\t\t\t\t\t\t{{/if}}\t\t\t\t\t\t{^{if multiSelectEnabled}}\t\t\t\t\t\t\t<input id="tree-checkbox-{{>id}}" type="checkbox" data-link="checked{:multiSelected ? \'checked\' : \'\'}" class="multiSelect" />\t\t\t\t\t\t{{/if}}\t\t\t\t\t\t{^{if selected}}\t\t\t\t\t\t\t<a id="tree-link-{{>id}}" href="#" title="{{>label}}" class="selected">{{>label}}</a>\t\t\t\t\t\t{{else}}\t\t\t\t\t\t\t<a id="tree-link-{{>id}}" href="#" title="{{>label}}">{{>label}}</a>\t\t\t\t\t\t{{/if}}\t\t\t\t</li>\t\t\t\t{^{if expanded}}\t\t\t\t\t<li>\t\t\t\t\t\t\t<ul>\t\t\t\t\t\t\t\t\t{^{for nodes}}\t\t\t\t\t\t\t\t\t\t{^{tree/}}\t\t\t\t\t\t\t\t\t{{/for}}\t\t\t\t\t\t\t</ul>\t\t\t\t\t</li>\t\t\t\t{{/if}}'}),w.views.tags({tree:{toggleExpanded:function(){var t=this.data;e._setNodeExpanded(t,!t.expanded)},toggleMultiSelect:function(){var t=this.data;if(e._setNodeMultiSelected(t,!t.multiSelected),t.isRange()){var i=e._getMultiSelectState();i&&i.selectRange(t.data,t.multiSelected)}e.fire(C.TREE_NODE_MULTISELECTED,t)},init:function(t,i,n){var s=t.view.data;if(this.data=s,s.dir="ltr",s.data.__jsonld&&s.data.__jsonld.label){var o=s.data.__jsonld.label["@language"];o&&e._data.rtlLanguageCodes.includes(o.trim())&&(s.dir="rtl")}},onAfterLink:function(){var t=this;t.contents("li").first().on("click",".toggle",(function(){t.toggleExpanded()})).on("click","a",(function(i){i.preventDefault();var n=t.data;n.nodes.length&&e._data.branchNodesExpandOnClick&&t.toggleExpanded(),n.multiSelectEnabled?t.toggleMultiSelect():n.nodes.length?e._data.branchNodesSelectable&&(e.fire(C.TREE_NODE_SELECTED,n),e.selectNode(n)):(e.fire(C.TREE_NODE_SELECTED,n),e.selectNode(n))})).on("click","input.multiSelect",(function(e){t.toggleMultiSelect()}))},template:w.templates.treeTemplate}}),!0},e.prototype.set=function(t){var e=this;if(this._data=Object.assign(this._data,t),this._data.helper){this._rootNode=this._data.helper.getTree(this._data.topRangeIndex,this._data.treeSortType),this._flattenedTree=null,this._multiSelectableNodes=null,this._$tree.link(w.templates.pageTemplate,this._rootNode);var i=this._getMultiSelectState();if(i)for(var n=function(t){var e=i.ranges[t],n=s._getMultiSelectableNodes().filter((function(t){return t.data.id===e.id}))[0];n&&(s._setNodeMultiSelectEnabled(n,e.multiSelectEnabled),s._setNodeMultiSelected(n,e.multiSelected))},s=this,o=0;o<i.ranges.length;o++)n(o);this._data.autoExpand&&this.getAllNodes().forEach((function(t,i){e._setNodeExpanded(t,!0)}))}},e.prototype._getMultiSelectState=function(){return this._data.helper?this._data.helper.getMultiSelectState():null},e.prototype.data=function(){return{autoExpand:!1,branchNodesExpandOnClick:!0,branchNodesSelectable:!0,helper:null,topRangeIndex:0,treeSortType:S.BG.NONE,rtlLanguageCodes:"ar, ara, dv, div, he, heb, ur, urd"}},e.prototype.allNodesSelected=function(){var t=this._getMultiSelectableNodes(),e=this.getMultiSelectedNodes();return t.length===e.length},e.prototype._getMultiSelectableNodes=function(){var t=this;if(this._multiSelectableNodes)return this._multiSelectableNodes;var e=this.getAllNodes();return e?this._multiSelectableNodes=e.filter((function(e){return t._nodeIsMultiSelectable(e)})):[]},e.prototype._nodeIsMultiSelectable=function(t){return!!(t.data.type===E.TreeNodeType.MANIFEST&&t.nodes&&t.nodes.length>0||t.data.type===E.TreeNodeType.RANGE)},e.prototype.getAllNodes=function(){return this._flattenedTree?this._flattenedTree:this._data.helper?this._flattenedTree=this._data.helper.getFlattenedTree(this._rootNode):[]},e.prototype.getMultiSelectedNodes=function(){var t=this;return this.getAllNodes().filter((function(e){return t._nodeIsMultiSelectable(e)&&e.multiSelected}))},e.prototype.getNodeById=function(t){return this.getAllNodes().filter((function(e){return e.id===t}))[0]},e.prototype.expandParents=function(t,e){t&&t.parentNode&&(this._setNodeExpanded(t.parentNode,e),this.expandParents(t.parentNode,e))},e.prototype._setNodeSelected=function(t,e){w.observable(t).setProperty("selected",e)},e.prototype._setNodeExpanded=function(t,e){w.observable(t).setProperty("expanded",e)},e.prototype._setNodeMultiSelected=function(t,e){w.observable(t).setProperty("multiSelected",e)},e.prototype._setNodeMultiSelectEnabled=function(t,e){w.observable(t).setProperty("multiSelectEnabled",e)},e.prototype.selectPath=function(t){if(this._rootNode){var e=t.split("/");e.length>=1&&e.shift();var i=this.getNodeByPath(this._rootNode,e);this.selectNode(i)}},e.prototype.deselectCurrentNode=function(){this.selectedNode&&this._setNodeSelected(this.selectedNode,!1)},e.prototype.selectNode=function(t){this._rootNode&&(this.deselectCurrentNode(),this.selectedNode=t,this._setNodeSelected(this.selectedNode,!0))},e.prototype.expandNode=function(t,e){this._rootNode&&this._setNodeExpanded(t,e)},e.prototype.getNodeByPath=function(t,e){if(0===e.length)return t;var i=Number(e.shift()),n=t.nodes[i];return this.getNodeByPath(n,e)},e.prototype.show=function(){this._$element.show()},e.prototype.hide=function(){this._$element.hide()},e.prototype._resize=function(){},e}(N.$),C=function(){function t(){}return t.TREE_NODE_MULTISELECTED="treeNodeMultiSelected",t.TREE_NODE_SELECTED="treeNodeSelected",t}(),O=function(){var t=function(e,i){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])},t(e,i)};return function(e,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");function n(){this.constructor=e}t(e,i),e.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}}(),R=window.$,B=function(t){function e(e,i,n){void 0===i&&(i=!0),void 0===n&&(n=!0);var s=t.call(this,e,i,n)||this;return s.isOpen=!1,s.expandedNodeIds=new Set,s}return O(e,t),e.prototype.create=function(){this.setConfig("contentLeftPanel"),t.prototype.create.call(this),this.$tree=R('<div class="iiif-tree-component"></div>'),this.$element.append(this.$tree)},e.prototype.setup=function(){var t=this;this.treeComponent=new x({target:this.$tree[0],data:this.treeData}),this.treeComponent.on("treeNodeSelected",(function(e){t.extensionHost.publish(g.b.TREE_NODE_SELECTED,e)}),!1),this.treeComponent.on("treeNodeMultiSelected",(function(e){t.extensionHost.publish(g.b.TREE_NODE_MULTISELECTED,e)}),!1)},e.prototype.saveState=function(){var t=this,e=this.treeComponent.getAllNodes();this.expandedNodeIds.clear(),e.forEach((function(e){e.expanded&&t.expandedNodeIds.add(e.id)}))},e.prototype.restoreState=function(){var t=this;this.treeComponent.getAllNodes().forEach((function(e){t.expandedNodeIds.has(e.id)&&t.treeComponent.expandNode(e,!0)}))},e.prototype.databind=function(){this.saveState(),this.treeComponent.set(this.treeData),this.restoreState(),this.resize()},e.prototype.show=function(){this.isOpen=!0,this.$element.show()},e.prototype.hide=function(){this.isOpen=!1,this.$element.hide()},e.prototype.selectNode=function(t){var e=this;this.treeComponent.expandParents(t,!0),this.$tree.find("#tree-link-"+t.id)[0],Promise.resolve().then((function(){e.treeComponent.selectNode(t)}))},e.prototype.expandNode=function(t,e){this.treeComponent.expandNode(t,e)},e.prototype.getAllNodes=function(){return this.treeComponent.getAllNodes()},e.prototype.deselectCurrentNode=function(){this.treeComponent.deselectCurrentNode()},e.prototype.getNodeById=function(t){return this.treeComponent.getNodeById(t)},e.prototype.resize=function(){t.prototype.resize.call(this)},e}(b.P),V=i(41),I=function(){var t=function(e,i){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])},t(e,i)};return function(e,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");function n(){this.constructor=e}t(e,i),e.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}}(),A=window.$,L=i(3957).T5,D=function(t){function e(e){var i=t.call(this,e)||this;return i.expandFullEnabled=!1,i.isThumbsViewOpen=!1,i.isTreeViewOpen=!1,i.keyPress=!1,i.treeSortType=S.BG.NONE,i}return I(e,t),e.prototype.create=function(){var e=this;this.setConfig("contentLeftPanel"),t.prototype.create.call(this),this.extensionHost.subscribe(g.b.SETTINGS_CHANGE,(function(){e.render()})),this.extensionHost.subscribe(g.b.CANVAS_INDEX_CHANGE,(function(){e.render()})),this.extensionHost.subscribe(g.b.GALLERY_THUMB_SELECTED,(function(){e.collapseFull()})),this.extensionHost.subscribe(g.b.METRIC_CHANGE,(function(){e.extension.isDesktopMetric()||e.isFullyExpanded&&e.collapseFull()})),this.extensionHost.subscribe(g.b.ANNOTATIONS,(function(){e.renderThumbs(),e.renderGallery()})),this.extensionHost.subscribe(g.b.ANNOTATIONS_CLEARED,(function(){e.renderThumbs(),e.renderGallery()})),this.extensionHost.subscribe(g.b.ANNOTATIONS_EMPTY,(function(){e.renderThumbs(),e.renderGallery()})),this.extensionHost.subscribe(g.b.CANVAS_INDEX_CHANGE,(function(){e.isFullyExpanded&&e.collapseFull(),e.selectCurrentTreeNodeByCanvas(),e.updateTreeTabBySelection()})),this.extensionHost.subscribe(g.b.RANGE_CHANGE,(function(){e.isFullyExpanded&&e.collapseFull(),e.selectCurrentTreeNodeByRange(),e.updateTreeTabBySelection()})),this.extensionHost.subscribe(g.b.TREE_NODE_SELECTED,(function(){e.extension.isMetric("sm")&&e.toggle(!0)})),this.extensionHost.subscribe(g.b.TOGGLE_EXPAND_LEFT_PANEL,(function(){e.openThumbsView()})),this.$tabs=A('<div class="tabs"></div>'),this.$main.append(this.$tabs),this.$treeButton=A('<a class="index tab" tabindex="0">'+this.content.index+"</a>"),this.$tabs.append(this.$treeButton),this.$thumbsButton=A('<a class="thumbs tab" tabindex="0">'+this.content.thumbnails+"</a>"),this.$tabs.append(this.$thumbsButton),this.$tabsContent=A('<div class="tabsContent"></div>'),this.$main.append(this.$tabsContent),this.$options=A('<div class="options"></div>'),this.$tabsContent.append(this.$options),this.$topOptions=A('<div class="top"></div>'),this.$options.append(this.$topOptions),this.$treeSelect=A('<select aria-label="'+this.content.manifestRanges+'"></select>'),this.$topOptions.append(this.$treeSelect),this.$bottomOptions=A('<div class="bottom"></div>'),this.$options.append(this.$bottomOptions),this.$leftOptions=A('<div class="left"></div>'),this.$bottomOptions.append(this.$leftOptions),this.$rightOptions=A('<div class="right"></div>'),this.$bottomOptions.append(this.$rightOptions),this.$treeViewOptions=A('<div class="treeView"></div>'),this.$leftOptions.append(this.$treeViewOptions),this.$sortByLabel=A('<span class="sort">'+this.content.sortBy+"</span>"),this.$treeViewOptions.append(this.$sortByLabel),this.$sortButtonGroup=A('<div class="btn-group"></div>'),this.$treeViewOptions.append(this.$sortButtonGroup),this.$sortByDateButton=A('<button class="btn" tabindex="0">'+this.content.date+"</button>"),this.$sortButtonGroup.append(this.$sortByDateButton),this.$sortByVolumeButton=A('<button class="btn" tabindex="0">'+this.content.volume+"</button>"),this.$sortButtonGroup.append(this.$sortByVolumeButton),this.$views=A('<div class="views"></div>'),this.$tabsContent.append(this.$views),this.$treeView=A('<div class="treeView"></div>'),this.$views.append(this.$treeView),this.$thumbsView=A('<div class="thumbsView" tabindex="-1"></div>'),this.$views.append(this.$thumbsView),this.$galleryView=A('<div class="galleryView"></div>'),this.$views.append(this.$galleryView),this.$treeSelect.hide(),this.$treeSelect.change((function(){e.renderTree(),e.selectCurrentTreeNode(),e.updateTreeTabBySelection()})),this.$sortByDateButton.on("click",(function(){e.sortByDate()})),this.$sortByVolumeButton.on("click",(function(){e.sortByVolume()})),this.$treeViewOptions.hide(),this.onAccessibleClick(this.$treeButton,(function(){e.openTreeView()}),!0,!0),this.onAccessibleClick(this.$thumbsButton,(function(){e.openThumbsView()}),!0,!0),this.setTitle(this.content.title),this.$sortByVolumeButton.addClass("on");var i=this.options.tabOrder;i&&("thumbs"===(i=(i=i.toLowerCase()).replace(/ /g,"")).split(",")[0]?(this.$treeButton.before(this.$thumbsButton),this.$thumbsButton.addClass("first")):this.$treeButton.addClass("first"))},e.prototype.createTreeView=function(){this.treeView=new B(this.$treeView,!1),this.treeView.treeData=this.getTreeData(),this.treeView.setup(),this.renderTree();var t=this.extension.helper.getTopRanges();if(t.length>1)for(var e=0;e<t.length;e++){var i=t[e];this.$treeSelect.append('<option value="'+i.id+'">'+E.LanguageMap.getValue(i.getLabel())+"</option>")}this.updateTreeViewOptions()},e.prototype.render=function(){this.renderThumbs(),this.renderTree(),this.renderGallery()},e.prototype.updateTreeViewOptions=function(){this.getTree()&&(this.defaultToThumbsView()?this.$treeViewOptions.hide():this.$treeViewOptions.show(),this.$treeSelect.find("option").length?this.$treeSelect.show():this.$treeSelect.hide())},e.prototype.sortByDate=function(){this.treeSortType=S.BG.DATE,this.treeView.treeData=this.getTreeData(),this.treeView.databind(),this.selectCurrentTreeNode(),this.$sortByDateButton.addClass("on"),this.$sortByVolumeButton.removeClass("on"),this.resize()},e.prototype.sortByVolume=function(){this.treeSortType=S.BG.NONE,this.treeView.treeData=this.getTreeData(),this.treeView.databind(),this.selectCurrentTreeNode(),this.$sortByDateButton.removeClass("on"),this.$sortByVolumeButton.addClass("on"),this.resize()},e.prototype.isCollection=function(){var t=this.getTree();if(t)return t.data.type===E.TreeNodeType.COLLECTION;throw new Error("Tree not available")},e.prototype.renderTree=function(){this.treeView&&(this.treeView.treeData=this.getTreeData(),this.treeView.databind(),this.selectCurrentTreeNode())},e.prototype.getTreeData=function(){return{autoExpand:this._isTreeAutoExpanded(),branchNodesExpandOnClick:c.YA.getBool(this.config.options.branchNodesExpandOnClick,!0),branchNodesSelectable:c.YA.getBool(this.config.options.branchNodesSelectable,!1),helper:this.extension.helper,topRangeIndex:this.getSelectedTopRangeIndex(),treeSortType:this.treeSortType}},e.prototype._isTreeAutoExpanded=function(){var t=c.YA.getBool(this.config.options.autoExpandTreeEnabled,!1),e=this.config.options.autoExpandTreeIfFewerThan||0;if(t){var i=this.extension.helper.getFlattenedTree();if(i&&i.length<e)return!0}return!1},e.prototype.updateTreeTabByCanvasIndex=function(){var t=this.extension.helper.getTopRanges();if(t.length>1){var e=this.getCurrentCanvasTopRangeIndex();if(-1===e)return;var i=t[e];this.setTreeTabTitle(E.LanguageMap.getValue(i.getLabel()))}else this.setTreeTabTitle(this.content.index)},e.prototype.setTreeTabTitle=function(t){this.$treeButton.text(t)},e.prototype.updateTreeTabBySelection=function(){var t=null,e=this.extension.helper.getTopRanges();e.length>1&&(t=this.treeView?this.getSelectedTree().text():E.LanguageMap.getValue(e[0].getLabel())),t?this.setTreeTabTitle(t):this.setTreeTabTitle(this.content.index)},e.prototype.getViewingHint=function(){return this.extension.helper.getViewingHint()},e.prototype.getViewingDirection=function(){return this.extension.helper.getViewingDirection()},e.prototype.createThumbsRoot=function(){this.thumbsRoot||(this.thumbsRoot=(0,s.createRoot)(this.$thumbsView[0])),this.renderThumbs()},e.prototype.renderThumbs=function(){var t=this;if(this.thumbsRoot){var e=this.getViewingDirection(),i=this.extension.helper.getThumbs(90);e&&e===L.BOTTOM_TO_TOP&&i.reverse();var s=this.extension.annotations;if(s&&s.length)for(var o=function(t){var e=s[t],n=i.filter((function(t){return t.index===e.canvasIndex}))[0];if(n){var o=Object.assign({},n.data);o.searchResults=e.rects.length,n.data=o}},a=0;a<s.length;a++)o(a);var r=!!this.extension.getSettings().pagingEnabled&&this.extension.helper.isPaged(),l=this.extension.getPagedIndices(this.extension.helper.canvasIndex),h=this.extension.getSettings();this.thumbsRoot.render((0,n.createElement)(d,{thumbs:i,paged:r,viewingDirection:e||p.T5.LEFT_TO_RIGHT,selected:l,thumbnailsLabel:this.content.thumbnails,truncateThumbnailLabels:void 0===h.truncateThumbnailLabels||h.truncateThumbnailLabels,onClick:function(e){t.extensionHost.publish(g.b.THUMB_SELECTED,e)},onKeyDown:function(e){t.extensionHost.publish(g.b.THUMB_SELECTED,e)}}))}},e.prototype.createGalleryView=function(){this.galleryView=new T(this.$galleryView,!1),this.galleryView.galleryData=this.getGalleryData(),this.galleryView.setup(),this.renderGallery()},e.prototype.renderGallery=function(){this.galleryView&&(this.galleryView.galleryData=this.getGalleryData(),this.galleryView.databind())},e.prototype.getGalleryData=function(){return{helper:this.extension.helper,chunkedResizingThreshold:this.config.options.galleryThumbChunkedResizingThreshold,content:this.config.content,debug:!1,imageFadeInDuration:300,initialZoom:6,minLabelWidth:20,pageModeEnabled:this.isPageModeEnabled(),scrollStopDuration:100,searchResults:this.extension.annotations,sizingEnabled:!0,thumbHeight:this.config.options.galleryThumbHeight,thumbLoadPadding:this.config.options.galleryThumbLoadPadding,thumbWidth:this.config.options.galleryThumbWidth,viewingDirection:this.getViewingDirection()}},e.prototype.isPageModeEnabled=function(){return"function"==typeof this.extension.getMode?c.YA.getBool(this.config.options.pageModeEnabled,!0)&&this.extension.getMode().toString()===v.K.page.toString():c.YA.getBool(this.config.options.pageModeEnabled,!0)},e.prototype.getSelectedTree=function(){return this.$treeSelect.find(":selected")},e.prototype.getSelectedTopRangeIndex=function(){var t=this.getSelectedTree().index();return-1===t&&(t=0),t},e.prototype.getTree=function(){var t=this.getSelectedTopRangeIndex();return this.extension.helper.getTree(t,S.BG.NONE)},e.prototype.toggleFinish=function(){if(t.prototype.toggleFinish.call(this),this.isUnopened){var e=c.YA.getBool(this.config.options.treeEnabled,!0),i=c.YA.getBool(this.config.options.thumbsEnabled,!0),n=this.getTree();n&&n.nodes.length||(e=!1),e&&i||this.$tabs.hide(),i&&this.defaultToThumbsView()?this.openThumbsView():e&&this.openTreeView()}},e.prototype.defaultToThumbsView=function(){var t=c.YA.getBool(this.config.options.defaultToTreeEnabled,!1),e=this.config.options.defaultToTreeIfGreaterThan||0,i=c.YA.getBool(this.config.options.defaultToTreeIfCollection,!1),n=this.getTree();return!(this.isCollection()&&(i||n&&this.extension.helper.treeHasNavDates(n))||t&&n&&n.nodes.length>e)},e.prototype.expandFullStart=function(){t.prototype.expandFullStart.call(this),this.extensionHost.publish(g.b.LEFTPANEL_EXPAND_FULL_START)},e.prototype.expandFullFinish=function(){t.prototype.expandFullFinish.call(this),this.$treeButton.hasClass("on")?this.openTreeView():this.$thumbsButton.hasClass("on")&&this.openThumbsView(),this.extensionHost.publish(g.b.LEFTPANEL_EXPAND_FULL_FINISH)},e.prototype.collapseFullStart=function(){t.prototype.collapseFullStart.call(this),this.extensionHost.publish(g.b.LEFTPANEL_COLLAPSE_FULL_START)},e.prototype.collapseFullFinish=function(){t.prototype.collapseFullFinish.call(this),this.$thumbsButton.hasClass("on")&&this.openThumbsView(),this.extensionHost.publish(g.b.LEFTPANEL_COLLAPSE_FULL_FINISH)},e.prototype.openTreeView=function(){this.isTreeViewOpen=!0,this.isThumbsViewOpen=!1,this.treeView||this.createTreeView(),this.$treeButton.addClass("on"),this.$thumbsButton.removeClass("on"),this.treeView.show(),this.$thumbsView&&this.$thumbsView.hide(),this.galleryView&&this.galleryView.hide(),this.updateTreeViewOptions(),this.selectCurrentTreeNode(),this.resize(),this.treeView.resize(),this.extensionHost.publish(g.b.OPEN_TREE_VIEW)},e.prototype.openThumbsView=function(){var t=this;this.isTreeViewOpen=!1,this.isThumbsViewOpen=!0,this.createThumbsRoot(),this.isFullyExpanded&&!this.galleryView&&this.createGalleryView(),this.$treeButton.removeClass("on"),this.$thumbsButton.addClass("on"),this.treeView&&this.treeView.hide(),this.$treeSelect.hide(),this.$treeViewOptions.hide(),this.resize(),this.isFullyExpanded?setTimeout((function(){t.$thumbsView.hide(),t.galleryView&&t.galleryView.show(),t.galleryView&&t.galleryView.resize()}),1):(this.galleryView&&this.galleryView.hide(),this.$thumbsView.show(),this.$thumbsView.resize()),this.extensionHost.publish(g.b.OPEN_THUMBS_VIEW)},e.prototype.selectTopRangeIndex=function(t){this.$treeSelect.prop("selectedIndex",t)},e.prototype.getCurrentCanvasTopRangeIndex=function(){var t=-1,e=this.extension.getCurrentCanvasRange();return e&&(t=Number(e.path.split("/")[0])),t},e.prototype.selectCurrentTreeNode=function(){var t;"uv-openseadragon-extension"===(null===(t=this.extension.type)||void 0===t?void 0:t.name)?this.selectCurrentTreeNodeByCanvas():this.selectCurrentTreeNodeByRange()},e.prototype.selectCurrentTreeNodeByRange=function(){if(this.treeView){var t=this.extension.helper.getCurrentRange();if(t&&t.treeNode){var e=this.treeView.getNodeById(t.treeNode.id);e?this.treeView.selectNode(e):this.selectTreeNodeByManifest()}}},e.prototype.selectCurrentTreeNodeByCanvas=function(){if(this.treeView){var t=null,e=this.getCurrentCanvasTopRangeIndex(),i=e===this.getSelectedTopRangeIndex(),n=null;-1!==e&&(n=this.extension.getCurrentCanvasRange())&&n.treeNode&&(t=this.treeView.getNodeById(n.treeNode.id)),t&&i?this.treeView.selectNode(t):((n=this.extension.helper.getCurrentRange())&&n.treeNode&&(t=this.treeView.getNodeById(n.treeNode.id)),t?this.treeView.selectNode(t):this.selectTreeNodeByManifest())}},e.prototype.selectTreeNodeByManifest=function(){var t=this,e=this.extension.helper.collectionIndex,i=this.extension.helper.manifestIndex,n=this.treeView.getAllNodes(),s=!1;n.map((function(n){n.isCollection()&&n.data.index===e&&(t.treeView.selectNode(n),t.treeView.expandNode(n,!0),s=!0),n.isManifest()&&n.data.index===i&&(t.treeView.selectNode(n),s=!0)})),s||this.treeView.deselectCurrentNode()},e.prototype.resize=function(){var e=this;t.prototype.resize.call(this),setTimeout((function(){e.$tabsContent.height(e.$main.height()-((0,V.zN)(e.$tabs)?e.$tabs.height():0)-e.$tabsContent.verticalPadding()),e.$views.height(e.$tabsContent.height()-e.$options.outerHeight())}),1)},e}(y.W)},9340(t,e,i){var n;i.d(e,{C:()=>n}),function(t){t.CANVAS_RENDERINGS="canvasRenderings",t.CURRENT_VIEW="currentView",t.ENTIRE_DOCUMENT_AS_PDF="entireDocumentAsPdf",t.ENTIRE_DOCUMENT_AS_TEXT="entireDocumentAsText",t.ENTIRE_FILE_AS_ORIGINAL="entireFileAsOriginal",t.IMAGE_RENDERINGS="imageRenderings",t.MANIFEST_RENDERINGS="manifestRenderings",t.RANGE_RENDERINGS="rangeRenderings",t.SELECTION="selection",t.UNKNOWN="unknown",t.WHOLE_IMAGE_HIGH_RES="wholeImageHighRes",t.WHOLE_IMAGE_LOW_RES="wholeImageLowRes",t.WHOLE_IMAGES_HIGH_RES="wholeImagesHighRes"}(n||(n={}))},7584(t,e,i){i.d(e,{A:()=>h});var n,s=i(5903),o=i(3664),a=i(2949),r=i(4692),l=(n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])},n(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function i(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}),h=function(t){function e(e){var i=t.call(this,e)||this;return i._data=i.data(),i._escapeHtml=function(t){return String(t).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")},i._galleryThumbsTemplate=function(t){var e=t.multiSelectEnabled,n=i._escapeHtml(i._galleryThumbClassName(t)),s=i._escapeHtml(t.label),o=i._escapeHtml(t.uri),a=i._escapeHtml(t.index),r=i._escapeHtml(t.visible),l=i._escapeHtml(t.width),h=i._escapeHtml(t.height),d=i._escapeHtml(t.initialWidth),u=i._escapeHtml(t.initialHeight),c=i._escapeHtml(t.data.searchResults||""),p=i._escapeHtml(i._galleryThumbSearchResultsTitle(t)||"");return'\n <button class="'.concat(n,'" \n data-src="').concat(o,'" \n data-index="').concat(a,'" \n data-visible="').concat(r,'" \n data-width="').concat(l,'" \n data-height="').concat(h,'" \n data-initialwidth="').concat(d,'" \n data-initialheight="').concat(u,'">\n <div class="wrap" \n style="width:').concat(d,"px; height:").concat(u,'px">\n ').concat(e?'\n <input id="thumb-checkbox-'.concat(a,'" \n tabindex="-1" \n type="checkbox" \n class="multiSelect" />'):"",'\n </div>\n <div class="info">\n <span class="index" style="width:').concat(d,'px">').concat(a,'</span>\n <span class="label" style="width:').concat(d,'px" title="').concat(s,'">').concat(s,'</span>\n <span class="searchResults" \n title="').concat(p,'">\n ').concat(c,"\n </span>\n </div>\n </button>\n ")},i._galleryThumbClassName=function(t){var e="thumb preLoad";return 0===t.index&&(e+=" first"),t.uri||(e+=" placeholder"),e},i._galleryThumbSearchResultsTitle=function(t){var e=Number(t.data.searchResults);return e?a.DH.format(i.options.data.content.searchResults,e.toString()):null},i._data=i.options.data,i._init(),i._resize(),i}return l(e,t),e.prototype._init=function(){var e=this;return t.prototype._init.call(this),this._$element=r(this.el),this._$header=r('<div class="header"></div>'),this._$element.append(this._$header),this._$leftOptions=r('<div class="left"></div>'),this._$header.append(this._$leftOptions),this._$rightOptions=r('<div class="right"></div>'),this._$header.append(this._$rightOptions),this._$sizeDownButton=r('<input class="btn btn-default size-down" type="button" value="-" />'),this._$leftOptions.append(this._$sizeDownButton),this._$sizeRange=r('<input type="range" name="size" min="1" max="10" value="'+this.options.data.initialZoom+'" />'),this._$leftOptions.append(this._$sizeRange),this._$sizeUpButton=r('<input class="btn btn-default size-up" type="button" value="+" />'),this._$leftOptions.append(this._$sizeUpButton),this._$multiSelectOptions=r('<div class="multiSelectOptions"></div>'),this._$rightOptions.append(this._$multiSelectOptions),this._$selectAllButton=r('<div class="multiSelectAll"><input id="multiSelectAll" type="checkbox" tabindex="0" /><label for="multiSelectAll">'+this.options.data.content.selectAll+"</label></div>"),this._$multiSelectOptions.append(this._$selectAllButton),this._$selectAllButtonCheckbox=r(this._$selectAllButton.find("input:checkbox")),this._$downloadButton=r('<a class="download" href="#">'+this.options.data.content.download+"</a>"),this._$multiSelectOptions.append(this._$downloadButton),this._$main=r('<div class="main"></div>'),this._$element.append(this._$main),this._$thumbs=r('<div class="thumbs"></div>'),this._$main.append(this._$thumbs),this._$sizeDownButton.on("click",(function(){var t=Number(e._$sizeRange.val())-1;t>=Number(e._$sizeRange.attr("min"))&&(e._$sizeRange.val(t.toString()),e._$sizeRange.trigger("change"),e.fire(d.DECREASE_SIZE))})),this._$sizeUpButton.on("click",(function(){var t=Number(e._$sizeRange.val())+1;t<=Number(e._$sizeRange.attr("max"))&&(e._$sizeRange.val(t.toString()),e._$sizeRange.trigger("change"),e.fire(d.INCREASE_SIZE))})),this._$sizeRange.on("change",(function(){e._updateThumbs(),e._scrollToThumb(e._getSelectedThumbIndex())})),this._$selectAllButton.checkboxButton((function(t){var i=e._getMultiSelectState();i&&(t?i.selectAll(!0):i.selectAll(!1)),e.set(e.options.data)})),this._$downloadButton.on("click",(function(){var t=e._getMultiSelectState();if(t){var i=t.getAllSelectedCanvases().map((function(t){return t.id}));e.fire(d.MULTISELECTION_MADE,i)}})),this._setRange(),this._$main.on("scroll",(function(){e._updateThumbs()}),this.options.data.scrollStopDuration),this.options.data.sizingEnabled||this._$sizeRange.hide(),!0},e.prototype.data=function(){return{chunkedResizingThreshold:400,content:{searchResult:"{0} search result",searchResults:"{0} search results"},debug:!1,helper:null,imageFadeInDuration:300,initialZoom:6,minLabelWidth:20,pageModeEnabled:!1,scrollStopDuration:100,searchResults:[],sizingEnabled:!0,thumbHeight:320,thumbLoadPadding:3,thumbWidth:200,viewingDirection:s.T5.LEFT_TO_RIGHT}},e.prototype.set=function(t){if(this._data=Object.assign(this._data,t),this._data.helper&&void 0!==this._data.thumbWidth&&void 0!==this._data.thumbHeight&&(this._thumbs=this._data.helper.getThumbs(this._data.thumbWidth,this._data.thumbHeight)),this._data.viewingDirection&&(this._data.viewingDirection===s.T5.BOTTOM_TO_TOP&&this._thumbs.reverse(),this._$thumbs.addClass(this._data.viewingDirection)),this._data.searchResults&&this._data.searchResults.length)for(var e=0;e<this._data.searchResults.length;e++){var i=this._data.searchResults[e],n=this._thumbs.filter((function(t){return t.index===i.canvasIndex}))[0],o=r.extend(!0,{},n.data);o.searchResults=i.rects.length,n.data=o}this._thumbsCache=null,this._createThumbs(),this._data.helper&&this.selectIndex(this._data.helper.canvasIndex);var a=this._getMultiSelectState();if(a&&a.isEnabled){for(this._$multiSelectOptions.show(),this._$thumbs.addClass("multiSelect"),e=0;e<a.canvases.length;e++){var l=a.canvases[e];n=this._getThumbByCanvas(l),this._updateThumbHtmlMultiSelected(n.index,l.multiSelected)}for(e=0;e<a.ranges.length;e++)for(var h=a.ranges[e],d=this._getThumbsByRange(h),u=0;u<d.length;u++)n=d[u],this._updateThumbHtmlMultiSelected(n.index,h.multiSelected)}else this._$multiSelectOptions.hide(),this._$thumbs.removeClass("multiSelect")},e.prototype._update=function(){var t=this._getMultiSelectState();t&&t.isEnabled&&(this._$selectAllButtonCheckbox.prop("checked",t.allSelected()),t.getAll().filter((function(t){return t.multiSelected})).length>0?this._$downloadButton.show():this._$downloadButton.hide())},e.prototype._getMultiSelectState=function(){return this._data.helper?this._data.helper.getMultiSelectState():null},e.prototype._createThumbs=function(){var t=this;if(this._thumbs){this._$thumbs.undelegate(".thumb","click"),this._$thumbs.empty();for(var e=this._getMultiSelectState(),i=[],n=0;n<this._thumbs.length;n++){var s=(u=this._thumbs[n]).width,o=u.height;u.initialWidth=s,i.push(o),u.multiSelectEnabled=!!e&&e.isEnabled}for(var l=a.eC.median(i),h=0;h<this._thumbs.length;h++){var u;(u=this._thumbs[h]).initialHeight=l}var c=this._thumbs.map(this._galleryThumbsTemplate).join("");if(this._$thumbs.html(c),e&&!e.isEnabled)this._$thumbs.delegate(".thumb","click",(function(e){var i=parseInt(this.dataset.index),n=t._thumbs[i];t.fire(d.THUMB_SELECTED,n)}));else for(var p=this._$thumbs.find(".thumb"),g=function(){var t=b;r(p[f]).checkboxButton((function(e){var i=parseInt(this.dataset.index),n=t._thumbs[i],s=t._getThumbMultiSelected(i);t._updateThumbHtmlMultiSelected(n.index,s);var o=t.options.data.helper.getCanvasRange(n.data),a=t._getMultiSelectState();a&&(o?a.selectRange(o,s):a.selectCanvas(n.data,s)),t._update(),t.fire(d.THUMB_MULTISELECTED,n)}))},b=this,f=0;f<p.length;f++)g()}},e.prototype._getThumbMultiSelected=function(t){return this._getThumbByIndex(t).find("#thumb-checkbox-".concat(t)).prop("checked")},e.prototype._getThumbByCanvas=function(t){return this._thumbs.filter((function(e){return e.data.id===t.id}))[0]},e.prototype._sizeThumb=function(t){var e=t.data().initialwidth,i=t.data().initialheight,n=Number(e),s=Number(i),o=Math.floor(n*this._range),a=Math.floor(s*this._range),r=t.find(".wrap"),l=t.find(".label"),h=t.find(".index"),d=t.find(".searchResults"),u=o;this._data.searchResults&&this._data.searchResults.length&&(d.show(),u=o-d.outerWidth(),void 0!==this._data.minLabelWidth&&u<this._data.minLabelWidth?(d.hide(),u=o):d.show()),this._data.pageModeEnabled?(h.hide(),l.show()):(h.show(),l.hide()),r.outerWidth(o),r.outerHeight(a),h.outerWidth(u),l.outerWidth(u)},e.prototype._loadThumb=function(t,e){var i=t.find(".wrap");if(!i.hasClass("loading")&&!i.hasClass("loaded")){t.removeClass("preLoad");var n=t.attr("data-visible"),s=this._data.imageFadeInDuration||0;if("false"!==n){i.addClass("loading");var o=t.attr("data-src"),a=r('<img class="thumbImage" src="'+o+'" />');a.hide(),a.on("load",(function(){r(this).fadeIn(s,(function(){r(this).parent().switchClass("loading","loaded")}))})),i.prepend(a),e&&e(a)}else i.addClass("hidden")}},e.prototype._getThumbsByRange=function(t){var e=[];if(!this._data.helper)return e;for(var i=0;i<this._thumbs.length;i++){var n=this._thumbs[i],s=n.data,o=this._data.helper.getCanvasRange(s,t.path);o&&o.id===t.id&&e.push(n)}return e},e.prototype._updateThumbs=function(){var t=!!this._data.debug;this._setRange();var e=this._$main.scrollTop(),i=e+this._$main.height();t&&console.log("scrollTop %s, scrollBottom %s",e,i);for(var n=this._getAllThumbs(),s=0,o=0;o<n.length;o++){var a=r(n[o]),l=a.position().top,h=a.outerHeight(),d=l+h,u=h*this._data.thumbLoadPadding;l<=i+u&&d>=e-u?(s+=1,this._sizeThumb(a),a.addClass("insideScrollArea"),this._loadThumb(a)):a.removeClass("insideScrollArea")}t&&console.log("number of thumbs to update: "+s)},e.prototype._getSelectedThumbIndex=function(){return Number(this._$selectedThumb.data("index"))},e.prototype._getAllThumbs=function(){return this._thumbsCache||(this._thumbsCache=this._$thumbs.find(".thumb")),this._thumbsCache},e.prototype._getThumbByIndex=function(t){return this._$thumbs.find('[data-index="'+t+'"]')},e.prototype._scrollToThumb=function(t){var e=this._getThumbByIndex(t);this._$main.scrollTop(e.position().top)},e.prototype.selectIndex=function(t){this._thumbs&&this._thumbs.length&&(this._getAllThumbs().removeClass("selected"),this._$selectedThumb=this._getThumbByIndex(t),this._$selectedThumb.addClass("selected"),this._scrollToThumb(t),this._updateThumbs())},e.prototype._setRange=function(){var t=a.eC.normalise(Number(this._$sizeRange.val()),0,10);this._range=a.eC.clamp(t,.05,1)},e.prototype._updateThumbHtmlMultiSelected=function(t,e){var i=this._getThumbByIndex(t),n=i.find(".wrap");e?n.addClass("multiSelected"):n.removeClass("multiSelected");var s=i.find("#thumb-checkbox-".concat(t));s.length&&s.prop("checked",e)},e.prototype._resize=function(){},e}(o.$),d=function(){function t(){}return t.DECREASE_SIZE="decreaseSize",t.INCREASE_SIZE="increaseSize",t.MULTISELECTION_MADE="multiSelectionMade",t.THUMB_SELECTED="thumbSelected",t.THUMB_MULTISELECTED="thumbMultiSelected",t}()}}]);