@scenar/embed 0.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/LICENSE +190 -0
- package/README.md +69 -0
- package/define.d.ts +2 -0
- package/define.d.ts.map +1 -0
- package/define.js +8 -0
- package/define.js.map +1 -0
- package/element.d.ts +55 -0
- package/element.d.ts.map +1 -0
- package/element.js +129 -0
- package/element.js.map +1 -0
- package/embed.global.js +1 -0
- package/global.d.ts +9 -0
- package/global.d.ts.map +1 -0
- package/global.js +10 -0
- package/global.js.map +1 -0
- package/index.d.ts +7 -0
- package/index.d.ts.map +1 -0
- package/index.js +11 -0
- package/index.js.map +1 -0
- package/mount.d.ts +40 -0
- package/mount.d.ts.map +1 -0
- package/mount.js +63 -0
- package/mount.js.map +1 -0
- package/package.json +61 -0
- package/react.d.ts +35 -0
- package/react.d.ts.map +1 -0
- package/react.js +58 -0
- package/react.js.map +1 -0
- package/resolve.d.ts +57 -0
- package/resolve.d.ts.map +1 -0
- package/resolve.js +57 -0
- package/resolve.js.map +1 -0
- package/src/define.ts +8 -0
- package/src/element.test.ts +108 -0
- package/src/element.ts +148 -0
- package/src/global.ts +11 -0
- package/src/index.ts +25 -0
- package/src/mount.test.ts +202 -0
- package/src/mount.ts +113 -0
- package/src/react.test.tsx +89 -0
- package/src/react.tsx +121 -0
- package/src/resolve.test.ts +77 -0
- package/src/resolve.ts +80 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to the Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by the Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding any notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
Copyright 2026 Scenar Contributors
|
|
179
|
+
|
|
180
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
181
|
+
you may not use this file except in compliance with the License.
|
|
182
|
+
You may obtain a copy of the License at
|
|
183
|
+
|
|
184
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
185
|
+
|
|
186
|
+
Unless required by applicable law or agreed to in writing, software
|
|
187
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
188
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
189
|
+
See the License for the specific language governing permissions and
|
|
190
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# @scenar/embed
|
|
2
|
+
|
|
3
|
+
Drop-in host-side embedding for hosted [Scenar](https://github.com/stigmer/scenar)
|
|
4
|
+
tours. Frame a published tour as a responsive, theme-synced iframe without
|
|
5
|
+
hand-writing the `postMessage` listener, the theme sync, or the resize-to-fit
|
|
6
|
+
glue.
|
|
7
|
+
|
|
8
|
+
It builds on the framework-free embed host controller in `@scenar/core`, so the
|
|
9
|
+
wire protocol is single-sourced and never drifts. It does **not** pull in the
|
|
10
|
+
player runtime (`@scenar/react`) — embedding a hosted tour costs your host page
|
|
11
|
+
nothing but this small package.
|
|
12
|
+
|
|
13
|
+
## Three ways to use it
|
|
14
|
+
|
|
15
|
+
### 1. Web component (any framework, or none)
|
|
16
|
+
|
|
17
|
+
```html
|
|
18
|
+
<script type="module" src="https://cdn.jsdelivr.net/npm/@scenar/embed/dist/embed.global.js"></script>
|
|
19
|
+
|
|
20
|
+
<scenar-embed
|
|
21
|
+
src="https://you.github.io/scenar-embeds/welcome-tour/"
|
|
22
|
+
title="Welcome tour"
|
|
23
|
+
></scenar-embed>
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Or, with a bundler:
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
import "@scenar/embed/define"; // registers <scenar-embed>
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### 2. React
|
|
33
|
+
|
|
34
|
+
```tsx
|
|
35
|
+
import { ScenarEmbed } from "@scenar/embed/react";
|
|
36
|
+
|
|
37
|
+
<ScenarEmbed
|
|
38
|
+
src="https://you.github.io/scenar-embeds/welcome-tour/"
|
|
39
|
+
title="Welcome tour"
|
|
40
|
+
/>;
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
`react` and `react-dom` are optional peer dependencies — only needed for this
|
|
44
|
+
subpath.
|
|
45
|
+
|
|
46
|
+
### 3. Imperative (build your own host)
|
|
47
|
+
|
|
48
|
+
```ts
|
|
49
|
+
import { createEmbedMount } from "@scenar/embed";
|
|
50
|
+
|
|
51
|
+
const mount = createEmbedMount(iframeElement, {
|
|
52
|
+
src: "https://you.github.io/scenar-embeds/welcome-tour/",
|
|
53
|
+
theme: "auto",
|
|
54
|
+
onAspectRatio: ({ widthPx, heightPx }) => {
|
|
55
|
+
/* size your container */
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
// mount.controller.play(); mount.controller.pause(); …
|
|
59
|
+
// mount.destroy();
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Theme
|
|
63
|
+
|
|
64
|
+
`theme` is `auto` (default), `light`, or `dark`. `auto` tracks the host page's
|
|
65
|
+
`dark` class on `<html>` and re-themes the embed when it toggles.
|
|
66
|
+
|
|
67
|
+
## License
|
|
68
|
+
|
|
69
|
+
Apache-2.0
|
package/define.d.ts
ADDED
package/define.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"define.d.ts","sourceRoot":"","sources":["../src/define.ts"],"names":[],"mappings":""}
|
package/define.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Side-effecting entry: importing `@scenar/embed/define` registers the
|
|
3
|
+
* `<scenar-embed>` custom element. For bundler hosts that want the tag available
|
|
4
|
+
* without calling {@link defineScenarEmbed} themselves.
|
|
5
|
+
*/
|
|
6
|
+
import { defineScenarEmbed } from "./element.js";
|
|
7
|
+
defineScenarEmbed();
|
|
8
|
+
//# sourceMappingURL=define.js.map
|
package/define.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"define.js","sourceRoot":"","sources":["../src/define.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjD,iBAAiB,EAAE,CAAC"}
|
package/element.d.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/** The custom element tag name. */
|
|
2
|
+
export declare const SCENAR_EMBED_TAG = "scenar-embed";
|
|
3
|
+
/**
|
|
4
|
+
* SSR-safe base: subclassing `HTMLElement` evaluates at module load, which would
|
|
5
|
+
* throw in a non-DOM environment (server render). Fall back to a stub so this
|
|
6
|
+
* module can be imported anywhere; the element is only ever *registered* in a
|
|
7
|
+
* browser via {@link defineScenarEmbed}.
|
|
8
|
+
*/
|
|
9
|
+
declare const HTMLElementBase: typeof HTMLElement;
|
|
10
|
+
/**
|
|
11
|
+
* `<scenar-embed src="…">` — a framework-agnostic, drop-in embed for a hosted
|
|
12
|
+
* Scenar tour. It owns an internal iframe and its responsive box; all bridge
|
|
13
|
+
* behavior (origin pinning, theme sync, resize → aspect-ratio) comes from
|
|
14
|
+
* {@link createEmbedMount}, so the element holds no protocol logic of its own.
|
|
15
|
+
*
|
|
16
|
+
* Attributes:
|
|
17
|
+
* - `src` (required) — the absolute embed URL.
|
|
18
|
+
* - `title` — accessible iframe title (defaults to a generic label).
|
|
19
|
+
* - `theme` — `auto` (default) | `light` | `dark`.
|
|
20
|
+
*
|
|
21
|
+
* Events: re-dispatches every embed event as a DOM `CustomEvent` named
|
|
22
|
+
* `scenar:<type>` (e.g. `scenar:ready`, `scenar:completed`) with the event in
|
|
23
|
+
* `detail`, so a vanilla host can listen without touching `postMessage`.
|
|
24
|
+
*
|
|
25
|
+
* Imperative transport (`play`/`pause`/`seek`/`setMuted`/`setVolume`) delegates
|
|
26
|
+
* to the bridge; calls before the element has a `src` are no-ops.
|
|
27
|
+
*/
|
|
28
|
+
export declare class ScenarEmbedElement extends HTMLElementBase {
|
|
29
|
+
static get observedAttributes(): string[];
|
|
30
|
+
private iframe;
|
|
31
|
+
private mount;
|
|
32
|
+
connectedCallback(): void;
|
|
33
|
+
disconnectedCallback(): void;
|
|
34
|
+
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
|
|
35
|
+
play(): void;
|
|
36
|
+
pause(): void;
|
|
37
|
+
seek(timeMs: number): void;
|
|
38
|
+
setMuted(muted: boolean): void;
|
|
39
|
+
setVolume(volume: number): void;
|
|
40
|
+
private titleAttr;
|
|
41
|
+
private themeAttr;
|
|
42
|
+
private setAspectRatio;
|
|
43
|
+
/** Build the host box + the internal iframe (once). */
|
|
44
|
+
private render;
|
|
45
|
+
/** (Re)create the bridge for the current `src`/`theme`. */
|
|
46
|
+
private attach;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Register `<scenar-embed>` (idempotent and SSR-safe). Pass a custom tag name to
|
|
50
|
+
* register under a different element name. A no-op when the registry is absent
|
|
51
|
+
* (server) or the tag is already defined.
|
|
52
|
+
*/
|
|
53
|
+
export declare function defineScenarEmbed(tagName?: string): void;
|
|
54
|
+
export {};
|
|
55
|
+
//# sourceMappingURL=element.d.ts.map
|
package/element.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"element.d.ts","sourceRoot":"","sources":["../src/element.ts"],"names":[],"mappings":"AAOA,mCAAmC;AACnC,eAAO,MAAM,gBAAgB,iBAAiB,CAAC;AAK/C;;;;;GAKG;AACH,QAAA,MAAM,eAAe,EAAE,OAAO,WAGmB,CAAC;AAElD;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,kBAAmB,SAAQ,eAAe;IACrD,MAAM,KAAK,kBAAkB,IAAI,MAAM,EAAE,CAExC;IAED,OAAO,CAAC,MAAM,CAAkC;IAChD,OAAO,CAAC,KAAK,CAA2B;IAExC,iBAAiB,IAAI,IAAI;IAKzB,oBAAoB,IAAI,IAAI;IAK5B,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAU9F,IAAI,IAAI,IAAI;IAIZ,KAAK,IAAI,IAAI;IAIb,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAI1B,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI;IAI9B,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAI/B,OAAO,CAAC,SAAS;IAIjB,OAAO,CAAC,SAAS;IAKjB,OAAO,CAAC,cAAc;IAItB,uDAAuD;IACvD,OAAO,CAAC,MAAM;IAkBd,2DAA2D;IAC3D,OAAO,CAAC,MAAM;CAaf;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,GAAE,MAAyB,GAAG,IAAI,CAI1E"}
|
package/element.js
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { createEmbedMount } from "./mount.js";
|
|
2
|
+
import { EMBED_BASE_ASPECT_HEIGHT, EMBED_BASE_ASPECT_WIDTH, } from "./resolve.js";
|
|
3
|
+
/** The custom element tag name. */
|
|
4
|
+
export const SCENAR_EMBED_TAG = "scenar-embed";
|
|
5
|
+
/** Accessible iframe title when the host sets none. */
|
|
6
|
+
const DEFAULT_TITLE = "Interactive product tour";
|
|
7
|
+
/**
|
|
8
|
+
* SSR-safe base: subclassing `HTMLElement` evaluates at module load, which would
|
|
9
|
+
* throw in a non-DOM environment (server render). Fall back to a stub so this
|
|
10
|
+
* module can be imported anywhere; the element is only ever *registered* in a
|
|
11
|
+
* browser via {@link defineScenarEmbed}.
|
|
12
|
+
*/
|
|
13
|
+
const HTMLElementBase = typeof HTMLElement !== "undefined"
|
|
14
|
+
? HTMLElement
|
|
15
|
+
: class {
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* `<scenar-embed src="…">` — a framework-agnostic, drop-in embed for a hosted
|
|
19
|
+
* Scenar tour. It owns an internal iframe and its responsive box; all bridge
|
|
20
|
+
* behavior (origin pinning, theme sync, resize → aspect-ratio) comes from
|
|
21
|
+
* {@link createEmbedMount}, so the element holds no protocol logic of its own.
|
|
22
|
+
*
|
|
23
|
+
* Attributes:
|
|
24
|
+
* - `src` (required) — the absolute embed URL.
|
|
25
|
+
* - `title` — accessible iframe title (defaults to a generic label).
|
|
26
|
+
* - `theme` — `auto` (default) | `light` | `dark`.
|
|
27
|
+
*
|
|
28
|
+
* Events: re-dispatches every embed event as a DOM `CustomEvent` named
|
|
29
|
+
* `scenar:<type>` (e.g. `scenar:ready`, `scenar:completed`) with the event in
|
|
30
|
+
* `detail`, so a vanilla host can listen without touching `postMessage`.
|
|
31
|
+
*
|
|
32
|
+
* Imperative transport (`play`/`pause`/`seek`/`setMuted`/`setVolume`) delegates
|
|
33
|
+
* to the bridge; calls before the element has a `src` are no-ops.
|
|
34
|
+
*/
|
|
35
|
+
export class ScenarEmbedElement extends HTMLElementBase {
|
|
36
|
+
static get observedAttributes() {
|
|
37
|
+
return ["src", "title", "theme"];
|
|
38
|
+
}
|
|
39
|
+
iframe = null;
|
|
40
|
+
mount = null;
|
|
41
|
+
connectedCallback() {
|
|
42
|
+
if (!this.iframe)
|
|
43
|
+
this.render();
|
|
44
|
+
this.attach();
|
|
45
|
+
}
|
|
46
|
+
disconnectedCallback() {
|
|
47
|
+
this.mount?.destroy();
|
|
48
|
+
this.mount = null;
|
|
49
|
+
}
|
|
50
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
51
|
+
if (oldValue === newValue)
|
|
52
|
+
return;
|
|
53
|
+
if (name === "title") {
|
|
54
|
+
if (this.iframe)
|
|
55
|
+
this.iframe.setAttribute("title", this.titleAttr());
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
// A new src or theme rebuilds the bridge (and reloads the frame).
|
|
59
|
+
if (this.isConnected)
|
|
60
|
+
this.attach();
|
|
61
|
+
}
|
|
62
|
+
play() {
|
|
63
|
+
this.mount?.controller.play();
|
|
64
|
+
}
|
|
65
|
+
pause() {
|
|
66
|
+
this.mount?.controller.pause();
|
|
67
|
+
}
|
|
68
|
+
seek(timeMs) {
|
|
69
|
+
this.mount?.controller.seek(timeMs);
|
|
70
|
+
}
|
|
71
|
+
setMuted(muted) {
|
|
72
|
+
this.mount?.controller.setMuted(muted);
|
|
73
|
+
}
|
|
74
|
+
setVolume(volume) {
|
|
75
|
+
this.mount?.controller.setVolume(volume);
|
|
76
|
+
}
|
|
77
|
+
titleAttr() {
|
|
78
|
+
return this.getAttribute("title") ?? DEFAULT_TITLE;
|
|
79
|
+
}
|
|
80
|
+
themeAttr() {
|
|
81
|
+
const theme = this.getAttribute("theme");
|
|
82
|
+
return theme === "light" || theme === "dark" ? theme : "auto";
|
|
83
|
+
}
|
|
84
|
+
setAspectRatio(width, height) {
|
|
85
|
+
this.style.aspectRatio = `${width} / ${height}`;
|
|
86
|
+
}
|
|
87
|
+
/** Build the host box + the internal iframe (once). */
|
|
88
|
+
render() {
|
|
89
|
+
this.style.display = "block";
|
|
90
|
+
this.style.position = "relative";
|
|
91
|
+
this.style.width = "100%";
|
|
92
|
+
this.setAspectRatio(EMBED_BASE_ASPECT_WIDTH, EMBED_BASE_ASPECT_HEIGHT);
|
|
93
|
+
const iframe = document.createElement("iframe");
|
|
94
|
+
iframe.setAttribute("title", this.titleAttr());
|
|
95
|
+
iframe.setAttribute("loading", "lazy");
|
|
96
|
+
iframe.setAttribute("allow", "autoplay; fullscreen");
|
|
97
|
+
iframe.setAttribute("allowfullscreen", "");
|
|
98
|
+
iframe.style.cssText =
|
|
99
|
+
"position:absolute;inset:0;width:100%;height:100%;border:0;border-radius:inherit";
|
|
100
|
+
this.appendChild(iframe);
|
|
101
|
+
this.iframe = iframe;
|
|
102
|
+
}
|
|
103
|
+
/** (Re)create the bridge for the current `src`/`theme`. */
|
|
104
|
+
attach() {
|
|
105
|
+
const src = this.getAttribute("src");
|
|
106
|
+
if (!src || !this.iframe)
|
|
107
|
+
return;
|
|
108
|
+
this.mount?.destroy();
|
|
109
|
+
this.mount = createEmbedMount(this.iframe, {
|
|
110
|
+
src,
|
|
111
|
+
theme: this.themeAttr(),
|
|
112
|
+
onAspectRatio: ({ widthPx, heightPx }) => this.setAspectRatio(widthPx, heightPx),
|
|
113
|
+
onEvent: (event) => this.dispatchEvent(new CustomEvent(`scenar:${event.type}`, { detail: event })),
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Register `<scenar-embed>` (idempotent and SSR-safe). Pass a custom tag name to
|
|
119
|
+
* register under a different element name. A no-op when the registry is absent
|
|
120
|
+
* (server) or the tag is already defined.
|
|
121
|
+
*/
|
|
122
|
+
export function defineScenarEmbed(tagName = SCENAR_EMBED_TAG) {
|
|
123
|
+
if (typeof customElements === "undefined")
|
|
124
|
+
return;
|
|
125
|
+
if (customElements.get(tagName))
|
|
126
|
+
return;
|
|
127
|
+
customElements.define(tagName, ScenarEmbedElement);
|
|
128
|
+
}
|
|
129
|
+
//# sourceMappingURL=element.js.map
|
package/element.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"element.js","sourceRoot":"","sources":["../src/element.ts"],"names":[],"mappings":"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"}
|
package/embed.global.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var ScenarEmbed=function(o){"use strict";var I=Object.defineProperty;var N=(o,u,d)=>u in o?I(o,u,{enumerable:!0,configurable:!0,writable:!0,value:d}):o[u]=d;var E=(o,u,d)=>N(o,typeof u!="symbol"?u+"":u,d);const u="scenar-embed";function g(e){return{source:u,v:1,...e}}function S(e){if(typeof e!="object"||e===null)return!1;const s=e;return s.source===u&&s.v===1}function l(e){return typeof e=="number"&&Number.isFinite(e)}function A(e){if(!S(e))return null;const s=e.type;switch(s){case"started":case"paused":case"completed":case"audioBlocked":return{type:s};case"ready":return l(e.totalSteps)&&typeof e.hasNarration=="boolean"?{type:s,totalSteps:e.totalSteps,hasNarration:e.hasNarration}:null;case"resize":return l(e.widthPx)&&l(e.heightPx)?{type:s,widthPx:e.widthPx,heightPx:e.heightPx}:null;case"stepchange":return l(e.stepIndex)&&l(e.totalSteps)?{type:s,stepIndex:e.stepIndex,totalSteps:e.totalSteps}:null;case"progress":return l(e.stepIndex)&&l(e.totalSteps)&&l(e.fraction)?{type:s,stepIndex:e.stepIndex,totalSteps:e.totalSteps,fraction:e.fraction}:null;case"error":return typeof e.message=="string"?{type:s,message:e.message}:null;default:return null}}function w(e,s={}){const{iframe:t,origin:n}=e,{onEvent:r}=s,a=typeof window<"u",c=i=>{var h;(h=t.contentWindow)==null||h.postMessage(g(i),n)},f=i=>{if(i.source!==t.contentWindow||i.origin!==n)return;const h=A(i.data);h&&(r==null||r(h))};return a&&window.addEventListener("message",f),{play:()=>c({type:"play"}),pause:()=>c({type:"pause"}),seek:i=>c({type:"seek",timeMs:i}),setMuted:i=>c({type:"setMuted",muted:i}),setVolume:i=>c({type:"setVolume",volume:i}),prefetch:()=>c({type:"prefetch"}),destroy:()=>{c({type:"destroy"}),a&&window.removeEventListener("message",f)}}}const T=896,C=480;function M(e,s){return e==="light"?"light":e==="dark"||s?"dark":"light"}function _(e,s){const t=new URL(e);return t.searchParams.set("theme",s),t.toString()}function P(e){return new URL(e).origin}function R(){return typeof document<"u"&&document.documentElement.classList.contains("dark")}function O(e,s){const{src:t,theme:n="auto",onAspectRatio:r,onEvent:a}=s,c=P(t);let f=null;const i=()=>{const m=M(n,R());m!==f&&(f=m,e.src=_(t,m))},h=w({iframe:e,origin:c},{onEvent:m=>{m.type==="resize"&&(r==null||r({widthPx:m.widthPx,heightPx:m.heightPx})),a==null||a(m)}});let p;return n==="auto"&&typeof MutationObserver<"u"&&typeof document<"u"&&(p=new MutationObserver(i),p.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]})),i(),{controller:h,destroy(){p==null||p.disconnect(),h.destroy()}}}const k="scenar-embed",x="Interactive product tour",L=typeof HTMLElement<"u"?HTMLElement:class{};class y extends L{constructor(){super(...arguments);E(this,"iframe",null);E(this,"mount",null)}static get observedAttributes(){return["src","title","theme"]}connectedCallback(){this.iframe||this.render(),this.attach()}disconnectedCallback(){var t;(t=this.mount)==null||t.destroy(),this.mount=null}attributeChangedCallback(t,n,r){if(n!==r){if(t==="title"){this.iframe&&this.iframe.setAttribute("title",this.titleAttr());return}this.isConnected&&this.attach()}}play(){var t;(t=this.mount)==null||t.controller.play()}pause(){var t;(t=this.mount)==null||t.controller.pause()}seek(t){var n;(n=this.mount)==null||n.controller.seek(t)}setMuted(t){var n;(n=this.mount)==null||n.controller.setMuted(t)}setVolume(t){var n;(n=this.mount)==null||n.controller.setVolume(t)}titleAttr(){return this.getAttribute("title")??x}themeAttr(){const t=this.getAttribute("theme");return t==="light"||t==="dark"?t:"auto"}setAspectRatio(t,n){this.style.aspectRatio=`${t} / ${n}`}render(){this.style.display="block",this.style.position="relative",this.style.width="100%",this.setAspectRatio(T,C);const t=document.createElement("iframe");t.setAttribute("title",this.titleAttr()),t.setAttribute("loading","lazy"),t.setAttribute("allow","autoplay; fullscreen"),t.setAttribute("allowfullscreen",""),t.style.cssText="position:absolute;inset:0;width:100%;height:100%;border:0;border-radius:inherit",this.appendChild(t),this.iframe=t}attach(){var n;const t=this.getAttribute("src");!t||!this.iframe||((n=this.mount)==null||n.destroy(),this.mount=O(this.iframe,{src:t,theme:this.themeAttr(),onAspectRatio:({widthPx:r,heightPx:a})=>this.setAspectRatio(r,a),onEvent:r=>this.dispatchEvent(new CustomEvent(`scenar:${r.type}`,{detail:r}))}))}}function b(e=k){typeof customElements>"u"||customElements.get(e)||customElements.define(e,y)}return b(),o.ScenarEmbedElement=y,o.defineScenarEmbed=b,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"}),o}({});
|
package/global.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The IIFE entry, bundled to `dist/embed.global.js` (see vite.config.ts) — the
|
|
3
|
+
* single pasteable `<script>` for no-bundler hosts. It auto-registers
|
|
4
|
+
* `<scenar-embed>` on load and also exposes the registrar on `window.ScenarEmbed`
|
|
5
|
+
* for hosts that register under a custom tag.
|
|
6
|
+
*/
|
|
7
|
+
import { ScenarEmbedElement, defineScenarEmbed } from "./element.js";
|
|
8
|
+
export { ScenarEmbedElement, defineScenarEmbed };
|
|
9
|
+
//# sourceMappingURL=global.d.ts.map
|
package/global.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"global.d.ts","sourceRoot":"","sources":["../src/global.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAIrE,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,CAAC"}
|
package/global.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The IIFE entry, bundled to `dist/embed.global.js` (see vite.config.ts) — the
|
|
3
|
+
* single pasteable `<script>` for no-bundler hosts. It auto-registers
|
|
4
|
+
* `<scenar-embed>` on load and also exposes the registrar on `window.ScenarEmbed`
|
|
5
|
+
* for hosts that register under a custom tag.
|
|
6
|
+
*/
|
|
7
|
+
import { ScenarEmbedElement, defineScenarEmbed } from "./element.js";
|
|
8
|
+
defineScenarEmbed();
|
|
9
|
+
export { ScenarEmbedElement, defineScenarEmbed };
|
|
10
|
+
//# sourceMappingURL=global.js.map
|
package/global.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"global.js","sourceRoot":"","sources":["../src/global.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAErE,iBAAiB,EAAE,CAAC;AAEpB,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,CAAC"}
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { ScenarEmbedElement, defineScenarEmbed, SCENAR_EMBED_TAG } from "./element.js";
|
|
2
|
+
export { createEmbedMount } from "./mount.js";
|
|
3
|
+
export type { EmbedMount, EmbedMountOptions, EmbedAspectRatio } from "./mount.js";
|
|
4
|
+
export { resolveEmbedSrc, resolveTheme, applyThemeToSrc, originFromSrc, EMBED_BASE_ASPECT_WIDTH, EMBED_BASE_ASPECT_HEIGHT, } from "./resolve.js";
|
|
5
|
+
export type { ScenarEmbedTheme, EmbedSource } from "./resolve.js";
|
|
6
|
+
export type { ScenarEmbedEvent, ScenarEmbedCommand } from "@scenar/core";
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
package/index.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAGvF,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,YAAY,EAAE,UAAU,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAGlF,OAAO,EACL,eAAe,EACf,YAAY,EACZ,eAAe,EACf,aAAa,EACb,uBAAuB,EACvB,wBAAwB,GACzB,MAAM,cAAc,CAAC;AACtB,YAAY,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGlE,YAAY,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC"}
|
package/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// @scenar/embed — public API
|
|
2
|
+
// Drop-in host-side embedding for hosted Scenar tours. Importing this entry has
|
|
3
|
+
// no side effects (it does not register the element); call `defineScenarEmbed()`
|
|
4
|
+
// or import `@scenar/embed/define` to register `<scenar-embed>`.
|
|
5
|
+
// Custom element + registrar
|
|
6
|
+
export { ScenarEmbedElement, defineScenarEmbed, SCENAR_EMBED_TAG } from "./element.js";
|
|
7
|
+
// Framework-free mount (the shared core both adapters build on)
|
|
8
|
+
export { createEmbedMount } from "./mount.js";
|
|
9
|
+
// Pure resolution helpers + baseline constants
|
|
10
|
+
export { resolveEmbedSrc, resolveTheme, applyThemeToSrc, originFromSrc, EMBED_BASE_ASPECT_WIDTH, EMBED_BASE_ASPECT_HEIGHT, } from "./resolve.js";
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
package/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,6BAA6B;AAC7B,gFAAgF;AAChF,iFAAiF;AACjF,iEAAiE;AAEjE,6BAA6B;AAC7B,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEvF,gEAAgE;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAG9C,+CAA+C;AAC/C,OAAO,EACL,eAAe,EACf,YAAY,EACZ,eAAe,EACf,aAAa,EACb,uBAAuB,EACvB,wBAAwB,GACzB,MAAM,cAAc,CAAC"}
|
package/mount.d.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type ScenarEmbedEvent, type ScenarEmbedHostController } from "@scenar/core";
|
|
2
|
+
import { type ScenarEmbedTheme } from "./resolve.js";
|
|
3
|
+
/** The embed's exact rendered size, reported over the `resize` event. */
|
|
4
|
+
export interface EmbedAspectRatio {
|
|
5
|
+
readonly widthPx: number;
|
|
6
|
+
readonly heightPx: number;
|
|
7
|
+
}
|
|
8
|
+
/** Options for {@link createEmbedMount}. */
|
|
9
|
+
export interface EmbedMountOptions {
|
|
10
|
+
/** The absolute embed URL, without a theme query (the mount adds it). */
|
|
11
|
+
readonly src: string;
|
|
12
|
+
/** Theme strategy (default `auto`). */
|
|
13
|
+
readonly theme?: ScenarEmbedTheme;
|
|
14
|
+
/** Called whenever the embed reports a new rendered size, for host layout. */
|
|
15
|
+
readonly onAspectRatio?: (ratio: EmbedAspectRatio) => void;
|
|
16
|
+
/** Called for every well-formed event from the pinned embed. */
|
|
17
|
+
readonly onEvent?: (event: ScenarEmbedEvent) => void;
|
|
18
|
+
}
|
|
19
|
+
/** A live mount: the host controller plus a teardown for all listeners. */
|
|
20
|
+
export interface EmbedMount {
|
|
21
|
+
/** Imperative transport (play/pause/seek/setMuted/setVolume) over the bridge. */
|
|
22
|
+
readonly controller: ScenarEmbedHostController;
|
|
23
|
+
/** Disconnect the theme observer and the controller's message listener. */
|
|
24
|
+
destroy(): void;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Wire an existing iframe to a hosted Scenar tour: set its themed `src`, pin the
|
|
28
|
+
* embed origin, adopt the embed's reported aspect ratio, and (for `theme:auto`)
|
|
29
|
+
* track the host's dark mode.
|
|
30
|
+
*
|
|
31
|
+
* This is the one place the loader's behavior lives. The `<scenar-embed>`
|
|
32
|
+
* element and the React `<ScenarEmbed>` are thin adapters that create the iframe
|
|
33
|
+
* + own layout, then hand it here — so neither re-implements the bridge, exactly
|
|
34
|
+
* as {@link createEmbedHostController} is shared by the console and this loader.
|
|
35
|
+
*
|
|
36
|
+
* The caller owns the iframe element (and removes it for full teardown); this
|
|
37
|
+
* function owns only the listeners it adds, all released by {@link EmbedMount.destroy}.
|
|
38
|
+
*/
|
|
39
|
+
export declare function createEmbedMount(iframe: HTMLIFrameElement, options: EmbedMountOptions): EmbedMount;
|
|
40
|
+
//# sourceMappingURL=mount.d.ts.map
|
package/mount.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mount.d.ts","sourceRoot":"","sources":["../src/mount.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,yBAAyB,EAE/B,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,KAAK,gBAAgB,EAItB,MAAM,cAAc,CAAC;AAEtB,yEAAyE;AACzE,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAED,4CAA4C;AAC5C,MAAM,WAAW,iBAAiB;IAChC,yEAAyE;IACzE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,uCAAuC;IACvC,QAAQ,CAAC,KAAK,CAAC,EAAE,gBAAgB,CAAC;IAClC,8EAA8E;IAC9E,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,gBAAgB,KAAK,IAAI,CAAC;IAC3D,gEAAgE;IAChE,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,gBAAgB,KAAK,IAAI,CAAC;CACtD;AAED,2EAA2E;AAC3E,MAAM,WAAW,UAAU;IACzB,iFAAiF;IACjF,QAAQ,CAAC,UAAU,EAAE,yBAAyB,CAAC;IAC/C,2EAA2E;IAC3E,OAAO,IAAI,IAAI,CAAC;CACjB;AAUD;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,iBAAiB,EACzB,OAAO,EAAE,iBAAiB,GACzB,UAAU,CAkDZ"}
|