@astl/astrolabe 0.1.3 → 0.1.4
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 +14 -0
- package/dist/cdn/astrolabe-editor.js +3 -3
- package/dist/cdn/astrolabe-player.js +1 -1
- package/dist/cdn/astrolabe.js +1 -1
- package/dist/cdn/astrolabe.standalone.js +1084 -1075
- package/dist/cdn/chunks/{audio-B0LSIn5N.js → audio-Biof5aA3.js} +2 -2
- package/dist/cdn/chunks/{audio-B0LSIn5N.js.map → audio-Biof5aA3.js.map} +1 -1
- package/dist/cdn/chunks/{block-styles-CKo9x7Vt.js → block-styles-CCtSFM4j.js} +2 -2
- package/dist/cdn/chunks/{block-styles-CKo9x7Vt.js.map → block-styles-CCtSFM4j.js.map} +1 -1
- package/dist/cdn/chunks/{book-CHzDDaim.js → book-IFipARhv.js} +2 -2
- package/dist/cdn/chunks/{book-CHzDDaim.js.map → book-IFipARhv.js.map} +1 -1
- package/dist/cdn/chunks/{callout-QFLFLPc5.js → callout-CuajbbYY.js} +2 -2
- package/dist/cdn/chunks/{callout-QFLFLPc5.js.map → callout-CuajbbYY.js.map} +1 -1
- package/dist/cdn/chunks/{categorise-BO2tNVJ3.js → categorise-Cm6kXLXw.js} +2 -2
- package/dist/cdn/chunks/{categorise-BO2tNVJ3.js.map → categorise-Cm6kXLXw.js.map} +1 -1
- package/dist/cdn/chunks/{chip-styles-Dme5daTO.js → chip-styles--gboWK2Z.js} +2 -2
- package/dist/cdn/chunks/{chip-styles-Dme5daTO.js.map → chip-styles--gboWK2Z.js.map} +1 -1
- package/dist/cdn/chunks/{choice-CExBvqKj.js → choice-BSpB6LHl.js} +2 -2
- package/dist/cdn/chunks/{choice-CExBvqKj.js.map → choice-BSpB6LHl.js.map} +1 -1
- package/dist/cdn/chunks/{color-control-Cl5cuMSO.js → color-control-1kkdM8ns.js} +2 -2
- package/dist/cdn/chunks/{color-control-Cl5cuMSO.js.map → color-control-1kkdM8ns.js.map} +1 -1
- package/dist/cdn/chunks/{crossword-Cb-a3Tjj.js → crossword-BdOAEPcL.js} +2 -2
- package/dist/cdn/chunks/{crossword-Cb-a3Tjj.js.map → crossword-BdOAEPcL.js.map} +1 -1
- package/dist/cdn/chunks/{definitions-CNX90WtL.js → definitions-BybSa1mq.js} +2 -2
- package/dist/cdn/chunks/{definitions-CNX90WtL.js.map → definitions-BybSa1mq.js.map} +1 -1
- package/dist/cdn/chunks/{directive-helpers-D7lOZKnB.js → directive-helpers-US6zRjJ1.js} +2 -2
- package/dist/cdn/chunks/{directive-helpers-D7lOZKnB.js.map → directive-helpers-US6zRjJ1.js.map} +1 -1
- package/dist/cdn/chunks/{drop-vRXndjHu.js → drop-D4NQ0WK_.js} +2 -2
- package/dist/cdn/chunks/{drop-vRXndjHu.js.map → drop-D4NQ0WK_.js.map} +1 -1
- package/dist/cdn/chunks/{flash-cards-0NrrKdrx.js → flash-cards-D4ebb5m6.js} +2 -2
- package/dist/cdn/chunks/{flash-cards-0NrrKdrx.js.map → flash-cards-D4ebb5m6.js.map} +1 -1
- package/dist/cdn/chunks/{gap-lor-khst.js → gap-D-Sipuyu.js} +2 -2
- package/dist/cdn/chunks/{gap-lor-khst.js.map → gap-D-Sipuyu.js.map} +1 -1
- package/dist/cdn/chunks/{help-C-woafz5.js → help-CmCFuNXk.js} +2 -2
- package/dist/cdn/chunks/{help-C-woafz5.js.map → help-CmCFuNXk.js.map} +1 -1
- package/dist/cdn/chunks/{help-form-DhIyMziw.js → help-form-Di2NtKDp.js} +2 -2
- package/dist/cdn/chunks/{help-form-DhIyMziw.js.map → help-form-Di2NtKDp.js.map} +1 -1
- package/dist/cdn/chunks/{hotspot-oel1Eelo.js → hotspot-B3bvqVzf.js} +2 -2
- package/dist/cdn/chunks/{hotspot-oel1Eelo.js.map → hotspot-B3bvqVzf.js.map} +1 -1
- package/dist/cdn/chunks/{image-drop-Dkprw0Kn.js → image-drop-vLc2B7rF.js} +2 -2
- package/dist/cdn/chunks/{image-drop-Dkprw0Kn.js.map → image-drop-vLc2B7rF.js.map} +1 -1
- package/dist/cdn/chunks/{image-label-Dm5shQSh.js → image-label-DsKxQDTQ.js} +2 -2
- package/dist/cdn/chunks/{image-label-Dm5shQSh.js.map → image-label-DsKxQDTQ.js.map} +1 -1
- package/dist/cdn/chunks/{inline-styles-CTgXWnHb.js → inline-styles-CFNlb6f2.js} +2 -2
- package/dist/cdn/chunks/{inline-styles-CTgXWnHb.js.map → inline-styles-CFNlb6f2.js.map} +1 -1
- package/dist/cdn/chunks/{insert-menu-Cn2E54V9.js → insert-menu-DAQglwtG.js} +2 -2
- package/dist/cdn/chunks/{insert-menu-Cn2E54V9.js.map → insert-menu-DAQglwtG.js.map} +1 -1
- package/dist/cdn/chunks/{issue-list-CQKAW39i.js → issue-list-CzSmohtT.js} +2 -2
- package/dist/cdn/chunks/{issue-list-CQKAW39i.js.map → issue-list-CzSmohtT.js.map} +1 -1
- package/dist/cdn/chunks/{live-jdiyYln2.js → live-qnReIRtj.js} +2 -2
- package/dist/cdn/chunks/{live-jdiyYln2.js.map → live-qnReIRtj.js.map} +1 -1
- package/dist/cdn/chunks/{long-answer-CtzClLAx.js → long-answer-NSWJiK0z.js} +2 -2
- package/dist/cdn/chunks/{long-answer-CtzClLAx.js.map → long-answer-NSWJiK0z.js.map} +1 -1
- package/dist/cdn/chunks/{mark-words-CpH3gTcX.js → mark-words-BKu-_uIl.js} +2 -2
- package/dist/cdn/chunks/{mark-words-CpH3gTcX.js.map → mark-words-BKu-_uIl.js.map} +1 -1
- package/dist/cdn/chunks/{match-DKE_4o-x.js → match-BpnJGW_5.js} +21 -13
- package/dist/cdn/chunks/match-BpnJGW_5.js.map +1 -0
- package/dist/cdn/chunks/{memory-B6hSyHyz.js → memory-BgTHujsU.js} +2 -2
- package/dist/cdn/chunks/{memory-B6hSyHyz.js.map → memory-BgTHujsU.js.map} +1 -1
- package/dist/cdn/chunks/{option-styles-WKzjKmCH.js → option-styles-B2sBX5Oz.js} +2 -2
- package/dist/cdn/chunks/{option-styles-WKzjKmCH.js.map → option-styles-B2sBX5Oz.js.map} +1 -1
- package/dist/cdn/chunks/{order-BhG_6IC-.js → order-B9gqH5wm.js} +2 -2
- package/dist/cdn/chunks/{order-BhG_6IC-.js.map → order-B9gqH5wm.js.map} +1 -1
- package/dist/cdn/chunks/{picture-view-BKnAyScQ.js → picture-view-Deodu_mb.js} +2 -2
- package/dist/cdn/chunks/{picture-view-BKnAyScQ.js.map → picture-view-Deodu_mb.js.map} +1 -1
- package/dist/cdn/chunks/{repeat-CY2W2URZ.js → repeat-BDXokpxQ.js} +2 -2
- package/dist/cdn/chunks/{repeat-CY2W2URZ.js.map → repeat-BDXokpxQ.js.map} +1 -1
- package/dist/cdn/chunks/{runtime-DxAbpr3S.js → runtime-C25QK5B0.js} +3 -3
- package/dist/cdn/chunks/{runtime-DxAbpr3S.js.map → runtime-C25QK5B0.js.map} +1 -1
- package/dist/cdn/chunks/{scan-jWgPnVxA.js → scan-BVhxT2Hw.js} +2 -2
- package/dist/cdn/chunks/{scan-jWgPnVxA.js.map → scan-BVhxT2Hw.js.map} +1 -1
- package/dist/cdn/chunks/{select-DTA3dJzr.js → select-DPpKJwSg.js} +2 -2
- package/dist/cdn/chunks/{select-DTA3dJzr.js.map → select-DPpKJwSg.js.map} +1 -1
- package/dist/cdn/chunks/select-QZ35cyns.js +2 -0
- package/dist/cdn/chunks/select-QZ35cyns.js.map +1 -0
- package/dist/cdn/chunks/{source-view-BlJ2mRns.js → source-view-gqFlZzwR.js} +2 -2
- package/dist/cdn/chunks/{source-view-BlJ2mRns.js.map → source-view-gqFlZzwR.js.map} +1 -1
- package/dist/cdn/chunks/{style-form-D1C2sHzg.js → style-form-DuR0EEum.js} +2 -2
- package/dist/cdn/chunks/{style-form-D1C2sHzg.js.map → style-form-DuR0EEum.js.map} +1 -1
- package/dist/cdn/chunks/{style-popups-BobgX1WK.js → style-popups-Bcl5imdP.js} +2 -2
- package/dist/cdn/chunks/{style-popups-BobgX1WK.js.map → style-popups-Bcl5imdP.js.map} +1 -1
- package/dist/cdn/chunks/{style-rules-ChqPVgZn.js → style-rules-ozpLz2ec.js} +2 -2
- package/dist/cdn/chunks/{style-rules-ChqPVgZn.js.map → style-rules-ozpLz2ec.js.map} +1 -1
- package/dist/cdn/chunks/{styled-Dmx5Yjv7.js → styled-bQqnDxBf.js} +2 -2
- package/dist/cdn/chunks/{styled-Dmx5Yjv7.js.map → styled-bQqnDxBf.js.map} +1 -1
- package/dist/cdn/chunks/{styles-CXkkL_Qi.js → styles-DiY3VA_T.js} +5 -5
- package/dist/cdn/chunks/styles-DiY3VA_T.js.map +1 -0
- package/dist/cdn/chunks/surface-CIz1z2oY.js +1059 -0
- package/dist/cdn/chunks/surface-CIz1z2oY.js.map +1 -0
- package/dist/cdn/chunks/{true-false-DP3MO599.js → true-false-C-S6RmZY.js} +2 -2
- package/dist/cdn/chunks/{true-false-DP3MO599.js.map → true-false-C-S6RmZY.js.map} +1 -1
- package/dist/cdn/chunks/{video-j9MCH6Kw.js → video-Dae8Gguf.js} +2 -2
- package/dist/cdn/chunks/{video-j9MCH6Kw.js.map → video-Dae8Gguf.js.map} +1 -1
- package/dist/cdn/chunks/{word-bank-ARjwUKZf.js → word-bank-CsIle0Ro.js} +2 -2
- package/dist/cdn/chunks/{word-bank-ARjwUKZf.js.map → word-bank-CsIle0Ro.js.map} +1 -1
- package/dist/cdn/chunks/{word-search-AHvM7yCJ.js → word-search-IOCwqo3y.js} +2 -2
- package/dist/cdn/chunks/{word-search-AHvM7yCJ.js.map → word-search-IOCwqo3y.js.map} +1 -1
- package/package.json +9 -9
- package/dist/cdn/chunks/match-DKE_4o-x.js.map +0 -1
- package/dist/cdn/chunks/styles-CXkkL_Qi.js.map +0 -1
- package/dist/cdn/chunks/surface-BhmSAte0.js +0 -1058
- package/dist/cdn/chunks/surface-BhmSAte0.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{C as e,E as t,b as n,h as r,n as i,v as a,y as o}from"./runtime-
|
|
1
|
+
import{C as e,E as t,b as n,h as r,n as i,v as a,y as o}from"./runtime-C25QK5B0.js";import{n as s,r as c,t as l}from"./true-false-manifest-B4exv60u.js";import{t as u}from"./live-qnReIRtj.js";import{t as d}from"./block-styles-CCtSFM4j.js";import{t as f}from"./repeat-BDXokpxQ.js";import{t as p}from"./option-styles-B2sBX5Oz.js";var m=`astl.true-false`,h=[{namespace:m,locale:`en`,messages:s},{namespace:m,locale:`pl`,messages:l}],g=[`true`,`false`],_=e=>e===`true`||e===`false`,v=class extends i{static manifest=c;static messages=h;static shadowRootOptions={...o.shadowRootOptions,slotAssignment:`manual`};static properties={picked:{state:!0}};static styles=[t`
|
|
2
2
|
:host {
|
|
3
3
|
container-type: inline-size;
|
|
4
4
|
}
|
|
@@ -143,4 +143,4 @@ margin-block: var(--astl-space-3) 0;
|
|
|
143
143
|
</p>`}
|
|
144
144
|
</div>`}
|
|
145
145
|
</div>`}#n(e,t){if(this.disabled||this.picked.get(e)===t)return;let n=new Map(this.picked);n.set(e,t),this.picked=n,this.emitChange({[e]:t})}},y={manifest:c,element:v,messages:h};export{y as trueFalseElement};
|
|
146
|
-
//# sourceMappingURL=true-false-
|
|
146
|
+
//# sourceMappingURL=true-false-C-S6RmZY.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"true-false-DP3MO599.js","names":["en","pl","LitElement","repeat","ifDefined","nothing","live","b","i$1","A","verdictIcon","AstlElement","o","i","en_default","trueFalseManifest","pl_default","l","blockStyles","c","optionStyles","namespace","trueFalseUiMessages","VALUES","isValue","value","TrueFalseElement","statement","answers","id","next","ids","#names","yes","no","statements","only","repeated","ui","names","count","hint","#renderStatement","index","picked","marked","verdict","shown","answer","lang","labelOf","describedBy","ref","numbered","label","#pick","name","trueFalseElement"],"sources":["../../../../components/src/true-false/ui-messages.ts","../../../../components/src/true-false/element.ts"],"sourcesContent":["import type { MessageCatalog } from '@astl/core';\nimport en from './messages/ui/en.json' with { type: 'json' };\nimport pl from './messages/ui/pl.json' with { type: 'json' };\n\nconst namespace = 'astl.true-false';\n\n/**\n * The student strings (`ui.*`): the element's catalogs. A module of their own, because bundlers split by module: one\n * that also built `trueFalseMessages` would put the authoring strings into the element's chunk.\n */\nexport const trueFalseUiMessages: readonly MessageCatalog[] = [\n { namespace, locale: 'en', messages: en },\n { namespace, locale: 'pl', messages: pl },\n];\n","import type { Answers, ComponentManifest, MessageCatalog, Units } from '@astl/core';\nimport { AstlElement, type ElementRegistration, verdictIcon } from '@astl/player';\nimport {\n type CSSResultGroup,\n css,\n html,\n LitElement,\n nothing,\n type PropertyDeclarations,\n type TemplateResult,\n} from 'lit';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { live } from 'lit/directives/live.js';\nimport { repeat } from 'lit/directives/repeat.js';\nimport { blockStyles } from '../block-styles.js';\nimport { optionStyles } from '../option-styles.js';\nimport { trueFalseManifest } from './manifest.js';\nimport { trueFalseUiMessages } from './ui-messages.js';\n\n/** The two answers of every statement, in the order each pair shows them. */\nconst VALUES = ['true', 'false'] as const;\ntype Value = (typeof VALUES)[number];\n\nconst isValue = (value: string | undefined): value is Value => value === 'true' || value === 'false';\n\n/**\n * `<astl-true-false>`: one radio group per statement (a native pair \"True\" / \"False\", named by the statement text)\n * in one shadow root, so the browser provides the keyboard: Tab moves between statements, arrow keys within a pair.\n * The light-DOM `<astl-prompt>` and `<astl-statement>` children are slotted manually and never moved or changed.\n * Slots: one per statement (its id), answered `true` or `false`; an unanswered statement has no answer at all.\n * No `delegatesFocus`: a click on a statement's text must not move focus to the first statement.\n */\nexport class TrueFalseElement extends AstlElement {\n static override manifest: ComponentManifest = trueFalseManifest;\n static override messages: readonly MessageCatalog[] = trueFalseUiMessages;\n static override shadowRootOptions: ShadowRootInit = {\n ...LitElement.shadowRootOptions,\n slotAssignment: 'manual',\n };\n\n static override properties: PropertyDeclarations = {\n picked: { state: true },\n };\n\n // Notes on the rules are JS comments between css parts: inside a css literal they would ship to every student.\n static override styles: CSSResultGroup = [\n // The rows follow the width the block gets, not the viewport (players sit in any layout).\n css`\n :host {\n container-type: inline-size;\n }\n .statements {\n display: flex;\n flex-direction: column;\n gap: var(--astl-space-2);\n }\n `,\n // Narrow: the statement, its pair across the full width under it, then its verdict and solution. The two buttons\n // share the row in equal halves while both names fit whole, else one per row (a column of a layout can be narrower\n // than the pair): a name never hyphenates and breaks inside a word only when that word is wider than the row. Wide\n // (see the container query): the pair beside the statement, the same width in every row, at most half of it (long\n // button names wrap between words). A row without a verdict or a solution has no third line, so pristine rows stay\n // compact.\n css`\n .statement {\n box-sizing: border-box;\n display: grid;\n grid-template-columns: minmax(0, 1fr);\n align-items: center;\n gap: var(--astl-space-2) var(--astl-space-4);\n padding: var(--astl-space-3);\n border: var(--astl-outline-width) solid var(--astl-line);\n border-radius: var(--astl-radius-m);\n background: var(--astl-surface);\n }\n .text {\n display: flex;\n align-items: baseline;\n gap: var(--astl-space-2);\n min-inline-size: 0;\n overflow-wrap: break-word;\n }\n .text > :last-child {\n min-inline-size: 0;\n }\n .pair {\n display: flex;\n flex-wrap: wrap;\n gap: var(--astl-space-2);\n }\n .pair .option {\n flex: 1 1 0;\n max-inline-size: 100%;\n hyphens: manual;\n overflow-wrap: break-word;\n }\n @container (min-inline-size: 36rem) {\n .statement {\n grid-template-columns: minmax(0, 1fr) fit-content(50%);\n }\n .pair {\n display: grid;\n grid-template-columns: 1fr 1fr;\n }\n }\n `,\n // The statement's number: a column of its own, so a long statement wraps under its text, not under the number.\n css`\n .number {\n flex: none;\n min-inline-size: 1.5em;\n color: var(--astl-ink-muted);\n font-weight: 600;\n font-variant-numeric: tabular-nums;\n text-align: end;\n }\n `,\n // Selected: the fill and the bar of optionStyles; in hc also bold text (selected-weight).\n css`\n .option {\n position: relative;\n box-sizing: border-box;\n display: flex;\n align-items: center;\n gap: var(--astl-space-2);\n min-block-size: var(--astl-target-min);\n padding-block: var(--astl-space-1);\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 font-size: var(--astl-size-ui);\n cursor: pointer;\n overflow: clip;\n }\n .option[data-selected] {\n font-weight: var(--astl-selected-weight);\n }\n `,\n // The label keeps the width of the wider name in its selected form (bold in hc): aria-hidden copies of both names\n // in that weight share its grid cell, so the two buttons are equal halves until they stack, and a pick never\n // widens its pair out of line with the other rows.\n css`\n .label {\n display: inline-grid;\n }\n .label > * {\n grid-area: 1 / 1;\n }\n .sizer {\n visibility: hidden;\n font-weight: var(--astl-selected-weight);\n }\n .option:has(input:disabled) {\n cursor: default;\n }\n `,\n // Under the pair: the verdict and the solution line (block-styles.ts).\n css`\n .note {\n grid-column: 1 / -1;\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: var(--astl-space-1) var(--astl-space-4);\n font-size: var(--astl-size-ui);\n }\n .group-verdict {\n margin-block: var(--astl-space-3) 0;\n }\n `,\n optionStyles,\n blockStyles,\n ];\n\n /** Answers by statement id. */\n declare protected picked: ReadonlyMap<string, Value>;\n\n constructor() {\n super();\n this.picked = new Map();\n }\n\n /** `<astl-statement>` children in view order. */\n get statements(): readonly HTMLElement[] {\n return this.childElements('astl-statement');\n }\n\n get slotIds(): readonly string[] {\n return this.statements.map((statement) => statement.id);\n }\n\n getAnswers(): Answers {\n const answers: Record<string, string> = {};\n for (const id of this.slotIds) {\n const value = this.picked.get(id);\n if (value !== undefined) answers[id] = value;\n }\n return answers;\n }\n\n setAnswers(answers: Answers): void {\n const next = new Map(this.picked);\n for (const id of this.slotIds) {\n const value = answers[id];\n if (value === undefined) continue;\n // `''` clears; anything but `true` or `false` cannot be shown, so it clears too.\n if (isValue(value)) next.set(id, value);\n else next.delete(id);\n }\n this.picked = next;\n }\n\n /** One unit per statement: \"2 empty answers\" means two statements nobody marked. */\n units(): Units {\n const ids = this.slotIds;\n return { answered: ids.filter((id) => this.picked.has(id)).length, total: ids.length };\n }\n\n /** The author's names of the two buttons (content), or null for the UI's \"True\" and \"False\": both or neither. */\n get #names(): Readonly<Record<Value, string>> | null {\n const [yes = '', no = ''] = VALUES.map((value) => (this.getAttribute(`${value}-label`) ?? '').trim());\n return yes !== '' && no !== '' ? { true: yes, false: no } : null;\n }\n\n protected override render(): TemplateResult {\n const statements = this.statements;\n const [only] = statements.length === 1 ? statements : [];\n // A single statement that shows its verdict already says what the block line would repeat.\n const repeated = only !== undefined && this.picked.has(only.id) && this.slotVerdict(only.id) !== null;\n const ui = this.uiLanguage;\n const names = this.#names;\n const count = statements.length;\n const hint =\n names === null\n ? this.t('ui.hint', { count })\n : this.t('ui.hintNamed', { count, yes: names.true, no: names.false });\n return html`<fieldset part=\"true-false\">\n <legend part=\"prompt\">\n <slot data-tag=\"astl-prompt\"></slot>\n <span class=\"hint\" lang=${ui.lang}><bdi>${hint}</bdi></span>\n </legend>\n <div class=\"statements\">\n ${repeat(\n statements,\n (statement) => statement.id,\n (statement, index) => this.#renderStatement(statement.id, index, names, count > 1),\n )}\n </div>\n ${this.renderGroupVerdict(repeated ? null : this.groupVerdict)}\n </fieldset>`;\n }\n\n #renderStatement(\n id: string,\n index: number,\n names: Readonly<Record<Value, string>> | null,\n numbered: boolean,\n ): TemplateResult {\n const picked = this.picked.get(id) ?? null;\n // Where statements are marked one by one, an unanswered one shows \"no answer\" (dotted), as in every type.\n const marked = Object.keys(this.feedback?.slots ?? {}).length > 0;\n const verdict = picked === null ? (marked ? 'empty' : null) : this.slotVerdict(id);\n const shown = this.solution?.[id];\n // One clear indicator: a statement whose answer shows \"correct\" needs no solution line.\n const answer = isValue(shown) && verdict !== 'correct' ? shown : null;\n const ui = this.uiLanguage;\n // The author's names are content and keep its language; the UI's carry the UI language.\n const lang = names === null ? ui : { lang: undefined, dir: undefined };\n const labelOf = (value: Value) => names?.[value] ?? this.t(`ui.${value}`);\n const describedBy = [\n verdict === null ? '' : `verdict-${index}`,\n answer === null ? '' : `solution-${index}`,\n ]\n .filter((ref) => ref !== '')\n .join(' ');\n // The number is part of the text that names the pair: \"2 The Moon is a planet\".\n return html`<div class=\"statement astl-box\" part=\"statement\" data-verdict=${ifDefined(verdict ?? undefined)}>\n <span class=\"text\" id=\"text-${index}\"\n >${numbered ? html`<span class=\"number\">${index + 1}</span>` : nothing}<span\n ><slot data-statement=${id}></slot></span\n ></span>\n <div class=\"pair\" role=\"radiogroup\" aria-labelledby=\"text-${index}\">\n ${VALUES.map((value) => {\n const label = labelOf(value);\n return html`<label class=\"option astl-ring\" part=\"option\" ?data-selected=${picked === value}>\n <input\n part=\"control\"\n type=\"radio\"\n name=${id}\n value=${value}\n .checked=${live(picked === value)}\n ?disabled=${this.disabled}\n aria-describedby=${describedBy === '' ? nothing : describedBy}\n @change=${() => this.#pick(id, value)}\n />\n <span class=\"label\" lang=${ifDefined(lang.lang)} dir=${ifDefined(lang.dir)}\n ><span>${label}</span>${VALUES.map(\n (name) => html`<span class=\"sizer\" aria-hidden=\"true\">${labelOf(name)}</span>`,\n )}</span\n >\n </label>`;\n })}\n </div>\n ${\n verdict === null && answer === null\n ? nothing\n : html`<div class=\"note\">\n ${this.renderVerdict(verdict, { id: `verdict-${index}` })}\n ${\n answer === null\n ? nothing\n : // A UI sentence around the answer's name, which keeps its own language.\n html`<p class=\"astl-solution\" part=\"solution\" id=\"solution-${index}\" lang=${ui.lang} dir=${ui.dir}>\n ${verdictIcon('correct')}<span class=\"astl-solution-label\">${this.t('ui.solution')}</span>\n <bdi lang=${ifDefined(names === null ? undefined : this.contentLang || undefined)}>${labelOf(answer)}</bdi>\n </p>`\n }\n </div>`\n }\n </div>`;\n }\n\n #pick(id: string, value: Value): void {\n if (this.disabled || this.picked.get(id) === value) return;\n const next = new Map(this.picked);\n next.set(id, value);\n this.picked = next;\n this.emitChange({ [id]: value });\n }\n}\n\nexport const trueFalseElement: ElementRegistration = {\n manifest: trueFalseManifest,\n element: TrueFalseElement,\n messages: trueFalseUiMessages,\n};\n"],"mappings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KACP3C,EAEA,CAAI,yDAAyDsC,EAAM,SAASL,EAAG,KAAK,OAAOA,EAAG,IAAI;wBAC9F5B,EAAY,SAAS,EAAE,oCAAoC,KAAK,EAAE,aAAa,EAAE;kCACvEN,EAAUmC,IAAU,KAAO,IAAA,GAAY,KAAK,aAAe,IAAA,EAAS,EAAE,GAAGW,EAAQF,CAAM,EAAE;0BAE5G;oBAER;WAEL,CAEA,GAAM,EAAY,EAAoB,CACpC,GAAI,KAAK,UAAY,KAAK,OAAO,IAAInB,CAAE,IAAMJ,EAAO,OACpD,IAAMK,EAAO,IAAI,IAAI,KAAK,MAAM,EAChCA,EAAK,IAAID,EAAIJ,CAAK,EAClB,KAAK,OAASK,EACd,KAAK,WAAW,EAAGD,GAAKJ,CAAM,CAAC,CACjC,CACF,EAEagC,EAAwC,CACnD,SAAU1C,EACV,QAASW,EACT,SAAUJ,CACZ,E"}
|
|
1
|
+
{"version":3,"file":"true-false-C-S6RmZY.js","names":["en","pl","LitElement","repeat","ifDefined","nothing","live","b","i$1","A","verdictIcon","AstlElement","o","i","en_default","trueFalseManifest","pl_default","l","blockStyles","c","optionStyles","namespace","trueFalseUiMessages","VALUES","isValue","value","TrueFalseElement","statement","answers","id","next","ids","#names","yes","no","statements","only","repeated","ui","names","count","hint","#renderStatement","index","picked","marked","verdict","shown","answer","lang","labelOf","describedBy","ref","numbered","label","#pick","name","trueFalseElement"],"sources":["../../../../components/src/true-false/ui-messages.ts","../../../../components/src/true-false/element.ts"],"sourcesContent":["import type { MessageCatalog } from '@astl/core';\nimport en from './messages/ui/en.json' with { type: 'json' };\nimport pl from './messages/ui/pl.json' with { type: 'json' };\n\nconst namespace = 'astl.true-false';\n\n/**\n * The student strings (`ui.*`): the element's catalogs. A module of their own, because bundlers split by module: one\n * that also built `trueFalseMessages` would put the authoring strings into the element's chunk.\n */\nexport const trueFalseUiMessages: readonly MessageCatalog[] = [\n { namespace, locale: 'en', messages: en },\n { namespace, locale: 'pl', messages: pl },\n];\n","import type { Answers, ComponentManifest, MessageCatalog, Units } from '@astl/core';\nimport { AstlElement, type ElementRegistration, verdictIcon } from '@astl/player';\nimport {\n type CSSResultGroup,\n css,\n html,\n LitElement,\n nothing,\n type PropertyDeclarations,\n type TemplateResult,\n} from 'lit';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { live } from 'lit/directives/live.js';\nimport { repeat } from 'lit/directives/repeat.js';\nimport { blockStyles } from '../block-styles.js';\nimport { optionStyles } from '../option-styles.js';\nimport { trueFalseManifest } from './manifest.js';\nimport { trueFalseUiMessages } from './ui-messages.js';\n\n/** The two answers of every statement, in the order each pair shows them. */\nconst VALUES = ['true', 'false'] as const;\ntype Value = (typeof VALUES)[number];\n\nconst isValue = (value: string | undefined): value is Value => value === 'true' || value === 'false';\n\n/**\n * `<astl-true-false>`: one radio group per statement (a native pair \"True\" / \"False\", named by the statement text)\n * in one shadow root, so the browser provides the keyboard: Tab moves between statements, arrow keys within a pair.\n * The light-DOM `<astl-prompt>` and `<astl-statement>` children are slotted manually and never moved or changed.\n * Slots: one per statement (its id), answered `true` or `false`; an unanswered statement has no answer at all.\n * No `delegatesFocus`: a click on a statement's text must not move focus to the first statement.\n */\nexport class TrueFalseElement extends AstlElement {\n static override manifest: ComponentManifest = trueFalseManifest;\n static override messages: readonly MessageCatalog[] = trueFalseUiMessages;\n static override shadowRootOptions: ShadowRootInit = {\n ...LitElement.shadowRootOptions,\n slotAssignment: 'manual',\n };\n\n static override properties: PropertyDeclarations = {\n picked: { state: true },\n };\n\n // Notes on the rules are JS comments between css parts: inside a css literal they would ship to every student.\n static override styles: CSSResultGroup = [\n // The rows follow the width the block gets, not the viewport (players sit in any layout).\n css`\n :host {\n container-type: inline-size;\n }\n .statements {\n display: flex;\n flex-direction: column;\n gap: var(--astl-space-2);\n }\n `,\n // Narrow: the statement, its pair across the full width under it, then its verdict and solution. The two buttons\n // share the row in equal halves while both names fit whole, else one per row (a column of a layout can be narrower\n // than the pair): a name never hyphenates and breaks inside a word only when that word is wider than the row. Wide\n // (see the container query): the pair beside the statement, the same width in every row, at most half of it (long\n // button names wrap between words). A row without a verdict or a solution has no third line, so pristine rows stay\n // compact.\n css`\n .statement {\n box-sizing: border-box;\n display: grid;\n grid-template-columns: minmax(0, 1fr);\n align-items: center;\n gap: var(--astl-space-2) var(--astl-space-4);\n padding: var(--astl-space-3);\n border: var(--astl-outline-width) solid var(--astl-line);\n border-radius: var(--astl-radius-m);\n background: var(--astl-surface);\n }\n .text {\n display: flex;\n align-items: baseline;\n gap: var(--astl-space-2);\n min-inline-size: 0;\n overflow-wrap: break-word;\n }\n .text > :last-child {\n min-inline-size: 0;\n }\n .pair {\n display: flex;\n flex-wrap: wrap;\n gap: var(--astl-space-2);\n }\n .pair .option {\n flex: 1 1 0;\n max-inline-size: 100%;\n hyphens: manual;\n overflow-wrap: break-word;\n }\n @container (min-inline-size: 36rem) {\n .statement {\n grid-template-columns: minmax(0, 1fr) fit-content(50%);\n }\n .pair {\n display: grid;\n grid-template-columns: 1fr 1fr;\n }\n }\n `,\n // The statement's number: a column of its own, so a long statement wraps under its text, not under the number.\n css`\n .number {\n flex: none;\n min-inline-size: 1.5em;\n color: var(--astl-ink-muted);\n font-weight: 600;\n font-variant-numeric: tabular-nums;\n text-align: end;\n }\n `,\n // Selected: the fill and the bar of optionStyles; in hc also bold text (selected-weight).\n css`\n .option {\n position: relative;\n box-sizing: border-box;\n display: flex;\n align-items: center;\n gap: var(--astl-space-2);\n min-block-size: var(--astl-target-min);\n padding-block: var(--astl-space-1);\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 font-size: var(--astl-size-ui);\n cursor: pointer;\n overflow: clip;\n }\n .option[data-selected] {\n font-weight: var(--astl-selected-weight);\n }\n `,\n // The label keeps the width of the wider name in its selected form (bold in hc): aria-hidden copies of both names\n // in that weight share its grid cell, so the two buttons are equal halves until they stack, and a pick never\n // widens its pair out of line with the other rows.\n css`\n .label {\n display: inline-grid;\n }\n .label > * {\n grid-area: 1 / 1;\n }\n .sizer {\n visibility: hidden;\n font-weight: var(--astl-selected-weight);\n }\n .option:has(input:disabled) {\n cursor: default;\n }\n `,\n // Under the pair: the verdict and the solution line (block-styles.ts).\n css`\n .note {\n grid-column: 1 / -1;\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: var(--astl-space-1) var(--astl-space-4);\n font-size: var(--astl-size-ui);\n }\n .group-verdict {\n margin-block: var(--astl-space-3) 0;\n }\n `,\n optionStyles,\n blockStyles,\n ];\n\n /** Answers by statement id. */\n declare protected picked: ReadonlyMap<string, Value>;\n\n constructor() {\n super();\n this.picked = new Map();\n }\n\n /** `<astl-statement>` children in view order. */\n get statements(): readonly HTMLElement[] {\n return this.childElements('astl-statement');\n }\n\n get slotIds(): readonly string[] {\n return this.statements.map((statement) => statement.id);\n }\n\n getAnswers(): Answers {\n const answers: Record<string, string> = {};\n for (const id of this.slotIds) {\n const value = this.picked.get(id);\n if (value !== undefined) answers[id] = value;\n }\n return answers;\n }\n\n setAnswers(answers: Answers): void {\n const next = new Map(this.picked);\n for (const id of this.slotIds) {\n const value = answers[id];\n if (value === undefined) continue;\n // `''` clears; anything but `true` or `false` cannot be shown, so it clears too.\n if (isValue(value)) next.set(id, value);\n else next.delete(id);\n }\n this.picked = next;\n }\n\n /** One unit per statement: \"2 empty answers\" means two statements nobody marked. */\n units(): Units {\n const ids = this.slotIds;\n return { answered: ids.filter((id) => this.picked.has(id)).length, total: ids.length };\n }\n\n /** The author's names of the two buttons (content), or null for the UI's \"True\" and \"False\": both or neither. */\n get #names(): Readonly<Record<Value, string>> | null {\n const [yes = '', no = ''] = VALUES.map((value) => (this.getAttribute(`${value}-label`) ?? '').trim());\n return yes !== '' && no !== '' ? { true: yes, false: no } : null;\n }\n\n protected override render(): TemplateResult {\n const statements = this.statements;\n const [only] = statements.length === 1 ? statements : [];\n // A single statement that shows its verdict already says what the block line would repeat.\n const repeated = only !== undefined && this.picked.has(only.id) && this.slotVerdict(only.id) !== null;\n const ui = this.uiLanguage;\n const names = this.#names;\n const count = statements.length;\n const hint =\n names === null\n ? this.t('ui.hint', { count })\n : this.t('ui.hintNamed', { count, yes: names.true, no: names.false });\n return html`<fieldset part=\"true-false\">\n <legend part=\"prompt\">\n <slot data-tag=\"astl-prompt\"></slot>\n <span class=\"hint\" lang=${ui.lang}><bdi>${hint}</bdi></span>\n </legend>\n <div class=\"statements\">\n ${repeat(\n statements,\n (statement) => statement.id,\n (statement, index) => this.#renderStatement(statement.id, index, names, count > 1),\n )}\n </div>\n ${this.renderGroupVerdict(repeated ? null : this.groupVerdict)}\n </fieldset>`;\n }\n\n #renderStatement(\n id: string,\n index: number,\n names: Readonly<Record<Value, string>> | null,\n numbered: boolean,\n ): TemplateResult {\n const picked = this.picked.get(id) ?? null;\n // Where statements are marked one by one, an unanswered one shows \"no answer\" (dotted), as in every type.\n const marked = Object.keys(this.feedback?.slots ?? {}).length > 0;\n const verdict = picked === null ? (marked ? 'empty' : null) : this.slotVerdict(id);\n const shown = this.solution?.[id];\n // One clear indicator: a statement whose answer shows \"correct\" needs no solution line.\n const answer = isValue(shown) && verdict !== 'correct' ? shown : null;\n const ui = this.uiLanguage;\n // The author's names are content and keep its language; the UI's carry the UI language.\n const lang = names === null ? ui : { lang: undefined, dir: undefined };\n const labelOf = (value: Value) => names?.[value] ?? this.t(`ui.${value}`);\n const describedBy = [\n verdict === null ? '' : `verdict-${index}`,\n answer === null ? '' : `solution-${index}`,\n ]\n .filter((ref) => ref !== '')\n .join(' ');\n // The number is part of the text that names the pair: \"2 The Moon is a planet\".\n return html`<div class=\"statement astl-box\" part=\"statement\" data-verdict=${ifDefined(verdict ?? undefined)}>\n <span class=\"text\" id=\"text-${index}\"\n >${numbered ? html`<span class=\"number\">${index + 1}</span>` : nothing}<span\n ><slot data-statement=${id}></slot></span\n ></span>\n <div class=\"pair\" role=\"radiogroup\" aria-labelledby=\"text-${index}\">\n ${VALUES.map((value) => {\n const label = labelOf(value);\n return html`<label class=\"option astl-ring\" part=\"option\" ?data-selected=${picked === value}>\n <input\n part=\"control\"\n type=\"radio\"\n name=${id}\n value=${value}\n .checked=${live(picked === value)}\n ?disabled=${this.disabled}\n aria-describedby=${describedBy === '' ? nothing : describedBy}\n @change=${() => this.#pick(id, value)}\n />\n <span class=\"label\" lang=${ifDefined(lang.lang)} dir=${ifDefined(lang.dir)}\n ><span>${label}</span>${VALUES.map(\n (name) => html`<span class=\"sizer\" aria-hidden=\"true\">${labelOf(name)}</span>`,\n )}</span\n >\n </label>`;\n })}\n </div>\n ${\n verdict === null && answer === null\n ? nothing\n : html`<div class=\"note\">\n ${this.renderVerdict(verdict, { id: `verdict-${index}` })}\n ${\n answer === null\n ? nothing\n : // A UI sentence around the answer's name, which keeps its own language.\n html`<p class=\"astl-solution\" part=\"solution\" id=\"solution-${index}\" lang=${ui.lang} dir=${ui.dir}>\n ${verdictIcon('correct')}<span class=\"astl-solution-label\">${this.t('ui.solution')}</span>\n <bdi lang=${ifDefined(names === null ? undefined : this.contentLang || undefined)}>${labelOf(answer)}</bdi>\n </p>`\n }\n </div>`\n }\n </div>`;\n }\n\n #pick(id: string, value: Value): void {\n if (this.disabled || this.picked.get(id) === value) return;\n const next = new Map(this.picked);\n next.set(id, value);\n this.picked = next;\n this.emitChange({ [id]: value });\n }\n}\n\nexport const trueFalseElement: ElementRegistration = {\n manifest: trueFalseManifest,\n element: TrueFalseElement,\n messages: trueFalseUiMessages,\n};\n"],"mappings":"A,uUAIA,IAAMqB,EAAY,kBAMLC,EAAiD,CAC5D,CAAE,YAAW,OAAQ,KAAM,SAAUtB,CAAG,EACxC,CAAE,YAAW,OAAQ,KAAM,SAAUC,CAAG,CAC1C,ECOMsB,EAAS,CAAC,OAAQ,OAAO,EAGzBC,EAAW,GAA8CC,IAAU,QAAUA,IAAU,QAShFC,EAAb,cAAsCf,CAAY,CAChD,OAAgB,SAA8BI,EAC9C,OAAgB,SAAs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AAI,KAAK,UAAY,KAAK,OAAO,IAAInB,CAAE,IAAMJ,EAAO,OACpD,IAAMK,EAAO,IAAI,IAAI,KAAK,MAAM,EAChCA,EAAK,IAAID,EAAIJ,CAAK,EAClB,KAAK,OAASK,EACd,KAAK,WAAW,EAAGD,GAAKJ,CAAM,CAAC,CACjC,CACF,EAEagC,EAAwC,CACnD,SAAU1C,EACV,QAASW,EACT,SAAUJ,CACZ,E"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{C as e,E as t,b as n,n as r,v as i}from"./runtime-
|
|
1
|
+
import{C as e,E as t,b as n,n as r,v as i}from"./runtime-C25QK5B0.js";import{n as a,r as o,t as s}from"./video-manifest-8OwkhhAI.js";import{t as c}from"./block-styles-CCtSFM4j.js";var l=`astl.video`,u=[{namespace:l,locale:`en`,messages:a},{namespace:l,locale:`pl`,messages:s}],d={youtube:e=>`https://www.youtube-nocookie.com/embed/${encodeURIComponent(e)}?autoplay=1`,vimeo:e=>`https://player.vimeo.com/video/${encodeURIComponent(e)}?autoplay=1&dnt=1`};function f(e,t){try{return new Intl.DisplayNames([t],{type:`language`}).of(e)??e}catch{return e}}var p=class extends r{static manifest=o;static messages=u;static properties={playing:{state:!0}};static styles=[t`
|
|
2
2
|
.title {
|
|
3
3
|
margin-block: 0 var(--astl-space-2);
|
|
4
4
|
font-weight: 600;
|
|
@@ -95,4 +95,4 @@ font-size: var(--astl-size-ui);
|
|
|
95
95
|
<p class="loads" id="loads" lang=${r.lang} dir=${r.dir} aria-hidden="true">
|
|
96
96
|
${this.t(`ui.loads`,{provider:t})}
|
|
97
97
|
</p>`}updated(e){e.has(`playing`)&&this.playing&&this.renderRoot.querySelector(`iframe`)?.focus()}},m={manifest:o,element:p,messages:u};export{m as videoElement};
|
|
98
|
-
//# sourceMappingURL=video-
|
|
98
|
+
//# sourceMappingURL=video-Dae8Gguf.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"video-
|
|
1
|
+
{"version":3,"file":"video-Dae8Gguf.js","names":["en","pl","ifDefined","nothing","b","i","A","AstlElement","o","en_default","videoManifest","pl_default","blockStyles","namespace","videoUiMessages","EMBEDS","id","languageName","locale","tag","VideoElement","label","provider","name","#file","#provider","captions","lang","ui","changed","videoElement"],"sources":["../../../../components/src/video/ui-messages.ts","../../../../components/src/video/element.ts"],"sourcesContent":["import type { MessageCatalog } from '@astl/core';\nimport en from './messages/ui/en.json' with { type: 'json' };\nimport pl from './messages/ui/pl.json' with { type: 'json' };\n\nconst namespace = 'astl.video';\n\n/**\n * The student strings (`ui.*`): the element's catalogs. A module of their own, because bundlers split by module: one\n * that also built `videoMessages` would put the authoring strings into the element's chunk.\n */\nexport const videoUiMessages: readonly MessageCatalog[] = [\n { namespace, locale: 'en', messages: en },\n { namespace, locale: 'pl', messages: pl },\n];\n","import type { Answers, ComponentManifest, MessageCatalog, Units } from '@astl/core';\nimport { AstlElement, type ElementRegistration } from '@astl/player';\nimport {\n type CSSResultGroup,\n css,\n html,\n nothing,\n type PropertyDeclarations,\n type PropertyValues,\n type TemplateResult,\n} from 'lit';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { blockStyles } from '../block-styles.js';\nimport { videoManifest } from './manifest.js';\nimport { videoUiMessages } from './ui-messages.js';\n\ntype Provider = 'youtube' | 'vimeo';\n\n/** Where a provider video plays, from its id: YouTube without cookies, Vimeo with do-not-track, both at once. */\nconst EMBEDS: Readonly<Record<Provider, (id: string) => string>> = {\n youtube: (id) => `https://www.youtube-nocookie.com/embed/${encodeURIComponent(id)}?autoplay=1`,\n vimeo: (id) => `https://player.vimeo.com/video/${encodeURIComponent(id)}?autoplay=1&dnt=1`,\n};\n\n/** A language in the UI language (\"English\", \"angielski\"), or its tag when the browser cannot name it. */\nfunction languageName(tag: string, locale: string): string {\n try {\n return new Intl.DisplayNames([locale], { type: 'language' }).of(tag) ?? tag;\n } catch {\n return tag;\n }\n}\n\n/**\n * `<astl-video>`: the title, then a file in the browser's video player (captions on by default), or a YouTube or Vimeo\n * video behind a Play button: nothing loads from the provider until it is pressed, and then only its privacy-friendly\n * player, sandboxed, which takes the focus. Nothing is answered or stored; a handed-in attempt still plays.\n */\nexport class VideoElement extends AstlElement {\n static override manifest: ComponentManifest = videoManifest;\n static override messages: readonly MessageCatalog[] = videoUiMessages;\n\n static override properties: PropertyDeclarations = {\n playing: { state: true },\n };\n\n static override styles: CSSResultGroup = [\n css`\n .title {\n margin-block: 0 var(--astl-space-2);\n font-weight: 600;\n }\n .frame {\n box-sizing: border-box;\n display: block;\n inline-size: 100%;\n aspect-ratio: 16 / 9;\n border: 0;\n border-radius: var(--astl-radius-l);\n background: var(--astl-surface-raised);\n }\n `,\n // The Play button stands where the provider's player will: a frame with a large play sign and the word; what\n // it loads is said under it (its description, outside it: the name of a button holds all its visible text).\n css`\n .facade {\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n gap: var(--astl-space-2);\n margin: 0;\n padding: var(--astl-space-4);\n border: var(--astl-outline-width) solid var(--astl-outline);\n color: var(--astl-ink);\n font: inherit;\n cursor: pointer;\n }\n .facade:hover {\n border-color: var(--astl-accent);\n }\n .facade svg {\n inline-size: 4rem;\n block-size: 4rem;\n }\n .facade circle {\n fill: var(--astl-accent);\n }\n .facade path {\n fill: var(--astl-on-accent);\n }\n .play {\n font-size: 1.25rem;\n font-weight: 600;\n }\n .loads {\n margin-block: var(--astl-space-2) 0;\n color: var(--astl-ink-muted);\n font-size: var(--astl-size-ui);\n }\n `,\n blockStyles,\n ];\n\n /** Whether the student pressed Play on a provider video: only then does its player load. */\n declare protected playing: boolean;\n\n constructor() {\n super();\n this.playing = false;\n }\n\n get slotIds(): readonly string[] {\n return [];\n }\n\n getAnswers(): Answers {\n return {};\n }\n\n setAnswers(): void {}\n\n units(): Units {\n return { answered: 0, total: 0 };\n }\n\n protected override render(): TemplateResult {\n const label = this.stringAttribute('label') ?? '';\n const provider = (['youtube', 'vimeo'] as const).find((name) => this.stringAttribute(name));\n return html`<div part=\"video\">\n <p class=\"title\" part=\"title\" id=\"title\">${label}</p>\n ${provider === undefined ? this.#file() : this.#provider(provider, label)}\n </div>`;\n }\n\n #file(): TemplateResult {\n const captions = this.stringAttribute('captions');\n const lang = this.stringAttribute('captions-lang') ?? 'en';\n // Captions load with CORS (`crossorigin`), the only way a browser shows them from another origin.\n return html`<video\n class=\"frame\"\n part=\"player\"\n controls\n preload=\"metadata\"\n src=${ifDefined(this.stringAttribute('src') ?? undefined)}\n poster=${ifDefined(this.stringAttribute('poster') ?? undefined)}\n crossorigin=${ifDefined(captions === null ? undefined : 'anonymous')}\n aria-labelledby=\"title\"\n >\n ${\n captions === null\n ? nothing\n : html`<track\n kind=\"captions\"\n src=${captions}\n srclang=${lang}\n label=${languageName(lang, this.context.locale)}\n default\n />`\n }\n </video>`;\n }\n\n #provider(provider: Provider, label: string): TemplateResult {\n if (this.playing) {\n return html`<iframe\n class=\"frame\"\n part=\"player\"\n src=${EMBEDS[provider](this.stringAttribute(provider) ?? '')}\n title=${label}\n sandbox=\"allow-scripts allow-same-origin\"\n allow=\"autoplay; encrypted-media; fullscreen; picture-in-picture\"\n referrerpolicy=\"strict-origin-when-cross-origin\"\n ></iframe>`;\n }\n const ui = this.uiLanguage;\n // Named \"Play\" and the title, described by what it loads. UI text in the UI language; the title keeps its own.\n return html`<button\n type=\"button\"\n class=\"frame facade\"\n part=\"play\"\n lang=${ui.lang}\n dir=${ui.dir}\n aria-labelledby=\"play title\"\n aria-describedby=\"loads\"\n @click=${() => {\n this.playing = true;\n }}\n >\n <svg viewBox=\"0 0 64 64\" aria-hidden=\"true\" focusable=\"false\">\n <circle cx=\"32\" cy=\"32\" r=\"32\"></circle>\n <path d=\"M25 19v26l21-13z\"></path>\n </svg>\n <span class=\"play\" id=\"play\">${this.t('ui.play')}</span>\n </button>\n <p class=\"loads\" id=\"loads\" lang=${ui.lang} dir=${ui.dir} aria-hidden=\"true\">\n ${this.t('ui.loads', { provider })}\n </p>`;\n }\n\n protected override updated(changed: PropertyValues): void {\n // The button the student pressed is gone: its player takes the focus.\n if (changed.has('playing') && this.playing) this.renderRoot.querySelector('iframe')?.focus();\n }\n}\n\nexport const videoElement: ElementRegistration = {\n manifest: videoManifest,\n element: VideoElement,\n messages: videoUiMessages,\n};\n"],"mappings":"A,oLAIA,IAAMa,EAAY,aAMLC,EAA6C,CACxD,CAAE,YAAW,OAAQ,KAAM,SAAUd,CAAG,EACxC,CAAE,YAAW,OAAQ,KAAM,SAAUC,CAAG,CAC1C,ECMMc,EAA6D,CACjE,QAAU,GAAO,0CAA0C,mBAAmBC,CAAE,EAAE,aAClF,MAAQ,GAAO,kCAAkC,mBAAmBA,CAAE,EAAE,kBAC1E,EAGA,SAASC,EAAa,EAAa,EAAwB,CACzD,GAAI,CACF,OAAO,IAAI,KAAK,aAAa,CAACC,CAAM,EAAG,CAAE,KAAM,UAAW,CAAC,CAAC,CAAC,GAAGC,CAAG,GAAKA,CAC1E,MAAQ,CACN,OAAOA,CACT,CACF,CAOA,IAAaC,EAAb,cAAkCb,CAAY,CAC5C,OAAgB,SAA8BG,EAC9C,OAAgB,SAAsCI,EAEtD,OAAgB,WAAmC,CACjD,QAAS,CAAE,MAAO,EAAK,CACzB,EAEA,OAAgB,OAAyB,CACvC,CAAG;;;;;;;;;;;;;;EAiBH,CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqCHF,CACF,EAKA,aAAc,CACZ,MAAM,EACN,KAAK,QAAU,EACjB,CAEA,IAAI,SAA6B,CAC/B,MAAO,CAAC,CACV,CAEA,YAAsB,CACpB,MAAO,CAAC,CACV,CAEA,YAAmB,CAAC,CAEpB,OAAe,CACb,MAAO,CAAE,SAAU,EAAG,MAAO,CAAE,CACjC,CAEA,QAA4C,CAC1C,IAAMS,EAAQ,KAAK,gBAAgB,OAAO,GAAK,GACzCC,EAAY,CAAC,UAAW,OAAO,CAAC,CAAW,KAAM,GAAS,KAAK,gBAAgBC,CAAI,CAAC,EAC1F,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n,b as r,n as i,y as a}from"./runtime-C25QK5B0.js";import{n as o,r as s,t as c}from"./word-bank-manifest-C1FSo1kH.js";import{t as l}from"./pick-and-place-DVQIPYuL.js";import{t as u}from"./block-styles-CCtSFM4j.js";import{t as d}from"./repeat-BDXokpxQ.js";import{t as f}from"./chip-styles--gboWK2Z.js";var p=`astl.word-bank`,m=[{namespace:p,locale:`en`,messages:o},{namespace:p,locale:`pl`,messages:c}],h=``,g=250,_=n`<path d="M10 2.5v15M2.5 10h15M10 2.5 7.5 5M10 2.5 12.5 5M10 17.5 7.5 15M10 17.5 12.5 15M2.5 10 5 7.5M2.5 10 5 12.5M17.5 10 15 7.5M17.5 10 15 12.5" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>`,v=e=>(e?.textContent??``).replace(/\s+/g,` `).trim(),y=class extends i{static manifest=s;static messages=m;static shadowRootOptions={...a.shadowRootOptions,slotAssignment:`manual`};static styles=[t`
|
|
2
2
|
.tray {
|
|
3
3
|
display: flex;
|
|
4
4
|
flex-direction: column;
|
|
@@ -77,4 +77,4 @@ pointer-events: none;
|
|
|
77
77
|
>${this.t(`ui.placed`,{n:i.number})}</span
|
|
78
78
|
>`}
|
|
79
79
|
</span>`}updated(){let e=new Map(this.words.map(e=>[e.id,e]));for(let t of this.renderRoot.querySelectorAll(`slot[data-word]`)){let n=e.get(t.dataset.word??``);t.assign(...n?[n]:[])}for(let e of this.drops)e.requestUpdate()}#i(e){return this.drops.find(t=>t.id===e)}#a(e){return this.reuse?void 0:this.drops.find(t=>t.word===e)}#o(e){return v(this.words.find(t=>t.id===e))}#s(e,t){let n=this.#i(e),r=n!==void 0&&n.word===``,i=r?t:n?.word??e,a=r?n:this.#i(t);if(this.#n=i,r||n?.place(``),a===void 0)n===void 0&&this.#a(i)?.place(``);else{if(!this.reuse)for(let e of this.drops)e!==a&&e.word===i&&e.place(``);a.place(i)}}#c(e,t,n){let r=e=>this.#i(e)?.number??0,i=this.#o(t),a=this.#t;if(a!==null)return this.t(`ui.announce.out`,{word:i,n:a.number});if(e===`put`){let e=this.#o(this.#n);return n===h?this.t(`ui.announce.back`,{word:e}):this.t(`ui.announce.put`,{word:e,n:r(this.#i(n)===void 0?t:n)})}let o=e=>{let t=this.#i(e)?.word??``;return t===``?this.t(`ui.announce.gapEmpty`,{n:r(e)}):this.t(`ui.announce.gap`,{n:r(e),word:this.#o(t)})};if(this.#i(t)!==void 0){if(e===`pick`)return this.t(`ui.announce.wait`,{n:r(t)});if(e===`cancel`)return this.t(`ui.announce.stayEmpty`,{n:r(t)});if(n===t)return o(t);let i=this.#a(n);return i===void 0?this.t(`ui.announce.word`,{word:this.#o(n)}):this.t(`ui.announce.wordPlaced`,{word:this.#o(n),n:i.number})}return e===`pick`?this.t(`ui.announce.pick`,{word:i}):e===`target`?n===h?this.t(`ui.announce.bank`):o(n):n===h?this.t(`ui.announce.stay`,{word:i}):this.t(`ui.announce.stayGap`,{word:i,n:r(n)})}},b={manifest:s,element:y,messages:m};export{b as wordBankElement};
|
|
80
|
-
//# sourceMappingURL=word-bank-
|
|
80
|
+
//# sourceMappingURL=word-bank-CsIle0Ro.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"word-bank-ARjwUKZf.js","names":["en","pl","LitElement","repeat","nothing","b","i$1","w","A","AstlElement","i","en_default","wordBankManifest","pl_default","PickAndPlace","blockStyles","c","chipStyles","namespace","wordBankUiMessages","BANK","LONG_PRESS","MOVE_ICON","textOf","el","WordBankElement","#drop","item","drop","word","#holder","hits","x","y","d","#commit","to","#message","moment","#pick","child","pick","event","picked","#out","ui","waiting","hint","#label","holders","#renderWord","id","holder","words","slot","source","target","#moved","other","n","out","moved","gap","held","wordBankElement"],"sources":["../../../../components/src/word-bank/ui-messages.ts","../../../../components/src/word-bank/element.ts"],"sourcesContent":["import type { MessageCatalog } from '@astl/core';\nimport en from './messages/ui/en.json' with { type: 'json' };\nimport pl from './messages/ui/pl.json' with { type: 'json' };\n\nconst namespace = 'astl.word-bank';\n\n/**\n * The student strings (`ui.*`): the element's catalogs. A module of their own, because bundlers split by module: one\n * that also built `wordBankMessages` would put the authoring strings into the element's chunk.\n */\nexport const wordBankUiMessages: readonly MessageCatalog[] = [\n { namespace, locale: 'en', messages: en },\n { namespace, locale: 'pl', messages: pl },\n];\n","import type { Answers, ComponentManifest, MessageCatalog, Units } from '@astl/core';\nimport { AstlElement, type ElementRegistration } from '@astl/player';\nimport { PickAndPlace, type PickMoment } from '@astl/player/interaction';\nimport { type CSSResultGroup, css, html, LitElement, nothing, svg, type TemplateResult } from 'lit';\nimport { repeat } from 'lit/directives/repeat.js';\nimport { blockStyles } from '../block-styles.js';\nimport { chipStyles } from '../chip-styles.js';\nimport { wordBankManifest } from './manifest.js';\nimport { wordBankUiMessages } from './ui-messages.js';\n\n/** Where a word is when no gap holds it, as a destination: back in the bank. */\nconst BANK = '';\n\n/** A touch held this long (ms) without moving starts a drag; a touch that moves sooner scrolls, a short one taps. */\nconst LONG_PRESS = 250;\n\n/**\n * Marks the picked word next to its other cues (lift, fill, `aria-pressed`), also where forced colours drop fills and\n * shadows: four arrows, \"this word moves\", as on a picked card of `astl-categorise`.\n */\nconst MOVE_ICON = svg`<path d=\"M10 2.5v15M2.5 10h15M10 2.5 7.5 5M10 2.5 12.5 5M10 17.5 7.5 15M10 17.5 12.5 15M2.5 10 5 7.5M2.5 10 5 12.5M17.5 10 15 7.5M17.5 10 15 12.5\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>`;\n\n/** What the bank asks of its gaps (`<astl-drop>` with its id as `bank`; the two folders never import each other). */\ninterface Drop extends HTMLElement {\n /** The word id it holds; '' when empty. */\n readonly word: string;\n readonly number: number;\n place(word: string): void;\n requestUpdate(): void;\n}\n\nconst textOf = (el: Element | undefined): string => (el?.textContent ?? '').replace(/\\s+/g, ' ').trim();\n\n/**\n * `<astl-word-bank>`: the words its gaps (`<astl-drop bank>`) take. No slots: the gaps hold the answers, the bank holds\n * the one pick and place of them all (its gaps are its parts), as native toggle buttons in the tab order:\n * - a word, then a gap: Space or Enter on the word, then Enter on the gap (or the arrow keys from the word to choose\n * one, and Enter); a tap on the word, then on the gap; or a drag onto the gap;\n * - a gap holding a word: a press takes the word out, back in the bank and picked, so the next gap moves it; a drag\n * moves it to another gap (or the bank);\n * - an empty gap with nothing picked waits for a word: the arrow keys on it choose one and Enter puts it there, or a\n * tap on a word.\n * Without `reuse`, a word fills one gap: a gap that takes it from another empties that one, and the bank shows placed\n * words as placed, still pickable to move them. The light-DOM words are slotted manually and never moved or changed.\n */\nexport class WordBankElement extends AstlElement {\n static override manifest: ComponentManifest = wordBankManifest;\n static override messages: readonly MessageCatalog[] = wordBankUiMessages;\n static override shadowRootOptions: ShadowRootInit = {\n ...LitElement.shadowRootOptions,\n slotAssignment: 'manual',\n };\n\n // Notes on the rules are JS comments between css parts: inside a css literal they would ship to every student.\n static override styles: CSSResultGroup = [\n // A tinted tray (solid edges: dashed, dotted and double borders are the verdict language) with its title and hint\n // at the top, as the cards to sort of astl-categorise (the legend floats, so it sits inside the tray), then the\n // words in a wrapping row, each a chip (chipStyles: its box, button, pick and drag); a long press starts a drag\n // (see LONG_PRESS). A long word hyphenates in its chip. Locked (review, handed in): a quieter edge, the text at full\n // contrast.\n css`\n .tray {\n display: flex;\n flex-direction: column;\n gap: var(--astl-space-2);\n padding: var(--astl-space-3);\n border: var(--astl-outline-width) solid var(--astl-line);\n border-radius: var(--astl-radius-l);\n background: var(--astl-canvas);\n }\n legend {\n float: inline-start;\n inline-size: 100%;\n margin: 0;\n font-size: var(--astl-size-ui);\n line-height: 1.4;\n }\n .words {\n display: flex;\n flex-wrap: wrap;\n gap: var(--astl-space-2);\n }\n button {\n max-inline-size: 100%;\n overflow-wrap: anywhere;\n }\n .chip:has(button:disabled) {\n border-color: var(--astl-line);\n }\n `,\n // Placed (a bank without reuse): crossed out, as students cross out the words they used on paper (a tick would read\n // as a verdict), on a chip that still looks pressable: a placed word can be picked to move it. Picked: in hc also\n // bold text (selected-weight). The word a gap waiting for one would take (the arrow keys' target): a doubled edge,\n // which forced colours keep. Dragged: no pointer target, so what is under it counts.\n css`\n .chip[data-placed] {\n text-decoration: line-through;\n }\n .chip[data-picked] {\n color: var(--astl-ink);\n font-weight: var(--astl-selected-weight);\n }\n .chip[data-target] {\n border-color: var(--astl-accent);\n outline: var(--astl-outline-width) solid var(--astl-accent);\n outline-offset: calc(-2 * var(--astl-outline-width));\n background: var(--astl-accent-soft);\n }\n .chip[data-dragging] {\n pointer-events: none;\n }\n `,\n chipStyles,\n blockStyles,\n ];\n\n /** Picking and putting words: items are words and gaps (a gap's word, or a gap waiting for one), see below. */\n readonly #pick: PickAndPlace<string> = new PickAndPlace<string>(this, {\n // A word goes back to the bank or into a gap; a waiting gap takes one of the words.\n destinations: (item) =>\n this.#drop(item) === undefined\n ? [BANK, ...this.drops.map((drop) => drop.id)]\n : [item, ...this.words.map((word) => word.id)],\n current: (item) => (this.#drop(item) === undefined ? (this.#holder(item)?.id ?? BANK) : item),\n // Hit testing, not boxes: a gap in a line is taller than its inline host's box. A dragged word takes no pointer\n // events (see the styles), so what is under it counts, and never the gap it is dragged from.\n at: (x, y, item) => {\n const hits = (this.getRootNode() as Document | ShadowRoot).elementsFromPoint(x, y);\n const drop = this.drops.find((d) => d.id !== item && hits.includes(d));\n return drop?.id ?? (hits.includes(this) ? BANK : null);\n },\n commit: (item, to) => this.#commit(item, to),\n say: (moment, item, to) => this.#message(moment, item, to),\n box: '.chip',\n hold: LONG_PRESS,\n wrap: true,\n parts: () => this.drops,\n });\n /** The gap a press just took a word out of: the pick that follows is announced as that. */\n #out: Drop | null = null;\n /** The word the last commit moved, for its announcement (a gap that gave it up no longer holds it). */\n #moved = '';\n\n /** The pick and place of the bank and its gaps, which they read and forward their keys and presses to. */\n get pick(): PickAndPlace<string> {\n return this.#pick;\n }\n\n get reuse(): boolean {\n return this.booleanAttribute('reuse');\n }\n\n /** `<astl-word>` children in rendered order: view order, or shuffled per attempt with a seed. */\n get words(): readonly HTMLElement[] {\n return this.shuffled(\n Array.from(this.children).filter(\n (child): child is HTMLElement => child.localName === 'astl-word' && child.id !== '',\n ),\n );\n }\n\n /** Its gaps, in reading order: the view's `<astl-drop>` elements naming this bank. */\n get drops(): readonly Drop[] {\n if (this.id === '' || !this.isConnected) return [];\n const root = this.getRootNode() as Document | ShadowRoot;\n return [...root.querySelectorAll<Drop>('astl-drop')].filter(\n (drop) => drop.getAttribute('bank') === this.id,\n );\n }\n\n get slotIds(): readonly string[] {\n return [];\n }\n\n getAnswers(): Answers {\n return {};\n }\n\n /** The gaps hold the answers; the player clears them all (start over), so a pick goes too. */\n setAnswers(_answers: Answers): void {\n this.#pick.reset();\n }\n\n units(): Units {\n return { answered: 0, total: 0 };\n }\n\n /** A press on one of its gaps (a tap, or Enter or Space on it); see the class comment. */\n activate(drop: Drop, event: MouseEvent): void {\n const pick = this.#pick;\n if (!pick.tap(event) || this.disabled) return;\n const picked = pick.picked;\n if (picked !== null && this.#drop(picked) === undefined) pick.put(drop.id);\n else if (drop.word !== '') {\n const word = drop.word;\n drop.place('');\n this.#out = drop;\n pick.pick(word);\n this.#out = null;\n } else pick.click(event, drop.id);\n }\n\n protected override render(): TemplateResult {\n const ui = this.uiLanguage;\n const pick = this.#pick;\n const picked = pick.picked;\n const waiting = picked === null ? undefined : this.#drop(picked);\n const hint =\n waiting !== undefined\n ? this.t('ui.hintWaiting', { n: waiting.number })\n : picked === null\n ? this.t('ui.hint')\n : this.t('ui.hintPicked', { word: this.#label(picked) });\n // The first gap that holds a word wins, as in #holder (reversed: a Map keeps the last of equal keys).\n const holders = new Map(\n this.reuse ? [] : [...this.drops].reverse().map((drop) => [drop.word, drop] as const),\n );\n return html`<fieldset class=\"tray\" part=\"word-bank\">\n <legend part=\"label\" lang=${ui.lang} dir=${ui.dir}>\n <bdi>${this.t('ui.label')}</bdi><span class=\"hint\" part=\"hint\"><bdi>${hint}</bdi></span>\n </legend>\n <div class=\"words\">\n ${repeat(\n this.words,\n (word) => word.id,\n (word) => this.#renderWord(word.id, waiting !== undefined, holders.get(word.id)),\n )}\n </div>\n </fieldset>`;\n }\n\n #renderWord(id: string, waiting: boolean, holder: Drop | undefined): TemplateResult {\n const pick = this.#pick;\n const ui = this.uiLanguage;\n return html`<span\n class=\"chip astl-ring\"\n part=\"word\"\n data-word=${id}\n ?data-picked=${pick.picked === id}\n ?data-target=${waiting && pick.target === id}\n ?data-placed=${holder !== undefined}\n ?data-dragging=${pick.dragging === id}\n >\n <button\n type=\"button\"\n data-word=${id}\n aria-pressed=${pick.picked === id ? 'true' : 'false'}\n aria-describedby=${holder === undefined ? nothing : `placed-${id}`}\n ?disabled=${this.disabled}\n @click=${(event: MouseEvent) => pick.click(event, id, waiting ? id : undefined)}\n @keydown=${(event: KeyboardEvent) => pick.keydown(event, id)}\n @pointerdown=${(event: PointerEvent) => pick.pointerdown(event, id)}\n @touchmove=${pick.touchmove}\n >\n ${\n pick.picked === id\n ? html`<svg class=\"move\" viewBox=\"0 0 20 20\" aria-hidden=\"true\" focusable=\"false\">${MOVE_ICON}</svg>`\n : nothing\n }<slot data-word=${id}></slot>\n </button>\n ${\n holder === undefined\n ? nothing\n : html`<span class=\"astl-vh\" id=\"placed-${id}\" lang=${ui.lang} dir=${ui.dir}\n >${this.t('ui.placed', { n: holder.number })}</span\n >`\n }\n </span>`;\n }\n\n protected override updated(): void {\n // Manual slot assignment: the view's light DOM is projected as is, never moved or rewritten.\n const words = new Map(this.words.map((word) => [word.id, word]));\n for (const slot of (this.renderRoot as ShadowRoot).querySelectorAll<HTMLSlotElement>('slot[data-word]')) {\n const word = words.get(slot.dataset.word ?? '');\n slot.assign(...(word ? [word] : []));\n }\n // The gaps show the pick (waiting, target, dragged), and the words they hold may have moved.\n for (const drop of this.drops) drop.requestUpdate();\n }\n\n // Moving words\n\n #drop(id: string): Drop | undefined {\n return this.drops.find((drop) => drop.id === id);\n }\n\n /** The gap that holds word `id`; none with reuse, where words stay in the bank. */\n #holder(id: string): Drop | undefined {\n return this.reuse ? undefined : this.drops.find((drop) => drop.word === id);\n }\n\n #label(word: string): string {\n return textOf(this.words.find((w) => w.id === word));\n }\n\n /**\n * Puts `item` at `to`: a word into a gap (or, placed, back to the bank); a gap's word into another gap or back; a\n * waiting gap takes word `to`. Without reuse, a gap that takes a word empties the one that held it.\n */\n #commit(item: string, to: string): void {\n const source = this.#drop(item);\n const waiting = source !== undefined && source.word === '';\n const word = waiting ? to : (source?.word ?? item);\n const target = waiting ? source : this.#drop(to);\n this.#moved = word;\n if (!waiting) source?.place('');\n if (target === undefined) {\n // Back to the bank: a placed word picked in the bank leaves its gap.\n if (source === undefined) this.#holder(word)?.place('');\n return;\n }\n if (!this.reuse)\n for (const other of this.drops) if (other !== target && other.word === word) other.place('');\n target.place(word);\n }\n\n /** The announcement of a moment: of a word, of a waiting gap, or of a gap's word taken out. */\n #message(moment: PickMoment, item: string, to: string): string {\n const n = (id: string) => this.#drop(id)?.number ?? 0;\n const word = this.#label(item);\n const out = this.#out;\n if (out !== null) return this.t('ui.announce.out', { word, n: out.number });\n if (moment === 'put') {\n const moved = this.#label(this.#moved);\n if (to === BANK) return this.t('ui.announce.back', { word: moved });\n return this.t('ui.announce.put', { word: moved, n: n(this.#drop(to) === undefined ? item : to) });\n }\n const gap = (id: string): string => {\n const held = this.#drop(id)?.word ?? '';\n return held === ''\n ? this.t('ui.announce.gapEmpty', { n: n(id) })\n : this.t('ui.announce.gap', { n: n(id), word: this.#label(held) });\n };\n if (this.#drop(item) !== undefined) {\n if (moment === 'pick') return this.t('ui.announce.wait', { n: n(item) });\n if (moment === 'cancel') return this.t('ui.announce.stayEmpty', { n: n(item) });\n if (to === item) return gap(item);\n const holder = this.#holder(to);\n return holder === undefined\n ? this.t('ui.announce.word', { word: this.#label(to) })\n : this.t('ui.announce.wordPlaced', { word: this.#label(to), n: holder.number });\n }\n if (moment === 'pick') return this.t('ui.announce.pick', { word });\n if (moment === 'target') return to === BANK ? this.t('ui.announce.bank') : gap(to);\n return to === BANK\n ? this.t('ui.announce.stay', { word })\n : this.t('ui.announce.stayGap', { word, n: n(to) });\n }\n}\n\nexport const wordBankElement: ElementRegistration = {\n manifest: wordBankManifest,\n element: WordBankElement,\n messages: wordBankUiMessages,\n};\n"],"mappings":"A,uUAIA,IAAMkB,EAAY,iBAMLC,EAAgD,CAC3D,CAAE,YAAW,OAAQ,KAAM,SAAUnB,CAAG,EACxC,CAAE,YAAW,OAAQ,KAAM,SAAUC,CAAG,CAC1C,ECFMmB,EAAO,GAGPC,EAAa,IAMbC,EAAY,CAAG,yPAWfC,EAAU,IAAqCC,GAAI,aAAe,GAAA,CAAI,QAAQ,OAAQ,GAAG,CAAC,CAAC,KAAK,EAczFC,EAAb,cAAqChB,CAAY,CAC/C,OAAgB,SAA8BG,EAC9C,OAAgB,SAAsCO,EACtD,OAAgB,kBAAoC,CAClD,GAAGjB,EAAW,kBACd,eAAgB,QAClB,EAGA,OAAgB,OAAyB,CAMvC,CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkCH,CAAG;;;;;;;;;;;;;;;;;EAkBHe,EACAF,CACF,EAGA,GAAuC,IAAID,EAAqB,KAAM,CAEpE,aAAe,GACb,KAAKY,GAAMC,CAAI,IAAM,IAAA,GACjB,CAACP,EAAM,GAAG,KAAK,MAAM,IAAK,GAASQ,EAAK,EAAE,CAAC,EAC3C,CAACD,EAAM,GAAG,KAAK,MAAM,IAAK,GAASE,EAAK,EAAE,CAAC,EACjD,QAAU,GAAU,KAAKH,GAAMC,CAAI,IAAM,IAAA,GAAa,KAAKG,GAAQH,CAAI,CAAC,EAAE,IAAMP,EAAQO,EAGxF,IAAK,EAAG,EAAG,IAAS,CAClB,IAAMI,EAAQ,KAAK,YAAY,CAAC,CAA2B,kBAAkBC,EAAGC,CAAC,EAEjF,OADa,KAAK,MAAM,KAAM,GAAMC,EAAE,KAAOP,GAAQI,EAA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GAAW,CAClC,GAAIW,IAAW,OAAQ,OAAO,KAAK,EAAE,mBAAoB,CAAE,EAAGqB,EAAEhC,CAAI,CAAE,CAAC,EACvE,GAAIW,IAAW,SAAU,OAAO,KAAK,EAAE,wBAAyB,CAAE,EAAGqB,EAAEhC,CAAI,CAAE,CAAC,EAC9E,GAAIS,IAAOT,EAAM,OAAOmC,EAAInC,CAAI,EAChC,IAAMyB,EAAS,KAAKtB,GAAQM,CAAE,EAC9B,OAAOgB,IAAW,IAAA,GACd,KAAK,EAAE,mBAAoB,CAAE,KAAM,KAAKJ,GAAOZ,CAAE,CAAE,CAAC,EACpD,KAAK,EAAE,yBAA0B,CAAE,KAAM,KAAKY,GAAOZ,CAAE,EAAG,EAAGgB,EAAO,MAAO,CAAC,CAClF,CAGA,OAFId,IAAW,OAAe,KAAK,EAAE,mBAAoB,CAAE,MAAK,CAAC,EAC7DA,IAAW,SAAiBF,IAAOhB,EAAO,KAAK,EAAE,kBAAkB,EAAI0C,EAAI1B,CAAE,EAC1EA,IAAOhB,EACV,KAAK,EAAE,mBAAoB,CAAE,MAAK,CAAC,EACnC,KAAK,EAAE,sBAAuB,CAAE,OAAM,EAAGuC,EAAEvB,CAAE,CAAE,CAAC,CACtD,CACF,EAEa4B,EAAuC,CAClD,SAAUpD,EACV,QAASa,EACT,SAAUN,CACZ,E"}
|
|
1
|
+
{"version":3,"file":"word-bank-CsIle0Ro.js","names":["en","pl","LitElement","repeat","nothing","b","i$1","w","A","AstlElement","i","en_default","wordBankManifest","pl_default","PickAndPlace","blockStyles","c","chipStyles","namespace","wordBankUiMessages","BANK","LONG_PRESS","MOVE_ICON","textOf","el","WordBankElement","#drop","item","drop","word","#holder","hits","x","y","d","#commit","to","#message","moment","#pick","child","pick","event","picked","#out","ui","waiting","hint","#label","holders","#renderWord","id","holder","words","slot","source","target","#moved","other","n","out","moved","gap","held","wordBankElement"],"sources":["../../../../components/src/word-bank/ui-messages.ts","../../../../components/src/word-bank/element.ts"],"sourcesContent":["import type { MessageCatalog } from '@astl/core';\nimport en from './messages/ui/en.json' with { type: 'json' };\nimport pl from './messages/ui/pl.json' with { type: 'json' };\n\nconst namespace = 'astl.word-bank';\n\n/**\n * The student strings (`ui.*`): the element's catalogs. A module of their own, because bundlers split by module: one\n * that also built `wordBankMessages` would put the authoring strings into the element's chunk.\n */\nexport const wordBankUiMessages: readonly MessageCatalog[] = [\n { namespace, locale: 'en', messages: en },\n { namespace, locale: 'pl', messages: pl },\n];\n","import type { Answers, ComponentManifest, MessageCatalog, Units } from '@astl/core';\nimport { AstlElement, type ElementRegistration } from '@astl/player';\nimport { PickAndPlace, type PickMoment } from '@astl/player/interaction';\nimport { type CSSResultGroup, css, html, LitElement, nothing, svg, type TemplateResult } from 'lit';\nimport { repeat } from 'lit/directives/repeat.js';\nimport { blockStyles } from '../block-styles.js';\nimport { chipStyles } from '../chip-styles.js';\nimport { wordBankManifest } from './manifest.js';\nimport { wordBankUiMessages } from './ui-messages.js';\n\n/** Where a word is when no gap holds it, as a destination: back in the bank. */\nconst BANK = '';\n\n/** A touch held this long (ms) without moving starts a drag; a touch that moves sooner scrolls, a short one taps. */\nconst LONG_PRESS = 250;\n\n/**\n * Marks the picked word next to its other cues (lift, fill, `aria-pressed`), also where forced colours drop fills and\n * shadows: four arrows, \"this word moves\", as on a picked card of `astl-categorise`.\n */\nconst MOVE_ICON = svg`<path d=\"M10 2.5v15M2.5 10h15M10 2.5 7.5 5M10 2.5 12.5 5M10 17.5 7.5 15M10 17.5 12.5 15M2.5 10 5 7.5M2.5 10 5 12.5M17.5 10 15 7.5M17.5 10 15 12.5\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>`;\n\n/** What the bank asks of its gaps (`<astl-drop>` with its id as `bank`; the two folders never import each other). */\ninterface Drop extends HTMLElement {\n /** The word id it holds; '' when empty. */\n readonly word: string;\n readonly number: number;\n place(word: string): void;\n requestUpdate(): void;\n}\n\nconst textOf = (el: Element | undefined): string => (el?.textContent ?? '').replace(/\\s+/g, ' ').trim();\n\n/**\n * `<astl-word-bank>`: the words its gaps (`<astl-drop bank>`) take. No slots: the gaps hold the answers, the bank holds\n * the one pick and place of them all (its gaps are its parts), as native toggle buttons in the tab order:\n * - a word, then a gap: Space or Enter on the word, then Enter on the gap (or the arrow keys from the word to choose\n * one, and Enter); a tap on the word, then on the gap; or a drag onto the gap;\n * - a gap holding a word: a press takes the word out, back in the bank and picked, so the next gap moves it; a drag\n * moves it to another gap (or the bank);\n * - an empty gap with nothing picked waits for a word: the arrow keys on it choose one and Enter puts it there, or a\n * tap on a word.\n * Without `reuse`, a word fills one gap: a gap that takes it from another empties that one, and the bank shows placed\n * words as placed, still pickable to move them. The light-DOM words are slotted manually and never moved or changed.\n */\nexport class WordBankElement extends AstlElement {\n static override manifest: ComponentManifest = wordBankManifest;\n static override messages: readonly MessageCatalog[] = wordBankUiMessages;\n static override shadowRootOptions: ShadowRootInit = {\n ...LitElement.shadowRootOptions,\n slotAssignment: 'manual',\n };\n\n // Notes on the rules are JS comments between css parts: inside a css literal they would ship to every student.\n static override styles: CSSResultGroup = [\n // A tinted tray (solid edges: dashed, dotted and double borders are the verdict language) with its title and hint\n // at the top, as the cards to sort of astl-categorise (the legend floats, so it sits inside the tray), then the\n // words in a wrapping row, each a chip (chipStyles: its box, button, pick and drag); a long press starts a drag\n // (see LONG_PRESS). A long word hyphenates in its chip. Locked (review, handed in): a quieter edge, the text at full\n // contrast.\n css`\n .tray {\n display: flex;\n flex-direction: column;\n gap: var(--astl-space-2);\n padding: var(--astl-space-3);\n border: var(--astl-outline-width) solid var(--astl-line);\n border-radius: var(--astl-radius-l);\n background: var(--astl-canvas);\n }\n legend {\n float: inline-start;\n inline-size: 100%;\n margin: 0;\n font-size: var(--astl-size-ui);\n line-height: 1.4;\n }\n .words {\n display: flex;\n flex-wrap: wrap;\n gap: var(--astl-space-2);\n }\n button {\n max-inline-size: 100%;\n overflow-wrap: anywhere;\n }\n .chip:has(button:disabled) {\n border-color: var(--astl-line);\n }\n `,\n // Placed (a bank without reuse): crossed out, as students cross out the words they used on paper (a tick would read\n // as a verdict), on a chip that still looks pressable: a placed word can be picked to move it. Picked: in hc also\n // bold text (selected-weight). The word a gap waiting for one would take (the arrow keys' target): a doubled edge,\n // which forced colours keep. Dragged: no pointer target, so what is under it counts.\n css`\n .chip[data-placed] {\n text-decoration: line-through;\n }\n .chip[data-picked] {\n color: var(--astl-ink);\n font-weight: var(--astl-selected-weight);\n }\n .chip[data-target] {\n border-color: var(--astl-accent);\n outline: var(--astl-outline-width) solid var(--astl-accent);\n outline-offset: calc(-2 * var(--astl-outline-width));\n background: var(--astl-accent-soft);\n }\n .chip[data-dragging] {\n pointer-events: none;\n }\n `,\n chipStyles,\n blockStyles,\n ];\n\n /** Picking and putting words: items are words and gaps (a gap's word, or a gap waiting for one), see below. */\n readonly #pick: PickAndPlace<string> = new PickAndPlace<string>(this, {\n // A word goes back to the bank or into a gap; a waiting gap takes one of the words.\n destinations: (item) =>\n this.#drop(item) === undefined\n ? [BANK, ...this.drops.map((drop) => drop.id)]\n : [item, ...this.words.map((word) => word.id)],\n current: (item) => (this.#drop(item) === undefined ? (this.#holder(item)?.id ?? BANK) : item),\n // Hit testing, not boxes: a gap in a line is taller than its inline host's box. A dragged word takes no pointer\n // events (see the styles), so what is under it counts, and never the gap it is dragged from.\n at: (x, y, item) => {\n const hits = (this.getRootNode() as Document | ShadowRoot).elementsFromPoint(x, y);\n const drop = this.drops.find((d) => d.id !== item && hits.includes(d));\n return drop?.id ?? (hits.includes(this) ? BANK : null);\n },\n commit: (item, to) => this.#commit(item, to),\n say: (moment, item, to) => this.#message(moment, item, to),\n box: '.chip',\n hold: LONG_PRESS,\n wrap: true,\n parts: () => this.drops,\n });\n /** The gap a press just took a word out of: the pick that follows is announced as that. */\n #out: Drop | null = null;\n /** The word the last commit moved, for its announcement (a gap that gave it up no longer holds it). */\n #moved = '';\n\n /** The pick and place of the bank and its gaps, which they read and forward their keys and presses to. */\n get pick(): PickAndPlace<string> {\n return this.#pick;\n }\n\n get reuse(): boolean {\n return this.booleanAttribute('reuse');\n }\n\n /** `<astl-word>` children in rendered order: view order, or shuffled per attempt with a seed. */\n get words(): readonly HTMLElement[] {\n return this.shuffled(\n Array.from(this.children).filter(\n (child): child is HTMLElement => child.localName === 'astl-word' && child.id !== '',\n ),\n );\n }\n\n /** Its gaps, in reading order: the view's `<astl-drop>` elements naming this bank. */\n get drops(): readonly Drop[] {\n if (this.id === '' || !this.isConnected) return [];\n const root = this.getRootNode() as Document | ShadowRoot;\n return [...root.querySelectorAll<Drop>('astl-drop')].filter(\n (drop) => drop.getAttribute('bank') === this.id,\n );\n }\n\n get slotIds(): readonly string[] {\n return [];\n }\n\n getAnswers(): Answers {\n return {};\n }\n\n /** The gaps hold the answers; the player clears them all (start over), so a pick goes too. */\n setAnswers(_answers: Answers): void {\n this.#pick.reset();\n }\n\n units(): Units {\n return { answered: 0, total: 0 };\n }\n\n /** A press on one of its gaps (a tap, or Enter or Space on it); see the class comment. */\n activate(drop: Drop, event: MouseEvent): void {\n const pick = this.#pick;\n if (!pick.tap(event) || this.disabled) return;\n const picked = pick.picked;\n if (picked !== null && this.#drop(picked) === undefined) pick.put(drop.id);\n else if (drop.word !== '') {\n const word = drop.word;\n drop.place('');\n this.#out = drop;\n pick.pick(word);\n this.#out = null;\n } else pick.click(event, drop.id);\n }\n\n protected override render(): TemplateResult {\n const ui = this.uiLanguage;\n const pick = this.#pick;\n const picked = pick.picked;\n const waiting = picked === null ? undefined : this.#drop(picked);\n const hint =\n waiting !== undefined\n ? this.t('ui.hintWaiting', { n: waiting.number })\n : picked === null\n ? this.t('ui.hint')\n : this.t('ui.hintPicked', { word: this.#label(picked) });\n // The first gap that holds a word wins, as in #holder (reversed: a Map keeps the last of equal keys).\n const holders = new Map(\n this.reuse ? [] : [...this.drops].reverse().map((drop) => [drop.word, drop] as const),\n );\n return html`<fieldset class=\"tray\" part=\"word-bank\">\n <legend part=\"label\" lang=${ui.lang} dir=${ui.dir}>\n <bdi>${this.t('ui.label')}</bdi><span class=\"hint\" part=\"hint\"><bdi>${hint}</bdi></span>\n </legend>\n <div class=\"words\">\n ${repeat(\n this.words,\n (word) => word.id,\n (word) => this.#renderWord(word.id, waiting !== undefined, holders.get(word.id)),\n )}\n </div>\n </fieldset>`;\n }\n\n #renderWord(id: string, waiting: boolean, holder: Drop | undefined): TemplateResult {\n const pick = this.#pick;\n const ui = this.uiLanguage;\n return html`<span\n class=\"chip astl-ring\"\n part=\"word\"\n data-word=${id}\n ?data-picked=${pick.picked === id}\n ?data-target=${waiting && pick.target === id}\n ?data-placed=${holder !== undefined}\n ?data-dragging=${pick.dragging === id}\n >\n <button\n type=\"button\"\n data-word=${id}\n aria-pressed=${pick.picked === id ? 'true' : 'false'}\n aria-describedby=${holder === undefined ? nothing : `placed-${id}`}\n ?disabled=${this.disabled}\n @click=${(event: MouseEvent) => pick.click(event, id, waiting ? id : undefined)}\n @keydown=${(event: KeyboardEvent) => pick.keydown(event, id)}\n @pointerdown=${(event: PointerEvent) => pick.pointerdown(event, id)}\n @touchmove=${pick.touchmove}\n >\n ${\n pick.picked === id\n ? html`<svg class=\"move\" viewBox=\"0 0 20 20\" aria-hidden=\"true\" focusable=\"false\">${MOVE_ICON}</svg>`\n : nothing\n }<slot data-word=${id}></slot>\n </button>\n ${\n holder === undefined\n ? nothing\n : html`<span class=\"astl-vh\" id=\"placed-${id}\" lang=${ui.lang} dir=${ui.dir}\n >${this.t('ui.placed', { n: holder.number })}</span\n >`\n }\n </span>`;\n }\n\n protected override updated(): void {\n // Manual slot assignment: the view's light DOM is projected as is, never moved or rewritten.\n const words = new Map(this.words.map((word) => [word.id, word]));\n for (const slot of (this.renderRoot as ShadowRoot).querySelectorAll<HTMLSlotElement>('slot[data-word]')) {\n const word = words.get(slot.dataset.word ?? '');\n slot.assign(...(word ? [word] : []));\n }\n // The gaps show the pick (waiting, target, dragged), and the words they hold may have moved.\n for (const drop of this.drops) drop.requestUpdate();\n }\n\n // Moving words\n\n #drop(id: string): Drop | undefined {\n return this.drops.find((drop) => drop.id === id);\n }\n\n /** The gap that holds word `id`; none with reuse, where words stay in the bank. */\n #holder(id: string): Drop | undefined {\n return this.reuse ? undefined : this.drops.find((drop) => drop.word === id);\n }\n\n #label(word: string): string {\n return textOf(this.words.find((w) => w.id === word));\n }\n\n /**\n * Puts `item` at `to`: a word into a gap (or, placed, back to the bank); a gap's word into another gap or back; a\n * waiting gap takes word `to`. Without reuse, a gap that takes a word empties the one that held it.\n */\n #commit(item: string, to: string): void {\n const source = this.#drop(item);\n const waiting = source !== undefined && source.word === '';\n const word = waiting ? to : (source?.word ?? item);\n const target = waiting ? source : this.#drop(to);\n this.#moved = word;\n if (!waiting) source?.place('');\n if (target === undefined) {\n // Back to the bank: a placed word picked in the bank leaves its gap.\n if (source === undefined) this.#holder(word)?.place('');\n return;\n }\n if (!this.reuse)\n for (const other of this.drops) if (other !== target && other.word === word) other.place('');\n target.place(word);\n }\n\n /** The announcement of a moment: of a word, of a waiting gap, or of a gap's word taken out. */\n #message(moment: PickMoment, item: string, to: string): string {\n const n = (id: string) => this.#drop(id)?.number ?? 0;\n const word = this.#label(item);\n const out = this.#out;\n if (out !== null) return this.t('ui.announce.out', { word, n: out.number });\n if (moment === 'put') {\n const moved = this.#label(this.#moved);\n if (to === BANK) return this.t('ui.announce.back', { word: moved });\n return this.t('ui.announce.put', { word: moved, n: n(this.#drop(to) === undefined ? item : to) });\n }\n const gap = (id: string): string => {\n const held = this.#drop(id)?.word ?? '';\n return held === ''\n ? this.t('ui.announce.gapEmpty', { n: n(id) })\n : this.t('ui.announce.gap', { n: n(id), word: this.#label(held) });\n };\n if (this.#drop(item) !== undefined) {\n if (moment === 'pick') return this.t('ui.announce.wait', { n: n(item) });\n if (moment === 'cancel') return this.t('ui.announce.stayEmpty', { n: n(item) });\n if (to === item) return gap(item);\n const holder = this.#holder(to);\n return holder === undefined\n ? this.t('ui.announce.word', { word: this.#label(to) })\n : this.t('ui.announce.wordPlaced', { word: this.#label(to), n: holder.number });\n }\n if (moment === 'pick') return this.t('ui.announce.pick', { word });\n if (moment === 'target') return to === BANK ? this.t('ui.announce.bank') : gap(to);\n return to === BANK\n ? this.t('ui.announce.stay', { word })\n : this.t('ui.announce.stayGap', { word, n: n(to) });\n }\n}\n\nexport const wordBankElement: ElementRegistration = {\n manifest: wordBankManifest,\n element: WordBankElement,\n messages: wordBankUiMessages,\n};\n"],"mappings":"A,uUAIA,IAAMkB,EAAY,iBAMLC,EAAgD,CAC3D,CAAE,YAAW,OAAQ,KAAM,SAAUnB,CAAG,EACxC,CAAE,YAAW,OAAQ,KAAM,SAAUC,CAAG,CAC1C,ECFMmB,EAAO,GAGPC,EAAa,IAMbC,EAAY,CAAG,yPAWfC,EAAU,IAAqCC,GAAI,aAAe,GAAA,CAAI,QAAQ,OAAQ,GAAG,CAAC,CAAC,KAAK,EAczFC,EAAb,cAAqChB,CAAY,CAC/C,OAAgB,SAA8BG,EAC9C,OAAgB,SAAsCO,EACtD,OAAgB,kBAAoC,CAClD,GAAGjB,EAAW,kBACd,eAAgB,QAClB,EAGA,OAAgB,OAAyB,CAMvC,CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkCH,CAAG;;;;;;;;;;;;;;;;;EAkBHe,EACAF,CACF,EAGA,GAAuC,IAAID,EAAqB,KAAM,CAEpE,aAAe,GACb,KAAKY,GAAMC,CAAI,IAAM,IAAA,GACjB,CAACP,EAAM,GAAG,KAAK,MAAM,IAAK,GAASQ,EAAK,EAAE,CAAC,EAC3C,CAACD,EAAM,GAAG,KAAK,MAAM,IAAK,GAASE,EAAK,EAAE,CAAC,EACjD,QAAU,GAAU,KAAKH,GAAMC,CAAI,IAAM,IAAA,GAAa,KAAKG,GAAQH,CAAI,CAAC,EAAE,IAAMP,EAAQO,EAGxF,IAAK,EAAG,EAAG,IAAS,CAClB,IAAMI,EAAQ,KAAK,YAAY,CAA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AAG,KAAM,KAAKH,GAAOe,CAAI,CAAE,CAAC,CACrE,EACA,GAAI,KAAKrC,GAAMC,CAAI,IAAM,IAAA,GAAW,CAClC,GAAIW,IAAW,OAAQ,OAAO,KAAK,EAAE,mBAAoB,CAAE,EAAGqB,EAAEhC,CAAI,CAAE,CAAC,EACvE,GAAIW,IAAW,SAAU,OAAO,KAAK,EAAE,wBAAyB,CAAE,EAAGqB,EAAEhC,CAAI,CAAE,CAAC,EAC9E,GAAIS,IAAOT,EAAM,OAAOmC,EAAInC,CAAI,EAChC,IAAMyB,EAAS,KAAKtB,GAAQM,CAAE,EAC9B,OAAOgB,IAAW,IAAA,GACd,KAAK,EAAE,mBAAoB,CAAE,KAAM,KAAKJ,GAAOZ,CAAE,CAAE,CAAC,EACpD,KAAK,EAAE,yBAA0B,CAAE,KAAM,KAAKY,GAAOZ,CAAE,EAAG,EAAGgB,EAAO,MAAO,CAAC,CAClF,CAGA,OAFId,IAAW,OAAe,KAAK,EAAE,mBAAoB,CAAE,MAAK,CAAC,EAC7DA,IAAW,SAAiBF,IAAOhB,EAAO,KAAK,EAAE,kBAAkB,EAAI0C,EAAI1B,CAAE,EAC1EA,IAAOhB,EACV,KAAK,EAAE,mBAAoB,CAAE,MAAK,CAAC,EACnC,KAAK,EAAE,sBAAuB,CAAE,OAAM,EAAGuC,EAAEvB,CAAE,CAAE,CAAC,CACtD,CACF,EAEa4B,EAAuC,CAClD,SAAUpD,EACV,QAASa,EACT,SAAUN,CACZ,E"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{C as e,D as t,E as n,T as r,b as i,h as a,m as o,n as s,v as c,y as l}from"./runtime-
|
|
1
|
+
import{C as e,D as t,E as n,T as r,b as i,h as a,m as o,n as s,v as c,y as l}from"./runtime-C25QK5B0.js";import{a as u,i as d,n as f,o as p,r as m,t as h}from"./word-search-manifest-Fg1a59Z1.js";import{t as g}from"./roving-focus-BxGgi2DD.js";import{t as _}from"./block-styles-CCtSFM4j.js";var v=`astl.word-search`,y=[{namespace:v,locale:`en`,messages:u},{namespace:v,locale:`pl`,messages:d}],b=e=>(e.textContent??``).replace(/\s+/g,` `).trim(),x=e=>b(e)||[...e.querySelectorAll(`img`)].map(e=>e.alt).join(` `).trim(),S=(e,t)=>e[0]===t[0]&&e[1]===t[1];function C(e,t){let n=m(t);return e===t||n!==null&&e===h(n[1],n[0])}var w=r`<path d="M4 10h12" stroke="currentColor" stroke-width="6" stroke-linecap="round"/>`,T=class extends s{static manifest=p;static messages=y;static shadowRootOptions={...l.shadowRootOptions,slotAssignment:`manual`};static properties={lines:{state:!0},anchor:{state:!0},clue:{state:!0},status:{state:!0}};static styles=[n`
|
|
2
2
|
.board {
|
|
3
3
|
--astl-ws-edge: calc(var(--astl-focus-width) + var(--astl-focus-offset));
|
|
4
4
|
display: flex;
|
|
@@ -271,4 +271,4 @@ margin-block: var(--astl-space-3) 0;
|
|
|
271
271
|
</li>`}#i(t,n,r){let i=this.uiLanguage,[[o,s],[c,l]]=m(t),u={clue:r?`yes`:`no`,word:this.#d(this.#u(t)),fromRow:o+1,fromColumn:s+1,toRow:c+1,toColumn:l+1};return e`<p class="astl-solution" part="solution" id="solution-${n}" data-span=${t} lang=${i.lang} dir=${i.dir}
|
|
272
272
|
>${a(`correct`)}<span class="astl-solution-label">${this.t(`ui.solution`,u)}</span></p
|
|
273
273
|
>`}#a(){let e=(e,t,n,a)=>{let o=m(e);if(o===null)return i;let[[s,l],[u,d]]=o,f={x1:l+.5,y1:s+.5,x2:d+.5,y2:u+.5};return r`<line class=${t} data-span=${e} data-item=${c(n)} data-palette=${c(a)} x1=${f.x1} y1=${f.y1} x2=${f.x2} y2=${f.y2}></line><line class="${t} fill" data-palette=${c(a)} x1=${f.x1} y1=${f.y1} x2=${f.x2} y2=${f.y2}></line>`},t=e=>r`<g class="solution" data-span=${e}>${this.#u(e).map(([e,t])=>r`<circle cx=${t+.5} cy=${e+.5} r="0.4"></circle>`)}</g>`,n=this.#c,a=this.#e,o=this.#l(this.#n.active),s=a?.from??this.anchor,l=a?.to??o,u=s!==null&&f(s,l,this.#s)!==null?h(s,l):null;return r`${n.map((t,n)=>{let r=this.lines.get(t.id);return r===void 0?i:e(r,`found`,t.id,n%8+1)})}${n.map(e=>{let n=this.solution?.[e.id],r=this.lines.get(e.id);return n===void 0||r!==void 0&&C(r,n)?i:t(n)})}${u===null?i:e(u,`draft`)}`}updated(){let e=this.renderRoot,t=Array.from(this.children).find(e=>e.localName===`astl-prompt`);e.querySelector(`slot.prompt-slot`)?.assign(...t?[t]:[]);let n=new Map(this.#c.map(e=>[e.id,e.el]));for(let t of e.querySelectorAll(`slot[data-item]`)){let e=n.get(t.dataset.item??``);t.assign(...e?[e]:[])}e.querySelector(`.board`)?.style.setProperty(`--astl-ws-size`,`${this.#s}`)}get#o(){let e=this.getAttribute(`grid`)??``;return e!==this.#t.value&&(this.#t={value:e,rows:e.split(` `).filter(e=>e!==``).map(e=>[...e])}),this.#t.rows}get#s(){return this.#o.length}get#c(){return Array.from(this.children).filter(e=>e.localName===`astl-search-word`&&e.id!==``).map(e=>{let t=e.hasAttribute(`clue`);return{id:e.id,el:e,clue:t,letters:t?``:b(e)}})}#l(e){let t=Math.max(1,this.#s);return[Math.floor(e/t),e%t]}#u(e){let t=m(e);return(t===null?null:f(t[0],t[1],this.#s))??[]}#d(e){return e.map(([e,t])=>this.#o[e]?.[t]??``).join(``)}#f(e,t){let n=this.#d(e);return t!==``&&(n===t||[...n].reverse().join(``)===t)}#p(e,t=!1){let n=e.currentTarget.getBoundingClientRect(),r=this.#s,i=Math.floor((e.clientY-n.top)/n.height*r),a=Math.floor((e.clientX-n.left)/n.width*r),o=e=>e>=0&&e<r;if(!t&&!(o(i)&&o(a)))return null;let s=e=>Math.min(Math.max(e,0),r-1);return[s(i),s(a)]}#m(e,t){let n=t[0]-e[0],r=t[1]-e[1],[i,a]=[Math.abs(n),Math.abs(r)],o=i*2<a?[0,Math.sign(r)]:a*2<i?[Math.sign(n),0]:[Math.sign(n),Math.sign(r)],s=o[0]!==0&&o[1]!==0?Math.round((i+a)/2):Math.max(i,a),c=this.#s-1,l=t=>[e[0]+o[0]*t,e[1]+o[1]*t].every(e=>e>=0&&e<=c);for(;s>0&&!l(s);)s--;return[e[0]+o[0]*s,e[1]+o[1]*s]}#h(e){if(this.disabled||e.button!==0||!e.isPrimary)return;let t=this.#p(e);t!==null&&(e.currentTarget.setPointerCapture(e.pointerId),this.#e={pointer:e.pointerId,from:t,to:t},this.#n.focus(t[0]*this.#s+t[1]))}#g(e){let t=this.#e;if(t===null||e.pointerId!==t.pointer)return;let n=this.#m(t.from,this.#p(e,!0));S(n,t.to)||(this.#e={...t,to:n},this.requestUpdate())}#_(e){let t=this.#e;t!==null&&e.pointerId===t.pointer&&(this.#e=null,S(t.from,t.to)?this.#b(t.from):(this.anchor=null,this.#x(t.from,t.to)),this.requestUpdate())}#v(e){this.#e?.pointer===e.pointerId&&(this.#e=null,this.requestUpdate())}#y(e){this.disabled||(e.key===`Enter`||e.key===` `?(e.preventDefault(),e.repeat||this.#b(this.#l(this.#n.active))):e.key===`Escape`&&(this.anchor!==null||this.clue!==null)?(e.preventDefault(),this.anchor===null?this.clue=null:this.anchor=null,this.#E(`cancel`)):this.#n.keydown(e))}#b(e){let t=this.anchor;if(t===null){this.anchor=e;let t=this.#d([e]);this.#E(`first`,{letter:t,row:e[0]+1,column:e[1]+1})}else S(t,e)?(this.anchor=null,this.#E(`cancel`)):(this.anchor=null,this.#x(t,e))}#x(e,t){let n=f(e,t,this.#s);if(n===null){this.#E(`notStraight`);return}let r=h(e,t),i=this.#c,a=i.find(e=>e.id===this.clue);if(a!==void 0){this.clue=null,this.#C(a.id,r),this.#E(`saved`,{clue:x(a.el),...this.#w()});return}let o=i.find(e=>!e.clue&&this.#f(n,e.letters));o===void 0?this.#E(`none`,{letters:this.#d(n)}):this.lines.has(o.id)?this.#E(`again`,{word:o.letters}):(this.#C(o.id,r),this.#E(`found`,{word:o.letters,...this.#w()}))}#S(e){this.disabled||(this.lines.has(e.id)?(this.#C(e.id,``),this.#E(`released`,{word:e.clue?x(e.el):e.letters,...this.#w()})):e.clue?this.clue===e.id?(this.clue=null,this.#E(`cancel`)):(this.clue=e.id,this.anchor=null,this.#E(`clue`,{clue:x(e.el)}),this.#n.focus(this.#n.active)):this.#E(`find`,{word:e.letters}))}#C(e,t){let n=new Map(this.lines);t===``?n.delete(e):n.set(e,t),this.lines=n,this.emitChange({[e]:t})}#w(){return{count:this.lines.size,total:this.#c.length}}#T(e,t){let n=this.t(e,t);return this.#c.some(e=>e.clue)?`${n} ${this.t(`ui.hintClues`)}`:n}#E(e,t){this.status=e===`none`?this.#T(`ui.status.none`,t):this.t(`ui.status.${e}`,t),this.announce(this.status)}},E={manifest:p,element:T,messages:y};export{E as wordSearchElement};
|
|
274
|
-
//# sourceMappingURL=word-search-
|
|
274
|
+
//# sourceMappingURL=word-search-IOCwqo3y.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"word-search-AHvM7yCJ.js","names":["en","pl","LitElement","unsafeCSS","nothing","ifDefined","b","r","i$1","w","A","verdictIcon","renderVerdict","AstlElement","o","i","en_default","pl_default","lineCells","wordSearchManifest","parseSpan","formatSpan","RovingFocus","blockStyles","namespace","wordSearchUiMessages","textOf","el","nameOf","img","same","a","sameLine","ends","MARKED","WordSearchElement","element","#roving","#size","#entries","entry","next","span","answers","cells","#spells","ui","rows","#rows","size","entries","first","#press","marked","#cells","c","group","#withClues","#strokes","#down","#move","#up","#lost","#keydown","row","state","letter","#renderEntry","key","params","line","verdict","correct","solution","refs","#pressEntry","#renderSolution","fromRow","fromColumn","toRow","toColumn","clue","#letters","r1","c1","r2","c2","ends2","kind","palette","dots","press","active","#cellOf","from","to","draft","root","prompt","child","items","slot","item","value","#grid","index","letters","word","box","event","column","inside","n","clamp","fit","dr","dc","ar","ac","step","last","k","v","cell","#hit","#snap","#tap","#complete","#say","anchor","#set","#progress","id","message","wordSearchElement"],"sources":["../../../../components/src/word-search/ui-messages.ts","../../../../components/src/word-search/element.ts"],"sourcesContent":["import type { MessageCatalog } from '@astl/core';\nimport en from './messages/ui/en.json' with { type: 'json' };\nimport pl from './messages/ui/pl.json' with { type: 'json' };\n\nconst namespace = 'astl.word-search';\n\n/**\n * The student strings (`ui.*`): the element's catalogs. A module of their own, because bundlers split by module: one\n * that also built `wordSearchMessages` would put the authoring strings into the element's chunk.\n */\nexport const wordSearchUiMessages: readonly MessageCatalog[] = [\n { namespace, locale: 'en', messages: en },\n { namespace, locale: 'pl', messages: pl },\n];\n","import type { Answers, ComponentManifest, MessageCatalog, MessageParams, Units } from '@astl/core';\nimport { AstlElement, type ElementRegistration, renderVerdict, verdictIcon } from '@astl/player';\nimport { RovingFocus } from '@astl/player/interaction';\nimport {\n type CSSResultGroup,\n css,\n html,\n LitElement,\n nothing,\n type PropertyDeclarations,\n svg,\n type TemplateResult,\n unsafeCSS,\n} from 'lit';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { blockStyles } from '../block-styles.js';\nimport { wordSearchManifest } from './manifest.js';\nimport { type Cell, formatSpan, lineCells, parseSpan } from './span.js';\nimport { wordSearchUiMessages } from './ui-messages.js';\n\n/** An entry of the list: a word to find (its letters are in the view) or a clue (its word is not). */\ninterface Entry {\n readonly id: string;\n readonly el: HTMLElement;\n readonly clue: boolean;\n readonly letters: string;\n}\n\n/** A press on the grid: a tap while it stays on its first cell, else a drag to `to`. */\ninterface Press {\n readonly pointer: number;\n readonly from: Cell;\n readonly to: Cell;\n}\n\nconst textOf = (el: Element): string => (el.textContent ?? '').replace(/\\s+/g, ' ').trim();\n/** What an entry is called in messages: its text, else the alt text of its pictures. */\nconst nameOf = (el: Element): string =>\n textOf(el) ||\n [...el.querySelectorAll('img')]\n .map((img) => img.alt)\n .join(' ')\n .trim();\nconst same = (a: Cell, b: Cell): boolean => a[0] === b[0] && a[1] === b[1];\n/** Whether two spans cover the same line, either way. */\nfunction sameLine(a: string, b: string): boolean {\n const ends = parseSpan(b);\n return a === b || (ends !== null && a === formatSpan(ends[1], ends[0]));\n}\n\nconst MARKED = svg`<path d=\"M4 10h12\" stroke=\"currentColor\" stroke-width=\"6\" stroke-linecap=\"round\"/>`;\n\n/**\n * `<astl-word-search>`: a grid of letters (the view's `grid`) and a list of entries, the light-DOM `<astl-search-word>`\n * children (slotted manually, never moved or changed). Slots: one per entry (its id), answered with the span of a\n * line, `r2c3-r2c5`.\n * - The grid is an ARIA grid with one tab stop (`RovingFocus`); a line goes from a first to a last letter: a drag\n * (pointer capture: mouse, touch, pen; snapped to the nearest of the 8 directions), two taps, or Enter / Space twice\n * on the keyboard. Escape cancels.\n * - A line is matched against the listed words not yet found; with a clue pressed first, it is saved for that clue\n * without a check. Found words and marked clues take a stroke in their palette slot; pressing them releases it.\n * - Messages show in a status line and go to the player's live region.\n */\nexport class WordSearchElement extends AstlElement {\n static override manifest: ComponentManifest = wordSearchManifest;\n static override messages: readonly MessageCatalog[] = wordSearchUiMessages;\n static override shadowRootOptions: ShadowRootInit = {\n ...LitElement.shadowRootOptions,\n slotAssignment: 'manual',\n };\n\n static override properties: PropertyDeclarations = {\n lines: { state: true },\n anchor: { state: true },\n clue: { state: true },\n status: { state: true },\n };\n\n static override styles: CSSResultGroup = [\n // The grid gets up to 44px a letter and shrinks with the room it has (a container), down to 24 px a letter (the\n // WCAG 2.5.8 minimum target: letters touch, so each must be the minimum itself); a wider grid scrolls sideways in\n // its field, with a cue (below). The list sits beside it when there is room, else below. The field clips what it\n // scrolls, so a letter keeps room around it as wide as a focus ring reaches: the paper's padding at the edges of\n // the grid, its scroll margin when it is scrolled into view (the ring shows whole, and the next letter in part, so\n // a step scrolls one column: focus() centres a letter it finds wholly hidden).\n css`\n .board {\n --astl-ws-edge: calc(var(--astl-focus-width) + var(--astl-focus-offset));\n display: flex;\n flex-wrap: wrap;\n align-items: flex-start;\n gap: var(--astl-space-4);\n }\n .field {\n flex: 0 1 calc(var(--astl-ws-size) * var(--astl-target-min) + 2 * var(--astl-ws-edge));\n min-inline-size: 0;\n container-type: inline-size;\n }\n .paper {\n --astl-ws-cell: clamp(1.5rem, (100cqi - 2 * var(--astl-ws-edge)) / var(--astl-ws-size), var(--astl-target-min));\n position: relative;\n inline-size: calc(var(--astl-ws-cell) * var(--astl-ws-size));\n padding: var(--astl-ws-edge);\n }\n .grid {\n display: flex;\n flex-direction: column;\n touch-action: none;\n user-select: none;\n -webkit-user-select: none;\n -webkit-touch-callout: none;\n }\n .row {\n display: flex;\n }\n .cell {\n box-sizing: border-box;\n display: grid;\n place-items: center;\n flex: none;\n inline-size: var(--astl-ws-cell);\n block-size: var(--astl-ws-cell);\n font-family: var(--astl-font-mono);\n font-size: max(var(--astl-size-small), calc(var(--astl-ws-cell) * 0.55));\n font-weight: 600;\n line-height: 1;\n cursor: pointer;\n scroll-margin: var(--astl-ws-edge);\n }\n .grid[aria-disabled] .cell {\n cursor: default;\n }\n .cell[data-first] {\n border-radius: var(--astl-radius-m);\n box-shadow: inset 0 0 0 var(--astl-focus-width) var(--astl-selected);\n font-weight: 800;\n }\n .status {\n margin-block: var(--astl-space-2) 0;\n color: var(--astl-ink-muted);\n font-size: var(--astl-size-ui);\n }\n `,\n // A grid wider than its field scrolls sideways, and shows it: a shadow at each edge that has more to scroll to\n // (scroll shadows: covers that move with the content over shadows that stay with the field).\n css`\n .field {\n overflow-x: auto;\n background:\n linear-gradient(to right, var(--astl-surface) 40%, transparent) left / 2rem 100% no-repeat local,\n linear-gradient(to left, var(--astl-surface) 40%, transparent) right / 2rem 100% no-repeat local,\n radial-gradient(farthest-side at 0 50%, color-mix(in srgb, var(--astl-ink) 35%, transparent), transparent)\n left / 0.75rem 100% no-repeat scroll,\n radial-gradient(farthest-side at 100% 50%, color-mix(in srgb, var(--astl-ink) 35%, transparent), transparent)\n right / 0.75rem 100% no-repeat scroll;\n scrollbar-color: var(--astl-outline) transparent;\n }\n `,\n // Forced colours drop box shadows: the first letter gets an outline there (a focus ring wins over it).\n css`\n @media (forced-colors: active) {\n .cell[data-first] {\n outline: var(--astl-focus-width) solid var(--astl-selected);\n outline-offset: calc(-1 * var(--astl-focus-width));\n }\n }\n `,\n // Strokes lie on the grid (inside the paper's padding) and under the letters, in grid units (one cell = 1): a found\n // word or a marked clue is a loop around its letters, an edge in its palette slot (3:1 on the page in every theme)\n // round a fill of that slot's soft colour (the letters read on it); the line being made the same in the selection\n // colour; a solution a ring in the success colour behind each letter. Under, because the grid is positioned too and\n // comes after them: positioned boxes paint after in-flow ones, and among themselves in tree order (CSS 2.1,\n // appendix E). The cells have no fill, so the strokes show through.\n css`\n .grid {\n position: relative;\n }\n .lines {\n position: absolute;\n inset: var(--astl-ws-edge);\n inline-size: calc(100% - 2 * var(--astl-ws-edge));\n block-size: calc(100% - 2 * var(--astl-ws-edge));\n overflow: visible;\n pointer-events: none;\n forced-color-adjust: none;\n }\n .lines line {\n stroke: var(--astl-ws-ink);\n stroke-width: 0.76;\n stroke-linecap: round;\n }\n .lines .fill {\n stroke: var(--astl-ws-soft);\n stroke-width: 0.6;\n }\n .lines .draft {\n stroke: var(--astl-selected);\n }\n .lines .draft.fill {\n stroke: var(--astl-selected-soft);\n }\n .lines circle {\n fill: var(--astl-success-soft);\n stroke: var(--astl-success);\n stroke-width: 0.08;\n }\n `,\n css`\n .words {\n flex: 1 1 12rem;\n display: grid;\n grid-template-columns: repeat(auto-fill, minmax(min(100%, 11rem), 1fr));\n gap: var(--astl-space-2);\n margin: 0;\n padding: 0;\n list-style: none;\n }\n .entry {\n position: relative;\n box-sizing: border-box;\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n border: var(--astl-outline-width) solid var(--astl-outline);\n border-radius: var(--astl-radius-m);\n background: var(--astl-surface);\n overflow: clip;\n }\n .entry:has(> [data-clue], > .astl-solution) {\n grid-column: 1 / -1;\n }\n .entry > button {\n flex: 1 1 auto;\n display: flex;\n align-items: center;\n gap: var(--astl-space-2);\n min-inline-size: var(--astl-target-min);\n min-block-size: var(--astl-target-min);\n margin: 0;\n padding-block: var(--astl-space-1);\n padding-inline: var(--astl-space-3);\n border: 0;\n background: none;\n color: inherit;\n font: inherit;\n text-align: start;\n cursor: pointer;\n }\n .entry > button:disabled {\n cursor: default;\n }\n .text {\n min-inline-size: 0;\n overflow-wrap: anywhere;\n hyphens: auto;\n }\n .sign {\n flex: none;\n display: inline-flex;\n inline-size: 1.1em;\n color: var(--astl-ws-ink);\n }\n .sign > svg {\n inline-size: 1.1em;\n block-size: 1.1em;\n }\n .entry[data-marked] {\n background: var(--astl-ws-soft);\n }\n .entry[data-picked] {\n border-color: var(--astl-selected);\n background: var(--astl-selected-soft);\n font-weight: var(--astl-selected-weight);\n }\n .entry[data-picked]::before {\n content: '';\n position: absolute;\n inset-block: 0;\n inset-inline-start: 0;\n inline-size: var(--astl-selected-bar);\n background: var(--astl-selected);\n }\n .entry > .astl-verdict {\n margin-inline-start: auto;\n padding-inline-end: var(--astl-space-3);\n }\n .entry > .astl-solution {\n flex-basis: 100%;\n padding-inline: var(--astl-space-3);\n padding-block-end: var(--astl-space-2);\n }\n .group-verdict {\n margin-block: var(--astl-space-3) 0;\n }\n `,\n // Palette slots through an attribute: a strict Content Security Policy blocks inline style attributes.\n unsafeCSS(\n Array.from(\n { length: 8 },\n (_, i) =>\n `[data-palette='${i + 1}']{--astl-ws-ink:var(--astl-palette-${i + 1});--astl-ws-soft:var(--astl-palette-${i + 1}-soft)}`,\n ).join(''),\n ),\n blockStyles,\n ];\n\n /** Entry id to the span of its line. */\n declare protected lines: ReadonlyMap<string, string>;\n /** The first letter of a line being made with taps or the keyboard. */\n declare protected anchor: Cell | null;\n /** The clue pressed: the next line is saved for it. */\n declare protected clue: string | null;\n declare protected status: string;\n #press: Press | null = null;\n #grid: { readonly value: string; readonly rows: readonly (readonly string[])[] } = { value: '', rows: [] };\n readonly #roving: RovingFocus;\n\n constructor() {\n super();\n this.lines = new Map();\n this.anchor = null;\n this.clue = null;\n this.status = '';\n const element = this;\n this.#roving = new RovingFocus(this, {\n count: () => this.#size ** 2,\n item: (i) => this.renderRoot.querySelector<HTMLElement>(`[data-cell=\"${i}\"]`),\n axis: 'grid',\n get columns() {\n return element.#size;\n },\n });\n }\n\n get slotIds(): readonly string[] {\n return this.#entries.map((entry) => entry.id);\n }\n\n getAnswers(): Answers {\n return Object.fromEntries(this.lines);\n }\n\n /** Spans the element can show: a straight line in the grid, for a listed word one that spells it. */\n setAnswers(answers: Answers): void {\n const next = new Map(this.lines);\n for (const entry of this.#entries) {\n const span = answers[entry.id];\n if (span === undefined) continue;\n next.delete(entry.id);\n const ends = parseSpan(span);\n const cells = ends === null ? null : lineCells(ends[0], ends[1], this.#size);\n if (cells !== null && (entry.clue || this.#spells(cells, entry.letters))) next.set(entry.id, span);\n }\n this.lines = next;\n this.anchor = null;\n this.clue = null;\n this.status = '';\n }\n\n units(): Units {\n return { answered: this.lines.size, total: this.#entries.length };\n }\n\n protected override render(): TemplateResult {\n const ui = this.uiLanguage;\n const rows = this.#rows;\n const size = rows.length;\n const entries = this.#entries;\n const first = this.#press?.from ?? this.anchor;\n const marked = new Set(\n [...this.lines.values()].flatMap((span) => this.#cells(span).map(([r, c]) => r * size + c)),\n );\n const group = this.groupVerdict;\n const say = (key: string, params?: MessageParams) => this.t(key, params);\n return html`<fieldset part=\"word-search\">\n <legend part=\"prompt\">\n <slot class=\"prompt-slot\"></slot>\n <span class=\"hint\" lang=${ui.lang} dir=${ui.dir}>${this.#withClues('ui.hint')}</span>\n </legend>\n <div class=\"board\">\n <div class=\"field\">\n <div class=\"paper\">\n <svg class=\"lines\" part=\"line\" viewBox=\"0 0 ${size} ${size}\" preserveAspectRatio=\"none\" aria-hidden=\"true\" focusable=\"false\">\n ${this.#strokes()}\n </svg>\n <div\n class=\"grid\"\n part=\"grid\"\n role=\"grid\"\n lang=${ui.lang}\n aria-label=${this.t('ui.grid', { size })}\n aria-describedby=\"instructions\"\n aria-disabled=${this.disabled ? 'true' : nothing}\n tabindex=${this.disabled ? '0' : nothing}\n @pointerdown=${this.#down}\n @pointermove=${this.#move}\n @pointerup=${this.#up}\n @pointercancel=${this.#lost}\n @lostpointercapture=${this.#lost}\n @keydown=${this.#keydown}\n >\n ${rows.map(\n (row, r) => html`<div class=\"row\" role=\"row\">\n ${row.map((letter, c) => {\n const i = r * size + c;\n const state =\n first !== null && same(first, [r, c]) ? 'first' : marked.has(i) ? 'marked' : 'other';\n return html`<div\n class=\"cell\"\n part=\"cell\"\n role=\"gridcell\"\n data-cell=${i}\n tabindex=${this.disabled ? nothing : this.#roving.tabIndex(i)}\n aria-label=${this.t('ui.cell', { letter, row: r + 1, column: c + 1, state })}\n ?data-first=${state === 'first'}\n >${letter}</div>`;\n })}\n </div>`,\n )}\n </div>\n </div>\n <p class=\"status\" part=\"status\" lang=${ui.lang} dir=${ui.dir} ?hidden=${this.status === ''}>${this.status}</p>\n </div>\n <ul class=\"words\" part=\"words\" role=\"list\" aria-label=${this.t('ui.words')}>\n ${entries.map((entry, i) => this.#renderEntry(entry, i))}\n </ul>\n </div>\n <span class=\"astl-vh\" id=\"instructions\" lang=${ui.lang} dir=${ui.dir}>${this.t('ui.instructions')}</span>\n <span class=\"astl-vh\" id=\"list-help\" lang=${ui.lang} dir=${ui.dir}>${this.t('ui.listHelp')}</span>\n ${\n group === null\n ? nothing\n : html`<p class=\"group-verdict\" part=\"verdict\" data-verdict=${group}>${renderVerdict(group, say, ui)}</p>`\n }\n </fieldset>`;\n }\n\n #renderEntry(entry: Entry, i: number): TemplateResult {\n const ui = this.uiLanguage;\n const line = this.lines.get(entry.id);\n // Marked one by one, a word not found shows \"no answer\" (dotted), as in every type.\n const marked = Object.keys(this.feedback?.slots ?? {}).length > 0;\n const verdict =\n (line === undefined ? (marked ? 'empty' : null) : this.slotVerdict(entry.id)) ?? undefined;\n const correct = this.solution?.[entry.id];\n const solution =\n correct === undefined || (line !== undefined && sameLine(line, correct)) ? null : correct;\n const state = entry.clue ? (line ? 'ui.marked' : 'ui.notMarked') : line ? 'ui.found' : 'ui.notFound';\n const refs = [verdict && `verdict-${i}`, solution && `solution-${i}`, this.disabled ? '' : 'list-help'];\n return html`<li\n class=\"entry astl-box astl-ring\"\n part=\"word\"\n data-item=${entry.id}\n data-palette=${ifDefined(line === undefined ? undefined : (i % 8) + 1)}\n data-verdict=${ifDefined(verdict)}\n ?data-marked=${line !== undefined}\n ?data-picked=${this.clue === entry.id}\n >\n <button\n type=\"button\"\n data-item=${entry.id}\n ?data-clue=${entry.clue}\n aria-pressed=${entry.clue ? String(this.clue === entry.id) : nothing}\n aria-describedby=${refs.filter(Boolean).join(' ') || nothing}\n ?disabled=${this.disabled}\n @click=${() => this.#pressEntry(entry)}\n >\n <span class=\"sign\" aria-hidden=\"true\"\n >${line === undefined ? nothing : html`<svg viewBox=\"0 0 20 20\">${MARKED}</svg>`}</span\n ><span class=\"text\"><slot data-item=${entry.id}></slot></span\n ><span class=\"astl-vh\" lang=${ui.lang} dir=${ui.dir}>, ${this.t(state)}</span>\n </button>\n ${\n verdict === undefined\n ? nothing\n : renderVerdict(verdict, (key, params) => this.t(key, params), {\n hiddenWord: true,\n id: `verdict-${i}`,\n part: 'verdict',\n ...ui,\n })\n }\n ${solution === null ? nothing : this.#renderSolution(solution, i, entry.clue)}\n </li>`;\n }\n\n /** \"Correct answer: KOT, row 2, column 3 to row 2, column 5\": where the word is, and for a clue the word itself. */\n #renderSolution(span: string, i: number, clue: boolean): TemplateResult {\n const ui = this.uiLanguage;\n const [[fromRow, fromColumn], [toRow, toColumn]] = parseSpan(span) as readonly [Cell, Cell];\n const params = {\n clue: clue ? 'yes' : 'no',\n word: this.#letters(this.#cells(span)),\n fromRow: fromRow + 1,\n fromColumn: fromColumn + 1,\n toRow: toRow + 1,\n toColumn: toColumn + 1,\n };\n return html`<p class=\"astl-solution\" part=\"solution\" id=\"solution-${i}\" data-span=${span} lang=${ui.lang} dir=${ui.dir}\n >${verdictIcon('correct')}<span class=\"astl-solution-label\">${this.t('ui.solution', params)}</span></p\n >`;\n }\n\n /** Saved lines, the solutions not shown by them, then the line being made. */\n #strokes(): TemplateResult {\n const line = (span: string, kind: string, entry?: string, palette?: number) => {\n const ends = parseSpan(span);\n if (ends === null) return nothing;\n const [[r1, c1], [r2, c2]] = ends;\n const ends2 = { x1: c1 + 0.5, y1: r1 + 0.5, x2: c2 + 0.5, y2: r2 + 0.5 };\n // The edge, then the fill over it: a loop round the letters.\n return svg`<line class=${kind} data-span=${span} data-item=${ifDefined(entry)} data-palette=${ifDefined(palette)} x1=${ends2.x1} y1=${ends2.y1} x2=${ends2.x2} y2=${ends2.y2}></line><line class=\"${kind} fill\" data-palette=${ifDefined(palette)} x1=${ends2.x1} y1=${ends2.y1} x2=${ends2.x2} y2=${ends2.y2}></line>`;\n };\n // A solution is a dot behind each of its letters: a pattern apart from the strokes students draw.\n const dots = (span: string) =>\n svg`<g class=\"solution\" data-span=${span}>${this.#cells(span).map(\n ([r, c]) => svg`<circle cx=${c + 0.5} cy=${r + 0.5} r=\"0.4\"></circle>`,\n )}</g>`;\n const entries = this.#entries;\n const press = this.#press;\n const active = this.#cellOf(this.#roving.active);\n const from = press?.from ?? this.anchor;\n const to = press?.to ?? active;\n const draft = from !== null && lineCells(from, to, this.#size) !== null ? formatSpan(from, to) : null;\n return svg`${entries.map((entry, i) => {\n const span = this.lines.get(entry.id);\n return span === undefined ? nothing : line(span, 'found', entry.id, (i % 8) + 1);\n })}${entries.map((entry) => {\n const correct = this.solution?.[entry.id];\n const span = this.lines.get(entry.id);\n return correct === undefined || (span !== undefined && sameLine(span, correct))\n ? nothing\n : dots(correct);\n })}${draft === null ? nothing : line(draft, 'draft')}`;\n }\n\n protected override updated(): void {\n // Manual slot assignment: the view's light DOM is projected as is, never moved or rewritten.\n const root = this.renderRoot as ShadowRoot;\n const prompt = Array.from(this.children).find((child) => child.localName === 'astl-prompt');\n root.querySelector<HTMLSlotElement>('slot.prompt-slot')?.assign(...(prompt ? [prompt] : []));\n const items = new Map(this.#entries.map((entry) => [entry.id, entry.el]));\n for (const slot of root.querySelectorAll<HTMLSlotElement>('slot[data-item]')) {\n const item = items.get(slot.dataset.item ?? '');\n slot.assign(...(item ? [item] : []));\n }\n // Through the CSSOM, which a strict Content Security Policy allows (an inline style attribute it blocks).\n root.querySelector<HTMLElement>('.board')?.style.setProperty('--astl-ws-size', `${this.#size}`);\n }\n\n // The grid and the list\n\n get #rows(): readonly (readonly string[])[] {\n const value = this.getAttribute('grid') ?? '';\n if (value !== this.#grid.value) {\n this.#grid = {\n value,\n rows: value\n .split(' ')\n .filter((row) => row !== '')\n .map((row) => [...row]),\n };\n }\n return this.#grid.rows;\n }\n\n get #size(): number {\n return this.#rows.length;\n }\n\n get #entries(): readonly Entry[] {\n return Array.from(this.children)\n .filter((child): child is HTMLElement => child.localName === 'astl-search-word' && child.id !== '')\n .map((el) => {\n const clue = el.hasAttribute('clue');\n return { id: el.id, el, clue, letters: clue ? '' : textOf(el) };\n });\n }\n\n #cellOf(index: number): Cell {\n const size = Math.max(1, this.#size);\n return [Math.floor(index / size), index % size];\n }\n\n #cells(span: string): readonly Cell[] {\n const ends = parseSpan(span);\n return (ends === null ? null : lineCells(ends[0], ends[1], this.#size)) ?? [];\n }\n\n #letters(cells: readonly Cell[]): string {\n return cells.map(([r, c]) => this.#rows[r]?.[c] ?? '').join('');\n }\n\n #spells(cells: readonly Cell[], word: string): boolean {\n const letters = this.#letters(cells);\n return word !== '' && (letters === word || [...letters].reverse().join('') === word);\n }\n\n // Marking lines\n\n /** The cell under a pointer, or (`clamp`) the nearest one; null outside the grid. */\n #hit(event: PointerEvent, clamp = false): Cell | null {\n const box = (event.currentTarget as HTMLElement).getBoundingClientRect();\n const size = this.#size;\n const row = Math.floor(((event.clientY - box.top) / box.height) * size);\n const column = Math.floor(((event.clientX - box.left) / box.width) * size);\n const inside = (n: number) => n >= 0 && n < size;\n if (!clamp && !(inside(row) && inside(column))) return null;\n const fit = (n: number) => Math.min(Math.max(n, 0), size - 1);\n return [fit(row), fit(column)];\n }\n\n /** A drag from `from` towards `to`, snapped to the nearest of the 8 directions and kept inside the grid. */\n #snap(from: Cell, to: Cell): Cell {\n const dr = to[0] - from[0];\n const dc = to[1] - from[1];\n const [ar, ac] = [Math.abs(dr), Math.abs(dc)];\n const step: Cell =\n ar * 2 < ac ? [0, Math.sign(dc)] : ac * 2 < ar ? [Math.sign(dr), 0] : [Math.sign(dr), Math.sign(dc)];\n let n = step[0] !== 0 && step[1] !== 0 ? Math.round((ar + ac) / 2) : Math.max(ar, ac);\n const last = this.#size - 1;\n const inside = (k: number) =>\n [from[0] + step[0] * k, from[1] + step[1] * k].every((v) => v >= 0 && v <= last);\n while (n > 0 && !inside(n)) n--;\n return [from[0] + step[0] * n, from[1] + step[1] * n];\n }\n\n #down(event: PointerEvent): void {\n if (this.disabled || event.button !== 0 || !event.isPrimary) return;\n const cell = this.#hit(event);\n if (cell === null) return;\n (event.currentTarget as HTMLElement).setPointerCapture(event.pointerId);\n this.#press = { pointer: event.pointerId, from: cell, to: cell };\n this.#roving.focus(cell[0] * this.#size + cell[1]);\n }\n\n #move(event: PointerEvent): void {\n const press = this.#press;\n if (press === null || event.pointerId !== press.pointer) return;\n const to = this.#snap(press.from, this.#hit(event, true) as Cell);\n if (same(to, press.to)) return;\n this.#press = { ...press, to };\n this.requestUpdate();\n }\n\n #up(event: PointerEvent): void {\n const press = this.#press;\n if (press === null || event.pointerId !== press.pointer) return;\n this.#press = null;\n if (same(press.from, press.to)) this.#tap(press.from);\n else {\n this.anchor = null;\n this.#complete(press.from, press.to);\n }\n this.requestUpdate();\n }\n\n #lost(event: PointerEvent): void {\n if (this.#press?.pointer !== event.pointerId) return;\n this.#press = null;\n this.requestUpdate();\n }\n\n #keydown(event: KeyboardEvent): void {\n if (this.disabled) return;\n if (event.key === 'Enter' || event.key === ' ') {\n event.preventDefault();\n if (!event.repeat) this.#tap(this.#cellOf(this.#roving.active));\n } else if (event.key === 'Escape' && (this.anchor !== null || this.clue !== null)) {\n // The first letter goes first, then the clue chosen.\n event.preventDefault();\n if (this.anchor !== null) this.anchor = null;\n else this.clue = null;\n this.#say('cancel');\n } else this.#roving.keydown(event);\n }\n\n /** A first letter, then a last one; the same letter again cancels. */\n #tap(cell: Cell): void {\n const anchor = this.anchor;\n if (anchor === null) {\n this.anchor = cell;\n const letter = this.#letters([cell]);\n this.#say('first', { letter, row: cell[0] + 1, column: cell[1] + 1 });\n } else if (same(anchor, cell)) {\n this.anchor = null;\n this.#say('cancel');\n } else {\n this.anchor = null;\n this.#complete(anchor, cell);\n }\n }\n\n /** A line from `from` to `to`: saved for the pressed clue, else matched against the listed words not found yet. */\n #complete(from: Cell, to: Cell): void {\n const cells = lineCells(from, to, this.#size);\n if (cells === null) {\n this.#say('notStraight');\n return;\n }\n const span = formatSpan(from, to);\n const entries = this.#entries;\n const clue = entries.find((entry) => entry.id === this.clue);\n if (clue !== undefined) {\n this.clue = null;\n this.#set(clue.id, span);\n this.#say('saved', { clue: nameOf(clue.el), ...this.#progress() });\n return;\n }\n const word = entries.find((entry) => !entry.clue && this.#spells(cells, entry.letters));\n if (word === undefined) {\n this.#say('none', { letters: this.#letters(cells) });\n } else if (this.lines.has(word.id)) {\n this.#say('again', { word: word.letters });\n } else {\n this.#set(word.id, span);\n this.#say('found', { word: word.letters, ...this.#progress() });\n }\n }\n\n /** A found word or a marked clue is released; a clue is pressed or let go; a word not found yet gets a hint. */\n #pressEntry(entry: Entry): void {\n if (this.disabled) return;\n if (this.lines.has(entry.id)) {\n this.#set(entry.id, '');\n this.#say('released', { word: entry.clue ? nameOf(entry.el) : entry.letters, ...this.#progress() });\n } else if (!entry.clue) {\n this.#say('find', { word: entry.letters });\n } else if (this.clue === entry.id) {\n this.clue = null;\n this.#say('cancel');\n } else {\n this.clue = entry.id;\n this.anchor = null;\n this.#say('clue', { clue: nameOf(entry.el) });\n // On to the letters: keyboard users mark the word next.\n this.#roving.focus(this.#roving.active);\n }\n }\n\n /** Sets (or with '' clears) the line of an entry and reports it. */\n #set(id: string, span: string): void {\n const next = new Map(this.lines);\n if (span === '') next.delete(id);\n else next.set(id, span);\n this.lines = next;\n this.emitChange({ [id]: span });\n }\n\n #progress(): { readonly count: number; readonly total: number } {\n return { count: this.lines.size, total: this.#entries.length };\n }\n\n /** A message, followed by how to mark a clue's word when the list has clues. */\n #withClues(key: string, params?: MessageParams): string {\n const message = this.t(key, params);\n return this.#entries.some((entry) => entry.clue) ? `${message} ${this.t('ui.hintClues')}` : message;\n }\n\n /** Shows a message in the status line and announces it; a line that spells no word also says how clues work. */\n #say(key: string, params?: MessageParams): void {\n this.status =\n key === 'none' ? this.#withClues('ui.status.none', params) : this.t(`ui.status.${key}`, params);\n this.announce(this.status);\n }\n}\n\nexport const wordSearchElement: ElementRegistration = {\n manifest: wordSearchManifest,\n element: WordSearchElement,\n messages: wordSearchUiMessages,\n};\n"],"mappings":"A,iSAIA,IAAMwB,EAAY,mBAMLC,EAAkD,CAC7D,CAAE,YAAW,OAAQ,KAAM,SAAUzB,CAAG,EACxC,CAAE,YAAW,OAAQ,KAAM,SAAUC,CAAG,CAC1C,ECsBMyB,EAAU,IAAyBC,EAAG,aAAe,GAAA,CAAI,QAAQ,OAAQ,GAAG,CAAC,CAAC,KAAK,EAEnFC,EAAU,GACdF,EAAOC,CAAE,GACT,CAAC,GAAGA,EAAG,iBAAiB,KAAK,CAAC,CAAC,CAC5B,IAAK,GAAQE,EAAI,GAAG,CAAC,CACrB,KAAK,GAAG,CAAC,CACT,KAAK,EACJC,GAAQ,EAAS,IAAqBC,EAAE,KAAOzB,EAAE,IAAMyB,EAAE,KAAOzB,EAAE,GAExE,SAAS0B,EAAS,EAAW,EAAoB,CAC/C,IAAMC,EAAOb,EAAUd,CAAC,EACxB,OAAOyB,IAAMzB,GAAM2B,IAAS,MAAQF,IAAMV,EAAWY,EAAK,GAAIA,EAAK,EAAE,CACvE,CAEA,IAAMC,EAAS,CAAG,qFAaLC,EAAb,cAAuCtB,CAAY,CACjD,OAAgB,SAA8BM,E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,EAAG2F,GAAK1F,CAAK,CAAC,CAChC,CAEA,IAAgE,CAC9D,MAAO,CAAE,MAAO,KAAK,MAAM,KAAM,MAAO,KAAKH,GAAS,MAAO,CAC/D,CAGA,GAAW,EAAa,EAAgC,CACtD,IAAM8F,EAAU,KAAK,EAAEjE,EAAKC,CAAM,EAClC,OAAO,KAAK9B,GAAS,KAAM,GAAUC,EAAM,IAAI,EAAI,GAAG6F,EAAQ,GAAG,KAAK,EAAE,cAAc,IAAMA,CAC9F,CAGA,GAAK,EAAa,EAA8B,CAC9C,KAAK,OACHjE,IAAQ,OAAS,KAAKX,GAAW,iBAAkBY,CAAM,EAAI,KAAK,EAAE,aAAaD,IAAOC,CAAM,EAChG,KAAK,SAAS,KAAK,MAAM,CAC3B,CACF,EAEaiE,EAAyC,CACpD,SAAUnH,EACV,QAASgB,EACT,SAAUV,CACZ,E"}
|
|
1
|
+
{"version":3,"file":"word-search-IOCwqo3y.js","names":["en","pl","LitElement","unsafeCSS","nothing","ifDefined","b","r","i$1","w","A","verdictIcon","renderVerdict","AstlElement","o","i","en_default","pl_default","lineCells","wordSearchManifest","parseSpan","formatSpan","RovingFocus","blockStyles","namespace","wordSearchUiMessages","textOf","el","nameOf","img","same","a","sameLine","ends","MARKED","WordSearchElement","element","#roving","#size","#entries","entry","next","span","answers","cells","#spells","ui","rows","#rows","size","entries","first","#press","marked","#cells","c","group","#withClues","#strokes","#down","#move","#up","#lost","#keydown","row","state","letter","#renderEntry","key","params","line","verdict","correct","solution","refs","#pressEntry","#renderSolution","fromRow","fromColumn","toRow","toColumn","clue","#letters","r1","c1","r2","c2","ends2","kind","palette","dots","press","active","#cellOf","from","to","draft","root","prompt","child","items","slot","item","value","#grid","index","letters","word","box","event","column","inside","n","clamp","fit","dr","dc","ar","ac","step","last","k","v","cell","#hit","#snap","#tap","#complete","#say","anchor","#set","#progress","id","message","wordSearchElement"],"sources":["../../../../components/src/word-search/ui-messages.ts","../../../../components/src/word-search/element.ts"],"sourcesContent":["import type { MessageCatalog } from '@astl/core';\nimport en from './messages/ui/en.json' with { type: 'json' };\nimport pl from './messages/ui/pl.json' with { type: 'json' };\n\nconst namespace = 'astl.word-search';\n\n/**\n * The student strings (`ui.*`): the element's catalogs. A module of their own, because bundlers split by module: one\n * that also built `wordSearchMessages` would put the authoring strings into the element's chunk.\n */\nexport const wordSearchUiMessages: readonly MessageCatalog[] = [\n { namespace, locale: 'en', messages: en },\n { namespace, locale: 'pl', messages: pl },\n];\n","import type { Answers, ComponentManifest, MessageCatalog, MessageParams, Units } from '@astl/core';\nimport { AstlElement, type ElementRegistration, renderVerdict, verdictIcon } from '@astl/player';\nimport { RovingFocus } from '@astl/player/interaction';\nimport {\n type CSSResultGroup,\n css,\n html,\n LitElement,\n nothing,\n type PropertyDeclarations,\n svg,\n type TemplateResult,\n unsafeCSS,\n} from 'lit';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { blockStyles } from '../block-styles.js';\nimport { wordSearchManifest } from './manifest.js';\nimport { type Cell, formatSpan, lineCells, parseSpan } from './span.js';\nimport { wordSearchUiMessages } from './ui-messages.js';\n\n/** An entry of the list: a word to find (its letters are in the view) or a clue (its word is not). */\ninterface Entry {\n readonly id: string;\n readonly el: HTMLElement;\n readonly clue: boolean;\n readonly letters: string;\n}\n\n/** A press on the grid: a tap while it stays on its first cell, else a drag to `to`. */\ninterface Press {\n readonly pointer: number;\n readonly from: Cell;\n readonly to: Cell;\n}\n\nconst textOf = (el: Element): string => (el.textContent ?? '').replace(/\\s+/g, ' ').trim();\n/** What an entry is called in messages: its text, else the alt text of its pictures. */\nconst nameOf = (el: Element): string =>\n textOf(el) ||\n [...el.querySelectorAll('img')]\n .map((img) => img.alt)\n .join(' ')\n .trim();\nconst same = (a: Cell, b: Cell): boolean => a[0] === b[0] && a[1] === b[1];\n/** Whether two spans cover the same line, either way. */\nfunction sameLine(a: string, b: string): boolean {\n const ends = parseSpan(b);\n return a === b || (ends !== null && a === formatSpan(ends[1], ends[0]));\n}\n\nconst MARKED = svg`<path d=\"M4 10h12\" stroke=\"currentColor\" stroke-width=\"6\" stroke-linecap=\"round\"/>`;\n\n/**\n * `<astl-word-search>`: a grid of letters (the view's `grid`) and a list of entries, the light-DOM `<astl-search-word>`\n * children (slotted manually, never moved or changed). Slots: one per entry (its id), answered with the span of a\n * line, `r2c3-r2c5`.\n * - The grid is an ARIA grid with one tab stop (`RovingFocus`); a line goes from a first to a last letter: a drag\n * (pointer capture: mouse, touch, pen; snapped to the nearest of the 8 directions), two taps, or Enter / Space twice\n * on the keyboard. Escape cancels.\n * - A line is matched against the listed words not yet found; with a clue pressed first, it is saved for that clue\n * without a check. Found words and marked clues take a stroke in their palette slot; pressing them releases it.\n * - Messages show in a status line and go to the player's live region.\n */\nexport class WordSearchElement extends AstlElement {\n static override manifest: ComponentManifest = wordSearchManifest;\n static override messages: readonly MessageCatalog[] = wordSearchUiMessages;\n static override shadowRootOptions: ShadowRootInit = {\n ...LitElement.shadowRootOptions,\n slotAssignment: 'manual',\n };\n\n static override properties: PropertyDeclarations = {\n lines: { state: true },\n anchor: { state: true },\n clue: { state: true },\n status: { state: true },\n };\n\n static override styles: CSSResultGroup = [\n // The grid gets up to 44px a letter and shrinks with the room it has (a container), down to 24 px a letter (the\n // WCAG 2.5.8 minimum target: letters touch, so each must be the minimum itself); a wider grid scrolls sideways in\n // its field, with a cue (below). The list sits beside it when there is room, else below. The field clips what it\n // scrolls, so a letter keeps room around it as wide as a focus ring reaches: the paper's padding at the edges of\n // the grid, its scroll margin when it is scrolled into view (the ring shows whole, and the next letter in part, so\n // a step scrolls one column: focus() centres a letter it finds wholly hidden).\n css`\n .board {\n --astl-ws-edge: calc(var(--astl-focus-width) + var(--astl-focus-offset));\n display: flex;\n flex-wrap: wrap;\n align-items: flex-start;\n gap: var(--astl-space-4);\n }\n .field {\n flex: 0 1 calc(var(--astl-ws-size) * var(--astl-target-min) + 2 * var(--astl-ws-edge));\n min-inline-size: 0;\n container-type: inline-size;\n }\n .paper {\n --astl-ws-cell: clamp(1.5rem, (100cqi - 2 * var(--astl-ws-edge)) / var(--astl-ws-size), var(--astl-target-min));\n position: relative;\n inline-size: calc(var(--astl-ws-cell) * var(--astl-ws-size));\n padding: var(--astl-ws-edge);\n }\n .grid {\n display: flex;\n flex-direction: column;\n touch-action: none;\n user-select: none;\n -webkit-user-select: none;\n -webkit-touch-callout: none;\n }\n .row {\n display: flex;\n }\n .cell {\n box-sizing: border-box;\n display: grid;\n place-items: center;\n flex: none;\n inline-size: var(--astl-ws-cell);\n block-size: var(--astl-ws-cell);\n font-family: var(--astl-font-mono);\n font-size: max(var(--astl-size-small), calc(var(--astl-ws-cell) * 0.55));\n font-weight: 600;\n line-height: 1;\n cursor: pointer;\n scroll-margin: var(--astl-ws-edge);\n }\n .grid[aria-disabled] .cell {\n cursor: default;\n }\n .cell[data-first] {\n border-radius: var(--astl-radius-m);\n box-shadow: inset 0 0 0 var(--astl-focus-width) var(--astl-selected);\n font-weight: 800;\n }\n .status {\n margin-block: var(--astl-space-2) 0;\n color: var(--astl-ink-muted);\n font-size: var(--astl-size-ui);\n }\n `,\n // A grid wider than its field scrolls sideways, and shows it: a shadow at each edge that has more to scroll to\n // (scroll shadows: covers that move with the content over shadows that stay with the field).\n css`\n .field {\n overflow-x: auto;\n background:\n linear-gradient(to right, var(--astl-surface) 40%, transparent) left / 2rem 100% no-repeat local,\n linear-gradient(to left, var(--astl-surface) 40%, transparent) right / 2rem 100% no-repeat local,\n radial-gradient(farthest-side at 0 50%, color-mix(in srgb, var(--astl-ink) 35%, transparent), transparent)\n left / 0.75rem 100% no-repeat scroll,\n radial-gradient(farthest-side at 100% 50%, color-mix(in srgb, var(--astl-ink) 35%, transparent), transparent)\n right / 0.75rem 100% no-repeat scroll;\n scrollbar-color: var(--astl-outline) transparent;\n }\n `,\n // Forced colours drop box shadows: the first letter gets an outline there (a focus ring wins over it).\n css`\n @media (forced-colors: active) {\n .cell[data-first] {\n outline: var(--astl-focus-width) solid var(--astl-selected);\n outline-offset: calc(-1 * var(--astl-focus-width));\n }\n }\n `,\n // Strokes lie on the grid (inside the paper's padding) and under the letters, in grid units (one cell = 1): a found\n // word or a marked clue is a loop around its letters, an edge in its palette slot (3:1 on the page in every theme)\n // round a fill of that slot's soft colour (the letters read on it); the line being made the same in the selection\n // colour; a solution a ring in the success colour behind each letter. Under, because the grid is positioned too and\n // comes after them: positioned boxes paint after in-flow ones, and among themselves in tree order (CSS 2.1,\n // appendix E). The cells have no fill, so the strokes show through.\n css`\n .grid {\n position: relative;\n }\n .lines {\n position: absolute;\n inset: var(--astl-ws-edge);\n inline-size: calc(100% - 2 * var(--astl-ws-edge));\n block-size: calc(100% - 2 * var(--astl-ws-edge));\n overflow: visible;\n pointer-events: none;\n forced-color-adjust: none;\n }\n .lines line {\n stroke: var(--astl-ws-ink);\n stroke-width: 0.76;\n stroke-linecap: round;\n }\n .lines .fill {\n stroke: var(--astl-ws-soft);\n stroke-width: 0.6;\n }\n .lines .draft {\n stroke: var(--astl-selected);\n }\n .lines .draft.fill {\n stroke: var(--astl-selected-soft);\n }\n .lines circle {\n fill: var(--astl-success-soft);\n stroke: var(--astl-success);\n stroke-width: 0.08;\n }\n `,\n css`\n .words {\n flex: 1 1 12rem;\n display: grid;\n grid-template-columns: repeat(auto-fill, minmax(min(100%, 11rem), 1fr));\n gap: var(--astl-space-2);\n margin: 0;\n padding: 0;\n list-style: none;\n }\n .entry {\n position: relative;\n box-sizing: border-box;\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n border: var(--astl-outline-width) solid var(--astl-outline);\n border-radius: var(--astl-radius-m);\n background: var(--astl-surface);\n overflow: clip;\n }\n .entry:has(> [data-clue], > .astl-solution) {\n grid-column: 1 / -1;\n }\n .entry > button {\n flex: 1 1 auto;\n display: flex;\n align-items: center;\n gap: var(--astl-space-2);\n min-inline-size: var(--astl-target-min);\n min-block-size: var(--astl-target-min);\n margin: 0;\n padding-block: var(--astl-space-1);\n padding-inline: var(--astl-space-3);\n border: 0;\n background: none;\n color: inherit;\n font: inherit;\n text-align: start;\n cursor: pointer;\n }\n .entry > button:disabled {\n cursor: default;\n }\n .text {\n min-inline-size: 0;\n overflow-wrap: anywhere;\n hyphens: auto;\n }\n .sign {\n flex: none;\n display: inline-flex;\n inline-size: 1.1em;\n color: var(--astl-ws-ink);\n }\n .sign > svg {\n inline-size: 1.1em;\n block-size: 1.1em;\n }\n .entry[data-marked] {\n background: var(--astl-ws-soft);\n }\n .entry[data-picked] {\n border-color: var(--astl-selected);\n background: var(--astl-selected-soft);\n font-weight: var(--astl-selected-weight);\n }\n .entry[data-picked]::before {\n content: '';\n position: absolute;\n inset-block: 0;\n inset-inline-start: 0;\n inline-size: var(--astl-selected-bar);\n background: var(--astl-selected);\n }\n .entry > .astl-verdict {\n margin-inline-start: auto;\n padding-inline-end: var(--astl-space-3);\n }\n .entry > .astl-solution {\n flex-basis: 100%;\n padding-inline: var(--astl-space-3);\n padding-block-end: var(--astl-space-2);\n }\n .group-verdict {\n margin-block: var(--astl-space-3) 0;\n }\n `,\n // Palette slots through an attribute: a strict Content Security Policy blocks inline style attributes.\n unsafeCSS(\n Array.from(\n { length: 8 },\n (_, i) =>\n `[data-palette='${i + 1}']{--astl-ws-ink:var(--astl-palette-${i + 1});--astl-ws-soft:var(--astl-palette-${i + 1}-soft)}`,\n ).join(''),\n ),\n blockStyles,\n ];\n\n /** Entry id to the span of its line. */\n declare protected lines: ReadonlyMap<string, string>;\n /** The first letter of a line being made with taps or the keyboard. */\n declare protected anchor: Cell | null;\n /** The clue pressed: the next line is saved for it. */\n declare protected clue: string | null;\n declare protected status: string;\n #press: Press | null = null;\n #grid: { readonly value: string; readonly rows: readonly (readonly string[])[] } = { value: '', rows: [] };\n readonly #roving: RovingFocus;\n\n constructor() {\n super();\n this.lines = new Map();\n this.anchor = null;\n this.clue = null;\n this.status = '';\n const element = this;\n this.#roving = new RovingFocus(this, {\n count: () => this.#size ** 2,\n item: (i) => this.renderRoot.querySelector<HTMLElement>(`[data-cell=\"${i}\"]`),\n axis: 'grid',\n get columns() {\n return element.#size;\n },\n });\n }\n\n get slotIds(): readonly string[] {\n return this.#entries.map((entry) => entry.id);\n }\n\n getAnswers(): Answers {\n return Object.fromEntries(this.lines);\n }\n\n /** Spans the element can show: a straight line in the grid, for a listed word one that spells it. */\n setAnswers(answers: Answers): void {\n const next = new Map(this.lines);\n for (const entry of this.#entries) {\n const span = answers[entry.id];\n if (span === undefined) continue;\n next.delete(entry.id);\n const ends = parseSpan(span);\n const cells = ends === null ? null : lineCells(ends[0], ends[1], this.#size);\n if (cells !== null && (entry.clue || this.#spells(cells, entry.letters))) next.set(entry.id, span);\n }\n this.lines = next;\n this.anchor = null;\n this.clue = null;\n this.status = '';\n }\n\n units(): Units {\n return { answered: this.lines.size, total: this.#entries.length };\n }\n\n protected override render(): TemplateResult {\n const ui = this.uiLanguage;\n const rows = this.#rows;\n const size = rows.length;\n const entries = this.#entries;\n const first = this.#press?.from ?? this.anchor;\n const marked = new Set(\n [...this.lines.values()].flatMap((span) => this.#cells(span).map(([r, c]) => r * size + c)),\n );\n const group = this.groupVerdict;\n const say = (key: string, params?: MessageParams) => this.t(key, params);\n return html`<fieldset part=\"word-search\">\n <legend part=\"prompt\">\n <slot class=\"prompt-slot\"></slot>\n <span class=\"hint\" lang=${ui.lang} dir=${ui.dir}>${this.#withClues('ui.hint')}</span>\n </legend>\n <div class=\"board\">\n <div class=\"field\">\n <div class=\"paper\">\n <svg class=\"lines\" part=\"line\" viewBox=\"0 0 ${size} ${size}\" preserveAspectRatio=\"none\" aria-hidden=\"true\" focusable=\"false\">\n ${this.#strokes()}\n </svg>\n <div\n class=\"grid\"\n part=\"grid\"\n role=\"grid\"\n lang=${ui.lang}\n aria-label=${this.t('ui.grid', { size })}\n aria-describedby=\"instructions\"\n aria-disabled=${this.disabled ? 'true' : nothing}\n tabindex=${this.disabled ? '0' : nothing}\n @pointerdown=${this.#down}\n @pointermove=${this.#move}\n @pointerup=${this.#up}\n @pointercancel=${this.#lost}\n @lostpointercapture=${this.#lost}\n @keydown=${this.#keydown}\n >\n ${rows.map(\n (row, r) => html`<div class=\"row\" role=\"row\">\n ${row.map((letter, c) => {\n const i = r * size + c;\n const state =\n first !== null && same(first, [r, c]) ? 'first' : marked.has(i) ? 'marked' : 'other';\n return html`<div\n class=\"cell\"\n part=\"cell\"\n role=\"gridcell\"\n data-cell=${i}\n tabindex=${this.disabled ? nothing : this.#roving.tabIndex(i)}\n aria-label=${this.t('ui.cell', { letter, row: r + 1, column: c + 1, state })}\n ?data-first=${state === 'first'}\n >${letter}</div>`;\n })}\n </div>`,\n )}\n </div>\n </div>\n <p class=\"status\" part=\"status\" lang=${ui.lang} dir=${ui.dir} ?hidden=${this.status === ''}>${this.status}</p>\n </div>\n <ul class=\"words\" part=\"words\" role=\"list\" aria-label=${this.t('ui.words')}>\n ${entries.map((entry, i) => this.#renderEntry(entry, i))}\n </ul>\n </div>\n <span class=\"astl-vh\" id=\"instructions\" lang=${ui.lang} dir=${ui.dir}>${this.t('ui.instructions')}</span>\n <span class=\"astl-vh\" id=\"list-help\" lang=${ui.lang} dir=${ui.dir}>${this.t('ui.listHelp')}</span>\n ${\n group === null\n ? nothing\n : html`<p class=\"group-verdict\" part=\"verdict\" data-verdict=${group}>${renderVerdict(group, say, ui)}</p>`\n }\n </fieldset>`;\n }\n\n #renderEntry(entry: Entry, i: number): TemplateResult {\n const ui = this.uiLanguage;\n const line = this.lines.get(entry.id);\n // Marked one by one, a word not found shows \"no answer\" (dotted), as in every type.\n const marked = Object.keys(this.feedback?.slots ?? {}).length > 0;\n const verdict =\n (line === undefined ? (marked ? 'empty' : null) : this.slotVerdict(entry.id)) ?? undefined;\n const correct = this.solution?.[entry.id];\n const solution =\n correct === undefined || (line !== undefined && sameLine(line, correct)) ? null : correct;\n const state = entry.clue ? (line ? 'ui.marked' : 'ui.notMarked') : line ? 'ui.found' : 'ui.notFound';\n const refs = [verdict && `verdict-${i}`, solution && `solution-${i}`, this.disabled ? '' : 'list-help'];\n return html`<li\n class=\"entry astl-box astl-ring\"\n part=\"word\"\n data-item=${entry.id}\n data-palette=${ifDefined(line === undefined ? undefined : (i % 8) + 1)}\n data-verdict=${ifDefined(verdict)}\n ?data-marked=${line !== undefined}\n ?data-picked=${this.clue === entry.id}\n >\n <button\n type=\"button\"\n data-item=${entry.id}\n ?data-clue=${entry.clue}\n aria-pressed=${entry.clue ? String(this.clue === entry.id) : nothing}\n aria-describedby=${refs.filter(Boolean).join(' ') || nothing}\n ?disabled=${this.disabled}\n @click=${() => this.#pressEntry(entry)}\n >\n <span class=\"sign\" aria-hidden=\"true\"\n >${line === undefined ? nothing : html`<svg viewBox=\"0 0 20 20\">${MARKED}</svg>`}</span\n ><span class=\"text\"><slot data-item=${entry.id}></slot></span\n ><span class=\"astl-vh\" lang=${ui.lang} dir=${ui.dir}>, ${this.t(state)}</span>\n </button>\n ${\n verdict === undefined\n ? nothing\n : renderVerdict(verdict, (key, params) => this.t(key, params), {\n hiddenWord: true,\n id: `verdict-${i}`,\n part: 'verdict',\n ...ui,\n })\n }\n ${solution === null ? nothing : this.#renderSolution(solution, i, entry.clue)}\n </li>`;\n }\n\n /** \"Correct answer: KOT, row 2, column 3 to row 2, column 5\": where the word is, and for a clue the word itself. */\n #renderSolution(span: string, i: number, clue: boolean): TemplateResult {\n const ui = this.uiLanguage;\n const [[fromRow, fromColumn], [toRow, toColumn]] = parseSpan(span) as readonly [Cell, Cell];\n const params = {\n clue: clue ? 'yes' : 'no',\n word: this.#letters(this.#cells(span)),\n fromRow: fromRow + 1,\n fromColumn: fromColumn + 1,\n toRow: toRow + 1,\n toColumn: toColumn + 1,\n };\n return html`<p class=\"astl-solution\" part=\"solution\" id=\"solution-${i}\" data-span=${span} lang=${ui.lang} dir=${ui.dir}\n >${verdictIcon('correct')}<span class=\"astl-solution-label\">${this.t('ui.solution', params)}</span></p\n >`;\n }\n\n /** Saved lines, the solutions not shown by them, then the line being made. */\n #strokes(): TemplateResult {\n const line = (span: string, kind: string, entry?: string, palette?: number) => {\n const ends = parseSpan(span);\n if (ends === null) return nothing;\n const [[r1, c1], [r2, c2]] = ends;\n const ends2 = { x1: c1 + 0.5, y1: r1 + 0.5, x2: c2 + 0.5, y2: r2 + 0.5 };\n // The edge, then the fill over it: a loop round the letters.\n return svg`<line class=${kind} data-span=${span} data-item=${ifDefined(entry)} data-palette=${ifDefined(palette)} x1=${ends2.x1} y1=${ends2.y1} x2=${ends2.x2} y2=${ends2.y2}></line><line class=\"${kind} fill\" data-palette=${ifDefined(palette)} x1=${ends2.x1} y1=${ends2.y1} x2=${ends2.x2} y2=${ends2.y2}></line>`;\n };\n // A solution is a dot behind each of its letters: a pattern apart from the strokes students draw.\n const dots = (span: string) =>\n svg`<g class=\"solution\" data-span=${span}>${this.#cells(span).map(\n ([r, c]) => svg`<circle cx=${c + 0.5} cy=${r + 0.5} r=\"0.4\"></circle>`,\n )}</g>`;\n const entries = this.#entries;\n const press = this.#press;\n const active = this.#cellOf(this.#roving.active);\n const from = press?.from ?? this.anchor;\n const to = press?.to ?? active;\n const draft = from !== null && lineCells(from, to, this.#size) !== null ? formatSpan(from, to) : null;\n return svg`${entries.map((entry, i) => {\n const span = this.lines.get(entry.id);\n return span === undefined ? nothing : line(span, 'found', entry.id, (i % 8) + 1);\n })}${entries.map((entry) => {\n const correct = this.solution?.[entry.id];\n const span = this.lines.get(entry.id);\n return correct === undefined || (span !== undefined && sameLine(span, correct))\n ? nothing\n : dots(correct);\n })}${draft === null ? nothing : line(draft, 'draft')}`;\n }\n\n protected override updated(): void {\n // Manual slot assignment: the view's light DOM is projected as is, never moved or rewritten.\n const root = this.renderRoot as ShadowRoot;\n const prompt = Array.from(this.children).find((child) => child.localName === 'astl-prompt');\n root.querySelector<HTMLSlotElement>('slot.prompt-slot')?.assign(...(prompt ? [prompt] : []));\n const items = new Map(this.#entries.map((entry) => [entry.id, entry.el]));\n for (const slot of root.querySelectorAll<HTMLSlotElement>('slot[data-item]')) {\n const item = items.get(slot.dataset.item ?? '');\n slot.assign(...(item ? [item] : []));\n }\n // Through the CSSOM, which a strict Content Security Policy allows (an inline style attribute it blocks).\n root.querySelector<HTMLElement>('.board')?.style.setProperty('--astl-ws-size', `${this.#size}`);\n }\n\n // The grid and the list\n\n get #rows(): readonly (readonly string[])[] {\n const value = this.getAttribute('grid') ?? '';\n if (value !== this.#grid.value) {\n this.#grid = {\n value,\n rows: value\n .split(' ')\n .filter((row) => row !== '')\n .map((row) => [...row]),\n };\n }\n return this.#grid.rows;\n }\n\n get #size(): number {\n return this.#rows.length;\n }\n\n get #entries(): readonly Entry[] {\n return Array.from(this.children)\n .filter((child): child is HTMLElement => child.localName === 'astl-search-word' && child.id !== '')\n .map((el) => {\n const clue = el.hasAttribute('clue');\n return { id: el.id, el, clue, letters: clue ? '' : textOf(el) };\n });\n }\n\n #cellOf(index: number): Cell {\n const size = Math.max(1, this.#size);\n return [Math.floor(index / size), index % size];\n }\n\n #cells(span: string): readonly Cell[] {\n const ends = parseSpan(span);\n return (ends === null ? null : lineCells(ends[0], ends[1], this.#size)) ?? [];\n }\n\n #letters(cells: readonly Cell[]): string {\n return cells.map(([r, c]) => this.#rows[r]?.[c] ?? '').join('');\n }\n\n #spells(cells: readonly Cell[], word: string): boolean {\n const letters = this.#letters(cells);\n return word !== '' && (letters === word || [...letters].reverse().join('') === word);\n }\n\n // Marking lines\n\n /** The cell under a pointer, or (`clamp`) the nearest one; null outside the grid. */\n #hit(event: PointerEvent, clamp = false): Cell | null {\n const box = (event.currentTarget as HTMLElement).getBoundingClientRect();\n const size = this.#size;\n const row = Math.floor(((event.clientY - box.top) / box.height) * size);\n const column = Math.floor(((event.clientX - box.left) / box.width) * size);\n const inside = (n: number) => n >= 0 && n < size;\n if (!clamp && !(inside(row) && inside(column))) return null;\n const fit = (n: number) => Math.min(Math.max(n, 0), size - 1);\n return [fit(row), fit(column)];\n }\n\n /** A drag from `from` towards `to`, snapped to the nearest of the 8 directions and kept inside the grid. */\n #snap(from: Cell, to: Cell): Cell {\n const dr = to[0] - from[0];\n const dc = to[1] - from[1];\n const [ar, ac] = [Math.abs(dr), Math.abs(dc)];\n const step: Cell =\n ar * 2 < ac ? [0, Math.sign(dc)] : ac * 2 < ar ? [Math.sign(dr), 0] : [Math.sign(dr), Math.sign(dc)];\n let n = step[0] !== 0 && step[1] !== 0 ? Math.round((ar + ac) / 2) : Math.max(ar, ac);\n const last = this.#size - 1;\n const inside = (k: number) =>\n [from[0] + step[0] * k, from[1] + step[1] * k].every((v) => v >= 0 && v <= last);\n while (n > 0 && !inside(n)) n--;\n return [from[0] + step[0] * n, from[1] + step[1] * n];\n }\n\n #down(event: PointerEvent): void {\n if (this.disabled || event.button !== 0 || !event.isPrimary) return;\n const cell = this.#hit(event);\n if (cell === null) return;\n (event.currentTarget as HTMLElement).setPointerCapture(event.pointerId);\n this.#press = { pointer: event.pointerId, from: cell, to: cell };\n this.#roving.focus(cell[0] * this.#size + cell[1]);\n }\n\n #move(event: PointerEvent): void {\n const press = this.#press;\n if (press === null || event.pointerId !== press.pointer) return;\n const to = this.#snap(press.from, this.#hit(event, true) as Cell);\n if (same(to, press.to)) return;\n this.#press = { ...press, to };\n this.requestUpdate();\n }\n\n #up(event: PointerEvent): void {\n const press = this.#press;\n if (press === null || event.pointerId !== press.pointer) return;\n this.#press = null;\n if (same(press.from, press.to)) this.#tap(press.from);\n else {\n this.anchor = null;\n this.#complete(press.from, press.to);\n }\n this.requestUpdate();\n }\n\n #lost(event: PointerEvent): void {\n if (this.#press?.pointer !== event.pointerId) return;\n this.#press = null;\n this.requestUpdate();\n }\n\n #keydown(event: KeyboardEvent): void {\n if (this.disabled) return;\n if (event.key === 'Enter' || event.key === ' ') {\n event.preventDefault();\n if (!event.repeat) this.#tap(this.#cellOf(this.#roving.active));\n } else if (event.key === 'Escape' && (this.anchor !== null || this.clue !== null)) {\n // The first letter goes first, then the clue chosen.\n event.preventDefault();\n if (this.anchor !== null) this.anchor = null;\n else this.clue = null;\n this.#say('cancel');\n } else this.#roving.keydown(event);\n }\n\n /** A first letter, then a last one; the same letter again cancels. */\n #tap(cell: Cell): void {\n const anchor = this.anchor;\n if (anchor === null) {\n this.anchor = cell;\n const letter = this.#letters([cell]);\n this.#say('first', { letter, row: cell[0] + 1, column: cell[1] + 1 });\n } else if (same(anchor, cell)) {\n this.anchor = null;\n this.#say('cancel');\n } else {\n this.anchor = null;\n this.#complete(anchor, cell);\n }\n }\n\n /** A line from `from` to `to`: saved for the pressed clue, else matched against the listed words not found yet. */\n #complete(from: Cell, to: Cell): void {\n const cells = lineCells(from, to, this.#size);\n if (cells === null) {\n this.#say('notStraight');\n return;\n }\n const span = formatSpan(from, to);\n const entries = this.#entries;\n const clue = entries.find((entry) => entry.id === this.clue);\n if (clue !== undefined) {\n this.clue = null;\n this.#set(clue.id, span);\n this.#say('saved', { clue: nameOf(clue.el), ...this.#progress() });\n return;\n }\n const word = entries.find((entry) => !entry.clue && this.#spells(cells, entry.letters));\n if (word === undefined) {\n this.#say('none', { letters: this.#letters(cells) });\n } else if (this.lines.has(word.id)) {\n this.#say('again', { word: word.letters });\n } else {\n this.#set(word.id, span);\n this.#say('found', { word: word.letters, ...this.#progress() });\n }\n }\n\n /** A found word or a marked clue is released; a clue is pressed or let go; a word not found yet gets a hint. */\n #pressEntry(entry: Entry): void {\n if (this.disabled) return;\n if (this.lines.has(entry.id)) {\n this.#set(entry.id, '');\n this.#say('released', { word: entry.clue ? nameOf(entry.el) : entry.letters, ...this.#progress() });\n } else if (!entry.clue) {\n this.#say('find', { word: entry.letters });\n } else if (this.clue === entry.id) {\n this.clue = null;\n this.#say('cancel');\n } else {\n this.clue = entry.id;\n this.anchor = null;\n this.#say('clue', { clue: nameOf(entry.el) });\n // On to the letters: keyboard users mark the word next.\n this.#roving.focus(this.#roving.active);\n }\n }\n\n /** Sets (or with '' clears) the line of an entry and reports it. */\n #set(id: string, span: string): void {\n const next = new Map(this.lines);\n if (span === '') next.delete(id);\n else next.set(id, span);\n this.lines = next;\n this.emitChange({ [id]: span });\n }\n\n #progress(): { readonly count: number; readonly total: number } {\n return { count: this.lines.size, total: this.#entries.length };\n }\n\n /** A message, followed by how to mark a clue's word when the list has clues. */\n #withClues(key: string, params?: MessageParams): string {\n const message = this.t(key, params);\n return this.#entries.some((entry) => entry.clue) ? `${message} ${this.t('ui.hintClues')}` : message;\n }\n\n /** Shows a message in the status line and announces it; a line that spells no word also says how clues work. */\n #say(key: string, params?: MessageParams): void {\n this.status =\n key === 'none' ? this.#withClues('ui.status.none', params) : this.t(`ui.status.${key}`, params);\n this.announce(this.status);\n }\n}\n\nexport const wordSearchElement: ElementRegistration = {\n manifest: wordSearchManifest,\n element: WordSearchElement,\n messages: wordSearchUiMessages,\n};\n"],"mappings":"A,iSAIA,IAAMwB,EAAY,mBAMLC,EAAkD,CAC7D,CAAE,YAAW,OAAQ,KAAM,SAAUzB,CAAG,EACxC,CAAE,YAAW,OAAQ,KAAM,SAAUC,CAAG,CAC1C,ECsBMyB,EAAU,IAAyBC,EAAG,aAAe,GAAA,CAAI,QAAQ,OAAQ,GAAG,CAAC,CAAC,KAAK,EAEnFC,EAAU,GACdF,EAAOC,CAAE,GACT,CAAC,GAAGA,EAAG,iBAAiB,KAAK,CAAC,CAAC,CAC5B,IAAK,GAAQE,EAAI,GAAG,CAAC,CACrB,KAAK,GAAG,CAAC,CACT,KAAK,EACJC,GAAQ,EAAS,IAAqBC,EAAE,KAAOzB,EAAE,IAAMyB,EAAE,KAAOzB,EAAE,GAExE,SAAS0B,EAAS,EAAW,EAAoB,CAC/C,IAAMC,EAAOb,EAAUd,CAAC,EACxB,OAAOyB,IAAMzB,GAAM2B,IAAS,MAAQF,IAAMV,EAAWY,EAAK,GAAIA,EAAK,EAAE,CACvE,CAEA,IAAMC,EAAS,CAAG,qFAaLC,EAAb,cAAuCtB,CAAY,CACjD,OAAgB,SAA8BM,EAC9C,OAAgB,SAAsCM,EACtD,OAAgB,kBAAoC,CAClD,GAAGvB,E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