@pie-players/pie-assessment-toolkit 1.0.0-beta.0 → 1.0.0-beta.1

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.
@@ -4,6 +4,8 @@
4
4
  * Defines the context types passed to tools for making visibility and behavior decisions.
5
5
  * Each context level provides increasingly specific information about where the tool is being used.
6
6
  */
7
+ import { runtimeElementTags } from "@pie-players/pie-players-shared/pie";
8
+ import { parseVersionedTagName } from "@pie-players/pie-players-shared/pie/tag-names";
7
9
  /**
8
10
  * Type guard to check if context is at item level
9
11
  */
@@ -300,63 +302,81 @@ export function hasMathContent(context) {
300
302
  hasSpacedSubtraction(text) ||
301
303
  hasAppliedPercentage(text));
302
304
  }
303
- const CHOICE_INTERACTION_ELEMENTS = new Set([
304
- "multiple-choice",
305
- "inline-choice",
306
- "select-text",
307
- "ebsr",
308
- ]);
309
- // Content names one interaction several ways: `multiple-choice`, `pie-multiple-choice`,
310
- // `pie-element-multiple-choice`, a runtime `--version-*` tag, or any tag the item's
311
- // `elements` map binds to `@pie-element/multiple-choice`.
312
- const baseElementName = (tag) => tag
313
- .toLowerCase()
314
- .replace(/--version-[0-9a-z-]+$/, "")
315
- .replace(/^pie-(element-)?/, "");
316
- function isChoiceElement(tag, elements) {
317
- if (CHOICE_INTERACTION_ELEMENTS.has(baseElementName(tag)))
318
- return true;
305
+ function packageSpecFor(tag, elements) {
319
306
  if (!elements || typeof elements !== "object")
320
- return false;
307
+ return undefined;
321
308
  const map = elements;
322
- const spec = map[tag] ?? map[tag.replace(/--version-[0-9A-Za-z-]+$/, "")];
323
- if (typeof spec !== "string")
324
- return false;
325
- const packageName = spec.match(/^@pie-element\/([^@]+)/)?.[1];
326
- return !!packageName && CHOICE_INTERACTION_ELEMENTS.has(packageName);
309
+ const spec = map[tag] ?? map[parseVersionedTagName(tag).baseName];
310
+ return typeof spec === "string" && spec ? spec : undefined;
311
+ }
312
+ function declaredSupports(elementClass) {
313
+ let declared;
314
+ try {
315
+ declared = elementClass.pieSupports;
316
+ }
317
+ catch {
318
+ return undefined;
319
+ }
320
+ if (!Array.isArray(declared))
321
+ return undefined;
322
+ return declared.filter((term) => typeof term === "string");
323
+ }
324
+ function readElementSupports(model, elements) {
325
+ if (!model || typeof model !== "object")
326
+ return null;
327
+ const { id, element } = model;
328
+ if (typeof element !== "string" || !element)
329
+ return null;
330
+ const packageSpec = packageSpecFor(element, elements);
331
+ const candidates = runtimeElementTags(element, packageSpec);
332
+ const registry = typeof customElements === "undefined" ? undefined : customElements;
333
+ for (const tag of candidates) {
334
+ const elementClass = registry?.get(tag);
335
+ if (elementClass) {
336
+ return {
337
+ elementId: typeof id === "string" ? id : undefined,
338
+ tag: element,
339
+ packageSpec,
340
+ supports: declaredSupports(elementClass),
341
+ pendingTags: [],
342
+ };
343
+ }
344
+ }
345
+ return {
346
+ elementId: typeof id === "string" ? id : undefined,
347
+ tag: element,
348
+ packageSpec,
349
+ supports: undefined,
350
+ pendingTags: registry ? candidates : [],
351
+ };
327
352
  }
328
353
  /**
329
- * Helper to check if context contains choice-based interactions
354
+ * The supports each element of a context declares: the element's own at element
355
+ * level, every element of the item or passage config at those levels, and none
356
+ * elsewhere. A model that names no element renders nothing and is skipped.
330
357
  */
331
- export function hasChoiceInteraction(context) {
358
+ export function elementSupports(context) {
359
+ let config;
360
+ let models;
332
361
  if (isElementContext(context)) {
333
- const config = context.item.config;
334
- if (!config?.models)
335
- return false;
336
- const model = findElementModel(config.models, context.elementId);
337
- if (!model)
338
- return false;
339
- const type = model.element || "";
340
- return isChoiceElement(type, config.elements);
362
+ config = context.item.config;
363
+ models = [findElementModel(config?.models, context.elementId)];
341
364
  }
342
- if (isItemContext(context)) {
343
- const config = context.item.config;
344
- return normalizeModels(config?.models).some((candidate) => {
345
- if (!candidate || typeof candidate !== "object")
346
- return false;
347
- const model = candidate;
348
- const type = model.element || "";
349
- // A model that names its element has answered the question, whichever way
350
- // the answer falls: `placement-ordering`, `categorize` and
351
- // `drag-in-the-blank` each hold their draggables in `choices` without
352
- // being choice interactions. The `choices` heuristic remains for configs
353
- // that name no element.
354
- if (type)
355
- return isChoiceElement(type, config?.elements);
356
- return Array.isArray(model.choices) && model.choices.length > 0;
357
- });
365
+ else if (isItemContext(context)) {
366
+ config = context.item?.config;
367
+ models = normalizeModels(config?.models);
358
368
  }
359
- return false;
369
+ else if (isPassageContext(context)) {
370
+ config = context.passage?.config;
371
+ models = normalizeModels(config?.models);
372
+ }
373
+ else {
374
+ return [];
375
+ }
376
+ return models.flatMap((model) => {
377
+ const supports = readElementSupports(model, config?.elements);
378
+ return supports ? [supports] : [];
379
+ });
360
380
  }
361
381
  /**
362
382
  * Helper to check if context contains text that can be read aloud
@@ -4,6 +4,7 @@ export interface DecidedToolbarTool {
4
4
  toolId: string;
5
5
  required: boolean;
6
6
  alwaysAvailable: boolean;
7
+ activateAtInit: boolean;
7
8
  parameters?: Record<string, unknown>;
8
9
  }
9
10
  /**
@@ -17,6 +17,7 @@ export function createDecidedToolsTracker() {
17
17
  toolId: entry.toolId,
18
18
  required: entry.required,
19
19
  alwaysAvailable: entry.alwaysAvailable,
20
+ activateAtInit: entry.activateAtInit,
20
21
  parameters: entry.parameters,
21
22
  }));
22
23
  if (last?.renderVersion === renderVersion &&
@@ -37,6 +37,8 @@ export const browserFallbackConfig = (config) => {
37
37
  fallback.rate = config.rate;
38
38
  if (config.pitch !== undefined)
39
39
  fallback.pitch = config.pitch;
40
+ if (config.volume !== undefined)
41
+ fallback.volume = config.volume;
40
42
  if (config.mathTokenHighlighting !== undefined) {
41
43
  fallback.mathTokenHighlighting = config.mathTokenHighlighting;
42
44
  }
@@ -437,8 +439,10 @@ class BrowserTTSProviderImpl {
437
439
  utterance.voice = voice;
438
440
  if (this.config?.rate)
439
441
  utterance.rate = this.config.rate;
440
- if (this.config?.pitch)
442
+ if (this.config?.pitch !== undefined)
441
443
  utterance.pitch = this.config.pitch;
444
+ if (this.config?.volume !== undefined)
445
+ utterance.volume = this.config.volume;
442
446
  let didStart = false;
443
447
  let settled = false;
444
448
  let startTimeout = null;
@@ -616,7 +620,7 @@ class BrowserTTSProviderImpl {
616
620
  this.releaseHold();
617
621
  }
618
622
  /**
619
- * Update settings dynamically (rate, pitch, voice)
623
+ * Update settings dynamically (rate, pitch, volume, voice)
620
624
  * Changes take effect on the next speak() call
621
625
  */
622
626
  updateSettings(settings) {
@@ -629,6 +633,9 @@ class BrowserTTSProviderImpl {
629
633
  if (settings.pitch !== undefined) {
630
634
  this.config.pitch = settings.pitch;
631
635
  }
636
+ if (settings.volume !== undefined) {
637
+ this.config.volume = settings.volume;
638
+ }
632
639
  if (settings.voice !== undefined) {
633
640
  this.config.voice = settings.voice;
634
641
  }
@@ -32,8 +32,8 @@ export type { ContentCapabilityPhase, ContentCapabilityPolicy, ResolveContentCap
32
32
  export { resolveContentCapabilities } from "./content-capability-resolution.js";
33
33
  export type { ToolSurfaceHost, ToolSurfaceHostInput, ToolSurfaceHostOptions, ToolSurfaceHostSnapshot, ToolSurfaceScope, } from "./tool-surface-host.js";
34
34
  export { createToolSurfaceHost } from "./tool-surface-host.js";
35
- export type { ToolContext } from "../services/tool-context.js";
36
- export { hasChoiceInteraction, hasMathContent, hasReadableText, hasSpokenContent, hasScienceContent, } from "../services/tool-context.js";
35
+ export type { ElementSupports, ToolContext, } from "../services/tool-context.js";
36
+ export { elementSupports, hasMathContent, hasReadableText, hasSpokenContent, hasScienceContent, } from "../services/tool-context.js";
37
37
  export type { ParsedToolInstanceId } from "../services/tool-instance-id.js";
38
38
  export { createScopedToolId, parseScopedToolId, } from "../services/tool-instance-id.js";
39
39
  export type { ToolComponentFactory, ToolComponentFactoryMap, ToolComponentOverrides, ToolTagMap, } from "./tool-tag-map.js";
@@ -30,7 +30,7 @@ export { reportToolFailure } from "../services/tool-failure.js";
30
30
  export { resolveFallbackToolIcon } from "../services/tool-icons.js";
31
31
  export { resolveContentCapabilities } from "./content-capability-resolution.js";
32
32
  export { createToolSurfaceHost } from "./tool-surface-host.js";
33
- export { hasChoiceInteraction, hasMathContent, hasReadableText, hasSpokenContent, hasScienceContent, } from "../services/tool-context.js";
33
+ export { elementSupports, hasMathContent, hasReadableText, hasSpokenContent, hasScienceContent, } from "../services/tool-context.js";
34
34
  export { createScopedToolId, parseScopedToolId, } from "../services/tool-instance-id.js";
35
35
  export { createToolElement, resolveToolTag } from "./tool-tag-map.js";
36
36
  // Toolbar button/overlay wiring shared by every toolbar-toggle registration,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pie-players/pie-assessment-toolkit",
3
- "version": "1.0.0-beta.0",
3
+ "version": "1.0.0-beta.1",
4
4
  "type": "module",
5
5
  "description": "PIE assessment toolkit: composable services + reference implementation for assessment players and tool coordination",
6
6
  "license": "MIT",
@@ -69,16 +69,16 @@
69
69
  "test": "bun test"
70
70
  },
71
71
  "dependencies": {
72
- "@pie-players/pie-calculator": "1.0.0-beta.0",
73
- "@pie-players/pie-context": "1.0.0-beta.0",
74
- "@pie-players/pie-players-shared": "1.0.0-beta.0",
75
- "@pie-players/pie-tts": "1.0.0-beta.0",
72
+ "@pie-players/pie-calculator": "1.0.0-beta.1",
73
+ "@pie-players/pie-context": "1.0.0-beta.1",
74
+ "@pie-players/pie-players-shared": "1.0.0-beta.1",
75
+ "@pie-players/pie-tts": "1.0.0-beta.1",
76
76
  "speech-rule-engine": "5.0.0-rc.4"
77
77
  },
78
78
  "devDependencies": {
79
79
  "@biomejs/biome": "^2.5.15",
80
80
  "@happy-dom/global-registrator": "^20.14.5",
81
- "@pie-players/tts-client-server": "1.0.0-beta.0",
81
+ "@pie-players/tts-client-server": "1.0.0-beta.1",
82
82
  "svelte": "^5.57.1",
83
83
  "svelte-check": "^4.7.6",
84
84
  "typescript": "^5.9.3"
@@ -1,40 +0,0 @@
1
- import{m as Qj,n as Vj,p as Oj,r as qj}from"./ItemToolBar-hzc5wyjp.js";import{$ as Uj,A as e,B as e0,C as EJ,D as SJ,F as TZ,G as c,H as r,I as J,K as UZ,L as Jj,M as QJ,N as _J,O as b,Q as NJ,R as Zj,S as KZ,T as j0,V as jj,W as XZ,X as U0,Y as OJ,Z as i,_ as wJ,aa as g,ba as Kj,ca as Xj,ha as Lj,ia as Yj,ka as K0,la as Dj,ma as s0,t as BZ,u as qJ,v as n0,w as t0,x as O,y as E,z as YJ}from"./ItemToolBar-3zrc4p3d.js";import{ContextProvider as ej}from"@pie-players/pie-context";function J0(k,N,B,S){if(typeof k?.reportToolFailure==="function"){k.reportToolFailure(N,B,S);return}console.error(`[${N}] ${B} failed:`,S)}function Z0(k){return typeof k.href==="string"}function h0(k){if(!k||typeof k!=="object"||Array.isArray(k))return!1;let N=k;if(typeof N.id!=="string"||N.id.trim().length===0)return!1;if(typeof N.label!=="string"||N.label.trim().length===0)return!1;if(N.ariaLabel!==void 0&&typeof N.ariaLabel!=="string")return!1;if(N.icon!==void 0&&typeof N.icon!=="string")return!1;if(N.tooltip!==void 0&&typeof N.tooltip!=="string")return!1;if(N.active!==void 0&&typeof N.active!=="boolean")return!1;if(N.disabled!==void 0&&typeof N.disabled!=="boolean")return!1;let B=typeof N.href==="string",S=typeof N.onClick==="function";return B!==S}function u0(k){return typeof k==="string"&&k.trimStart().startsWith("<svg")}function c0(k){return typeof k==="string"&&k.trimStart().startsWith("http")}import{sanitizeSvgIcon as i0}from"@pie-players/pie-players-shared/security";import{resolveInterfaceI18n as JU}from"@pie-players/pie-players-shared/i18n/provider";import{collectFocusable as ZU,createFocusTrap as jU,createPointerGesture as UU,FOCUSABLE_SELECTOR as KU,isProgrammaticFocusTarget as XU}from"@pie-players/pie-players-shared";var nj={calculator:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M7 2h10a2 2 0 0 1 2 2v16a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2Zm0 2v4h10V4H7Zm0 6v2h2v-2H7Zm4 0v2h2v-2h-2Zm4 0v2h2v-2h-2Zm-8 4v2h2v-2H7Zm4 0v2h2v-2h-2Zm4 0v2h2v-2h-2Zm-8 4v2h2v-2H7Zm4 0v2h2v-2h-2Zm4 0v2h2v-2h-2Z" fill="currentColor"/></svg>',"volume-up":'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M14 3.23v2.06A7.002 7.002 0 0 1 19 12a7 7 0 0 1-5 6.71v2.06c4.01-.91 7-4.49 7-8.77s-2.99-7.86-7-8.77Zm-2 17.75V3L7 8H3v8h4l5 5Zm4.5-9a4.5 4.5 0 0 0-2.5-4.03v8.05A4.5 4.5 0 0 0 16.5 12Z" fill="currentColor"/></svg>',swatch:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 3a9 9 0 1 0 9 9c0-.55-.45-1-1-1h-2.5a1.5 1.5 0 0 1 0-3H20a1 1 0 0 0 1-1 8.99 8.99 0 0 0-9-4Zm-5.5 9A1.5 1.5 0 1 1 8 13.5 1.5 1.5 0 0 1 6.5 12Zm3-4A1.5 1.5 0 1 1 11 9.5 1.5 1.5 0 0 1 9.5 8Zm5 0A1.5 1.5 0 1 1 16 9.5 1.5 1.5 0 0 1 14.5 8Z" fill="currentColor"/></svg>',"chart-bar":'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M4.75 5a.76.76 0 0 1 .75.75v11c0 .438.313.75.75.75h13a.76.76 0 0 1 .696 1.039.74.74 0 0 1-.696.461h-13C5 19 4 18 4 16.75v-11A.74.74 0 0 1 4.75 5ZM8 8.25a.74.74 0 0 1 .75-.75h6.5a.76.76 0 0 1 .696 1.039.74.74 0 0 1-.696.461h-6.5A.722.722 0 0 1 8 8.25Zm.75 2.25h4.5a.76.76 0 0 1 .696 1.039.74.74 0 0 1-.696.461h-4.5a.723.723 0 0 1-.75-.75.74.74 0 0 1 .75-.75Zm0 3h8.5a.76.76 0 0 1 .696 1.039.74.74 0 0 1-.696.461h-8.5a.723.723 0 0 1-.75-.75.74.74 0 0 1 .75-.75Z" fill="currentColor"/></svg>',beaker:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M5 21c-.85 0-1.454-.38-1.813-1.137-.358-.759-.27-1.463.263-2.113L9 11V5H8a.968.968 0 0 1-.713-.287A.968.968 0 0 1 7 4c0-.283.096-.52.287-.712A.968.968 0 0 1 8 3h8c.283 0 .52.096.712.288.192.191.288.429.288.712s-.096.52-.288.713A.968.968 0 0 1 16 5h-1v6l5.55 6.75c.533.65.62 1.354.262 2.113C20.454 20.62 19.85 21 19 21H5Zm2-3h10l-3.4-4h-3.2L7 18Zm-2 1h14l-6-7.3V5h-2v6.7L5 19Z" fill="currentColor"/></svg>',protractor:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="m6.75 21-.25-2.2 2.85-7.85a3.95 3.95 0 0 0 1.75.95l-2.75 7.55L6.75 21Zm10.5 0-1.6-1.55-2.75-7.55a3.948 3.948 0 0 0 1.75-.95l2.85 7.85-.25 2.2ZM12 11a2.893 2.893 0 0 1-2.125-.875A2.893 2.893 0 0 1 9 8c0-.65.188-1.23.563-1.737A2.935 2.935 0 0 1 11 5.2V3h2v2.2c.583.2 1.063.554 1.438 1.063C14.812 6.77 15 7.35 15 8c0 .833-.292 1.542-.875 2.125A2.893 2.893 0 0 1 12 11Zm0-2c.283 0 .52-.096.713-.287A.967.967 0 0 0 13 8a.967.967 0 0 0-.287-.713A.968.968 0 0 0 12 7a.968.968 0 0 0-.713.287A.967.967 0 0 0 11 8c0 .283.096.52.287.713.192.191.43.287.713.287Z" fill="currentColor"/></svg>',"bars-3":'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M6.85 15c.517 0 .98-.15 1.388-.45.408-.3.695-.692.862-1.175l.375-1.15c.267-.8.2-1.537-.2-2.213C8.875 9.337 8.3 9 7.55 9H4.025l.475 3.925c.083.583.346 1.075.787 1.475.442.4.963.6 1.563.6Zm10.3 0c.6 0 1.12-.2 1.563-.6.441-.4.704-.892.787-1.475L19.975 9h-3.5c-.75 0-1.325.342-1.725 1.025-.4.683-.467 1.425-.2 2.225l.35 1.125c.167.483.454.875.862 1.175.409.3.871.45 1.388.45Zm-10.3 2c-1.1 0-2.063-.363-2.887-1.088a4.198 4.198 0 0 1-1.438-2.737L2 9H1V7h6.55c.733 0 1.404.18 2.013.537A3.906 3.906 0 0 1 11 9h2.025c.35-.617.83-1.104 1.438-1.463A3.892 3.892 0 0 1 16.474 7H23v2h-1l-.525 4.175a4.198 4.198 0 0 1-1.438 2.737A4.238 4.238 0 0 1 17.15 17c-.95 0-1.804-.27-2.562-.813A4.234 4.234 0 0 1 13 14.026l-.375-1.125a21.35 21.35 0 0 1-.1-.363 4.926 4.926 0 0 1-.1-.537h-.85c-.033.2-.067.363-.1.488a21.35 21.35 0 0 1-.1.362L11 14a4.3 4.3 0 0 1-1.588 2.175A4.258 4.258 0 0 1 6.85 17Z" fill="currentColor"/></svg>',ruler:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="m8.8 10.95 2.15-2.175-1.4-1.425-1.1 1.1-1.4-1.4 1.075-1.1L7 4.825 4.825 7 8.8 10.95Zm8.2 8.225L19.175 17l-1.125-1.125-1.1 1.075-1.4-1.4 1.075-1.1-1.425-1.4-2.15 2.15L17 19.175ZM7.25 21H3v-4.25l4.375-4.375L2 7l5-5 5.4 5.4 3.775-3.8c.2-.2.425-.35.675-.45a2.068 2.068 0 0 1 1.55 0c.25.1.475.25.675.45L20.4 4.95c.2.2.35.425.45.675.1.25.15.508.15.775a1.975 1.975 0 0 1-.6 1.425l-3.775 3.8L22 17l-5 5-5.375-5.375L7.25 21ZM5 19h1.4l9.8-9.775L14.775 7.8 5 17.6V19Z" fill="currentColor"/></svg>',"book-open":'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 6.25a6.6 6.6 0 0 0-2.3-1.32A8.6 8.6 0 0 0 7 4.5c-.63 0-1.25.06-1.85.18-.6.12-1.19.3-1.76.54a1.5 1.5 0 0 0-.93 1.4v10.1c0 .52.26.98.68 1.24.42.26.92.28 1.35.06.36-.18.75-.31 1.18-.4.42-.09.86-.13 1.33-.13.78 0 1.53.14 2.24.42.7.28 1.35.7 1.93 1.24l.83-.75.83.75c.58-.54 1.22-.96 1.93-1.24a6.1 6.1 0 0 1 2.24-.42c.47 0 .91.04 1.33.13.43.09.82.22 1.18.4.43.22.93.2 1.35-.06.42-.26.68-.72.68-1.24V6.62c0-.6-.36-1.15-.93-1.4a9.3 9.3 0 0 0-1.76-.54A9.8 9.8 0 0 0 17 4.5a8.6 8.6 0 0 0-2.7.43A6.6 6.6 0 0 0 12 6.25Zm1 10.06V8.02c.55-.5 1.16-.88 1.84-1.13A6 6 0 0 1 17 6.5c.45 0 .89.04 1.32.11.43.08.85.19 1.26.34v9.24a8.2 8.2 0 0 0-1.28-.24A10 10 0 0 0 17 15.85c-.72 0-1.42.09-2.09.26a7.7 7.7 0 0 0-1.91.8Zm-2 0a7.7 7.7 0 0 0-1.91-.8 8.4 8.4 0 0 0-2.09-.26c-.44 0-.87.02-1.3.07-.43.05-.86.13-1.28.24V6.95c.41-.15.83-.26 1.26-.34A7.7 7.7 0 0 1 7 6.5c.76 0 1.48.13 2.16.39.68.25 1.29.63 1.84 1.13Z" fill="currentColor"/></svg>',photo:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M4 21c-.55 0-1.02-.2-1.41-.59A1.93 1.93 0 0 1 2 19V5c0-.55.2-1.02.59-1.41A1.93 1.93 0 0 1 4 3h16c.55 0 1.02.2 1.41.59.39.39.59.86.59 1.41v14c0 .55-.2 1.02-.59 1.41-.39.39-.86.59-1.41.59H4Zm0-2h16V5H4v14Zm1.5-2.5h13l-4.1-5.47-3.4 4.47-2.5-3.25L5.5 16.5ZM8.5 10a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3Z" fill="currentColor"/></svg>'};function a0(k){return nj[k]||null}function d0(){let k=null;return(N,B)=>{if(!N)return k=null,null;let S=N.visibleTools.map((GJ)=>({toolId:GJ.toolId,required:GJ.required,alwaysAvailable:GJ.alwaysAvailable,parameters:GJ.parameters}));if(k?.renderVersion===B&&s0(k.tools,S))return k.tools;return k={renderVersion:B,tools:S},S}}import"@pie-players/pie-players-shared/nds-icon-button";var tj=(k,N)=>{if(customElements.get(k))return;try{customElements.define(k,N)}catch(B){if(!(B instanceof DOMException&&B.name==="NotSupportedError"||B&&typeof B==="object"&&B.name==="NotSupportedError")||!customElements.get(k))throw B}},r0=(k,N=BZ)=>{var B=_J(),S=SJ(B);{var GJ=(l)=>{var JJ=l0();j0(JJ,()=>i0(N()),!0),qJ(JJ),b(l,JJ)},gJ=O(()=>u0(N())),xZ=(l)=>{var JJ=LU();r(()=>i(JJ,"src",N())),b(l,JJ)},mJ=O(()=>c0(N())),IZ=(l)=>{let JJ=O(()=>a0(N()));var hJ=_J(),CJ=SJ(hJ);{var LZ=(MJ)=>{var RJ=l0();j0(RJ,()=>i0(J(JJ)),!0),qJ(RJ),b(MJ,RJ)},AZ=(MJ)=>{var RJ=YU();r(()=>OJ(RJ,1,`icon icon-${N()}`,"svelte-1c13522")),b(MJ,RJ)};NJ(CJ,(MJ)=>{if(J(JJ))MJ(LZ);else MJ(AZ,-1)})}b(l,hJ)};NJ(S,(l)=>{if(J(gJ))l(GJ);else if(J(mJ))l(xZ,1);else l(IZ,-1)})}b(k,B)},l0=QJ('<span aria-hidden="true"></span>'),LU=QJ('<img class="item-toolbar__icon-image svelte-1c13522" alt=""/>'),YU=QJ('<i aria-hidden="true"></i>'),o0=QJ("<span></span>"),QU=QJ('<span class="item-toolbar__nds-button-zoom svelte-1c13522"><nds-icon-button></nds-icon-button></span>',2),VU=QJ("<a><!></a>"),DU=QJ('<button type="button"><!></button>'),OU=QJ("<div></div>"),qU=QJ('<div><div class="item-toolbar__tools-row svelte-1c13522"><!> <!> <!></div> <!></div>'),NU={hash:"svelte-1c13522",code:`.item-toolbar.svelte-1c13522 {display:flex;flex-direction:column;align-items:flex-end;min-width:0;max-width:100%;gap:0;--pie-toolbar-tools-row-height: 2rem;--pie-tts-controls-row-height: 2.875rem;}.item-toolbar__tools-row.svelte-1c13522 {display:flex;align-items:center;justify-content:flex-end;flex-wrap:wrap;gap:0.5rem;max-width:100%;min-height:var(--pie-toolbar-tools-row-height);}
2
-
3
- /* A granted section tool must stay reachable even when there isn't room for
4
- every button: scroll the row rather than clipping items past the edge,
5
- which left them impossible to focus, tab to, or click. \`min-width: 0\`
6
- beats the flex default (\`auto\`, i.e. never shrink below content), which
7
- would otherwise keep the row at full content width and make overflow-x
8
- moot. Item and passage rows wrap without an overflow clip so an inline
9
- reading-controls panel can still extend outside the row. */.item-toolbar[data-level="section"].svelte-1c13522 .item-toolbar__tools-row:where(.svelte-1c13522) {flex-wrap:nowrap;justify-content:flex-start;
10
- /* Keep the focus outline inside the scrolling box on both axes. */padding:4px;scroll-padding:4px;box-sizing:border-box;overflow-x:auto;max-width:100%;min-width:0;}.item-toolbar__controls-row.svelte-1c13522 {display:flex;align-items:center;justify-content:flex-end;width:100%;min-height:0;height:auto;}.item-toolbar__controls-row--reserve.svelte-1c13522 {min-height:var(--pie-tts-controls-row-height);height:var(--pie-tts-controls-row-height);}.item-toolbar__controls-row--active.svelte-1c13522 {min-height:var(--pie-tts-controls-row-height);height:var(--pie-tts-controls-row-height);}.item-toolbar__controls-row--align-start.svelte-1c13522 {justify-content:flex-start;}.item-toolbar__controls-host.svelte-1c13522 {display:inline-flex;align-items:center;justify-content:flex-end;width:100%;}.item-toolbar--top.svelte-1c13522,
11
- .item-toolbar--bottom.svelte-1c13522 {align-items:flex-end;}.item-toolbar--left.svelte-1c13522,
12
- .item-toolbar--right.svelte-1c13522 {align-items:stretch;}.item-toolbar--left.svelte-1c13522 .item-toolbar__tools-row:where(.svelte-1c13522),
13
- .item-toolbar--right.svelte-1c13522 .item-toolbar__tools-row:where(.svelte-1c13522) {flex-direction:column;align-items:center;justify-content:flex-start;flex-wrap:nowrap;}.item-toolbar--left.svelte-1c13522 .item-toolbar__controls-row:where(.svelte-1c13522),
14
- .item-toolbar--right.svelte-1c13522 .item-toolbar__controls-row:where(.svelte-1c13522) {justify-content:flex-start;width:auto;min-height:0;height:auto;}.item-toolbar__button.svelte-1c13522 {display:flex;flex-shrink:0;align-items:center;justify-content:center;width:2rem;height:2rem;padding:0.25rem;border:1px solid var(--pie-button-border, var(--pie-border, #ccc));border-radius:0.25rem;background-color:var(--pie-button-bg, var(--pie-background, white));color:var(--pie-button-color, var(--pie-text, #333));cursor:pointer;transition:all 0.15s ease;text-decoration:none;}
15
-
16
- /* Drive the vendored NDS icon button's outer size via its own \`--height-32\`
17
- custom property so its light-DOM inner button matches the toolbar's
18
- md/sm/lg dimensions (32 / 44 / 40 px) without a layout shift. The glyph
19
- keeps the NDS-native icon size (we render size="small"), so it isn't
20
- oversized. */.item-toolbar__nds-button-zoom.svelte-1c13522 {display:inline-flex;flex-shrink:0;}.item-toolbar.svelte-1c13522 nds-icon-button:where(.svelte-1c13522) {
21
- /* Host-settable button size per toolbar size (drives the NDS outer button
22
- via its own --height-32). */--height-32: var(--pie-calculator-button-size, 2rem);
23
- /* Host-settable accent for the calculator button: the NDS tertiary glyph
24
- colour derives from --color-interactive-blue, remapped here to a
25
- themeable variable. --pie-calculator-button-color is package-private, so
26
- nothing sets it and the default is what ships: it now resolves through
27
- --pie-button-color (DaisyUI base-content) instead of holding the Figma
28
- blue on every theme, with the literal as the no-theme last resort.
29
- Not --pie-primary or --pie-tertiary: both are \`direct\` mappings of
30
- DaisyUI slots chosen to pair with their own -content colour, so a glyph
31
- taken from either sits at 1.37:1 against the page under \`pastel\` and 11
32
- of the 35 shipped themes fall under SC 1.4.11's 3:1. */--color-interactive-blue: var(--pie-calculator-button-color, var(--pie-button-color, var(--pie-text, #222)));
33
- /* NDS palette bridge — keep in sync with the copies in tool-tts-inline
34
- and section-player SectionItemsPane (asserted by
35
- scripts/check-theme-tokens.mjs). The vendored button paints its fill,
36
- its on-accent glyph, its hover ring and its focus ring from the NDS
37
- design-system palette, which no PIE theme sets, so a tertiary button
38
- kept a #f3f5f7 pill on every page — and once the glyph followed the
39
- theme, a light glyph landed on that light pill. */--color-new-gray: var(--pie-background-dark, #f3f5f7);--color-primary-white: var(--pie-white, #ffffff);--color-primary-black: var(--pie-text, #000000);--color-focus-blue: var(--pie-button-focus-outline, #2b87ff);}.item-toolbar--sm.svelte-1c13522 nds-icon-button:where(.svelte-1c13522) {--height-32: var(--pie-calculator-button-size-sm, 2.75rem);}.item-toolbar--lg.svelte-1c13522 nds-icon-button:where(.svelte-1c13522) {--height-32: var(--pie-calculator-button-size-lg, 2.5rem);}.item-toolbar__element-host.svelte-1c13522 {display:contents;}.item-toolbar--sm.svelte-1c13522 .item-toolbar__button:where(.svelte-1c13522) {width:2.75rem;height:2.75rem;}.item-toolbar--sm.svelte-1c13522 {--pie-toolbar-tools-row-height: 2.75rem;--pie-tts-controls-row-height: 3.625rem;}.item-toolbar--lg.svelte-1c13522 .item-toolbar__button:where(.svelte-1c13522) {width:2.5rem;height:2.5rem;}.item-toolbar--lg.svelte-1c13522 {--pie-toolbar-tools-row-height: 2.5rem;--pie-tts-controls-row-height: 3.375rem;}.item-toolbar__button.svelte-1c13522:hover:not(:disabled) {background-color:var(--pie-button-hover-bg, var(--pie-secondary-background, #f5f5f5));border-color:var(--pie-button-hover-border, var(--pie-button-border, var(--pie-border, #ccc)));color:var(--pie-button-hover-color, var(--pie-button-color, var(--pie-text, #333)));transform:translateY(-1px);box-shadow:0 2px 4px color-mix(in srgb, var(--pie-black, #000) 10%, transparent);}.item-toolbar__button.svelte-1c13522:active:not(:disabled) {transform:translateY(0);box-shadow:none;}.item-toolbar__button--active.svelte-1c13522 {background-color:var(--pie-primary, #1976d2);color:var(--pie-white, #fff);border-color:var(--pie-primary, #1976d2);}.item-toolbar__button--active.svelte-1c13522:hover:not(:disabled) {background-color:var(--pie-primary-dark, #1565c0);}.item-toolbar__button.svelte-1c13522:focus-visible {outline:2px solid var(--pie-button-focus-outline, var(--pie-primary, #1976d2));outline-offset:2px;}.item-toolbar__button.svelte-1c13522:disabled {opacity:0.5;cursor:not-allowed;}.item-toolbar__button.svelte-1c13522 svg {width:100%;height:100%;}.item-toolbar__icon-image.svelte-1c13522 {width:100%;height:100%;object-fit:contain;}`};function Nj(k,N){n0(N,!0),jj(k,NU);let B=(Z,j=BZ,U=BZ)=>{var X=_J(),G=SJ(X);{var P=(M)=>{var x=_J(),W=SJ(x);Zj(W,()=>J(qZ),(D)=>{var o=o0();XZ(o,(n,s)=>Ej?.(n,s),()=>({mounted:j(),active:J(uZ)[j().toolId]??!1,runtime:J(w),i18n:J(L0)})),r(()=>OJ(o,1,U0(U()),"svelte-1c13522")),b(D,o)}),b(M,x)},V=(M)=>{var x=o0();XZ(x,(W,D)=>vj?.(W,D),()=>j().entry),r(()=>OJ(x,1,U0(U()),"svelte-1c13522")),b(M,x)};NJ(G,(M)=>{if(j().entry.shell)M(P);else M(V,-1)})}b(Z,X)},S=typeof window<"u",GJ="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@6.5.2/css/all.min.css",gJ=/font.?awesome|fa-?pro/i,xZ=/fontawesome-free/i,mJ=()=>Array.from(document.querySelectorAll('link[rel="stylesheet"][href]')),IZ=()=>mJ().some((Z)=>gJ.test(Z.href)&&!xZ.test(Z.href)),l=(Z,j)=>{let U=IZ()?j:"fa-solid";if(U==="fa-light")return()=>{};let X=()=>{for(let P of Z.querySelectorAll("i.fa-light"))P.classList.remove("fa-light"),P.classList.add(U)};X();let G=new MutationObserver(X);return G.observe(Z,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class"]}),()=>G.disconnect()},JJ=(Z)=>{if(document.querySelector(`link[href="${Z}"]`))return;let j=document.createElement("link");j.rel="stylesheet",j.href=Z,j.addEventListener("error",()=>{j.dataset.pieLoadFailed=""},{once:!0}),document.head.appendChild(j)},hJ=!1,CJ=()=>{if(!S||hJ)return;if(hJ=!0,mJ().some((j)=>gJ.test(j.href)))return;JJ(GJ)},LZ="__pieFaToolbarShadowInstalled",AZ=(Z)=>{let j=Z.getRootNode();if(!(j instanceof ShadowRoot))return;let U=j;if(U[LZ])return;U[LZ]=!0;let X=new Set,G=(V)=>{if(!V||X.has(V))return;X.add(V);let M=document.createElement("link");M.rel="stylesheet",M.href=V,j.appendChild(M)},P=mJ().filter((V)=>gJ.test(V.href));for(let V of P){if("pieLoadFailed"in V.dataset)continue;if(V.sheet){G(V.href);continue}let M=(x)=>{if(V.removeEventListener("load",M),V.removeEventListener("error",M),x.type==="load")G(V.href)};V.addEventListener("load",M),V.addEventListener("error",M)}},MJ=(Z)=>{return CJ(),AZ(Z),{destroy:l(Z,"fa-light")}},RJ=(Z,j)=>{let U=j,X=()=>{let P=Z.querySelector("button");if(P)P.setAttribute("aria-pressed",U?"true":"false")};X();let G=new MutationObserver(X);return G.observe(Z,{childList:!0,subtree:!0}),{update(P){U=P,X()},destroy(){G.disconnect()}}},X0=(Z)=>Z.faIconName||null,Gj=new Oj,HJ=YJ(e0({})),fJ=g(N,"level",7,"item"),YZ=g(N,"scopeId",7,""),SZ=g(N,"itemId",7,""),_Z=g(N,"sectionId",7,""),CZ=g(N,"catalogId",7,""),fZ=g(N,"tools",7,""),bZ=g(N,"contentKind",7,"assessment-item"),FJ=g(N,"position",7,"bottom"),QZ=g(N,"scopeElement",7,null),VZ=g(N,"toolRegistry",7,null),yZ=g(N,"item",7,null),DZ=g(N,"hostButtons",23,()=>[]),pZ=g(N,"class",7,""),OZ=g(N,"size",7,"md"),$Z=g(N,"language",7,""),ZJ=YJ(null),w=YJ(null),qZ=O(()=>J(w)?.ndsIcons===!0),L0=O(()=>JU(J(w))),Mj=O(()=>$Z()||J(w)?.contentLanguage||void 0),bJ=YJ(null),uJ=YJ(0),cJ=YJ(0),vZ=YJ(0),EZ=YJ(0);c(()=>{if(!J(ZJ))return;return Lj(J(ZJ),(Z)=>{e(w,Z,!0)})}),c(()=>{if(!J(ZJ))return;return Yj(J(ZJ),(Z)=>{e(bJ,Z,!0)})}),c(()=>{let Z=J(w)?.toolkitCoordinator;if(!Z||typeof Z.onPolicyChange!=="function")return;let j=Z.onPolicyChange((U)=>{if(e(cJ,J(cJ)+1),U?.reason!=="item-settings")e(vZ,J(vZ)+1)});return()=>{try{j?.()}catch{}}}),c(()=>{let Z=J(w)?.toolkitCoordinator;if(!Z||typeof Z.onToolContextResolverChange!=="function")return;let j=Z.onToolContextResolverChange(()=>{e(EZ,J(EZ)+1)});return()=>{try{j?.()}catch{}}});let jJ=O(()=>J(w)?.toolCoordinator),Rj=O(()=>J(w)?.ttsService),gZ=O(()=>J(w)?.elementToolStateStore),Y0=O(()=>J(w)?.assessmentId??""),NZ=O(()=>SZ()||J(bJ)?.itemId||""),TJ=O(()=>J(bJ)?.canonicalItemId||J(NZ)),aJ=O(()=>_Z()||J(w)?.sectionId||""),sJ=O(()=>bZ()||J(bJ)?.contentKind||(fJ()==="section"?"section":"assessment-item")),I=O(()=>{if(fJ()&&fJ()!=="item")return fJ();if(J(sJ)==="rubric-block-stimulus")return"passage";return"item"}),BJ=O(()=>{if(YZ())return YZ();if(J(I)==="section")return J(aJ)||J(w)?.sectionId||"default-section";if(J(I)==="assessment")return J(w)?.assessmentId||"default-assessment";return J(TJ)||J(NZ)||"default-item"}),Fj=O(()=>CZ()||J(BJ)),VJ=O(()=>yZ()||J(bJ)?.item||null),m=O(()=>{if(VZ())return VZ();return J(cJ),J(w)?.toolkitCoordinator?.getToolRegistry?.()||Gj}),Pj=O(()=>qj(fZ())),Wj=O(()=>J(m).normalizeToolIds(J(Pj)).filter(Boolean)),Q0=O(()=>{if(J(I)==="section")return"section";if(J(I)==="passage"||J(sJ)==="rubric-block-stimulus")return"passage";return"item"}),V0=O(()=>{J(cJ);let Z=J(w)?.toolkitCoordinator;if(!Z||typeof Z.decideToolPolicy!=="function")return null;return Z.decideToolPolicy({level:J(Q0),scope:{level:J(I),scopeId:J(BJ),assessmentId:J(w)?.assessmentId,sectionId:J(aJ)||void 0,itemId:J(NZ)||void 0,canonicalItemId:J(TJ)||void 0,contentKind:J(sJ)}})}),kj=d0(),GZ=O(()=>kj(J(V0),J(vZ))),dJ=O(()=>{let Z=(j)=>Array.from(new Set(j));if(J(GZ))return Z(J(m).normalizeToolIds(J(GZ).map((j)=>j.toolId)).filter(Boolean));return Z(J(Wj))});c(()=>{if(!J(V0)||J(dJ).length===0)return;if(J(m).getAllTools().length>0)return;let Z=J(ZJ)?.ownerDocument,j=J(dJ).join(", "),U=setTimeout(()=>{Dj(Z,"toolbarWithoutRegistry",`[pie-item-toolbar] Policy places ${j} on this toolbar, but its tool registry is still empty after ${K0/1000} s, so it renders no buttons. Pass a toolRegistry to <pie-assessment-toolkit> or its coordinator; @pie-players/pie-default-tool-loaders builds the stock one. Reported once per page.`)},K0);return()=>clearTimeout(U)});let mZ=O(()=>{if(J(I)==="section"||J(I)==="assessment")return!0;let Z=J(VJ)?.config;return!!(J(VJ)&&Z&&typeof Z==="object")}),zj=O(()=>{J(cJ);let Z=J(w)?.toolkitCoordinator;if(!Z||typeof Z.getPolicyInputs!=="function")return null;return Z.getPolicyInputs()}),yJ=O(()=>J(zj)?.assessment??null),MZ=O(()=>({id:J(TJ)})),RZ=O(()=>{if(J(I)==="section")return{level:"section",assessment:J(yJ)||{},section:{}};if(J(I)==="assessment")return{level:"assessment",assessment:J(yJ)||{}};if(!J(mZ)||!J(VJ))return null;if(J(I)==="passage")return{level:"passage",assessment:J(yJ)||{},itemRef:J(MZ),passage:J(VJ)};return{level:"item",assessment:J(yJ)||{},itemRef:J(MZ),item:J(VJ)}}),D0=O(()=>{if(J(RZ))return J(RZ);return{level:"item",assessment:J(yJ)||{},itemRef:J(MZ),item:J(VJ)||{id:J(TJ),config:{}}}}),O0=O(()=>{if(J(I)!=="item"&&J(I)!=="passage")return[];if(!J(mZ)||!J(VJ))return[];let Z=J(VJ)?.config?.models;return(Array.isArray(Z)?Z:Z&&typeof Z==="object"?Object.values(Z):[]).filter((U)=>U&&typeof U==="object"&&typeof U.id==="string").map((U)=>({level:"element",assessment:J(yJ)||{},itemRef:J(MZ),item:J(VJ),elementId:U.id}))});function FZ(Z){return Qj(Z,J(I),J(BJ))}let iJ=null;function q0(Z,j){if(iJ?.coordinator===Z)iJ.ids.add(j)}function N0(Z,j){let U=FZ(j);if(!Z.getToolState(U))Z.registerTool(U,j);return q0(Z,U),U}c(()=>{let Z=J(jJ);if(J(I),J(BJ),!Z)return;let j={coordinator:Z,ids:new Set};return iJ=j,()=>{if(iJ===j)iJ=null;for(let U of j.ids)Z.releaseTool(U)}});function wj(Z){if(!J(gZ)||!J(Y0)||!J(aJ)||!J(TJ))return null;return J(gZ).getGlobalElementId({assessmentId:J(Y0),sectionId:J(aJ),attemptId:J(w)?.attemptId??"",itemId:J(TJ),elementId:Z})}function Hj(){if(QZ())return QZ();return J(bJ)?.scopeElement||null}function G0(){let Z=J(jJ)||null;return{scope:{level:J(I),scopeId:J(BJ),assessmentId:J(w)?.assessmentId,sectionId:J(aJ),itemId:J(NZ),canonicalItemId:J(TJ),contentKind:J(sJ)},itemId:J(BJ),catalogId:J(Fj),language:J(Mj),i18n:J(L0),ui:{size:OZ()},getScopeElement:Hj,getGlobalElementId:wj,toolCoordinator:Z,toolkitCoordinator:J(w)?.toolkitCoordinator||null,ttsService:J(Rj)||null,elementToolStateStore:J(gZ)||null,toggleTool:(j)=>{if(!Z)return;Z.toggleTool(N0(Z,j))},isToolVisible:(j)=>Z?.isToolVisible(FZ(j))??!1,subscribeVisibility:Z?(j)=>Z.subscribe(j):null}}let Tj=O(G0),hZ=O(()=>{J(EZ);let Z=J(w)?.toolkitCoordinator;if(!Z||typeof Z.hasToolContextResolver!=="function"||typeof Z.resolveToolContext!=="function")return{};let j={};for(let U of J(dJ)){if(!J(m).get(U)?.supportedLevels.includes(J(I)))continue;if(!Z.hasToolContextResolver(U))continue;let G=Z.resolveToolContext({toolId:U,context:J(D0),toolbarContext:J(Tj)});if(G)j[U]=G}return j}),Bj=O(()=>{let Z=J(hZ),j=(J(GZ)??J(dJ).map((P)=>({toolId:P,required:!1,alwaysAvailable:!1}))).filter((P)=>!Z[J(m).normalizeToolId(P.toolId)]),U=!J(mZ)?[]:J(RZ)?[J(RZ),...J(O0)]:J(O0),X=(P,V,M)=>J0(J(w)?.toolkitCoordinator,P,V,M),G=new Set(J(m).filterDecidedToolIds(j,J(I),U,X));return J(dJ).filter((P)=>G.has(P)||Z[P]?.visible)}),rJ=YJ(null),lJ=O(()=>{let Z=J(rJ)?.registry===J(m)?J(rJ).toolIds:null,j=J(m).filterToolIdsByActivation(J(Bj),"toolbar-toggle");return Z?j.filter((U)=>!Z.has(U)):j});c(()=>{if(!S)return;let Z=J(m),j=!1;return Z.ensureToolModulesLoaded(J(lJ)).then((U)=>{if(U.size>0){let X=J(rJ)?.registry===Z?J(rJ).toolIds:[];e(rJ,{registry:Z,toolIds:new Set([...X,...U.keys()])},!0);for(let[G,P]of U)J0(J(w)?.toolkitCoordinator,G,"tool-module-load",P)}if(!j)e(uJ,J(uJ)+1)}),()=>{j=!0}});let xj=O(()=>{let Z=new Map;for(let j of J(GZ)??[]){if(!j.parameters)continue;let[U]=J(m).normalizeToolIds([j.toolId]);if(U)Z.set(U,j.parameters)}return Z}),xJ=O(()=>{let Z=J(xj);return{...G0(),getResolvedToolContext:(j)=>J(hZ)[j]??null,getToolParameters:(j)=>Z.get(J(m).normalizeToolId(j))??null,getToolRenderParams:(j)=>{let U=J(hZ)[j]?.params??null,X=M0.get(j);if(!X)return U;return{...U??{},...X}}}}),M0=new Map,R0=0,KJ=O(()=>{if(!S)return[];J(uJ);let Z=[];for(let j of J(lJ)){let U=J(m).renderForToolbar(j,J(D0),J(xJ));if(U)Z.push(U)}return Z});c(()=>{let Z=J(jJ);if(!Z)return;for(let j of J(KJ))q0(Z,FZ(j.toolId))});let Ij=O(()=>{if(!Array.isArray(DZ()))return[];let Z=[];return DZ().forEach((j,U)=>{if(h0(j)){Z.push(j);return}console.warn(`[ItemToolBar] Ignoring invalid host button at index ${U}. Expected { id, label, href | onClick } with valid types.`)}),Z}),Aj=O(()=>J(KJ).filter((Z)=>!!Z.button).map((Z)=>{let j=Z.button;return{id:Z.toolId,label:j.label,ariaLabel:j.ariaLabel||j.label,icon:j.icon,faIconName:j.faIconName,tooltip:j.tooltip||j.label,disabled:j.disabled,active:J(HJ)[Z.toolId]??j.active??!1,onClick:()=>{j.onClick(),pJ()}}})),F0=O(()=>[...J(Aj),...J(Ij)]),uZ=O(()=>{let Z={};for(let j of J(KJ))Z[j.toolId]=J(HJ)[j.toolId]??j.button?.active??!1;return Z}),cZ=(Z,j,U)=>Z.flatMap((X)=>(X.elements||[]).filter((G)=>G.mount===j).filter((G)=>Boolean(G.element)).map((G,P)=>({key:`${U}-${X.toolId}-${P}`,toolId:X.toolId,entry:G}))),Sj=O(()=>cZ(J(KJ),"before-buttons","before")),_j=O(()=>cZ(J(KJ),"after-buttons","after")),P0=O(()=>cZ(J(KJ),"controls-row","controls-row")),W0=O(()=>J(KJ).flatMap((Z)=>(Z.elements||[]).map((j)=>({toolId:Z.toolId,hint:j.layoutHints?.controlsRow})).filter((j)=>Boolean(j.hint)))),k0=O(()=>J(KJ).flatMap((Z)=>(Z.elements||[]).map((j)=>({toolId:Z.toolId,hint:j.layoutHints?.headerOverlay})).filter((j)=>Boolean(j.hint)))),z0=O(()=>J(W0).some((Z)=>Z.hint?.reserveSpace===!0)),w0=O(()=>J(W0).some((Z)=>Z.hint?.showWhenToolActive===!0&&(J(uZ)[Z.toolId]??!1))),Cj=O(()=>FJ()==="left"||FJ()==="right"),H0=O(()=>J(k0).some((Z)=>Z.hint?.showWhenToolActive===!0&&(J(uZ)[Z.toolId]??!1))),fj=O(()=>J(P0).length>0||J(z0)||J(w0));function bj(){if(!J(ZJ))return null;let Z=J(ZJ).getRootNode();if(Z instanceof ShadowRoot)return Z.host;return null}c(()=>{let Z=bj();if(!Z)return;let j=J(k0).length>0,U=J(H0);return Z.setAttribute("data-pie-header-overlay",j?"true":"false"),Z.setAttribute("data-pie-header-overlay-active",U?"true":"false"),()=>{Z.removeAttribute("data-pie-header-overlay"),Z.removeAttribute("data-pie-header-overlay-active")}}),c(()=>{if(!S||!J(qZ))return;if(J(F0).some((Z)=>!!X0(Z)))CJ()});function PZ(Z){if(Z.id in J(HJ))return J(HJ)[Z.id]===!0;return Z.active===!0}function pJ(){let Z={};for(let j of J(KJ))if(j.sync?.(),j.button)Z[j.toolId]=j.button.active??!1;e(HJ,Z,!0)}c(()=>{let Z=[];pJ();for(let j of J(KJ))if(j.subscribeActive){let U=!1,X=j.subscribeActive((G)=>{queueMicrotask(()=>{if(U)return;e(HJ,{...J(HJ),[j.toolId]:G},!0),j.sync?.()})});Z.push(()=>{U=!0,X()})}return()=>{Z.forEach((j)=>j())}}),c(()=>{let Z=J(w)?.toolkitCoordinator;if(typeof Z?.registerToolRequestTarget!=="function")return;let j=J(Q0);return Z.registerToolRequestTarget({level:j,get scopeId(){return J(BJ)},hostsTool:(U)=>J(lJ).includes(U),open:(U,X)=>{if(!J(jJ))return;if(!J(lJ).includes(U))return;if(X&&Object.keys(X).length>0)R0+=1,M0.set(U,{...X,toolRequestId:R0});let G=N0(J(jJ),U);J(jJ).showTool(G),queueMicrotask(()=>pJ())}})}),c(()=>{if(!J(xJ).subscribeVisibility)return;let Z=!1,j=J(xJ).subscribeVisibility(()=>{queueMicrotask(()=>{if(Z)return;pJ()})});return()=>{Z=!0,j?.()}}),c(()=>{let Z=J(xJ).toolkitCoordinator;if(typeof Z?.subscribeTelemetry!=="function")return;let j=!1,U=Z.subscribeTelemetry(({eventName:X,payload:G})=>{if(X!=="pie-toolkit-tool-config-updated")return;if(G?.toolId&&!J(lJ).includes(G.toolId))return;queueMicrotask(()=>{if(j)return;e(uJ,J(uJ)+1),pJ()})});return()=>{j=!0,U?.()}});let yj="[data-pie-tool-overlay-boundary]";function pj(Z,j){if(j.container!=="content-boundary")return Z;let U=Z;while(U){if(U instanceof HTMLElement&&U.matches(yj))return U;if(U instanceof HTMLElement&&U.parentElement){U=U.parentElement;continue}let X=U.getRootNode();U=X instanceof ShadowRoot?X.host:null}return Z}let $j="__pieToolElementUnmount";function aZ(Z){if(!Z)return;let j=Z[$j];if(typeof j==="function")j()}function vj(Z,j){let U=j,X=null,G=Z,P=(V)=>{if(X===V)return;if(X){if(aZ(X),X.parentNode===G)G.removeChild(X)}if(X=V,X){if(G=pj(Z,U),X.parentNode&&X.parentNode!==G)X.parentNode.removeChild(X);G.appendChild(X)}};return P(j.element),{update(V){U=V,P(V.element)},destroy(){P(null)}}}let T0=720,B0=560,x0=320,sZ=240,PJ=24,WJ=40;function Ej(Z,j){let U=j,X=null,G=null,P=[],V=null,M=null,x=null,W=null,D=null,o=null,n=null,s=!1,DJ=!1,oJ=()=>U.mounted.entry.shell?.pageTabOrder===!0,XJ=()=>U.mounted.entry.shell?.ndsHeaderControls===!0,T=null,IJ=null,nJ=UU({onMove:(K)=>oj(K),onEnd:()=>{IJ=null}}),t=0,z=0,H=0,y=0,kJ=0,_=0,tJ=0,dZ=0,eJ=null,iZ=[],p=0,$=0,C=U.mounted.entry.shell?.initialWidth??T0,f=U.mounted.entry.shell?.initialHeight??B0,A0=C,S0=f,JZ=!1,$J=null,LJ=null,WZ=!1,rZ=()=>{let K=U.mounted.entry.shell;if(!K)return null;return{toolId:U.mounted.toolId,toolbarContext:J(xJ),shellConfig:K}},uj=(K)=>{let Y=J(m).get(U.mounted.toolId),q=rZ();if(!Y?.onHostedMount||!q)return;Y.onHostedMount(K,q)},kZ=()=>{let K=J(m).get(U.mounted.toolId),Y=rZ();if(!K?.onHostedResize||!Y)return;K.onHostedResize({width:C,height:f},U.mounted.entry.element,Y)},cj=()=>{let K=J(m).get(U.mounted.toolId),Y=rZ();if(!K?.onHostedUnmount||!Y)return;K.onHostedUnmount(U.mounted.entry.element,Y)},a=(K,Y,q)=>Math.max(Y,Math.min(K,q)),AJ=(K)=>{try{K.focus()}catch{}},aj=()=>{let K=U.mounted.entry.shell,Y=K?.minWidth??x0,q=K?.minHeight??sZ,Q=K?.maxWidth??window.innerWidth,L=K?.maxHeight??window.innerHeight;return{minWidth:Y,minHeight:q,maxWidth:Q,maxHeight:L}},lZ=()=>{let K=U.mounted.entry.shell?.minWidth,Y=typeof K==="number"&&K>0&&C<K,q=Y?`${K}px`:"";if(T)T.style.minWidth=q;if(V)V.style.minWidth="0";if(M)M.style.minWidth="0",M.style.overflowX=Y?"auto":"hidden"},_0=()=>U.mounted.entry.shell?.content?.overflowY==="auto"?"auto":"hidden",sj=()=>{if(!V)return 0;let K=V.getBoundingClientRect().height;if(K>0)return K;return V.offsetHeight||0},oZ=()=>{if(!M)return;let K=U.mounted.entry.shell;if(M.style.overflowY=_0(),!T)return;if(K?.content?.preserveMinHeight===!0){let Y=sj(),q=K.minHeight??sZ,Q=Math.max(0,q-Y),L=Math.max(0,f-Y),R=Math.max(L,Q);T.style.height=`${R}px`,T.style.minHeight="0",T.style.flex=`0 0 ${R}px`;return}T.style.height="100%",T.style.minHeight="0",T.style.flex="1 1 auto"},dj=()=>{let K=U.mounted.entry.shell,Y=K?.initialWidth??T0,q=K?.initialHeight??B0;if(Y===A0&&q===S0)return;if(A0=Y,S0=q,JZ)return;C=Y,f=q,HZ()},zZ=()=>{let{minWidth:K,minHeight:Y,maxWidth:q,maxHeight:Q}=aj(),L=Math.min(K,window.innerWidth),R=Math.min(Y,window.innerHeight);C=a(C,L,Math.max(L,Math.min(q,window.innerWidth))),f=a(f,R,Math.max(R,Math.min(Q,window.innerHeight))),p=a(p,0,Math.max(0,window.innerWidth-C)),$=a($,0,Math.max(0,window.innerHeight-f)),ZZ(),lZ(),oZ(),kZ()},zJ=(K,Y)=>{JZ=!0,p+=K,$+=Y,zZ()},wZ=(K,Y)=>{JZ=!0,C+=K,f+=Y,zZ()},C0=(K,Y,q,Q="fa-regular")=>{CJ();let L=document.createElement("nds-icon-button");return L.setAttribute("variant","tertiary"),L.setAttribute("size","small"),L.setAttribute("type","circle"),L.setAttribute("icon-name",Y),L.setAttribute("button-aria-label",K),L.title=K,L.addEventListener("click",(R)=>{R.stopPropagation(),q(),vJ()}),l(L,Q),L},f0=(K,Y,q)=>{let Q=document.createElement("button");return Q.type="button",Q.className="pie-tool-shell__control",Q.setAttribute("aria-label",K),Q.title=K,Q.textContent=Y,Q.style.border="1px solid transparent",Q.style.background="color-mix(in srgb, var(--pie-white, #fff) 10%, transparent)",Q.style.color="inherit",Q.style.cursor="pointer",Q.style.display="inline-flex",Q.style.alignItems="center",Q.style.justifyContent="center",Q.style.width="28px",Q.style.height="28px",Q.style.padding="0",Q.style.fontSize="14px",Q.style.fontWeight="700",Q.style.borderRadius="8px",Q.style.lineHeight="1",Q.onclick=(L)=>{L.stopPropagation(),q(),vJ()},Q.onfocus=()=>{Q.style.outline="2px solid var(--pie-button-focus-outline, var(--pie-primary, #4A90E2))",Q.style.outlineOffset="2px"},Q.onblur=()=>{Q.style.outline="none",Q.style.outlineOffset="0"},Q},ZZ=()=>{if(!X)return;X.style.left=`${p}px`,X.style.top=`${$}px`,X.style.width=`${C}px`,X.style.height=`${f}px`,X.style.display=U.active?"flex":"none"},b0=()=>{if(x)x.textContent=U.mounted.entry.shell?.title||U.mounted.toolId;for(let{el:K,key:Y}of P){let q=U.i18n.t(Y);if(K.tagName==="NDS-ICON-BUTTON")K.setAttribute("button-aria-label",q);else K.setAttribute("aria-label",q);if(K.title)K.title=q}},y0=()=>{if(!M)return;let K=U.mounted.entry.element;if(K.style.display="block",K.style.width="100%",K.style.height="100%",K.style.flex="1 1 auto",K.style.minHeight="0",T&&T!==K){if(T.parentNode===M)aZ(T),M.removeChild(T);T=null}if(K.parentNode&&K.parentNode!==M)K.parentNode.removeChild(K);if(K.parentNode!==M)M.appendChild(K);T=K,lZ(),oZ(),uj(K)},vJ=()=>{if(J(jJ)&&X)J(jJ).bringToFront(X)},p0=()=>{if(!X||!J(jJ)||!U.active)return;let K=FZ(U.mounted.toolId);if(J(jJ).getToolState(K)?.element===X)return;J(jJ).updateToolElement(K,X)},HZ=()=>{let{innerWidth:K,innerHeight:Y}=window,q=U.mounted.entry.shell,Q=q?.initialAlign??"center",L=q?.initialMargin??16,R=L+60;switch(Q){case"top-left":p=L,$=R;break;case"top-right":p=Math.max(0,K-C-L),$=R;break;case"bottom-left":p=L,$=Math.max(0,Y-f-R);break;case"bottom-right":p=Math.max(0,K-C-L),$=Math.max(0,Y-f-R);break;default:p=Math.max(0,Math.round((K-C)/2)),$=Math.max(0,Math.round((Y-f)/2))}zZ()},ij=()=>{let K=LJ;if(!K)return;queueMicrotask(()=>{if(!K.isConnected)return;AJ(K)})},$0=()=>{if(typeof document>"u")return null;let K=document.activeElement;while(K){let Y=K.shadowRoot;if(Y&&Y.activeElement&&Y.activeElement!==K)K=Y.activeElement;else break}return K??null},v0=()=>{if(!X||$J)return;let K=$0();if(!LJ&&K&&!X.contains(K))LJ=K;if(oJ()&&!DJ)document.addEventListener("keydown",tZ,!0),DJ=!0;$J=jU(X,{initialFocus:D,onEscape:()=>{eZ()},wrap:!oJ(),onTabExit:oJ()?(Y,q)=>{if(Y==="backward"){if(LJ?.isConnected)q.preventDefault(),AJ(LJ);return}let Q=nZ();if(Q)q.preventDefault(),AJ(Q)}:void 0})},nZ=()=>{let K=J(xJ).getScopeElement?.()??null;if(!K)return null;let Y=(Q)=>{if(J(ZJ)&&J(ZJ).contains(Q))return!0;if(X&&X.contains(Q))return!0;return!1},q=(Q)=>{if(Q instanceof HTMLElement){if(Y(Q))return null;if(Q.matches?.(KU)&&XU(Q))return Q}let L=Q.shadowRoot;if(L)for(let R=0;R<L.children.length;R++){let F=q(L.children[R]);if(F)return F}for(let R=0;R<Q.children.length;R++){let F=q(Q.children[R]);if(F)return F}return null};return q(K)},rj=()=>{if(!X)return[];return ZU(X).filter((K)=>K!==o&&K!==n)},tZ=(K)=>{if(K.key!=="Tab")return;if(!X||!U.active)return;let Y=$0();if(!Y)return;if(X.contains(Y))return;let q=rj();if(q.length===0)return;if(K.shiftKey){let Q=nZ();if(Y!==Q)return;K.preventDefault(),AJ(q[q.length-1]);return}if(Y!==LJ)return;K.preventDefault(),AJ(q[0])},E0=()=>{if(DJ)document.removeEventListener("keydown",tZ,!0),DJ=!1;if(!$J)return;let K=$J;$J=null;try{K()}catch{}ij()},eZ=()=>{J(xJ).toggleTool(U.mounted.toolId),pJ()},g0=(K)=>{if(!U.mounted.entry.shell?.draggable)return;if(K.target.closest("button")||!X)return;if(!nJ.begin(K,X))return;IJ="drag",JZ=!0,t=K.clientX-p,z=K.clientY-$,X.setPointerCapture(K.pointerId),vJ()},lj=(K)=>(Y)=>{if(!X||!U.mounted.entry.shell?.resizable)return;if(Y.stopPropagation(),!nJ.begin(Y,X))return;IJ="resize",JZ=!0,eJ=K,H=C,y=f,kJ=Y.clientX,_=Y.clientY,tJ=p,dZ=$,X.setPointerCapture(Y.pointerId),vJ()},oj=(K)=>{if(!X)return;if(IJ==="drag"){K.preventDefault();let Y=Math.max(0,window.innerWidth-C),q=Math.max(0,window.innerHeight-f);p=a(K.clientX-t,0,Y),$=a(K.clientY-z,0,q),ZZ();return}if(IJ==="resize"){K.preventDefault();let Y=U.mounted.entry.shell,q=Y?.minWidth??x0,Q=Y?.minHeight??sZ,L=Math.min(q,window.innerWidth),R=Math.min(Q,window.innerHeight),F=Y?.maxWidth??window.innerWidth,v=Y?.maxHeight??window.innerHeight,h=K.clientX-kJ,d=K.clientY-_;if(eJ==="se")C=a(H+h,L,Math.max(L,Math.min(F,window.innerWidth-p))),f=a(y+d,R,Math.max(R,Math.min(v,window.innerHeight-$)));else if(eJ==="sw"){let u=tJ+H,UJ=a(H-h,L,Math.min(F,u));p=u-UJ,C=UJ,f=a(y+d,R,Math.max(R,Math.min(v,window.innerHeight-$)))}else if(eJ==="ne"){let u=dZ+y;C=a(H+h,L,Math.max(L,Math.min(F,window.innerWidth-p)));let UJ=a(y-d,R,Math.min(v,u));$=u-UJ,f=UJ}else if(eJ==="nw"){let u=tJ+H,UJ=dZ+y,A=a(H-h,L,Math.min(F,u));p=u-A,C=A;let jZ=a(y-d,R,Math.min(v,UJ));$=UJ-jZ,f=jZ}ZZ(),lZ(),oZ(),kZ()}},m0=()=>{zZ()};if(S&&U.mounted.entry.shell){let K=XJ()&&J(qZ);if(K)CJ();if(X=document.createElement("div"),X.className="pie-tool-shell",X.setAttribute("data-pie-tool-shell",U.mounted.toolId),X.style.position="fixed",X.style.zIndex=String(Vj.TOOL),X.style.background="var(--pie-background, #fff)",X.style.border="1px solid var(--pie-border-light, #d1d5db)",X.style.borderRadius="12px",X.style.boxShadow="0 10px 40px color-mix(in srgb, var(--pie-black, #000) 25%, transparent)",X.style.setProperty("--color-interactive-blue","var(--pie-calculator-button-color, var(--pie-button-color, var(--pie-text, #222)))"),X.style.setProperty("--color-new-gray","var(--pie-background-dark, #f3f5f7)"),X.style.setProperty("--color-primary-white","var(--pie-white, #ffffff)"),X.style.setProperty("--color-primary-black","var(--pie-text, #000000)"),X.style.setProperty("--color-focus-blue","var(--pie-button-focus-outline, #2b87ff)"),X.style.overflow="visible",X.style.display=U.active?"flex":"none",X.style.flexDirection="column",X.style.userSelect="none",X.style.webkitUserSelect="none",X.style.touchAction="none",X.setAttribute("draggable","false"),X.addEventListener("dragstart",(L)=>L.preventDefault()),V=document.createElement("div"),V.className="pie-tool-shell__header",V.style.display="flex",V.style.flexWrap="wrap",V.style.alignItems="center",V.style.justifyContent="space-between",V.style.gap="6px",V.style.padding=XJ()?"12px 12px 12px 28px":"10px 12px",XJ())V.style.minHeight="48px",V.style.background="var(--pie-section-player-card-header-background, var(--pie-button-active-bg, #f3f4f6))",V.style.color="var(--pie-text, #111827)",V.style.borderBottom="1px solid var(--pie-border-light, #e5e7eb)";else V.style.background="var(--pie-primary-dark, #2c3e50)",V.style.color="var(--pie-white, #fff)";V.style.cursor=U.mounted.entry.shell.draggable===!1?"default":"move",V.style.flex="0 0 auto",V.style.borderRadius="12px 12px 0 0",V.style.overflow="hidden",V.style.userSelect="none",V.style.webkitUserSelect="none",V.style.touchAction="none",V.setAttribute("draggable","false"),V.addEventListener("dragstart",(L)=>L.preventDefault()),x=document.createElement("span"),x.className="pie-tool-shell__title",x.style.minWidth="0",x.style.overflowWrap="anywhere",x.textContent=U.mounted.entry.shell.title||U.mounted.toolId,V.appendChild(x),W=document.createElement("div"),W.className="pie-tool-shell__controls",W.style.display="inline-flex",W.style.flexWrap="wrap",W.style.minWidth="0",W.style.alignItems="center",W.style.gap=XJ()?"6px":"4px";let Y=U.mounted.entry.shell,q=(L,R,F,v,h="fa-regular")=>{if(!W)return;let d=U.i18n.t(L),u=K?C0(d,F,v,h):f0(d,R,v);P.push({el:u,key:L}),W.appendChild(u)};if(Y?.draggable!==!1)q("toolkit.window.moveLeftA11y","←","chevron-left",()=>zJ(-PJ,0)),q("toolkit.window.moveRightA11y","→","chevron-right",()=>zJ(PJ,0)),q("toolkit.window.moveUpA11y","↑","chevron-up",()=>zJ(0,-PJ)),q("toolkit.window.moveDownA11y","↓","chevron-down",()=>zJ(0,PJ));if(Y?.resizable!==!1)q("toolkit.window.shrinkA11y","−","magnifying-glass-minus",()=>wZ(-WJ,-WJ)),q("toolkit.window.growA11y","+","magnifying-glass-plus",()=>wZ(WJ,WJ));if(!XJ()){let L=f0(U.i18n.t("toolkit.window.centerA11y"),"◎",HZ);P.push({el:L,key:"toolkit.window.centerA11y"}),W.appendChild(L)}let Q=null;if(XJ())Q=document.createElement("div"),Q.className="pie-tool-shell__header-right",Q.style.display="inline-flex",Q.style.flexWrap="wrap",Q.style.maxWidth="100%",Q.style.justifyContent="flex-end",Q.style.alignItems="center",Q.style.gap="6px",Q.appendChild(W),V.appendChild(Q);else V.appendChild(W);if(K)D=C0(U.i18n.t("toolkit.window.closeA11y"),"xmark",eZ,"fa-regular"),P.push({el:D,key:"toolkit.window.closeA11y"}),D.style.display=U.mounted.entry.shell.closeable===!1?"none":"inline-block";else{let L=document.createElement("button");L.type="button",L.className="pie-tool-shell__close",L.setAttribute("aria-label",U.i18n.t("toolkit.window.closeA11y")),P.push({el:L,key:"toolkit.window.closeA11y"});let R="http://www.w3.org/2000/svg",F=document.createElementNS(R,"svg");F.setAttribute("xmlns",R),F.setAttribute("viewBox","0 0 16 16"),F.setAttribute("aria-hidden","true");let v=document.createElementNS(R,"path");v.setAttribute("d","M3.5 3.5L12.5 12.5M12.5 3.5L3.5 12.5"),v.setAttribute("stroke","currentColor"),v.setAttribute("stroke-width","1.8"),v.setAttribute("stroke-linecap","round"),F.appendChild(v),L.appendChild(F);let h=F.style;h.width="16px",h.height="16px",h.display="block",h.flexShrink="0",h.pointerEvents="none";let d="color-mix(in srgb, var(--pie-white, #fff) 8%, transparent)",u="color-mix(in srgb, var(--pie-white, #fff) 18%, transparent)";L.style.border="1px solid transparent",L.style.background=d,L.style.color="inherit",L.style.cursor="pointer",L.style.display="inline-flex",L.style.alignItems="center",L.style.justifyItems="center",L.style.width="28px",L.style.height="28px",L.style.padding="0",L.style.borderRadius="8px",L.style.lineHeight="0",L.style.transition="background-color 0.15s ease, border-color 0.15s ease",L.style.display=U.mounted.entry.shell.closeable===!1?"none":"inline-flex",L.onmouseenter=()=>{L.style.background=u},L.onmouseleave=()=>{L.style.background=d},L.onfocus=()=>{L.style.outline="2px solid var(--pie-button-focus-outline, var(--pie-primary, #4A90E2))",L.style.outlineOffset="2px"},L.onblur=()=>{L.style.outline="none",L.style.outlineOffset="0"},L.onclick=eZ,D=L}if(Q)Q.appendChild(D);else V.appendChild(D);if(V.tabIndex=0,V.onkeydown=(L)=>{if(L.key==="Home"){L.preventDefault(),HZ();return}let R=U.mounted.entry.shell;if(L.shiftKey&&R?.resizable!==!1){if(L.key==="ArrowRight"||L.key==="ArrowDown"){L.preventDefault(),wZ(WJ,WJ);return}if(L.key==="ArrowLeft"||L.key==="ArrowUp"){L.preventDefault(),wZ(-WJ,-WJ);return}}if(R?.draggable!==!1){if(L.key==="ArrowLeft")L.preventDefault(),zJ(-PJ,0);else if(L.key==="ArrowRight")L.preventDefault(),zJ(PJ,0);else if(L.key==="ArrowUp")L.preventDefault(),zJ(0,-PJ);else if(L.key==="ArrowDown")L.preventDefault(),zJ(0,PJ)}},M=document.createElement("div"),M.className="pie-tool-shell__content",M.style.position="relative",M.style.width="100%",M.style.flex="1 1 auto",M.style.minHeight="0",M.style.overflowX="hidden",M.style.overflowY=_0(),M.style.borderRadius="0 0 12px 12px",XJ()){let L=(R)=>{let F=document.createElement("div");return F.tabIndex=0,F.setAttribute("aria-hidden","true"),F.setAttribute("data-pie-tool-shell-focus-guard",R),F.style.position="absolute",F.style.width="1px",F.style.height="1px",F.style.padding="0",F.style.margin="-1px",F.style.overflow="hidden",F.style.clipPath="inset(50%)",F.style.whiteSpace="nowrap",F.style.border="0",F};o=L("start"),n=L("end"),o.addEventListener("focus",(R)=>{if(s)return;s=!0;try{if(R.stopPropagation(),LJ?.isConnected)AJ(LJ)}finally{queueMicrotask(()=>{s=!1})}}),n.addEventListener("focus",(R)=>{if(s)return;s=!0;try{R.stopPropagation();let F=nZ();if(F)AJ(F)}finally{queueMicrotask(()=>{s=!1})}}),X.appendChild(o)}if(X.appendChild(V),X.appendChild(M),XJ()&&n)X.appendChild(n);if(U.mounted.entry.shell.resizable!==!1){let L=(R,F,v,h,d,u,UJ)=>{let A=document.createElement("div");if(A.className="pie-tool-shell__resize",A.style.position="absolute",A.style.width="24px",A.style.height="24px",A.style.cursor=u,A.style.zIndex="10",A.style.touchAction="none",A.setAttribute("draggable","false"),F!==null)A.style.top=F;if(v!==null)A.style.right=v;if(h!==null)A.style.bottom=h;if(d!==null)A.style.left=d;if(UJ!==null)A.style.background=`linear-gradient(${UJ}, transparent 0%, transparent 40%, rgba(0,0,0,0.35) 40%, rgba(0,0,0,0.35) 60%, transparent 60%, transparent 100%)`;let jZ=lj(R);A.addEventListener("pointerdown",jZ),X.appendChild(A),iZ.push({el:A,handler:jZ})};L("se",null,"0","0",null,"nwse-resize",null),L("nw","0",null,null,"0","nwse-resize","135deg"),L("ne","0","0",null,null,"nesw-resize",null),L("sw",null,null,"0","0","nesw-resize",null)}if(V.addEventListener("pointerdown",g0),X.addEventListener("pointerdown",vJ),window.addEventListener("resize",m0),document.body.appendChild(X),G=new ej(X,{context:Xj,initialValue:U.runtime}),G.connect(),HZ(),ZZ(),p0(),b0(),y0(),kZ(),U.active)v0();WZ=U.active}return{update(K){if(U=K,!X||!M||!x||!D)return;G?.setValue(U.runtime),b0(),dj();let Y=D.tagName.toLowerCase()==="nds-icon-button"?"inline-block":"inline-flex";if(D.style.display=U.mounted.entry.shell?.closeable===!1?"none":Y,ZZ(),p0(),y0(),kZ(),!WZ&&U.active)v0();else if(WZ&&!U.active)E0(),LJ=null;WZ=U.active},destroy(){if(cj(),G?.disconnect(),G=null,P.length=0,$J)E0();if(DJ)document.removeEventListener("keydown",tZ,!0),DJ=!1;for(let{el:K,handler:Y}of iZ)K.removeEventListener("pointerdown",Y);if(LJ=null,iZ.length=0,V)V.removeEventListener("pointerdown",g0),V.onkeydown=null;if(nJ.release(),X)X.removeEventListener("pointerdown",vJ);if(window.removeEventListener("resize",m0),T&&M&&T.parentNode===M)aZ(T),M.removeChild(T);if(T=null,X&&X.parentElement)X.remove()}}}var gj={get level(){return fJ()},set level(Z){fJ(Z),E()},get scopeId(){return YZ()},set scopeId(Z){YZ(Z),E()},get itemId(){return SZ()},set itemId(Z){SZ(Z),E()},get sectionId(){return _Z()},set sectionId(Z){_Z(Z),E()},get catalogId(){return CZ()},set catalogId(Z){CZ(Z),E()},get tools(){return fZ()},set tools(Z){fZ(Z),E()},get contentKind(){return bZ()},set contentKind(Z){bZ(Z),E()},get position(){return FJ()},set position(Z){FJ(Z),E()},get scopeElement(){return QZ()},set scopeElement(Z){QZ(Z),E()},get toolRegistry(){return VZ()},set toolRegistry(Z){VZ(Z),E()},get item(){return yZ()},set item(Z){yZ(Z),E()},get hostButtons(){return DZ()},set hostButtons(Z){DZ(Z),E()},get class(){return pZ()},set class(Z){pZ(Z),E()},get size(){return OZ()},set size(Z){OZ(Z),E()},get language(){return $Z()},set language(Z){$Z(Z),E()}},I0=_J(),mj=SJ(I0);{var hj=(Z)=>{var j=qU();let U;var X=EJ(j),G=EJ(X);KZ(G,17,()=>J(Sj),(W)=>W.key,(W,D)=>{B(W,()=>J(D),()=>"item-toolbar__element-host")});var P=TZ(G,2);KZ(P,17,()=>J(F0),(W)=>W.id,(W,D,o,n)=>{let s=O(()=>J(qZ)&&!Z0(J(D))?X0(J(D)):null);var DJ=_J(),oJ=SJ(DJ);{var XJ=(t)=>{var z=QU(),H=EJ(z);OJ(H,1,"item-toolbar__nds-button svelte-1c13522"),wJ(H,"type","circle"),wJ(H,"size","small"),wJ(H,"variant","tertiary"),r(()=>wJ(H,"icon-name",J(s))),r(()=>wJ(H,"button-aria-label",J(D).ariaLabel||J(D).label)),r(()=>wJ(H,"title",J(D).tooltip||J(D).label)),r(()=>wJ(H,"disabled",J(D).disabled)),XZ(H,(y)=>MJ?.(y)),XZ(H,(y,kJ)=>RJ?.(y,kJ),()=>PZ(J(D))),qJ(z),UZ("click",H,function(...y){J(D).onClick?.apply(this,y)}),b(t,z)},T=(t)=>{var z=VU();let H;var y=EJ(z);{var kJ=(_)=>{r0(_,()=>J(D).icon)};NJ(y,(_)=>{if(J(D).icon)_(kJ)})}qJ(z),r((_)=>{H=OJ(z,1,"item-toolbar__button svelte-1c13522",null,H,{"item-toolbar__button--active":_}),i(z,"href",J(D).disabled?void 0:J(D).href),i(z,"target",J(D).target),i(z,"rel",J(D).rel),i(z,"aria-label",J(D).ariaLabel||J(D).label),i(z,"title",J(D).tooltip||J(D).label),i(z,"aria-disabled",J(D).disabled?"true":void 0)},[()=>PZ(J(D))]),UZ("click",z,(_)=>{if(J(D).disabled)_.preventDefault()}),b(t,z)},IJ=O(()=>Z0(J(D))),nJ=(t)=>{var z=DU();let H;var y=EJ(z);{var kJ=(_)=>{r0(_,()=>J(D).icon)};NJ(y,(_)=>{if(J(D).icon)_(kJ)})}qJ(z),r((_,tJ)=>{H=OJ(z,1,"item-toolbar__button svelte-1c13522",null,H,{"item-toolbar__button--active":_}),i(z,"aria-label",J(D).ariaLabel||J(D).label),i(z,"aria-pressed",tJ),i(z,"title",J(D).tooltip||J(D).label),z.disabled=J(D).disabled},[()=>PZ(J(D)),()=>PZ(J(D))]),UZ("click",z,function(..._){J(D).onClick?.apply(this,_)}),b(t,z)};NJ(oJ,(t)=>{if(J(s))t(XJ);else if(J(IJ))t(T,1);else t(nJ,-1)})}b(W,DJ)});var V=TZ(P,2);KZ(V,17,()=>J(_j),(W)=>W.key,(W,D)=>{B(W,()=>J(D),()=>"item-toolbar__element-host")}),qJ(X);var M=TZ(X,2);{var x=(W)=>{var D=OU();let o;KZ(D,21,()=>J(P0),(n)=>n.key,(n,s)=>{B(n,()=>J(s),()=>"item-toolbar__controls-host")}),qJ(D),r(()=>o=OJ(D,1,"item-toolbar__controls-row svelte-1c13522",null,o,{"item-toolbar__controls-row--reserve":J(z0),"item-toolbar__controls-row--active":J(w0),"item-toolbar__controls-row--align-start":J(Cj)})),b(W,D)};NJ(M,(W)=>{if(J(fj))W(x)})}qJ(j),Uj(j,(W)=>e(ZJ,W),()=>J(ZJ)),r(()=>{U=OJ(j,1,`item-toolbar ${pZ()??""} item-toolbar--${OZ()??""}`,"svelte-1c13522",U,{"item-toolbar--top":FJ()==="top","item-toolbar--right":FJ()==="right","item-toolbar--bottom":FJ()==="bottom","item-toolbar--left":FJ()==="left","item-toolbar--header-overlay-active":J(H0)}),i(j,"data-content-kind",J(sJ)),i(j,"data-level",J(I))}),UZ("focusin",X,(W)=>{if(J(I)==="section"&&W.target instanceof HTMLElement)W.target.scrollIntoView({block:"nearest",inline:"nearest"})}),b(Z,j)};NJ(mj,(Z)=>{if(S)Z(hj)})}return b(k,I0),t0(gj)}Jj(["focusin","click"]);tj("pie-item-toolbar",Kj(Nj,{level:{attribute:"level",type:"String"},scopeId:{attribute:"scope-id",type:"String"},itemId:{attribute:"item-id",type:"String"},sectionId:{attribute:"section-id",type:"String"},catalogId:{attribute:"catalog-id",type:"String"},tools:{attribute:"tools",type:"String"},contentKind:{attribute:"content-kind",type:"String"},position:{attribute:"position",type:"String"},size:{attribute:"size",type:"String"},language:{attribute:"language",type:"String"},scopeElement:{type:"Object"},toolRegistry:{type:"Object"},item:{type:"Object"},hostButtons:{type:"Object"},class:{}},[],[],{mode:"open"}));
40
- export{Nj as l};