@cratis/event-models 0.347.0 → 0.348.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.
Files changed (29) hide show
  1. package/dist/References/EventNavigateButton.d.ts +1 -0
  2. package/dist/Rows/UserExperience/UiCell.d.ts +2 -1
  3. package/dist/event-models.css +1 -1
  4. package/dist/index.js +805 -791
  5. package/dist/index.js.map +1 -1
  6. package/dist/screen-editor/DataBindingSections-BeQxUfQM.js +1919 -0
  7. package/dist/screen-editor/{QueryBindingPropertyEditor-BzDtdbGf.js → QueryBindingPropertyEditor-XQDHU9xb.js} +15 -15
  8. package/dist/screen-editor/ScreenEditor/DesignMode/DesignModeStrings.d.ts +1 -0
  9. package/dist/screen-editor/ScreenEditor/DesignMode/designModeFeedback.d.ts +10 -0
  10. package/dist/screen-editor/ScreenEditor/DesignMode/useDesignMode.d.ts +1 -0
  11. package/dist/screen-editor/ScreenEditor/Host/ScreenEditorController.d.ts +2 -0
  12. package/dist/screen-editor/ScreenEditor/Host/ScreenEditorHost.d.ts +1 -0
  13. package/dist/screen-editor/ScreenEditor/Host/openSubject.d.ts +1 -0
  14. package/dist/screen-editor/ScreenEditor/Host/useEditingScene.d.ts +1 -1
  15. package/dist/screen-editor/ScreenEditor/Inspector/ScreenEditorStrings.d.ts +2 -0
  16. package/dist/screen-editor/ScreenEditor/Inspector/ViewportControls.d.ts +2 -1
  17. package/dist/screen-editor/ScreenEditor/Play/PlayScreen.d.ts +2 -1
  18. package/dist/screen-editor/ScreenEditor/Play/composePlayScreen.d.ts +4 -2
  19. package/dist/screen-editor/ScreenEditor/ShellFrame/shellVisibility.d.ts +3 -2
  20. package/dist/screen-editor/ScreenEditor/ShellFrame/useShellFrame.d.ts +3 -1
  21. package/dist/screen-editor/ScreenEditor/Surface/dialogFrameAttributes.d.ts +6 -0
  22. package/dist/screen-editor/ScreenEditor/Templates/dialogActionsChrome.d.ts +3 -3
  23. package/dist/screen-editor/ScreenEditor/Templates/dialogPresentation.d.ts +13 -0
  24. package/dist/screen-editor/ScreenEditor/Templates/displayedFits.d.ts +6 -0
  25. package/dist/screen-editor/ScreenEditor/Thumbnail/ScreenThumbnail.d.ts +2 -1
  26. package/dist/screen-editor/index.js +3701 -3626
  27. package/dist/screen-editor/screen-editor.css +1 -1
  28. package/package.json +3 -3
  29. package/dist/screen-editor/DataBindingSections-DLo6sV-E.js +0 -1862
