efficient-easel 8.0.0 → 8.2.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 (64) hide show
  1. package/README.md +2 -0
  2. package/dist/blocks/index.d.ts +2 -2
  3. package/dist/{chunk-CVUMGA2T.js → chunk-5HG62L3A.js} +1 -1
  4. package/dist/chunk-66WCYXIN.js +5 -0
  5. package/dist/{chunk-KYG35KKJ.js → chunk-E63CSJUL.js} +11 -11
  6. package/dist/chunk-ECM5F6JJ.js +1 -0
  7. package/dist/{chunk-BSZ54Q2T.js → chunk-IZPIXBQQ.js} +1 -1
  8. package/dist/{chunk-JO6FBCVR.js → chunk-JIKPYPI3.js} +1 -1
  9. package/dist/{chunk-2QUWI67X.js → chunk-JSO6F7IY.js} +1 -1
  10. package/dist/{chunk-3QK5R7RR.js → chunk-LGN4F6HL.js} +4 -4
  11. package/dist/chunk-OHMYY3FX.js +5 -0
  12. package/dist/chunk-Q6DCUUTQ.js +57 -0
  13. package/dist/{chunk-2LBXIYF7.js → chunk-WMQN4PHH.js} +1 -1
  14. package/dist/{chunk-3NB2IEXA.js → chunk-YIZ4YXPY.js} +1 -1
  15. package/dist/easel/easel.css +20 -0
  16. package/dist/easel/index.d.ts +18 -7
  17. package/dist/easel/index.js +1 -1
  18. package/dist/node-ops/index.d.ts +2 -2
  19. package/dist/node-ops/index.js +1 -1
  20. package/dist/{plan-xc48tt77.d.ts → plan-CGREINRO.d.ts} +6 -4
  21. package/dist/screen/components/AddBlockRow.js +1 -1
  22. package/dist/screen/components/AddSidePanel.js +1 -1
  23. package/dist/screen/components/MediaSidePanel.d.ts +2 -2
  24. package/dist/screen/components/MediaSidePanel.js +1 -1
  25. package/dist/screen/components/NodeContextMenu.d.ts +3 -3
  26. package/dist/screen/components/NodeContextMenu.js +1 -1
  27. package/dist/screen/components/SaveControls.d.ts +2 -2
  28. package/dist/screen/components/ScreenChrome.js +1 -1
  29. package/dist/screen/components/ScreenDocumentContext.d.ts +2 -2
  30. package/dist/screen/components/ScreenMount.d.ts +2 -2
  31. package/dist/screen/components/ScreenMount.js +1 -1
  32. package/dist/screen/components/ScreenStoreProvider.d.ts +2 -2
  33. package/dist/screen/components/ScreenStoreProvider.js +1 -1
  34. package/dist/screen/components/SectionScreenShell.js +16 -16
  35. package/dist/screen/components/usePartBridge.d.ts +2 -2
  36. package/dist/screen/components/usePartBridge.js +1 -1
  37. package/dist/screen/index.d.ts +2 -2
  38. package/dist/screen/index.js +1 -1
  39. package/dist/screen/lib/admin-bridge.d.ts +2 -2
  40. package/dist/screen/lib/document-addressing.d.ts +2 -2
  41. package/dist/screen/lib/document-hooks.d.ts +2 -2
  42. package/dist/screen/lib/host.d.ts +2 -2
  43. package/dist/screen/lib/key-scope.js +1 -1
  44. package/dist/screen/lib/media-panel.d.ts +2 -2
  45. package/dist/screen/lib/media-picker.d.ts +2 -2
  46. package/dist/screen/lib/page-lock.d.ts +2 -2
  47. package/dist/screen/lib/puck/palette-sections.d.ts +2 -2
  48. package/dist/screen/lib/puck/section-doc.d.ts +2 -2
  49. package/dist/screen/lib/puck/style-clipboard.d.ts +2 -2
  50. package/dist/screen/lib/puck/use-section-ops.d.ts +2 -2
  51. package/dist/screen/lib/puck/use-section-ops.js +1 -1
  52. package/dist/screen/lib/screen-parts.d.ts +31 -2
  53. package/dist/screen/lib/screen-parts.js +1 -1
  54. package/dist/screen/lib/section-templates.d.ts +2 -2
  55. package/dist/screen/lib/session-context.d.ts +2 -2
  56. package/dist/screen/lib/session.d.ts +2 -2
  57. package/dist/screen/screen.css +28 -0
  58. package/dist/{types-BbkxBdG9.d.ts → types-NQozKWEz.d.ts} +1 -1
  59. package/dist/{useNodeOps-CTQN3wky.d.ts → useNodeOps-BHRkUFfG.d.ts} +1 -1
  60. package/package.json +1 -1
  61. package/dist/chunk-246ONJJH.js +0 -58
  62. package/dist/chunk-E3PD66A3.js +0 -5
  63. package/dist/chunk-SOZUYCQZ.js +0 -1
  64. package/dist/chunk-ZPXKNO5L.js +0 -5
@@ -15,10 +15,10 @@ import { HostProduct } from './host-chrome.js';
15
15
  import { EaselSession } from './session.js';
16
16
  import { AddTarget } from './puck/add-target-types.js';
17
17
  import { SlotConfigView } from './puck/content-tree.js';
18
- import '../../types-BbkxBdG9.js';
18
+ import '../../types-NQozKWEz.js';
19
19
  import '../../data/index.js';
20
20
  import '../../resolve-D68pb3Bx.js';
21
- import '../../plan-xc48tt77.js';
21
+ import '../../plan-CGREINRO.js';
22
22
  import '../../edit-lock/index.js';
23
23
  import '../../panelWidths-D9hTLR25.js';
24
24
  import '../../session-DSQFmIvx.js';
@@ -1055,6 +1055,35 @@ interface ScreenPinnedNodes {
1055
1055
  * (0.103.0). Absent: a group label in the screen's words, the sections at
1056
1056
  * the tree's own depth, and no row after them. */
1057
1057
  band?: ScreenPinnedBand;
1058
+ /**
1059
+ * HEADER AND FOOTER EDITED IN PLACE (8.2.0, owner 2026-10-15). The words of
1060
+ * the canvas TAB on a pinned node — "Header · on every page" — or null for
1061
+ * a node that has none. Asked of each node pinned first or last and of each
1062
+ * group of sections. The screen draws the tab on the band's top edge while
1063
+ * the pointer is anywhere in it or anything in it is selected, at its true
1064
+ * size whatever the device is scaled by, kept inside the canvas when the
1065
+ * band starts above it; a click on the tab selects the band. Handing it
1066
+ * also makes a group of sections NO STEP of the canvas's click-through
1067
+ * chain: a click inside walks from the group's sections in, as on the page.
1068
+ * Absent: no tab, and the click chain as it was.
1069
+ */
1070
+ groupTab?: (node: ScreenNode) => string | null;
1071
+ /**
1072
+ * …the badge on the Layers row of each pinned node and group ("Every
1073
+ * page"). Handing it draws the in-place tree: the header and footer are
1074
+ * their own rows, with no "Header" / "Footer" group labels over them, and
1075
+ * no row that opens the footer somewhere else. Hidden while the left panel
1076
+ * is narrower than 240px, where the name needs the room. Absent: the tree
1077
+ * as it was.
1078
+ */
1079
+ groupBadge?: string;
1080
+ /**
1081
+ * …what the screen says ONCE per editing session (the easel session), the
1082
+ * first time an edit changes a pinned node or a group of sections: the
1083
+ * shell's toast, with Undo ("Changed on every page"). A seed, a load or an
1084
+ * undo says nothing. Absent: nothing is said.
1085
+ */
1086
+ changeNotice?: string;
1058
1087
  /** The type of the group of sections pinned first, ahead of everything. */
1059
1088
  firstGroup: string | null;
1060
1089
  /** …and of the one pinned last. */
@@ -1 +1 @@
1
- export{SELECTION_MODE,ScreenCanvasTargetProvider,ScreenPartsProvider,isPinnedFirst,isPinnedLast,isSlotMode,sameInspectorMode,screenSlotsOf,useScreenAdd,useScreenBlockLook,useScreenBlockRules,useScreenBridges,useScreenCanvasDrag,useScreenCanvasFrame,useScreenCanvasHead,useScreenCanvasTarget,useScreenDevices,useScreenDocumentLabel,useScreenDocumentPass,useScreenInspectorPanel,useScreenLeftView,useScreenNodeKeys,useScreenNotify,useScreenOwnerName,useScreenParts,useScreenPickFollowsSelection,useScreenPinned,useScreenSaveSwitch,useScreenStorageNamespace,useScreenStyleClipboard,useStandaloneScreenBridges}from"../../chunk-E3PD66A3.js";import"../../chunk-PLVEGYK6.js";import"../../chunk-R6WTQWAC.js";import"../../chunk-U3JP4VGF.js";import"../../chunk-KYG35KKJ.js";import"../../chunk-TBY3DFKS.js";import"../../chunk-PEDDDWSG.js";import"../../chunk-OZ72A6MY.js";import"../../chunk-4JSBIW5H.js";import"../../chunk-GZH4UVDH.js";import"../../chunk-K56YDHYQ.js";import"../../chunk-KFV7N2DJ.js";import"../../chunk-YRLPFZW3.js";import"../../chunk-EA2HTX37.js";import"../../chunk-SOZUYCQZ.js";import"../../chunk-WQASXLXS.js";import"../../chunk-66LWADFP.js";import"../../chunk-QLD57GBB.js";import"../../chunk-FFYXVAAL.js";import"../../chunk-546BBOPE.js";import"../../chunk-MFIRYGHW.js";import"../../chunk-67GNT6PF.js";import"../../chunk-AWJUYMX7.js";import"../../chunk-P2VEMZH5.js";import"../../chunk-KRXQM65X.js";import"../../chunk-NKB3KVAB.js";
1
+ export{SELECTION_MODE,ScreenCanvasTargetProvider,ScreenPartsProvider,isPinnedFirst,isPinnedLast,isSlotMode,sameInspectorMode,screenSlotsOf,useScreenAdd,useScreenBlockLook,useScreenBlockRules,useScreenBridges,useScreenCanvasDrag,useScreenCanvasFrame,useScreenCanvasHead,useScreenCanvasTarget,useScreenDevices,useScreenDocumentLabel,useScreenDocumentPass,useScreenInspectorPanel,useScreenLeftView,useScreenNodeKeys,useScreenNotify,useScreenOwnerName,useScreenParts,useScreenPickFollowsSelection,useScreenPinned,useScreenSaveSwitch,useScreenStorageNamespace,useScreenStyleClipboard,useStandaloneScreenBridges}from"../../chunk-OHMYY3FX.js";import"../../chunk-PLVEGYK6.js";import"../../chunk-R6WTQWAC.js";import"../../chunk-U3JP4VGF.js";import"../../chunk-E63CSJUL.js";import"../../chunk-TBY3DFKS.js";import"../../chunk-PEDDDWSG.js";import"../../chunk-OZ72A6MY.js";import"../../chunk-4JSBIW5H.js";import"../../chunk-GZH4UVDH.js";import"../../chunk-K56YDHYQ.js";import"../../chunk-KFV7N2DJ.js";import"../../chunk-YRLPFZW3.js";import"../../chunk-EA2HTX37.js";import"../../chunk-ECM5F6JJ.js";import"../../chunk-WQASXLXS.js";import"../../chunk-66LWADFP.js";import"../../chunk-QLD57GBB.js";import"../../chunk-FFYXVAAL.js";import"../../chunk-546BBOPE.js";import"../../chunk-MFIRYGHW.js";import"../../chunk-67GNT6PF.js";import"../../chunk-AWJUYMX7.js";import"../../chunk-P2VEMZH5.js";import"../../chunk-KRXQM65X.js";import"../../chunk-NKB3KVAB.js";
@@ -3,11 +3,11 @@ import { EaselSession } from './session.js';
3
3
  import './puck/content-tree.js';
4
4
  import '../../blocks/index.js';
5
5
  import 'react';
6
- import '../../types-BbkxBdG9.js';
6
+ import '../../types-NQozKWEz.js';
7
7
  import '../../data/index.js';
8
8
  import '../../types-41704JE4.js';
9
9
  import '../../resolve-D68pb3Bx.js';
10
- import '../../plan-xc48tt77.js';
10
+ import '../../plan-CGREINRO.js';
11
11
  import './backend-error.js';
12
12
  import '../../edit-lock/index.js';
13
13
  import './host-chrome.js';
@@ -2,11 +2,11 @@ import * as react from 'react';
2
2
  import { ReactNode } from 'react';
3
3
  import { EaselSession } from './session.js';
4
4
  import '../../blocks/index.js';
5
- import '../../types-BbkxBdG9.js';
5
+ import '../../types-NQozKWEz.js';
6
6
  import '../../data/index.js';
7
7
  import '../../types-41704JE4.js';
8
8
  import '../../resolve-D68pb3Bx.js';
9
- import '../../plan-xc48tt77.js';
9
+ import '../../plan-CGREINRO.js';
10
10
  import './backend-error.js';
11
11
  import '../../edit-lock/index.js';
12
12
  import './host-chrome.js';
@@ -5,11 +5,11 @@ import { WebsiteEditLock } from './document-contract.js';
5
5
  import { EaselDocumentHooks } from './document-hooks.js';
6
6
  import { SectionTemplateStore } from './section-template-types.js';
7
7
  import 'react';
8
- import '../../types-BbkxBdG9.js';
8
+ import '../../types-NQozKWEz.js';
9
9
  import '../../data/index.js';
10
10
  import '../../types-41704JE4.js';
11
11
  import '../../resolve-D68pb3Bx.js';
12
- import '../../plan-xc48tt77.js';
12
+ import '../../plan-CGREINRO.js';
13
13
  import '../../edit-lock/index.js';
14
14
  import './links/link-filters.js';
15
15
  import 'efficient-shell/ui';
@@ -820,3 +820,31 @@
820
820
  align-items: center;
821
821
  gap: 12px;
822
822
  }
