efficient-easel 6.4.0 → 6.6.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 (63) hide show
  1. package/README.md +6 -0
  2. package/dist/{CanvasDragLayer-O1gVT1AL.d.ts → CanvasDragLayer-CLb7j-CZ.d.ts} +18 -2
  3. package/dist/{canvas-typing-Dec_zyuM.d.ts → canvas-typing-U7TV-iax.d.ts} +16 -1
  4. package/dist/{chunk-3PPA5S2J.js → chunk-4UJ6CPLO.js} +1 -1
  5. package/dist/{chunk-6EKKPFVG.js → chunk-57NRNFLO.js} +1 -1
  6. package/dist/{chunk-NL4OU4UU.js → chunk-5PUEZ22M.js} +1 -1
  7. package/dist/chunk-CIHKZMNR.js +1 -0
  8. package/dist/{chunk-7XHDCQVL.js → chunk-CRWFB7MU.js} +16 -16
  9. package/dist/chunk-DSXKBICS.js +5 -0
  10. package/dist/{chunk-VFI3ONLN.js → chunk-ESQZG7B3.js} +1 -1
  11. package/dist/chunk-HXLF2ZQO.js +62 -0
  12. package/dist/{chunk-ISBKAONU.js → chunk-LVUDUQNL.js} +1 -1
  13. package/dist/chunk-M5VRWM7M.js +11 -0
  14. package/dist/{chunk-F4XCIEXI.js → chunk-Q2L6YTII.js} +1 -1
  15. package/dist/chunk-SSORUDHE.js +18 -0
  16. package/dist/chunk-TBY3DFKS.js +1 -0
  17. package/dist/chunk-TCVTMNYE.js +1 -0
  18. package/dist/{chunk-QPQXKKSC.js → chunk-UY7BCB32.js} +1 -1
  19. package/dist/{chunk-LWQQQ72E.js → chunk-VQOIVFSG.js} +3 -3
  20. package/dist/chunk-ZR4CFNMW.js +5 -0
  21. package/dist/copy/index.d.ts +1 -1
  22. package/dist/copy/index.js +18 -18
  23. package/dist/drag/drag.css +33 -26
  24. package/dist/drag/index.d.ts +34 -3
  25. package/dist/drag/index.js +1 -1
  26. package/dist/easel/index.d.ts +13 -1
  27. package/dist/easel/index.js +1 -1
  28. package/dist/fields/index.js +1 -1
  29. package/dist/screen/components/AddBlockRow.js +1 -1
  30. package/dist/screen/components/AddSidePanel.js +1 -1
  31. package/dist/screen/components/MediaSidePanel.js +1 -1
  32. package/dist/screen/components/NodeContextMenu.d.ts +1 -1
  33. package/dist/screen/components/NodeContextMenu.js +1 -1
  34. package/dist/screen/components/ScreenChrome.js +1 -1
  35. package/dist/screen/components/ScreenMount.d.ts +1 -1
  36. package/dist/screen/components/ScreenMount.js +1 -1
  37. package/dist/screen/components/ScreenStoreProvider.d.ts +1 -1
  38. package/dist/screen/components/ScreenStoreProvider.js +1 -1
  39. package/dist/screen/components/SectionScreenShell.js +16 -16
  40. package/dist/screen/components/usePartBridge.d.ts +1 -1
  41. package/dist/screen/components/usePartBridge.js +1 -1
  42. package/dist/screen/index.d.ts +1 -1
  43. package/dist/screen/index.js +1 -1
  44. package/dist/screen/lib/key-scope.js +1 -1
  45. package/dist/screen/lib/puck/style-clipboard.d.ts +1 -1
  46. package/dist/screen/lib/puck/style-clipboard.js +1 -1
  47. package/dist/screen/lib/puck/use-section-ops.js +1 -1
  48. package/dist/screen/lib/screen-parts.d.ts +1 -1
  49. package/dist/screen/lib/screen-parts.js +1 -1
  50. package/dist/screen/screen.css +6 -127
  51. package/dist/strings/catalogue.d.ts +5 -2
  52. package/dist/strings/catalogue.js +1 -1
  53. package/dist/strings/index.js +1 -1
  54. package/dist/text-styles/index.js +16 -16
  55. package/package.json +1 -1
  56. package/dist/chunk-6XXW6ZW3.js +0 -5
  57. package/dist/chunk-AELNNAFM.js +0 -1
  58. package/dist/chunk-AYNU4FYF.js +0 -14
  59. package/dist/chunk-DSUMM2WF.js +0 -10
  60. package/dist/chunk-JIWPANGM.js +0 -1
  61. package/dist/chunk-NTMY5EXS.js +0 -1
  62. package/dist/chunk-TAF5AECR.js +0 -65
  63. package/dist/chunk-YB4QPUEZ.js +0 -5
package/README.md CHANGED
@@ -851,6 +851,12 @@ const drag = useTreeDrag({ …, session }); // the tree
851
851
  to nudge it with a mouse move of its own.
852
852
  - **The line** runs across a list, or down between columns (a slot laid out
853
853
  across).
854
+ - **A ➕ insert point** (`CanvasInsert`, 6.6.0) is the one look of every place
855
+ the canvas offers to add: the shell's ghost `IconButton` with the plus, named
856
+ by its `Tooltip`, in the tab order, a 2px accent line across the gap on hover
857
+ and focus. The layer draws one per `seam`; `insertSeams(zone, label)` makes
858
+ them before, between and after a list's children (an end is kept 12px inside
859
+ the list), across or down as the list runs.
854
860
  - **An empty slot** is a dashed "+ Add block" cell that also takes drops. A
855
861
  zone the model marks `addLabel` says its own words, and `addAlways` draws it
