efficient-easel 24.2.0 → 25.0.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 (149) hide show
  1. package/README.md +43 -2
  2. package/dist/{CanvasDragLayer-NZpaX6aq.d.ts → CanvasDragLayer-DXeQGrwJ.d.ts} +42 -3
  3. package/dist/canvas/index.d.ts +2 -139
  4. package/dist/canvas/index.js +1 -1
  5. package/dist/chrome/index.js +1 -1
  6. package/dist/{chunk-6NJHYXJM.js → chunk-3XECMGXX.js} +1 -1
  7. package/dist/chunk-4OMAA45Q.js +5 -0
  8. package/dist/{chunk-G67G63O5.js → chunk-4Y3TK65H.js} +1 -1
  9. package/dist/chunk-53ME3GAI.js +16 -0
  10. package/dist/{chunk-FRAIEWRC.js → chunk-62UGN7VM.js} +1 -1
  11. package/dist/{chunk-HNKB2ZYR.js → chunk-6ATIYLUL.js} +1 -1
  12. package/dist/{chunk-Y53EKN35.js → chunk-6EDVZBUO.js} +1 -1
  13. package/dist/chunk-7UFKEX72.js +1 -0
  14. package/dist/chunk-CEC5XLN4.js +1 -0
  15. package/dist/chunk-CWELHADJ.js +1 -0
  16. package/dist/chunk-DX3VILZ3.js +6 -0
  17. package/dist/chunk-ERB6FAZT.js +2 -0
  18. package/dist/{chunk-TGZCD6IP.js → chunk-EUFDQ4KL.js} +1 -1
  19. package/dist/chunk-FR7EEKFF.js +1 -0
  20. package/dist/{chunk-75C6WFNF.js → chunk-FYV6GZXP.js} +1 -1
  21. package/dist/chunk-GDO4QJ4G.js +1 -0
  22. package/dist/chunk-GEPSJJWW.js +1 -0
  23. package/dist/{chunk-GMCZXMOV.js → chunk-GR3XRILS.js} +1 -1
  24. package/dist/chunk-H6BER2EU.js +1 -0
  25. package/dist/chunk-JIP5JNRB.js +1 -0
  26. package/dist/{chunk-AGWKB77Q.js → chunk-K53PQAMP.js} +1 -1
  27. package/dist/{chunk-CLOS6SSX.js → chunk-KO47WAWR.js} +1 -1
  28. package/dist/chunk-KTV7ORWF.js +64 -0
  29. package/dist/chunk-LUG22U5L.js +1 -0
  30. package/dist/{chunk-DDH2DYQP.js → chunk-LUOY3A3Q.js} +1 -1
  31. package/dist/{chunk-OITNWE52.js → chunk-M4THI4OO.js} +1 -1
  32. package/dist/chunk-MBEUSPIN.js +18 -0
  33. package/dist/chunk-MIX7EGRG.js +2 -0
  34. package/dist/{chunk-2FYFAAAK.js → chunk-OXOUGEAT.js} +1 -1
  35. package/dist/chunk-PMRN5Z3T.js +1 -0
  36. package/dist/{chunk-55KKGABA.js → chunk-PVBDKBJB.js} +1 -1
  37. package/dist/{chunk-RPMSET77.js → chunk-QTHQPJWA.js} +1 -1
  38. package/dist/{chunk-ISS72IKO.js → chunk-QZJKWKGH.js} +1 -1
  39. package/dist/{chunk-IYHO4XQX.js → chunk-S6YOIRXQ.js} +1 -1
  40. package/dist/{chunk-5PXVT7JY.js → chunk-SBVIW3KJ.js} +1 -1
  41. package/dist/chunk-SC6E3UUS.js +13 -0
  42. package/dist/chunk-SSDKT4AY.js +9 -0
  43. package/dist/chunk-TOKMFZPB.js +1 -0
  44. package/dist/chunk-U3LTJSBU.js +20 -0
  45. package/dist/{chunk-WYTPBF3Q.js → chunk-VBEVZZTV.js} +11 -11
  46. package/dist/chunk-VIUES5R6.js +8 -0
  47. package/dist/{chunk-4ESG53BH.js → chunk-YFHKE54W.js} +1 -1
  48. package/dist/chunk-YYD257TD.js +1 -0
  49. package/dist/chunk-ZLOMH2PD.js +1 -0
  50. package/dist/{chunk-JMAOCKB2.js → chunk-ZYOQXBJF.js} +3 -3
  51. package/dist/copy/index.js +13 -13
  52. package/dist/copy-place-CQIemdtU.d.ts +25 -0
  53. package/dist/data/index.d.ts +4 -1
  54. package/dist/data/index.js +1 -1
  55. package/dist/dom-BpxMcHFP.d.ts +200 -0
  56. package/dist/drag/index.d.ts +2 -3
  57. package/dist/drag/index.js +1 -1
  58. package/dist/draw/index.d.ts +1 -1
  59. package/dist/draw/index.js +1 -1
  60. package/dist/easel/index.d.ts +67 -1
  61. package/dist/easel/index.js +1 -1
  62. package/dist/edit-lock/index.d.ts +0 -46
  63. package/dist/edit-lock/index.js +1 -1
  64. package/dist/fields/fields.css +6 -40
  65. package/dist/fields/index.d.ts +1 -6
  66. package/dist/fields/index.js +1 -1
  67. package/dist/node-ops/index.js +1 -1
  68. package/dist/page-copy/index.d.ts +110 -0
  69. package/dist/page-copy/index.js +5 -0
  70. package/dist/panel/index.d.ts +29 -34
  71. package/dist/panel/index.js +1 -1
  72. package/dist/panel/panel.css +0 -78
  73. package/dist/screen/components/AddBlockRow.js +1 -1
  74. package/dist/screen/components/AddSidePanel.d.ts +37 -57
  75. package/dist/screen/components/AddSidePanel.js +1 -1
  76. package/dist/screen/components/NodeContextMenu.d.ts +19 -11
  77. package/dist/screen/components/NodeContextMenu.js +1 -1
  78. package/dist/screen/components/PageEditGuardNotices.js +1 -1
  79. package/dist/screen/components/SaveControls.d.ts +10 -11
  80. package/dist/screen/components/SaveControls.js +1 -1
  81. package/dist/screen/components/ScreenChrome.js +1 -1
  82. package/dist/screen/components/ScreenDocumentContext.js +1 -1
  83. package/dist/screen/components/ScreenMount.d.ts +5 -6
  84. package/dist/screen/components/ScreenMount.js +1 -1
  85. package/dist/screen/components/ScreenStoreProvider.d.ts +8 -9
  86. package/dist/screen/components/ScreenStoreProvider.js +1 -1
  87. package/dist/screen/components/SectionScreenShell.js +17 -17
  88. package/dist/screen/components/SidePanelHead.js +1 -1
  89. package/dist/screen/components/panel-widths.js +1 -1
  90. package/dist/screen/components/usePartBridge.d.ts +10 -11
  91. package/dist/screen/components/usePartBridge.js +1 -1
  92. package/dist/screen/index.d.ts +9 -10
  93. package/dist/screen/index.js +1 -1
  94. package/dist/screen/lib/document/block-set-host.d.ts +55 -0
  95. package/dist/screen/lib/document/block-set-host.js +1 -0
  96. package/dist/screen/lib/document/block-types-in.js +1 -1
  97. package/dist/screen/lib/document/box-fields.d.ts +70 -3
  98. package/dist/screen/lib/document/box-fields.js +1 -9
  99. package/dist/screen/lib/document/device-fields.js +1 -1
  100. package/dist/screen/lib/document/palette-sections.d.ts +33 -97
  101. package/dist/screen/lib/document/palette-sections.js +1 -1
  102. package/dist/screen/lib/document/preview-dom.js +1 -1
  103. package/dist/screen/lib/document/section-doc.js +1 -1
  104. package/dist/screen/lib/document/style-clipboard.d.ts +10 -11
  105. package/dist/screen/lib/document/style-clipboard.js +1 -1
  106. package/dist/screen/lib/document/use-section-ops.js +1 -1
  107. package/dist/screen/lib/document-switch.js +1 -1
  108. package/dist/screen/lib/failure.js +1 -1
  109. package/dist/screen/lib/host-inbound.js +1 -1
  110. package/dist/screen/lib/key-scope.js +1 -1
  111. package/dist/screen/lib/media-picker.js +1 -1
  112. package/dist/screen/lib/page-lock.js +1 -1
  113. package/dist/screen/lib/screen-parts.d.ts +251 -12
  114. package/dist/screen/lib/screen-parts.js +1 -1
  115. package/dist/screen/screen.css +6 -0
  116. package/dist/screen/words.d.ts +9 -0
  117. package/dist/screen/words.js +1 -1
  118. package/dist/strings/index.d.ts +4 -1
  119. package/dist/strings/index.js +2 -2
  120. package/dist/style-clipboard/index.d.ts +0 -32
  121. package/dist/style-clipboard/index.js +1 -1
  122. package/dist/text-styles/index.d.ts +7 -6
  123. package/dist/text-styles/index.js +37 -36
  124. package/dist/text-styles/text-styles.css +5 -53
  125. package/dist/tree/index.d.ts +2 -2
  126. package/dist/{types-DBy3L69b.d.ts → types-CoUTWUwB.d.ts} +1 -1
  127. package/dist/words-Dl8Qja4K.d.ts +32 -0
  128. package/package.json +15 -3
  129. package/dist/chunk-3FIS2FRS.js +0 -1
  130. package/dist/chunk-7RSE6KKY.js +0 -1
  131. package/dist/chunk-CMPFUJ26.js +0 -8
  132. package/dist/chunk-CZAAGBVL.js +0 -7
  133. package/dist/chunk-DSKNJXB4.js +0 -1
  134. package/dist/chunk-FJTCSQWK.js +0 -16
  135. package/dist/chunk-G7ISR6DI.js +0 -1
  136. package/dist/chunk-H4Z2V56N.js +0 -21
  137. package/dist/chunk-K7MMLCTT.js +0 -2
  138. package/dist/chunk-KRL3IUV3.js +0 -1
  139. package/dist/chunk-LF3FUSCQ.js +0 -1
  140. package/dist/chunk-LN43DP2A.js +0 -18
  141. package/dist/chunk-QORC32JO.js +0 -5
  142. package/dist/chunk-THWO5YVZ.js +0 -1
  143. package/dist/chunk-TOHOGVAE.js +0 -15
  144. package/dist/chunk-UKPZ2YWE.js +0 -64
  145. package/dist/chunk-V7U33NF2.js +0 -1
  146. package/dist/chunk-VKPOH6MK.js +0 -1
  147. package/dist/chunk-YU3WHLGI.js +0 -1
  148. package/dist/repeat-D65bJS8d.d.ts +0 -49
  149. package/dist/session-EsjORLQ0.d.ts +0 -43
