@astl/astrolabe 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +119 -0
- package/LICENSE +202 -0
- package/README.md +64 -2
- package/dist/cdn/astrolabe-editor.js +1441 -0
- package/dist/cdn/astrolabe-editor.js.map +1 -0
- package/dist/cdn/astrolabe-player.js +2 -0
- package/dist/cdn/astrolabe-player.js.map +1 -0
- package/dist/cdn/astrolabe.css +238 -0
- package/dist/cdn/astrolabe.js +3 -0
- package/dist/cdn/astrolabe.js.map +1 -0
- package/dist/cdn/astrolabe.standalone.js +8007 -0
- package/dist/cdn/chunks/audio-B0LSIn5N.js +48 -0
- package/dist/cdn/chunks/audio-B0LSIn5N.js.map +1 -0
- package/dist/cdn/chunks/audio-manifest-B9FWQzRy.js +2 -0
- package/dist/cdn/chunks/audio-manifest-B9FWQzRy.js.map +1 -0
- package/dist/cdn/chunks/block-styles-CKo9x7Vt.js +68 -0
- package/dist/cdn/chunks/block-styles-CKo9x7Vt.js.map +1 -0
- package/dist/cdn/chunks/book-CHzDDaim.js +15 -0
- package/dist/cdn/chunks/book-CHzDDaim.js.map +1 -0
- package/dist/cdn/chunks/callout-QFLFLPc5.js +49 -0
- package/dist/cdn/chunks/callout-QFLFLPc5.js.map +1 -0
- package/dist/cdn/chunks/callout-manifest-Cb12O4jl.js +2 -0
- package/dist/cdn/chunks/callout-manifest-Cb12O4jl.js.map +1 -0
- package/dist/cdn/chunks/categorise-BO2tNVJ3.js +203 -0
- package/dist/cdn/chunks/categorise-BO2tNVJ3.js.map +1 -0
- package/dist/cdn/chunks/categorise-manifest-C_hEDVYQ.js +2 -0
- package/dist/cdn/chunks/categorise-manifest-C_hEDVYQ.js.map +1 -0
- package/dist/cdn/chunks/chip-styles-Dme5daTO.js +77 -0
- package/dist/cdn/chunks/chip-styles-Dme5daTO.js.map +1 -0
- package/dist/cdn/chunks/choice-CExBvqKj.js +136 -0
- package/dist/cdn/chunks/choice-CExBvqKj.js.map +1 -0
- package/dist/cdn/chunks/choice-manifest-C-XahD7m.js +2 -0
- package/dist/cdn/chunks/choice-manifest-C-XahD7m.js.map +1 -0
- package/dist/cdn/chunks/color-control-Cl5cuMSO.js +91 -0
- package/dist/cdn/chunks/color-control-Cl5cuMSO.js.map +1 -0
- package/dist/cdn/chunks/crossword-Cb-a3Tjj.js +270 -0
- package/dist/cdn/chunks/crossword-Cb-a3Tjj.js.map +1 -0
- package/dist/cdn/chunks/crossword-manifest-2qlu7AYd.js +2 -0
- package/dist/cdn/chunks/crossword-manifest-2qlu7AYd.js.map +1 -0
- package/dist/cdn/chunks/declarations-BhqOz1ap.js +2 -0
- package/dist/cdn/chunks/declarations-BhqOz1ap.js.map +1 -0
- package/dist/cdn/chunks/definitions-CNX90WtL.js +6 -0
- package/dist/cdn/chunks/definitions-CNX90WtL.js.map +1 -0
- package/dist/cdn/chunks/directive-helpers-D7lOZKnB.js +14 -0
- package/dist/cdn/chunks/directive-helpers-D7lOZKnB.js.map +1 -0
- package/dist/cdn/chunks/drop-manifest-bzNOa5ks.js +2 -0
- package/dist/cdn/chunks/drop-manifest-bzNOa5ks.js.map +1 -0
- package/dist/cdn/chunks/drop-vRXndjHu.js +86 -0
- package/dist/cdn/chunks/drop-vRXndjHu.js.map +1 -0
- package/dist/cdn/chunks/flash-cards-0NrrKdrx.js +87 -0
- package/dist/cdn/chunks/flash-cards-0NrrKdrx.js.map +1 -0
- package/dist/cdn/chunks/flash-cards-manifest-B8nWXbRy.js +2 -0
- package/dist/cdn/chunks/flash-cards-manifest-B8nWXbRy.js.map +1 -0
- package/dist/cdn/chunks/gap-lor-khst.js +78 -0
- package/dist/cdn/chunks/gap-lor-khst.js.map +1 -0
- package/dist/cdn/chunks/gap-manifest-RSydA41N.js +2 -0
- package/dist/cdn/chunks/gap-manifest-RSydA41N.js.map +1 -0
- package/dist/cdn/chunks/help-C-woafz5.js +138 -0
- package/dist/cdn/chunks/help-C-woafz5.js.map +1 -0
- package/dist/cdn/chunks/help-form-DaC6KaFG.js +160 -0
- package/dist/cdn/chunks/help-form-DaC6KaFG.js.map +1 -0
- package/dist/cdn/chunks/hotspot-manifest-CNs1oiZ_.js +2 -0
- package/dist/cdn/chunks/hotspot-manifest-CNs1oiZ_.js.map +1 -0
- package/dist/cdn/chunks/hotspot-oel1Eelo.js +154 -0
- package/dist/cdn/chunks/hotspot-oel1Eelo.js.map +1 -0
- package/dist/cdn/chunks/image-drop-Dkprw0Kn.js +295 -0
- package/dist/cdn/chunks/image-drop-Dkprw0Kn.js.map +1 -0
- package/dist/cdn/chunks/image-drop-manifest-BZ6hCoAd.js +2 -0
- package/dist/cdn/chunks/image-drop-manifest-BZ6hCoAd.js.map +1 -0
- package/dist/cdn/chunks/image-label-Dm5shQSh.js +177 -0
- package/dist/cdn/chunks/image-label-Dm5shQSh.js.map +1 -0
- package/dist/cdn/chunks/image-label-manifest--1CLRJzd.js +2 -0
- package/dist/cdn/chunks/image-label-manifest--1CLRJzd.js.map +1 -0
- package/dist/cdn/chunks/inline-styles-CTgXWnHb.js +80 -0
- package/dist/cdn/chunks/inline-styles-CTgXWnHb.js.map +1 -0
- package/dist/cdn/chunks/insert-menu-LgrifBYT.js +80 -0
- package/dist/cdn/chunks/insert-menu-LgrifBYT.js.map +1 -0
- package/dist/cdn/chunks/issue-list-BgnXzXRM.js +51 -0
- package/dist/cdn/chunks/issue-list-BgnXzXRM.js.map +1 -0
- package/dist/cdn/chunks/keys-DU-Qknmz.js +2 -0
- package/dist/cdn/chunks/keys-DU-Qknmz.js.map +1 -0
- package/dist/cdn/chunks/live-jdiyYln2.js +7 -0
- package/dist/cdn/chunks/live-jdiyYln2.js.map +1 -0
- package/dist/cdn/chunks/long-answer-CtzClLAx.js +71 -0
- package/dist/cdn/chunks/long-answer-CtzClLAx.js.map +1 -0
- package/dist/cdn/chunks/long-answer-manifest-BYJpZRtB.js +2 -0
- package/dist/cdn/chunks/long-answer-manifest-BYJpZRtB.js.map +1 -0
- package/dist/cdn/chunks/mark-words-CpH3gTcX.js +131 -0
- package/dist/cdn/chunks/mark-words-CpH3gTcX.js.map +1 -0
- package/dist/cdn/chunks/mark-words-manifest-Cs2pXCEx.js +2 -0
- package/dist/cdn/chunks/mark-words-manifest-Cs2pXCEx.js.map +1 -0
- package/dist/cdn/chunks/match-DKE_4o-x.js +352 -0
- package/dist/cdn/chunks/match-DKE_4o-x.js.map +1 -0
- package/dist/cdn/chunks/match-manifest-D0UfoajU.js +2 -0
- package/dist/cdn/chunks/match-manifest-D0UfoajU.js.map +1 -0
- package/dist/cdn/chunks/memory-B6hSyHyz.js +187 -0
- package/dist/cdn/chunks/memory-B6hSyHyz.js.map +1 -0
- package/dist/cdn/chunks/memory-manifest-D1589iR0.js +2 -0
- package/dist/cdn/chunks/memory-manifest-D1589iR0.js.map +1 -0
- package/dist/cdn/chunks/menu-messages-Dx3jYUEp.js +2 -0
- package/dist/cdn/chunks/menu-messages-Dx3jYUEp.js.map +1 -0
- package/dist/cdn/chunks/messages-9xiYDvRT.js +2 -0
- package/dist/cdn/chunks/messages-9xiYDvRT.js.map +1 -0
- package/dist/cdn/chunks/option-styles-WKzjKmCH.js +50 -0
- package/dist/cdn/chunks/option-styles-WKzjKmCH.js.map +1 -0
- package/dist/cdn/chunks/order-BhG_6IC-.js +225 -0
- package/dist/cdn/chunks/order-BhG_6IC-.js.map +1 -0
- package/dist/cdn/chunks/order-manifest-J5IXN0he.js +2 -0
- package/dist/cdn/chunks/order-manifest-J5IXN0he.js.map +1 -0
- package/dist/cdn/chunks/pick-and-place-DVQIPYuL.js +2 -0
- package/dist/cdn/chunks/pick-and-place-DVQIPYuL.js.map +1 -0
- package/dist/cdn/chunks/picture-D10YRMYH.js +2 -0
- package/dist/cdn/chunks/picture-D10YRMYH.js.map +1 -0
- package/dist/cdn/chunks/picture-view-BKnAyScQ.js +92 -0
- package/dist/cdn/chunks/picture-view-BKnAyScQ.js.map +1 -0
- package/dist/cdn/chunks/repeat-CY2W2URZ.js +8 -0
- package/dist/cdn/chunks/repeat-CY2W2URZ.js.map +1 -0
- package/dist/cdn/chunks/roving-focus-BxGgi2DD.js +2 -0
- package/dist/cdn/chunks/roving-focus-BxGgi2DD.js.map +1 -0
- package/dist/cdn/chunks/runtime-DxAbpr3S.js +526 -0
- package/dist/cdn/chunks/runtime-DxAbpr3S.js.map +1 -0
- package/dist/cdn/chunks/scan-jWgPnVxA.js +2 -0
- package/dist/cdn/chunks/scan-jWgPnVxA.js.map +1 -0
- package/dist/cdn/chunks/select-DTA3dJzr.js +345 -0
- package/dist/cdn/chunks/select-DTA3dJzr.js.map +1 -0
- package/dist/cdn/chunks/select-manifest-BBMbvdkH.js +2 -0
- package/dist/cdn/chunks/select-manifest-BBMbvdkH.js.map +1 -0
- package/dist/cdn/chunks/source-view-DXKPFCl9.js +29 -0
- package/dist/cdn/chunks/source-view-DXKPFCl9.js.map +1 -0
- package/dist/cdn/chunks/style-form-D5haJtWM.js +240 -0
- package/dist/cdn/chunks/style-form-D5haJtWM.js.map +1 -0
- package/dist/cdn/chunks/style-messages-BbZpeD2a.js +2 -0
- package/dist/cdn/chunks/style-messages-BbZpeD2a.js.map +1 -0
- package/dist/cdn/chunks/style-model-ZXNe_c8R.js +2 -0
- package/dist/cdn/chunks/style-model-ZXNe_c8R.js.map +1 -0
- package/dist/cdn/chunks/style-placing-DPw1zyrz.js +2 -0
- package/dist/cdn/chunks/style-placing-DPw1zyrz.js.map +1 -0
- package/dist/cdn/chunks/style-popups-BobgX1WK.js +74 -0
- package/dist/cdn/chunks/style-popups-BobgX1WK.js.map +1 -0
- package/dist/cdn/chunks/style-rules-D45PZLCv.js +136 -0
- package/dist/cdn/chunks/style-rules-D45PZLCv.js.map +1 -0
- package/dist/cdn/chunks/styled-Dmx5Yjv7.js +57 -0
- package/dist/cdn/chunks/styled-Dmx5Yjv7.js.map +1 -0
- package/dist/cdn/chunks/styles-DxJJxVNH.js +136 -0
- package/dist/cdn/chunks/styles-DxJJxVNH.js.map +1 -0
- package/dist/cdn/chunks/surface-CgxfAwCR.js +1019 -0
- package/dist/cdn/chunks/surface-CgxfAwCR.js.map +1 -0
- package/dist/cdn/chunks/true-false-DP3MO599.js +146 -0
- package/dist/cdn/chunks/true-false-DP3MO599.js.map +1 -0
- package/dist/cdn/chunks/true-false-manifest-B4exv60u.js +2 -0
- package/dist/cdn/chunks/true-false-manifest-B4exv60u.js.map +1 -0
- package/dist/cdn/chunks/video-j9MCH6Kw.js +98 -0
- package/dist/cdn/chunks/video-j9MCH6Kw.js.map +1 -0
- package/dist/cdn/chunks/video-manifest-8OwkhhAI.js +2 -0
- package/dist/cdn/chunks/video-manifest-8OwkhhAI.js.map +1 -0
- package/dist/cdn/chunks/word-bank-ARjwUKZf.js +80 -0
- package/dist/cdn/chunks/word-bank-ARjwUKZf.js.map +1 -0
- package/dist/cdn/chunks/word-bank-manifest-C1FSo1kH.js +2 -0
- package/dist/cdn/chunks/word-bank-manifest-C1FSo1kH.js.map +1 -0
- package/dist/cdn/chunks/word-search-AHvM7yCJ.js +274 -0
- package/dist/cdn/chunks/word-search-AHvM7yCJ.js.map +1 -0
- package/dist/cdn/chunks/word-search-manifest-Fg1a59Z1.js +2 -0
- package/dist/cdn/chunks/word-search-manifest-Fg1a59Z1.js.map +1 -0
- package/dist/editor.d.ts +32 -0
- package/dist/editor.d.ts.map +1 -0
- package/dist/editor.js +51 -0
- package/dist/editor.js.map +1 -0
- package/dist/engine.d.ts +33 -0
- package/dist/engine.d.ts.map +1 -0
- package/dist/engine.js +53 -0
- package/dist/engine.js.map +1 -0
- package/dist/player.d.ts +19 -0
- package/dist/player.d.ts.map +1 -0
- package/dist/player.js +22 -0
- package/dist/player.js.map +1 -0
- package/dist/server.d.ts +8 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +8 -0
- package/dist/server.js.map +1 -0
- package/package.json +70 -3
- package/src/bundles/astrolabe-editor.ts +11 -0
- package/src/bundles/astrolabe-player.ts +10 -0
- package/src/bundles/astrolabe-standalone.ts +23 -0
- package/src/bundles/astrolabe.ts +12 -0
- package/src/editor.ts +98 -0
- package/src/engine.ts +59 -0
- package/src/player.ts +23 -0
- package/src/server.ts +7 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"help-C-woafz5.js","names":["en","pl","nothing","b","i","helpPolicy","A","FEEDBACK_VARIANTS","runtime","inertStyles","PLAYER_NAMESPACE","CheckerError","createI18n","renderVerdict","cleanContent","playerMessages","D","helpMessages","COST","readHelp","words","el","name","hints","w","written","feedback","v","explanation","readContent","template","content","holder","live","isFeedback","own","record","id","overall","verdicts","isCount","anchorOf","anchor","element","PLACING","place","value","box","float","mountHelp","host","policy","controller","help","practice","t","locale","adoptHelpSheet","rows","after","row","extra","entry","owner","offer","field","inline","manifest","n","page","index","shown","apply","result","response","only","g","update","view","ask","checker","hint","error","code","problemText","active","focused","message","open","next","cost","costId","check","shows","unsubscribe","change","r","changed","helpSheet","root"],"sources":["../../../../player/src/messages/help/en.json","../../../../player/src/messages/help/pl.json","../../../../player/src/player/help.ts"],"sourcesContent":["{\n \"help.label\": \"Help with this question\",\n \"help.labelField\": \"Help with field {n}\",\n \"help.labelPage\": \"Help with this page\",\n \"help.hint\": \"Hint ({n}/{total})\",\n \"help.hintCost\": \"Costs {percent}% of the points\",\n \"help.hintItem\": \"Hint {n}\",\n \"help.hintAnnounce\": \"Hint {n}: {text}\",\n \"help.check\": \"this question\",\n \"help.checkField\": \"field {n}\",\n \"help.why\": \"Why?\",\n \"error.hints_not_allowed\": \"Hints are not available in this exercise.\",\n \"error.hints_exhausted\": \"There are no more hints.\"\n}\n","{\n \"help.label\": \"Pomoc do tego pytania\",\n \"help.labelField\": \"Pomoc do pola {n}\",\n \"help.labelPage\": \"Pomoc do tej strony\",\n \"help.hint\": \"Podpowiedź ({n}/{total})\",\n \"help.hintCost\": \"Kosztuje {percent}% punktów\",\n \"help.hintItem\": \"Podpowiedź {n}\",\n \"help.hintAnnounce\": \"Podpowiedź {n}: {text}\",\n \"help.check\": \"to pytanie\",\n \"help.checkField\": \"pole {n}\",\n \"help.why\": \"Dlaczego?\",\n \"error.hints_not_allowed\": \"W tym zadaniu nie ma podpowiedzi.\",\n \"error.hints_exhausted\": \"Nie ma już więcej podpowiedzi.\"\n}\n","/**\n * Help for students in the player, in a module of its own: only a view that offers help (`hasHelp`) loads it, and\n * without it (or when its chunk fails) the exercise plays without help.\n *\n * Under each graded interaction that offers help (after the block holding it, for one in a line of text), and at the\n * foot of each page with help of its own, a row:\n * - \"Podpowiedź (1/2)\", one hint at a time from the checker, the cost of the next one said before it is used;\n * - \"Sprawdź\" for that interaction alone (practice with `checkScope: 'interaction'`), counted like any check;\n * - the feedback text of the last verdict, in a box of the verdict's colour and edge;\n * - \"Dlaczego?\", a disclosure with the explanation.\n * The texts come with check and submit responses as the policy says (`helpShown` in the engine); the view only says\n * what there is (`HELP_ATTRIBUTES`). A row next to a floated or placed interaction floats with it, below it.\n *\n * What a checker sends is read as hostile, like a view: counts are checked and the HTML is cleaned like view content.\n */\nimport {\n type AttemptPolicy,\n type Checker,\n CheckerError,\n type CheckResponse,\n type ComponentManifest,\n createI18n,\n type ElementHelp,\n FEEDBACK_VARIANTS,\n type Feedback,\n type GradeResult,\n type GroupVerdict,\n helpPolicy,\n inertStyles,\n type MessageCatalog,\n type PlayerElementApi,\n type SubmitResponse,\n type Translate,\n type UrlPolicy,\n} from '@astl/core';\nimport { css, html, nothing, render, type TemplateResult } from 'lit';\nimport { renderVerdict } from '../a11y.js';\nimport type { AttemptController } from '../attempt/controller.js';\nimport en from '../messages/help/en.json' with { type: 'json' };\nimport pl from '../messages/help/pl.json' with { type: 'json' };\nimport { PLAYER_NAMESPACE, playerMessages } from '../messages.js';\nimport { runtime } from '../runtime.js';\nimport { cleanContent } from './view.js';\n\n/** The help strings of the player namespace: in this module, so a view without help never loads them. */\nexport const helpMessages: readonly MessageCatalog[] = [\n { namespace: PLAYER_NAMESPACE, locale: 'en', messages: en },\n { namespace: PLAYER_NAMESPACE, locale: 'pl', messages: pl },\n];\n\n/** What the player gives the help module: the mounted attempt, and how to check, announce and show problems. */\nexport interface HelpHost {\n readonly controller: AttemptController;\n /** The mounted elements in view order, with their page index. */\n readonly mounted: readonly {\n readonly element: HTMLElement & PlayerElementApi;\n readonly manifest: ComponentManifest;\n readonly page: number;\n }[];\n /** The page elements, in order. */\n readonly pages: readonly HTMLElement[];\n /** The UI locale. */\n readonly locale: string;\n readonly urlPolicy: UrlPolicy;\n /** The player's shadow root, for the module's stylesheet. */\n readonly root: Node;\n checker(): Checker | null;\n /** Checks one interaction through the player, which shows a failure; resolves either way. */\n check(id: string): Promise<unknown>;\n announce(message: string): void;\n}\n\nexport interface Help {\n /** Removes the rows and stops listening. */\n destroy(): void;\n}\n\nconst COST = /^(?:0|1|0?\\.\\d{1,6}|1\\.0{1,6})$/;\n\n/** What a view element offers, from its `HELP_ATTRIBUTES`; null when nothing. Costs outside 0..1 are left out. */\nexport function readHelp(el: Element): ElementHelp | null {\n const words = (name: string) => (el.getAttribute(name) ?? '').split(' ').filter(Boolean);\n const hints = words('hints').flatMap((w) => (COST.test(w) ? [Number(w)] : []));\n const written = new Set(words('feedback'));\n const feedback = FEEDBACK_VARIANTS.filter((v) => written.has(v));\n const explanation = el.hasAttribute('explanation');\n return hints.length === 0 && feedback.length === 0 && !explanation\n ? null\n : { hints, explanation, feedback };\n}\n\n/**\n * Help content from a checker (rich text of format 1) as clean live DOM in a `div`: cleaned in an inert document like\n * a view's content, without components or other custom elements, and without styles (the engine writes none into\n * help; a `style` from elsewhere is parsed under its inert name, so a strict CSP reports nothing, and goes).\n */\nexport function readContent(content: string, urlPolicy: UrlPolicy): HTMLElement {\n const template = document.createElement('template');\n template.innerHTML = inertStyles(content);\n const holder = template.content.ownerDocument.createElement('div');\n holder.append(template.content);\n cleanContent(holder, { manifests: new Map(), urlPolicy }, false, false);\n for (const el of Array.from(holder.querySelectorAll('*'))) if (el.localName.includes('-')) el.remove();\n const live = document.importNode(holder, true);\n live.className = 'help-content';\n return live;\n}\n\nconst isFeedback = (v: unknown): v is Feedback =>\n typeof v === 'object' &&\n v !== null &&\n typeof (v as Feedback).html === 'string' &&\n FEEDBACK_VARIANTS.includes((v as Feedback).variant);\n\nconst own = <T>(record: Readonly<Record<string, T>> | undefined, id: string): T | undefined =>\n typeof record === 'object' && record !== null && Object.hasOwn(record, id) ? record[id] : undefined;\n\n/** The engine's rule for several groups: nothing answered is empty, all right correct, some right partial. */\nfunction overall(verdicts: readonly GroupVerdict[]): GroupVerdict | null {\n if (verdicts.length === 0) return null;\n if (verdicts.every((v) => v === 'empty')) return 'empty';\n if (verdicts.every((v) => v === 'correct')) return 'correct';\n return verdicts.some((v) => v === 'correct' || v === 'partial') ? 'partial' : 'incorrect';\n}\n\nconst isCount = (v: unknown): v is number => Number.isInteger(v) && (v as number) >= 0;\n\ninterface Row {\n /** View element or page id: what the checker's help is keyed by. */\n readonly id: string;\n readonly offer: ElementHelp;\n readonly box: HTMLElement;\n readonly label: string;\n /** The hidden end of the check button's name (\"to pytanie\"); null where there is no check of one interaction. */\n readonly check: string | null;\n /**\n * Its element says its verdict in words itself (a block, right above): the feedback box then keeps the icon beside\n * its text and leaves the word to assistive tech. A field in a line of text shows an icon only, a page nothing.\n */\n readonly ownVerdict: boolean;\n /** Its groups in a result (an element's own, or those it is graded in); empty for a page. */\n readonly groups: readonly string[];\n /** The slots whose change makes its feedback stale. */\n readonly slots: ReadonlySet<string>;\n /** The language and direction of its element: its help is content in that language, the row's labels UI text. */\n readonly lang: string;\n readonly dir: string;\n hints: { readonly n: number; readonly content: HTMLElement }[];\n /** Hints given so far, and how many there are (what the checker says once it was asked). */\n used: number;\n total: number;\n pending: boolean;\n /** Problem code of the last hint request. */\n problem: string | null;\n verdict: GroupVerdict | null;\n feedback: HTMLElement | null;\n explanation: HTMLElement | null;\n}\n\n/** Where an element's row goes: after the block of the page (or column) that holds it. */\nfunction anchorOf(element: Element): Element {\n let anchor = element;\n while (anchor.parentElement !== null && !/^astl-(page|column|doc)$/.test(anchor.parentElement.localName)) {\n anchor = anchor.parentElement;\n }\n return anchor;\n}\n\n/**\n * What a floated or placed block writes of its place: its row takes the same, and clears the float. `margin` brings a\n * centring an author wrote as `margin: 0 auto`, which the style keeps as the four sides.\n */\nconst PLACING = [\n 'float',\n 'width',\n 'inline-size',\n 'max-width',\n 'max-inline-size',\n 'margin',\n 'margin-inline',\n 'margin-inline-start',\n 'margin-inline-end',\n];\n\nfunction place(box: HTMLElement, anchor: Element): void {\n if (!(anchor instanceof HTMLElement)) return;\n for (const name of PLACING) {\n const value = anchor.style.getPropertyValue(name);\n if (value !== '') box.style.setProperty(name, value);\n }\n const float = anchor.style.getPropertyValue('float');\n if (float !== '' && float !== 'none') box.style.setProperty('clear', float);\n}\n\n/** Mounts the rows into a mounted view and keeps them in step with the attempt. */\nexport function mountHelp(host: HelpHost): Help {\n const { controller, locale } = host;\n const policy: AttemptPolicy = controller.policy;\n const help = helpPolicy(policy);\n const practice = policy.mode === 'practice';\n const t: Translate = createI18n({\n catalogs: [...playerMessages, ...helpMessages, ...runtime.catalogs],\n }).translator(locale, PLAYER_NAMESPACE);\n adoptHelpSheet(host.root);\n\n const rows: Row[] = [];\n const after = new Map<Element, Element>();\n const row = (\n owner: Element,\n offer: ElementHelp,\n extra: Pick<Row, 'label' | 'check' | 'ownVerdict' | 'groups' | 'slots'>,\n ) => {\n const box = document.createElement('div');\n box.className = 'astl-help';\n box.setAttribute('part', 'help');\n box.setAttribute('role', 'group');\n box.setAttribute('aria-label', extra.label);\n box.lang = locale;\n const entry: Row = {\n id: owner.id,\n offer,\n box,\n ...extra,\n lang: owner.closest('[lang]')?.getAttribute('lang') ?? '',\n dir: owner.closest('[dir]')?.getAttribute('dir') ?? '',\n hints: [],\n used: 0,\n total: offer.hints.length,\n pending: false,\n problem: null,\n verdict: null,\n feedback: null,\n explanation: null,\n };\n rows.push(entry);\n return entry;\n };\n\n let field = 0;\n for (const { element, manifest } of host.mounted) {\n const inline = manifest.display === 'inline';\n if (inline) field++;\n const offer = manifest.graded ? readHelp(element) : null;\n if (offer === null) continue;\n const n = field;\n const entry = row(element, offer, {\n label: inline ? t('help.labelField', { n }) : t('help.label'),\n check:\n practice && help.checkScope === 'interaction'\n ? inline\n ? t('help.checkField', { n })\n : t('help.check')\n : null,\n ownVerdict: !inline,\n groups: element.groupIds ?? [element.id],\n slots: new Set(element.slotIds),\n });\n const anchor = anchorOf(element);\n (after.get(anchor) ?? anchor).after(entry.box);\n after.set(anchor, entry.box);\n place(entry.box, anchor);\n }\n host.pages.forEach((page, index) => {\n const offer = page.localName === 'astl-page' ? readHelp(page) : null;\n if (offer === null) return;\n const entry = row(page, offer, {\n label: t('help.labelPage'),\n check: null,\n ownVerdict: false,\n groups: [],\n slots: new Set(controller.pages[index]?.slotIds ?? []),\n });\n entry.box.dataset.page = '';\n page.append(entry.box);\n });\n\n const content = (value: unknown, entry: Row): HTMLElement | null => {\n if (typeof value !== 'string') return null;\n const shown = readContent(value, host.urlPolicy);\n if (entry.lang) shown.lang = entry.lang;\n if (entry.dir) shown.dir = entry.dir;\n return shown;\n };\n\n /** Takes in what a response says of the rows it graded (`only`: a check of one interaction). */\n const apply = (response: CheckResponse | SubmitResponse, only: string | null): void => {\n const result: GradeResult | null = response.result;\n if (result === null) return;\n for (const entry of rows) {\n if (only !== null && entry.id !== only) continue;\n const verdicts = result.groups.filter((g) => entry.groups.includes(g.id)).map((g) => g.verdict);\n const graded = entry.groups.length === 0 ? Object.hasOwn(result.pages, entry.id) : verdicts.length > 0;\n if (!graded) continue;\n const feedback = own(response.feedback, entry.id);\n entry.verdict = isFeedback(feedback)\n ? feedback.variant === 'omitted'\n ? 'empty'\n : feedback.variant\n : overall(verdicts);\n entry.feedback = isFeedback(feedback) ? content(feedback.html, entry) : null;\n entry.explanation = content(own(response.explanations, entry.id), entry) ?? entry.explanation;\n }\n };\n\n const update = (): void => {\n for (const entry of rows) render(view(entry), entry.box);\n };\n\n const ask = async (entry: Row): Promise<void> => {\n const checker = host.checker();\n if (entry.pending) return;\n entry.pending = true;\n entry.problem = null;\n update();\n try {\n if (checker?.hint === undefined) throw checker === null ? 'no_checker' : 'hints_not_allowed';\n const hint = await checker.hint({ element: entry.id });\n const index = isCount(hint.index) ? hint.index : entry.used;\n const shown = content(hint.html, entry) as HTMLElement;\n entry.hints = [...entry.hints, { n: index + 1, content: shown }];\n entry.used = index + 1;\n entry.total = isCount(hint.left) ? entry.used + hint.left : Math.max(entry.total, entry.used);\n host.announce(t('help.hintAnnounce', { n: index + 1, text: shown.textContent?.trim() ?? '' }));\n } catch (error) {\n const code =\n error instanceof CheckerError\n ? error.problem.code\n : typeof error === 'string'\n ? error\n : 'internal_error';\n if (code === 'hints_exhausted') entry.total = entry.used;\n entry.problem = code;\n host.announce(problemText(code));\n } finally {\n entry.pending = false;\n const active = host.root instanceof ShadowRoot ? host.root.activeElement : document.activeElement;\n const focused = entry.box.contains(active);\n update();\n // The last hint takes its button away: the focus goes to that hint, not to the page.\n if (focused && entry.used >= entry.total) {\n entry.box.querySelector<HTMLElement>('.help-hints li:last-child')?.focus();\n }\n }\n };\n\n const problemText = (code: string): string => {\n const message = t(`error.${code}`);\n return message === `error.${code}` ? t('error.internal_error') : message;\n };\n\n const view = (entry: Row): TemplateResult | typeof nothing => {\n const open = !controller.readOnly;\n const next = entry.used < entry.total && help.hints && practice && open ? entry.used : null;\n const cost = next === null ? 0 : (entry.offer.hints[next] ?? 0);\n const costId = `astl-help-cost-${rows.indexOf(entry)}`;\n const check = entry.check !== null && open;\n const shows =\n next !== null ||\n check ||\n entry.hints.length > 0 ||\n entry.feedback !== null ||\n entry.explanation !== null;\n entry.box.hidden = !shows && entry.problem === null;\n if (entry.box.hidden) return nothing;\n return html`${\n next === null && !check\n ? nothing\n : html`<div class=\"help-actions\">\n ${\n next === null\n ? nothing\n : html`<span class=\"help-hint\"\n ><button\n type=\"button\"\n class=\"button\"\n aria-describedby=${cost > 0 ? costId : nothing}\n aria-disabled=${entry.pending ? 'true' : nothing}\n @click=${() => void ask(entry)}\n >\n ${t('help.hint', { n: next + 1, total: entry.total })}\n </button>\n ${\n cost > 0\n ? html`<span class=\"help-cost\" id=${costId}\n >${t('help.hintCost', { percent: Math.round(cost * 100) })}</span\n >`\n : nothing\n }</span\n >`\n }\n ${\n check\n ? html`<button\n type=\"button\"\n class=\"button\"\n aria-disabled=${controller.canCheck() ? nothing : 'true'}\n @click=${() => {\n if (controller.canCheck()) void host.check(entry.id);\n }}\n >\n ${t('action.check')}<span class=\"astl-vh\"> ${entry.check}</span>\n </button>`\n : nothing\n }\n </div>`\n }\n ${\n entry.hints.length === 0\n ? nothing\n : html`<ol class=\"help-hints\">\n ${entry.hints.map(\n (hint) =>\n html`<li tabindex=\"-1\">\n <span class=\"help-label\">${t('help.hintItem', { n: hint.n })}</span>${hint.content}\n </li>`,\n )}\n </ol>`\n }\n ${\n entry.feedback === null || entry.verdict === null\n ? nothing\n : html`<div class=\"help-feedback\" data-verdict=${entry.verdict} ?data-own=${entry.ownVerdict}>\n ${renderVerdict(entry.verdict, t, { lang: locale, hiddenWord: entry.ownVerdict })}${entry.feedback}\n </div>`\n }\n ${\n entry.explanation === null\n ? nothing\n : html`<details class=\"help-why\">\n <summary>${t('help.why')}</summary>\n ${entry.explanation}\n </details>`\n }\n ${entry.problem === null ? nothing : html`<p class=\"help-problem\" role=\"alert\">${problemText(entry.problem)}</p>`}`;\n };\n\n const unsubscribe = controller.subscribe((change) => {\n if (change.type === 'result') apply(change.response, null);\n else if (change.type === 'element') {\n apply(change.response, change.id);\n const entry = rows.find((r) => r.id === change.id);\n if (entry?.verdict != null) {\n host.announce(\n [t(`verdict.${entry.verdict}`), entry.feedback?.textContent?.trim()].filter(Boolean).join('. '),\n );\n }\n } else if (change.type === 'answers') {\n const changed = Object.keys(change.answers);\n for (const entry of rows) {\n if (changed.some((id) => entry.slots.has(id))) {\n entry.verdict = null;\n entry.feedback = null;\n }\n }\n } else if (change.type === 'reset') {\n for (const entry of rows) {\n entry.verdict = null;\n entry.feedback = null;\n entry.explanation = null;\n }\n }\n update();\n });\n update();\n\n return {\n destroy() {\n unsubscribe();\n for (const entry of rows) entry.box.remove();\n },\n };\n}\n\n// Rows sit in the content's flow, in the UI's type size. A page's row opens with a line across the page, under its\n// floats. The feedback box has the verdict's colour and edge (solid, double, dashed, dotted), never colour alone;\n// under a block, which says its verdict in words right above, it keeps the icon beside the text, the word hidden.\n// A hint's cost stays by its button (closer than the next action), and wraps under it, never beside \"Check\".\nconst helpSheet = css`\n .canvas .astl-help {\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n gap: var(--astl-space-2);\n margin-block: 0 var(--astl-space-4);\n font-size: var(--astl-size-ui);\n line-height: 1.4;\n }\n .canvas .astl-help[hidden] {\n display: none;\n }\n .canvas .astl-help[data-page] {\n clear: both;\n padding-block-start: var(--astl-space-3);\n border-block-start: var(--astl-outline-width) solid var(--astl-line);\n }\n .help-actions {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: var(--astl-space-2) var(--astl-space-5);\n }\n .help-hint {\n display: inline-flex;\n flex-wrap: wrap;\n align-items: center;\n gap: var(--astl-space-1) var(--astl-space-2);\n }\n .help-cost {\n color: var(--astl-ink-muted);\n font-size: var(--astl-size-small);\n }\n .help-hints {\n display: grid;\n gap: var(--astl-space-2);\n margin: 0;\n padding: 0;\n list-style: none;\n }\n .help-hints li,\n .help-feedback,\n .help-why {\n box-sizing: border-box;\n max-inline-size: 100%;\n padding-block: var(--astl-space-2);\n padding-inline: 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-raised);\n color: var(--astl-ink);\n }\n .help-label {\n display: block;\n color: var(--astl-ink-muted);\n font-size: var(--astl-size-small);\n font-weight: 600;\n }\n .help-feedback {\n border-style: var(--astl-verdict-border);\n border-color: var(--astl-verdict-color);\n background: var(--astl-verdict-soft);\n }\n .help-feedback[data-own] {\n display: flex;\n align-items: flex-start;\n gap: var(--astl-space-2);\n }\n .help-feedback[data-own] > .astl-verdict {\n block-size: 1lh;\n }\n .help-feedback[data-own] > .help-content {\n flex: 1;\n min-inline-size: 0;\n }\n .help-content > :first-child {\n margin-block-start: 0;\n }\n .help-content > :last-child {\n margin-block-end: 0;\n }\n .help-why {\n padding-block: 0;\n }\n .help-why summary {\n display: flex;\n align-items: center;\n min-block-size: var(--astl-target-min);\n min-inline-size: var(--astl-target-min);\n cursor: pointer;\n font-weight: 600;\n }\n .help-why[open] {\n padding-block-end: var(--astl-space-2);\n }\n .help-problem {\n margin: 0;\n color: var(--astl-ink);\n }\n`.styleSheet;\n\n/** Adopts the rows' stylesheet in a player's root, once. */\nfunction adoptHelpSheet(root: Node): void {\n if (helpSheet !== undefined && root instanceof ShadowRoot && !root.adoptedStyleSheets.includes(helpSheet)) {\n root.adoptedStyleSheets = [...root.adoptedStyleSheets, helpSheet];\n }\n}\n"],"mappings":"A,yIE6CA,IAAaiB,EAA0C,CACrD,CAAE,UAAWP,EAAkB,OAAQ,KAAM,SAAUV,C,+cAAAA,CAAG,EAC1D,CAAE,UAAWU,EAAkB,OAAQ,KAAM,SAAUT,C,ydAAAA,CAAG,CAC5D,EA6BMiB,EAAO,kCAGb,SAAgBC,EAAS,EAAiC,CACxD,IAAMC,EAAS,IAAkBC,EAAG,aAAaC,CAAI,GAAK,GAAA,CAAI,MAAM,GAAG,CAAC,CAAC,OAAO,OAAO,EACjFC,EAAQH,EAAM,OAAO,CAAC,CAAC,QAAS,GAAOF,EAAK,KAAKM,CAAC,EAAI,CAAC,OAAOA,CAAC,CAAC,EAAI,CAAC,CAAE,EACvEC,EAAU,IAAI,IAAIL,EAAM,UAAU,CAAC,EACnCM,EAAWnB,EAAkB,OAAQ,GAAMkB,EAAQ,IAAIE,CAAC,CAAC,EACzDC,EAAcP,EAAG,aAAa,aAAa,EACjD,OAAOE,EAAM,SAAW,GAAKG,EA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oGnB,WAGF,SAASzC,EAAe,EAAkB,CACpCyC,IAAc,IAAA,IAAaC,aAAgB,YAAc,CAACA,EAAK,mBAAmB,SAASD,CAAS,IACtG,EAAK,mBAAqB,CAAC,GAAGC,EAAK,mBAAoBD,CAAS,EAEpE,C"}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import{H as e}from"./definitions-CNX90WtL.js";import{C as t,Ct as n,E as r,St as i,b as a,bt as o,fn as s,mn as c,vt as l,yt as u}from"./runtime-DxAbpr3S.js";import{i as d,l as f,n as p,o as m,r as h,t as g}from"./scan-jWgPnVxA.js";import{t as _}from"./messages-9xiYDvRT.js";import{n as v,r as y}from"./styles-DxJJxVNH.js";import{t as b}from"./live-jdiyYln2.js";var x=(e,t)=>t.endTag===null&&t.startTag.selfClosing?``:e.slice(t.startTag.end,t.endTag?.start??t.end),S=e=>e.children.filter(e=>i.has(e.name)),C=e=>o.includes(e);function w(e){let t=h(e)[0],n=[],r=null,i={};for(let a of t===void 0?[]:S(t)){let t=x(e,a);if(a.name===`astl-hint`)n.push({html:t,cost:p(a.startTag,`cost`)});else if(a.name===`astl-explanation`)r??=t;else{let e=p(a.startTag,`when`);C(e)&&(i[e]??=t)}}return{hints:n,explanation:r,feedback:i}}function T(e){let t=e=>e===null?``:` cost="${d(e)}"`;return[...e.hints.map(e=>`<${n}${t(e.cost)}>${e.html}</${n}>`),...e.explanation===null?[]:[`<${l}>${e.explanation}</${l}>`],...o.flatMap(t=>{let n=e.feedback[t];return n===void 0?[]:[`<${u} when="${t}">${n}</${u}>`]})]}function E(e,t){let n=h(e)[0];if(n===void 0)return e;let r=g(e,S(n).map(t=>({start:f(e,t.start),end:t.end,text:``}))),i=T(t),a=h(r)[0];if(a===void 0||i.length===0)return r;let o=a.children.at(-1);if(o===void 0){let e=a.endTag?.start??a.end;return a.endTag===null&&a.startTag.selfClosing?`${r.slice(0,a.start)}${r.slice(a.start,f(r,a.startTag.end-2))}>${i.join(``)}</${a.name}>${r.slice(a.end)}`:g(r,[{start:e,end:e,text:i.join(``)}])}let s=r.slice(f(r,o.start),o.start),c=/^\s*$/.test(s)?s:``;return g(r,[{start:o.end,end:o.end,text:i.map(e=>c+e).join(``)}])}var D=e=>s(e)?e.tag===`br`?`
|
|
2
|
+
`:e.children.map(D).join(``):c(e);function O(t){return(e=>e.flatMap(e=>s(e)?e.tag===`p`||e.tag===`li`?[`\n\n${D(e).trim()}\n\n`]:[D(e)]:[c(e)]))(e(t)).join(``).replace(/[ \t]+/g,` `).split(/\n{2,}/).map(e=>e.trim()).filter(Boolean).join(`
|
|
3
|
+
|
|
4
|
+
`)}function k(t,n){let r=(e,t)=>!n&&Object.keys(e.attrs).length===0&&(t===0?e.tag===`p`:t===1&&e.tag===`br`),i=(e,t)=>e.some(e=>s(e)&&(!r(e,t)||i(e.children,t+1)));return i(e(t),0)}function A(e,t){return t?m(e.replace(/\s+/g,` `).trim()):e.split(/\n\s*\n/).map(e=>e.trim()).filter(Boolean).map(e=>`<p>${m(e).replace(/\n/g,`<br>`)}</p>`).join(``)}var j=[{namespace:_,locale:`en`,messages:{"help.title":`Help for students`,"help.hints":`Hints`,"help.hintsNote":`Students ask for them one at a time, in this order. A cost is the share of the question's points a student loses for using that hint.`,"help.hintN":`Hint {n}`,"help.cost":`Cost (% of the points)`,"help.costN":`Hint {n}: cost (% of the points)`,"help.addHint":`Add a hint`,"help.up":`Up`,"help.down":`Down`,"help.upN":`Move hint {n} up`,"help.downN":`Move hint {n} down`,"help.removeN":`Remove hint {n}`,"help.drag":`Drag to reorder`,"help.explanationNote":`Students open it under "Why?" once their answer is checked. Leave it empty for none.`,"help.feedbackNote":`Shown after a check, by the verdict. Leave a text empty for none.`,"help.formatted":`This text has formatting. A change in this field keeps only the text.`}},{namespace:_,locale:`pl`,messages:{"help.title":`Pomoc dla ucznia`,"help.hints":`Podpowiedzi`,"help.hintsNote":`Uczeń prosi o nie po kolei, w tej kolejności. Koszt to część punktów za to pytanie, którą uczeń traci, gdy użyje podpowiedzi.`,"help.hintN":`Podpowiedź {n}`,"help.cost":`Koszt (% punktów)`,"help.costN":`Podpowiedź {n}: koszt (% punktów)`,"help.addHint":`Dodaj podpowiedź`,"help.up":`W górę`,"help.down":`W dół`,"help.upN":`Przenieś podpowiedź {n} w górę`,"help.downN":`Przenieś podpowiedź {n} w dół`,"help.removeN":`Usuń podpowiedź {n}`,"help.drag":`Przeciągnij, aby zmienić kolejność`,"help.explanationNote":`Uczeń otwiera je pod „Dlaczego?”, gdy jego odpowiedź zostanie sprawdzona. Zostaw puste, jeśli nie ma.`,"help.feedbackNote":`Widać ją po sprawdzeniu, zależnie od wyniku. Zostaw tekst pusty, jeśli nie ma.`,"help.formatted":`Ten tekst ma formatowanie. Zmiana w tym polu zostawi sam tekst.`}}],M=null,N=(e,t)=>e.descriptor(t)?.manifest.graded===!0;function P(e,t,n){let r=t.getSelection(),i=r===null?null:t.getElement(r.id);if(r===null||i===null||!N(e,r.tag)){let e=n===`feedback`?`<astl-feedback when="correct"><p></p></astl-feedback>`:`<astl-${n}><p></p></astl-${n}>`;return t.insert(e),e}let a=w(i),o,s;if(n===`hint`)o={...a,hints:[...a.hints,{html:``,cost:null}]},s=`hint-${a.hints.length}`;else if(n===`explanation`)o={...a,explanation:a.explanation??``},s=`explanation`;else{let e=F.find(e=>a.feedback[e]===void 0)??`correct`;o={...a,feedback:{...a.feedback,[e]:a.feedback[e]??``}},s=`feedback-${e}`}return M={element:r.id,field:s},t.replaceElement(r.id,E(i,o)),null}var F=[`correct`,`incorrect`,`omitted`,`partial`],I=e=>{if(e===null)return`0`;let t=Number(e);return Number.isFinite(t)&&t>=0&&t<=1?String(Math.round(t*100)):``},L=e=>e.target.value,R=class extends y{static properties={...y.properties,element:{},inline:{type:Boolean}};static styles=[v,r`
|
|
5
|
+
:host {
|
|
6
|
+
display: block;
|
|
7
|
+
}
|
|
8
|
+
section {
|
|
9
|
+
display: flex;
|
|
10
|
+
flex-direction: column;
|
|
11
|
+
gap: var(--astl-space-3);
|
|
12
|
+
padding-block-start: var(--astl-space-3);
|
|
13
|
+
border-block-start: var(--astl-outline-width) solid var(--astl-line);
|
|
14
|
+
}
|
|
15
|
+
h3 {
|
|
16
|
+
margin: 0;
|
|
17
|
+
font-size: 1rem;
|
|
18
|
+
}
|
|
19
|
+
fieldset,
|
|
20
|
+
.field {
|
|
21
|
+
display: flex;
|
|
22
|
+
flex-direction: column;
|
|
23
|
+
gap: var(--astl-space-1);
|
|
24
|
+
min-inline-size: 0;
|
|
25
|
+
margin: 0;
|
|
26
|
+
padding: 0;
|
|
27
|
+
border: 0;
|
|
28
|
+
}
|
|
29
|
+
legend,
|
|
30
|
+
label {
|
|
31
|
+
padding: 0;
|
|
32
|
+
font-weight: 600;
|
|
33
|
+
}
|
|
34
|
+
ol {
|
|
35
|
+
display: flex;
|
|
36
|
+
flex-direction: column;
|
|
37
|
+
gap: var(--astl-space-3);
|
|
38
|
+
margin: 0;
|
|
39
|
+
padding: 0;
|
|
40
|
+
list-style: none;
|
|
41
|
+
}
|
|
42
|
+
li {
|
|
43
|
+
display: flex;
|
|
44
|
+
flex-direction: column;
|
|
45
|
+
gap: var(--astl-space-1);
|
|
46
|
+
padding: var(--astl-space-2);
|
|
47
|
+
border: var(--astl-outline-width) solid var(--astl-line);
|
|
48
|
+
border-radius: var(--astl-radius-s);
|
|
49
|
+
}
|
|
50
|
+
li[data-over] {
|
|
51
|
+
border-color: var(--astl-accent);
|
|
52
|
+
}
|
|
53
|
+
.row {
|
|
54
|
+
display: flex;
|
|
55
|
+
flex-wrap: wrap;
|
|
56
|
+
align-items: center;
|
|
57
|
+
gap: var(--astl-space-2);
|
|
58
|
+
}
|
|
59
|
+
.handle {
|
|
60
|
+
cursor: grab;
|
|
61
|
+
user-select: none;
|
|
62
|
+
}
|
|
63
|
+
.cost {
|
|
64
|
+
display: flex;
|
|
65
|
+
align-items: center;
|
|
66
|
+
gap: var(--astl-space-1);
|
|
67
|
+
font-weight: 400;
|
|
68
|
+
}
|
|
69
|
+
.cost input {
|
|
70
|
+
inline-size: 6em;
|
|
71
|
+
}
|
|
72
|
+
textarea {
|
|
73
|
+
field-sizing: content;
|
|
74
|
+
min-block-size: 3lh;
|
|
75
|
+
resize: vertical;
|
|
76
|
+
}
|
|
77
|
+
.delete {
|
|
78
|
+
color: var(--astl-danger);
|
|
79
|
+
}
|
|
80
|
+
`];#e=new Map;#t=null;constructor(){super(),this.element=null,this.inline=!1}willUpdate(e){super.willUpdate(e),e.has(`authoring`)&&this.authoring?.addMessages(j),e.has(`element`)&&this.#e.clear()}updated(){if(M===null||M.element!==this.element)return;let e=this.renderRoot.querySelector(`[data-help="${M.field}"]`);e!==null&&(M=null,e.focus())}#n(){let e=this.element===null?null:this.adapter?.getElement(this.element)??null;return e===null?null:{html:e,help:w(e)}}#r(e){let t=this.#n();if(t===null||this.element===null||this.adapter===null)return;let n=E(t.html,e(t.help));n!==t.html&&this.adapter.replaceElement(this.element,n)}#i(e,t){return this.#e.get(e)??O(t)}#a(e,n){return k(n,this.inline)?t`<p class="note" id=${`${e}-formatted`}>${this.t(`help.formatted`)}</p>`:null}#o(e,t){let n=L(t);return this.#e.set(e,n),A(n,this.inline)}#s(e){this.#e.delete(e),this.requestUpdate()}#c(e,t){this.#r(n=>{if(t<0||t>=n.hints.length||e===t)return n;let r=[...n.hints],[i]=r.splice(e,1);return i!==void 0&&r.splice(t,0,i),{...n,hints:r}}),this.#e.clear()}#l(e,n){let r=e.hints[n],i=n+1,o=`hint-${n}`,s=n===e.hints.length-1,c=this.#a(o,r.html),l=(e,t)=>{this.#t!==null&&(e.preventDefault(),e.currentTarget.toggleAttribute(`data-over`,t))};return t`<li
|
|
81
|
+
@dragover=${e=>l(e,!0)}
|
|
82
|
+
@dragleave=${e=>l(e,!1)}
|
|
83
|
+
@drop=${e=>{l(e,!1),this.#t!==null&&this.#c(this.#t,n),this.#t=null}}
|
|
84
|
+
>
|
|
85
|
+
<div class="row">
|
|
86
|
+
<span
|
|
87
|
+
class="handle"
|
|
88
|
+
draggable="true"
|
|
89
|
+
aria-hidden="true"
|
|
90
|
+
title=${this.t(`help.drag`)}
|
|
91
|
+
@dragstart=${e=>{this.#t=n,e.dataTransfer?.setData(`text/plain`,String(i))}}
|
|
92
|
+
@dragend=${()=>{this.#t=null}}
|
|
93
|
+
>⠿</span
|
|
94
|
+
>
|
|
95
|
+
<label for=${o}>${this.t(`help.hintN`,{n:i})}</label>
|
|
96
|
+
</div>
|
|
97
|
+
<textarea
|
|
98
|
+
id=${o}
|
|
99
|
+
data-help=${o}
|
|
100
|
+
dir="auto"
|
|
101
|
+
aria-describedby=${c===null?a:`${o}-formatted`}
|
|
102
|
+
.value=${b(this.#i(o,r.html))}
|
|
103
|
+
@input=${e=>{let t=this.#o(o,e);this.#r(e=>({...e,hints:e.hints.map((e,r)=>r===n?{...e,html:t}:e)}))}}
|
|
104
|
+
@change=${()=>this.#s(o)}
|
|
105
|
+
></textarea>
|
|
106
|
+
${c??a}
|
|
107
|
+
<div class="row">
|
|
108
|
+
<label class="cost">
|
|
109
|
+
${this.t(`help.cost`)}
|
|
110
|
+
<input
|
|
111
|
+
type="number"
|
|
112
|
+
aria-label=${this.t(`help.costN`,{n:i})}
|
|
113
|
+
min="0"
|
|
114
|
+
max="100"
|
|
115
|
+
step="5"
|
|
116
|
+
inputmode="numeric"
|
|
117
|
+
data-help=${`cost-${n}`}
|
|
118
|
+
.value=${b(I(r.cost))}
|
|
119
|
+
@change=${e=>{let t=Number(L(e));if(!Number.isFinite(t)||t<0||t>100)return;let r=t===0?null:String(Math.round(t)/100);this.#r(e=>({...e,hints:e.hints.map((e,t)=>t===n?{...e,cost:r}:e)}))}}
|
|
120
|
+
/>
|
|
121
|
+
</label>
|
|
122
|
+
<button type="button" aria-label=${this.t(`help.upN`,{n:i})} aria-disabled=${String(n===0)}
|
|
123
|
+
@click=${()=>this.#c(n,n-1)}>${this.t(`help.up`)}</button>
|
|
124
|
+
<button type="button" aria-label=${this.t(`help.downN`,{n:i})} aria-disabled=${String(s)}
|
|
125
|
+
@click=${()=>this.#c(n,n+1)}>${this.t(`help.down`)}</button>
|
|
126
|
+
<button type="button" class="delete" aria-label=${this.t(`help.removeN`,{n:i})}
|
|
127
|
+
@click=${()=>{this.#e.clear(),this.#r(e=>({...e,hints:e.hints.filter((e,t)=>t!==n)})),M={element:this.element??``,field:e.hints.length>1?`hint-${Math.max(0,n-1)}`:`add-hint`}}}>${this.t(`inspector.remove`)}</button>
|
|
128
|
+
</div>
|
|
129
|
+
</li>`}#u(e,n,r,i){let o=this.#a(e,r??``);return t`<div class="field">
|
|
130
|
+
<label for=${e}>${n}</label>
|
|
131
|
+
<textarea
|
|
132
|
+
id=${e}
|
|
133
|
+
data-help=${e}
|
|
134
|
+
dir="auto"
|
|
135
|
+
aria-describedby=${o===null?a:`${e}-formatted`}
|
|
136
|
+
.value=${b(this.#i(e,r??``))}
|
|
137
|
+
@input=${t=>{let n=this.#o(e,t);i(n===``?null:n)}}
|
|
138
|
+
@change=${()=>this.#s(e)}
|
|
139
|
+
></textarea>
|
|
140
|
+
${o??a}
|
|
141
|
+
</div>`}render(){let e=this.#n();if(e===null||this.authoring===null)return a;let{help:n}=e,{lang:r,dir:i}=this.ui;return t`<section class="kit" part="help" lang=${r} dir=${i} aria-labelledby="help-title">
|
|
142
|
+
<h3 id="help-title">${this.t(`help.title`)}</h3>
|
|
143
|
+
<fieldset aria-describedby="hints-note">
|
|
144
|
+
<legend>${this.t(`help.hints`)}</legend>
|
|
145
|
+
<p class="note" id="hints-note">${this.t(`help.hintsNote`)}</p>
|
|
146
|
+
${n.hints.length===0?a:t`<ol>${n.hints.map((e,t)=>this.#l(n,t))}</ol>`}
|
|
147
|
+
<div class="row">
|
|
148
|
+
<button type="button" data-help="add-hint"
|
|
149
|
+
@click=${()=>{M={element:this.element??``,field:`hint-${n.hints.length}`},this.#r(e=>({...e,hints:[...e.hints,{html:``,cost:null}]}))}}>${this.t(`help.addHint`)}</button>
|
|
150
|
+
</div>
|
|
151
|
+
</fieldset>
|
|
152
|
+
${this.#u(`explanation`,this.t(`insert.explanation`),n.explanation,e=>this.#r(t=>({...t,explanation:e})))}
|
|
153
|
+
<p class="note">${this.t(`help.explanationNote`)}</p>
|
|
154
|
+
<fieldset aria-describedby="feedback-note">
|
|
155
|
+
<legend>${this.t(`insert.feedback`)}</legend>
|
|
156
|
+
<p class="note" id="feedback-note">${this.t(`help.feedbackNote`)}</p>
|
|
157
|
+
${o.map(e=>this.#u(`feedback-${e}`,this.t(`help.when.${e}`),n.feedback[e],t=>this.#r(n=>{let r={...n.feedback};return t===null?delete r[e]:r[e]=t,{...n,feedback:r}})))}
|
|
158
|
+
</fieldset>
|
|
159
|
+
</section>`}};export{R as AstlHelpForm,P as addHelp};
|
|
160
|
+
//# sourceMappingURL=help-form-DaC6KaFG.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"help-form-DaC6KaFG.js","names":["en","pl","nothing","live","parseHtml","b","HINT_TAG","i","HELP_TAGS","A","FEEDBACK_VARIANTS","isElement","textContent","EXPLANATION_TAG","FEEDBACK_TAG","escapeAttribute","spaceBefore","attributeValue","escapeText","elementTree","applyEdits","EDITOR_NAMESPACE","kitStyles","AuthoringElement","l","inner","range","source","helpChildren","root","c","isVariant","value","readHelp","html","hints","explanation","feedback","child","content","when","helpSource","cost","help","h","text","writeHelp","first","cleared","added","last","at","gap","sep","a","lines","node","helpText","nodes","part","helpFormatted","plain","inline","depth","formatted","textHelp","helpMessages","pending","graded","authoring","tag","addHelp","selection","adapter","current","block","kind","next","field","FEEDBACK_ORDER","w","percentOf","n","inputValue","event","AstlHelpForm","changed","#drafts","#help","change","#write","to","from","moved","hint","index","#formatted","over","#dragged","on","#move","#text","#typed","x","#done","percent","label","e","set","lang","dir","#hint","#area"],"sources":["../../../../editor/src/help.ts","../../../../editor/src/messages/help/en.json","../../../../editor/src/messages/help/pl.json","../../../../editor/src/elements/help-form.ts"],"sourcesContent":["/**\n * The help for students of one graded element, read from and written to its source HTML: its hints (in order, each\n * with its cost), its explanation and its feedback texts, its direct children. Writing replaces them all, after the\n * element's other children, and leaves everything else byte-identical. The help form edits plain text: a text becomes\n * paragraphs (text alone in an element in a line of text); a text not edited keeps its HTML.\n */\nimport {\n type ElementNode,\n EXPLANATION_TAG,\n FEEDBACK_TAG,\n FEEDBACK_VARIANTS,\n type FeedbackVariant,\n HELP_TAGS,\n HINT_TAG,\n isElement,\n type Node,\n textContent,\n} from '@astl/core';\nimport { parseHtml } from '@astl/engine';\nimport {\n applyEdits,\n attributeValue,\n type ElementRange,\n elementTree,\n escapeAttribute,\n escapeText,\n spaceBefore,\n} from './scan.js';\n\nexport interface HelpHint {\n /** Its content as written. */\n readonly html: string;\n /** Its `cost` attribute as written, null when it has none (free). */\n readonly cost: string | null;\n}\n\n/** An element's help. Contents are HTML as written; an absent explanation or feedback text is null or missing. */\nexport interface HelpValue {\n readonly hints: readonly HelpHint[];\n readonly explanation: string | null;\n readonly feedback: Readonly<Partial<Record<FeedbackVariant, string>>>;\n}\n\nconst inner = (source: string, range: ElementRange): string =>\n range.endTag === null && range.startTag.selfClosing\n ? ''\n : source.slice(range.startTag.end, range.endTag?.start ?? range.end);\n\nconst helpChildren = (root: ElementRange): ElementRange[] =>\n root.children.filter((c) => HELP_TAGS.has(c.name));\n\nconst isVariant = (value: string | null): value is FeedbackVariant =>\n FEEDBACK_VARIANTS.includes(value as FeedbackVariant);\n\n/** The help of the first element in `html`. Later duplicates of an explanation or a feedback text are left out. */\nexport function readHelp(html: string): HelpValue {\n const root = elementTree(html)[0];\n const hints: HelpHint[] = [];\n let explanation: string | null = null;\n const feedback: Partial<Record<FeedbackVariant, string>> = {};\n for (const child of root === undefined ? [] : helpChildren(root)) {\n const content = inner(html, child);\n if (child.name === HINT_TAG) hints.push({ html: content, cost: attributeValue(child.startTag, 'cost') });\n else if (child.name === EXPLANATION_TAG) explanation ??= content;\n else {\n const when = attributeValue(child.startTag, 'when');\n if (isVariant(when)) feedback[when] ??= content;\n }\n }\n return { hints, explanation, feedback };\n}\n\n/** The help as source: hints, the explanation, then the feedback texts in the order of `FEEDBACK_VARIANTS`. */\nfunction helpSource(help: HelpValue): string[] {\n const cost = (value: string | null) => (value === null ? '' : ` cost=\"${escapeAttribute(value)}\"`);\n return [\n ...help.hints.map((h) => `<${HINT_TAG}${cost(h.cost)}>${h.html}</${HINT_TAG}>`),\n ...(help.explanation === null ? [] : [`<${EXPLANATION_TAG}>${help.explanation}</${EXPLANATION_TAG}>`]),\n ...FEEDBACK_VARIANTS.flatMap((when) => {\n const text = help.feedback[when];\n return text === undefined ? [] : [`<${FEEDBACK_TAG} when=\"${when}\">${text}</${FEEDBACK_TAG}>`];\n }),\n ];\n}\n\n/** Replaces the help of the first element in `html` with `help`, after its other children. */\nexport function writeHelp(html: string, help: HelpValue): string {\n const first = elementTree(html)[0];\n if (first === undefined) return html;\n // Out first, then in: an insertion where a removal starts would shift it.\n const cleared = applyEdits(\n html,\n helpChildren(first).map((c) => ({ start: spaceBefore(html, c.start), end: c.end, text: '' })),\n );\n const added = helpSource(help);\n const root = elementTree(cleared)[0];\n if (root === undefined || added.length === 0) return cleared;\n const last = root.children.at(-1);\n if (last === undefined) {\n const at = root.endTag?.start ?? root.end;\n const closed = root.endTag === null && root.startTag.selfClosing;\n return closed\n ? `${cleared.slice(0, root.start)}${cleared.slice(root.start, spaceBefore(cleared, root.startTag.end - 2))}>${added.join('')}</${root.name}>${cleared.slice(root.end)}`\n : applyEdits(cleared, [{ start: at, end: at, text: added.join('') }]);\n }\n // On their own lines when the children are.\n const gap = cleared.slice(spaceBefore(cleared, last.start), last.start);\n const sep = /^\\s*$/.test(gap) ? gap : '';\n return applyEdits(cleared, [{ start: last.end, end: last.end, text: added.map((a) => sep + a).join('') }]);\n}\n\n/** The text of a node with its line breaks, as a field shows them (`textHelp` writes them back as `<br>`). */\nconst lines = (node: Node): string =>\n !isElement(node) ? textContent(node) : node.tag === 'br' ? '\\n' : node.children.map(lines).join('');\n\n/** What a help text says, for a text field: its paragraphs apart by a blank line, its line breaks kept. */\nexport function helpText(html: string): string {\n const blocks = (nodes: readonly Node[]): string[] =>\n nodes.flatMap((node) => {\n if (!isElement(node)) return [textContent(node)];\n return node.tag === 'p' || node.tag === 'li' ? [`\\n\\n${lines(node).trim()}\\n\\n`] : [lines(node)];\n });\n return blocks(parseHtml(html))\n .join('')\n .replace(/[ \\t]+/g, ' ')\n .split(/\\n{2,}/)\n .map((part) => part.trim())\n .filter(Boolean)\n .join('\\n\\n');\n}\n\n/**\n * Whether a help text holds more than its field writes back (paragraphs of plain text, or text alone for an element in\n * a line of text): a change in the field keeps the words and drops the rest, so the form says so first.\n */\nexport function helpFormatted(html: string, inline: boolean): boolean {\n // What a field writes: paragraphs holding text and line breaks; text alone in a line of text.\n const plain = (node: ElementNode, depth: number): boolean =>\n !inline &&\n Object.keys(node.attrs).length === 0 &&\n (depth === 0 ? node.tag === 'p' : depth === 1 && node.tag === 'br');\n const formatted = (nodes: readonly Node[], depth: number): boolean =>\n nodes.some((node) => isElement(node) && (!plain(node, depth) || formatted(node.children, depth + 1)));\n return formatted(parseHtml(html), 0);\n}\n\n/** HTML from a field's text: paragraphs (blank lines part them), or text alone for an element in a line of text. */\nexport function textHelp(text: string, inline: boolean): string {\n if (inline) return escapeText(text.replace(/\\s+/g, ' ').trim());\n return text\n .split(/\\n\\s*\\n/)\n .map((part) => part.trim())\n .filter(Boolean)\n .map((part) => `<p>${escapeText(part).replace(/\\n/g, '<br>')}</p>`)\n .join('');\n}\n","{\n \"help.title\": \"Help for students\",\n \"help.hints\": \"Hints\",\n \"help.hintsNote\": \"Students ask for them one at a time, in this order. A cost is the share of the question's points a student loses for using that hint.\",\n \"help.hintN\": \"Hint {n}\",\n \"help.cost\": \"Cost (% of the points)\",\n \"help.costN\": \"Hint {n}: cost (% of the points)\",\n \"help.addHint\": \"Add a hint\",\n \"help.up\": \"Up\",\n \"help.down\": \"Down\",\n \"help.upN\": \"Move hint {n} up\",\n \"help.downN\": \"Move hint {n} down\",\n \"help.removeN\": \"Remove hint {n}\",\n \"help.drag\": \"Drag to reorder\",\n \"help.explanationNote\": \"Students open it under \\\"Why?\\\" once their answer is checked. Leave it empty for none.\",\n \"help.feedbackNote\": \"Shown after a check, by the verdict. Leave a text empty for none.\",\n \"help.formatted\": \"This text has formatting. A change in this field keeps only the text.\"\n}\n","{\n \"help.title\": \"Pomoc dla ucznia\",\n \"help.hints\": \"Podpowiedzi\",\n \"help.hintsNote\": \"Uczeń prosi o nie po kolei, w tej kolejności. Koszt to część punktów za to pytanie, którą uczeń traci, gdy użyje podpowiedzi.\",\n \"help.hintN\": \"Podpowiedź {n}\",\n \"help.cost\": \"Koszt (% punktów)\",\n \"help.costN\": \"Podpowiedź {n}: koszt (% punktów)\",\n \"help.addHint\": \"Dodaj podpowiedź\",\n \"help.up\": \"W górę\",\n \"help.down\": \"W dół\",\n \"help.upN\": \"Przenieś podpowiedź {n} w górę\",\n \"help.downN\": \"Przenieś podpowiedź {n} w dół\",\n \"help.removeN\": \"Usuń podpowiedź {n}\",\n \"help.drag\": \"Przeciągnij, aby zmienić kolejność\",\n \"help.explanationNote\": \"Uczeń otwiera je pod „Dlaczego?”, gdy jego odpowiedź zostanie sprawdzona. Zostaw puste, jeśli nie ma.\",\n \"help.feedbackNote\": \"Widać ją po sprawdzeniu, zależnie od wyniku. Zostaw tekst pusty, jeśli nie ma.\",\n \"help.formatted\": \"Ten tekst ma formatowanie. Zmiana w tym polu zostawi sam tekst.\"\n}\n","/**\n * `<astl-help-form>`: the inspector's \"Help for students\" section of a graded element: its hints in order, each with\n * its cost (Up, Down, a drag, Remove, Add), its explanation and its four feedback texts. Every edit rewrites the\n * element's help (`writeHelp`) through `EditorAdapter.replaceElement`. A module of its own, outside the editor's first\n * load (`loadHelpForm`), with its messages; `addHelp` is the insert menu's way in.\n */\nimport { type EditorAdapter, FEEDBACK_VARIANTS, type FeedbackVariant, type MessageCatalog } from '@astl/core';\nimport {\n type CSSResultGroup,\n css,\n html,\n nothing,\n type PropertyDeclarations,\n type PropertyValues,\n type TemplateResult,\n} from 'lit';\nimport { live } from 'lit/directives/live.js';\nimport type { Authoring } from '../authoring.js';\nimport { type HelpValue, helpFormatted, helpText, readHelp, textHelp, writeHelp } from '../help.js';\nimport en from '../messages/help/en.json' with { type: 'json' };\nimport pl from '../messages/help/pl.json' with { type: 'json' };\nimport { EDITOR_NAMESPACE } from '../messages.js';\nimport { AuthoringElement } from './base.js';\nimport { kitStyles } from './styles.js';\n\nconst helpMessages: readonly MessageCatalog[] = [\n { namespace: EDITOR_NAMESPACE, locale: 'en', messages: en },\n { namespace: EDITOR_NAMESPACE, locale: 'pl', messages: pl },\n];\n\n/** What the insert menu adds: a hint, the explanation, or the next feedback text the element lacks. */\nexport type HelpKind = 'hint' | 'explanation' | 'feedback';\n\n/** The field to focus once the form shows it (after an insert), by element id. */\nlet pending: { readonly element: string; readonly field: string } | null = null;\n\nconst graded = (authoring: Authoring, tag: string) => authoring.descriptor(tag)?.manifest.graded === true;\n\n/**\n * Adds help to the graded element at the cursor (and asks the form to focus it), or else to the page at the cursor.\n * Returns the HTML inserted on a page, or null when the element got it.\n */\nexport function addHelp(authoring: Authoring, adapter: EditorAdapter, kind: HelpKind): string | null {\n const selection = adapter.getSelection();\n const current = selection === null ? null : adapter.getElement(selection.id);\n if (selection === null || current === null || !graded(authoring, selection.tag)) {\n const block =\n kind === 'feedback'\n ? '<astl-feedback when=\"correct\"><p></p></astl-feedback>'\n : `<astl-${kind}><p></p></astl-${kind}>`;\n adapter.insert(block);\n return block;\n }\n const help = readHelp(current);\n let next: HelpValue;\n let field: string;\n if (kind === 'hint') {\n next = { ...help, hints: [...help.hints, { html: '', cost: null }] };\n field = `hint-${help.hints.length}`;\n } else if (kind === 'explanation') {\n next = { ...help, explanation: help.explanation ?? '' };\n field = 'explanation';\n } else {\n const when = FEEDBACK_ORDER.find((w) => help.feedback[w] === undefined) ?? 'correct';\n next = { ...help, feedback: { ...help.feedback, [when]: help.feedback[when] ?? '' } };\n field = `feedback-${when}`;\n }\n pending = { element: selection.id, field };\n adapter.replaceElement(selection.id, writeHelp(current, next));\n return null;\n}\n\n/** The order the menu fills feedback texts in: right and wrong first. */\nconst FEEDBACK_ORDER: readonly FeedbackVariant[] = ['correct', 'incorrect', 'omitted', 'partial'];\n\n/** A cost in percent of the points (0 to 100) from a `cost` attribute, or '' when there is none or it is not one. */\nconst percentOf = (cost: string | null): string => {\n if (cost === null) return '0';\n const n = Number(cost);\n return Number.isFinite(n) && n >= 0 && n <= 1 ? String(Math.round(n * 100)) : '';\n};\n\nconst inputValue = (event: Event) => (event.target as HTMLInputElement | HTMLTextAreaElement).value;\n\nexport class AstlHelpForm extends AuthoringElement {\n static override properties: PropertyDeclarations = {\n ...AuthoringElement.properties,\n element: {},\n inline: { type: Boolean },\n };\n\n static override styles: CSSResultGroup = [\n kitStyles,\n css`\n :host {\n display: block;\n }\n section {\n display: flex;\n flex-direction: column;\n gap: var(--astl-space-3);\n padding-block-start: var(--astl-space-3);\n border-block-start: var(--astl-outline-width) solid var(--astl-line);\n }\n h3 {\n margin: 0;\n font-size: 1rem;\n }\n fieldset,\n .field {\n display: flex;\n flex-direction: column;\n gap: var(--astl-space-1);\n min-inline-size: 0;\n margin: 0;\n padding: 0;\n border: 0;\n }\n legend,\n label {\n padding: 0;\n font-weight: 600;\n }\n ol {\n display: flex;\n flex-direction: column;\n gap: var(--astl-space-3);\n margin: 0;\n padding: 0;\n list-style: none;\n }\n li {\n display: flex;\n flex-direction: column;\n gap: var(--astl-space-1);\n padding: var(--astl-space-2);\n border: var(--astl-outline-width) solid var(--astl-line);\n border-radius: var(--astl-radius-s);\n }\n li[data-over] {\n border-color: var(--astl-accent);\n }\n .row {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: var(--astl-space-2);\n }\n .handle {\n cursor: grab;\n user-select: none;\n }\n .cost {\n display: flex;\n align-items: center;\n gap: var(--astl-space-1);\n font-weight: 400;\n }\n .cost input {\n inline-size: 6em;\n }\n textarea {\n field-sizing: content;\n min-block-size: 3lh;\n resize: vertical;\n }\n .delete {\n color: var(--astl-danger);\n }\n `,\n ];\n\n /** Source id of the element whose help this is. */\n declare element: string | null;\n /** The element sits in a line of text: its help holds text, not paragraphs. */\n declare inline: boolean;\n /** What the author is typing in a field, by field: the source has it cleaned, the field keeps it as typed. */\n #drafts = new Map<string, string>();\n #dragged: number | null = null;\n\n constructor() {\n super();\n this.element = null;\n this.inline = false;\n }\n\n protected override willUpdate(changed: PropertyValues<this>): void {\n super.willUpdate(changed);\n if (changed.has('authoring')) this.authoring?.addMessages(helpMessages);\n if (changed.has('element')) this.#drafts.clear();\n }\n\n protected override updated(): void {\n if (pending === null || pending.element !== this.element) return;\n const field = this.renderRoot.querySelector<HTMLElement>(`[data-help=\"${pending.field}\"]`);\n if (field === null) return;\n pending = null;\n field.focus();\n }\n\n #help(): { readonly html: string; readonly help: HelpValue } | null {\n const html = this.element === null ? null : (this.adapter?.getElement(this.element) ?? null);\n return html === null ? null : { html, help: readHelp(html) };\n }\n\n #write(change: (help: HelpValue) => HelpValue): void {\n const current = this.#help();\n if (current === null || this.element === null || this.adapter === null) return;\n const next = writeHelp(current.html, change(current.help));\n if (next !== current.html) this.adapter.replaceElement(this.element, next);\n }\n\n /** A text field's value: as typed while it is being edited, else what the source says. */\n #text(field: string, html: string): string {\n return this.#drafts.get(field) ?? helpText(html);\n }\n\n /** The note under a field whose text has formatting a change there would drop; null when there is none. */\n #formatted(field: string, source: string): TemplateResult | null {\n return helpFormatted(source, this.inline)\n ? html`<p class=\"note\" id=${`${field}-formatted`}>${this.t('help.formatted')}</p>`\n : null;\n }\n\n #typed(field: string, event: Event): string {\n const value = inputValue(event);\n this.#drafts.set(field, value);\n return textHelp(value, this.inline);\n }\n\n #done(field: string): void {\n this.#drafts.delete(field);\n this.requestUpdate();\n }\n\n #move(from: number, to: number): void {\n this.#write((help) => {\n if (to < 0 || to >= help.hints.length || from === to) return help;\n const hints = [...help.hints];\n const [moved] = hints.splice(from, 1);\n if (moved !== undefined) hints.splice(to, 0, moved);\n return { ...help, hints };\n });\n this.#drafts.clear();\n }\n\n #hint(help: HelpValue, index: number): TemplateResult {\n const hint = help.hints[index] as HelpValue['hints'][number];\n const n = index + 1;\n const field = `hint-${index}`;\n const last = index === help.hints.length - 1;\n const formatted = this.#formatted(field, hint.html);\n const over = (event: DragEvent, on: boolean) => {\n if (this.#dragged === null) return;\n event.preventDefault();\n (event.currentTarget as HTMLElement).toggleAttribute('data-over', on);\n };\n return html`<li\n @dragover=${(e: DragEvent) => over(e, true)}\n @dragleave=${(e: DragEvent) => over(e, false)}\n @drop=${(e: DragEvent) => {\n over(e, false);\n if (this.#dragged !== null) this.#move(this.#dragged, index);\n this.#dragged = null;\n }}\n >\n <div class=\"row\">\n <span\n class=\"handle\"\n draggable=\"true\"\n aria-hidden=\"true\"\n title=${this.t('help.drag')}\n @dragstart=${(e: DragEvent) => {\n this.#dragged = index;\n e.dataTransfer?.setData('text/plain', String(n));\n }}\n @dragend=${() => {\n this.#dragged = null;\n }}\n >⠿</span\n >\n <label for=${field}>${this.t('help.hintN', { n })}</label>\n </div>\n <textarea\n id=${field}\n data-help=${field}\n dir=\"auto\"\n aria-describedby=${formatted === null ? nothing : `${field}-formatted`}\n .value=${live(this.#text(field, hint.html))}\n @input=${(e: Event) => {\n const text = this.#typed(field, e);\n this.#write((h) => ({\n ...h,\n hints: h.hints.map((x, i) => (i === index ? { ...x, html: text } : x)),\n }));\n }}\n @change=${() => this.#done(field)}\n ></textarea>\n ${formatted ?? nothing}\n <div class=\"row\">\n <label class=\"cost\">\n ${this.t('help.cost')}\n <input\n type=\"number\"\n aria-label=${this.t('help.costN', { n })}\n min=\"0\"\n max=\"100\"\n step=\"5\"\n inputmode=\"numeric\"\n data-help=${`cost-${index}`}\n .value=${live(percentOf(hint.cost))}\n @change=${(e: Event) => {\n const percent = Number(inputValue(e));\n if (!Number.isFinite(percent) || percent < 0 || percent > 100) return;\n const cost = percent === 0 ? null : String(Math.round(percent) / 100);\n this.#write((h) => ({\n ...h,\n hints: h.hints.map((x, i) => (i === index ? { ...x, cost } : x)),\n }));\n }}\n />\n </label>\n <button type=\"button\" aria-label=${this.t('help.upN', { n })} aria-disabled=${String(index === 0)}\n @click=${() => this.#move(index, index - 1)}>${this.t('help.up')}</button>\n <button type=\"button\" aria-label=${this.t('help.downN', { n })} aria-disabled=${String(last)}\n @click=${() => this.#move(index, index + 1)}>${this.t('help.down')}</button>\n <button type=\"button\" class=\"delete\" aria-label=${this.t('help.removeN', { n })}\n @click=${() => {\n this.#drafts.clear();\n this.#write((h) => ({ ...h, hints: h.hints.filter((_, i) => i !== index) }));\n pending = {\n element: this.element ?? '',\n field: help.hints.length > 1 ? `hint-${Math.max(0, index - 1)}` : 'add-hint',\n };\n }}>${this.t('inspector.remove')}</button>\n </div>\n </li>`;\n }\n\n #area(\n field: string,\n label: string,\n value: string | null | undefined,\n set: (html: string | null) => void,\n ): TemplateResult {\n const formatted = this.#formatted(field, value ?? '');\n return html`<div class=\"field\">\n <label for=${field}>${label}</label>\n <textarea\n id=${field}\n data-help=${field}\n dir=\"auto\"\n aria-describedby=${formatted === null ? nothing : `${field}-formatted`}\n .value=${live(this.#text(field, value ?? ''))}\n @input=${(e: Event) => {\n const text = this.#typed(field, e);\n set(text === '' ? null : text);\n }}\n @change=${() => this.#done(field)}\n ></textarea>\n ${formatted ?? nothing}\n </div>`;\n }\n\n protected override render(): TemplateResult | typeof nothing {\n const current = this.#help();\n if (current === null || this.authoring === null) return nothing;\n const { help } = current;\n const { lang, dir } = this.ui;\n return html`<section class=\"kit\" part=\"help\" lang=${lang} dir=${dir} aria-labelledby=\"help-title\">\n <h3 id=\"help-title\">${this.t('help.title')}</h3>\n <fieldset aria-describedby=\"hints-note\">\n <legend>${this.t('help.hints')}</legend>\n <p class=\"note\" id=\"hints-note\">${this.t('help.hintsNote')}</p>\n ${help.hints.length === 0 ? nothing : html`<ol>${help.hints.map((_, i) => this.#hint(help, i))}</ol>`}\n <div class=\"row\">\n <button type=\"button\" data-help=\"add-hint\"\n @click=${() => {\n pending = { element: this.element ?? '', field: `hint-${help.hints.length}` };\n this.#write((h) => ({ ...h, hints: [...h.hints, { html: '', cost: null }] }));\n }}>${this.t('help.addHint')}</button>\n </div>\n </fieldset>\n ${this.#area('explanation', this.t('insert.explanation'), help.explanation, (text) =>\n this.#write((h) => ({ ...h, explanation: text })),\n )}\n <p class=\"note\">${this.t('help.explanationNote')}</p>\n <fieldset aria-describedby=\"feedback-note\">\n <legend>${this.t('insert.feedback')}</legend>\n <p class=\"note\" id=\"feedback-note\">${this.t('help.feedbackNote')}</p>\n ${FEEDBACK_VARIANTS.map((when) =>\n this.#area(`feedback-${when}`, this.t(`help.when.${when}`), help.feedback[when], (text) =>\n this.#write((h) => {\n const feedback: Partial<Record<FeedbackVariant, string>> = { ...h.feedback };\n if (text === null) delete feedback[when];\n else feedback[when] = text;\n return { ...h, feedback };\n }),\n ),\n )}\n </fieldset>\n </section>`;\n }\n}\n"],"mappings":"A,0WA2CA,IAAMyB,GAAS,EAAgB,IAC7BC,EAAM,SAAW,MAAQA,EAAM,SAAS,YACpC,GACAC,EAAO,MAAMD,EAAM,SAAS,IAAKA,EAAM,QAAQ,OAASA,EAAM,GAAG,EAEjEE,EAAgB,GACpBC,EAAK,SAAS,OAAQ,GAAMrB,EAAU,IAAIsB,EAAE,IAAI,CAAC,EAE7CC,EAAa,GACjBrB,EAAkB,SAASsB,CAAwB,EAGrD,SAAgBC,EAAS,EAAyB,CAChD,IAAMJ,EAAOV,EAAYe,CAAI,CAAC,CAAC,GACzBC,EAAoB,CAAC,EACvBC,EAA6B,KAC3BC,EAAqD,CAAC,EAC5D,IAAK,IAAMC,KAAST,IAAS,IAAA,GAAY,CAAC,EAAID,EAAaC,CAAI,EAAG,CAChE,IAAMU,EAAUd,EAAMS,EAAMI,CAAK,EACjC,GAAIA,EAAM,OAAA,YAAmBH,E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-hotspot`,version:1,display:`block`,graded:!0,attributes:[{name:`src`,type:`url`,visibility:`public`,required:!0},{name:`alt`,type:`string`,visibility:`public`,required:!0},{name:`width`,type:`integer`,visibility:`public`,min:1},{name:`height`,type:`integer`,visibility:`public`,min:1},{name:`multiple`,type:`boolean`,visibility:`public`,default:!1},{name:`outline`,type:`boolean`,visibility:`public`,default:!1}],children:[{tag:`astl-prompt`,visibility:`public`,content:`inline`,min:0,max:1,attributes:[]},{tag:`astl-hotspot-region`,visibility:`public`,content:`text`,min:2,max:30,attributes:[{name:`id`,type:`id`,visibility:`public`,required:!0},{name:`shape`,type:`enum`,visibility:`public`,values:[`rect`,`circle`,`polygon`],default:`rect`},{name:`x`,type:`number`,visibility:`public`,min:0,max:100},{name:`y`,type:`number`,visibility:`public`,min:0,max:100},{name:`width`,type:`number`,visibility:`public`,min:0,max:100},{name:`height`,type:`number`,visibility:`public`,min:0,max:100},{name:`r`,type:`number`,visibility:`public`,min:0,max:50},{name:`points`,type:`string`,visibility:`public`},{name:`label`,type:`string`,visibility:`public`},{name:`correct`,type:`boolean`,visibility:`private`,default:!1}]}],scoring:{default:`all`,modes:{all:`all-correct`,"per-region":`proportional`}},variants:null,slotKinds:[`flag`],issues:[`HOTSPOT_ALT_EMPTY`,`HOTSPOT_REGION_INCOMPLETE`,`HOTSPOT_REGION_POINTS`,`HOTSPOT_REGION_OUTSIDE`,`HOTSPOT_REGION_EMPTY`,`HOTSPOT_CORRECT_MISSING`,`HOTSPOT_SINGLE_MANY_CORRECT`,`HOTSPOT_ALL_CORRECT`,`HOTSPOT_PROMPT_EMPTY`],messages:`astl.hotspot`,a11y:{pattern:`a group of native radio buttons (one right place) or checkboxes (several), named by the alt text: Tab reaches the areas, Space picks one and picks it again to undo; in a radio group the arrow keys pick the next area`,keys:[`Tab`,`Space`,`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`]},cssParts:[`hotspot`,`prompt`,`picture`,`region`,`marker`,`verdict`,`solution`]},t={"ui.single":`Pick the right place in the picture.`,"ui.multiple":`Pick every right place in the picture.`,"ui.instructions":`Space picks a place, and picks it again to undo.`,"ui.area":`Area {n}`,"ui.solution":`Right place`,"ui.missed":`missed`},n={"ui.single":`Wskaż właściwe miejsce na obrazku.`,"ui.multiple":`Wskaż wszystkie właściwe miejsca na obrazku.`,"ui.instructions":`Spacja zaznacza miejsce, a ponowne naciśnięcie cofa wybór.`,"ui.area":`Obszar {n}`,"ui.solution":`Właściwe miejsce`,"ui.missed":`pominięte`};export{t as n,e as r,n as t};
|
|
2
|
+
//# sourceMappingURL=hotspot-manifest-CNs1oiZ_.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hotspot-manifest-CNs1oiZ_.js","names":["hotspotManifest","en_default","pl_default"],"sources":["../../../../components/src/hotspot/manifest.ts","../../../../components/src/hotspot/messages/ui/en.json","../../../../components/src/hotspot/messages/ui/pl.json"],"sourcesContent":["import type { ComponentManifest } from '@astl/core';\n\n/**\n * Find it in the picture: the student picks the right place on a picture (`multiple`: every right place). The areas\n * are invisible until picked; a picked one gets a marker at its centre. One `flag` slot per area. Coordinates are\n * percent of the picture: x of its width from the left edge, y of its height from the top.\n */\nexport const hotspotManifest: ComponentManifest = {\n tag: 'astl-hotspot',\n version: 1,\n display: 'block',\n graded: true,\n attributes: [\n /** The picture's address, under the URL policy. */\n { name: 'src', type: 'url', visibility: 'public', required: true },\n /** What the picture shows, for students who cannot see it; it names the group of areas. Never the answer. */\n { name: 'alt', type: 'string', visibility: 'public', required: true },\n /** The picture's size in pixels, so its space is kept while it loads (optional, as on an `img`). */\n { name: 'width', type: 'integer', visibility: 'public', min: 1 },\n { name: 'height', type: 'integer', visibility: 'public', min: 1 },\n /** Several areas may be right: checkboxes instead of radio buttons. */\n { name: 'multiple', type: 'boolean', visibility: 'public', default: false },\n /** Outline each area while the pointer is over it. */\n { name: 'outline', type: 'boolean', visibility: 'public', default: false },\n ],\n children: [\n /** The task. */\n { tag: 'astl-prompt', visibility: 'public', content: 'inline', min: 0, max: 1, attributes: [] },\n /**\n * A place on the picture students can pick: a rectangle (`x`, `y` its top-left corner, `width`, `height`), a circle\n * (`x`, `y` its centre, `r` in percent of the picture's width) or a polygon (`points`, 3 to 64 `x,y` pairs).\n * `label` is its name for screen readers (\"area n\" without one), never the answer; `correct` (private) marks the\n * right ones. Areas are listed in reading order of their centres, whatever the source order.\n */\n {\n tag: 'astl-hotspot-region',\n visibility: 'public',\n content: 'text',\n min: 2,\n max: 30,\n attributes: [\n { name: 'id', type: 'id', visibility: 'public', required: true },\n {\n name: 'shape',\n type: 'enum',\n visibility: 'public',\n values: ['rect', 'circle', 'polygon'],\n default: 'rect',\n },\n { name: 'x', type: 'number', visibility: 'public', min: 0, max: 100 },\n { name: 'y', type: 'number', visibility: 'public', min: 0, max: 100 },\n { name: 'width', type: 'number', visibility: 'public', min: 0, max: 100 },\n { name: 'height', type: 'number', visibility: 'public', min: 0, max: 100 },\n { name: 'r', type: 'number', visibility: 'public', min: 0, max: 50 },\n { name: 'points', type: 'string', visibility: 'public' },\n { name: 'label', type: 'string', visibility: 'public' },\n { name: 'correct', type: 'boolean', visibility: 'private', default: false },\n ],\n },\n ],\n scoring: { default: 'all', modes: { all: 'all-correct', 'per-region': 'proportional' } },\n variants: null,\n slotKinds: ['flag'],\n issues: [\n 'HOTSPOT_ALT_EMPTY',\n 'HOTSPOT_REGION_INCOMPLETE',\n 'HOTSPOT_REGION_POINTS',\n 'HOTSPOT_REGION_OUTSIDE',\n 'HOTSPOT_REGION_EMPTY',\n 'HOTSPOT_CORRECT_MISSING',\n 'HOTSPOT_SINGLE_MANY_CORRECT',\n 'HOTSPOT_ALL_CORRECT',\n 'HOTSPOT_PROMPT_EMPTY',\n ],\n messages: 'astl.hotspot',\n a11y: {\n pattern:\n 'a group of native radio buttons (one right place) or checkboxes (several), named by the alt text: Tab reaches the areas, Space picks one and picks it again to undo; in a radio group the arrow keys pick the next area',\n keys: ['Tab', 'Space', 'ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'],\n },\n cssParts: ['hotspot', 'prompt', 'picture', 'region', 'marker', 'verdict', 'solution'],\n};\n","{\n \"ui.single\": \"Pick the right place in the picture.\",\n \"ui.multiple\": \"Pick every right place in the picture.\",\n \"ui.instructions\": \"Space picks a place, and picks it again to undo.\",\n \"ui.area\": \"Area {n}\",\n \"ui.solution\": \"Right place\",\n \"ui.missed\": \"missed\"\n}\n","{\n \"ui.single\": \"Wskaż właściwe miejsce na obrazku.\",\n \"ui.multiple\": \"Wskaż wszystkie właściwe miejsca na obrazku.\",\n \"ui.instructions\": \"Spacja zaznacza miejsce, a ponowne naciśnięcie cofa wybór.\",\n \"ui.area\": \"Obszar {n}\",\n \"ui.solution\": \"Właściwe miejsce\",\n \"ui.missed\": \"pominięte\"\n}\n"],"mappings":"AAOA,IAAaA,EAAqC,CAChD,IAAK,eACL,QAAS,EACT,QAAS,QACT,OAAQ,GACR,WAAY,CAEV,CAAE,KAAM,MAAO,KAAM,MAAO,WAAY,SAAU,SAAU,EAAK,EAEjE,CAAE,KAAM,MAAO,KAAM,SAAU,WAAY,SAAU,SAAU,EAAK,EAEpE,CAAE,KAAM,QAAS,KAAM,UAAW,WAAY,SAAU,IAAK,CAAE,EAC/D,CAAE,KAAM,SAAU,KAAM,UAAW,WAAY,SAAU,IAAK,CAAE,EAEhE,CAAE,KAAM,WAAY,KAAM,UAAW,WAAY,SAAU,QAAS,EAAM,EAE1E,CAAE,KAAM,UAAW,KAAM,UAAW,WAAY,SAAU,QAAS,EAAM,CAC3E,EACA,SAAU,CAER,CAAE,IAAK,cAAe,WAAY,SAAU,QAAS,SAAU,IAAK,EAAG,IAAK,EAAG,WAAY,CAAC,CAAE,EAO9F,CACE,IAAK,sBACL,WAAY,SACZ,QAAS,OACT,IAAK,EACL,IAAK,GACL,WAAY,CACV,CAAE,KAAM,KAAM,KAAM,KAAM,WAAY,SAAU,SAAU,EAAK,EAC/D,CACE,KAAM,QACN,KAAM,OACN,WAAY,SACZ,OAAQ,CAAC,OAAQ,SAAU,SAAS,EACpC,QAAS,MACX,EACA,CAAE,KAAM,IAAK,KAAM,SAAU,WAAY,SAAU,IAAK,EAAG,IAAK,GAAI,EACpE,CAAE,KAAM,IAAK,KAAM,SAAU,WAAY,SAAU,IAAK,EAAG,IAAK,GAAI,EACpE,CAAE,KAAM,QAAS,KAAM,SAAU,WAAY,SAAU,IAAK,EAAG,IAAK,GAAI,EACxE,CAAE,KAAM,SAAU,KAAM,SAAU,WAAY,SAAU,IAAK,EAAG,IAAK,GAAI,EACzE,CAAE,KAAM,IAAK,KAAM,SAAU,WAAY,SAAU,IAAK,EAAG,IAAK,EAAG,EACnE,CAAE,KAAM,SAAU,KAAM,SAAU,WAAY,QAAS,EACvD,CAAE,KAAM,QAAS,KAAM,SAAU,WAAY,QAAS,EACtD,CAAE,KAAM,UAAW,KAAM,UAAW,WAAY,UAAW,QAAS,EAAM,CAC5E,CACF,CACF,EACA,QAAS,CAAE,QAAS,MAAO,MAAO,CAAE,IAAK,cAAe,aAAc,cAAe,CAAE,EACvF,SAAU,KACV,UAAW,CAAC,MAAM,EAClB,OAAQ,CACN,oBACA,4BACA,wBACA,yBACA,uBACA,0BACA,8BACA,sBACA,sBACF,EACA,SAAU,eACV,KAAM,CACJ,QACE,0NACF,KAAM,CAAC,MAAO,QAAS,UAAW,YAAa,YAAa,YAAY,CAC1E,EACA,SAAU,CAAC,UAAW,SAAU,UAAW,SAAU,SAAU,UAAW,UAAU,CACtF,E"}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import{C as e,E as t,T as n,b as r,hn as i,n as a,v as o,y as s}from"./runtime-DxAbpr3S.js";import{i as c,n as l,r as u,t as d}from"./picture-D10YRMYH.js";import{n as f,r as p,t as m}from"./hotspot-manifest-CNs1oiZ_.js";import{t as h}from"./live-jdiyYln2.js";import{t as g}from"./block-styles-CKo9x7Vt.js";import{i as _,n as v,o as y,r as b,t as x}from"./picture-view-BKnAyScQ.js";var S=`astl.hotspot`,C=[{namespace:S,locale:`en`,messages:f},{namespace:S,locale:`pl`,messages:m}];function w({region:e},t){if(e.shape===`rect`)return n`<rect class="shape" width="100" height="100"></rect>`;if(e.shape===`circle`)return n`<ellipse class="shape" cx="50" cy="50" rx="50" ry="50"></ellipse>`;let r=l(e,t),i=Math.max(r.right-r.left,1e-6),a=Math.max(r.bottom-r.top,1e-6),o=e.points.map(([e,t])=>`${(e-r.left)/i*100},${(t-r.top)/a*100}`);return n`<polygon class="shape" points=${o.join(` `)}></polygon>`}var T=class extends a{static manifest=p;static messages=C;static shadowRootOptions={...s.shadowRootOptions,slotAssignment:`manual`};static properties={picked:{state:!0},loaded:{state:!0}};static styles=[t`
|
|
2
|
+
fieldset {
|
|
3
|
+
display: flex;
|
|
4
|
+
flex-direction: column;
|
|
5
|
+
gap: var(--astl-space-3);
|
|
6
|
+
}
|
|
7
|
+
.group-verdict {
|
|
8
|
+
margin-block: 0;
|
|
9
|
+
}
|
|
10
|
+
`,t`
|
|
11
|
+
.region {
|
|
12
|
+
pointer-events: none;
|
|
13
|
+
}
|
|
14
|
+
.region[data-shape='circle'] {
|
|
15
|
+
inline-size: calc(2 * var(--r));
|
|
16
|
+
block-size: auto;
|
|
17
|
+
aspect-ratio: 1;
|
|
18
|
+
border-radius: 50%;
|
|
19
|
+
translate: 0 -50%;
|
|
20
|
+
}
|
|
21
|
+
.region svg {
|
|
22
|
+
position: absolute;
|
|
23
|
+
inset: 0;
|
|
24
|
+
inline-size: 100%;
|
|
25
|
+
block-size: 100%;
|
|
26
|
+
overflow: visible;
|
|
27
|
+
}
|
|
28
|
+
.shape {
|
|
29
|
+
fill: transparent;
|
|
30
|
+
stroke: transparent;
|
|
31
|
+
stroke-width: calc(2 * var(--astl-outline-width));
|
|
32
|
+
vector-effect: non-scaling-stroke;
|
|
33
|
+
pointer-events: all;
|
|
34
|
+
cursor: pointer;
|
|
35
|
+
touch-action: manipulation;
|
|
36
|
+
}
|
|
37
|
+
.region[data-locked] .shape {
|
|
38
|
+
cursor: default;
|
|
39
|
+
}
|
|
40
|
+
:host([outline]) .region:not([data-locked]) .shape:hover,
|
|
41
|
+
.region:has(:focus-visible) .shape {
|
|
42
|
+
stroke: var(--astl-accent);
|
|
43
|
+
}
|
|
44
|
+
.region[data-solution] .shape {
|
|
45
|
+
stroke: var(--astl-success);
|
|
46
|
+
stroke-width: var(--astl-focus-width);
|
|
47
|
+
}
|
|
48
|
+
.region[data-solution]:not([data-picked]) .shape {
|
|
49
|
+
stroke-dasharray: 2 4;
|
|
50
|
+
stroke-linecap: round;
|
|
51
|
+
}
|
|
52
|
+
.region[data-solution] svg {
|
|
53
|
+
filter: drop-shadow(0 0 1px var(--astl-surface)) drop-shadow(0 0 1px var(--astl-surface));
|
|
54
|
+
}
|
|
55
|
+
`,t`
|
|
56
|
+
.marker,
|
|
57
|
+
.mark {
|
|
58
|
+
--size: 1.75rem;
|
|
59
|
+
box-sizing: border-box;
|
|
60
|
+
display: grid;
|
|
61
|
+
place-items: center;
|
|
62
|
+
inline-size: var(--size);
|
|
63
|
+
block-size: var(--size);
|
|
64
|
+
border: var(--astl-focus-width) solid var(--astl-selected);
|
|
65
|
+
border-radius: 50%;
|
|
66
|
+
background: var(--astl-surface);
|
|
67
|
+
color: var(--astl-selected);
|
|
68
|
+
pointer-events: none;
|
|
69
|
+
z-index: 100;
|
|
70
|
+
}
|
|
71
|
+
.dot {
|
|
72
|
+
inline-size: 0.6rem;
|
|
73
|
+
block-size: 0.6rem;
|
|
74
|
+
border-radius: 50%;
|
|
75
|
+
background: currentColor;
|
|
76
|
+
}
|
|
77
|
+
.marker[data-verdict] {
|
|
78
|
+
background: var(--astl-verdict-soft);
|
|
79
|
+
}
|
|
80
|
+
.marker .astl-verdict-icon,
|
|
81
|
+
.mark .astl-verdict-icon {
|
|
82
|
+
inline-size: 1rem;
|
|
83
|
+
block-size: 1rem;
|
|
84
|
+
}
|
|
85
|
+
.mark {
|
|
86
|
+
border-color: var(--astl-success);
|
|
87
|
+
background: transparent;
|
|
88
|
+
}
|
|
89
|
+
.marker,
|
|
90
|
+
.mark {
|
|
91
|
+
box-shadow: 0 0 0 var(--astl-outline-width) var(--astl-surface);
|
|
92
|
+
}
|
|
93
|
+
@media (forced-colors: active) {
|
|
94
|
+
.shape {
|
|
95
|
+
stroke: transparent;
|
|
96
|
+
}
|
|
97
|
+
:host([outline]) .region:not([data-locked]) .shape:hover,
|
|
98
|
+
.region:has(:focus-visible) .shape,
|
|
99
|
+
.region[data-solution] .shape {
|
|
100
|
+
stroke: Highlight;
|
|
101
|
+
}
|
|
102
|
+
.dot {
|
|
103
|
+
background: CanvasText;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
`,b,g];constructor(){super(),this.picked=new Set,this.loaded=null}get multiple(){return this.booleanAttribute(`multiple`)}get regions(){return this.childElements(`astl-hotspot-region`)}get slotIds(){return this.id===``?[]:this.regions.map(e=>e.id)}getAnswers(){return this.id===``?{}:Object.fromEntries([...this.picked].map(e=>[e,i]))}setAnswers(e){let t=new Set(this.regions.map(e=>e.id)),n=new Set(this.picked);for(let[r,i]of Object.entries(e))t.has(r)&&(i===`true`?this.multiple?n.add(r):n=new Set([r]):n.delete(r));this.picked=n}units(){return{answered:+(this.picked.size>0),total:1}}render(){let t=this.uiLanguage,n=this.multiple,r=x(this,this.loaded),i=this.regions.map((e,t)=>({el:e,index:t,region:c(t=>e.getAttribute(t))})),a=[...i].sort((e,t)=>d(t.region,r)-d(e.region,r)),o=new Map(a.map((e,t)=>[e.el.id,t+1]));return e`<fieldset part="hotspot">
|
|
107
|
+
<legend part="prompt">
|
|
108
|
+
<slot data-tag="astl-prompt"></slot>
|
|
109
|
+
<span class="hint" lang=${t.lang}><bdi>${this.t(n?`ui.multiple`:`ui.single`)}</bdi></span>
|
|
110
|
+
</legend>
|
|
111
|
+
<span class="astl-vh" id="instructions" lang=${t.lang} dir=${t.dir}>${this.t(`ui.instructions`)}</span>
|
|
112
|
+
${_(this,r,e=>{this.loaded=e},[...i.map(e=>this.#t(e,r,o.get(e.el.id)??0)),...i.map(e=>this.#n(e))],{role:n?`group`:`radiogroup`,label:this.getAttribute(`alt`)??``,describedBy:this.disabled?void 0:`instructions`})}
|
|
113
|
+
${this.renderGroupVerdict()}
|
|
114
|
+
</fieldset>`}#e(e){return this.solution?.[e]===`true`&&!this.picked.has(e)}#t(t,n,a){let{el:o,index:s,region:c}=t,u=o.id,d=this.picked.has(u),f=d?this.slotVerdict(u):null,p=this.solution?.[u]===i,m=o.getAttribute(`label`)?.trim()??``,g=[f===null?``:`verdict-${s}`,this.#e(u)?`solution-${s}`:``].filter(e=>e!==``).join(` `),_=l(c,n),b=c.shape===`circle`?v({x:c.x-c.r,y:c.y,r:c.r}):v({x:_.left,y:_.top,w:_.right-_.left,h:_.bottom-_.top});return e`<div
|
|
115
|
+
class="region box astl-ring"
|
|
116
|
+
part="region"
|
|
117
|
+
data-region=${u}
|
|
118
|
+
data-shape=${c.shape}
|
|
119
|
+
?data-picked=${d}
|
|
120
|
+
?data-solution=${p}
|
|
121
|
+
?data-locked=${this.disabled}
|
|
122
|
+
${y({...b,"z-index":String(a)})}
|
|
123
|
+
@click=${()=>this.#r(u)}
|
|
124
|
+
>
|
|
125
|
+
<input
|
|
126
|
+
class="astl-vh"
|
|
127
|
+
type=${this.multiple?`checkbox`:`radio`}
|
|
128
|
+
name="hotspot"
|
|
129
|
+
value=${u}
|
|
130
|
+
.checked=${h(d)}
|
|
131
|
+
?disabled=${this.disabled}
|
|
132
|
+
aria-label=${m||this.t(`ui.area`,{n:s+1})}
|
|
133
|
+
lang=${m===``?this.uiLanguage.lang:r}
|
|
134
|
+
aria-describedby=${g===``?r:g}
|
|
135
|
+
@click=${e=>{e.stopPropagation(),this.#r(u)}}
|
|
136
|
+
@change=${e=>{e.target.checked&&!this.picked.has(u)&&this.#r(u)}}
|
|
137
|
+
@keyup=${e=>{e.key===` `&&!this.multiple&&d&&(e.preventDefault(),this.#r(u))}}
|
|
138
|
+
/>
|
|
139
|
+
<svg viewBox="0 0 100 100" preserveAspectRatio="none" aria-hidden="true" focusable="false">
|
|
140
|
+
${w(t,n)}
|
|
141
|
+
</svg>
|
|
142
|
+
</div>`}#n({el:t,index:n,region:i}){let a=t.id,[s,c]=u(i);if(this.picked.has(a)){let t=this.slotVerdict(a);return e`<span
|
|
143
|
+
class="marker point astl-box"
|
|
144
|
+
part="marker"
|
|
145
|
+
data-marker=${a}
|
|
146
|
+
data-verdict=${o(t??void 0)}
|
|
147
|
+
${y(v({x:s,y:c}))}
|
|
148
|
+
>${t===null?e`<span class="dot"></span>`:this.renderVerdict(t,{hiddenWord:!0,id:`verdict-${n}`})}</span
|
|
149
|
+
>`}if(!this.#e(a))return r;let l=this.uiLanguage;return e`<span class="mark point" part="solution" data-mark=${a} ${y(v({x:s,y:c}))}
|
|
150
|
+
><span class="astl-vh" id="solution-${n}" lang=${l.lang} dir=${l.dir}
|
|
151
|
+
>${this.t(`ui.solution`)}, ${this.t(`ui.missed`)}</span
|
|
152
|
+
></span
|
|
153
|
+
>`}#r(e){if(this.disabled)return;if(this.picked.has(e)){let t=new Set(this.picked);t.delete(e),this.picked=t,this.emitChange({[e]:``});return}let t=this.multiple?[]:[...this.picked];this.picked=this.multiple?new Set([...this.picked,e]):new Set([e]),this.emitChange({...Object.fromEntries(t.map(e=>[e,``])),[e]:i})}},E={manifest:p,element:T,messages:C};export{E as hotspotElement};
|
|
154
|
+
//# sourceMappingURL=hotspot-oel1Eelo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hotspot-oel1Eelo.js","names":["en","pl","w","LitElement","live","nothing","ifDefined","b","i$1","w","A","FLAG_SELECTED","AstlElement","i","readRegion","boundsOf","centreOf","areaOf","en_default","hotspotManifest","pl_default","l","blockStyles","renderPicture","percent","styles","pictureStyles","aspectOf","namespace","hotspotUiMessages","shapeOf","region","box","aspect","w$1","h","points","x","y","HotspotElement","id","known","next","value","answers","ui","multiple","areas","el","name","lower","a","layer","area","loaded","#renderRegion","#renderMarker","checked","verdict","solution","label","describedBy","index","#solutionMark","ref","place","#toggle","event","before","old","hotspotElement"],"sources":["../../../../components/src/hotspot/ui-messages.ts","../../../../components/src/hotspot/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.hotspot';\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 `hotspotMessages` would put the authoring strings into the element's chunk.\n */\nexport const hotspotUiMessages: readonly MessageCatalog[] = [\n { namespace, locale: 'en', messages: en },\n { namespace, locale: 'pl', messages: pl },\n];\n","import {\n type Answers,\n type ComponentManifest,\n FLAG_SELECTED,\n type MessageCatalog,\n type Units,\n} from '@astl/core';\nimport { AstlElement, type ElementRegistration } from '@astl/player';\nimport {\n type CSSResultGroup,\n css,\n html,\n LitElement,\n nothing,\n type PropertyDeclarations,\n type SVGTemplateResult,\n svg,\n type TemplateResult,\n} from 'lit';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { live } from 'lit/directives/live.js';\nimport { blockStyles } from '../block-styles.js';\nimport { areaOf, boundsOf, centreOf, type Region, readRegion } from '../picture.js';\nimport { aspectOf, percent, pictureStyles, renderPicture, styles } from '../picture-view.js';\nimport { hotspotManifest } from './manifest.js';\nimport { hotspotUiMessages } from './ui-messages.js';\n\ninterface Area {\n readonly el: HTMLElement;\n readonly index: number;\n readonly region: Region;\n}\n\n/**\n * An area's shape in its own box: a rectangle fills it, a circle's box is square (so the circle stays round), a\n * polygon's points are placed in its bounding box.\n */\nfunction shapeOf({ region }: Area, aspect: number): SVGTemplateResult {\n if (region.shape === 'rect') return svg`<rect class=\"shape\" width=\"100\" height=\"100\"></rect>`;\n if (region.shape === 'circle')\n return svg`<ellipse class=\"shape\" cx=\"50\" cy=\"50\" rx=\"50\" ry=\"50\"></ellipse>`;\n const box = boundsOf(region, aspect);\n const w = Math.max(box.right - box.left, 1e-6);\n const h = Math.max(box.bottom - box.top, 1e-6);\n const points = region.points.map(([x, y]) => `${((x - box.left) / w) * 100},${((y - box.top) / h) * 100}`);\n return svg`<polygon class=\"shape\" points=${points.join(' ')}></polygon>`;\n}\n\n/**\n * `<astl-hotspot>`: the picture with an invisible native radio button (single) or checkbox (`multiple`) over each\n * area, so the browser gives the keyboard behaviour: Tab to the areas, Space picks; in a radio group the arrow keys\n * pick the next one. Picking a picked area again undoes it, with a radio too. A tap or a click on an area does the\n * same. A picked area gets a marker at its centre; areas are invisible otherwise (outlined under the pointer with\n * `outline`). Larger areas lie lower, so a small area inside a large one stays on top. Slots: one flag per area.\n */\nexport class HotspotElement extends AstlElement {\n static override manifest: ComponentManifest = hotspotManifest;\n static override messages: readonly MessageCatalog[] = hotspotUiMessages;\n static override shadowRootOptions: ShadowRootInit = {\n ...LitElement.shadowRootOptions,\n slotAssignment: 'manual',\n };\n\n static override properties: PropertyDeclarations = {\n picked: { state: true },\n loaded: { 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 picture between the task and the group verdict line, which the fieldset's gap spaces.\n css`\n fieldset {\n display: flex;\n flex-direction: column;\n gap: var(--astl-space-3);\n }\n .group-verdict {\n margin-block: 0;\n }\n `,\n // An area's box takes the pointer on its shape only (the SVG shape), so a press next to a circle or a polygon\n // reaches the area below; no double-tap zoom on it, so a tap picks at once. A circle's box is square in pixels:\n // its radius is a share of the picture's width.\n css`\n .region {\n pointer-events: none;\n }\n .region[data-shape='circle'] {\n inline-size: calc(2 * var(--r));\n block-size: auto;\n aspect-ratio: 1;\n border-radius: 50%;\n translate: 0 -50%;\n }\n .region svg {\n position: absolute;\n inset: 0;\n inline-size: 100%;\n block-size: 100%;\n overflow: visible;\n }\n .shape {\n fill: transparent;\n stroke: transparent;\n stroke-width: calc(2 * var(--astl-outline-width));\n vector-effect: non-scaling-stroke;\n pointer-events: all;\n cursor: pointer;\n touch-action: manipulation;\n }\n .region[data-locked] .shape {\n cursor: default;\n }\n :host([outline]) .region:not([data-locked]) .shape:hover,\n .region:has(:focus-visible) .shape {\n stroke: var(--astl-accent);\n }\n .region[data-solution] .shape {\n stroke: var(--astl-success);\n stroke-width: var(--astl-focus-width);\n }\n .region[data-solution]:not([data-picked]) .shape {\n stroke-dasharray: 2 4;\n stroke-linecap: round;\n }\n .region[data-solution] svg {\n filter: drop-shadow(0 0 1px var(--astl-surface)) drop-shadow(0 0 1px var(--astl-surface));\n }\n `,\n // A marker at a picked area's centre: a ring with a dot (a shape, never colour alone), or the verdict icon in a\n // ring of the verdict's colour and style. A right place left unpicked (missed) looks apart from a found one: its\n // outline dotted (above) and an empty ring, no tick; its own word (missed) is read. Neither takes the pointer: a\n // press goes to the area below. Both have a halo of the surface colour, so they show on light and dark pictures.\n css`\n .marker,\n .mark {\n --size: 1.75rem;\n box-sizing: border-box;\n display: grid;\n place-items: center;\n inline-size: var(--size);\n block-size: var(--size);\n border: var(--astl-focus-width) solid var(--astl-selected);\n border-radius: 50%;\n background: var(--astl-surface);\n color: var(--astl-selected);\n pointer-events: none;\n z-index: 100;\n }\n .dot {\n inline-size: 0.6rem;\n block-size: 0.6rem;\n border-radius: 50%;\n background: currentColor;\n }\n .marker[data-verdict] {\n background: var(--astl-verdict-soft);\n }\n .marker .astl-verdict-icon,\n .mark .astl-verdict-icon {\n inline-size: 1rem;\n block-size: 1rem;\n }\n .mark {\n border-color: var(--astl-success);\n background: transparent;\n }\n .marker,\n .mark {\n box-shadow: 0 0 0 var(--astl-outline-width) var(--astl-surface);\n }\n @media (forced-colors: active) {\n .shape {\n stroke: transparent;\n }\n :host([outline]) .region:not([data-locked]) .shape:hover,\n .region:has(:focus-visible) .shape,\n .region[data-solution] .shape {\n stroke: Highlight;\n }\n .dot {\n background: CanvasText;\n }\n }\n `,\n pictureStyles,\n blockStyles,\n ];\n\n /** Picked area ids. */\n declare protected picked: ReadonlySet<string>;\n /** The loaded picture's width over its height; null until it loads. */\n declare protected loaded: number | null;\n\n constructor() {\n super();\n this.picked = new Set();\n this.loaded = null;\n }\n\n get multiple(): boolean {\n return this.booleanAttribute('multiple');\n }\n\n /** `<astl-hotspot-region>` children, in view order (reading order of their centres). */\n get regions(): readonly HTMLElement[] {\n return this.childElements('astl-hotspot-region');\n }\n\n get slotIds(): readonly string[] {\n return this.id === '' ? [] : this.regions.map((region) => region.id);\n }\n\n getAnswers(): Answers {\n return this.id === '' ? {} : Object.fromEntries([...this.picked].map((id) => [id, FLAG_SELECTED]));\n }\n\n /** Flags other than \"true\" clear an area; with one right place, a picked area replaces the one before. */\n setAnswers(answers: Answers): void {\n const known = new Set(this.regions.map((region) => region.id));\n let next = new Set(this.picked);\n for (const [id, value] of Object.entries(answers)) {\n if (!known.has(id)) continue;\n if (value !== FLAG_SELECTED) next.delete(id);\n else if (this.multiple) next.add(id);\n else next = new Set([id]);\n }\n this.picked = next;\n }\n\n units(): Units {\n return { answered: this.picked.size > 0 ? 1 : 0, total: 1 };\n }\n\n protected override render(): TemplateResult {\n const ui = this.uiLanguage;\n const multiple = this.multiple;\n const aspect = aspectOf(this, this.loaded);\n const areas: Area[] = this.regions.map((el, index) => ({\n el,\n index,\n region: readRegion((name) => el.getAttribute(name)),\n }));\n // Larger areas lie lower, so a small area inside a large one stays on top and can be picked.\n const lower = [...areas].sort((a, b) => areaOf(b.region, aspect) - areaOf(a.region, aspect));\n const layer = new Map(lower.map((area, i) => [area.el.id, i + 1]));\n return html`<fieldset part=\"hotspot\">\n <legend part=\"prompt\">\n <slot data-tag=\"astl-prompt\"></slot>\n <span class=\"hint\" lang=${ui.lang}><bdi>${this.t(multiple ? 'ui.multiple' : 'ui.single')}</bdi></span>\n </legend>\n <span class=\"astl-vh\" id=\"instructions\" lang=${ui.lang} dir=${ui.dir}>${this.t('ui.instructions')}</span>\n ${renderPicture(\n this,\n aspect,\n (loaded) => {\n this.loaded = loaded;\n },\n [\n ...areas.map((area) => this.#renderRegion(area, aspect, layer.get(area.el.id) ?? 0)),\n ...areas.map((area) => this.#renderMarker(area)),\n ],\n {\n role: multiple ? 'group' : 'radiogroup',\n label: this.getAttribute('alt') ?? '',\n describedBy: this.disabled ? undefined : 'instructions',\n },\n )}\n ${this.renderGroupVerdict()}\n </fieldset>`;\n }\n\n /** Whether the solution marks an area: a right place left unpicked (a picked one has its marker). */\n #solutionMark(id: string): boolean {\n return this.solution?.[id] === FLAG_SELECTED && !this.picked.has(id);\n }\n\n #renderRegion(area: Area, aspect: number, layer: number): TemplateResult {\n const { el, index, region } = area;\n const id = el.id;\n const checked = this.picked.has(id);\n const verdict = checked ? this.slotVerdict(id) : null;\n const solution = this.solution?.[id] === FLAG_SELECTED;\n const label = el.getAttribute('label')?.trim() ?? '';\n const describedBy = [\n verdict === null ? '' : `verdict-${index}`,\n this.#solutionMark(id) ? `solution-${index}` : '',\n ]\n .filter((ref) => ref !== '')\n .join(' ');\n const box = boundsOf(region, aspect);\n const place =\n region.shape === 'circle'\n ? percent({ x: region.x - region.r, y: region.y, r: region.r })\n : percent({ x: box.left, y: box.top, w: box.right - box.left, h: box.bottom - box.top });\n return html`<div\n class=\"region box astl-ring\"\n part=\"region\"\n data-region=${id}\n data-shape=${region.shape}\n ?data-picked=${checked}\n ?data-solution=${solution}\n ?data-locked=${this.disabled}\n ${styles({ ...place, 'z-index': String(layer) })}\n @click=${() => this.#toggle(id)}\n >\n <input\n class=\"astl-vh\"\n type=${this.multiple ? 'checkbox' : 'radio'}\n name=\"hotspot\"\n value=${id}\n .checked=${live(checked)}\n ?disabled=${this.disabled}\n aria-label=${label || this.t('ui.area', { n: index + 1 })}\n lang=${label === '' ? this.uiLanguage.lang : nothing}\n aria-describedby=${describedBy === '' ? nothing : describedBy}\n @click=${(event: MouseEvent) => {\n event.stopPropagation();\n this.#toggle(id);\n }}\n @change=${(event: Event) => {\n // An arrow key in a radio group checks the next radio; a click is not promised for it.\n if ((event.target as HTMLInputElement).checked && !this.picked.has(id)) this.#toggle(id);\n }}\n @keyup=${(event: KeyboardEvent) => {\n // Space on a checked radio does nothing natively: here it undoes the pick, as on a checkbox. Prevented, so\n // the browser does not click the radio it finds unchecked by then.\n if (event.key !== ' ' || this.multiple || !checked) return;\n event.preventDefault();\n this.#toggle(id);\n }}\n />\n <svg viewBox=\"0 0 100 100\" preserveAspectRatio=\"none\" aria-hidden=\"true\" focusable=\"false\">\n ${shapeOf(area, aspect)}\n </svg>\n </div>`;\n }\n\n #renderMarker({ el, index, region }: Area): TemplateResult | typeof nothing {\n const id = el.id;\n const [x, y] = centreOf(region);\n if (this.picked.has(id)) {\n const verdict = this.slotVerdict(id);\n return html`<span\n class=\"marker point astl-box\"\n part=\"marker\"\n data-marker=${id}\n data-verdict=${ifDefined(verdict ?? undefined)}\n ${styles(percent({ x, y }))}\n >${\n verdict === null\n ? html`<span class=\"dot\"></span>`\n : this.renderVerdict(verdict, { hiddenWord: true, id: `verdict-${index}` })\n }</span\n >`;\n }\n if (!this.#solutionMark(id)) return nothing;\n const ui = this.uiLanguage;\n return html`<span class=\"mark point\" part=\"solution\" data-mark=${id} ${styles(percent({ x, y }))}\n ><span class=\"astl-vh\" id=\"solution-${index}\" lang=${ui.lang} dir=${ui.dir}\n >${this.t('ui.solution')}, ${this.t('ui.missed')}</span\n ></span\n >`;\n }\n\n /** Picks area `id`, or undoes its pick; with one right place, a new pick replaces the one before. */\n #toggle(id: string): void {\n if (this.disabled) return;\n if (this.picked.has(id)) {\n const next = new Set(this.picked);\n next.delete(id);\n this.picked = next;\n this.emitChange({ [id]: '' });\n return;\n }\n const before = this.multiple ? [] : [...this.picked];\n this.picked = this.multiple ? new Set([...this.picked, id]) : new Set([id]);\n this.emitChange({ ...Object.fromEntries(before.map((old) => [old, ''])), [id]: FLAG_SELECTED });\n }\n}\n\nexport const hotspotElement: ElementRegistration = {\n manifest: hotspotManifest,\n element: HotspotElement,\n messages: hotspotUiMessages,\n};\n"],"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