@astl/astrolabe 0.0.0 → 0.1.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/CHANGELOG.md +119 -0
- package/LICENSE +202 -0
- package/README.md +65 -0
- package/dist/cdn/astrolabe-editor.js +1441 -0
- package/dist/cdn/astrolabe-editor.js.map +1 -0
- package/dist/cdn/astrolabe-player.js +2 -0
- package/dist/cdn/astrolabe-player.js.map +1 -0
- package/dist/cdn/astrolabe.css +238 -0
- package/dist/cdn/astrolabe.js +3 -0
- package/dist/cdn/astrolabe.js.map +1 -0
- package/dist/cdn/astrolabe.standalone.js +8007 -0
- package/dist/cdn/chunks/audio-B0LSIn5N.js +48 -0
- package/dist/cdn/chunks/audio-B0LSIn5N.js.map +1 -0
- package/dist/cdn/chunks/audio-manifest-B9FWQzRy.js +2 -0
- package/dist/cdn/chunks/audio-manifest-B9FWQzRy.js.map +1 -0
- package/dist/cdn/chunks/block-styles-CKo9x7Vt.js +68 -0
- package/dist/cdn/chunks/block-styles-CKo9x7Vt.js.map +1 -0
- package/dist/cdn/chunks/book-CHzDDaim.js +15 -0
- package/dist/cdn/chunks/book-CHzDDaim.js.map +1 -0
- package/dist/cdn/chunks/callout-QFLFLPc5.js +49 -0
- package/dist/cdn/chunks/callout-QFLFLPc5.js.map +1 -0
- package/dist/cdn/chunks/callout-manifest-Cb12O4jl.js +2 -0
- package/dist/cdn/chunks/callout-manifest-Cb12O4jl.js.map +1 -0
- package/dist/cdn/chunks/categorise-BO2tNVJ3.js +203 -0
- package/dist/cdn/chunks/categorise-BO2tNVJ3.js.map +1 -0
- package/dist/cdn/chunks/categorise-manifest-C_hEDVYQ.js +2 -0
- package/dist/cdn/chunks/categorise-manifest-C_hEDVYQ.js.map +1 -0
- package/dist/cdn/chunks/chip-styles-Dme5daTO.js +77 -0
- package/dist/cdn/chunks/chip-styles-Dme5daTO.js.map +1 -0
- package/dist/cdn/chunks/choice-CExBvqKj.js +136 -0
- package/dist/cdn/chunks/choice-CExBvqKj.js.map +1 -0
- package/dist/cdn/chunks/choice-manifest-C-XahD7m.js +2 -0
- package/dist/cdn/chunks/choice-manifest-C-XahD7m.js.map +1 -0
- package/dist/cdn/chunks/color-control-Cl5cuMSO.js +91 -0
- package/dist/cdn/chunks/color-control-Cl5cuMSO.js.map +1 -0
- package/dist/cdn/chunks/crossword-Cb-a3Tjj.js +270 -0
- package/dist/cdn/chunks/crossword-Cb-a3Tjj.js.map +1 -0
- package/dist/cdn/chunks/crossword-manifest-2qlu7AYd.js +2 -0
- package/dist/cdn/chunks/crossword-manifest-2qlu7AYd.js.map +1 -0
- package/dist/cdn/chunks/declarations-BhqOz1ap.js +2 -0
- package/dist/cdn/chunks/declarations-BhqOz1ap.js.map +1 -0
- package/dist/cdn/chunks/definitions-CNX90WtL.js +6 -0
- package/dist/cdn/chunks/definitions-CNX90WtL.js.map +1 -0
- package/dist/cdn/chunks/directive-helpers-D7lOZKnB.js +14 -0
- package/dist/cdn/chunks/directive-helpers-D7lOZKnB.js.map +1 -0
- package/dist/cdn/chunks/drop-manifest-bzNOa5ks.js +2 -0
- package/dist/cdn/chunks/drop-manifest-bzNOa5ks.js.map +1 -0
- package/dist/cdn/chunks/drop-vRXndjHu.js +86 -0
- package/dist/cdn/chunks/drop-vRXndjHu.js.map +1 -0
- package/dist/cdn/chunks/flash-cards-0NrrKdrx.js +87 -0
- package/dist/cdn/chunks/flash-cards-0NrrKdrx.js.map +1 -0
- package/dist/cdn/chunks/flash-cards-manifest-B8nWXbRy.js +2 -0
- package/dist/cdn/chunks/flash-cards-manifest-B8nWXbRy.js.map +1 -0
- package/dist/cdn/chunks/gap-lor-khst.js +78 -0
- package/dist/cdn/chunks/gap-lor-khst.js.map +1 -0
- package/dist/cdn/chunks/gap-manifest-RSydA41N.js +2 -0
- package/dist/cdn/chunks/gap-manifest-RSydA41N.js.map +1 -0
- package/dist/cdn/chunks/help-C-woafz5.js +138 -0
- package/dist/cdn/chunks/help-C-woafz5.js.map +1 -0
- package/dist/cdn/chunks/help-form-DaC6KaFG.js +160 -0
- package/dist/cdn/chunks/help-form-DaC6KaFG.js.map +1 -0
- package/dist/cdn/chunks/hotspot-manifest-CNs1oiZ_.js +2 -0
- package/dist/cdn/chunks/hotspot-manifest-CNs1oiZ_.js.map +1 -0
- package/dist/cdn/chunks/hotspot-oel1Eelo.js +154 -0
- package/dist/cdn/chunks/hotspot-oel1Eelo.js.map +1 -0
- package/dist/cdn/chunks/image-drop-Dkprw0Kn.js +295 -0
- package/dist/cdn/chunks/image-drop-Dkprw0Kn.js.map +1 -0
- package/dist/cdn/chunks/image-drop-manifest-BZ6hCoAd.js +2 -0
- package/dist/cdn/chunks/image-drop-manifest-BZ6hCoAd.js.map +1 -0
- package/dist/cdn/chunks/image-label-Dm5shQSh.js +177 -0
- package/dist/cdn/chunks/image-label-Dm5shQSh.js.map +1 -0
- package/dist/cdn/chunks/image-label-manifest--1CLRJzd.js +2 -0
- package/dist/cdn/chunks/image-label-manifest--1CLRJzd.js.map +1 -0
- package/dist/cdn/chunks/inline-styles-CTgXWnHb.js +80 -0
- package/dist/cdn/chunks/inline-styles-CTgXWnHb.js.map +1 -0
- package/dist/cdn/chunks/insert-menu-LgrifBYT.js +80 -0
- package/dist/cdn/chunks/insert-menu-LgrifBYT.js.map +1 -0
- package/dist/cdn/chunks/issue-list-BgnXzXRM.js +51 -0
- package/dist/cdn/chunks/issue-list-BgnXzXRM.js.map +1 -0
- package/dist/cdn/chunks/keys-DU-Qknmz.js +2 -0
- package/dist/cdn/chunks/keys-DU-Qknmz.js.map +1 -0
- package/dist/cdn/chunks/live-jdiyYln2.js +7 -0
- package/dist/cdn/chunks/live-jdiyYln2.js.map +1 -0
- package/dist/cdn/chunks/long-answer-CtzClLAx.js +71 -0
- package/dist/cdn/chunks/long-answer-CtzClLAx.js.map +1 -0
- package/dist/cdn/chunks/long-answer-manifest-BYJpZRtB.js +2 -0
- package/dist/cdn/chunks/long-answer-manifest-BYJpZRtB.js.map +1 -0
- package/dist/cdn/chunks/mark-words-CpH3gTcX.js +131 -0
- package/dist/cdn/chunks/mark-words-CpH3gTcX.js.map +1 -0
- package/dist/cdn/chunks/mark-words-manifest-Cs2pXCEx.js +2 -0
- package/dist/cdn/chunks/mark-words-manifest-Cs2pXCEx.js.map +1 -0
- package/dist/cdn/chunks/match-DKE_4o-x.js +352 -0
- package/dist/cdn/chunks/match-DKE_4o-x.js.map +1 -0
- package/dist/cdn/chunks/match-manifest-D0UfoajU.js +2 -0
- package/dist/cdn/chunks/match-manifest-D0UfoajU.js.map +1 -0
- package/dist/cdn/chunks/memory-B6hSyHyz.js +187 -0
- package/dist/cdn/chunks/memory-B6hSyHyz.js.map +1 -0
- package/dist/cdn/chunks/memory-manifest-D1589iR0.js +2 -0
- package/dist/cdn/chunks/memory-manifest-D1589iR0.js.map +1 -0
- package/dist/cdn/chunks/menu-messages-Dx3jYUEp.js +2 -0
- package/dist/cdn/chunks/menu-messages-Dx3jYUEp.js.map +1 -0
- package/dist/cdn/chunks/messages-9xiYDvRT.js +2 -0
- package/dist/cdn/chunks/messages-9xiYDvRT.js.map +1 -0
- package/dist/cdn/chunks/option-styles-WKzjKmCH.js +50 -0
- package/dist/cdn/chunks/option-styles-WKzjKmCH.js.map +1 -0
- package/dist/cdn/chunks/order-BhG_6IC-.js +225 -0
- package/dist/cdn/chunks/order-BhG_6IC-.js.map +1 -0
- package/dist/cdn/chunks/order-manifest-J5IXN0he.js +2 -0
- package/dist/cdn/chunks/order-manifest-J5IXN0he.js.map +1 -0
- package/dist/cdn/chunks/pick-and-place-DVQIPYuL.js +2 -0
- package/dist/cdn/chunks/pick-and-place-DVQIPYuL.js.map +1 -0
- package/dist/cdn/chunks/picture-D10YRMYH.js +2 -0
- package/dist/cdn/chunks/picture-D10YRMYH.js.map +1 -0
- package/dist/cdn/chunks/picture-view-BKnAyScQ.js +92 -0
- package/dist/cdn/chunks/picture-view-BKnAyScQ.js.map +1 -0
- package/dist/cdn/chunks/repeat-CY2W2URZ.js +8 -0
- package/dist/cdn/chunks/repeat-CY2W2URZ.js.map +1 -0
- package/dist/cdn/chunks/roving-focus-BxGgi2DD.js +2 -0
- package/dist/cdn/chunks/roving-focus-BxGgi2DD.js.map +1 -0
- package/dist/cdn/chunks/runtime-DxAbpr3S.js +526 -0
- package/dist/cdn/chunks/runtime-DxAbpr3S.js.map +1 -0
- package/dist/cdn/chunks/scan-jWgPnVxA.js +2 -0
- package/dist/cdn/chunks/scan-jWgPnVxA.js.map +1 -0
- package/dist/cdn/chunks/select-DTA3dJzr.js +345 -0
- package/dist/cdn/chunks/select-DTA3dJzr.js.map +1 -0
- package/dist/cdn/chunks/select-manifest-BBMbvdkH.js +2 -0
- package/dist/cdn/chunks/select-manifest-BBMbvdkH.js.map +1 -0
- package/dist/cdn/chunks/source-view-DXKPFCl9.js +29 -0
- package/dist/cdn/chunks/source-view-DXKPFCl9.js.map +1 -0
- package/dist/cdn/chunks/style-form-D5haJtWM.js +240 -0
- package/dist/cdn/chunks/style-form-D5haJtWM.js.map +1 -0
- package/dist/cdn/chunks/style-messages-BbZpeD2a.js +2 -0
- package/dist/cdn/chunks/style-messages-BbZpeD2a.js.map +1 -0
- package/dist/cdn/chunks/style-model-ZXNe_c8R.js +2 -0
- package/dist/cdn/chunks/style-model-ZXNe_c8R.js.map +1 -0
- package/dist/cdn/chunks/style-placing-DPw1zyrz.js +2 -0
- package/dist/cdn/chunks/style-placing-DPw1zyrz.js.map +1 -0
- package/dist/cdn/chunks/style-popups-BobgX1WK.js +74 -0
- package/dist/cdn/chunks/style-popups-BobgX1WK.js.map +1 -0
- package/dist/cdn/chunks/style-rules-D45PZLCv.js +136 -0
- package/dist/cdn/chunks/style-rules-D45PZLCv.js.map +1 -0
- package/dist/cdn/chunks/styled-Dmx5Yjv7.js +57 -0
- package/dist/cdn/chunks/styled-Dmx5Yjv7.js.map +1 -0
- package/dist/cdn/chunks/styles-DxJJxVNH.js +136 -0
- package/dist/cdn/chunks/styles-DxJJxVNH.js.map +1 -0
- package/dist/cdn/chunks/surface-CgxfAwCR.js +1019 -0
- package/dist/cdn/chunks/surface-CgxfAwCR.js.map +1 -0
- package/dist/cdn/chunks/true-false-DP3MO599.js +146 -0
- package/dist/cdn/chunks/true-false-DP3MO599.js.map +1 -0
- package/dist/cdn/chunks/true-false-manifest-B4exv60u.js +2 -0
- package/dist/cdn/chunks/true-false-manifest-B4exv60u.js.map +1 -0
- package/dist/cdn/chunks/video-j9MCH6Kw.js +98 -0
- package/dist/cdn/chunks/video-j9MCH6Kw.js.map +1 -0
- package/dist/cdn/chunks/video-manifest-8OwkhhAI.js +2 -0
- package/dist/cdn/chunks/video-manifest-8OwkhhAI.js.map +1 -0
- package/dist/cdn/chunks/word-bank-ARjwUKZf.js +80 -0
- package/dist/cdn/chunks/word-bank-ARjwUKZf.js.map +1 -0
- package/dist/cdn/chunks/word-bank-manifest-C1FSo1kH.js +2 -0
- package/dist/cdn/chunks/word-bank-manifest-C1FSo1kH.js.map +1 -0
- package/dist/cdn/chunks/word-search-AHvM7yCJ.js +274 -0
- package/dist/cdn/chunks/word-search-AHvM7yCJ.js.map +1 -0
- package/dist/cdn/chunks/word-search-manifest-Fg1a59Z1.js +2 -0
- package/dist/cdn/chunks/word-search-manifest-Fg1a59Z1.js.map +1 -0
- package/dist/editor.d.ts +32 -0
- package/dist/editor.d.ts.map +1 -0
- package/dist/editor.js +51 -0
- package/dist/editor.js.map +1 -0
- package/dist/engine.d.ts +33 -0
- package/dist/engine.d.ts.map +1 -0
- package/dist/engine.js +53 -0
- package/dist/engine.js.map +1 -0
- package/dist/player.d.ts +19 -0
- package/dist/player.d.ts.map +1 -0
- package/dist/player.js +22 -0
- package/dist/player.js.map +1 -0
- package/dist/server.d.ts +8 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +8 -0
- package/dist/server.js.map +1 -0
- package/package.json +70 -4
- package/src/bundles/astrolabe-editor.ts +11 -0
- package/src/bundles/astrolabe-player.ts +10 -0
- package/src/bundles/astrolabe-standalone.ts +23 -0
- package/src/bundles/astrolabe.ts +12 -0
- package/src/editor.ts +98 -0
- package/src/engine.ts +59 -0
- package/src/player.ts +23 -0
- package/src/server.ts +7 -0
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import{C as e,E as t,b as n}from"./runtime-DxAbpr3S.js";import"./declarations-BhqOz1ap.js";import{n as r,r as i,t as a}from"./styles-DxJJxVNH.js";import{a as o}from"./style-placing-DPw1zyrz.js";import{t as s}from"./style-messages-BbZpeD2a.js";var c=[[`paragraph`,`p`],[`heading`,`h3`],[`subheading`,`h4`],[`quote`,`blockquote`],[`list`,`li`],[`caption`,`figcaption`],[`picture`,`img`]],l=class extends i{static styles=[r,a(`astl-style-form`),t`
|
|
2
|
+
h3 {
|
|
3
|
+
margin: 0;
|
|
4
|
+
font-size: 1rem;
|
|
5
|
+
}
|
|
6
|
+
li.row {
|
|
7
|
+
display: flex;
|
|
8
|
+
flex-direction: column;
|
|
9
|
+
gap: var(--astl-space-2);
|
|
10
|
+
}
|
|
11
|
+
.line {
|
|
12
|
+
display: flex;
|
|
13
|
+
flex-wrap: wrap;
|
|
14
|
+
align-items: center;
|
|
15
|
+
gap: var(--astl-space-1);
|
|
16
|
+
}
|
|
17
|
+
.line > .name {
|
|
18
|
+
flex: 1 1 8rem;
|
|
19
|
+
justify-content: flex-start;
|
|
20
|
+
}
|
|
21
|
+
.line > .name::after {
|
|
22
|
+
content: '';
|
|
23
|
+
margin-inline-start: auto;
|
|
24
|
+
border-block: 0.3em solid transparent;
|
|
25
|
+
border-inline-start: 0.45em solid currentColor;
|
|
26
|
+
}
|
|
27
|
+
.line > .name[aria-expanded='true']::after {
|
|
28
|
+
rotate: 90deg;
|
|
29
|
+
}
|
|
30
|
+
.line > input {
|
|
31
|
+
flex: 1 1 8rem;
|
|
32
|
+
inline-size: auto;
|
|
33
|
+
}
|
|
34
|
+
form {
|
|
35
|
+
display: grid;
|
|
36
|
+
grid-template-columns: minmax(0, 1fr) auto;
|
|
37
|
+
gap: var(--astl-space-2);
|
|
38
|
+
align-items: end;
|
|
39
|
+
}
|
|
40
|
+
form label {
|
|
41
|
+
grid-column: 1 / -1;
|
|
42
|
+
font-weight: 600;
|
|
43
|
+
}
|
|
44
|
+
.undo {
|
|
45
|
+
align-self: flex-start;
|
|
46
|
+
}
|
|
47
|
+
.summary {
|
|
48
|
+
color: var(--astl-ink-muted);
|
|
49
|
+
font-size: var(--astl-size-small);
|
|
50
|
+
}
|
|
51
|
+
`];#e=null;#t=null;#n=``;willUpdate(e){super.willUpdate(e),e.has(`authoring`)&&this.authoring?.addMessages(s)}#r(){return this.adapter?.style??null}#i(e){this.#e=this.#e===e?null:e,this.requestUpdate()}#a(t){return e`<astl-style-form
|
|
52
|
+
.authoring=${this.authoring}
|
|
53
|
+
.adapter=${this.adapter}
|
|
54
|
+
.rule=${t}
|
|
55
|
+
></astl-style-form>`}#o(){let e=this.#r(),t=this.#n.trim();if(e===null||t===``){this.renderRoot.querySelector(`#new-style`)?.focus();return}let n=new Set(e.rules().flatMap(e=>e.name??[])),r=o(t,n);e.setRule({name:r,label:t,style:``})&&(this.#n=``,this.#e=`name:${r}`),this.requestUpdate()}#s(e,t){if(this.#t!==e.name)return;let n=t.trim();n!==``&&this.#r()?.setRule({...e,label:n}),this.#t=null,this.requestUpdate()}#c(e){this.#r()?.removeRule({...e.name===void 0?{}:{name:e.name}}),this.#e===`name:${e.name}`&&(this.#e=null),this.requestUpdate(),this.updateComplete.then(()=>this.renderRoot.querySelector(`#new-style`)?.focus())}#l(t){let r=`name:${t.name}`,i=t.label??t.name??``,a=this.#e===r;return e`<li class="row" data-style=${t.name??``}>
|
|
56
|
+
<div class="line">
|
|
57
|
+
${this.#t===t.name?e`<input
|
|
58
|
+
type="text"
|
|
59
|
+
aria-label=${this.t(`style.rules.renameField`,{label:i})}
|
|
60
|
+
.value=${i}
|
|
61
|
+
@change=${e=>this.#s(t,e.target.value)}
|
|
62
|
+
@keydown=${e=>{e.key===`Enter`?(e.preventDefault(),this.#s(t,e.target.value)):e.key===`Escape`&&(e.preventDefault(),this.#t=null,this.requestUpdate())}}
|
|
63
|
+
/>`:e`<button
|
|
64
|
+
type="button"
|
|
65
|
+
class="name"
|
|
66
|
+
data-edit
|
|
67
|
+
aria-expanded=${String(a)}
|
|
68
|
+
aria-label=${this.t(`style.rules.edit`,{label:i})}
|
|
69
|
+
@click=${()=>this.#i(r)}
|
|
70
|
+
>
|
|
71
|
+
${i}
|
|
72
|
+
</button>`}
|
|
73
|
+
<button
|
|
74
|
+
type="button"
|
|
75
|
+
data-rename
|
|
76
|
+
aria-label=${this.t(`style.rules.rename`,{label:i})}
|
|
77
|
+
@click=${()=>{this.#t=t.name??null,this.requestUpdate(),this.updateComplete.then(()=>this.renderRoot.querySelector(`[data-style="${t.name}"] input`)?.select())}}
|
|
78
|
+
>
|
|
79
|
+
${this.t(`style.rules.renameShort`)}
|
|
80
|
+
</button>
|
|
81
|
+
<button
|
|
82
|
+
type="button"
|
|
83
|
+
data-delete
|
|
84
|
+
aria-label=${this.t(`style.rules.delete`,{label:i})}
|
|
85
|
+
@click=${()=>this.#c(t)}
|
|
86
|
+
>
|
|
87
|
+
${this.t(`style.rules.deleteShort`)}
|
|
88
|
+
</button>
|
|
89
|
+
</div>
|
|
90
|
+
${a?this.#a({...t.name===void 0?{}:{name:t.name}}):n}
|
|
91
|
+
</li>`}render(){if(this.authoring===null)return n;let{lang:t,dir:r}=this.ui,i=this.#r();if(i===null)return e`<p class="note" lang=${t} dir=${r}>${this.t(`style.form.none`)}</p>`;let a=i.rules(),o=a.filter(e=>e.name!==void 0),s=a.length>=100;return e`<section class="kit" part="root" lang=${t} dir=${r} aria-labelledby="rules-title">
|
|
92
|
+
<h2 class="title" id="rules-title" part="title">${this.t(`style.rules.title`)}</h2>
|
|
93
|
+
<h3 id="tags-title">${this.t(`style.rules.tags`)}</h3>
|
|
94
|
+
<ul role="list" aria-labelledby="tags-title">
|
|
95
|
+
${c.map(([t,r])=>{let i=`for:${r}`,o=this.#e===i,s=this.t(`style.tag.${t}`),c=a.find(e=>e.for===r)?.style;return e`<li class="row" data-for=${r}>
|
|
96
|
+
<div class="line">
|
|
97
|
+
<button
|
|
98
|
+
type="button"
|
|
99
|
+
class="name"
|
|
100
|
+
data-edit
|
|
101
|
+
aria-expanded=${String(o)}
|
|
102
|
+
aria-label=${this.t(`style.rules.edit`,{label:s})}
|
|
103
|
+
@click=${()=>this.#i(i)}
|
|
104
|
+
>
|
|
105
|
+
${s}
|
|
106
|
+
</button>
|
|
107
|
+
</div>
|
|
108
|
+
${c===void 0?n:e`<span class="summary">${c}</span>`}
|
|
109
|
+
${o?this.#a({for:r}):n}
|
|
110
|
+
</li>`})}
|
|
111
|
+
</ul>
|
|
112
|
+
<h3 id="named-title">${this.t(`toolbar.myStyles`)}</h3>
|
|
113
|
+
${o.length===0?e`<p class="note">${this.t(`style.rules.empty`)}</p>`:e`<ul role="list" aria-labelledby="named-title">${o.map(e=>this.#l(e))}</ul>`}
|
|
114
|
+
<form
|
|
115
|
+
@submit=${e=>{e.preventDefault(),this.#o()}}
|
|
116
|
+
>
|
|
117
|
+
<label for="new-style">${this.t(`style.rules.newLabel`)}</label>
|
|
118
|
+
<input
|
|
119
|
+
id="new-style"
|
|
120
|
+
type="text"
|
|
121
|
+
autocomplete="off"
|
|
122
|
+
.value=${this.#n}
|
|
123
|
+
@input=${e=>{this.#n=e.target.value}}
|
|
124
|
+
/>
|
|
125
|
+
<button type="submit" data-add ?disabled=${s}>${this.t(`style.rules.add`)}</button>
|
|
126
|
+
</form>
|
|
127
|
+
${this.adapter?.undo===void 0?n:e`<button
|
|
128
|
+
type="button"
|
|
129
|
+
class="undo"
|
|
130
|
+
data-undo
|
|
131
|
+
@click=${e=>{let t=e.currentTarget;this.adapter?.undo?.(),requestAnimationFrame(()=>t.focus()),this.requestUpdate()}}
|
|
132
|
+
>
|
|
133
|
+
${this.t(`toolbar.undo`)}
|
|
134
|
+
</button>`}
|
|
135
|
+
</section>`}};export{l as AstlStyleRules};
|
|
136
|
+
//# sourceMappingURL=style-rules-D45PZLCv.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"style-rules-D45PZLCv.js","names":["nothing","b","i","A","kitStyles","AuthoringElement","inheritTokens","styleNameFrom","styleMessages","TAGS","AstlStyleRules","changed","#open","key","rule","styles","#styles","label","#newLabel","taken","name","#renaming","text","open","#rename","event","#toggle","#delete","#form","lang","dir","rules","named","full","tag","id","own","#namedRow","#add","button"],"sources":["../../../../editor/src/elements/style-rules.ts"],"sourcesContent":["import type { EditorStyleRule } from '@astl/core';\nimport { MAX_STYLE_RULES } from '@astl/core/declarations';\nimport { type CSSResultGroup, css, html, nothing, type PropertyValues, type TemplateResult } from 'lit';\nimport { styleMessages } from '../style-messages.js';\nimport { styleNameFrom } from '../style-placing.js';\nimport { AuthoringElement } from './base.js';\nimport { inheritTokens, kitStyles } from './styles.js';\n\n/** The tags of \"Text styles\": what authors call them, and the element each rule reaches. */\nconst TAGS: readonly (readonly [key: string, tag: string])[] = [\n ['paragraph', 'p'],\n ['heading', 'h3'],\n ['subheading', 'h4'],\n ['quote', 'blockquote'],\n ['list', 'li'],\n ['caption', 'figcaption'],\n ['picture', 'img'],\n];\n\n/**\n * `<astl-style-rules>`: the document's rules, each opening the form that edits it. \"Text styles\" holds a rule per tag\n * (every paragraph, every heading of the exercise), \"My styles\" the named ones: add, rename, edit, delete. A deleted\n * style leaves no class behind. Everything is one undo step, undone here or in the editor. A host places it (a view of\n * its own, a card), with `authoring` and `adapter`, after `loadStyleElements`; the toolbar's style menu opens it in a\n * popup otherwise.\n */\nexport class AstlStyleRules extends AuthoringElement {\n static override styles: CSSResultGroup = [\n kitStyles,\n inheritTokens('astl-style-form'),\n css`\n h3 {\n margin: 0;\n font-size: 1rem;\n }\n li.row {\n display: flex;\n flex-direction: column;\n gap: var(--astl-space-2);\n }\n .line {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: var(--astl-space-1);\n }\n .line > .name {\n flex: 1 1 8rem;\n justify-content: flex-start;\n }\n .line > .name::after {\n content: '';\n margin-inline-start: auto;\n border-block: 0.3em solid transparent;\n border-inline-start: 0.45em solid currentColor;\n }\n .line > .name[aria-expanded='true']::after {\n rotate: 90deg;\n }\n .line > input {\n flex: 1 1 8rem;\n inline-size: auto;\n }\n form {\n display: grid;\n grid-template-columns: minmax(0, 1fr) auto;\n gap: var(--astl-space-2);\n align-items: end;\n }\n form label {\n grid-column: 1 / -1;\n font-weight: 600;\n }\n .undo {\n align-self: flex-start;\n }\n .summary {\n color: var(--astl-ink-muted);\n font-size: var(--astl-size-small);\n }\n `,\n ];\n\n /** The rule whose form is open: `for:<tag>` or `name:<name>`. */\n #open: string | null = null;\n /** The named style being renamed. */\n #renaming: string | null = null;\n #newLabel = '';\n\n protected override willUpdate(changed: PropertyValues<this>): void {\n super.willUpdate(changed);\n if (changed.has('authoring')) this.authoring?.addMessages(styleMessages);\n }\n\n #styles() {\n return this.adapter?.style ?? null;\n }\n\n #toggle(key: string): void {\n this.#open = this.#open === key ? null : key;\n this.requestUpdate();\n }\n\n #form(rule: Pick<EditorStyleRule, 'name' | 'for'>): TemplateResult {\n return html`<astl-style-form\n .authoring=${this.authoring}\n .adapter=${this.adapter}\n .rule=${rule}\n ></astl-style-form>`;\n }\n\n #add(): void {\n const styles = this.#styles();\n const label = this.#newLabel.trim();\n if (styles === null || label === '') {\n this.renderRoot.querySelector<HTMLInputElement>('#new-style')?.focus();\n return;\n }\n const taken = new Set(styles.rules().flatMap((rule) => rule.name ?? []));\n const name = styleNameFrom(label, taken);\n if (styles.setRule({ name, label, style: '' })) {\n this.#newLabel = '';\n this.#open = `name:${name}`;\n }\n this.requestUpdate();\n }\n\n #rename(rule: EditorStyleRule, text: string): void {\n // Removing the field after Enter or Escape fires its change: that one is not a rename.\n if (this.#renaming !== rule.name) return;\n const label = text.trim();\n if (label !== '') this.#styles()?.setRule({ ...rule, label });\n this.#renaming = null;\n this.requestUpdate();\n }\n\n #delete(rule: EditorStyleRule): void {\n this.#styles()?.removeRule({ ...(rule.name === undefined ? {} : { name: rule.name }) });\n if (this.#open === `name:${rule.name}`) this.#open = null;\n // The row and its button are gone: the focus goes to what is next to it for sure.\n this.requestUpdate();\n void this.updateComplete.then(() => this.renderRoot.querySelector<HTMLElement>('#new-style')?.focus());\n }\n\n #namedRow(rule: EditorStyleRule): TemplateResult {\n const key = `name:${rule.name}`;\n const label = rule.label ?? rule.name ?? '';\n const open = this.#open === key;\n return html`<li class=\"row\" data-style=${rule.name ?? ''}>\n <div class=\"line\">\n ${\n this.#renaming === rule.name\n ? html`<input\n type=\"text\"\n aria-label=${this.t('style.rules.renameField', { label })}\n .value=${label}\n @change=${(event: Event) => this.#rename(rule, (event.target as HTMLInputElement).value)}\n @keydown=${(event: KeyboardEvent) => {\n if (event.key === 'Enter') {\n event.preventDefault();\n this.#rename(rule, (event.target as HTMLInputElement).value);\n } else if (event.key === 'Escape') {\n event.preventDefault();\n this.#renaming = null;\n this.requestUpdate();\n }\n }}\n />`\n : html`<button\n type=\"button\"\n class=\"name\"\n data-edit\n aria-expanded=${String(open)}\n aria-label=${this.t('style.rules.edit', { label })}\n @click=${() => this.#toggle(key)}\n >\n ${label}\n </button>`\n }\n <button\n type=\"button\"\n data-rename\n aria-label=${this.t('style.rules.rename', { label })}\n @click=${() => {\n this.#renaming = rule.name ?? null;\n this.requestUpdate();\n void this.updateComplete.then(() =>\n this.renderRoot.querySelector<HTMLInputElement>(`[data-style=\"${rule.name}\"] input`)?.select(),\n );\n }}\n >\n ${this.t('style.rules.renameShort')}\n </button>\n <button\n type=\"button\"\n data-delete\n aria-label=${this.t('style.rules.delete', { label })}\n @click=${() => this.#delete(rule)}\n >\n ${this.t('style.rules.deleteShort')}\n </button>\n </div>\n ${open ? this.#form({ ...(rule.name === undefined ? {} : { name: rule.name }) }) : nothing}\n </li>`;\n }\n\n protected override render(): TemplateResult | typeof nothing {\n if (this.authoring === null) return nothing;\n const { lang, dir } = this.ui;\n const styles = this.#styles();\n if (styles === null)\n return html`<p class=\"note\" lang=${lang} dir=${dir}>${this.t('style.form.none')}</p>`;\n const rules = styles.rules();\n const named = rules.filter((rule) => rule.name !== undefined);\n const full = rules.length >= MAX_STYLE_RULES;\n return html`<section class=\"kit\" part=\"root\" lang=${lang} dir=${dir} aria-labelledby=\"rules-title\">\n <h2 class=\"title\" id=\"rules-title\" part=\"title\">${this.t('style.rules.title')}</h2>\n <h3 id=\"tags-title\">${this.t('style.rules.tags')}</h3>\n <ul role=\"list\" aria-labelledby=\"tags-title\">\n ${TAGS.map(([key, tag]) => {\n const id = `for:${tag}`;\n const open = this.#open === id;\n const label = this.t(`style.tag.${key}`);\n const own = rules.find((rule) => rule.for === tag)?.style;\n return html`<li class=\"row\" data-for=${tag}>\n <div class=\"line\">\n <button\n type=\"button\"\n class=\"name\"\n data-edit\n aria-expanded=${String(open)}\n aria-label=${this.t('style.rules.edit', { label })}\n @click=${() => this.#toggle(id)}\n >\n ${label}\n </button>\n </div>\n ${own === undefined ? nothing : html`<span class=\"summary\">${own}</span>`}\n ${open ? this.#form({ for: tag }) : nothing}\n </li>`;\n })}\n </ul>\n <h3 id=\"named-title\">${this.t('toolbar.myStyles')}</h3>\n ${\n named.length === 0\n ? html`<p class=\"note\">${this.t('style.rules.empty')}</p>`\n : html`<ul role=\"list\" aria-labelledby=\"named-title\">${named.map((rule) => this.#namedRow(rule))}</ul>`\n }\n <form\n @submit=${(event: Event) => {\n event.preventDefault();\n this.#add();\n }}\n >\n <label for=\"new-style\">${this.t('style.rules.newLabel')}</label>\n <input\n id=\"new-style\"\n type=\"text\"\n autocomplete=\"off\"\n .value=${this.#newLabel}\n @input=${(event: Event) => {\n this.#newLabel = (event.target as HTMLInputElement).value;\n }}\n />\n <button type=\"submit\" data-add ?disabled=${full}>${this.t('style.rules.add')}</button>\n </form>\n ${\n this.adapter?.undo === undefined\n ? nothing\n : html`<button\n type=\"button\"\n class=\"undo\"\n data-undo\n @click=${(event: Event) => {\n const button = event.currentTarget as HTMLElement;\n this.adapter?.undo?.();\n // Undoing focuses the text a frame later; the author is still here, and in a host's view the text is\n // not on show.\n requestAnimationFrame(() => button.focus());\n this.requestUpdate();\n }}\n >\n ${this.t('toolbar.undo')}\n </button>`\n }\n </section>`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'astl-style-rules': AstlStyleRules;\n }\n}\n"],"mappings":"A,mPASA,IAAMS,EAAyD,CAC7D,CAAC,YAAa,GAAG,EACjB,CAAC,UAAW,IAAI,EAChB,CAAC,aAAc,IAAI,EACnB,CAAC,QAAS,YAAY,EACtB,CAAC,OAAQ,IAAI,EACb,CAAC,UAAW,YAAY,EACxB,CAAC,UAAW,KAAK,CACnB,EASaC,EAAb,cAAoCL,CAAiB,CACnD,OAAgB,OAAyB,CACvCD,EACAE,EAAc,iBAAiB,EAC/B,CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmDL,EAGA,GAAuB,KAEvB,GAA2B,KAC3B,GAAY,GAEZ,WAA8B,EAAqC,CACjE,MAAM,WAAWK,CAAO,EACpBA,EAAQ,IAAI,WAAW,GAAG,KAAK,WAAW,YAAYH,CAAa,CACzE,CAEA,IAAU,CACR,OAAO,KAAK,SAAS,OAAS,IAChC,CAEA,GAAQ,EAAmB,CACzB,KAAKI,GAAQ,KAAKA,KAAUC,EAAM,KAAOA,EACzC,KAAK,cAAc,CACrB,CAEA,GAAM,EAA6D,CACjE,MAAO,EAAI;mBACI,KAAK,UAAU;iBACjB,KAAK,QAAQ;cAChBC,EAAK;wBAEjB,CAEA,IAAa,CACX,IAAMC,EAAS,KAAKC,GAAQ,EACtBC,EAAQ,KAAKC,GAAU,KAAK,EAClC,GAAIH,IAAW,MAAQE,IAAU,GAAI,CACnC,KAAK,WAAW,cAAgC,YAAY,CAAC,EAAE,MAAM,EACrE,MACF,CACA,IAAME,EAA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ime-DxAbpr3S.js";import{d as r,l as i,o as a,u as o}from"./declarations-BhqOz1ap.js";var s=4.6,c=/#[0-9a-f]+|rgba?\([^()]*\)/g,l=/^[\d.]/,u=new Set([`width`,`max-width`,`inline-size`,`max-inline-size`]),d=e=>e===`background-color`||e===`box-shadow`?`--astl-author-ground`:`--astl-author-ink`,f=e=>o(e),p=f(t.themes.dark[`surface-raised`]),m=f(t.themes.dark.ink);function h([e,t,n]){let[r,i,a]=[e/255,t/255,n/255],o=Math.max(r,i,a),s=Math.min(r,i,a),c=(o+s)/2,l=o-s;return l===0?[0,0,c]:[o===r?((i-a)/l+6)%6:o===i?(a-r)/l+2:(r-i)/l+4,l/(1-Math.abs(2*c-1)),c]}function g([e,t,n],r){let i=t*Math.min(n,1-n),a=t=>{let r=(t+e*2)%12;return Math.round((n-i*Math.max(-1,Math.min(r-3,9-r,1)))*255)};return[a(0),a(8),a(4),r]}function _(e){let[t,n,r]=h(e);return g([t,n,1-r],e[3])}var v=(e,t)=>r(i(e,t),t);function y(e,t){if(v(e,t)>=s)return e;let[n,r,i]=h(e),a=t=>g([n,r,t],e[3]),o=+(v(a(1),t)>=v(a(0),t)),c=i;for(let e=0;e<8;e++){let e=(o+c)/2;v(a(e),t)>=s?o=e:c=e}return a(o)}var b=([e,t,n,r])=>{let i=[e,t,n].map(Math.round).join(`, `);return r===1?`rgb(${i})`:`rgba(${i}, ${r})`},x=(e,t)=>{let n=e.find(([e])=>e===t)?.[1];return n===void 0?null:o(n)};function S(e,t){let n=t.inked||x(e,`color`)!==null,r=x(e,`background-color`);if(r===null)return{ground:t.ground,inked:n};let a=i(_(r),t.ground);return{ground:n?a:y(a,m),inked:n}}function C(e,t,n){return e===`font-family`?t:e===`font-size`?l.test(t)?`clamp(0.625rem, ${t}, 6rem)`:t:u.has(e)?l.test(t)&&!t.endsWith(`%`)?`min(${t}, 100%)`:t:t.replace(c,t=>{let r=f(t),i=e===`color`?y(_(r),n.ground):e===`background-color`?n.ground:_(r);return`var(${d(e)}, light-dark(${t}, ${b(i)}))`})}function w(e){let t=new Map,r=new Map,i={ground:p,inked:!1};for(let o of Array.from(e.querySelectorAll(`[${n}]`))){let{declarations:e}=a(o.getAttribute(`data-astl-style`)??``);o.removeAttribute(n);let s=i;for(let e=o.parentElement;e!==null;e=e.parentElement){let t=r.get(e);if(t!==void 0){s=t;break}}let c=S(e,s);r.set(o,c),t.set(o,e.map(([e,t])=>[e,C(e,t,c)]))}return t}function T(e,t,n){let r=n.querySelectorAll(`*`);t.querySelectorAll(`*`).forEach((t,n)=>{for(let[i,a]of e.get(t)??[])r[n]?.style.setProperty(i,a)})}var E=e`
|
|
2
|
+
.canvas {
|
|
3
|
+
container-type: inline-size;
|
|
4
|
+
}
|
|
5
|
+
.canvas astl-doc,
|
|
6
|
+
.canvas astl-page:not([hidden]) {
|
|
7
|
+
display: flow-root;
|
|
8
|
+
}
|
|
9
|
+
.canvas astl-page {
|
|
10
|
+
overflow-x: clip;
|
|
11
|
+
overflow-clip-margin: var(--astl-space-5);
|
|
12
|
+
}
|
|
13
|
+
.canvas [style][hidden] {
|
|
14
|
+
display: none !important;
|
|
15
|
+
}
|
|
16
|
+
.canvas [style] {
|
|
17
|
+
box-sizing: border-box;
|
|
18
|
+
max-inline-size: 100%;
|
|
19
|
+
}
|
|
20
|
+
.canvas astl-columns {
|
|
21
|
+
display: flex;
|
|
22
|
+
flex-wrap: wrap;
|
|
23
|
+
clear: both;
|
|
24
|
+
gap: var(--astl-space-4);
|
|
25
|
+
margin-block-end: var(--astl-space-4);
|
|
26
|
+
}
|
|
27
|
+
.canvas astl-columns > astl-column {
|
|
28
|
+
flex: 1 1 0;
|
|
29
|
+
min-inline-size: min(10rem, 100%);
|
|
30
|
+
}
|
|
31
|
+
.canvas astl-columns > astl-column > :first-child {
|
|
32
|
+
margin-block-start: 0;
|
|
33
|
+
}
|
|
34
|
+
.canvas astl-columns > astl-column > :last-child {
|
|
35
|
+
margin-block-end: 0;
|
|
36
|
+
}
|
|
37
|
+
:host([data-theme='hc']) {
|
|
38
|
+
--astl-author-ink: currentcolor;
|
|
39
|
+
--astl-author-ground: transparent;
|
|
40
|
+
}
|
|
41
|
+
@container (max-inline-size: 30rem) {
|
|
42
|
+
.canvas [style*='float'] {
|
|
43
|
+
float: none !important;
|
|
44
|
+
inline-size: auto !important;
|
|
45
|
+
}
|
|
46
|
+
.canvas [style*='margin']:not([style*='auto']) {
|
|
47
|
+
margin-inline: 0 !important;
|
|
48
|
+
}
|
|
49
|
+
.canvas [style*='padding'] {
|
|
50
|
+
padding-inline: min(var(--astl-space-3), 5%) !important;
|
|
51
|
+
}
|
|
52
|
+
.canvas img[style*='float'] {
|
|
53
|
+
display: block;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
`.styleSheet;function D(e){E!==void 0&&e instanceof ShadowRoot&&!e.adoptedStyleSheets.includes(E)&&(e.adoptedStyleSheets=[...e.adoptedStyleSheets,E])}export{D as adoptStyledSheet,T as applyStyles,w as takeStyles};
|
|
57
|
+
//# sourceMappingURL=styled-Dmx5Yjv7.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styled-Dmx5Yjv7.js","names":["i","tokens","INERT_STYLE","styleContrast","overStyleColor","cleanStyle","parseStyleColor","MIN_CONTRAST","RAW_COLOR","LENGTH","MEASURES","offWith","name","hex","value","DARK_SURFACE","DARK_INK","toHsl","red","green","blue","g","b","max","min","lightness","chroma","fromHsl","hue","saturation","a","channel","k","at","alpha","inverted","color","contrastOn","ink","ground","legible","l","reads","fails","step","middle","written","channels","declared","declarations","property","darkContext","inked","around","fill","dark","painted","raw","context","takeStyles","taken","contexts","page","el","fragment","up","known","applyStyles","copies","content","index","styledSheet","adoptStyledSheet","root"],"sources":["../../../../player/src/player/styled.ts"],"sourcesContent":["/**\n * Authors' styles and layouts in the player, in a module of its own: a view that has neither never loads it. Without it\n * (or when its chunk fails) `cleanView` removes every `style`, and the exercise plays unstyled.\n *\n * A view is engine output, and is still read as hostile here: each `style` goes through `cleanStyle` again. Declarations\n * are written with `el.style.setProperty`, on the mounted copy of the view: a strict CSP (`style-src 'self'`) blocks a\n * `style` attribute, and allows the CSSOM.\n *\n * What an author writes for a light page is changed in four ways, which is why nothing here is a plain copy:\n * - a colour becomes `light-dark(as written, lightness inverted)`, so it follows the player's `color-scheme`; text keeps\n * the nearest lightness that can be read on its ground, because inverting a colour of middle lightness changes nothing;\n * - in `hc` a colour resolves to `--astl-author-ink` or `--astl-author-ground`, set only there. A custom property, not\n * `!important` in the sheet, because it also reaches the copies components keep of their content in shadow roots;\n * - a font size is clamped: relative sizes compound through nesting;\n * - a width stays within its box: an inline `max-width` would beat any cap in a sheet.\n */\nimport { INERT_STYLE } from '@astl/core';\nimport {\n cleanStyle,\n overStyleColor,\n parseStyleColor,\n type StyleColor,\n type StyleDeclaration,\n styleContrast,\n} from '@astl/core/declarations';\nimport { tokens } from '@astl/tokens';\nimport { css } from 'lit';\n\n/**\n * The contrast text keeps on its ground in the dark: the one the engine asks of the light page (WCAG AA), and a little\n * more, because this module knows the theme's surfaces and not those of the looks, a shade lighter (a test holds the\n * built-in ones to 4.5).\n */\nconst MIN_CONTRAST = 4.6;\nconst RAW_COLOR = /#[0-9a-f]+|rgba?\\([^()]*\\)/g;\nconst LENGTH = /^[\\d.]/;\nconst MEASURES: ReadonlySet<string> = new Set(['width', 'max-width', 'inline-size', 'max-inline-size']);\n\n/** Off in `hc`: what is drawn on (a fill, a shadow) goes; what is drawn with (text, lines) takes the text colour. */\nconst offWith = (name: string): string =>\n name === 'background-color' || name === 'box-shadow' ? '--astl-author-ground' : '--astl-author-ink';\n\nconst hex = (value: string): StyleColor => parseStyleColor(value) as StyleColor;\n/** The lighter of the theme's surfaces: text sits on both. */\nconst DARK_SURFACE = hex(tokens.themes.dark['surface-raised']);\nconst DARK_INK = hex(tokens.themes.dark.ink);\n\n/** Hue (0 to 6), saturation and lightness (0 to 1). */\ntype Hsl = readonly [hue: number, saturation: number, lightness: number];\n\nfunction toHsl([red, green, blue]: StyleColor): Hsl {\n const [r, g, b] = [red / 255, green / 255, blue / 255];\n const max = Math.max(r, g, b);\n const min = Math.min(r, g, b);\n const lightness = (max + min) / 2;\n const chroma = max - min;\n if (chroma === 0) return [0, 0, lightness];\n const hue =\n max === r ? ((g - b) / chroma + 6) % 6 : max === g ? (b - r) / chroma + 2 : (r - g) / chroma + 4;\n return [hue, chroma / (1 - Math.abs(2 * lightness - 1)), lightness];\n}\n\nfunction fromHsl([hue, saturation, lightness]: Hsl, alpha: number): StyleColor {\n const a = saturation * Math.min(lightness, 1 - lightness);\n const channel = (at: number): number => {\n const k = (at + hue * 2) % 12;\n return Math.round((lightness - a * Math.max(-1, Math.min(k - 3, 9 - k, 1))) * 255);\n };\n return [channel(0), channel(8), channel(4), alpha];\n}\n\n/** The author's lightness inverted, with hue and saturation kept. */\nfunction inverted(color: StyleColor): StyleColor {\n const [hue, saturation, lightness] = toHsl(color);\n return fromHsl([hue, saturation, 1 - lightness], color[3]);\n}\n\nconst contrastOn = (ink: StyleColor, ground: StyleColor): number =>\n styleContrast(overStyleColor(ink, ground), ground);\n\n/** `color` with the lightness nearest its own that can be read on `ground`, hue and saturation kept. */\nfunction legible(color: StyleColor, ground: StyleColor): StyleColor {\n if (contrastOn(color, ground) >= MIN_CONTRAST) return color;\n const [hue, saturation, lightness] = toHsl(color);\n const at = (l: number) => fromHsl([hue, saturation, l], color[3]);\n let reads = contrastOn(at(1), ground) >= contrastOn(at(0), ground) ? 1 : 0;\n let fails = lightness;\n for (let step = 0; step < 8; step++) {\n const middle = (reads + fails) / 2;\n if (contrastOn(at(middle), ground) >= MIN_CONTRAST) reads = middle;\n else fails = middle;\n }\n return at(reads);\n}\n\nconst written = ([red, green, blue, alpha]: StyleColor): string => {\n const channels = [red, green, blue].map(Math.round).join(', ');\n return alpha === 1 ? `rgb(${channels})` : `rgba(${channels}, ${alpha})`;\n};\n\n/** What is known of the dark theme at an element: the ground, and whether an author's colour is the text colour. */\ninterface DarkContext {\n readonly ground: StyleColor;\n readonly inked: boolean;\n}\n\nconst declared = (declarations: readonly StyleDeclaration[], name: string): StyleColor | null => {\n const value = declarations.find(([property]) => property === name)?.[1];\n return value === undefined ? null : parseStyleColor(value);\n};\n\n/** The dark theme at an element with these declarations, inside `around`. */\nfunction darkContext(declarations: readonly StyleDeclaration[], around: DarkContext): DarkContext {\n const inked = around.inked || declared(declarations, 'color') !== null;\n const fill = declared(declarations, 'background-color');\n if (fill === null) return { ground: around.ground, inked };\n const dark = overStyleColor(inverted(fill), around.ground);\n // Without an author's colour, the text is the theme's: the fill is what has to give way.\n return { ground: inked ? dark : legible(dark, DARK_INK), inked };\n}\n\n/** A declaration as it is written on the mounted element. */\nfunction painted(name: string, value: string, context: DarkContext): string {\n if (name === 'font-family') return value;\n if (name === 'font-size') return LENGTH.test(value) ? `clamp(0.625rem, ${value}, 6rem)` : value;\n if (MEASURES.has(name)) return LENGTH.test(value) && !value.endsWith('%') ? `min(${value}, 100%)` : value;\n return value.replace(RAW_COLOR, (raw) => {\n const color = hex(raw);\n const dark =\n name === 'color'\n ? legible(inverted(color), context.ground)\n : name === 'background-color'\n ? context.ground\n : inverted(color);\n return `var(${offWith(name)}, light-dark(${raw}, ${written(dark)}))`;\n });\n}\n\n/** Styles taken from a view, by element of the fragment, as they will be written. */\nexport type TakenStyles = ReadonlyMap<Element, readonly StyleDeclaration[]>;\n\n/** Takes every `style` (read under its parsing name) out of a read view, before `cleanView` removes what is left. */\nexport function takeStyles(fragment: DocumentFragment): TakenStyles {\n const taken = new Map<Element, readonly StyleDeclaration[]>();\n const contexts = new Map<Element, DarkContext>();\n const page: DarkContext = { ground: DARK_SURFACE, inked: false };\n // In document order, so what is around an element has been read before it.\n for (const el of Array.from(fragment.querySelectorAll(`[${INERT_STYLE}]`))) {\n const { declarations } = cleanStyle(el.getAttribute(INERT_STYLE) ?? '');\n el.removeAttribute(INERT_STYLE);\n let around = page;\n for (let up = el.parentElement; up !== null; up = up.parentElement) {\n const known = contexts.get(up);\n if (known !== undefined) {\n around = known;\n break;\n }\n }\n const context = darkContext(declarations, around);\n contexts.set(el, context);\n taken.set(\n el,\n declarations.map(([name, value]): StyleDeclaration => [name, painted(name, value, context)]),\n );\n }\n return taken;\n}\n\n/** Writes taken styles on `content`, the copy of the cleaned `fragment` that gets mounted: same shape, same order. */\nexport function applyStyles(taken: TakenStyles, fragment: DocumentFragment, content: DocumentFragment): void {\n const copies = content.querySelectorAll<HTMLElement>('*');\n fragment.querySelectorAll('*').forEach((el, index) => {\n for (const [name, value] of taken.get(el) ?? []) copies[index]?.style.setProperty(name, value);\n });\n}\n\n// Pages hold their floats. `:not([hidden])` because `.canvas astl-page` would otherwise beat `astl-page[hidden]`.\n// An author's `display` must not bring back what the player or a component hides.\n// A page never scrolls sideways whatever is nested in it: the caps stop one element, not ten inside each other.\n// On a narrow player only what an author set gives way, so a coloured word gets no padding; `auto` margins centre.\nconst styledSheet = css`\n .canvas {\n container-type: inline-size;\n }\n .canvas astl-doc,\n .canvas astl-page:not([hidden]) {\n display: flow-root;\n }\n .canvas astl-page {\n overflow-x: clip;\n overflow-clip-margin: var(--astl-space-5);\n }\n .canvas [style][hidden] {\n display: none !important;\n }\n .canvas [style] {\n box-sizing: border-box;\n max-inline-size: 100%;\n }\n .canvas astl-columns {\n display: flex;\n flex-wrap: wrap;\n clear: both;\n gap: var(--astl-space-4);\n margin-block-end: var(--astl-space-4);\n }\n .canvas astl-columns > astl-column {\n flex: 1 1 0;\n min-inline-size: min(10rem, 100%);\n }\n .canvas astl-columns > astl-column > :first-child {\n margin-block-start: 0;\n }\n .canvas astl-columns > astl-column > :last-child {\n margin-block-end: 0;\n }\n :host([data-theme='hc']) {\n --astl-author-ink: currentcolor;\n --astl-author-ground: transparent;\n }\n @container (max-inline-size: 30rem) {\n .canvas [style*='float'] {\n float: none !important;\n inline-size: auto !important;\n }\n .canvas [style*='margin']:not([style*='auto']) {\n margin-inline: 0 !important;\n }\n .canvas [style*='padding'] {\n padding-inline: min(var(--astl-space-3), 5%) !important;\n }\n .canvas img[style*='float'] {\n display: block;\n }\n }\n`.styleSheet;\n\n/** Adopts the stylesheet of styles and layouts in a player's root, once. */\nexport function adoptStyledSheet(root: Node): void {\n if (\n styledSheet !== undefined &&\n root instanceof ShadowRoot &&\n !root.adoptedStyleSheets.includes(styledSheet)\n ) {\n root.adoptedStyleSheets = [...root.adoptedStyleSheets, styledSheet];\n }\n}\n"],"mappings":"A,6HAiCA,IAAMO,EAAe,IACfC,EAAY,8BACZC,EAAS,SACTC,EAAgC,IAAI,IAAI,CAAC,QAAS,YAAa,cAAe,iBAAiB,CAAC,EAGhGC,EAAW,GACfC,IAAS,oBAAsBA,IAAS,aAAe,uBAAyB,oBAE5EC,EAAO,GAA8BP,EAAgBQ,CAAK,EAE1DC,EAAeF,EAAIZ,EAAO,OAAO,KAAK,iBAAiB,EACvDe,EAAWH,EAAIZ,EAAO,OAAO,KAAK,GAAG,EAK3C,SAASgB,EAAM,CAACC,EAAKC,EAAOC,GAAwB,CAClD,GAAM,CAAC,EAAGC,EAAGC,GAAK,CAACJ,EAAM,IAAKC,EAAQ,IAAKC,EAAO,GAAG,EAC/CG,EAAM,KAAK,IAAI,EAAGF,EAAGC,CAAC,EACtBE,EAAM,KAAK,IAAI,EAAGH,EAAGC,CAAC,EACtBG,GAAaF,EAAMC,GAAO,EAC1BE,EAASH,EAAMC,EAIrB,OAHIE,IAAW,EAAU,CAAC,EAAG,EAAGD,CAAS,EAGlC,CADLF,IAAQ,IAAMF,EAAIC,GAAKI,EAAS,GAAK,EAAIH,IAAQF,GAAKC,EAAI,GAAKI,EAAS,GAAK,EAAIL,GAAKK,EAAS,EACpFA,GAAU,EAAI,KAAK,IAAI,EAAID,EAAY,CAAC,GAAIA,CAAS,CACpE,CAEA,SAASE,EAAQ,CAACC,EAAKC,EAAYJ,GAAiB,EAA2B,CAC7E,IAAMK,EAAID,EAAa,KAAK,IAAIJ,EAAW,EAAIA,CAAS,E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RT.js";var s=class extends o{static properties={authoring:{attribute:!1},adapter:{attribute:!1}};#e=null;constructor(){super(),this.authoring=null,this.adapter=null}connectedCallback(){super.connectedCallback(),this.#t()}disconnectedCallback(){super.disconnectedCallback(),this.#n()}willUpdate(e){e.has(`adapter`)&&this.#t()}#t(){let e=this.isConnected?this.adapter:null;if((this.#e?.adapter??null)===e||(this.#n(),e===null))return;let t=[e.onChange(()=>this.sourceChanged()),e.onSelectionChange(e=>this.selectionChanged(e)),e.onCursorChange?.(()=>this.cursorChanged())??(()=>{})];this.#e={adapter:e,off:()=>{for(let e of t)e()}}}#n(){this.#e?.off(),this.#e=null}sourceChanged(){this.requestUpdate()}selectionChanged(e){this.requestUpdate()}cursorChanged(){}t(e,t){return this.authoring?.t(`astl.editor`,e,t)??e}get ui(){let e=this.authoring?.locale??`en`;return{lang:e,dir:r(e)}}};function c(t){let r=[`color-scheme: inherit;`,...[n.scale,n.themes.light,n.themeScale.light].flatMap(Object.keys).map(e=>`--astl-${e}: inherit;`)];return e(`${t} {\n${r.join(`
|
|
2
|
+
`)}\n}`)}var l=[e(a(`:host`)),i,t`
|
|
3
|
+
:host {
|
|
4
|
+
display: block;
|
|
5
|
+
color: var(--astl-ink);
|
|
6
|
+
font-family: var(--astl-font-body);
|
|
7
|
+
font-size: var(--astl-size-ui);
|
|
8
|
+
line-height: 1.4;
|
|
9
|
+
}
|
|
10
|
+
:host([hidden]) {
|
|
11
|
+
display: none;
|
|
12
|
+
}
|
|
13
|
+
.kit {
|
|
14
|
+
box-sizing: border-box;
|
|
15
|
+
display: flex;
|
|
16
|
+
flex-direction: column;
|
|
17
|
+
gap: var(--astl-space-3);
|
|
18
|
+
min-inline-size: 0;
|
|
19
|
+
padding: var(--astl-space-4);
|
|
20
|
+
border: var(--astl-outline-width) solid var(--astl-line);
|
|
21
|
+
border-radius: var(--astl-radius-l);
|
|
22
|
+
background: var(--astl-surface);
|
|
23
|
+
color: var(--astl-ink);
|
|
24
|
+
overflow-wrap: anywhere;
|
|
25
|
+
}
|
|
26
|
+
.title {
|
|
27
|
+
margin: 0;
|
|
28
|
+
font-family: var(--astl-font-display);
|
|
29
|
+
font-size: 1.125rem;
|
|
30
|
+
line-height: 1.3;
|
|
31
|
+
}
|
|
32
|
+
.note {
|
|
33
|
+
margin: 0;
|
|
34
|
+
color: var(--astl-ink-muted);
|
|
35
|
+
}
|
|
36
|
+
ul {
|
|
37
|
+
display: flex;
|
|
38
|
+
flex-direction: column;
|
|
39
|
+
gap: var(--astl-space-2);
|
|
40
|
+
margin: 0;
|
|
41
|
+
padding: 0;
|
|
42
|
+
list-style: none;
|
|
43
|
+
}
|
|
44
|
+
button {
|
|
45
|
+
box-sizing: border-box;
|
|
46
|
+
display: inline-flex;
|
|
47
|
+
align-items: center;
|
|
48
|
+
gap: var(--astl-space-2);
|
|
49
|
+
min-block-size: var(--astl-target-min);
|
|
50
|
+
min-inline-size: var(--astl-target-min);
|
|
51
|
+
margin: 0;
|
|
52
|
+
padding-block: var(--astl-space-2);
|
|
53
|
+
padding-inline: var(--astl-space-3);
|
|
54
|
+
border: var(--astl-outline-width) solid var(--astl-outline);
|
|
55
|
+
border-radius: var(--astl-radius-m);
|
|
56
|
+
background: var(--astl-surface);
|
|
57
|
+
color: var(--astl-ink);
|
|
58
|
+
font: inherit;
|
|
59
|
+
text-align: start;
|
|
60
|
+
cursor: pointer;
|
|
61
|
+
}
|
|
62
|
+
button:hover:not(:disabled) {
|
|
63
|
+
background: var(--astl-accent-soft);
|
|
64
|
+
}
|
|
65
|
+
`,t`
|
|
66
|
+
button:is(:disabled, [aria-disabled='true']) {
|
|
67
|
+
border-color: var(--astl-line);
|
|
68
|
+
border-style: dashed;
|
|
69
|
+
background: transparent;
|
|
70
|
+
color: var(--astl-ink-muted);
|
|
71
|
+
cursor: not-allowed;
|
|
72
|
+
}
|
|
73
|
+
button.primary {
|
|
74
|
+
border-color: var(--astl-accent);
|
|
75
|
+
background: var(--astl-accent);
|
|
76
|
+
color: var(--astl-on-accent);
|
|
77
|
+
font-weight: 600;
|
|
78
|
+
}
|
|
79
|
+
button.primary:hover:not(:disabled) {
|
|
80
|
+
background: var(--astl-accent);
|
|
81
|
+
text-decoration: underline;
|
|
82
|
+
}
|
|
83
|
+
button.primary:disabled {
|
|
84
|
+
border-color: var(--astl-line);
|
|
85
|
+
background: transparent;
|
|
86
|
+
color: var(--astl-ink-muted);
|
|
87
|
+
}
|
|
88
|
+
input:not([type='checkbox'], [type='radio']),
|
|
89
|
+
select,
|
|
90
|
+
textarea {
|
|
91
|
+
box-sizing: border-box;
|
|
92
|
+
inline-size: 100%;
|
|
93
|
+
min-inline-size: 0;
|
|
94
|
+
min-block-size: var(--astl-target-min);
|
|
95
|
+
margin: 0;
|
|
96
|
+
padding-block: var(--astl-space-1);
|
|
97
|
+
padding-inline: var(--astl-space-2);
|
|
98
|
+
border: var(--astl-outline-width) solid var(--astl-outline);
|
|
99
|
+
border-radius: var(--astl-radius-s);
|
|
100
|
+
background: var(--astl-surface);
|
|
101
|
+
color: var(--astl-ink);
|
|
102
|
+
font: inherit;
|
|
103
|
+
}
|
|
104
|
+
input[type='checkbox'],
|
|
105
|
+
input[type='radio'] {
|
|
106
|
+
flex: none;
|
|
107
|
+
inline-size: 1.25rem;
|
|
108
|
+
block-size: 1.25rem;
|
|
109
|
+
margin: 0;
|
|
110
|
+
accent-color: var(--astl-accent);
|
|
111
|
+
}
|
|
112
|
+
:focus-visible {
|
|
113
|
+
outline: var(--astl-focus-width) solid var(--astl-focus);
|
|
114
|
+
outline-offset: var(--astl-focus-offset);
|
|
115
|
+
}
|
|
116
|
+
.icon {
|
|
117
|
+
flex: none;
|
|
118
|
+
inline-size: 1.25rem;
|
|
119
|
+
block-size: 1.25rem;
|
|
120
|
+
}
|
|
121
|
+
`,t`
|
|
122
|
+
@media (forced-colors: active) {
|
|
123
|
+
button.primary {
|
|
124
|
+
border-color: ButtonText;
|
|
125
|
+
}
|
|
126
|
+
button:disabled,
|
|
127
|
+
button.primary:disabled {
|
|
128
|
+
border-color: GrayText;
|
|
129
|
+
color: GrayText;
|
|
130
|
+
}
|
|
131
|
+
button.primary:not(:disabled) {
|
|
132
|
+
forced-color-adjust: none;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
`];export{l as n,s as r,c as t};
|
|
136
|
+
//# sourceMappingURL=styles-DxJJxVNH.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles-DxJJxVNH.js","names":["LitElement","unsafeCSS","r","i$1","tokens","directionOf","visuallyHidden","tokensCss","i","AuthoringElement","#subscribe","#unsubscribe","changed","adapter","#subscription","offs","selection","off","key","params","lang","inheritTokens","lines","name","selector","kitStyles"],"sources":["../../../../editor/src/elements/base.ts","../../../../editor/src/elements/styles.ts"],"sourcesContent":["import {\n type Direction,\n directionOf,\n type EditorAdapter,\n type EditorSelection,\n type MessageParams,\n} from '@astl/core';\nimport { LitElement, type PropertyDeclarations, type PropertyValues } from 'lit';\nimport type { Authoring } from '../authoring.js';\nimport { EDITOR_NAMESPACE } from '../messages.js';\n\n/**\n * Base of the kit elements: `authoring` and `adapter` properties, a subscription to the adapter's events while\n * connected (re-rendering by default) and UI strings in the authoring locale.\n */\nexport class AuthoringElement extends LitElement {\n static override properties: PropertyDeclarations = {\n authoring: { attribute: false },\n adapter: { attribute: false },\n };\n\n declare authoring: Authoring | null;\n declare adapter: EditorAdapter | null;\n\n #subscription: { readonly adapter: EditorAdapter; readonly off: () => void } | null = null;\n\n constructor() {\n super();\n this.authoring = null;\n this.adapter = null;\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.#subscribe();\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback();\n this.#unsubscribe();\n }\n\n protected override willUpdate(changed: PropertyValues<this>): void {\n if (changed.has('adapter')) this.#subscribe();\n }\n\n #subscribe(): void {\n const adapter = this.isConnected ? this.adapter : null;\n if ((this.#subscription?.adapter ?? null) === adapter) return;\n this.#unsubscribe();\n if (adapter === null) return;\n const offs = [\n adapter.onChange(() => this.sourceChanged()),\n adapter.onSelectionChange((selection) => this.selectionChanged(selection)),\n adapter.onCursorChange?.(() => this.cursorChanged()) ?? (() => {}),\n ];\n this.#subscription = {\n adapter,\n off: () => {\n for (const off of offs) off();\n },\n };\n }\n\n #unsubscribe(): void {\n this.#subscription?.off();\n this.#subscription = null;\n }\n\n /** The document changed. */\n protected sourceChanged(): void {\n this.requestUpdate();\n }\n\n /** The cursor entered or left a component. */\n protected selectionChanged(_selection: EditorSelection | null): void {\n this.requestUpdate();\n }\n\n /** The cursor moved, or the document or its history changed. Most elements have nothing to do. */\n protected cursorChanged(): void {}\n\n /** A kit message (`astl.editor`) in the authoring locale. */\n protected t(key: string, params?: MessageParams): string {\n return this.authoring?.t(EDITOR_NAMESPACE, key, params) ?? key;\n }\n\n /** Language and direction of the UI strings. */\n protected get ui(): { readonly lang: string; readonly dir: Direction } {\n const lang = this.authoring?.locale ?? 'en';\n return { lang, dir: directionOf(lang) };\n }\n}\n","import { visuallyHidden } from '@astl/player';\nimport { tokens, tokensCss } from '@astl/tokens';\nimport { type CSSResult, type CSSResultGroup, css, unsafeCSS } from 'lit';\n\n/**\n * Every token as `inherit` on `selector`, for elements that redeclare the tokens on their own `:host` (the player): a\n * rule from the outer tree wins over `:host`, so tokens set on the kit element reach them.\n */\nexport function inheritTokens(selector: string): CSSResult {\n const names = [tokens.scale, tokens.themes.light, tokens.themeScale.light].flatMap(Object.keys);\n const lines = ['color-scheme: inherit;', ...names.map((name) => `--astl-${name}: inherit;`)];\n return unsafeCSS(`${selector} {\\n${lines.join('\\n')}\\n}`);\n}\n\n/** Shared look of the kit elements: a card, native controls with 44px targets, visible focus. Tokens only. */\nexport const kitStyles: CSSResultGroup = [\n // Tokens sit on :host so host pages can override any --astl-* property on the element itself.\n unsafeCSS(tokensCss(':host')),\n visuallyHidden,\n css`\n :host {\n display: block;\n color: var(--astl-ink);\n font-family: var(--astl-font-body);\n font-size: var(--astl-size-ui);\n line-height: 1.4;\n }\n :host([hidden]) {\n display: none;\n }\n .kit {\n box-sizing: border-box;\n display: flex;\n flex-direction: column;\n gap: var(--astl-space-3);\n min-inline-size: 0;\n padding: var(--astl-space-4);\n border: var(--astl-outline-width) solid var(--astl-line);\n border-radius: var(--astl-radius-l);\n background: var(--astl-surface);\n color: var(--astl-ink);\n overflow-wrap: anywhere;\n }\n .title {\n margin: 0;\n font-family: var(--astl-font-display);\n font-size: 1.125rem;\n line-height: 1.3;\n }\n .note {\n margin: 0;\n color: var(--astl-ink-muted);\n }\n ul {\n display: flex;\n flex-direction: column;\n gap: var(--astl-space-2);\n margin: 0;\n padding: 0;\n list-style: none;\n }\n button {\n box-sizing: border-box;\n display: inline-flex;\n align-items: center;\n gap: var(--astl-space-2);\n min-block-size: var(--astl-target-min);\n min-inline-size: var(--astl-target-min);\n margin: 0;\n padding-block: var(--astl-space-2);\n padding-inline: var(--astl-space-3);\n border: var(--astl-outline-width) solid var(--astl-outline);\n border-radius: var(--astl-radius-m);\n background: var(--astl-surface);\n color: var(--astl-ink);\n font: inherit;\n text-align: start;\n cursor: pointer;\n }\n button:hover:not(:disabled) {\n background: var(--astl-accent-soft);\n }\n `,\n // Disabled shows without colour too: a dashed border and no fill. In the high contrast theme the line and muted\n // colours are as dark as the enabled ones. Disabled (no editor yet), the primary button must not look pressable.\n css`\n button:is(:disabled, [aria-disabled='true']) {\n border-color: var(--astl-line);\n border-style: dashed;\n background: transparent;\n color: var(--astl-ink-muted);\n cursor: not-allowed;\n }\n button.primary {\n border-color: var(--astl-accent);\n background: var(--astl-accent);\n color: var(--astl-on-accent);\n font-weight: 600;\n }\n button.primary:hover:not(:disabled) {\n background: var(--astl-accent);\n text-decoration: underline;\n }\n button.primary:disabled {\n border-color: var(--astl-line);\n background: transparent;\n color: var(--astl-ink-muted);\n }\n input:not([type='checkbox'], [type='radio']),\n select,\n textarea {\n box-sizing: border-box;\n inline-size: 100%;\n min-inline-size: 0;\n min-block-size: var(--astl-target-min);\n margin: 0;\n padding-block: var(--astl-space-1);\n padding-inline: var(--astl-space-2);\n border: var(--astl-outline-width) solid var(--astl-outline);\n border-radius: var(--astl-radius-s);\n background: var(--astl-surface);\n color: var(--astl-ink);\n font: inherit;\n }\n input[type='checkbox'],\n input[type='radio'] {\n flex: none;\n inline-size: 1.25rem;\n block-size: 1.25rem;\n margin: 0;\n accent-color: var(--astl-accent);\n }\n :focus-visible {\n outline: var(--astl-focus-width) solid var(--astl-focus);\n outline-offset: var(--astl-focus-offset);\n }\n .icon {\n flex: none;\n inline-size: 1.25rem;\n block-size: 1.25rem;\n }\n `,\n // Forced colours: disabled as the system draws disabled controls (the dashed border stays). The Canvas backplate\n // forced colours draw behind text would hide the HighlightText label on the Highlight fill, so the primary button\n // uses only system colours here and keeps its own. Disabled, it stays forced: its muted label would not read on the\n // fill.\n css`\n @media (forced-colors: active) {\n button.primary {\n border-color: ButtonText;\n }\n button:disabled,\n button.primary:disabled {\n border-color: GrayText;\n color: GrayText;\n }\n button.primary:not(:disabled) {\n forced-color-adjust: none;\n }\n }\n `,\n];\n"],"mappings":"A,oHAeA,IAAaS,EAAb,cAAsCT,CAAW,CAC/C,OAAgB,WAAmC,CACjD,UAAW,CAAE,UAAW,EAAM,EAC9B,QAAS,CAAE,UAAW,EAAM,CAC9B,EAKA,GAAsF,KAEtF,aAAc,CACZ,MAAM,EACN,KAAK,UAAY,KACjB,KAAK,QAAU,IACjB,CAEA,mBAAmC,CACjC,MAAM,kBAAkB,EACxB,KAAKU,GAAW,CAClB,CAEA,sBAAsC,CACpC,MAAM,qBAAqB,EAC3B,KAAKC,GAAa,CACpB,CAEA,WAA8B,EAAqC,CAC7DC,EAAQ,IAAI,SAAS,GAAG,KAAKF,GAAW,CAC9C,CAEA,IAAmB,CACjB,IAAMG,EAAU,KAAK,YAAc,KAAK,QAAU,KAGlD,IAFK,KAAKC,IAAe,SAAW,QAAUD,IAC9C,KAAKF,GAAa,EACdE,IAAY,MAAM,OACtB,IAAME,EAAO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