@seatsio/seatsio-react 14.1.0 → 14.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/Embeddable.d.mts +29 -0
- package/build/Embeddable.d.ts +6 -3
- package/build/Embeddable.js +114 -88
- package/build/Embeddable.js.map +1 -0
- package/build/Embeddable.mjs +94 -0
- package/build/Embeddable.mjs.map +1 -0
- package/build/SeatsioDesigner.d.mts +10 -0
- package/build/SeatsioDesigner.d.ts +8 -3
- package/build/SeatsioDesigner.js +132 -5
- package/build/SeatsioDesigner.js.map +1 -0
- package/build/SeatsioDesigner.mjs +101 -0
- package/build/SeatsioDesigner.mjs.map +1 -0
- package/build/SeatsioEventManager.d.mts +10 -0
- package/build/SeatsioEventManager.d.ts +8 -3
- package/build/SeatsioEventManager.js +132 -5
- package/build/SeatsioEventManager.js.map +1 -0
- package/build/SeatsioEventManager.mjs +101 -0
- package/build/SeatsioEventManager.mjs.map +1 -0
- package/build/SeatsioSeatingChart.d.mts +10 -0
- package/build/SeatsioSeatingChart.d.ts +8 -3
- package/build/SeatsioSeatingChart.js +132 -5
- package/build/SeatsioSeatingChart.js.map +1 -0
- package/build/SeatsioSeatingChart.mjs +101 -0
- package/build/SeatsioSeatingChart.mjs.map +1 -0
- package/build/index.d.mts +7 -0
- package/build/index.d.ts +7 -4
- package/build/index.js +170 -4
- package/build/index.js.map +1 -0
- package/build/index.mjs +127 -0
- package/build/index.mjs.map +1 -0
- package/build/util.d.mts +12 -0
- package/build/util.d.ts +10 -7
- package/build/util.js +60 -21
- package/build/util.js.map +1 -0
- package/build/util.mjs +33 -0
- package/build/util.mjs.map +1 -0
- package/package.json +10 -3
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { SeatingChart, Region, CommonConfigOptions, Seatsio, EventManager, ChartDesigner } from '@seatsio/seatsio-types';
|
|
3
|
+
|
|
4
|
+
type EmbeddableProps<T> = {
|
|
5
|
+
onRenderStarted?: (chart: SeatingChart) => void;
|
|
6
|
+
chartJsUrl?: string;
|
|
7
|
+
region: Region;
|
|
8
|
+
} & T;
|
|
9
|
+
declare abstract class Embeddable<T extends CommonConfigOptions> extends React.Component<EmbeddableProps<T>> {
|
|
10
|
+
private container;
|
|
11
|
+
private rendering?;
|
|
12
|
+
private chart;
|
|
13
|
+
static defaultProps: {
|
|
14
|
+
chartJsUrl: string;
|
|
15
|
+
};
|
|
16
|
+
constructor(props: EmbeddableProps<T>);
|
|
17
|
+
abstract createChart(seatsio: Seatsio, config: T): SeatingChart | EventManager | ChartDesigner;
|
|
18
|
+
componentDidMount(): Promise<void>;
|
|
19
|
+
componentDidUpdate(prevProps: EmbeddableProps<T>): Promise<void>;
|
|
20
|
+
createAndRenderChart(): Promise<void>;
|
|
21
|
+
extractConfigFromProps(): any;
|
|
22
|
+
componentWillUnmount(): void;
|
|
23
|
+
destroyChart(): void;
|
|
24
|
+
getSeatsio(): Promise<any>;
|
|
25
|
+
loadSeatsio(): Promise<unknown>;
|
|
26
|
+
render(): React.ReactNode;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export { EmbeddableProps, Embeddable as default };
|
package/build/Embeddable.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import { SeatingChart, Region, CommonConfigOptions, Seatsio, EventManager, ChartDesigner } from '@seatsio/seatsio-types';
|
|
3
|
+
|
|
4
|
+
type EmbeddableProps<T> = {
|
|
4
5
|
onRenderStarted?: (chart: SeatingChart) => void;
|
|
5
6
|
chartJsUrl?: string;
|
|
6
7
|
region: Region;
|
|
7
8
|
} & T;
|
|
8
|
-
|
|
9
|
+
declare abstract class Embeddable<T extends CommonConfigOptions> extends React.Component<EmbeddableProps<T>> {
|
|
9
10
|
private container;
|
|
10
11
|
private rendering?;
|
|
11
12
|
private chart;
|
|
@@ -24,3 +25,5 @@ export default abstract class Embeddable<T extends CommonConfigOptions> extends
|
|
|
24
25
|
loadSeatsio(): Promise<unknown>;
|
|
25
26
|
render(): React.ReactNode;
|
|
26
27
|
}
|
|
28
|
+
|
|
29
|
+
export { EmbeddableProps, Embeddable as default };
|
package/build/Embeddable.js
CHANGED
|
@@ -1,98 +1,124 @@
|
|
|
1
|
-
var
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
10
|
};
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
for (
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
t[p[i]] = s[p[i]];
|
|
18
|
-
}
|
|
19
|
-
return t;
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
20
18
|
};
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/main/Embeddable.tsx
|
|
30
|
+
var Embeddable_exports = {};
|
|
31
|
+
__export(Embeddable_exports, {
|
|
32
|
+
default: () => Embeddable
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(Embeddable_exports);
|
|
35
|
+
var React = __toESM(require("react"));
|
|
36
|
+
|
|
37
|
+
// src/main/util.ts
|
|
38
|
+
var didPropsChange = (prevProps, nextProps) => {
|
|
39
|
+
if (Object.keys(prevProps).length !== Object.keys(nextProps).length) {
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
return Object.keys(nextProps).some((propName) => {
|
|
43
|
+
let prevValue = prevProps[propName];
|
|
44
|
+
let nextValue = nextProps[propName];
|
|
45
|
+
if (prevValue && nextValue) {
|
|
46
|
+
if (typeof prevValue === "function" && typeof nextValue === "function") {
|
|
47
|
+
return prevValue.toString() !== nextValue.toString();
|
|
48
|
+
}
|
|
49
|
+
if (typeof prevValue === "object" && typeof nextValue === "object") {
|
|
50
|
+
return didPropsChange(prevValue, nextValue);
|
|
51
|
+
}
|
|
53
52
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
53
|
+
return prevValue !== nextValue;
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
// src/main/Embeddable.tsx
|
|
58
|
+
var Embeddable = class extends React.Component {
|
|
59
|
+
constructor(props) {
|
|
60
|
+
super(props);
|
|
61
|
+
this.container = React.createRef();
|
|
62
|
+
}
|
|
63
|
+
async componentDidMount() {
|
|
64
|
+
if (!this.rendering) {
|
|
65
|
+
this.rendering = this.createAndRenderChart();
|
|
61
66
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
67
|
+
}
|
|
68
|
+
async componentDidUpdate(prevProps) {
|
|
69
|
+
if (didPropsChange(this.props, prevProps) && this.chart) {
|
|
70
|
+
this.destroyChart();
|
|
71
|
+
this.createAndRenderChart();
|
|
66
72
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
else {
|
|
76
|
-
return Promise.resolve(seatsio);
|
|
77
|
-
}
|
|
73
|
+
}
|
|
74
|
+
async createAndRenderChart() {
|
|
75
|
+
const seatsio2 = await this.getSeatsio();
|
|
76
|
+
const config = this.extractConfigFromProps();
|
|
77
|
+
config.container = this.container.current;
|
|
78
|
+
this.chart = this.createChart(seatsio2, config).render();
|
|
79
|
+
if (this.props.onRenderStarted) {
|
|
80
|
+
this.props.onRenderStarted(this.chart);
|
|
78
81
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
82
|
+
}
|
|
83
|
+
extractConfigFromProps() {
|
|
84
|
+
let { chartJsUrl, divId, onRenderStarted, region, ...config } = this.props;
|
|
85
|
+
return config;
|
|
86
|
+
}
|
|
87
|
+
componentWillUnmount() {
|
|
88
|
+
this.destroyChart();
|
|
89
|
+
}
|
|
90
|
+
destroyChart() {
|
|
91
|
+
if (this.chart && this.chart.state !== "DESTROYED") {
|
|
92
|
+
this.chart.destroy();
|
|
90
93
|
}
|
|
91
|
-
|
|
92
|
-
|
|
94
|
+
}
|
|
95
|
+
getSeatsio() {
|
|
96
|
+
if (typeof seatsio === "undefined") {
|
|
97
|
+
return this.loadSeatsio();
|
|
98
|
+
} else if (seatsio.region !== this.props.region) {
|
|
99
|
+
seatsio = void 0;
|
|
100
|
+
return this.loadSeatsio();
|
|
101
|
+
} else {
|
|
102
|
+
return Promise.resolve(seatsio);
|
|
93
103
|
}
|
|
94
|
-
}
|
|
104
|
+
}
|
|
105
|
+
loadSeatsio() {
|
|
106
|
+
return new Promise((resolve, reject) => {
|
|
107
|
+
let script = document.createElement("script");
|
|
108
|
+
script.onload = () => {
|
|
109
|
+
seatsio.region = this.props.region;
|
|
110
|
+
resolve(seatsio);
|
|
111
|
+
};
|
|
112
|
+
script.onerror = () => reject(`Could not load ${script.src}`);
|
|
113
|
+
script.src = this.props.chartJsUrl.replace("{region}", this.props.region);
|
|
114
|
+
document.head.appendChild(script);
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
render() {
|
|
118
|
+
return /* @__PURE__ */ React.createElement("div", { ref: this.container, style: { "height": "100%", "width": "100%" } });
|
|
119
|
+
}
|
|
120
|
+
};
|
|
95
121
|
Embeddable.defaultProps = {
|
|
96
|
-
|
|
122
|
+
chartJsUrl: "https://cdn-{region}.seatsio.net/chart.js"
|
|
97
123
|
};
|
|
98
|
-
|
|
124
|
+
//# sourceMappingURL=Embeddable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/main/Embeddable.tsx","../src/main/util.ts"],"sourcesContent":["import * as React from 'react'\nimport {didPropsChange} from './util'\nimport { ChartDesigner, CommonConfigOptions, EventManager, Region, SeatingChart, Seatsio } from '@seatsio/seatsio-types'\n\nexport type EmbeddableProps<T> = {\n onRenderStarted?: (chart: SeatingChart) => void\n chartJsUrl?: string\n region: Region\n} & T\n\nexport default abstract class Embeddable<T extends CommonConfigOptions> extends React.Component<EmbeddableProps<T>> {\n private container: React.RefObject<HTMLDivElement>\n private rendering?: Promise<void>\n private chart: SeatingChart\n\n static defaultProps = {\n chartJsUrl: 'https://cdn-{region}.seatsio.net/chart.js'\n }\n\n constructor(props: EmbeddableProps<T>) {\n super(props);\n this.container = React.createRef();\n }\n\n abstract createChart (seatsio: Seatsio, config: T): SeatingChart | EventManager | ChartDesigner\n\n async componentDidMount () {\n if(!this.rendering) {\n this.rendering = this.createAndRenderChart()\n }\n }\n\n async componentDidUpdate (prevProps: EmbeddableProps<T>) {\n if (didPropsChange(this.props, prevProps) && this.chart) {\n this.destroyChart()\n this.createAndRenderChart()\n }\n }\n\n async createAndRenderChart () {\n const seatsio = await this.getSeatsio()\n const config = this.extractConfigFromProps()\n config.container = this.container.current\n this.chart = this.createChart(seatsio, config).render()\n if (this.props.onRenderStarted) {\n this.props.onRenderStarted(this.chart)\n }\n }\n\n extractConfigFromProps (): any {\n // noinspection JSUnusedLocalSymbols\n let { chartJsUrl, divId, onRenderStarted, region, ...config } = this.props\n return config\n }\n\n componentWillUnmount () {\n this.destroyChart()\n }\n\n destroyChart () {\n if (this.chart && (this.chart as any).state !== 'DESTROYED') {\n this.chart.destroy()\n }\n }\n\n getSeatsio () {\n if (typeof seatsio === 'undefined') {\n return this.loadSeatsio()\n } else if (seatsio.region !== this.props.region) {\n seatsio = undefined\n return this.loadSeatsio()\n } else {\n return Promise.resolve(seatsio)\n }\n }\n\n loadSeatsio () {\n return new Promise((resolve, reject) => {\n let script = document.createElement('script')\n script.onload = () => {\n seatsio.region = this.props.region\n resolve(seatsio)\n }\n script.onerror = () => reject(`Could not load ${script.src}`)\n script.src = this.props.chartJsUrl.replace('{region}', this.props.region)\n document.head.appendChild(script)\n })\n }\n\n render (): React.ReactNode {\n return (\n <div ref={this.container as unknown as React.RefObject<HTMLDivElement>} style={{'height': '100%', 'width': '100%'}} />\n )\n }\n}","import { BoothProps, GeneralAdmissionAreaProps, InteractiveObjectProps, InteractiveSectionProps, SeatProps, SelectableObjectProps, TableProps } from \"@seatsio/seatsio-types\"\n\nexport const didPropsChange = <P extends { [key: string]: any}>(prevProps: P, nextProps: P): boolean => {\n if (Object.keys(prevProps).length !== Object.keys(nextProps).length) {\n return true\n }\n return Object.keys(nextProps).some((propName: string) => {\n let prevValue = prevProps[propName]\n let nextValue = nextProps[propName]\n if (prevValue && nextValue) {\n if (typeof prevValue === 'function' && typeof nextValue === 'function') {\n return prevValue.toString() !== nextValue.toString()\n }\n if (typeof prevValue === 'object' && typeof nextValue === 'object') {\n return didPropsChange(prevValue, nextValue)\n }\n }\n return prevValue !== nextValue\n })\n}\n\nexport const isSeat = (obj: SelectableObjectProps): obj is SeatProps => obj.objectType === 'Seat'\nexport const isTable = (obj: SelectableObjectProps): obj is TableProps => obj.objectType === 'Table'\nexport const isSection = (obj: SelectableObjectProps): obj is InteractiveSectionProps => obj.objectType === 'section'\nexport const isBooth = (obj: SelectableObjectProps): obj is BoothProps => obj.objectType === 'Booth'\nexport const isGeneralAdmission = (obj: SelectableObjectProps): obj is GeneralAdmissionAreaProps => obj.objectType === 'GeneralAdmissionArea'"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,YAAuB;;;ACEhB,IAAM,iBAAiB,CAAkC,WAAc,cAA0B;AACpG,MAAI,OAAO,KAAK,SAAS,EAAE,WAAW,OAAO,KAAK,SAAS,EAAE,QAAQ;AACjE,WAAO;AAAA,EACX;AACA,SAAO,OAAO,KAAK,SAAS,EAAE,KAAK,CAAC,aAAqB;AACrD,QAAI,YAAY,UAAU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AAAA,IACvB;AAAA,EACJ;AAAA,EAEA,aAAc;AACV,QAAI,OAAO,YAAY,aAAa;AAChC,aAAO,KAAK,YAAY;AAAA,IAC5B,WAAW,QAAQ,WAAW,KAAK,MAAM,QAAQ;AAC7C,gBAAU;AACV,aAAO,KAAK,YAAY;AAAA,IAC5B,OAAO;AACH,aAAO,QAAQ,QAAQ,OAAO;AAAA,IAClC;AAAA,EACJ;AAAA,EAEA,cAAe;AACX,WAAO,IAAI,QAAQ,CAAC,SAAS,WAAW;AACpC,UAAI,SAAS,SAAS,cAAc,QAAQ;AAC5C,aAAO,SAAS,MAAM;AAClB,gBAAQ,SAAS,KAAK,MAAM;AAC5B,gBAAQ,OAAO;AAAA,MACnB;AACA,aAAO,UAAU,MAAM,OAAO,kBAAkB,OAAO,GAAG,EAAE;AAC5D,aAAO,MAAM,KAAK,MAAM,WAAW,QAAQ,YAAY,KAAK,MAAM,MAAM;AACxE,eAAS,KAAK,YAAY,MAAM;AAAA,IACpC,CAAC;AAAA,EACL;AAAA,EAEA,SAA2B;AACvB,WACI,oCAAC,SAAI,KAAK,KAAK,WAAyD,OAAO,EAAC,UAAU,QAAQ,SAAS,OAAM,GAAG;AAAA,EAE5H;AACJ;AApF8B,WAKnB,eAAe;AAAA,EAClB,YAAY;AAChB;","names":["seatsio"]}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
// src/main/Embeddable.tsx
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
|
|
4
|
+
// src/main/util.ts
|
|
5
|
+
var didPropsChange = (prevProps, nextProps) => {
|
|
6
|
+
if (Object.keys(prevProps).length !== Object.keys(nextProps).length) {
|
|
7
|
+
return true;
|
|
8
|
+
}
|
|
9
|
+
return Object.keys(nextProps).some((propName) => {
|
|
10
|
+
let prevValue = prevProps[propName];
|
|
11
|
+
let nextValue = nextProps[propName];
|
|
12
|
+
if (prevValue && nextValue) {
|
|
13
|
+
if (typeof prevValue === "function" && typeof nextValue === "function") {
|
|
14
|
+
return prevValue.toString() !== nextValue.toString();
|
|
15
|
+
}
|
|
16
|
+
if (typeof prevValue === "object" && typeof nextValue === "object") {
|
|
17
|
+
return didPropsChange(prevValue, nextValue);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return prevValue !== nextValue;
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
// src/main/Embeddable.tsx
|
|
25
|
+
var Embeddable = class extends React.Component {
|
|
26
|
+
constructor(props) {
|
|
27
|
+
super(props);
|
|
28
|
+
this.container = React.createRef();
|
|
29
|
+
}
|
|
30
|
+
async componentDidMount() {
|
|
31
|
+
if (!this.rendering) {
|
|
32
|
+
this.rendering = this.createAndRenderChart();
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
async componentDidUpdate(prevProps) {
|
|
36
|
+
if (didPropsChange(this.props, prevProps) && this.chart) {
|
|
37
|
+
this.destroyChart();
|
|
38
|
+
this.createAndRenderChart();
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
async createAndRenderChart() {
|
|
42
|
+
const seatsio2 = await this.getSeatsio();
|
|
43
|
+
const config = this.extractConfigFromProps();
|
|
44
|
+
config.container = this.container.current;
|
|
45
|
+
this.chart = this.createChart(seatsio2, config).render();
|
|
46
|
+
if (this.props.onRenderStarted) {
|
|
47
|
+
this.props.onRenderStarted(this.chart);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
extractConfigFromProps() {
|
|
51
|
+
let { chartJsUrl, divId, onRenderStarted, region, ...config } = this.props;
|
|
52
|
+
return config;
|
|
53
|
+
}
|
|
54
|
+
componentWillUnmount() {
|
|
55
|
+
this.destroyChart();
|
|
56
|
+
}
|
|
57
|
+
destroyChart() {
|
|
58
|
+
if (this.chart && this.chart.state !== "DESTROYED") {
|
|
59
|
+
this.chart.destroy();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
getSeatsio() {
|
|
63
|
+
if (typeof seatsio === "undefined") {
|
|
64
|
+
return this.loadSeatsio();
|
|
65
|
+
} else if (seatsio.region !== this.props.region) {
|
|
66
|
+
seatsio = void 0;
|
|
67
|
+
return this.loadSeatsio();
|
|
68
|
+
} else {
|
|
69
|
+
return Promise.resolve(seatsio);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
loadSeatsio() {
|
|
73
|
+
return new Promise((resolve, reject) => {
|
|
74
|
+
let script = document.createElement("script");
|
|
75
|
+
script.onload = () => {
|
|
76
|
+
seatsio.region = this.props.region;
|
|
77
|
+
resolve(seatsio);
|
|
78
|
+
};
|
|
79
|
+
script.onerror = () => reject(`Could not load ${script.src}`);
|
|
80
|
+
script.src = this.props.chartJsUrl.replace("{region}", this.props.region);
|
|
81
|
+
document.head.appendChild(script);
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
render() {
|
|
85
|
+
return /* @__PURE__ */ React.createElement("div", { ref: this.container, style: { "height": "100%", "width": "100%" } });
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
Embeddable.defaultProps = {
|
|
89
|
+
chartJsUrl: "https://cdn-{region}.seatsio.net/chart.js"
|
|
90
|
+
};
|
|
91
|
+
export {
|
|
92
|
+
Embeddable as default
|
|
93
|
+
};
|
|
94
|
+
//# sourceMappingURL=Embeddable.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/main/Embeddable.tsx","../src/main/util.ts"],"sourcesContent":["import * as React from 'react'\nimport {didPropsChange} from './util'\nimport { ChartDesigner, CommonConfigOptions, EventManager, Region, SeatingChart, Seatsio } from '@seatsio/seatsio-types'\n\nexport type EmbeddableProps<T> = {\n onRenderStarted?: (chart: SeatingChart) => void\n chartJsUrl?: string\n region: Region\n} & T\n\nexport default abstract class Embeddable<T extends CommonConfigOptions> extends React.Component<EmbeddableProps<T>> {\n private container: React.RefObject<HTMLDivElement>\n private rendering?: Promise<void>\n private chart: SeatingChart\n\n static defaultProps = {\n chartJsUrl: 'https://cdn-{region}.seatsio.net/chart.js'\n }\n\n constructor(props: EmbeddableProps<T>) {\n super(props);\n this.container = React.createRef();\n }\n\n abstract createChart (seatsio: Seatsio, config: T): SeatingChart | EventManager | ChartDesigner\n\n async componentDidMount () {\n if(!this.rendering) {\n this.rendering = this.createAndRenderChart()\n }\n }\n\n async componentDidUpdate (prevProps: EmbeddableProps<T>) {\n if (didPropsChange(this.props, prevProps) && this.chart) {\n this.destroyChart()\n this.createAndRenderChart()\n }\n }\n\n async createAndRenderChart () {\n const seatsio = await this.getSeatsio()\n const config = this.extractConfigFromProps()\n config.container = this.container.current\n this.chart = this.createChart(seatsio, config).render()\n if (this.props.onRenderStarted) {\n this.props.onRenderStarted(this.chart)\n }\n }\n\n extractConfigFromProps (): any {\n // noinspection JSUnusedLocalSymbols\n let { chartJsUrl, divId, onRenderStarted, region, ...config } = this.props\n return config\n }\n\n componentWillUnmount () {\n this.destroyChart()\n }\n\n destroyChart () {\n if (this.chart && (this.chart as any).state !== 'DESTROYED') {\n this.chart.destroy()\n }\n }\n\n getSeatsio () {\n if (typeof seatsio === 'undefined') {\n return this.loadSeatsio()\n } else if (seatsio.region !== this.props.region) {\n seatsio = undefined\n return this.loadSeatsio()\n } else {\n return Promise.resolve(seatsio)\n }\n }\n\n loadSeatsio () {\n return new Promise((resolve, reject) => {\n let script = document.createElement('script')\n script.onload = () => {\n seatsio.region = this.props.region\n resolve(seatsio)\n }\n script.onerror = () => reject(`Could not load ${script.src}`)\n script.src = this.props.chartJsUrl.replace('{region}', this.props.region)\n document.head.appendChild(script)\n })\n }\n\n render (): React.ReactNode {\n return (\n <div ref={this.container as unknown as React.RefObject<HTMLDivElement>} style={{'height': '100%', 'width': '100%'}} />\n )\n }\n}","import { BoothProps, GeneralAdmissionAreaProps, InteractiveObjectProps, InteractiveSectionProps, SeatProps, SelectableObjectProps, TableProps } from \"@seatsio/seatsio-types\"\n\nexport const didPropsChange = <P extends { [key: string]: any}>(prevProps: P, nextProps: P): boolean => {\n if (Object.keys(prevProps).length !== Object.keys(nextProps).length) {\n return true\n }\n return Object.keys(nextProps).some((propName: string) => {\n let prevValue = prevProps[propName]\n let nextValue = nextProps[propName]\n if (prevValue && nextValue) {\n if (typeof prevValue === 'function' && typeof nextValue === 'function') {\n return prevValue.toString() !== nextValue.toString()\n }\n if (typeof prevValue === 'object' && typeof nextValue === 'object') {\n return didPropsChange(prevValue, nextValue)\n }\n }\n return prevValue !== nextValue\n })\n}\n\nexport const isSeat = (obj: SelectableObjectProps): obj is SeatProps => obj.objectType === 'Seat'\nexport const isTable = (obj: SelectableObjectProps): obj is TableProps => obj.objectType === 'Table'\nexport const isSection = (obj: SelectableObjectProps): obj is InteractiveSectionProps => obj.objectType === 'section'\nexport const isBooth = (obj: SelectableObjectProps): obj is BoothProps => obj.objectType === 'Booth'\nexport const isGeneralAdmission = (obj: SelectableObjectProps): obj is GeneralAdmissionAreaProps => obj.objectType === 'GeneralAdmissionArea'"],"mappings":";AAAA,YAAY,WAAW;;;ACEhB,IAAM,iBAAiB,CAAkC,WAAc,cAA0B;AACpG,MAAI,OAAO,KAAK,SAAS,EAAE,WAAW,OAAO,KAAK,SAAS,EAAE,QAAQ;AACjE,WAAO;AAAA,EACX;AACA,SAAO,OAAO,KAAK,SAAS,EAAE,KAAK,CAAC,aAAqB;AACrD,QAAI,YAAY,UAAU,QAAQ;AAClC,QAAI,YAAY,UAAU,QAAQ;AAClC,QAAI,aAAa,WAAW;AACxB,UAAI,OAAO,cAAc,cAAc,OAAO,cAAc,YAAY;AACpE,eAAO,UAAU,SAAS,MAAM,UAAU,SAAS;AAAA,MACvD;AACA,UAAI,OAAO,cAAc,YAAY,OAAO,cAAc,UAAU;AAChE,eAAO,eAAe,WAAW,SAAS;AAAA,MAC9C;AAAA,IACJ;AACA,WAAO,cAAc;AAAA,EACzB,CAAC;AACL;;;ADTA,IAA8B,aAA9B,cAAsF,gBAA8B;AAAA,EAShH,YAAY,OAA2B;AACnC,UAAM,KAAK;AACX,SAAK,YAAkB,gBAAU;AAA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B,gBAAQ,OAAO;AAAA,MACnB;AACA,aAAO,UAAU,MAAM,OAAO,kBAAkB,OAAO,GAAG,EAAE;AAC5D,aAAO,MAAM,KAAK,MAAM,WAAW,QAAQ,YAAY,KAAK,MAAM,MAAM;AACxE,eAAS,KAAK,YAAY,MAAM;AAAA,IACpC,CAAC;AAAA,EACL;AAAA,EAEA,SAA2B;AACvB,WACI,oCAAC,SAAI,KAAK,KAAK,WAAyD,OAAO,EAAC,UAAU,QAAQ,SAAS,OAAM,GAAG;AAAA,EAE5H;AACJ;AApF8B,WAKnB,eAAe;AAAA,EAClB,YAAY;AAChB;","names":["seatsio"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as _seatsio_seatsio_types from '@seatsio/seatsio-types';
|
|
2
|
+
import { ChartDesignerConfigOptions, Seatsio } from '@seatsio/seatsio-types';
|
|
3
|
+
import Embeddable from './Embeddable.mjs';
|
|
4
|
+
import 'react';
|
|
5
|
+
|
|
6
|
+
declare class SeatsioDesigner extends Embeddable<ChartDesignerConfigOptions> {
|
|
7
|
+
createChart(seatsio: Seatsio, config: ChartDesignerConfigOptions): _seatsio_seatsio_types.ChartDesigner;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export { SeatsioDesigner as default };
|
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as _seatsio_seatsio_types from '@seatsio/seatsio-types';
|
|
2
2
|
import { ChartDesignerConfigOptions, Seatsio } from '@seatsio/seatsio-types';
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
import Embeddable from './Embeddable.js';
|
|
4
|
+
import 'react';
|
|
5
|
+
|
|
6
|
+
declare class SeatsioDesigner extends Embeddable<ChartDesignerConfigOptions> {
|
|
7
|
+
createChart(seatsio: Seatsio, config: ChartDesignerConfigOptions): _seatsio_seatsio_types.ChartDesigner;
|
|
5
8
|
}
|
|
9
|
+
|
|
10
|
+
export { SeatsioDesigner as default };
|
package/build/SeatsioDesigner.js
CHANGED
|
@@ -1,6 +1,133 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/main/SeatsioDesigner.tsx
|
|
30
|
+
var SeatsioDesigner_exports = {};
|
|
31
|
+
__export(SeatsioDesigner_exports, {
|
|
32
|
+
default: () => SeatsioDesigner
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(SeatsioDesigner_exports);
|
|
35
|
+
|
|
36
|
+
// src/main/Embeddable.tsx
|
|
37
|
+
var React = __toESM(require("react"));
|
|
38
|
+
|
|
39
|
+
// src/main/util.ts
|
|
40
|
+
var didPropsChange = (prevProps, nextProps) => {
|
|
41
|
+
if (Object.keys(prevProps).length !== Object.keys(nextProps).length) {
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
return Object.keys(nextProps).some((propName) => {
|
|
45
|
+
let prevValue = prevProps[propName];
|
|
46
|
+
let nextValue = nextProps[propName];
|
|
47
|
+
if (prevValue && nextValue) {
|
|
48
|
+
if (typeof prevValue === "function" && typeof nextValue === "function") {
|
|
49
|
+
return prevValue.toString() !== nextValue.toString();
|
|
50
|
+
}
|
|
51
|
+
if (typeof prevValue === "object" && typeof nextValue === "object") {
|
|
52
|
+
return didPropsChange(prevValue, nextValue);
|
|
53
|
+
}
|
|
5
54
|
}
|
|
6
|
-
|
|
55
|
+
return prevValue !== nextValue;
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
// src/main/Embeddable.tsx
|
|
60
|
+
var Embeddable = class extends React.Component {
|
|
61
|
+
constructor(props) {
|
|
62
|
+
super(props);
|
|
63
|
+
this.container = React.createRef();
|
|
64
|
+
}
|
|
65
|
+
async componentDidMount() {
|
|
66
|
+
if (!this.rendering) {
|
|
67
|
+
this.rendering = this.createAndRenderChart();
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
async componentDidUpdate(prevProps) {
|
|
71
|
+
if (didPropsChange(this.props, prevProps) && this.chart) {
|
|
72
|
+
this.destroyChart();
|
|
73
|
+
this.createAndRenderChart();
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
async createAndRenderChart() {
|
|
77
|
+
const seatsio2 = await this.getSeatsio();
|
|
78
|
+
const config = this.extractConfigFromProps();
|
|
79
|
+
config.container = this.container.current;
|
|
80
|
+
this.chart = this.createChart(seatsio2, config).render();
|
|
81
|
+
if (this.props.onRenderStarted) {
|
|
82
|
+
this.props.onRenderStarted(this.chart);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
extractConfigFromProps() {
|
|
86
|
+
let { chartJsUrl, divId, onRenderStarted, region, ...config } = this.props;
|
|
87
|
+
return config;
|
|
88
|
+
}
|
|
89
|
+
componentWillUnmount() {
|
|
90
|
+
this.destroyChart();
|
|
91
|
+
}
|
|
92
|
+
destroyChart() {
|
|
93
|
+
if (this.chart && this.chart.state !== "DESTROYED") {
|
|
94
|
+
this.chart.destroy();
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
getSeatsio() {
|
|
98
|
+
if (typeof seatsio === "undefined") {
|
|
99
|
+
return this.loadSeatsio();
|
|
100
|
+
} else if (seatsio.region !== this.props.region) {
|
|
101
|
+
seatsio = void 0;
|
|
102
|
+
return this.loadSeatsio();
|
|
103
|
+
} else {
|
|
104
|
+
return Promise.resolve(seatsio);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
loadSeatsio() {
|
|
108
|
+
return new Promise((resolve, reject) => {
|
|
109
|
+
let script = document.createElement("script");
|
|
110
|
+
script.onload = () => {
|
|
111
|
+
seatsio.region = this.props.region;
|
|
112
|
+
resolve(seatsio);
|
|
113
|
+
};
|
|
114
|
+
script.onerror = () => reject(`Could not load ${script.src}`);
|
|
115
|
+
script.src = this.props.chartJsUrl.replace("{region}", this.props.region);
|
|
116
|
+
document.head.appendChild(script);
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
render() {
|
|
120
|
+
return /* @__PURE__ */ React.createElement("div", { ref: this.container, style: { "height": "100%", "width": "100%" } });
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
Embeddable.defaultProps = {
|
|
124
|
+
chartJsUrl: "https://cdn-{region}.seatsio.net/chart.js"
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
// src/main/SeatsioDesigner.tsx
|
|
128
|
+
var SeatsioDesigner = class extends Embeddable {
|
|
129
|
+
createChart(seatsio2, config) {
|
|
130
|
+
return new seatsio2.SeatingChartDesigner(config);
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
//# sourceMappingURL=SeatsioDesigner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/main/SeatsioDesigner.tsx","../src/main/Embeddable.tsx","../src/main/util.ts"],"sourcesContent":["import Embeddable from './Embeddable'\nimport { ChartDesignerConfigOptions, Seatsio } from '@seatsio/seatsio-types'\n\nexport default class SeatsioDesigner extends Embeddable<ChartDesignerConfigOptions> {\n createChart (seatsio: Seatsio, config: ChartDesignerConfigOptions) {\n return new seatsio.SeatingChartDesigner(config)\n }\n}","import * as React from 'react'\nimport {didPropsChange} from './util'\nimport { ChartDesigner, CommonConfigOptions, EventManager, Region, SeatingChart, Seatsio } from '@seatsio/seatsio-types'\n\nexport type EmbeddableProps<T> = {\n onRenderStarted?: (chart: SeatingChart) => void\n chartJsUrl?: string\n region: Region\n} & T\n\nexport default abstract class Embeddable<T extends CommonConfigOptions> extends React.Component<EmbeddableProps<T>> {\n private container: React.RefObject<HTMLDivElement>\n private rendering?: Promise<void>\n private chart: SeatingChart\n\n static defaultProps = {\n chartJsUrl: 'https://cdn-{region}.seatsio.net/chart.js'\n }\n\n constructor(props: EmbeddableProps<T>) {\n super(props);\n this.container = React.createRef();\n }\n\n abstract createChart (seatsio: Seatsio, config: T): SeatingChart | EventManager | ChartDesigner\n\n async componentDidMount () {\n if(!this.rendering) {\n this.rendering = this.createAndRenderChart()\n }\n }\n\n async componentDidUpdate (prevProps: EmbeddableProps<T>) {\n if (didPropsChange(this.props, prevProps) && this.chart) {\n this.destroyChart()\n this.createAndRenderChart()\n }\n }\n\n async createAndRenderChart () {\n const seatsio = await this.getSeatsio()\n const config = this.extractConfigFromProps()\n config.container = this.container.current\n this.chart = this.createChart(seatsio, config).render()\n if (this.props.onRenderStarted) {\n this.props.onRenderStarted(this.chart)\n }\n }\n\n extractConfigFromProps (): any {\n // noinspection JSUnusedLocalSymbols\n let { chartJsUrl, divId, onRenderStarted, region, ...config } = this.props\n return config\n }\n\n componentWillUnmount () {\n this.destroyChart()\n }\n\n destroyChart () {\n if (this.chart && (this.chart as any).state !== 'DESTROYED') {\n this.chart.destroy()\n }\n }\n\n getSeatsio () {\n if (typeof seatsio === 'undefined') {\n return this.loadSeatsio()\n } else if (seatsio.region !== this.props.region) {\n seatsio = undefined\n return this.loadSeatsio()\n } else {\n return Promise.resolve(seatsio)\n }\n }\n\n loadSeatsio () {\n return new Promise((resolve, reject) => {\n let script = document.createElement('script')\n script.onload = () => {\n seatsio.region = this.props.region\n resolve(seatsio)\n }\n script.onerror = () => reject(`Could not load ${script.src}`)\n script.src = this.props.chartJsUrl.replace('{region}', this.props.region)\n document.head.appendChild(script)\n })\n }\n\n render (): React.ReactNode {\n return (\n <div ref={this.container as unknown as React.RefObject<HTMLDivElement>} style={{'height': '100%', 'width': '100%'}} />\n )\n }\n}","import { BoothProps, GeneralAdmissionAreaProps, InteractiveObjectProps, InteractiveSectionProps, SeatProps, SelectableObjectProps, TableProps } from \"@seatsio/seatsio-types\"\n\nexport const didPropsChange = <P extends { [key: string]: any}>(prevProps: P, nextProps: P): boolean => {\n if (Object.keys(prevProps).length !== Object.keys(nextProps).length) {\n return true\n }\n return Object.keys(nextProps).some((propName: string) => {\n let prevValue = prevProps[propName]\n let nextValue = nextProps[propName]\n if (prevValue && nextValue) {\n if (typeof prevValue === 'function' && typeof nextValue === 'function') {\n return prevValue.toString() !== nextValue.toString()\n }\n if (typeof prevValue === 'object' && typeof nextValue === 'object') {\n return didPropsChange(prevValue, nextValue)\n }\n }\n return prevValue !== nextValue\n })\n}\n\nexport const isSeat = (obj: SelectableObjectProps): obj is SeatProps => obj.objectType === 'Seat'\nexport const isTable = (obj: SelectableObjectProps): obj is TableProps => obj.objectType === 'Table'\nexport const isSection = (obj: SelectableObjectProps): obj is InteractiveSectionProps => obj.objectType === 'section'\nexport const isBooth = (obj: SelectableObjectProps): obj is BoothProps => obj.objectType === 'Booth'\nexport const isGeneralAdmission = (obj: SelectableObjectProps): obj is GeneralAdmissionAreaProps => obj.objectType === 'GeneralAdmissionArea'"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,YAAuB;;;ACEhB,IAAM,iBAAiB,CAAkC,WAAc,cAA0B;AACpG,MAAI,OAAO,KAAK,SAAS,EAAE,WAAW,OAAO,KAAK,SAAS,EAAE,QAAQ;AACjE,WAAO;AAAA,EACX;AACA,SAAO,OAAO,KAAK,SAAS,EAAE,KAAK,CAAC,aAAqB;AACrD,QAAI,YAAY,UAAU,QAAQ;AAClC,QAAI,YAAY,UAAU,QAAQ;AAClC,QAAI,aAAa,WAAW;AACxB,UAAI,OAAO,cAAc,cAAc,OAAO,cAAc,YAAY;AACpE,eAAO,UAAU,SAAS,MAAM,UAAU,SAAS;AAAA,MACvD;AACA,UAAI,OAAO,cAAc,YAAY,OAAO,cAAc,UAAU;AAChE,eAAO,eAAe,WAAW,SAAS;AAAA,MAC9C;AAAA,IACJ;AACA,WAAO,cAAc;AAAA,EACzB,CAAC;AACL;;;ADTA,IAA8B,aAA9B,cAAsF,gBAA8B;AAAA,EAShH,YAAY,OAA2B;AACnC,UAAM,KAAK;AACX,SAAK,YAAkB,gBAAU;AAAA,EACrC;AAAA,EAIA,MAAM,oBAAqB;AACvB,QAAG,CAAC,KAAK,WAAW;AAChB,WAAK,YAAY,KAAK,qBAAqB;AAAA,IAC/C;AAAA,EACJ;AAAA,EAEA,MAAM,mBAAoB,WAA+B;AACrD,QAAI,eAAe,KAAK,OAAO,SAAS,KAAK,KAAK,OAAO;AACrD,WAAK,aAAa;AAClB,WAAK,qBAAqB;AAAA,IAC9B;AAAA,EACJ;AAAA,EAEA,MAAM,uBAAwB;AAC1B,UAAMA,WAAU,MAAM,KAAK,WAAW;AACtC,UAA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