@internetarchive/bookreader 5.0.0-114 → 5.0.0-116
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.
- package/BookReader/474.js.map +1 -1
- package/BookReader/BookReader.css +27 -10
- package/BookReader/BookReader.js +1 -43
- package/BookReader/BookReader.js.map +1 -1
- package/BookReader/ia-bookreader-bundle.js +63 -39
- package/BookReader/ia-bookreader-bundle.js.map +1 -1
- package/BookReader/plugins/plugin.archive_analytics.js.map +1 -1
- package/BookReader/plugins/plugin.autoplay.js.map +1 -1
- package/BookReader/plugins/plugin.chapters.js +2 -2
- package/BookReader/plugins/plugin.chapters.js.map +1 -1
- package/BookReader/plugins/plugin.experiments.js.map +1 -1
- package/BookReader/plugins/plugin.iframe.js +1 -1
- package/BookReader/plugins/plugin.iframe.js.map +1 -1
- package/BookReader/plugins/plugin.iiif.js.map +1 -1
- package/BookReader/plugins/plugin.resume.js.map +1 -1
- package/BookReader/plugins/plugin.search.js +1 -1
- package/BookReader/plugins/plugin.search.js.map +1 -1
- package/BookReader/plugins/plugin.text_selection.js +43 -1
- package/BookReader/plugins/plugin.text_selection.js.map +1 -1
- package/BookReader/plugins/plugin.translate.js +45 -3
- package/BookReader/plugins/plugin.translate.js.map +1 -1
- package/BookReader/plugins/plugin.tts.js +1 -1
- package/BookReader/plugins/plugin.tts.js.map +1 -1
- package/BookReader/plugins/plugin.url.js +1 -1
- package/BookReader/plugins/plugin.url.js.map +1 -1
- package/BookReader/plugins/plugin.vendor-fullscreen.js +1 -1
- package/BookReader/plugins/plugin.vendor-fullscreen.js.map +1 -1
- package/BookReader/plugins/translator-worker.js.map +1 -1
- package/BookReader/webcomponents-bundle.js.map +1 -1
- package/jsconfig.json +2 -3
- package/package.json +41 -32
- package/src/BookReader/utils/SelectionObserver.js +4 -2
- package/src/BookReader.js +10 -21
- package/src/css/_TextSelection.scss +25 -10
- package/src/plugins/plugin.iiif.js +7 -1
- package/src/plugins/plugin.text_selection.js +4 -90
- package/src/plugins/search/plugin.search.js +2 -0
- package/src/plugins/tts/WebTTSEngine.js +2 -2
- package/src/plugins/tts/utils.js +0 -9
- package/src/plugins/url/UrlPlugin.js +12 -0
- package/src/util/TextSelectionManager.js +246 -173
- package/src/util/browserSniffing.js +9 -0
- package/src/util/generators.js +89 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";(self.webpackChunk_internetarchive_bookreader=self.webpackChunk_internetarchive_bookreader||[]).push([[479],{6098:function(t,e,r){var n=r(9504),o=2147483647,a=/[^\0-\u007E]/,i=/[.\u3002\uFF0E\uFF61]/g,s="Overflow: input needs wider integers to process",u=RangeError,l=n(i.exec),h=Math.floor,c=String.fromCharCode,f=n("".charCodeAt),p=n([].join),d=n([].push),m=n("".replace),g=n("".split),v=n("".toLowerCase),y=function(t){return t+22+75*(t<26)},b=function(t,e,r){var n=0;for(t=r?h(t/700):t>>1,t+=h(t/e);t>455;)t=h(t/35),n+=36;return h(n+36*t/(t+38))},w=function(t){var e=[];t=function(t){for(var e=[],r=0,n=t.length;r<n;){var o=f(t,r++);if(o>=55296&&o<=56319&&r<n){var a=f(t,r++);56320==(64512&a)?d(e,((1023&o)<<10)+(1023&a)+65536):(d(e,o),r--)}else d(e,o)}return e}(t);var r,n,a=t.length,i=128,l=0,m=72;for(r=0;r<t.length;r++)(n=t[r])<128&&d(e,c(n));var g=e.length,v=g;for(g&&d(e,"-");v<a;){var w=o;for(r=0;r<t.length;r++)(n=t[r])>=i&&n<w&&(w=n);var P=v+1;if(w-i>h((o-l)/P))throw new u(s);for(l+=(w-i)*P,i=w,r=0;r<t.length;r++){if((n=t[r])<i&&++l>o)throw new u(s);if(n===i){for(var S=l,k=36;;){var R=k<=m?1:k>=m+26?26:k-m;if(S<R)break;var U=S-R,B=36-R;d(e,c(y(R+U%B))),S=h(U/B),k+=36}d(e,c(y(S))),m=b(l,P,v===g),l=0,v++}}l++,i++}return p(e,"")};t.exports=function(t){var e,r,n=[],o=g(m(v(t),i,"."),".");for(e=0;e<o.length;e++)r=o[e],d(n,l(a,r)?"xn--"+w(r):r);return p(n,".")}},3921:function(t,e,r){var n=r(6518),o=r(2652),a=r(4659);n({target:"Object",stat:!0},{fromEntries:function(t){var e={};return o(t,function(t,r){a(e,t,r)},{AS_ENTRIES:!0}),e}})},5806:function(t,e,r){r(7764);var n,o=r(6518),a=r(3724),i=r(7416),s=r(4576),u=r(6080),l=r(9504),h=r(6840),c=r(2106),f=r(679),p=r(9297),d=r(4213),m=r(7916),g=r(7680),v=r(8183).codeAt,y=r(6098),b=r(655),w=r(687),P=r(2812),S=r(8406),k=r(1181),R=k.set,U=k.getterFor("URL"),B=S.URLSearchParams,H=S.getState,L=s.URL,O=s.TypeError,j=s.encodeURIComponent,I=s.parseInt,q=Math.floor,T=Math.pow,A=l("".charAt),F=l(/./.exec),C=l([].join),_=l(1.1.toString),M=l([].pop),E=l([].push),x=l("".replace),z=l([].shift),$=l("".split),N=l("".slice),D=l("".toLowerCase),J=l([].unshift),W="Invalid scheme",Q="Invalid host",G="Invalid port",K=/[a-z]/i,V=/[\d+\-.a-z]/i,X=/\d/,Y=/^0x/i,Z=/^[0-7]+$/,tt=/^\d+$/,et=/^[\da-f]+$/i,rt=/[\0\t\n\r #%/:<>?@[\\\]^|]/,nt=/[\0\t\n\r #/:<>?@[\\\]^|]/,ot=/^[\u0000-\u0020]+/,at=/(^|[^\u0000-\u0020])[\u0000-\u0020]+$/,it=/[\t\n\r]/g,st=function(t){var e,r,n,o;if("number"==typeof t){for(e=[],r=0;r<4;r++)J(e,t%256),t=q(t/256);return C(e,".")}if("object"==typeof t){for(e="",n=function(t){for(var e=null,r=1,n=null,o=0,a=0;a<8;a++)0!==t[a]?(o>r&&(e=n,r=o),n=null,o=0):(null===n&&(n=a),++o);return o>r?n:e}(t),r=0;r<8;r++)o&&0===t[r]||(o&&(o=!1),n===r?(e+=r?":":"::",o=!0):(e+=_(t[r],16),r<7&&(e+=":")));return"["+e+"]"}return t},ut={},lt=d({},ut,{" ":1,'"':1,"#":1,"<":1,">":1}),ht=d({},lt,{"'":1}),ct=d({},ut,{" ":1,'"':1,"<":1,">":1,"`":1}),ft=d({},ct,{"#":1,"?":1,"{":1,"}":1,"^":1}),pt=d({},ft,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),dt=function(t,e){var r=v(t,0);return r>=32&&r<127&&!p(e,t)?t:"'"===t&&p(e,t)?"%27":j(t)},mt={ftp:21,file:null,http:80,https:443,ws:80,wss:443},gt=function(t,e){var r;return 2===t.length&&F(K,A(t,0))&&(":"===(r=A(t,1))||!e&&"|"===r)},vt=function(t){var e;return t.length>1&>(N(t,0,2))&&(2===t.length||"/"===(e=A(t,2))||"\\"===e||"?"===e||"#"===e)},yt=function(t){return"."===t||"%2e"===D(t)},bt=function(t){return".."===(t=D(t))||"%2e."===t||".%2e"===t||"%2e%2e"===t},wt={},Pt={},St={},kt={},Rt={},Ut={},Bt={},Ht={},Lt={},Ot={},jt={},It={},qt={},Tt={},At={},Ft={},Ct={},_t={},Mt={},Et={},xt={},zt=function(t,e,r){var n,o,a,i=b(t);if(e){if(o=this.parse(i))throw new O(o);this.searchParams=null}else{if(void 0!==r&&(n=new zt(r,!0)),o=this.parse(i,null,n))throw new O(o);(a=H(new B)).bindURL(this),this.searchParams=a}};zt.prototype={type:"URL",parse:function(t,e,r){var o,a,i,s,u=this,l=e||wt,h=0,c="",f=!1,d=!1,v=!1;for(t=b(t),e||(u.scheme="",u.username="",u.password="",u.host=null,u.port=null,u.path=[],u.query=null,u.fragment=null,u.cannotBeABaseURL=!1,t=x(t,ot,""),t=x(t,at,"$1")),t=x(t,it,""),o=m(t);h<=o.length;){switch(a=o[h],l){case wt:if(!a||!F(K,a)){if(e)return W;l=St;continue}c+=D(a),l=Pt;break;case Pt:if(a&&F(V,a))c+=D(a);else{if(":"!==a){if(e)return W;c="",l=St,h=0;continue}if(e&&(u.isSpecial()!==p(mt,c)||"file"===c&&(u.includesCredentials()||null!==u.port)||"file"===u.scheme&&""===u.host))return;if(u.scheme=c,e)return void(u.isSpecial()&&mt[u.scheme]===u.port&&(u.port=null));c="","file"===u.scheme?l=Tt:u.isSpecial()&&r&&r.scheme===u.scheme?l=kt:u.isSpecial()?l=Ht:"/"===o[h+1]?(l=Rt,h++):(u.cannotBeABaseURL=!0,E(u.path,""),l=Mt)}break;case St:if(!r||r.cannotBeABaseURL&&"#"!==a)return W;if(r.cannotBeABaseURL&&"#"===a){u.scheme=r.scheme,u.path=g(r.path),u.query=r.query,u.fragment="",u.cannotBeABaseURL=!0,l=xt;break}l="file"===r.scheme?Tt:Ut;continue;case kt:if("/"!==a||"/"!==o[h+1]){l=Ut;continue}l=Lt,h++;break;case Rt:if("/"===a){l=Ot;break}l=_t;continue;case Ut:if(u.scheme=r.scheme,a===n)u.username=r.username,u.password=r.password,u.host=r.host,u.port=r.port,u.path=g(r.path),u.query=r.query;else if("/"===a||"\\"===a&&u.isSpecial())l=Bt;else if("?"===a)u.username=r.username,u.password=r.password,u.host=r.host,u.port=r.port,u.path=g(r.path),u.query="",l=Et;else{if("#"!==a){u.username=r.username,u.password=r.password,u.host=r.host,u.port=r.port,u.path=g(r.path),u.path.length&&u.path.length--,l=_t;continue}u.username=r.username,u.password=r.password,u.host=r.host,u.port=r.port,u.path=g(r.path),u.query=r.query,u.fragment="",l=xt}break;case Bt:if(!u.isSpecial()||"/"!==a&&"\\"!==a){if("/"!==a){u.username=r.username,u.password=r.password,u.host=r.host,u.port=r.port,l=_t;continue}l=Ot}else l=Lt;break;case Ht:if(l=Lt,"/"!==a||"/"!==o[h+1])continue;h++;break;case Lt:if("/"!==a&&"\\"!==a){l=Ot;continue}break;case Ot:if("@"===a){f&&(c="%40"+c),f=!0,i=m(c);for(var y=0;y<i.length;y++){var w=i[y];if(":"!==w||v){var P=dt(w,pt);v?u.password+=P:u.username+=P}else v=!0}c=""}else if(a===n||"/"===a||"?"===a||"#"===a||"\\"===a&&u.isSpecial()){if(f&&""===c)return"Invalid authority";h-=m(c).length+1,c="",l=jt}else c+=a;break;case jt:case It:if(e&&"file"===u.scheme){l=Ft;continue}if(":"!==a||d){if(a===n||"/"===a||"?"===a||"#"===a||"\\"===a&&u.isSpecial()){if(u.isSpecial()&&""===c)return Q;if(e&&""===c&&(u.includesCredentials()||null!==u.port))return;if(s=u.parseHost(c))return s;if(c="",l=Ct,e)return;continue}"["===a?d=!0:"]"===a&&(d=!1),c+=a}else{if(""===c)return Q;if(e===It)return;if(s=u.parseHost(c))return s;c="",l=qt}break;case qt:if(!F(X,a)){if(a===n||"/"===a||"?"===a||"#"===a||"\\"===a&&u.isSpecial()||e){if(""!==c){var S=I(c,10);if(S>65535)return G;u.port=u.isSpecial()&&S===mt[u.scheme]?null:S,c=""}if(e)return;l=Ct;continue}return G}c+=a;break;case Tt:if(u.scheme="file",u.host="","/"===a||"\\"===a)l=At;else{if(!r||"file"!==r.scheme){l=_t;continue}switch(a){case n:u.host=r.host,u.path=g(r.path),u.query=r.query;break;case"?":u.host=r.host,u.path=g(r.path),u.query="",l=Et;break;case"#":u.host=r.host,u.path=g(r.path),u.query=r.query,u.fragment="",l=xt;break;default:u.host=r.host,vt(C(g(o,h),""))||(u.path=g(r.path),u.shortenPath()),l=_t;continue}}break;case At:if("/"===a||"\\"===a){l=Ft;break}r&&"file"===r.scheme&&(u.host=r.host,!vt(C(g(o,h),""))&>(r.path[0],!0)&&E(u.path,r.path[0])),l=_t;continue;case Ft:if(a===n||"/"===a||"\\"===a||"?"===a||"#"===a){if(!e&>(c))l=_t;else if(""===c){if(u.host="",e)return;l=Ct}else{if(s=u.parseHost(c))return s;if("localhost"===u.host&&(u.host=""),e)return;c="",l=Ct}continue}c+=a;break;case Ct:if(u.isSpecial()){if(l=_t,"/"!==a&&"\\"!==a)continue}else if(e||"?"!==a)if(e||"#"!==a){if(a!==n&&(l=_t,"/"!==a))continue}else u.fragment="",l=xt;else u.query="",l=Et;break;case _t:if(a===n||"/"===a||"\\"===a&&u.isSpecial()||!e&&("?"===a||"#"===a)){if(bt(c)?(u.shortenPath(),"/"===a||"\\"===a&&u.isSpecial()||E(u.path,"")):yt(c)?"/"===a||"\\"===a&&u.isSpecial()||E(u.path,""):("file"===u.scheme&&!u.path.length&>(c)&&(null!==u.host&&""!==u.host&&(u.host=""),c=A(c,0)+":"),E(u.path,c)),c="","file"===u.scheme&&(a===n||"?"===a||"#"===a))for(;u.path.length>1&&""===u.path[0];)z(u.path);"?"===a?(u.query="",l=Et):"#"===a&&(u.fragment="",l=xt)}else c+=dt(a,ft);break;case Mt:"?"===a?(u.query="",l=Et):"#"===a?(u.fragment="",l=xt):a!==n&&(u.path[0]+=dt(a,ut));break;case Et:e||"#"!==a?a!==n&&(u.query+=dt(a,u.isSpecial()?ht:lt)):(u.fragment="",l=xt);break;case xt:a!==n&&(u.fragment+=dt(a,ct))}h++}},parseHost:function(t){var e,r,n;if("["===A(t,0)){if("]"!==A(t,t.length-1))return Q;if(e=function(t){var e,r,n,o,a,i,s,u=[0,0,0,0,0,0,0,0],l=0,h=null,c=0,f=function(){return A(t,c)};if(":"===f()){if(":"!==A(t,1))return;c+=2,h=++l}for(;f();){if(8===l)return;if(":"!==f()){for(e=r=0;r<4&&F(et,f());)e=16*e+I(f(),16),c++,r++;if("."===f()){if(0===r)return;if(c-=r,l>6)return;for(n=0;f();){if(o=null,n>0){if(!("."===f()&&n<4))return;c++}if(!F(X,f()))return;for(;F(X,f());){if(a=I(f(),10),null===o)o=a;else{if(0===o)return;o=10*o+a}if(o>255)return;c++}u[l]=256*u[l]+o,2!==++n&&4!==n||l++}if(4!==n)return;break}if(":"===f()){if(c++,!f())return}else if(f())return;u[l++]=e}else{if(null!==h)return;c++,h=++l}}if(null!==h)for(i=l-h,l=7;0!==l&&i>0;)s=u[l],u[l--]=u[h+i-1],u[h+--i]=s;else if(8!==l)return;return u}(N(t,1,-1)),!e)return Q;this.host=e}else if(this.isSpecial()){if(t=y(t),F(rt,t))return Q;if(function(t){var e,r,n=$(t,".");if(""===n[n.length-1]){if(1===n.length)return!1;n.length--}return e=n[n.length-1],!!F(tt,e)||!!F(Y,e)&&(""===(r=N(e,2))||!!F(et,r))}(t)){if(e=function(t){var e,r,n,o,a,i,s,u=$(t,".");if(u.length&&""===u[u.length-1]&&u.length--,(e=u.length)>4)return null;for(r=[],n=0;n<e;n++){if(""===(o=u[n]))return null;if(a=10,o.length>1&&"0"===A(o,0)&&(a=F(Y,o)?16:8,o=N(o,8===a?1:2)),""===o)i=0;else{if(!F(10===a?tt:8===a?Z:et,o))return null;i=I(o,a)}E(r,i)}for(n=0;n<e;n++)if(i=r[n],n===e-1){if(i>=T(256,5-e))return null}else if(i>255)return null;for(s=M(r),n=0;n<r.length;n++)s+=r[n]*T(256,3-n);return s}(t),null===e)return Q;this.host=e}else this.host=t}else{if(F(nt,t))return Q;for(e="",r=m(t),n=0;n<r.length;n++)e+=dt(r[n],ut);this.host=e}},cannotHaveUsernamePasswordPort:function(){return null===this.host||""===this.host||this.cannotBeABaseURL||"file"===this.scheme},includesCredentials:function(){return""!==this.username||""!==this.password},isSpecial:function(){return p(mt,this.scheme)},shortenPath:function(){var t=this.path,e=t.length;!e||"file"===this.scheme&&1===e&>(t[0],!0)||t.length--},serialize:function(){var t=this,e=t.scheme,r=t.username,n=t.password,o=t.host,a=t.port,i=t.path,s=t.query,u=t.fragment,l=e+":";return null!==o?(l+="//",t.includesCredentials()&&(l+=r+(n?":"+n:"")+"@"),l+=st(o),null!==a&&(l+=":"+a)):"file"===e&&(l+="//"),null===o&&!t.cannotBeABaseURL&&i.length>1&&""===i[0]&&(l+="/."),l+=t.cannotBeABaseURL?i[0]:i.length?"/"+C(i,"/"):"",null!==s&&(l+="?"+s),null!==u&&(l+="#"+u),l},setHref:function(t){var e=this.parse(t);if(e)throw new O(e);this.searchParams.update()},getOrigin:function(){var t=this.scheme,e=this.port;if("blob"===t)try{return new $t(this.path[0]).origin}catch(t){return"null"}return"file"!==t&&this.isSpecial()?t+"://"+st(this.host)+(null!==e?":"+e:""):"null"},getProtocol:function(){return this.scheme+":"},setProtocol:function(t){this.parse(b(t)+":",wt)},getUsername:function(){return this.username},setUsername:function(t){var e=m(b(t));if(!this.cannotHaveUsernamePasswordPort()){this.username="";for(var r=0;r<e.length;r++)this.username+=dt(e[r],pt)}},getPassword:function(){return this.password},setPassword:function(t){var e=m(b(t));if(!this.cannotHaveUsernamePasswordPort()){this.password="";for(var r=0;r<e.length;r++)this.password+=dt(e[r],pt)}},getHost:function(){var t=this.host,e=this.port;return null===t?"":null===e?st(t):st(t)+":"+e},setHost:function(t){this.cannotBeABaseURL||this.parse(t,jt)},getHostname:function(){var t=this.host;return null===t?"":st(t)},setHostname:function(t){this.cannotBeABaseURL||this.parse(t,It)},getPort:function(){var t=this.port;return null===t?"":b(t)},setPort:function(t){this.cannotHaveUsernamePasswordPort()||(""===(t=b(t))?this.port=null:this.parse(t,qt))},getPathname:function(){var t=this.path;return this.cannotBeABaseURL?t[0]:t.length?"/"+C(t,"/"):""},setPathname:function(t){this.cannotBeABaseURL||(this.path=[],this.parse(t,Ct))},getSearch:function(){var t=this.query;return t?"?"+t:""},setSearch:function(t){""===(t=b(t))?this.query=null:("?"===A(t,0)&&(t=N(t,1)),this.query="",this.parse(t,Et)),this.searchParams.update()},getSearchParams:function(){return this.searchParams.facade},getHash:function(){var t=this.fragment;return t?"#"+t:""},setHash:function(t){""!==(t=b(t))?("#"===A(t,0)&&(t=N(t,1)),this.fragment="",this.parse(t,xt)):this.fragment=null},update:function(){this.query=this.searchParams.serialize()||null}};var $t=function(t){var e=f(this,Nt),r=P(arguments.length,1)>1?arguments[1]:void 0,n=R(e,new zt(t,!1,r));a||(e.href=n.serialize(),e.origin=n.getOrigin(),e.protocol=n.getProtocol(),e.username=n.getUsername(),e.password=n.getPassword(),e.host=n.getHost(),e.hostname=n.getHostname(),e.port=n.getPort(),e.pathname=n.getPathname(),e.search=n.getSearch(),e.searchParams=n.getSearchParams(),e.hash=n.getHash())},Nt=$t.prototype,Dt=function(t,e){return{get:function(){return U(this)[t]()},set:e&&function(t){return U(this)[e](t)},configurable:!0,enumerable:!0}};if(a&&(c(Nt,"href",Dt("serialize","setHref")),c(Nt,"origin",Dt("getOrigin")),c(Nt,"protocol",Dt("getProtocol","setProtocol")),c(Nt,"username",Dt("getUsername","setUsername")),c(Nt,"password",Dt("getPassword","setPassword")),c(Nt,"host",Dt("getHost","setHost")),c(Nt,"hostname",Dt("getHostname","setHostname")),c(Nt,"port",Dt("getPort","setPort")),c(Nt,"pathname",Dt("getPathname","setPathname")),c(Nt,"search",Dt("getSearch","setSearch")),c(Nt,"searchParams",Dt("getSearchParams")),c(Nt,"hash",Dt("getHash","setHash"))),h(Nt,"toJSON",function(){return U(this).serialize()},{enumerable:!0}),h(Nt,"toString",function(){return U(this).serialize()},{enumerable:!0}),L){var Jt=L.createObjectURL,Wt=L.revokeObjectURL;Jt&&h($t,"createObjectURL",u(Jt,L)),Wt&&h($t,"revokeObjectURL",u(Wt,L))}w($t,"URL"),o({global:!0,constructor:!0,forced:!i,sham:!a},{URL:$t})},3296:function(t,e,r){r(5806)},7208:function(t,e,r){var n=r(6518),o=r(9565);n({target:"URL",proto:!0,enumerable:!0},{toJSON:function(){return o(URL.prototype.toString,this)}})},5857:function(t,e,r){function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}function o(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function a(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,i(n.key),n)}}function i(t){var e=function(t){if("object"!=n(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=n(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==n(e)?e:e+""}r(2675),r(9463),r(2259),r(5700),r(8706),r(3792),r(2712),r(9572),r(8130),r(3851),r(875),r(6099),r(825),r(888),r(7495),r(7764),r(5440),r(2953),r(8408),r(2008),r(113),r(3418),r(8598),r(2062),r(4782),r(2010),r(5506),r(3921),r(9432),r(8781),r(1761),r(5746),r(2762),r(3500),r(3296),r(7208);var s,u=function(){return t=function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.bookReaderOptions=e,this.urlSchema=[{name:"page",position:"path",default:"n0"},{name:"mode",position:"path",default:"2up"},{name:"search",position:"path",deprecated_for:"q"},{name:"q",position:"query_param"},{name:"sort",position:"query_param"},{name:"view",position:"query_param"},{name:"admin",position:"query_param"}],this.urlState={},this.urlMode=this.bookReaderOptions.urlMode||"hash",this.urlHistoryBasePath=this.bookReaderOptions.urlHistoryBasePath||"/",this.urlLocationPollId=null,this.oldLocationHash=null,this.oldUserHash=null},e=[{key:"urlStateToUrlString",value:function(t){var e=this,r=new URLSearchParams,n={};Object.keys(t).forEach(function(o){var a,i,s,u,l=e.urlSchema.find(function(t){return t.name===o});null!==(a=l)&&void 0!==a&&a.deprecated_for&&(l=e.urlSchema.find(function(t){return t.name===l.deprecated_for})),"path"==(null===(i=l)||void 0===i?void 0:i.position)?n[null===(s=l)||void 0===s?void 0:s.name]=t[o]:r.append((null===(u=l)||void 0===u?void 0:u.name)||o,t[o])});var o=this.urlSchema.filter(function(t){return"path"==t.position}).map(function(t){return n[t.name]?"".concat(t.name,"/").concat(encodeURIComponent(n[t.name])):""}).join("/"),a="".concat(o.replace(/\/+/g,"/").replace(/\/+$/,"")),i="".concat(a,"?").concat(r.toString());return r.toString()?i:"".concat(a)}},{key:"urlStringToUrlState",value:function(t){var e={},r=new URL(t,"http://example.com"),n=Object.fromEntries(r.searchParams.entries()),a=r.pathname.match(/[^\\/]+\/[^\\/]+/g),i=a?Object.fromEntries(a.map(function(t){return t.split("/")})):{},s=function(t,e){return Object.keys(t).some(function(t){return t==e})};return this.urlSchema.filter(function(t){return"path"==t.position}).forEach(function(t){var r=s(i,t.name),n=s(t,"deprecated_for")&&r;if(r||n){var o=n?t.deprecated_for:t.name;e[o]=decodeURIComponent(i[t.name])}}),Object.entries(n).forEach(function(t){var r=function(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,a,i,s=[],u=!0,l=!1;try{if(a=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=a.call(r)).done)&&(s.push(n.value),s.length!==e);u=!0);}catch(t){l=!0,o=t}finally{try{if(!u&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(l)throw o}}return s}}(t,e)||function(t,e){if(t){if("string"==typeof t)return o(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?o(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(t,2),n=r[0],a=r[1];e[n]=a}),e}},{key:"setUrlParam",value:function(t,e){this.urlState[t]=e,this.pushToAddressBar()}},{key:"removeUrlParam",value:function(t){delete this.urlState[t],this.pushToAddressBar()}},{key:"getUrlParam",value:function(t){return this.urlState[t]}},{key:"pushToAddressBar",value:function(){var t=this.urlStateToUrlString(this.urlState),e="/"!==t?t:"";if("history"==this.urlMode)if(window.history&&window.history.replaceState){var r="".concat(this.urlHistoryBasePath).concat(e).trim().replace(/(\/+)/g,"/");try{window.history.replaceState({},null,r)}catch(t){this.urlMode="hash"}}else this.options.urlMode="hash";"hash"==this.urlMode&&window.location.replace("#"+e),this.oldLocationHash=t}},{key:"listenForHashChanges",value:function(){var t=this;this.oldLocationHash=this.getHash(),this.urlLocationPollId&&(clearInterval(this.urlLocationPollId),this.urlLocationPollId=null),this.urlLocationPollId=setInterval(function(){var e=t.getHash();e!=t.oldLocationHash&&(t.urlState=t.urlStringToUrlState(e))},500)}},{key:"pullFromAddressBar",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:window.location,e="history"===this.urlMode?t.pathname.substr(this.urlHistoryBasePath.length)+t.search:t.hash.substr(1);this.urlState=this.urlStringToUrlState(e)}},{key:"getHash",value:function(){return window.location.hash.slice(1)}}],e&&a(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();function l(t){return l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},l(t)}function h(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,c(n.key),n)}}function c(t){var e=function(t){if("object"!=l(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=l(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==l(e)?e:e+""}function f(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(f=function(){return!!t})()}function p(){return p="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,r){var n=function(t,e){for(;!{}.hasOwnProperty.call(t,e)&&null!==(t=d(t)););return t}(t,e);if(n){var o=Object.getOwnPropertyDescriptor(n,e);return o.get?o.get.call(arguments.length<3?t:r):o.value}},p.apply(null,arguments)}function d(t){return d=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},d(t)}function m(t,e){return m=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},m(t,e)}r(1669).extend(BookReader.defaultOptions,{enableUrlPlugin:!0,bookId:"",defaults:null,updateWindowTitle:!1,urlMode:"hash",urlHistoryBasePath:"/",urlTrackedParams:["page","search","mode","region","highlight","view","text"],urlTrackIndex0:!1}),BookReader.prototype.setup=(s=BookReader.prototype.setup,function(t){s.call(this,t),this.bookId=t.bookId,this.defaults=t.defaults,this.locationPollId=null,this.oldLocationHash=null,this.oldUserHash=null}),BookReader.prototype.init=function(t){return function(){var e=this;this.options.enableUrlPlugin&&(this.bind(BookReader.eventNames.PostInit,function(){var t=e.options,r=t.updateWindowTitle,n=t.urlMode;r&&(document.title=e.shortTitle(e.bookTitle,50)),"hash"===n&&e.urlStartLocationPolling()}),this.bind(BookReader.eventNames.fragmentChange,this.urlUpdateFragment.bind(this))),t.call(this)}}(BookReader.prototype.init),BookReader.prototype.shortTitle=function(t){return this.bookTitle.length<t?this.bookTitle:"".concat(this.bookTitle.substr(0,t-3),"...")},BookReader.prototype.urlStartLocationPolling=function(){var t=this;this.oldLocationHash=this.urlReadFragment(),this.locationPollId&&(clearInterval(this.locationPollId),this.locationPollId=null),this.locationPollId=setInterval(function(){var e=t.urlReadFragment();if(e!=t.oldLocationHash&&e!=t.oldUserHash){var r,n=t.paramsFromFragment(e),o=function(){return t.updateFromParams(n)};t.trigger(BookReader.eventNames.stop),t.animating?(null===(r=t.plugins.autoplay)||void 0===r||r.stop(),t.animationFinishedCallback=o):o(),t.oldUserHash=e}},500)},BookReader.prototype.urlUpdateFragment=function(){var t=this.paramsFromCurrent(),e=this.options,r=e.urlTrackIndex0,n=e.urlTrackedParams;r||void 0===t.index||0!==t.index||(delete t.index,delete t.page);var o=n.reduce(function(e,r){return r in t&&(e[r]=t[r]),e},{}),a=this.fragmentFromParams(o,this.options.urlMode),i=""===a?"":"/".concat(a),s=this.urlReadFragment(),u=this.getLocationSearch(),l=this.queryStringFromParams(o,u,this.options.urlMode);if(s!==a||u!==l){if("history"===this.options.urlMode)if(window.history&&window.history.replaceState){var h=this.options.urlHistoryBasePath.replace(/\/+$/,""),c="".concat(h).concat(i).concat(l);try{window.history.replaceState({},null,c),this.oldLocationHash=a+l}catch(t){this.options.urlMode="hash"}}else this.options.urlMode="hash";if("hash"===this.options.urlMode){var f=this.urlParamsFiltersOnlySearch(this.readQueryString());window.location.replace("#"+a+f),this.oldLocationHash=a+f}}},BookReader.prototype.urlParamsFiltersOnlySearch=function(t){var e=new URLSearchParams(t);return e.has("q")?"?".concat(new URLSearchParams({q:e.get("q")})):""},BookReader.prototype.urlReadFragment=function(){var t=this.options,e=t.urlMode,r=t.urlHistoryBasePath;return"history"===e?window.location.pathname.substr(r.length):this.urlPlugin.getHash()},BookReader.prototype.urlReadHashFragment=function(){return window.location.hash.substr(1)};var g=function(){function t(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),function(t,e,r){return e=d(e),function(t,e){if(e&&("object"==l(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,f()?Reflect.construct(e,r||[],d(t).constructor):e.apply(t,r))}(this,t,arguments)}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&m(t,e)}(t,BookReader),e=t,r=[{key:"init",value:function(){var e,r,n,o=this;this.options.enableUrlPlugin&&(this.urlPlugin=new u(this.options),this.on(BookReader.eventNames.PostInit,function(){"hash"===o.options.urlMode&&o.urlPlugin.listenForHashChanges()})),(e=t,r=this,"function"==typeof(n=p(d(1&3?e.prototype:e),"init",r))?function(t){return n.apply(r,t)}:n)([])}}],r&&h(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,r}();window.BookReader=g}},function(t){t(t.s=5857)}]);
|
|
1
|
+
"use strict";(self.webpackChunk_internetarchive_bookreader=self.webpackChunk_internetarchive_bookreader||[]).push([[479],{6098:function(t,e,r){var n=r(9504),o=2147483647,a=/[^\0-\u007E]/,i=/[.\u3002\uFF0E\uFF61]/g,s="Overflow: input needs wider integers to process",u=RangeError,l=n(i.exec),h=Math.floor,c=String.fromCharCode,f=n("".charCodeAt),p=n([].join),d=n([].push),m=n("".replace),g=n("".split),v=n("".toLowerCase),y=function(t){return t+22+75*(t<26)},b=function(t,e,r){var n=0;for(t=r?h(t/700):t>>1,t+=h(t/e);t>455;)t=h(t/35),n+=36;return h(n+36*t/(t+38))},w=function(t){var e=[];t=function(t){for(var e=[],r=0,n=t.length;r<n;){var o=f(t,r++);if(o>=55296&&o<=56319&&r<n){var a=f(t,r++);56320==(64512&a)?d(e,((1023&o)<<10)+(1023&a)+65536):(d(e,o),r--)}else d(e,o)}return e}(t);var r,n,a=t.length,i=128,l=0,m=72;for(r=0;r<t.length;r++)(n=t[r])<128&&d(e,c(n));var g=e.length,v=g;for(g&&d(e,"-");v<a;){var w=o;for(r=0;r<t.length;r++)(n=t[r])>=i&&n<w&&(w=n);var P=v+1;if(w-i>h((o-l)/P))throw new u(s);for(l+=(w-i)*P,i=w,r=0;r<t.length;r++){if((n=t[r])<i&&++l>o)throw new u(s);if(n===i){for(var S=l,k=36;;){var R=k<=m?1:k>=m+26?26:k-m;if(S<R)break;var U=S-R,B=36-R;d(e,c(y(R+U%B))),S=h(U/B),k+=36}d(e,c(y(S))),m=b(l,P,v===g),l=0,v++}}l++,i++}return p(e,"")};t.exports=function(t){var e,r,n=[],o=g(m(v(t),i,"."),".");for(e=0;e<o.length;e++)r=o[e],d(n,l(a,r)?"xn--"+w(r):r);return p(n,".")}},706:function(t,e,r){var n=r(350).PROPER,o=r(9039),a=r(7452);t.exports=function(t){return o(function(){return!!a[t]()||"
"!=="
"[t]()||n&&a[t].name!==t})}},3921:function(t,e,r){var n=r(6518),o=r(2652),a=r(4659);n({target:"Object",stat:!0},{fromEntries:function(t){var e={};return o(t,function(t,r){a(e,t,r)},{AS_ENTRIES:!0}),e}})},2762:function(t,e,r){var n=r(6518),o=r(3802).trim;n({target:"String",proto:!0,forced:r(706)("trim")},{trim:function(){return o(this)}})},5806:function(t,e,r){r(7764);var n,o=r(6518),a=r(3724),i=r(7416),s=r(4576),u=r(6080),l=r(9504),h=r(6840),c=r(2106),f=r(679),p=r(9297),d=r(4213),m=r(7916),g=r(7680),v=r(8183).codeAt,y=r(6098),b=r(655),w=r(687),P=r(2812),S=r(8406),k=r(1181),R=k.set,U=k.getterFor("URL"),B=S.URLSearchParams,H=S.getState,L=s.URL,O=s.TypeError,j=s.encodeURIComponent,q=s.parseInt,I=Math.floor,T=Math.pow,A=l("".charAt),F=l(/./.exec),_=l([].join),C=l(1.1.toString),E=l([].pop),M=l([].push),x=l("".replace),z=l([].shift),$=l("".split),N=l("".slice),D=l("".toLowerCase),J=l([].unshift),W="Invalid scheme",Q="Invalid host",G="Invalid port",K=/[a-z]/i,V=/[\d+\-.a-z]/i,X=/\d/,Y=/^0x/i,Z=/^[0-7]+$/,tt=/^\d+$/,et=/^[\da-f]+$/i,rt=/[\0\t\n\r #%/:<>?@[\\\]^|]/,nt=/[\0\t\n\r #/:<>?@[\\\]^|]/,ot=/^[\u0000-\u0020]+/,at=/(^|[^\u0000-\u0020])[\u0000-\u0020]+$/,it=/[\t\n\r]/g,st=function(t){var e,r,n,o;if("number"==typeof t){for(e=[],r=0;r<4;r++)J(e,t%256),t=I(t/256);return _(e,".")}if("object"==typeof t){for(e="",n=function(t){for(var e=null,r=1,n=null,o=0,a=0;a<8;a++)0!==t[a]?(o>r&&(e=n,r=o),n=null,o=0):(null===n&&(n=a),++o);return o>r?n:e}(t),r=0;r<8;r++)o&&0===t[r]||(o&&(o=!1),n===r?(e+=r?":":"::",o=!0):(e+=C(t[r],16),r<7&&(e+=":")));return"["+e+"]"}return t},ut={},lt=d({},ut,{" ":1,'"':1,"#":1,"<":1,">":1}),ht=d({},lt,{"'":1}),ct=d({},ut,{" ":1,'"':1,"<":1,">":1,"`":1}),ft=d({},ct,{"#":1,"?":1,"{":1,"}":1,"^":1}),pt=d({},ft,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),dt=function(t,e){var r=v(t,0);return r>=32&&r<127&&!p(e,t)?t:"'"===t&&p(e,t)?"%27":j(t)},mt={ftp:21,file:null,http:80,https:443,ws:80,wss:443},gt=function(t,e){var r;return 2===t.length&&F(K,A(t,0))&&(":"===(r=A(t,1))||!e&&"|"===r)},vt=function(t){var e;return t.length>1&>(N(t,0,2))&&(2===t.length||"/"===(e=A(t,2))||"\\"===e||"?"===e||"#"===e)},yt=function(t){return"."===t||"%2e"===D(t)},bt=function(t){return".."===(t=D(t))||"%2e."===t||".%2e"===t||"%2e%2e"===t},wt={},Pt={},St={},kt={},Rt={},Ut={},Bt={},Ht={},Lt={},Ot={},jt={},qt={},It={},Tt={},At={},Ft={},_t={},Ct={},Et={},Mt={},xt={},zt=function(t,e,r){var n,o,a,i=b(t);if(e){if(o=this.parse(i))throw new O(o);this.searchParams=null}else{if(void 0!==r&&(n=new zt(r,!0)),o=this.parse(i,null,n))throw new O(o);(a=H(new B)).bindURL(this),this.searchParams=a}};zt.prototype={type:"URL",parse:function(t,e,r){var o,a,i,s,u=this,l=e||wt,h=0,c="",f=!1,d=!1,v=!1;for(t=b(t),e||(u.scheme="",u.username="",u.password="",u.host=null,u.port=null,u.path=[],u.query=null,u.fragment=null,u.cannotBeABaseURL=!1,t=x(t,ot,""),t=x(t,at,"$1")),t=x(t,it,""),o=m(t);h<=o.length;){switch(a=o[h],l){case wt:if(!a||!F(K,a)){if(e)return W;l=St;continue}c+=D(a),l=Pt;break;case Pt:if(a&&F(V,a))c+=D(a);else{if(":"!==a){if(e)return W;c="",l=St,h=0;continue}if(e&&(u.isSpecial()!==p(mt,c)||"file"===c&&(u.includesCredentials()||null!==u.port)||"file"===u.scheme&&""===u.host))return;if(u.scheme=c,e)return void(u.isSpecial()&&mt[u.scheme]===u.port&&(u.port=null));c="","file"===u.scheme?l=Tt:u.isSpecial()&&r&&r.scheme===u.scheme?l=kt:u.isSpecial()?l=Ht:"/"===o[h+1]?(l=Rt,h++):(u.cannotBeABaseURL=!0,M(u.path,""),l=Et)}break;case St:if(!r||r.cannotBeABaseURL&&"#"!==a)return W;if(r.cannotBeABaseURL&&"#"===a){u.scheme=r.scheme,u.path=g(r.path),u.query=r.query,u.fragment="",u.cannotBeABaseURL=!0,l=xt;break}l="file"===r.scheme?Tt:Ut;continue;case kt:if("/"!==a||"/"!==o[h+1]){l=Ut;continue}l=Lt,h++;break;case Rt:if("/"===a){l=Ot;break}l=Ct;continue;case Ut:if(u.scheme=r.scheme,a===n)u.username=r.username,u.password=r.password,u.host=r.host,u.port=r.port,u.path=g(r.path),u.query=r.query;else if("/"===a||"\\"===a&&u.isSpecial())l=Bt;else if("?"===a)u.username=r.username,u.password=r.password,u.host=r.host,u.port=r.port,u.path=g(r.path),u.query="",l=Mt;else{if("#"!==a){u.username=r.username,u.password=r.password,u.host=r.host,u.port=r.port,u.path=g(r.path),u.path.length&&u.path.length--,l=Ct;continue}u.username=r.username,u.password=r.password,u.host=r.host,u.port=r.port,u.path=g(r.path),u.query=r.query,u.fragment="",l=xt}break;case Bt:if(!u.isSpecial()||"/"!==a&&"\\"!==a){if("/"!==a){u.username=r.username,u.password=r.password,u.host=r.host,u.port=r.port,l=Ct;continue}l=Ot}else l=Lt;break;case Ht:if(l=Lt,"/"!==a||"/"!==o[h+1])continue;h++;break;case Lt:if("/"!==a&&"\\"!==a){l=Ot;continue}break;case Ot:if("@"===a){f&&(c="%40"+c),f=!0,i=m(c);for(var y=0;y<i.length;y++){var w=i[y];if(":"!==w||v){var P=dt(w,pt);v?u.password+=P:u.username+=P}else v=!0}c=""}else if(a===n||"/"===a||"?"===a||"#"===a||"\\"===a&&u.isSpecial()){if(f&&""===c)return"Invalid authority";h-=m(c).length+1,c="",l=jt}else c+=a;break;case jt:case qt:if(e&&"file"===u.scheme){l=Ft;continue}if(":"!==a||d){if(a===n||"/"===a||"?"===a||"#"===a||"\\"===a&&u.isSpecial()){if(u.isSpecial()&&""===c)return Q;if(e&&""===c&&(u.includesCredentials()||null!==u.port))return;if(s=u.parseHost(c))return s;if(c="",l=_t,e)return;continue}"["===a?d=!0:"]"===a&&(d=!1),c+=a}else{if(""===c)return Q;if(e===qt)return;if(s=u.parseHost(c))return s;c="",l=It}break;case It:if(!F(X,a)){if(a===n||"/"===a||"?"===a||"#"===a||"\\"===a&&u.isSpecial()||e){if(""!==c){var S=q(c,10);if(S>65535)return G;u.port=u.isSpecial()&&S===mt[u.scheme]?null:S,c=""}if(e)return;l=_t;continue}return G}c+=a;break;case Tt:if(u.scheme="file",u.host="","/"===a||"\\"===a)l=At;else{if(!r||"file"!==r.scheme){l=Ct;continue}switch(a){case n:u.host=r.host,u.path=g(r.path),u.query=r.query;break;case"?":u.host=r.host,u.path=g(r.path),u.query="",l=Mt;break;case"#":u.host=r.host,u.path=g(r.path),u.query=r.query,u.fragment="",l=xt;break;default:u.host=r.host,vt(_(g(o,h),""))||(u.path=g(r.path),u.shortenPath()),l=Ct;continue}}break;case At:if("/"===a||"\\"===a){l=Ft;break}r&&"file"===r.scheme&&(u.host=r.host,!vt(_(g(o,h),""))&>(r.path[0],!0)&&M(u.path,r.path[0])),l=Ct;continue;case Ft:if(a===n||"/"===a||"\\"===a||"?"===a||"#"===a){if(!e&>(c))l=Ct;else if(""===c){if(u.host="",e)return;l=_t}else{if(s=u.parseHost(c))return s;if("localhost"===u.host&&(u.host=""),e)return;c="",l=_t}continue}c+=a;break;case _t:if(u.isSpecial()){if(l=Ct,"/"!==a&&"\\"!==a)continue}else if(e||"?"!==a)if(e||"#"!==a){if(a!==n&&(l=Ct,"/"!==a))continue}else u.fragment="",l=xt;else u.query="",l=Mt;break;case Ct:if(a===n||"/"===a||"\\"===a&&u.isSpecial()||!e&&("?"===a||"#"===a)){if(bt(c)?(u.shortenPath(),"/"===a||"\\"===a&&u.isSpecial()||M(u.path,"")):yt(c)?"/"===a||"\\"===a&&u.isSpecial()||M(u.path,""):("file"===u.scheme&&!u.path.length&>(c)&&(null!==u.host&&""!==u.host&&(u.host=""),c=A(c,0)+":"),M(u.path,c)),c="","file"===u.scheme&&(a===n||"?"===a||"#"===a))for(;u.path.length>1&&""===u.path[0];)z(u.path);"?"===a?(u.query="",l=Mt):"#"===a&&(u.fragment="",l=xt)}else c+=dt(a,ft);break;case Et:"?"===a?(u.query="",l=Mt):"#"===a?(u.fragment="",l=xt):a!==n&&(u.path[0]+=dt(a,ut));break;case Mt:e||"#"!==a?a!==n&&(u.query+=dt(a,u.isSpecial()?ht:lt)):(u.fragment="",l=xt);break;case xt:a!==n&&(u.fragment+=dt(a,ct))}h++}},parseHost:function(t){var e,r,n;if("["===A(t,0)){if("]"!==A(t,t.length-1))return Q;if(e=function(t){var e,r,n,o,a,i,s,u=[0,0,0,0,0,0,0,0],l=0,h=null,c=0,f=function(){return A(t,c)};if(":"===f()){if(":"!==A(t,1))return;c+=2,h=++l}for(;f();){if(8===l)return;if(":"!==f()){for(e=r=0;r<4&&F(et,f());)e=16*e+q(f(),16),c++,r++;if("."===f()){if(0===r)return;if(c-=r,l>6)return;for(n=0;f();){if(o=null,n>0){if(!("."===f()&&n<4))return;c++}if(!F(X,f()))return;for(;F(X,f());){if(a=q(f(),10),null===o)o=a;else{if(0===o)return;o=10*o+a}if(o>255)return;c++}u[l]=256*u[l]+o,2!==++n&&4!==n||l++}if(4!==n)return;break}if(":"===f()){if(c++,!f())return}else if(f())return;u[l++]=e}else{if(null!==h)return;c++,h=++l}}if(null!==h)for(i=l-h,l=7;0!==l&&i>0;)s=u[l],u[l--]=u[h+i-1],u[h+--i]=s;else if(8!==l)return;return u}(N(t,1,-1)),!e)return Q;this.host=e}else if(this.isSpecial()){if(t=y(t),F(rt,t))return Q;if(function(t){var e,r,n=$(t,".");if(""===n[n.length-1]){if(1===n.length)return!1;n.length--}return e=n[n.length-1],!!F(tt,e)||!!F(Y,e)&&(""===(r=N(e,2))||!!F(et,r))}(t)){if(e=function(t){var e,r,n,o,a,i,s,u=$(t,".");if(u.length&&""===u[u.length-1]&&u.length--,(e=u.length)>4)return null;for(r=[],n=0;n<e;n++){if(""===(o=u[n]))return null;if(a=10,o.length>1&&"0"===A(o,0)&&(a=F(Y,o)?16:8,o=N(o,8===a?1:2)),""===o)i=0;else{if(!F(10===a?tt:8===a?Z:et,o))return null;i=q(o,a)}M(r,i)}for(n=0;n<e;n++)if(i=r[n],n===e-1){if(i>=T(256,5-e))return null}else if(i>255)return null;for(s=E(r),n=0;n<r.length;n++)s+=r[n]*T(256,3-n);return s}(t),null===e)return Q;this.host=e}else this.host=t}else{if(F(nt,t))return Q;for(e="",r=m(t),n=0;n<r.length;n++)e+=dt(r[n],ut);this.host=e}},cannotHaveUsernamePasswordPort:function(){return null===this.host||""===this.host||this.cannotBeABaseURL||"file"===this.scheme},includesCredentials:function(){return""!==this.username||""!==this.password},isSpecial:function(){return p(mt,this.scheme)},shortenPath:function(){var t=this.path,e=t.length;!e||"file"===this.scheme&&1===e&>(t[0],!0)||t.length--},serialize:function(){var t=this,e=t.scheme,r=t.username,n=t.password,o=t.host,a=t.port,i=t.path,s=t.query,u=t.fragment,l=e+":";return null!==o?(l+="//",t.includesCredentials()&&(l+=r+(n?":"+n:"")+"@"),l+=st(o),null!==a&&(l+=":"+a)):"file"===e&&(l+="//"),null===o&&!t.cannotBeABaseURL&&i.length>1&&""===i[0]&&(l+="/."),l+=t.cannotBeABaseURL?i[0]:i.length?"/"+_(i,"/"):"",null!==s&&(l+="?"+s),null!==u&&(l+="#"+u),l},setHref:function(t){var e=this.parse(t);if(e)throw new O(e);this.searchParams.update()},getOrigin:function(){var t=this.scheme,e=this.port;if("blob"===t)try{return new $t(this.path[0]).origin}catch(t){return"null"}return"file"!==t&&this.isSpecial()?t+"://"+st(this.host)+(null!==e?":"+e:""):"null"},getProtocol:function(){return this.scheme+":"},setProtocol:function(t){this.parse(b(t)+":",wt)},getUsername:function(){return this.username},setUsername:function(t){var e=m(b(t));if(!this.cannotHaveUsernamePasswordPort()){this.username="";for(var r=0;r<e.length;r++)this.username+=dt(e[r],pt)}},getPassword:function(){return this.password},setPassword:function(t){var e=m(b(t));if(!this.cannotHaveUsernamePasswordPort()){this.password="";for(var r=0;r<e.length;r++)this.password+=dt(e[r],pt)}},getHost:function(){var t=this.host,e=this.port;return null===t?"":null===e?st(t):st(t)+":"+e},setHost:function(t){this.cannotBeABaseURL||this.parse(t,jt)},getHostname:function(){var t=this.host;return null===t?"":st(t)},setHostname:function(t){this.cannotBeABaseURL||this.parse(t,qt)},getPort:function(){var t=this.port;return null===t?"":b(t)},setPort:function(t){this.cannotHaveUsernamePasswordPort()||(""===(t=b(t))?this.port=null:this.parse(t,It))},getPathname:function(){var t=this.path;return this.cannotBeABaseURL?t[0]:t.length?"/"+_(t,"/"):""},setPathname:function(t){this.cannotBeABaseURL||(this.path=[],this.parse(t,_t))},getSearch:function(){var t=this.query;return t?"?"+t:""},setSearch:function(t){""===(t=b(t))?this.query=null:("?"===A(t,0)&&(t=N(t,1)),this.query="",this.parse(t,Mt)),this.searchParams.update()},getSearchParams:function(){return this.searchParams.facade},getHash:function(){var t=this.fragment;return t?"#"+t:""},setHash:function(t){""!==(t=b(t))?("#"===A(t,0)&&(t=N(t,1)),this.fragment="",this.parse(t,xt)):this.fragment=null},update:function(){this.query=this.searchParams.serialize()||null}};var $t=function(t){var e=f(this,Nt),r=P(arguments.length,1)>1?arguments[1]:void 0,n=R(e,new zt(t,!1,r));a||(e.href=n.serialize(),e.origin=n.getOrigin(),e.protocol=n.getProtocol(),e.username=n.getUsername(),e.password=n.getPassword(),e.host=n.getHost(),e.hostname=n.getHostname(),e.port=n.getPort(),e.pathname=n.getPathname(),e.search=n.getSearch(),e.searchParams=n.getSearchParams(),e.hash=n.getHash())},Nt=$t.prototype,Dt=function(t,e){return{get:function(){return U(this)[t]()},set:e&&function(t){return U(this)[e](t)},configurable:!0,enumerable:!0}};if(a&&(c(Nt,"href",Dt("serialize","setHref")),c(Nt,"origin",Dt("getOrigin")),c(Nt,"protocol",Dt("getProtocol","setProtocol")),c(Nt,"username",Dt("getUsername","setUsername")),c(Nt,"password",Dt("getPassword","setPassword")),c(Nt,"host",Dt("getHost","setHost")),c(Nt,"hostname",Dt("getHostname","setHostname")),c(Nt,"port",Dt("getPort","setPort")),c(Nt,"pathname",Dt("getPathname","setPathname")),c(Nt,"search",Dt("getSearch","setSearch")),c(Nt,"searchParams",Dt("getSearchParams")),c(Nt,"hash",Dt("getHash","setHash"))),h(Nt,"toJSON",function(){return U(this).serialize()},{enumerable:!0}),h(Nt,"toString",function(){return U(this).serialize()},{enumerable:!0}),L){var Jt=L.createObjectURL,Wt=L.revokeObjectURL;Jt&&h($t,"createObjectURL",u(Jt,L)),Wt&&h($t,"revokeObjectURL",u(Wt,L))}w($t,"URL"),o({global:!0,constructor:!0,forced:!i,sham:!a},{URL:$t})},3296:function(t,e,r){r(5806)},7208:function(t,e,r){var n=r(6518),o=r(9565);n({target:"URL",proto:!0,enumerable:!0},{toJSON:function(){return o(URL.prototype.toString,this)}})},5857:function(t,e,r){function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}function o(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function a(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,i(n.key),n)}}function i(t){var e=function(t){if("object"!=n(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=n(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==n(e)?e:e+""}r(2675),r(9463),r(2259),r(5700),r(8706),r(3792),r(2712),r(9572),r(8130),r(3851),r(875),r(6099),r(825),r(888),r(7495),r(7764),r(5440),r(2953),r(8408),r(2008),r(113),r(3418),r(8598),r(2062),r(4782),r(2010),r(5506),r(3921),r(9432),r(8781),r(1761),r(5746),r(2762),r(3500),r(3296),r(7208);var s,u=function(){return t=function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.bookReaderOptions=e,this.urlSchema=[{name:"page",position:"path",default:"n0"},{name:"mode",position:"path",default:"2up"},{name:"search",position:"path",deprecated_for:"q"},{name:"q",position:"query_param"},{name:"sort",position:"query_param"},{name:"view",position:"query_param"},{name:"admin",position:"query_param"},{name:"focus",position:"query_param",readOnly:!0}],this.urlState={},this.urlMode=this.bookReaderOptions.urlMode||"hash",this.urlHistoryBasePath=this.bookReaderOptions.urlHistoryBasePath||"/",this.urlLocationPollId=null,this.oldLocationHash=null,this.oldUserHash=null},e=[{key:"urlStateToUrlString",value:function(t){var e=this,r=new URLSearchParams,n={};Object.keys(t).forEach(function(o){var a,i,s,u,l,h=e.urlSchema.find(function(t){return t.name===o});null!==(a=h)&&void 0!==a&&a.deprecated_for&&(h=e.urlSchema.find(function(t){return t.name===h.deprecated_for})),null!==(i=h)&&void 0!==i&&i.readOnly||("path"==(null===(s=h)||void 0===s?void 0:s.position)?n[null===(u=h)||void 0===u?void 0:u.name]=t[o]:r.append((null===(l=h)||void 0===l?void 0:l.name)||o,t[o]))});var o=this.urlSchema.filter(function(t){return"path"==t.position}).map(function(t){return n[t.name]?"".concat(t.name,"/").concat(encodeURIComponent(n[t.name])):""}).join("/"),a="".concat(o.replace(/\/+/g,"/").replace(/\/+$/,"")),i="".concat(a,"?").concat(r.toString());return r.toString()?i:"".concat(a)}},{key:"urlStringToUrlState",value:function(t){var e={},r=new URL(t,"http://example.com"),n=Object.fromEntries(r.searchParams.entries()),a=r.pathname.match(/[^\\/]+\/[^\\/]+/g),i=a?Object.fromEntries(a.map(function(t){return t.split("/")})):{},s=function(t,e){return Object.keys(t).some(function(t){return t==e})};return this.urlSchema.filter(function(t){return"path"==t.position}).forEach(function(t){var r=s(i,t.name),n=s(t,"deprecated_for")&&r;if(r||n){var o=n?t.deprecated_for:t.name;e[o]=decodeURIComponent(i[t.name])}}),Object.entries(n).forEach(function(t){var r=function(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,a,i,s=[],u=!0,l=!1;try{if(a=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=a.call(r)).done)&&(s.push(n.value),s.length!==e);u=!0);}catch(t){l=!0,o=t}finally{try{if(!u&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(l)throw o}}return s}}(t,e)||function(t,e){if(t){if("string"==typeof t)return o(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?o(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(t,2),n=r[0],a=r[1];e[n]=a}),e}},{key:"setUrlParam",value:function(t,e){this.urlState[t]=e,this.pushToAddressBar()}},{key:"removeUrlParam",value:function(t){delete this.urlState[t],this.pushToAddressBar()}},{key:"getUrlParam",value:function(t){return this.urlState[t]}},{key:"pushToAddressBar",value:function(){var t=this.urlStateToUrlString(this.urlState),e="/"!==t?t:"";if("history"==this.urlMode)if(window.history&&window.history.replaceState){var r="".concat(this.urlHistoryBasePath).concat(e).trim().replace(/(\/+)/g,"/");try{window.history.replaceState({},null,r)}catch(t){this.urlMode="hash"}}else this.options.urlMode="hash";"hash"==this.urlMode&&window.location.replace("#"+e),this.oldLocationHash=t}},{key:"listenForHashChanges",value:function(){var t=this;this.oldLocationHash=this.getHash(),this.urlLocationPollId&&(clearInterval(this.urlLocationPollId),this.urlLocationPollId=null),this.urlLocationPollId=setInterval(function(){var e=t.getHash();e!=t.oldLocationHash&&(t.urlState=t.urlStringToUrlState(e))},500)}},{key:"pullFromAddressBar",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:window.location,e="history"===this.urlMode?t.pathname.substr(this.urlHistoryBasePath.length)+t.search:t.hash.substr(1);this.urlState=this.urlStringToUrlState(e)}},{key:"getHash",value:function(){return window.location.hash.slice(1)}}],e&&a(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();function l(t){return l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},l(t)}function h(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,c(n.key),n)}}function c(t){var e=function(t){if("object"!=l(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=l(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==l(e)?e:e+""}function f(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(f=function(){return!!t})()}function p(){return p="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,r){var n=function(t,e){for(;!{}.hasOwnProperty.call(t,e)&&null!==(t=d(t)););return t}(t,e);if(n){var o=Object.getOwnPropertyDescriptor(n,e);return o.get?o.get.call(arguments.length<3?t:r):o.value}},p.apply(null,arguments)}function d(t){return d=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},d(t)}function m(t,e){return m=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},m(t,e)}r(1669).extend(BookReader.defaultOptions,{enableUrlPlugin:!0,bookId:"",defaults:null,updateWindowTitle:!1,urlMode:"hash",urlHistoryBasePath:"/",urlTrackedParams:["page","search","mode","region","highlight","view","text"],urlTrackIndex0:!1}),BookReader.prototype.setup=(s=BookReader.prototype.setup,function(t){s.call(this,t),this.bookId=t.bookId,this.defaults=t.defaults,this.locationPollId=null,this.oldLocationHash=null,this.oldUserHash=null}),BookReader.prototype.init=function(t){return function(){var e=this;this.options.enableUrlPlugin&&(this.bind(BookReader.eventNames.PostInit,function(){var t=e.options,r=t.updateWindowTitle,n=t.urlMode;r&&(document.title=e.shortTitle(e.bookTitle,50)),"hash"===n&&e.urlStartLocationPolling()}),this.bind(BookReader.eventNames.fragmentChange,this.urlUpdateFragment.bind(this))),t.call(this)}}(BookReader.prototype.init),BookReader.prototype.shortTitle=function(t){return this.bookTitle.length<t?this.bookTitle:"".concat(this.bookTitle.substr(0,t-3),"...")},BookReader.prototype.urlStartLocationPolling=function(){var t=this;this.oldLocationHash=this.urlReadFragment(),this.locationPollId&&(clearInterval(this.locationPollId),this.locationPollId=null),this.locationPollId=setInterval(function(){var e=t.urlReadFragment();if(e!=t.oldLocationHash&&e!=t.oldUserHash){var r,n=t.paramsFromFragment(e),o=function(){return t.updateFromParams(n)};t.trigger(BookReader.eventNames.stop),t.animating?(null===(r=t.plugins.autoplay)||void 0===r||r.stop(),t.animationFinishedCallback=o):o(),t.oldUserHash=e}},500)},BookReader.prototype.urlUpdateFragment=function(){var t=this.paramsFromCurrent(),e=this.options,r=e.urlTrackIndex0,n=e.urlTrackedParams;r||void 0===t.index||0!==t.index||(delete t.index,delete t.page);var o=n.reduce(function(e,r){return r in t&&(e[r]=t[r]),e},{}),a=this.fragmentFromParams(o,this.options.urlMode),i=""===a?"":"/".concat(a),s=this.urlReadFragment(),u=this.getLocationSearch(),l=this.queryStringFromParams(o,u,this.options.urlMode);if(s!==a||u!==l){if("history"===this.options.urlMode)if(window.history&&window.history.replaceState){var h=this.options.urlHistoryBasePath.replace(/\/+$/,""),c="".concat(h).concat(i).concat(l);try{window.history.replaceState({},null,c),this.oldLocationHash=a+l}catch(t){this.options.urlMode="hash"}}else this.options.urlMode="hash";if("hash"===this.options.urlMode){var f=this.urlParamsFiltersOnlySearch(this.readQueryString());window.location.replace("#"+a+f),this.oldLocationHash=a+f}}},BookReader.prototype.urlParamsFiltersOnlySearch=function(t){var e=new URLSearchParams(t);return e.has("q")?"?".concat(new URLSearchParams({q:e.get("q")})):""},BookReader.prototype.urlReadFragment=function(){var t=this.options,e=t.urlMode,r=t.urlHistoryBasePath;return"history"===e?window.location.pathname.substr(r.length):this.urlPlugin.getHash()},BookReader.prototype.urlReadHashFragment=function(){return window.location.hash.substr(1)};var g=function(){function t(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),function(t,e,r){return e=d(e),function(t,e){if(e&&("object"==l(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,f()?Reflect.construct(e,r||[],d(t).constructor):e.apply(t,r))}(this,t,arguments)}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&m(t,e)}(t,BookReader),e=t,r=[{key:"init",value:function(){var e,r,n,o=this;this.options.enableUrlPlugin&&(this.urlPlugin=new u(this.options),this.on(BookReader.eventNames.PostInit,function(){"hash"===o.options.urlMode&&o.urlPlugin.listenForHashChanges()})),(e=t,r=this,"function"==typeof(n=p(d(1&3?e.prototype:e),"init",r))?function(t){return n.apply(r,t)}:n)([])}}],r&&h(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,r}();window.BookReader=g}},function(t){t(t.s=5857)}]);
|
|
2
2
|
//# sourceMappingURL=plugin.url.js.map
|