@fluid-topics/ft-reader-context 0.3.8 → 0.3.9
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/build/ft-reader-context.d.ts +10 -1
- package/build/ft-reader-context.js +39 -6
- package/build/ft-reader-context.light.js +3 -3
- package/build/ft-reader-context.min.js +5 -5
- package/build/store/FtReaderStateManager.js +0 -1
- package/build/store/model.d.ts +8 -0
- package/build/store/utils/FtReaderService.d.ts +2 -1
- package/build/store/utils/FtReaderService.js +24 -13
- package/package.json +3 -3
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { PropertyValues } from "lit";
|
|
2
2
|
import { FtLitElementRedux } from "@fluid-topics/ft-wc-utils";
|
|
3
|
+
import { FtReaderNavigationData } from "./store/model";
|
|
3
4
|
import { FtMap } from "@fluid-topics/public-api";
|
|
4
5
|
export declare class MapLoadedEvent extends CustomEvent<FtMap> {
|
|
5
6
|
constructor(map: FtMap);
|
|
@@ -7,18 +8,23 @@ export declare class MapLoadedEvent extends CustomEvent<FtMap> {
|
|
|
7
8
|
export interface FtReaderVisibleTopic {
|
|
8
9
|
tocId: string;
|
|
9
10
|
title: string;
|
|
11
|
+
page?: number;
|
|
12
|
+
prettyUrl?: string;
|
|
13
|
+
prettyUrlDuplicated: boolean;
|
|
10
14
|
breadcrumb?: Array<{
|
|
11
15
|
tocId: string;
|
|
12
16
|
title: string;
|
|
13
17
|
}>;
|
|
14
18
|
}
|
|
15
19
|
export interface VisibleTopicsChangeData {
|
|
16
|
-
map: FtMap;
|
|
17
20
|
visibleTopics: FtReaderVisibleTopic[];
|
|
18
21
|
}
|
|
19
22
|
export declare class VisibleTopicsChangeEvent extends CustomEvent<VisibleTopicsChangeData> {
|
|
20
23
|
constructor(map: FtMap, visibleTopics: FtReaderVisibleTopic[]);
|
|
21
24
|
}
|
|
25
|
+
export declare class NavigationDoneEvent extends CustomEvent<FtReaderNavigationData> {
|
|
26
|
+
constructor(data: FtReaderNavigationData);
|
|
27
|
+
}
|
|
22
28
|
export declare class FtReaderContext extends FtLitElementRedux {
|
|
23
29
|
static styles: import("lit").CSSResult;
|
|
24
30
|
baseUrl?: string;
|
|
@@ -30,11 +36,14 @@ export declare class FtReaderContext extends FtLitElementRedux {
|
|
|
30
36
|
private map?;
|
|
31
37
|
private toc?;
|
|
32
38
|
private visibleTopics;
|
|
39
|
+
private currentPageNumber?;
|
|
40
|
+
private scrollTarget?;
|
|
33
41
|
protected render(): import("lit-html").TemplateResult<1>;
|
|
34
42
|
private _stateManager?;
|
|
35
43
|
private get stateManager();
|
|
36
44
|
protected updated(props: PropertyValues): void;
|
|
37
45
|
protected contentAvailableCallback(props: PropertyValues): void;
|
|
46
|
+
navigateToTarget(): void;
|
|
38
47
|
private registerComponent;
|
|
39
48
|
}
|
|
40
49
|
//# sourceMappingURL=ft-reader-context.d.ts.map
|
|
@@ -15,7 +15,12 @@ export class MapLoadedEvent extends CustomEvent {
|
|
|
15
15
|
}
|
|
16
16
|
export class VisibleTopicsChangeEvent extends CustomEvent {
|
|
17
17
|
constructor(map, visibleTopics) {
|
|
18
|
-
super("ft-reader-visible-topics-change", { detail: {
|
|
18
|
+
super("ft-reader-visible-topics-change", { detail: { visibleTopics } });
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export class NavigationDoneEvent extends CustomEvent {
|
|
22
|
+
constructor(data) {
|
|
23
|
+
super("ft-reader-navigation-done", { detail: data });
|
|
19
24
|
}
|
|
20
25
|
}
|
|
21
26
|
export class FtReaderContext extends FtLitElementRedux {
|
|
@@ -56,22 +61,44 @@ export class FtReaderContext extends FtLitElementRedux {
|
|
|
56
61
|
}
|
|
57
62
|
}
|
|
58
63
|
contentAvailableCallback(props) {
|
|
64
|
+
var _a;
|
|
59
65
|
super.contentAvailableCallback(props);
|
|
60
66
|
if ((props.has("map") || props.has("toc")) && this.map && this.toc) {
|
|
61
67
|
this.dispatchEvent(new MapLoadedEvent(this.map));
|
|
62
68
|
}
|
|
69
|
+
if (props.has("scrollTarget") && ((_a = this.scrollTarget) === null || _a === void 0 ? void 0 : _a.tocId) == null) {
|
|
70
|
+
const oldScrollTarget = props.get("scrollTarget");
|
|
71
|
+
if ((oldScrollTarget === null || oldScrollTarget === void 0 ? void 0 : oldScrollTarget.tocId) != null) {
|
|
72
|
+
this.dispatchEvent(new NavigationDoneEvent(this.stateManager.service.getNavigationData(oldScrollTarget.tocId, this.currentPageNumber, oldScrollTarget.section)));
|
|
73
|
+
}
|
|
74
|
+
}
|
|
63
75
|
if (props.has("visibleTopics")) {
|
|
64
76
|
Promise.all(this.visibleTopics.map(tocId => this.stateManager.service.getTocNode(tocId)))
|
|
65
77
|
.then(tocNodes => {
|
|
66
|
-
let visibleTopics = tocNodes.
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
78
|
+
let visibleTopics = tocNodes.filter(n => n != null)
|
|
79
|
+
.map(node => {
|
|
80
|
+
const n = this.stateManager.service.getNavigationData(node.tocId, this.currentPageNumber);
|
|
81
|
+
return {
|
|
82
|
+
tocId: node.tocId,
|
|
83
|
+
title: node.title,
|
|
84
|
+
page: n.page,
|
|
85
|
+
prettyUrl: n.prettyUrl,
|
|
86
|
+
prettyUrlDuplicated: n.prettyUrlDuplicated,
|
|
87
|
+
// TODO : breadcrumb
|
|
88
|
+
};
|
|
89
|
+
});
|
|
71
90
|
this.dispatchEvent(new VisibleTopicsChangeEvent(this.map, visibleTopics));
|
|
72
91
|
});
|
|
73
92
|
}
|
|
74
93
|
}
|
|
94
|
+
navigateToTarget() {
|
|
95
|
+
if (this.tocId != null) {
|
|
96
|
+
this.stateManager.navigateToTopic(this.tocId, this.section, this.page);
|
|
97
|
+
}
|
|
98
|
+
else if (this.page != null) {
|
|
99
|
+
this.stateManager.navigateToPage(this.page);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
75
102
|
registerComponent(e) {
|
|
76
103
|
e.stopPropagation();
|
|
77
104
|
const component = e.composedPath()[0];
|
|
@@ -111,4 +138,10 @@ __decorate([
|
|
|
111
138
|
__decorate([
|
|
112
139
|
redux()
|
|
113
140
|
], FtReaderContext.prototype, "visibleTopics", void 0);
|
|
141
|
+
__decorate([
|
|
142
|
+
redux((state) => { var _a; return (_a = state.currentPage) === null || _a === void 0 ? void 0 : _a.number; })
|
|
143
|
+
], FtReaderContext.prototype, "currentPageNumber", void 0);
|
|
144
|
+
__decorate([
|
|
145
|
+
redux()
|
|
146
|
+
], FtReaderContext.prototype, "scrollTarget", void 0);
|
|
114
147
|
//# sourceMappingURL=ft-reader-context.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
!function(t,n,r,e){function i(t){for(var n=arguments.length,r=Array(n>1?n-1:0),e=1;e<n;e++)r[e-1]=arguments[e];throw Error("[Immer] minified error nr: "+t+(r.length?" "+r.map((function(t){return"'"+t+"'"})).join(","):"")+". Find the full error at: https://bit.ly/3cXEKWf")}function o(t){return!!t&&!!t[V]}function u(t){return!!t&&(function(t){if(!t||"object"!=typeof t)return!1;var n=Object.getPrototypeOf(t);if(null===n)return!0;var r=Object.hasOwnProperty.call(n,"constructor")&&n.constructor;return r===Object||"function"==typeof r&&Function.toString.call(r)===J}(t)||Array.isArray(t)||!!t[L]||!!t.constructor[L]||d(t)||v(t))}function c(t,n,r){void 0===r&&(r=!1),0===a(t)?(r?Object.keys:W)(t).forEach((function(e){r&&"symbol"==typeof e||n(e,t[e],t)})):t.forEach((function(r,e){return n(e,r,t)}))}function a(t){var n=t[V];return n?n.i>3?n.i-4:n.i:Array.isArray(t)?1:d(t)?2:v(t)?3:0}function s(t,n){return 2===a(t)?t.has(n):Object.prototype.hasOwnProperty.call(t,n)}function f(t,n,r){var e=a(t);2===e?t.set(n,r):3===e?(t.delete(n),t.add(r)):t[n]=r}function l(t,n){return t===n?0!==t||1/t==1/n:t!=t&&n!=n}function d(t){return N&&t instanceof Map}function v(t){return G&&t instanceof Set}function h(t){return t.o||t.t}function p(t){if(Array.isArray(t))return Array.prototype.slice.call(t);var n=X(t);delete n[V];for(var r=W(n),e=0;e<r.length;e++){var i=r[e],o=n[i];!1===o.writable&&(o.writable=!0,o.configurable=!0),(o.get||o.set)&&(n[i]={configurable:!0,writable:!0,enumerable:o.enumerable,value:t[i]})}return Object.create(Object.getPrototypeOf(t),n)}function b(t,n){return void 0===n&&(n=!1),w(t)||o(t)||!u(t)||(a(t)>1&&(t.set=t.add=t.clear=t.delete=y),Object.freeze(t),n&&c(t,(function(t,n){return b(n,!0)}),!0)),t}function y(){i(2)}function w(t){return null==t||"object"!=typeof t||Object.isFrozen(t)}function m(t){var n=Y[t];return n||i(18,t),n}function g(){return $}function j(t,n){n&&(m("Patches"),t.u=[],t.s=[],t.v=n)}function I(t){O(t),t.p.forEach(T),t.p=null}function O(t){t===$&&($=t.l)}function P(t){return $={p:[],l:$,h:t,m:!0,_:0}}function T(t){var n=t[V];0===n.i||1===n.i?n.j():n.O=!0}function A(t,n){n._=n.p.length;var r=n.p[0],e=void 0!==t&&t!==r;return n.h.g||m("ES5").S(n,t,e),e?(r[V].P&&(I(n),i(4)),u(t)&&(t=S(n,t),n.l||M(n,t)),n.u&&m("Patches").M(r[V].t,t,n.u,n.s)):t=S(n,r,[]),I(n),n.u&&n.v(n.u,n.s),t!==q?t:void 0}function S(t,n,r){if(w(n))return n;var e=n[V];if(!e)return c(n,(function(i,o){return E(t,e,n,i,o,r)}),!0),n;if(e.A!==t)return n;if(!e.P)return M(t,e.t,!0),e.t;if(!e.I){e.I=!0,e.A._--;var i=4===e.i||5===e.i?e.o=p(e.k):e.o;c(3===e.i?new Set(i):i,(function(n,o){return E(t,e,i,n,o,r)})),M(t,i,!1),r&&t.u&&m("Patches").R(e,r,t.u,t.s)}return e.o}function E(t,n,r,e,i,c){if(o(i)){var a=S(t,i,c&&n&&3!==n.i&&!s(n.D,e)?c.concat(e):void 0);if(f(r,e,a),!o(a))return;t.m=!1}if(u(i)&&!w(i)){if(!t.h.F&&t._<1)return;S(t,i),n&&n.A.l||M(t,i)}}function M(t,n,r){void 0===r&&(r=!1),t.h.F&&t.m&&b(n,r)}function _(t,n){var r=t[V];return(r?h(r):t)[n]}function C(t,n){if(n in t)for(var r=Object.getPrototypeOf(t);r;){var e=Object.getOwnPropertyDescriptor(r,n);if(e)return e;r=Object.getPrototypeOf(r)}}function x(t){t.P||(t.P=!0,t.l&&x(t.l))}function R(t){t.o||(t.o=p(t.t))}function U(t,n,r){var e=d(n)?m("MapSet").N(n,r):v(n)?m("MapSet").T(n,r):t.g?function(t,n){var r=Array.isArray(t),e={i:r?1:0,A:n?n.A:g(),P:!1,I:!1,D:{},l:n,t,k:null,o:null,j:null,C:!1},i=e,o=z;r&&(i=[e],o=H);var u=Proxy.revocable(i,o),c=u.revoke,a=u.proxy;return e.k=a,e.j=c,a}(n,r):m("ES5").J(n,r);return(r?r.A:g()).p.push(e),e}function D(t){return o(t)||i(22,t),function t(n){if(!u(n))return n;var r,e=n[V],i=a(n);if(e){if(!e.P&&(e.i<4||!m("ES5").K(e)))return e.t;e.I=!0,r=k(n,i),e.I=!1}else r=k(n,i);return c(r,(function(n,i){e&&function(t,n){return 2===a(t)?t.get(n):t[n]}(e.t,n)===i||f(r,n,t(i))})),3===i?new Set(r):r}(t)}function k(t,n){switch(n){case 2:return new Map(t);case 3:return Array.from(t)}return p(t)}var B,$,F="undefined"!=typeof Symbol&&"symbol"==typeof Symbol("x"),N="undefined"!=typeof Map,G="undefined"!=typeof Set,K="undefined"!=typeof Proxy&&void 0!==Proxy.revocable&&"undefined"!=typeof Reflect,q=F?Symbol.for("immer-nothing"):((B={})["immer-nothing"]=!0,B),L=F?Symbol.for("immer-draftable"):"__$immer_draftable",V=F?Symbol.for("immer-state"):"__$immer_state",J=""+Object.prototype.constructor,W="undefined"!=typeof Reflect&&Reflect.ownKeys?Reflect.ownKeys:void 0!==Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:Object.getOwnPropertyNames,X=Object.getOwnPropertyDescriptors||function(t){var n={};return W(t).forEach((function(r){n[r]=Object.getOwnPropertyDescriptor(t,r)})),n},Y={},z={get:function(t,n){if(n===V)return t;var r=h(t);if(!s(r,n))return function(t,n,r){var e,i=C(n,r);return i?"value"in i?i.value:null===(e=i.get)||void 0===e?void 0:e.call(t.k):void 0}(t,r,n);var e=r[n];return t.I||!u(e)?e:e===_(t.t,n)?(R(t),t.o[n]=U(t.A.h,e,t)):e},has:function(t,n){return n in h(t)},ownKeys:function(t){return Reflect.ownKeys(h(t))},set:function(t,n,r){var e=C(h(t),n);if(null==e?void 0:e.set)return e.set.call(t.k,r),!0;if(!t.P){var i=_(h(t),n),o=null==i?void 0:i[V];if(o&&o.t===r)return t.o[n]=r,t.D[n]=!1,!0;if(l(r,i)&&(void 0!==r||s(t.t,n)))return!0;R(t),x(t)}return t.o[n]===r&&"number"!=typeof r&&(void 0!==r||n in t.o)||(t.o[n]=r,t.D[n]=!0,!0)},deleteProperty:function(t,n){return void 0!==_(t.t,n)||n in t.t?(t.D[n]=!1,R(t),x(t)):delete t.D[n],t.o&&delete t.o[n],!0},getOwnPropertyDescriptor:function(t,n){var r=h(t),e=Reflect.getOwnPropertyDescriptor(r,n);return e?{writable:!0,configurable:1!==t.i||"length"!==n,enumerable:e.enumerable,value:r[n]}:e},defineProperty:function(){i(11)},getPrototypeOf:function(t){return Object.getPrototypeOf(t.t)},setPrototypeOf:function(){i(12)}},H={};c(z,(function(t,n){H[t]=function(){return arguments[0]=arguments[0][0],n.apply(this,arguments)}})),H.deleteProperty=function(t,n){return H.set.call(this,t,n,void 0)},H.set=function(t,n,r){return z.set.call(this,t[0],n,r,t[0])};var Q=function(){function t(t){var n=this;this.g=K,this.F=!0,this.produce=function(t,r,e){if("function"==typeof t&&"function"!=typeof r){var o=r;r=t;var c=n;return function(t){var n=this;void 0===t&&(t=o);for(var e=arguments.length,i=Array(e>1?e-1:0),u=1;u<e;u++)i[u-1]=arguments[u];return c.produce(t,(function(t){var e;return(e=r).call.apply(e,[n,t].concat(i))}))}}var a;if("function"!=typeof r&&i(6),void 0!==e&&"function"!=typeof e&&i(7),u(t)){var s=P(n),f=U(n,t,void 0),l=!0;try{a=r(f),l=!1}finally{l?I(s):O(s)}return"undefined"!=typeof Promise&&a instanceof Promise?a.then((function(t){return j(s,e),A(t,s)}),(function(t){throw I(s),t})):(j(s,e),A(a,s))}if(!t||"object"!=typeof t){if(void 0===(a=r(t))&&(a=t),a===q&&(a=void 0),n.F&&b(a,!0),e){var d=[],v=[];m("Patches").M(t,a,d,v),e(d,v)}return a}i(21,t)},this.produceWithPatches=function(t,r){if("function"==typeof t)return function(r){for(var e=arguments.length,i=Array(e>1?e-1:0),o=1;o<e;o++)i[o-1]=arguments[o];return n.produceWithPatches(r,(function(n){return t.apply(void 0,[n].concat(i))}))};var e,i,o=n.produce(t,r,(function(t,n){e=t,i=n}));return"undefined"!=typeof Promise&&o instanceof Promise?o.then((function(t){return[t,e,i]})):[o,e,i]},"boolean"==typeof(null==t?void 0:t.useProxies)&&this.setUseProxies(t.useProxies),"boolean"==typeof(null==t?void 0:t.autoFreeze)&&this.setAutoFreeze(t.autoFreeze)}var n=t.prototype;return n.createDraft=function(t){u(t)||i(8),o(t)&&(t=D(t));var n=P(this),r=U(this,t,void 0);return r[V].C=!0,O(n),r},n.finishDraft=function(t,n){var r=(t&&t[V]).A;return j(r,n),A(void 0,r)},n.setAutoFreeze=function(t){this.F=t},n.setUseProxies=function(t){t&&!K&&i(20),this.g=t},n.applyPatches=function(t,n){var r;for(r=n.length-1;r>=0;r--){var e=n[r];if(0===e.path.length&&"replace"===e.op){t=e.value;break}}r>-1&&(n=n.slice(r+1));var i=m("Patches").$;return o(t)?i(t,n):this.produce(t,(function(t){return i(t,n)}))},t}(),Z=new Q,tt=Z.produce;Z.produceWithPatches.bind(Z),Z.setAutoFreeze.bind(Z),Z.setUseProxies.bind(Z),Z.applyPatches.bind(Z),Z.createDraft.bind(Z),Z.finishDraft.bind(Z);var nt,rt=tt,et=(nt=function(t,n){return nt=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])},nt(t,n)},function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}nt(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}),it=function(t,n){for(var r=0,e=n.length,i=t.length;r<e;r++,i++)t[i]=n[r];return t},ot=Object.defineProperty,ut=Object.getOwnPropertySymbols,ct=Object.prototype.hasOwnProperty,at=Object.prototype.propertyIsEnumerable,st=function(t,n,r){return n in t?ot(t,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[n]=r},ft=function(t,n){for(var r in n||(n={}))ct.call(n,r)&&st(t,r,n[r]);if(ut)for(var e=0,i=ut(n);e<i.length;e++){r=i[e];at.call(n,r)&&st(t,r,n[r])}return t};function lt(t){return u(t)?rt(t,(function(){})):t}function dt(t,n){function r(){for(var r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];if(n){var i=n.apply(void 0,r);if(!i)throw new Error("prepareAction did not return an object");return ft(ft({type:t,payload:i.payload},"meta"in i&&{meta:i.meta}),"error"in i&&{error:i.error})}return{type:t,payload:r[0]}}return r.toString=function(){return""+t},r.type=t,r.match=function(n){return n.type===t},r}function vt(t){var n,r={},e=[],i={addCase:function(t,n){var e="string"==typeof t?t:t.type;if(e in r)throw new Error("addCase cannot be called with two reducers for the same action type");return r[e]=n,i},addMatcher:function(t,n){return e.push({matcher:t,reducer:n}),i},addDefaultCase:function(t){return n=t,i}};return t(i),[r,e,n]}function ht(t){var n=t.name;if(!n)throw new Error("`name` is a required option for createSlice");var r,e="function"==typeof t.initialState?t.initialState:lt(t.initialState),i=t.reducers||{},c=Object.keys(i),a={},s={},f={};function l(){var n="function"==typeof t.extraReducers?vt(t.extraReducers):[t.extraReducers],r=n[0],i=void 0===r?{}:r,c=n[1],a=void 0===c?[]:c,f=n[2],l=void 0===f?void 0:f,d=ft(ft({},i),s);return function(t,n,r,e){void 0===r&&(r=[]);var i,c="function"==typeof n?vt(n):[n,r,e],a=c[0],s=c[1],f=c[2];if(function(t){return"function"==typeof t}(t))i=function(){return lt(t())};else{var l=lt(t);i=function(){return l}}function d(t,n){void 0===t&&(t=i());var r=it([a[n.type]],s.filter((function(t){return(0,t.matcher)(n)})).map((function(t){return t.reducer})));return 0===r.filter((function(t){return!!t})).length&&(r=[f]),r.reduce((function(t,r){if(r){var e;if(o(t))return void 0===(e=r(t,n))?t:e;if(u(t))return rt(t,(function(t){return r(t,n)}));if(void 0===(e=r(t,n))){if(null===t)return t;throw Error("A case reducer on a non-draftable value must not return undefined")}return e}return t}),t)}return d.getInitialState=i,d}(e,d,a,l)}return c.forEach((function(t){var r,e,o=i[t],u=n+"/"+t;"reducer"in o?(r=o.reducer,e=o.prepare):r=o,a[t]=r,s[u]=r,f[t]=e?dt(u,e):dt(u)})),{name:n,reducer:function(t,n){return r||(r=l()),r(t,n)},actions:f,caseReducers:a,getInitialState:function(){return r||(r=l()),r.getInitialState()}}}!function(t){function n(){for(var r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];var i=t.apply(this,r)||this;return Object.setPrototypeOf(i,n.prototype),i}et(n,t),Object.defineProperty(n,Symbol.species,{get:function(){return n},enumerable:!1,configurable:!0}),n.prototype.concat=function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return t.prototype.concat.apply(this,n)},n.prototype.prepend=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return 1===t.length&&Array.isArray(t[0])?new(n.bind.apply(n,it([void 0],t[0].concat(this)))):new(n.bind.apply(n,it([void 0],t.concat(this))))}}(Array);var pt="listenerMiddleware";dt(pt+"/add"),dt(pt+"/removeAll"),dt(pt+"/remove"),function(){function t(t,n){var r=i[t];return r?r.enumerable=n:i[t]=r={configurable:!0,enumerable:n,get:function(){var n=this[V];return z.get(n,t)},set:function(n){var r=this[V];z.set(r,t,n)}},r}function n(t){for(var n=t.length-1;n>=0;n--){var i=t[n][V];if(!i.P)switch(i.i){case 5:e(i)&&x(i);break;case 4:r(i)&&x(i)}}}function r(t){for(var n=t.t,r=t.k,e=W(r),i=e.length-1;i>=0;i--){var o=e[i];if(o!==V){var u=n[o];if(void 0===u&&!s(n,o))return!0;var c=r[o],a=c&&c[V];if(a?a.t!==u:!l(c,u))return!0}}var f=!!n[V];return e.length!==W(n).length+(f?0:1)}function e(t){var n=t.k;if(n.length!==t.t.length)return!0;var r=Object.getOwnPropertyDescriptor(n,n.length-1);if(r&&!r.get)return!0;for(var e=0;e<n.length;e++)if(!n.hasOwnProperty(e))return!0;return!1}var i={};!function(t,n){Y[t]||(Y[t]=n)}("ES5",{J:function(n,r){var e=Array.isArray(n),i=function(n,r){if(n){for(var e=Array(r.length),i=0;i<r.length;i++)Object.defineProperty(e,""+i,t(i,!0));return e}var o=X(r);delete o[V];for(var u=W(o),c=0;c<u.length;c++){var a=u[c];o[a]=t(a,n||!!o[a].enumerable)}return Object.create(Object.getPrototypeOf(r),o)}(e,n),o={i:e?5:4,A:r?r.A:g(),P:!1,I:!1,D:{},l:r,t:n,k:i,o:null,O:!1,C:!1};return Object.defineProperty(i,V,{value:o,writable:!0}),i},S:function(t,r,i){i?o(r)&&r[V].A===t&&n(t.p):(t.u&&function t(n){if(n&&"object"==typeof n){var r=n[V];if(r){var i=r.t,o=r.k,u=r.D,a=r.i;if(4===a)c(o,(function(n){n!==V&&(void 0!==i[n]||s(i,n)?u[n]||t(o[n]):(u[n]=!0,x(r)))})),c(i,(function(t){void 0!==o[t]||s(o,t)||(u[t]=!1,x(r))}));else if(5===a){if(e(r)&&(x(r),u.length=!0),o.length<i.length)for(var f=o.length;f<i.length;f++)u[f]=!1;else for(var l=i.length;l<o.length;l++)u[l]=!0;for(var d=Math.min(o.length,i.length),v=0;v<d;v++)o.hasOwnProperty(v)||(u[v]=!0),void 0===u[v]&&t(o[v])}}}}(t.p[0]),n(t.p))},K:function(t){return 4===t.i?r(t):e(t)}})}();const bt={setBaseUrl:(t,n)=>{t.baseUrl=n.payload},setApiIntegrationIdentifier:(t,n)=>{t.apiIntegrationIdentifier=n.payload},setMapId:(t,n)=>{t.mapId=n.payload},setTocId:(t,n)=>{t.tocId=n.payload},setMap:(t,n)=>{t.map=n.payload},setToc:(t,n)=>{t.toc=n.payload},setCurrentPage:(t,n)=>{t.currentPage=n.payload},setScrollTarget:(t,n)=>{t.scrollTarget=n.payload},setVisibleTopics:(t,n)=>{t.visibleTopics=n.payload}};class yt{convertNodes(t){var n,r,e,i;const o={},u=new Set,c=new Set,a=[],s=(t,n,r)=>t.map((t=>{var e;t.page&&a.push(t.tocId);let i=null===(e=t.prettyUrl)||void 0===e?void 0:e.replace(/^\//,"");const f={...t,prettyUrl:i,depth:n,parentTocId:r,children:s(t.children,n+1,t.tocId)};return i&&(u.has(i)&&c.add(i),u.add(i)),o[t.tocId]=f,f})),f=s(null!=t?t:[],1),l=this.buildPages(a,o);let d={};return 0===l.length?l.push({number:1,title:null!==(r=null===(n=f[0])||void 0===n?void 0:n.title)&&void 0!==r?r:"",rootTocId:null!==(i=null===(e=f[0])||void 0===e?void 0:e.tocId)&&void 0!==i?i:"root",toc:[],topics:this.tocIds(f),hiddenTopics:[]}):d=this.indexPages(l),{toc:f,nodeByTocId:o,duplicatedPrettyUrls:c,pages:l,pageByTocId:d}}tocIds(t){return t.flatMap((t=>[t.tocId,...this.tocIds(t.children)]))}buildPages(t,n){const r=t=>t.parentTocId?[...r(n[t.parentTocId]),t.parentTocId]:[];return t.map((t=>n[t])).map(((t,n)=>{var e,i,o,u,c;const a={number:n+1,title:t.title,rootTocId:t.tocId,toc:(null===(e=t.page)||void 0===e?void 0:e.onItsOwn)?[]:t.children,topics:[],hiddenTopics:[]},s=(t,n)=>(n?a.topics:a.hiddenTopics).push(t),f=null!==(o=null===(i=t.page)||void 0===i?void 0:i.parentsVisibility)&&void 0!==o?o:[];return r(t).forEach(((t,n)=>{s(t,f[n])})),s(t.tocId,null===(u=t.page)||void 0===u?void 0:u.visible),(null===(c=t.page)||void 0===c?void 0:c.onItsOwn)||a.topics.push(...this.tocIds(t.children)),a}))}indexPages(t){const n={};for(let r of t)for(let t of[...r.topics,...r.hiddenTopics])n[t]||(n[t]=r);return n}}class wt{constructor(t,n,r,e){this.converter=t,this.api=n,this.baseUrl=r,this.mapId=e,this.topics={},this.topicContents={},r.endsWith("/")||(this.baseUrl=r+"/")}static build(t,n,r){if(null==window.fluidtopics)throw console.error("Fluid Topics public API was not found. You can find it here: https://www.npmjs.com/package/@fluid-topics/public-api"),new Error("Fluid Topics public API not found");return new wt(new yt,new window.fluidtopics.FluidTopicsApi(t,n,!0),t,r)}clear(){this.map=void 0,this.enrichedToc=void 0,this.topics={},this.topicContents={}}getMap(){return this.loadIfNeeded((()=>this.map),(t=>this.map=t),(()=>this.api.getMap(this.mapId)))}getEnrichedToc(){return this.loadIfNeeded((()=>this.enrichedToc),(t=>this.enrichedToc=t),(()=>this.api.getTableOfContent(this.mapId).then((t=>this.converter.convertNodes(t)))))}async getToc(){return(await this.getEnrichedToc()).toc}async getTocNode(t){return(await this.getEnrichedToc()).nodeByTocId[t]}async getPage(t){const n=await this.getEnrichedToc();return n.pages[t-1]||n.pages[0]}async getPageByTocId(t){const n=await this.getEnrichedToc();return n.pageByTocId[t]||n.pages[0]}getTopicInfo(t){return this.loadIfNeeded((()=>this.topics[t]),(n=>this.topics[t]=n),(()=>this.api.getTopic(this.mapId,t)))}getTopicContent(t){return this.loadIfNeeded((()=>this.topicContents[t]),(n=>this.topicContents[t]=n),(()=>this.api.getTopicHTMLContent(this.mapId,t,"DESIGNED_READER")))}getLink(t,n,r){var e;t=t||"root";let i=this.enrichedToc,o=null===(e=null==i?void 0:i.nodeByTocId[t])||void 0===e?void 0:e.prettyUrl,u=o||`r/${this.mapId}/${t}`,c=new URL(u,this.baseUrl),a=null==i?void 0:i.pageByTocId[t];return n&&a&&a.number!==n&&c.searchParams.set("page",`${n}`),o&&(null==i?void 0:i.duplicatedPrettyUrls.has(o))&&c.searchParams.set("tocId",t),r&&c.searchParams.set("section",r),c.href}async loadIfNeeded(t,r,e){for(void 0===t()&&(r(!0),r(await e().catch((t=>(console.error(t),!1)))));!0===t();)await n.delay(10);const i=t();if(!1===i)throw new Error("Could not load data");return i}}class mt{constructor(t,r){this.store=t,this.slice=r,this.reloadDebouncer=new n.Debouncer(10)}static build(t){const r=(t=>ht({name:"ft-reader-"+t,initialState:{baseUrl:"",apiIntegrationIdentifier:"ft-reader",visibleTopics:[]},reducers:bt}))(t.trim()||"context");return new mt(n.getStore(r),r)}setBaseUrl(t){this.setRequiredStateField("baseUrl","setBaseUrl",t)}setApiIntegrationIdentifier(t){this.setRequiredStateField("apiIntegrationIdentifier","setApiIntegrationIdentifier",t)}setMapId(t){this.setRequiredStateField("mapId","setMapId",t)}setVisibleTopics(t){this.dispatch(this.slice.actions.setVisibleTopics(t))}async navigateToTopic(t,r,e){for(;null===this.service;)await n.delay(5);let i=null!=e?await this.service.getPage(e):await this.service.getPageByTocId(t);console.log(e,i),this.dispatch(this.slice.actions.setCurrentPage(i),this.slice.actions.setScrollTarget({tocId:t,section:r}))}async navigateToPage(t){for(;null===this.service;)await n.delay(5);let r=await this.service.getPage(t);this.dispatch(this.slice.actions.setCurrentPage(r))}scrollDone(){this.dispatch(this.slice.actions.setScrollTarget({}))}setRequiredStateField(t,n,r){this.store.getState()[t]!==r&&(this.dispatch(this.slice.actions[n](r)),this.clearAll(),this.reload())}clearAll(){this.dispatch(this.slice.actions.setMap(void 0),this.slice.actions.setToc(void 0),this.slice.actions.setCurrentPage(void 0))}reload(){const t=this.store.getState();t.baseUrl&&t.apiIntegrationIdentifier&&t.mapId?this.service=wt.build(t.baseUrl,t.apiIntegrationIdentifier,t.mapId):this.service=void 0,this.reloadDebouncer.run((async()=>{this.reloadMap(),this.reloadToc()}))}async reloadMap(){var t;const n=await(null===(t=this.service)||void 0===t?void 0:t.getMap());this.dispatch(this.slice.actions.setMap(n))}async reloadToc(){var t;const n=await(null===(t=this.service)||void 0===t?void 0:t.getToc());this.dispatch(this.slice.actions.setToc(n))}dispatch(...t){for(let n of t)this.store.dispatch(n)}}var gt=function(t,n,r,e){for(var i,o=arguments.length,u=o<3?n:null===e?e=Object.getOwnPropertyDescriptor(n,r):e,c=t.length-1;c>=0;c--)(i=t[c])&&(u=(o<3?i(u):o>3?i(n,r,u):i(n,r))||u);return o>3&&u&&Object.defineProperty(n,r,u),u};class jt extends CustomEvent{constructor(t){super("ft-reader-map-loaded",{detail:t})}}class It extends CustomEvent{constructor(t,n){super("ft-reader-visible-topics-change",{detail:{map:t,visibleTopics:n}})}}class Ot extends n.FtLitElementRedux{constructor(){super(...arguments),this.apiIntegrationIdentifier="ft-reader",this.visibleTopics=[]}render(){return r.html`
|
|
1
|
+
!function(t,n,r,e){function i(t){for(var n=arguments.length,r=Array(n>1?n-1:0),e=1;e<n;e++)r[e-1]=arguments[e];throw Error("[Immer] minified error nr: "+t+(r.length?" "+r.map((function(t){return"'"+t+"'"})).join(","):"")+". Find the full error at: https://bit.ly/3cXEKWf")}function o(t){return!!t&&!!t[V]}function u(t){return!!t&&(function(t){if(!t||"object"!=typeof t)return!1;var n=Object.getPrototypeOf(t);if(null===n)return!0;var r=Object.hasOwnProperty.call(n,"constructor")&&n.constructor;return r===Object||"function"==typeof r&&Function.toString.call(r)===J}(t)||Array.isArray(t)||!!t[L]||!!t.constructor[L]||d(t)||v(t))}function a(t,n,r){void 0===r&&(r=!1),0===c(t)?(r?Object.keys:W)(t).forEach((function(e){r&&"symbol"==typeof e||n(e,t[e],t)})):t.forEach((function(r,e){return n(e,r,t)}))}function c(t){var n=t[V];return n?n.i>3?n.i-4:n.i:Array.isArray(t)?1:d(t)?2:v(t)?3:0}function s(t,n){return 2===c(t)?t.has(n):Object.prototype.hasOwnProperty.call(t,n)}function f(t,n,r){var e=c(t);2===e?t.set(n,r):3===e?(t.delete(n),t.add(r)):t[n]=r}function l(t,n){return t===n?0!==t||1/t==1/n:t!=t&&n!=n}function d(t){return F&&t instanceof Map}function v(t){return G&&t instanceof Set}function h(t){return t.o||t.t}function p(t){if(Array.isArray(t))return Array.prototype.slice.call(t);var n=X(t);delete n[V];for(var r=W(n),e=0;e<r.length;e++){var i=r[e],o=n[i];!1===o.writable&&(o.writable=!0,o.configurable=!0),(o.get||o.set)&&(n[i]={configurable:!0,writable:!0,enumerable:o.enumerable,value:t[i]})}return Object.create(Object.getPrototypeOf(t),n)}function b(t,n){return void 0===n&&(n=!1),w(t)||o(t)||!u(t)||(c(t)>1&&(t.set=t.add=t.clear=t.delete=y),Object.freeze(t),n&&a(t,(function(t,n){return b(n,!0)}),!0)),t}function y(){i(2)}function w(t){return null==t||"object"!=typeof t||Object.isFrozen(t)}function g(t){var n=Y[t];return n||i(18,t),n}function m(){return B}function j(t,n){n&&(g("Patches"),t.u=[],t.s=[],t.v=n)}function I(t){O(t),t.p.forEach(P),t.p=null}function O(t){t===B&&(B=t.l)}function T(t){return B={p:[],l:B,h:t,m:!0,_:0}}function P(t){var n=t[V];0===n.i||1===n.i?n.j():n.O=!0}function A(t,n){n._=n.p.length;var r=n.p[0],e=void 0!==t&&t!==r;return n.h.g||g("ES5").S(n,t,e),e?(r[V].P&&(I(n),i(4)),u(t)&&(t=S(n,t),n.l||M(n,t)),n.u&&g("Patches").M(r[V].t,t,n.u,n.s)):t=S(n,r,[]),I(n),n.u&&n.v(n.u,n.s),t!==q?t:void 0}function S(t,n,r){if(w(n))return n;var e=n[V];if(!e)return a(n,(function(i,o){return E(t,e,n,i,o,r)}),!0),n;if(e.A!==t)return n;if(!e.P)return M(t,e.t,!0),e.t;if(!e.I){e.I=!0,e.A._--;var i=4===e.i||5===e.i?e.o=p(e.k):e.o;a(3===e.i?new Set(i):i,(function(n,o){return E(t,e,i,n,o,r)})),M(t,i,!1),r&&t.u&&g("Patches").R(e,r,t.u,t.s)}return e.o}function E(t,n,r,e,i,a){if(o(i)){var c=S(t,i,a&&n&&3!==n.i&&!s(n.D,e)?a.concat(e):void 0);if(f(r,e,c),!o(c))return;t.m=!1}if(u(i)&&!w(i)){if(!t.h.F&&t._<1)return;S(t,i),n&&n.A.l||M(t,i)}}function M(t,n,r){void 0===r&&(r=!1),t.h.F&&t.m&&b(n,r)}function C(t,n){var r=t[V];return(r?h(r):t)[n]}function U(t,n){if(n in t)for(var r=Object.getPrototypeOf(t);r;){var e=Object.getOwnPropertyDescriptor(r,n);if(e)return e;r=Object.getPrototypeOf(r)}}function _(t){t.P||(t.P=!0,t.l&&_(t.l))}function x(t){t.o||(t.o=p(t.t))}function D(t,n,r){var e=d(n)?g("MapSet").N(n,r):v(n)?g("MapSet").T(n,r):t.g?function(t,n){var r=Array.isArray(t),e={i:r?1:0,A:n?n.A:m(),P:!1,I:!1,D:{},l:n,t,k:null,o:null,j:null,C:!1},i=e,o=z;r&&(i=[e],o=H);var u=Proxy.revocable(i,o),a=u.revoke,c=u.proxy;return e.k=c,e.j=a,c}(n,r):g("ES5").J(n,r);return(r?r.A:m()).p.push(e),e}function R(t){return o(t)||i(22,t),function t(n){if(!u(n))return n;var r,e=n[V],i=c(n);if(e){if(!e.P&&(e.i<4||!g("ES5").K(e)))return e.t;e.I=!0,r=k(n,i),e.I=!1}else r=k(n,i);return a(r,(function(n,i){e&&function(t,n){return 2===c(t)?t.get(n):t[n]}(e.t,n)===i||f(r,n,t(i))})),3===i?new Set(r):r}(t)}function k(t,n){switch(n){case 2:return new Map(t);case 3:return Array.from(t)}return p(t)}var N,B,$="undefined"!=typeof Symbol&&"symbol"==typeof Symbol("x"),F="undefined"!=typeof Map,G="undefined"!=typeof Set,K="undefined"!=typeof Proxy&&void 0!==Proxy.revocable&&"undefined"!=typeof Reflect,q=$?Symbol.for("immer-nothing"):((N={})["immer-nothing"]=!0,N),L=$?Symbol.for("immer-draftable"):"__$immer_draftable",V=$?Symbol.for("immer-state"):"__$immer_state",J=""+Object.prototype.constructor,W="undefined"!=typeof Reflect&&Reflect.ownKeys?Reflect.ownKeys:void 0!==Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:Object.getOwnPropertyNames,X=Object.getOwnPropertyDescriptors||function(t){var n={};return W(t).forEach((function(r){n[r]=Object.getOwnPropertyDescriptor(t,r)})),n},Y={},z={get:function(t,n){if(n===V)return t;var r=h(t);if(!s(r,n))return function(t,n,r){var e,i=U(n,r);return i?"value"in i?i.value:null===(e=i.get)||void 0===e?void 0:e.call(t.k):void 0}(t,r,n);var e=r[n];return t.I||!u(e)?e:e===C(t.t,n)?(x(t),t.o[n]=D(t.A.h,e,t)):e},has:function(t,n){return n in h(t)},ownKeys:function(t){return Reflect.ownKeys(h(t))},set:function(t,n,r){var e=U(h(t),n);if(null==e?void 0:e.set)return e.set.call(t.k,r),!0;if(!t.P){var i=C(h(t),n),o=null==i?void 0:i[V];if(o&&o.t===r)return t.o[n]=r,t.D[n]=!1,!0;if(l(r,i)&&(void 0!==r||s(t.t,n)))return!0;x(t),_(t)}return t.o[n]===r&&"number"!=typeof r&&(void 0!==r||n in t.o)||(t.o[n]=r,t.D[n]=!0,!0)},deleteProperty:function(t,n){return void 0!==C(t.t,n)||n in t.t?(t.D[n]=!1,x(t),_(t)):delete t.D[n],t.o&&delete t.o[n],!0},getOwnPropertyDescriptor:function(t,n){var r=h(t),e=Reflect.getOwnPropertyDescriptor(r,n);return e?{writable:!0,configurable:1!==t.i||"length"!==n,enumerable:e.enumerable,value:r[n]}:e},defineProperty:function(){i(11)},getPrototypeOf:function(t){return Object.getPrototypeOf(t.t)},setPrototypeOf:function(){i(12)}},H={};a(z,(function(t,n){H[t]=function(){return arguments[0]=arguments[0][0],n.apply(this,arguments)}})),H.deleteProperty=function(t,n){return H.set.call(this,t,n,void 0)},H.set=function(t,n,r){return z.set.call(this,t[0],n,r,t[0])};var Q=function(){function t(t){var n=this;this.g=K,this.F=!0,this.produce=function(t,r,e){if("function"==typeof t&&"function"!=typeof r){var o=r;r=t;var a=n;return function(t){var n=this;void 0===t&&(t=o);for(var e=arguments.length,i=Array(e>1?e-1:0),u=1;u<e;u++)i[u-1]=arguments[u];return a.produce(t,(function(t){var e;return(e=r).call.apply(e,[n,t].concat(i))}))}}var c;if("function"!=typeof r&&i(6),void 0!==e&&"function"!=typeof e&&i(7),u(t)){var s=T(n),f=D(n,t,void 0),l=!0;try{c=r(f),l=!1}finally{l?I(s):O(s)}return"undefined"!=typeof Promise&&c instanceof Promise?c.then((function(t){return j(s,e),A(t,s)}),(function(t){throw I(s),t})):(j(s,e),A(c,s))}if(!t||"object"!=typeof t){if(void 0===(c=r(t))&&(c=t),c===q&&(c=void 0),n.F&&b(c,!0),e){var d=[],v=[];g("Patches").M(t,c,d,v),e(d,v)}return c}i(21,t)},this.produceWithPatches=function(t,r){if("function"==typeof t)return function(r){for(var e=arguments.length,i=Array(e>1?e-1:0),o=1;o<e;o++)i[o-1]=arguments[o];return n.produceWithPatches(r,(function(n){return t.apply(void 0,[n].concat(i))}))};var e,i,o=n.produce(t,r,(function(t,n){e=t,i=n}));return"undefined"!=typeof Promise&&o instanceof Promise?o.then((function(t){return[t,e,i]})):[o,e,i]},"boolean"==typeof(null==t?void 0:t.useProxies)&&this.setUseProxies(t.useProxies),"boolean"==typeof(null==t?void 0:t.autoFreeze)&&this.setAutoFreeze(t.autoFreeze)}var n=t.prototype;return n.createDraft=function(t){u(t)||i(8),o(t)&&(t=R(t));var n=T(this),r=D(this,t,void 0);return r[V].C=!0,O(n),r},n.finishDraft=function(t,n){var r=(t&&t[V]).A;return j(r,n),A(void 0,r)},n.setAutoFreeze=function(t){this.F=t},n.setUseProxies=function(t){t&&!K&&i(20),this.g=t},n.applyPatches=function(t,n){var r;for(r=n.length-1;r>=0;r--){var e=n[r];if(0===e.path.length&&"replace"===e.op){t=e.value;break}}r>-1&&(n=n.slice(r+1));var i=g("Patches").$;return o(t)?i(t,n):this.produce(t,(function(t){return i(t,n)}))},t}(),Z=new Q,tt=Z.produce;Z.produceWithPatches.bind(Z),Z.setAutoFreeze.bind(Z),Z.setUseProxies.bind(Z),Z.applyPatches.bind(Z),Z.createDraft.bind(Z),Z.finishDraft.bind(Z);var nt,rt=tt,et=(nt=function(t,n){return nt=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])},nt(t,n)},function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}nt(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}),it=function(t,n){for(var r=0,e=n.length,i=t.length;r<e;r++,i++)t[i]=n[r];return t},ot=Object.defineProperty,ut=Object.getOwnPropertySymbols,at=Object.prototype.hasOwnProperty,ct=Object.prototype.propertyIsEnumerable,st=function(t,n,r){return n in t?ot(t,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[n]=r},ft=function(t,n){for(var r in n||(n={}))at.call(n,r)&&st(t,r,n[r]);if(ut)for(var e=0,i=ut(n);e<i.length;e++){r=i[e];ct.call(n,r)&&st(t,r,n[r])}return t};function lt(t){return u(t)?rt(t,(function(){})):t}function dt(t,n){function r(){for(var r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];if(n){var i=n.apply(void 0,r);if(!i)throw new Error("prepareAction did not return an object");return ft(ft({type:t,payload:i.payload},"meta"in i&&{meta:i.meta}),"error"in i&&{error:i.error})}return{type:t,payload:r[0]}}return r.toString=function(){return""+t},r.type=t,r.match=function(n){return n.type===t},r}function vt(t){var n,r={},e=[],i={addCase:function(t,n){var e="string"==typeof t?t:t.type;if(e in r)throw new Error("addCase cannot be called with two reducers for the same action type");return r[e]=n,i},addMatcher:function(t,n){return e.push({matcher:t,reducer:n}),i},addDefaultCase:function(t){return n=t,i}};return t(i),[r,e,n]}function ht(t){var n=t.name;if(!n)throw new Error("`name` is a required option for createSlice");var r,e="function"==typeof t.initialState?t.initialState:lt(t.initialState),i=t.reducers||{},a=Object.keys(i),c={},s={},f={};function l(){var n="function"==typeof t.extraReducers?vt(t.extraReducers):[t.extraReducers],r=n[0],i=void 0===r?{}:r,a=n[1],c=void 0===a?[]:a,f=n[2],l=void 0===f?void 0:f,d=ft(ft({},i),s);return function(t,n,r,e){void 0===r&&(r=[]);var i,a="function"==typeof n?vt(n):[n,r,e],c=a[0],s=a[1],f=a[2];if(function(t){return"function"==typeof t}(t))i=function(){return lt(t())};else{var l=lt(t);i=function(){return l}}function d(t,n){void 0===t&&(t=i());var r=it([c[n.type]],s.filter((function(t){return(0,t.matcher)(n)})).map((function(t){return t.reducer})));return 0===r.filter((function(t){return!!t})).length&&(r=[f]),r.reduce((function(t,r){if(r){var e;if(o(t))return void 0===(e=r(t,n))?t:e;if(u(t))return rt(t,(function(t){return r(t,n)}));if(void 0===(e=r(t,n))){if(null===t)return t;throw Error("A case reducer on a non-draftable value must not return undefined")}return e}return t}),t)}return d.getInitialState=i,d}(e,d,c,l)}return a.forEach((function(t){var r,e,o=i[t],u=n+"/"+t;"reducer"in o?(r=o.reducer,e=o.prepare):r=o,c[t]=r,s[u]=r,f[t]=e?dt(u,e):dt(u)})),{name:n,reducer:function(t,n){return r||(r=l()),r(t,n)},actions:f,caseReducers:c,getInitialState:function(){return r||(r=l()),r.getInitialState()}}}!function(t){function n(){for(var r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];var i=t.apply(this,r)||this;return Object.setPrototypeOf(i,n.prototype),i}et(n,t),Object.defineProperty(n,Symbol.species,{get:function(){return n},enumerable:!1,configurable:!0}),n.prototype.concat=function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return t.prototype.concat.apply(this,n)},n.prototype.prepend=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return 1===t.length&&Array.isArray(t[0])?new(n.bind.apply(n,it([void 0],t[0].concat(this)))):new(n.bind.apply(n,it([void 0],t.concat(this))))}}(Array);var pt="listenerMiddleware";dt(pt+"/add"),dt(pt+"/removeAll"),dt(pt+"/remove"),function(){function t(t,n){var r=i[t];return r?r.enumerable=n:i[t]=r={configurable:!0,enumerable:n,get:function(){var n=this[V];return z.get(n,t)},set:function(n){var r=this[V];z.set(r,t,n)}},r}function n(t){for(var n=t.length-1;n>=0;n--){var i=t[n][V];if(!i.P)switch(i.i){case 5:e(i)&&_(i);break;case 4:r(i)&&_(i)}}}function r(t){for(var n=t.t,r=t.k,e=W(r),i=e.length-1;i>=0;i--){var o=e[i];if(o!==V){var u=n[o];if(void 0===u&&!s(n,o))return!0;var a=r[o],c=a&&a[V];if(c?c.t!==u:!l(a,u))return!0}}var f=!!n[V];return e.length!==W(n).length+(f?0:1)}function e(t){var n=t.k;if(n.length!==t.t.length)return!0;var r=Object.getOwnPropertyDescriptor(n,n.length-1);if(r&&!r.get)return!0;for(var e=0;e<n.length;e++)if(!n.hasOwnProperty(e))return!0;return!1}var i={};!function(t,n){Y[t]||(Y[t]=n)}("ES5",{J:function(n,r){var e=Array.isArray(n),i=function(n,r){if(n){for(var e=Array(r.length),i=0;i<r.length;i++)Object.defineProperty(e,""+i,t(i,!0));return e}var o=X(r);delete o[V];for(var u=W(o),a=0;a<u.length;a++){var c=u[a];o[c]=t(c,n||!!o[c].enumerable)}return Object.create(Object.getPrototypeOf(r),o)}(e,n),o={i:e?5:4,A:r?r.A:m(),P:!1,I:!1,D:{},l:r,t:n,k:i,o:null,O:!1,C:!1};return Object.defineProperty(i,V,{value:o,writable:!0}),i},S:function(t,r,i){i?o(r)&&r[V].A===t&&n(t.p):(t.u&&function t(n){if(n&&"object"==typeof n){var r=n[V];if(r){var i=r.t,o=r.k,u=r.D,c=r.i;if(4===c)a(o,(function(n){n!==V&&(void 0!==i[n]||s(i,n)?u[n]||t(o[n]):(u[n]=!0,_(r)))})),a(i,(function(t){void 0!==o[t]||s(o,t)||(u[t]=!1,_(r))}));else if(5===c){if(e(r)&&(_(r),u.length=!0),o.length<i.length)for(var f=o.length;f<i.length;f++)u[f]=!1;else for(var l=i.length;l<o.length;l++)u[l]=!0;for(var d=Math.min(o.length,i.length),v=0;v<d;v++)o.hasOwnProperty(v)||(u[v]=!0),void 0===u[v]&&t(o[v])}}}}(t.p[0]),n(t.p))},K:function(t){return 4===t.i?r(t):e(t)}})}();const bt={setBaseUrl:(t,n)=>{t.baseUrl=n.payload},setApiIntegrationIdentifier:(t,n)=>{t.apiIntegrationIdentifier=n.payload},setMapId:(t,n)=>{t.mapId=n.payload},setTocId:(t,n)=>{t.tocId=n.payload},setMap:(t,n)=>{t.map=n.payload},setToc:(t,n)=>{t.toc=n.payload},setCurrentPage:(t,n)=>{t.currentPage=n.payload},setScrollTarget:(t,n)=>{t.scrollTarget=n.payload},setVisibleTopics:(t,n)=>{t.visibleTopics=n.payload}};class yt{convertNodes(t){var n,r,e,i;const o={},u=new Set,a=new Set,c=[],s=(t,n,r)=>t.map((t=>{var e;t.page&&c.push(t.tocId);let i=null===(e=t.prettyUrl)||void 0===e?void 0:e.replace(/^\//,"");const f={...t,prettyUrl:i,depth:n,parentTocId:r,children:s(t.children,n+1,t.tocId)};return i&&(u.has(i)&&a.add(i),u.add(i)),o[t.tocId]=f,f})),f=s(null!=t?t:[],1),l=this.buildPages(c,o);let d={};return 0===l.length?l.push({number:1,title:null!==(r=null===(n=f[0])||void 0===n?void 0:n.title)&&void 0!==r?r:"",rootTocId:null!==(i=null===(e=f[0])||void 0===e?void 0:e.tocId)&&void 0!==i?i:"root",toc:[],topics:this.tocIds(f),hiddenTopics:[]}):d=this.indexPages(l),{toc:f,nodeByTocId:o,duplicatedPrettyUrls:a,pages:l,pageByTocId:d}}tocIds(t){return t.flatMap((t=>[t.tocId,...this.tocIds(t.children)]))}buildPages(t,n){const r=t=>t.parentTocId?[...r(n[t.parentTocId]),t.parentTocId]:[];return t.map((t=>n[t])).map(((t,n)=>{var e,i,o,u,a;const c={number:n+1,title:t.title,rootTocId:t.tocId,toc:(null===(e=t.page)||void 0===e?void 0:e.onItsOwn)?[]:t.children,topics:[],hiddenTopics:[]},s=(t,n)=>(n?c.topics:c.hiddenTopics).push(t),f=null!==(o=null===(i=t.page)||void 0===i?void 0:i.parentsVisibility)&&void 0!==o?o:[];return r(t).forEach(((t,n)=>{s(t,f[n])})),s(t.tocId,null===(u=t.page)||void 0===u?void 0:u.visible),(null===(a=t.page)||void 0===a?void 0:a.onItsOwn)||c.topics.push(...this.tocIds(t.children)),c}))}indexPages(t){const n={};for(let r of t)for(let t of[...r.topics,...r.hiddenTopics])n[t]||(n[t]=r);return n}}class wt{constructor(t,n,r,e){this.converter=t,this.api=n,this.baseUrl=r,this.mapId=e,this.topics={},this.topicContents={},r.endsWith("/")||(this.baseUrl=r+"/")}static build(t,n,r){if(null==window.fluidtopics)throw console.error("Fluid Topics public API was not found. You can find it here: https://www.npmjs.com/package/@fluid-topics/public-api"),new Error("Fluid Topics public API not found");return new wt(new yt,new window.fluidtopics.FluidTopicsApi(t,n,!0),t,r)}clear(){this.map=void 0,this.enrichedToc=void 0,this.topics={},this.topicContents={}}getMap(){return this.loadIfNeeded((()=>this.map),(t=>this.map=t),(()=>this.api.getMap(this.mapId)))}getEnrichedToc(){return this.loadIfNeeded((()=>this.enrichedToc),(t=>this.enrichedToc=t),(()=>this.api.getTableOfContent(this.mapId).then((t=>this.converter.convertNodes(t)))))}async getToc(){return(await this.getEnrichedToc()).toc}async getTocNode(t){return(await this.getEnrichedToc()).nodeByTocId[t]}async getPage(t){const n=await this.getEnrichedToc();return n.pages[t-1]||n.pages[0]}async getPageByTocId(t){const n=await this.getEnrichedToc();return n.pageByTocId[t]||n.pages[0]}getTopicInfo(t){return this.loadIfNeeded((()=>this.topics[t]),(n=>this.topics[t]=n),(()=>this.api.getTopic(this.mapId,t)))}getTopicContent(t){return this.loadIfNeeded((()=>this.topicContents[t]),(n=>this.topicContents[t]=n),(()=>this.api.getTopicHTMLContent(this.mapId,t,"DESIGNED_READER")))}getLink(t,n,r){const e=this.getNavigationData(t,n,r),i="r/"+(e.prettyUrl?e.prettyUrl:`${e.mapId}/${e.tocId}`),o=new URL(i,this.baseUrl);return null!=e.page&&o.searchParams.set("page",`${e.page}`),e.prettyUrlDuplicated&&o.searchParams.set("tocId",e.tocId),null!=e.section&&o.searchParams.set("section",e.section),o.href}getNavigationData(t,n,r){var e,i;t=t||"root";const o="object"==typeof this.enrichedToc?this.enrichedToc:void 0,u=null==o?void 0:o.pageByTocId[t],a=null===(e=null==o?void 0:o.nodeByTocId[t])||void 0===e?void 0:e.prettyUrl;return{mapId:this.mapId,tocId:t,page:n&&u&&u.number!==n?n:void 0,prettyUrl:null!=a?a.replace(/^r\//,""):void 0,prettyUrlDuplicated:null!==(i=null==o?void 0:o.duplicatedPrettyUrls.has(null!=a?a:""))&&void 0!==i&&i,section:r}}async loadIfNeeded(t,r,e){for(void 0===t()&&(r(!0),r(await e().catch((t=>(console.error(t),!1)))));!0===t();)await n.delay(10);const i=t();if(!1===i)throw new Error("Could not load data");return i}}class gt{constructor(t,r){this.store=t,this.slice=r,this.reloadDebouncer=new n.Debouncer(10)}static build(t){const r=(t=>ht({name:"ft-reader-"+t,initialState:{baseUrl:"",apiIntegrationIdentifier:"ft-reader",visibleTopics:[]},reducers:bt}))(t.trim()||"context");return new gt(n.getStore(r),r)}setBaseUrl(t){this.setRequiredStateField("baseUrl","setBaseUrl",t)}setApiIntegrationIdentifier(t){this.setRequiredStateField("apiIntegrationIdentifier","setApiIntegrationIdentifier",t)}setMapId(t){this.setRequiredStateField("mapId","setMapId",t)}setVisibleTopics(t){this.dispatch(this.slice.actions.setVisibleTopics(t))}async navigateToTopic(t,r,e){for(;null===this.service;)await n.delay(5);let i=null!=e?await this.service.getPage(e):await this.service.getPageByTocId(t);this.dispatch(this.slice.actions.setCurrentPage(i),this.slice.actions.setScrollTarget({tocId:t,section:r}))}async navigateToPage(t){for(;null===this.service;)await n.delay(5);let r=await this.service.getPage(t);this.dispatch(this.slice.actions.setCurrentPage(r))}scrollDone(){this.dispatch(this.slice.actions.setScrollTarget({}))}setRequiredStateField(t,n,r){this.store.getState()[t]!==r&&(this.dispatch(this.slice.actions[n](r)),this.clearAll(),this.reload())}clearAll(){this.dispatch(this.slice.actions.setMap(void 0),this.slice.actions.setToc(void 0),this.slice.actions.setCurrentPage(void 0))}reload(){const t=this.store.getState();t.baseUrl&&t.apiIntegrationIdentifier&&t.mapId?this.service=wt.build(t.baseUrl,t.apiIntegrationIdentifier,t.mapId):this.service=void 0,this.reloadDebouncer.run((async()=>{this.reloadMap(),this.reloadToc()}))}async reloadMap(){var t;const n=await(null===(t=this.service)||void 0===t?void 0:t.getMap());this.dispatch(this.slice.actions.setMap(n))}async reloadToc(){var t;const n=await(null===(t=this.service)||void 0===t?void 0:t.getToc());this.dispatch(this.slice.actions.setToc(n))}dispatch(...t){for(let n of t)this.store.dispatch(n)}}var mt=function(t,n,r,e){for(var i,o=arguments.length,u=o<3?n:null===e?e=Object.getOwnPropertyDescriptor(n,r):e,a=t.length-1;a>=0;a--)(i=t[a])&&(u=(o<3?i(u):o>3?i(n,r,u):i(n,r))||u);return o>3&&u&&Object.defineProperty(n,r,u),u};class jt extends CustomEvent{constructor(t){super("ft-reader-map-loaded",{detail:t})}}class It extends CustomEvent{constructor(t,n){super("ft-reader-visible-topics-change",{detail:{visibleTopics:n}})}}class Ot extends CustomEvent{constructor(t){super("ft-reader-navigation-done",{detail:t})}}class Tt extends n.FtLitElementRedux{constructor(){super(...arguments),this.apiIntegrationIdentifier="ft-reader",this.visibleTopics=[]}render(){return r.html`
|
|
2
2
|
<slot @register-ft-reader-component=${this.registerComponent}></slot>
|
|
3
|
-
`}get stateManager(){return null==this._stateManager&&(this._stateManager=
|
|
4
|
-
`,
|
|
3
|
+
`}get stateManager(){return null==this._stateManager&&(this._stateManager=gt.build(this.id||""+Math.round(1e4*Math.random())),this.store=this.stateManager.store),this._stateManager}updated(t){super.updated(t),t.has("baseUrl")&&this.baseUrl&&this.stateManager.setBaseUrl(this.baseUrl),t.has("apiIntegrationIdentifier")&&this.stateManager.setApiIntegrationIdentifier(this.apiIntegrationIdentifier),t.has("mapId")&&this.mapId&&(this.stateManager.setMapId(this.mapId),this.stateManager.navigateToTopic("root")),t.has("page")&&!this.tocId&&null!=this.page&&this.stateManager.navigateToPage(this.page),(t.has("tocId")||t.has("section")||t.has("page"))&&this.tocId&&this.stateManager.navigateToTopic(this.tocId,this.section,this.page)}contentAvailableCallback(t){var n;if(super.contentAvailableCallback(t),(t.has("map")||t.has("toc"))&&this.map&&this.toc&&this.dispatchEvent(new jt(this.map)),t.has("scrollTarget")&&null==(null===(n=this.scrollTarget)||void 0===n?void 0:n.tocId)){const n=t.get("scrollTarget");null!=(null==n?void 0:n.tocId)&&this.dispatchEvent(new Ot(this.stateManager.service.getNavigationData(n.tocId,this.currentPageNumber,n.section)))}t.has("visibleTopics")&&Promise.all(this.visibleTopics.map((t=>this.stateManager.service.getTocNode(t)))).then((t=>{let n=t.filter((t=>null!=t)).map((t=>{const n=this.stateManager.service.getNavigationData(t.tocId,this.currentPageNumber);return{tocId:t.tocId,title:t.title,page:n.page,prettyUrl:n.prettyUrl,prettyUrlDuplicated:n.prettyUrlDuplicated}}));this.dispatchEvent(new It(this.map,n))}))}navigateToTarget(){null!=this.tocId?this.stateManager.navigateToTopic(this.tocId,this.section,this.page):null!=this.page&&this.stateManager.navigateToPage(this.page)}registerComponent(t){t.stopPropagation();t.composedPath()[0].setReaderStateManager(this.stateManager)}}Tt.styles=r.css`
|
|
4
|
+
`,mt([e.property()],Tt.prototype,"baseUrl",void 0),mt([e.property()],Tt.prototype,"apiIntegrationIdentifier",void 0),mt([e.property()],Tt.prototype,"mapId",void 0),mt([e.property()],Tt.prototype,"tocId",void 0),mt([e.property()],Tt.prototype,"section",void 0),mt([e.property({type:Number,converter:{fromAttribute:t=>t?+t:void 0}})],Tt.prototype,"page",void 0),mt([n.redux()],Tt.prototype,"map",void 0),mt([n.redux()],Tt.prototype,"toc",void 0),mt([n.redux()],Tt.prototype,"visibleTopics",void 0),mt([n.redux((t=>{var n;return null===(n=t.currentPage)||void 0===n?void 0:n.number}))],Tt.prototype,"currentPageNumber",void 0),mt([n.redux()],Tt.prototype,"scrollTarget",void 0),n.customElement("ft-reader-context")(Tt),t.FtReaderContext=Tt,t.MapLoadedEvent=jt,t.NavigationDoneEvent=Ot,t.VisibleTopicsChangeEvent=It,Object.defineProperty(t,"U",{value:!0})}({},ftGlobals.wcUtils,ftGlobals.lit,ftGlobals.litDecorators);
|
|
@@ -40,7 +40,7 @@ if(!ShadowRoot.prototype.createElement){const t=window.HTMLElement,e=window.cust
|
|
|
40
40
|
* Copyright 2017 Google LLC
|
|
41
41
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
42
42
|
*/
|
|
43
|
-
var E;O.finalized=!0,O.elementProperties=new Map,O.elementStyles=[],O.shadowRootOptions={mode:"open"},null==y||y({ReactiveElement:O}),(null!==(p=globalThis.reactiveElementVersions)&&void 0!==p?p:globalThis.reactiveElementVersions=[]).push("1.3.4");const j=globalThis.trustedTypes,N=j?j.createPolicy("lit-html",{createHTML:t=>t}):void 0,S=`lit$${(Math.random()+"").slice(9)}$`,R="?"+S,C=`<${R}>`,M=document,A=(t="")=>M.createComment(t),U=t=>null===t||"object"!=typeof t&&"function"!=typeof t,T=Array.isArray,$=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,I=/-->/g,k=/>/g,
|
|
43
|
+
var E;O.finalized=!0,O.elementProperties=new Map,O.elementStyles=[],O.shadowRootOptions={mode:"open"},null==y||y({ReactiveElement:O}),(null!==(p=globalThis.reactiveElementVersions)&&void 0!==p?p:globalThis.reactiveElementVersions=[]).push("1.3.4");const j=globalThis.trustedTypes,N=j?j.createPolicy("lit-html",{createHTML:t=>t}):void 0,S=`lit$${(Math.random()+"").slice(9)}$`,R="?"+S,C=`<${R}>`,M=document,A=(t="")=>M.createComment(t),U=t=>null===t||"object"!=typeof t&&"function"!=typeof t,T=Array.isArray,$=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,I=/-->/g,k=/>/g,P=RegExp(">|[ \t\n\f\r](?:([^\\s\"'>=/]+)([ \t\n\f\r]*=[ \t\n\f\r]*(?:[^ \t\n\f\r\"'`<>=]|(\"|')|))|$)","g"),F=/'/g,_=/"/g,L=/^(?:script|style|textarea|title)$/i,B=(t=>(e,...i)=>({_$litType$:t,strings:e,values:i}))(1),W=Symbol.for("lit-noChange"),D=Symbol.for("lit-nothing"),K=new WeakMap,H=M.createTreeWalker(M,129,null,!1);class z{constructor({strings:t,_$litType$:e},i){let n;this.parts=[];let r=0,o=0;const s=t.length-1,u=this.parts,[c,a]=((t,e)=>{const i=t.length-1,n=[];let r,o=2===e?"<svg>":"",s=$;for(let e=0;e<i;e++){const i=t[e];let u,c,a=-1,l=0;for(;l<i.length&&(s.lastIndex=l,c=s.exec(i),null!==c);)l=s.lastIndex,s===$?"!--"===c[1]?s=I:void 0!==c[1]?s=k:void 0!==c[2]?(L.test(c[2])&&(r=RegExp("</"+c[2],"g")),s=P):void 0!==c[3]&&(s=P):s===P?">"===c[0]?(s=null!=r?r:$,a=-1):void 0===c[1]?a=-2:(a=s.lastIndex-c[2].length,u=c[1],s=void 0===c[3]?P:'"'===c[3]?_:F):s===_||s===F?s=P:s===I||s===k?s=$:(s=P,r=void 0);const f=s===P&&t[e+1].startsWith("/>")?" ":"";o+=s===$?i+C:a>=0?(n.push(u),i.slice(0,a)+"$lit$"+i.slice(a)+S+f):i+S+(-2===a?(n.push(void 0),e):f)}const u=o+(t[i]||"<?>")+(2===e?"</svg>":"");if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return[void 0!==N?N.createHTML(u):u,n]})(t,e);if(this.el=z.createElement(c,i),H.currentNode=this.el.content,2===e){const t=this.el.content,e=t.firstChild;e.remove(),t.append(...e.childNodes)}for(;null!==(n=H.nextNode())&&u.length<s;){if(1===n.nodeType){if(n.hasAttributes()){const t=[];for(const e of n.getAttributeNames())if(e.endsWith("$lit$")||e.startsWith(S)){const i=a[o++];if(t.push(e),void 0!==i){const t=n.getAttribute(i.toLowerCase()+"$lit$").split(S),e=/([.?@])?(.*)/.exec(i);u.push({type:1,index:r,name:e[2],strings:t,ctor:"."===e[1]?X:"?"===e[1]?Y:"@"===e[1]?Q:q})}else u.push({type:6,index:r})}for(const e of t)n.removeAttribute(e)}if(L.test(n.tagName)){const t=n.textContent.split(S),e=t.length-1;if(e>0){n.textContent=j?j.emptyScript:"";for(let i=0;i<e;i++)n.append(t[i],A()),H.nextNode(),u.push({type:2,index:++r});n.append(t[e],A())}}}else if(8===n.nodeType)if(n.data===R)u.push({type:2,index:r});else{let t=-1;for(;-1!==(t=n.data.indexOf(S,t+1));)u.push({type:7,index:r}),t+=S.length-1}r++}}static createElement(t,e){const i=M.createElement("template");return i.innerHTML=t,i}}function J(t,e,i=t,n){var r,o,s,u;if(e===W)return e;let c=void 0!==n?null===(r=i._$Cl)||void 0===r?void 0:r[n]:i._$Cu;const a=U(e)?void 0:e._$litDirective$;return(null==c?void 0:c.constructor)!==a&&(null===(o=null==c?void 0:c._$AO)||void 0===o||o.call(c,!1),void 0===a?c=void 0:(c=new a(t),c._$AT(t,i,n)),void 0!==n?(null!==(s=(u=i)._$Cl)&&void 0!==s?s:u._$Cl=[])[n]=c:i._$Cu=c),void 0!==c&&(e=J(t,c._$AS(t,e.values),c,n)),e}class V{constructor(t,e){this.v=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}p(t){var e;const{el:{content:i},parts:n}=this._$AD,r=(null!==(e=null==t?void 0:t.creationScope)&&void 0!==e?e:M).importNode(i,!0);H.currentNode=r;let o=H.nextNode(),s=0,u=0,c=n[0];for(;void 0!==c;){if(s===c.index){let e;2===c.type?e=new Z(o,o.nextSibling,this,t):1===c.type?e=new c.ctor(o,c.name,c.strings,this,t):6===c.type&&(e=new tt(o,this,t)),this.v.push(e),c=n[++u]}s!==(null==c?void 0:c.index)&&(o=H.nextNode(),s++)}return r}m(t){let e=0;for(const i of this.v)void 0!==i&&(void 0!==i.strings?(i._$AI(t,i,e),e+=i.strings.length-2):i._$AI(t[e])),e++}}class Z{constructor(t,e,i,n){var r;this.type=2,this._$AH=D,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=i,this.options=n,this._$C_=null===(r=null==n?void 0:n.isConnected)||void 0===r||r}get _$AU(){var t,e;return null!==(e=null===(t=this._$AM)||void 0===t?void 0:t._$AU)&&void 0!==e?e:this._$C_}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return void 0!==e&&11===t.nodeType&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=J(this,t,e),U(t)?t===D||null==t||""===t?(this._$AH!==D&&this._$AR(),this._$AH=D):t!==this._$AH&&t!==W&&this.T(t):void 0!==t._$litType$?this.$(t):void 0!==t.nodeType?this.k(t):(t=>T(t)||"function"==typeof(null==t?void 0:t[Symbol.iterator]))(t)?this.S(t):this.T(t)}j(t,e=this._$AB){return this._$AA.parentNode.insertBefore(t,e)}k(t){this._$AH!==t&&(this._$AR(),this._$AH=this.j(t))}T(t){this._$AH!==D&&U(this._$AH)?this._$AA.nextSibling.data=t:this.k(M.createTextNode(t)),this._$AH=t}$(t){var e;const{values:i,_$litType$:n}=t,r="number"==typeof n?this._$AC(t):(void 0===n.el&&(n.el=z.createElement(n.h,this.options)),n);if((null===(e=this._$AH)||void 0===e?void 0:e._$AD)===r)this._$AH.m(i);else{const t=new V(r,this),e=t.p(this.options);t.m(i),this.k(e),this._$AH=t}}_$AC(t){let e=K.get(t.strings);return void 0===e&&K.set(t.strings,e=new z(t)),e}S(t){T(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,n=0;for(const r of t)n===e.length?e.push(i=new Z(this.j(A()),this.j(A()),this,this.options)):i=e[n],i._$AI(r),n++;n<e.length&&(this._$AR(i&&i._$AB.nextSibling,n),e.length=n)}_$AR(t=this._$AA.nextSibling,e){var i;for(null===(i=this._$AP)||void 0===i||i.call(this,!1,!0,e);t&&t!==this._$AB;){const e=t.nextSibling;t.remove(),t=e}}setConnected(t){var e;void 0===this._$AM&&(this._$C_=t,null===(e=this._$AP)||void 0===e||e.call(this,t))}}class q{constructor(t,e,i,n,r){this.type=1,this._$AH=D,this._$AN=void 0,this.element=t,this.name=e,this._$AM=n,this.options=r,i.length>2||""!==i[0]||""!==i[1]?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=D}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(t,e=this,i,n){const r=this.strings;let o=!1;if(void 0===r)t=J(this,t,e,0),o=!U(t)||t!==this._$AH&&t!==W,o&&(this._$AH=t);else{const n=t;let s,u;for(t=r[0],s=0;s<r.length-1;s++)u=J(this,n[i+s],e,s),u===W&&(u=this._$AH[s]),o||(o=!U(u)||u!==this._$AH[s]),u===D?t=D:t!==D&&(t+=(null!=u?u:"")+r[s+1]),this._$AH[s]=u}o&&!n&&this.P(t)}P(t){t===D?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,null!=t?t:"")}}class X extends q{constructor(){super(...arguments),this.type=3}P(t){this.element[this.name]=t===D?void 0:t}}const G=j?j.emptyScript:"";class Y extends q{constructor(){super(...arguments),this.type=4}P(t){t&&t!==D?this.element.setAttribute(this.name,G):this.element.removeAttribute(this.name)}}class Q extends q{constructor(t,e,i,n,r){super(t,e,i,n,r),this.type=5}_$AI(t,e=this){var i;if((t=null!==(i=J(this,t,e,0))&&void 0!==i?i:D)===W)return;const n=this._$AH,r=t===D&&n!==D||t.capture!==n.capture||t.once!==n.once||t.passive!==n.passive,o=t!==D&&(n===D||r);r&&this.element.removeEventListener(this.name,this,n),o&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var e,i;"function"==typeof this._$AH?this._$AH.call(null!==(i=null===(e=this.options)||void 0===e?void 0:e.host)&&void 0!==i?i:this.element,t):this._$AH.handleEvent(t)}}class tt{constructor(t,e,i){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(t){J(this,t)}}const et=window.litHtmlPolyfillSupport;
|
|
44
44
|
/**
|
|
45
45
|
* @license
|
|
46
46
|
* Copyright 2017 Google LLC
|
|
@@ -57,7 +57,7 @@ function(t){return class extends t{createRenderRoot(){const t=this.constructor,{
|
|
|
57
57
|
<style>${t}</style>
|
|
58
58
|
`))}
|
|
59
59
|
${this.getTemplate()}
|
|
60
|
-
`}updated(t){super.updated(t),setTimeout((()=>{var e;this.contentAvailableCallback(t),(null===(e=this.exportpartsPrefix)||void 0===e?void 0:e.trim())?this.setExportpartsAttribute([this.exportpartsPrefix]):null!=this.exportpartsPrefixes&&this.exportpartsPrefixes.length>0&&this.setExportpartsAttribute(this.exportpartsPrefixes)}),0)}setExportpartsAttribute(t){var e,i,n,r,o,s;const u=t=>null!=t&&t.trim().length>0,c=t.filter(u).map((t=>t.trim()));if(0===c.length)return void this.removeAttribute("exportparts");const a=new Set;for(let t of null!==(i=null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelectorAll("[part],[exportparts]"))&&void 0!==i?i:[]){const e=null!==(r=null===(n=t.getAttribute("part"))||void 0===n?void 0:n.split(" "))&&void 0!==r?r:[],i=null!==(s=null===(o=t.getAttribute("exportparts"))||void 0===o?void 0:o.split(",").map((t=>t.split(":")[1])))&&void 0!==s?s:[];new Array(...e,...i).filter(u).map((t=>t.trim())).forEach((t=>a.add(t)))}if(0===a.size)return void this.removeAttribute("exportparts");const l=[...a.values()].flatMap((t=>c.map((e=>`${t}:${e}--${t}`))));this.setAttribute("exportparts",[...this.part,...l].join(", "))}contentAvailableCallback(t){}}function at(t){for(var e=arguments.length,i=Array(e>1?e-1:0),n=1;n<e;n++)i[n-1]=arguments[n];throw Error("[Immer] minified error nr: "+t+(i.length?" "+i.map((function(t){return"'"+t+"'"})).join(","):"")+". Find the full error at: https://bit.ly/3cXEKWf")}function lt(t){return!!t&&!!t[Xt]}function ft(t){return!!t&&(function(t){if(!t||"object"!=typeof t)return!1;var e=Object.getPrototypeOf(t);if(null===e)return!0;var i=Object.hasOwnProperty.call(e,"constructor")&&e.constructor;return i===Object||"function"==typeof i&&Function.toString.call(i)===Gt}(t)||Array.isArray(t)||!!t[qt]||!!t.constructor[qt]||wt(t)||yt(t))}function ht(t,e,i){void 0===i&&(i=!1),0===dt(t)?(i?Object.keys:Yt)(t).forEach((function(n){i&&"symbol"==typeof n||e(n,t[n],t)})):t.forEach((function(i,n){return e(n,i,t)}))}function dt(t){var e=t[Xt];return e?e.i>3?e.i-4:e.i:Array.isArray(t)?1:wt(t)?2:yt(t)?3:0}function vt(t,e){return 2===dt(t)?t.has(e):Object.prototype.hasOwnProperty.call(t,e)}function pt(t,e,i){var n=dt(t);2===n?t.set(e,i):3===n?(t.delete(e),t.add(i)):t[e]=i}function bt(t,e){return t===e?0!==t||1/t==1/e:t!=t&&e!=e}function wt(t){return zt&&t instanceof Map}function yt(t){return Jt&&t instanceof Set}function mt(t){return t.o||t.t}function gt(t){if(Array.isArray(t))return Array.prototype.slice.call(t);var e=Qt(t);delete e[Xt];for(var i=Yt(e),n=0;n<i.length;n++){var r=i[n],o=e[r];!1===o.writable&&(o.writable=!0,o.configurable=!0),(o.get||o.set)&&(e[r]={configurable:!0,writable:!0,enumerable:o.enumerable,value:t[r]})}return Object.create(Object.getPrototypeOf(t),e)}function xt(t,e){return void 0===e&&(e=!1),Et(t)||lt(t)||!ft(t)||(dt(t)>1&&(t.set=t.add=t.clear=t.delete=Ot),Object.freeze(t),e&&ht(t,(function(t,e){return xt(e,!0)}),!0)),t}function Ot(){at(2)}function Et(t){return null==t||"object"!=typeof t||Object.isFrozen(t)}function jt(t){var e=te[t];return e||at(18,t),e}function Nt(){return
|
|
60
|
+
`}updated(t){super.updated(t),setTimeout((()=>{var e;this.contentAvailableCallback(t),(null===(e=this.exportpartsPrefix)||void 0===e?void 0:e.trim())?this.setExportpartsAttribute([this.exportpartsPrefix]):null!=this.exportpartsPrefixes&&this.exportpartsPrefixes.length>0&&this.setExportpartsAttribute(this.exportpartsPrefixes)}),0)}setExportpartsAttribute(t){var e,i,n,r,o,s;const u=t=>null!=t&&t.trim().length>0,c=t.filter(u).map((t=>t.trim()));if(0===c.length)return void this.removeAttribute("exportparts");const a=new Set;for(let t of null!==(i=null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelectorAll("[part],[exportparts]"))&&void 0!==i?i:[]){const e=null!==(r=null===(n=t.getAttribute("part"))||void 0===n?void 0:n.split(" "))&&void 0!==r?r:[],i=null!==(s=null===(o=t.getAttribute("exportparts"))||void 0===o?void 0:o.split(",").map((t=>t.split(":")[1])))&&void 0!==s?s:[];new Array(...e,...i).filter(u).map((t=>t.trim())).forEach((t=>a.add(t)))}if(0===a.size)return void this.removeAttribute("exportparts");const l=[...a.values()].flatMap((t=>c.map((e=>`${t}:${e}--${t}`))));this.setAttribute("exportparts",[...this.part,...l].join(", "))}contentAvailableCallback(t){}}function at(t){for(var e=arguments.length,i=Array(e>1?e-1:0),n=1;n<e;n++)i[n-1]=arguments[n];throw Error("[Immer] minified error nr: "+t+(i.length?" "+i.map((function(t){return"'"+t+"'"})).join(","):"")+". Find the full error at: https://bit.ly/3cXEKWf")}function lt(t){return!!t&&!!t[Xt]}function ft(t){return!!t&&(function(t){if(!t||"object"!=typeof t)return!1;var e=Object.getPrototypeOf(t);if(null===e)return!0;var i=Object.hasOwnProperty.call(e,"constructor")&&e.constructor;return i===Object||"function"==typeof i&&Function.toString.call(i)===Gt}(t)||Array.isArray(t)||!!t[qt]||!!t.constructor[qt]||wt(t)||yt(t))}function ht(t,e,i){void 0===i&&(i=!1),0===dt(t)?(i?Object.keys:Yt)(t).forEach((function(n){i&&"symbol"==typeof n||e(n,t[n],t)})):t.forEach((function(i,n){return e(n,i,t)}))}function dt(t){var e=t[Xt];return e?e.i>3?e.i-4:e.i:Array.isArray(t)?1:wt(t)?2:yt(t)?3:0}function vt(t,e){return 2===dt(t)?t.has(e):Object.prototype.hasOwnProperty.call(t,e)}function pt(t,e,i){var n=dt(t);2===n?t.set(e,i):3===n?(t.delete(e),t.add(i)):t[e]=i}function bt(t,e){return t===e?0!==t||1/t==1/e:t!=t&&e!=e}function wt(t){return zt&&t instanceof Map}function yt(t){return Jt&&t instanceof Set}function mt(t){return t.o||t.t}function gt(t){if(Array.isArray(t))return Array.prototype.slice.call(t);var e=Qt(t);delete e[Xt];for(var i=Yt(e),n=0;n<i.length;n++){var r=i[n],o=e[r];!1===o.writable&&(o.writable=!0,o.configurable=!0),(o.get||o.set)&&(e[r]={configurable:!0,writable:!0,enumerable:o.enumerable,value:t[r]})}return Object.create(Object.getPrototypeOf(t),e)}function xt(t,e){return void 0===e&&(e=!1),Et(t)||lt(t)||!ft(t)||(dt(t)>1&&(t.set=t.add=t.clear=t.delete=Ot),Object.freeze(t),e&&ht(t,(function(t,e){return xt(e,!0)}),!0)),t}function Ot(){at(2)}function Et(t){return null==t||"object"!=typeof t||Object.isFrozen(t)}function jt(t){var e=te[t];return e||at(18,t),e}function Nt(){return Kt}function St(t,e){e&&(jt("Patches"),t.u=[],t.s=[],t.v=e)}function Rt(t){Ct(t),t.p.forEach(At),t.p=null}function Ct(t){t===Kt&&(Kt=t.l)}function Mt(t){return Kt={p:[],l:Kt,h:t,m:!0,_:0}}function At(t){var e=t[Xt];0===e.i||1===e.i?e.j():e.O=!0}function Ut(t,e){e._=e.p.length;var i=e.p[0],n=void 0!==t&&t!==i;return e.h.g||jt("ES5").S(e,t,n),n?(i[Xt].P&&(Rt(e),at(4)),ft(t)&&(t=Tt(e,t),e.l||It(e,t)),e.u&&jt("Patches").M(i[Xt].t,t,e.u,e.s)):t=Tt(e,i,[]),Rt(e),e.u&&e.v(e.u,e.s),t!==Zt?t:void 0}function Tt(t,e,i){if(Et(e))return e;var n=e[Xt];if(!n)return ht(e,(function(r,o){return $t(t,n,e,r,o,i)}),!0),e;if(n.A!==t)return e;if(!n.P)return It(t,n.t,!0),n.t;if(!n.I){n.I=!0,n.A._--;var r=4===n.i||5===n.i?n.o=gt(n.k):n.o;ht(3===n.i?new Set(r):r,(function(e,o){return $t(t,n,r,e,o,i)})),It(t,r,!1),i&&t.u&&jt("Patches").R(n,i,t.u,t.s)}return n.o}function $t(t,e,i,n,r,o){if(lt(r)){var s=Tt(t,r,o&&e&&3!==e.i&&!vt(e.D,n)?o.concat(n):void 0);if(pt(i,n,s),!lt(s))return;t.m=!1}if(ft(r)&&!Et(r)){if(!t.h.F&&t._<1)return;Tt(t,r),e&&e.A.l||It(t,r)}}function It(t,e,i){void 0===i&&(i=!1),t.h.F&&t.m&&xt(e,i)}function kt(t,e){var i=t[Xt];return(i?mt(i):t)[e]}function Pt(t,e){if(e in t)for(var i=Object.getPrototypeOf(t);i;){var n=Object.getOwnPropertyDescriptor(i,e);if(n)return n;i=Object.getPrototypeOf(i)}}function Ft(t){t.P||(t.P=!0,t.l&&Ft(t.l))}function _t(t){t.o||(t.o=gt(t.t))}function Lt(t,e,i){var n=wt(e)?jt("MapSet").N(e,i):yt(e)?jt("MapSet").T(e,i):t.g?function(t,e){var i=Array.isArray(t),n={i:i?1:0,A:e?e.A:Nt(),P:!1,I:!1,D:{},l:e,t,k:null,o:null,j:null,C:!1},r=n,o=ee;i&&(r=[n],o=ie);var s=Proxy.revocable(r,o),u=s.revoke,c=s.proxy;return n.k=c,n.j=u,c}(e,i):jt("ES5").J(e,i);return(i?i.A:Nt()).p.push(n),n}function Bt(t){return lt(t)||at(22,t),function t(e){if(!ft(e))return e;var i,n=e[Xt],r=dt(e);if(n){if(!n.P&&(n.i<4||!jt("ES5").K(n)))return n.t;n.I=!0,i=Wt(e,r),n.I=!1}else i=Wt(e,r);return ht(i,(function(e,r){n&&function(t,e){return 2===dt(t)?t.get(e):t[e]}(n.t,e)===r||pt(i,e,t(r))})),3===r?new Set(i):i}(t)}function Wt(t,e){switch(e){case 2:return new Map(t);case 3:return Array.from(t)}return gt(t)}ut([n()],ct.prototype,"exportpartsPrefix",void 0),ut([function(t,e){const i=()=>JSON.parse(JSON.stringify(t));return n({type:Object,converter:{fromAttribute:t=>{if(null==t)return i();try{return JSON.parse(t)}catch{return i()}},toAttribute:t=>JSON.stringify(t)},...null!=e?e:{}})}([])],ct.prototype,"exportpartsPrefixes",void 0),h`
|
|
61
61
|
.ft-no-text-select {
|
|
62
62
|
-webkit-touch-callout: none;
|
|
63
63
|
-webkit-user-select: none;
|
|
@@ -66,7 +66,7 @@ function(t){return class extends t{createRenderRoot(){const t=this.constructor,{
|
|
|
66
66
|
-ms-user-select: none;
|
|
67
67
|
user-select: none;
|
|
68
68
|
}
|
|
69
|
-
`;var Kt,Dt,Ht="undefined"!=typeof Symbol&&"symbol"==typeof Symbol("x"),zt="undefined"!=typeof Map,Jt="undefined"!=typeof Set,Vt="undefined"!=typeof Proxy&&void 0!==Proxy.revocable&&"undefined"!=typeof Reflect,Zt=Ht?Symbol.for("immer-nothing"):((Kt={})["immer-nothing"]=!0,Kt),qt=Ht?Symbol.for("immer-draftable"):"__$immer_draftable",Xt=Ht?Symbol.for("immer-state"):"__$immer_state",Gt=""+Object.prototype.constructor,Yt="undefined"!=typeof Reflect&&Reflect.ownKeys?Reflect.ownKeys:void 0!==Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:Object.getOwnPropertyNames,Qt=Object.getOwnPropertyDescriptors||function(t){var e={};return Yt(t).forEach((function(i){e[i]=Object.getOwnPropertyDescriptor(t,i)})),e},te={},ee={get:function(t,e){if(e===Xt)return t;var i=mt(t);if(!vt(i,e))return function(t,e,i){var n,r=Ft(e,i);return r?"value"in r?r.value:null===(n=r.get)||void 0===n?void 0:n.call(t.k):void 0}(t,i,e);var n=i[e];return t.I||!ft(n)?n:n===kt(t.t,e)?(_t(t),t.o[e]=Lt(t.A.h,n,t)):n},has:function(t,e){return e in mt(t)},ownKeys:function(t){return Reflect.ownKeys(mt(t))},set:function(t,e,i){var n=Ft(mt(t),e);if(null==n?void 0:n.set)return n.set.call(t.k,i),!0;if(!t.P){var r=kt(mt(t),e),o=null==r?void 0:r[Xt];if(o&&o.t===i)return t.o[e]=i,t.D[e]=!1,!0;if(bt(i,r)&&(void 0!==i||vt(t.t,e)))return!0;_t(t),Pt(t)}return t.o[e]===i&&"number"!=typeof i&&(void 0!==i||e in t.o)||(t.o[e]=i,t.D[e]=!0,!0)},deleteProperty:function(t,e){return void 0!==kt(t.t,e)||e in t.t?(t.D[e]=!1,_t(t),Pt(t)):delete t.D[e],t.o&&delete t.o[e],!0},getOwnPropertyDescriptor:function(t,e){var i=mt(t),n=Reflect.getOwnPropertyDescriptor(i,e);return n?{writable:!0,configurable:1!==t.i||"length"!==e,enumerable:n.enumerable,value:i[e]}:n},defineProperty:function(){at(11)},getPrototypeOf:function(t){return Object.getPrototypeOf(t.t)},setPrototypeOf:function(){at(12)}},ie={};ht(ee,(function(t,e){ie[t]=function(){return arguments[0]=arguments[0][0],e.apply(this,arguments)}})),ie.deleteProperty=function(t,e){return ie.set.call(this,t,e,void 0)},ie.set=function(t,e,i){return ee.set.call(this,t[0],e,i,t[0])};var ne=function(){function t(t){var e=this;this.g=Vt,this.F=!0,this.produce=function(t,i,n){if("function"==typeof t&&"function"!=typeof i){var r=i;i=t;var o=e;return function(t){var e=this;void 0===t&&(t=r);for(var n=arguments.length,s=Array(n>1?n-1:0),u=1;u<n;u++)s[u-1]=arguments[u];return o.produce(t,(function(t){var n;return(n=i).call.apply(n,[e,t].concat(s))}))}}var s;if("function"!=typeof i&&at(6),void 0!==n&&"function"!=typeof n&&at(7),ft(t)){var u=Mt(e),c=Lt(e,t,void 0),a=!0;try{s=i(c),a=!1}finally{a?Rt(u):Ct(u)}return"undefined"!=typeof Promise&&s instanceof Promise?s.then((function(t){return St(u,n),Ut(t,u)}),(function(t){throw Rt(u),t})):(St(u,n),Ut(s,u))}if(!t||"object"!=typeof t){if(void 0===(s=i(t))&&(s=t),s===Zt&&(s=void 0),e.F&&xt(s,!0),n){var l=[],f=[];jt("Patches").M(t,s,l,f),n(l,f)}return s}at(21,t)},this.produceWithPatches=function(t,i){if("function"==typeof t)return function(i){for(var n=arguments.length,r=Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return e.produceWithPatches(i,(function(e){return t.apply(void 0,[e].concat(r))}))};var n,r,o=e.produce(t,i,(function(t,e){n=t,r=e}));return"undefined"!=typeof Promise&&o instanceof Promise?o.then((function(t){return[t,n,r]})):[o,n,r]},"boolean"==typeof(null==t?void 0:t.useProxies)&&this.setUseProxies(t.useProxies),"boolean"==typeof(null==t?void 0:t.autoFreeze)&&this.setAutoFreeze(t.autoFreeze)}var e=t.prototype;return e.createDraft=function(t){ft(t)||at(8),lt(t)&&(t=Bt(t));var e=Mt(this),i=Lt(this,t,void 0);return i[Xt].C=!0,Ct(e),i},e.finishDraft=function(t,e){var i=(t&&t[Xt]).A;return St(i,e),Ut(void 0,i)},e.setAutoFreeze=function(t){this.F=t},e.setUseProxies=function(t){t&&!Vt&&at(20),this.g=t},e.applyPatches=function(t,e){var i;for(i=e.length-1;i>=0;i--){var n=e[i];if(0===n.path.length&&"replace"===n.op){t=n.value;break}}i>-1&&(e=e.slice(i+1));var r=jt("Patches").$;return lt(t)?r(t,e):this.produce(t,(function(t){return r(t,e)}))},t}(),re=new ne,oe=re.produce;re.produceWithPatches.bind(re),re.setAutoFreeze.bind(re),re.setUseProxies.bind(re),re.applyPatches.bind(re),re.createDraft.bind(re),re.finishDraft.bind(re);var se=oe;function ue(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function ce(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),i.push.apply(i,n)}return i}function ae(t){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?ce(Object(i),!0).forEach((function(e){ue(t,e,i[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):ce(Object(i)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))}))}return t}function le(t){return"Minified Redux error #"+t+"; visit https://redux.js.org/Errors?code="+t+" for the full message or use the non-minified dev environment for full errors. "}var fe="function"==typeof Symbol&&Symbol.observable||"@@observable",he=function(){return Math.random().toString(36).substring(7).split("").join(".")},de={INIT:"@@redux/INIT"+he(),REPLACE:"@@redux/REPLACE"+he(),PROBE_UNKNOWN_ACTION:function(){return"@@redux/PROBE_UNKNOWN_ACTION"+he()}};function ve(t){if("object"!=typeof t||null===t)return!1;for(var e=t;null!==Object.getPrototypeOf(e);)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e}function pe(t,e,i){var n;if("function"==typeof e&&"function"==typeof i||"function"==typeof i&&"function"==typeof arguments[3])throw new Error(le(0));if("function"==typeof e&&void 0===i&&(i=e,e=void 0),void 0!==i){if("function"!=typeof i)throw new Error(le(1));return i(pe)(t,e)}if("function"!=typeof t)throw new Error(le(2));var r=t,o=e,s=[],u=s,c=!1;function a(){u===s&&(u=s.slice())}function l(){if(c)throw new Error(le(3));return o}function f(t){if("function"!=typeof t)throw new Error(le(4));if(c)throw new Error(le(5));var e=!0;return a(),u.push(t),function(){if(e){if(c)throw new Error(le(6));e=!1,a();var i=u.indexOf(t);u.splice(i,1),s=null}}}function h(t){if(!ve(t))throw new Error(le(7));if(void 0===t.type)throw new Error(le(8));if(c)throw new Error(le(9));try{c=!0,o=r(o,t)}finally{c=!1}for(var e=s=u,i=0;i<e.length;i++){(0,e[i])()}return t}function d(t){if("function"!=typeof t)throw new Error(le(10));r=t,h({type:de.REPLACE})}function v(){var t,e=f;return(t={subscribe:function(t){if("object"!=typeof t||null===t)throw new Error(le(11));function i(){t.next&&t.next(l())}return i(),{unsubscribe:e(i)}}})[fe]=function(){return this},t}return h({type:de.INIT}),(n={dispatch:h,subscribe:f,getState:l,replaceReducer:d})[fe]=v,n}function be(t){for(var e=Object.keys(t),i={},n=0;n<e.length;n++){var r=e[n];"function"==typeof t[r]&&(i[r]=t[r])}var o,s=Object.keys(i);try{!function(t){Object.keys(t).forEach((function(e){var i=t[e];if(void 0===i(void 0,{type:de.INIT}))throw new Error(le(12));if(void 0===i(void 0,{type:de.PROBE_UNKNOWN_ACTION()}))throw new Error(le(13))}))}(i)}catch(t){o=t}return function(t,e){if(void 0===t&&(t={}),o)throw o;for(var n=!1,r={},u=0;u<s.length;u++){var c=s[u],a=i[c],l=t[c],f=a(l,e);if(void 0===f)throw e&&e.type,new Error(le(14));r[c]=f,n=n||f!==l}return(n=n||s.length!==Object.keys(t).length)?r:t}}function we(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];return 0===e.length?function(t){return t}:1===e.length?e[0]:e.reduce((function(t,e){return function(){return t(e.apply(void 0,arguments))}}))}function ye(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];return function(t){return function(){var i=t.apply(void 0,arguments),n=function(){throw new Error(le(15))},r={getState:i.getState,dispatch:function(){return n.apply(void 0,arguments)}},o=e.map((function(t){return t(r)}));return n=we.apply(void 0,o)(i.dispatch),ae(ae({},i),{},{dispatch:n})}}}function me(t){return function(e){var i=e.dispatch,n=e.getState;return function(e){return function(r){return"function"==typeof r?r(i,n,t):e(r)}}}}var ge=me();ge.withExtraArgument=me;var xe,Oe=ge,Ee=(xe=function(t,e){return xe=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])},xe(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}xe(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}),je=function(t,e){for(var i=0,n=e.length,r=t.length;i<n;i++,r++)t[r]=e[i];return t},Ne=Object.defineProperty,Se=Object.getOwnPropertySymbols,Re=Object.prototype.hasOwnProperty,Ce=Object.prototype.propertyIsEnumerable,Me=function(t,e,i){return e in t?Ne(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i},Ae=function(t,e){for(var i in e||(e={}))Re.call(e,i)&&Me(t,i,e[i]);if(Se)for(var n=0,r=Se(e);n<r.length;n++){i=r[n];Ce.call(e,i)&&Me(t,i,e[i])}return t},Ue="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(0!==arguments.length)return"object"==typeof arguments[0]?we:we.apply(null,arguments)};var Te=function(t){function e(){for(var i=[],n=0;n<arguments.length;n++)i[n]=arguments[n];var r=t.apply(this,i)||this;return Object.setPrototypeOf(r,e.prototype),r}return Ee(e,t),Object.defineProperty(e,Symbol.species,{get:function(){return e},enumerable:!1,configurable:!0}),e.prototype.concat=function(){for(var e=[],i=0;i<arguments.length;i++)e[i]=arguments[i];return t.prototype.concat.apply(this,e)},e.prototype.prepend=function(){for(var t=[],i=0;i<arguments.length;i++)t[i]=arguments[i];return 1===t.length&&Array.isArray(t[0])?new(e.bind.apply(e,je([void 0],t[0].concat(this)))):new(e.bind.apply(e,je([void 0],t.concat(this))))},e}(Array);function $e(t){return ft(t)?se(t,(function(){})):t}function Ie(){return function(t){return function(t){void 0===t&&(t={});var e=t.thunk,i=void 0===e||e;t.immutableCheck,t.serializableCheck;var n=new Te;i&&(!function(t){return"boolean"==typeof t}(i)?n.push(Oe.withExtraArgument(i.extraArgument)):n.push(Oe));return n}(t)}}function ke(t){var e,i=Ie(),n=t||{},r=n.reducer,o=void 0===r?void 0:r,s=n.middleware,u=void 0===s?i():s,c=n.devTools,a=void 0===c||c,l=n.preloadedState,f=void 0===l?void 0:l,h=n.enhancers,d=void 0===h?void 0:h;if("function"==typeof o)e=o;else{if(!function(t){if("object"!=typeof t||null===t)return!1;var e=Object.getPrototypeOf(t);if(null===e)return!0;for(var i=e;null!==Object.getPrototypeOf(i);)i=Object.getPrototypeOf(i);return e===i}(o))throw new Error('"reducer" is a required argument, and must be a function or an object of functions that can be passed to combineReducers');e=be(o)}var v=u;"function"==typeof v&&(v=v(i));var p=ye.apply(void 0,v),b=we;a&&(b=Ue(Ae({trace:!1},"object"==typeof a&&a)));var w=[p];return Array.isArray(d)?w=je([p],d):"function"==typeof d&&(w=d(w)),pe(e,f,b.apply(void 0,w))}function Fe(t,e){function i(){for(var i=[],n=0;n<arguments.length;n++)i[n]=arguments[n];if(e){var r=e.apply(void 0,i);if(!r)throw new Error("prepareAction did not return an object");return Ae(Ae({type:t,payload:r.payload},"meta"in r&&{meta:r.meta}),"error"in r&&{error:r.error})}return{type:t,payload:i[0]}}return i.toString=function(){return""+t},i.type=t,i.match=function(e){return e.type===t},i}function Pe(t){var e,i={},n=[],r={addCase:function(t,e){var n="string"==typeof t?t:t.type;if(n in i)throw new Error("addCase cannot be called with two reducers for the same action type");return i[n]=e,r},addMatcher:function(t,e){return n.push({matcher:t,reducer:e}),r},addDefaultCase:function(t){return e=t,r}};return t(r),[i,n,e]}function _e(t){var e=t.name;if(!e)throw new Error("`name` is a required option for createSlice");var i,n="function"==typeof t.initialState?t.initialState:$e(t.initialState),r=t.reducers||{},o=Object.keys(r),s={},u={},c={};function a(){var e="function"==typeof t.extraReducers?Pe(t.extraReducers):[t.extraReducers],i=e[0],r=void 0===i?{}:i,o=e[1],s=void 0===o?[]:o,c=e[2],a=void 0===c?void 0:c,l=Ae(Ae({},r),u);return function(t,e,i,n){void 0===i&&(i=[]);var r,o="function"==typeof e?Pe(e):[e,i,n],s=o[0],u=o[1],c=o[2];if(function(t){return"function"==typeof t}(t))r=function(){return $e(t())};else{var a=$e(t);r=function(){return a}}function l(t,e){void 0===t&&(t=r());var i=je([s[e.type]],u.filter((function(t){return(0,t.matcher)(e)})).map((function(t){return t.reducer})));return 0===i.filter((function(t){return!!t})).length&&(i=[c]),i.reduce((function(t,i){if(i){var n;if(lt(t))return void 0===(n=i(t,e))?t:n;if(ft(t))return se(t,(function(t){return i(t,e)}));if(void 0===(n=i(t,e))){if(null===t)return t;throw Error("A case reducer on a non-draftable value must not return undefined")}return n}return t}),t)}return l.getInitialState=r,l}(n,l,s,a)}return o.forEach((function(t){var i,n,o=r[t],a=e+"/"+t;"reducer"in o?(i=o.reducer,n=o.prepare):i=o,s[t]=i,u[a]=i,c[t]=n?Fe(a,n):Fe(a)})),{name:e,reducer:function(t,e){return i||(i=a()),i(t,e)},actions:c,caseReducers:s,getInitialState:function(){return i||(i=a()),i.getInitialState()}}}var Le="listenerMiddleware";Fe(Le+"/add"),Fe(Le+"/removeAll"),Fe(Le+"/remove"),function(){function t(t,e){var i=r[t];return i?i.enumerable=e:r[t]=i={configurable:!0,enumerable:e,get:function(){var e=this[Xt];return ee.get(e,t)},set:function(e){var i=this[Xt];ee.set(i,t,e)}},i}function e(t){for(var e=t.length-1;e>=0;e--){var r=t[e][Xt];if(!r.P)switch(r.i){case 5:n(r)&&Pt(r);break;case 4:i(r)&&Pt(r)}}}function i(t){for(var e=t.t,i=t.k,n=Yt(i),r=n.length-1;r>=0;r--){var o=n[r];if(o!==Xt){var s=e[o];if(void 0===s&&!vt(e,o))return!0;var u=i[o],c=u&&u[Xt];if(c?c.t!==s:!bt(u,s))return!0}}var a=!!e[Xt];return n.length!==Yt(e).length+(a?0:1)}function n(t){var e=t.k;if(e.length!==t.t.length)return!0;var i=Object.getOwnPropertyDescriptor(e,e.length-1);if(i&&!i.get)return!0;for(var n=0;n<e.length;n++)if(!e.hasOwnProperty(n))return!0;return!1}var r={};!function(t,e){te[t]||(te[t]=e)}("ES5",{J:function(e,i){var n=Array.isArray(e),r=function(e,i){if(e){for(var n=Array(i.length),r=0;r<i.length;r++)Object.defineProperty(n,""+r,t(r,!0));return n}var o=Qt(i);delete o[Xt];for(var s=Yt(o),u=0;u<s.length;u++){var c=s[u];o[c]=t(c,e||!!o[c].enumerable)}return Object.create(Object.getPrototypeOf(i),o)}(n,e),o={i:n?5:4,A:i?i.A:Nt(),P:!1,I:!1,D:{},l:i,t:e,k:r,o:null,O:!1,C:!1};return Object.defineProperty(r,Xt,{value:o,writable:!0}),r},S:function(t,i,r){r?lt(i)&&i[Xt].A===t&&e(t.p):(t.u&&function t(e){if(e&&"object"==typeof e){var i=e[Xt];if(i){var r=i.t,o=i.k,s=i.D,u=i.i;if(4===u)ht(o,(function(e){e!==Xt&&(void 0!==r[e]||vt(r,e)?s[e]||t(o[e]):(s[e]=!0,Pt(i)))})),ht(r,(function(t){void 0!==o[t]||vt(o,t)||(s[t]=!1,Pt(i))}));else if(5===u){if(n(i)&&(Pt(i),s.length=!0),o.length<r.length)for(var c=o.length;c<r.length;c++)s[c]=!1;else for(var a=r.length;a<o.length;a++)s[a]=!0;for(var l=Math.min(o.length,r.length),f=0;f<l;f++)o.hasOwnProperty(f)||(s[f]=!0),void 0===s[f]&&t(o[f])}}}}(t.p[0]),e(t.p))},K:function(t){return 4===t.i?i(t):n(t)}})}();const Be=(t,e)=>(i,n)=>{i.constructor.createProperty(n,{attribute:!1,hasChanged:null!=e?e:o});const r=i;r.reduxProperties=r.reduxProperties||new Map,r.reduxProperties.set(n,null!=t?t:t=>t[n])};class We extends ct{get store(){return this.internalStore}set store(t){this.internalStore=t,this.store&&this.setupStore()}updateFromStore(){const t=this.store.getState();this.reduxProperties&&this.reduxProperties.forEach(((e,i)=>{this[i]=e(t,this)}))}setupStore(){this.unsubscribeFromStore&&this.unsubscribeFromStore(),this.updateFromStore(),this.unsubscribeFromStore=this.store.subscribe((()=>{this.updateFromStore()})),this.onStoreAvailable(),this.requestUpdate()}onStoreAvailable(){}connectedCallback(){super.connectedCallback(),this.store&&this.setupStore()}disconnectedCallback(){this.unsubscribeFromStore&&this.unsubscribeFromStore(),super.disconnectedCallback()}}var Ke,De;navigator.vendor&&navigator.vendor.match(/apple/i)||(null===(De=null===(Ke=window.safari)||void 0===Ke?void 0:Ke.pushNotification)||void 0===De||De.toString());const He={setBaseUrl:(t,e)=>{t.baseUrl=e.payload},setApiIntegrationIdentifier:(t,e)=>{t.apiIntegrationIdentifier=e.payload},setMapId:(t,e)=>{t.mapId=e.payload},setTocId:(t,e)=>{t.tocId=e.payload},setMap:(t,e)=>{t.map=e.payload},setToc:(t,e)=>{t.toc=e.payload},setCurrentPage:(t,e)=>{t.currentPage=e.payload},setScrollTarget:(t,e)=>{t.scrollTarget=e.payload},setVisibleTopics:(t,e)=>{t.visibleTopics=e.payload}};class ze{convertNodes(t){var e,i,n,r;const o={},s=new Set,u=new Set,c=[],a=(t,e,i)=>t.map((t=>{var n;t.page&&c.push(t.tocId);let r=null===(n=t.prettyUrl)||void 0===n?void 0:n.replace(/^\//,"");const l={...t,prettyUrl:r,depth:e,parentTocId:i,children:a(t.children,e+1,t.tocId)};return r&&(s.has(r)&&u.add(r),s.add(r)),o[t.tocId]=l,l})),l=a(null!=t?t:[],1),f=this.buildPages(c,o);let h={};return 0===f.length?f.push({number:1,title:null!==(i=null===(e=l[0])||void 0===e?void 0:e.title)&&void 0!==i?i:"",rootTocId:null!==(r=null===(n=l[0])||void 0===n?void 0:n.tocId)&&void 0!==r?r:"root",toc:[],topics:this.tocIds(l),hiddenTopics:[]}):h=this.indexPages(f),{toc:l,nodeByTocId:o,duplicatedPrettyUrls:u,pages:f,pageByTocId:h}}tocIds(t){return t.flatMap((t=>[t.tocId,...this.tocIds(t.children)]))}buildPages(t,e){const i=t=>t.parentTocId?[...i(e[t.parentTocId]),t.parentTocId]:[];return t.map((t=>e[t])).map(((t,e)=>{var n,r,o,s,u;const c={number:e+1,title:t.title,rootTocId:t.tocId,toc:(null===(n=t.page)||void 0===n?void 0:n.onItsOwn)?[]:t.children,topics:[],hiddenTopics:[]},a=(t,e)=>(e?c.topics:c.hiddenTopics).push(t),l=null!==(o=null===(r=t.page)||void 0===r?void 0:r.parentsVisibility)&&void 0!==o?o:[];return i(t).forEach(((t,e)=>{a(t,l[e])})),a(t.tocId,null===(s=t.page)||void 0===s?void 0:s.visible),(null===(u=t.page)||void 0===u?void 0:u.onItsOwn)||c.topics.push(...this.tocIds(t.children)),c}))}indexPages(t){const e={};for(let i of t)for(let t of[...i.topics,...i.hiddenTopics])e[t]||(e[t]=i);return e}}class Je{constructor(t,e,i,n){this.converter=t,this.api=e,this.baseUrl=i,this.mapId=n,this.topics={},this.topicContents={},i.endsWith("/")||(this.baseUrl=i+"/")}static build(t,e,i){if(null==window.fluidtopics)throw console.error("Fluid Topics public API was not found. You can find it here: https://www.npmjs.com/package/@fluid-topics/public-api"),new Error("Fluid Topics public API not found");return new Je(new ze,new window.fluidtopics.FluidTopicsApi(t,e,!0),t,i)}clear(){this.map=void 0,this.enrichedToc=void 0,this.topics={},this.topicContents={}}getMap(){return this.loadIfNeeded((()=>this.map),(t=>this.map=t),(()=>this.api.getMap(this.mapId)))}getEnrichedToc(){return this.loadIfNeeded((()=>this.enrichedToc),(t=>this.enrichedToc=t),(()=>this.api.getTableOfContent(this.mapId).then((t=>this.converter.convertNodes(t)))))}async getToc(){return(await this.getEnrichedToc()).toc}async getTocNode(t){return(await this.getEnrichedToc()).nodeByTocId[t]}async getPage(t){const e=await this.getEnrichedToc();return e.pages[t-1]||e.pages[0]}async getPageByTocId(t){const e=await this.getEnrichedToc();return e.pageByTocId[t]||e.pages[0]}getTopicInfo(t){return this.loadIfNeeded((()=>this.topics[t]),(e=>this.topics[t]=e),(()=>this.api.getTopic(this.mapId,t)))}getTopicContent(t){return this.loadIfNeeded((()=>this.topicContents[t]),(e=>this.topicContents[t]=e),(()=>this.api.getTopicHTMLContent(this.mapId,t,"DESIGNED_READER")))}getLink(t,e,i){var n;t=t||"root";let r=this.enrichedToc,o=null===(n=null==r?void 0:r.nodeByTocId[t])||void 0===n?void 0:n.prettyUrl,s=o||`r/${this.mapId}/${t}`,u=new URL(s,this.baseUrl),c=null==r?void 0:r.pageByTocId[t];return e&&c&&c.number!==e&&u.searchParams.set("page",`${e}`),o&&(null==r?void 0:r.duplicatedPrettyUrls.has(o))&&u.searchParams.set("tocId",t),i&&u.searchParams.set("section",i),u.href}async loadIfNeeded(t,e,i){for(void 0===t()&&(e(!0),e(await i().catch((t=>(console.error(t),!1)))));!0===t();)await s(10);const n=t();if(!1===n)throw new Error("Could not load data");return n}}class Ve{constructor(t,i){this.store=t,this.slice=i,this.reloadDebouncer=new e(10)}static build(t){const e=(t=>_e({name:"ft-reader-"+t,initialState:{baseUrl:"",apiIntegrationIdentifier:"ft-reader",visibleTopics:[]},reducers:He}))(t.trim()||"context");return new Ve(function(t,e,i){window.ftReduxStores||(window.ftReduxStores={});const n=e||t.name;return window.ftReduxStores[n]||(window.ftReduxStores[n]=ke({reducer:t.reducer})),window.ftReduxStores[n]}(e),e)}setBaseUrl(t){this.setRequiredStateField("baseUrl","setBaseUrl",t)}setApiIntegrationIdentifier(t){this.setRequiredStateField("apiIntegrationIdentifier","setApiIntegrationIdentifier",t)}setMapId(t){this.setRequiredStateField("mapId","setMapId",t)}setVisibleTopics(t){this.dispatch(this.slice.actions.setVisibleTopics(t))}async navigateToTopic(t,e,i){for(;null===this.service;)await s(5);let n=null!=i?await this.service.getPage(i):await this.service.getPageByTocId(t);console.log(i,n),this.dispatch(this.slice.actions.setCurrentPage(n),this.slice.actions.setScrollTarget({tocId:t,section:e}))}async navigateToPage(t){for(;null===this.service;)await s(5);let e=await this.service.getPage(t);this.dispatch(this.slice.actions.setCurrentPage(e))}scrollDone(){this.dispatch(this.slice.actions.setScrollTarget({}))}setRequiredStateField(t,e,i){this.store.getState()[t]!==i&&(this.dispatch(this.slice.actions[e](i)),this.clearAll(),this.reload())}clearAll(){this.dispatch(this.slice.actions.setMap(void 0),this.slice.actions.setToc(void 0),this.slice.actions.setCurrentPage(void 0))}reload(){const t=this.store.getState();t.baseUrl&&t.apiIntegrationIdentifier&&t.mapId?this.service=Je.build(t.baseUrl,t.apiIntegrationIdentifier,t.mapId):this.service=void 0,this.reloadDebouncer.run((async()=>{this.reloadMap(),this.reloadToc()}))}async reloadMap(){var t;const e=await(null===(t=this.service)||void 0===t?void 0:t.getMap());this.dispatch(this.slice.actions.setMap(e))}async reloadToc(){var t;const e=await(null===(t=this.service)||void 0===t?void 0:t.getToc());this.dispatch(this.slice.actions.setToc(e))}dispatch(...t){for(let e of t)this.store.dispatch(e)}}var Ze,qe=function(t,e,i,n){for(var r,o=arguments.length,s=o<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n,u=t.length-1;u>=0;u--)(r=t[u])&&(s=(o<3?r(s):o>3?r(e,i,s):r(e,i))||s);return o>3&&s&&Object.defineProperty(e,i,s),s};class Xe extends CustomEvent{constructor(t){super("ft-reader-map-loaded",{detail:t})}}class Ge extends CustomEvent{constructor(t,e){super("ft-reader-visible-topics-change",{detail:{map:t,visibleTopics:e}})}}class Ye extends We{constructor(){super(...arguments),this.apiIntegrationIdentifier="ft-reader",this.visibleTopics=[]}render(){return B`
|
|
69
|
+
`;var Dt,Kt,Ht="undefined"!=typeof Symbol&&"symbol"==typeof Symbol("x"),zt="undefined"!=typeof Map,Jt="undefined"!=typeof Set,Vt="undefined"!=typeof Proxy&&void 0!==Proxy.revocable&&"undefined"!=typeof Reflect,Zt=Ht?Symbol.for("immer-nothing"):((Dt={})["immer-nothing"]=!0,Dt),qt=Ht?Symbol.for("immer-draftable"):"__$immer_draftable",Xt=Ht?Symbol.for("immer-state"):"__$immer_state",Gt=""+Object.prototype.constructor,Yt="undefined"!=typeof Reflect&&Reflect.ownKeys?Reflect.ownKeys:void 0!==Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:Object.getOwnPropertyNames,Qt=Object.getOwnPropertyDescriptors||function(t){var e={};return Yt(t).forEach((function(i){e[i]=Object.getOwnPropertyDescriptor(t,i)})),e},te={},ee={get:function(t,e){if(e===Xt)return t;var i=mt(t);if(!vt(i,e))return function(t,e,i){var n,r=Pt(e,i);return r?"value"in r?r.value:null===(n=r.get)||void 0===n?void 0:n.call(t.k):void 0}(t,i,e);var n=i[e];return t.I||!ft(n)?n:n===kt(t.t,e)?(_t(t),t.o[e]=Lt(t.A.h,n,t)):n},has:function(t,e){return e in mt(t)},ownKeys:function(t){return Reflect.ownKeys(mt(t))},set:function(t,e,i){var n=Pt(mt(t),e);if(null==n?void 0:n.set)return n.set.call(t.k,i),!0;if(!t.P){var r=kt(mt(t),e),o=null==r?void 0:r[Xt];if(o&&o.t===i)return t.o[e]=i,t.D[e]=!1,!0;if(bt(i,r)&&(void 0!==i||vt(t.t,e)))return!0;_t(t),Ft(t)}return t.o[e]===i&&"number"!=typeof i&&(void 0!==i||e in t.o)||(t.o[e]=i,t.D[e]=!0,!0)},deleteProperty:function(t,e){return void 0!==kt(t.t,e)||e in t.t?(t.D[e]=!1,_t(t),Ft(t)):delete t.D[e],t.o&&delete t.o[e],!0},getOwnPropertyDescriptor:function(t,e){var i=mt(t),n=Reflect.getOwnPropertyDescriptor(i,e);return n?{writable:!0,configurable:1!==t.i||"length"!==e,enumerable:n.enumerable,value:i[e]}:n},defineProperty:function(){at(11)},getPrototypeOf:function(t){return Object.getPrototypeOf(t.t)},setPrototypeOf:function(){at(12)}},ie={};ht(ee,(function(t,e){ie[t]=function(){return arguments[0]=arguments[0][0],e.apply(this,arguments)}})),ie.deleteProperty=function(t,e){return ie.set.call(this,t,e,void 0)},ie.set=function(t,e,i){return ee.set.call(this,t[0],e,i,t[0])};var ne=function(){function t(t){var e=this;this.g=Vt,this.F=!0,this.produce=function(t,i,n){if("function"==typeof t&&"function"!=typeof i){var r=i;i=t;var o=e;return function(t){var e=this;void 0===t&&(t=r);for(var n=arguments.length,s=Array(n>1?n-1:0),u=1;u<n;u++)s[u-1]=arguments[u];return o.produce(t,(function(t){var n;return(n=i).call.apply(n,[e,t].concat(s))}))}}var s;if("function"!=typeof i&&at(6),void 0!==n&&"function"!=typeof n&&at(7),ft(t)){var u=Mt(e),c=Lt(e,t,void 0),a=!0;try{s=i(c),a=!1}finally{a?Rt(u):Ct(u)}return"undefined"!=typeof Promise&&s instanceof Promise?s.then((function(t){return St(u,n),Ut(t,u)}),(function(t){throw Rt(u),t})):(St(u,n),Ut(s,u))}if(!t||"object"!=typeof t){if(void 0===(s=i(t))&&(s=t),s===Zt&&(s=void 0),e.F&&xt(s,!0),n){var l=[],f=[];jt("Patches").M(t,s,l,f),n(l,f)}return s}at(21,t)},this.produceWithPatches=function(t,i){if("function"==typeof t)return function(i){for(var n=arguments.length,r=Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return e.produceWithPatches(i,(function(e){return t.apply(void 0,[e].concat(r))}))};var n,r,o=e.produce(t,i,(function(t,e){n=t,r=e}));return"undefined"!=typeof Promise&&o instanceof Promise?o.then((function(t){return[t,n,r]})):[o,n,r]},"boolean"==typeof(null==t?void 0:t.useProxies)&&this.setUseProxies(t.useProxies),"boolean"==typeof(null==t?void 0:t.autoFreeze)&&this.setAutoFreeze(t.autoFreeze)}var e=t.prototype;return e.createDraft=function(t){ft(t)||at(8),lt(t)&&(t=Bt(t));var e=Mt(this),i=Lt(this,t,void 0);return i[Xt].C=!0,Ct(e),i},e.finishDraft=function(t,e){var i=(t&&t[Xt]).A;return St(i,e),Ut(void 0,i)},e.setAutoFreeze=function(t){this.F=t},e.setUseProxies=function(t){t&&!Vt&&at(20),this.g=t},e.applyPatches=function(t,e){var i;for(i=e.length-1;i>=0;i--){var n=e[i];if(0===n.path.length&&"replace"===n.op){t=n.value;break}}i>-1&&(e=e.slice(i+1));var r=jt("Patches").$;return lt(t)?r(t,e):this.produce(t,(function(t){return r(t,e)}))},t}(),re=new ne,oe=re.produce;re.produceWithPatches.bind(re),re.setAutoFreeze.bind(re),re.setUseProxies.bind(re),re.applyPatches.bind(re),re.createDraft.bind(re),re.finishDraft.bind(re);var se=oe;function ue(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function ce(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),i.push.apply(i,n)}return i}function ae(t){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?ce(Object(i),!0).forEach((function(e){ue(t,e,i[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):ce(Object(i)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))}))}return t}function le(t){return"Minified Redux error #"+t+"; visit https://redux.js.org/Errors?code="+t+" for the full message or use the non-minified dev environment for full errors. "}var fe="function"==typeof Symbol&&Symbol.observable||"@@observable",he=function(){return Math.random().toString(36).substring(7).split("").join(".")},de={INIT:"@@redux/INIT"+he(),REPLACE:"@@redux/REPLACE"+he(),PROBE_UNKNOWN_ACTION:function(){return"@@redux/PROBE_UNKNOWN_ACTION"+he()}};function ve(t){if("object"!=typeof t||null===t)return!1;for(var e=t;null!==Object.getPrototypeOf(e);)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e}function pe(t,e,i){var n;if("function"==typeof e&&"function"==typeof i||"function"==typeof i&&"function"==typeof arguments[3])throw new Error(le(0));if("function"==typeof e&&void 0===i&&(i=e,e=void 0),void 0!==i){if("function"!=typeof i)throw new Error(le(1));return i(pe)(t,e)}if("function"!=typeof t)throw new Error(le(2));var r=t,o=e,s=[],u=s,c=!1;function a(){u===s&&(u=s.slice())}function l(){if(c)throw new Error(le(3));return o}function f(t){if("function"!=typeof t)throw new Error(le(4));if(c)throw new Error(le(5));var e=!0;return a(),u.push(t),function(){if(e){if(c)throw new Error(le(6));e=!1,a();var i=u.indexOf(t);u.splice(i,1),s=null}}}function h(t){if(!ve(t))throw new Error(le(7));if(void 0===t.type)throw new Error(le(8));if(c)throw new Error(le(9));try{c=!0,o=r(o,t)}finally{c=!1}for(var e=s=u,i=0;i<e.length;i++){(0,e[i])()}return t}function d(t){if("function"!=typeof t)throw new Error(le(10));r=t,h({type:de.REPLACE})}function v(){var t,e=f;return(t={subscribe:function(t){if("object"!=typeof t||null===t)throw new Error(le(11));function i(){t.next&&t.next(l())}return i(),{unsubscribe:e(i)}}})[fe]=function(){return this},t}return h({type:de.INIT}),(n={dispatch:h,subscribe:f,getState:l,replaceReducer:d})[fe]=v,n}function be(t){for(var e=Object.keys(t),i={},n=0;n<e.length;n++){var r=e[n];"function"==typeof t[r]&&(i[r]=t[r])}var o,s=Object.keys(i);try{!function(t){Object.keys(t).forEach((function(e){var i=t[e];if(void 0===i(void 0,{type:de.INIT}))throw new Error(le(12));if(void 0===i(void 0,{type:de.PROBE_UNKNOWN_ACTION()}))throw new Error(le(13))}))}(i)}catch(t){o=t}return function(t,e){if(void 0===t&&(t={}),o)throw o;for(var n=!1,r={},u=0;u<s.length;u++){var c=s[u],a=i[c],l=t[c],f=a(l,e);if(void 0===f)throw e&&e.type,new Error(le(14));r[c]=f,n=n||f!==l}return(n=n||s.length!==Object.keys(t).length)?r:t}}function we(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];return 0===e.length?function(t){return t}:1===e.length?e[0]:e.reduce((function(t,e){return function(){return t(e.apply(void 0,arguments))}}))}function ye(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];return function(t){return function(){var i=t.apply(void 0,arguments),n=function(){throw new Error(le(15))},r={getState:i.getState,dispatch:function(){return n.apply(void 0,arguments)}},o=e.map((function(t){return t(r)}));return n=we.apply(void 0,o)(i.dispatch),ae(ae({},i),{},{dispatch:n})}}}function me(t){return function(e){var i=e.dispatch,n=e.getState;return function(e){return function(r){return"function"==typeof r?r(i,n,t):e(r)}}}}var ge=me();ge.withExtraArgument=me;var xe,Oe=ge,Ee=(xe=function(t,e){return xe=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])},xe(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}xe(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}),je=function(t,e){for(var i=0,n=e.length,r=t.length;i<n;i++,r++)t[r]=e[i];return t},Ne=Object.defineProperty,Se=Object.getOwnPropertySymbols,Re=Object.prototype.hasOwnProperty,Ce=Object.prototype.propertyIsEnumerable,Me=function(t,e,i){return e in t?Ne(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i},Ae=function(t,e){for(var i in e||(e={}))Re.call(e,i)&&Me(t,i,e[i]);if(Se)for(var n=0,r=Se(e);n<r.length;n++){i=r[n];Ce.call(e,i)&&Me(t,i,e[i])}return t},Ue="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(0!==arguments.length)return"object"==typeof arguments[0]?we:we.apply(null,arguments)};var Te=function(t){function e(){for(var i=[],n=0;n<arguments.length;n++)i[n]=arguments[n];var r=t.apply(this,i)||this;return Object.setPrototypeOf(r,e.prototype),r}return Ee(e,t),Object.defineProperty(e,Symbol.species,{get:function(){return e},enumerable:!1,configurable:!0}),e.prototype.concat=function(){for(var e=[],i=0;i<arguments.length;i++)e[i]=arguments[i];return t.prototype.concat.apply(this,e)},e.prototype.prepend=function(){for(var t=[],i=0;i<arguments.length;i++)t[i]=arguments[i];return 1===t.length&&Array.isArray(t[0])?new(e.bind.apply(e,je([void 0],t[0].concat(this)))):new(e.bind.apply(e,je([void 0],t.concat(this))))},e}(Array);function $e(t){return ft(t)?se(t,(function(){})):t}function Ie(){return function(t){return function(t){void 0===t&&(t={});var e=t.thunk,i=void 0===e||e;t.immutableCheck,t.serializableCheck;var n=new Te;i&&(!function(t){return"boolean"==typeof t}(i)?n.push(Oe.withExtraArgument(i.extraArgument)):n.push(Oe));return n}(t)}}function ke(t){var e,i=Ie(),n=t||{},r=n.reducer,o=void 0===r?void 0:r,s=n.middleware,u=void 0===s?i():s,c=n.devTools,a=void 0===c||c,l=n.preloadedState,f=void 0===l?void 0:l,h=n.enhancers,d=void 0===h?void 0:h;if("function"==typeof o)e=o;else{if(!function(t){if("object"!=typeof t||null===t)return!1;var e=Object.getPrototypeOf(t);if(null===e)return!0;for(var i=e;null!==Object.getPrototypeOf(i);)i=Object.getPrototypeOf(i);return e===i}(o))throw new Error('"reducer" is a required argument, and must be a function or an object of functions that can be passed to combineReducers');e=be(o)}var v=u;"function"==typeof v&&(v=v(i));var p=ye.apply(void 0,v),b=we;a&&(b=Ue(Ae({trace:!1},"object"==typeof a&&a)));var w=[p];return Array.isArray(d)?w=je([p],d):"function"==typeof d&&(w=d(w)),pe(e,f,b.apply(void 0,w))}function Pe(t,e){function i(){for(var i=[],n=0;n<arguments.length;n++)i[n]=arguments[n];if(e){var r=e.apply(void 0,i);if(!r)throw new Error("prepareAction did not return an object");return Ae(Ae({type:t,payload:r.payload},"meta"in r&&{meta:r.meta}),"error"in r&&{error:r.error})}return{type:t,payload:i[0]}}return i.toString=function(){return""+t},i.type=t,i.match=function(e){return e.type===t},i}function Fe(t){var e,i={},n=[],r={addCase:function(t,e){var n="string"==typeof t?t:t.type;if(n in i)throw new Error("addCase cannot be called with two reducers for the same action type");return i[n]=e,r},addMatcher:function(t,e){return n.push({matcher:t,reducer:e}),r},addDefaultCase:function(t){return e=t,r}};return t(r),[i,n,e]}function _e(t){var e=t.name;if(!e)throw new Error("`name` is a required option for createSlice");var i,n="function"==typeof t.initialState?t.initialState:$e(t.initialState),r=t.reducers||{},o=Object.keys(r),s={},u={},c={};function a(){var e="function"==typeof t.extraReducers?Fe(t.extraReducers):[t.extraReducers],i=e[0],r=void 0===i?{}:i,o=e[1],s=void 0===o?[]:o,c=e[2],a=void 0===c?void 0:c,l=Ae(Ae({},r),u);return function(t,e,i,n){void 0===i&&(i=[]);var r,o="function"==typeof e?Fe(e):[e,i,n],s=o[0],u=o[1],c=o[2];if(function(t){return"function"==typeof t}(t))r=function(){return $e(t())};else{var a=$e(t);r=function(){return a}}function l(t,e){void 0===t&&(t=r());var i=je([s[e.type]],u.filter((function(t){return(0,t.matcher)(e)})).map((function(t){return t.reducer})));return 0===i.filter((function(t){return!!t})).length&&(i=[c]),i.reduce((function(t,i){if(i){var n;if(lt(t))return void 0===(n=i(t,e))?t:n;if(ft(t))return se(t,(function(t){return i(t,e)}));if(void 0===(n=i(t,e))){if(null===t)return t;throw Error("A case reducer on a non-draftable value must not return undefined")}return n}return t}),t)}return l.getInitialState=r,l}(n,l,s,a)}return o.forEach((function(t){var i,n,o=r[t],a=e+"/"+t;"reducer"in o?(i=o.reducer,n=o.prepare):i=o,s[t]=i,u[a]=i,c[t]=n?Pe(a,n):Pe(a)})),{name:e,reducer:function(t,e){return i||(i=a()),i(t,e)},actions:c,caseReducers:s,getInitialState:function(){return i||(i=a()),i.getInitialState()}}}var Le="listenerMiddleware";Pe(Le+"/add"),Pe(Le+"/removeAll"),Pe(Le+"/remove"),function(){function t(t,e){var i=r[t];return i?i.enumerable=e:r[t]=i={configurable:!0,enumerable:e,get:function(){var e=this[Xt];return ee.get(e,t)},set:function(e){var i=this[Xt];ee.set(i,t,e)}},i}function e(t){for(var e=t.length-1;e>=0;e--){var r=t[e][Xt];if(!r.P)switch(r.i){case 5:n(r)&&Ft(r);break;case 4:i(r)&&Ft(r)}}}function i(t){for(var e=t.t,i=t.k,n=Yt(i),r=n.length-1;r>=0;r--){var o=n[r];if(o!==Xt){var s=e[o];if(void 0===s&&!vt(e,o))return!0;var u=i[o],c=u&&u[Xt];if(c?c.t!==s:!bt(u,s))return!0}}var a=!!e[Xt];return n.length!==Yt(e).length+(a?0:1)}function n(t){var e=t.k;if(e.length!==t.t.length)return!0;var i=Object.getOwnPropertyDescriptor(e,e.length-1);if(i&&!i.get)return!0;for(var n=0;n<e.length;n++)if(!e.hasOwnProperty(n))return!0;return!1}var r={};!function(t,e){te[t]||(te[t]=e)}("ES5",{J:function(e,i){var n=Array.isArray(e),r=function(e,i){if(e){for(var n=Array(i.length),r=0;r<i.length;r++)Object.defineProperty(n,""+r,t(r,!0));return n}var o=Qt(i);delete o[Xt];for(var s=Yt(o),u=0;u<s.length;u++){var c=s[u];o[c]=t(c,e||!!o[c].enumerable)}return Object.create(Object.getPrototypeOf(i),o)}(n,e),o={i:n?5:4,A:i?i.A:Nt(),P:!1,I:!1,D:{},l:i,t:e,k:r,o:null,O:!1,C:!1};return Object.defineProperty(r,Xt,{value:o,writable:!0}),r},S:function(t,i,r){r?lt(i)&&i[Xt].A===t&&e(t.p):(t.u&&function t(e){if(e&&"object"==typeof e){var i=e[Xt];if(i){var r=i.t,o=i.k,s=i.D,u=i.i;if(4===u)ht(o,(function(e){e!==Xt&&(void 0!==r[e]||vt(r,e)?s[e]||t(o[e]):(s[e]=!0,Ft(i)))})),ht(r,(function(t){void 0!==o[t]||vt(o,t)||(s[t]=!1,Ft(i))}));else if(5===u){if(n(i)&&(Ft(i),s.length=!0),o.length<r.length)for(var c=o.length;c<r.length;c++)s[c]=!1;else for(var a=r.length;a<o.length;a++)s[a]=!0;for(var l=Math.min(o.length,r.length),f=0;f<l;f++)o.hasOwnProperty(f)||(s[f]=!0),void 0===s[f]&&t(o[f])}}}}(t.p[0]),e(t.p))},K:function(t){return 4===t.i?i(t):n(t)}})}();const Be=(t,e)=>(i,n)=>{i.constructor.createProperty(n,{attribute:!1,hasChanged:null!=e?e:(t,e)=>!o(t,e)});const r=i;r.reduxProperties=r.reduxProperties||new Map,r.reduxProperties.set(n,null!=t?t:t=>t[n])};class We extends ct{get store(){return this.internalStore}set store(t){this.internalStore=t,this.store&&this.setupStore()}updateFromStore(){const t=this.store.getState();this.reduxProperties&&this.reduxProperties.forEach(((e,i)=>{this[i]=e(t,this)}))}setupStore(){this.unsubscribeFromStore&&this.unsubscribeFromStore(),this.updateFromStore(),this.unsubscribeFromStore=this.store.subscribe((()=>{this.updateFromStore()})),this.onStoreAvailable(),this.requestUpdate()}onStoreAvailable(){}connectedCallback(){super.connectedCallback(),this.store&&this.setupStore()}disconnectedCallback(){this.unsubscribeFromStore&&this.unsubscribeFromStore(),super.disconnectedCallback()}}var De,Ke;navigator.vendor&&navigator.vendor.match(/apple/i)||(null===(Ke=null===(De=window.safari)||void 0===De?void 0:De.pushNotification)||void 0===Ke||Ke.toString());const He={setBaseUrl:(t,e)=>{t.baseUrl=e.payload},setApiIntegrationIdentifier:(t,e)=>{t.apiIntegrationIdentifier=e.payload},setMapId:(t,e)=>{t.mapId=e.payload},setTocId:(t,e)=>{t.tocId=e.payload},setMap:(t,e)=>{t.map=e.payload},setToc:(t,e)=>{t.toc=e.payload},setCurrentPage:(t,e)=>{t.currentPage=e.payload},setScrollTarget:(t,e)=>{t.scrollTarget=e.payload},setVisibleTopics:(t,e)=>{t.visibleTopics=e.payload}};class ze{convertNodes(t){var e,i,n,r;const o={},s=new Set,u=new Set,c=[],a=(t,e,i)=>t.map((t=>{var n;t.page&&c.push(t.tocId);let r=null===(n=t.prettyUrl)||void 0===n?void 0:n.replace(/^\//,"");const l={...t,prettyUrl:r,depth:e,parentTocId:i,children:a(t.children,e+1,t.tocId)};return r&&(s.has(r)&&u.add(r),s.add(r)),o[t.tocId]=l,l})),l=a(null!=t?t:[],1),f=this.buildPages(c,o);let h={};return 0===f.length?f.push({number:1,title:null!==(i=null===(e=l[0])||void 0===e?void 0:e.title)&&void 0!==i?i:"",rootTocId:null!==(r=null===(n=l[0])||void 0===n?void 0:n.tocId)&&void 0!==r?r:"root",toc:[],topics:this.tocIds(l),hiddenTopics:[]}):h=this.indexPages(f),{toc:l,nodeByTocId:o,duplicatedPrettyUrls:u,pages:f,pageByTocId:h}}tocIds(t){return t.flatMap((t=>[t.tocId,...this.tocIds(t.children)]))}buildPages(t,e){const i=t=>t.parentTocId?[...i(e[t.parentTocId]),t.parentTocId]:[];return t.map((t=>e[t])).map(((t,e)=>{var n,r,o,s,u;const c={number:e+1,title:t.title,rootTocId:t.tocId,toc:(null===(n=t.page)||void 0===n?void 0:n.onItsOwn)?[]:t.children,topics:[],hiddenTopics:[]},a=(t,e)=>(e?c.topics:c.hiddenTopics).push(t),l=null!==(o=null===(r=t.page)||void 0===r?void 0:r.parentsVisibility)&&void 0!==o?o:[];return i(t).forEach(((t,e)=>{a(t,l[e])})),a(t.tocId,null===(s=t.page)||void 0===s?void 0:s.visible),(null===(u=t.page)||void 0===u?void 0:u.onItsOwn)||c.topics.push(...this.tocIds(t.children)),c}))}indexPages(t){const e={};for(let i of t)for(let t of[...i.topics,...i.hiddenTopics])e[t]||(e[t]=i);return e}}class Je{constructor(t,e,i,n){this.converter=t,this.api=e,this.baseUrl=i,this.mapId=n,this.topics={},this.topicContents={},i.endsWith("/")||(this.baseUrl=i+"/")}static build(t,e,i){if(null==window.fluidtopics)throw console.error("Fluid Topics public API was not found. You can find it here: https://www.npmjs.com/package/@fluid-topics/public-api"),new Error("Fluid Topics public API not found");return new Je(new ze,new window.fluidtopics.FluidTopicsApi(t,e,!0),t,i)}clear(){this.map=void 0,this.enrichedToc=void 0,this.topics={},this.topicContents={}}getMap(){return this.loadIfNeeded((()=>this.map),(t=>this.map=t),(()=>this.api.getMap(this.mapId)))}getEnrichedToc(){return this.loadIfNeeded((()=>this.enrichedToc),(t=>this.enrichedToc=t),(()=>this.api.getTableOfContent(this.mapId).then((t=>this.converter.convertNodes(t)))))}async getToc(){return(await this.getEnrichedToc()).toc}async getTocNode(t){return(await this.getEnrichedToc()).nodeByTocId[t]}async getPage(t){const e=await this.getEnrichedToc();return e.pages[t-1]||e.pages[0]}async getPageByTocId(t){const e=await this.getEnrichedToc();return e.pageByTocId[t]||e.pages[0]}getTopicInfo(t){return this.loadIfNeeded((()=>this.topics[t]),(e=>this.topics[t]=e),(()=>this.api.getTopic(this.mapId,t)))}getTopicContent(t){return this.loadIfNeeded((()=>this.topicContents[t]),(e=>this.topicContents[t]=e),(()=>this.api.getTopicHTMLContent(this.mapId,t,"DESIGNED_READER")))}getLink(t,e,i){const n=this.getNavigationData(t,e,i),r="r/"+(n.prettyUrl?n.prettyUrl:`${n.mapId}/${n.tocId}`),o=new URL(r,this.baseUrl);return null!=n.page&&o.searchParams.set("page",`${n.page}`),n.prettyUrlDuplicated&&o.searchParams.set("tocId",n.tocId),null!=n.section&&o.searchParams.set("section",n.section),o.href}getNavigationData(t,e,i){var n,r;t=t||"root";const o="object"==typeof this.enrichedToc?this.enrichedToc:void 0,s=null==o?void 0:o.pageByTocId[t],u=null===(n=null==o?void 0:o.nodeByTocId[t])||void 0===n?void 0:n.prettyUrl;return{mapId:this.mapId,tocId:t,page:e&&s&&s.number!==e?e:void 0,prettyUrl:null!=u?u.replace(/^r\//,""):void 0,prettyUrlDuplicated:null!==(r=null==o?void 0:o.duplicatedPrettyUrls.has(null!=u?u:""))&&void 0!==r&&r,section:i}}async loadIfNeeded(t,e,i){for(void 0===t()&&(e(!0),e(await i().catch((t=>(console.error(t),!1)))));!0===t();)await s(10);const n=t();if(!1===n)throw new Error("Could not load data");return n}}class Ve{constructor(t,i){this.store=t,this.slice=i,this.reloadDebouncer=new e(10)}static build(t){const e=(t=>_e({name:"ft-reader-"+t,initialState:{baseUrl:"",apiIntegrationIdentifier:"ft-reader",visibleTopics:[]},reducers:He}))(t.trim()||"context");return new Ve(function(t,e,i){window.ftReduxStores||(window.ftReduxStores={});const n=e||t.name;return window.ftReduxStores[n]||(window.ftReduxStores[n]=ke({reducer:t.reducer})),window.ftReduxStores[n]}(e),e)}setBaseUrl(t){this.setRequiredStateField("baseUrl","setBaseUrl",t)}setApiIntegrationIdentifier(t){this.setRequiredStateField("apiIntegrationIdentifier","setApiIntegrationIdentifier",t)}setMapId(t){this.setRequiredStateField("mapId","setMapId",t)}setVisibleTopics(t){this.dispatch(this.slice.actions.setVisibleTopics(t))}async navigateToTopic(t,e,i){for(;null===this.service;)await s(5);let n=null!=i?await this.service.getPage(i):await this.service.getPageByTocId(t);this.dispatch(this.slice.actions.setCurrentPage(n),this.slice.actions.setScrollTarget({tocId:t,section:e}))}async navigateToPage(t){for(;null===this.service;)await s(5);let e=await this.service.getPage(t);this.dispatch(this.slice.actions.setCurrentPage(e))}scrollDone(){this.dispatch(this.slice.actions.setScrollTarget({}))}setRequiredStateField(t,e,i){this.store.getState()[t]!==i&&(this.dispatch(this.slice.actions[e](i)),this.clearAll(),this.reload())}clearAll(){this.dispatch(this.slice.actions.setMap(void 0),this.slice.actions.setToc(void 0),this.slice.actions.setCurrentPage(void 0))}reload(){const t=this.store.getState();t.baseUrl&&t.apiIntegrationIdentifier&&t.mapId?this.service=Je.build(t.baseUrl,t.apiIntegrationIdentifier,t.mapId):this.service=void 0,this.reloadDebouncer.run((async()=>{this.reloadMap(),this.reloadToc()}))}async reloadMap(){var t;const e=await(null===(t=this.service)||void 0===t?void 0:t.getMap());this.dispatch(this.slice.actions.setMap(e))}async reloadToc(){var t;const e=await(null===(t=this.service)||void 0===t?void 0:t.getToc());this.dispatch(this.slice.actions.setToc(e))}dispatch(...t){for(let e of t)this.store.dispatch(e)}}var Ze,qe=function(t,e,i,n){for(var r,o=arguments.length,s=o<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n,u=t.length-1;u>=0;u--)(r=t[u])&&(s=(o<3?r(s):o>3?r(e,i,s):r(e,i))||s);return o>3&&s&&Object.defineProperty(e,i,s),s};class Xe extends CustomEvent{constructor(t){super("ft-reader-map-loaded",{detail:t})}}class Ge extends CustomEvent{constructor(t,e){super("ft-reader-visible-topics-change",{detail:{visibleTopics:e}})}}class Ye extends CustomEvent{constructor(t){super("ft-reader-navigation-done",{detail:t})}}class Qe extends We{constructor(){super(...arguments),this.apiIntegrationIdentifier="ft-reader",this.visibleTopics=[]}render(){return B`
|
|
70
70
|
<slot @register-ft-reader-component=${this.registerComponent}></slot>
|
|
71
|
-
`}get stateManager(){return null==this._stateManager&&(this._stateManager=Ve.build(this.id||""+Math.round(1e4*Math.random())),this.store=this.stateManager.store),this._stateManager}updated(t){super.updated(t),t.has("baseUrl")&&this.baseUrl&&this.stateManager.setBaseUrl(this.baseUrl),t.has("apiIntegrationIdentifier")&&this.stateManager.setApiIntegrationIdentifier(this.apiIntegrationIdentifier),t.has("mapId")&&this.mapId&&(this.stateManager.setMapId(this.mapId),this.stateManager.navigateToTopic("root")),t.has("page")&&!this.tocId&&null!=this.page&&this.stateManager.navigateToPage(this.page),(t.has("tocId")||t.has("section")||t.has("page"))&&this.tocId&&this.stateManager.navigateToTopic(this.tocId,this.section,this.page)}contentAvailableCallback(t){super.contentAvailableCallback(t),(t.has("map")||t.has("toc"))&&this.map&&this.toc&&this.dispatchEvent(new Xe(this.map)),t.has("visibleTopics")&&Promise.all(this.visibleTopics.map((t=>this.stateManager.service.getTocNode(t)))).then((t=>{let e=t.map((t=>({tocId:t.tocId,title:t.title}))
|
|
72
|
-
`,qe([n()],
|
|
71
|
+
`}get stateManager(){return null==this._stateManager&&(this._stateManager=Ve.build(this.id||""+Math.round(1e4*Math.random())),this.store=this.stateManager.store),this._stateManager}updated(t){super.updated(t),t.has("baseUrl")&&this.baseUrl&&this.stateManager.setBaseUrl(this.baseUrl),t.has("apiIntegrationIdentifier")&&this.stateManager.setApiIntegrationIdentifier(this.apiIntegrationIdentifier),t.has("mapId")&&this.mapId&&(this.stateManager.setMapId(this.mapId),this.stateManager.navigateToTopic("root")),t.has("page")&&!this.tocId&&null!=this.page&&this.stateManager.navigateToPage(this.page),(t.has("tocId")||t.has("section")||t.has("page"))&&this.tocId&&this.stateManager.navigateToTopic(this.tocId,this.section,this.page)}contentAvailableCallback(t){var e;if(super.contentAvailableCallback(t),(t.has("map")||t.has("toc"))&&this.map&&this.toc&&this.dispatchEvent(new Xe(this.map)),t.has("scrollTarget")&&null==(null===(e=this.scrollTarget)||void 0===e?void 0:e.tocId)){const e=t.get("scrollTarget");null!=(null==e?void 0:e.tocId)&&this.dispatchEvent(new Ye(this.stateManager.service.getNavigationData(e.tocId,this.currentPageNumber,e.section)))}t.has("visibleTopics")&&Promise.all(this.visibleTopics.map((t=>this.stateManager.service.getTocNode(t)))).then((t=>{let e=t.filter((t=>null!=t)).map((t=>{const e=this.stateManager.service.getNavigationData(t.tocId,this.currentPageNumber);return{tocId:t.tocId,title:t.title,page:e.page,prettyUrl:e.prettyUrl,prettyUrlDuplicated:e.prettyUrlDuplicated}}));this.dispatchEvent(new Ge(this.map,e))}))}navigateToTarget(){null!=this.tocId?this.stateManager.navigateToTopic(this.tocId,this.section,this.page):null!=this.page&&this.stateManager.navigateToPage(this.page)}registerComponent(t){t.stopPropagation();t.composedPath()[0].setReaderStateManager(this.stateManager)}}Qe.styles=h`
|
|
72
|
+
`,qe([n()],Qe.prototype,"baseUrl",void 0),qe([n()],Qe.prototype,"apiIntegrationIdentifier",void 0),qe([n()],Qe.prototype,"mapId",void 0),qe([n()],Qe.prototype,"tocId",void 0),qe([n()],Qe.prototype,"section",void 0),qe([n({type:Number,converter:{fromAttribute:t=>t?+t:void 0}})],Qe.prototype,"page",void 0),qe([Be()],Qe.prototype,"map",void 0),qe([Be()],Qe.prototype,"toc",void 0),qe([Be()],Qe.prototype,"visibleTopics",void 0),qe([Be((t=>{var e;return null===(e=t.currentPage)||void 0===e?void 0:e.number}))],Qe.prototype,"currentPageNumber",void 0),qe([Be()],Qe.prototype,"scrollTarget",void 0),(Ze="ft-reader-context",t=>{window.customElements.get(Ze)||window.customElements.define(Ze,t)})(Qe),t.FtReaderContext=Qe,t.MapLoadedEvent=Xe,t.NavigationDoneEvent=Ye,t.VisibleTopicsChangeEvent=Ge,Object.defineProperty(t,"U",{value:!0})}({});
|
|
@@ -28,7 +28,6 @@ export class FtReaderStateManager {
|
|
|
28
28
|
await delay(5);
|
|
29
29
|
}
|
|
30
30
|
let page = pageNumber != null ? await this.service.getPage(pageNumber) : await this.service.getPageByTocId(tocId);
|
|
31
|
-
console.log(pageNumber, page);
|
|
32
31
|
this.dispatch(this.slice.actions.setCurrentPage(page), this.slice.actions.setScrollTarget({ tocId, section }));
|
|
33
32
|
}
|
|
34
33
|
async navigateToPage(pageNumber) {
|
package/build/store/model.d.ts
CHANGED
|
@@ -32,4 +32,12 @@ export interface FtReaderState {
|
|
|
32
32
|
scrollTarget?: FtReaderScrollTarget;
|
|
33
33
|
visibleTopics: string[];
|
|
34
34
|
}
|
|
35
|
+
export interface FtReaderNavigationData {
|
|
36
|
+
mapId: string;
|
|
37
|
+
tocId: string;
|
|
38
|
+
section?: string;
|
|
39
|
+
page?: number;
|
|
40
|
+
prettyUrl?: string;
|
|
41
|
+
prettyUrlDuplicated: boolean;
|
|
42
|
+
}
|
|
35
43
|
//# sourceMappingURL=model.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { FluidTopicsApi, FtMap, FtTopic } from "@fluid-topics/public-api";
|
|
2
|
-
import { FtReaderPage, FtReaderTocNode } from "../model";
|
|
2
|
+
import { FtReaderNavigationData, FtReaderPage, FtReaderTocNode } from "../model";
|
|
3
3
|
import { FtReaderConverter } from "./FtReaderConverter";
|
|
4
4
|
declare global {
|
|
5
5
|
interface Window {
|
|
@@ -29,6 +29,7 @@ export declare class FtReaderService {
|
|
|
29
29
|
private topicContents;
|
|
30
30
|
getTopicContent(contentId: string): Promise<string>;
|
|
31
31
|
getLink(tocId?: string, pageNumber?: number, section?: string): string;
|
|
32
|
+
getNavigationData(tocId?: string, pageNumber?: number, section?: string): FtReaderNavigationData;
|
|
32
33
|
private loadIfNeeded;
|
|
33
34
|
}
|
|
34
35
|
//# sourceMappingURL=FtReaderService.d.ts.map
|
|
@@ -55,24 +55,35 @@ export class FtReaderService {
|
|
|
55
55
|
return this.loadIfNeeded(() => this.topicContents[contentId], v => this.topicContents[contentId] = v, () => this.api.getTopicHTMLContent(this.mapId, contentId, "DESIGNED_READER"));
|
|
56
56
|
}
|
|
57
57
|
getLink(tocId, pageNumber, section) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
let url = new URL(path, this.baseUrl);
|
|
64
|
-
let page = enrichedToc === null || enrichedToc === void 0 ? void 0 : enrichedToc.pageByTocId[tocId];
|
|
65
|
-
if (pageNumber && page && page.number !== pageNumber) {
|
|
66
|
-
url.searchParams.set("page", `${pageNumber}`);
|
|
58
|
+
const navigationData = this.getNavigationData(tocId, pageNumber, section);
|
|
59
|
+
const path = "r/" + (navigationData.prettyUrl ? navigationData.prettyUrl : `${navigationData.mapId}/${navigationData.tocId}`);
|
|
60
|
+
const url = new URL(path, this.baseUrl);
|
|
61
|
+
if (navigationData.page != null) {
|
|
62
|
+
url.searchParams.set("page", `${navigationData.page}`);
|
|
67
63
|
}
|
|
68
|
-
if (
|
|
69
|
-
url.searchParams.set("tocId", tocId);
|
|
64
|
+
if (navigationData.prettyUrlDuplicated) {
|
|
65
|
+
url.searchParams.set("tocId", navigationData.tocId);
|
|
70
66
|
}
|
|
71
|
-
if (section) {
|
|
72
|
-
url.searchParams.set("section", section);
|
|
67
|
+
if (navigationData.section != null) {
|
|
68
|
+
url.searchParams.set("section", navigationData.section);
|
|
73
69
|
}
|
|
74
70
|
return url.href;
|
|
75
71
|
}
|
|
72
|
+
getNavigationData(tocId, pageNumber, section) {
|
|
73
|
+
var _a, _b;
|
|
74
|
+
tocId = tocId || "root";
|
|
75
|
+
const enrichedToc = typeof this.enrichedToc === "object" ? this.enrichedToc : undefined;
|
|
76
|
+
const page = enrichedToc === null || enrichedToc === void 0 ? void 0 : enrichedToc.pageByTocId[tocId];
|
|
77
|
+
const prettyUrl = (_a = enrichedToc === null || enrichedToc === void 0 ? void 0 : enrichedToc.nodeByTocId[tocId]) === null || _a === void 0 ? void 0 : _a.prettyUrl;
|
|
78
|
+
return {
|
|
79
|
+
mapId: this.mapId,
|
|
80
|
+
tocId,
|
|
81
|
+
page: pageNumber && page && page.number !== pageNumber ? pageNumber : undefined,
|
|
82
|
+
prettyUrl: prettyUrl != null ? prettyUrl.replace(/^r\//, "") : undefined,
|
|
83
|
+
prettyUrlDuplicated: (_b = enrichedToc === null || enrichedToc === void 0 ? void 0 : enrichedToc.duplicatedPrettyUrls.has(prettyUrl !== null && prettyUrl !== void 0 ? prettyUrl : "")) !== null && _b !== void 0 ? _b : false,
|
|
84
|
+
section: section
|
|
85
|
+
};
|
|
86
|
+
}
|
|
76
87
|
async loadIfNeeded(get, set, load) {
|
|
77
88
|
if (get() === undefined) {
|
|
78
89
|
set(true);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluid-topics/ft-reader-context",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.9",
|
|
4
4
|
"description": "Context block for integrated reader components",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Lit"
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"url": "ssh://git@scm.mrs.antidot.net:2222/fluidtopics/ft-web-components.git"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@fluid-topics/ft-wc-utils": "0.3.
|
|
22
|
+
"@fluid-topics/ft-wc-utils": "0.3.9",
|
|
23
23
|
"@reduxjs/toolkit": "^1.6.2",
|
|
24
24
|
"lit": "2.2.8"
|
|
25
25
|
},
|
|
@@ -29,5 +29,5 @@
|
|
|
29
29
|
"peerDependencies": {
|
|
30
30
|
"@fluid-topics/public-api": "1.0.22"
|
|
31
31
|
},
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "b326dc3ac2a2e625407370a2fc240df938e0d09f"
|
|
33
33
|
}
|