823
+
824
+ /* ── Header and footer edited in place (8.2.0, owner 2026-10-15) ───────────
825
+ THE BAND TABS: "Header · on every page" on a pinned band's edge, drawn in
826
+ the device sizer beside the frame (ScreenChrome `PinnedBandTabs`), so the
827
+ device's scale never reaches them. The layer ignores the pointer; only a
828
+ tab takes it (a click selects the band). The look is the shell's solid
829
+ badge; nothing here colours it. */
830
+ .es-band-tabs {
831
+ position: absolute;
832
+ inset: 0;
833
+ overflow: hidden;
834
+ pointer-events: none;
835
+ z-index: 6;
836
+ }
837
+ .es-band-tab {
838
+ position: absolute;
839
+ display: inline-flex;
840
+ pointer-events: auto;
841
+ cursor: pointer;
842
+ }
843
+ /* THE LAYERS BADGE ("Every page") gives way below a 240px panel: the row's
844
+ name needs the room (owner 2026-10-15). The side panel is the size
845
+ container (chrome.css). */
846
+ @container (width < 240px) {
847
+ .es-tree-group-badge {
848
+ display: none;
849
+ }
850
+ }
@@ -1,5 +1,5 @@
1
1
  import { DataInput } from './data/index.js';
2
- import { I as ItemSelector, N as NodeSelection } from './plan-xc48tt77.js';
2
+ import { I as ItemSelector, N as NodeSelection } from './plan-CGREINRO.js';
3
3
  import { D as Data, S as SlotAddress, a as DataConfig, N as Node } from './types-41704JE4.js';
4
4
 