@@ -1 +0,0 @@
1
- import{useEaselSession as e}from"./chunk-YM4UEGBV.js";import{useHostEscape as n}from"./chunk-LX23TCTP.js";import{DEFAULT_SCREEN_WORDS as t}from"./chunk-IYHO4XQX.js";import{styleMenuItems as o}from"./chunk-V7U33NF2.js";import{ROOT_ZONE as l}from"./chunk-TCAAOYQY.js";import{easelMenuEntries as r,menuLabel as i}from"./chunk-FIVU2COQ.js";import{createNodeClipboard as c,nodeMenuItems as s}from"./chunk-P5VYGWYO.js";import{DEFAULT_NODE_MENU_WORDS as a}from"./chunk-WK3AFPXY.js";import{isTypingTarget as u,useCanvasEvent as d,framePointToHost as p}from"./chunk-YU3WHLGI.js";import{zoneKey as f,ROOT_SLOT as m,ROOT_ID as y}from"./chunk-TGZCD6IP.js";import{useState as h,useCallback as k,useRef as b,useEffect as v}from"react";import{ContextMenu as g}from"efficient-shell/ui";import{UndoIcon as w,RedoIcon as x,PasteIcon as C,StylesIcon as O,LayersIcon as z,CopyIcon as P}from"efficient-shell/icons/efficient";import{jsx as A}from"react/jsx-runtime";function T(e,n){const t=[],o=/* @__PURE__ */new Set;let r={zone:n.zone,index:n.index};for(;r;){const n=e.nodeAt(r.zone,r.index);if(!n||o.has(n.props.id))break;if(o.add(n.props.id),t.push({zone:r.zone,index:r.index,node:n,parentType:null}),r.zone===l)break;const i=r.zone.lastIndexOf(":");if(i<=0)break;r=e.locate(r.zone.slice(0,i))}for(let e=0;e<t.length-1;e+=1)t[e].parentType=t[e+1].node.type;return t}var Y=c(),j=/* @__PURE__ */new WeakMap;function D(e){if(e.claimsPage)return Y;const n=e.registry;if(!n)return e.cache("easel:node-clipboard",c);let t=j.get(n);return t||(t=c(),j.set(n,t)),t}function I(){return D(e())}function K(e,n,t){if(n===l){const{floor:n,cap:o}=e.sectionBand();return{parentId:y,slot:m,index:Math.min(Math.max(t,n),o)}}const o=n.lastIndexOf(":");return{parentId:n.slice(0,o),slot:n.slice(o+1),index:t}}function M(e,n,t){const o=e.isPinned(n,t),l=!o&&!e.isLocked(n)&&!e.duplicateBlocked(n),r=e.permits?.(n)??{duplicate:!0,delete:!0};return{copy:!o&&r.duplicate,cut:l&&r.duplicate&&r.delete,delete:l&&r.delete}}function X(e,n,t){const o=e.canPasteAt;if(!o)return f(n.from)===t.zone?K(e,t.zone,t.index+1):null;for(const l of T(e,t)){const t=K(e,l.zone,l.index+1);if(o(n,t))return t}return null}function S(e){if(e.defaultPrevented||e.altKey||e.shiftKey)return null;if(u(e.target))return null;const n=e.target,t=n&&"ownerDocument"in n?n.ownerDocument??n:null,o=t?.getSelection?.();if(o&&!o.isCollapsed&&o.toString().trim())return null;if(!e.metaKey&&!e.ctrlKey)return"Delete"===e.key?"delete":null;const l=e.code||(1===e.key.length?`Key${e.key.toUpperCase()}`:"");return"KeyC"===l?"copy":"KeyX"===l?"cut":"KeyV"===l?"paste":null}function L(e,n,t,o){const l=e.nodeAt(t.zone,t.index);if(!l)return null;const r=l.props.id,i=e.labelOf(l.type,t.zone),c=M(e,l,t.zone);if("copy"===n)return c.copy?(e.nodeOps.copy(r,i),{done:"copied",name:i}):null;if(o.readOnly)return null;if("cut"===n)return c.cut?(e.nodeOps.cut(r,i),{done:"cut",name:i}):null;if("delete"===n)return c.delete?(e.nodeOps.remove(r),{done:"deleted",name:i}):null;const s=o.held;if(!s)return null;const a=e.isPinned(l,t.zone)?null:X(e,s,t);return a?(e.nodeOps.paste(a),{done:"pasted",name:s.label}):(e.onPasteRefused(s),{done:"refused",name:s.label})}function E(e,n){const{zone:t,index:r}=n,i=e.nodeAt(t,r);if(!i)return[];const c=i.props.id,a=e.labelOf(i.type,t),u=Boolean(i.props._hidden),d=e.nodeOps,p=e.isPinned(i,t),f=e.isLocked(i),m=!p&&!f&&!e.duplicateBlocked(i),y=e.permits?.(i)??{duplicate:!0,delete:!0},h=M(e,i,t),k=T(e,n),b=d.held,v=b&&!p?X(e,b,n):null,g=!e.readOnly,w=e.style?o({held:g?e.style.held():null,canCopy:e.style.canCopy(i,t),onCopy:()=>e.style?.copy(i,t),onPaste:()=>e.style?.paste(t,r,i),words:e.words?.styleClipboard}):[];return s({title:a,words:e.words?.menu,layer:{group:"pick",items:k.flatMap((n,t)=>{const o={label:e.rowNameOf(n.node,n.zone),checked:0===t,onClick:()=>e.selectAt(n.zone,n.index,n.node.props.id,n.parentType)},r=n.zone===l?null:e.slotRung?.(n.zone)??null;return r?[o,{label:r.label,checked:!1,onClick:r.select}]:[o]})},actions:{duplicate:g&&m&&y.duplicate?()=>d.duplicate(c):void 0,...U(g&&!p,e=>d.canStep(c,e),e=>d.step(c,e)),copy:h.copy?()=>d.copy(c,a):void 0,cut:g&&h.cut?()=>d.cut(c,a):void 0,paste:g&&b&&v?{label:b.label,run:()=>d.paste(v)}:void 0,rename:g&&e.renamePropOf(i,t)?()=>e.beginRename(t,r):void 0,hide:!g||f||p?void 0:{hidden:u,run:()=>d.setProps(c,{_hidden:!u})},delete:g&&m&&y.delete?()=>d.remove(c):void 0},style:w,extras:e.menuRows?.(i,t,r)??void 0,pinnedLine:p?V(e).pinned:void 0})}function U(e,n,t){return e?{moveUp:n(-1)?()=>t(-1):null,moveDown:n(1)?()=>t(1):null}:{}}var V=e=>e.words?.screen??t.menu;function B(e){const n=V(e),o=!e.readOnly,r=[];o&&e.history.hasPast&&r.push({label:n.undo,icon:/* @__PURE__ */A(w,{}),shortcut:"⌘Z",onClick:e.history.back}),o&&e.history.hasFuture&&r.push({label:n.redo,icon:/* @__PURE__ */A(x,{}),shortcut:"⇧⌘Z",onClick:e.history.forward});const i=[],c=e.nodeOps.held,s=K(e,l,e.sectionBand().cap);if(o&&c&&(e.canPasteAt?e.canPasteAt(c,s):f(c.from)===l)){const n=s,t=e.words?.menu??a;i.push({label:t.pasteNamed({paste:t.paste,label:c.label}),icon:/* @__PURE__ */A(C,{}),shortcut:"⌘V",onClick:()=>e.nodeOps.paste(n)})}const u=[r,i,[...e.openPageStyles?[{label:e.pageStylesLabel??t.pageStyles,icon:/* @__PURE__ */A(O,{}),onClick:e.openPageStyles}]:[],{label:n.collapseAll,icon:/* @__PURE__ */A(z,{}),onClick:e.collapseAll}]].filter(e=>e.length>0),d={label:"—",onClick:()=>{}};return u.flatMap((e,n)=>n?[d,...e]:e)}function R(e,n){const t=n.selectionStart??0,o=n.selectionEnd??0,l=n.value.slice(t,o),r=e=>{n.focus(),n.setRangeText(e,t,o,"end"),n.dispatchEvent(new Event("input",{bubbles:!0}))},i=e.words?.menu??a,c=V(e),s=[];l&&(s.push({label:i.copy,icon:/* @__PURE__ */A(P,{}),shortcut:"⌘C",onClick:()=>navigator.clipboard?.writeText(l)}),s.push({label:i.cut,icon:/* @__PURE__ */A(P,{}),shortcut:"⌘X",onClick:()=>{navigator.clipboard?.writeText(l),r("")}})),s.push({label:i.paste,icon:/* @__PURE__ */A(C,{}),shortcut:"⌘V",onClick:()=>{navigator.clipboard?.readText().then(e=>{e&&r(e)}).catch(()=>e.onPasteRefused())}});const u=[s,n.value?[{label:c.selectAll,shortcut:"⌘A",onClick:()=>{n.focus(),n.select()}}]:[]].filter(e=>e.length>0),d={label:"—",onClick:()=>{}};return u.flatMap((e,n)=>n?[d,...e]:e)}function N(e){return e.shiftKey}function F(e,t){const[o,l]=h(null),r=k(()=>l(null),[]);n(null!==o,r);const i=b(e);i.current=e;const c=k(e=>{const n=i.current,t=n.keys;if(!t)return;const o=S(e);if(!o)return;const l=t.selected();if(!l)return;const r=L(n,o,l,{readOnly:t.readOnly,held:t.held()});r&&(e.preventDefault(),t.onDone?.(r))},[]),s=e.keys?.target??null;v(()=>{if(!s)return;const e=e=>c(e);return s.addEventListener("keydown",e),()=>s.removeEventListener("keydown",e)},[s,c]),d(t,"keydown",c);const a=k(n=>{if(N(n))return;const t=n.target;if(t?.closest?.("[data-slot-zone]"))return n.preventDefault(),void l(null);const o=function(e){const n=e?.closest?.("input, textarea");return n&&("INPUT"!==n.tagName||["text","search","url","email","tel","number",""].includes(n.type))?n:null}(t);if(o)return n.preventDefault(),void l({kind:"input",x:n.clientX,y:n.clientY,el:o,owner:t});const r=t?.closest?.("[data-node-id]")?.getAttribute("data-node-id"),i=r?e.locate(r):null;n.preventDefault(),l(i?{kind:"node",x:n.clientX,y:n.clientY,...i,owner:t}:{kind:"empty",x:n.clientX,y:n.clientY,owner:t})},[e]);d(t,"contextmenu",n=>{if(N(n)||!t)return;const o=n.target?.closest?.("[data-easel-block]")??null,r=o?.getAttribute("data-easel-block"),i=r?e.locate(r):null;n.preventDefault();const c=p(t.frame,n.clientX,n.clientY),s=t.frame;l(i?{kind:"node",...c,...i,owner:s}:{kind:"empty",...c,owner:s})}),d(t,"mousedown",r),d(t,"scroll",r,{on:"window"});return{onEditorContextMenu:a,menu:o?/* @__PURE__ */A(G,{host:e,target:o,onClose:r}):null,closeMenu:r}}function G({host:e,target:n,onClose:t}){const o="node"===n.kind?E(e,n):"input"===n.kind?R(e,n.el):B(e);return 0===o.length?null:/* @__PURE__ */A(g,{at:{x:n.x,y:n.y},owner:n.owner??null,onClose:t,"aria-label":i(o),items:r(o)})}export{Y as EASEL_NODE_CLIPBOARD,T as ancestorChain,D as nodeClipboardOf,M as nodeClipboardRules,E as nodeMenuItems,S as nodeShortcut,B as pageMenuItems,X as pastePlace,L as runNodeShortcut,R as textMenuItems,I as useNodeClipboard,F as useNodeContextMenu};
@@ -1,21 +0,0 @@
1
- import{fieldIsShown as e,shownFields as n}from"./chunk-BPXEFVSQ.js";import{noControlMetaOf as t,deviceMetaOf as l}from"./chunk-YCSZAP7T.js";import{TreeSeam as r}from"./chunk-WHS6Y55E.js";import{DEFAULT_TREE_WORDS as a}from"./chunk-K56YDHYQ.js";import{easelMenuEntries as o}from"./chunk-FIVU2COQ.js";import{SETTINGS_BUCKETS as i,SettingsGroup as s}from"./chunk-FM6JO4WF.js";import{DEFAULT_PANEL_WORDS as c}from"./chunk-KFV7N2DJ.js";import{FieldNumber as d}from"./chunk-Y2T3JX7K.js";import{FieldSelect as u}from"./chunk-KFWNGPW3.js";import{DEFAULT_FIELDS_WORDS as m}from"./chunk-JACEEVVF.js";import{SettingsField as h,SettingsSegmented as p}from"./chunk-CZAAGBVL.js";import{useWords as f}from"./chunk-MFIRYGHW.js";import{useTreeDrag as b,gapToMoveIndex as g}from"./chunk-6NJHYXJM.js";import{withTip as v}from"./chunk-P2VEMZH5.js";import{Textarea as y,Input as k,ItemCount as x,SortableList as w,ListRow as C,ContextMenu as N,tabPanelId as O,Tabs as j,tabButtonId as $}from"efficient-shell/ui";export{LinkPicker}from"efficient-shell/ui";import{useRef as S,useState as I,useLayoutEffect as D,useId as F}from"react";import{jsx as P,jsxs as L}from"react/jsx-runtime";import{ChevronIcon as E,LockIcon as M,MoveUpIcon as A,MoveDownIcon as T,DuplicateIcon as W,TrashIcon as z}from"efficient-shell/icons/efficient";function R({id:e,value:n,onChange:t,placeholder:l,multiline:r=!1,rows:a=3,readOnly:o=!1,ariaLabel:i,ariaLabelledBy:s}){const c=n??"";return r?/* @__PURE__ */P(y,{id:e,size:"sm",className:"es-fin",value:c,rows:a,placeholder:l,readOnly:o,"aria-label":i,"aria-labelledby":s,onChange:e=>t(e.target.value)}):/* @__PURE__ */P(k,{id:e,size:"md",className:"es-fin",type:"text",value:c,placeholder:l,readOnly:o,"aria-label":i,"aria-labelledby":s,onChange:e=>t(e.target.value)})}function H(e,n,t){const l=e.slice();return l.splice(Math.max(0,Math.min(n,l.length)),0,t),l}function J(e,n,t){const l=e.slice(),[r]=l.splice(n,1);return l.splice(Math.max(0,Math.min(t,l.length)),0,r),l}function V(e,n){return e.filter((e,t)=>t!==n)}function Y(e){return null===e||"object"!=typeof e?e:JSON.parse(JSON.stringify(e))}var K='input, textarea, select, button, [contenteditable]:not([contenteditable="false"]), [tabindex]',B={parentId:"list",slot:"items"};function Z({label:e,icon:n,noun:t,items:l,onChange:i,newItem:s,summary:c,itemName:d,thumb:u,min:h=0,max:p,readOnly:y=!1,open:k,onOpen:O,renderItem:j,renderRow:$,canRemove:F,lockedReason:R,fixed:Z=!1,removeOnRow:X=!0,canDuplicate:G,above:Q,head:q=!0}){const U=f("fields",m).list,_=f("tree",a),ee=t??U.item,ne=!y&&!Z&&("number"!=typeof p||l.length<p),te=l.length<=h,le=e=>!!F&&!F(l[e],e),re=e=>!y&&!Z&&X&&!te&&!le(e),ae=e=>ne&&(!G||G(l[e],e)),oe=(e,n)=>d?d(e,n):U.itemName({noun:ee,n:n+1}),ie=S([]),se=S(null),[ce,de]=I(null),ue=S(null),[me,he]=I(null),[pe,fe]=I("");D(()=>{const e=se.current;if(!e)return;se.current=null;const n=ie.current[e.index]?.querySelectorAll(K)[e.nth]??ie.current[e.index];if(n?.focus(),n&&null!==e.start&&"setSelectionRange"in n)try{n.setSelectionRange(e.start,e.end)}catch{}});const be=(e,n)=>{if(n<0||n>=l.length||n===e)return;const t=ie.current[e],r=t?.ownerDocument.activeElement;if(t&&r&&t.contains(r)){const e=[...t.querySelectorAll(K)].indexOf(r),l=r;se.current={index:n,nth:e,start:"number"==typeof l.selectionStart?l.selectionStart:null,end:"number"==typeof l.selectionEnd?l.selectionEnd:null}}i(J(l,e,n));const a=function(e,n,t){return null===e?null:e===n?t:n<e&&t>=e?e-1:n>e&&t<=e?e+1:e}(k,e,n);a!==k&&O(a),fe(U.moved({n:n+1,total:l.length}))},ge=e=>{ne&&(i(H(l,e,s())),$?(se.current={index:e,nth:0,start:null,end:null},null!==k&&k>=e&&O(k+1)):O(e))},ve=e=>{re(e)&&(i(V(l,e)),k===e?O(null):null!==k&&k>e&&O(k-1))},ye=b({keyOf:e=>String(e),canDrop:(e,n)=>n.parentId===B.parentId&&n.slot===B.slot,onDrop:(e,n)=>{const t=g({...B,index:e},n);t!==e&&be(e,t)},onStep:(e,n)=>be(e,e+n),canStep:(e,n)=>e+n>=0&&e+n<l.length,readOnly:y}),ke=e=>{const n=[];return e>0&&n.push({label:U.moveUp,icon:/* @__PURE__ */P(A,{size:14}),shortcut:"⌥↑",onClick:()=>be(e,e-1)}),e<l.length-1&&n.push({label:U.moveDown,icon:/* @__PURE__ */P(T,{size:14}),shortcut:"⌥↓",onClick:()=>be(e,e+1)}),ae(e)&&n.push({label:U.duplicate,icon:/* @__PURE__ */P(W,{size:14}),onClick:()=>(e=>{ae(e)&&(i(H(l,e+1,Y(l[e]))),null!==k&&k>e&&O(k+1))})(e)}),re(e)&&n.push({label:U.delete,icon:/* @__PURE__ */P(z,{size:14}),danger:!0,onClick:()=>ve(e)}),n},xe=(e,n,t,l)=>{y||0===ke(e).length||he({index:e,x:n,y:t,owner:l})},we=e=>n=>{const t=l.slice();t[e]=n,i(t)};/* @__PURE__ */
2
- return L("div",{className:"es-list",children:[q?/* @__PURE__ */L("div",{className:"es-list-head",children:[
3
- /* @__PURE__ */L("span",{className:"es-list-label",children:[n?/* @__PURE__ */P("span",{className:"es-field-icon","aria-hidden":"true",children:n}):null,e]}),
4
- /* @__PURE__ */P(x,{count:l.length,label:U.count({noun:ee,n:l.length}),showZero:!0})]}):null,Q?/* @__PURE__ */P("div",{className:"es-list-above",children:Q}):null,l.length?/* @__PURE__ */L(w,{"aria-label":e,spacing:"comfortable",className:"es-list-rows",rootProps:ye.rootProps(),children:[l.map((e,n)=>{const t=ye.row({item:n,place:{...B,index:n}}),l=t.draggable&&ce!==n,a=!$&&k===n,o=!y&&!Z&&X&&le(n),i=["es-list-row",$?"is-inline":"is-item",a?"is-open":"",l?"is-draggable":"",t.dragging?"is-dragging":"",t.drop?`is-drop-${t.drop}`:""].filter(Boolean).join(" ");return[n>0?/* @__PURE__ */P(r,{...ye.seam({place:{...B,index:n}}),onAdd:ne?()=>ge(n):void 0,label:U.addHere({noun:ee})},`seam-${n}`):null,
5
- /* @__PURE__ */P(C,{className:i,flat:!!$,active:a,draggable:t.draggable,dragHint:_.dragHint,dragging:t.dragging,drop:"before"===t.drop||"after"===t.drop?t.drop:void 0,onMove:t.draggable?e=>be(n,"up"===e?n-1:n+1):void 0,rowRef:e=>{ie.current[n]=e},rowProps:{...t.rowProps,draggable:l||void 0,onPointerDown:e=>{const l=e.target.closest?.('input, textarea, select, [contenteditable]:not([contenteditable="false"])'),r=!!l&&l===l.ownerDocument.activeElement;e.currentTarget.draggable=t.draggable&&!r,ue.current=l&&!r?l:null,de(r?n:null)},onDragStart:e=>{const n=ue.current;ue.current=null,n&&n.ownerDocument.activeElement===n&&n.blur(),t.rowProps.onDragStart?.(e)},onContextMenu:e=>{y||(e.preventDefault(),e.stopPropagation(),xe(n,e.clientX,e.clientY,e.currentTarget))},onKeyDown:e=>{if("ContextMenu"===e.key||e.shiftKey&&"F10"===e.key){e.preventDefault();const t=e.currentTarget.ownerDocument,l=e=>e.preventDefault();t.addEventListener("contextmenu",l,{capture:!0,once:!0}),t.defaultView?.setTimeout(()=>t.removeEventListener("contextmenu",l,{capture:!0}),500);const r=e.currentTarget.getBoundingClientRect();return void xe(n,r.left+24,r.bottom,e.currentTarget)}t.rowProps.onKeyDown?.(e)}},actions:y||Z||!X?void 0:o?v(R?R(e,n):U.locked,/* @__PURE__ */P("span",{className:"es-list-lock",role:"img","aria-label":R?R(e,n):U.locked,children:/* @__PURE__ */P(M,{size:13})})):v(U.deleteItem({noun:ee}),/* @__PURE__ */P("button",{type:"button",className:"es-list-x","aria-label":U.deleteItem({noun:ee}),disabled:!re(n),onClick:()=>ve(n),children:"×"})),below:a?/* @__PURE__ */P("div",{className:"es-list-item",children:j(e,n,we(n))}):void 0,children:$?/* @__PURE__ */P("div",{className:"es-list-row-main",children:$(e,n,we(n))}):/* @__PURE__ */L("button",{type:"button",className:"es-list-open","aria-expanded":a,onClick:()=>O(a?null:n),children:[u?/* @__PURE__ */P("span",{className:"es-list-thumb","aria-hidden":"true",children:u(e,n)}):null,
6
- /* @__PURE__ */P("span",{className:"es-list-row-name",children:oe(e,n)}),/* @__PURE__ */P("span",c?{className:"es-list-row-summary",children:c(e,n)}:{className:"es-list-row-summary"}),
7
- /* @__PURE__ */P(E,{size:14,className:"es-list-chev","aria-hidden":"true"})]})},n)]}),
8
- /* @__PURE__ */P(r,{...ye.seam({place:{...B,index:l.length}})})]}):null,y||Z?null:/* @__PURE__ */P("button",{type:"button",className:"es-list-add",disabled:!ne,onClick:()=>ge(l.length),children:U.add({noun:ee})}),
9
- /* @__PURE__ */P("span",{className:"es-list-said","aria-live":"polite",children:pe}),me&&me.index<l.length?
10
- /* @__PURE__ */P(N,{at:{x:me.x,y:me.y},owner:me.owner,onClose:()=>he(null),items:o(ke(me.index))}):null]})}var X=e=>e<6?e+1:6,G=(e,n)=>"string"==typeof e.label&&e.label?e.label:n;function Q({field:e,name:t,id:l,value:r,onChange:a,readOnly:o,context:i,showWhenContext:c,renderers:d,headingLevel:u=3}){const[m,h]=I(!0),p=r&&"object"==typeof r?r:{};/* @__PURE__ */
11
- return P(s,{id:`${l}-group`,title:G(e,t),open:m,onToggle:h,level:u,children:Object.entries(n(e.objectFields,{values:p,context:c})).map(([e,n])=>/* @__PURE__ */P(U,{field:n,name:`${t}.${e}`,id:`${l}-${e}`,value:p[e],onChange:n=>a({...p,[e]:n}),readOnly:o,context:i,showWhenContext:c,renderers:d,headingLevel:X(u)},e))})}function q({field:e,name:t,id:l,value:r,onChange:a,readOnly:o,context:i,showWhenContext:s,renderers:c,openItem:d,onOpenItem:u,headingLevel:m}){const[h,p]=I(null),f=u?d??null:h,b=u??p,g=Array.isArray(r)?r:[],v=e.getItemSummary;/* @__PURE__ */
12
- return P(Z,{label:G(e,t),icon:e.icon,noun:"string"==typeof e.noun?e.noun:void 0,items:g,onChange:a,newItem:()=>Y({...e.defaultItemProps??{}}),summary:v?(e,n)=>v(e,n):void 0,min:e.min,max:e.max,readOnly:o,open:f,onOpen:b,renderItem:(r,a,d)=>Object.entries(n(e.arrayFields,{values:r,context:s})).map(([e,n])=>/* @__PURE__ */P(U,{field:n,name:`${t}[${a}].${e}`,id:`${l}-${a}-${e}`,value:r?.[e],onChange:n=>d({...r,[e]:n}),readOnly:o,context:i,showWhenContext:s,renderers:c,headingLevel:m},e))})}function U(e){const{field:n,name:t,id:l,value:r,onChange:a,readOnly:o,context:i,renderers:s}=e;if(!n||n.marker||!1===n.visible)return null;const c=s?.[n.type];if(c)return c({field:n,name:t,id:l,value:r,onChange:a,readOnly:o});switch(n.type){case"custom":{const e={...i,field:n,name:t,id:l,value:r,onChange:a,readOnly:o};return n.render(e)}case"text":case"textarea":/* @__PURE__ */
13
- return P(h,{label:G(n,t),htmlFor:l,icon:n.icon,hint:n.hint,children:/* @__PURE__ */P(R,{id:l,value:"string"==typeof r?r:null==r?"":String(r),onChange:a,placeholder:n.placeholder,multiline:"textarea"===n.type,readOnly:o})});case"number":/* @__PURE__ */
14
- return P(h,{label:G(n,t),htmlFor:l,icon:n.icon,hint:n.hint,children:/* @__PURE__ */P(d,{id:l,value:"number"==typeof r?r:void 0,onChange:a,min:n.min,max:n.max,step:n.step,placeholder:n.placeholder,readOnly:o})});case"select":{const e=`${l}-label`;/* @__PURE__ */
15
- return P(h,{label:G(n,t),labelId:e,htmlFor:l,icon:n.icon,hint:n.hint,children:/* @__PURE__ */P(u,{id:l,value:r,options:n.options,onChange:a,readOnly:o,ariaLabelledBy:e})})}case"radio":/* @__PURE__ */
16
- return P(h,{label:G(n,t),icon:n.icon,hint:n.hint,children:/* @__PURE__ */P(p,{ariaLabel:G(n,t),value:r,options:n.options.map(e=>({id:e.value,label:e.label,icon:e.icon,disabled:e.disabled||o})),onChange:e=>{o||a(e)}})});case"object":/* @__PURE__ */
17
- return P(Q,{...e,field:n});case"array":/* @__PURE__ */
18
- return P(q,{...e,field:n});case"slot":return null}}function _(e,n){if("mobile"!==n)return!0;const r=e;if(!r||r.marker||"slot"===r.type||"always"===t(e))return!0;const a=l(e)?.tier;return"mobile"===a||"each"===a}var ee={},ne=e=>i.includes(e);function te(n,t){let l,r=i[0];const a=[],o=/* @__PURE__ */new Set;for(const[i,s]of Object.entries(n))s&&(ne(s.bucket)&&((s.marker||s.bucket!==r)&&(l=void 0),r=s.bucket),s.marker&&"string"==typeof s.fold?l={key:i,title:s.fold}:s.marker&&!1===s.fold&&(l=void 0),s.marker||!1===s.visible||t&&!e(s,t)||t&&!_(s,t.context?.device)||(a.push(l?{name:i,field:s,bucket:r,fold:l}:{name:i,field:s,bucket:r}),"slot"!==s.type&&o.add(r)));return{rows:a,buckets:i.filter(e=>o.has(e))}}function le(e){return new Map(te(e).rows.map(e=>[e.name,e.bucket]))}function re(e){const n=[];for(const t of e){const e=n[n.length-1];e&&e.fold?.key===t.fold?.key?e.rows.push(t):n.push({fold:t.fold,rows:[t]})}return n}function ae({fields:e,values:n,onChange:t,readOnly:l=!1,context:r,showWhenContext:a,tab:o,onTab:i,tabs:d=!0,tabIcons:u,renderers:m,idPrefix:h,ariaLabel:p,lead:b,children:g,leadFold:v,closedFolds:y,onFold:k,headingLevel:x=3}){const w=f("panel",c),C=F(),N=h??`es-insp${C.replace(/:/g,"")}`,S=te(e,{values:n,context:a}),[D,E]=I(void 0),M=o??D,A=M&&S.buckets.includes(M)?M:S.buckets[0],[T,W]=I(null),z=T&&T.panel===N&&S.rows.some(e=>e.name===T.name)?T:null,R=d&&S.buckets.length>1,H=R&&A?O(N,A):`${N}-rows`,[J,V]=I(()=>/* @__PURE__ */new Set),Y=y??J,K=(e,n)=>{/* @__PURE__ */return P(s,{title:e.title,open:!Y.has(e.key),onToggle:n=>((e,n)=>{void 0===y&&V(t=>{const l=new Set(t);return n?l.delete(e):l.add(e),l}),k?.(e,n)})(e.key,n),id:`${N}-fold-${t=e.key,[...t].map(e=>/[A-Za-z0-9_-]/.test(e)?e:`-u${e.codePointAt(0).toString(16)}-`).join("")}`,level:x,children:n});var t},B=e=>R&&e!==A,Z=({name:e,field:o,bucket:i,fold:s})=>/* @__PURE__ */P("div",{className:"es-insp-row","data-field":e,"data-bucket":i,hidden:!!B(i)||void 0,children:/* @__PURE__ */P(U,{field:o,name:e,id:`${N}-${e}`,value:n[e],onChange:n=>t(e,n),readOnly:l,context:r,showWhenContext:a,renderers:m,openItem:z&&z.name===e?z.index:null,onOpenItem:n=>W(null===n?null:{panel:N,name:e,index:n}),headingLevel:s?X(x):x})},e);/* @__PURE__ */
19
- return L("div",{className:"es-insp",children:[R?/* @__PURE__ */P("div",{className:"es-insp-tabs",children:/* @__PURE__ */P(j,{variant:"underline",block:!0,"aria-label":p??w.settings,idPrefix:N,value:A,onChange:e=>{const n=e;void 0===o&&E(n),i?.(n)},items:S.buckets.map(e=>{const n=w.buckets[e],t=u?.[e];return t?{id:e,icon:t,label:/* @__PURE__ */P("span",{className:"sr-only",children:n}),tooltip:n}:{id:e,label:n}})})}):null,
20
- /* @__PURE__ */L("div",{className:"es-insp-rows",id:H,role:R?"tabpanel":void 0,"aria-labelledby":R&&A?$(N,A):void 0,children:[b&&_(ee,a?.device)?v?/* @__PURE__ */P("div",{className:"es-insp-band","data-fold":v.key,children:K(v,b)}):b:null,re(S.rows).map((e,n)=>{if(!e.fold)return e.rows.map(Z);const t=e.rows[0].bucket,l=e.rows.every(e=>"slot"===e.field.type);/* @__PURE__ */
21
- return P("div",{className:"es-insp-band","data-fold":e.fold.key,"data-bucket":t,hidden:!(!B(t)&&!l)||void 0,children:K(e.fold,e.rows.map(Z))},`fold-${e.fold.key}-${n}`)}),g]})]})}export{R as FieldText,ae as Inspector,U as InspectorField,Z as ListField,le as bucketsOf,Y as copyItem,_ as fieldShownInView,H as insertAt,G as labelOf,J as moveTo,te as planFields,V as removeAt};
@@ -1,2 +0,0 @@
1
- import{routeSharedHostMessage as e}from"./chunk-ISS72IKO.js";import{describeLoadFailure as r,hostLoadRefusal as n}from"./chunk-ERR437B5.js";import{editLockOf as t}from"./chunk-GMCZXMOV.js";import{NO_DOCUMENT_ADDRESSING as o}from"./chunk-RLBXE4EU.js";import{saveStatusOf as u,resetForDocumentSwitch as a}from"./chunk-HNKB2ZYR.js";import{isExpiredSession as s,readEaselFailure as i}from"./chunk-CLOS6SSX.js";import{useAdminBridge as l}from"./chunk-NQW6XCAY.js";import{STATUS_UNREACHABLE as c}from"./chunk-KCOBHPN6.js";import{useEaselSession as d}from"./chunk-YM4UEGBV.js";import{backendOf as f,setSessionDocumentSite as m}from"./chunk-SNF5764Q.js";import{useEaselHost as k}from"./chunk-LX23TCTP.js";import{DEFAULT_SCREEN_WORDS as v}from"./chunk-IYHO4XQX.js";import{useAutosave as g}from"./chunk-NDRZP6YR.js";import{canWriteDocument as p,newEaselClientId as h,reloadIfVersionMoved as y,openUnansweredClaim as w,FAIL_OPEN_RETRY_MS as S,CLAIM_FAIL_OPEN_MS as b,holderOf as I}from"./chunk-THWO5YVZ.js";import{useWords as P}from"./chunk-MFIRYGHW.js";import{createContext as j,useContext as R,useState as B,useMemo as C,useCallback as E,useEffect as H,useRef as O}from"react";import{jsx as T}from"react/jsx-runtime";var N={content:[],root:{},zones:{}};var A=j(null);function M(){const e=R(A);if(!e)throw new Error("useStorefrontDocument must be used within StorefrontDocumentProvider");return e}function L({target:j,addressing:R=o,onHostMessage:M,children:L}){const Y=R,{homeSlug:D,entryMayBounce:F,entryBounce:V,onSwitch:X,tellsHost:W,adapterFor:K,migrateRenamedProps:U,describeMissing:Z,onLoadFailed:x}=Y,[G,Q]=B(j),z=k(),_=d(),q=C(()=>f(_),[_]),J=C(()=>t(_),[_]),$="template"===G.kind,ee="template"===G.kind?G.id:null,re="template"===G.kind?G.pageSlug??D??"":"document"===G.kind?G.slug??"":G.slug,ne="page"===G.kind?G.siteId??null:null,te=_.blocks,oe=C(()=>K(G,q,te),[K,q,te,G.kind,"template"===G.kind?G.id:"document"===G.kind?G.record:G.siteId]),ue=oe.capabilities,ae=E(e=>_.documentHooks?.stored?.(e)??e,[_]);H(()=>{m(_,ne)},[_,ne]);const se=O(G);H(()=>{se.current=G},[G]);const{token:ie,tokenRef:le,capabilities:ce}=l({onMessage:r=>{if(M?.(r)||e(r))return;const n=r;if("storefront-editor:navigate"===n?.type){const e=r;e?.target&&Br(e.target)}}}),de=!_.usesBridgedToken||null!==ie,fe=oe.lock,me=Boolean(q.lock),[ke,ve]=B(null),[ge,pe]=B(null),[he,ye]=B(null),[we,Se]=B(null),be=P("screen",v),Ie=we?function(e,r){if(null!==e.sentence)return e.sentence;if(!e.missing)return r.loadFailed({cause:e.cause});switch(e.target.kind){case"template":return r.missingTemplatePage;case"document":return r.missingDocument;default:return r.missingPage({slug:e.slug})}}(we,be):null,[Pe,je]=B(null),Re=O(null),Be=O(null),[Ce,Ee]=B(!1),He=O(null),[Oe,Te]=B(null),Ne=O(null),[Ae,Me]=B(null),[Le,Ye]=B(!1),De=O(null);H(()=>{De.current=Ae},[Ae]);const[Fe,Ve]=B(ue.hasEditLock?{kind:"checking"}:{kind:"editing"}),Xe=O(Fe);H(()=>{Xe.current=Fe},[Fe]);const We=O(()=>Promise.resolve(!1)),Ke=E(e=>{Be.current=e,Ee(!0)},[]),Ue=g({save:async({id:e,data:r})=>{if(p(Xe.current)){if(!await We.current(e,r)){if(!p(Xe.current))return void Ke({id:e,data:r});throw new Error("page save did not land")}}else Ke({id:e,data:r})},onFailure:(e,r)=>{0===r&&z.send("storefront-editor:save-failed")}}),{state:Ze,push:xe,flush:Ge,pause:Qe,resume:ze,stop:_e,reset:qe,retryNow:Je,hasPending:$e}=Ue,er=O(Ze);H(()=>{er.current=Ze},[Ze]);const rr=u(Ze),nr=E(()=>{const e=Be.current;e&&(Be.current=null,Ee(!1),xe(e))},[xe]),tr=O("");tr.current||(tr.current=h());const[or,ur]=B(0),ar=O(!1),[sr,ir]=B(F(j)),lr=O(!1);H(()=>{if(lr.current)return;lr.current=!0;const e=z.address.search(),r=V(j,e);r?z.address.load(r):F(j)&&ir(!1)},[j,z]);const cr=z.send;H(()=>{if(!de)return;let e=!1;const t=se.current,o=oe.resolve(re),u=_.documentHooks?.opening?.({slug:re,isTemplate:$,capabilities:ue});return o.then(async r=>{if(e)return;if(!r)return"page"===t.kind&&null!==D&&re!==D?void z.address.load({kind:"page",slug:D,siteId:ne??void 0}):(Se({target:t,slug:re,missing:!0,sentence:Z?.(t)??null}),void x?.(t,null));const n=r.readOnlyReason?r.readOnlyReason:null;Re.current=n,je(n),ve(r.id),pe(r.kind??null),Ne.current=r.version??null;const o=r.layout,a=o&&Object.keys(o).length?o:N,s=U(a),i=u?await u(s):s;e||ye(i)}).catch(o=>{e||(console.error("[storefront-editor] document load failed",o),Se({target:t,slug:re,missing:!1,sentence:n(o,{slug:re},_),cause:r(o,_)}),x?.(t,o))}),()=>{e=!0}},[de,ie,$,oe,re]);const dr=E(e=>new Promise(r=>{const n=Date.now(),t=setInterval(()=>{const o=le.current;o&&o!==e?(clearInterval(t),r(o)):Date.now()-n>6e3&&(clearInterval(t),r(null))},200)}),[]),fr=E(async e=>{const r=le.current;if(!r&&_.usesBridgedToken)return{ok:!1,error:new Error("no editor token")};try{return{ok:!0,value:await e(r??"")}}catch(n){if(s(n,_)){cr("storefront-editor:auth-expired");const n=r?await dr(r):null;if(n)try{return{ok:!0,value:await e(n)}}catch(e){return{ok:!1,error:e}}}return{ok:!1,error:n}}},[cr,dr,_]),mr=E(async e=>{const r=le.current?await fr(e):{ok:!1};return r.ok||cr("storefront-editor:save-failed"),r.ok},[cr,fr]),kr=E(async(e,r,n=!1)=>{if(null!==Re.current)return!1;if(!p(Xe.current))return!1;if(De.current)return!1;const t=await fr(()=>oe.saveLayout(e,r,Ne.current,tr.current));if(t.ok)return Ne.current=t.value.version??Ne.current,Ye(!1),!0;const o=J.readLockTaken(t.error);if(o){const e={kind:"takenover",holder:o};return Xe.current=e,Ve(e),!1}const u=J.readSaveConflict(t.error);if(u){if(u.savedByYou&&!n&&oe.rereadVersion){const n=await fr(()=>oe.rereadVersion(e));if(n.ok&&n.value)return Ne.current=n.value,We.current(e,r,!0)}_e(),De.current=u,Me(u)}return Ye(i(t.error,_)?.status===c),!1},[oe,fr,_e,_]);H(()=>{We.current=kr},[kr]);const vr=E(e=>{if(null!==Re.current)return;if(cr("storefront-editor:dirty"),!ke)return;const r=ae(e);He.current=r,p(Xe.current)?xe({id:ke,data:r}):Ke({id:ke,data:r})},[ke,cr,Ke,xe,ae]),gr=E(async()=>{p(Xe.current)&&nr();return await Ge()&&null==Be.current},[nr,Ge]),pr=O(gr);H(()=>{pr.current=gr},[gr]);const hr=O(fr);H(()=>{hr.current=fr},[fr]);const yr=E(()=>{z.address.reload()},[z]),wr=O(()=>Promise.resolve(!1));H(()=>{wr.current=()=>{const e=oe.rereadVersion;return ke&&e?y({ours:Ne.current,stored:async()=>{const r=await hr.current(()=>e(ke));return r.ok?r.value:null},hasPending:()=>null!=Be.current||$e(),reload:yr}):Promise.resolve(!1)}},[oe,ke,$e,yr]);const Sr=null!==Pe;H(()=>{if(!fe||!ke||!de||Sr)return;let e=!1,r=null,n=null;const t=tr.current,o={claim:async e=>{const r=await hr.current(()=>fe.claim(ke,t,e));if(r.ok)return{heartbeat_seconds:r.value.heartbeatSeconds};throw r.error},cancelled:()=>e,currentAccess:()=>Xe.current,heldWrite:()=>({pending:null!=Be.current||$e(),autoSaveEnabled:!er.current.paused,saveConflict:null!=De.current}),setAccess:e=>{Xe.current=e,Ve(e)},releaseHeldWrite:()=>{pr.current()},startHeartbeat:e=>{r&&clearInterval(r),r=setInterval(()=>{u(!1)},e)},stopHeartbeat:()=>{r&&(clearInterval(r),r=null)},reloadIfMoved:()=>{wr.current()}},u=J.makeClaimBeat(o),a=ar.current;return ar.current=!1,a||(Ve({kind:"checking"}),n=setTimeout(()=>{n=null,w(o)&&o.startHeartbeat(S)},b)),u(a).finally(()=>{n&&clearTimeout(n),n=null}),()=>{e=!0,n&&clearTimeout(n),r&&clearInterval(r),fe.release(ke,t).catch(()=>{})}},[ke,fe,de,ie,or,Sr]);const br=E(()=>{fe&&ke&&(ar.current=!0,ur(e=>e+1))},[ke,fe]),Ir=E(()=>{Ve(e=>{const r="blocked"===e.kind||"takenover"===e.kind?e.holder:null;return r?{kind:"readonly",holder:r}:e})},[]),Pr=E(()=>{er.current.paused?(p(Xe.current)&&nr(),ze()):Qe()},[nr,Qe,ze]),jr=E(()=>{Je()},[Je]),Rr=E(e=>{He.current=null,a("template"!==e.kind&&me,{resetAutosave:()=>{qe(),Be.current=null,Ee(!1)},setVersion:e=>{Ne.current=e},setSaveConflict:Me,setAccess:Ve}),X(e),Q(e),Re.current=null,je(null),ve(null),pe(null),ye(null),Se(null),z.address.show(e),"document"!==e.kind&&W(e)&&z.send("storefront-editor:navigated",{target:e})},[qe,z,me,X,W]),Br=E(e=>{if(function(e,r,n){if(e.kind!==r.kind)return!1;if("template"===e.kind){const t=r;return e.id===t.id&&(e.pageSlug??n)===(t.pageSlug??n)}if("document"===e.kind){const n=r;return e.record===n.record&&(e.slug??"")===(n.slug??"")}const t=r;return e.slug===t.slug&&e.siteId===t.siteId}(e,se.current,D))return;const r=null!=Be.current;if(!r&&!$e())return void Rr(e);const n=er.current;r||n.paused||n.failed||n.stopped?Te(e):Ge().then(r=>{r?Rr(e):Te(e)})},[Rr,$e,Ge,D]),Cr=E(()=>Te(null),[]),Er=E(()=>{Te(e=>(e&&Rr(e),null))},[Rr]),Hr=E(async()=>{const e=Oe;if(!e)return;await gr()&&(Te(null),Rr(e))},[Oe,gr,Rr]),Or=E(async e=>{if(null!==Re.current)return;if(!ke)return;if(!p(Xe.current)||De.current)return;const r=ae(e);if(!await kr(ke,r))return void(De.current||cr("storefront-editor:save-failed"));const n=oe.publish;if(!ue.canPublish||!n)return void cr("storefront-editor:saved");const t=await fr(()=>n(ke,Ne.current??void 0));if(!t.ok){const{error:e}=t;return void cr("storefront-editor:publish-failed",{reason:e instanceof Error&&e.message?e.message:null})}Ne.current=t.value.version??Ne.current,cr("storefront-editor:published")},[ke,oe,ue.canPublish,cr,kr,fr,ae]);/* @__PURE__ */
2
- return T(A.Provider,{value:{target:G,adapter:oe,capabilities:ue,templateId:ee,currentSlug:re,currentKind:ge,siteId:ne,ready:de,token:ie,tokenRef:le,notifyParent:cr,bridgeCapabilities:ce,runAuthed:mr,docId:ke,data:he,getLiveData:()=>He.current??he,error:Ie,redirecting:sr,saveStatus:rr,saveState:Ze,autoSaveEnabled:!Ze.paused,autoSaveStoppedByConflict:Ze.stopped,hasUnsavedEdits:Ze.pending||Ce,toggleAutoSave:Pr,retrySave:jr,onChange:vr,flushSave:gr,onPublish:Or,access:Fe,readOnly:null!==I(Fe)||null!==Pe||null!==Ae,readOnlyReason:Pe,takeOverEditing:br,viewReadOnly:Ir,saveConflict:Ae,saveUnreachable:Le,reloadFromServer:yr,navigate:Br,pendingNav:Oe,cancelPendingNav:Cr,discardAndNavigate:Er,saveAndNavigate:Hr},children:L})}export{A as ScreenDocumentContext,L as ScreenDocumentProvider,M as useScreenDocument};
@@ -1 +0,0 @@
1
- import{MARKUP_TOOLS as e,MARK_PLACEHOLDERS as t}from"efficient-shell/markup";var i={formatting:"Formatting",alignment:"Alignment",marks:{...Object.fromEntries(e.map(e=>[e.style,{name:e.name??e.title,title:e.title}])),underline:{name:"Underline",title:"Underline · [words]{underline}"},sup:{name:"Superscript",title:"Superscript · [words]{sup}"},sub:{name:"Subscript",title:"Subscript · [words]{sub}"}},placeholders:t,showMarks:"Show marks",colors:{title:"Color",theme:"Theme colors",remove:"Remove",any:"Any color",square:"Saturation and brightness",hue:"Hue",hex:"Hex color"},panel:{style:"Style",editStyles:"Edit styles",updateStyle:"Update style",font:"Font",italic:"Italic",list:"List",lists:{none:"No list",bullet:"Bulleted",number:"Numbered"},capitalization:"Capitalization",cases:{none:"As typed",upper:"Uppercase",capitalize:"Capitalized",lower:"Lowercase"}},cells:{fontSize:"Font size",lineHeight:"Line spacing",letterSpacing:"Letter spacing",paragraphSpacing:"Paragraph spacing",tip:({name:e,step:t,unit:i})=>`${e} · step ${t} ${i} · Shift ×10`}};export{i as DEFAULT_COPY_WORDS};
@@ -1 +0,0 @@
1
- var t="data-sf-repeat",e="data-sf-repeat-index",r=`[${t}][${e}]:not([${e}="0"])`;function n(t){return null!==t.closest(r)}function l(t){let e=null;for(const r of t){if(!n(r))return r;e??=r}return e}function o(t,e){return l(t.querySelectorAll(e))}function u(t,e){const r=[...t.querySelectorAll(e)],o=l(r);return o?[o,...r.filter(t=>t!==o&&n(t))]:[]}export{t as REPEAT_ATTRIBUTE,e as REPEAT_INDEX_ATTRIBUTE,n as isRepeatCopy,l as mainCopyOf,u as queryAllCopies,o as queryMainCopy};
@@ -1,18 +0,0 @@
1
- import{DEFAULT_DRAG_WORDS as e}from"./chunk-TQ5Y6S2X.js";import{dropEffectFor as t,scrollBoxOf as n,frameScrollBox as l,startAutoScroll as r,isNoOpDrop as a}from"./chunk-6NJHYXJM.js";import{withTip as s}from"./chunk-P2VEMZH5.js";import{useCanvasLayout as o,useCanvasTyping as i,useCanvasEvent as c,CANVAS_TYPABLE_EVENT as d,framePointToHost as u,elementScale as h,related as f,WORDS_CLEAR as p,frameRectToLayer as m,clientPointToLayer as g}from"./chunk-YU3WHLGI.js";import{isRepeatCopy as b}from"./chunk-LF3FUSCQ.js";import{parseZoneKey as y,ROOT_ID as x}from"./chunk-TGZCD6IP.js";import{useRef as v,useEffect as w,useState as k,useCallback as N,useMemo as D,useSyncExternalStore as A,useId as z,useLayoutEffect as T}from"react";import{Tooltip as M,IconButton as C,solidSurfaceStyle as $,Input as S,ItemCount as E}from"efficient-shell/ui";import{AddIcon as j,CloseIcon as L,SearchIcon as B}from"efficient-shell/icons/efficient";import{jsxs as I,jsx as O}from"react/jsx-runtime";function Y({label:e,onInsert:t,style:n,axis:l="y",className:r,index:a}){const s=["es-canvas-insert","x"===l?"is-x":"",r??""].filter(Boolean).join(" ");/* @__PURE__ */
2
- return I("div",{className:s,style:n,"data-index":a,children:[
3
- /* @__PURE__ */O("span",{className:"es-canvas-insert-line","aria-hidden":"true"}),
4
- /* @__PURE__ */O("span",{className:"es-canvas-insert-chip",children:/* @__PURE__ */O(M,{content:e,children:/* @__PURE__ */O(C,{variant:"ghost",size:"sm","aria-label":e,onClick:t,children:/* @__PURE__ */O(j,{})})})})]})}var X=(e,t,n)=>t>=e.left&&t<=e.left+e.width&&n>=e.top&&n<=e.top+e.height,q=e=>e.width*e.height;function K(e,t,n){return e.map((e,t)=>({s:e,at:t})).filter(({s:e})=>X(e.box,t,n)).sort((e,t)=>q(t.s.box)-q(e.s.box)||e.at-t.at).map(({s:e})=>e)}function H(e,t,n){return K(e,t,n).at(-1)??null}function P(e,t,n){const l="x"===e.axis?t:n;let r=0;for(const t of e.children){l>("x"===e.axis?t.left+t.width/2:t.top+t.height/2)&&(r+=1)}return r}function Z(e,t){const n=e.children;if("x"===e.axis){const l=n[t-1],r=n[t],a=l&&r?(l.left+l.width+r.left)/2:l?l.left+l.width:r?r.left:e.box.left,s=r??l??e.box;return{left:a-1,top:s.top,width:2,height:s.height}}const l=n[t-1],r=n[t],a=l&&r?(l.top+l.height+r.top)/2:l?l.top+l.height:r?r.top:e.box.top;return{left:e.box.left,top:a-1,width:e.box.width,height:2}}function F(e,t,n,l,r=()=>!1,a=()=>!0){const s=e.filter(e=>X(e.box,t,n)).sort((e,t)=>q(e.box)-q(t.box));for(const e of s){const s=P(e,t,n),o={...e.list,index:s};if(r(o))return null;if(l(o))return{zone:e,to:o,line:Z(e,s)};if(!a(o))return null}return null}function G(e,t,n=12){const l=e.children;if(0===l.length)return[];const r=e.box,a="x"===e.axis,s=a?r.left:r.top,o=s+(a?r.width:r.height),i=e=>a?e.left:e.top,c=e=>a?e.left+e.width:e.top+e.height,d=[];for(let r=0;r<=l.length;r++){const u=l[r-1],h=l[r];let f,p;if(u&&h)f=c(u),p=Math.max(i(h)-f,0);else{const e=u?(c(u)+o)/2:(s+i(h))/2,t=Math.min(Math.max(e,s+n),o-n);f=u?Math.max(t,c(u)):Math.min(t,i(h)),p=0}const m=[u,h].filter(e=>Boolean(e)),g=Math.min(...m.map(e=>a?e.top:e.left)),b=Math.max(...m.map(e=>a?e.top+e.height:e.left+e.width)),y=a?{left:f,top:g,width:p,height:b-g}:{left:g,top:f,width:b-g,height:p};d.push({key:`${e.key}:+${r}`,place:{...e.list,index:r},box:y,axis:e.axis,label:t})}return d}function J(e,t=e.key){const n=[];for(let l=1;l<e.children.length;l++){const r=e.children[l-1],a=e.children[l],s=r.top+r.height;n.push({key:`${t}:${l}`,place:{...e.list,index:l},box:{left:e.box.left,top:s,width:e.box.width,height:Math.max(a.top-s,0)}})}return n}var Q={nodes:[],zones:[]},R="data-easel-dropzone",U="data-easel-block";function V(e){const t=e.getBoundingClientRect();return{left:t.left,top:t.top,width:t.width,height:t.height}}function W(e,t){if(e.length>=2){const[t,n]=e;return Math.abs(n.top-t.top)<Math.min(t.height,n.height)/2&&n.left>t.left?"x":"y"}const n=t.ownerDocument.defaultView?.getComputedStyle(t);return n&&n.display.includes("flex")&&n.flexDirection.startsWith("row")?"x":"y"}function _(e,t,n){return m(e.frame,V(n),t)}function ee(e,t){const{frame:n,document:l}=e,r=e=>m(n,V(e),t),a=[],s=[];for(const e of l.querySelectorAll(`[${R}]`)){if(b(e))continue;const t=e.getAttribute(R)??"";let n;try{n=y(t)}catch{continue}const l=[...e.querySelectorAll(`[${U}]`)].filter(t=>t.parentElement?.closest(`[${R}]`)===e&&!b(t)),o=l.map(r);s.push({key:t,list:n,box:r(e),axis:W(o,e),children:o}),l.forEach((e,t)=>{const l=e.getAttribute(U);l&&a.push({id:l,place:{...n,index:t},box:o[t]})})}return{nodes:a,zones:s}}var te="data-es-empty-cell",ne="data-easel-dropzone",le=140;var re=e=>({left:e.left,top:e.top,width:e.width,height:e.height}),ae=e=>({left:e.left+2,top:Math.max(e.top-11,0)});function se(s){const{canvas:m,session:b,readOnly:y,words:z=e.canvas}=s,C=v(s);w(()=>{C.current=s});const S=v(null),E=o(m),[j,L]=k(0),B=N(()=>L(e=>e+1),[]),[X,q]=k(Q);w(()=>{const e=S.current;m&&e&&q((C.current.measure??ee)(m,e))},[m,E,s.revision,j]);const H=s.model,P=D(()=>H(X),[H,X]),Z=A(b.subscribe,b.shown,b.shown),G=s.choose,J=(e,t)=>{const n=K(P.sources,e,t);return 0===n.length?null:G?G(n):n[n.length-1]},[R,U]=k(null),[V,W]=k(null),[le,se]=k(null),oe=v(null),ie=()=>{oe.current&&clearTimeout(oe.current),oe.current=null},ce=()=>{ie(),oe.current=setTimeout(()=>{b.get()||U(null)},140)};w(()=>ie,[]);const de=v(null),ue=i(m),he=v(!1);he.current=ue;const[fe,pe]=k(null),me=v(null),ge=v(R);ge.current=R,w(()=>{ue?(pe(ge.current?.key??me.current?.id??null),ie(),U(null)):pe(null)},[ue]);const[be,ye]=k(null);c(m,d,e=>{const t=e.detail?.id??null,n=t?{id:t,words:e.detail?.words??null}:null;ye(n),n&&(me.current=n)});const xe=e=>{if(!(e&&e.isConnected&&m&&S.current))return null;const t=_(m,S.current,e);return{left:t.left-p,top:t.top-p,width:t.width+2*p,height:t.height+2*p}},ve=!be||ue||y||Z?null:xe(be.words)??X.nodes.find(e=>e.id===be.id)?.box??null;c(m,"mousemove",e=>{const t=S.current;if(!m||!t)return;const n=u(m.frame,e.clientX,e.clientY,t),l=h(t),r={x:n.x/l,y:n.y/l};if(de.current=r,C.current.readOnly||b.get()||he.current)return;ie();const a=J(r.x,r.y);U(e=>e?.key===a?.key&&e?.box===a?.box?e:a)}),c(m,"mouseout",e=>{e.relatedTarget||(de.current=null,ce())}),c(m,"mouseover",e=>{e.relatedTarget||B()});const we=v(null),ke=N(()=>{we.current?.(),we.current=null,W(null),se(null)},[]);w(()=>b.subscribe(()=>{b.get()?B():ke()}),[b,ke,B]),w(()=>ke,[ke]),("undefined"==typeof document?w:T)(()=>{if(b.get())return;const e=de.current;U(t=>y||he.current?null:e?J(e.x,e.y):t?P.sources.find(e=>e.key===t.key)??null:null)},[P,Z,b,y,G]);const Ne=e=>{const t=b.get(),n=S.current,l=C.current.dropOn;if(!t||!n||!l)return null;const r=g(n,e.clientX,e.clientY);de.current=r;const a=K(P.sources,r.x,r.y);for(let e=a.length-1;e>=0;e-=1)if(l.accepts(t.item,a[e]))return{h:t,source:a[e]};return null},De=e=>{const t=b.get(),n=S.current;if(!t||!n)return null;const l=g(n,e.clientX,e.clientY);de.current=l;const r=F(P.zones,l.x,l.y,e=>C.current.canDrop(t.item,e),e=>!!t.from&&a(t.from,e),e=>C.current.fallThrough?.(t.item,e,t.from)??!0);return r?{h:t,t:r}:null},Ae={onDragEnter:e=>{if(we.current)return;const t=n(e.currentTarget.parentElement?.parentElement??null),a=m?l(m.document):null,s=[];t&&s.push(r(t)),a&&m&&s.push(r(a,m.frame)),we.current=s.length?()=>s.forEach(e=>e()):null},onDragOver:e=>{const n=Ne(e);if(n)return e.preventDefault(),e.dataTransfer.dropEffect=t(e.dataTransfer.effectAllowed),W(null),void se(e=>e&&e.key===n.source.key&&e.box===n.source.box?e:n.source);se(null);const l=De(e);if(!l)return void W(null);e.preventDefault(),e.dataTransfer.dropEffect=t(e.dataTransfer.effectAllowed);const r={zoneKey:l.t.zone.key,line:l.t.line,axis:l.t.zone.axis};W(e=>e&&e.zoneKey===r.zoneKey&&e.line.left===r.line.left&&e.line.top===r.line.top?e:r)},onDragLeave:e=>{const t=e.relatedTarget;t&&e.currentTarget.contains(t)||(de.current=null,W(null),se(null))},onDrop:e=>{const t=Ne(e);if(t)return e.preventDefault(),b.end(),ke(),void C.current.dropOn.onDrop(t.h.item,t.source);const n=De(e);n&&(e.preventDefault(),b.end(),ke(),C.current.onDrop(n.h.item,n.t.to))}},ze={draggable:!y&&!!R,onMouseEnter:ie,onMouseLeave:()=>!b.get()&&ce(),onDragStart:e=>{if(R&&!y){b.start({key:R.key,item:R.item,from:R.from}),e.dataTransfer.effectAllowed="move";try{e.dataTransfer.setData("text/plain",R.key)}catch{}}else e.preventDefault()},onDragEnd:()=>{b.end(),ke()},onClick:()=>{R&&!y&&C.current.onPick?.(R.item)}},{seams:Te=[]}=P,Me=be?.words??(ue?me.current?.words??null:null),Ce=s.tag&&m&&S.current&&!Z?(Me&&f(s.tag.element,Me)?xe(Me):null)??_(m,S.current,s.tag.element):null,$e=R?(be&&be.id===R.key?xe(be.words):null)??R.box:null,Se=ue&&fe&&!s.tag?P.sources.find(e=>e.key===fe)??null:null,Ee=Se?xe(Me)??Se.box:null,je=P.zones.filter(e=>0===e.children.length),Le=!s.onZoneAdd||y||ue?[]:je,Be=Le.map(e=>e.key).join("\n");return w(()=>{const e=m?.document;if(!e)return;const t=new Set(Be?Be.split("\n"):[]);for(const n of e.querySelectorAll(`[${ne}]`))n.toggleAttribute(te,t.has(n.getAttribute(ne)??""));return()=>{for(const t of e.querySelectorAll(`[${te}]`))t.removeAttribute(te)}},[m,Be,X,E,j]),/* @__PURE__ */I("div",{ref:S,className:"es-canvas-layer",children:[Z||!s.onSeamAdd||y||ue?null:Te.map(e=>
5
- /* @__PURE__ */O(Y,{className:"es-canvas-seam",axis:e.axis,index:e.place.index,label:e.label??s.seamLabel??z.addSection,onInsert:()=>s.onSeamAdd?.(e.place),style:"x"===e.axis?{left:e.box.left+e.box.width/2-12,top:e.box.top,width:24,height:e.box.height}:{left:e.box.left,top:e.box.top+e.box.height/2-12,width:e.box.width,height:24}},e.key)),Le.length?Le.map(e=>/* @__PURE__ */O("button",{type:"button",className:["es-canvas-empty",e.addAlways?"is-always":"",V?.zoneKey===e.key?"is-over":""].filter(Boolean).join(" "),style:re(e.box),"data-node-id":e.list.parentId===x?void 0:e.list.parentId,onClick:()=>s.onZoneAdd?.({...e.list,index:0}),children:/* @__PURE__ */O("span",{className:"es-canvas-empty-add",children:z.addButton({label:e.addLabel??s.zoneAddLabel??z.addBlock})})},e.key)):null,Z?/* @__PURE__ */O("div",{className:"es-canvas-catch",...Ae}):null,le&&Z?/* @__PURE__ */O("div",{className:"es-canvas-target",style:re(le.box),children:s.dropOn?.label?/* @__PURE__ */O("span",{className:"es-canvas-target-label",style:$(),children:s.dropOn.label(Z.item,le)}):null}):null,V&&!je.some(e=>e.key===V.zoneKey)?/* @__PURE__ */O("div",{className:`es-canvas-line is-${V.axis}`,style:re(V.line)}):null,ve?/* @__PURE__ */O("span",{className:"es-canvas-hint"+(ve.width<200?" is-below":""),style:{...$(),left:ve.left+ve.width,top:ve.width<200?ve.top+ve.height:ve.top},children:z.typeHint}):null,Ce&&s.tag?/* @__PURE__ */O("span",{className:"es-canvas-tag",style:ae(Ce),children:s.tag.label}):Se&&Ee?/* @__PURE__ */O("span",{className:"es-canvas-tag",style:ae(Ee),children:Se.label}):null,
6
- /* @__PURE__ */O("div",{className:"es-canvas-handle-spot",style:$e?{"--es-handle-x":`${ae($e).left}px`,"--es-handle-y":`${ae($e).top}px`}:void 0,children:/* @__PURE__ */O(M,{className:"es-canvas-handle-tip",side:"top",content:!R||y||Z?null:R.title??z.handle({label:R.label}),children:/* @__PURE__ */I("div",{className:["es-canvas-handle",R&&!y?"is-shown":"",Z?"is-dragging":""].filter(Boolean).join(" "),...ze,children:[
7
- /* @__PURE__ */O("span",{className:"es-canvas-grip","aria-hidden":"true",children:"⋮⋮"}),R?.label]})})})]})}var oe=e=>e.tiles.length>0&&e.tiles.every(e=>null!=e.cover);function ie({groups:t,session:n,itemFor:l,onInsert:r,onTileMenu:a,at:o,hint:i,searchLabel:c,readOnly:d,words:u=e.add}){const h=i??u.hint,f=c??u.search,[p,m]=k(""),g=z(),b=p.trim().toLowerCase(),y=function(e){const t=/* @__PURE__ */new Map;return e.map(e=>{const n=e.key??e.title,l=t.get(n)??0;return t.set(n,l+1),0===l?n:`${n}\0${l}`})}(t),x=t.map((e,t)=>({...e,key:y[t],tiles:b?e.tiles.filter(e=>((e,t)=>e.label.toLowerCase().includes(t)||(e.keywords??[]).some(e=>e.toLowerCase().includes(t)))(e,b)):e.tiles})).filter(e=>e.tiles.length>0),v=(e,t)=>r=>{if(t)r.preventDefault();else{n.start({key:`new:${e}`,item:l(e)}),r.dataTransfer.effectAllowed="copy";try{r.dataTransfer.setData("text/plain",e)}catch{}}};/* @__PURE__ */
8
- return I("div",{className:"es-add",children:[o?/* @__PURE__ */I("div",{className:"es-add-at",role:"status",children:[
9
- /* @__PURE__ */O("span",{children:o.label}),s(u.stop,/* @__PURE__ */O("button",{type:"button",className:"es-add-at-clear","aria-label":u.stop,onClick:o.onClear,children:/* @__PURE__ */O(L,{size:12,"aria-hidden":"true"})}))]}):null,
10
- /* @__PURE__ */O("p",{className:"es-add-hint",children:h}),
11
- /* @__PURE__ */O("div",{className:"es-add-find",children:/* @__PURE__ */O(S,{id:g,type:"search","aria-label":f,placeholder:u.searchPlaceholder({label:f}),value:p,onChange:e=>m(e.target.value),leftIcon:/* @__PURE__ */O(B,{size:16,"aria-hidden":"true"}),rightAdornment:p?/* @__PURE__ */O(C,{size:"sm","aria-label":u.clearSearch,onClick:()=>m(""),children:/* @__PURE__ */O(L,{size:12,"aria-hidden":"true"})}):void 0})}),0===x.length?/* @__PURE__ */I("div",{className:"es-add-empty",role:"status",children:[
12
- /* @__PURE__ */O("div",{className:"es-add-empty-title",children:u.nothing({query:p.trim()})}),
13
- /* @__PURE__ */O("div",{className:"es-add-empty-sub",children:u.tryAnother})]}):x.map(e=>/* @__PURE__ */I("section",{className:"es-add-group","aria-label":e.title,children:[
14
- /* @__PURE__ */I("div",{className:"es-add-group-head",children:[
15
- /* @__PURE__ */O("span",{className:"es-add-group-title",children:e.title}),
16
- /* @__PURE__ */O(E,{count:e.tiles.length,label:u.count({count:e.tiles.length,sections:oe(e)}),className:"ml-auto"})]}),
17
- /* @__PURE__ */O("div",{className:oe(e)?"es-add-grid is-cards":"es-add-grid",children:e.tiles.map(e=>{const t=Boolean(d||e.disabled),l=d?void 0:e.disabled?e.disabledReason:e.title??u.tile({label:e.label});return s(l,/* @__PURE__ */I("button",{type:"button",className:null!=e.cover?"es-add-tile has-cover":"es-add-tile",draggable:!t,"aria-disabled":t||void 0,"aria-label":u.tile({label:e.label}),onDragStart:v(e.type,t),onDragEnd:()=>n.end(),onClick:()=>!t&&r?.(e.type),onContextMenu:a?t=>{a(e.type,{x:t.clientX,y:t.clientY,owner:t.currentTarget})&&t.preventDefault()}:void 0,children:[null!=e.cover?/* @__PURE__ */O("span",{className:"es-add-tile-cover","aria-hidden":"true",children:e.cover}):e.icon?/* @__PURE__ */O("span",{className:"es-add-tile-glyph","aria-hidden":"true",children:e.icon}):null,
18
- /* @__PURE__ */I("span",{className:"es-add-tile-label",children:[e.label,null!=e.mark?/* @__PURE__ */O("span",{className:"es-add-tile-mark","aria-hidden":"true",children:e.mark}):null]})]},e.type))})})]},e.key))]})}export{ie as AddPanel,se as CanvasDragLayer,Y as CanvasInsert,Q as EMPTY_MEASURE,le as HANDLE_GRACE_MS,F as canvasTarget,X as contains,P as gapInZone,Z as gapLine,G as insertSeams,ee as measureCanvas,H as pickSource,J as seamsBetween,K as sourcesAt};
@@ -1,5 +0,0 @@
1
- import{usePickFollowsSelection as n}from"./chunk-NCXYC7WI.js";import{slotFieldsOf as e,slotChildrenIn as t}from"./chunk-TCAAOYQY.js";import{EaselCanvas as r,useSelectedFields as o}from"./chunk-FJTCSQWK.js";import{Inspector as i}from"./chunk-H4Z2V56N.js";import{fieldIsShown as u}from"./chunk-BPXEFVSQ.js";import{createContext as l,useContext as s}from"react";import{DesktopIcon as c}from"efficient-shell/icons/efficient";import{jsx as f}from"react/jsx-runtime";var a={kind:"selection"};function d(n){return"selection"===n.kind}function p(n,e){if(d(n)&&d(e))return!0;const t=n,r=e,o=Object.keys(t);return o.length===Object.keys(r).length&&o.every(n=>Object.is(t[n],r[n]))}function m(n){const e=n;return"string"==typeof e.nodeId&&"string"==typeof e.slot}function k(n,t){const r=n.components?.[t.type]?.fields??{};return e(n,t.type).filter(n=>u(r[n],{values:t.props}))}function h(n,e){return k(n,e).flatMap(n=>t(e,n))}function v(n,e,t){const r=n.slotsOf?.(t);return r||k(e,t).map(n=>({slot:n,label:n,rung:!1}))}function y(n,e){return n.isFirst?n.isFirst(e):e.type===n.first}function g(n,e){return n.isLast?n.isLast(e):e.type===n.last}var b={},O=()=>b,j=()=>"",C=()=>null,S=()=>{},w={isLockedBlock:()=>!1,duplicateBlocked:()=>null,nestDepth:()=>0,newSectionNode:()=>null,canAddTo:()=>null,blockIsOffered:()=>!0},L={labelAtLevel:(n,e,t)=>t,descriptions:{},categoryLabel:()=>{},firstSection:null,blockRowName:(n,e)=>e(n.type),plainText:n=>n,Icon:()=>null,Thumbnail:()=>null,useProducts:()=>null},N={options:[{id:"desktop",label:"Desktop",icon:/* @__PURE__ */f(c,{})}],initial:"desktop",fluid:"desktop",widths:{desktop:2e3}},P={read:()=>"sections",write:()=>{},forSelection:(n,e)=>n?"sections":e},B={first:null,last:null,firstGroup:null,lastGroup:null,isSectionGroup:()=>!1,sectionGroupZone:()=>"",panelOf:()=>null};function D(){/* @__PURE__ */
2
- return f(r,{height:"fill"})}function F(){const{id:n,fields:e,values:t,readOnly:r,onChange:u}=o();/* @__PURE__ */
3
- return f("div",{className:"es-sidepanel es-sidepanel--right",children:/* @__PURE__ */f(i,{fields:e,values:t,onChange:u,readOnly:r,idPrefix:n})})}var I=l({});function T({parts:n,children:e}){/* @__PURE__ */
4
- return f(I.Provider,{value:n,children:e})}function x(){return s(I)}function A(){return(x().useOwnerName??j)()}function G(){return(x().useDocumentLabel??C)()}function Q(n,e,t,r){return(x().useBridges??O)(n,e,t,r)}function V(n){return(x().useStandaloneBridges??O)(n)}function Y(n,e){(x().useDocumentPass??S)(n,e)}function H(){return x().blockRules??w}function K(){return x().blockLook??L}function R(){return x().devices??N}function W(){return x().leftView??P}function X(){return x().pinned??B}function Z(){return x().saveSwitch??!0}function E(e){n(!0===x().pickFollowsSelection,e)}function J(){return x().storageNamespace||void 0}function M(){return x().styleClipboard??null}function q(){return x().nodeKeys??!0}function z(){return x().notify??null}function U(){return x().Canvas??D}function $(){return x().CanvasHead??null}function _(){return x().canvasDrag??null}var nn=l(null);function en({target:n,children:e}){/* @__PURE__ */
5
- return f(nn.Provider,{value:n,children:e})}function tn(){return s(nn)}function rn(){return x().Inspector??F}export{a as SELECTION_MODE,en as ScreenCanvasTargetProvider,T as ScreenPartsProvider,y as isPinnedFirst,g as isPinnedLast,d as isSelectionMode,m as isSlotMode,p as sameInspectorMode,v as screenSlotsOf,h as shownChildSlotsOf,k as shownSlotFieldsOf,K as useScreenBlockLook,H as useScreenBlockRules,Q as useScreenBridges,_ as useScreenCanvasDrag,U as useScreenCanvasFrame,$ as useScreenCanvasHead,tn as useScreenCanvasTarget,R as useScreenDevices,G as useScreenDocumentLabel,Y as useScreenDocumentPass,rn as useScreenInspectorPanel,W as useScreenLeftView,q as useScreenNodeKeys,z as useScreenNotify,A as useScreenOwnerName,x as useScreenParts,E as useScreenPickFollowsSelection,X as useScreenPinned,Z as useScreenSaveSwitch,J as useScreenStorageNamespace,M as useScreenStyleClipboard,V as useStandaloneScreenBridges};
@@ -1 +0,0 @@
1
- import{DEFAULT_LOCK_WORDS as e}from"./chunk-RE4LP46F.js";var n=e=>"editing"===e.kind;function t(e){return e?{kind:"checking"}:{kind:"editing"}}var r=e=>"blocked"===e.kind||"readonly"===e.kind||"takenover"===e.kind?e.holder:null;function c(e){if(!e||"object"!=typeof e)return null;const n=e;return"string"!=typeof n.holder_name?null:{name:n.holder_name,secondsSinceSeen:"number"==typeof n.seconds_since_seen?n.seconds_since_seen:0,secondsSinceHeld:"number"==typeof n.seconds_since_held?n.seconds_since_held:0}}var s=e=>e?{edit:!0,insert:!0,delete:!0,duplicate:!0,drag:!1}:{edit:!1,insert:!1,delete:!1,duplicate:!1,drag:!1};function o(n,t=e){if(!Number.isFinite(n)||n<45)return t.justNow;const r=Math.round(n/60);if(r<60)return t.minutesAgo({count:r});const c=Math.round(r/60);return t.hoursAgo({count:c})}var a=(n,t=e)=>n.trim()||t.someone;function i(){return`tab-${"undefined"!=typeof crypto&&"randomUUID"in crypto?crypto.randomUUID():Math.random().toString(36).slice(2)}`.slice(0,64)}var d="edit_lock_taken";function u(e,t,r){return!(n(e)||!n(t))&&(r.pending&&r.autoSaveEnabled&&!r.saveConflict)}function l(e,t,c){return!(null===r(e)||!n(t))&&(!c.pending&&!c.saveConflict)}function f(e,n){return e!==n&&Date.parse(e)>=Date.parse(n)}async function k(e){if(!e.ours)return!1;const n=await e.stored().catch(()=>null);return!(!n||!f(n,e.ours)||e.hasPending())&&(e.reload(),!0)}var h=8e3,y=3e4;function g(e){if(e.cancelled())return!1;const n=e.currentAccess();if("checking"!==n.kind)return!1;const t={kind:"editing"};return e.setAccess(t),u(n,t,e.heldWrite())&&e.releaseHeldWrite(),!0}function p(e){const{readFailure:n,conflictCode:t}=e,r=e=>{const t=n(e);return t&&409===t.status?c(t.data):null},s=e=>{const n=r(e);return n?{kind:"blocked",holder:n}:{kind:"editing"}},o=(e,n)=>{const t=r(e);return t?{kind:"blocked",holder:t}:n},a=(e,n)=>{const t=r(e);return t?{kind:"takenover",holder:t}:n},i=e=>{const t=n(e);return null!==t&&(401===t.status||403===t.status)};return{accessAfterClaimFailure:s,accessAfterTakeoverFailure:o,accessAfterHeartbeatFailure:a,isAuthRejection:i,readSaveConflict:e=>{const r=n(e);if(!r||409!==r.status)return null;if(!r.data||"object"!=typeof r.data)return null;const c=r.data;return c.code!==t?null:{savedBy:"string"==typeof c.saved_by?c.saved_by:"",savedByYou:!0===c.saved_by_you,secondsAgo:"number"==typeof c.seconds_ago?c.seconds_ago:0}},readLockTaken:e=>{const t=n(e);return t&&409===t.status&&t.data&&"object"==typeof t.data?t.data.code!==d?null:c(t.data)??{name:"",secondsSinceSeen:0,secondsSinceHeld:0}:null},makeClaimBeat:e=>{let n=!1;return async t=>{let r,c;try{const s=await e.claim(t);if(e.cancelled())return;r=e.currentAccess(),c={kind:"editing"},!n&&s.heartbeat_seconds>0&&(n=!0,e.startHeartbeat(1e3*s.heartbeat_seconds))}catch(n){if(e.cancelled())return;r=e.currentAccess(),c=t?o(n,r):"checking"===r.kind?s(n):a(n,r),i(n)&&e.stopHeartbeat()}e.setAccess(c);const d=e.heldWrite();u(r,c,d)?e.releaseHeldWrite():t&&l(r,c,d)&&e.reloadIfMoved?.()}}}}export{h as CLAIM_FAIL_OPEN_MS,d as EDIT_LOCK_TAKEN,y as FAIL_OPEN_RETRY_MS,t as accessForNewDocument,n as canWriteDocument,p as createEditLock,o as describeAge,s as documentPermissions,f as documentVersionMoved,r as holderOf,a as nameOrSomeone,i as newEaselClientId,g as openUnansweredClaim,c as readLockHolder,k as reloadIfVersionMoved,u as shouldReleaseHeldWrite,l as shouldReloadAfterTakeover};
@@ -1,15 +0,0 @@
1
- import{DEFAULT_PANEL_WORDS as e}from"./chunk-KFV7N2DJ.js";import{SettingsField as l,SettingsSegmented as n}from"./chunk-CZAAGBVL.js";import{AccordionHeading as a,SettingReset as i,Tooltip as t}from"efficient-shell/ui";export{AlignmentGrid,BorderInput,CornersInput,SidesEachToggle,SidesInput,borderSides,borderStartEach,sidesStartEach}from"efficient-shell/ui";import{jsx as s,jsxs as d,Fragment as o}from"react/jsx-runtime";import{BackgroundIcon as r,WidthIcon as c}from"efficient-shell/icons/efficient";function u({title:e,level:l=3,id:n,className:i}){/* @__PURE__ */
2
- return s(a,{title:e,level:l,id:n,className:i?`es-panel-band ${i}`:"es-panel-band"})}function b({title:e,level:l=4,id:n,className:i}){/* @__PURE__ */
3
- return s(a,{tier:"row",title:e,level:l,id:n,className:i})}function h({label:l,changed:n,onReset:a,detail:t,disabled:d,defaultAction:o,words:r,className:c}){const u={...e,...r},b=u.resetName({label:l});/* @__PURE__ */
4
- return s(i,{label:l,changed:n,onReset:a,detail:t,disabled:d,defaultAction:o,name:b,tip:t?u.resetTitle({label:l,detail:t}):b,className:c})}function m({name:e,preview:l,offPage:n,status:a,onOpen:i,id:r,className:c}){const u=null!=l;/* @__PURE__ */
5
- return d("button",{type:"button",id:r,className:c?`es-drill ${c}`:"es-drill",onClick:i,children:[
6
- /* @__PURE__ */d(t,{content:u?/* @__PURE__ */d(o,{children:[e,
7
- /* @__PURE__ */s("br",{}),l]}):e,describe:!1,className:"es-drill-text",children:[
8
- /* @__PURE__ */s("span",{className:"es-drill-name",children:e}),u?/* @__PURE__ */s("span",{className:n?"es-drill-preview is-offpage":"es-drill-preview",children:l}):null]}),a?/* @__PURE__ */s("span",{className:"es-drill-status",children:a}):null,
9
- /* @__PURE__ */s("span",{className:"es-drill-chev","aria-hidden":"true"})]})}function f({label:e,onPress:l,disabled:n,note:a,done:i,doneLabel:t,icon:o,id:r,className:c}){const u=void 0===t?e:t,b=i?u:e,h=null!=a,m=h&&r?`${r}-note`:void 0;/* @__PURE__ */
10
- return d("div",{className:c?`es-action-wrap ${c}`:"es-action-wrap",children:[
11
- /* @__PURE__ */d("button",{type:"button",id:r,className:i?"es-action is-done":"es-action",disabled:n,"aria-describedby":m,onClick:l,children:[o?/* @__PURE__ */s("span",{className:"es-action-icon","aria-hidden":"true",children:o}):null,
12
- /* @__PURE__ */s("span",{className:"es-action-label",children:b})]}),h?/* @__PURE__ */s("p",{id:m,className:"es-action-note",children:a}):null,
13
- /* @__PURE__ */s("span",{className:"es-action-live",role:"status","aria-live":"polite",children:i?u:null})]})}var p=["full","content"],N={label:"Background",full:"Full width",content:"Content width"};function v({value:e,changed:a,detail:i,onChange:t,onReset:d,disabled:o=!1,hint:c,labelId:u,words:b,resetWords:m}){const f={...N,...b};/* @__PURE__ */
14
- return s(l,{label:f.label,labelId:u,icon:/* @__PURE__ */s(r,{}),changed:a,hint:c,action:/* @__PURE__ */s(h,{words:m,label:f.label,changed:a,detail:i,onReset:d}),children:/* @__PURE__ */s(n,{options:p.map(e=>({id:e,label:"full"===e?f.full:f.content})),value:e,onChange:t,ariaLabel:f.label,disabled:o})})}var g={label:"Content",full:"Full width",content:"Content width"};function w({mode:e,onMode:a,number:i,changed:t,detail:o,onReset:r,fullClosed:u=!1,disabled:b=!1,hint:m,labelId:f,words:N,resetWords:v}){const w={...g,...N},C=void 0!==e&&a?/* @__PURE__ */s(n,{options:p.map(e=>({id:e,label:"full"===e?w.full:w.content,disabled:"full"===e&&u})),value:e,onChange:a,ariaLabel:w.label,disabled:b}):null;/* @__PURE__ */
15
- return s(l,{label:w.label,labelId:f,icon:/* @__PURE__ */s(c,{}),changed:t,hint:m,action:/* @__PURE__ */s(h,{words:v,label:w.label,changed:t,detail:o,onReset:r}),children:C&&i?/* @__PURE__ */d("div",{className:"es-width-stack",children:[C,i]}):C??i??null})}export{p as BACKGROUND_WIDTHS,N as DEFAULT_BACKGROUND_WIDTH_WORDS,g as DEFAULT_CONTENT_WIDTH_WORDS,f as SettingsAction,v as SettingsBackgroundWidth,w as SettingsContentWidth,h as SettingsDefaultReset,m as SettingsDrill,u as SettingsGroupHead,b as SettingsGroupSub};
@@ -1,64 +0,0 @@
1
- import{cloneNodeWithFreshIds as e}from"./chunk-OXZDSOZV.js";import{dedupeSlotChildren as n}from"./chunk-7OCEPOEJ.js";import{styleClipboardOf as t}from"./chunk-DSKNJXB4.js";import{markedTreeNodeId as o,revealSelectedTreeRow as r,sameSelector as i}from"./chunk-UMBNBCL4.js";import{scrollPreviewToSection as l,gotoPreviewSlide as s}from"./chunk-DDH2DYQP.js";import{useEaselKeyTarget as d,useEaselUndoKeys as a,useEaselSaveKey as c,editorRootFocus as p}from"./chunk-75C6WFNF.js";import{SlotChildActionsProvider as u}from"./chunk-KCBEE2MC.js";import{screenStorageKeys as h,DEFAULT_PANEL_W as f,clampPanelWidth as m}from"./chunk-Y53EKN35.js";import{usePartBridge as g}from"./chunk-7RSE6KKY.js";import{useSectionOps as y}from"./chunk-OITNWE52.js";import{ScreenSaveIcon as v,ScreenMainButton as b}from"./chunk-55KKGABA.js";import{useBrowserOffline as k}from"./chunk-RKTF5XLP.js";import{AddChildRow as S}from"./chunk-5545A3PC.js";import{AddSidePanel as w}from"./chunk-CMPFUJ26.js";import{keepsSharedSections as x,sharedSectionsOf as z}from"./chunk-N3MJOHAG.js";import{PanelHideButton as C,SidePanelHead as N,PanelShowStrip as I}from"./chunk-5PXVT7JY.js";import{offeredChoices as O}from"./chunk-RUQOIQWI.js";import{useScreenSaveSwitch as B,useScreenNodeKeys as P,useScreenPinned as $,useScreenDocumentLabel as T,useScreenCanvasFrame as M,useScreenInspectorPanel as j,useScreenDevices as A,useScreenPickFollowsSelection as L,useScreenLeftView as E,SELECTION_MODE as R,isSelectionMode as F,sameInspectorMode as D,useScreenBridges as W,useScreenBlockRules as H,useScreenBlockLook as V,useScreenStorageNamespace as Y,useScreenNotify as U,useScreenCanvasHead as J,isSlotMode as X,useScreenStyleClipboard as K,useScreenDocumentPass as G,useScreenCanvasDrag as Q,ScreenCanvasTargetProvider as _,isPinnedFirst as Z,isPinnedLast as q,screenSlotsOf as ee,shownChildSlotsOf as ne}from"./chunk-QORC32JO.js";import{MediaPopup as te}from"./chunk-T2RINM7R.js";import{useNodeClipboard as oe,useNodeContextMenu as re}from"./chunk-G7ISR6DI.js";import{PageEditGuardNotices as ie}from"./chunk-FRAIEWRC.js";import{useScreenDocument as le}from"./chunk-K7MMLCTT.js";import{requestMediaPick as se}from"./chunk-3FIS2FRS.js";import{useMediaPanel as de,usePanelPick as ae,useMediaBrowsing as ce,useOpenMediaBrowse as pe,useMediaPlace as ue}from"./chunk-NCXYC7WI.js";import{useEaselSession as he}from"./chunk-YM4UEGBV.js";import{useEaselHost as fe,useHostEscape as me}from"./chunk-LX23TCTP.js";import{LayersIcon as ge,MediaIcon as ye}from"./chunk-XFYFKITX.js";import{DEFAULT_SCREEN_WORDS as ve}from"./chunk-IYHO4XQX.js";import{heldStyle as be,styleShortcut as ke}from"./chunk-V7U33NF2.js";import{DEFAULT_STYLE_CLIPBOARD_WORDS as Se}from"./chunk-6WY6ZXJG.js";import{rootRowName as we,slotChildRowName as xe,slotChildRenameProp as ze,sectionRenameProp as Ce}from"./chunk-5NHQ452C.js";import{ROOT_ZONE as Ne,blockNodeActions as Ie,TREE_MAX_DEPTH as Oe,childSlotsOf as Be,slotFieldsOf as Pe,newNodeId as $e,slotChildrenIn as Te,nestsInTree as Me}from"./chunk-TCAAOYQY.js";import{useEasel as je,useEaselApi as Ae,CanvasPartsContext as Le,partHasOwnBox as Ee,CanvasPassThroughContext as Re,CanvasSharedContext as Fe}from"./chunk-FJTCSQWK.js";import{TreeRow as De,Subtree as We,LayersTree as He,TreeGroupLabel as Ve,TreeRowAction as Ye,TreeSeam as Ue}from"./chunk-WHS6Y55E.js";import{DEFAULT_TREE_WORDS as Je}from"./chunk-K56YDHYQ.js";import{DEFAULT_NODE_MENU_WORDS as Xe}from"./chunk-WK3AFPXY.js";import{toItemSelector as Ke,useNodeOps as Ge,clickPick as Qe}from"./chunk-RPMSET77.js";import{EaselTopBar as _e,EaselIconButton as Ze,TopBarCluster as qe,DeviceSwitch as en,InspectorIconButton as nn,PanelResizeHandle as tn,MAX_PANEL_W as on,MIN_PANEL_W_BY_SIDE as rn,panelWidthVars as ln}from"./chunk-WYTPBF3Q.js";import{DEFAULT_NOTICE_WORDS as sn,DEFAULT_CHROME_WORDS as dn}from"./chunk-AJSDWWJW.js";import{holderOf as an,nameOrSomeone as cn}from"./chunk-THWO5YVZ.js";import{DEFAULT_LOCK_WORDS as pn}from"./chunk-RE4LP46F.js";import{useWords as un}from"./chunk-MFIRYGHW.js";import{insertSeams as hn,CanvasDragLayer as fn,CanvasInsert as mn}from"./chunk-LN43DP2A.js";import{DEFAULT_DRAG_WORDS as gn}from"./chunk-TQ5Y6S2X.js";import{createDragSession as yn,useTreeDrag as vn,gapToMoveIndex as bn}from"./chunk-6NJHYXJM.js";import{useCanvasFrame as kn,LIST_SELECTOR as Sn,BLOCK_SELECTOR as wn,useCanvasTyping as xn,useCanvasEvent as zn,nodeIdAt as Cn,frameRectToHost as Nn,BLOCK_ATTRIBUTE as In,drawnBox as On}from"./chunk-YU3WHLGI.js";import{queryMainCopy as Bn}from"./chunk-LF3FUSCQ.js";import{ROOT_ID as Pn,ROOT_SLOT as $n,zoneKey as Tn,parseZoneKey as Mn,find as jn,DataError as An}from"./chunk-TGZCD6IP.js";import{useRef as Ln,useMemo as En,useState as Rn,useEffect as Fn,useCallback as Dn,useLayoutEffect as Wn,useContext as Hn,Fragment as Vn,useId as Yn}from"react";import{ColoredBadge as Un,Button as Jn,Tabs as Xn,toast as Kn,readMediaFileDrag as Gn,Tooltip as Qn,groupColors as _n,Dialog as Zn,FormField as qn,Input as et,MEDIA_FILE_DRAG_TYPE as nt}from"efficient-shell/ui";import{UndoIcon as tt,RedoIcon as ot,RefreshIcon as rt,AddIcon as it,TrashIcon as lt,EyeOffIcon as st,EyeIcon as dt,SharedIcon as at,DuplicateIcon as ct}from"efficient-shell/icons/efficient";import{jsx as pt,jsxs as ut,Fragment as ht}from"react/jsx-runtime";var ft="media-file";function mt({name:e,onMake:n,onCancel:t}){const o=un("screen",ve).shared,[r,i]=Rn(e),[l,s]=Rn(!1),d=Yn(),a=Ln(null),c=async()=>{const e=r.trim();if(e&&!l){s(!0);try{await n(e)}finally{s(!1)}}};/* @__PURE__ */
2
- return pt(Zn,{open:!0,size:"sm",title:o.makeShared,description:o.makeSharedHint,onClose:t,initialFocus:a,footer:/* @__PURE__ */ut(ht,{children:[
3
- /* @__PURE__ */pt(Jn,{variant:"secondary",onClick:t,children:o.cancel}),
4
- /* @__PURE__ */pt(Jn,{variant:"primary",loading:l,disabled:!r.trim(),onClick:()=>{c()},children:o.makeShared})]}),children:/* @__PURE__ */pt("form",{onSubmit:e=>{e.preventDefault(),c()},children:/* @__PURE__ */pt(qn,{label:o.name,htmlFor:d,children:/* @__PURE__ */pt(et,{id:d,ref:a,value:r,onChange:e=>i(e.target.value)})})})})}var gt=/* @__PURE__ */new WeakSet;function yt(e,n,t){const o=jn(e,n,t);if(!o)return null;const r=o.path.find(e=>"root"!==e.parentId);return r?r.parentId:t}function vt({canvas:e,tabs:n,onSelect:t}){const o=Ln(null),[r,i]=Rn({}),l=n.map(e=>`${e.id}:${e.below?1:0}`).join("|");return Wn(()=>{const t=e?.document,r=e?.window,l=e?.frame;if(!t||!r||!l||0===n.length)return void i({});let s=0;const d=()=>{s=0;const e=o.current;if(!e)return;const d=Nn(l,{left:0,top:0,width:r.innerWidth,height:r.innerHeight},e),a={};for(const o of n){const n=Bn(t,`[${In}="${r.CSS?.escape?r.CSS.escape(o.id):o.id}"]`),i=n?On(n):null;if(!i||0===i.height){a[o.id]=null;continue}const s=Nn(l,{left:i.left,top:i.top,width:i.width,height:i.height},e),c=s.top+s.height;if(c<d.top||s.top>d.top+d.height){a[o.id]=null;continue}const p=o.below?c+4:Math.max(s.top,d.top)+6;a[o.id]={left:Math.max(s.left,d.left)+6,top:p}}i(a)},a=()=>{s||(s=r.requestAnimationFrame(d))};d(),r.addEventListener("scroll",a,!0),r.addEventListener("resize",a);const c=new r.MutationObserver(a);return c.observe(t.body,{childList:!0,subtree:!0,attributes:!0}),()=>{s&&r.cancelAnimationFrame(s),r.removeEventListener("scroll",a,!0),r.removeEventListener("resize",a),c.disconnect()}},[e,l]),/* @__PURE__ */pt("div",{ref:o,className:"es-band-tabs","aria-hidden":"true",children:n.map(e=>{const n=r[e.id];return n?/* @__PURE__ */pt("span",{className:"es-band-tab","data-band-tab":e.id,style:{left:n.left,top:n.top},onClick:n=>{n.stopPropagation(),t(e.id)},children:e.reach?
5
- /* @__PURE__ */pt(Qn,{content:e.reach,children:/* @__PURE__ */ut(Un,{colorClass:_n("success","solid"),size:"sm",children:[
6
- /* @__PURE__ */pt("span",{className:"es-band-tab-mark",children:/* @__PURE__ */pt(at,{size:12})}),e.label]})}):/* @__PURE__ */pt(Un,{colorClass:_n("info","solid"),size:"sm",children:e.label})},e.id):null})})}function bt({expand:e}){/* @__PURE__ */
7
- return pt("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.9,strokeLinecap:"round",strokeLinejoin:"round",children:/* @__PURE__ */ut(ht,e?{children:[
8
- /* @__PURE__ */pt("path",{d:"M8 9l4-4 4 4"}),
9
- /* @__PURE__ */pt("path",{d:"M8 15l4 4 4-4"})]}:{children:[
10
- /* @__PURE__ */pt("path",{d:"M8 4l4 4 4-4"}),
11
- /* @__PURE__ */pt("path",{d:"M8 20l4-4 4 4"}),
12
- /* @__PURE__ */pt("path",{d:"M5 12h14"})]})})}var kt=`${Sn}, ${wn}`;function St(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 wt="__rungs";var xt="screen:band",zt={duplicate:!0,delete:!0},Ct=()=>null;function Nt(){const Sn=fe(),Nn=Sn.panels?.Toolbar,In=(Sn.panels?.useRight??Ct)(),{target:On,docId:Yn,capabilities:Qn,currentSlug:_n,siteId:Zn,onPublish:qn,saveState:et,saveConflict:at,retrySave:Nt,toggleAutoSave:It,flushSave:Ot,access:Bt,saveUnreachable:Pt=!1,readOnly:$t,readOnlyReason:Tt=null}=le(),Mt=B(),jt=P(),{mediaEditing:At,hasEditGuard:Lt,hasPinnedChrome:Et}=Qn,{appState:Rt,dispatch:Ft,history:Dt,selectedItem:Wt,getSelectorForId:Ht,config:Vt}=je(e=>e),Yt=$(),{first:Ut,firstGroup:Jt,lastGroup:Xt,isSectionGroup:Kt,sectionGroupZone:Gt,panelOf:Qt}=Yt,_t=Qt(Ut),Zt=e=>Z(Yt,e),qt=e=>q(Yt,e),eo="node"===Yt.firstRow,no=Yt.band??null,to=un("screen",ve),oo=un("tree",Je),ro=un("drag",gn),io=un("notice",sn),lo=un("lock",pn),so=un("menu",Xe),ao=un("styleClipboard",Se),co=un("chrome",dn),po=T()??`/${_n}`,uo=M(),ho=j(),fo=y({readOnly:$t}),mo=y({readOnly:$t,foldIntoHistory:!0}),go=Ln(null),yo=Ae(),vo=En(()=>({...fo,select:e=>{go.current=e,fo.select(e)},commitDocument:(e,n)=>{if(void 0!==n){const t=yo.config;go.current=Ke(e,t,n)}fo.commitDocument(e,n)}}),[fo,yo]),bo=Rt.ui,ko=bo.leftSideBarVisible,So=bo.rightSideBarVisible,{options:wo,widths:xo,initial:zo,fluid:Co,fit:No}=A(),[Io,Oo]=Rn(zo),Bo=de(),Po=At&&null!==Bo;ae(),ce();const $o=pe();L(Wt?.props.id);const{read:To,write:Mo,forSelection:jo}=E(),[Ao,Lo]=Rn(To);Fn(()=>{Mo(Ao)},[Ao]);const[Eo,Ro]=Rn(0),Fo=Ln(null),Do=Ln(null),Wo=kn(Do,{readySelector:kt}),Ho=xn(Wo),Vo=d(Do);a(Do,Wo);const Yo=k(),Uo=an(Bt),Jo={state:et,offline:Yo||et.failed&&Pt,readOnlyReason:Tt,editing:Uo?io.editing({name:cn(Uo.name,lo),noun:to.noun}):null,conflict:null!=at,notSaving:to.bar.notSaving},Xo=()=>{$t||(et.failed?Nt():Ot())};c(Do,Wo,Xo);const[Ko,Go]=Rn(!1),Qo=Ln(!1),[_o,Zo]=Rn(null),[qo,er]=Rn([]),[nr,tr]=Rn(R);F(nr);const or=o(nr,Wt?.props.id),[rr,ir]=Rn(null);Fn(()=>{rr&&(r(),ir(null))},[rr]);const lr=Ln(Ht);lr.current=Ht;const sr=Dn((e,{scroll:n})=>{Lo(n=>jo(e,n)),n&&ir(e);const t=[];let o=e;for(let e=0;e<4;e++){const e=lr.current(o)?.zone;if(!e||!e.includes(":"))break;const n=e.split(":")[0];t.push(n),t.push(e),o=n}0!==t.length&&Er(e=>{if(t.every(n=>!e.has(n)))return e;const n=new Set(e);return t.forEach(e=>n.delete(e)),n})},[]),dr=Ln(null);Fn(()=>{const e=dr.current;dr.current=null;const n=null==Wt?.props.id?null:String(Wt.props.id);tr(t=>e&&e.id===n?e.mode:"part"===t.kind&&"nodeId"in t&&t.nodeId===n?t:Qt(Wt?.type)??R);const t=Wt?.props.id,o=go.current;if(go.current=null,!t)return;const r=Ht(t);sr(String(t),{scroll:!i(o,r??null,Ne)})},[Wt?.props.id,sr]);const ar=Dn(e=>{tr(n=>D(n,e)?n:e),Ft({type:"setUi",ui:{rightSideBarVisible:!0}})},[Ft]),cr=Ln(()=>{});cr.current=(e,n)=>{const t=e?Ti(e.zone??Ne)[e.index]?.props.id:null,o=null==t?null:String(t),r=null==Wt?.props.id?null:String(Wt.props.id);tr(e=>D(e,n)?e:n),o!==r&&(dr.current={id:o,mode:n},vo.select(e))};const pr=Dn((e,n)=>cr.current(e,n),[]),ur={kind:nr.kind,mode:nr,open:ar,show:e=>tr(e),reveal:()=>{So||Ft({type:"setUi",ui:{rightSideBarVisible:!0}})},select:pr},hr=W(ur,{data:Rt.data,selected:Wt??null,zoneOf:e=>Ht(e)?.zone,readOnly:Boolean($t),select:e=>{tr(R),vo.select({index:e})},replace:(e,n)=>vo.replaceComponent(Ne,e,n),scrollTo:e=>l(e)},{device:Io,refreshes:Eo},{setView:Lo,reveal:()=>{ko||Ft({type:"setUi",ui:{leftSideBarVisible:!0}})}}),fr=hr.resolveLeftView?hr.resolveLeftView(Ao):"sections",mr=H(),{isLockedBlock:gr,duplicateBlocked:yr,nestDepth:vr,newSectionNode:br,canAddTo:kr,blockIsOffered:Sr}=mr,wr=e=>({id:String(e.props.id??""),data:Rt?.data}),xr=V(),{labelAtLevel:zr,Icon:Cr,useProducts:Nr}=xr,Ir=xr.rowName?(e,n,t)=>xr.rowName(e,n,t):void 0,Or=Dn(e=>{Ft({type:"setUi",ui:{rightSideBarVisible:!0}}),l(e),sr(e,{scroll:!0})},[Ft,sr]),{selectNode:Br,openPartId:Pr}=g({mode:nr,setMode:tr,onOpenPart:Or}),[$r,Tr]=Rn(null);me(null!==$r,()=>Tr(null));const Mr=h(Y()),jr=Mr.collapsed,Ar=Mr.panelWidths,[Lr,Er]=Rn(()=>{if("undefined"==typeof window)/* @__PURE__ */return new Set;try{const e=window.localStorage.getItem(jr);return new Set(e?JSON.parse(e):[])}catch{/* @__PURE__ */
13
- return new Set}});Fn(()=>{try{window.localStorage.setItem(jr,JSON.stringify([...Lr]))}catch{}},[Lr]);const[Rr,Fr]=Rn(()=>{if("undefined"==typeof window)return{...f};try{const e=window.localStorage.getItem(Ar);if(!e)return{...f};const n=JSON.parse(e);return{left:m(Number(n.left)||f.left,"left"),right:m(Number(n.right)||f.right,"right")}}catch{return{...f}}});Fn(()=>{const e=setTimeout(()=>{try{window.localStorage.setItem(Ar,JSON.stringify(Rr))}catch{}},300);return()=>clearTimeout(e)},[Rr]);const Dr=Dn((e,n)=>Fr(t=>{const o="function"==typeof n?n(t[e]):n;return t[e]===o?t:{...t,[e]:o}}),[]),Wr=Dn(e=>Dr("left",e),[Dr]),Hr=Dn(e=>Dr("right",e),[Dr]),Vr=e=>Lr.has(e),Yr=e=>Er(n=>{const t=new Set(n);return t.has(e)?t.delete(e):t.add(e),t}),Ur=Ln(!1),Jr=Ln(null);Fn(()=>{if(Ur.current&&!Ko){const e=Jr.current,n=e&&e.isConnected&&!e.closest('[aria-hidden="true"]')?e:null;(n??Do.current?.querySelector(`button[aria-label="${CSS.escape(to.add.title)}"]`))?.focus(),Jr.current=null}Ur.current=Ko},[Ko]),Fn(()=>{if(!Ko||!Vo)return;const e=e=>{"Escape"===e.key&&cl()};return Vo.addEventListener("keydown",e),()=>Vo.removeEventListener("keydown",e)},[Ko,Vo]),me(Ko,()=>cl()),Fn(()=>{!ko&&Ko&&(Go(!1),Zo(null),Qo.current=!1)},[ko]);const Xr=U(),Kr=(e,n="success",t)=>{if(Xr)return void(t?Xr(e,"error"===n?"error":"info",t):Xr(e,"error"===n?"error":"info"));const o={sound:!1,action:t?.action,onClose:t?.onClose};"error"===n?Kn.error(e,{...o,duration:t?.duration??3200}):Kn.success(e,{...o,duration:t?.duration??1900})},Gr=Ln(null),[Qr,_r]=Rn(0),[Zr,qr]=Rn(0),ei=J(),ni=Ln(null),ti=e=>Math.max(0,e.clientHeight-(ni.current?.offsetHeight??0));Fn(()=>{const e=Gr.current;if(!e)return;const n=()=>{_r(e.clientWidth),qr(ti(e))};n();const t=new ResizeObserver(n);return t.observe(e),ni.current&&t.observe(ni.current),()=>t.disconnect()},[]),Wn(()=>{Gr.current&&(_r(Gr.current.clientWidth),qr(ti(Gr.current)))},[Rr,ko,So]);const oi=Io===Co?Qr>0?Qr:xo[Co]:xo[Io],ri=Qr>0?Math.min(Qr/oi,"shrink"===No?1:2):1,ii=oi*ri,li=Qr>0&&ii>Qr+1,si={width:ii,height:Zr||"100%",flex:"none",position:"relative"},di={width:oi,height:Zr?Zr/ri:"100%",maxHeight:"none",transform:1!==ri?`scale(${ri})`:void 0,transformOrigin:"top left"},ai=()=>Ft({type:"setUi",ui:{leftSideBarVisible:!ko}}),ci=()=>Ft({type:"setUi",ui:{rightSideBarVisible:!So}}),pi=e=>{Ko&&(Go(!1),Zo(null),Qo.current=!1,ko&&Ao===e)||(Lo(e),ko||Ft({type:"setUi",ui:{leftSideBarVisible:!0}}))},ui=()=>{tr(_t??R),So||Ft({type:"setUi",ui:{rightSideBarVisible:!0}})},hi=Rt.data.content??[],fi=()=>{const e=hi.findIndex(Zt),n=hi.findIndex(qt);return{floor:e>=0?e+1:0,cap:n>=0?n:hi.length}},mi=Vt,gi=mr.stripCopy,yi=n=>e(n,gi),vi=oe(),bi=Ge({data:Rt.data,config:mi,readOnly:Boolean($t),clipboard:vi,strip:gi?e=>gi(e):void 0,afterRemove:"none",stepBounds:(e,n)=>{if(e.parentId!==Pn||e.slot!==$n)return{min:0,max:n-1};const{floor:t,cap:o}=fi();return{min:t,max:o-1}},commit:(e,{select:n})=>{void 0!==n&&tr(R);const t=void 0===n||"node"===n?.kind?n:null;vo.commitDocument(e,t)}}),ki=he(),[Si,wi]=Rn(null),xi=e=>{const n=hi.find(n=>String(n.props.id)===e),t=Yt.shared;n&&t&&bi.swap(e,t.detach(n))},zi=e=>{const n=jn(Rt.data,Vt,e);if(!n)return!1;const t=Tn(n.place),o=n.node,r=t===Ne?Bi(o):Vi(o),i=t===Ne?Yt.shared?.usedOn(o):null;return!!bi.remove(e)&&(Kr(i?to.shared.removed({count:Math.max(0,i.length-1)}):to.deleted({name:r}),"success",{duration:8e3,action:{label:to.bar.undo,onClick:()=>{bi.restore(n.node,n.place)}}}),!0)},Ci={...bi,remove:zi},Ni=e=>zr(e,"block",Vt.components[e]?.label??e),Ii=Dn(e=>Vt.components[e]?.defaultProps??{},[Vt]),Oi=e=>zr(e,"section",Ni(e)),Bi=e=>we({type:e.type,props:e.props??{}},Oi(e.type),Ir),{nodeAddresses:Pi,zoneItems:$i}=En(()=>{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>=Oe)return;const s=/* @__PURE__ */new Map;for(const{child:e,zone:t}of Be(Vt,n))s.set(t,[...s.get(t)??[],e]);for(const[e,n]of s)t(n,e,i+1)})};return t(hi,Ne,0),{nodeAddresses:e,zoneItems:n}},[hi,Vt]),Ti=Dn(e=>$i.get(e)??[],[$i]),Mi=e=>{const n=Pi.get(e);return n?Ti(n.zone)[n.index]:void 0},ji=e=>ee(mr,Vt,e),Ai=e=>{if(!mr.slotsOf||e===Ne)return null;const n=e.lastIndexOf(":");if(n<=0)return null;const t=Mi(e.slice(0,n));if(!t)return null;const o=ji(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}},Li=(()=>{if(!X(nr))return null;const e=`${nr.nodeId}:${nr.slot}`;return Ai(e)?.slot.panel===nr.kind?e:null})(),Ei=Ln(null);Fn(()=>{const e=Ei.current;if(Ei.current=null,!Li||!X(nr))return;const n=nr.nodeId;sr(n,{scroll:e!==Li}),Er(e=>{if(!e.has(n))return e;const t=new Set(e);return t.delete(n),t})},[nr]);const Ri=(e,n,t)=>{const o=String(e.props.id);if(!n.panel)return void(e=>{const n=Pi.get(e);n&&(n.zone===Ne?ol(n.index):Pl(n.zone,n.index,e,Mi(n.zone.slice(0,n.zone.lastIndexOf(":")))?.type??""))})(o);const r={kind:n.panel,nodeId:o,slot:n.slot},i=`${o}:${n.slot}`;t&&Li!==i&&(Ei.current=i),pr(null,r),So||Ft({type:"setUi",ui:{rightSideBarVisible:!0}}),l(o)},Fi=(e,n,t)=>{const o=`${e}:${n}`;if(Er(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;Li!==o&&(Ei.current=o);pr(null,{kind:t,nodeId:e,slot:n})},Di=(e,n,t)=>{if($t||!mr.moveSlot)return;const o=Mi(e),r=o?ji(o).filter(e=>e.rung):[],i=r[n];if(!i)return;const l={parentId:e,slot:wt,index:n},s=bn(l,{...l,index:Math.min(Math.max(t,0),r.length)});if(s===n)return;const d=mr.moveSlot(e,n,s);"string"==typeof d&&Fi(e,d,i.panel)},Wi=Nr(),Hi=En(()=>{const e=/* @__PURE__ */new Map;for(const n of Wi??[])e.set(n.slug,n.name);return e},[Wi]),Vi=e=>xe(e,Ni,xr.plainText,e=>Hi.get(e),xr.rowName),Yi=(e,n)=>{const t=Vt.components[e.type]?.fields,o=n===Ne||ts(n)?"section":"block",r=n===Ne&&(Zt(e)||qt(e)||Kt(e.type)),i="block"===o?ze(t):r?null:Ce(t);return xr.renamePropOf?xr.renamePropOf(e,o,i):i},Ui=(e,n,t,o)=>{if(!(!$t&&$r?.zone===e&&$r.index===n))return;const r=(t,o)=>{Tr(null),o&&((e,n,t)=>{const o=Ti(e)[n];if(!o)return;const r=Yi(o,e);r&&vo.replaceComponent(e,n,{...o,props:{...o.props,[r]:t.trim()}})})(e,n,t)};/* @__PURE__ */
14
- return pt("input",{className:"es-tree-rename",defaultValue:o,autoFocus:!0,"aria-label":to.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)},Ji=t(K(),ao),Xi=Ji.scope({target:On,siteId:Zn,docId:Yn}),Ki=Vt,Gi=(e,n)=>n===Ne?Oi(e):Ni(e),Qi=(e,n,t)=>{const o=Ji.plan(Xi,t,Gi(t.type,e),Ki);o&&(o.changed&&vo.replaceComponent(e,n,{...t,props:{...o.props,id:t.props.id}}),Kr(o.message))},_i=re({nodesIn:Ti,nodeAt:(e,n)=>Ti(e)[n]??null,labelOf:(e,n)=>n===Ne?Oi(e):Ni(e),renamePropOf:Yi,beginRename:(e,n)=>Tr({zone:e,index:n}),history:{hasPast:Dt.hasPast,hasFuture:Dt.hasFuture,back:()=>Dt.back(),forward:()=>Dt.forward()},openPageStyles:hr.openPageStyles,pageStylesLabel:to.pageStyles,words:{menu:so,styleClipboard:ao,screen:to.menu},readOnly:Boolean($t),collapseAll:()=>Er(new Set(Ti(Ne).map(e=>String(e.props.id)))),onPasteRefused:e=>Kr(e?to.pasteRefused({name:e.label}):to.menu.clipboardRefused,"error"),canPasteAt:(e,n)=>is(e,n),menuRows:(e,n,t)=>{const o=hr.menuRows?.(e,n,t)??null,r=((e,n)=>{const t=Yt.shared;if(!t||n!==Ne)return null;const o=t.usedOn(e);if(o){const n={pick:[{label:to.shared.onPages({count:o.length}),onClick:()=>{},children:o.map(e=>({label:e.title,onClick:()=>t.openPage(e)}))}]};return $t||gr(e.type,e)?n:{...n,change:[{label:to.shared.detach,onClick:()=>xi(e.props.id)}],remove:[{label:to.shared.removeFromPage,danger:!0,onClick:()=>{zi(e.props.id)}}]}}return $t||Zt(e)||qt(e)||Kt(e.type)?null:x(ki)?{change:[{label:to.shared.makeShared,onClick:()=>wi({id:e.props.id,name:Bi(e)})}]}:null})(e,n);if(!r)return o;return Object.fromEntries(["pick","make","change","remove"].map(e=>[e,[...o?.[e]??[],...r[e]??[]]]).filter(([,e])=>e.length>0))},isLocked:e=>gr(e.type,e),duplicateBlocked:e=>yr(Rt.data,e),permits:e=>{const n=Ie(Vt,e.type);return Yt.shared?.usedOn(e)?{...n,delete:!1}:n},nodeOps:Ci,isPinned:(e,n)=>n===Ne&&(Zt(e)||qt(e)),sectionBand:fi,locate:e=>Pi.get(e)??null,rowNameOf:(e,n)=>n===Ne?Bi(e):Vi(e),selectAt:(e,n,t,o)=>{e===Ne?ol(n):Pl(e,n,t,o??"")},slotRung:e=>{const n=Ai(e);return n?.slot.panel?{label:n.slot.label,select:()=>Ri(n.node,n.slot,!1)}:null},style:{held:()=>be(Xi),canCopy:e=>Ji.rows(Ki,e).some(e=>!1!==e.counted),copy:(e,n)=>Ji.copy(Xi,e,Gi(e.type,n),Ki),paste:(e,n,t)=>Qi(e,n,t)},keys:jt?{target:Vo,selected:()=>{const e=Rt.ui.itemSelector;return e?{zone:e.zone??Ne,index:e.index}:null},held:()=>vi.get(),readOnly:Boolean($t),onDone:({done:e,name:n})=>{"copied"===e&&Kr(to.copied({name:n}))}}:void 0},Wo),Zi=Ln({copy:(e,n)=>{},paste:(e,n,t)=>{},at:()=>null,readOnly:!1});Fn(()=>{Zi.current={copy:(e,n)=>Ji.copy(Xi,e,Gi(e.type,n),Ki),paste:Qi,at:()=>{const e=Rt.ui.itemSelector;if(!e)return null;const n=e.zone??Ne,t=Ti(n)[e.index];return t?{zone:n,index:e.index,node:t}:null},readOnly:Boolean($t)}});const qi=Dn(e=>{const n=ke(e);if(!n)return;const t=Zi.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))},[]);Fn(()=>{if(!Vo)return;const e=e=>qi(e);return Vo.addEventListener("keydown",e),()=>Vo.removeEventListener("keydown",e)},[qi,Vo]),zn(Wo,"keydown",qi);const el=hi.map(e=>e.props.id).join("|");Fn(()=>{const e=Wo?.document??null,n=Wo?.window??null;let t=0;const o=[],r=()=>{if(!e)return void er(e=>e.length?[]:e);const n=hi.findIndex(qt),t=n>=0?n:hi.length,o=n=>{const t=hi[n]?.props?.id;return null==t?null:Bn(e,`[data-easel-block="${CSS.escape(String(t))}"]`)},r=e=>e?[...e.querySelectorAll(wn)].map(e=>e.getBoundingClientRect()).filter(e=>e.width>0||e.height>0):[],i=[];for(let e=hi.length>0&&!Zt(hi[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=St(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})}er(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()}},[Wo,el,Io,ri,ko,So,Wt?.props.id]);const nl=Wo?.document??null,tl=Wo?.window??null;Fn(()=>{const e=Fo.current;if(!e||!nl||!tl)return;const n=[],t=()=>{const n=Bn(nl,`[data-easel-block="${CSS.escape(e.id)}"]`);if(!n)return!1;const t=n.getBoundingClientRect().top-e.offset;return Math.abs(t)>1&&tl.scrollTo({left:tl.scrollX,top:tl.scrollY+t,behavior:"instant"}),!0};return Fo.current=null,t()&&n.push(setTimeout(t,150),setTimeout(t,450)),()=>n.forEach(clearTimeout)},[nl,tl]);const ol=e=>{tr(R),vo.select({index:e}),hr.sectionPressed?.(hi[e]);const n=hi[e]?.props?.id;n&&l(n)},rl=e=>{const{floor:n,cap:t}=fi(),o=e=>Math.min(Math.max(n,e),t);if("number"==typeof e)return o(e);const r=Wt&&nr.kind!==_t?.kind?hi.findIndex(e=>e.props.id===Wt.props.id):-1;return o(r>=0?r+1:t)},il=(e,n)=>{const{floor:t,cap:o}=fi(),r=Math.min(Math.max(n,t),o),i=e<r?r-1:r;return i===e?{moved:!1,dest:e}:(vo.reorderComponent(Ne,e,i),vo.select({index:i}),{moved:!0,dest:i})},ll=(e,n,t,o)=>{tr(R),vo.select(o?{index:o.index,zone:o.zone}:{index:e}),l(n),Kr(to.sectionAdded({name:t}))},sl=(e,n)=>{const t=rl(n),o=br(e,{nodeDefaults:Ii,newNodeId:$e,sectionLabel:Oi,blockIsOffered:Sr}),r=o?vo.insertNode(Ne,t,o):vo.insertSection(e,t);return ll(t,r,Oi(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:a}of Be(Vt,e)){if(s.type===t&&(!o.at||n>o.at.depth)){const r=kr(e.type,l,d.slice(d.lastIndexOf(":")+1),wr(e)),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:a,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},dl=e=>al(Ne,e),al=(e,n)=>{Jr.current=document.activeElement??null,Zo(null===n?null:{zone:e,index:n}),Go(!0),ko||(Qo.current=!0,Ft({type:"setUi",ui:{leftSideBarVisible:!0}}))},cl=()=>{Go(!1),Zo(null),Qo.current&&Ft({type:"setUi",ui:{leftSideBarVisible:!1}}),Qo.current=!1},pl=(e,n)=>xr.rowName?n?Zt(e)?xr.rowName(e,"section",to.header):qt(e)?xr.rowName(e,"section",to.footer):Kt(e.type)?xr.rowName(e,"section",Ni(e.type)):Bi(e):Vi(e):n?Oi(e.type):Ni(e.type),ul=e=>n=>{e()},hl=(e,n,t)=>{if($t)return null;const o=Ti(e)[n];return o&&!Ie(Vt,o.type).delete||o&&gr(o.type,o)?null:/* @__PURE__ */pt(Ye,{kind:"delete",label:e===Ne&&o&&Yt.shared?.usedOn(o)?to.shared.removeFromPage:to.deleteNamed({name:t}),onClick:()=>((e,n)=>{const t=Ti(e)[n]?.props?.id;null!=t&&zi(String(t))})(e,n),children:/* @__PURE__ */pt(lt,{size:15})})},fl=e=>xr.rowPreview?.(e)||void 0,ml=e=>xr.rowMarks?.(e)??void 0,gl=(e,n,t)=>xr.rowActions?.(e,n,t)??null,yl=(e,n,t,o)=>{if($t)return null;if(gr(t.type,t))return null;const r=Boolean(t.props._hidden);/* @__PURE__ */
15
- return pt(Ye,{kind:"eye",label:r?to.showNamed({name:o}):to.hideNamed({name:o}),onClick:()=>bl(e,n,t),children:/* @__PURE__ */pt(r?st:dt,{size:14,strokeWidth:1.8,strokeLinecap:void 0,strokeLinejoin:void 0})})},vl=e=>Qs(Ne,e),bl=(e,n,t)=>{vo.replaceComponent(e,n,{...t,props:{...t.props,_hidden:!t.props._hidden}})},kl=e=>Pe(Vt,e),Sl=e=>Be(Vt,e),wl=e=>mr.slotsOf?ji(e).map(n=>({slot:n.slot,rung:n.rung?n:null,kids:Te(e,n.slot)})):[{slot:null,rung:null,kids:ne(Vt,e)}],xl=e=>mr.slotsOf?wl(e).flatMap(e=>e.kids):ne(Vt,e),zl=e=>Boolean(mr.slotsOf)&&ji(e).some(e=>e.rung),Cl=(e,n,t)=>kr(e.type,n,t??void 0,wr(e)),Nl=(e,n,t)=>{const o=Me(Vt,e.type,n)&&(t||xl(e).length>0||zl(e));return{collapsible:o,folded:o&&Vr(String(e.props.id))}},Il=(e,n,t)=>wl(e).flatMap(o=>{const r=o.rung?n+1:n,i=o.kids.flatMap(({child:e})=>Nl(e,r,t(e.type)).collapsible?[String(e.props.id),...Il(e,r+1,t)]:[]);return o.rung?[`${e.props.id}:${o.rung.slot}`,...i]:i}),Ol=e=>xl(e).length>0||zl(e)||Boolean(kr(e.type)),Bl=e=>Boolean(kr(e)),Pl=(e,n,t,o)=>{if(tr(R),kr(o)?.spec?.slider){const t=e.split(":")[0];s(t,n),vo.select({index:n,zone:e}),l(t)}else vo.select({index:n,zone:e}),l(t)},$l=(e,n,t,o,r)=>{const i=`${e}:${n}`;vo.insertComponent(i,t,o),kr(r)?.spec?.slider?requestAnimationFrame(()=>{s(e,o),vo.select({index:o,zone:i})}):vo.select({index:o,zone:i})},Tl=Ln(/* @__PURE__ */new Set);Fn(()=>{hi.forEach(e=>{const n=kr(e.type)?.spec;if(!n)return;const t=e.props.id;if(Tl.current.has(t))return;Tl.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(Ii)).forEach((e,t)=>mo.seedChild(o,t,n.childType,e))})},[hi,mo,Ii]);const Ml=Ln(/* @__PURE__ */new Set);Fn(()=>{hi.forEach((e,t)=>{const o=e.props.id;if(Ml.current.has(o))return;const r=n(e,kl(e.type));Ml.current.add(o),r&&mo.replaceComponent(Ne,t,{...e,props:r})})},[hi,mo]),G(mo,Vt);const jl=hi.findIndex(qt),Al=jl>=0?hi[jl]:null,Ll=eo?hi.findIndex(Zt):-1,El=Ll>=0?hi[Ll]:null,Rl=Yt.groupTab,Fl=En(()=>Rl?e=>Kt(e.type):void 0,[Rl]),Dl=Boolean(Yt.groupBadge),Wl=Yt.sharedReach,Hl=e=>Wl?.(e)??void 0,Vl=En(()=>Wl?new Set(hi.filter(e=>Hl(e)).map(e=>String(e.props.id))):null,[hi,Wl]),Yl=En(()=>Vl?e=>Vl.has(e):void 0,[Vl]),Ul=Yt.first?Wl?.({type:Yt.first,props:{id:""}})??void 0:void 0,Jl=Yt.groupBadge?/* @__PURE__ */pt("span",{className:"es-tree-group-badge",children:/* @__PURE__ */pt(Un,{tone:"info",size:"xs",children:Yt.groupBadge})}):void 0,Xl=hi.find(e=>e.type===Jt)??null,Kl=hi.find(e=>e.type===Xt)??null,Gl=jl>=0?jl:hi.length,Ql=[];hi.forEach(e=>{qt(e)||(Ol(e)&&Ql.push(String(e.props.id)),Ql.push(...Il(e,1,Bl)))}),Al&&(Ql.push(String(Al.props.id)),Ql.push(...Il(Al,1,Bl)));const _l=Ql.length>0&&Ql.every(e=>Lr.has(e)),Zl=e=>{const n=xr.blockRowName(e,Ni);return xr.rowName?xr.rowName(e,"block",n):n},ql=(e,n,t,o)=>{const r=Ti(e)[t];if(!r)return;const i={...Mn(e),index:t},l={...Mn(n),index:Math.min(Math.max(o,0),Ti(n).length)},s=bn(i,l);if(e!==n||s!==t)try{bi.move(String(r.props.id),{...l,index:s})}catch(e){if(!(e instanceof An))throw e}},es=e=>{const n=/* @__PURE__ */new Set,t=e=>{for(const{child:o,zone:r}of Sl(e))n.add(r),t(o)};for(const t of kl(e.type))n.add(`${e.props.id}:${t}`);return t(e),n},ns=e=>{let n=e.slice(0,e.indexOf(":"));for(let e=0;e<64;e++){const e=Pi.get(n);if(!e)return null;if(e.zone===Ne)return n;n=e.zone.slice(0,e.zone.indexOf(":"))}return null},ts=e=>{const n=e.slice(0,e.indexOf(":")),t=hi.find(e=>Kt(e.type)&&String(e.props.id)===n);return t&&Gt(n)===e?t:null},os=(e,n)=>{const t=ts(e);return!t||(!Yt.groupAccepts||Yt.groupAccepts(t.type,n,Ti(e).length))},rs=(e,n,t)=>{if(e.rung){const t=Mi(e.rung.nodeId),o=t?ji(t).filter(e=>e.rung).length:0;return n.parentId===e.rung.nodeId&&n.slot===wt&&n.index>=0&&n.index<=o}if(n.slot===wt)return!1;if(e.add)return ds(e.add,n);const o=Tn(n);if(Kt(e.type))return!1;const r=ts(o),i=ts(e.zone);if(r||i)return!(!r||!i)&&(!(r!==i&&!os(o,e.type))&&(n.index>=0&&n.index<=Ti(o).length));if(e.zone===Ne||o===Ne){if(e.zone!==o)return!1;const{floor:t,cap:r}=fi();return n.index>=t&&n.index<=r}if(n.index<0||n.index>Ti(o).length)return!1;if(e.zone===o)return!0;const l=Al&&!Yt.lastIsOpen?String(Al.props.id):null;return(!l||ns(e.zone)!==l&&ns(o)!==l)&&((e,n,t,o)=>{if(e===n)return!0;const r=o??Ti(e)[t];if(!r)return!1;const i=n.split(":")[0],l=Pi.get(i),s=l?Ti(l.zone)[l.index]:void 0;if(!s)return!1;if(!o&&es(r).has(n))return!1;const d=kr(s.type,vr(Rt?.data,s.type,i),n.slice(n.lastIndexOf(":")+1),wr(s));return!!d&&(!!(d.choices?d.choices.some(e=>e.type===r.type):d.spec?.childType===r.type)&&!d.spec?.addBlocked?.(Ti(n),r))})(e.zone,o,e.index,t)},is=(e,n)=>{const t=Tn(e.from),o=e.node;return t===Tn(n)?os(t,o.type):rs({id:String(o.props?.id??""),zone:t,index:-1,type:o.type},n,o)},ls=e=>{const n=e.slice(0,e.indexOf(":")),t=Pi.get(n),o=t?Ti(t.zone)[t.index]:void 0;if(!t||!o)return null;const r=kr(o.type,vr(Rt?.data,o.type,n),e.slice(e.lastIndexOf(":")+1),wr(o));if(!r||`${n}:${r.slot}`!==e)return null;if("footer"===r.source)return null;const i=O(r.choices??(r.spec?[{type:r.spec.childType,label:Ni(r.spec.childType)}]:[])),l=Ai(e);return{parent:o,parentId:n,target:r,choices:i,parentName:l?l.slot.label:pl(o,t.zone===Ne)}},ss=(e,n)=>{if("section"!==e.kind)return e;const t=Tn(n);return t===Ne||ts(t)?e:ls(t)?.choices.some(n=>n.type===e.type)?{kind:"block",type:e.type}:e},ds=(e,n)=>{const t=ss(e,n),o=Tn(n);if("shared"===t.kind){if(o!==Ne||!Yt.shared?.nodeOf(t.section))return!1;const{floor:e,cap:r}=fi();return n.index>=e&&n.index<=r}if("block"!==t.kind){if(ts(o)){const e="section"===t.kind?t.type:t.template.node.type;return os(o,e)&&n.index>=0&&n.index<=Ti(o).length}if(o!==Ne)return!1;const{floor:e,cap:r}=fi();return n.index>=e&&n.index<=r}if(o===Ne)return!1;const r=ls(o);return!(!r||!r.choices.some(e=>e.type===t.type))&&!r.target.spec?.addBlocked?.(Ti(o))},as=(e,n)=>{const t=ss(e,n);if("block"!==t.kind&&ts(Tn(n)))return void((e,n,t)=>{const o="section"===e.kind?e.type:"template"===e.kind?e.template.node.type:null;if(o&&os(n,o)){if("section"===e.kind)vo.insertComponent(n,e.type,t);else{if("template"!==e.kind)return;vo.insertNode(n,t,yi(e.template.node))}tr(R),vo.select({index:t,zone:n})}})(t,Tn(n),n.index);if("section"===t.kind)return void sl(t.type,n.index);if("template"===t.kind)return void((e,n,t)=>{const o=rl(t),r=vo.insertNode(Ne,o,n);ll(o,r,e)})(t.template.name,yi(t.template.node),n.index);if("shared"===t.kind){const e=Yt.shared?.nodeOf(t.section);if(!e)return;const o=rl(n.index);return void(bi.restore(e,{parentId:Pn,slot:$n,index:o})&&ll(o,e.props.id,t.section.title))}const o=Tn(n),r=ls(o);r&&(r.target.spec?$l(r.parentId,r.target.slot,t.type,n.index,r.parent.type):((e,n,t)=>{vo.insertComponent(e,n,t),tr(R),vo.select({index:t,zone:e})})(o,t.type,n.index))},cs=(e,n)=>{e.media?function(e){const n=Us();if(!n||!Hs)return;Xs(n).then(n=>{n&&function(e,n){if(!Hs)return;const t=Hs.create(e,{nodeDefaults:Ii,newNodeId:$e,sectionLabel:Oi,blockIsOffered:Sr}),o=Tn(n);if(o===Ne){const e=rl(n.index),o=vo.insertNode(Ne,e,t);return void ll(e,o,Oi(t.type))}vo.insertNode(o,n.index,t),tr(R),vo.select({index:n.index,zone:o})}(n,e)})}(n):e.rung?Di(e.rung.nodeId,e.index,n.index):e.add?as(e.add,n):e.zone===Ne?il(e.index,n.index):ql(e.zone,Tn(n),e.index,n.index)},[ps]=Rn(()=>yn()),us=vn({keyOf:e=>e.id,readOnly:Boolean($t),session:ps,canDrop:rs,onDrop:cs,onStep:(e,n)=>{e.rung?Di(e.rung.nodeId,e.index,n<0?e.index-1:e.index+2):e.zone===Ne?((e,n)=>{const t=Oi(hi[e]?.type??""),o=il(e,n<0?e-1:e+2);if(!o.moved)return void Kr(n<0?to.sectionFirst({name:t}):to.sectionLast({name:t}));const{floor:r,cap:i}=fi();Kr(to.sectionMoved({name:t,n:o.dest-r+1,total:i-r}))})(e.index,n):ql(e.zone,e.zone,e.index,n<0?e.index-1:e.index+2)}}),hs=Dn(e=>{const{floor:n,cap:t}=fi(),o=[];for(const r of e.nodes){const e=Tn(r.place),i=Ti(e)[r.place.index];if(!i||String(i.props.id)!==r.id)continue;if(Zt(i)||qt(i)||gr(i.type,i))continue;if(Kt(i.type))continue;const l=Boolean(ts(e)),s=e===Ne||l;e===Ne&&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?Oi(i.type):Vi(i),from:r.place})}const r=e.zones.flatMap(e=>{const n=Tn(e.list);if(n===Ne&&0===e.children.length)return[{...e,addLabel:to.addSection,addAlways:!0}];const t=ls(n),o=t?.target.spec?.addLabel;return e.children.length>0||Boolean(t?.choices.length)||Boolean(ts(n))?[o?{...e,addLabel:o}:e]:[]}),i=r.flatMap(e=>{const n=Tn(e.list),t=n===Ne||ts(n)?null:ls(n);return t?.choices.length?hn(e,t.target.spec?.addLabel??to.addBlockHere):[]});return{sources:o,zones:r,seams:i}},[Rt.data]),fs=null==Wt?.props.id?null:String(Wt.props.id),ms=Hn(Le),gs=ms?.selected()&&Wo?.document&&fs?ms.selectedPart?.(Wo.document)??null:null,ys=gs&&fs&&Ee(Rt.data,Vt,fs,gs)?gs:null,vs=ys?.label?{element:ys.element,label:ys.label}:null,bs=null!==ys,ks=Dn(e=>{const n=Vt,t=e=>!e.item.rung&&null!==jn(Rt.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(fs);return i?bs?null:i:r(Qe(Rt.data,n,o.item.id,fs,Fl))??o},[Rt.data,Vt,fs,Fl,bs]),[Ss,ws]=Rn(null),xs=Boolean(Rl||Wl);zn(Wo,"mouseover",e=>{if(!xs)return;const n=Cn(e.target),t=n?yt(Rt.data,Vt,n):null;t!==Ss&&ws(t)}),zn(Wo,"mouseout",e=>{xs&&!e.relatedTarget&&ws(null)});const zs=e=>Zt(e)||qt(e)||Kt(e.type),Cs=e=>{const n=Kt(e.type)?Ni(e.type):Zt(e)?to.header:qt(e)?to.footer:null;return null===n?Bi(e):xr.rowName?xr.rowName(e,"section",n):n},Ns=[];if(xs){const e=fs?yt(Rt.data,Vt,fs):null;for(const n of/* @__PURE__ */new Set([e,Ss])){const e=n?hi.find(e=>String(e.props.id)===n):void 0;if(!e)continue;const t=Zt(e)||e.type===Jt,o=Hl(e);if(o){Ns.push({id:String(e.props.id),label:Cs(e),below:t,reach:o});continue}if(!Rl||!zs(e))continue;const r=Rl(e);r&&Ns.push({id:String(e.props.id),label:r,below:t})}}const Is=he(),Os=Ln(null);Fn(()=>{const e=Yt.changeNotice;if(!e)return;const n=JSON.stringify(hi.filter(zs)),t=Os.current;if(Os.current={doc:Yn,bands:n,index:Dt.index},!t||t.doc!==Yn||t.bands===n)return;Dt.hasPast&&Dt.index>=t.index&&!gt.has(Is)&&(gt.add(Is),Kr(e,"success",{action:{label:to.bar.undo,onClick:()=>Dt.back()},duration:8e3}))},[hi]);const Bs=e=>{tr(R),vo.select(e.zone===Ne?{index:e.index}:{index:e.index,zone:e.zone})},Ps=Q(),$s=()=>({data:Rt.data,device:Io,ops:vo,inspector:ur}),Ts=Ps?.model,Ms=En(()=>Ts?e=>Ts(e,hs(e),$s()):hs,[Ts,hs,Io]),js=Ps?.measure,As=js?(e,n)=>js(e,n,$s()):void 0,Ls=Ps?.canDrop,Es=Ls?(e,n)=>Ls(e,n,rs,$s()):rs,Rs=Ps?.drop,Fs=Rs?(e,n)=>Rs(e,n,cs,$s()):cs,Ds=Ps?.pick,Ws=Ds?e=>Ds(e,Bs,$s()):Bs,Hs=Ps?.media??null,Vs=Ln(null),Ys=En(()=>Hs?{id:ft,zone:"",index:-1,type:Hs.adds.type,add:{kind:Hs.adds.kind,type:Hs.adds.type},media:!0}:null,[Hs]);Fn(()=>{if(!Ys||$t||"undefined"==typeof document)return;const e=e=>{(e=>Array.from(e.dataTransfer?.types??[]).includes(nt))(e)&&(Vs.current=null,ps.start({key:ft,item:Ys}))},n=e=>{ps.get()?.item.media&&(Vs.current=Gn(e.dataTransfer))},t=()=>{ps.get()?.item.media&&ps.end()};return document.addEventListener("dragstart",e),document.addEventListener("drop",n,!0),document.addEventListener("dragend",t,!0),()=>{document.removeEventListener("dragstart",e),document.removeEventListener("drop",n,!0),document.removeEventListener("dragend",t,!0)}},[Ys,$t,ps]);const Us=()=>{const e=Vs.current;return Vs.current=null,e},Js=ue(),Xs=async e=>{if(!Js)return e;const n=await Js(e);return n?{...e,id:n.id,url:n.url}:null};const Ks=(e,n)=>{if(!Hs)return;const t=jn(yo.getState().appState.data,mi,n);if(!t)return;const o=t.node;vo.replaceComponent(Tn(t.place),t.place.index,{...o,props:{...Hs.replace(o,e),id:o.props.id}})},Gs=e=>{const n=Tn(e),t=Ai(n);t&&Ri(t.node,t.slot,!1),al(n,e.index)},Qs=(e,n)=>/* @__PURE__ */pt(Ue,{...$t?{}:us.seam({place:{...Mn(e),index:n}})},`seam:${e}:${n}`),_s={rowClick:ul,isCollapsed:Vr,toggleCollapse:Yr},Zs=e=>{const n=String(e.props.id),t=hi.findIndex(e=>String(e.props.id)===n),o=Gt(n),r=Ti(o),i=Vr(n),l=Ni(e.type),s=xr.rowName?xr.rowName(e,"section",l):l,d=e=>Qs(o,e);/* @__PURE__ */
16
- return ut(ht,{children:[
17
- /* @__PURE__ */pt(De,{words:oo,icon:/* @__PURE__ */pt(Cr,{type:e.type,size:13}),name:s,preview:fl(e),marks:ml(e),onSelect:()=>ol(t),nameSlot:Ui(Ne,t,n,s),selected:or===n,badge:Hl(e)?void 0:Jl,shared:Hl(e),actions:gl(e,Ne,t)??void 0,rowProps:{"data-node-id":n,onClick:ul(()=>ol(t))},fold:{open:!i,label:"section",onToggle:()=>Yr(n)}}),!i&&/* @__PURE__ */ut(We,{children:[r.map((n,t)=>{const r=String(n.props.id),i=Bi(n),l=Ol(n),s=l&&Vr(r),a=()=>Pl(o,t,r,e.type),{rowProps:c,...p}=us.row({item:{id:r,zone:o,index:t,type:n.type},place:{...Mn(o),index:t}},{"data-node-id":r,onClick:ul(a)});/* @__PURE__ */
18
- return ut(Vn,{children:[d(t),
19
- /* @__PURE__ */pt(De,{words:oo,icon:/* @__PURE__ */pt(Cr,{type:n.type,size:13}),name:i,preview:fl(n),marks:ml(n),onSelect:a,nameSlot:Ui(o,t,r,i),selected:or===r,hidden:Boolean(n.props._hidden),...p,fold:l?{open:!s,label:"section",onToggle:()=>Yr(r)}:void 0,actions:/* @__PURE__ */ut(ht,{children:[hl(o,t,i),gl(n,o,t),yl(o,t,n,i)]}),rowProps:c}),l&&!s&&/* @__PURE__ */pt(We,{children:nd(n,2)})]},r)}),d(r.length)]})]})},qs=(e,n,t,o,r)=>{const i=String(e.props.id),l=`${i}:${n.slot}`,s=us.dragging,d=!Vr(l)&&s?.rung?.nodeId!==i,a={...Mn(l),index:0},c=s&&!s.rung&&rs(s,a)?a:void 0,p=()=>Ri(e,n,!0),{rowProps:u,...h}=us.row({item:{id:`rung:${l}`,zone:`${i}:${wt}`,index:t,type:e.type,rung:{nodeId:i,slot:n.slot}},place:{parentId:i,slot:wt,index:t},into:c,canDrag:Boolean(mr.moveSlot)&&!1!==n.movable&&o>1},{"data-slot-zone":l,onClick:ul(p)}),f=$t?null:mr.slotActions?.(e,n.slot);/* @__PURE__ */
20
- return ut(Vn,{children:[n.heading,
21
- /* @__PURE__ */pt(De,{words:oo,icon:n.glyph??null,name:n.label,badge:n.badge,onSelect:p,selected:Li===l,...h,dragHint:n.dragHint,fold:{open:d,label:n.label,onToggle:()=>Yr(l)},actions:f&&f.length>0?/* @__PURE__ */pt(ht,{children:f.map((t,o)=>/* @__PURE__ */pt(Ye,{kind:"delete"===t.kind?"delete":"plain",label:t.label,disabled:t.disabled,onClick:()=>((e,n,t)=>{if($t||t.disabled)return;const o=String(e.props.id),r=e=>{"string"==typeof e&&Fi(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__ */pt(lt,{size:15}):/* @__PURE__ */pt(ct,{size:15})},`${o}:${t.kind}`))}):void 0,rowProps:u}),d&&/* @__PURE__ */pt(We,{children:r})]},l)},ed=(e,n)=>{const t=wl(e),o=t.filter(e=>e.rung).length;let r=0;/* @__PURE__ */
22
- return pt(ht,{children:t.map(t=>{const i=t.kids,l=t.rung?n+1:n,s=Cl(e,void 0,t.slot),d=s?`${e.props.id}:${s.slot}`:null,a=null===t.slot?null:`${e.props.id}:${t.slot}`,c=(e,n)=>Qs(e,n),p=/* @__PURE__ */ut(ht,{children:[i.map(({child:n,zone:t,index:o})=>{const r=or===String(n.props.id),{collapsible:i,folded:s}=Nl(n,l,Bl(n.type)),d=String(n.props.id),a=Zl(n),p=()=>Pl(t,o,d,e.type),{rowProps:u,...h}=us.row({item:{id:d,zone:t,index:o,type:n.type},place:{...Mn(t),index:o}},{"data-node-id":d,onClick:ul(p)});/* @__PURE__ */
23
- return ut(Vn,{children:[0===o&&c(t,0),
24
- /* @__PURE__ */pt(De,{words:oo,icon:/* @__PURE__ */pt(Cr,{type:n.type,size:13}),name:a,preview:fl(n),marks:ml(n),onSelect:p,nameSlot:Ui(t,o,d,a),selected:r,hidden:Boolean(n.props._hidden),...h,fold:i?{open:!s,label:"group",onToggle:()=>Yr(d)}:void 0,actions:/* @__PURE__ */ut(ht,{children:[hl(t,o,a),gl(n,t,o),yl(t,o,n,a)]}),rowProps:u}),i&&!s&&/* @__PURE__ */pt(We,{children:ed(n,l+1)}),c(t,o+1)]},String(n.props.id??`${t}-${o}`))}),null===a?d&&!i.some(e=>e.zone===d)?c(d,0):null:0!==i.length||!t.rung&&d!==a?null:c(a,0)]});return t.rung?qs(e,t.rung,r++,o,p):/* @__PURE__ */pt(Vn,{children:p},t.slot??"")})})},nd=(e,n)=>{const t=vr(Rt?.data,e.type,String(e.props.id)),o=wl(e),r=o.filter(e=>e.rung).length;let i=0;/* @__PURE__ */
25
- return pt(ht,{children:o.map(o=>{const l=o.kids,s=o.rung?n+1:n,d=Cl(e,t,o.slot),a=d?.spec??null,c=a&&Array.isArray(e.props[a.slot])?e.props[a.slot]:[],p=d&&d.choices?{slot:d.slot,choices:d.choices}:null,u=String(e.props.id),h=a&&!a.fixed?`${u}:${a.slot}`:null,f=p?`${u}:${p.slot}`:null,m=(e,n)=>Qs(e,n),g=null===o.slot?null:`${u}:${o.slot}`,y=Boolean(a&&!a.fixed&&(null===g||g===h)),v=/* @__PURE__ */ut(ht,{children:[l.map(({child:n,zone:t,index:o})=>{const r=or===String(n.props.id),i=Vi(n),l=String(n.props.id),{collapsible:d,folded:a}=Nl(n,s,Bl(n.type)),c=kl(n.type),p=1===c.length?`${l}:${c[0]}`:null,u=p?{...Mn(p),index:Ti(p).length}:void 0,h=us.dragging,f=u&&h&&rs(h,u)?u:void 0,g=()=>Pl(t,o,l,e.type),{rowProps:y,...v}=us.row({item:{id:l,zone:t,index:o,type:n.type},place:{...Mn(t),index:o},into:f,canDrag:!gr(n.type,n)},{"data-node-id":l,onClick:ul(g)});/* @__PURE__ */
26
- return ut(Vn,{children:[0===o&&m(t,0),
27
- /* @__PURE__ */pt(De,{words:oo,icon:/* @__PURE__ */pt(Cr,{type:n.type,size:13}),name:i,preview:fl(n),marks:ml(n),onSelect:g,nameSlot:Ui(t,o,l,i),selected:r,hidden:Boolean(n.props._hidden),...v,fold:d?{open:!a,label:"group",onToggle:()=>Yr(l)}:void 0,actions:gr(n.type,n)?gl(n,t,o)??void 0:/* @__PURE__ */ut(ht,{children:[hl(t,o,i),gl(n,t,o),yl(t,o,n,i)]}),rowProps:y}),d&&!a&&/* @__PURE__ */pt(We,{children:nd(n,s+1)}),m(t,o+1)]},String(n.props.id??`${t}-${o}`))}),y&&a&&
28
- /* @__PURE__ */pt(S,{small:!0,label:a.addLabel,blocked:a.addBlocked?.(c)??null,onAdd:()=>$l(e.props.id,a.slot,a.childType,c.length,e.type)}),null===g?f&&!l.some(e=>e.zone===f)?m(f,0):null:0!==l.length||(o.rung?y:g!==f)?null:m(g,0)]});return o.rung?qs(e,o.rung,i++,r,v):/* @__PURE__ */pt(Vn,{children:v},o.slot??"")})})},td=Ko,od=e=>"panel"in e?{id:e.id,label:e.label,icon:e.icon,active:ko&&!td&&fr===e.id,onSelect:()=>pi(e.id)}:e,rd=[...(hr.railLead??[]).map(od),{id:"sections",label:to.layers,icon:/* @__PURE__ */pt(ge,{}),active:ko&&!td&&"sections"===fr,onSelect:()=>pi("sections")},...(hr.railTrail??[]).map(od)],id=Po?{onPress:$o}:At?{onPress:()=>{se(Sn,{accept:"image/*",title:co.mediaLibrary})}}:null,ld={value:rd.find(e=>!0===e.active)?.id??"",press:e=>{const n=rd.find(n=>n.id===e);n&&!n.disabled&&!0!==n.active&&n.onSelect?.()},items:rd.map(e=>({id:e.id,icon:e.icon,label:/* @__PURE__ */pt("span",{className:"sr-only",children:e.label}),tooltip:e.label,disabled:e.disabled}))},sd=[...hr.railLead??[],...hr.railTrail??[]].find(e=>"panel"in e&&e.id===fr),dd=Boolean(no?.foldable),ad=no?.label??(Lt?to.pageSections:to.templateSections),cd=dd&&Vr(xt),pd=/* @__PURE__ */ut(ht,{children:[hi.map((e,n)=>{if(Zt(e)||qt(e)||Kt(e.type))return null;const t=or===String(e.props.id),o=Boolean(e.props._hidden);Sl(e);const r=String(e.props.id),i=hr.hasOwnRows?.(e)??!1,l=Ol(e)||i,s=l&&Vr(r),d=kl(e.type),a=1===d.length?`${r}:${d[0]}`:null,c=a?{...Mn(a),index:Ti(a).length}:void 0,p=us.dragging,u=c&&p&&rs(p,c)?c:void 0,{rowProps:h,...f}=us.row({item:{id:r,zone:Ne,index:n,type:e.type},place:{...Mn(Ne),index:n},into:u,canDrag:!gr(e.type,e)},{"data-node-id":r,onClick:ul(()=>ol(n))});/* @__PURE__ */
29
- return ut(Vn,{children:[n>0&&vl(n),
30
- /* @__PURE__ */pt(De,{words:oo,icon:/* @__PURE__ */pt(Cr,{type:e.type,size:13}),name:Bi(e),preview:fl(e),marks:ml(e),shared:Hl(e),onSelect:()=>ol(n),nameSlot:Ui(Ne,n,r,Bi(e)),selected:t,hidden:o,...f,fold:l?{open:!s,label:"section",onToggle:()=>Yr(r)}:void 0,actions:/* @__PURE__ */ut(ht,{children:[hl(Ne,n,Bi(e)),gl(e,Ne,n),yl(Ne,n,e,Bi(e))]}),rowProps:h}),Ol(e)&&!s&&/* @__PURE__ */ut(We,{children:[nd(e,1),hr.partRows?.(e,_s)]}),i&&!s&&/* @__PURE__ */pt(We,{children:hr.ownRows?.(e,n,_s)})]},String(e.props.id??n))}),Gl>0&&vl(Gl)]}),ud=(e,n,t)=>{const o=String(e.props.id),r=xl(e).length>0||zl(e)||Boolean(kr(e.type)),i=r&&Vr(o),l="header"===t?to.header:to.footer,s=xr.rowName?xr.rowName(e,"section",l):l;/* @__PURE__ */
31
- return ut(ht,{children:[
32
- /* @__PURE__ */pt(De,{words:oo,icon:/* @__PURE__ */pt(Cr,{type:t,size:13}),name:s,preview:fl(e),marks:ml(e),badge:Hl(e)?void 0:Jl,shared:Hl(e),onSelect:()=>ol(n),nameSlot:Ui(Ne,n,o,s),selected:or===String(e.props.id),fold:r?{open:!i,label:"section",onToggle:()=>Yr(o)}:void 0,actions:gl(e,Ne,n)??void 0,rowProps:{"data-node-id":o,onClick:ul(()=>ol(n))}}),r&&!i&&/* @__PURE__ */pt(We,{children:ed(e,1)})]})};return(hr.wrap??(e=>e))(
33
- /* @__PURE__ */pt(_,{target:Wo,children:/* @__PURE__ */ut("div",{ref:Do,className:"sf-editor es-editor",style:ln(Rr),onContextMenu:_i.onEditorContextMenu,...p(Sn),children:[
34
- /* @__PURE__ */ut(_e,{children:[
35
- /* @__PURE__ */ut("div",{className:"es-cluster es-cluster--left",children:[id?/* @__PURE__ */pt(Jn,{variant:"secondary",className:"es-barbtn",leftIcon:/* @__PURE__ */pt(ye,{}),onClick:id.onPress,children:to.railMedia}):null,
36
- /* @__PURE__ */pt(Ze,{label:to.bar.undo,disabled:Boolean($t)||!Dt.hasPast,onClick:()=>Dt.back(),children:/* @__PURE__ */pt(tt,{})}),
37
- /* @__PURE__ */pt(Ze,{label:to.bar.redo,disabled:Boolean($t)||!Dt.hasFuture,onClick:()=>Dt.forward(),children:/* @__PURE__ */pt(ot,{})})]}),
38
- /* @__PURE__ */ut(qe,{children:[
39
- /* @__PURE__ */pt(en,{devices:wo,value:Io,onChange:Oo}),
40
- /* @__PURE__ */pt(Ze,{label:to.bar.refresh,tip:to.bar.refreshTip,onClick:()=>{Fo.current=(()=>{const e=Wo?.document;if(!e)return null;const n=hi.findIndex(qt),t=n>=0?n:hi.length;let o=null;for(let n=0;n<t;n++){const t=hi[n]?.props?.id;if(null==t)continue;const r=Bn(e,`[data-easel-block="${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=Wt?.props?.id??hi[0]?.props?.id;null!=e&&(o={id:String(e),offset:0})}return o})(),Ro(e=>e+1)},children:/* @__PURE__ */pt(rt,{})}),hr.barView?.()]}),
41
- /* @__PURE__ */ut(qe,{kind:"right",style:{minWidth:300},children:[
42
- /* @__PURE__ */pt(v,{input:Jo,words:to.saveStatus}),Nn?/* @__PURE__ */pt(Nn,{}):null,hr.barLead?.(),hr.barTrail?.(),hr.mainAction||!hr.barMain?/* @__PURE__ */pt(b,{input:Jo,action:hr.mainAction??{label:to.done,onPress:()=>{qn(Rt.data)}},readOnly:Boolean($t),saveSwitch:Mt,onToggleAutoSave:It,onSaveNow:Xo,bar:to.bar,words:to.saveStatus}):hr.barMain()]})]}),
43
- /* @__PURE__ */pt(ie,{}),
44
- /* @__PURE__ */ut("div",{className:"sf-body",children:[ko?/* @__PURE__ */ut(ht,{children:[
45
- /* @__PURE__ */ut("aside",{className:"es-sidepanel es-sidepanel--left sf-panel sf-panel--left","aria-label":to.leftPanel,children:[
46
- /* @__PURE__ */ut("div",{className:"es-paneltabs es-paneltabs--with-hide",children:[
47
- /* @__PURE__ */pt(C,{side:"left",onHide:ai}),
48
- /* @__PURE__ */pt("span",{className:"es-paneltabs-divider","aria-hidden":"true"}),
49
- /* @__PURE__ */pt(Xn,{variant:"underline",block:!0,"aria-label":to.bar.views,value:ld.value,onChange:ld.press,items:ld.items})]}),Ko?/* @__PURE__ */pt(w,{at:_o?{label:(e=>{const n=ts(e.zone);if(n)return to.add.addingTo({name:xr.rowName?pl(n,!0):Ni(n.type)});if(e.zone===Ne){const n=hi[e.index];return n&&!qt(n)?to.add.addingBefore({name:pl(n,!0)}):to.add.addingAtEnd}const t=ls(e.zone);return t?to.add.addingTo({name:t.parentName}):to.add.addingHere})(_o),onClear:()=>Zo(null)}:void 0,placeBlocks:_o&&_o.zone!==Ne?ls(_o.zone)?.choices:void 0,canTake:_o?e=>{if(!_o)return null;const n={...Mn(_o.zone),index:_o.index};if(ds(e,n))return null;if("shared"===e.kind&&_o.zone===Ne&&!Yt.shared?.nodeOf(e.section))return to.shared.alreadyHere;const t=ts(_o.zone);if(t)return to.add.notInside({name:pl(t,!0)});if(_o.zone===Ne)return to.add.onlySections;const o=ls(_o.zone);return o?to.add.notInside({name:o.parentName}):to.add.onlySections}:void 0,onPick:_o?e=>{if(!_o)return;const n={...Mn(_o.zone),index:_o.index};ds(e,n)&&(as(e,n),cl())}:void 0,itemFor:e=>({id:`new:${e.kind}:${"template"===e.kind?e.template.id:"shared"===e.kind?e.section.id:e.type}`,zone:"",index:-1,type:"template"===e.kind?e.template.node.type:"shared"===e.kind?e.section.node.type:e.type,add:e}),session:ps,siteWide:hr.addPanelRow?.(cl),onClose:cl,readOnly:Boolean($t)}):sd?sd.panel({onHide:ai,notify:Kr}):/* @__PURE__ */ut(ht,{children:[
50
- /* @__PURE__ */pt(N,{icon:/* @__PURE__ */pt(ge,{}),title:to.layers,context:po,actions:/* @__PURE__ */ut(ht,{children:[!$t&&/* @__PURE__ */pt(nn,{label:to.add.title,onClick:()=>dl(null),children:/* @__PURE__ */pt(it,{size:15})}),
51
- /* @__PURE__ */pt(nn,{label:_l?to.expandAll:to.collapseAll,title:0===Ql.length?to.nothingToFold:void 0,disabled:0===Ql.length,onClick:()=>Er(e=>{const n=new Set(Ql);return _l?new Set([...e].filter(e=>!n.has(e))):/* @__PURE__ */new Set([...e,...Ql])}),children:/* @__PURE__ */pt(bt,{expand:_l})})]})}),
52
- /* @__PURE__ */ut(He,{className:"sf-tree sf-scroll",words:oo,children:[Xl&&/* @__PURE__ */ut(ht,{children:[!Dl&&/* @__PURE__ */pt(Ve,{children:to.header}),Zs(Xl)]}),Et&&!(Dl&&Xl)&&/* @__PURE__ */ut(ht,{children:[!Dl&&/* @__PURE__ */pt(Ve,{children:to.header}),!eo&&/* @__PURE__ */pt(De,{words:oo,icon:/* @__PURE__ */pt(Cr,{type:"header",size:13}),name:to.header,badge:Ul?void 0:Jl,shared:Ul,onSelect:ui,selected:nr.kind===_t?.kind,rowProps:{onClick:ul(ui)}})]}),El&&!(Dl&&Xl)&&ud(El,Ll,"header"),!dd&&/* @__PURE__ */pt(Ve,{children:ad}),dd?/* @__PURE__ */ut(ht,{children:[
53
- /* @__PURE__ */pt(De,{words:oo,icon:null,name:ad,fold:{open:!cd,label:ad,onToggle:()=>Yr(xt)}}),!cd&&/* @__PURE__ */pt(We,{children:pd})]}):pd,Et&&!Dl&&/* @__PURE__ */pt(Ve,{children:to.footer}),Al&&!(Dl&&Kl)&&ud(Al,jl,"footer"),Kl&&Zs(Kl),hr.treeFoot?.()]})]})]}),
54
- /* @__PURE__ */pt(tn,{side:"left",width:Rr.left,min:rn.left,max:on,defaultWidth:f.left,label:to.resizeLeftPanel,onResize:Wr})]}):/* @__PURE__ */pt(I,{side:"left",onShow:ai}),
55
- /* @__PURE__ */ut("div",{ref:Gr,className:"sf-center sf-scroll","data-sf-canvas-head":ei?"":void 0,style:{overflowX:li?"auto":"hidden",overflowY:"hidden"},children:[ei&&/* @__PURE__ */pt("div",{ref:ni,className:"sf-canvas-head",children:/* @__PURE__ */pt(ei,{device:Io})}),
56
- /* @__PURE__ */ut("div",{className:"sf-frame-scaler",style:si,children:[
57
- /* @__PURE__ */pt("div",{className:"sf-frame "+(Io===Co?"":`sf-frame--${Io}`),style:di,children:/* @__PURE__ */ut("div",{className:"sf-preview-host",children:[
58
- /* @__PURE__ */pt(Re.Provider,{value:Fl,children:/* @__PURE__ */pt(Fe.Provider,{value:Yl,children:/* @__PURE__ */pt(uo,{},Eo)})}),
59
- /* @__PURE__ */pt(fn,{canvas:Wo,session:ps,model:Ms,measure:As,canDrop:Es,onDrop:Fs,choose:ks,tag:vs,onPick:Ws,dropOn:Hs?{accepts:(e,n)=>{if(!e.media||!Hs||n.item.rung)return!1;const t=jn(Rt.data,mi,n.item.id);return null!==t&&Hs.takes(t.node)},onDrop:(e,n)=>(e=>{const n=Us();n&&Hs&&Xs(n).then(n=>{n&&Ks(n,e.item.id)})})(n),label:()=>to.canvasReplaceImage}:void 0,onZoneAdd:Gs,onSeamAdd:Gs,zoneAddLabel:to.canvasAddBlock,words:ro.canvas,readOnly:Boolean($t),revision:Rt.data}),qo.length>0&&!Ho&&/* @__PURE__ */pt("div",{className:"sf-preview-gaps",children:qo.map(e=>
60
- /* @__PURE__ */pt(mn,{index:e.index,label:to.addSectionHere,onInsert:()=>dl(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))})]})}),xs?/* @__PURE__ */pt(vt,{canvas:Wo,tabs:Ns,onSelect:e=>{const n=hi.findIndex(n=>String(n.props.id)===e);n>=0&&ol(n)}}):null]})]}),So?/* @__PURE__ */ut(ht,{children:[In?
61
- /* @__PURE__ */pt("div",{className:"es-sidepanel es-sidepanel--right","data-es-host-panel":"",children:In}):/* @__PURE__ */pt(ht,{children:/* @__PURE__ */pt(u,{value:{selectChild:Pl,addChild:$l,childRowName:Vi,blockRowName:Zl},children:/* @__PURE__ */pt(ho,{mode:nr,onOpenWebsiteSettings:hr.openSettings??(()=>{}),onOpenSiteStyles:hr.openStyles,onOpenPageStyles:hr.openPageStyles,onSelectNode:Br,onNotify:Kr,onHidePanel:ci,nodeActions:Wt?Ie(Vt,Wt.type):zt})})}),
62
- /* @__PURE__ */pt(tn,{side:"right",width:Rr.right,min:rn.right,max:on,defaultWidth:f.right,label:to.resizeSettingsPanel,onResize:Hr})]}):
63
- /* @__PURE__ */pt(I,{side:"right",onShow:ci})]}),_i.menu,
64
- /* @__PURE__ */pt(te,{}),Si?/* @__PURE__ */pt(mt,{name:Si.name,onMake:e=>(async(e,n)=>{const t=hi.find(n=>String(n.props.id)===e),o=Yt.shared;if(!t||!o)return;let r;try{r=await z(ki).create(n,t)}catch{return void Kr(to.shared.makeFailed,"error")}o.adopt(t,r),wi(null)})(Si.id,e),onCancel:()=>wi(null)}):null]})}))}export{Nt as ScreenChrome};
@@ -1 +0,0 @@
1
- import{DEFAULT_STYLE_CLIPBOARD_WORDS as t}from"./chunk-6WY6ZXJG.js";import{CopyStyleIcon as e,PasteStyleIcon as n}from"efficient-shell/icons/efficient";import{jsx as o}from"react/jsx-runtime";var r="__styleKind";function c(t,e){return t[r]=e,t}function i(t,e){return`${t}:${e.map(t=>String(t)).sort().join("|")}`}function u(t){if(!t)return null;const e=t.indexOf(":");if(e<0)return null;const n=t.slice(0,e);return s.has(n)?{control:n,values:t.slice(e+1).split("|")}:null}var s=/* @__PURE__ */new Set(["choice","select","radio"]);function l(t){if(!t||"object"!=typeof t)return null;const e=t;return"string"==typeof e[r]?e[r]:"text"===e.type||"textarea"===e.type||"number"===e.type?e.type:"select"!==e.type&&"radio"!==e.type||!Array.isArray(e.options)?null:i(e.type,e.options.map(t=>t?.value))}function a(t){return null!=t&&""!==t}function p(t,e){let n=t;for(const t of e){if(!n||"object"!=typeof n)return;n=n[t]}return n}function f(t){return void 0===t?t:JSON.parse(JSON.stringify(t))}function d(t,e,n){const[o,...r]=e,c={...t};if(0===r.length)return void 0===n?delete c[o]:c[o]=n,c;const i=c[o],u=d(i&&"object"==typeof i?i:{},r,n);return 0===Object.keys(u).length?delete c[o]:c[o]=u,c}var y=t=>t.join("."),h="editor-shell:style-clipboard",g=null,m=!1,v=/* @__PURE__ */new Set;function S(){try{return"undefined"==typeof sessionStorage?null:sessionStorage}catch{return null}}function b(){if(!m){m=!0;try{const t=S()?.getItem(h);t&&(g=JSON.parse(t))}catch{g=null}}}function k(t){b(),g={scope:t.scope,sourceType:t.type,sourceLabel:t.label,rows:t.rows.map(e=>{const n=p(t.props,e.path);return{path:[...e.path],kind:e.kind,counted:!1!==e.counted,value:a(n)?f(n):void 0}})};try{S()?.setItem(h,JSON.stringify(g))}catch{}return v.forEach(t=>t()),g}function N(t){return b(),g&&g.scope===t?g:null}function C(t){return v.add(t),()=>{v.delete(t)}}function j(){g=null,m=!0;try{S()?.removeItem(h)}catch{}v.forEach(t=>t())}function w(t,e,n){if(t.kind===e.kind)return null!==e.kind||n;const o=u(t.kind),r=u(e.kind);return!(!o||!r||o.control!==r.control)&&(!a(t.value)||r.values.includes(String(t.value)))}function O(t,e){const n=t.sourceType===e.type,o=new Map(t.rows.map(t=>[y(t.path),t]));let r=e.props,c=0,i=!1;for(const t of e.rows){const e=o.get(y(t.path));if(!e)continue;if(!w(e,t,n))continue;const u=p(r,t.path),s=void 0===e.value?void 0:f(e.value);JSON.stringify(a(u)?u:void 0)!==JSON.stringify(s)&&(r=d(r,t.path,s),i=!0),!1!==t.counted&&(c+=1)}return{props:r,pasted:c,changed:i}}function E(e,n,o,r=t){return 0===e.pasted?r.nothing({source:n,target:o}):r.pasted({count:e.pasted,source:n})}var J="⌥⌘C",K="⌥⌘V";function T(r){const c=r.words??t,i=[];return r.canCopy&&i.push({label:c.copy,icon:/* @__PURE__ */o(e,{}),shortcut:"⌥⌘C",onClick:r.onCopy}),r.held&&i.push({label:c.paste({source:r.held.sourceLabel}),icon:/* @__PURE__ */o(n,{}),shortcut:"⌥⌘V",onClick:r.onPaste}),i}function x(t){if(!t.altKey||t.shiftKey||!t.metaKey&&!t.ctrlKey)return null;const e=t.target;return e&&(e.isContentEditable||"INPUT"===e.tagName||"TEXTAREA"===e.tagName||"SELECT"===e.tagName)?null:"KeyC"===t.code?"copy":"KeyV"===t.code?"paste":null}export{J as COPY_STYLE_SHORTCUT,K as PASTE_STYLE_SHORTCUT,r as STYLE_KIND,i as choiceKind,j as clearStyle,k as copyStyle,l as fieldKind,N as heldStyle,E as pasteMessage,O as planPaste,T as styleMenuItems,x as styleShortcut,C as subscribeStyle,c as withStyleKind};
@@ -1 +0,0 @@
1
- function e(e,n){const o=e.categories??{},c=e.components,i=[];for(const[s,r]of Object.entries(o))if(!1!==r?.visible)for(const o of r?.components??[]){const r=c[o];if(!r)continue;const a=r.label??o,l=n.labelAtLevel(o,"section",a);i.push({type:o,cat:s,catLabel:t(e,s,n.categoryLabel),name:l,desc:n.descriptions[o]??"",...l===a?{}:{alias:a}})}return i}function t(e,t,n){return n(t)??e.categories?.[t]?.title??t}function n(e,t){return!t||`${e.name} ${e.alias??""} ${e.desc} ${e.type} ${e.catLabel}`.toLowerCase().includes(t)}function o(e,t){return e.find(e=>e.type===t)??null}function c(e,t){return e.filter(e=>e.type!==t)}export{e as buildPaletteSections,t as categoryLabel,n as matchesQuery,c as paletteWithoutPinned,o as pinnedSection};
@@ -1 +0,0 @@
1
- import{useState as t,useEffect as e,useRef as n}from"react";var o=/* @__PURE__ */new Set(["button","checkbox","color","file","hidden","image","radio","range","reset","submit"]);function r(t){const e=t;if(!e||"string"!=typeof e.tagName)return!1;const n=e.tagName.toUpperCase();if("TEXTAREA"===n||"SELECT"===n)return!0;if("INPUT"===n)return!o.has(String(e.type??"text").toLowerCase());if(e.isContentEditable)return!0;const r=e.closest?.("[contenteditable]");return!(!r||"false"===r.getAttribute("contenteditable"))||null!=e.closest?.('[role="textbox"]')}var i="data-easel-block";function c(t,e=i){const n=t;return n&&"function"==typeof n.closest?n.closest(`[${e}]`)?.getAttribute(e)??null:null}function u(t){const e=t.getBoundingClientRect();if(e.width>0&&e.height>0)return{left:e.left,top:e.top,width:e.width,height:e.height};let n=1/0,o=1/0,r=-1/0,i=-1/0;for(const e of Array.from(t.children)){const t=u(e);t.width<=0||t.height<=0||(n=Math.min(n,t.left),o=Math.min(o,t.top),r=Math.max(r,t.left+t.width),i=Math.max(i,t.top+t.height))}return n===1/0?{left:e.left,top:e.top,width:e.width,height:e.height}:{left:n,top:o,width:r-n,height:i-o}}function s(t,e){return t===e||t.contains(e)||e.contains(t)}var l=4;function a(t){const e=t.offsetWidth;if(!e)return 1;const n=t.getBoundingClientRect().width;return n>0?n/e:1}function d(t,e,n){const o=t.getBoundingClientRect(),r=n?.getBoundingClientRect()??{left:0,top:0},i=a(t);return{left:o.left-r.left+e.left*i,top:o.top-r.top+e.top*i,width:e.width*i,height:e.height*i}}function f(t){const e=t.offsetWidth;if(!e)return 1;const n=t.getBoundingClientRect().width;return n>0?n/e:1}function h(t,e,n){const o=d(t,e,n),r=f(n);return{left:o.left/r,top:o.top/r,width:o.width/r,height:o.height/r}}function m(t,e,n){const o=t.getBoundingClientRect(),r=f(t);return{x:(e-o.left)/r,y:(n-o.top)/r}}function w(t,e,n,o){const{left:r,top:i}=d(t,{left:e,top:n,width:0,height:0},o);return{x:r,y:i}}function b({available:t,width:e,maxScale:n=1}){const o=Math.max(0,t);if(!e||e<=0)return{width:o,scale:1,shownWidth:o};const r=o>0?Math.min(o/e,n):1;return{width:e,scale:r,shownWidth:e*r}}var g="data-es-canvas-style",v=/* @__PURE__ */new WeakMap;function p(t,e){e?v.set(t,e):v.delete(t)}function y(t,e,n){const o=t.head??t.documentElement;let r=A(t,e);if(!r){r=t.createElement("style"),r.setAttribute(g,e);const n=v.get(t);n&&r.setAttribute("nonce",n),o.appendChild(r)}return r.textContent!==n&&(r.textContent=n),r}function E(t,e){A(t,e)?.remove()}function A(t,e){for(const n of Array.from(t.querySelectorAll(`style[${g}]`)))if(n.getAttribute(g)===e)return n;return null}var C="[data-easel-block]",L="[data-easel-dropzone]",x="iframe#preview-frame";function M(t){const e=t.contentDocument;if(!e||!t.contentWindow||"loading"===e.readyState||!e.body)return!1;if(t.hasAttribute("srcdoc"))return"about:srcdoc"===e.URL;const n=t.getAttribute("src");return!n||"about:blank"===n||"about:blank"!==e.URL}function S(t,e,{selector:n=x,readySelector:o}={}){let r=null,i=null,c=!1,u=!1,s=null;const l=()=>{s?.observer.disconnect(),s=null},a=()=>{if(u)return;let t=null;if(r&&M(r)){const e=r.contentDocument;(t=>{if(!o||t.querySelector(o))return l(),!0;if(s?.doc!==t){l();const e=t.defaultView?.MutationObserver;if(e){const n=new e(()=>a());n.observe(t,{childList:!0,subtree:!0}),s={doc:t,observer:n}}}return!1})(e)&&(t={frame:r,document:e,window:r.contentWindow})}else l();(t===i||!!t&&!!i&&t.frame===i.frame&&t.document===i.document)&&c||(c=!0,i=t,e(i))},d=()=>a(),f=()=>{const e=t.querySelector?.(n);e!==r?(r?.removeEventListener("load",d),r=e,r?.addEventListener("load",d),a()):a()},h=t.ownerDocument?.defaultView??t.defaultView,m=h?.MutationObserver,w=m?new m(t=>(t=>null!==r&&!r.isConnected||t.some(t=>[...t.addedNodes,...t.removedNodes].some(t=>"IFRAME"===t.nodeName||!!t.querySelector?.("iframe"))))(t)&&f()):null;return w?.observe(t,{childList:!0,subtree:!0}),f(),()=>{u=!0,w?.disconnect(),l(),r?.removeEventListener("load",d),r=null}}function R(n,{selector:o,readySelector:r}={}){const[i,c]=t(null);return e(()=>{const t=n.current;if(!t)return;const e=S(t,c,{selector:o,readySelector:r});return()=>{e(),c(null)}},[n,o,r]),i}var B="easel:canvas-typing",W="easel:canvas-typable";function k(t,o,r,{on:i="document",capture:c=!1}={}){const u=n(r);u.current=r;const s=t?.document??null,l=t?.window??null;e(()=>{const t="window"===i?l:s;if(!t)return;const e=t=>u.current(t);return t.addEventListener(o,e,c),()=>t.removeEventListener(o,e,c)},[s,l,o,i,c])}function q(e){const[n,o]=t(!1);return k(e,B,t=>o(Boolean(t.detail?.typing))),n}function N(t,n,o){const r=t?.document??null;e(()=>{if(!r)return;if(!o)return void E(r,n);const t=y(r,n,o),e=r.defaultView?.MutationObserver,i=e?new e(()=>{t.isConnected||y(r,n,o)}):null;return i?.observe(r.head??r.documentElement,{childList:!0}),()=>{i?.disconnect(),E(r,n)}},[r,n,o])}function T(n,{settle:o=[150,450]}={}){const[r,i]=t(0),c=n?.frame??null,u=n?.document??null,s=n?.window??null,l=o.join(",");return e(()=>{if(!c||!u||!s)return;const t=c.ownerDocument.defaultView;let e=!1,n=0;const r=()=>{if(e)return;e=!0;const o=()=>{e=!1,i(t=>t+1)};t?.requestAnimationFrame?n=t.requestAnimationFrame(o):o()},l=[],a=(t,e)=>{t.addEventListener(e,r,!0),l.push(()=>t.removeEventListener(e,r,!0))};a(u,"scroll"),a(s,"resize"),t&&(a(t,"scroll"),a(t,"resize"));const d=t?.ResizeObserver;if(d){const t=new d(r);t.observe(c),u.documentElement&&t.observe(u.documentElement),l.push(()=>t.disconnect())}const f=u.defaultView?.MutationObserver,h=u.body??u.documentElement;if(f&&h){const t=new f(r);t.observe(u===c.ownerDocument?c:h,{childList:!0,subtree:!0}),l.push(()=>t.disconnect())}const m=u.fonts;m&&a(m,"loadingdone");const w=o.map(t=>setTimeout(r,t));return r(),()=>{for(const t of l)t();for(const t of w)clearTimeout(t);n&&t?.cancelAnimationFrame&&t.cancelAnimationFrame(n)}},[c,u,s,l]),r}export{i as BLOCK_ATTRIBUTE,C as BLOCK_SELECTOR,x as CANVAS_SELECTOR,W as CANVAS_TYPABLE_EVENT,B as CANVAS_TYPING_EVENT,L as LIST_SELECTOR,l as WORDS_CLEAR,m as clientPointToLayer,u as drawnBox,f as elementScale,b as fitCanvas,w as framePointToHost,d as frameRectToHost,h as frameRectToLayer,a as frameScale,M as isFrameReady,r as isTypingTarget,c as nodeIdAt,s as related,E as removeCanvasStyle,p as setCanvasNonce,y as upsertCanvasStyle,k as useCanvasEvent,R as useCanvasFrame,T as useCanvasLayout,N as useCanvasStyle,q as useCanvasTyping,S as watchCanvasFrame};
@@ -1,49 +0,0 @@
1
- /**
2
- * A TEMPLATE DRAWN MANY TIMES (section parts plan §3.2, row B5, 2026-10-23).
3
- *
4
- * A data block (a product grid, a list of posts) holds ONE `template` slot of
5
- * real blocks and draws it once per data row. So the same block ids are in the
6
- * canvas several times. The host wraps each drawn copy:
7
- *
8
- * <div data-sf-repeat="<ownerId>:template" data-sf-repeat-index={i}>
9
- *
10
- * Index 0 is the MAIN copy. The blocks inside keep their real
11
- * `data-easel-block` / `data-easel-dnd` ids in every copy, so a click on any
12
- * copy selects the template block. What the canvas does with the copies:
13
- * - the hover and the selected outline are drawn on every copy;
14
- * - only the main copy's lists are drop targets (the others are pictures);
15
- * - a lookup of one element by id reads the main copy.
16
- *
17
- * The two names are written HERE, once. The website draws the wrappers with
18
- * them (it imports them from `efficient-easel/draw`, a render entry), so the
19
- * string is never typed twice. Pure DOM, no import, nothing run at import.
20
- *
21
- * A page with no `data-sf-repeat` gets the same answers as before: every
22
- * helper below falls back to the first match.
23
- */
24
- /** The wrapper round one drawn copy of a template: `"<ownerId>:<slot>"`. */
25
- declare const REPEAT_ATTRIBUTE = "data-sf-repeat";
26
- /** Which copy the wrapper holds: `"0"` is the main copy. */
27
- declare const REPEAT_INDEX_ATTRIBUTE = "data-sf-repeat-index";
28
- /**
29
- * Is `el` in a copy that is NOT the main one — inside (or itself) a wrapper
30
- * whose index is not 0, at any depth (a template inside a copy of an outer
31
- * template is a copy too)? False for a block in no wrapper at all.
32
- */
33
- declare function isRepeatCopy(el: Element): boolean;
34
- /** The main copy among `matches`: the first that is not a copy, else the first. */
35
- declare function mainCopyOf<T extends Element>(matches: Iterable<T>): T | null;
36
- /**
37
- * `root.querySelector(selector)`, but the main copy when a template is drawn
38
- * many times. With no `data-sf-repeat` it is exactly `querySelector`.
39
- */
40
- declare function queryMainCopy<T extends Element = Element>(root: ParentNode, selector: string): T | null;
41
- /**
42
- * The element for `selector` in every drawn copy: the main copy first, then
43
- * each other copy in page order. With no `data-sf-repeat` it is the first
44
- * match alone, as `querySelector` answers — a second element with the same id
45
- * that is not a drawn copy is never added.
46
- */
47
- declare function queryAllCopies<T extends Element = Element>(root: ParentNode, selector: string): T[];
48
-
49
- export { REPEAT_ATTRIBUTE as R, REPEAT_INDEX_ATTRIBUTE as a, queryMainCopy as b, isRepeatCopy as i, mainCopyOf as m, queryAllCopies as q };
@@ -1,43 +0,0 @@
1
- import { P as Place } from './types-Dq180WRV.js';
2
-
3
- /**
4
- * The one drag in flight, shared by every surface of an editor — the Layers
5
- * tree, the canvas and the Add list (blueprint step 3.2).
6
- *
7
- * Native drag-and-drop does not let a drop target read what is being dragged
8
- * until the drop itself (the data is sealed during `dragover`), and a tree that
9
- * only knows about drags it started cannot take a block from the Add list. So
10
- * the surface that starts a drag writes it here and every surface reads it: a
11
- * block picked up on the canvas can land in the tree, a tile from the Add list
12
- * on either.
13
- *
14
- * `from` is where the thing sits now — absent for something new (an Add tile),
15
- * which is also why a new thing can never be a no-op drop.
16
- */
17
-
18
- type DragHeld<I> = {
19
- /** The identity `keyOf` gave it — which row or box is the one being dragged. */
20
- key: string;
21
- item: I;
22
- /** Where it sits now. Absent: it is new, from the Add list. */
23
- from?: Place;
24
- };
25
- type DragSession<I> = {
26
- /** The drag in flight, current at once (for event handlers). */
27
- get: () => DragHeld<I> | null;
28
- /** The drag as last TOLD to subscribers (for rendering — see below). */
29
- shown: () => DragHeld<I> | null;
30
- start: (held: DragHeld<I>) => void;
31
- end: () => void;
32
- subscribe: (listener: () => void) => () => void;
33
- };
34
- /**
35
- * `get()` is current the moment a drag starts — the drop targets read it on
36
- * their first `dragover`. SUBSCRIBERS hear about a start one tick later: the
37
- * browser takes the drag picture when the `dragstart` handlers return, and a
38
- * render in between (a row dimming, the handle hiding) would be in the picture.
39
- * An end is told at once.
40
- */
41
- declare function createDragSession<I>(): DragSession<I>;
42
-
43
- export { type DragSession as D, type DragHeld as a, createDragSession as c };