@@ -0,0 +1,1919 @@
1
+ import { r as et, t as tt } from "./sceneTree-CNx3I3MJ.js";
2
+ import { a as nt, c as rt, i as st, n as ot, r as it, t as at } from "./hookBinding-DOpu2dMp.js";
3
+ import { useMemo as R } from "react";
4
+ import { Fragment as lt, jsx as I, jsxs as q } from "react/jsx-runtime";
5
+ import { EditingScopeKind as ie, FilterControl as ae, HorizontalAlignment as dt, OutletItemKind as O, OutletKind as F, OutletMode as D, OutletSubject as ct, PropertyEditorKind as Q, PropertyValueType as x, QueryResultShape as Fe, SceneEditKind as ut, ScreenFit as U, ValueSource as me, VerticalAlignment as mt, Visibility as pt, componentIcon as Ee, dialogActionsOutletName as xe } from "@cratis/scene.model";
6
+ import { NavigationEditKind as we, OutletDiagnosticCode as ft, OutletItemSource as Te, OutletLevelKind as $, OutletRemoval as ht, addNavigationItem as gt, applicationNavigationLevel as vt, diagnoseNavigationOutlets as bt, dialogTemplateOutlets as yt, effectiveNavigation as Ot, effectiveOutlet as St, elementNodeId as wt, findComponentDescriptor as Tt, isExternalComponent as kt, outletChainOf as It, outletItemsComponentName as Me, ownOutletItems as Nt, switchOutletMode as At } from "@cratis/scene.engine";
7
+ import { itemEditableRule as Re, itemInheritedReason as De, navigationDesignMode as Ct, toolbarDesignMode as jt } from "@cratis/scene.react";
8
+ import { defaultBlueprint as ee } from "@cratis/scene.blueprint.default";
9
+ var pe = {
10
+ name: "StudioScreen",
11
+ slots: [{ name: "content" }]
12
+ }, H = "content", E = "Screen", tr = "template-root", nr = "screen-root", Le = () => ({
13
+ layouts: [pe],
14
+ screenTemplates: [],
15
+ dialogTemplates: [],
16
+ screens: [],
17
+ exposures: [],
18
+ instanceContributions: []
19
+ });
20
+ function rr(e, t) {
21
+ return {
22
+ ...Le(),
23
+ screens: [{
24
+ name: E,
25
+ layout: pe.name,
26
+ slotContent: { [H]: [e] },
27
+ forms: [],
28
+ contributions: [],
29
+ ...t ? { screenTemplate: t } : {}
30
+ }]
31
+ };
32
+ }
33
+ function sr(e, t, n) {
34
+ return {
35
+ ...Le(),
36
+ screenTemplates: [{
37
+ name: e,
38
+ slots: [{ name: H }],
39
+ content: { [H]: [t] },
40
+ ...n ? { fitsSlot: n } : {}
41
+ }]
42
+ };
43
+ }
44
+ function or(e, t) {
45
+ return (t === void 0 ? e.screens.find((n) => n.name === E)?.slotContent : e.screenTemplates.find((n) => n.name === t)?.content)?.[H]?.[0];
46
+ }
47
+ function ir(e, t = !1) {
48
+ return t && e !== void 0 ? {
49
+ kind: ie.ScreenTemplate,
50
+ name: e,
51
+ layout: pe.name
52
+ } : {
53
+ kind: ie.Screen,
54
+ name: E
55
+ };
56
+ }
57
+ var $t = () => ({
58
+ application: { outlets: [] },
59
+ modules: []
60
+ }), fe = (e) => e.navigation ?? $t(), Ft = (e, t) => ({
61
+ ...e,
62
+ navigation: t
63
+ });
64
+ function Et(e, t, n) {
65
+ return Nt(e, t, n).filter((r) => r.kind === O.Navigation);
66
+ }
67
+ var Be = (e, t) => e !== void 0 && t !== void 0 && e.kind === t.kind && e.name === t.name, he = (e) => e.outletLevels ?? [];
68
+ function xt(e, t) {
69
+ const { outletLevels: n, ...r } = e, s = t.filter((o) => (o.refinements ?? []).length > 0 || (o.contributions ?? []).length > 0 || (o.outlets ?? []).length > 0);
70
+ return s.length === 0 ? r : {
71
+ ...r,
72
+ outletLevels: s
73
+ };
74
+ }
75
+ function Mt(e, t, n) {
76
+ return t.kind === $.Module ? fe(e).modules.find((r) => r.module === t.name)?.refinements?.find((r) => r.outlet === n) : he(e).find((r) => r.kind === t.kind && r.name === t.name)?.refinements?.find((r) => r.outlet === n);
77
+ }
78
+ function Rt(e, t, n, r) {
79
+ const s = (i) => {
80
+ const d = (i ?? []).filter((a) => a.outlet !== n);
81
+ return r ? [...d, r] : d;
82
+ };
83
+ if (t.kind === $.Module) {
84
+ const i = fe(e), d = (i.modules.some((a) => a.module === t.name) ? i.modules : [...i.modules, { module: t.name }]).flatMap((a) => {
85
+ if (a.module !== t.name) return [a];
86
+ const { refinements: f, ...y } = a, h = s(a.refinements), g = h.length > 0 ? {
87
+ ...y,
88
+ refinements: h
89
+ } : y;
90
+ return g.refinements || g.contributions ? [g] : [];
91
+ });
92
+ return Ft(e, {
93
+ ...i,
94
+ modules: d
95
+ });
96
+ }
97
+ const o = he(e);
98
+ return xt(e, (o.some((i) => i.kind === t.kind && i.name === t.name) ? o : [...o, {
99
+ kind: t.kind,
100
+ name: t.name
101
+ }]).map((i) => {
102
+ if (i.kind !== t.kind || i.name !== t.name) return i;
103
+ const { refinements: d, ...a } = i, f = s(i.refinements);
104
+ return f.length > 0 ? {
105
+ ...a,
106
+ refinements: f
107
+ } : a;
108
+ }));
109
+ }
110
+ function ar(e, t, n) {
111
+ return {
112
+ ...e,
113
+ screenTemplates: e.screenTemplates.map((r) => {
114
+ if (r.name !== t) return r;
115
+ const { outlets: s, ...o } = r;
116
+ return n.length > 0 ? {
117
+ ...o,
118
+ outlets: [...n]
119
+ } : o;
120
+ })
121
+ };
122
+ }
123
+ function lr(e) {
124
+ return { types: e };
125
+ }
126
+ var dr = ({ diagnostics: e, label: t }) => {
127
+ if (e.length === 0) return null;
128
+ const n = [...e].sort((r, s) => +(s.severity === "error") - +(r.severity === "error"));
129
+ return /* @__PURE__ */ I("div", {
130
+ className: "studio-editor-diagnostics__announce",
131
+ role: "alert",
132
+ "aria-label": t,
133
+ children: /* @__PURE__ */ I("ul", {
134
+ className: "studio-editor-diagnostics",
135
+ children: n.map((r, s) => /* @__PURE__ */ q("li", {
136
+ "data-severity": r.severity,
137
+ "data-code": r.code,
138
+ children: [
139
+ r.severityLabel && /* @__PURE__ */ I("strong", {
140
+ className: "studio-editor-diagnostics__severity",
141
+ children: r.severityLabel
142
+ }),
143
+ /* @__PURE__ */ I("span", {
144
+ className: "studio-editor-diagnostics__message",
145
+ children: r.message
146
+ }),
147
+ r.where && /* @__PURE__ */ I("span", {
148
+ className: "studio-editor-diagnostics__where",
149
+ children: r.where
150
+ }),
151
+ r.jump && /* @__PURE__ */ I("button", {
152
+ type: "button",
153
+ className: "studio-editor-diagnostics__jump",
154
+ onClick: r.jump.onJump,
155
+ children: r.jump.label
156
+ })
157
+ ]
158
+ }, `${r.code}:${r.path ?? ""}:${s}`))
159
+ })
160
+ });
161
+ }, c = {
162
+ addItem: "addItem",
163
+ addButton: "addButton",
164
+ rename: "rename",
165
+ target: "target",
166
+ slot: "slot",
167
+ slice: "slice",
168
+ emphasis: "emphasis",
169
+ display: "display",
170
+ addFilter: "addFilter",
171
+ addTab: "addTab",
172
+ addStat: "addStat",
173
+ sets: "sets",
174
+ control: "control",
175
+ shows: "shows",
176
+ valueFrom: "valueFrom",
177
+ opens: "opens",
178
+ enabled: "enabled",
179
+ moveEarlier: "moveEarlier",
180
+ moveLater: "moveLater",
181
+ duplicate: "duplicate",
182
+ delete: "delete",
183
+ addSubItem: "addSubItem"
184
+ }, _e = /* @__PURE__ */ (function(e) {
185
+ return e.Elements = "elements", e.Collection = "collection", e.Region = "region", e.Outlet = "outlet", e;
186
+ })({}), Dt = (e) => "rejected" in e, M = (e, t, n) => ({
187
+ id: e,
188
+ icon: Ee(t),
189
+ title: n,
190
+ availability: Re,
191
+ readOnlyReason: De
192
+ }), Lt = [
193
+ M(c.moveEarlier, "arrow-left", "Move earlier"),
194
+ M(c.moveLater, "arrow-right", "Move later"),
195
+ M(c.duplicate, "copy", "Duplicate"),
196
+ M(c.delete, "trash", "Delete")
197
+ ], le = {
198
+ [F.Actions]: {
199
+ id: c.addButton,
200
+ item: O.Button
201
+ },
202
+ [F.Filters]: {
203
+ id: c.addFilter,
204
+ item: O.Filter
205
+ },
206
+ [F.Tabs]: {
207
+ id: c.addTab,
208
+ item: O.Tab
209
+ },
210
+ [F.Stats]: {
211
+ id: c.addStat,
212
+ item: O.Stat
213
+ },
214
+ [F.Navigation]: {
215
+ id: c.addItem,
216
+ item: O.Navigation
217
+ }
218
+ }, se = (e, t, n) => ({
219
+ addActions: [{
220
+ id: le[e].id,
221
+ label: t,
222
+ icon: Ee("plus")
223
+ }],
224
+ itemToolbar: [
225
+ M(c.rename, "pencil", "Rename"),
226
+ ...n,
227
+ ...Lt
228
+ ]
229
+ });
230
+ function Bt(e) {
231
+ switch (e) {
232
+ case F.Actions: {
233
+ const t = jt(), n = t.itemToolbar.findIndex((o) => o.id === c.emphasis), r = [M(c.opens, "panel-right-open", "Opens"), M(c.enabled, "toggle-right", "Enabled")], s = n < 0 ? [...t.itemToolbar, ...r] : [
234
+ ...t.itemToolbar.slice(0, n),
235
+ ...r,
236
+ ...t.itemToolbar.slice(n)
237
+ ];
238
+ return {
239
+ ...t,
240
+ itemToolbar: s
241
+ };
242
+ }
243
+ case F.Navigation:
244
+ return Ct({ sidebar: !0 });
245
+ case F.Filters:
246
+ return se(e, "Add filter", [M(c.sets, "filter", "Sets"), M(c.control, "sliders-horizontal", "Control")]);
247
+ case F.Tabs:
248
+ return se(e, "Add tab", [M(c.shows, "app-window", "Shows")]);
249
+ case F.Stats:
250
+ return se(e, "Add stat", [M(c.valueFrom, "hash", "Value from")]);
251
+ }
252
+ }
253
+ var _t = {
254
+ kinds: {
255
+ actions: "actions",
256
+ filters: "filters",
257
+ tabs: "tabs",
258
+ stats: "stats",
259
+ navigation: "navigation"
260
+ },
261
+ newItem: {
262
+ button: "New button",
263
+ filter: "New filter",
264
+ tab: "New tab",
265
+ stat: "New stat",
266
+ navigation: "New item",
267
+ menuEntry: "New entry",
268
+ separator: "Separator",
269
+ group: "New group"
270
+ },
271
+ frameName: (e, t) => `outlet ${e} · ${t}`,
272
+ tagLong: (e, t) => `${e} · ${t}`,
273
+ title: (e, t) => `Outlet · ${e} ${t}`,
274
+ declaredBy: (e) => `From ${e}.`,
275
+ editingAs: "Editing as",
276
+ levels: {
277
+ module: "module",
278
+ feature: "feature",
279
+ slice: "slice",
280
+ screen: "screen",
281
+ template: "template",
282
+ layout: "layout"
283
+ },
284
+ levelName: (e, t) => `${e} ${t}`,
285
+ everyScreenBelow: (e) => `Every screen in ${e} gets this.`,
286
+ modeTitle: "How this level takes the outlet",
287
+ modes: {
288
+ inherit: {
289
+ title: "Inherit",
290
+ description: (e) => `${e}'s items, unchanged.`
291
+ },
292
+ extend: {
293
+ title: "Extend",
294
+ description: (e) => `${e}'s items, then yours. Hide the ones you don't want.`
295
+ },
296
+ override: {
297
+ title: "Override",
298
+ description: (e) => `Only your items. ${e}'s stay listed, struck through, so you can bring one back.`
299
+ }
300
+ },
301
+ copyPrompt: "Copy the inherited items, so you start from them?",
302
+ copyYes: "Copy them",
303
+ copyNo: "Start empty",
304
+ extendsNotice: "This level now extends the inherited items",
305
+ items: "Items",
306
+ add: (e) => `Add ${e}`,
307
+ own: "yours",
308
+ fromLevel: (e) => `from ${e}`,
309
+ contributedBy: (e) => `contributed by ${e}`,
310
+ hiddenHere: "hidden here",
311
+ overriddenHere: "overridden here",
312
+ hide: "Hide",
313
+ bringBack: "Bring back",
314
+ contributionNote: "Contributed items belong to the feature that adds them; they always come after the inherited items.",
315
+ nothingYet: "No items yet.",
316
+ bindings: {
317
+ title: "Title",
318
+ sets: "Sets",
319
+ control: "Control",
320
+ controls: {
321
+ search: "Search",
322
+ choice: "Choice chips",
323
+ range: "Range",
324
+ date: "Date"
325
+ },
326
+ shows: "Shows",
327
+ valueFrom: "Value from",
328
+ trend: "Trend from",
329
+ target: "Navigate to",
330
+ slot: "Render into slot",
331
+ icon: "Icon",
332
+ opens: "Opens",
333
+ opensChoices: {
334
+ automatic: "Automatic",
335
+ none: "Run directly",
336
+ dialog: "Dialog",
337
+ drawer: "Drawer",
338
+ slot: "In a slot"
339
+ },
340
+ chooseParameter: "Choose parameter",
341
+ chooseScreen: "Choose screen",
342
+ chooseField: "Choose field",
343
+ automatic: "Automatic",
344
+ noQuery: "The screen shows no query yet, so there is nothing to bind to."
345
+ },
346
+ otherOutlets: "Other outlets on this screen",
347
+ modeOf: {
348
+ inherit: "inherits",
349
+ extend: "extends",
350
+ override: "overrides",
351
+ declares: "declares"
352
+ },
353
+ added: (e) => `+${e}`,
354
+ template: {
355
+ slots: "Slots",
356
+ outlets: "Outlets",
357
+ name: "Name",
358
+ kind: "Kind",
359
+ subject: "Acts on",
360
+ subjects: {
361
+ "": "The screen",
362
+ item: "The selected item",
363
+ screen: "The screen"
364
+ },
365
+ slot: "In slot",
366
+ noSlot: "No slot",
367
+ defaults: "Defaults",
368
+ defaultsCount: (e) => e === 1 ? "1 default" : `${e} defaults`,
369
+ addOutlet: "Add outlet",
370
+ removeOutlet: "Remove outlet",
371
+ removeDefault: "Remove",
372
+ newOutletName: "outlet",
373
+ routed: "routed",
374
+ primary: "primary",
375
+ optional: "optional"
376
+ }
377
+ }, qt = {
378
+ toolbarLabel: (e) => `Actions for ${e}`,
379
+ slotName: (e) => `slot: ${e}`,
380
+ titleField: "Title",
381
+ notLinked: "Not linked",
382
+ chooseSlice: "Choose slice",
383
+ mainArea: "Main area",
384
+ emphasis: {
385
+ primary: "Primary",
386
+ secondary: "Secondary",
387
+ quiet: "Quiet"
388
+ },
389
+ noSliceWarning: "No slice is linked to this button",
390
+ readOnlyReasons: { "item.inherited": "Inherited from the template" },
391
+ inheritedFrom: (e) => `Inherited from ${e}`,
392
+ editAtOwner: "Edit at application level",
393
+ choiceLabel: (e) => e,
394
+ toolbar: {
395
+ toolbarButton: "Button",
396
+ opensAsDialog: "opens as dialog",
397
+ dialogFromSlice: (e) => `Opens the slice's own dialog template, ${e}.`,
398
+ dialogDefault: (e) => `The slice names no dialog template, so it opens the default ${e}.`,
399
+ sliceHelp: "Only State Change slices can be picked. State Views and Automations never take user input, so they are listed as unavailable.",
400
+ stateChangeHeading: "State Change slices",
401
+ notInvokableHeading: "Not invokable from a button",
402
+ upgrade: "Upgrade to the slice",
403
+ upgradeNote: (e) => `This button names a command. The slice that accepts it is ${e}, and that is what it runs. `,
404
+ shows: "Shows",
405
+ showsHelp: "An icon-only button keeps its title as its accessible name and tooltip.",
406
+ displays: {
407
+ iconAndTitle: "Icon and title",
408
+ icon: "Icon only",
409
+ title: "Title only"
410
+ }
411
+ },
412
+ navigation: {
413
+ application: "Application",
414
+ extendsNotice: "Region now extends the inherited items",
415
+ overrideHere: "Override here",
416
+ editAtApplication: "Edit at application level",
417
+ backToModule: (e) => `Back to ${e}`,
418
+ tagLong: (e, t) => `${e === "sidebar" ? "Sidebar" : "Topbar"} · ${t === "defined here" ? "defined here" : t === "inherited" ? "inherits the application" : t.endsWith(" only") ? "overrides the application" : "extends application"}`,
419
+ regionName: {
420
+ topbar: "topbar",
421
+ sidebar: "sidebar"
422
+ },
423
+ inheritedFromApplication: "Inherited from Application",
424
+ inheritedNote: (e) => `This item comes from the Application. Override this region to edit a copy in ${e}.`,
425
+ definedIn: (e) => `defined in ${e}`,
426
+ inheritedReadOnly: "inherited · read-only",
427
+ navigationItem: "Navigation item",
428
+ hierarchy: "Where it appears",
429
+ label: "Label",
430
+ navigateTo: "Navigate to",
431
+ renderIntoSlot: "Render into slot",
432
+ icon: "Icon",
433
+ notLinked: "Not linked",
434
+ mainArea: "Main area",
435
+ sidePanel: "Side panel",
436
+ modeTitle: (e, t) => `${e} · ${t}`,
437
+ modeDescription: (e) => `How this module relates to the application-level ${e} items.`,
438
+ modes: {
439
+ inherit: {
440
+ title: "Inherit",
441
+ description: "Use the application items as they are. Removes items added in this module."
442
+ },
443
+ extend: {
444
+ title: "Extend",
445
+ description: "Application items first, then this module's own items."
446
+ },
447
+ override: {
448
+ title: "Override",
449
+ description: "Only this module's items. Switching copies the application items so you can edit them."
450
+ }
451
+ },
452
+ copyPrompt: "Copy the application items so you can edit them?",
453
+ copyYes: "Copy them",
454
+ copyNo: "Start empty",
455
+ logo: "Logo",
456
+ logoTitle: "Name",
457
+ logoImage: "Image",
458
+ logoLocked: "The logo is defined at the application level only.",
459
+ target: {
460
+ heading: "Navigate to",
461
+ application: "Application",
462
+ module: "module",
463
+ unresolved: (e) => `${e} no longer exists`
464
+ },
465
+ problems: {
466
+ navTargetMissing: "This item leads nowhere yet.",
467
+ navTargetOutOfScope: "A module can only link to itself.",
468
+ navModuleWithoutFeatures: "That module has no feature to open.",
469
+ navSlotUnknown: "The layout has no such slot.",
470
+ navDuplicateId: "Another item uses this identity."
471
+ }
472
+ },
473
+ close: "Close",
474
+ outlets: _t,
475
+ announce: {
476
+ added: (e) => `Added ${e}`,
477
+ moved: (e, t, n) => `Moved ${e} to position ${t} of ${n}`,
478
+ duplicated: (e) => `Duplicated ${e}`,
479
+ removed: (e) => `Removed ${e}`,
480
+ refused: (e) => `Not possible: ${e}`,
481
+ nothingToAdd: "Not possible: there is nothing here to add to"
482
+ }
483
+ }, qe = () => globalThis.crypto.randomUUID();
484
+ function Pt({ document: e, screen: t, slices: n, queries: r, templates: s = [], layouts: o = [] }) {
485
+ return {
486
+ slices: n,
487
+ slots: rt(e, s, o, t),
488
+ itemFields: new Set(r.filter((i) => i.resultShape === Fe.Collection).flatMap((i) => i.resultFields.map((d) => d.name))),
489
+ routeParameters: []
490
+ };
491
+ }
492
+ function Ht(e, t) {
493
+ switch (e.availability) {
494
+ case void 0:
495
+ return !0;
496
+ case Re:
497
+ return !t.readOnly;
498
+ default:
499
+ return !1;
500
+ }
501
+ }
502
+ var Y = De;
503
+ function cr(e, t) {
504
+ if (!Ht(e, t)) return {
505
+ visible: !1,
506
+ enabled: !1
507
+ };
508
+ switch (e.id) {
509
+ case c.moveEarlier:
510
+ return {
511
+ visible: !0,
512
+ enabled: t.index > 0
513
+ };
514
+ case c.moveLater:
515
+ return {
516
+ visible: !0,
517
+ enabled: t.index < t.count - 1
518
+ };
519
+ case c.addSubItem:
520
+ return {
521
+ visible: !0,
522
+ enabled: t.parentId === void 0
523
+ };
524
+ default:
525
+ return {
526
+ visible: !0,
527
+ enabled: !0
528
+ };
529
+ }
530
+ }
531
+ var ge = (e, t, n) => e.flatMap((r) => {
532
+ if (r.id === t) {
533
+ const s = n(r);
534
+ return s ? [s] : [];
535
+ }
536
+ return [r.children ? {
537
+ ...r,
538
+ children: ge(r.children, t, n)
539
+ } : r];
540
+ }), Vt = (e) => Object.fromEntries(Object.entries(e).filter(([, t]) => t !== void 0)), Z = (e, t, n) => ge(e, t, (r) => Vt({
541
+ ...r,
542
+ ...n
543
+ })), Wt = (e, t) => ge(e, t, () => {
544
+ });
545
+ function G(e, t) {
546
+ for (const n of e) {
547
+ if (n.id === t) return n;
548
+ const r = n.children ? G(n.children, t) : void 0;
549
+ if (r) return r;
550
+ }
551
+ }
552
+ function J(e, t) {
553
+ if (e.some((n) => n.id === t)) return e;
554
+ for (const n of e) {
555
+ const r = n.children ? J(n.children, t) : void 0;
556
+ if (r) return r;
557
+ }
558
+ }
559
+ function Ut(e, t, n) {
560
+ const r = J(e, t);
561
+ if (!r) return [...e];
562
+ const s = r.findIndex((d) => d.id === t);
563
+ if (s < 0 || n < 0 || n >= r.length || s === n) return [...e];
564
+ const o = [...r], [i] = o.splice(s, 1);
565
+ return o.splice(n, 0, i), r === e ? o : ve(e, r, o);
566
+ }
567
+ function ve(e, t, n) {
568
+ return e.map((r) => r.children === t ? {
569
+ ...r,
570
+ children: n
571
+ } : r.children ? {
572
+ ...r,
573
+ children: ve(r.children, t, n)
574
+ } : r);
575
+ }
576
+ var Pe = (e, t) => ({
577
+ ...structuredClone(e),
578
+ id: t(),
579
+ ...e.children ? { children: e.children.map((n) => Pe(n, t)) } : {}
580
+ });
581
+ function zt(e, t, n) {
582
+ const r = G(e, t), s = J(e, t);
583
+ if (!r || !s) return { items: [...e] };
584
+ const o = Pe(r, n), i = s.findIndex((a) => a.id === t) + 1, d = [
585
+ ...s.slice(0, i),
586
+ o,
587
+ ...s.slice(i)
588
+ ];
589
+ return {
590
+ items: s === e ? d : ve(e, s, d),
591
+ copy: o
592
+ };
593
+ }
594
+ var Kt = (e) => e === D.Inherits ? "inherit" : e === D.Extends ? "extend" : e === D.Overrides ? "override" : void 0;
595
+ function He(e, t) {
596
+ if (!t?.module) return;
597
+ const n = e.modules.find((o) => o.id === t.module);
598
+ if (!n) return t.module;
599
+ if (!t.feature) return n.name;
600
+ const r = [];
601
+ let s = n.features;
602
+ for (const o of t.feature.split(".")) {
603
+ const i = s.find((d) => d.id === o);
604
+ r.push(i?.name ?? o), s = i?.features ?? [];
605
+ }
606
+ return [n.name, ...r].join(" › ");
607
+ }
608
+ function ur(e) {
609
+ const { region: t, module: n, navigation: r, structure: s, newId: o, slots: i, startingLabel: d, strings: a } = e, f = Ot(s, r, n, t), y = Et(r, n, t), h = bt(s, r, { slots: [...i] }), g = (T) => `${n ?? "application"}:${t}:${T}`, p = [], k = (T, v) => {
610
+ const S = T.filter((u) => !u.readOnly);
611
+ T.forEach((u) => {
612
+ const C = G(y, u.id)?.target ?? (u.target ? {
613
+ module: u.target.module,
614
+ ...u.target.feature ? { feature: u.target.feature } : {}
615
+ } : void 0), K = u.readOnly ? -1 : S.indexOf(u), ne = He(s, C), V = h.filter((W) => W.entry === g(u.id)).map((W) => ({
616
+ code: W.code,
617
+ message: W.message
618
+ }));
619
+ p.push({
620
+ id: u.id,
621
+ label: u.title,
622
+ index: K,
623
+ count: S.length,
624
+ ...v ? { parentId: v } : {},
625
+ readOnly: u.readOnly,
626
+ ...u.readOnly ? {
627
+ readOnlyReason: Y,
628
+ origin: a.application
629
+ } : {},
630
+ values: {
631
+ target: C,
632
+ slot: u.slot,
633
+ icon: u.icon,
634
+ children: u.children?.length
635
+ },
636
+ chips: {
637
+ target: ne ?? "",
638
+ slot: u.slot === "content" || u.slot === "" ? a.mainArea : u.slot
639
+ },
640
+ ...V.length > 0 ? { problems: V } : {},
641
+ unlinked: C === void 0 && !(u.children && u.children.length > 0)
642
+ }), u.children && k(u.children, u.id);
643
+ });
644
+ };
645
+ k(f.items);
646
+ const L = t, j = (T, v, S, u = {}) => v.rejected ? { rejected: v.rejected } : {
647
+ label: T,
648
+ edits: [],
649
+ navigationEdits: v.edits,
650
+ ...S ? { select: S } : {},
651
+ ...u
652
+ }, w = (T) => ({ edits: [{
653
+ kind: we.SetOutletItems,
654
+ ...n !== void 0 ? { module: n } : {},
655
+ outlet: t,
656
+ items: T
657
+ }] }), A = (T) => {
658
+ const v = o(), S = gt(r, n, t, {
659
+ kind: O.Navigation,
660
+ id: v,
661
+ title: d
662
+ }, T), u = S.edits.some((C) => C.kind === we.SetOutletMode);
663
+ return j("Add", S, { itemId: v }, {
664
+ renameNext: !0,
665
+ ...u ? { notice: a.extendsNotice } : {}
666
+ });
667
+ };
668
+ return {
669
+ kind: _e.Region,
670
+ items: p,
671
+ regionTag: {
672
+ text: f.sources.label,
673
+ long: a.tagLong(t, f.sources.label),
674
+ kind: f.sources.kind
675
+ },
676
+ region: {
677
+ region: L,
678
+ ...n !== void 0 ? { module: n } : {},
679
+ ...f.mode ? { mode: Kt(f.mode) } : {}
680
+ },
681
+ add: (T) => T === c.addItem ? A() : { rejected: T },
682
+ act: (T, v) => {
683
+ switch (T) {
684
+ case c.addSubItem:
685
+ return v.parentId !== void 0 ? { rejected: "subItemOfSubItem" } : A(v.id);
686
+ case c.moveEarlier:
687
+ case c.moveLater: {
688
+ const S = v.index + (T === c.moveEarlier ? -1 : 1), u = J(y, v.id);
689
+ return !u || S < 0 || S >= u.length ? { rejected: "noWhere" } : j("Move", w(Ut(y, v.id, S)), { itemId: v.id });
690
+ }
691
+ case c.duplicate: {
692
+ const S = zt(y, v.id, o);
693
+ return S.copy ? j("Duplicate", w(S.items), { itemId: S.copy.id }) : { rejected: T };
694
+ }
695
+ case c.delete: {
696
+ const S = J(y, v.id) ?? [], u = S.findIndex((K) => K.id === v.id), C = S[u + 1] ?? S[u - 1];
697
+ return j("Remove", w(Wt(y, v.id)), { itemId: C?.id ?? null });
698
+ }
699
+ default:
700
+ return { rejected: T };
701
+ }
702
+ },
703
+ rename: (T, v) => j("Rename", w(Z(y, T.id, { title: v })), { itemId: T.id }),
704
+ choice: (T, v) => {
705
+ const S = G(y, v.id);
706
+ if (S) {
707
+ if (T === c.target) return {
708
+ property: oe("target", "Navigate to", "navigationItemTarget", S.target),
709
+ plan: (u) => j("Link", w(Z(y, v.id, { target: Qt(u) ? u : void 0 })), { itemId: v.id })
710
+ };
711
+ if (T === c.slot) return {
712
+ property: oe("slot", "Render into slot", "renderingSlot", S.slot ?? "content"),
713
+ plan: (u) => j("Change", w(Z(y, v.id, { slot: typeof u == "string" && u !== "content" ? u : void 0 })), { itemId: v.id })
714
+ };
715
+ if (T === "icon") return {
716
+ property: oe("icon", "Icon", "icon", S.icon),
717
+ plan: (u) => j("Change", w(Z(y, v.id, { icon: typeof u == "string" && u !== "" ? u : void 0 })), { itemId: v.id })
718
+ };
719
+ }
720
+ },
721
+ readOnlyActions: () => n === void 0 ? [] : [{
722
+ id: "overrideHere",
723
+ label: a.overrideHere,
724
+ plan: () => j("Override", At(r, n, t, D.Overrides, { copy: !0 }))
725
+ }, {
726
+ id: "editAtApplication",
727
+ label: a.editAtApplication,
728
+ plan: () => ({
729
+ label: "Edit at application level",
730
+ edits: [],
731
+ editAtApplication: !0
732
+ })
733
+ }]
734
+ };
735
+ }
736
+ var Qt = (e) => typeof e == "object" && e !== null && typeof e.module == "string";
737
+ function oe(e, t, n, r) {
738
+ return {
739
+ descriptor: {
740
+ path: e,
741
+ label: t,
742
+ group: "Content",
743
+ valueType: x.String,
744
+ editorKind: n
745
+ },
746
+ currentValue: r,
747
+ effectiveValue: r,
748
+ source: me.Local,
749
+ editable: !0
750
+ };
751
+ }
752
+ function Yt(e, t) {
753
+ return {
754
+ id: e,
755
+ name: t,
756
+ visibility: pt.Visible,
757
+ isEnabled: !0,
758
+ opacity: 1,
759
+ size: {},
760
+ zIndex: 0,
761
+ minimumSize: {},
762
+ maximumSize: {},
763
+ margin: {
764
+ left: 0,
765
+ top: 0,
766
+ right: 0,
767
+ bottom: 0
768
+ },
769
+ horizontalAlignment: dt.Stretch,
770
+ verticalAlignment: mt.Stretch,
771
+ properties: {}
772
+ };
773
+ }
774
+ function Jt(e, t, n, r = {}, s = {}) {
775
+ return {
776
+ ...Yt(e, t),
777
+ componentName: n,
778
+ properties: r,
779
+ slots: s
780
+ };
781
+ }
782
+ function Zt(e, t = [], n = !1, r = Gt) {
783
+ if (e?.fits && e.fits.length > 0) return e.fits;
784
+ const s = e?.screenTemplate;
785
+ return s !== void 0 && r.includes(s) ? [U.Dialog] : s !== void 0 && t.includes(s) ? [U.Page] : n ? [U.Dialog] : [U.Page];
786
+ }
787
+ var Gt = (ee.dialogTemplates ?? []).map((e) => e.name);
788
+ function Ve(e, t = []) {
789
+ const n = new Set((e?.screenTemplates ?? []).map((s) => s.name)), r = new Set((e?.dialogTemplates ?? []).map((s) => s.name));
790
+ for (const s of [...ee.dialogTemplates ?? [], ...t]) n.has(s.name) || r.add(s.name);
791
+ return [...r];
792
+ }
793
+ function Xt(e, t = []) {
794
+ const n = /* @__PURE__ */ new Set();
795
+ for (const r of [
796
+ ...e?.screenTemplates ?? [],
797
+ ...ee.screenTemplates ?? [],
798
+ ...t.flatMap((s) => s.screenTemplates ?? [])
799
+ ]) n.add(r.name);
800
+ return [...n];
801
+ }
802
+ function ke(e = []) {
803
+ const t = /* @__PURE__ */ new Set();
804
+ return [...ee.dialogTemplates ?? [], ...e.flatMap((n) => n.dialogTemplates ?? [])].filter((n) => !t.has(n.name) && !!t.add(n.name));
805
+ }
806
+ var Ie = /* @__PURE__ */ (function(e) {
807
+ return e.Dialog = "dialog", e.Drawer = "drawer", e;
808
+ })({});
809
+ function en(e, t = []) {
810
+ return [...e.dialogTemplates ?? [], ...t];
811
+ }
812
+ function We(e, t = [], n = !1, r) {
813
+ const s = Zt(e, t, n, r)[0];
814
+ if (s === U.Dialog) return Ie.Dialog;
815
+ if (s === U.Drawer) return Ie.Drawer;
816
+ }
817
+ function mr(e, t = [], n = [], r = !1) {
818
+ const s = e.screens.find((a) => a.name === E);
819
+ if (!s) return;
820
+ const o = en(e, t), i = We(s, [...e.screenTemplates.map((a) => a.name), ...n], r, Ve(e, t));
821
+ if (i === void 0) return;
822
+ const d = s.screenTemplate === void 0 ? void 0 : o.find((a) => a.name === s.screenTemplate);
823
+ return {
824
+ presentation: i,
825
+ ...d ? {
826
+ template: d.name,
827
+ title: d.displayName ?? d.name
828
+ } : {}
829
+ };
830
+ }
831
+ var tn = "dialog-actions-chrome";
832
+ function nn(e, t = [], n = !1, r) {
833
+ const s = e.screens.find((o) => o.name === E);
834
+ return s !== void 0 && We(s, [...e.screenTemplates.map((o) => o.name), ...t], n, Ve(e, r)) !== void 0;
835
+ }
836
+ function rn(e, t = []) {
837
+ const n = e.dialogTemplates ?? [], r = e.screens.find((s) => s.name === E)?.screenTemplate;
838
+ return (r === void 0 ? void 0 : [...n, ...t].find((s) => s.name === r)) ?? n.find((s) => s.name === "FormDialog") ?? n[0] ?? {
839
+ name: "FormDialog",
840
+ slots: []
841
+ };
842
+ }
843
+ function sn(e, t = [], n = [], r = !1, s) {
844
+ if (!nn(e, Xt(e, [{ screenTemplates: [...t] }]), r, s)) return !1;
845
+ const o = e.screens.find((a) => a.name === E), i = o?.screenTemplate ? [...e.screenTemplates, ...t].find((a) => a.name === o.screenTemplate) : void 0, d = o?.layout ? [...e.layouts, ...n].find((a) => a.name === o.layout) : void 0;
846
+ return ![...i?.outlets ?? [], ...d?.outlets ?? []].some((a) => a.name === xe);
847
+ }
848
+ function pr(e, t) {
849
+ if (t.length === 0) return e;
850
+ const n = e.screens.map((r) => {
851
+ if (r.name !== "Screen") return r;
852
+ const s = r.slotContent?.[H]?.[0];
853
+ return s ? {
854
+ ...r,
855
+ slotContent: {
856
+ ...r.slotContent,
857
+ [H]: [{
858
+ ...s,
859
+ children: [...s.children ?? [], ...t]
860
+ }, ...r.slotContent[H].slice(1)]
861
+ }
862
+ } : r;
863
+ });
864
+ return {
865
+ ...e,
866
+ screens: n
867
+ };
868
+ }
869
+ function fr() {
870
+ return Jt(tn, "Dialog actions", Me, {
871
+ name: xe,
872
+ kind: "actions",
873
+ items: []
874
+ });
875
+ }
876
+ function X(e, t) {
877
+ const n = e;
878
+ return {
879
+ ...typeof n.slice == "string" && n.slice !== "" ? { slice: n.slice } : typeof n.command == "string" && n.command !== "" ? { slice: n.command } : {},
880
+ ...n.opens ? { opens: n.opens } : {},
881
+ ...typeof n.opensIn == "string" && n.opensIn !== "" ? { opensIn: n.opensIn } : {},
882
+ subject: n.subject ?? t.outletSubject ?? ct.Screen,
883
+ ...typeof n.enabledWhen == "string" && n.enabledWhen !== "" ? { enabledWhen: n.enabledWhen } : {}
884
+ };
885
+ }
886
+ var on = (e) => {
887
+ switch (e) {
888
+ case O.Button:
889
+ case O.MenuEntry:
890
+ return [
891
+ c.slice,
892
+ c.opens,
893
+ c.enabled,
894
+ c.emphasis,
895
+ c.display
896
+ ];
897
+ case O.Filter:
898
+ return [c.sets, c.control];
899
+ case O.Tab:
900
+ return [c.shows];
901
+ case O.Stat:
902
+ return [c.valueFrom];
903
+ case O.Navigation:
904
+ return [
905
+ c.target,
906
+ c.slot,
907
+ "icon"
908
+ ];
909
+ default:
910
+ return [];
911
+ }
912
+ }, be = (e, t) => `${e}.${t}`, Ne = (e) => {
913
+ if (typeof e != "string") return;
914
+ const t = e.lastIndexOf(".");
915
+ return t > 0 && t < e.length - 1 ? {
916
+ first: e.slice(0, t),
917
+ second: e.slice(t + 1)
918
+ } : void 0;
919
+ }, _ = (e, t, n, r, s, o, i) => ({
920
+ descriptor: {
921
+ path: e,
922
+ label: t,
923
+ group: "Behavior",
924
+ valueType: n,
925
+ editorKind: r,
926
+ ...o ? { choices: [...o] } : {},
927
+ ...i ? { editorOptions: i } : {}
928
+ },
929
+ currentValue: s,
930
+ effectiveValue: s,
931
+ source: me.Local,
932
+ editable: !0
933
+ }), an = (e) => e.flatMap((t) => t.parameters.map((n) => ({
934
+ value: be(t.name, n.name),
935
+ label: `${t.name} › ${n.name}`
936
+ }))), ln = (e) => e.filter((t) => t.resultShape !== Fe.Collection).flatMap((t) => t.resultFields.map((n) => ({
937
+ value: be(t.name, n.name),
938
+ label: `${t.name} › ${n.name}`
939
+ })));
940
+ function dn(e, t, n) {
941
+ const r = t, s = n.strings, o = (i) => {
942
+ const d = i;
943
+ return d?.query ? be(d.query, d.parameter ?? d.field ?? "") : void 0;
944
+ };
945
+ switch (e) {
946
+ case c.sets:
947
+ return _("sets", s.sets, x.Enum, Q.Enum, o(r.sets), an(n.queries));
948
+ case c.control:
949
+ return _("control", s.control, x.Enum, Q.Enum, r.control ?? ae.Search, Object.values(ae).map((i) => ({
950
+ value: i,
951
+ label: s.controls[i] ?? i
952
+ })));
953
+ case c.shows:
954
+ return _("shows", s.shows, x.Enum, Q.Enum, r.shows, n.screens.map((i) => ({
955
+ value: i.id,
956
+ label: i.label
957
+ })));
958
+ case c.valueFrom:
959
+ return _("valueFrom", s.valueFrom, x.Enum, Q.Enum, o(r.valueFrom), ln(n.queries));
960
+ case c.target:
961
+ return _("target", s.target, x.String, "navigationItemTarget", r.target);
962
+ case c.slot:
963
+ return _("slot", s.slot, x.String, "renderingSlot", r.slot ?? "content");
964
+ case "icon":
965
+ return _("icon", s.icon, x.String, "icon", r.icon);
966
+ case c.opens:
967
+ return _("opens", n.placementStrings?.opens ?? s.opens, x.String, "hookOpens", {
968
+ value: nt(r.opens, r.opensIn),
969
+ hook: X(t, n)
970
+ });
971
+ case c.enabled:
972
+ return _("enabled", n.placementStrings?.enabled ?? "Enabled", x.String, "hookEnabled", {
973
+ subject: r.subject,
974
+ enabledWhen: r.enabledWhen,
975
+ hook: X(t, n),
976
+ ...n.outletSubject ? { outletSubject: n.outletSubject } : {}
977
+ });
978
+ case c.slice:
979
+ case c.emphasis:
980
+ case c.display: {
981
+ const i = n.actionProperties.find((d) => d.path === e);
982
+ return i ? {
983
+ descriptor: i,
984
+ currentValue: r[e],
985
+ effectiveValue: r[e] ?? i.default,
986
+ source: me.Local,
987
+ editable: !0
988
+ } : e === c.slice ? _("slice", "Slice", x.String, Q.Slice, r.slice) : void 0;
989
+ }
990
+ default:
991
+ return;
992
+ }
993
+ }
994
+ function cn(e, t) {
995
+ const n = t == null || t === "";
996
+ switch (e) {
997
+ case c.sets: {
998
+ const r = Ne(t);
999
+ return n ? { sets: void 0 } : r ? { sets: {
1000
+ query: r.first,
1001
+ parameter: r.second
1002
+ } } : void 0;
1003
+ }
1004
+ case c.valueFrom: {
1005
+ const r = Ne(t);
1006
+ return n ? { valueFrom: void 0 } : r ? { valueFrom: {
1007
+ query: r.first,
1008
+ field: r.second
1009
+ } } : void 0;
1010
+ }
1011
+ case c.control:
1012
+ return { control: n ? void 0 : t };
1013
+ case c.shows:
1014
+ return typeof t == "string" && t !== "" ? { shows: t } : void 0;
1015
+ case c.target:
1016
+ return { target: typeof t == "object" && t !== null && typeof t.module == "string" ? t : void 0 };
1017
+ case c.slot:
1018
+ return { slot: typeof t == "string" && t !== "content" && t !== "" ? t : void 0 };
1019
+ case c.opens:
1020
+ return it(t);
1021
+ case c.enabled:
1022
+ return at(t);
1023
+ case "icon":
1024
+ case c.slice:
1025
+ case c.emphasis:
1026
+ case c.display:
1027
+ return { [e]: n ? void 0 : t };
1028
+ default:
1029
+ return;
1030
+ }
1031
+ }
1032
+ function un(e, t) {
1033
+ const n = e, r = t.strings, s = {}, o = n.sets, i = n.valueFrom;
1034
+ switch (e.kind) {
1035
+ case O.Filter:
1036
+ s[c.sets] = o?.query ? `${o.query} › ${o.parameter ?? ""}` : r.chooseParameter, s[c.control] = r.controls[String(n.control ?? ae.Search)] ?? String(n.control);
1037
+ break;
1038
+ case O.Tab:
1039
+ s[c.shows] = typeof n.shows == "string" && n.shows !== "" ? t.screens.find((d) => d.id === n.shows)?.label ?? n.shows : r.chooseScreen;
1040
+ break;
1041
+ case O.Stat:
1042
+ s[c.valueFrom] = i?.query ? `${i.query} › ${i.field ?? ""}` : r.chooseField;
1043
+ break;
1044
+ case O.Navigation: {
1045
+ const d = n.target;
1046
+ s[c.target] = (t.structure ? He(t.structure, d) : d?.module) ?? "";
1047
+ break;
1048
+ }
1049
+ case O.Button:
1050
+ case O.MenuEntry:
1051
+ s[c.opens] = t.placement ? st(X(e, t), t.placement, t.placementStrings) : r.opensChoices[String(n.opens ?? "automatic")] ?? r.automatic, s[c.enabled] = ot(X(e, t), t.outletSubject, t.placementStrings);
1052
+ }
1053
+ return s;
1054
+ }
1055
+ function mn(e) {
1056
+ const t = e;
1057
+ switch (e.kind) {
1058
+ case O.Button:
1059
+ case O.MenuEntry:
1060
+ return !t.slice && !t.command && !t.navigateTo && !t.builtIn;
1061
+ case O.Filter:
1062
+ return !t.sets;
1063
+ case O.Tab:
1064
+ return !t.shows;
1065
+ case O.Stat:
1066
+ return !t.valueFrom;
1067
+ case O.Navigation:
1068
+ return !t.target && !(Array.isArray(t.children) && t.children.length > 0);
1069
+ default:
1070
+ return !1;
1071
+ }
1072
+ }
1073
+ var z = (e) => {
1074
+ const t = e;
1075
+ if (Array.isArray(t.children)) return {
1076
+ key: "children",
1077
+ items: t.children
1078
+ };
1079
+ if (Array.isArray(t.items)) return {
1080
+ key: "items",
1081
+ items: t.items
1082
+ };
1083
+ }, pn = (e) => Object.fromEntries(Object.entries(e).filter(([, t]) => t !== void 0));
1084
+ function te(e, t, n) {
1085
+ return e.flatMap((r) => {
1086
+ if (r.id === t) {
1087
+ const o = n(r);
1088
+ return o ? [o] : [];
1089
+ }
1090
+ const s = z(r);
1091
+ return [s ? {
1092
+ ...r,
1093
+ [s.key]: te(s.items, t, n)
1094
+ } : r];
1095
+ });
1096
+ }
1097
+ function ye(e, t) {
1098
+ for (const n of e) {
1099
+ if (n.id === t) return n;
1100
+ const r = z(n), s = r ? ye(r.items, t) : void 0;
1101
+ if (s) return s;
1102
+ }
1103
+ }
1104
+ function de(e, t) {
1105
+ if (e.some((n) => n.id === t)) return e;
1106
+ for (const n of e) {
1107
+ const r = z(n), s = r ? de(r.items, t) : void 0;
1108
+ if (s) return s;
1109
+ }
1110
+ }
1111
+ var Ae = (e, t, n) => te(e, t, (r) => pn({
1112
+ ...r,
1113
+ ...n
1114
+ })), fn = (e, t) => te(e, t, () => {
1115
+ });
1116
+ function hn(e, t, n) {
1117
+ const r = (s) => {
1118
+ const o = s.findIndex((a) => a.id === t);
1119
+ if (o < 0) return s.map((a) => {
1120
+ const f = z(a);
1121
+ return f ? {
1122
+ ...a,
1123
+ [f.key]: r(f.items)
1124
+ } : a;
1125
+ });
1126
+ const i = [...s], [d] = i.splice(o, 1);
1127
+ return i.splice(Math.max(0, Math.min(n, i.length)), 0, d), i;
1128
+ };
1129
+ return r(e);
1130
+ }
1131
+ function gn(e, t, n) {
1132
+ const r = ye(e, t);
1133
+ if (!r) return { items: [...e] };
1134
+ const s = (d) => {
1135
+ const a = z(d), f = {
1136
+ ...d,
1137
+ id: n()
1138
+ };
1139
+ return a ? {
1140
+ ...f,
1141
+ [a.key]: a.items.map(s)
1142
+ } : f;
1143
+ }, o = s(r), i = (d) => d.flatMap((a) => {
1144
+ if (a.id === t) return [a, o];
1145
+ const f = z(a);
1146
+ return [f ? {
1147
+ ...a,
1148
+ [f.key]: i(f.items)
1149
+ } : a];
1150
+ });
1151
+ return {
1152
+ items: i(e),
1153
+ copy: o
1154
+ };
1155
+ }
1156
+ var vn = (e, t, n) => te(e, t, (r) => ({
1157
+ ...r,
1158
+ children: [...r.children ?? [], n]
1159
+ })), Ce = (e, t) => [...e, ...(t ?? []).filter((n) => !e.some((r) => r.name === n.name))];
1160
+ function bn({ document: e, screen: t, path: n, templates: r, layouts: s, dialogTemplate: o }) {
1161
+ const i = he(e), d = i.find((p) => p.kind === $.Screen && p.name === t), a = e.screens.map((p) => p.name === t && !p.path && n && n.length > 0 ? {
1162
+ ...p,
1163
+ path: [...n]
1164
+ } : p), { chain: f, contributors: y } = It({
1165
+ layouts: Ce(e.layouts, s),
1166
+ screenTemplates: Ce(e.screenTemplates, r),
1167
+ screens: a,
1168
+ navigation: fe(e),
1169
+ levels: i.filter((p) => p.kind !== $.Screen)
1170
+ }, t), h = o ? yn(f, o) : f;
1171
+ if (h.length === 0 || !d?.refinements) return {
1172
+ chain: h,
1173
+ contributors: y
1174
+ };
1175
+ const g = h[h.length - 1];
1176
+ return {
1177
+ chain: [...h.slice(0, -1), {
1178
+ ...g,
1179
+ refinements: [...g.refinements ?? [], ...d.refinements]
1180
+ }],
1181
+ contributors: y
1182
+ };
1183
+ }
1184
+ function yn(e, t) {
1185
+ const n = new Set(e.flatMap((i) => (i.outlets ?? []).map((d) => d.name))), r = yt(t).filter((i) => !n.has(i.name));
1186
+ if (r.length === 0) return [...e];
1187
+ const s = e.findIndex((i) => i.kind === $.Module || i.kind === $.Feature || i.kind === $.Slice || i.kind === $.Screen), o = s < 0 ? e.length : s;
1188
+ return [
1189
+ ...e.slice(0, o),
1190
+ {
1191
+ kind: $.Template,
1192
+ name: t.name,
1193
+ outlets: r
1194
+ },
1195
+ ...e.slice(o)
1196
+ ];
1197
+ }
1198
+ var On = (e) => e.filter((t) => t.kind === $.Module || t.kind === $.Feature || t.kind === $.Slice || t.kind === $.Screen).map((t) => ({
1199
+ kind: t.kind,
1200
+ name: t.name
1201
+ }));
1202
+ function Sn(e, t) {
1203
+ if (!t) return e;
1204
+ const n = wn(e.chain, (s) => Be(s, t));
1205
+ if (n < 0 || n === e.chain.length - 1) return e;
1206
+ const r = e.chain.slice(n + 1).filter((s) => (s.contributions ?? []).length > 0).map((s) => ({
1207
+ kind: s.kind,
1208
+ name: s.name,
1209
+ contributions: s.contributions
1210
+ }));
1211
+ return {
1212
+ chain: e.chain.slice(0, n + 1),
1213
+ contributors: [...e.contributors, ...r]
1214
+ };
1215
+ }
1216
+ function wn(e, t) {
1217
+ for (let n = e.length - 1; n >= 0; n--) if (t(e[n])) return n;
1218
+ return -1;
1219
+ }
1220
+ var Tn = (e) => e.flatMap((t) => (t.outlets ?? []).map((n) => ({
1221
+ outlet: n,
1222
+ level: t
1223
+ }))), kn = (e) => e === D.Overrides ? "override" : e === D.Extends ? "extend" : "inherit", In = {
1224
+ inherit: D.Inherits,
1225
+ extend: D.Extends,
1226
+ override: D.Overrides
1227
+ }, je = (e) => {
1228
+ const t = e.title;
1229
+ return typeof t == "string" ? t : "";
1230
+ }, Nn = (e) => {
1231
+ const t = e.children;
1232
+ return Array.isArray(t) ? t : [];
1233
+ };
1234
+ function An(e, t) {
1235
+ return e.chain.some((n) => (n.outlets ?? []).some((r) => r.name === t));
1236
+ }
1237
+ function Cn(e) {
1238
+ const { document: t, outlet: n, level: r, newId: s, binding: o, strings: i } = e, d = Sn(e.outlets, r);
1239
+ if (!An(d, n)) return;
1240
+ const a = St(d.chain, n, d.contributors), f = a.subject ? {
1241
+ ...o,
1242
+ outletSubject: a.subject
1243
+ } : o;
1244
+ if (a.diagnostics.some((l) => l.code === ft.UnknownOutlet) || !a.kind) return;
1245
+ const y = a.kind, h = Mt(t, r, n), g = h?.items ?? [], p = h?.hide ?? [], k = kn(a.mode), L = (l) => a.diagnostics.filter((m) => m.item === l).map((m) => ({
1246
+ code: m.code,
1247
+ message: m.message
1248
+ })), j = [], w = g.map((l) => l.id), A = (l, m, b, N) => {
1249
+ const B = b ? de(g, l.id) ?? [] : [], P = L(l.id);
1250
+ j.push({
1251
+ id: l.id,
1252
+ label: je(l),
1253
+ index: b ? B.findIndex((re) => re.id === l.id) : -1,
1254
+ count: b ? B.length : 0,
1255
+ ...N ? { parentId: N } : {},
1256
+ readOnly: !b,
1257
+ ...b ? {} : {
1258
+ readOnlyReason: Y,
1259
+ origin: m.owner
1260
+ },
1261
+ values: {
1262
+ ...l,
1263
+ provenance: m
1264
+ },
1265
+ chips: un(l, f),
1266
+ ...P.length > 0 ? { problems: P } : {},
1267
+ unlinked: mn(l),
1268
+ provenance: m
1269
+ }), Nn(l).forEach((re) => A(re, m, b, l.id));
1270
+ };
1271
+ a.items.forEach((l) => {
1272
+ const m = l.provenance.source === Te.Own && l.editable && w.includes(l.item.id);
1273
+ A(l.item, {
1274
+ owner: l.provenance.owner,
1275
+ level: l.provenance.level,
1276
+ source: l.provenance.source
1277
+ }, m);
1278
+ });
1279
+ const T = a.removed.map((l) => ({
1280
+ id: l.item.id,
1281
+ label: je(l.item),
1282
+ index: -1,
1283
+ count: 0,
1284
+ readOnly: !0,
1285
+ readOnlyReason: Y,
1286
+ origin: l.provenance.owner,
1287
+ values: { ...l.item },
1288
+ unlinked: !1,
1289
+ provenance: {
1290
+ owner: l.provenance.owner,
1291
+ level: l.provenance.level,
1292
+ source: l.provenance.source
1293
+ },
1294
+ removal: l.removal === ht.Hidden ? "hidden" : "overridden"
1295
+ })), v = (l) => {
1296
+ const m = {
1297
+ ...h ?? { outlet: n },
1298
+ ...l,
1299
+ outlet: n
1300
+ };
1301
+ return (!m.items || m.items.length === 0) && delete m.items, (!m.hide || m.hide.length === 0) && delete m.hide, m.mode === void 0 && delete m.mode, m.items || m.hide || m.mode !== void 0 ? m : void 0;
1302
+ }, S = (l, m, b, N = {}) => ({
1303
+ label: l,
1304
+ edits: [],
1305
+ documentChange: (B) => Rt(B, r, n, m),
1306
+ ...b ? { select: b } : {},
1307
+ ...N
1308
+ }), u = () => k === "inherit" ? { mode: D.Extends } : {}, C = (l, m, b, N = {}) => {
1309
+ const B = k === "inherit" && m.length > g.length;
1310
+ return S(l, v({
1311
+ items: m,
1312
+ ...u()
1313
+ }), { itemId: b }, {
1314
+ ...N,
1315
+ ...B ? { notice: i.extendsNotice } : {}
1316
+ });
1317
+ }, K = () => {
1318
+ const l = s(), m = le[y].item, b = i.newItem[m] ?? i.newItem.button;
1319
+ switch (m) {
1320
+ case O.Tab: {
1321
+ const N = o.screens[0];
1322
+ return N ? {
1323
+ kind: O.Tab,
1324
+ id: l,
1325
+ title: b,
1326
+ shows: N.id
1327
+ } : { rejected: "noScreenForTab" };
1328
+ }
1329
+ case O.Filter:
1330
+ return {
1331
+ kind: O.Filter,
1332
+ id: l,
1333
+ title: b
1334
+ };
1335
+ case O.Stat:
1336
+ return {
1337
+ kind: O.Stat,
1338
+ id: l,
1339
+ title: b
1340
+ };
1341
+ case O.Navigation:
1342
+ return {
1343
+ kind: O.Navigation,
1344
+ id: l,
1345
+ title: b
1346
+ };
1347
+ default:
1348
+ return {
1349
+ kind: O.Button,
1350
+ id: l,
1351
+ title: b
1352
+ };
1353
+ }
1354
+ }, ne = (l) => "rejected" in l, V = (l) => l.readOnly ? void 0 : ye(g, l.id), W = Bt(y), Oe = (l) => l.readOnly ? p.includes(l.id) ? { rejected: "alreadyHidden" } : S("Hide", v({
1355
+ hide: [...p, l.id],
1356
+ ...u()
1357
+ }), { itemId: null }) : { rejected: "ownItem" }, Se = (l) => {
1358
+ if (p.includes(l.id)) return S("Bring back", v({ hide: p.filter((m) => m !== l.id) }), { itemId: l.id });
1359
+ if (l.removal === "overridden") {
1360
+ const m = a.removed.find((b) => b.item.id === l.id)?.item;
1361
+ return m ? S("Bring back", v({ items: [...g, structuredClone(m)] }), { itemId: l.id }) : { rejected: "notRemoved" };
1362
+ }
1363
+ return { rejected: "notRemoved" };
1364
+ }, Ge = (l, m = !1) => {
1365
+ if (l === k) return { rejected: "sameMode" };
1366
+ if (l === "inherit") return S("Inherit", void 0, { itemId: null });
1367
+ if (l === "extend") return S("Extend", v({ mode: D.Extends }));
1368
+ const b = m ? a.items.filter((N) => N.provenance.source !== Te.Contribution && !w.includes(N.item.id)).map((N) => structuredClone(N.item)) : [];
1369
+ return S("Override", v({
1370
+ mode: In.override,
1371
+ items: [...b, ...g],
1372
+ hide: []
1373
+ }));
1374
+ }, Xe = (l) => l.removal ? [{
1375
+ id: "bringBack",
1376
+ label: i.bringBack,
1377
+ plan: () => Se(l)
1378
+ }] : l.parentId !== void 0 ? [] : [{
1379
+ id: "hide",
1380
+ label: i.hide,
1381
+ plan: () => Oe(l)
1382
+ }];
1383
+ return {
1384
+ kind: _e.Outlet,
1385
+ items: j,
1386
+ removed: T,
1387
+ name: n,
1388
+ ...a.subject ? { subject: a.subject } : {},
1389
+ ...a.slot ? { slot: a.slot } : {},
1390
+ ...a.declaredBy ? { declaredBy: a.declaredBy } : {},
1391
+ outletKind: y,
1392
+ level: r,
1393
+ mode: k,
1394
+ effective: a,
1395
+ designMode: W,
1396
+ regionTag: {
1397
+ text: a.summary,
1398
+ long: i.tagLong(n, a.summary),
1399
+ kind: k
1400
+ },
1401
+ addItem: (l) => C("Add", [...g, l], l.id),
1402
+ add: (l) => {
1403
+ if (l !== le[y].id) return { rejected: l };
1404
+ const m = K();
1405
+ return ne(m) ? m : C("Add", [...g, m], m.id, { renameNext: !0 });
1406
+ },
1407
+ act: (l, m) => {
1408
+ if (!V(m)) return { rejected: m.readOnlyReason ?? Y };
1409
+ switch (l) {
1410
+ case c.moveEarlier:
1411
+ case c.moveLater: {
1412
+ const b = m.index + (l === c.moveEarlier ? -1 : 1);
1413
+ return b < 0 || b >= m.count ? { rejected: "noWhere" } : C("Move", hn(g, m.id, b), m.id);
1414
+ }
1415
+ case c.duplicate: {
1416
+ const b = gn(g, m.id, s);
1417
+ return b.copy ? C("Duplicate", b.items, b.copy.id) : { rejected: l };
1418
+ }
1419
+ case c.delete: {
1420
+ const b = de(g, m.id) ?? [], N = b.findIndex((P) => P.id === m.id), B = b[N + 1] ?? b[N - 1];
1421
+ return C("Remove", fn(g, m.id), B?.id ?? null);
1422
+ }
1423
+ case c.addSubItem: {
1424
+ if (y !== F.Navigation || m.parentId !== void 0) return { rejected: "subItemOfSubItem" };
1425
+ const b = {
1426
+ kind: O.Navigation,
1427
+ id: s(),
1428
+ title: i.newItem.navigation
1429
+ };
1430
+ return C("Add", vn(g, m.id, b), b.id, { renameNext: !0 });
1431
+ }
1432
+ default:
1433
+ return { rejected: l };
1434
+ }
1435
+ },
1436
+ rename: (l, m) => V(l) ? C("Rename", Ae(g, l.id, { title: m }), l.id) : { rejected: l.readOnlyReason ?? Y },
1437
+ choice: (l, m) => {
1438
+ const b = V(m);
1439
+ if (!b || !on(b.kind).includes(l)) return;
1440
+ const N = dn(l, b, f);
1441
+ if (N)
1442
+ return {
1443
+ property: N,
1444
+ plan: (B) => {
1445
+ const P = cn(l, B);
1446
+ return P ? C("Bind", Ae(g, m.id, P), m.id) : { rejected: l };
1447
+ }
1448
+ };
1449
+ },
1450
+ readOnlyActions: Xe,
1451
+ setMode: Ge,
1452
+ hide: Oe,
1453
+ bringBack: Se
1454
+ };
1455
+ }
1456
+ function jn(e, t) {
1457
+ const n = /* @__PURE__ */ new Set(), r = (o) => {
1458
+ if (Array.isArray(o)) {
1459
+ o.forEach(r);
1460
+ return;
1461
+ }
1462
+ if (typeof o != "object" || o === null) return;
1463
+ const i = o;
1464
+ typeof i.queryId == "string" && n.add(i.queryId), typeof i.queryId == "string" && typeof i.query == "string" && n.add(i.query), Object.values(i).forEach(r);
1465
+ };
1466
+ r(e.screens.find((o) => o.name === E));
1467
+ const s = t.filter((o) => n.has(o.id) || n.has(o.name));
1468
+ return s.length > 0 ? s : [...t];
1469
+ }
1470
+ function $n(e) {
1471
+ return Tt(e, Me)?.properties.find((t) => t.path === "items")?.item?.properties ?? [];
1472
+ }
1473
+ function Fn(e) {
1474
+ const { document: t, catalog: n, strings: r } = e, s = bn({
1475
+ document: t,
1476
+ screen: E,
1477
+ ...e.path ? { path: e.path } : {},
1478
+ ...e.templates ? { templates: e.templates } : {},
1479
+ ...e.layouts ? { layouts: e.layouts } : {},
1480
+ ...e.dialogTemplate ? { dialogTemplate: e.dialogTemplate } : {}
1481
+ }), o = On(s.chain), i = o.find((h) => h.kind === $.Screen), d = o.find((h) => Be(h, e.requestedLevel)) ?? i, a = {
1482
+ queries: jn(t, e.queries),
1483
+ screens: e.screens,
1484
+ actionProperties: $n(n),
1485
+ ...e.slices ? { placement: Pt({
1486
+ document: t,
1487
+ screen: E,
1488
+ slices: e.slices,
1489
+ queries: e.queries,
1490
+ ...e.templates ? { templates: e.templates } : {},
1491
+ ...e.layouts ? { layouts: e.layouts } : {}
1492
+ }) } : {},
1493
+ ...e.structure ? { structure: e.structure } : {},
1494
+ strings: r.bindings
1495
+ }, f = Tn(s.chain).map(({ outlet: h, level: g }) => ({
1496
+ name: h.name,
1497
+ kind: h.kind,
1498
+ owner: g.name,
1499
+ shell: g.kind === $.Layout && g.name === vt
1500
+ })), y = e.newId ?? qe;
1501
+ return {
1502
+ outlets: s,
1503
+ levels: o,
1504
+ level: d,
1505
+ declared: f,
1506
+ binding: a,
1507
+ design: (h) => d ? Cn({
1508
+ document: t,
1509
+ outlets: s,
1510
+ outlet: h,
1511
+ level: d,
1512
+ newId: y,
1513
+ binding: a,
1514
+ strings: r
1515
+ }) : void 0
1516
+ };
1517
+ }
1518
+ function En(e, t, n) {
1519
+ const { document: r, context: s, outletLevel: o, structure: i } = e, d = t.location?.path, a = R(() => [...t.ownTemplates ?? [], ...t.runtime.bundles.flatMap((p) => p.screenTemplates ?? [])], [t.ownTemplates, t.runtime.bundles]), f = R(() => t.runtime.bundles.flatMap((p) => p.layouts ?? []), [t.runtime.bundles]), y = R(() => t.destinations.map((p) => ({
1520
+ id: p.id,
1521
+ label: p.label
1522
+ })), [t.destinations]), h = s.scope.kind === ie.Screen, g = R(() => h && sn(r, a, f, e.opensOverPage, ke(t.runtime.bundles)) ? rn(r, ke(t.runtime.bundles)) : void 0, [
1523
+ r,
1524
+ h,
1525
+ a,
1526
+ f,
1527
+ t.runtime.bundles,
1528
+ e.opensOverPage
1529
+ ]);
1530
+ return R(() => Fn({
1531
+ document: r,
1532
+ catalog: s.catalog,
1533
+ templates: a,
1534
+ layouts: f,
1535
+ ...g ? { dialogTemplate: g } : {},
1536
+ queries: t.queryCandidates,
1537
+ slices: t.stateChangeSlices,
1538
+ screens: y,
1539
+ strings: n,
1540
+ ...d ? { path: d } : {},
1541
+ ...o ? { requestedLevel: o } : {},
1542
+ ...i.modules.length > 0 ? { structure: i } : {}
1543
+ }), [
1544
+ r,
1545
+ s.catalog,
1546
+ a,
1547
+ f,
1548
+ t.queryCandidates,
1549
+ t.stateChangeSlices,
1550
+ y,
1551
+ n,
1552
+ d,
1553
+ o,
1554
+ i,
1555
+ g
1556
+ ]);
1557
+ }
1558
+ function hr(e) {
1559
+ return {
1560
+ queryId: e.id,
1561
+ query: e.name,
1562
+ arguments: [],
1563
+ results: []
1564
+ };
1565
+ }
1566
+ function xn(e) {
1567
+ const t = e;
1568
+ return !!t && typeof t == "object" && typeof t.queryId == "string" && Array.isArray(t.arguments) && Array.isArray(t.results);
1569
+ }
1570
+ function Mn(e, t, n) {
1571
+ const r = e.arguments.filter((s) => s.parameter !== t);
1572
+ return {
1573
+ ...e,
1574
+ arguments: n.trim() === "" ? r : [...r, {
1575
+ parameter: t,
1576
+ source: { path: n.trim() }
1577
+ }]
1578
+ };
1579
+ }
1580
+ function gr(e, t, n = t) {
1581
+ return e.results.some((r) => r.field === t) ? e : {
1582
+ ...e,
1583
+ results: [...e.results, {
1584
+ target: n,
1585
+ field: t
1586
+ }]
1587
+ };
1588
+ }
1589
+ function vr(e, t, n, r = t) {
1590
+ const s = e.results.findIndex((f) => f.field === t), o = e.results.filter((f) => f.field !== t), i = s >= 0 ? e.results[s] : {
1591
+ target: r,
1592
+ field: t
1593
+ }, d = n === void 0 ? s >= 0 ? s : o.length : s >= 0 && s < n ? n - 1 : n, a = Math.max(0, Math.min(o.length, d));
1594
+ return {
1595
+ ...e,
1596
+ results: [
1597
+ ...o.slice(0, a),
1598
+ i,
1599
+ ...o.slice(a)
1600
+ ]
1601
+ };
1602
+ }
1603
+ function br(e, t) {
1604
+ return {
1605
+ ...e,
1606
+ results: e.results.filter((n) => n.field !== t)
1607
+ };
1608
+ }
1609
+ var Rn = (e, t) => e.arguments.find((n) => n.parameter === t.name)?.source.path ?? "", yr = (e, t) => e.results.some((n) => n.field === t.name), ce = (e) => {
1610
+ const t = e.values.sets;
1611
+ return t !== null && typeof t == "object" && typeof t.query == "string" && typeof t.parameter == "string" ? t : void 0;
1612
+ };
1613
+ function Dn(e, t, n, r) {
1614
+ return t.filter((s) => s.values.kind === O.Filter && ce(s)?.query === n && ce(s)?.parameter === r).map((s) => ({
1615
+ outlet: e,
1616
+ id: s.id,
1617
+ title: s.label
1618
+ }));
1619
+ }
1620
+ var Or = (e, t) => e.filter((n) => n.values.kind === O.Filter && ce(n)?.query === t);
1621
+ function Ln(e, t, n) {
1622
+ return {
1623
+ kind: O.Filter,
1624
+ id: n,
1625
+ title: t.charAt(0).toUpperCase() + t.slice(1),
1626
+ sets: {
1627
+ query: e,
1628
+ parameter: t
1629
+ }
1630
+ };
1631
+ }
1632
+ var Bn = (e, t, n) => {
1633
+ const r = e.arguments.find((s) => s.parameter === t)?.source.path;
1634
+ return n.find((s) => s.path === r);
1635
+ }, _n = (e, t, n) => Mn(e, t, n?.path ?? ""), Ue = /^show\s+(\S+)\s+by\s+(\S+)\s+from\s+(\S+?)\.selection\s*$/, qn = (e) => `show ${e.screen} by ${e.by} from ${e.element}.selection`;
1636
+ function Pn(e) {
1637
+ const t = [...e].filter((n) => /[A-Za-z0-9_]/.test(n)).join("");
1638
+ return t.length === 0 ? "Unnamed" : /^[0-9]/.test(t) ? `_${t}` : t;
1639
+ }
1640
+ var ze = (e) => e.screens.find((t) => t.name === E);
1641
+ function Hn(e) {
1642
+ const t = ze(e)?.native?.slots ?? {};
1643
+ return Object.entries(t).flatMap(([n, r]) => r.flatMap((s) => {
1644
+ const o = Ue.exec(s.text.trim());
1645
+ return o ? [{
1646
+ slot: n,
1647
+ screen: o[1],
1648
+ by: o[2],
1649
+ element: o[3]
1650
+ }] : [];
1651
+ }));
1652
+ }
1653
+ function $e(e, t, n) {
1654
+ const r = ze(e);
1655
+ if (!r) return e;
1656
+ const s = r.native ?? {}, o = (s.slots?.[t] ?? []).filter((k) => !Ue.test(k.text.trim())), i = n ? [...o, {
1657
+ at: (r.slotContent[t] ?? []).length,
1658
+ text: qn(n)
1659
+ }] : o, d = {
1660
+ ...s.slots ?? {},
1661
+ [t]: i
1662
+ };
1663
+ i.length === 0 && delete d[t];
1664
+ const { slots: a, ...f } = s, y = {
1665
+ ...f,
1666
+ ...Object.keys(d).length > 0 ? { slots: d } : {}
1667
+ }, { native: h, ...g } = r, p = Object.keys(y).length > 0 ? {
1668
+ ...g,
1669
+ native: y
1670
+ } : g;
1671
+ return {
1672
+ ...e,
1673
+ screens: e.screens.map((k) => k === r ? p : k)
1674
+ };
1675
+ }
1676
+ function Ke(e, t, n) {
1677
+ const r = e.screens.find((s) => s.name === E);
1678
+ return (r?.screenTemplate ? t.find((s) => s.name === r.screenTemplate)?.slots : n.find((s) => s.name === r?.layout)?.slots) ?? [];
1679
+ }
1680
+ var Vn = (e, t, n) => Ke(e, t, n).some((r) => r.routed === !0);
1681
+ function Qe(e, t, n) {
1682
+ return Ke(e, t, n).filter((r) => r.routed === !0 && (r.routedBy ?? []).length > 0).map((r) => ({
1683
+ name: r.name,
1684
+ routedBy: r.routedBy ?? []
1685
+ }));
1686
+ }
1687
+ var Wn = [
1688
+ "dataTable",
1689
+ "table",
1690
+ "observableDataTable"
1691
+ ], Ye = "query", Un = (e) => e.slice(e.lastIndexOf(":") + 1);
1692
+ function ue(e) {
1693
+ if (!kt(e)) return;
1694
+ const t = e, n = t.properties?.[Ye];
1695
+ return Wn.includes(Un(t.componentName)) && xn(n) ? {
1696
+ elementId: t.id,
1697
+ binding: n
1698
+ } : void 0;
1699
+ }
1700
+ function zn(e) {
1701
+ return e.flatMap((t) => [...ue(t) ? [ue(t)] : [], ...zn(tt(t))]);
1702
+ }
1703
+ var Sr = (e, t) => ({
1704
+ kind: ut.SetProperty,
1705
+ nodeId: wt(e),
1706
+ path: Ye,
1707
+ value: t
1708
+ }), Je = (e, t) => [
1709
+ ...t.screenTemplates,
1710
+ ...e.ownTemplates ?? [],
1711
+ ...e.runtime.bundles.flatMap((n) => n.screenTemplates ?? [])
1712
+ ], Ze = (e, t) => [...t.layouts, ...e.runtime.bundles.flatMap((n) => n.layouts ?? [])], wr = ({ controller: e, environment: t, strings: n, binding: r, candidate: s, disabled: o, onChange: i }) => {
1713
+ const d = n.properties.dataBinding, a = n.designMode ?? qt, f = En(e, t, a.outlets), y = R(() => Je(t, e.document), [t, e.document]), h = R(() => Ze(t, e.document), [t, e.document]), g = R(() => Qe(e.document, y, h), [
1714
+ e.document,
1715
+ y,
1716
+ h
1717
+ ]), p = g.flatMap((w) => w.routedBy.map((A) => ({
1718
+ slot: w.name,
1719
+ parameter: A,
1720
+ path: `route.${A}`
1721
+ }))), k = f.declared.filter((w) => w.kind === F.Filters && !w.shell);
1722
+ if (s.parameters.length === 0) return null;
1723
+ const L = k.flatMap((w) => (f.design(w.name)?.items ?? []).map((A) => ({
1724
+ outlet: w.name,
1725
+ item: {
1726
+ id: A.id,
1727
+ label: A.label,
1728
+ values: A.values
1729
+ }
1730
+ }))), j = (w) => {
1731
+ const A = k[0] && f.design(k[0].name);
1732
+ if (!A) return;
1733
+ const T = A.addItem(Ln(s.name, w, qe()));
1734
+ !Dt(T) && T.documentChange && e.changeDocument(T.documentChange, T.label);
1735
+ };
1736
+ return /* @__PURE__ */ q("div", {
1737
+ className: "studio-editor-query__group",
1738
+ "data-parameter-feeds": s.name,
1739
+ children: [
1740
+ /* @__PURE__ */ I("strong", { children: d.feedsTitle }),
1741
+ /* @__PURE__ */ I("ul", {
1742
+ className: "studio-editor-query__feeds",
1743
+ children: s.parameters.map((w) => {
1744
+ const A = L.flatMap((u) => Dn(u.outlet, [u.item], s.name, w.name)), T = g.filter((u) => u.routedBy.includes(w.name)), v = Rn(r, w), S = A.length > 0 || T.length > 0 || v !== "";
1745
+ return /* @__PURE__ */ q("li", {
1746
+ "data-fed": S,
1747
+ children: [
1748
+ /* @__PURE__ */ I("span", { children: w.name }),
1749
+ A.map((u) => /* @__PURE__ */ I("span", {
1750
+ className: "studio-editor-properties__chip",
1751
+ "data-feed": "filter",
1752
+ children: d.fedByFilter(u.title)
1753
+ }, u.id)),
1754
+ T.map((u) => /* @__PURE__ */ I("span", {
1755
+ className: "studio-editor-properties__chip",
1756
+ "data-feed": "route",
1757
+ children: d.fedByRoute(w.name, u.name)
1758
+ }, u.name)),
1759
+ v !== "" && /* @__PURE__ */ I("span", {
1760
+ className: "studio-editor-properties__chip",
1761
+ "data-feed": "mapping",
1762
+ children: d.fedByMapping(v)
1763
+ }),
1764
+ !S && /* @__PURE__ */ I("span", {
1765
+ className: "studio-editor-properties__chip",
1766
+ "data-feed": "none",
1767
+ children: d.fedByNothing
1768
+ }),
1769
+ !S && k.length > 0 && /* @__PURE__ */ I("button", {
1770
+ type: "button",
1771
+ onClick: () => j(w.name),
1772
+ children: d.addFilter
1773
+ }),
1774
+ i && p.length > 0 && /* @__PURE__ */ q("select", {
1775
+ "aria-label": d.routeSource(w.name),
1776
+ "data-route-source": w.name,
1777
+ disabled: o,
1778
+ value: Bn(r, w.name, p)?.path ?? "",
1779
+ onChange: (u) => i(_n(r, w.name, p.find((C) => C.path === u.target.value)), w, u.target.value),
1780
+ children: [/* @__PURE__ */ I("option", {
1781
+ value: "",
1782
+ children: d.routeSourceNone
1783
+ }), p.map((u) => /* @__PURE__ */ I("option", {
1784
+ value: u.path,
1785
+ children: d.routeSourceOption(u.parameter, u.slot)
1786
+ }, `${u.slot}.${u.parameter}`))]
1787
+ })
1788
+ ]
1789
+ }, w.name);
1790
+ })
1791
+ }),
1792
+ L.length > 0 && Vn(e.document, y, h) && /* @__PURE__ */ I("p", {
1793
+ className: "studio-editor-properties__hint",
1794
+ children: d.filtersInAddress
1795
+ })
1796
+ ]
1797
+ });
1798
+ }, Tr = ({ controller: e, environment: t, strings: n, elementId: r, disabled: s }) => {
1799
+ const o = n.properties.dataBinding, i = R(() => Je(t, e.document), [t, e.document]), d = R(() => Ze(t, e.document), [t, e.document]), a = R(() => Qe(e.document, i, d), [
1800
+ e.document,
1801
+ i,
1802
+ d
1803
+ ]), f = et(e.composition.roots, r);
1804
+ if (!(f && ue(f))) return null;
1805
+ const y = Pn(r), h = Hn(e.document).filter((p) => p.element === y)[0], g = (p, k, L) => e.changeDocument((j) => {
1806
+ const w = h && h.slot !== p ? $e(j, h.slot, void 0) : j;
1807
+ return $e(w, p, k === "" ? void 0 : {
1808
+ screen: k,
1809
+ by: L,
1810
+ element: y
1811
+ });
1812
+ }, o.selectionTitle);
1813
+ return /* @__PURE__ */ q("fieldset", {
1814
+ className: "studio-editor-query",
1815
+ disabled: s,
1816
+ "data-selection-detail": r,
1817
+ children: [
1818
+ /* @__PURE__ */ I("legend", { children: o.selectionTitle }),
1819
+ a.length === 0 && /* @__PURE__ */ I("p", {
1820
+ className: "studio-editor-properties__hint",
1821
+ children: o.selectionNoSlot
1822
+ }),
1823
+ a.length > 0 && /* @__PURE__ */ q(lt, { children: [
1824
+ /* @__PURE__ */ I("p", {
1825
+ className: "studio-editor-properties__hint",
1826
+ children: o.selectionHint
1827
+ }),
1828
+ /* @__PURE__ */ q("label", { children: [/* @__PURE__ */ I("span", { children: o.selectionSlot }), /* @__PURE__ */ I("select", {
1829
+ value: h?.slot ?? a[0].name,
1830
+ onChange: (p) => h && g(p.target.value, h.screen, a.find((k) => k.name === p.target.value)?.routedBy[0] ?? h.by),
1831
+ children: a.map((p) => /* @__PURE__ */ q("option", {
1832
+ value: p.name,
1833
+ children: [
1834
+ p.name,
1835
+ " (",
1836
+ p.routedBy.join(", "),
1837
+ ")"
1838
+ ]
1839
+ }, p.name))
1840
+ })] }),
1841
+ /* @__PURE__ */ q("label", { children: [/* @__PURE__ */ I("span", { children: o.selectionScreen }), /* @__PURE__ */ q("select", {
1842
+ value: h?.screen ?? "",
1843
+ onChange: (p) => {
1844
+ const k = a.find((L) => L.name === (h?.slot ?? a[0].name)) ?? a[0];
1845
+ g(k.name, p.target.value, k.routedBy[0]);
1846
+ },
1847
+ children: [/* @__PURE__ */ I("option", {
1848
+ value: "",
1849
+ children: o.selectionNone
1850
+ }), t.destinations.map((p) => /* @__PURE__ */ I("option", {
1851
+ value: p.label,
1852
+ children: p.label
1853
+ }, p.id))]
1854
+ })] }),
1855
+ h && /* @__PURE__ */ I("p", {
1856
+ className: "studio-editor-query__preview",
1857
+ role: "status",
1858
+ children: o.selectionSummary(h.screen, h.slot, h.by)
1859
+ })
1860
+ ] })
1861
+ ]
1862
+ });
1863
+ };
1864
+ export {
1865
+ pe as $,
1866
+ Y as A,
1867
+ he as B,
1868
+ mr as C,
1869
+ Yt as D,
1870
+ Jt as E,
1871
+ _e as F,
1872
+ Ft as G,
1873
+ Rt as H,
1874
+ c as I,
1875
+ rr as J,
1876
+ or as K,
1877
+ Dt as L,
1878
+ qe as M,
1879
+ qt as N,
1880
+ ur as O,
1881
+ le as P,
1882
+ nr as Q,
1883
+ dr as R,
1884
+ Ie as S,
1885
+ Xt as T,
1886
+ ar as U,
1887
+ xt as V,
1888
+ fe as W,
1889
+ ir as X,
1890
+ sr as Y,
1891
+ E as Z,
1892
+ Sn as _,
1893
+ zn as a,
1894
+ pr as b,
1895
+ hr as c,
1896
+ gr as d,
1897
+ tr as et,
1898
+ Mn as f,
1899
+ En as g,
1900
+ br as h,
1901
+ ue as i,
1902
+ Pt as j,
1903
+ cr as k,
1904
+ yr as l,
1905
+ Rn as m,
1906
+ Tr as n,
1907
+ Wn as o,
1908
+ vr as p,
1909
+ H as q,
1910
+ Sr as r,
1911
+ Or as s,
1912
+ wr as t,
1913
+ xn as u,
1914
+ on as v,
1915
+ ke as w,
1916
+ sn as x,
1917
+ fr as y,
1918
+ lr as z
1919
+ };