5
5
  /**
@@ -1,5 +1,5 @@
1
1
  import { N as Node, S as SlotAddress, D as Data, a as DataConfig, P as Place } from './types-41704JE4.js';
2
- import { N as NodeSelection, A as AfterRemove, S as StepBounds } from './plan-xc48tt77.js';
2
+ import { N as NodeSelection, A as AfterRemove, S as StepBounds } from './plan-CGREINRO.js';
3
3
 
4
4
  /**
5
5
  * The node clipboard — what Copy and Cut hold, and Paste reads.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "efficient-easel",
3
- "version": "8.0.0",
3
+ "version": "8.2.0",
4
4
  "description": "Efficient Easel: the EFFICIENT editors' shared engine and chrome: the saved document as pure functions, the published renderer, and the editor frame, panels, Layers tree, text grammar and type-in-place box. Published as editor-shell up to 0.66.0 and as efficient-editor up to 0.95.0.",
5
5
  "license": "UNLICENSED",
6
6
  "author": "Efficient Pty Ltd",
@@ -1,58 +0,0 @@
1
- import{cloneNodeWithFreshIds as e}from"./chunk-2GVCAIPX.js";import{dedupeSlotChildren as n}from"./chunk-26OOWIJJ.js";import{styleClipboardOf as t}from"./chunk-BRDCD4LK.js";import{markedTreeNodeId as o,revealSelectedTreeRow as r,sameSelector as i}from"./chunk-FGNR22NY.js";import{rootRowName as l,slotChildRowName as s,slotChildRenameProp as d,sectionRenameProp as c}from"./chunk-BHRC3ASL.js";import{scrollPreviewToSection as a,gotoPreviewSlide as p,scrollPreviewToTop as u}from"./chunk-4ES5JGGX.js";import{useEaselKeyTarget as f,useEaselUndoKeys as m,useEaselSaveKey as h,editorRootFocus as g}from"./chunk-3NB2IEXA.js";import{SlotChildActionsProvider as y}from"./chunk-KCBEE2MC.js";import{screenStorageKeys as k,DEFAULT_PANEL_W as S,clampPanelWidth as x}from"./chunk-DPKWJTNX.js";import{usePartBridge as v}from"./chunk-2LBXIYF7.js";import{useSectionOps as w}from"./chunk-2QUWI67X.js";import{useNodeClipboard as b,useNodeContextMenu as z}from"./chunk-R2G64ZNC.js";import{PageEditGuardNotices as B}from"./chunk-NCQSBU3O.js";import{ScreenSaveIcon as C,ScreenMainButton as O}from"./chunk-HDUAODXJ.js";import{useBrowserOffline as I}from"./chunk-RKTF5XLP.js";import{useScreenDocument as N}from"./chunk-THZ46DC5.js";import{requestMediaPick as $}from"./chunk-KG7RJWOK.js";import{heldStyle as A,styleShortcut as P}from"./chunk-V7U33NF2.js";import{AddChildRow as T}from"./chunk-5545A3PC.js";import{AddSidePanel as j}from"./chunk-ZPXKNO5L.js";import{SidePanelHead as M,PanelShowStrip as R}from"./chunk-XTJCKV6Z.js";import{MediaSidePanel as L}from"./chunk-CVUMGA2T.js";import{useScreenSaveSwitch as E,useScreenNodeKeys as V,useScreenPinned as D,useScreenDocumentLabel as H,useScreenCanvasFrame as U,useScreenInspectorPanel as F,useScreenDevices as W,useScreenPickFollowsSelection as G,useScreenLeftView as J,useScreenAdd as X,SELECTION_MODE as K,sameInspectorMode as Y,useScreenBridges as Z,useScreenBlockRules as _,useScreenBlockLook as Q,useScreenStorageNamespace as q,useScreenNotify as ee,useScreenCanvasHead as ne,isSlotMode as te,useScreenStyleClipboard as oe,useScreenDocumentPass as re,useScreenCanvasDrag as ie,ScreenCanvasTargetProvider as le,isPinnedFirst as se,isPinnedLast as de,screenSlotsOf as ce}from"./chunk-E3PD66A3.js";import{ROOT_ZONE as ae,blockNodeActions as pe,TREE_MAX_DEPTH as ue,childSlotsOf as fe,slotFieldsOf as me,slotChildrenIn as he,nestsInTree as ge,newNodeId as ye}from"./chunk-PLVEGYK6.js";import{useMediaPanel as ke,usePanelPick as Se,useCancelPanelPick as xe}from"./chunk-R6WTQWAC.js";import{useEaselHost as ve,useHostEscape as we}from"./chunk-U3JP4VGF.js";import{DEFAULT_STYLE_CLIPBOARD_WORDS as be}from"./chunk-6WY6ZXJG.js";import{DEFAULT_SCREEN_WORDS as ze}from"./chunk-JTUUIVBZ.js";import{useEasel as Be,useEaselApi as Ce}from"./chunk-KYG35KKJ.js";import{TreeRow as Oe,Subtree as Ie,LayersTree as Ne,TreeGroupLabel as $e,TreeRowAction as Ae,TreeSeam as Pe}from"./chunk-4JSBIW5H.js";import{DEFAULT_TREE_WORDS as Te}from"./chunk-K56YDHYQ.js";import{DEFAULT_NODE_MENU_WORDS as je}from"./chunk-WK3AFPXY.js";import{toItemSelector as Me,useNodeOps as Re,clickPick as Le}from"./chunk-SOZUYCQZ.js";import{LayersIcon as Ee,MediaIcon as Ve}from"./chunk-4VJATVVR.js";import{EaselTopBar as De,TopBarRail as He,TopBarCluster as Ue,EaselIconButton as Fe,TopBarDivider as We,DeviceSwitch as Ge,InspectorIconButton as Je,PanelResizeHandle as Xe,MAX_PANEL_W as Ke,MIN_PANEL_W as Ye,panelWidthVars as Ze}from"./chunk-QVUVDBGA.js";import{DEFAULT_NOTICE_WORDS as _e,DEFAULT_CHROME_WORDS as Qe}from"./chunk-Y2G7CU6A.js";import{holderOf as qe,nameOrSomeone as en}from"./chunk-THWO5YVZ.js";import{DEFAULT_LOCK_WORDS as nn}from"./chunk-RE4LP46F.js";import{useWords as tn}from"./chunk-MFIRYGHW.js";import{insertSeams as on,CanvasDragLayer as rn,CanvasInsert as ln}from"./chunk-SSORUDHE.js";import{DEFAULT_DRAG_WORDS as sn}from"./chunk-O2NLQBFX.js";import{createDragSession as dn,useTreeDrag as cn,gapToMoveIndex as an}from"./chunk-67GNT6PF.js";import{useCanvasFrame as pn,LIST_SELECTOR as un,BLOCK_SELECTOR as fn,useCanvasEvent as mn}from"./chunk-AWJUYMX7.js";import{zoneKey as hn,ROOT_ID as gn,ROOT_SLOT as yn,parseZoneKey as kn,find as Sn,DataError as xn}from"./chunk-KRXQM65X.js";import{useRef as vn,useMemo as wn,useState as bn,useEffect as zn,useCallback as Bn,useLayoutEffect as Cn,Fragment as On}from"react";import{toast as In}from"efficient-shell/ui";import{UndoIcon as Nn,RedoIcon as $n,RefreshIcon as An,TrashIcon as Pn,EyeOffIcon as Tn,EyeIcon as jn,DuplicateIcon as Mn}from"efficient-shell/icons/efficient";import{jsx as Rn,jsxs as Ln,Fragment as En}from"react/jsx-runtime";function Vn({expand:e}){/* @__PURE__ */
2
- return Rn("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.9,strokeLinecap:"round",strokeLinejoin:"round",children:/* @__PURE__ */Ln(En,e?{children:[
3
- /* @__PURE__ */Rn("path",{d:"M8 9l4-4 4 4"}),
4
- /* @__PURE__ */Rn("path",{d:"M8 15l4 4 4-4"})]}:{children:[
5
- /* @__PURE__ */Rn("path",{d:"M8 4l4 4 4-4"}),
6
- /* @__PURE__ */Rn("path",{d:"M8 20l4-4 4 4"}),
7
- /* @__PURE__ */Rn("path",{d:"M5 12h14"})]})})}var Dn=`${un}, ${fn}`;function Hn(e,n,t){const o=t-n;if(o<6)return null;if(o<24)return{top:Math.round((n+t)/2),height:Math.round(o)};return{top:Math.round(Math.min(Math.max(e,n+12),t-12))}}var Un="__rungs";var Fn="screen:band",Wn={duplicate:!0,delete:!0};function Gn(){const un=ve(),{target:Gn,docId:Jn,capabilities:Xn,currentSlug:Kn,siteId:Yn,onPublish:Zn,saveState:_n,saveConflict:Qn,retrySave:qn,toggleAutoSave:et,flushSave:nt,access:tt,saveUnreachable:ot=!1,readOnly:rt,readOnlyReason:it=null}=N(),lt=E(),st=V(),{mediaEditing:dt,hasEditGuard:ct,hasPinnedChrome:at}=Xn,{appState:pt,dispatch:ut,history:ft,selectedItem:mt,getSelectorForId:ht,config:gt}=Be(e=>e),yt=D(),{first:kt,firstGroup:St,lastGroup:xt,isSectionGroup:vt,sectionGroupZone:wt,panelOf:bt}=yt,zt=bt(kt),Bt=e=>se(yt,e),Ct=e=>de(yt,e),Ot="node"===yt.firstRow,It=yt.band??null,Nt=tn("screen",ze),$t=tn("tree",Te),At=tn("drag",sn),Pt=tn("notice",_e),Tt=tn("lock",nn),jt=tn("menu",je),Mt=tn("styleClipboard",be),Rt=tn("chrome",Qe),Lt=H()??`/${Kn}`,Et=U(),Vt=F(),Dt=w({readOnly:rt}),Ht=w({readOnly:rt,foldIntoHistory:!0}),Ut=vn(null),Ft=Ce(),Wt=wn(()=>({...Dt,select:e=>{Ut.current=e,Dt.select(e)},commitDocument:(e,n)=>{if(void 0!==n){const t=Ft.config;Ut.current=Me(e,t,n)}Dt.commitDocument(e,n)}}),[Dt,Ft]),Gt=pt.ui,Jt=Gt.leftSideBarVisible,Xt=Gt.rightSideBarVisible,{options:Kt,widths:Yt,initial:Zt,fluid:_t,fit:Qt}=W(),[qt,eo]=bn(Zt),no=ke(),to=dt&&null!==no,oo=Se(),ro=xe();G(mt?.props.id);const{read:io,write:lo,forSelection:so}=J(),[co,ao]=bn(io);zn(()=>{lo(co)},[co]);const[po,uo]=bn(0),fo=vn(null),mo=vn(null),ho=pn(mo,{readySelector:Dn}),go=f(mo);m(mo,ho);const yo=I(),ko=qe(tt),So={state:_n,offline:yo||_n.failed&&ot,readOnlyReason:it,editing:ko?Pt.editing({name:en(ko.name,Tt),noun:Nt.noun}):null,conflict:null!=Qn,notSaving:Nt.bar.notSaving},xo=()=>{rt||(_n.failed?qn():nt())};h(mo,ho,xo);const[vo,wo]=bn(!1),bo=vn(!1),zo=vn(!1),[Bo,Co]=bn(null),Oo=X(),Io=e=>Co(null===e?null:{zone:ae,index:e}),[No,$o]=bn([]),[Ao,Po]=bn(K),To="puck"===Ao.kind,jo=vo&&!Bo&&Oo.railTarget?Oo.railTarget(pt.data,{node:mt??null,mode:Ao}):null,Mo=jo?{zone:hn(jo),index:jo.index}:null,Ro=Bo??Mo,Lo=Ro&&Ro.zone===ae?Ro.index:null,Eo=o(Ao,mt?.props.id),[Vo,Do]=bn(null);zn(()=>{Vo&&(r(),Do(null))},[Vo]);const Ho=vn(ht);Ho.current=ht;const Uo=Bn((e,{scroll:n})=>{ao(n=>so(e,n)),n&&Do(e);const t=[];let o=e;for(let e=0;e<4;e++){const e=Ho.current(o)?.zone;if(!e||!e.includes(":"))break;const n=e.split(":")[0];t.push(n),t.push(e),o=n}0!==t.length&&kr(e=>{if(t.every(n=>!e.has(n)))return e;const n=new Set(e);return t.forEach(e=>n.delete(e)),n})},[]),Fo=vn(null);zn(()=>{const e=Fo.current;Fo.current=null;const n=null==mt?.props.id?null:String(mt.props.id);Po(t=>e&&e.id===n?e.mode:"part"===t.kind&&"nodeId"in t&&t.nodeId===n?t:bt(mt?.type)??K);const t=mt?.props.id,o=Ut.current;if(Ut.current=null,!t)return;const r=ht(t);Uo(String(t),{scroll:!i(o,r??null,ae)})},[mt?.props.id,Uo]);const Wo=Bn(e=>{Po(n=>Y(n,e)?n:e),ut({type:"setUi",ui:{rightSideBarVisible:!0}})},[ut]),Go=vn(()=>{});Go.current=(e,n)=>{const t=e?pi(e.zone??ae)[e.index]?.props.id:null,o=null==t?null:String(t),r=null==mt?.props.id?null:String(mt.props.id);Po(e=>Y(e,n)?e:n),o!==r&&(Fo.current={id:o,mode:n},Wt.select(e))};const Jo=Bn((e,n)=>Go.current(e,n),[]),Xo={kind:Ao.kind,mode:Ao,open:Wo,show:e=>Po(e),reveal:()=>{Xt||ut({type:"setUi",ui:{rightSideBarVisible:!0}})},select:Jo},Ko=Z(Xo,{data:pt.data,selected:mt??null,zoneOf:e=>ht(e)?.zone,readOnly:Boolean(rt),select:e=>{Po(K),Wt.select({index:e})},replace:(e,n)=>Wt.replaceComponent(ae,e,n),scrollTo:e=>Ri(e)},{device:qt,refreshes:po},{setView:ao,reveal:()=>{Jt||ut({type:"setUi",ui:{leftSideBarVisible:!0}})}}),Yo=Ko.pinnedSource??!1,Zo=Ko.resolveLeftView?Ko.resolveLeftView(co,to):"media"===co&&to?co:"sections",_o=_(),{isLockedBlock:Qo,duplicateBlocked:qo,nestDepth:er,newSectionNode:nr,canAddTo:tr,blockIsOffered:or}=_o,rr=Q(),{labelAtLevel:ir,Icon:lr,useProducts:sr}=rr,dr=rr.rowName?(e,n,t)=>rr.rowName(e,n,t):void 0,cr=Bn(e=>{ut({type:"setUi",ui:{rightSideBarVisible:!0}}),a(e),Uo(e,{scroll:!0})},[ut,Uo]),{selectNode:ar,openPartId:pr}=v({mode:Ao,setMode:Po,onOpenPart:cr}),[ur,fr]=bn(null);we(null!==ur,()=>fr(null));const mr=k(q()),hr=mr.collapsed,gr=mr.panelWidths,[yr,kr]=bn(()=>{if("undefined"==typeof window)/* @__PURE__ */return new Set;try{const e=window.localStorage.getItem(hr);return new Set(e?JSON.parse(e):[])}catch{/* @__PURE__ */
8
- return new Set}});zn(()=>{try{window.localStorage.setItem(hr,JSON.stringify([...yr]))}catch{}},[yr]);const[Sr,xr]=bn(()=>{if("undefined"==typeof window)return{...S};try{const e=window.localStorage.getItem(gr);if(!e)return{...S};const n=JSON.parse(e);return{left:x(Number(n.left)||S.left),right:x(Number(n.right)||S.right)}}catch{return{...S}}});zn(()=>{const e=setTimeout(()=>{try{window.localStorage.setItem(gr,JSON.stringify(Sr))}catch{}},300);return()=>clearTimeout(e)},[Sr]);const vr=Bn((e,n)=>xr(t=>{const o="function"==typeof n?n(t[e]):n;return t[e]===o?t:{...t,[e]:o}}),[]),wr=Bn(e=>vr("left",e),[vr]),br=Bn(e=>vr("right",e),[vr]),zr=e=>yr.has(e),Br=e=>kr(n=>{const t=new Set(n);return t.has(e)?t.delete(e):t.add(e),t}),Cr=vn(!1),Or=vn(null);zn(()=>{if(Cr.current&&!vo){const e=Or.current,n=e&&e.isConnected&&!e.closest('[aria-hidden="true"]')?e:null;(n??mo.current?.querySelector(`button[aria-label="${CSS.escape(Nt.add.title)}"]`))?.focus(),Or.current=null}Cr.current=vo},[vo]),zn(()=>{if(!vo||!go)return;const e=e=>{"Escape"===e.key&&Gi()};return go.addEventListener("keydown",e),()=>go.removeEventListener("keydown",e)},[vo,go]),we(vo,()=>Gi()),zn(()=>{!Jt&&vo&&(wo(!1),Co(null),bo.current=!1)},[Jt]),zn(()=>{if(!oo)return zo.current&&ut({type:"setUi",ui:{leftSideBarVisible:!1}}),void(zo.current=!1);vo&&(wo(!1),Co(null),zo.current=bo.current,bo.current=!1),Jt||(zo.current=!0,ut({type:"setUi",ui:{leftSideBarVisible:!0}}))},[oo]),zn(()=>{!Jt&&oo&&(zo.current=!1,ro())},[Jt]),zn(()=>{if(!oo||!go)return;const e=e=>{"Escape"===e.key&&ro()};return go.addEventListener("keydown",e),()=>go.removeEventListener("keydown",e)},[oo,go]),we(null!==oo,()=>ro());const Ir=ee(),Nr=(e,n="success",t)=>{if(Ir)return void(t?Ir(e,"error"===n?"error":"info",t):Ir(e,"error"===n?"error":"info"));const o={sound:!1,action:t?.action,onClose:t?.onClose};"error"===n?In.error(e,{...o,duration:t?.duration??3200}):In.success(e,{...o,duration:t?.duration??1900})},$r=vn(null),[Ar,Pr]=bn(0),[Tr,jr]=bn(0),Mr=ne(),Rr=vn(null),Lr=e=>Math.max(0,e.clientHeight-(Rr.current?.offsetHeight??0));zn(()=>{const e=$r.current;if(!e)return;const n=()=>{Pr(e.clientWidth),jr(Lr(e))};n();const t=new ResizeObserver(n);return t.observe(e),Rr.current&&t.observe(Rr.current),()=>t.disconnect()},[]),Cn(()=>{$r.current&&(Pr($r.current.clientWidth),jr(Lr($r.current)))},[Sr,Jt,Xt]);const Er=qt===_t?Ar>0?Ar:Yt[_t]:Yt[qt],Vr=Ar>0?Math.min(Ar/Er,"shrink"===Qt?1:2):1,Dr=Er*Vr,Hr=Ar>0&&Dr>Ar+1,Ur={width:Dr,height:Tr||"100%",flex:"none",position:"relative"},Fr={width:Er,height:Tr?Tr/Vr:"100%",maxHeight:"none",transform:1!==Vr?`scale(${Vr})`:void 0,transformOrigin:"top left"},Wr=()=>ut({type:"setUi",ui:{leftSideBarVisible:!Jt}}),Gr=()=>ut({type:"setUi",ui:{rightSideBarVisible:!Xt}}),Jr=e=>{vo&&(wo(!1),Co(null),bo.current=!1,Jt&&co===e)||oo&&(zo.current=!1,ro(),Jt&&co===e)||(Jt&&co===e?Wr():(ao(e),Jt||ut({type:"setUi",ui:{leftSideBarVisible:!0}})))},Xr=()=>{$(un,{accept:"image/*",title:Rt.mediaLibrary})},Kr=()=>{Po(K),Wt.select(null),u()},Yr=()=>{Po(zt??K),Xt||ut({type:"setUi",ui:{rightSideBarVisible:!0}})},Zr=pt.data.content??[],_r=()=>{const e=Zr.findIndex(Bt),n=Zr.findIndex(Ct);return{floor:e>=0?e+1:0,cap:n>=0?n:Zr.length}},Qr=gt,qr=_o.stripCopy,ei=n=>e(n,qr),ni=b(),ti=Re({data:pt.data,config:Qr,readOnly:Boolean(rt),clipboard:ni,strip:qr?e=>qr(e):void 0,afterRemove:"none",stepBounds:(e,n)=>{if(e.parentId!==gn||e.slot!==yn)return{min:0,max:n-1};const{floor:t,cap:o}=_r();return{min:t,max:o-1}},commit:(e,{select:n})=>{void 0!==n&&Po(K);const t=void 0===n||"node"===n?.kind?n:null;Wt.commitDocument(e,t)}}),oi=e=>{const n=Sn(pt.data,gt,e);if(!n)return!1;const t=hn(n.place),o=n.node,r=t===ae?di(o):wi(o);return!!ti.remove(e)&&(Nr(Nt.deleted({name:r}),"success",{duration:8e3,action:{label:Nt.bar.undo,onClick:()=>{ti.restore(n.node,n.place)}}}),!0)},ri={...ti,remove:oi},ii=e=>ir(e,"block",gt.components[e]?.label??e),li=Bn(e=>gt.components[e]?.defaultProps??{},[gt]),si=e=>ir(e,"section",ii(e)),di=e=>l({type:e.type,props:e.props??{}},si(e.type),dr),{nodeAddresses:ci,zoneItems:ai}=wn(()=>{const e=/* @__PURE__ */new Map,n=/* @__PURE__ */new Map,t=(o,r,i)=>{n.set(r,o),o.forEach((n,o)=>{const l=String(n.props?.id??"");if(l&&e.set(l,{zone:r,index:o}),i>=ue)return;const s=/* @__PURE__ */new Map;for(const{child:e,zone:t}of fe(gt,n))s.set(t,[...s.get(t)??[],e]);for(const[e,n]of s)t(n,e,i+1)})};return t(Zr,ae,0),{nodeAddresses:e,zoneItems:n}},[Zr,gt]),pi=Bn(e=>ai.get(e)??[],[ai]),ui=e=>{const n=ci.get(e);return n?pi(n.zone)[n.index]:void 0},fi=e=>ce(_o,gt,e),mi=e=>{if(!_o.slotsOf||e===ae)return null;const n=e.lastIndexOf(":");if(n<=0)return null;const t=ui(e.slice(0,n));if(!t)return null;const o=fi(t).filter(e=>e.rung),r=o.findIndex(t=>t.slot===e.slice(n+1));return r<0?null:{node:t,slot:o[r],position:r}},hi=(()=>{if(!te(Ao))return null;const e=`${Ao.nodeId}:${Ao.slot}`;return mi(e)?.slot.panel===Ao.kind?e:null})(),gi=vn(null);zn(()=>{const e=gi.current;if(gi.current=null,!hi||!te(Ao))return;const n=Ao.nodeId;Uo(n,{scroll:e!==hi}),kr(e=>{if(!e.has(n))return e;const t=new Set(e);return t.delete(n),t})},[Ao]);const yi=(e,n,t)=>{const o=String(e.props.id);if(!n.panel)return void(e=>{const n=ci.get(e);n&&(n.zone===ae?Li(n.index):fl(n.zone,n.index,e,ui(n.zone.slice(0,n.zone.lastIndexOf(":")))?.type??""))})(o);const r={kind:n.panel,nodeId:o,slot:n.slot},i=`${o}:${n.slot}`;t&&hi!==i&&(gi.current=i),Jo(null,r),Xt||ut({type:"setUi",ui:{rightSideBarVisible:!0}}),Ri(o)},ki=(e,n,t)=>{const o=`${e}:${n}`;if(kr(n=>{if(!n.has(o)&&!n.has(e))return n;const t=new Set(n);return t.delete(o),t.delete(e),t}),!t)return;hi!==o&&(gi.current=o);Jo(null,{kind:t,nodeId:e,slot:n})},Si=(e,n,t)=>{if(rt||!_o.moveSlot)return;const o=ui(e),r=o?fi(o).filter(e=>e.rung):[],i=r[n];if(!i)return;const l={parentId:e,slot:Un,index:n},s=an(l,{...l,index:Math.min(Math.max(t,0),r.length)});if(s===n)return;const d=_o.moveSlot(e,n,s);"string"==typeof d&&ki(e,d,i.panel)},xi=sr(),vi=wn(()=>{const e=/* @__PURE__ */new Map;for(const n of xi??[])e.set(n.slug,n.name);return e},[xi]),wi=e=>s(e,ii,rr.plainText,e=>vi.get(e),rr.rowName),bi=(e,n)=>{const t=gt.components[e.type]?.fields,o=n===ae||Al(n)?"section":"block",r=n===ae&&(Bt(e)||Ct(e)||vt(e.type)),i="block"===o?d(t):r?null:c(t);return rr.renamePropOf?rr.renamePropOf(e,o,i):i},zi=(e,n,t,o)=>{if(!(!rt&&ur?.zone===e&&ur.index===n))return;const r=(t,o)=>{fr(null),o&&((e,n,t)=>{const o=pi(e)[n];if(!o)return;const r=bi(o,e);r&&Wt.replaceComponent(e,n,{...o,props:{...o.props,[r]:t.trim()}})})(e,n,t)};/* @__PURE__ */
9
- return Rn("input",{className:"es-tree-rename",defaultValue:o,autoFocus:!0,"aria-label":Nt.rename,onClick:e=>e.stopPropagation(),onBlur:e=>r(e.currentTarget.value,!0),onKeyDown:e=>{"Enter"===e.key?(e.preventDefault(),r(e.currentTarget.value,!0)):"Escape"===e.key&&(e.preventDefault(),r("",!1))}},t)},Bi=t(oe(),Mt),Ci=Bi.scope({target:Gn,siteId:Yn,docId:Jn}),Oi=gt,Ii=(e,n)=>n===ae?si(e):ii(e),Ni=(e,n,t)=>{const o=Bi.plan(Ci,t,Ii(t.type,e),Oi);o&&(o.changed&&Wt.replaceComponent(e,n,{...t,props:{...o.props,id:t.props.id}}),Nr(o.message))},$i=z({nodesIn:pi,nodeAt:(e,n)=>pi(e)[n]??null,labelOf:(e,n)=>n===ae?si(e):ii(e),renamePropOf:bi,beginRename:(e,n)=>fr({zone:e,index:n}),history:{hasPast:ft.hasPast,hasFuture:ft.hasFuture,back:()=>ft.back(),forward:()=>ft.forward()},openAddSection:()=>{Wt.select(null),Fi(null)},openPageSettings:()=>{Wt.select(null),Po(K)},pageSettingsLabel:Nt.pageSettings,words:{menu:jt,styleClipboard:Mt,screen:Nt.menu},readOnly:Boolean(rt),collapseAll:()=>kr(new Set(pi(ae).map(e=>String(e.props.id)))),onPasteRefused:e=>Nr(e?Nt.pasteRefused({name:e.label}):Nt.menu.clipboardRefused,"error"),canPasteAt:(e,n)=>Tl(e,n),menuRows:Ko.menuRows,isLocked:e=>Qo(e.type),duplicateBlocked:e=>qo(pt.data,e),permits:e=>pe(gt,e.type),canAddTo:tr,nodeOps:ri,isPinned:(e,n)=>n===ae&&(Bt(e)||Ct(e)),sectionBand:_r,openAddInside:(e,n)=>{e===ae?Li(n):Wt.select({zone:e,index:n}),Fi(null)},locate:e=>ci.get(e)??null,rowNameOf:(e,n)=>n===ae?di(e):wi(e),selectAt:(e,n,t,o)=>{e===ae?Li(n):fl(e,n,t,o??"")},slotRung:e=>{const n=mi(e);return n?.slot.panel?{label:n.slot.label,select:()=>yi(n.node,n.slot,!1)}:null},style:{held:()=>A(Ci),canCopy:e=>Bi.rows(Oi,e).some(e=>!1!==e.counted),copy:(e,n)=>Bi.copy(Ci,e,Ii(e.type,n),Oi),paste:(e,n,t)=>Ni(e,n,t)},keys:st?{target:go,selected:()=>{const e=pt.ui.itemSelector;return e?{zone:e.zone??ae,index:e.index}:null},held:()=>ni.get(),readOnly:Boolean(rt),onDone:({done:e,name:n})=>{"copied"===e&&Nr(Nt.copied({name:n}))}}:void 0},ho),Ai=vn({copy:(e,n)=>{},paste:(e,n,t)=>{},at:()=>null,readOnly:!1});zn(()=>{Ai.current={copy:(e,n)=>Bi.copy(Ci,e,Ii(e.type,n),Oi),paste:Ni,at:()=>{const e=pt.ui.itemSelector;if(!e)return null;const n=e.zone??ae,t=pi(n)[e.index];return t?{zone:n,index:e.index,node:t}:null},readOnly:Boolean(rt)}});const Pi=Bn(e=>{const n=P(e);if(!n)return;const t=Ai.current,o=t.at();o&&(e.preventDefault(),"copy"===n?t.copy(o.node,o.zone):t.readOnly||t.paste(o.zone,o.index,o.node))},[]);zn(()=>{if(!go)return;const e=e=>Pi(e);return go.addEventListener("keydown",e),()=>go.removeEventListener("keydown",e)},[Pi,go]),mn(ho,"keydown",Pi);const Ti=Zr.map(e=>e.props.id).join("|");zn(()=>{const e=ho?.document??null,n=ho?.window??null;let t=0;const o=[],r=()=>{if(!e)return void $o(e=>e.length?[]:e);const n=Zr.findIndex(Ct),t=n>=0?n:Zr.length,o=n=>{const t=Zr[n]?.props?.id;return null==t?null:e.querySelector(`[data-puck-component="${CSS.escape(String(t))}"]`)},r=e=>e?[...e.querySelectorAll(fn)].map(e=>e.getBoundingClientRect()).filter(e=>e.width>0||e.height>0):[],i=[];for(let e=Zr.length>0&&!Bt(Zr[0])?0:1;e<=t;e++){const n=o(e),t=o(e-1),l=n?.getBoundingClientRect()??null,s=t?.getBoundingClientRect()??null;if(!l&&!s)continue;const d=Hn(l&&s?(s.bottom+l.top)/2:l?0===e?l.top+12:l.top:s.bottom,Math.max(0===e?0:-1/0,...r(t).map(e=>e.bottom)),Math.min(1/0,...r(n).map(e=>e.top)));d&&i.push({...d,index:e})}$o(e=>function(e,n){if(e.length!==n.length)return!1;for(let t=0;t<e.length;t++)if(e[t].top!==n[t].top||e[t].index!==n[t].index||e[t].height!==n[t].height)return!1;return!0}(e,i)?e:i)},i=()=>{cancelAnimationFrame(t),t=requestAnimationFrame(r)};if(!e||!n)return void r();n.addEventListener("scroll",i,{passive:!0});const l=new ResizeObserver(i);return l.observe(e.documentElement),r(),o.push(setTimeout(r,150),setTimeout(r,450)),()=>{cancelAnimationFrame(t),o.forEach(clearTimeout),n.removeEventListener("scroll",i),l.disconnect()}},[ho,Ti,qt,Vr,Jt,Xt,mt?.props.id]);const ji=ho?.document??null,Mi=ho?.window??null;zn(()=>{const e=fo.current;if(!e||!ji||!Mi)return;const n=[],t=()=>{const n=ji.querySelector(`[data-puck-component="${CSS.escape(e.id)}"]`);if(!n)return!1;const t=n.getBoundingClientRect().top-e.offset;return Math.abs(t)>1&&Mi.scrollTo({left:Mi.scrollX,top:Mi.scrollY+t,behavior:"instant"}),!0};return fo.current=null,t()&&n.push(setTimeout(t,150),setTimeout(t,450)),()=>n.forEach(clearTimeout)},[ji,Mi]);const Ri=e=>{Ko.holdCanvasOn?Ko.holdCanvasOn(e):a(e)},Li=e=>{Po(K),Wt.select({index:e}),Ko.sectionPressed?.(Zr[e]);const n=Zr[e]?.props?.id;n&&Ri(n)},Ei=e=>{const{floor:n,cap:t}=_r(),o=e=>Math.min(Math.max(n,e),t);if("number"==typeof e)return o(e);const r=mt&&Ao.kind!==zt?.kind?Zr.findIndex(e=>e.props.id===mt.props.id):-1;return o(r>=0?r+1:t)},Vi=(e,n)=>{const{floor:t,cap:o}=_r(),r=Math.min(Math.max(n,t),o),i=e<r?r-1:r;return i===e?{moved:!1,dest:e}:(Wt.reorderComponent(ae,e,i),Wt.select({index:i}),{moved:!0,dest:i})},Di=(e,n,t,o)=>{Po(K),Wt.select(o?{index:o.index,zone:o.zone}:{index:e}),a(n),Nr(Nt.sectionAdded({name:t}))},Hi=(e,n)=>{const t=Ei(n),o=nr(e,{nodeDefaults:li,newNodeId:ye,sectionLabel:si,blockIsOffered:or}),r=o?Wt.insertNode(ae,t,o):Wt.insertSection(e,t);return Di(t,r,si(e),o?((e,n,t)=>{if(e.type===t)return null;const o={at:null},r=(e,n,i)=>{const l=i.filter(n=>n===e.type).length;for(const{child:s,zone:d,index:c}of fe(gt,e)){if(s.type===t&&(!o.at||n>o.at.depth)){const r=tr(e.type,l,d.slice(d.lastIndexOf(":")+1)),i=r?.choices??(r?.spec?[{type:r.spec.childType,label:r.spec.childType}]:[]);null!==r&&"footer"!==r.source&&`${e.props.id}:${r.slot}`===d&&i.some(e=>e.type===t)&&(o.at={zone:d,index:c,depth:n})}r(s,n+1,[...i,e.type])}};return r({type:e.type,props:{...e.props,id:n}},1,[]),o.at?{zone:o.at.zone,index:o.at.index}:null})(o,r,e):null),t},Ui=(e,n,t)=>{const o=Ei(t),r=Wt.insertNode(ae,o,n);return Di(o,r,e),o},Fi=e=>Wi(ae,e),Wi=(e,n)=>{Or.current=document.activeElement??null,oo&&(bo.current=zo.current,zo.current=!1,ro()),Co(null===n?null:{zone:e,index:n}),wo(!0),Jt||(bo.current=!0,ut({type:"setUi",ui:{leftSideBarVisible:!0}}))},Gi=()=>{wo(!1),Co(null),bo.current&&ut({type:"setUi",ui:{leftSideBarVisible:!1}}),bo.current=!1},Ji=(e,n,t)=>{if("section"===e.kind)Wt.insertComponent(n,e.type,t);else{if("template"!==e.kind)return;Wt.insertNode(n,t,ei(e.template.node))}Po(K),Wt.select({index:t,zone:n})},Xi=(e,n)=>rr.rowName?n?Bt(e)?rr.rowName(e,"section",Nt.header):Ct(e)?rr.rowName(e,"section",Nt.footer):vt(e.type)?rr.rowName(e,"section",ii(e.type)):di(e):wi(e):n?si(e.type):ii(e.type),Ki=e=>n=>{e()},Yi=()=>Ko.editPinnedSource?.(),Zi=(e,n,t)=>{if(rt)return null;const o=pi(e)[n];return o&&!pe(gt,o.type).delete?null:/* @__PURE__ */Rn(Ae,{kind:"delete",label:Nt.deleteNamed({name:t}),onClick:()=>((e,n)=>{const t=pi(e)[n]?.props?.id;null!=t&&oi(String(t))})(e,n),children:/* @__PURE__ */Rn(Pn,{size:15})})},_i=e=>rr.rowPreview?.(e)||void 0,Qi=e=>rr.rowMarks?.(e)??void 0,qi=(e,n,t)=>rr.rowActions?.(e,n,t)??null,el=(e,n,t,o)=>{if(rt)return null;const r=Boolean(t.props._hidden);/* @__PURE__ */
10
- return Rn(Ae,{kind:"eye",label:r?Nt.showNamed({name:o}):Nt.hideNamed({name:o}),onClick:()=>tl(e,n,t),children:/* @__PURE__ */Rn(r?Tn:jn,{size:14,strokeWidth:1.8,strokeLinecap:void 0,strokeLinejoin:void 0})})},nl=e=>{const n=si(Zr[e]?.type??""),t=n?Nt.addSectionBefore({name:n}):Nt.addSectionHere;return ts(ae,e,()=>Fi(e),t)},tl=(e,n,t)=>{Wt.replaceComponent(e,n,{...t,props:{...t.props,_hidden:!t.props._hidden}})},ol=e=>me(gt,e),rl=e=>fe(gt,e),il=e=>_o.slotsOf?fi(e).map(n=>({slot:n.slot,rung:n.rung?n:null,kids:he(e,n.slot)})):[{slot:null,rung:null,kids:rl(e)}],ll=e=>_o.slotsOf?il(e).flatMap(e=>e.kids):rl(e),sl=e=>Boolean(_o.slotsOf)&&fi(e).some(e=>e.rung),dl=(e,n,t)=>null===t?void 0===n?tr(e):tr(e,n):tr(e,n,t),cl=(e,n,t)=>{const o=ge(gt,e.type,n)&&(t||ll(e).length>0||sl(e));return{collapsible:o,folded:o&&zr(String(e.props.id))}},al=(e,n,t)=>il(e).flatMap(o=>{const r=o.rung?n+1:n,i=o.kids.flatMap(({child:e})=>cl(e,r,t(e.type)).collapsible?[String(e.props.id),...al(e,r+1,t)]:[]);return o.rung?[`${e.props.id}:${o.rung.slot}`,...i]:i}),pl=e=>ll(e).length>0||sl(e)||Boolean(tr(e.type)),ul=e=>Boolean(tr(e)),fl=(e,n,t,o)=>{if(Po(K),tr(o)?.spec?.slider){const t=e.split(":")[0];p(t,n),Wt.select({index:n,zone:e}),a(t)}else Wt.select({index:n,zone:e}),Ri(t)},ml=(e,n,t,o,r)=>{const i=`${e}:${n}`;Wt.insertComponent(i,t,o),tr(r)?.spec?.slider?requestAnimationFrame(()=>{p(e,o),Wt.select({index:o,zone:i})}):Wt.select({index:o,zone:i})},hl=(e,n,t)=>{Wt.insertComponent(e,n,t),Po(K),Wt.select({index:t,zone:e})},gl=vn(/* @__PURE__ */new Set);zn(()=>{Zr.forEach(e=>{const n=tr(e.type)?.spec;if(!n)return;const t=e.props.id;if(gl.current.has(t))return;gl.current.add(t);if((Array.isArray(e.props[n.slot])?e.props[n.slot]:[]).length>0)return;if(n.skipSeed?.(e.props))return;const o=`${t}:${n.slot}`,r=n.legacy?.(e.props)??[];(r.length?r:n.seeds(li)).forEach((e,t)=>Ht.seedChild(o,t,n.childType,e))})},[Zr,Ht,li]);const yl=vn(/* @__PURE__ */new Set);zn(()=>{Zr.forEach((e,t)=>{const o=e.props.id;if(yl.current.has(o))return;const r=n(e,ol(e.type));yl.current.add(o),r&&Ht.replaceComponent(ae,t,{...e,props:r})})},[Zr,Ht]),re(Ht,gt);const kl=Zr.findIndex(Ct),Sl=kl>=0?Zr[kl]:null,xl=Ot?Zr.findIndex(Bt):-1,vl=xl>=0?Zr[xl]:null,wl=Zr.find(e=>e.type===St)??null,bl=Zr.find(e=>e.type===xt)??null,zl=kl>=0?kl:Zr.length,Bl=[];Zr.forEach(e=>{Ct(e)||(pl(e)&&Bl.push(String(e.props.id)),Bl.push(...al(e,1,ul)))}),Sl&&(Bl.push(String(Sl.props.id)),Bl.push(...al(Sl,1,ul)));const Cl=Bl.length>0&&Bl.every(e=>yr.has(e)),Ol=e=>{const n=rr.blockRowName(e,ii);return rr.rowName?rr.rowName(e,"block",n):n},Il=(e,n,t,o)=>{const r=pi(e)[t];if(!r)return;const i={...kn(e),index:t},l={...kn(n),index:Math.min(Math.max(o,0),pi(n).length)},s=an(i,l);if(e!==n||s!==t)try{ti.move(String(r.props.id),{...l,index:s})}catch(e){if(!(e instanceof xn))throw e}},Nl=e=>{const n=/* @__PURE__ */new Set,t=e=>{for(const{child:o,zone:r}of rl(e))n.add(r),t(o)};for(const t of ol(e.type))n.add(`${e.props.id}:${t}`);return t(e),n},$l=e=>{let n=e.slice(0,e.indexOf(":"));for(let e=0;e<64;e++){const e=ci.get(n);if(!e)return null;if(e.zone===ae)return n;n=e.zone.slice(0,e.zone.indexOf(":"))}return null},Al=e=>{const n=e.slice(0,e.indexOf(":")),t=Zr.find(e=>vt(e.type)&&String(e.props.id)===n);return t&&wt(n)===e?t:null},Pl=(e,n,t)=>{if(e.rung){const t=ui(e.rung.nodeId),o=t?fi(t).filter(e=>e.rung).length:0;return n.parentId===e.rung.nodeId&&n.slot===Un&&n.index>=0&&n.index<=o}if(n.slot===Un)return!1;if(e.add)return Ml(e.add,n);const o=hn(n);if(vt(e.type))return!1;const r=Al(o),i=Al(e.zone);if(r||i)return!(!r||!i)&&(n.index>=0&&n.index<=pi(o).length);if(e.zone===ae||o===ae){if(e.zone!==o)return!1;const{floor:t,cap:r}=_r();return n.index>=t&&n.index<=r}if(n.index<0||n.index>pi(o).length)return!1;if(e.zone===o)return!0;const l=Sl&&!yt.lastIsOpen?String(Sl.props.id):null;return(!l||$l(e.zone)!==l&&$l(o)!==l)&&((e,n,t,o)=>{if(e===n)return!0;const r=o??pi(e)[t];if(!r)return!1;const i=n.split(":")[0],l=ci.get(i),s=l?pi(l.zone)[l.index]:void 0;if(!s)return!1;if(!o&&Nl(r).has(n))return!1;const d=tr(s.type,er(pt?.data,s.type,i),n.slice(n.lastIndexOf(":")+1));return!!d&&(!!(d.choices?d.choices.some(e=>e.type===r.type):d.spec?.childType===r.type)&&!d.spec?.addBlocked?.(pi(n),r))})(e.zone,o,e.index,t)},Tl=(e,n)=>{const t=hn(e.from);if(t===hn(n))return!0;const o=e.node;return Pl({id:String(o.props?.id??""),zone:t,index:-1,type:o.type},n,o)},jl=e=>{const n=e.slice(0,e.indexOf(":")),t=ci.get(n),o=t?pi(t.zone)[t.index]:void 0;if(!t||!o)return null;const r=tr(o.type,er(pt?.data,o.type,n),e.slice(e.lastIndexOf(":")+1));if(!r||`${n}:${r.slot}`!==e)return null;if("footer"===r.source)return null;const i=r.choices??(r.spec?[{type:r.spec.childType,label:ii(r.spec.childType)}]:[]),l=mi(e);return{parent:o,parentId:n,target:r,choices:i,parentName:l?l.slot.label:Xi(o,t.zone===ae)}},Ml=(e,n)=>{const t=hn(n);if("block"!==e.kind){if(Al(t))return n.index>=0&&n.index<=pi(t).length;if(t!==ae)return!1;const{floor:e,cap:o}=_r();return n.index>=e&&n.index<=o}if(t===ae)return!1;const o=jl(t);return!(!o||!o.choices.some(n=>n.type===e.type))&&!o.target.spec?.addBlocked?.(pi(t))},Rl=(e,n)=>{e.rung?Si(e.rung.nodeId,e.index,n.index):e.add?((e,n)=>{if("block"!==e.kind&&Al(hn(n)))return void Ji(e,hn(n),n.index);if("section"===e.kind)return void Hi(e.type,n.index);if("template"===e.kind)return void Ui(e.template.name,ei(e.template.node),n.index);const t=hn(n),o=jl(t);o&&(o.target.spec?ml(o.parentId,o.target.slot,e.type,n.index,o.parent.type):hl(t,e.type,n.index))})(e.add,n):e.zone===ae?Vi(e.index,n.index):Il(e.zone,hn(n),e.index,n.index)},[Ll]=bn(()=>dn()),El=cn({keyOf:e=>e.id,readOnly:Boolean(rt),session:Ll,canDrop:Pl,onDrop:Rl,onStep:(e,n)=>{e.rung?Si(e.rung.nodeId,e.index,n<0?e.index-1:e.index+2):e.zone===ae?((e,n)=>{const t=si(Zr[e]?.type??""),o=Vi(e,n<0?e-1:e+2);if(!o.moved)return void Nr(n<0?Nt.sectionFirst({name:t}):Nt.sectionLast({name:t}));const{floor:r,cap:i}=_r();Nr(Nt.sectionMoved({name:t,n:o.dest-r+1,total:i-r}))})(e.index,n):Il(e.zone,e.zone,e.index,n<0?e.index-1:e.index+2)}}),Vl=Bn(e=>{const{floor:n,cap:t}=_r(),o=[];for(const r of e.nodes){const e=hn(r.place),i=pi(e)[r.place.index];if(!i||String(i.props.id)!==r.id)continue;if(Bt(i)||Ct(i)||Qo(i.type))continue;if(vt(i.type))continue;const l=Boolean(Al(e)),s=e===ae||l;e===ae&&t-n<2||o.push({key:r.id,item:{id:r.id,zone:e,index:r.place.index,type:i.type},box:r.box,label:s?si(i.type):wi(i),from:r.place})}const r=e.zones.flatMap(e=>{const n=hn(e.list);return n===ae&&0===e.children.length?[{...e,addLabel:Nt.addSection,addAlways:!0}]:e.children.length>0||Boolean(jl(n)?.choices.length)||Boolean(Al(n))?[e]:[]}),i=r.flatMap(e=>{const n=hn(e.list);return n===ae||Al(n)||!jl(n)?.choices.length?[]:on(e,Nt.addBlockHere)});return{sources:o,zones:r,seams:i}},[pt.data]),Dl=null==mt?.props.id?null:String(mt.props.id),Hl=Bn(e=>{const n=gt,t=e=>!e.item.rung&&null!==Sn(pt.data,n,e.item.id),o=e[e.length-1];if(!t(o))return o;const r=n=>e.find(e=>t(e)&&e.item.id===n),i=r(Dl);return i||(r(Le(pt.data,n,o.item.id,Dl))??o)},[pt.data,gt,Dl]),Ul=e=>{Po(K),Wt.select(e.zone===ae?{index:e.index}:{index:e.index,zone:e.zone})},Fl=ie(),Wl=()=>({data:pt.data,device:qt,ops:Wt,inspector:Xo}),Gl=Fl?.model,Jl=wn(()=>Gl?e=>Gl(e,Vl(e),Wl()):Vl,[Gl,Vl,qt]),Xl=Fl?.measure,Kl=Xl?(e,n)=>Xl(e,n,Wl()):void 0,Yl=Fl?.canDrop,Zl=Yl?(e,n)=>Yl(e,n,Pl,Wl()):Pl,_l=Fl?.drop,Ql=_l?(e,n)=>_l(e,n,Rl,Wl()):Rl,ql=Fl?.pick,es=ql?e=>ql(e,Ul,Wl()):Ul,ns=e=>{const n=hn(e),t=mi(n);t&&yi(t.node,t.slot,!1),Wi(n,e.index)},ts=(e,n,t,o)=>/* @__PURE__ */Rn(Pe,{...rt?{}:El.seam({place:{...kn(e),index:n}}),onAdd:rt?void 0:t,label:o},`seam:${e}:${n}`),os={rowClick:Ki,isCollapsed:zr,toggleCollapse:Br},rs=e=>{const n=String(e.props.id),t=Zr.findIndex(e=>String(e.props.id)===n),o=wt(n),r=pi(o),i=zr(n),l=ii(e.type),s=rr.rowName?rr.rowName(e,"section",l):l,d=e=>ts(o,e,()=>Wi(o,e),Nt.addSectionHere);/* @__PURE__ */
11
- return Ln(En,{children:[
12
- /* @__PURE__ */Rn(Oe,{words:$t,icon:/* @__PURE__ */Rn(lr,{type:e.type,size:13}),name:s,preview:_i(e),marks:Qi(e),onSelect:()=>Li(t),nameSlot:zi(ae,t,n,s),selected:Eo===n,actions:qi(e,ae,t)??void 0,rowProps:{"data-node-id":n,onClick:Ki(()=>Li(t))},fold:{open:!i,label:"section",onToggle:()=>Br(n)}}),!i&&/* @__PURE__ */Ln(Ie,{children:[r.map((n,t)=>{const r=String(n.props.id),i=di(n),l=pl(n),s=l&&zr(r),c=()=>fl(o,t,r,e.type),{rowProps:a,...p}=El.row({item:{id:r,zone:o,index:t,type:n.type},place:{...kn(o),index:t}},{"data-node-id":r,onClick:Ki(c)});/* @__PURE__ */
13
- return Ln(On,{children:[d(t),
14
- /* @__PURE__ */Rn(Oe,{words:$t,icon:/* @__PURE__ */Rn(lr,{type:n.type,size:13}),name:i,preview:_i(n),marks:Qi(n),onSelect:c,nameSlot:zi(o,t,r,i),selected:Eo===r,hidden:Boolean(n.props._hidden),...p,fold:l?{open:!s,label:"section",onToggle:()=>Br(r)}:void 0,actions:/* @__PURE__ */Ln(En,{children:[Zi(o,t,i),qi(n,o,t),el(o,t,n,i)]}),rowProps:a}),l&&!s&&/* @__PURE__ */Rn(Ie,{children:ss(n,2)})]},r)}),d(r.length)]})]})},is=(e,n,t,o,r)=>{const i=String(e.props.id),l=`${i}:${n.slot}`,s=El.dragging,d=!zr(l)&&s?.rung?.nodeId!==i,c={...kn(l),index:0},a=s&&!s.rung&&Pl(s,c)?c:void 0,p=()=>yi(e,n,!0),{rowProps:u,...f}=El.row({item:{id:`rung:${l}`,zone:`${i}:${Un}`,index:t,type:e.type,rung:{nodeId:i,slot:n.slot}},place:{parentId:i,slot:Un,index:t},into:a,canDrag:Boolean(_o.moveSlot)&&!1!==n.movable&&o>1},{"data-slot-zone":l,onClick:Ki(p)}),m=rt?null:_o.slotActions?.(e,n.slot);/* @__PURE__ */
15
- return Ln(On,{children:[n.heading,
16
- /* @__PURE__ */Rn(Oe,{words:$t,icon:n.glyph??null,name:n.label,badge:n.badge,onSelect:p,selected:hi===l,...f,dragHint:n.dragHint,fold:{open:d,label:n.label,onToggle:()=>Br(l)},actions:m&&m.length>0?/* @__PURE__ */Rn(En,{children:m.map((t,o)=>/* @__PURE__ */Rn(Ae,{kind:"delete"===t.kind?"delete":"plain",label:t.label,disabled:t.disabled,onClick:()=>((e,n,t)=>{if(rt||t.disabled)return;const o=String(e.props.id),r=e=>{"string"==typeof e&&ki(o,e,n.panel)},i=t.run();i&&"function"==typeof i.then?i.then(r):r(i)})(e,n,t),children:"delete"===t.kind?/* @__PURE__ */Rn(Pn,{size:15}):/* @__PURE__ */Rn(Mn,{size:15})},`${o}:${t.kind}`))}):void 0,rowProps:u}),d&&/* @__PURE__ */Rn(Ie,{children:r})]},l)},ls=(e,n)=>{const t=il(e),o=t.filter(e=>e.rung).length;let r=0;/* @__PURE__ */
17
- return Rn(En,{children:t.map(t=>{const i=t.kids,l=t.rung?n+1:n,s=dl(e.type,void 0,t.slot),d=s?`${e.props.id}:${s.slot}`:null,c=null===t.slot?null:`${e.props.id}:${t.slot}`,a=null!==c&&Boolean(jl(c)?.choices.length),p=(e,n)=>a?ts(e,n,()=>Wi(e,n),Nt.addBlockHere):ts(e,n),u=/* @__PURE__ */Ln(En,{children:[i.map(({child:n,zone:t,index:o})=>{const r=Eo===String(n.props.id),{collapsible:i,folded:s}=cl(n,l,ul(n.type)),d=String(n.props.id),c=Ol(n),a=()=>fl(t,o,d,e.type),{rowProps:u,...f}=El.row({item:{id:d,zone:t,index:o,type:n.type},place:{...kn(t),index:o}},{"data-node-id":d,onClick:Ki(a)});/* @__PURE__ */
18
- return Ln(On,{children:[0===o&&p(t,0),
19
- /* @__PURE__ */Rn(Oe,{words:$t,icon:/* @__PURE__ */Rn(lr,{type:n.type,size:13}),name:c,preview:_i(n),marks:Qi(n),onSelect:a,nameSlot:zi(t,o,d,c),selected:r,hidden:Boolean(n.props._hidden),...f,fold:i?{open:!s,label:"group",onToggle:()=>Br(d)}:void 0,actions:/* @__PURE__ */Ln(En,{children:[Zi(t,o,c),qi(n,t,o),el(t,o,n,c)]}),rowProps:u}),i&&!s&&/* @__PURE__ */Rn(Ie,{children:ls(n,l+1)}),p(t,o+1)]},String(n.props.id??`${t}-${o}`))}),null===c?d&&!i.some(e=>e.zone===d)?p(d,0):null:0!==i.length||!t.rung&&d!==c?null:p(c,0)]});return t.rung?is(e,t.rung,r++,o,u):/* @__PURE__ */Rn(On,{children:u},t.slot??"")})})},ss=(e,n)=>{const t=er(pt?.data,e.type,String(e.props.id)),o=il(e),r=o.filter(e=>e.rung).length;let i=0;/* @__PURE__ */
20
- return Rn(En,{children:o.map(o=>{const l=o.kids,s=o.rung?n+1:n,d=dl(e.type,t,o.slot),c=d?.spec??null,a=c&&Array.isArray(e.props[c.slot])?e.props[c.slot]:[],p=d&&d.choices?{slot:d.slot,choices:d.choices}:null,u=String(e.props.id),f=c&&!c.fixed?`${u}:${c.slot}`:null,m=p?`${u}:${p.slot}`:null,h=(n,t)=>{const o=n===f&&c&&!c.addBlocked?.(a)?()=>ml(e.props.id,c.slot,c.childType,t,e.type):n===m?()=>Wi(n,t):void 0;return ts(n,t,o,n===f&&c?c.addLabel:Nt.addBlockHere)},g=null===o.slot?null:`${u}:${o.slot}`,y=Boolean(c&&!c.fixed&&(null===g||g===f)),k=/* @__PURE__ */Ln(En,{children:[l.map(({child:n,zone:t,index:o})=>{const r=Eo===String(n.props.id),i=wi(n),l=String(n.props.id),{collapsible:d,folded:c}=cl(n,s,ul(n.type)),a=ol(n.type),p=1===a.length?`${l}:${a[0]}`:null,u=p?{...kn(p),index:pi(p).length}:void 0,f=El.dragging,m=u&&f&&Pl(f,u)?u:void 0,g=()=>fl(t,o,l,e.type),{rowProps:y,...k}=El.row({item:{id:l,zone:t,index:o,type:n.type},place:{...kn(t),index:o},into:m,canDrag:!Qo(n.type)},{"data-node-id":l,onClick:Ki(g)});/* @__PURE__ */
21
- return Ln(On,{children:[0===o&&h(t,0),
22
- /* @__PURE__ */Rn(Oe,{words:$t,icon:/* @__PURE__ */Rn(lr,{type:n.type,size:13}),name:i,preview:_i(n),marks:Qi(n),onSelect:g,nameSlot:zi(t,o,l,i),selected:r,hidden:Boolean(n.props._hidden),...k,fold:d?{open:!c,label:"group",onToggle:()=>Br(l)}:void 0,actions:Qo(n.type)?qi(n,t,o)??void 0:/* @__PURE__ */Ln(En,{children:[Zi(t,o,i),qi(n,t,o),el(t,o,n,i)]}),rowProps:y}),d&&!c&&/* @__PURE__ */Rn(Ie,{children:ss(n,s+1)}),h(t,o+1)]},String(n.props.id??`${t}-${o}`))}),y&&c&&
23
- /* @__PURE__ */Rn(T,{small:!0,label:c.addLabel,blocked:c.addBlocked?.(a)??null,onAdd:()=>ml(e.props.id,c.slot,c.childType,a.length,e.type)}),null===g?m&&!l.some(e=>e.zone===m)?h(m,0):null:0!==l.length||(o.rung?y:g!==m)?null:h(g,0)]});return o.rung?is(e,o.rung,i++,r,k):/* @__PURE__ */Rn(On,{children:k},o.slot??"")})})},ds=(()=>{if(!mt||!To)return null;const e=String(mt.type),n=String(mt.props.id),t=tr(e,er(pt?.data,e,n));if(!t||"footer"===t.source)return null;const o=Zr.some(e=>String(e.props?.id)===n),r=Array.isArray(mt.props[t.slot])?mt.props[t.slot]:[];if(t.spec?.addBlocked?.(r))return null;const i=t.choices??(t.spec?[{type:t.spec.childType,label:ii(t.spec.childType)}]:[]);return 0===i.length?null:{parentName:Xi(mt,o),choices:i,onPick:o=>{t.spec?ml(n,t.slot,o,r.length,e):hl(`${n}:${t.slot}`,o,r.length)}}})(),cs=Ro&&Ro.zone!==ae&&!Al(Ro.zone)?Ro.zone:null,as=!0===Oo.blocksFirst,ps=cs?jl(cs):as&&Ro?null:ds,us=Boolean(Bo&&cs)||as&&Boolean(ps&&ps.choices.length>0),fs=vo||null!==oo,ms=e=>"panel"in e?{id:e.id,label:e.label,icon:e.icon,active:Jt&&!fs&&Zo===e.id,onSelect:()=>Jr(e.id)}:e,hs=[{id:"add",label:Nt.add.title,icon:/* @__PURE__ */Rn("span",{className:"sf-rail-plus","aria-hidden":"true",children:"+"}),active:vo,onSelect:()=>vo?Gi():Fi(null)},...(Ko.railLead??[]).map(ms),{id:"sections",label:Nt.layers,icon:/* @__PURE__ */Rn(Ee,{}),active:Jt&&!fs&&"sections"===Zo,onSelect:()=>Jr("sections")},...(Ko.railTrail??[]).map(ms)];to?hs.push({id:"media",label:Nt.railMedia,icon:/* @__PURE__ */Rn(Ve,{}),active:Jt&&!vo&&(null!==oo||"media"===Zo),onSelect:()=>Jr("media")}):dt&&hs.push({id:"media",label:Nt.railMedia,icon:/* @__PURE__ */Rn(Ve,{}),onSelect:Xr});const gs=[...Ko.railLead??[],...Ko.railTrail??[]].find(e=>"panel"in e&&e.id===Zo),ys=Boolean(It?.foldable)&&!Yo,ks=It?.label??(ct?Nt.pageSections:Nt.templateSections),Ss=ys&&zr(Fn),xs=/* @__PURE__ */Ln(En,{children:[Zr.map((e,n)=>{if(Bt(e)||Ct(e)||vt(e.type))return null;const t=Eo===String(e.props.id),o=Boolean(e.props._hidden);rl(e);const r=String(e.props.id),i=Ko.hasOwnRows?.(e)??!1,l=pl(e)||i,s=l&&zr(r),d=ol(e.type),c=1===d.length?`${r}:${d[0]}`:null,a=c?{...kn(c),index:pi(c).length}:void 0,p=El.dragging,u=a&&p&&Pl(p,a)?a:void 0,{rowProps:f,...m}=El.row({item:{id:r,zone:ae,index:n,type:e.type},place:{...kn(ae),index:n},into:u},{"data-node-id":r,onClick:Ki(()=>Li(n))});/* @__PURE__ */
24
- return Ln(On,{children:[n>0&&nl(n),
25
- /* @__PURE__ */Rn(Oe,{words:$t,icon:/* @__PURE__ */Rn(lr,{type:e.type,size:13}),name:di(e),preview:_i(e),marks:Qi(e),onSelect:()=>Li(n),nameSlot:zi(ae,n,r,di(e)),selected:t,hidden:o,...m,fold:l?{open:!s,label:"section",onToggle:()=>Br(r)}:void 0,actions:/* @__PURE__ */Ln(En,{children:[Zi(ae,n,di(e)),qi(e,ae,n),el(ae,n,e,di(e))]}),rowProps:f}),pl(e)&&!s&&/* @__PURE__ */Ln(Ie,{children:[ss(e,1),Ko.partRows?.(e,os)]}),i&&!s&&/* @__PURE__ */Rn(Ie,{children:Ko.ownRows?.(e,n,os)})]},String(e.props.id??n))}),!Yo&&zl>0&&nl(zl),It?.addAtEnd&&!Yo&&!rt&&/* @__PURE__ */Rn(T,{small:!0,label:Nt.addSection,blocked:null,onAdd:()=>Fi(zl)})]}),vs=(e,n,t)=>{const o=String(e.props.id),r=ll(e).length>0||sl(e)||Boolean(tr(e.type)),i=r&&zr(o),l="header"===t?Nt.header:Nt.footer,s=rr.rowName?rr.rowName(e,"section",l):l;/* @__PURE__ */
26
- return Ln(En,{children:[
27
- /* @__PURE__ */Rn(Oe,{words:$t,icon:/* @__PURE__ */Rn(lr,{type:t,size:13}),name:s,preview:_i(e),marks:Qi(e),onSelect:()=>Li(n),nameSlot:zi(ae,n,o,s),selected:Eo===String(e.props.id),fold:r?{open:!i,label:"section",onToggle:()=>Br(o)}:void 0,actions:qi(e,ae,n)??void 0,rowProps:{"data-node-id":o,onClick:Ki(()=>Li(n))}}),r&&!i&&/* @__PURE__ */Rn(Ie,{children:ls(e,1)})]})};return(Ko.wrap??(e=>e))(
28
- /* @__PURE__ */Rn(le,{target:ho,children:/* @__PURE__ */Ln("div",{ref:mo,className:"sf-editor es-editor",style:Ze(Sr),onContextMenu:$i.onEditorContextMenu,...g(un),children:[
29
- /* @__PURE__ */Ln(De,{children:[
30
- /* @__PURE__ */Rn(He,{items:hs,ariaLabel:Nt.bar.views}),
31
- /* @__PURE__ */Ln(Ue,{children:[
32
- /* @__PURE__ */Rn(Fe,{label:Nt.bar.undo,disabled:Boolean(rt)||!ft.hasPast,onClick:()=>ft.back(),children:/* @__PURE__ */Rn(Nn,{})}),
33
- /* @__PURE__ */Rn(Fe,{label:Nt.bar.redo,disabled:Boolean(rt)||!ft.hasFuture,onClick:()=>ft.forward(),children:/* @__PURE__ */Rn($n,{})}),
34
- /* @__PURE__ */Rn(We,{}),
35
- /* @__PURE__ */Rn(Ge,{devices:Kt,value:qt,onChange:eo}),
36
- /* @__PURE__ */Rn(Fe,{label:Nt.bar.refresh,tip:Nt.bar.refreshTip,onClick:()=>{fo.current=(()=>{const e=ho?.document;if(!e)return null;const n=Zr.findIndex(Ct),t=n>=0?n:Zr.length;let o=null;for(let n=0;n<t;n++){const t=Zr[n]?.props?.id;if(null==t)continue;const r=e.querySelector(`[data-puck-component="${CSS.escape(String(t))}"]`);if(!r)continue;const i=r.getBoundingClientRect().top;i<=4&&(null===o||i>o.offset)&&(o={id:String(t),offset:i})}if(!o){const e=mt?.props?.id??Zr[0]?.props?.id;null!=e&&(o={id:String(e),offset:0})}return o})(),uo(e=>e+1)},children:/* @__PURE__ */Rn(An,{})})]}),
37
- /* @__PURE__ */Ln(Ue,{kind:"right",style:{minWidth:300},children:[
38
- /* @__PURE__ */Rn(C,{input:So,words:Nt.saveStatus}),Ko.barLead?.(),Ko.barTrail?.(),Ko.mainAction||!Ko.barMain?/* @__PURE__ */Rn(O,{input:So,action:Ko.mainAction??{label:Nt.done,onPress:()=>{Zn(pt.data)}},readOnly:Boolean(rt),saveSwitch:lt,onToggleAutoSave:et,onSaveNow:xo,bar:Nt.bar,words:Nt.saveStatus}):Ko.barMain()]})]}),
39
- /* @__PURE__ */Rn(B,{}),
40
- /* @__PURE__ */Ln("div",{className:"sf-body",children:[Jt?/* @__PURE__ */Ln(En,{children:[
41
- /* @__PURE__ */Rn("aside",{className:"es-sidepanel es-sidepanel--left sf-panel sf-panel--left","aria-label":Nt.leftPanel,children:vo?/* @__PURE__ */Rn(j,{blocks:ps,blocksOnly:us,at:Bo?{label:(e=>{const n=Al(e.zone);if(n)return Nt.add.addingTo({name:rr.rowName?Xi(n,!0):ii(n.type)});if(e.zone===ae){const n=Zr[e.index];return n&&!Ct(n)?Nt.add.addingBefore({name:Xi(n,!0)}):Nt.add.addingAtEnd}const t=jl(e.zone);return t?Nt.add.addingTo({name:t.parentName}):Nt.add.addingHere})(Bo),onClear:()=>Co(null)}:void 0,onAdd:e=>{const n=Ro,t=(e,n)=>{Bo&&Co({zone:e,index:n})};if(n&&"block"!==e.kind&&Al(n.zone))return Ji(e,n.zone,n.index),void t(n.zone,n.index+1);if("section"===e.kind)return(e=>{if(null===Lo)return void Hi(e);const n=Hi(e,Lo);Bo&&Io(n+1)})(e.type);if("template"===e.kind)return((e,n)=>{if(null===Lo)return void Ui(e,n);const t=Ui(e,n,Lo);Bo&&Io(t+1)})(e.template.name,ei(e.template.node));if(n&&n.zone!==ae){const o=jl(n.zone);if(!o)return;return o.target.spec?ml(o.parentId,o.target.slot,e.type,n.index,o.parent.type):hl(n.zone,e.type,n.index),void t(n.zone,n.index+1)}ds?.onPick(e.type)},itemFor:e=>({id:`new:${e.kind}:${"template"===e.kind?e.template.id:e.type}`,zone:"",index:-1,type:"template"===e.kind?e.template.node.type:e.type,add:e}),session:Ll,siteWide:Ko.addPanelRow?.(Gi),onClose:Gi,onHide:Wr,readOnly:Boolean(rt)}):oo&&no?
42
- /* @__PURE__ */Rn(L,{panel:no,pick:oo,onHide:Wr}):gs?gs.panel({onHide:Wr,notify:Nr}):"media"===Zo&&no?/* @__PURE__ */Rn(L,{panel:no,pick:null,onHide:Wr}):/* @__PURE__ */Ln(En,{children:[
43
- /* @__PURE__ */Rn(M,{icon:/* @__PURE__ */Rn(Ee,{}),title:Nt.layers,context:Lt,actions:
44
- /* @__PURE__ */Rn(Je,{label:Cl?Nt.expandAll:Nt.collapseAll,title:0===Bl.length?Nt.nothingToFold:void 0,disabled:0===Bl.length,onClick:()=>kr(e=>{const n=new Set(Bl);return Cl?new Set([...e].filter(e=>!n.has(e))):/* @__PURE__ */new Set([...e,...Bl])}),children:/* @__PURE__ */Rn(Vn,{expand:Cl})}),onHide:Wr}),
45
- /* @__PURE__ */Ln(Ne,{className:"sf-tree sf-scroll",words:$t,children:[
46
- /* @__PURE__ */Rn(Oe,{words:$t,icon:/* @__PURE__ */Rn(lr,{type:"page",size:13}),name:Nt.pageSettings,onSelect:Kr,selected:!mt&&To,rowProps:{onClick:Ki(Kr)}}),wl&&/* @__PURE__ */Ln(En,{children:[
47
- /* @__PURE__ */Rn($e,{children:Nt.header}),rs(wl)]}),!Yo&&at&&/* @__PURE__ */Ln(En,{children:[
48
- /* @__PURE__ */Rn($e,{children:Nt.header}),!Ot&&/* @__PURE__ */Rn(Oe,{words:$t,icon:/* @__PURE__ */Rn(lr,{type:"header",size:13}),name:Nt.header,onSelect:Yr,selected:Ao.kind===zt?.kind,rowProps:{onClick:Ki(Yr)}})]}),!Yo&&vl&&vs(vl,xl,"header"),!Yo&&!ys&&/* @__PURE__ */Rn($e,{children:ks}),ys?/* @__PURE__ */Ln(En,{children:[
49
- /* @__PURE__ */Rn(Oe,{words:$t,icon:null,name:ks,fold:{open:!Ss,label:ks,onToggle:()=>Br(Fn)}}),!Ss&&/* @__PURE__ */Rn(Ie,{children:xs})]}):xs,at&&/* @__PURE__ */Rn($e,{children:Nt.footer}),Sl&&vs(Sl,kl,"footer"),!Yo&&!Sl&&at&&/* @__PURE__ */Rn(Oe,{words:$t,icon:/* @__PURE__ */Rn(lr,{type:"footer",size:13}),name:Nt.footer,onSelect:Yi,rowProps:{onClick:Ki(Yi),title:Nt.editFooter}}),bl&&rs(bl),Ko.treeFoot?.()]})]})}),
50
- /* @__PURE__ */Rn(Xe,{side:"left",width:Sr.left,min:Ye,max:Ke,defaultWidth:S.left,label:Nt.resizeLeftPanel,onResize:wr})]}):/* @__PURE__ */Rn(R,{side:"left",onShow:Wr}),
51
- /* @__PURE__ */Ln("div",{ref:$r,className:"sf-center sf-scroll","data-sf-canvas-head":Mr?"":void 0,style:{overflowX:Hr?"auto":"hidden",overflowY:"hidden"},children:[Mr&&/* @__PURE__ */Rn("div",{ref:Rr,className:"sf-canvas-head",children:/* @__PURE__ */Rn(Mr,{device:qt})}),
52
- /* @__PURE__ */Rn("div",{className:"sf-frame-scaler",style:Ur,children:/* @__PURE__ */Rn("div",{className:"sf-frame "+(qt===_t?"":`sf-frame--${qt}`),style:Fr,children:/* @__PURE__ */Ln("div",{className:"sf-preview-host",children:[
53
- /* @__PURE__ */Rn(Et,{},po),
54
- /* @__PURE__ */Rn(rn,{canvas:ho,session:Ll,model:Jl,measure:Kl,canDrop:Zl,onDrop:Ql,choose:Hl,onPick:es,onZoneAdd:ns,onSeamAdd:ns,zoneAddLabel:Nt.canvasAddBlock,words:At.canvas,readOnly:Boolean(rt),revision:pt.data}),No.length>0&&/* @__PURE__ */Rn("div",{className:"sf-preview-gaps",children:No.map(e=>
55
- /* @__PURE__ */Rn(ln,{index:e.index,label:Nt.addSectionHere,onInsert:()=>Fi(e.index),className:void 0===e.height?"sf-preview-gap":"sf-preview-gap sf-preview-gap--tight",style:void 0===e.height?{top:e.top}:{top:e.top,height:e.height}},e.index))})]})})})]}),Xt?/* @__PURE__ */Ln(En,{children:[
56
- /* @__PURE__ */Rn(y,{value:{selectChild:fl,addChild:ml,childRowName:wi,blockRowName:Ol},children:/* @__PURE__ */Rn(Vt,{mode:Ao,onOpenWebsiteSettings:Ko.openSettings??(()=>{}),onOpenSiteStyles:Ko.openStyles,onSelectNode:ar,onNotify:Nr,onHidePanel:Gr,nodeActions:mt?pe(gt,mt.type):Wn})}),
57
- /* @__PURE__ */Rn(Xe,{side:"right",width:Sr.right,min:Ye,max:Ke,defaultWidth:S.right,label:Nt.resizeSettingsPanel,onResize:br})]}):
58
- /* @__PURE__ */Rn(R,{side:"right",onShow:Gr})]}),$i.menu]})}))}export{Gn as ScreenChrome};
@@ -1,5 +0,0 @@
1
- import{slotFieldsOf as n}from"./chunk-PLVEGYK6.js";import{usePickFollowsSelection as e}from"./chunk-R6WTQWAC.js";import{EaselCanvas as t,useSelectedFields as r}from"./chunk-KYG35KKJ.js";import{Inspector as i}from"./chunk-PEDDDWSG.js";import{createContext as o,useContext as u}from"react";import{DesktopIcon as l}from"efficient-shell/icons/efficient";import{jsx as s}from"react/jsx-runtime";var c={kind:"puck"};function f(n,e){const t=n,r=e,i=Object.keys(t);return i.length===Object.keys(r).length&&i.every(n=>Object.is(t[n],r[n]))}function a(n){const e=n;return"string"==typeof e.nodeId&&"string"==typeof e.slot}function d(e,t,r){const i=e.slotsOf?.(r);return i||n(t,r.type).map(n=>({slot:n,label:n,rung:!1}))}function p(n,e){return n.isFirst?n.isFirst(e):e.type===n.first}function m(n,e){return n.isLast?n.isLast(e):e.type===n.last}var k={},h={},v=()=>k,g=()=>"",y=()=>null,b=()=>{},O={isLockedBlock:()=>!1,duplicateBlocked:()=>null,nestDepth:()=>0,newSectionNode:()=>null,canAddTo:()=>null,blockIsOffered:()=>!0},j={labelAtLevel:(n,e,t)=>t,descriptions:{},categoryLabel:()=>{},firstSection:null,blockRowName:(n,e)=>e(n.type),plainText:n=>n,Icon:()=>null,Thumbnail:()=>null,useProducts:()=>null},w={options:[{id:"desktop",label:"Desktop",icon:/* @__PURE__ */s(l,{})}],initial:"desktop",fluid:"desktop",widths:{desktop:2e3}},D={read:()=>"sections",write:()=>{},forSelection:(n,e)=>n?"sections":e},L={first:null,last:null,firstGroup:null,lastGroup:null,isSectionGroup:()=>!1,sectionGroupZone:()=>"",panelOf:()=>null};function S(){/* @__PURE__ */
2
- return s(t,{height:"fill"})}function G(){const{id:n,fields:e,values:t,readOnly:o,onChange:u}=r();/* @__PURE__ */
3
- return s("div",{className:"es-sidepanel es-sidepanel--right",children:/* @__PURE__ */s(i,{fields:e,values:t,onChange:u,readOnly:o,idPrefix:n})})}var P=o({});function C({parts:n,children:e}){/* @__PURE__ */
4
- return s(P.Provider,{value:n,children:e})}function K(){return u(P)}function N(){return(K().useOwnerName??g)()}function x(){return(K().useDocumentLabel??y)()}function B(n,e,t,r){return(K().useBridges??v)(n,e,t,r)}function I(n){return(K().useStandaloneBridges??v)(n)}function T(n,e){(K().useDocumentPass??b)(n,e)}function A(){return K().blockRules??O}function F(){return K().blockLook??j}function R(){return K().devices??w}function W(){return K().leftView??D}function E(){return K().pinned??L}function V(){return K().saveSwitch??!0}function Y(n){e(!0===K().pickFollowsSelection,n)}function H(){return K().add??h}function J(){return K().storageNamespace||void 0}function Q(){return K().styleClipboard??null}function Z(){return K().nodeKeys??!0}function q(){return K().notify??null}function z(){return K().Canvas??S}function M(){return K().CanvasHead??null}function U(){return K().canvasDrag??null}var X=o(null);function $({target:n,children:e}){/* @__PURE__ */
5
- return s(X.Provider,{value:n,children:e})}function _(){return u(X)}function nn(){return K().Inspector??G}export{c as SELECTION_MODE,$ as ScreenCanvasTargetProvider,C as ScreenPartsProvider,p as isPinnedFirst,m as isPinnedLast,a as isSlotMode,f as sameInspectorMode,d as screenSlotsOf,H as useScreenAdd,F as useScreenBlockLook,A as useScreenBlockRules,B as useScreenBridges,U as useScreenCanvasDrag,z as useScreenCanvasFrame,M as useScreenCanvasHead,_ as useScreenCanvasTarget,R as useScreenDevices,x as useScreenDocumentLabel,T as useScreenDocumentPass,nn as useScreenInspectorPanel,W as useScreenLeftView,Z as useScreenNodeKeys,q as useScreenNotify,N as useScreenOwnerName,K as useScreenParts,Y as useScreenPickFollowsSelection,E as useScreenPinned,V as useScreenSaveSwitch,J as useScreenStorageNamespace,Q as useScreenStyleClipboard,I as useStandaloneScreenBridges};
@@ -1 +0,0 @@
1
- import{find as t,remove as n,getList as e,newId as r,duplicate as o,move as a,copyNode as l,insert as c,setProps as i,slotsOf as d}from"./chunk-KRXQM65X.js";import{useRef as s,useSyncExternalStore as p,useCallback as u,useMemo as f}from"react";var m=t=>({kind:"node",id:t});function x(r,o,a,l="none"){const c=t(r,o,a),i=n(r,o,a);if("none"===l||!c)return{data:i,select:null};const d=e(r,o,c.place)??[],s=d[c.place.index+1]??d[c.place.index-1];return s?.props?.id?{data:i,select:m(s.props.id)}:"root"!==c.place.parentId?{data:i,select:m(c.place.parentId)}:{data:i,select:null}}function I(n,e,a,l={}){const c=t(n,e,a)?.node,i=l.id??r(c?.type??"Node");return{data:o(n,e,a,{strip:l.strip,id:i}),select:m(i)}}function g(t,n,e,r){return{data:a(t,n,e,r),select:m(e)}}var h=(t,n)=>({min:0,max:n-1});function v(n,r,o,a,l=h){const c=t(n,r,o);if(!c)return!1;const i=e(n,r,c.place)?.length??0,{min:d,max:s}=l(c.place,i),p=c.place.index+a;return c.place.index>=d&&c.place.index<=s&&p>=d&&p<=s}function b(n,e,r,o,a=h){if(!v(n,e,r,o,a))return null;const l=t(n,e,r);return g(n,e,r,{...l.place,index:l.place.index+o})}function k(t,n,e,r,o={}){const a=l(e,n,{strip:o.strip});return{data:c(t,n,r,a),select:m(a.props.id)}}function y(n,r,o,a){if(t(n,r,o.props.id))return null;const l=e(n,r,a)??[],i={...a,index:Math.max(0,Math.min(a.index,l.length))};return{data:c(n,r,i,o),select:m(o.props.id)}}function M(t,n,e,r){return{data:i(t,n,e,r),select:void 0}}function O(n,e,r,o=()=>!1){if(!r)return null;if("slot"===r.kind)return t(n,e,r.parentId)?m(r.parentId):null;const a=t(n,e,r.id);if(!a||"root"===a.place.parentId)return null;const l=t(n,e,a.place.parentId);return l?o(l.node,a.place.slot)?{kind:"slot",parentId:l.node.props.id,slot:a.place.slot}:m(l.node.props.id):null}function z(n,e,r){const o=t(n,e,r);return o?[...o.path.filter(t=>"root"!==t.parentId).map(t=>t.parentId),r]:[]}function R(t,n){if(0===t.length)return null;const e=null===n?-1:t.indexOf(n);return-1===e?t[0]:t[Math.min(e+1,t.length-1)]}function B(n,e,r,o){const a=t(n,e,r);return a?0===d(a.node,e).length?r:R(z(n,e,r),o):null}function X(n,e,r){if(!r||"node"!==r.kind)return null;const o=t(n,e,r.id);return o?{zone:`${o.place.parentId}:${o.place.slot}`,index:o.place.index}:null}function $(t,n,r){if(!r)return null;const[o,a]=(r.zone??"root:default-zone").split(/:(.*)/s),l={parentId:o,slot:a},c=e(t,n,l)?.[r.index];return c?.props?.id?m(c.props.id):null}var j={get:()=>null,set:()=>{},subscribe:()=>()=>{}};function K(n){const e=s(n);e.current=n;const r=n.clipboard??j,o=p(r.subscribe,r.get,r.get),a=u(t=>{const n=e.current;if(n.readOnly)return!1;const r=t(n.data,n.config);return!!r&&((r.data!==n.data||void 0!==r.select)&&(n.commit(r.data,{select:r.select}),e.current={...n,data:r.data},!0))},[]);return f(()=>{const n=()=>e.current,r=(e,r)=>{const o=t(n().data,n().config,e);return o?{node:o.node,label:r,from:{parentId:o.place.parentId,slot:o.place.slot}}:null};return{held:o,remove:t=>a((e,r)=>x(e,r,t,n().afterRemove)),duplicate:t=>a((e,r)=>I(e,r,t,{strip:n().strip})),move:(t,n)=>a((e,r)=>g(e,r,t,n)),step:(t,e)=>a((r,o)=>b(r,o,t,e,n().stepBounds)),canStep:(t,e)=>v(n().data,n().config,t,e,n().stepBounds),setProps:(t,n)=>a((e,r)=>M(e,r,t,n)),copy:(t,e)=>{const o=r(t,e);return o&&(n().clipboard??j).set(o),!!o},cut:(t,e)=>{if(n().readOnly)return!1;const o=r(t,e);return!!o&&((n().clipboard??j).set(o),a((e,r)=>x(e,r,t,n().afterRemove)))},paste:t=>{const e=(n().clipboard??j).get();return!!e&&a((r,o)=>k(r,o,e.node,t,{strip:n().strip}))},restore:(t,n)=>a((e,r)=>y(e,r,t,n)),parentOf:t=>O(n().data,n().config,t,n().slotIsLevel)}},[o,a])}export{v as canStep,B as clickPick,$ as fromItemSelector,R as nextInChain,z as nodeChain,O as parentStep,I as planDuplicate,g as planMove,k as planPaste,x as planRemove,y as planRestore,M as planSetProps,b as planStep,X as toItemSelector,K as useNodeOps};
@@ -1,5 +0,0 @@
1
- import{buildPaletteSections as e,pinnedSection as t,paletteWithoutPinned as o,categoryLabel as n}from"./chunk-PA3PNTVV.js";import{blockTypesIn as i}from"./chunk-5ZBY24K7.js";import{sectionTemplatesOf as s}from"./chunk-BVN33R76.js";import{SidePanelHead as r,PanelModeExit as c}from"./chunk-XTJCKV6Z.js";import{useEaselSession as l}from"./chunk-O7Q4DDJT.js";import{blockRuns as a}from"./chunk-HQ4VVRIC.js";import{useScreenBlockLook as p,useScreenBlockRules as m}from"./chunk-E3PD66A3.js";import{DEFAULT_SCREEN_WORDS as d}from"./chunk-JTUUIVBZ.js";import{useEasel as f}from"./chunk-KYG35KKJ.js";import{useWords as u}from"./chunk-MFIRYGHW.js";import{AddPanel as k}from"./chunk-SSORUDHE.js";import{DEFAULT_DRAG_WORDS as h}from"./chunk-O2NLQBFX.js";import{useState as y,useEffect as b,useMemo as j}from"react";import{AddIcon as g}from"efficient-shell/icons/efficient";import{jsx as $,jsxs as B,Fragment as O}from"react/jsx-runtime";var v=e=>`section:${e}`,V=e=>`block:${e}`,x=e=>`template:${e}`;function I({blocks:I,blocksOnly:A,at:D,onAdd:H,itemFor:K,session:L,siteWide:N,onClose:T,onHide:C,readOnly:F}){const J=f(e=>e.config),R=p(),{labelAtLevel:S,categoryLabel:w,firstSection:E,Icon:P,Thumbnail:Q}=R,{blockIsOffered:U}=m(),Y=u("screen",d).add,Z=u("drag",h).add,z=l(),[G,W]=y([]);b(()=>{let e=!1;const t=e=>U(e,z);return s(z).list().then(o=>{if(e)return;const n=J.components;W(o.filter(e=>e.node?.type&&n[e.node.type]&&i(e.node).every(t)))}).catch(()=>{}),()=>{e=!0}},[J,z]);const X=j(()=>e(J,R),[J]),M=e=>({type:v(e.type),label:e.name,cover:/* @__PURE__ */$(Q,{type:e.type}),title:e.desc?`${e.name} — ${e.desc}`:Y.tile({name:e.name}),keywords:[e.alias??"",e.desc,e.type,e.catLabel].filter(Boolean)}),q=j(()=>{const e=[];if(I&&I.choices.length>0&&a(I.choices).forEach((t,o)=>{e.push({key:`blocks:${o}`,title:0===o?`${Y.inside({name:I.parentName})}${t.group?` · ${t.group}`:""}`:t.group??"",tiles:t.items.map(e=>({type:V(e.type),label:e.label,icon:/* @__PURE__ */$(P,{type:e.type,size:18}),title:Y.tile({name:e.label})}))})}),A)return e;const i=t(X,E);i&&e.push({key:"start",title:Y.startBlank,tiles:[M(i)]}),G.length>0&&e.push({key:"templates",title:Y.templates,tiles:G.map(e=>{return{type:x(e.id),label:e.name,cover:/* @__PURE__ */$(Q,{type:e.node.type}),keywords:[(t=e.node.type,S(t,"section",J.components[t]?.label??t)),e.node.type]};var t})});const s=o(X,E);for(const t of Object.keys(J.categories??{})){const o=s.filter(e=>e.cat===t);0!==o.length&&e.push({key:`category:${t}`,title:n(J,t,w),tiles:o.map(M)})}return e},[I,A,G,X,J,Y]),_=e=>{const t=e.indexOf(":"),o=e.slice(0,t),n=e.slice(t+1);if("section"===o)return{kind:"section",type:n};if("block"===o)return{kind:"block",type:n};if("template"===o){const e=G.find(e=>e.id===n);return e?{kind:"template",template:e}:null}return null};/* @__PURE__ */
2
- return B(O,{children:[
3
- /* @__PURE__ */$(r,{icon:/* @__PURE__ */$(g,{size:15}),title:Y.title,context:A?Y.contextBlocks:Y.contextAll,actions:/* @__PURE__ */$(c,{label:Y.done,description:Y.doneDescription,onClick:T}),onHide:C}),
4
- /* @__PURE__ */B("div",{className:"sf-addside sf-scroll",children:[
5
- /* @__PURE__ */$(k,{groups:q,session:L,itemFor:e=>K(_(e)??{kind:"section",type:e}),onInsert:e=>{const t=_(e);t&&H(t)},at:D,hint:A?Y.hintBlocks:Y.hint,searchLabel:A?Y.searchBlocks:Y.searchSections,readOnly:F,words:Z}),N&&!A?N:null]})]})}export{I as AddSidePanel,V as blockKey,v as sectionKey,x as templateKey};