856
862
  at rest, not only on hover (the screen's empty page: "+ Add section", 5.1.0).
@@ -62,11 +62,17 @@ type CanvasZone = {
62
62
  */
63
63
  addAlways?: boolean;
64
64
  };
65
- /** The gap between two sections, offered as a place to add one. */
65
+ /**
66
+ * A place offered to add at: the gap between two sections, or before, between
67
+ * or after the blocks of a list. `axis` is the list's ('x': the line runs
68
+ * down); `label` is the ➕'s name, when not the layer's `seamLabel`.
69
+ */
66
70
  type CanvasSeam = {
67
71
  key: string;
68
72
  place: Place;
69
73
  box: Box;
74
+ axis?: 'x' | 'y';
75
+ label?: string;
70
76
  };
71
77
  declare const contains: (b: Box, x: number, y: number) => boolean;
72
78
  /** Every source under the point, outermost first (largest box first; of two
@@ -111,6 +117,16 @@ type CanvasTarget = {
111
117
  */
112
118
  declare function canvasTarget(zones: readonly CanvasZone[], x: number, y: number, accept: (to: Place) => boolean, isNoOp?: (to: Place) => boolean, fallThrough?: (refused: Place) => boolean): CanvasTarget;
113
119
  /** The seams between a zone's children — where "+ Add section" goes. */
120
+ /**
121
+ * Every place in a list a ➕ may add at — before its first child, between each
122
+ * two, and after its last (owner 2026-10-14) — for a list that HAS children
123
+ * (an empty one draws its cell instead). Across a 'y' list, down an 'x' one.
124
+ * Between two children the band is the room they leave. At an end it is the
125
+ * room between the list's edge and its child, centred there but never closer
126
+ * than `inset` to the edge: a ➕ half outside its list is cut by the canvas, and
127
+ * focusing it scrolls the canvas to show it.
128
+ */
129
+ declare function insertSeams(zone: CanvasZone, label?: string, inset?: number): CanvasSeam[];
114
130
  declare function seamsBetween(zone: CanvasZone, keyPrefix?: string): CanvasSeam[];
115
131
 
116
132
  type MeasuredNode = {
@@ -187,4 +203,4 @@ type CanvasDragLayerProps<I> = {
187
203
  declare const HANDLE_GRACE_MS = 140;
188
204
  declare function CanvasDragLayer<I>(props: CanvasDragLayerProps<I>): react.JSX.Element;
189
205
 
190
- export { type Box as B, type CanvasDragModel as C, EMPTY_MEASURE as E, HANDLE_GRACE_MS as H, type MeasuredCanvas as M, CanvasDragLayer as a, type CanvasDragLayerProps as b, type CanvasTarget as c, type CanvasSeam as d, type CanvasSource as e, type CanvasZone as f, type MeasuredNode as g, canvasTarget as h, contains as i, gapInZone as j, gapLine as k, sourcesAt as l, measureCanvas as m, pickSource as p, seamsBetween as s };
206
+ export { type Box as B, type CanvasDragModel as C, EMPTY_MEASURE as E, HANDLE_GRACE_MS as H, type MeasuredCanvas as M, CanvasDragLayer as a, type CanvasDragLayerProps as b, type CanvasTarget as c, type CanvasSeam as d, type CanvasSource as e, type CanvasZone as f, type MeasuredNode as g, canvasTarget as h, contains as i, gapInZone as j, gapLine as k, insertSeams as l, measureCanvas as m, sourcesAt as n, pickSource as p, seamsBetween as s };
@@ -1,4 +1,4 @@
1
- import { InlineRule } from './markup/index.js';
1
+ import { InlineRule, MarkStyle } from './markup/index.js';
2
2
 
3
3
  interface TextMap {
4
4
  /** The words as drawn: text in order, a `<br>` or a new block line as `\n`. */
@@ -33,6 +33,9 @@ interface CanvasTypingOptions {
33
33
  end: (why: CanvasTypingEnd) => void;
34
34
  /** The browser wrote into the words (a composition): draw them afresh. */
35
35
  remount?: () => void;
36
+ /** What the toolbar shows may have changed (the selection moved, a press, a
37
+ * write): a host draws its buttons again from `pressed()`. */
38
+ onSelect?: () => void;
36
39
  now?: () => number;
37
40
  }
38
41
  interface CanvasTypingSession {
@@ -42,6 +45,18 @@ interface CanvasTypingSession {
42
45
  update: (next: string) => void;
43
46
  /** End typing. Once: a second call does nothing. */
44
47
  stop: (why?: CanvasTypingEnd) => void;
48
+ /** What the selection wears, for the toolbar's pressed buttons (a pending
49
+ * press included), and the list its lines are in. */
50
+ pressed: () => {
51
+ marks: Partial<Record<string, boolean>>;
52
+ list: 'bullet' | 'number' | null;
53
+ };
54
+ /** A mark button pressed (B, I, U, S, superscript, subscript): on the
55
+ * selected words, or for the words typed next — `markPress`, as the panel
56
+ * box presses. */
57
+ press: (style: MarkStyle) => void;
58
+ /** A list button pressed: the selection's lines become that list, or stop being one. */
59
+ list: (kind: 'bullet' | 'number') => void;
45
60
  }
46
61
  /** Start typing in the words `element()` drew, or `null` where they are not the string's. */
47
62
  declare function startCanvasTyping(o: CanvasTypingOptions): CanvasTypingSession | null;
@@ -1,2 +1,2 @@
1
- import{ScreenPartsProvider as t}from"./chunk-6XXW6ZW3.js";import{useEaselHost as r}from"./chunk-U3JP4VGF.js";import{createEasel as e,EaselProvider as n}from"./chunk-DSUMM2WF.js";import{useState as o,useEffect as s}from"react";import{jsx as i}from"react/jsx-runtime";function a({config:a,data:c,onChange:m,permissions:p,parts:f,children:u}){const[h]=o(()=>e({config:a,data:c,permissions:p}));s(()=>{h.setConfig(a)},[h,a]),s(()=>{if(!m)return;let t=h.getState().appState.data;return h.subscribe(()=>{const r=h.getState().appState.data;r!==t&&(t=r,m(r))})},[h,m]),s(()=>{p&&h.setPermissions(p)},[h,p]);const d=r();/* @__PURE__ */
1
+ import{ScreenPartsProvider as t}from"./chunk-ZR4CFNMW.js";import{useEaselHost as r}from"./chunk-U3JP4VGF.js";import{createEasel as e,EaselProvider as n}from"./chunk-M5VRWM7M.js";import{useState as o,useEffect as s}from"react";import{jsx as i}from"react/jsx-runtime";function a({config:a,data:c,onChange:m,permissions:p,parts:f,children:u}){const[h]=o(()=>e({config:a,data:c,permissions:p}));s(()=>{h.setConfig(a)},[h,a]),s(()=>{if(!m)return;let t=h.getState().appState.data;return h.subscribe(()=>{const r=h.getState().appState.data;r!==t&&(t=r,m(r))})},[h,m]),s(()=>{p&&h.setPermissions(p)},[h,p]);const d=r();/* @__PURE__ */
2
2
  return i(n,{easel:h,hotkeys:d.ownsDocument,children:/* @__PURE__ */i(t,{parts:f,children:u})})}export{a as ScreenStoreProvider};
@@ -1 +1 @@
1
- import{useScreenBlockRules as e}from"./chunk-6XXW6ZW3.js";import{newNodeId as t,ROOT_ZONE as n}from"./chunk-PLVEGYK6.js";import{useEasel as o,useEaselApi as r}from"./chunk-DSUMM2WF.js";import{useMemo as s}from"react";function i(i={}){const{dispatch:p}=o(e=>e),d=r(),c=!0===i.readOnly,a=e().resolveOnInsert,l=!0===(i.resolveOnInsert??a),m=!0===i.foldIntoHistory;return s(()=>{const e=m?e=>p({...e,recordHistory:!1}):p,o=(n,o,r)=>{const s=t(o);return c||e({type:"insert",componentType:o,destinationZone:n,destinationIndex:r,id:s}),s},r=e=>(l&&!c&&d.resolveNode(e,{trigger:"insert"}),e),s=(t,n,o)=>{c||e({type:"replace",destinationZone:t,destinationIndex:n,data:o})},i=(e,t,n)=>r(o(e,t,n));return{insertComponent:i,insertSection:(e,t)=>i(n,e,t),replaceComponent:s,seedChild:(e,t,n,i)=>{const p=o(e,n,t);s(e,t,{type:n,props:{id:p,...i}}),r(p)},insertNode:(e,t,n)=>{const i=o(e,n.type,t);return s(e,t,{type:n.type,props:{...n.props,id:i}}),r(i)},removeComponent:(t,n)=>{c||e({type:"remove",index:n,zone:t})},reorderComponent:(t,n,o)=>{c||e({type:"reorder",sourceIndex:n,destinationIndex:o,destinationZone:t})},duplicateComponent:(t,n)=>{c||e({type:"duplicate",sourceIndex:n,sourceZone:t})},select:e=>p({type:"setUi",ui:{itemSelector:e}}),setDocument:t=>{c||e({type:"setData",data:t})},commitDocument:(t,n)=>{c||(m?d.batch(()=>{e({type:"setData",data:t}),void 0!==n&&("slot"===n?.kind?d.selectSlot({parentId:n.parentId,slot:n.slot}):d.select(n?n.id:null))}):d.run({data:t,select:n}))}}},[p,c,l,d,m])}export{i as useSectionOps};
1
+ import{useScreenBlockRules as e}from"./chunk-ZR4CFNMW.js";import{newNodeId as t,ROOT_ZONE as n}from"./chunk-PLVEGYK6.js";import{useEasel as o,useEaselApi as r}from"./chunk-M5VRWM7M.js";import{useMemo as s}from"react";function i(i={}){const{dispatch:p}=o(e=>e),d=r(),c=!0===i.readOnly,a=e().resolveOnInsert,l=!0===(i.resolveOnInsert??a),m=!0===i.foldIntoHistory;return s(()=>{const e=m?e=>p({...e,recordHistory:!1}):p,o=(n,o,r)=>{const s=t(o);return c||e({type:"insert",componentType:o,destinationZone:n,destinationIndex:r,id:s}),s},r=e=>(l&&!c&&d.resolveNode(e,{trigger:"insert"}),e),s=(t,n,o)=>{c||e({type:"replace",destinationZone:t,destinationIndex:n,data:o})},i=(e,t,n)=>r(o(e,t,n));return{insertComponent:i,insertSection:(e,t)=>i(n,e,t),replaceComponent:s,seedChild:(e,t,n,i)=>{const p=o(e,n,t);s(e,t,{type:n,props:{id:p,...i}}),r(p)},insertNode:(e,t,n)=>{const i=o(e,n.type,t);return s(e,t,{type:n.type,props:{...n.props,id:i}}),r(i)},removeComponent:(t,n)=>{c||e({type:"remove",index:n,zone:t})},reorderComponent:(t,n,o)=>{c||e({type:"reorder",sourceIndex:n,destinationIndex:o,destinationZone:t})},duplicateComponent:(t,n)=>{c||e({type:"duplicate",sourceIndex:n,sourceZone:t})},select:e=>p({type:"setUi",ui:{itemSelector:e}}),setDocument:t=>{c||e({type:"setData",data:t})},commitDocument:(t,n)=>{c||(m?d.batch(()=>{e({type:"setData",data:t}),void 0!==n&&("slot"===n?.kind?d.selectSlot({parentId:n.parentId,slot:n.slot}):d.select(n?n.id:null))}):d.run({data:t,select:n}))}}},[p,c,l,d,m])}export{i as useSectionOps};
@@ -1 +1 @@
1
- import{useSectionOps as o}from"./chunk-6EKKPFVG.js";import{decodePartId as e,encodePartId as r}from"./chunk-IYT6NN2J.js";import{usePreviewParts as t}from"./chunk-I54UCYOU.js";import{SELECTION_MODE as n}from"./chunk-6XXW6ZW3.js";import{useEasel as p}from"./chunk-DSUMM2WF.js";import{useCallback as d,useEffect as c}from"react";var s=o=>"part"===o.kind;function m({mode:m,setMode:i,onOpenPart:a}){const{getSelectorForId:u}=p(o=>o),I=o(),{setSelectedPartId:f,setSelectHandler:k}=t(),l=d(o=>{const r=e(o);if(!r)return;const{nodeId:t,propKey:p}=r;p?(i(o=>s(o)&&o.nodeId===t&&o.propKey===p?o:{kind:"part",nodeId:t,propKey:p}),a?.(t)):i(o=>"part"===o.kind?n:o)},[i,a]);c(()=>{k(l)},[k,l]);const K=s(m)?r(m.nodeId,m.propKey):null;c(()=>{f(K)},[K,f]);return{selectNode:d(o=>{i(()=>n);const e=u(o);e&&I.select(e)},[i,u,I]),openPartId:K}}export{m as usePartBridge};
1
+ import{useSectionOps as o}from"./chunk-57NRNFLO.js";import{decodePartId as e,encodePartId as r}from"./chunk-IYT6NN2J.js";import{usePreviewParts as t}from"./chunk-I54UCYOU.js";import{SELECTION_MODE as n}from"./chunk-ZR4CFNMW.js";import{useEasel as p}from"./chunk-M5VRWM7M.js";import{useCallback as d,useEffect as c}from"react";var s=o=>"part"===o.kind;function m({mode:m,setMode:i,onOpenPart:a}){const{getSelectorForId:u}=p(o=>o),I=o(),{setSelectedPartId:f,setSelectHandler:k}=t(),l=d(o=>{const r=e(o);if(!r)return;const{nodeId:t,propKey:p}=r;p?(i(o=>s(o)&&o.nodeId===t&&o.propKey===p?o:{kind:"part",nodeId:t,propKey:p}),a?.(t)):i(o=>"part"===o.kind?n:o)},[i,a]);c(()=>{k(l)},[k,l]);const N=s(m)?r(m.nodeId,m.propKey):null;c(()=>{f(N)},[N,f]);return{selectNode:d(o=>{i(()=>n);const e=u(o);e&&I.select(e)},[i,u,I]),openPartId:N}}export{m as usePartBridge};
@@ -0,0 +1 @@
1
+ import{STANDARD_MARKUP as t,writeMarkedLines as e,sameMarks as n,markedLines as r,spanFor as l,marksIn as o,toggleMark as i,listIn as s,setList as a,isSafeLinkHref as u}from"./chunk-546BBOPE.js";var c=/* @__PURE__ */new Set(["script","style","head","title","meta","link","template","noscript","svg","math","object","iframe"]),d=/* @__PURE__ */new Set(["p","div","li","ul","ol","dl","dt","dd","h1","h2","h3","h4","h5","h6","blockquote","pre","table","thead","tbody","tfoot","tr","section","article","header","footer","aside","nav","figure","figcaption","address","hr"]);function h(l,o){const i=o.rules??t,s=l.html&&""!==l.html.trim()?function(t,l,o){const i=l.createElement("template");i.innerHTML=t;const s=[[]],a=()=>s[s.length-1],h=()=>{const t=a();for(;t.length>0&&" "===t[t.length-1].ch;)t.pop();t.length>0&&s.push([])},p=(t,e,n,r)=>{if(3===t.nodeType){for(const l of t.textContent??""){const t=/\s/.test(l)?" ":l,o=a();" "===t&&(0===o.length&&s.length>1||" "===o[o.length-1]?.ch)||o.push({ch:t,bold:e,italic:n,href:r})}return}if(1!==t.nodeType&&11!==t.nodeType)return;const l=t,o=1===t.nodeType?l.localName:"";if(c.has(o))return;if("br"===o)return void s.push([]);let i=e,f=n,m=r;if("b"!==o&&"strong"!==o||(i=!0),"i"!==o&&"em"!==o||(f=!0),"a"===o){const t=(l.getAttribute("href")??"").trim();m=u(t)?t:null}const g=1===t.nodeType?l.style:null;if(g){const t=g.fontWeight;"bold"===t||"bolder"===t||Number(t)>=600?i=!0:("normal"===t||"lighter"===t||""!==t&&Number(t)<600)&&(i=!1),"italic"===g.fontStyle||"oblique"===g.fontStyle?f=!0:"normal"===g.fontStyle&&(f=!1)}const b=d.has(o);b&&h();for(const e of[...t.childNodes])p(e,i,f,m);b&&h()};p(i.content,!1,!1,null);for(;s.length>1&&0===s[s.length-1].length;)s.pop();return s.map(t=>function(t,l){const o=e=>t.map((n,r)=>n[e]&&(" "!==n.ch||Boolean(t[r-1]?.[e])&&Boolean(t[r+1]?.[e]))),i=[{bold:!0,italic:!0,links:!0},{bold:!0,italic:!1,links:!0},{bold:!1,italic:!1,links:!0},{bold:!1,italic:!1,links:!1}];for(const s of i){const i=f(t,s.bold?o("bold"):null,s.italic?o("italic"):null,s.links),a=e([i]).text;if(n([i],r(a,l)))return a}return t.map(t=>t.ch).join("")}(t,o))}(l.html,o.doc,i):(l.text??"").replace(/\r\n?/g,"\n").split("\n");return o.multiline?s.join("\n"):1===s.length?s[0]:s.map(t=>t.trim()).filter(t=>""!==t).join(" ")}function f(t,e,n,r){let o=0,i=null,s=null,a=null;return{bullet:!1,chars:t.map((t,u)=>{const c=r?t.href:null;return i=null===c?null:i&&i.href===c?i:l(++o,"link",c),s=e?.[u]?s??l(++o,"bold"):null,a=n?.[u]?a??l(++o,"italic"):null,{ch:t.ch,at:-1,marks:[i,s,a].filter(t=>null!==t)}})}}var p="application/x-efficient-markup",m=/^([0-9]{1,3})\. $/;function g(t,e){const n=t.split("\n"),l=r(t,e);let o=0,i=0;const s=l.map((t,e)=>{const r=!t.bullet&&null==t.number&&"- "===n[e],l=null!=t.number||t.bullet?null:m.exec(n[e]),s=t.bullet||r,a=l?l[1]:t.number??null,u=r||l?[]:t.chars,c=u.map(t=>t.ch).join(""),d=null!=a?a.length+2:s?2:0,h={bullet:s,number:a,chars:u,start:o,src:o+d,vis:i,text:c};return o+=n[e].length+1,i+=c.length+1,h});return{lines:s,text:s.map(t=>t.text).join("\n")}}function b(t,e){const{lines:n}=t;for(let t=0;t<n.length;t+=1){const r=n[t];if(e<=r.vis+r.text.length||t===n.length-1)return[r,Math.max(0,Math.min(e-r.vis,r.text.length)),t]}return[n[0],0,0]}function k(t,e){const[n,r]=b(t,e);if(0===r)return n.src;let l=0;for(const t of n.chars){if(r<=l+t.ch.length)return t.at+(r-l);l+=t.ch.length}return n.src}function x(t,e){const[n,r]=b(t,e);let l=0;for(const t of n.chars){if(r===l)return t.at;l+=t.ch.length}return k(t,e)}function y(t,e){const{lines:n}=t;let r=n[0];for(const t of n)e>=t.start&&(r=t);let l=0;for(const t of r.chars){if(!(e>=t.at+t.ch.length)){e>t.at&&(l+=e-t.at);break}l+=t.ch.length}return r.vis+l}function v(t,e,n){return[y(t,e),y(t,n)]}function D(t,e,n){return e===n?[k(t,e),k(t,e)]:[x(t,e),k(t,n)]}function w(t,e){let n=0;for(let r=0;r<t.chars.length;r+=1){if(n>=e)return r;n+=t.chars[r].ch.length}return t.chars.length}function T(t,o,i,s,a){const u=g(t,o),[c,d,h]=b(u,Math.min(i,s)),[f,p,m]=b(u,Math.max(i,s)),k=w(c,d),x=w(f,p),y=c.chars.slice(0,k),v=f.chars.slice(x),D=i!==s&&c.chars[k]&&(h!==m||k<x)?c.chars[k].marks:function(t,e){const n=t.chars[e-1],r=t.chars[e],l=(t,e)=>{const n=t.findIndex(t=>"link"===t.kind);return-1===n||e?t:t.slice(0,n)};if(n){const t=n.marks.find(t=>"link"===t.kind),e=Boolean(t&&r?.marks.some(e=>e.id===t.id));return l(n.marks,e)}return r?l(r.marks,!1):[]}(c,k);let T=(A=u.lines,Math.max(0,...A.flatMap(t=>t.chars.flatMap(t=>t.marks.map(t=>t.id))))+1);var A;const M=t=>{let e;if(void 0!==a.markup){const t=T;e=r(a.markup,o).map(e=>({bullet:e.bullet,number:e.number??null,chars:e.chars.map(e=>({...e,at:-1,marks:e.marks.map(e=>({...e,id:e.id+t}))}))}))}else{let n=c.number??null;e=(a.text??"").split("\n").map((e,r)=>(r>0&&null!=n&&(n=function(t){return String(Number(t)+1).padStart(t.length,"0")}(n)),{bullet:c.bullet,number:n,chars:[...e].map(e=>({ch:e,at:-1,marks:t??[]}))}))}const n=e.map(t=>t.chars.map(t=>t.ch).join("")).join("\n"),l={bullet:c.bullet,number:c.number??null,chars:[...y,...e[0].chars]},i=e.slice(1);if(i.length>0){const t=i[i.length-1];i[i.length-1]={...t,chars:[...t.chars,...v]}}else l.chars.push(...v);return{lines:[...u.lines.slice(0,h).map(({bullet:t,number:e,chars:n})=>({bullet:t,number:e,chars:n})),l,...i,...u.lines.slice(m+1).map(({bullet:t,number:e,chars:n})=>({bullet:t,number:e,chars:n}))],shown:n}},S=void 0!==a.markup?[null]:[(t=>{let e=t.filter(t=>!a.drop?.some(e=>t.kind===e||"highlight"===e&&"accent"===t.kind));for(const t of a.add??[]){if(e.some(e=>e.kind===t))continue;const n=l(T++,t);n&&(e=[...e,n])}if(void 0!==a.color){e=e.filter(t=>"color"!==t.kind);const t=null===a.color?null:l(T++,"color",a.color);t&&(e=[...e,t])}return e})(D),D,[]];let N="",E="";for(const t of S){const r=M(t),l=e(r.lines).text;if(N=l,E=r.shown,n(r.lines,g(l,o).lines))break}return{text:N,caret:Math.min(i,s)+E.length}}function A(t,e,n,r){const l=g(t,e),[o,,i]=b(l,n);return n!==r||!o.bullet&&null==o.number||""!==o.text?T(t,e,n,r,{text:"\n"}):M(t,e,i,!1,n)}function M(t,n,r,l,o){const i=g(t,n).lines.map(({bullet:t,number:e,chars:n},o)=>o===r?{bullet:l,number:null,chars:n}:{bullet:t,number:e,chars:n});return{text:e(i).text,caret:o}}function S(t,n,r,l){const o=g(t,n),[i,s,a]=b(o,Math.min(r,l)),[u,c,d]=b(o,Math.max(r,l)),h=o.lines.slice(a,d+1).map(({bullet:t,number:e,chars:n},r)=>{const l=0===r?w(i,s):0,o=r===d-a?w(u,c):n.length;return{bullet:t,number:e,chars:n.slice(l,o)}});return e(h).text}function N(t,e,n){if(n<0){const n=t.charCodeAt(e-1);return e-(n>=56320&&n<=57343&&e>=2?2:1)}const r=t.charCodeAt(e);return e+(r>=55296&&r<=56319?2:1)}function E(t){const{value:e,rules:n,multiline:r,inputType:l,pending:o}=t;let[i,s]=t.sel;t.target&&t.target[0]!==t.target[1]&&l.startsWith("delete")&&([i,s]=t.target);const a=[i,s];if("historyUndo"===l||"historyRedo"===l)return{kind:"history",dir:"historyUndo"===l?"undo":"redo"};if("formatBold"===l||"formatItalic"===l||"formatStrikeThrough"===l)return{kind:"format",style:"formatBold"===l?"bold":"formatItalic"===l?"italic":"strike"};if("insertParagraph"===l||"insertLineBreak"===l)return r?{kind:"edit",edit:A(e,n,i,s),range:a}:null;if(l.startsWith("insert")){if("insertTranspose"===l)return null;let u=t.data??"";if("insertFromDrop"===l||"insertFromPaste"===l){const l=h({html:t.html??void 0,text:u},{doc:t.doc,multiline:r,rules:n});return{kind:"edit",edit:T(e,n,i,s,{markup:l}),range:a}}return r||(u=u.replace(/\s*\r?\n\s*/g," ")),{kind:"type",edit:T(e,n,i,s,{text:u,add:o?.add,drop:o?.drop,color:o?.color}),range:a}}if(l.startsWith("delete")){const t=g(e,n),r=t.text;if(i===s){const o=l.includes("Backward"),u=t.lines.findIndex(t=>i>=t.vis&&i<=t.vis+t.text.length),c=t.lines[u];if(o&&c&&i===c.vis&&(c.bullet||null!=c.number))return{kind:"edit",edit:M(e,n,u,!1,i),range:a};if(o?0===i:i===r.length)return null;o?i=N(r,i,-1):s=N(r,s,1)}return{kind:"type",edit:T(e,n,i,s,{text:""}),range:[i,s]}}return null}var B=1e3;function j(t=200){let e=[],n=[],r=null,l=0;return{record(o,i,s){const a="type"===i&&"type"===r&&s-l<1e3;r=i,l=s,n=[],a||(e.push(o),e.length>t&&e.shift())},undo(t){const l=e.pop();return l?(n.push(t),r=null,l):null},redo(t){const l=n.pop();return l?(e.push(t),r=null,l):null},reset(){e=[],n=[],r=null}}}var C={sup:"sub",sub:"sup"};function L(t){const{value:e,rules:n,start:r,end:l,style:s,pending:a}=t,u=C[s];if(r===l){const t=o(e,r,l,n),i=a&&a.at===r?a:null,c=t.has(s),d=!!i?.add.includes(s)||!i?.drop.includes(s)&&c;let h=(i?.add??[]).filter(t=>t!==s),f=(i?.drop??[]).filter(t=>t!==s);return d&&c?f.push(s):d||c||h.push(s),!d&&u&&(h=h.filter(t=>t!==u),t.has(u)&&(f=[...f.filter(t=>t!==u),u])),{kind:"pending",pending:h.length||f.length||void 0!==i?.color?{add:h,drop:f,color:i?.color,at:r}:null}}let c=e,d=r,h=l;if(u&&!o(c,d,h,n).has(s)&&o(c,d,h,n).has(u)){const t=i(c,d,h,u,n);({text:c,selectionStart:d,selectionEnd:h}=t)}return{kind:"edit",result:i(c,d,h,s,n)}}var P=/^(block|list-item|flex|grid|table|flow-root)$/;function q(t){const e=t.ownerDocument.defaultView;return!!e&&P.test(e.getComputedStyle(t).display)}function F(t){const e=[],n=/* @__PURE__ */new Map,r=/* @__PURE__ */new Map;let l="",o=!1;const i=()=>{o&&(l+="\n",o=!1)},s=t=>{for(const a of Array.from(t.childNodes)){if(3===a.nodeType){a.data.length>0&&i(),n.set(a,l.length),e.push({node:a,start:l.length,length:a.data.length}),l+=a.data,r.set(a,l.length);continue}if(1!==a.nodeType)continue;const t=a;if("BR"===t.tagName){i(),n.set(t,l.length),l+="\n",r.set(t,l.length);continue}const u=q(t);u&&((o||l.length>0&&!l.endsWith("\n"))&&(l+="\n"),o=!1),n.set(t,l.length);const c=l.length;s(t),u&&l.length===c&&!o&&e.push({node:t,start:c,length:0}),r.set(t,l.length),u&&(o=!0)}};n.set(t,0),s(t),r.set(t,l.length);return{text:l,at:(t,e)=>{if(3===t.nodeType)return(n.get(t)??0)+Math.min(e,t.data.length);const o=t.childNodes;return e<o.length?n.get(o[e])??r.get(t)??0:r.get(t)??l.length},dom:n=>{for(let t=0;t<e.length;t+=1){const r=e[t],l=r.start+r.length;if(n<r.start)return[r.node,0];if(n<l||n===l&&(t===e.length-1||e[t+1].start>n))return 3===r.node.nodeType?[r.node,n-r.start]:[r.node,0]}const r=e[e.length-1];return r?3===r.node.nodeType?[r.node,r.length]:[r.node,0]:[t,0]}}}function O(t){const e=t.element();if(!e)return null;let n=t.value;const r=t.rules;if(F(e).text!==g(n,r).text)return null;const l=t.now??(()=>Date.now()),i=j();let u=e,c=!1,d=null,f=null,m=[t.caret[0],t.caret[1]],b=null;const k=()=>t.onSelect?.(),x={contenteditable:e.getAttribute("contenteditable"),spellcheck:e.getAttribute("spellcheck")},y=()=>u.ownerDocument,w=()=>y().defaultView?.getSelection()??null,A=()=>{if(!f)return!0;!function(){const e=t.element();if(!e||e===u)return;$(u),u=e,U(u)}();const e=F(u);if(e.text!==g(n,r).text)return!1;const[l,o]=f,[i,s]=e.dom(l),[a,c]=e.dom(o);return y().activeElement!==u&&u.focus({preventScroll:!0}),w()?.setBaseAndExtent(i,s,a,c),m=f,f=null,!0},M=()=>{A();const t=w();if(!(t&&t.anchorNode&&t.focusNode&&u.contains(t.anchorNode)&&u.contains(t.focusNode)))return m;const e=F(u),n=e.at(t.anchorNode,t.anchorOffset),r=e.at(t.focusNode,t.focusOffset);return m=n<=r?[n,r]:[r,n],m},N=(t,e)=>{f=[t,e];const n=t=>{if(c||A())return;const e=y().defaultView;t>0&&e&&e.requestAnimationFrame(()=>n(t-1))};n(30)},B=(e,r,o)=>{e.text!==n?(i.record({text:n,start:r[0],end:r[1]},o,l()),n=e.text,t.write(n),N(e.caret,e.caret),k()):N(e.caret,e.caret)},C=t=>D(g(n,r),t[0],t[1]),P=(e,o)=>{if(e.text===n)return;i.record({text:n,start:o[0],end:o[1]},"edit",l()),n=e.text,t.write(n);const[s,a]=v(g(n,r),e.selectionStart,e.selectionEnd);N(s,a),k()},q=t=>{if(c)return;const e=M(),[l,o]=C(e),i=L({value:n,rules:r,start:l,end:o,style:t,pending:b});if("pending"===i.kind)return b=i.pending,void k();P(i.result,e)},O=e=>{n=e.text,t.write(n),N(e.start,e.end)},W=e=>{c||(c=!0,z.removeEventListener("selectionchange",H),$(u),t.end(e))},I=(t,e)=>{const l=M();!c&&l[0]!==l[1]&&t.clipboardData&&(t.preventDefault(),t.clipboardData.setData("text/plain",g(n,r).text.slice(l[0],l[1])),t.clipboardData.setData(p,S(n,r,l[0],l[1])),e&&B(T(n,r,l[0],l[1],{text:""}),l,"edit"))},K=t=>t.preventDefault(),R=()=>{t.remount?.()},V=[["keydown",t=>{if(c||t.isComposing)return;const e=t.metaKey||t.ctrlKey;if("Escape"===t.key)return t.preventDefault(),t.stopPropagation(),void W("escape");if("Enter"===t.key&&(!t.shiftKey||e))return t.preventDefault(),t.stopPropagation(),void W("enter");if(e&&("z"===t.key||"Z"===t.key||"y"===t.key)){t.preventDefault(),t.stopPropagation();const e=M(),r={text:n,start:e[0],end:e[1]},l="y"===t.key||t.shiftKey?i.redo(r):i.undo(r);l&&O(l)}}],["beforeinput",e=>{if(c)return;if("insertCompositionText"===e.inputType)return;e.preventDefault();const l=M(),o=F(u),s="function"==typeof e.getTargetRanges?e.getTargetRanges()[0]:void 0,a=s&&!s.collapsed?[o.at(s.startContainer,s.startOffset),o.at(s.endContainer,s.endOffset)]:null,d=E({value:n,rules:r,multiline:t.multiline,inputType:e.inputType,data:e.data??e.dataTransfer?.getData("text/plain")??"",html:e.dataTransfer?.getData("text/html"),doc:y(),sel:l,target:a,pending:b&&b.at===C(l)[0]?b:null});if(d){if("type"!==d.kind&&"edit"!==d.kind||(b=null),"history"===d.kind){const t={text:n,start:l[0],end:l[1]},e="undo"===d.dir?i.undo(t):i.redo(t);return void(e&&O(e))}"format"!==d.kind?B(d.edit,d.range,d.kind):q(d.style)}}],["compositionstart",()=>{d=M()}],["compositionend",e=>{const o=d;if(d=null,!c&&o)if(e.data){const s=T(n,r,o[0],o[1],{text:e.data});i.record({text:n,start:o[0],end:o[1]},"type",l()),n=s.text,t.write(n),R(),N(s.caret,s.caret)}else R(),N(o[0],o[0])}],["paste",e=>{if(c)return;e.preventDefault();const l=M(),o=e.clipboardData,i=o?.getData(p)??"",s=i?t.multiline?i:i.replace(/\s*\r?\n\s*/g," "):h({html:o?.getData("text/html")??"",text:o?.getData("text/plain")??""},{doc:y(),multiline:t.multiline,rules:r});B(T(n,r,l[0],l[1],{markup:s}),l,"edit")}],["copy",t=>I(t,!1)],["cut",t=>I(t,!0)],["drop",K],["dragstart",K],["blur",e=>{if(c||null!==d)return;const n=e.target,r=n.ownerDocument.defaultView,l=()=>{c||(n.isConnected&&n===t.element()?n.ownerDocument.activeElement!==n&&W("blur"):N(m[0],m[1]))};r?.requestAnimationFrame?r.requestAnimationFrame(l):setTimeout(l,0)}]];function U(t){t.setAttribute("contenteditable","true"),t.setAttribute("spellcheck","false"),t.setAttribute("data-es-typing","");for(const[e,n]of V)t.addEventListener(e,n)}function $(t){for(const[e,n]of V)t.removeEventListener(e,n);null===x.contenteditable?t.removeAttribute("contenteditable"):t.setAttribute("contenteditable",x.contenteditable),null===x.spellcheck?t.removeAttribute("spellcheck"):t.setAttribute("spellcheck",x.spellcheck),t.removeAttribute("data-es-typing")}const z=u.ownerDocument;function H(){c||k()}return z.addEventListener("selectionchange",H),U(u),u.focus({preventScroll:!0}),N(t.caret[0],t.caret[1]),{get value(){return n},update(t){if(t===n)return;const e=g(t,r).text.length,[l,o]=M();n=t,i.reset(),N(Math.min(l,e),Math.min(o,e))},stop(t="stop"){W(t)},pressed(){const[t,e]=C(M()),l=o(n,t,e,r),i={};for(const e of["bold","italic","underline","strike","sup","sub","link"]){const n=l.has(e),r=b&&b.at===t?b:null;i[e]=!!r?.add.includes(e)||!r?.drop.includes(e)&&n}return{marks:i,list:s(n,t,e,r)}},press:q,list(e){if(c||!t.multiline)return;const l=M(),[o,i]=C(l),u=s(n,o,i,r);P(a(n,o,i,u===e?null:e,r),l)}}}export{p as MARKUP_CLIPBOARD_TYPE,B as TYPING_BURST_MS,j as createHistory,T as editVisible,L as markPress,S as markupOfRange,A as newLine,h as pasteToMarkup,E as richInput,g as richLayout,D as selectionToSource,v as selectionToVisible,M as setBullet,O as startCanvasTyping,F as textMap,k as toSource,x as toSourceStart,y as toVisible};
@@ -1,21 +1,21 @@
1
- import{FieldSelect as e}from"./chunk-OZ72A6MY.js";import{TreeSeam as n}from"./chunk-4JSBIW5H.js";import{EaselMenuItems as t}from"./chunk-EA2HTX37.js";import{DEFAULT_TREE_WORDS as l}from"./chunk-K56YDHYQ.js";import{SettingsField as r,SETTINGS_BUCKETS as a,SettingsGroup as o}from"./chunk-3ZJSLHHI.js";import{DEFAULT_PANEL_WORDS as i}from"./chunk-KFV7N2DJ.js";import{FieldNumber as s}from"./chunk-66LWADFP.js";import{DEFAULT_FIELDS_WORDS as c}from"./chunk-FFYXVAAL.js";import{SettingsSegmented as d}from"./chunk-QLD57GBB.js";import{useWords as u}from"./chunk-MFIRYGHW.js";import{useTreeDrag as m,gapToMoveIndex as p}from"./chunk-67GNT6PF.js";import{withTip as h}from"./chunk-P2VEMZH5.js";import{Textarea as f,Input as b,SortableList as g,ListRow as v,ContextMenu as y,tabPanelId as k,Tabs as x,tabButtonId as w}from"efficient-shell/ui";export{LinkPicker}from"efficient-shell/ui";import{useRef as N,useState as C,useLayoutEffect as O,useId as $}from"react";import{jsx as j,jsxs as D}from"react/jsx-runtime";import{ChevronIcon as I,LockIcon as S,MoveUpIcon as F,MoveDownIcon as P,DuplicateIcon as L,TrashIcon as M}from"efficient-shell/icons/efficient";function T({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__ */j(f,{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__ */j(b,{id:e,size:"sm",className:"es-fin",type:"text",value:c,placeholder:l,readOnly:o,"aria-label":i,"aria-labelledby":s,onChange:e=>t(e.target.value)})}function A(e,n,t){const l=e.slice();return l.splice(Math.max(0,Math.min(n,l.length)),0,t),l}function H(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 E(e,n){return e.filter((e,t)=>t!==n)}function R(e){return null===e||"object"!=typeof e?e:JSON.parse(JSON.stringify(e))}var z='input, textarea, select, button, [contenteditable]:not([contenteditable="false"]), [tabindex]',B={parentId:"list",slot:"items"};function Y({label:e,icon:r,noun:a,items:o,onChange:i,newItem:s,summary:d,itemName:f,thumb:b,min:k=0,max:x,readOnly:w=!1,open:$,onOpen:T,renderItem:Y,renderRow:J,canRemove:K,lockedReason:V,fixed:G=!1,removeOnRow:W=!0,canDuplicate:X,above:Z,head:q=!0}){const Q=u("fields",c).list,U=u("tree",l),_=a??Q.item,ee=!w&&!G&&("number"!=typeof x||o.length<x),ne=o.length<=k,te=e=>!!K&&!K(o[e],e),le=e=>!w&&!G&&W&&!ne&&!te(e),re=e=>ee&&(!X||X(o[e],e)),ae=(e,n)=>f?f(e,n):Q.itemName({noun:_,n:n+1}),oe=N([]),ie=N(null),[se,ce]=C(null),de=N(null),[ue,me]=C(null),[pe,he]=C("");O(()=>{const e=ie.current;if(!e)return;ie.current=null;const n=oe.current[e.index]?.querySelectorAll(z)[e.nth]??oe.current[e.index];if(n?.focus(),n&&null!==e.start&&"setSelectionRange"in n)try{n.setSelectionRange(e.start,e.end)}catch{}});const fe=(e,n)=>{if(n<0||n>=o.length||n===e)return;const t=oe.current[e],l=t?.ownerDocument.activeElement;if(t&&l&&t.contains(l)){const e=[...t.querySelectorAll(z)].indexOf(l),r=l;ie.current={index:n,nth:e,start:"number"==typeof r.selectionStart?r.selectionStart:null,end:"number"==typeof r.selectionEnd?r.selectionEnd:null}}i(H(o,e,n));const r=function(e,n,t){return null===e?null:e===n?t:n<e&&t>=e?e-1:n>e&&t<=e?e+1:e}($,e,n);r!==$&&T(r),he(Q.moved({n:n+1,total:o.length}))},be=e=>{ee&&(i(A(o,e,s())),J?(ie.current={index:e,nth:0,start:null,end:null},null!==$&&$>=e&&T($+1)):T(e))},ge=e=>{le(e)&&(i(E(o,e)),$===e?T(null):null!==$&&$>e&&T($-1))},ve=m({keyOf:e=>String(e),canDrop:(e,n)=>n.parentId===B.parentId&&n.slot===B.slot,onDrop:(e,n)=>{const t=p({...B,index:e},n);t!==e&&fe(e,t)},onStep:(e,n)=>fe(e,e+n),canStep:(e,n)=>e+n>=0&&e+n<o.length,readOnly:w}),ye=e=>{const n=[];return e>0&&n.push({label:Q.moveUp,icon:/* @__PURE__ */j(F,{size:14}),shortcut:"⌥↑",onClick:()=>fe(e,e-1)}),e<o.length-1&&n.push({label:Q.moveDown,icon:/* @__PURE__ */j(P,{size:14}),shortcut:"⌥↓",onClick:()=>fe(e,e+1)}),re(e)&&n.push({label:Q.duplicate,icon:/* @__PURE__ */j(L,{size:14}),onClick:()=>(e=>{re(e)&&(i(A(o,e+1,R(o[e]))),null!==$&&$>e&&T($+1))})(e)}),le(e)&&n.push({label:Q.delete,icon:/* @__PURE__ */j(M,{size:14}),danger:!0,onClick:()=>ge(e)}),n},ke=(e,n,t,l)=>{w||0===ye(e).length||me({index:e,x:n,y:t,owner:l})},xe=e=>n=>{const t=o.slice();t[e]=n,i(t)};/* @__PURE__ */
1
+ import{FieldSelect as e}from"./chunk-OZ72A6MY.js";import{TreeSeam as n}from"./chunk-4JSBIW5H.js";import{SettingsField as t,SETTINGS_BUCKETS as l,SettingsGroup as r}from"./chunk-3ZJSLHHI.js";import{DEFAULT_TREE_WORDS as a}from"./chunk-K56YDHYQ.js";import{DEFAULT_PANEL_WORDS as o}from"./chunk-KFV7N2DJ.js";import{EaselMenuItems as i}from"./chunk-EA2HTX37.js";import{FieldNumber as s}from"./chunk-66LWADFP.js";import{SettingsSegmented as c}from"./chunk-QLD57GBB.js";import{DEFAULT_FIELDS_WORDS as d}from"./chunk-FFYXVAAL.js";import{useWords as u}from"./chunk-MFIRYGHW.js";import{useTreeDrag as m,gapToMoveIndex as p}from"./chunk-67GNT6PF.js";import{withTip as h}from"./chunk-P2VEMZH5.js";import{Textarea as f,Input as b,SortableList as g,ListRow as v,ContextMenu as y,tabPanelId as k,Tabs as x,tabButtonId as w}from"efficient-shell/ui";export{LinkPicker}from"efficient-shell/ui";import{useRef as N,useState as C,useLayoutEffect as O,useId as $}from"react";import{jsx as j,jsxs as D}from"react/jsx-runtime";import{ChevronIcon as I,LockIcon as S,MoveUpIcon as F,MoveDownIcon as P,DuplicateIcon as L,TrashIcon as M}from"efficient-shell/icons/efficient";function T({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__ */j(f,{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__ */j(b,{id:e,size:"sm",className:"es-fin",type:"text",value:c,placeholder:l,readOnly:o,"aria-label":i,"aria-labelledby":s,onChange:e=>t(e.target.value)})}function A(e,n,t){const l=e.slice();return l.splice(Math.max(0,Math.min(n,l.length)),0,t),l}function H(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 E(e,n){return e.filter((e,t)=>t!==n)}function R(e){return null===e||"object"!=typeof e?e:JSON.parse(JSON.stringify(e))}var z='input, textarea, select, button, [contenteditable]:not([contenteditable="false"]), [tabindex]',B={parentId:"list",slot:"items"};function Y({label:e,icon:t,noun:l,items:r,onChange:o,newItem:s,summary:c,itemName:f,thumb:b,min:k=0,max:x,readOnly:w=!1,open:$,onOpen:T,renderItem:Y,renderRow:J,canRemove:K,lockedReason:V,fixed:G=!1,removeOnRow:W=!0,canDuplicate:X,above:Z,head:q=!0}){const Q=u("fields",d).list,U=u("tree",a),_=l??Q.item,ee=!w&&!G&&("number"!=typeof x||r.length<x),ne=r.length<=k,te=e=>!!K&&!K(r[e],e),le=e=>!w&&!G&&W&&!ne&&!te(e),re=e=>ee&&(!X||X(r[e],e)),ae=(e,n)=>f?f(e,n):Q.itemName({noun:_,n:n+1}),oe=N([]),ie=N(null),[se,ce]=C(null),de=N(null),[ue,me]=C(null),[pe,he]=C("");O(()=>{const e=ie.current;if(!e)return;ie.current=null;const n=oe.current[e.index]?.querySelectorAll(z)[e.nth]??oe.current[e.index];if(n?.focus(),n&&null!==e.start&&"setSelectionRange"in n)try{n.setSelectionRange(e.start,e.end)}catch{}});const fe=(e,n)=>{if(n<0||n>=r.length||n===e)return;const t=oe.current[e],l=t?.ownerDocument.activeElement;if(t&&l&&t.contains(l)){const e=[...t.querySelectorAll(z)].indexOf(l),r=l;ie.current={index:n,nth:e,start:"number"==typeof r.selectionStart?r.selectionStart:null,end:"number"==typeof r.selectionEnd?r.selectionEnd:null}}o(H(r,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}($,e,n);a!==$&&T(a),he(Q.moved({n:n+1,total:r.length}))},be=e=>{ee&&(o(A(r,e,s())),J?(ie.current={index:e,nth:0,start:null,end:null},null!==$&&$>=e&&T($+1)):T(e))},ge=e=>{le(e)&&(o(E(r,e)),$===e?T(null):null!==$&&$>e&&T($-1))},ve=m({keyOf:e=>String(e),canDrop:(e,n)=>n.parentId===B.parentId&&n.slot===B.slot,onDrop:(e,n)=>{const t=p({...B,index:e},n);t!==e&&fe(e,t)},onStep:(e,n)=>fe(e,e+n),canStep:(e,n)=>e+n>=0&&e+n<r.length,readOnly:w}),ye=e=>{const n=[];return e>0&&n.push({label:Q.moveUp,icon:/* @__PURE__ */j(F,{size:14}),shortcut:"⌥↑",onClick:()=>fe(e,e-1)}),e<r.length-1&&n.push({label:Q.moveDown,icon:/* @__PURE__ */j(P,{size:14}),shortcut:"⌥↓",onClick:()=>fe(e,e+1)}),re(e)&&n.push({label:Q.duplicate,icon:/* @__PURE__ */j(L,{size:14}),onClick:()=>(e=>{re(e)&&(o(A(r,e+1,R(r[e]))),null!==$&&$>e&&T($+1))})(e)}),le(e)&&n.push({label:Q.delete,icon:/* @__PURE__ */j(M,{size:14}),danger:!0,onClick:()=>ge(e)}),n},ke=(e,n,t,l)=>{w||0===ye(e).length||me({index:e,x:n,y:t,owner:l})},xe=e=>n=>{const t=r.slice();t[e]=n,o(t)};/* @__PURE__ */
2
2
  return D("div",{className:"es-list",children:[q?/* @__PURE__ */D("div",{className:"es-list-head",children:[
3
- /* @__PURE__ */D("span",{className:"es-list-label",children:[r?/* @__PURE__ */j("span",{className:"es-field-icon","aria-hidden":"true",children:r}):null,e]}),
4
- /* @__PURE__ */j("span",{className:"es-list-count",children:o.length})]}):null,Z?/* @__PURE__ */j("div",{className:"es-list-above",children:Z}):null,o.length?/* @__PURE__ */D(g,{"aria-label":e,spacing:"comfortable",className:"es-list-rows",rootProps:ve.rootProps(),children:[o.map((e,t)=>{const l=ve.row({item:t,place:{...B,index:t}}),r=l.draggable&&se!==t,a=!J&&$===t,o=!w&&!G&&W&&te(t),i=["es-list-row",J?"is-inline":"is-item",a?"is-open":"",r?"is-draggable":"",l.dragging?"is-dragging":"",l.drop?`is-drop-${l.drop}`:""].filter(Boolean).join(" ");return[t>0?/* @__PURE__ */j(n,{...ve.seam({place:{...B,index:t}}),onAdd:ee?()=>be(t):void 0,label:Q.addHere({noun:_})},`seam-${t}`):null,
3
+ /* @__PURE__ */D("span",{className:"es-list-label",children:[t?/* @__PURE__ */j("span",{className:"es-field-icon","aria-hidden":"true",children:t}):null,e]}),
4
+ /* @__PURE__ */j("span",{className:"es-list-count",children:r.length})]}):null,Z?/* @__PURE__ */j("div",{className:"es-list-above",children:Z}):null,r.length?/* @__PURE__ */D(g,{"aria-label":e,spacing:"comfortable",className:"es-list-rows",rootProps:ve.rootProps(),children:[r.map((e,t)=>{const l=ve.row({item:t,place:{...B,index:t}}),r=l.draggable&&se!==t,a=!J&&$===t,o=!w&&!G&&W&&te(t),i=["es-list-row",J?"is-inline":"is-item",a?"is-open":"",r?"is-draggable":"",l.dragging?"is-dragging":"",l.drop?`is-drop-${l.drop}`:""].filter(Boolean).join(" ");return[t>0?/* @__PURE__ */j(n,{...ve.seam({place:{...B,index:t}}),onAdd:ee?()=>be(t):void 0,label:Q.addHere({noun:_})},`seam-${t}`):null,
5
5
  /* @__PURE__ */j(v,{className:i,flat:!!J,active:a,draggable:l.draggable,dragHint:U.dragHint,dragging:l.dragging,drop:"before"===l.drop||"after"===l.drop?l.drop:void 0,onMove:l.draggable?e=>fe(t,"up"===e?t-1:t+1):void 0,rowRef:e=>{oe.current[t]=e},rowProps:{...l.rowProps,draggable:r||void 0,onPointerDown:e=>{const n=e.target.closest?.('input, textarea, select, [contenteditable]:not([contenteditable="false"])'),r=!!n&&n===n.ownerDocument.activeElement;e.currentTarget.draggable=l.draggable&&!r,de.current=n&&!r?n:null,ce(r?t:null)},onDragStart:e=>{const n=de.current;de.current=null,n&&n.ownerDocument.activeElement===n&&n.blur(),l.rowProps.onDragStart?.(e)},onContextMenu:e=>{w||(e.preventDefault(),e.stopPropagation(),ke(t,e.clientX,e.clientY,e.currentTarget))},onKeyDown:e=>{if("ContextMenu"===e.key||e.shiftKey&&"F10"===e.key){e.preventDefault();const n=e.currentTarget.ownerDocument,l=e=>e.preventDefault();n.addEventListener("contextmenu",l,{capture:!0,once:!0}),n.defaultView?.setTimeout(()=>n.removeEventListener("contextmenu",l,{capture:!0}),500);const r=e.currentTarget.getBoundingClientRect();return void ke(t,r.left+24,r.bottom,e.currentTarget)}l.rowProps.onKeyDown?.(e)}},actions:w||G||!W?void 0:o?h(V?V(e,t):Q.locked,/* @__PURE__ */j("span",{className:"es-list-lock",role:"img","aria-label":V?V(e,t):Q.locked,children:/* @__PURE__ */j(S,{size:13})})):h(Q.deleteItem({noun:_}),/* @__PURE__ */j("button",{type:"button",className:"es-list-x","aria-label":Q.deleteItem({noun:_}),disabled:!le(t),onClick:()=>ge(t),children:"×"})),below:a?/* @__PURE__ */j("div",{className:"es-list-item",children:Y(e,t,xe(t))}):void 0,children:J?/* @__PURE__ */j("div",{className:"es-list-row-main",children:J(e,t,xe(t))}):/* @__PURE__ */D("button",{type:"button",className:"es-list-open","aria-expanded":a,onClick:()=>T(a?null:t),children:[b?/* @__PURE__ */j("span",{className:"es-list-thumb","aria-hidden":"true",children:b(e,t)}):null,
6
- /* @__PURE__ */j("span",{className:"es-list-row-name",children:ae(e,t)}),/* @__PURE__ */j("span",d?{className:"es-list-row-summary",children:d(e,t)}:{className:"es-list-row-summary"}),
6
+ /* @__PURE__ */j("span",{className:"es-list-row-name",children:ae(e,t)}),/* @__PURE__ */j("span",c?{className:"es-list-row-summary",children:c(e,t)}:{className:"es-list-row-summary"}),
7
7
  /* @__PURE__ */j(I,{size:14,className:"es-list-chev","aria-hidden":"true"})]})},t)]}),
8
- /* @__PURE__ */j(n,{...ve.seam({place:{...B,index:o.length}})})]}):null,w||G?null:/* @__PURE__ */j("button",{type:"button",className:"es-list-add",disabled:!ee,onClick:()=>be(o.length),children:Q.add({noun:_})}),
9
- /* @__PURE__ */j("span",{className:"es-list-said","aria-live":"polite",children:pe}),ue&&ue.index<o.length?
10
- /* @__PURE__ */j(y,{at:{x:ue.x,y:ue.y},owner:ue.owner,onClose:()=>me(null),children:/* @__PURE__ */j(t,{items:ye(ue.index),onClose:()=>me(null)})}):null]})}var J=(e,n)=>"string"==typeof e.label&&e.label?e.label:n;function K({field:e,name:n,id:t,value:l,onChange:r,readOnly:a,context:i,renderers:s}){const[c,d]=C(!0),u=l&&"object"==typeof l?l:{};/* @__PURE__ */
11
- return j(o,{id:`${t}-group`,title:J(e,n),open:c,onToggle:d,children:Object.entries(e.objectFields).map(([e,l])=>/* @__PURE__ */j(G,{field:l,name:`${n}.${e}`,id:`${t}-${e}`,value:u[e],onChange:n=>r({...u,[e]:n}),readOnly:a,context:i,renderers:s},e))})}function V({field:e,name:n,id:t,value:l,onChange:r,readOnly:a,context:o,renderers:i,openItem:s,onOpenItem:c}){const[d,u]=C(null),m=c?s??null:d,p=c??u,h=Array.isArray(l)?l:[],f=e.getItemSummary;/* @__PURE__ */
12
- return j(Y,{label:J(e,n),icon:e.icon,noun:"string"==typeof e.noun?e.noun:void 0,items:h,onChange:r,newItem:()=>R({...e.defaultItemProps??{}}),summary:f?(e,n)=>f(e,n):void 0,min:e.min,max:e.max,readOnly:a,open:m,onOpen:p,renderItem:(l,r,s)=>Object.entries(e.arrayFields).map(([e,c])=>/* @__PURE__ */j(G,{field:c,name:`${n}[${r}].${e}`,id:`${t}-${r}-${e}`,value:l?.[e],onChange:n=>s({...l,[e]:n}),readOnly:a,context:o,renderers:i},e))})}function G(n){const{field:t,name:l,id:a,value:o,onChange:i,readOnly:c,context:u,renderers:m}=n;if(!t||t.marker||!1===t.visible)return null;const p=m?.[t.type];if(p)return p({field:t,name:l,id:a,value:o,onChange:i,readOnly:c});switch(t.type){case"custom":{const e={...u,field:t,name:l,id:a,value:o,onChange:i,readOnly:c};return t.render(e)}case"text":case"textarea":/* @__PURE__ */
13
- return j(r,{label:J(t,l),htmlFor:a,icon:t.icon,hint:t.hint,children:/* @__PURE__ */j(T,{id:a,value:"string"==typeof o?o:null==o?"":String(o),onChange:i,placeholder:t.placeholder,multiline:"textarea"===t.type,readOnly:c})});case"number":/* @__PURE__ */
14
- return j(r,{label:J(t,l),htmlFor:a,icon:t.icon,hint:t.hint,children:/* @__PURE__ */j(s,{id:a,value:"number"==typeof o?o:void 0,onChange:i,min:t.min,max:t.max,step:t.step,placeholder:t.placeholder,readOnly:c})});case"select":{const n=`${a}-label`;/* @__PURE__ */
15
- return j(r,{label:J(t,l),labelId:n,htmlFor:a,icon:t.icon,hint:t.hint,children:/* @__PURE__ */j(e,{id:a,value:o,options:t.options,onChange:i,readOnly:c,ariaLabelledBy:n})})}case"radio":/* @__PURE__ */
16
- return j(r,{label:J(t,l),icon:t.icon,hint:t.hint,children:/* @__PURE__ */j(d,{ariaLabel:J(t,l),value:o,options:t.options.map(e=>({id:e.value,label:e.label,icon:e.icon,disabled:e.disabled||c})),onChange:e=>{c||i(e)}})});case"object":/* @__PURE__ */
17
- return j(K,{...n,field:t});case"array":/* @__PURE__ */
18
- return j(V,{...n,field:t});case"slot":return null}}var W=e=>a.includes(e);function X(e){let n,t=a[0];const l=[],r=/* @__PURE__ */new Set;for(const[a,o]of Object.entries(e))o&&(W(o.bucket)&&((o.marker||o.bucket!==t)&&(n=void 0),t=o.bucket),o.marker&&"string"==typeof o.fold?n={key:a,title:o.fold}:o.marker&&!1===o.fold&&(n=void 0),o.marker||!1===o.visible||(l.push(n?{name:a,field:o,bucket:t,fold:n}:{name:a,field:o,bucket:t}),"slot"!==o.type&&r.add(t)));return{rows:l,buckets:a.filter(e=>r.has(e))}}function Z(e){return new Map(X(e).rows.map(e=>[e.name,e.bucket]))}function q(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 Q({fields:e,values:n,onChange:t,readOnly:l=!1,context:r,tab:a,onTab:s,tabs:c=!0,tabIcons:d,renderers:m,idPrefix:p,ariaLabel:h,lead:f,children:b,leadFold:g,closedFolds:v,onFold:y}){const N=u("panel",i),O=$(),I=p??`es-insp${O.replace(/:/g,"")}`,S=X(e),[F,P]=C(void 0),L=a??F,M=L&&S.buckets.includes(L)?L:S.buckets[0],[T,A]=C(null),H=T&&T.panel===I&&S.rows.some(e=>e.name===T.name)?T:null,E=c&&S.buckets.length>1,R=E&&M?k(I,M):`${I}-rows`,[z,B]=C(()=>/* @__PURE__ */new Set),Y=v??z,J=(e,n)=>/* @__PURE__ */j(o,{title:e.title,open:!Y.has(e.key),onToggle:n=>((e,n)=>{void 0===v&&B(t=>{const l=new Set(t);return n?l.delete(e):l.add(e),l}),y?.(e,n)})(e.key,n),id:`${I}-fold-${e.key}`,children:n}),K=e=>E&&e!==M,V=({name:e,field:a,bucket:o})=>/* @__PURE__ */j("div",{className:"es-insp-row","data-field":e,"data-bucket":o,hidden:!!K(o)||void 0,children:/* @__PURE__ */j(G,{field:a,name:e,id:`${I}-${e}`,value:n[e],onChange:n=>t(e,n),readOnly:l,context:r,renderers:m,openItem:H&&H.name===e?H.index:null,onOpenItem:n=>A(null===n?null:{panel:I,name:e,index:n})})},e);/* @__PURE__ */
19
- return D("div",{className:"es-insp",children:[E?/* @__PURE__ */j("div",{className:"es-insp-tabs",children:/* @__PURE__ */j(x,{variant:"underline",block:!0,"aria-label":h??N.settings,idPrefix:I,value:M,onChange:e=>{const n=e;void 0===a&&P(n),s?.(n)},items:S.buckets.map(e=>{const n=N.buckets[e],t=d?.[e];return t?{id:e,icon:t,label:/* @__PURE__ */j("span",{className:"sr-only",children:n}),tooltip:n}:{id:e,label:n}})})}):null,
8
+ /* @__PURE__ */j(n,{...ve.seam({place:{...B,index:r.length}})})]}):null,w||G?null:/* @__PURE__ */j("button",{type:"button",className:"es-list-add",disabled:!ee,onClick:()=>be(r.length),children:Q.add({noun:_})}),
9
+ /* @__PURE__ */j("span",{className:"es-list-said","aria-live":"polite",children:pe}),ue&&ue.index<r.length?
10
+ /* @__PURE__ */j(y,{at:{x:ue.x,y:ue.y},owner:ue.owner,onClose:()=>me(null),children:/* @__PURE__ */j(i,{items:ye(ue.index),onClose:()=>me(null)})}):null]})}var J=(e,n)=>"string"==typeof e.label&&e.label?e.label:n;function K({field:e,name:n,id:t,value:l,onChange:a,readOnly:o,context:i,renderers:s}){const[c,d]=C(!0),u=l&&"object"==typeof l?l:{};/* @__PURE__ */
11
+ return j(r,{id:`${t}-group`,title:J(e,n),open:c,onToggle:d,children:Object.entries(e.objectFields).map(([e,l])=>/* @__PURE__ */j(G,{field:l,name:`${n}.${e}`,id:`${t}-${e}`,value:u[e],onChange:n=>a({...u,[e]:n}),readOnly:o,context:i,renderers:s},e))})}function V({field:e,name:n,id:t,value:l,onChange:r,readOnly:a,context:o,renderers:i,openItem:s,onOpenItem:c}){const[d,u]=C(null),m=c?s??null:d,p=c??u,h=Array.isArray(l)?l:[],f=e.getItemSummary;/* @__PURE__ */
12
+ return j(Y,{label:J(e,n),icon:e.icon,noun:"string"==typeof e.noun?e.noun:void 0,items:h,onChange:r,newItem:()=>R({...e.defaultItemProps??{}}),summary:f?(e,n)=>f(e,n):void 0,min:e.min,max:e.max,readOnly:a,open:m,onOpen:p,renderItem:(l,r,s)=>Object.entries(e.arrayFields).map(([e,c])=>/* @__PURE__ */j(G,{field:c,name:`${n}[${r}].${e}`,id:`${t}-${r}-${e}`,value:l?.[e],onChange:n=>s({...l,[e]:n}),readOnly:a,context:o,renderers:i},e))})}function G(n){const{field:l,name:r,id:a,value:o,onChange:i,readOnly:d,context:u,renderers:m}=n;if(!l||l.marker||!1===l.visible)return null;const p=m?.[l.type];if(p)return p({field:l,name:r,id:a,value:o,onChange:i,readOnly:d});switch(l.type){case"custom":{const e={...u,field:l,name:r,id:a,value:o,onChange:i,readOnly:d};return l.render(e)}case"text":case"textarea":/* @__PURE__ */
13
+ return j(t,{label:J(l,r),htmlFor:a,icon:l.icon,hint:l.hint,children:/* @__PURE__ */j(T,{id:a,value:"string"==typeof o?o:null==o?"":String(o),onChange:i,placeholder:l.placeholder,multiline:"textarea"===l.type,readOnly:d})});case"number":/* @__PURE__ */
14
+ return j(t,{label:J(l,r),htmlFor:a,icon:l.icon,hint:l.hint,children:/* @__PURE__ */j(s,{id:a,value:"number"==typeof o?o:void 0,onChange:i,min:l.min,max:l.max,step:l.step,placeholder:l.placeholder,readOnly:d})});case"select":{const n=`${a}-label`;/* @__PURE__ */
15
+ return j(t,{label:J(l,r),labelId:n,htmlFor:a,icon:l.icon,hint:l.hint,children:/* @__PURE__ */j(e,{id:a,value:o,options:l.options,onChange:i,readOnly:d,ariaLabelledBy:n})})}case"radio":/* @__PURE__ */
16
+ return j(t,{label:J(l,r),icon:l.icon,hint:l.hint,children:/* @__PURE__ */j(c,{ariaLabel:J(l,r),value:o,options:l.options.map(e=>({id:e.value,label:e.label,icon:e.icon,disabled:e.disabled||d})),onChange:e=>{d||i(e)}})});case"object":/* @__PURE__ */
17
+ return j(K,{...n,field:l});case"array":/* @__PURE__ */
18
+ return j(V,{...n,field:l});case"slot":return null}}var W=e=>l.includes(e);function X(e){let n,t=l[0];const r=[],a=/* @__PURE__ */new Set;for(const[l,o]of Object.entries(e))o&&(W(o.bucket)&&((o.marker||o.bucket!==t)&&(n=void 0),t=o.bucket),o.marker&&"string"==typeof o.fold?n={key:l,title:o.fold}:o.marker&&!1===o.fold&&(n=void 0),o.marker||!1===o.visible||(r.push(n?{name:l,field:o,bucket:t,fold:n}:{name:l,field:o,bucket:t}),"slot"!==o.type&&a.add(t)));return{rows:r,buckets:l.filter(e=>a.has(e))}}function Z(e){return new Map(X(e).rows.map(e=>[e.name,e.bucket]))}function q(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 Q({fields:e,values:n,onChange:t,readOnly:l=!1,context:a,tab:i,onTab:s,tabs:c=!0,tabIcons:d,renderers:m,idPrefix:p,ariaLabel:h,lead:f,children:b,leadFold:g,closedFolds:v,onFold:y}){const N=u("panel",o),O=$(),I=p??`es-insp${O.replace(/:/g,"")}`,S=X(e),[F,P]=C(void 0),L=i??F,M=L&&S.buckets.includes(L)?L:S.buckets[0],[T,A]=C(null),H=T&&T.panel===I&&S.rows.some(e=>e.name===T.name)?T:null,E=c&&S.buckets.length>1,R=E&&M?k(I,M):`${I}-rows`,[z,B]=C(()=>/* @__PURE__ */new Set),Y=v??z,J=(e,n)=>/* @__PURE__ */j(r,{title:e.title,open:!Y.has(e.key),onToggle:n=>((e,n)=>{void 0===v&&B(t=>{const l=new Set(t);return n?l.delete(e):l.add(e),l}),y?.(e,n)})(e.key,n),id:`${I}-fold-${e.key}`,children:n}),K=e=>E&&e!==M,V=({name:e,field:r,bucket:o})=>/* @__PURE__ */j("div",{className:"es-insp-row","data-field":e,"data-bucket":o,hidden:!!K(o)||void 0,children:/* @__PURE__ */j(G,{field:r,name:e,id:`${I}-${e}`,value:n[e],onChange:n=>t(e,n),readOnly:l,context:a,renderers:m,openItem:H&&H.name===e?H.index:null,onOpenItem:n=>A(null===n?null:{panel:I,name:e,index:n})})},e);/* @__PURE__ */
19
+ return D("div",{className:"es-insp",children:[E?/* @__PURE__ */j("div",{className:"es-insp-tabs",children:/* @__PURE__ */j(x,{variant:"underline",block:!0,"aria-label":h??N.settings,idPrefix:I,value:M,onChange:e=>{const n=e;void 0===i&&P(n),s?.(n)},items:S.buckets.map(e=>{const n=N.buckets[e],t=d?.[e];return t?{id:e,icon:t,label:/* @__PURE__ */j("span",{className:"sr-only",children:n}),tooltip:n}:{id:e,label:n}})})}):null,
20
20
  /* @__PURE__ */D("div",{className:"es-insp-rows",id:R,role:E?"tabpanel":void 0,"aria-labelledby":E&&M?w(I,M):void 0,children:[f?g?/* @__PURE__ */j("div",{className:"es-insp-band","data-fold":g.key,children:J(g,f)}):f:null,q(S.rows).map((e,n)=>{if(!e.fold)return e.rows.map(V);const t=e.rows[0].bucket,l=e.rows.every(e=>"slot"===e.field.type);/* @__PURE__ */
21
21
  return j("div",{className:"es-insp-band","data-fold":e.fold.key,"data-bucket":t,hidden:!(!K(t)&&!l)||void 0,children:J(e.fold,e.rows.map(V))},`fold-${e.fold.key}-${n}`)}),b]})]})}export{T as FieldText,Q as Inspector,G as InspectorField,Y as ListField,Z as bucketsOf,R as copyItem,A as insertAt,J as labelOf,H as moveTo,X as planFields,E as removeAt};
@@ -0,0 +1,5 @@
1
+ import{blockTypesIn as e}from"./chunk-5ZBY24K7.js";import{buildPaletteSections as t,pinnedSection as o,paletteWithoutPinned as n,categoryLabel as i}from"./chunk-PA3PNTVV.js";import{sectionTemplatesOf as s}from"./chunk-BVN33R76.js";import{SidePanelHead as r,PanelModeExit as c}from"./chunk-PFNIVZPN.js";import{useEaselSession as l}from"./chunk-O7Q4DDJT.js";import{blockRuns as a}from"./chunk-HQ4VVRIC.js";import{useScreenBlockLook as p,useScreenBlockRules as m}from"./chunk-ZR4CFNMW.js";import{DEFAULT_SCREEN_WORDS as d}from"./chunk-MCHMF32I.js";import{useEasel as f}from"./chunk-M5VRWM7M.js";import{useWords as u}from"./chunk-MFIRYGHW.js";import{AddPanel as k}from"./chunk-SSORUDHE.js";import{DEFAULT_DRAG_WORDS as h}from"./chunk-O2NLQBFX.js";import{useState as y,useEffect as b,useMemo as j}from"react";import{AddIcon as g}from"efficient-shell/icons/efficient";import{jsx as $,jsxs as O,Fragment as B}from"react/jsx-runtime";var N=e=>`section:${e}`,v=e=>`block:${e}`,F=e=>`template:${e}`;function I({blocks:I,blocksOnly:M,at:V,onAdd:x,itemFor:H,session:R,siteWide:C,onClose:L,onHide:A,readOnly:D}){const P=f(e=>e.config),S=p(),{labelAtLevel:W,categoryLabel:w,firstSection:Q,Icon:T,Thumbnail:Z}=S,{blockIsOffered:z}=m(),E=u("screen",d).add,Y=u("drag",h).add,G=l(),[J,K]=y([]);b(()=>{let t=!1;const o=e=>z(e,G);return s(G).list().then(n=>{if(t)return;const i=P.components;K(n.filter(t=>t.node?.type&&i[t.node.type]&&e(t.node).every(o)))}).catch(()=>{}),()=>{t=!0}},[P,G]);const U=j(()=>t(P,S),[P]),X=e=>({type:N(e.type),label:e.name,cover:/* @__PURE__ */$(Z,{type:e.type}),title:e.desc?`${e.name} — ${e.desc}`:E.tile({name:e.name}),keywords:[e.alias??"",e.desc,e.type,e.catLabel].filter(Boolean)}),q=j(()=>{const e=[];if(I&&I.choices.length>0&&a(I.choices).forEach((t,o)=>{e.push({key:`blocks:${o}`,title:0===o?`${E.inside({name:I.parentName})}${t.group?` · ${t.group}`:""}`:t.group??"",tiles:t.items.map(e=>({type:v(e.type),label:e.label,icon:/* @__PURE__ */$(T,{type:e.type,size:18}),title:E.tile({name:e.label})}))})}),M)return e;const t=o(U,Q);t&&e.push({key:"start",title:E.startBlank,tiles:[X(t)]}),J.length>0&&e.push({key:"templates",title:E.templates,tiles:J.map(e=>{return{type:F(e.id),label:e.name,cover:/* @__PURE__ */$(Z,{type:e.node.type}),keywords:[(t=e.node.type,W(t,"section",P.components[t]?.label??t)),e.node.type]};var t})});const s=n(U,Q);for(const t of Object.keys(P.categories??{})){const o=s.filter(e=>e.cat===t);0!==o.length&&e.push({key:`category:${t}`,title:i(P,t,w),tiles:o.map(X)})}return e},[I,M,J,U,P,E]),_=e=>{const t=e.indexOf(":"),o=e.slice(0,t),n=e.slice(t+1);if("section"===o)return{kind:"section",type:n};if("block"===o)return{kind:"block",type:n};if("template"===o){const e=J.find(e=>e.id===n);return e?{kind:"template",template:e}:null}return null};/* @__PURE__ */
2
+ return O(B,{children:[
3
+ /* @__PURE__ */$(r,{icon:/* @__PURE__ */$(g,{size:15}),title:E.title,context:M?E.contextBlocks:E.contextAll,actions:/* @__PURE__ */$(c,{label:E.done,description:E.doneDescription,onClick:L}),onHide:A}),
4
+ /* @__PURE__ */O("div",{className:"sf-addside sf-scroll",children:[
5
+ /* @__PURE__ */$(k,{groups:q,session:R,itemFor:e=>H(_(e)??{kind:"section",type:e}),onInsert:e=>{const t=_(e);t&&x(t)},at:V,hint:M?E.hintBlocks:E.hint,searchLabel:M?E.searchBlocks:E.searchSections,readOnly:D,words:Y}),C&&!M?C:null]})]})}export{I as AddSidePanel,v as blockKey,N as sectionKey,F as templateKey};
@@ -1,4 +1,4 @@
1
- import{blockRuns as e}from"./chunk-HQ4VVRIC.js";import{useScreenBlockLook as r}from"./chunk-6XXW6ZW3.js";import{DEFAULT_SCREEN_WORDS as s}from"./chunk-MCHMF32I.js";import{useWords as t}from"./chunk-MFIRYGHW.js";import{DropdownMenu as n}from"efficient-shell/ui";import{jsxs as c,Fragment as i,jsx as o}from"react/jsx-runtime";function l({choices:l,onPick:p}){const{Icon:a}=r(),m=t("screen",s),u=e(l).flatMap(e=>[...e.group?[{type:"label",key:`group:${e.group}`,label:/* @__PURE__ */c(i,{children:[e.group," ",
1
+ import{blockRuns as e}from"./chunk-HQ4VVRIC.js";import{useScreenBlockLook as r}from"./chunk-ZR4CFNMW.js";import{DEFAULT_SCREEN_WORDS as s}from"./chunk-MCHMF32I.js";import{useWords as t}from"./chunk-MFIRYGHW.js";import{DropdownMenu as n}from"efficient-shell/ui";import{jsxs as c,Fragment as i,jsx as o}from"react/jsx-runtime";function l({choices:l,onPick:p}){const{Icon:a}=r(),m=t("screen",s),u=e(l).flatMap(e=>[...e.group?[{type:"label",key:`group:${e.group}`,label:/* @__PURE__ */c(i,{children:[e.group," ",
2
2
  /* @__PURE__ */o("span",{className:"sf-menugroup-count",children:e.items.length})]})}]:[],...e.items.map(e=>({key:e.type,label:e.label,icon:/* @__PURE__ */o("span",{className:"sf-chip",children:/* @__PURE__ */o(a,{type:e.type,size:13})}),onSelect:()=>p(e.type)}))]);/* @__PURE__ */
3
3
  return o(n,{align:"start",triggerClassName:"sf-add-card",items:u,trigger:/* @__PURE__ */c(i,{children:[
4
4
  /* @__PURE__ */o("span",{className:"sf-plus sf-plus--sm",children:"+"}),m.addBlockMenu]})})}export{l as AddBlockRow};
@@ -0,0 +1,62 @@
1
+ import{dedupeSlotChildren as e}from"./chunk-26OOWIJJ.js";import{styleClipboardOf as n}from"./chunk-BXQBCW3P.js";import{markedTreeNodeId as t,revealSelectedTreeRow as o,sameSelector as r}from"./chunk-FGNR22NY.js";import{cloneNodeWithFreshIds as i}from"./chunk-2GVCAIPX.js";import{rootRowName as l,slotChildRowName as s,slotChildRenameProp as d,sectionRenameProp as c}from"./chunk-TBF5CVPA.js";import{scrollPreviewToSection as a,gotoPreviewSlide as p,scrollPreviewToTop as u}from"./chunk-4ES5JGGX.js";import{useEaselKeyTarget as f,useEaselUndoKeys as h,editorRootFocus as m}from"./chunk-UY7BCB32.js";import{SlotChildActionsProvider as g}from"./chunk-KCBEE2MC.js";import{screenStorageKeys as y,DEFAULT_PANEL_W as k,clampPanelWidth as S}from"./chunk-6TOYXESC.js";import{usePartBridge as v}from"./chunk-5PUEZ22M.js";import{useSectionOps as x}from"./chunk-57NRNFLO.js";import{useNodeClipboard as w,useNodeContextMenu as b}from"./chunk-LVUDUQNL.js";import{PageEditGuardNotices as z}from"./chunk-HQWQLDCB.js";import{useScreenDocument as B}from"./chunk-WZMU646D.js";import{requestMediaPick as C}from"./chunk-KG7RJWOK.js";import{heldStyle as O,styleShortcut as I}from"./chunk-V7U33NF2.js";import{AddChildRow as N}from"./chunk-5545A3PC.js";import{AddSidePanel as $}from"./chunk-DSXKBICS.js";import{SidePanelHead as P,PanelShowStrip as M}from"./chunk-PFNIVZPN.js";import{MediaSidePanel as T}from"./chunk-Q2L6YTII.js";import{useScreenSaveSwitch as A,useScreenNodeKeys as j,useScreenPinned as R,useScreenDocumentLabel as L,useScreenCanvasFrame as E,useScreenInspectorPanel as V,useScreenDevices as F,useScreenPickFollowsSelection as W,useScreenLeftView as H,useScreenAdd as U,SELECTION_MODE as D,sameInspectorMode as G,useScreenBridges as J,useScreenBlockRules as Y,useScreenBlockLook as X,useScreenStorageNamespace as Q,useScreenNotify as K,useScreenCanvasHead as _,isSlotMode as q,useScreenStyleClipboard as Z,useScreenDocumentPass as ee,useScreenCanvasDrag as ne,ScreenCanvasTargetProvider as te,isPinnedFirst as oe,isPinnedLast as re,screenSlotsOf as ie}from"./chunk-ZR4CFNMW.js";import{ROOT_ZONE as le,blockNodeActions as se,TREE_MAX_DEPTH as de,childSlotsOf as ce,slotFieldsOf as ae,slotChildrenIn as pe,nestsInTree as ue,newNodeId as fe}from"./chunk-PLVEGYK6.js";import{useMediaPanel as he,usePanelPick as me,useCancelPanelPick as ge}from"./chunk-R6WTQWAC.js";import{useEaselHost as ye,useHostEscape as ke}from"./chunk-U3JP4VGF.js";import{DEFAULT_STYLE_CLIPBOARD_WORDS as Se}from"./chunk-6WY6ZXJG.js";import{DEFAULT_SCREEN_WORDS as ve}from"./chunk-MCHMF32I.js";import{useEasel as xe,useEaselApi as we}from"./chunk-M5VRWM7M.js";import{TreeRow as be,Subtree as ze,LayersTree as Be,TreeGroupLabel as Ce,TreeRowAction as Oe,TreeSeam as Ie}from"./chunk-4JSBIW5H.js";import{DEFAULT_TREE_WORDS as Ne}from"./chunk-K56YDHYQ.js";import{DEFAULT_NODE_MENU_WORDS as $e}from"./chunk-WK3AFPXY.js";import{toItemSelector as Pe,useNodeOps as Me,clickPick as Te}from"./chunk-UK2FQOUT.js";import{LayersIcon as Ae,MediaIcon as je}from"./chunk-4VJATVVR.js";import{DEFAULT_SAVE_WORDS as Re,saveIndicator as Le}from"./chunk-H6DDIBQ4.js";import{EaselTopBar as Ee,TopBarRail as Ve,TopBarCluster as Fe,EaselIconButton as We,TopBarDivider as He,DeviceSwitch as Ue,InspectorIconButton as De,PanelResizeHandle as Ge,MAX_PANEL_W as Je,MIN_PANEL_W as Ye,panelWidthVars as Xe,SaveState as Qe,SaveStateToggle as Ke}from"./chunk-UB4TLWVJ.js";import{DEFAULT_CHROME_WORDS as _e}from"./chunk-Y2G7CU6A.js";import{useWords as qe}from"./chunk-MFIRYGHW.js";import{insertSeams as Ze,CanvasDragLayer as en,CanvasInsert as nn}from"./chunk-SSORUDHE.js";import{DEFAULT_DRAG_WORDS as tn}from"./chunk-O2NLQBFX.js";import{createDragSession as on,useTreeDrag as rn,gapToMoveIndex as ln}from"./chunk-67GNT6PF.js";import{useCanvasFrame as sn,LIST_SELECTOR as dn,BLOCK_SELECTOR as cn,useCanvasEvent as an}from"./chunk-AWJUYMX7.js";import{zoneKey as pn,ROOT_ID as un,ROOT_SLOT as fn,parseZoneKey as hn,DataError as mn,find as gn}from"./chunk-KRXQM65X.js";import{useRef as yn,useMemo as kn,useState as Sn,useEffect as vn,useCallback as xn,useLayoutEffect as wn,Fragment as bn}from"react";import{Tooltip as zn,Button as Bn,toast as Cn}from"efficient-shell/ui";import{UndoIcon as On,RedoIcon as In,TrashIcon as Nn,EyeOffIcon as $n,EyeIcon as Pn,DuplicateIcon as Mn}from"efficient-shell/icons/efficient";import{jsx as Tn,jsxs as An,Fragment as jn}from"react/jsx-runtime";function Rn({saveState:e,notSaving:n,readOnlyReason:t,toggle:o,onToggle:r,onRetry:i,words:l,saveWords:s}){if(null!==t)/* @__PURE__ */return Tn(Qe,{tone:"off",label:t,role:"status"});if(n)/* @__PURE__ */
2
+ return Tn(Qe,{tone:e.pending?"off-unsaved":"off",label:l.notSaving,role:"status"});const{tone:d,label:c}=Le(e,s),a=e.failed&&!e.paused&&/* @__PURE__ */Tn(Bn,{variant:"secondary",size:"sm",onClick:i,children:l.retry});/* @__PURE__ */
3
+ return An(jn,o?{children:[
4
+ /* @__PURE__ */Tn(Ke,{pressed:e.paused,onToggle:r,title:e.paused?l.autoSaveOff:l.autoSaveOn,children:/* @__PURE__ */Tn(Qe,{tone:d,label:c})}),a]}:{children:[
5
+ /* @__PURE__ */Tn(Qe,{tone:d,label:c,role:"status"}),a]})}function Ln({expand:e}){/* @__PURE__ */
6
+ return Tn("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.9,strokeLinecap:"round",strokeLinejoin:"round",children:/* @__PURE__ */An(jn,e?{children:[
7
+ /* @__PURE__ */Tn("path",{d:"M8 9l4-4 4 4"}),
8
+ /* @__PURE__ */Tn("path",{d:"M8 15l4 4 4-4"})]}:{children:[
9
+ /* @__PURE__ */Tn("path",{d:"M8 4l4 4 4-4"}),
10
+ /* @__PURE__ */Tn("path",{d:"M8 20l4-4 4 4"}),
11
+ /* @__PURE__ */Tn("path",{d:"M5 12h14"})]})})}var En=`${dn}, ${cn}`;function Vn(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 Fn="__rungs";var Wn="screen:band",Hn={duplicate:!0,delete:!0};function Un(){const Le=ye(),{target:Qe,docId:Ke,capabilities:dn,currentSlug:Un,siteId:Dn,onPublish:Gn,saveState:Jn,saveConflict:Yn,retrySave:Xn,toggleAutoSave:Qn,readOnly:Kn,readOnlyReason:_n=null}=B(),qn=A(),Zn=j(),{mediaEditing:et,hasEditGuard:nt,hasPinnedChrome:tt}=dn,{appState:ot,dispatch:rt,history:it,selectedItem:lt,getSelectorForId:st,config:dt}=xe(e=>e),ct=R(),{first:at,firstGroup:pt,lastGroup:ut,isSectionGroup:ft,sectionGroupZone:ht,panelOf:mt}=ct,gt=mt(at),yt=e=>oe(ct,e),kt=e=>re(ct,e),St="node"===ct.firstRow,vt=ct.band??null,xt=qe("screen",ve),wt=qe("tree",Ne),bt=qe("drag",tn),zt=qe("save",Re),Bt=qe("menu",$e),Ct=qe("styleClipboard",Se),Ot=qe("chrome",_e),It=L()??`/${Un}`,Nt=E(),$t=V(),Pt=x({readOnly:Kn}),Mt=x({readOnly:Kn,foldIntoHistory:!0}),Tt=yn(null),At=we(),jt=kn(()=>({...Pt,select:e=>{Tt.current=e,Pt.select(e)},commitDocument:(e,n)=>{if(void 0!==n){const t=At.config;Tt.current=Pe(e,t,n)}Pt.commitDocument(e,n)}}),[Pt,At]),Rt=ot.ui,Lt=Rt.leftSideBarVisible,Et=Rt.rightSideBarVisible,{options:Vt,widths:Ft,initial:Wt,fluid:Ht,fit:Ut}=F(),[Dt,Gt]=Sn(Wt),Jt=he(),Yt=et&&null!==Jt,Xt=me(),Qt=ge();W(lt?.props.id);const{read:Kt,write:_t,forSelection:qt}=H(),[Zt,eo]=Sn(Kt);vn(()=>{_t(Zt)},[Zt]);const[no,to]=Sn(0),oo=yn(null),ro=yn(null),io=sn(ro,{readySelector:En}),lo=f(ro);h(ro,io);const[so,co]=Sn(!1),ao=yn(!1),po=yn(!1),[uo,fo]=Sn(null),ho=U(),mo=e=>fo(null===e?null:{zone:le,index:e}),[go,yo]=Sn([]),[ko,So]=Sn(D),vo="puck"===ko.kind,xo=so&&!uo&&ho.railTarget?ho.railTarget(ot.data,{node:lt??null,mode:ko}):null,wo=xo?{zone:pn(xo),index:xo.index}:null,bo=uo??wo,zo=bo&&bo.zone===le?bo.index:null,Bo=t(ko,lt?.props.id),[Co,Oo]=Sn(null);vn(()=>{Co&&(o(),Oo(null))},[Co]);const Io=yn(st);Io.current=st;const No=xn((e,{scroll:n})=>{eo(n=>qt(e,n)),n&&Oo(e);const t=[];let o=e;for(let e=0;e<4;e++){const e=Io.current(o)?.zone;if(!e||!e.includes(":"))break;const n=e.split(":")[0];t.push(n),t.push(e),o=n}0!==t.length&&ir(e=>{if(t.every(n=>!e.has(n)))return e;const n=new Set(e);return t.forEach(e=>n.delete(e)),n})},[]),$o=yn(null);vn(()=>{const e=$o.current;$o.current=null;const n=null==lt?.props.id?null:String(lt.props.id);So(e&&e.id===n?e.mode:mt(lt?.type)??D);const t=lt?.props.id,o=Tt.current;if(Tt.current=null,!t)return;const i=st(t);No(String(t),{scroll:!r(o,i??null,le)})},[lt?.props.id,No]);const Po=xn(e=>{So(n=>G(n,e)?n:e),rt({type:"setUi",ui:{rightSideBarVisible:!0}})},[rt]),Mo=yn(()=>{});Mo.current=(e,n)=>{const t=e?Kr(e.zone??le)[e.index]?.props.id:null,o=null==t?null:String(t),r=null==lt?.props.id?null:String(lt.props.id);So(e=>G(e,n)?e:n),o!==r&&($o.current={id:o,mode:n},jt.select(e))};const To=xn((e,n)=>Mo.current(e,n),[]),Ao={kind:ko.kind,mode:ko,open:Po,show:e=>So(e),reveal:()=>{Et||rt({type:"setUi",ui:{rightSideBarVisible:!0}})},select:To},jo=J(Ao,{data:ot.data,selected:lt??null,zoneOf:e=>st(e)?.zone,readOnly:Boolean(Kn),select:e=>{So(D),jt.select({index:e})},replace:(e,n)=>jt.replaceComponent(le,e,n),scrollTo:e=>xi(e)},{device:Dt,refreshes:no},{setView:eo,reveal:()=>{Lt||rt({type:"setUi",ui:{leftSideBarVisible:!0}})}}),Ro=jo.pinnedSource??!1,Lo=jo.resolveLeftView?jo.resolveLeftView(Zt,Yt):"media"===Zt&&Yt?Zt:"sections",Eo=Y(),{isLockedBlock:Vo,duplicateBlocked:Fo,nestDepth:Wo,newSectionNode:Ho,canAddTo:Uo,blockIsOffered:Do}=Eo,Go=X(),{labelAtLevel:Jo,Icon:Yo,useProducts:Xo}=Go,Qo=Go.rowName?(e,n,t)=>Go.rowName(e,n,t):void 0,Ko=xn(e=>{rt({type:"setUi",ui:{rightSideBarVisible:!0}}),a(e),No(e,{scroll:!0})},[rt,No]),{selectNode:_o,openPartId:qo}=v({mode:ko,setMode:So,onOpenPart:Ko}),[Zo,er]=Sn(null);ke(null!==Zo,()=>er(null));const nr=y(Q()),tr=nr.collapsed,or=nr.panelWidths,[rr,ir]=Sn(()=>{if("undefined"==typeof window)/* @__PURE__ */return new Set;try{const e=window.localStorage.getItem(tr);return new Set(e?JSON.parse(e):[])}catch{/* @__PURE__ */
12
+ return new Set}});vn(()=>{try{window.localStorage.setItem(tr,JSON.stringify([...rr]))}catch{}},[rr]);const[lr,sr]=Sn(()=>{if("undefined"==typeof window)return{...k};try{const e=window.localStorage.getItem(or);if(!e)return{...k};const n=JSON.parse(e);return{left:S(Number(n.left)||k.left),right:S(Number(n.right)||k.right)}}catch{return{...k}}});vn(()=>{const e=setTimeout(()=>{try{window.localStorage.setItem(or,JSON.stringify(lr))}catch{}},300);return()=>clearTimeout(e)},[lr]);const dr=xn((e,n)=>sr(t=>{const o="function"==typeof n?n(t[e]):n;return t[e]===o?t:{...t,[e]:o}}),[]),cr=xn(e=>dr("left",e),[dr]),ar=xn(e=>dr("right",e),[dr]),pr=e=>rr.has(e),ur=e=>ir(n=>{const t=new Set(n);return t.has(e)?t.delete(e):t.add(e),t}),fr=yn(!1),hr=yn(null);vn(()=>{if(fr.current&&!so){const e=hr.current,n=e&&e.isConnected&&!e.closest('[aria-hidden="true"]')?e:null;(n??ro.current?.querySelector(`button[aria-label="${CSS.escape(xt.add.title)}"]`))?.focus(),hr.current=null}fr.current=so},[so]),vn(()=>{if(!so||!lo)return;const e=e=>{"Escape"===e.key&&$i()};return lo.addEventListener("keydown",e),()=>lo.removeEventListener("keydown",e)},[so,lo]),ke(so,()=>$i()),vn(()=>{!Lt&&so&&(co(!1),fo(null),ao.current=!1)},[Lt]),vn(()=>{if(!Xt)return po.current&&rt({type:"setUi",ui:{leftSideBarVisible:!1}}),void(po.current=!1);so&&(co(!1),fo(null),po.current=ao.current,ao.current=!1),Lt||(po.current=!0,rt({type:"setUi",ui:{leftSideBarVisible:!0}}))},[Xt]),vn(()=>{!Lt&&Xt&&(po.current=!1,Qt())},[Lt]),vn(()=>{if(!Xt||!lo)return;const e=e=>{"Escape"===e.key&&Qt()};return lo.addEventListener("keydown",e),()=>lo.removeEventListener("keydown",e)},[Xt,lo]),ke(null!==Xt,()=>Qt());const mr=K(),gr=(e,n="success")=>{mr?mr(e,"error"===n?"error":"info"):"error"===n?Cn.error(e,{duration:3200,sound:!1}):Cn.success(e,{duration:1900,sound:!1})},yr=yn(null),[kr,Sr]=Sn(0),[vr,xr]=Sn(0),wr=_(),br=yn(null),zr=e=>Math.max(0,e.clientHeight-(br.current?.offsetHeight??0));vn(()=>{const e=yr.current;if(!e)return;const n=()=>{Sr(e.clientWidth),xr(zr(e))};n();const t=new ResizeObserver(n);return t.observe(e),br.current&&t.observe(br.current),()=>t.disconnect()},[]),wn(()=>{yr.current&&(Sr(yr.current.clientWidth),xr(zr(yr.current)))},[lr,Lt,Et]);const Br=Dt===Ht?kr>0?kr:Ft[Ht]:Ft[Dt],Cr=kr>0?Math.min(kr/Br,"shrink"===Ut?1:2):1,Or=Br*Cr,Ir=kr>0&&Or>kr+1,Nr={width:Or,height:vr||"100%",flex:"none",position:"relative"},$r={width:Br,height:vr?vr/Cr:"100%",maxHeight:"none",transform:1!==Cr?`scale(${Cr})`:void 0,transformOrigin:"top left"},Pr=()=>rt({type:"setUi",ui:{leftSideBarVisible:!Lt}}),Mr=()=>rt({type:"setUi",ui:{rightSideBarVisible:!Et}}),Tr=e=>{so&&(co(!1),fo(null),ao.current=!1,Lt&&Zt===e)||Xt&&(po.current=!1,Qt(),Lt&&Zt===e)||(Lt&&Zt===e?Pr():(eo(e),Lt||rt({type:"setUi",ui:{leftSideBarVisible:!0}})))},Ar=()=>{C(Le,{accept:"image/*",title:Ot.mediaLibrary})},jr=()=>{So(D),jt.select(null),u()},Rr=()=>{So(gt??D),Et||rt({type:"setUi",ui:{rightSideBarVisible:!0}})},Lr=ot.data.content??[],Er=()=>{const e=Lr.findIndex(yt),n=Lr.findIndex(kt);return{floor:e>=0?e+1:0,cap:n>=0?n:Lr.length}},Vr=dt,Fr=Eo.stripCopy,Wr=e=>i(e,Fr),Hr=w(),Ur=Me({data:ot.data,config:Vr,readOnly:Boolean(Kn),clipboard:Hr,strip:Fr?e=>Fr(e):void 0,afterRemove:"none",stepBounds:(e,n)=>{if(e.parentId!==un||e.slot!==fn)return{min:0,max:n-1};const{floor:t,cap:o}=Er();return{min:t,max:o-1}},commit:(e,{select:n})=>{void 0!==n&&So(D);const t=void 0===n||"node"===n?.kind?n:null;jt.commitDocument(e,t)}}),Dr=e=>Jo(e,"block",dt.components[e]?.label??e),Gr=xn(e=>dt.components[e]?.defaultProps??{},[dt]),Jr=e=>Jo(e,"section",Dr(e)),Yr=e=>l({type:e.type,props:e.props??{}},Jr(e.type),Qo),{nodeAddresses:Xr,zoneItems:Qr}=kn(()=>{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>=de)return;const s=/* @__PURE__ */new Map;for(const{child:e,zone:t}of ce(dt,n))s.set(t,[...s.get(t)??[],e]);for(const[e,n]of s)t(n,e,i+1)})};return t(Lr,le,0),{nodeAddresses:e,zoneItems:n}},[Lr,dt]),Kr=xn(e=>Qr.get(e)??[],[Qr]),_r=e=>{const n=Xr.get(e);return n?Kr(n.zone)[n.index]:void 0},qr=e=>ie(Eo,dt,e),Zr=e=>{if(!Eo.slotsOf||e===le)return null;const n=e.lastIndexOf(":");if(n<=0)return null;const t=_r(e.slice(0,n));if(!t)return null;const o=qr(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}},ei=(()=>{if(!q(ko))return null;const e=`${ko.nodeId}:${ko.slot}`;return Zr(e)?.slot.panel===ko.kind?e:null})(),ni=yn(null);vn(()=>{const e=ni.current;if(ni.current=null,!ei||!q(ko))return;const n=ko.nodeId;No(n,{scroll:e!==ei}),ir(e=>{if(!e.has(n))return e;const t=new Set(e);return t.delete(n),t})},[ko]);const ti=(e,n,t)=>{const o=String(e.props.id);if(!n.panel)return void(e=>{const n=Xr.get(e);n&&(n.zone===le?wi(n.index):qi(n.zone,n.index,e,_r(n.zone.slice(0,n.zone.lastIndexOf(":")))?.type??""))})(o);const r={kind:n.panel,nodeId:o,slot:n.slot},i=`${o}:${n.slot}`;t&&ei!==i&&(ni.current=i),To(null,r),Et||rt({type:"setUi",ui:{rightSideBarVisible:!0}}),xi(o)},oi=(e,n,t)=>{const o=`${e}:${n}`;if(ir(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;ei!==o&&(ni.current=o);To(null,{kind:t,nodeId:e,slot:n})},ri=(e,n,t)=>{if(Kn||!Eo.moveSlot)return;const o=_r(e),r=o?qr(o).filter(e=>e.rung):[],i=r[n];if(!i)return;const l={parentId:e,slot:Fn,index:n},s=ln(l,{...l,index:Math.min(Math.max(t,0),r.length)});if(s===n)return;const d=Eo.moveSlot(e,n,s);"string"==typeof d&&oi(e,d,i.panel)},ii=Xo(),li=kn(()=>{const e=/* @__PURE__ */new Map;for(const n of ii??[])e.set(n.slug,n.name);return e},[ii]),si=e=>s(e,Dr,Go.plainText,e=>li.get(e),Go.rowName),di=(e,n)=>{const t=dt.components[e.type]?.fields,o=n===le||gl(n)?"section":"block",r=n===le&&(yt(e)||kt(e)||ft(e.type)),i="block"===o?d(t):r?null:c(t);return Go.renamePropOf?Go.renamePropOf(e,o,i):i},ci=(e,n,t,o)=>{if(!(!Kn&&Zo?.zone===e&&Zo.index===n))return;const r=(t,o)=>{er(null),o&&((e,n,t)=>{const o=Kr(e)[n];if(!o)return;const r=di(o,e);r&&jt.replaceComponent(e,n,{...o,props:{...o.props,[r]:t.trim()}})})(e,n,t)};/* @__PURE__ */
13
+ return Tn("input",{className:"es-tree-rename",defaultValue:o,autoFocus:!0,"aria-label":xt.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)},ai=n(Z(),Ct),pi=ai.scope({target:Qe,siteId:Dn,docId:Ke}),ui=dt,fi=(e,n)=>n===le?Jr(e):Dr(e),hi=(e,n,t)=>{const o=ai.plan(pi,t,fi(t.type,e),ui);o&&(o.changed&&jt.replaceComponent(e,n,{...t,props:{...o.props,id:t.props.id}}),gr(o.message))},mi=b({nodesIn:Kr,nodeAt:(e,n)=>Kr(e)[n]??null,labelOf:(e,n)=>n===le?Jr(e):Dr(e),renamePropOf:di,beginRename:(e,n)=>er({zone:e,index:n}),history:{hasPast:it.hasPast,hasFuture:it.hasFuture,back:()=>it.back(),forward:()=>it.forward()},openAddSection:()=>{jt.select(null),Ii(null)},openPageSettings:()=>{jt.select(null),So(D)},pageSettingsLabel:xt.pageSettings,words:{menu:Bt,styleClipboard:Ct,screen:xt.menu},readOnly:Boolean(Kn),collapseAll:()=>ir(new Set(Kr(le).map(e=>String(e.props.id)))),onPasteRefused:e=>gr(e?xt.pasteRefused({name:e.label}):xt.menu.clipboardRefused,"error"),canPasteAt:(e,n)=>kl(e,n),menuRows:jo.menuRows,isLocked:e=>Vo(e.type),duplicateBlocked:e=>Fo(ot.data,e),permits:e=>se(dt,e.type),canAddTo:Uo,nodeOps:Ur,isPinned:(e,n)=>n===le&&(yt(e)||kt(e)),sectionBand:Er,openAddInside:(e,n)=>{e===le?wi(n):jt.select({zone:e,index:n}),Ii(null)},locate:e=>Xr.get(e)??null,rowNameOf:(e,n)=>n===le?Yr(e):si(e),selectAt:(e,n,t,o)=>{e===le?wi(n):qi(e,n,t,o??"")},slotRung:e=>{const n=Zr(e);return n?.slot.panel?{label:n.slot.label,select:()=>ti(n.node,n.slot,!1)}:null},style:{held:()=>O(pi),canCopy:e=>ai.rows(ui,e).some(e=>!1!==e.counted),copy:(e,n)=>ai.copy(pi,e,fi(e.type,n),ui),paste:(e,n,t)=>hi(e,n,t)},keys:Zn?{target:lo,selected:()=>{const e=ot.ui.itemSelector;return e?{zone:e.zone??le,index:e.index}:null},held:()=>Hr.get(),readOnly:Boolean(Kn),onDone:({done:e,name:n})=>{"copied"===e&&gr(xt.copied({name:n}))}}:void 0},io),gi=yn({copy:(e,n)=>{},paste:(e,n,t)=>{},at:()=>null,readOnly:!1});vn(()=>{gi.current={copy:(e,n)=>ai.copy(pi,e,fi(e.type,n),ui),paste:hi,at:()=>{const e=ot.ui.itemSelector;if(!e)return null;const n=e.zone??le,t=Kr(n)[e.index];return t?{zone:n,index:e.index,node:t}:null},readOnly:Boolean(Kn)}});const yi=xn(e=>{const n=I(e);if(!n)return;const t=gi.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))},[]);vn(()=>{if(!lo)return;const e=e=>yi(e);return lo.addEventListener("keydown",e),()=>lo.removeEventListener("keydown",e)},[yi,lo]),an(io,"keydown",yi);const ki=Lr.map(e=>e.props.id).join("|");vn(()=>{const e=io?.document??null,n=io?.window??null;let t=0;const o=[],r=()=>{if(!e)return void yo(e=>e.length?[]:e);const n=Lr.findIndex(kt),t=n>=0?n:Lr.length,o=n=>{const t=Lr[n]?.props?.id;return null==t?null:e.querySelector(`[data-puck-component="${CSS.escape(String(t))}"]`)},r=e=>e?[...e.querySelectorAll(cn)].map(e=>e.getBoundingClientRect()).filter(e=>e.width>0||e.height>0):[],i=[];for(let e=Lr.length>0&&!yt(Lr[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=Vn(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})}yo(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()}},[io,ki,Dt,Cr,Lt,Et,lt?.props.id]);const Si=io?.document??null,vi=io?.window??null;vn(()=>{const e=oo.current;if(!e||!Si||!vi)return;const n=[],t=()=>{const n=Si.querySelector(`[data-puck-component="${CSS.escape(e.id)}"]`);if(!n)return!1;const t=n.getBoundingClientRect().top-e.offset;return Math.abs(t)>1&&vi.scrollTo({left:vi.scrollX,top:vi.scrollY+t,behavior:"instant"}),!0};return oo.current=null,t()&&n.push(setTimeout(t,150),setTimeout(t,450)),()=>n.forEach(clearTimeout)},[Si,vi]);const xi=e=>{jo.holdCanvasOn?jo.holdCanvasOn(e):a(e)},wi=e=>{So(D),jt.select({index:e}),jo.sectionPressed?.(Lr[e]);const n=Lr[e]?.props?.id;n&&xi(n)},bi=e=>{const{floor:n,cap:t}=Er(),o=e=>Math.min(Math.max(n,e),t);if("number"==typeof e)return o(e);const r=lt&&ko.kind!==gt?.kind?Lr.findIndex(e=>e.props.id===lt.props.id):-1;return o(r>=0?r+1:t)},zi=(e,n)=>{const{floor:t,cap:o}=Er(),r=Math.min(Math.max(n,t),o),i=e<r?r-1:r;return i===e?{moved:!1,dest:e}:(jt.reorderComponent(le,e,i),jt.select({index:i}),{moved:!0,dest:i})},Bi=(e,n,t,o)=>{So(D),jt.select(o?{index:o.index,zone:o.zone}:{index:e}),a(n),gr(xt.sectionAdded({name:t}))},Ci=(e,n)=>{const t=bi(n),o=Ho(e,{nodeDefaults:Gr,newNodeId:fe,sectionLabel:Jr,blockIsOffered:Do}),r=o?jt.insertNode(le,t,o):jt.insertSection(e,t);return Bi(t,r,Jr(e),o?((e,n,t)=>{if(e.type===t)return null;const o={at:null},r=(e,n,i)=>{const l=i.filter(n=>n===e.type).length;for(const{child:s,zone:d,index:c}of ce(dt,e)){if(s.type===t&&(!o.at||n>o.at.depth)){const r=Uo(e.type,l,d.slice(d.lastIndexOf(":")+1)),i=r?.choices??(r?.spec?[{type:r.spec.childType,label:r.spec.childType}]:[]);null!==r&&"footer"!==r.source&&`${e.props.id}:${r.slot}`===d&&i.some(e=>e.type===t)&&(o.at={zone:d,index:c,depth:n})}r(s,n+1,[...i,e.type])}};return r({type:e.type,props:{...e.props,id:n}},1,[]),o.at?{zone:o.at.zone,index:o.at.index}:null})(o,r,e):null),t},Oi=(e,n,t)=>{const o=bi(t),r=jt.insertNode(le,o,n);return Bi(o,r,e),o},Ii=e=>Ni(le,e),Ni=(e,n)=>{hr.current=document.activeElement??null,Xt&&(ao.current=po.current,po.current=!1,Qt()),fo(null===n?null:{zone:e,index:n}),co(!0),Lt||(ao.current=!0,rt({type:"setUi",ui:{leftSideBarVisible:!0}}))},$i=()=>{co(!1),fo(null),ao.current&&rt({type:"setUi",ui:{leftSideBarVisible:!1}}),ao.current=!1},Pi=(e,n,t)=>{if("section"===e.kind)jt.insertComponent(n,e.type,t);else{if("template"!==e.kind)return;jt.insertNode(n,t,Wr(e.template.node))}So(D),jt.select({index:t,zone:n})},Mi=(e,n)=>Go.rowName?n?yt(e)?Go.rowName(e,"section",xt.header):kt(e)?Go.rowName(e,"section",xt.footer):ft(e.type)?Go.rowName(e,"section",Dr(e.type)):Yr(e):si(e):n?Jr(e.type):Dr(e.type),Ti=e=>n=>{e()},Ai=()=>jo.editPinnedSource?.(),ji=(e,n,t)=>{if(Kn)return null;const o=Kr(e)[n];return o&&!se(dt,o.type).delete?null:/* @__PURE__ */Tn(Oe,{kind:"delete",label:xt.deleteNamed({name:t}),onClick:()=>((e,n)=>{const t=Kr(e)[n]?.props?.id;null!=t&&Ur.remove(String(t))})(e,n),children:/* @__PURE__ */Tn(Nn,{size:15})})},Ri=e=>Go.rowPreview?.(e)||void 0,Li=e=>Go.rowMarks?.(e)??void 0,Ei=(e,n,t)=>Go.rowActions?.(e,n,t)??null,Vi=(e,n,t,o)=>{if(Kn)return null;const r=Boolean(t.props._hidden);/* @__PURE__ */
14
+ return Tn(Oe,{kind:"eye",label:r?xt.showNamed({name:o}):xt.hideNamed({name:o}),onClick:()=>Wi(e,n,t),children:/* @__PURE__ */Tn(r?$n:Pn,{size:14,strokeWidth:1.8,strokeLinecap:void 0,strokeLinejoin:void 0})})},Fi=e=>{const n=Jr(Lr[e]?.type??""),t=n?xt.addSectionBefore({name:n}):xt.addSectionHere;return Wl(le,e,()=>Ii(e),t)},Wi=(e,n,t)=>{jt.replaceComponent(e,n,{...t,props:{...t.props,_hidden:!t.props._hidden}})},Hi=e=>ae(dt,e),Ui=e=>ce(dt,e),Di=e=>Eo.slotsOf?qr(e).map(n=>({slot:n.slot,rung:n.rung?n:null,kids:pe(e,n.slot)})):[{slot:null,rung:null,kids:Ui(e)}],Gi=e=>Eo.slotsOf?Di(e).flatMap(e=>e.kids):Ui(e),Ji=e=>Boolean(Eo.slotsOf)&&qr(e).some(e=>e.rung),Yi=(e,n,t)=>null===t?void 0===n?Uo(e):Uo(e,n):Uo(e,n,t),Xi=(e,n,t)=>{const o=ue(dt,e.type,n)&&(t||Gi(e).length>0||Ji(e));return{collapsible:o,folded:o&&pr(String(e.props.id))}},Qi=(e,n,t)=>Di(e).flatMap(o=>{const r=o.rung?n+1:n,i=o.kids.flatMap(({child:e})=>Xi(e,r,t(e.type)).collapsible?[String(e.props.id),...Qi(e,r+1,t)]:[]);return o.rung?[`${e.props.id}:${o.rung.slot}`,...i]:i}),Ki=e=>Gi(e).length>0||Ji(e)||Boolean(Uo(e.type)),_i=e=>Boolean(Uo(e)),qi=(e,n,t,o)=>{if(So(D),Uo(o)?.spec?.slider){const t=e.split(":")[0];p(t,n),jt.select({index:n,zone:e}),a(t)}else jt.select({index:n,zone:e}),xi(t)},Zi=(e,n,t,o,r)=>{const i=`${e}:${n}`;jt.insertComponent(i,t,o),Uo(r)?.spec?.slider?requestAnimationFrame(()=>{p(e,o),jt.select({index:o,zone:i})}):jt.select({index:o,zone:i})},el=(e,n,t)=>{jt.insertComponent(e,n,t),So(D),jt.select({index:t,zone:e})},nl=yn(/* @__PURE__ */new Set);vn(()=>{Lr.forEach(e=>{const n=Uo(e.type)?.spec;if(!n)return;const t=e.props.id;if(nl.current.has(t))return;nl.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(Gr)).forEach((e,t)=>Mt.seedChild(o,t,n.childType,e))})},[Lr,Mt,Gr]);const tl=yn(/* @__PURE__ */new Set);vn(()=>{Lr.forEach((n,t)=>{const o=n.props.id;if(tl.current.has(o))return;const r=e(n,Hi(n.type));tl.current.add(o),r&&Mt.replaceComponent(le,t,{...n,props:r})})},[Lr,Mt]),ee(Mt,dt);const ol=Lr.findIndex(kt),rl=ol>=0?Lr[ol]:null,il=St?Lr.findIndex(yt):-1,ll=il>=0?Lr[il]:null,sl=Lr.find(e=>e.type===pt)??null,dl=Lr.find(e=>e.type===ut)??null,cl=ol>=0?ol:Lr.length,al=[];Lr.forEach(e=>{kt(e)||(Ki(e)&&al.push(String(e.props.id)),al.push(...Qi(e,1,_i)))}),rl&&(al.push(String(rl.props.id)),al.push(...Qi(rl,1,_i)));const pl=al.length>0&&al.every(e=>rr.has(e)),ul=e=>{const n=Go.blockRowName(e,Dr);return Go.rowName?Go.rowName(e,"block",n):n},fl=(e,n,t,o)=>{const r=Kr(e)[t];if(!r)return;const i={...hn(e),index:t},l={...hn(n),index:Math.min(Math.max(o,0),Kr(n).length)},s=ln(i,l);if(e!==n||s!==t)try{Ur.move(String(r.props.id),{...l,index:s})}catch(e){if(!(e instanceof mn))throw e}},hl=e=>{const n=/* @__PURE__ */new Set,t=e=>{for(const{child:o,zone:r}of Ui(e))n.add(r),t(o)};for(const t of Hi(e.type))n.add(`${e.props.id}:${t}`);return t(e),n},ml=e=>{let n=e.slice(0,e.indexOf(":"));for(let e=0;e<64;e++){const e=Xr.get(n);if(!e)return null;if(e.zone===le)return n;n=e.zone.slice(0,e.zone.indexOf(":"))}return null},gl=e=>{const n=e.slice(0,e.indexOf(":")),t=Lr.find(e=>ft(e.type)&&String(e.props.id)===n);return t&&ht(n)===e?t:null},yl=(e,n,t)=>{if(e.rung){const t=_r(e.rung.nodeId),o=t?qr(t).filter(e=>e.rung).length:0;return n.parentId===e.rung.nodeId&&n.slot===Fn&&n.index>=0&&n.index<=o}if(n.slot===Fn)return!1;if(e.add)return vl(e.add,n);const o=pn(n);if(ft(e.type))return!1;const r=gl(o),i=gl(e.zone);if(r||i)return!(!r||!i)&&(n.index>=0&&n.index<=Kr(o).length);if(e.zone===le||o===le){if(e.zone!==o)return!1;const{floor:t,cap:r}=Er();return n.index>=t&&n.index<=r}if(n.index<0||n.index>Kr(o).length)return!1;if(e.zone===o)return!0;const l=rl&&!ct.lastIsOpen?String(rl.props.id):null;return(!l||ml(e.zone)!==l&&ml(o)!==l)&&((e,n,t,o)=>{if(e===n)return!0;const r=o??Kr(e)[t];if(!r)return!1;const i=n.split(":")[0],l=Xr.get(i),s=l?Kr(l.zone)[l.index]:void 0;if(!s)return!1;if(!o&&hl(r).has(n))return!1;const d=Uo(s.type,Wo(ot?.data,s.type,i),n.slice(n.lastIndexOf(":")+1));return!!d&&(!!(d.choices?d.choices.some(e=>e.type===r.type):d.spec?.childType===r.type)&&!d.spec?.addBlocked?.(Kr(n),r))})(e.zone,o,e.index,t)},kl=(e,n)=>{const t=pn(e.from);if(t===pn(n))return!0;const o=e.node;return yl({id:String(o.props?.id??""),zone:t,index:-1,type:o.type},n,o)},Sl=e=>{const n=e.slice(0,e.indexOf(":")),t=Xr.get(n),o=t?Kr(t.zone)[t.index]:void 0;if(!t||!o)return null;const r=Uo(o.type,Wo(ot?.data,o.type,n),e.slice(e.lastIndexOf(":")+1));if(!r||`${n}:${r.slot}`!==e)return null;if("footer"===r.source)return null;const i=r.choices??(r.spec?[{type:r.spec.childType,label:Dr(r.spec.childType)}]:[]),l=Zr(e);return{parent:o,parentId:n,target:r,choices:i,parentName:l?l.slot.label:Mi(o,t.zone===le)}},vl=(e,n)=>{const t=pn(n);if("block"!==e.kind){if(gl(t))return n.index>=0&&n.index<=Kr(t).length;if(t!==le)return!1;const{floor:e,cap:o}=Er();return n.index>=e&&n.index<=o}if(t===le)return!1;const o=Sl(t);return!(!o||!o.choices.some(n=>n.type===e.type))&&!o.target.spec?.addBlocked?.(Kr(t))},xl=(e,n)=>{e.rung?ri(e.rung.nodeId,e.index,n.index):e.add?((e,n)=>{if("block"!==e.kind&&gl(pn(n)))return void Pi(e,pn(n),n.index);if("section"===e.kind)return void Ci(e.type,n.index);if("template"===e.kind)return void Oi(e.template.name,Wr(e.template.node),n.index);const t=pn(n),o=Sl(t);o&&(o.target.spec?Zi(o.parentId,o.target.slot,e.type,n.index,o.parent.type):el(t,e.type,n.index))})(e.add,n):e.zone===le?zi(e.index,n.index):fl(e.zone,pn(n),e.index,n.index)},[wl]=Sn(()=>on()),bl=rn({keyOf:e=>e.id,readOnly:Boolean(Kn),session:wl,canDrop:yl,onDrop:xl,onStep:(e,n)=>{e.rung?ri(e.rung.nodeId,e.index,n<0?e.index-1:e.index+2):e.zone===le?((e,n)=>{const t=Jr(Lr[e]?.type??""),o=zi(e,n<0?e-1:e+2);if(!o.moved)return void gr(n<0?xt.sectionFirst({name:t}):xt.sectionLast({name:t}));const{floor:r,cap:i}=Er();gr(xt.sectionMoved({name:t,n:o.dest-r+1,total:i-r}))})(e.index,n):fl(e.zone,e.zone,e.index,n<0?e.index-1:e.index+2)}}),zl=xn(e=>{const{floor:n,cap:t}=Er(),o=[];for(const r of e.nodes){const e=pn(r.place),i=Kr(e)[r.place.index];if(!i||String(i.props.id)!==r.id)continue;if(yt(i)||kt(i)||Vo(i.type))continue;if(ft(i.type))continue;const l=Boolean(gl(e)),s=e===le||l;e===le&&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?Jr(i.type):si(i),from:r.place})}const r=e.zones.flatMap(e=>{const n=pn(e.list);return n===le&&0===e.children.length?[{...e,addLabel:xt.addSection,addAlways:!0}]:e.children.length>0||Boolean(Sl(n)?.choices.length)||Boolean(gl(n))?[e]:[]}),i=r.flatMap(e=>{const n=pn(e.list);return n===le||gl(n)||!Sl(n)?.choices.length?[]:Ze(e,xt.addBlockHere)});return{sources:o,zones:r,seams:i}},[ot.data]),Bl=null==lt?.props.id?null:String(lt.props.id),Cl=xn(e=>{const n=dt,t=e=>!e.item.rung&&null!==gn(ot.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(Bl);return i||(r(Te(ot.data,n,o.item.id,Bl))??o)},[ot.data,dt,Bl]),Ol=e=>{So(D),jt.select(e.zone===le?{index:e.index}:{index:e.index,zone:e.zone})},Il=ne(),Nl=()=>({data:ot.data,device:Dt,ops:jt,inspector:Ao}),$l=Il?.model,Pl=kn(()=>$l?e=>$l(e,zl(e),Nl()):zl,[$l,zl,Dt]),Ml=Il?.measure,Tl=Ml?(e,n)=>Ml(e,n,Nl()):void 0,Al=Il?.canDrop,jl=Al?(e,n)=>Al(e,n,yl,Nl()):yl,Rl=Il?.drop,Ll=Rl?(e,n)=>Rl(e,n,xl,Nl()):xl,El=Il?.pick,Vl=El?e=>El(e,Ol,Nl()):Ol,Fl=e=>{const n=pn(e),t=Zr(n);t&&ti(t.node,t.slot,!1),Ni(n,e.index)},Wl=(e,n,t,o)=>/* @__PURE__ */Tn(Ie,{...Kn?{}:bl.seam({place:{...hn(e),index:n}}),onAdd:Kn?void 0:t,label:o},`seam:${e}:${n}`),Hl={rowClick:Ti,isCollapsed:pr,toggleCollapse:ur},Ul=e=>{const n=String(e.props.id),t=Lr.findIndex(e=>String(e.props.id)===n),o=ht(n),r=Kr(o),i=pr(n),l=Dr(e.type),s=Go.rowName?Go.rowName(e,"section",l):l,d=e=>Wl(o,e,()=>Ni(o,e),xt.addSectionHere);/* @__PURE__ */
15
+ return An(jn,{children:[
16
+ /* @__PURE__ */Tn(be,{words:wt,icon:/* @__PURE__ */Tn(Yo,{type:e.type,size:13}),name:s,preview:Ri(e),marks:Li(e),onSelect:()=>wi(t),nameSlot:ci(le,t,n,s),selected:Bo===n,actions:Ei(e,le,t)??void 0,rowProps:{"data-node-id":n,onClick:Ti(()=>wi(t))},fold:{open:!i,label:"section",onToggle:()=>ur(n)}}),!i&&/* @__PURE__ */An(ze,{children:[r.map((n,t)=>{const r=String(n.props.id),i=Yr(n),l=Ki(n),s=l&&pr(r),c=()=>qi(o,t,r,e.type),{rowProps:a,...p}=bl.row({item:{id:r,zone:o,index:t,type:n.type},place:{...hn(o),index:t}},{"data-node-id":r,onClick:Ti(c)});/* @__PURE__ */
17
+ return An(bn,{children:[d(t),
18
+ /* @__PURE__ */Tn(be,{words:wt,icon:/* @__PURE__ */Tn(Yo,{type:n.type,size:13}),name:i,preview:Ri(n),marks:Li(n),onSelect:c,nameSlot:ci(o,t,r,i),selected:Bo===r,hidden:Boolean(n.props._hidden),...p,fold:l?{open:!s,label:"section",onToggle:()=>ur(r)}:void 0,actions:/* @__PURE__ */An(jn,{children:[ji(o,t,i),Ei(n,o,t),Vi(o,t,n,i)]}),rowProps:a}),l&&!s&&/* @__PURE__ */Tn(ze,{children:Jl(n,2)})]},r)}),d(r.length)]})]})},Dl=(e,n,t,o,r)=>{const i=String(e.props.id),l=`${i}:${n.slot}`,s=bl.dragging,d=!pr(l)&&s?.rung?.nodeId!==i,c={...hn(l),index:0},a=s&&!s.rung&&yl(s,c)?c:void 0,p=()=>ti(e,n,!0),{rowProps:u,...f}=bl.row({item:{id:`rung:${l}`,zone:`${i}:${Fn}`,index:t,type:e.type,rung:{nodeId:i,slot:n.slot}},place:{parentId:i,slot:Fn,index:t},into:a,canDrag:Boolean(Eo.moveSlot)&&!1!==n.movable&&o>1},{"data-slot-zone":l,onClick:Ti(p)}),h=Kn?null:Eo.slotActions?.(e,n.slot);/* @__PURE__ */
19
+ return An(bn,{children:[n.heading,
20
+ /* @__PURE__ */Tn(be,{words:wt,icon:n.glyph??null,name:n.label,badge:n.badge,onSelect:p,selected:ei===l,...f,dragHint:n.dragHint,fold:{open:d,label:n.label,onToggle:()=>ur(l)},actions:h&&h.length>0?/* @__PURE__ */Tn(jn,{children:h.map((t,o)=>/* @__PURE__ */Tn(Oe,{kind:"delete"===t.kind?"delete":"plain",label:t.label,disabled:t.disabled,onClick:()=>((e,n,t)=>{if(Kn||t.disabled)return;const o=String(e.props.id),r=e=>{"string"==typeof e&&oi(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__ */Tn(Nn,{size:15}):/* @__PURE__ */Tn(Mn,{size:15})},`${o}:${t.kind}`))}):void 0,rowProps:u}),d&&/* @__PURE__ */Tn(ze,{children:r})]},l)},Gl=(e,n)=>{const t=Di(e),o=t.filter(e=>e.rung).length;let r=0;/* @__PURE__ */
21
+ return Tn(jn,{children:t.map(t=>{const i=t.kids,l=t.rung?n+1:n,s=Yi(e.type,void 0,t.slot),d=s?`${e.props.id}:${s.slot}`:null,c=null===t.slot?null:`${e.props.id}:${t.slot}`,a=null!==c&&Boolean(Sl(c)?.choices.length),p=(e,n)=>a?Wl(e,n,()=>Ni(e,n),xt.addBlockHere):Wl(e,n),u=/* @__PURE__ */An(jn,{children:[i.map(({child:n,zone:t,index:o})=>{const r=Bo===String(n.props.id),{collapsible:i,folded:s}=Xi(n,l,_i(n.type)),d=String(n.props.id),c=ul(n),a=()=>qi(t,o,d,e.type),{rowProps:u,...f}=bl.row({item:{id:d,zone:t,index:o,type:n.type},place:{...hn(t),index:o}},{"data-node-id":d,onClick:Ti(a)});/* @__PURE__ */
22
+ return An(bn,{children:[0===o&&p(t,0),
23
+ /* @__PURE__ */Tn(be,{words:wt,icon:/* @__PURE__ */Tn(Yo,{type:n.type,size:13}),name:c,preview:Ri(n),marks:Li(n),onSelect:a,nameSlot:ci(t,o,d,c),selected:r,hidden:Boolean(n.props._hidden),...f,fold:i?{open:!s,label:"group",onToggle:()=>ur(d)}:void 0,actions:/* @__PURE__ */An(jn,{children:[ji(t,o,c),Ei(n,t,o),Vi(t,o,n,c)]}),rowProps:u}),i&&!s&&/* @__PURE__ */Tn(ze,{children:Gl(n,l+1)}),p(t,o+1)]},String(n.props.id??`${t}-${o}`))}),null===c?d&&!i.some(e=>e.zone===d)?p(d,0):null:0!==i.length||!t.rung&&d!==c?null:p(c,0)]});return t.rung?Dl(e,t.rung,r++,o,u):/* @__PURE__ */Tn(bn,{children:u},t.slot??"")})})},Jl=(e,n)=>{const t=Wo(ot?.data,e.type,String(e.props.id)),o=Di(e),r=o.filter(e=>e.rung).length;let i=0;/* @__PURE__ */
24
+ return Tn(jn,{children:o.map(o=>{const l=o.kids,s=o.rung?n+1:n,d=Yi(e.type,t,o.slot),c=d?.spec??null,a=c&&Array.isArray(e.props[c.slot])?e.props[c.slot]:[],p=d&&d.choices?{slot:d.slot,choices:d.choices}:null,u=String(e.props.id),f=c&&!c.fixed?`${u}:${c.slot}`:null,h=p?`${u}:${p.slot}`:null,m=(n,t)=>{const o=n===f&&c&&!c.addBlocked?.(a)?()=>Zi(e.props.id,c.slot,c.childType,t,e.type):n===h?()=>Ni(n,t):void 0;return Wl(n,t,o,n===f&&c?c.addLabel:xt.addBlockHere)},g=null===o.slot?null:`${u}:${o.slot}`,y=Boolean(c&&!c.fixed&&(null===g||g===f)),k=/* @__PURE__ */An(jn,{children:[l.map(({child:n,zone:t,index:o})=>{const r=Bo===String(n.props.id),i=si(n),l=String(n.props.id),{collapsible:d,folded:c}=Xi(n,s,_i(n.type)),a=Hi(n.type),p=1===a.length?`${l}:${a[0]}`:null,u=p?{...hn(p),index:Kr(p).length}:void 0,f=bl.dragging,h=u&&f&&yl(f,u)?u:void 0,g=()=>qi(t,o,l,e.type),{rowProps:y,...k}=bl.row({item:{id:l,zone:t,index:o,type:n.type},place:{...hn(t),index:o},into:h,canDrag:!Vo(n.type)},{"data-node-id":l,onClick:Ti(g)});/* @__PURE__ */
25
+ return An(bn,{children:[0===o&&m(t,0),
26
+ /* @__PURE__ */Tn(be,{words:wt,icon:/* @__PURE__ */Tn(Yo,{type:n.type,size:13}),name:i,preview:Ri(n),marks:Li(n),onSelect:g,nameSlot:ci(t,o,l,i),selected:r,hidden:Boolean(n.props._hidden),...k,fold:d?{open:!c,label:"group",onToggle:()=>ur(l)}:void 0,actions:Vo(n.type)?Ei(n,t,o)??void 0:/* @__PURE__ */An(jn,{children:[ji(t,o,i),Ei(n,t,o),Vi(t,o,n,i)]}),rowProps:y}),d&&!c&&/* @__PURE__ */Tn(ze,{children:Jl(n,s+1)}),m(t,o+1)]},String(n.props.id??`${t}-${o}`))}),y&&c&&
27
+ /* @__PURE__ */Tn(N,{small:!0,label:c.addLabel,blocked:c.addBlocked?.(a)??null,onAdd:()=>Zi(e.props.id,c.slot,c.childType,a.length,e.type)}),null===g?h&&!l.some(e=>e.zone===h)?m(h,0):null:0!==l.length||(o.rung?y:g!==h)?null:m(g,0)]});return o.rung?Dl(e,o.rung,i++,r,k):/* @__PURE__ */Tn(bn,{children:k},o.slot??"")})})},Yl=(()=>{if(!lt||!vo)return null;const e=String(lt.type),n=String(lt.props.id),t=Uo(e,Wo(ot?.data,e,n));if(!t||"footer"===t.source)return null;const o=Lr.some(e=>String(e.props?.id)===n),r=Array.isArray(lt.props[t.slot])?lt.props[t.slot]:[];if(t.spec?.addBlocked?.(r))return null;const i=t.choices??(t.spec?[{type:t.spec.childType,label:Dr(t.spec.childType)}]:[]);return 0===i.length?null:{parentName:Mi(lt,o),choices:i,onPick:o=>{t.spec?Zi(n,t.slot,o,r.length,e):el(`${n}:${t.slot}`,o,r.length)}}})(),Xl=bo&&bo.zone!==le&&!gl(bo.zone)?bo.zone:null,Ql=!0===ho.blocksFirst,Kl=Xl?Sl(Xl):Ql&&bo?null:Yl,_l=Boolean(uo&&Xl)||Ql&&Boolean(Kl&&Kl.choices.length>0),ql=so||null!==Xt,Zl=e=>"panel"in e?{id:e.id,label:e.label,icon:e.icon,active:Lt&&!ql&&Lo===e.id,onSelect:()=>Tr(e.id)}:e,es=[{id:"add",label:xt.add.title,icon:/* @__PURE__ */Tn("span",{className:"sf-rail-plus","aria-hidden":"true",children:"+"}),active:so,onSelect:()=>so?$i():Ii(null)},...(jo.railLead??[]).map(Zl),{id:"sections",label:xt.layers,icon:/* @__PURE__ */Tn(Ae,{}),active:Lt&&!ql&&"sections"===Lo,onSelect:()=>Tr("sections")},...(jo.railTrail??[]).map(Zl)];Yt?es.push({id:"media",label:xt.railMedia,icon:/* @__PURE__ */Tn(je,{}),active:Lt&&!so&&(null!==Xt||"media"===Lo),onSelect:()=>Tr("media")}):et&&es.push({id:"media",label:xt.railMedia,icon:/* @__PURE__ */Tn(je,{}),onSelect:Ar});const ns=[...jo.railLead??[],...jo.railTrail??[]].find(e=>"panel"in e&&e.id===Lo),ts=Boolean(vt?.foldable)&&!Ro,os=vt?.label??(nt?xt.pageSections:xt.templateSections),rs=ts&&pr(Wn),is=/* @__PURE__ */An(jn,{children:[Lr.map((e,n)=>{if(yt(e)||kt(e)||ft(e.type))return null;const t=Bo===String(e.props.id),o=Boolean(e.props._hidden);Ui(e);const r=String(e.props.id),i=jo.hasOwnRows?.(e)??!1,l=Ki(e)||i,s=l&&pr(r),d=Hi(e.type),c=1===d.length?`${r}:${d[0]}`:null,a=c?{...hn(c),index:Kr(c).length}:void 0,p=bl.dragging,u=a&&p&&yl(p,a)?a:void 0,{rowProps:f,...h}=bl.row({item:{id:r,zone:le,index:n,type:e.type},place:{...hn(le),index:n},into:u},{"data-node-id":r,onClick:Ti(()=>wi(n))});/* @__PURE__ */
28
+ return An(bn,{children:[n>0&&Fi(n),
29
+ /* @__PURE__ */Tn(be,{words:wt,icon:/* @__PURE__ */Tn(Yo,{type:e.type,size:13}),name:Yr(e),preview:Ri(e),marks:Li(e),onSelect:()=>wi(n),nameSlot:ci(le,n,r,Yr(e)),selected:t,hidden:o,...h,fold:l?{open:!s,label:"section",onToggle:()=>ur(r)}:void 0,actions:/* @__PURE__ */An(jn,{children:[ji(le,n,Yr(e)),Ei(e,le,n),Vi(le,n,e,Yr(e))]}),rowProps:f}),Ki(e)&&!s&&/* @__PURE__ */An(ze,{children:[Jl(e,1),jo.partRows?.(e,Hl)]}),i&&!s&&/* @__PURE__ */Tn(ze,{children:jo.ownRows?.(e,n,Hl)})]},String(e.props.id??n))}),!Ro&&cl>0&&Fi(cl),vt?.addAtEnd&&!Ro&&!Kn&&/* @__PURE__ */Tn(N,{small:!0,label:xt.addSection,blocked:null,onAdd:()=>Ii(cl)})]}),ls=(e,n,t)=>{const o=String(e.props.id),r=Gi(e).length>0||Ji(e)||Boolean(Uo(e.type)),i=r&&pr(o),l="header"===t?xt.header:xt.footer,s=Go.rowName?Go.rowName(e,"section",l):l;/* @__PURE__ */
30
+ return An(jn,{children:[
31
+ /* @__PURE__ */Tn(be,{words:wt,icon:/* @__PURE__ */Tn(Yo,{type:t,size:13}),name:s,preview:Ri(e),marks:Li(e),onSelect:()=>wi(n),nameSlot:ci(le,n,o,s),selected:Bo===String(e.props.id),fold:r?{open:!i,label:"section",onToggle:()=>ur(o)}:void 0,actions:Ei(e,le,n)??void 0,rowProps:{"data-node-id":o,onClick:Ti(()=>wi(n))}}),r&&!i&&/* @__PURE__ */Tn(ze,{children:Gl(e,1)})]})};return(jo.wrap??(e=>e))(
32
+ /* @__PURE__ */Tn(te,{target:io,children:/* @__PURE__ */An("div",{ref:ro,className:"sf-editor es-editor",style:Xe(lr),onContextMenu:mi.onEditorContextMenu,...m(Le),children:[
33
+ /* @__PURE__ */An(Ee,{children:[
34
+ /* @__PURE__ */Tn(Ve,{items:es,ariaLabel:xt.bar.views}),
35
+ /* @__PURE__ */An(Fe,{children:[
36
+ /* @__PURE__ */Tn(We,{label:xt.bar.undo,disabled:Boolean(Kn)||!it.hasPast,onClick:()=>it.back(),children:/* @__PURE__ */Tn(On,{})}),
37
+ /* @__PURE__ */Tn(We,{label:xt.bar.redo,disabled:Boolean(Kn)||!it.hasFuture,onClick:()=>it.forward(),children:/* @__PURE__ */Tn(In,{})}),
38
+ /* @__PURE__ */Tn(He,{}),
39
+ /* @__PURE__ */Tn(Ue,{devices:Vt,value:Dt,onChange:Gt})]}),
40
+ /* @__PURE__ */An(Fe,{kind:"right",style:{minWidth:300},children:[
41
+ /* @__PURE__ */Tn(Rn,{saveState:Jn,notSaving:Boolean(Kn)||null!=Yn,readOnlyReason:_n,toggle:qn,onToggle:Qn,onRetry:Xn,words:xt.bar,saveWords:zt}),jo.barLead?.(),
42
+ /* @__PURE__ */Tn(zn,{content:xt.bar.refreshTip,side:"bottom",children:/* @__PURE__ */Tn(Bn,{variant:"secondary",onClick:()=>{oo.current=(()=>{const e=io?.document;if(!e)return null;const n=Lr.findIndex(kt),t=n>=0?n:Lr.length;let o=null;for(let n=0;n<t;n++){const t=Lr[n]?.props?.id;if(null==t)continue;const r=e.querySelector(`[data-puck-component="${CSS.escape(String(t))}"]`);if(!r)continue;const i=r.getBoundingClientRect().top;i<=4&&(null===o||i>o.offset)&&(o={id:String(t),offset:i})}if(!o){const e=lt?.props?.id??Lr[0]?.props?.id;null!=e&&(o={id:String(e),offset:0})}return o})(),to(e=>e+1)},children:xt.bar.refresh})}),jo.barTrail?.(),jo.barMain?jo.barMain():/* @__PURE__ */Tn(Bn,{variant:"primary",disabled:null!==_n,onClick:()=>{Gn(ot.data)},children:xt.done})]})]}),
43
+ /* @__PURE__ */Tn(z,{}),
44
+ /* @__PURE__ */An("div",{className:"sf-body",children:[Lt?/* @__PURE__ */An(jn,{children:[
45
+ /* @__PURE__ */Tn("aside",{className:"es-sidepanel es-sidepanel--left sf-panel sf-panel--left","aria-label":xt.leftPanel,children:so?/* @__PURE__ */Tn($,{blocks:Kl,blocksOnly:_l,at:uo?{label:(e=>{const n=gl(e.zone);if(n)return xt.add.addingTo({name:Go.rowName?Mi(n,!0):Dr(n.type)});if(e.zone===le){const n=Lr[e.index];return n&&!kt(n)?xt.add.addingBefore({name:Mi(n,!0)}):xt.add.addingAtEnd}const t=Sl(e.zone);return t?xt.add.addingTo({name:t.parentName}):xt.add.addingHere})(uo),onClear:()=>fo(null)}:void 0,onAdd:e=>{const n=bo,t=(e,n)=>{uo&&fo({zone:e,index:n})};if(n&&"block"!==e.kind&&gl(n.zone))return Pi(e,n.zone,n.index),void t(n.zone,n.index+1);if("section"===e.kind)return(e=>{if(null===zo)return void Ci(e);const n=Ci(e,zo);uo&&mo(n+1)})(e.type);if("template"===e.kind)return((e,n)=>{if(null===zo)return void Oi(e,n);const t=Oi(e,n,zo);uo&&mo(t+1)})(e.template.name,Wr(e.template.node));if(n&&n.zone!==le){const o=Sl(n.zone);if(!o)return;return o.target.spec?Zi(o.parentId,o.target.slot,e.type,n.index,o.parent.type):el(n.zone,e.type,n.index),void t(n.zone,n.index+1)}Yl?.onPick(e.type)},itemFor:e=>({id:`new:${e.kind}:${"template"===e.kind?e.template.id:e.type}`,zone:"",index:-1,type:"template"===e.kind?e.template.node.type:e.type,add:e}),session:wl,siteWide:jo.addPanelRow?.($i),onClose:$i,onHide:Pr,readOnly:Boolean(Kn)}):Xt&&Jt?
46
+ /* @__PURE__ */Tn(T,{panel:Jt,pick:Xt,onHide:Pr}):ns?ns.panel({onHide:Pr,notify:gr}):"media"===Lo&&Jt?/* @__PURE__ */Tn(T,{panel:Jt,pick:null,onHide:Pr}):/* @__PURE__ */An(jn,{children:[
47
+ /* @__PURE__ */Tn(P,{icon:/* @__PURE__ */Tn(Ae,{}),title:xt.layers,context:It,actions:
48
+ /* @__PURE__ */Tn(De,{label:pl?xt.expandAll:xt.collapseAll,title:0===al.length?xt.nothingToFold:void 0,disabled:0===al.length,onClick:()=>ir(e=>{const n=new Set(al);return pl?new Set([...e].filter(e=>!n.has(e))):/* @__PURE__ */new Set([...e,...al])}),children:/* @__PURE__ */Tn(Ln,{expand:pl})}),onHide:Pr}),
49
+ /* @__PURE__ */An(Be,{className:"sf-tree sf-scroll",words:wt,children:[
50
+ /* @__PURE__ */Tn(be,{words:wt,icon:/* @__PURE__ */Tn(Yo,{type:"page",size:13}),name:xt.pageSettings,onSelect:jr,selected:!lt&&vo,rowProps:{onClick:Ti(jr)}}),sl&&/* @__PURE__ */An(jn,{children:[
51
+ /* @__PURE__ */Tn(Ce,{children:xt.header}),Ul(sl)]}),!Ro&&tt&&/* @__PURE__ */An(jn,{children:[
52
+ /* @__PURE__ */Tn(Ce,{children:xt.header}),!St&&/* @__PURE__ */Tn(be,{words:wt,icon:/* @__PURE__ */Tn(Yo,{type:"header",size:13}),name:xt.header,onSelect:Rr,selected:ko.kind===gt?.kind,rowProps:{onClick:Ti(Rr)}})]}),!Ro&&ll&&ls(ll,il,"header"),!Ro&&!ts&&/* @__PURE__ */Tn(Ce,{children:os}),ts?/* @__PURE__ */An(jn,{children:[
53
+ /* @__PURE__ */Tn(be,{words:wt,icon:null,name:os,fold:{open:!rs,label:os,onToggle:()=>ur(Wn)}}),!rs&&/* @__PURE__ */Tn(ze,{children:is})]}):is,tt&&/* @__PURE__ */Tn(Ce,{children:xt.footer}),rl&&ls(rl,ol,"footer"),!Ro&&!rl&&tt&&/* @__PURE__ */Tn(be,{words:wt,icon:/* @__PURE__ */Tn(Yo,{type:"footer",size:13}),name:xt.footer,onSelect:Ai,rowProps:{onClick:Ti(Ai),title:xt.editFooter}}),dl&&Ul(dl),jo.treeFoot?.()]})]})}),
54
+ /* @__PURE__ */Tn(Ge,{side:"left",width:lr.left,min:Ye,max:Je,defaultWidth:k.left,label:xt.resizeLeftPanel,onResize:cr})]}):/* @__PURE__ */Tn(M,{side:"left",onShow:Pr}),
55
+ /* @__PURE__ */An("div",{ref:yr,className:"sf-center sf-scroll","data-sf-canvas-head":wr?"":void 0,style:{overflowX:Ir?"auto":"hidden",overflowY:"hidden"},children:[wr&&/* @__PURE__ */Tn("div",{ref:br,className:"sf-canvas-head",children:/* @__PURE__ */Tn(wr,{device:Dt})}),
56
+ /* @__PURE__ */Tn("div",{className:"sf-frame-scaler",style:Nr,children:/* @__PURE__ */Tn("div",{className:"sf-frame "+(Dt===Ht?"":`sf-frame--${Dt}`),style:$r,children:/* @__PURE__ */An("div",{className:"sf-preview-host",children:[
57
+ /* @__PURE__ */Tn(Nt,{},no),
58
+ /* @__PURE__ */Tn(en,{canvas:io,session:wl,model:Pl,measure:Tl,canDrop:jl,onDrop:Ll,choose:Cl,onPick:Vl,onZoneAdd:Fl,onSeamAdd:Fl,zoneAddLabel:xt.canvasAddBlock,words:bt.canvas,readOnly:Boolean(Kn),revision:ot.data}),go.length>0&&/* @__PURE__ */Tn("div",{className:"sf-preview-gaps",children:go.map(e=>
59
+ /* @__PURE__ */Tn(nn,{index:e.index,label:xt.addSectionHere,onInsert:()=>Ii(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))})]})})})]}),Et?/* @__PURE__ */An(jn,{children:[
60
+ /* @__PURE__ */Tn(g,{value:{selectChild:qi,addChild:Zi,childRowName:si,blockRowName:ul},children:/* @__PURE__ */Tn($t,{mode:ko,onOpenWebsiteSettings:jo.openSettings??(()=>{}),onOpenSiteStyles:jo.openStyles,onSelectNode:_o,onNotify:gr,onHidePanel:Mr,nodeActions:lt?se(dt,lt.type):Hn})}),
61
+ /* @__PURE__ */Tn(Ge,{side:"right",width:lr.right,min:Ye,max:Je,defaultWidth:k.right,label:xt.resizeSettingsPanel,onResize:ar})]}):
62
+ /* @__PURE__ */Tn(M,{side:"right",onShow:Mr})]}),mi.menu]})}))}export{Un as ScreenChrome};
@@ -1 +1 @@
1
- import{useEaselSession as e}from"./chunk-O7Q4DDJT.js";import{ROOT_ZONE as n}from"./chunk-PLVEGYK6.js";import{useHostEscape as t}from"./chunk-U3JP4VGF.js";import{DEFAULT_SCREEN_WORDS as o}from"./chunk-MCHMF32I.js";import{styleMenuItems as l}from"./chunk-V7U33NF2.js";import{EaselMenuItems as r,menuLabel as i}from"./chunk-EA2HTX37.js";import{createNodeClipboard as c,nodeMenuItems as s}from"./chunk-OSPUG6S6.js";import{DEFAULT_NODE_MENU_WORDS as a}from"./chunk-WK3AFPXY.js";import{isTypingTarget as u,useCanvasEvent as d,framePointToHost as p}from"./chunk-AWJUYMX7.js";import{zoneKey as f,ROOT_SLOT as m,ROOT_ID as h}from"./chunk-KRXQM65X.js";import{useState as y,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,AddIcon as C,PasteIcon as z,SettingsIcon as P,LayersIcon as A,CopyIcon as O}from"efficient-shell/icons/efficient";import{jsx as M}from"react/jsx-runtime";function S(e,t){const o=[],l=/* @__PURE__ */new Set;let r={zone:t.zone,index:t.index};for(;r;){const t=e.nodeAt(r.zone,r.index);if(!t||l.has(t.props.id))break;if(l.add(t.props.id),o.push({zone:r.zone,index:r.index,node:t,parentType:null}),r.zone===n)break;const i=r.zone.lastIndexOf(":");if(i<=0)break;r=e.locate(r.zone.slice(0,i))}for(let e=0;e<o.length-1;e+=1)o[e].parentType=o[e+1].node.type;return o}var K=c(),j=/* @__PURE__ */new WeakMap;function D(e){if(e.claimsPage)return K;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 T(){return D(e())}function X(e,t,o){if(t===n){const{floor:n,cap:t}=e.sectionBand();return{parentId:h,slot:m,index:Math.min(Math.max(o,n),t)}}const l=t.lastIndexOf(":");return{parentId:t.slice(0,l),slot:t.slice(l+1),index:o}}function I(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}}function E(e,n,t){const o=e.canPasteAt;if(!o)return f(n.from)===t.zone?X(e,t.zone,t.index+1):null;for(const l of S(e,t)){const t=X(e,l.zone,l.index+1);if(o(n,t))return t}return null}function L(e){if(e.defaultPrevented||e.altKey||e.shiftKey||!e.metaKey&&!e.ctrlKey)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;const l=e.code||(1===e.key.length?`Key${e.key.toUpperCase()}`:"");return"KeyC"===l?"copy":"KeyX"===l?"cut":"KeyV"===l?"paste":null}function R(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=I(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;const s=o.held;if(!s)return null;const a=e.isPinned(l,t.zone)?null:E(e,s,t);return a?(e.nodeOps.paste(a),{done:"pasted",name:s.label}):(e.onPasteRefused(s),{done:"refused",name:s.label})}function U(e,t){const{zone:o,index:r}=t,i=e.nodeAt(o,r);if(!i)return[];const c=i.props.id,a=e.labelOf(i.type,o),u=Boolean(i.props._hidden),d=e.nodeOps,p=e.isPinned(i,o),f=e.isLocked(i),m=!p&&!f&&!e.duplicateBlocked(i),h=e.permits?.(i)??{duplicate:!0,delete:!0},y=I(e,i,o),k=S(e,t),b=d.held,v=b&&!p?E(e,b,t):null,g=!e.readOnly,w=e.style?l({held:g?e.style.held():null,canCopy:e.style.canCopy(i,o),onCopy:()=>e.style?.copy(i,o),onPaste:()=>e.style?.paste(o,r,i),words:e.words?.styleClipboard}):[];return s({title:a,words:e.words?.menu,layer:{group:"pick",items:k.flatMap((t,o)=>{const l={label:e.rowNameOf(t.node,t.zone),checked:0===o,onClick:()=>e.selectAt(t.zone,t.index,t.node.props.id,t.parentType)},r=t.zone===n?null:e.slotRung?.(t.zone)??null;return r?[l,{label:r.label,checked:!1,onClick:r.select}]:[l]})},actions:{addInside:g&&e.canAddTo(i.type)?()=>e.openAddInside(o,r):void 0,duplicate:g&&m&&h.duplicate?()=>d.duplicate(c):void 0,moveUp:g&&d.canStep(c,-1)?()=>d.step(c,-1):void 0,moveDown:g&&d.canStep(c,1)?()=>d.step(c,1):void 0,copy:y.copy?()=>d.copy(c,a):void 0,cut:g&&y.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,o)?()=>e.beginRename(o,r):void 0,hide:!g||f||p?void 0:{hidden:u,run:()=>d.setProps(c,{_hidden:!u})},delete:g&&m&&h.delete?()=>d.remove(c):void 0},style:w,extras:e.menuRows?.(i,o,r)??void 0,pinnedLine:p?Y(e).pinned:void 0})}var Y=e=>e.words?.screen??o.menu;function V(e){const t=Y(e),l=!e.readOnly,r=[];l&&e.history.hasPast&&r.push({label:t.undo,icon:/* @__PURE__ */M(w,{}),shortcut:"⌘Z",onClick:e.history.back}),l&&e.history.hasFuture&&r.push({label:t.redo,icon:/* @__PURE__ */M(x,{}),shortcut:"⇧⌘Z",onClick:e.history.forward});const i=l?[{label:t.addSection,icon:/* @__PURE__ */M(C,{}),onClick:e.openAddSection}]:[],c=e.nodeOps.held,s=X(e,n,e.sectionBand().cap);if(l&&c&&(e.canPasteAt?e.canPasteAt(c,s):f(c.from)===n)){const n=s,t=e.words?.menu??a;i.push({label:t.pasteNamed({paste:t.paste,label:c.label}),icon:/* @__PURE__ */M(z,{}),shortcut:"⌘V",onClick:()=>e.nodeOps.paste(n)})}const u=[r,i,[{label:e.pageSettingsLabel??o.pageSettings,icon:/* @__PURE__ */M(P,{}),onClick:e.openPageSettings},{label:t.collapseAll,icon:/* @__PURE__ */M(A,{}),onClick:e.collapseAll}]].filter(e=>e.length>0),d={label:"—",onClick:()=>{}};return u.flatMap((e,n)=>n?[d,...e]:e)}function B(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=Y(e),s=[];l&&(s.push({label:i.copy,icon:/* @__PURE__ */M(O,{}),shortcut:"⌘C",onClick:()=>navigator.clipboard?.writeText(l)}),s.push({label:i.cut,icon:/* @__PURE__ */M(O,{}),shortcut:"⌘X",onClick:()=>{navigator.clipboard?.writeText(l),r("")}})),s.push({label:i.paste,icon:/* @__PURE__ */M(z,{}),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 F(e){return e.shiftKey}function N(e,n){const[o,l]=y(null),r=k(()=>l(null),[]);t(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=L(e);if(!o)return;const l=t.selected();if(!l)return;const r=R(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(n,"keydown",c);const a=k(n=>{if(F(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(n,"contextmenu",t=>{if(F(t)||!n)return;const o=t.target?.closest?.("[data-puck-component]")??null,r=o?.getAttribute("data-puck-component"),i=r?e.locate(r):null;t.preventDefault();const c=p(n.frame,t.clientX,t.clientY),s=n.frame;l(i?{kind:"node",...c,...i,owner:s}:{kind:"empty",...c,owner:s})}),d(n,"mousedown",r),d(n,"scroll",r,{on:"window"});return{onEditorContextMenu:a,menu:o?/* @__PURE__ */M(G,{host:e,target:o,onClose:r}):null,closeMenu:r}}function G({host:e,target:n,onClose:t}){const o="node"===n.kind?U(e,n):"input"===n.kind?B(e,n.el):V(e);return 0===o.length?null:/* @__PURE__ */M(g,{at:{x:n.x,y:n.y},owner:n.owner??null,onClose:t,"aria-label":i(o),children:/* @__PURE__ */M(r,{items:o,onClose:t})})}export{K as EASEL_NODE_CLIPBOARD,S as ancestorChain,D as nodeClipboardOf,I as nodeClipboardRules,U as nodeMenuItems,L as nodeShortcut,V as pageMenuItems,E as pastePlace,R as runNodeShortcut,B as textMenuItems,T as useNodeClipboard,N as useNodeContextMenu};
1
+ import{styleMenuItems as e}from"./chunk-V7U33NF2.js";import{useEaselSession as n}from"./chunk-O7Q4DDJT.js";import{ROOT_ZONE as t}from"./chunk-PLVEGYK6.js";import{useHostEscape as o}from"./chunk-U3JP4VGF.js";import{DEFAULT_SCREEN_WORDS as l}from"./chunk-MCHMF32I.js";import{EaselMenuItems as r,menuLabel as i}from"./chunk-EA2HTX37.js";import{createNodeClipboard as c,nodeMenuItems as s}from"./chunk-OSPUG6S6.js";import{DEFAULT_NODE_MENU_WORDS as a}from"./chunk-WK3AFPXY.js";import{isTypingTarget as u,useCanvasEvent as d,framePointToHost as p}from"./chunk-AWJUYMX7.js";import{zoneKey as f,ROOT_SLOT as m,ROOT_ID as h}from"./chunk-KRXQM65X.js";import{useState as y,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,AddIcon as C,PasteIcon as z,SettingsIcon as P,LayersIcon as A,CopyIcon as O}from"efficient-shell/icons/efficient";import{jsx as M}from"react/jsx-runtime";function S(e,n){const o=[],l=/* @__PURE__ */new Set;let r={zone:n.zone,index:n.index};for(;r;){const n=e.nodeAt(r.zone,r.index);if(!n||l.has(n.props.id))break;if(l.add(n.props.id),o.push({zone:r.zone,index:r.index,node:n,parentType:null}),r.zone===t)break;const i=r.zone.lastIndexOf(":");if(i<=0)break;r=e.locate(r.zone.slice(0,i))}for(let e=0;e<o.length-1;e+=1)o[e].parentType=o[e+1].node.type;return o}var K=c(),j=/* @__PURE__ */new WeakMap;function D(e){if(e.claimsPage)return K;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 T(){return D(n())}function X(e,n,o){if(n===t){const{floor:n,cap:t}=e.sectionBand();return{parentId:h,slot:m,index:Math.min(Math.max(o,n),t)}}const l=n.lastIndexOf(":");return{parentId:n.slice(0,l),slot:n.slice(l+1),index:o}}function I(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}}function E(e,n,t){const o=e.canPasteAt;if(!o)return f(n.from)===t.zone?X(e,t.zone,t.index+1):null;for(const l of S(e,t)){const t=X(e,l.zone,l.index+1);if(o(n,t))return t}return null}function L(e){if(e.defaultPrevented||e.altKey||e.shiftKey||!e.metaKey&&!e.ctrlKey)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;const l=e.code||(1===e.key.length?`Key${e.key.toUpperCase()}`:"");return"KeyC"===l?"copy":"KeyX"===l?"cut":"KeyV"===l?"paste":null}function R(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=I(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;const s=o.held;if(!s)return null;const a=e.isPinned(l,t.zone)?null:E(e,s,t);return a?(e.nodeOps.paste(a),{done:"pasted",name:s.label}):(e.onPasteRefused(s),{done:"refused",name:s.label})}function U(n,o){const{zone:l,index:r}=o,i=n.nodeAt(l,r);if(!i)return[];const c=i.props.id,a=n.labelOf(i.type,l),u=Boolean(i.props._hidden),d=n.nodeOps,p=n.isPinned(i,l),f=n.isLocked(i),m=!p&&!f&&!n.duplicateBlocked(i),h=n.permits?.(i)??{duplicate:!0,delete:!0},y=I(n,i,l),k=S(n,o),b=d.held,v=b&&!p?E(n,b,o):null,g=!n.readOnly,w=n.style?e({held:g?n.style.held():null,canCopy:n.style.canCopy(i,l),onCopy:()=>n.style?.copy(i,l),onPaste:()=>n.style?.paste(l,r,i),words:n.words?.styleClipboard}):[];return s({title:a,words:n.words?.menu,layer:{group:"pick",items:k.flatMap((e,o)=>{const l={label:n.rowNameOf(e.node,e.zone),checked:0===o,onClick:()=>n.selectAt(e.zone,e.index,e.node.props.id,e.parentType)},r=e.zone===t?null:n.slotRung?.(e.zone)??null;return r?[l,{label:r.label,checked:!1,onClick:r.select}]:[l]})},actions:{addInside:g&&n.canAddTo(i.type)?()=>n.openAddInside(l,r):void 0,duplicate:g&&m&&h.duplicate?()=>d.duplicate(c):void 0,moveUp:g&&d.canStep(c,-1)?()=>d.step(c,-1):void 0,moveDown:g&&d.canStep(c,1)?()=>d.step(c,1):void 0,copy:y.copy?()=>d.copy(c,a):void 0,cut:g&&y.cut?()=>d.cut(c,a):void 0,paste:g&&b&&v?{label:b.label,run:()=>d.paste(v)}:void 0,rename:g&&n.renamePropOf(i,l)?()=>n.beginRename(l,r):void 0,hide:!g||f||p?void 0:{hidden:u,run:()=>d.setProps(c,{_hidden:!u})},delete:g&&m&&h.delete?()=>d.remove(c):void 0},style:w,extras:n.menuRows?.(i,l,r)??void 0,pinnedLine:p?Y(n).pinned:void 0})}var Y=e=>e.words?.screen??l.menu;function V(e){const n=Y(e),o=!e.readOnly,r=[];o&&e.history.hasPast&&r.push({label:n.undo,icon:/* @__PURE__ */M(w,{}),shortcut:"⌘Z",onClick:e.history.back}),o&&e.history.hasFuture&&r.push({label:n.redo,icon:/* @__PURE__ */M(x,{}),shortcut:"⇧⌘Z",onClick:e.history.forward});const i=o?[{label:n.addSection,icon:/* @__PURE__ */M(C,{}),onClick:e.openAddSection}]:[],c=e.nodeOps.held,s=X(e,t,e.sectionBand().cap);if(o&&c&&(e.canPasteAt?e.canPasteAt(c,s):f(c.from)===t)){const n=s,t=e.words?.menu??a;i.push({label:t.pasteNamed({paste:t.paste,label:c.label}),icon:/* @__PURE__ */M(z,{}),shortcut:"⌘V",onClick:()=>e.nodeOps.paste(n)})}const u=[r,i,[{label:e.pageSettingsLabel??l.pageSettings,icon:/* @__PURE__ */M(P,{}),onClick:e.openPageSettings},{label:n.collapseAll,icon:/* @__PURE__ */M(A,{}),onClick:e.collapseAll}]].filter(e=>e.length>0),d={label:"—",onClick:()=>{}};return u.flatMap((e,n)=>n?[d,...e]:e)}function B(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=Y(e),s=[];l&&(s.push({label:i.copy,icon:/* @__PURE__ */M(O,{}),shortcut:"⌘C",onClick:()=>navigator.clipboard?.writeText(l)}),s.push({label:i.cut,icon:/* @__PURE__ */M(O,{}),shortcut:"⌘X",onClick:()=>{navigator.clipboard?.writeText(l),r("")}})),s.push({label:i.paste,icon:/* @__PURE__ */M(z,{}),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 F(e){return e.shiftKey}function N(e,n){const[t,l]=y(null),r=k(()=>l(null),[]);o(null!==t,r);const i=b(e);i.current=e;const c=k(e=>{const n=i.current,t=n.keys;if(!t)return;const o=L(e);if(!o)return;const l=t.selected();if(!l)return;const r=R(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(n,"keydown",c);const a=k(n=>{if(F(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(n,"contextmenu",t=>{if(F(t)||!n)return;const o=t.target?.closest?.("[data-puck-component]")??null,r=o?.getAttribute("data-puck-component"),i=r?e.locate(r):null;t.preventDefault();const c=p(n.frame,t.clientX,t.clientY),s=n.frame;l(i?{kind:"node",...c,...i,owner:s}:{kind:"empty",...c,owner:s})}),d(n,"mousedown",r),d(n,"scroll",r,{on:"window"});return{onEditorContextMenu:a,menu:t?/* @__PURE__ */M(G,{host:e,target:t,onClose:r}):null,closeMenu:r}}function G({host:e,target:n,onClose:t}){const o="node"===n.kind?U(e,n):"input"===n.kind?B(e,n.el):V(e);return 0===o.length?null:/* @__PURE__ */M(g,{at:{x:n.x,y:n.y},owner:n.owner??null,onClose:t,"aria-label":i(o),children:/* @__PURE__ */M(r,{items:o,onClose:t})})}export{K as EASEL_NODE_CLIPBOARD,S as ancestorChain,D as nodeClipboardOf,I as nodeClipboardRules,U as nodeMenuItems,L as nodeShortcut,V as pageMenuItems,E as pastePlace,R as runNodeShortcut,B as textMenuItems,T as useNodeClipboard,N as useNodeContextMenu};
@@ -0,0 +1,11 @@
1
+ import{DEFAULT_CANVAS_WORDS as e}from"./chunk-TBY3DFKS.js";import{useResolvedFields as t}from"./chunk-YRLPFZW3.js";import{toItemSelector as n,fromItemSelector as o,useNodeOps as r,parentStep as i,clickPick as a}from"./chunk-UK2FQOUT.js";import{startCanvasTyping as s,textMap as l}from"./chunk-CIHKZMNR.js";import{useWords as c}from"./chunk-MFIRYGHW.js";import{setCanvasNonce as d,isTypingTarget as u,frameRectToHost as p,CANVAS_TYPING_EVENT as f}from"./chunk-AWJUYMX7.js";import{find as h,ROOT_ID as m,getList as g,remove as v,parseZoneKey as y,move as w,duplicate as k,replaceNode as b,createNode as S,insert as I,normalizeData as C,createResolveCache as E,resolveNodeData as x,ROOT_SLOT as D}from"./chunk-KRXQM65X.js";import{topLevelSlotKeys as O,fieldsFrom as A,defaultsFrom as M}from"./chunk-NKB3KVAB.js";import{createContext as K,useEffect as P,useContext as z,useRef as R,useSyncExternalStore as B,useState as N,useMemo as Z,useCallback as $,useLayoutEffect as j}from"react";import{jsx as L,jsxs as F}from"react/jsx-runtime";import{createPortal as V}from"react-dom";import{FloatingBar as H,TextToolbar as T}from"efficient-shell/ui";function Y(e){return!["setData","setUi","set"].includes(e.type)}var U=(e,t,n,o)=>{const r=g(e,t,y(n));return r?.[o]??null},W=(e,t,n,o,r)=>{const i=U(e,t,n,o);if(!i)throw new Error(`${r}: nothing at ${n}[${o}]`);return i};function q(e,t){const{selection:o}=e;return{...e.ui,itemSelector:n(e.data,t,o),selectedSlot:o&&"slot"===o.kind?{parentId:o.parentId,slot:o.slot}:null}}function X(e,t,n){return n?"node"===n.kind?h(e,t,n.id)?n:null:n.parentId===m?g(e,t,n)?n:null:h(e,t,n.parentId)&&g(e,t,n)?n:null:null}function Q(e,t,n,r=!1){const{itemSelector:i,selectedSlot:a,...s}=n;let l=e.selection;var c;return"itemSelector"in n&&(l=o(e.data,t,i??null)),"selectedSlot"in n&&(a?l=(c=a)?{kind:"slot",parentId:c.parentId,slot:c.slot}:null:"slot"===l?.kind&&(l=null)),{...e,selection:l,ui:r?s:{...e.ui,...s}}}function G(e,t,n){const o=J(e,t,n);if(o===e)return e;const r=X(o.data,n,o.selection);return r===o.selection?o:{...o,selection:r}}function J(e,t,n){const{data:o}=e;switch(t.type){case"setData":{const n="function"==typeof t.data?t.data(o):t.data;return{...e,data:{...o,...n}}}case"setUi":return Q(e,n,"function"==typeof t.ui?t.ui(q(e,n)):t.ui);case"set":{const r={data:o,ui:q(e,n)},i="function"==typeof t.state?t.state(r):t.state;let a=i.data?{...e,data:i.data}:e;return i.ui&&(a=Q(a,n,i.ui,!0)),a}case"insert":{const r={...y(t.destinationZone),index:t.destinationIndex},i=S(n,t.componentType,{},t.id?{id:t.id}:{});return{...e,data:I(o,n,r,i)}}case"replace":{const r=W(o,n,t.destinationZone,t.destinationIndex,"replace");if(r.props.id!==t.data.props.id)throw new Error("Can't change the id during a replace action. Use remove and insert for a new node.");return{...e,data:b(o,n,r.props.id,t.data)}}case"replaceRoot":{const n={...o.root,props:{...o.root.props,...t.root.props},readOnly:t.root.readOnly};return{...e,data:{...o,root:n}}}case"duplicate":{const r=W(o,n,t.sourceZone,t.sourceIndex,"duplicate"),i=k(o,n,r.props.id),a=U(i,n,t.sourceZone,t.sourceIndex+1);return{...e,data:i,selection:a?{kind:"node",id:a.props.id}:e.selection}}case"reorder":return J(e,{...t,type:"move",sourceZone:t.destinationZone},n);case"move":{if(t.sourceZone===t.destinationZone&&t.sourceIndex===t.destinationIndex)return e;const r=U(o,n,t.sourceZone,t.sourceIndex);if(!r)return e;const i={...y(t.destinationZone),index:t.destinationIndex};return{...e,data:w(o,n,r.props.id,i)}}case"remove":{const r=W(o,n,t.zone,t.index,"remove");return{...e,data:v(o,n,r.props.id)}}default:return e}}var _={drag:!0,duplicate:!0,delete:!0,edit:!0,insert:!0},ee={leftSideBarVisible:!0,rightSideBarVisible:!0,arrayState:{},componentList:{},isDragging:!1,previewMode:"edit",viewports:{current:{width:360,height:"auto"},options:[],controlsVisible:!0},field:{focus:null}},te=0,ne=()=>`history-${te+=1}`;function oe(e){let t=e.config;const r=e.now??(()=>Date.now()),i=e.historyCoalesceMs??250;let a=e.permissions??{};const s=C(e.data,t);let l={data:s,selection:null,ui:{...ee}};if(e.ui){const{itemSelector:n,selectedSlot:r,...i}=e.ui;l={data:s,selection:r?{kind:"slot",...r}:o(s,t,n??null),ui:{...ee,...i}}}let c=[{core:l,at:-1/0,sealed:!0,id:ne()}],d=0;const u=e=>{const t=c[d],n=r();!e&&d===c.length-1&&d>0&&!t.sealed&&n-t.at<i?c=[...c.slice(0,d),{...t,core:l,at:n}]:(c=[...c.slice(0,d+1),{core:l,at:n,sealed:e,id:ne()}],d=c.length-1)},p=/* @__PURE__ */new Set;let f=null,m=null,v=0,y=null,w=!1;const k=()=>{for(const e of[...p])e()},S=()=>{c=[...c.slice(0,d),{...c[d],core:l},...c.slice(d+1)]},I=(t,n)=>{v>0?w=w||n:(n?u(!1):l!==t&&S(),l.data!==t.data&&e.onChange?.(l.data),l!==t&&k())},D=e=>{const n=l;if(l=G(l,e,t),l===n)return;const o=e.recordHistory??Y(e);I(n,o&&l.data!==n.data)},O=t=>{0===v&&(y=l,w=!1),v+=1;try{t()}catch(e){throw v-=1,0===v&&y&&(l=y,y=null),e}if(v-=1,v>0||!y)return;const n=y;y=null,w&&l.data!==n.data?u(!0):l!==n&&S(),l.data!==n.data&&e.onChange?.(l.data),l!==n&&k()},A=e=>{const n=l,o=X(l.data,t,e);var r,i;(r=o,i=l.selection,r===i||r&&i&&r.kind===i.kind&&("node"===r.kind&&"node"===i.kind?r.id===i.id:"slot"===r.kind&&"slot"===i.kind&&r.parentId===i.parentId&&r.slot===i.slot))||(l={...l,selection:o},I(n,!1))},M=t=>{const n=l;d=t,l=c[d].core,l.data!==n.data&&e.onChange?.(l.data),l!==n&&k()},K=()=>(e={})=>{const n=e.root?t.root?.permissions:t.components[e.item?.type??e.type??""]?.permissions;return{..._,...a,...n}};let P=K();const z=E(),R={resolveCache:z,async resolveAll({trigger:e="load",metadata:n}={}){const o=l.data,r={type:"root",props:{...o.root.props??{}}},i=[...o.content,...Object.values(o.zones??{}).flat()],[a,...s]=await Promise.all([x(r,t,{cache:z,trigger:e,metadata:n}),...i.map(o=>x(o,t,{cache:z,trigger:e,metadata:n}))]);O(()=>{const e=l;let n=l.data;s.forEach((e,r)=>{if(!e.didChange)return;const a=i[r].props.id,s=h(n,t,a)?.node;s&&s===h(o,t,a)?.node&&(n=b(n,t,a,e.node))}),a.didChange&&n.root===o.root&&(n={...n,root:{...n.root,props:a.node.props,readOnly:a.node.readOnly??n.root.readOnly}}),n!==l.data&&(l={...l,data:n,selection:X(n,t,l.selection)},I(e,!1))})},async resolveNode(e,{trigger:n="replace",metadata:o}={}){const r=h(l.data,t,e)?.node;if(!r)return!1;const i=await x(r,t,{cache:z,trigger:n,metadata:o});if(!i.didChange)return!1;let a=!1;return O(()=>{const n=l;if(h(l.data,t,e)?.node!==r)return;const o=b(l.data,t,e,i.node);o!==l.data&&(l={...l,data:o,selection:X(o,t,l.selection)},I(n,!1),a=!0)}),a},get config(){return t},getState(){if(f&&m===l)return f;const e=l,o={data:e.data,ui:q(e,t)},r="node"===e.selection?.kind?h(e.data,t,e.selection.id)?.node??null:null;return f={appState:o,selection:e.selection,selectedItem:r,config:t,dispatch:D,history:{back:()=>R.undo(),forward:()=>R.redo(),hasPast:d>0,hasFuture:d<c.length-1,histories:c.map(e=>({id:e.id,state:{data:e.core.data,ui:q(e.core,t)}})),index:d,setHistoryIndex:e=>{e>=0&&e<c.length&&e!==d&&M(e)}},getPermissions:P,getItemById:n=>h(e.data,t,n)?.node,getItemBySelector:n=>function(e,t,n){const[o,r]=(n.zone??"root:default-zone").split(/:(.*)/s);return g(e,t,{parentId:o,slot:r})?.[n.index]}(e.data,t,n),getSelectorForId:o=>{const r=n(e.data,t,{kind:"node",id:o});return r?{index:r.index,zone:r.zone??"root:default-zone"}:void 0}},m=e,f},subscribe:e=>(p.add(e),()=>{p.delete(e)}),dispatch:D,batch:O,group:()=>{const e=d,t=c[e].id;let n=!0;return{close:()=>{if(!n)return;if(n=!1,c[e]?.id!==t)return;if(d<=e+1)return void(d===e+1&&(c=[...c.slice(0,d),{...c[d],sealed:!0},...c.slice(d+1)]));const o=c[d];c=[...c.slice(0,e+1),{...o,sealed:!0},...c.slice(d+1)],d=e+1}}},select:e=>A(e?{kind:"node",id:e}:null),selectSlot:e=>A(e?{kind:"slot",parentId:e.parentId,slot:e.slot}:null),run(e){O(()=>{const n=l,o=void 0===e.select?l.selection:e.select;l={...l,data:e.data,selection:X(e.data,t,o)},I(n,e.data!==n.data)})},load(e,n={}){const o=l,r=C(e,t);l={...l,data:r,selection:X(r,t,n.selection??l.selection)},n.keepHistory||(c=[{core:l,at:-1/0,sealed:!0,id:ne()}],d=0),l!==o&&k()},undo(){d>0&&M(d-1)},redo(){d<c.length-1&&M(d+1)},setPermissions(e){(function(e,t){if(e===t)return!0;const n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>e[n]===t[n])})(e,a)||(a=e,P=K(),f=null,k())},setConfig(e){e!==t&&(t=e,P=K(),f=null,k())}};return R}function re(e,t,n={}){const o=e=>{if(e.altKey)return;if(!(e.metaKey!==e.ctrlKey))return;const o="KeyZ"===e.code,r="KeyY"===e.code&&!e.shiftKey;(o||r)&&(n.leaveTyping&&u(e.target)||!1!==t.getState?.().getPermissions().edit&&(e.preventDefault(),r||e.shiftKey?t.redo():t.undo()))};return e.addEventListener("keydown",o),()=>e.removeEventListener("keydown",o)}var ie=K(null),ae=K(!0);function se({easel:e,hotkeys:t=!0,resolveOnMount:n=!0,children:o}){return P(()=>{n&&e.resolveAll()},[e,n]),P(()=>{if(t&&"undefined"!=typeof document)return re(document,e)},[e,t]),/* @__PURE__ */L(ie.Provider,{value:e,children:/* @__PURE__ */L(ae.Provider,{value:t,children:o})})}function le(){const e=z(ie);if(!e)throw new Error("useEasel: no <EaselProvider> above this component");return e}function ce(e){const t=le(),n=R({view:null,selector:null,value:void 0,has:!1}),o=()=>{const o=t.getState(),r=n.current;if(r.has&&r.view===o&&r.selector===e)return r.value;const i=e(o);return r.has&&Object.is(r.value,i)?(n.current={view:o,selector:e,value:r.value,has:!0},r.value):(n.current={view:o,selector:e,value:i,has:!0},i)};return B(t.subscribe,o,o)}function de(){return function(e){return ce(e)}}var ue="data-puck-component",pe="data-puck-dropzone",fe={},he="data-es-mirror",me="undefined"==typeof window?P:j;function ge(e,t,n){for(const e of Array.from(t.head.querySelectorAll(`[${he}]`)))e.remove();for(const o of Array.from(e.head.querySelectorAll('style, link[rel="stylesheet"]'))){const e=o.cloneNode(!0);e.setAttribute(he,""),n&&e.setAttribute("nonce",n),t.head.appendChild(e)}}function ve({children:t,id:n="preview-frame",title:o,className:r,style:i,mirrorStyles:a=!0,onDocument:s,height:l="auto",nonce:u}){const p=c("canvas",e),f=R(null),[h,m]=N(null);return me(()=>{const e=f.current,t=h?.ownerDocument.defaultView;if("auto"!==l||!e||!h||!t)return;const n=()=>{e.style.height=`${Math.ceil(h.getBoundingClientRect().height)}px`};n();const o=t.ResizeObserver,r=o?new o(n):null;return r?.observe(h),()=>r?.disconnect()},[h,l]),me(()=>{let e=f.current?.contentDocument;if(!e)return;"CSS1Compat"!==e.compatMode&&(e.open(),e.write("<!DOCTYPE html><html><head></head><body></body></html>"),e.close(),e=f.current?.contentDocument??e),e.body||e.documentElement.appendChild(e.createElement("body")),e.body.style.margin="0";const t=e.createElement("div");t.setAttribute("data-puck-entry",""),t.id="frame-root","fill"===l&&t.classList.add("es-frame-fill"),e.body.appendChild(t),d(e,u),m(t),s?.(e);let n=null;const o=f.current?.ownerDocument;if(a&&o){ge(o,e,u);const t=o.defaultView;t&&"MutationObserver"in t&&(n=new t.MutationObserver(()=>ge(o,e,u)),n.observe(o.head,{childList:!0,subtree:!0,characterData:!0}))}return()=>{n?.disconnect(),t.remove(),m(null),s?.(null)}},[]),/* @__PURE__ */L("iframe",{ref:f,id:n,title:o??p.frame,className:["es-canvas-frame","fill"===l?"is-fill":"",r??""].filter(Boolean).join(" "),style:i,children:h?V(t,h):null})}var ye=K(null),we=K(fe),ke=[];function be({parentId:e,slot:t,className:n,style:o,minEmptyHeight:r=128,minEmptyWidth:i=120}){const a=le(),s=ce(n=>g(n.appState.data,a.config,{parentId:e,slot:t})??ke),l=ce(t=>"node"===t.selection?.kind&&t.selection.id===e&&e!==m),c=ce(n=>"slot"===n.selection?.kind&&n.selection.parentId===e&&n.selection.slot===t),d=z(ye),u=["es-zone"];return s.length&&u.push("has-children"),e===m&&u.push("is-root"),(l||c)&&u.push("is-area-selected"),null!==d&&d===e&&e!==m&&u.push("is-hovering-area"),n&&u.push(n),/* @__PURE__ */L("div",{className:u.join(" "),[pe]:`${e}:${t}`,style:{...o,"--min-empty-height":`${r}px`,"--min-empty-width":`${i}px`},children:s.map(e=>/* @__PURE__ */L(Ce,{node:e},e.props.id))})}function Se(e,t,n,o){const r="root"===t?e.root:e.components[t],i={...o};for(const e of O(A(r)))i[e]=function(t={}){/* @__PURE__ */
2
+ return L(be,{parentId:n,slot:e,...t})};return i}function Ie(e){return function({zone:t,...n}){/* @__PURE__ */
3
+ return L(be,{parentId:e,slot:t,...n})}}function Ce({node:e}){const t=le().config,n=t.components[e.type],o=e.props.id,r=function(e){const t=R(null);return Z(()=>n=>{const o=t.current;o&&o!==n&&(o.removeAttribute(ue),o.removeAttribute("data-puck-dnd")),t.current=n,n&&(n.setAttribute(ue,e),n.setAttribute("data-puck-dnd",e),n.style.position="relative")},[e])}(o),i=z(we);if(!n?.render)return null;const a=n.render,s=Se(t,e.type,o,{...M(n),...e.props}),l={renderDropZone:Ie(o),isEditing:!0,dragRef:n.inline?r:null,metadata:{...i,...n.metadata}};return n.inline?/* @__PURE__ */L(a,{...s,puck:l,editMode:!0}):/* @__PURE__ */L("div",{[ue]:o,"data-puck-dnd":o,style:{position:"relative"},children:/* @__PURE__ */L(a,{...s,puck:l,editMode:!0})})}function Ee({metadata:e}){const t=ce(e=>e.config),n=ce(e=>e.appState.data.root).props??{},o=t.root?.render,r=/* @__PURE__ */L(be,{parentId:m,slot:D}),i=o?/* @__PURE__ */L(o,{id:"puck-root",...Se(t,"root",m,n),puck:{renderDropZone:Ie(m),isEditing:!0,dragRef:null,metadata:e??{}},editMode:!0,children:r}):r;/* @__PURE__ */
4
+ return L(we.Provider,{value:e??fe,children:i})}function xe(e,t,n){const[o,r]=N(null),i=R(t);return i.current=t,me(()=>{const t=e.current?.ownerDocument,n=t?.defaultView;if(!t||!n||!i.current)return void r(null);let o=0;const a=()=>{o=0;const n=function(e,t){if(!e||!t)return null;const n=e.getBoundingClientRect(),o=t.getBoundingClientRect();return{top:n.top-o.top,left:n.left-o.left,width:n.width,height:n.height}}(i.current?i.current(t):null,e.current?.parentElement??null);r(e=>{return(t=e)===(o=n)||t&&o&&t.top===o.top&&t.left===o.left&&t.width===o.width&&t.height===o.height?e:n;var t,o})},s=()=>{o||(o=(n.requestAnimationFrame??(e=>n.setTimeout(e,16)))(a))};a();const l="MutationObserver"in n?new n.MutationObserver(s):null;l?.observe(t.body,{childList:!0,subtree:!0,attributes:!0,characterData:!0});const c="ResizeObserver"in n?new n.ResizeObserver(s):null;return c?.observe(t.documentElement),n.addEventListener("resize",s),()=>{l?.disconnect(),c?.disconnect(),n.removeEventListener("resize",s),o&&(n.cancelAnimationFrame??n.clearTimeout)(o)}},[n]),o}function De({id:e,kind:t,overlay:n}){const o=R(null),r=xe(o,e?t=>t.querySelector(`[${ue}="${t.defaultView?.CSS?.escape?t.defaultView.CSS.escape(e):e}"]`):null,e),i=/* @__PURE__ */L("div",{ref:o,"aria-hidden":"true",className:`es-canvas-outline is-${t}`,style:r?{position:"absolute",top:r.top,left:r.left,width:r.width,height:r.height}:{display:"none"}});return n&&e?/* @__PURE__ */L(n,{componentId:e,kind:t,children:i}):i}function Oe(e,t){const n=l(e),o=n.text.length,r=e.ownerDocument;if(!t)return[o,o];let i=null;const a=r.caretPositionFromPoint?.(t.x,t.y);if(a&&e.contains(a.offsetNode))i=n.at(a.offsetNode,a.offset);else{const o=r.caretRangeFromPoint?.(t.x,t.y);o&&e.contains(o.startContainer)&&(i=n.at(o.startContainer,o.startOffset))}if(null===i)return[o,o];const s=n.text;let c=i,d=i;for(;c>0&&!/\s/.test(s[c-1]);)c-=1;for(;d<s.length&&!/\s/.test(s[d]);)d+=1;return[c,d]}function Ae({s:e,element:t,toolbar:n,label:o}){const r=e.pressed(),i=new Set(n.offered.filter(e=>"link"!==e));/* @__PURE__ */
5
+ return L(H,{anchor:()=>{const e=t();if(!e)return null;const n=e.getBoundingClientRect(),o=e.ownerDocument.defaultView?.frameElement,r=o?p(o,{left:n.left,top:n.top,width:n.width,height:n.height}):{left:n.left,top:n.top,width:n.width,height:n.height};return{left:r.left-6,top:r.top-6,right:r.left+r.width+6,bottom:r.top+r.height+6}},bounds:()=>{const e=t(),n=e?.ownerDocument.defaultView?.frameElement,o=(n??e?.closest(".es-canvas")??e)?.getBoundingClientRect();return o?{left:o.left,top:o.top,right:o.right,bottom:o.bottom}:{left:0,top:0,right:window.innerWidth,bottom:window.innerHeight}},"aria-label":o,children:/* @__PURE__ */L("div",{style:{width:"18rem"},children:/* @__PURE__ */L(T,{offered:i,pressed:r.marks,onMark:t=>{"link"!==t&&e.press(t)},list:{pressed:r.list,onList:t=>e.list(t)},alignment:n.alignment,letterCase:n.letterCase})})})}function Me({element:e}){const t=R(null),n=xe(t,()=>e(),e);/* @__PURE__ */
6
+ return L("div",{ref:t,"aria-hidden":"true",className:"es-canvas-outline is-typing",style:n?{position:"absolute",top:n.top,left:n.left,width:n.width,height:n.height}:{display:"none"}})}function Ke({frame:t=!0,className:n,style:o,metadata:r,mirrorStyles:l,onDocument:d,height:u,title:p,nonce:h,hotkeys:m,frameWrapper:g,overlay:v,children:y,typing:w}){const k=le(),b=z(ae),S=c("canvas",e),I=m??b,[C,E]=N(void 0),x=ce(e=>"node"===e.selection?.kind?e.selection.id:null),[D,O]=N(null),[A,M]=N(null),K=R(null),[,B]=N(0),Z=R(w);Z.current=w;const $=R(null),j=e=>{const t=$.current?.ownerDocument,n=t?.defaultView?.CustomEvent;t&&n&&t.dispatchEvent(new n(f,{detail:{typing:e}}))},V=(e,t)=>{K.current?.s.stop("stop");const n=e.element();if(!n)return!1;const o=k.group(),r=e.element,i=s({element:r,value:e.value,rules:e.rules,multiline:e.multiline,caret:Oe(n,t),write:e.write,remount:e.remount,onSelect:()=>B(e=>e+1),end:e=>{o.close(),K.current?.element===r&&(K.current=null),M(null),j(!1),Z.current?.onChange?.({typing:!1,why:e})}});if(!i)return o.close(),!1;const a=n.closest?.(`[${ue}]`)?.getAttribute(ue);return a&&k.select(a),K.current={s:i,element:r,target:e},M(()=>r),O(null),j(!0),Z.current?.onChange?.({typing:!0,element:n}),!0};P(()=>()=>K.current?.s.stop("stop"),[]);const H=e=>{const t=K.current?.element();return Boolean(t&&t.contains(e))},T=e=>{const t=e.closest?.(`[${ue}]`)?.getAttribute(ue);if(!t)return;const n=k.getState(),o="node"===n.selection?.kind?n.selection.id:null;return a(n.appState.data,k.config,t,o)??t},Y=e=>{if("Enter"!==e.key||e.defaultPrevented||e.shiftKey||e.metaKey||e.ctrlKey||e.altKey)return;if(K.current)return;const t=e.target;if(t?.isContentEditable||t?.closest?.("input, textarea, select, button, a[href]"))return;const n=Z.current?.atSelection?.();n&&V(n,null)&&e.preventDefault()},U=/* @__PURE__ */F("div",{ref:$,className:"es-canvas-content",style:{position:"relative"},onClick:e=>{const t=e.target;if(t.closest?.("a[href]")&&e.preventDefault(),K.current){if(H(t))return;K.current.s.stop("outside")}const n=T(t);void 0===n?t.hasAttribute?.(pe)||k.select(null):k.select(n)},onDoubleClick:e=>{const t=Z.current;if(!t||H(e.target))return;const n=t.at(e.target);n&&V(n,{x:e.clientX,y:e.clientY})&&e.preventDefault()},onKeyDown:e=>Y(e),onMouseOver:e=>{if(K.current)return;const t=T(e.target)??null;t!==D&&O(t)},onMouseLeave:()=>O(null),children:[
7
+ /* @__PURE__ */L(ye.Provider,{value:D,children:/* @__PURE__ */L(Ee,{metadata:r})}),
8
+ /* @__PURE__ */F("div",{className:"es-canvas-outlines",style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:[
9
+ /* @__PURE__ */L(De,{id:!A&&D&&D!==x?D:null,kind:"hover",overlay:v}),
10
+ /* @__PURE__ */L(De,{id:A?null:x,kind:"selected",overlay:v}),A?/* @__PURE__ */L(Me,{element:A}):null]}),y]}),W=g?/* @__PURE__ */L(g,{document:C,children:U}):U;P(()=>{if(C&&I)return re(C,k)},[C,I,k]),P(()=>{if(!C)return;const e=e=>{if("Enter"===e.key)return void Y(e);if("Escape"!==e.key||e.defaultPrevented)return;const t=e.target;if(t?.isContentEditable||t?.closest?.("input, textarea, select"))return;const n=k.getState();if("node"!==n.selection?.kind)return;const o=i(n.appState.data,k.config,n.selection);"node"===o?.kind&&k.select(o.id)};return C.addEventListener("keydown",e),()=>C.removeEventListener("keydown",e)},[C,k]);/* @__PURE__ */
11
+ return F("div",{className:"es-canvas"+(n?` ${n}`:""),style:o,"data-puck-preview":"","data-es-typing":A?"":void 0,children:[A&&K.current?.target.toolbar?/* @__PURE__ */L(Ae,{s:K.current.s,element:K.current.element,toolbar:K.current.target.toolbar,label:S.textTools}):null,t?/* @__PURE__ */L(ve,{mirrorStyles:l,onDocument:e=>{E(e??void 0),d?.(e)},height:u,title:p,nonce:h,children:W}):/* @__PURE__ */L("div",{id:"preview-frame","data-puck-entry":"",children:W})]})}function Pe(e={}){const t=le(),n=ce(e=>e.appState.data);return r({...e,data:n,config:t.config,commit:(e,{select:n})=>t.run({data:e,select:n})})}function ze(){const e=le(),n=ce(e=>e.config),o=e.resolveCache,r=ce(e=>e.selectedItem),i=ce(e=>e.appState.data.root),a=r?r.props.id:"root",s=i.props??{},l=Z(()=>r||{type:"root",props:s},[r,s]),c=r?n.components[r.type]:n.root,d=e.getState(),u=r?h(d.appState.data,n,a):null,p=u&&"root"!==u.place.parentId?u.place.parentId:null,f=p?d.getItemById(p)??null:null,{fields:m}=t({id:a,node:l,block:c,parent:f,appState:d.appState}),g=ce(e=>!1===e.getPermissions(r?{item:r}:{root:!0}).edit),v=$((t,r)=>{(async()=>{const i=e.getState();if("root"!==a){const s=i.getItemById(a),l=i.getSelectorForId(a);if(!s||!l)return;const c={...s,props:{...s.props,[t]:r}},{node:d}=await x(c,n,{cache:o,trigger:"replace"}),u=e.getState().getSelectorForId(a);if(!u)return;return void e.dispatch({type:"replace",destinationZone:u.zone??"root:default-zone",destinationIndex:u.index,data:d})}const s=i.appState.data.root.props??{},{node:l}=await x({type:"root",props:{...s,[t]:r}},n,{cache:o,trigger:"replace"});e.dispatch({type:"replaceRoot",root:{props:l.props,readOnly:l.readOnly},recordHistory:!0})})()},[e,n,o,a]);return{id:a,node:l,fields:m,values:l.props,readOnly:g,onChange:v}}export{ve as CanvasFrame,ee as DEFAULT_UI,Ke as EaselCanvas,se as EaselProvider,Ee as EditDocument,re as bindUndoKeys,oe as createEasel,de as createUseEasel,Y as recordsByDefault,G as reduce,q as uiView,ce as useEasel,le as useEaselApi,Pe as useEaselNodeOps,ze as useSelectedFields,X as validSelection};
@@ -1,4 +1,4 @@
1
- import{useScreenOwnerName as e}from"./chunk-6XXW6ZW3.js";import{settlePanelPick as n}from"./chunk-R6WTQWAC.js";import{MediaPanelHead as i,mediaPickKind as c}from"./chunk-UB4TLWVJ.js";import{jsxs as o,Fragment as r,jsx as t}from"react/jsx-runtime";function l({panel:l,pick:d,onHide:m}){const p=e();/* @__PURE__ */
1
+ import{useScreenOwnerName as e}from"./chunk-ZR4CFNMW.js";import{settlePanelPick as n}from"./chunk-R6WTQWAC.js";import{MediaPanelHead as i,mediaPickKind as c}from"./chunk-UB4TLWVJ.js";import{jsxs as o,Fragment as r,jsx as t}from"react/jsx-runtime";function l({panel:l,pick:d,onHide:m}){const p=e();/* @__PURE__ */
2
2
  return o(r,{children:[
3
3
  /* @__PURE__ */t(i,{context:p,pick:d?{kind:c(d.accept),field:d.title||void 0}:null,onCancel:()=>d&&n(d.requestId,null),onHide:m}),
4
4
  /* @__PURE__ */t("div",{className:"sf-media-panel",children:/* @__PURE__ */t(l,{pick:d,onPick:e=>d&&n(d.requestId,e)})})]})}export{l as MediaSidePanel};