efficient-easel 20.2.1 → 21.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. package/README.md +15 -6
  2. package/dist/{CanvasDragLayer-ARfaivCu.d.ts → CanvasDragLayer-Cd1o0HQf.d.ts} +1 -1
  3. package/dist/{chunk-TNGOL65V.js → chunk-2E2SXDYQ.js} +1 -1
  4. package/dist/chunk-2M4T27BI.js +18 -0
  5. package/dist/chunk-4IJVV7DA.js +1 -0
  6. package/dist/{chunk-JQXD3TDE.js → chunk-66JNVRQM.js} +1 -1
  7. package/dist/{chunk-EFHV56BO.js → chunk-7L3NKHEC.js} +14 -14
  8. package/dist/{chunk-XJ2WXGFJ.js → chunk-APVUYICP.js} +42 -42
  9. package/dist/{chunk-HK6I3NVO.js → chunk-E52W3M5I.js} +1 -1
  10. package/dist/chunk-EB6NI2VK.js +1 -0
  11. package/dist/chunk-EZTP6E2M.js +5 -0
  12. package/dist/chunk-FM6JO4WF.js +2 -0
  13. package/dist/chunk-FOHHXSOL.js +1 -0
  14. package/dist/{chunk-I7BROL77.js → chunk-HGCGIRVA.js} +1 -1
  15. package/dist/chunk-JACEEVVF.js +1 -0
  16. package/dist/{chunk-QAJAEWCZ.js → chunk-KFWNGPW3.js} +5 -5
  17. package/dist/{chunk-276MBG5P.js → chunk-LXTM2OLQ.js} +2 -2
  18. package/dist/{chunk-FGYJ5DJY.js → chunk-MSGZ56QL.js} +1 -1
  19. package/dist/chunk-MZ5GSSZ3.js +7 -0
  20. package/dist/{chunk-UJ46J7QW.js → chunk-N2RISV46.js} +1 -1
  21. package/dist/chunk-NA3GMA43.js +5 -0
  22. package/dist/chunk-OBWDHKLI.js +8 -0
  23. package/dist/chunk-Q2A7RHG2.js +1 -0
  24. package/dist/{chunk-JBOSEHIX.js → chunk-R4QJ6DC5.js} +1 -1
  25. package/dist/chunk-S3DUFDQ6.js +6 -0
  26. package/dist/chunk-TQ5Y6S2X.js +1 -0
  27. package/dist/{chunk-7YVEYQDE.js → chunk-V2ULLALL.js} +3 -3
  28. package/dist/chunk-WHS6Y55E.js +10 -0
  29. package/dist/{chunk-ZOBSIXRD.js → chunk-Y2T3JX7K.js} +1 -1
  30. package/dist/chunk-YHFKWV7H.js +21 -0
  31. package/dist/copy/index.js +13 -13
  32. package/dist/drag/drag.css +3 -9
  33. package/dist/drag/index.d.ts +2 -2
  34. package/dist/drag/index.js +1 -1
  35. package/dist/draw/index.d.ts +1 -1
  36. package/dist/draw/index.js +1 -1
  37. package/dist/easel/index.js +1 -1
  38. package/dist/fields/fields.css +2 -2
  39. package/dist/fields/index.d.ts +1 -1
  40. package/dist/fields/index.js +1 -1
  41. package/dist/panel/index.d.ts +37 -138
  42. package/dist/panel/index.js +15 -15
  43. package/dist/panel/panel.css +53 -347
  44. package/dist/screen/components/AddBlockRow.js +1 -1
  45. package/dist/screen/components/AddSidePanel.js +1 -1
  46. package/dist/screen/components/NodeContextMenu.d.ts +3 -3
  47. package/dist/screen/components/NodeContextMenu.js +1 -1
  48. package/dist/screen/components/PageEditGuardNotices.js +1 -1
  49. package/dist/screen/components/SaveControls.d.ts +3 -3
  50. package/dist/screen/components/ScreenChrome.js +1 -1
  51. package/dist/screen/components/ScreenDocumentContext.js +1 -1
  52. package/dist/screen/components/ScreenMount.d.ts +3 -3
  53. package/dist/screen/components/ScreenMount.js +1 -1
  54. package/dist/screen/components/ScreenStoreProvider.d.ts +3 -3
  55. package/dist/screen/components/ScreenStoreProvider.js +1 -1
  56. package/dist/screen/components/SectionScreenShell.js +16 -16
  57. package/dist/screen/components/usePartBridge.d.ts +3 -3
  58. package/dist/screen/components/usePartBridge.js +1 -1
  59. package/dist/screen/index.d.ts +3 -3
  60. package/dist/screen/index.js +1 -1
  61. package/dist/screen/lib/content/view-tiers.d.ts +14 -2
  62. package/dist/screen/lib/content/view-tiers.js +1 -1
  63. package/dist/screen/lib/key-scope.js +1 -1
  64. package/dist/screen/lib/puck/device-fields.js +1 -1
  65. package/dist/screen/lib/puck/preview-dom.js +1 -1
  66. package/dist/screen/lib/puck/style-clipboard.d.ts +3 -3
  67. package/dist/screen/lib/puck/style-clipboard.js +1 -1
  68. package/dist/screen/lib/puck/use-section-ops.js +1 -1
  69. package/dist/screen/lib/screen-parts.d.ts +3 -3
  70. package/dist/screen/lib/screen-parts.js +1 -1
  71. package/dist/screen/screen.css +3 -7
  72. package/dist/screen/words.d.ts +4 -0
  73. package/dist/screen/words.js +1 -1
  74. package/dist/strings/index.d.ts +2 -2
  75. package/dist/strings/index.js +2 -2
  76. package/dist/text-styles/index.js +30 -30
  77. package/dist/tree/index.d.ts +4 -4
  78. package/dist/tree/index.js +1 -1
  79. package/dist/{types-Bqq6ya0y.d.ts → types-DBy3L69b.d.ts} +11 -4
  80. package/dist/{words-vhnV8sM7.d.ts → words-CFkb8XtN.d.ts} +5 -0
  81. package/dist/{words-CvwYvkJm.d.ts → words-SD4neL0n.d.ts} +6 -0
  82. package/package.json +3 -3
  83. package/dist/chunk-23DYNW6S.js +0 -1
  84. package/dist/chunk-23VM4PMV.js +0 -7
  85. package/dist/chunk-6FWAE2RN.js +0 -1
  86. package/dist/chunk-7LYKFL3Q.js +0 -21
  87. package/dist/chunk-A6Z4SD3I.js +0 -10
  88. package/dist/chunk-KAML3KQH.js +0 -1
  89. package/dist/chunk-L2Y3PF2R.js +0 -4
  90. package/dist/chunk-LQV5FZTQ.js +0 -18
  91. package/dist/chunk-MEHLY5Q4.js +0 -1
  92. package/dist/chunk-PAOZMXEI.js +0 -5
  93. package/dist/chunk-R5KEFI55.js +0 -8
  94. package/dist/chunk-RC25EGHD.js +0 -5
  95. package/dist/chunk-VANKQVOW.js +0 -8
  96. package/dist/chunk-WEIE2FBC.js +0 -1
  97. package/dist/chunk-WRFD4EXD.js +0 -1
package/README.md CHANGED
@@ -1008,7 +1008,10 @@ const easel = createEasel<EaselConfig>({ config, data, onChange: (doc) => autosa
1008
1008
  which bands are closed. A folded band's rows stay mounted.
1009
1009
  - **A band's title is a heading since 7.2.0** (WAI-ARIA accordion pattern):
1010
1010
  `SettingsGroup` draws `<h3 class="es-group-title"><button aria-expanded
1011
- aria-controls>…</button></h3>`. `headingLevel` (default 3) sets the bands'
1011
+ aria-controls>…</button></h3>` — since the B2 plan C move (2026-10-26) through
1012
+ the shell's `Accordion`, which draws the band's look; the panel parts
1013
+ (`SettingsField`, `SettingsDefaultReset`, `SettingsGroup`, `SettingsGroupHead`,
1014
+ `SettingsGroupSub`) all call the shell's parts, same names and props. `headingLevel` (default 3) sets the bands'
1012
1015
  level; a group inside a band draws one under it. `SettingsGroup` takes
1013
1016
  `level` too. A band's DOM id is built from a safe form of its key (any
1014
1017
  character but letters, digits, `-` and `_` becomes `-u<hex>-`, so `" text"`
@@ -1071,11 +1074,17 @@ runs the same rules (`--axe <axe.min.js>`).
1071
1074
  (`InspectorField`) the list is `aria-labelledby` the row's own label. A
1072
1075
  `FieldSelect` on its own is named by `ariaLabelledBy` or `ariaLabel`, and
1073
1076
  with neither the list takes its button's name, so it is never nameless.
1074
- - **Small grey words can be read.** The Add panel's group count, a menu
1075
- row's shortcut, a read-only or disabled field's value and an empty slot's
1076
- note are at least 4.5:1 on their ground (WCAG AA), held by ratio in
1077
- `tests/contrast-small-text.test.ts`. A host that overrode
1078
- `.es-add-group-count` or `--es-menu-shortcut-fg` can drop the override.
1077
+ - **Small grey words can be read.** A menu row's shortcut, a read-only or
1078
+ disabled field's value and an empty slot's note are at least 4.5:1 on their
1079
+ ground (WCAG AA), held by ratio in `tests/contrast-small-text.test.ts`. A
1080
+ host that overrode `--es-menu-shortcut-fg` can drop the override.
1081
+ - **Every count is the shell's `ItemCount`** (Lewis, 2026-10-23): the Add
1082
+ panel's group heads ("3 sections", "2 blocks"), a list field's head (in the
1083
+ field's `noun`: "3 slides") and the "Add block" menu's run headings. A muted
1084
+ box at the end of the row; its words are in the Tooltip and for the screen
1085
+ reader (`drag.add.count`, `fields.list.count`, `screen.blockCount`). The
1086
+ classes `.es-add-group-count`, `.es-list-count` and `.sf-menugroup-count`
1087
+ are gone; a host that styled them can drop the rule.
1079
1088
  - **The rail says which words it draws.** The width decides in CSS between
1080
1089
  every word, the open panel's word, and glyphs only, so a longer language
1081
1090
  folds sooner (German "Zurück", "Ebenen"). `<TopBarRail onWords={…}>` is told
@@ -2,7 +2,7 @@ import * as react from 'react';
2
2
  import { C as CanvasTarget$1 } from './watch-BTYOJpQU.js';
3
3
  import { S as SlotAddress, P as Place } from './types-41704JE4.js';
4
4
  import { D as DragSession } from './session-DSQFmIvx.js';
5
- import { D as DragWords } from './words-CvwYvkJm.js';
5
+ import { D as DragWords } from './words-SD4neL0n.js';
6
6
 
7
7
  /**
8
8
  * Where a drop on the CANVAS lands — pure functions over measured boxes
@@ -1 +1 @@
1
- import{isPreviewClick as t}from"./chunk-R5L2E7JX.js";import{HERO_SLIDER_GOTO_EVENT as n}from"./chunk-IQ5TA7AM.js";import{queryMainCopy as o}from"./chunk-LF3FUSCQ.js";var e=()=>document.querySelector(".sf-editor #preview-frame");function r(n){t()||requestAnimationFrame(()=>{const t=e()?.contentDocument;t&&o(t,`[data-puck-component="${CSS.escape(n)}"]`)?.scrollIntoView({behavior:"smooth",block:"start"})})}function c(t,o){const r=e()?.contentWindow;if(!r)return;const c={id:t,index:o};r.dispatchEvent(new CustomEvent(n,{detail:c}))}function i(){requestAnimationFrame(()=>{e()?.contentWindow?.scrollTo({top:0,behavior:"smooth"})})}function u(t,{passes:n=[150,400],onPinned:o}={}){let r=0,c=!1;const i=[],u=()=>{const r=e(),s=r?.contentWindow,l=r?.contentDocument;if(!s||!l)return!1;const m=t(s,l);if(null==m)return!1;if(s.scrollTo({left:s.scrollX,top:m,behavior:"instant"}),!c){c=!0,o?.();for(const t of n)i.push(setTimeout(u,t))}return!0},s=()=>{!u()&&r++<150&&i.push(setTimeout(s,32))};return s(),()=>i.forEach(clearTimeout)}function s(t){return u((n,e)=>{const r=o(e,`[data-puck-component="${CSS.escape(t)}"]`);return r?n.scrollY+r.getBoundingClientRect().top:null})}function l(t){return u((t,n)=>{if(!n.querySelector("[data-puck-component]"))return null;const o=Math.max(n.documentElement.scrollHeight,n.body?.scrollHeight??0);return o<=n.documentElement.clientHeight?null:o},{passes:[150,400,800,1300,2e3],onPinned:t})}export{c as gotoPreviewSlide,l as pinPreviewToBottom,s as pinPreviewToSection,e as previewFrame,r as scrollPreviewToSection,i as scrollPreviewToTop};
1
+ import{HERO_SLIDER_GOTO_EVENT as t}from"./chunk-IQ5TA7AM.js";import{queryMainCopy as n}from"./chunk-LF3FUSCQ.js";import{isPreviewClick as o}from"./chunk-R5L2E7JX.js";var e=()=>document.querySelector(".sf-editor #preview-frame");function r(t){o()||requestAnimationFrame(()=>{const o=e()?.contentDocument;o&&n(o,`[data-puck-component="${CSS.escape(t)}"]`)?.scrollIntoView({behavior:"smooth",block:"start"})})}function c(n,o){const r=e()?.contentWindow;if(!r)return;const c={id:n,index:o};r.dispatchEvent(new CustomEvent(t,{detail:c}))}function i(){requestAnimationFrame(()=>{e()?.contentWindow?.scrollTo({top:0,behavior:"smooth"})})}function u(t,{passes:n=[150,400],onPinned:o}={}){let r=0,c=!1;const i=[],u=()=>{const r=e(),s=r?.contentWindow,l=r?.contentDocument;if(!s||!l)return!1;const m=t(s,l);if(null==m)return!1;if(s.scrollTo({left:s.scrollX,top:m,behavior:"instant"}),!c){c=!0,o?.();for(const t of n)i.push(setTimeout(u,t))}return!0},s=()=>{!u()&&r++<150&&i.push(setTimeout(s,32))};return s(),()=>i.forEach(clearTimeout)}function s(t){return u((o,e)=>{const r=n(e,`[data-puck-component="${CSS.escape(t)}"]`);return r?o.scrollY+r.getBoundingClientRect().top:null})}function l(t){return u((t,n)=>{if(!n.querySelector("[data-puck-component]"))return null;const o=Math.max(n.documentElement.scrollHeight,n.body?.scrollHeight??0);return o<=n.documentElement.clientHeight?null:o},{passes:[150,400,800,1300,2e3],onPinned:t})}export{c as gotoPreviewSlide,l as pinPreviewToBottom,s as pinPreviewToSection,e as previewFrame,r as scrollPreviewToSection,i as scrollPreviewToTop};
@@ -0,0 +1,18 @@
1
+ import{DEFAULT_DRAG_WORDS as e}from"./chunk-TQ5Y6S2X.js";import{dropEffectFor as t,scrollBoxOf as n,frameScrollBox as l,startAutoScroll as a,isNoOpDrop as r}from"./chunk-3S5N4HLJ.js";import{withTip as o}from"./chunk-P2VEMZH5.js";import{parseZoneKey as s,ROOT_ID as i}from"./chunk-K7BTCBWD.js";import{useCanvasLayout as c,useCanvasTyping as d,useCanvasEvent as u,CANVAS_TYPABLE_EVENT as h,framePointToHost as f,elementScale as p,frameRectToLayer as m,clientPointToLayer as g}from"./chunk-QIDRJH3S.js";import{isRepeatCopy as b}from"./chunk-LF3FUSCQ.js";import{useRef as x,useEffect as y,useState as v,useCallback as w,useMemo as k,useSyncExternalStore as N,useId as D,useLayoutEffect as A}from"react";import{Tooltip as z,IconButton as T,solidSurfaceStyle as M,Input as C,ItemCount as S}from"efficient-shell/ui";import{AddIcon as $,CloseIcon as E,SearchIcon as j}from"efficient-shell/icons/efficient";import{jsxs as L,jsx as B}from"react/jsx-runtime";function O({label:e,onInsert:t,style:n,axis:l="y",className:a,index:r}){const o=["es-canvas-insert","x"===l?"is-x":"",a??""].filter(Boolean).join(" ");/* @__PURE__ */
2
+ return L("div",{className:o,style:n,"data-index":r,children:[
3
+ /* @__PURE__ */B("span",{className:"es-canvas-insert-line","aria-hidden":"true"}),
4
+ /* @__PURE__ */B("span",{className:"es-canvas-insert-chip",children:/* @__PURE__ */B(z,{content:e,children:/* @__PURE__ */B(T,{variant:"ghost",size:"sm","aria-label":e,onClick:t,children:/* @__PURE__ */B($,{})})})})]})}var I=(e,t,n)=>t>=e.left&&t<=e.left+e.width&&n>=e.top&&n<=e.top+e.height,K=e=>e.width*e.height;function q(e,t,n){return e.map((e,t)=>({s:e,at:t})).filter(({s:e})=>I(e.box,t,n)).sort((e,t)=>K(t.s.box)-K(e.s.box)||e.at-t.at).map(({s:e})=>e)}function X(e,t,n){return q(e,t,n).at(-1)??null}function Y(e,t,n){const l="x"===e.axis?t:n;let a=0;for(const t of e.children){l>("x"===e.axis?t.left+t.width/2:t.top+t.height/2)&&(a+=1)}return a}function H(e,t){const n=e.children;if("x"===e.axis){const l=n[t-1],a=n[t],r=l&&a?(l.left+l.width+a.left)/2:l?l.left+l.width:a?a.left:e.box.left,o=a??l??e.box;return{left:r-1,top:o.top,width:2,height:o.height}}const l=n[t-1],a=n[t],r=l&&a?(l.top+l.height+a.top)/2:l?l.top+l.height:a?a.top:e.box.top;return{left:e.box.left,top:r-1,width:e.box.width,height:2}}function F(e,t,n,l,a=()=>!1,r=()=>!0){const o=e.filter(e=>I(e.box,t,n)).sort((e,t)=>K(e.box)-K(t.box));for(const e of o){const o=Y(e,t,n),s={...e.list,index:o};if(a(s))return null;if(l(s))return{zone:e,to:s,line:H(e,o)};if(!r(s))return null}return null}function P(e,t,n=12){const l=e.children;if(0===l.length)return[];const a=e.box,r="x"===e.axis,o=r?a.left:a.top,s=o+(r?a.width:a.height),i=e=>r?e.left:e.top,c=e=>r?e.left+e.width:e.top+e.height,d=[];for(let a=0;a<=l.length;a++){const u=l[a-1],h=l[a];let f,p;if(u&&h)f=c(u),p=Math.max(i(h)-f,0);else{const e=u?(c(u)+s)/2:(o+i(h))/2,t=Math.min(Math.max(e,o+n),s-n);f=u?Math.max(t,c(u)):Math.min(t,i(h)),p=0}const m=[u,h].filter(e=>Boolean(e)),g=Math.min(...m.map(e=>r?e.top:e.left)),b=Math.max(...m.map(e=>r?e.top+e.height:e.left+e.width)),x=r?{left:f,top:g,width:p,height:b-g}:{left:g,top:f,width:b-g,height:p};d.push({key:`${e.key}:+${a}`,place:{...e.list,index:a},box:x,axis:e.axis,label:t})}return d}function Q(e,t=e.key){const n=[];for(let l=1;l<e.children.length;l++){const a=e.children[l-1],r=e.children[l],o=a.top+a.height;n.push({key:`${t}:${l}`,place:{...e.list,index:l},box:{left:e.box.left,top:o,width:e.box.width,height:Math.max(r.top-o,0)}})}return n}var R={nodes:[],zones:[]},Z="data-puck-dropzone",J="data-puck-component";function V(e,t){if(e.length>=2){const[t,n]=e;return Math.abs(n.top-t.top)<Math.min(t.height,n.height)/2&&n.left>t.left?"x":"y"}const n=t.ownerDocument.defaultView?.getComputedStyle(t);return n&&n.display.includes("flex")&&n.flexDirection.startsWith("row")?"x":"y"}function W(e,t){const{frame:n,document:l}=e,a=e=>m(n,function(e){const t=e.getBoundingClientRect();return{left:t.left,top:t.top,width:t.width,height:t.height}}(e),t),r=[],o=[];for(const e of l.querySelectorAll(`[${Z}]`)){if(b(e))continue;const t=e.getAttribute(Z)??"";let n;try{n=s(t)}catch{continue}const l=[...e.querySelectorAll(`[${J}]`)].filter(t=>t.parentElement?.closest(`[${Z}]`)===e&&!b(t)),i=l.map(a);o.push({key:t,list:n,box:a(e),axis:V(i,e),children:i}),l.forEach((e,t)=>{const l=e.getAttribute(J);l&&r.push({id:l,place:{...n,index:t},box:i[t]})})}return{nodes:r,zones:o}}var U="data-es-empty-cell",G="data-puck-dropzone",_=140;var ee=e=>({left:e.left,top:e.top,width:e.width,height:e.height});function te(o){const{canvas:s,session:m,readOnly:b,words:D=e.canvas}=o,T=x(o);y(()=>{T.current=o});const C=x(null),S=c(s),[$,E]=v(0),j=w(()=>E(e=>e+1),[]),[I,K]=v(R);y(()=>{const e=C.current;s&&e&&K((T.current.measure??W)(s,e))},[s,S,o.revision,$]);const X=o.model,Y=k(()=>X(I),[X,I]),H=N(m.subscribe,m.shown,m.shown),P=o.choose,Q=(e,t)=>{const n=q(Y.sources,e,t);return 0===n.length?null:P?P(n):n[n.length-1]},[Z,J]=v(null),[V,_]=v(null),[te,ne]=v(null),le=x(null),ae=()=>{le.current&&clearTimeout(le.current),le.current=null},re=()=>{ae(),le.current=setTimeout(()=>{m.get()||J(null)},140)};y(()=>ae,[]);const oe=x(null),se=d(s),ie=x(!1);ie.current=se,y(()=>{se&&(ae(),J(null))},[se]);const[ce,de]=v(null);u(s,h,e=>de(e.detail?.id??null));const ue=!ce||se||b||H?null:I.nodes.find(e=>e.id===ce)?.box??null;u(s,"mousemove",e=>{const t=C.current;if(!s||!t)return;const n=f(s.frame,e.clientX,e.clientY,t),l=p(t),a={x:n.x/l,y:n.y/l};if(oe.current=a,T.current.readOnly||m.get()||ie.current)return;ae();const r=Q(a.x,a.y);J(e=>e?.key===r?.key&&e?.box===r?.box?e:r)}),u(s,"mouseout",e=>{e.relatedTarget||(oe.current=null,re())}),u(s,"mouseover",e=>{e.relatedTarget||j()});const he=x(null),fe=w(()=>{he.current?.(),he.current=null,_(null),ne(null)},[]);y(()=>m.subscribe(()=>{m.get()?j():fe()}),[m,fe,j]),y(()=>fe,[fe]),("undefined"==typeof document?y:A)(()=>{if(m.get())return;const e=oe.current;J(t=>b||ie.current?null:e?Q(e.x,e.y):t?Y.sources.find(e=>e.key===t.key)??null:null)},[Y,H,m,b,P]);const pe=e=>{const t=m.get(),n=C.current,l=T.current.dropOn;if(!t||!n||!l)return null;const a=g(n,e.clientX,e.clientY);oe.current=a;const r=q(Y.sources,a.x,a.y);for(let e=r.length-1;e>=0;e-=1)if(l.accepts(t.item,r[e]))return{h:t,source:r[e]};return null},me=e=>{const t=m.get(),n=C.current;if(!t||!n)return null;const l=g(n,e.clientX,e.clientY);oe.current=l;const a=F(Y.zones,l.x,l.y,e=>T.current.canDrop(t.item,e),e=>!!t.from&&r(t.from,e),e=>T.current.fallThrough?.(t.item,e,t.from)??!0);return a?{h:t,t:a}:null},ge={onDragEnter:e=>{if(he.current)return;const t=n(e.currentTarget.parentElement?.parentElement??null),r=s?l(s.document):null,o=[];t&&o.push(a(t)),r&&s&&o.push(a(r,s.frame)),he.current=o.length?()=>o.forEach(e=>e()):null},onDragOver:e=>{const n=pe(e);if(n)return e.preventDefault(),e.dataTransfer.dropEffect=t(e.dataTransfer.effectAllowed),_(null),void ne(e=>e&&e.key===n.source.key&&e.box===n.source.box?e:n.source);ne(null);const l=me(e);if(!l)return void _(null);e.preventDefault(),e.dataTransfer.dropEffect=t(e.dataTransfer.effectAllowed);const a={zoneKey:l.t.zone.key,line:l.t.line,axis:l.t.zone.axis};_(e=>e&&e.zoneKey===a.zoneKey&&e.line.left===a.line.left&&e.line.top===a.line.top?e:a)},onDragLeave:e=>{const t=e.relatedTarget;t&&e.currentTarget.contains(t)||(oe.current=null,_(null),ne(null))},onDrop:e=>{const t=pe(e);if(t)return e.preventDefault(),m.end(),fe(),void T.current.dropOn.onDrop(t.h.item,t.source);const n=me(e);n&&(e.preventDefault(),m.end(),fe(),T.current.onDrop(n.h.item,n.t.to))}},be={draggable:!b&&!!Z,onMouseEnter:ae,onMouseLeave:()=>!m.get()&&re(),onDragStart:e=>{if(Z&&!b){m.start({key:Z.key,item:Z.item,from:Z.from}),e.dataTransfer.effectAllowed="move";try{e.dataTransfer.setData("text/plain",Z.key)}catch{}}else e.preventDefault()},onDragEnd:()=>{m.end(),fe()},onClick:()=>{Z&&!b&&T.current.onPick?.(Z.item)}},{seams:xe=[]}=Y,ye=Y.zones.filter(e=>0===e.children.length),ve=!o.onZoneAdd||b||se?[]:ye,we=ve.map(e=>e.key).join("\n");return y(()=>{const e=s?.document;if(!e)return;const t=new Set(we?we.split("\n"):[]);for(const n of e.querySelectorAll(`[${G}]`))n.toggleAttribute(U,t.has(n.getAttribute(G)??""));return()=>{for(const t of e.querySelectorAll(`[${U}]`))t.removeAttribute(U)}},[s,we,I,S,$]),/* @__PURE__ */L("div",{ref:C,className:"es-canvas-layer",children:[H||!o.onSeamAdd||b||se?null:xe.map(e=>
5
+ /* @__PURE__ */B(O,{className:"es-canvas-seam",axis:e.axis,index:e.place.index,label:e.label??o.seamLabel??D.addSection,onInsert:()=>o.onSeamAdd?.(e.place),style:"x"===e.axis?{left:e.box.left+e.box.width/2-12,top:e.box.top,width:24,height:e.box.height}:{left:e.box.left,top:e.box.top+e.box.height/2-12,width:e.box.width,height:24}},e.key)),ve.length?ve.map(e=>/* @__PURE__ */B("button",{type:"button",className:["es-canvas-empty",e.addAlways?"is-always":"",V?.zoneKey===e.key?"is-over":""].filter(Boolean).join(" "),style:ee(e.box),"data-node-id":e.list.parentId===i?void 0:e.list.parentId,onClick:()=>o.onZoneAdd?.({...e.list,index:0}),children:/* @__PURE__ */B("span",{className:"es-canvas-empty-add",children:D.addButton({label:e.addLabel??o.zoneAddLabel??D.addBlock})})},e.key)):null,H?/* @__PURE__ */B("div",{className:"es-canvas-catch",...ge}):null,te&&H?/* @__PURE__ */B("div",{className:"es-canvas-target",style:ee(te.box),children:o.dropOn?.label?/* @__PURE__ */B("span",{className:"es-canvas-target-label",style:M(),children:o.dropOn.label(H.item,te)}):null}):null,V&&!ye.some(e=>e.key===V.zoneKey)?/* @__PURE__ */B("div",{className:`es-canvas-line is-${V.axis}`,style:ee(V.line)}):null,ue?/* @__PURE__ */B("span",{className:"es-canvas-hint"+(ue.width<200?" is-below":""),style:{...M(),left:ue.left+ue.width,top:ue.width<200?ue.top+ue.height:ue.top},children:D.typeHint}):null,
6
+ /* @__PURE__ */B("div",{className:"es-canvas-handle-spot",style:Z?{"--es-handle-x":`${Z.box.left+2}px`,"--es-handle-y":`${Math.max(Z.box.top-11,0)}px`}:void 0,children:/* @__PURE__ */B(z,{className:"es-canvas-handle-tip",side:"top",content:!Z||b||H?null:Z.title??D.handle({label:Z.label}),children:/* @__PURE__ */L("div",{className:["es-canvas-handle",Z&&!b?"is-shown":"",H?"is-dragging":""].filter(Boolean).join(" "),...be,children:[
7
+ /* @__PURE__ */B("span",{className:"es-canvas-grip","aria-hidden":"true",children:"⋮⋮"}),Z?.label]})})})]})}var ne=e=>e.tiles.length>0&&e.tiles.every(e=>null!=e.cover);function le({groups:t,session:n,itemFor:l,onInsert:a,onTileMenu:r,at:s,hint:i,searchLabel:c,readOnly:d,words:u=e.add}){const h=i??u.hint,f=c??u.search,[p,m]=v(""),g=D(),b=p.trim().toLowerCase(),x=function(e){const t=/* @__PURE__ */new Map;return e.map(e=>{const n=e.key??e.title,l=t.get(n)??0;return t.set(n,l+1),0===l?n:`${n}\0${l}`})}(t),y=t.map((e,t)=>({...e,key:x[t],tiles:b?e.tiles.filter(e=>((e,t)=>e.label.toLowerCase().includes(t)||(e.keywords??[]).some(e=>e.toLowerCase().includes(t)))(e,b)):e.tiles})).filter(e=>e.tiles.length>0),w=(e,t)=>a=>{if(t)a.preventDefault();else{n.start({key:`new:${e}`,item:l(e)}),a.dataTransfer.effectAllowed="copy";try{a.dataTransfer.setData("text/plain",e)}catch{}}};/* @__PURE__ */
8
+ return L("div",{className:"es-add",children:[s?/* @__PURE__ */L("div",{className:"es-add-at",role:"status",children:[
9
+ /* @__PURE__ */B("span",{children:s.label}),o(u.stop,/* @__PURE__ */B("button",{type:"button",className:"es-add-at-clear","aria-label":u.stop,onClick:s.onClear,children:/* @__PURE__ */B(E,{size:12,"aria-hidden":"true"})}))]}):null,
10
+ /* @__PURE__ */B("p",{className:"es-add-hint",children:h}),
11
+ /* @__PURE__ */B("div",{className:"es-add-find",children:/* @__PURE__ */B(C,{id:g,type:"search","aria-label":f,placeholder:u.searchPlaceholder({label:f}),value:p,onChange:e=>m(e.target.value),leftIcon:/* @__PURE__ */B(j,{size:16,"aria-hidden":"true"}),rightAdornment:p?/* @__PURE__ */B(T,{size:"sm","aria-label":u.clearSearch,onClick:()=>m(""),children:/* @__PURE__ */B(E,{size:12,"aria-hidden":"true"})}):void 0})}),0===y.length?/* @__PURE__ */L("div",{className:"es-add-empty",role:"status",children:[
12
+ /* @__PURE__ */B("div",{className:"es-add-empty-title",children:u.nothing({query:p.trim()})}),
13
+ /* @__PURE__ */B("div",{className:"es-add-empty-sub",children:u.tryAnother})]}):y.map(e=>/* @__PURE__ */L("section",{className:"es-add-group","aria-label":e.title,children:[
14
+ /* @__PURE__ */L("div",{className:"es-add-group-head",children:[
15
+ /* @__PURE__ */B("span",{className:"es-add-group-title",children:e.title}),
16
+ /* @__PURE__ */B(S,{count:e.tiles.length,label:u.count({count:e.tiles.length,sections:ne(e)}),className:"ml-auto"})]}),
17
+ /* @__PURE__ */B("div",{className:ne(e)?"es-add-grid is-cards":"es-add-grid",children:e.tiles.map(e=>{const t=Boolean(d||e.disabled),l=d?void 0:e.disabled?e.disabledReason:e.title??u.tile({label:e.label});return o(l,/* @__PURE__ */L("button",{type:"button",className:null!=e.cover?"es-add-tile has-cover":"es-add-tile",draggable:!t,"aria-disabled":t||void 0,"aria-label":u.tile({label:e.label}),onDragStart:w(e.type,t),onDragEnd:()=>n.end(),onClick:()=>!t&&a?.(e.type),onContextMenu:r?t=>{r(e.type,{x:t.clientX,y:t.clientY,owner:t.currentTarget})&&t.preventDefault()}:void 0,children:[null!=e.cover?/* @__PURE__ */B("span",{className:"es-add-tile-cover","aria-hidden":"true",children:e.cover}):e.icon?/* @__PURE__ */B("span",{className:"es-add-tile-glyph","aria-hidden":"true",children:e.icon}):null,
18
+ /* @__PURE__ */L("span",{className:"es-add-tile-label",children:[e.label,null!=e.mark?/* @__PURE__ */B("span",{className:"es-add-tile-mark","aria-hidden":"true",children:e.mark}):null]})]},e.type))})})]},e.key))]})}export{le as AddPanel,te as CanvasDragLayer,O as CanvasInsert,R as EMPTY_MEASURE,_ as HANDLE_GRACE_MS,F as canvasTarget,I as contains,Y as gapInZone,H as gapLine,P as insertSeams,W as measureCanvas,X as pickSource,Q as seamsBetween,q as sourcesAt};
@@ -0,0 +1 @@
1
+ import{useEaselSession as e}from"./chunk-O7Q4DDJT.js";import{useHostEscape as n}from"./chunk-MQA7OFRA.js";import{DEFAULT_SCREEN_WORDS as t}from"./chunk-EB6NI2VK.js";import{styleMenuItems as o}from"./chunk-V7U33NF2.js";import{ROOT_ZONE as l}from"./chunk-PLVEGYK6.js";import{easelMenuEntries as r,menuLabel as i}from"./chunk-FIVU2COQ.js";import{createNodeClipboard as c,nodeMenuItems as s}from"./chunk-P5VYGWYO.js";import{DEFAULT_NODE_MENU_WORDS as u}from"./chunk-WK3AFPXY.js";import{zoneKey as a,ROOT_SLOT as d,ROOT_ID as p}from"./chunk-K7BTCBWD.js";import{isTypingTarget as f,useCanvasEvent as m,framePointToHost as h}from"./chunk-QIDRJH3S.js";import{useState as y,useCallback as k,useRef as b,useEffect as g}from"react";import{ContextMenu as v}from"efficient-shell/ui";import{UndoIcon as w,RedoIcon as x,PasteIcon as C,SettingsIcon as O,LayersIcon as z,CopyIcon as P}from"efficient-shell/icons/efficient";import{jsx as A}from"react/jsx-runtime";function D(e,n){const t=[],o=/* @__PURE__ */new Set;let r={zone:n.zone,index:n.index};for(;r;){const n=e.nodeAt(r.zone,r.index);if(!n||o.has(n.props.id))break;if(o.add(n.props.id),t.push({zone:r.zone,index:r.index,node:n,parentType:null}),r.zone===l)break;const i=r.zone.lastIndexOf(":");if(i<=0)break;r=e.locate(r.zone.slice(0,i))}for(let e=0;e<t.length-1;e+=1)t[e].parentType=t[e+1].node.type;return t}var K=c(),j=/* @__PURE__ */new WeakMap;function M(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 M(e())}function I(e,n,t){if(n===l){const{floor:n,cap:o}=e.sectionBand();return{parentId:p,slot:d,index:Math.min(Math.max(t,n),o)}}const o=n.lastIndexOf(":");return{parentId:n.slice(0,o),slot:n.slice(o+1),index:t}}function S(e,n,t){const o=e.isPinned(n,t),l=!o&&!e.isLocked(n)&&!e.duplicateBlocked(n),r=e.permits?.(n)??{duplicate:!0,delete:!0};return{copy:!o&&r.duplicate,cut:l&&r.duplicate&&r.delete,delete:l&&r.delete}}function B(e,n,t){const o=e.canPasteAt;if(!o)return a(n.from)===t.zone?I(e,t.zone,t.index+1):null;for(const l of D(e,t)){const t=I(e,l.zone,l.index+1);if(o(n,t))return t}return null}function E(e){if(e.defaultPrevented||e.altKey||e.shiftKey)return null;if(f(e.target))return null;const n=e.target,t=n&&"ownerDocument"in n?n.ownerDocument??n:null,o=t?.getSelection?.();if(o&&!o.isCollapsed&&o.toString().trim())return null;if(!e.metaKey&&!e.ctrlKey)return"Delete"===e.key?"delete":null;const l=e.code||(1===e.key.length?`Key${e.key.toUpperCase()}`:"");return"KeyC"===l?"copy":"KeyX"===l?"cut":"KeyV"===l?"paste":null}function 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=S(e,l,t.zone);if("copy"===n)return c.copy?(e.nodeOps.copy(r,i),{done:"copied",name:i}):null;if(o.readOnly)return null;if("cut"===n)return c.cut?(e.nodeOps.cut(r,i),{done:"cut",name:i}):null;if("delete"===n)return c.delete?(e.nodeOps.remove(r),{done:"deleted",name:i}):null;const s=o.held;if(!s)return null;const u=e.isPinned(l,t.zone)?null:B(e,s,t);return u?(e.nodeOps.paste(u),{done:"pasted",name:s.label}):(e.onPasteRefused(s),{done:"refused",name:s.label})}function V(e,n){const{zone:t,index:r}=n,i=e.nodeAt(t,r);if(!i)return[];const c=i.props.id,u=e.labelOf(i.type,t),a=Boolean(i.props._hidden),d=e.nodeOps,p=e.isPinned(i,t),f=e.isLocked(i),m=!p&&!f&&!e.duplicateBlocked(i),h=e.permits?.(i)??{duplicate:!0,delete:!0},y=S(e,i,t),k=D(e,n),b=d.held,g=b&&!p?B(e,b,n):null,v=!e.readOnly,w=e.style?o({held:v?e.style.held():null,canCopy:e.style.canCopy(i,t),onCopy:()=>e.style?.copy(i,t),onPaste:()=>e.style?.paste(t,r,i),words:e.words?.styleClipboard}):[];return s({title:u,words:e.words?.menu,layer:{group:"pick",items:k.flatMap((n,t)=>{const o={label:e.rowNameOf(n.node,n.zone),checked:0===t,onClick:()=>e.selectAt(n.zone,n.index,n.node.props.id,n.parentType)},r=n.zone===l?null:e.slotRung?.(n.zone)??null;return r?[o,{label:r.label,checked:!1,onClick:r.select}]:[o]})},actions:{duplicate:v&&m&&h.duplicate?()=>d.duplicate(c):void 0,...Y(v&&!p,e=>d.canStep(c,e),e=>d.step(c,e)),copy:y.copy?()=>d.copy(c,u):void 0,cut:v&&y.cut?()=>d.cut(c,u):void 0,paste:v&&b&&g?{label:b.label,run:()=>d.paste(g)}:void 0,rename:v&&e.renamePropOf(i,t)?()=>e.beginRename(t,r):void 0,hide:!v||f||p?void 0:{hidden:a,run:()=>d.setProps(c,{_hidden:!a})},delete:v&&m&&h.delete?()=>d.remove(c):void 0},style:w,extras:e.menuRows?.(i,t,r)??void 0,pinnedLine:p?L(e).pinned:void 0})}function Y(e,n,t){return e?{moveUp:n(-1)?()=>t(-1):null,moveDown:n(1)?()=>t(1):null}:{}}var L=e=>e.words?.screen??t.menu;function X(e){const n=L(e),o=!e.readOnly,r=[];o&&e.history.hasPast&&r.push({label:n.undo,icon:/* @__PURE__ */A(w,{}),shortcut:"⌘Z",onClick:e.history.back}),o&&e.history.hasFuture&&r.push({label:n.redo,icon:/* @__PURE__ */A(x,{}),shortcut:"⇧⌘Z",onClick:e.history.forward});const i=[],c=e.nodeOps.held,s=I(e,l,e.sectionBand().cap);if(o&&c&&(e.canPasteAt?e.canPasteAt(c,s):a(c.from)===l)){const n=s,t=e.words?.menu??u;i.push({label:t.pasteNamed({paste:t.paste,label:c.label}),icon:/* @__PURE__ */A(C,{}),shortcut:"⌘V",onClick:()=>e.nodeOps.paste(n)})}const d=[r,i,[{label:e.pageSettingsLabel??t.pageSettings,icon:/* @__PURE__ */A(O,{}),onClick:e.openPageSettings},{label:n.collapseAll,icon:/* @__PURE__ */A(z,{}),onClick:e.collapseAll}]].filter(e=>e.length>0),p={label:"—",onClick:()=>{}};return d.flatMap((e,n)=>n?[p,...e]:e)}function N(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??u,c=L(e),s=[];l&&(s.push({label:i.copy,icon:/* @__PURE__ */A(P,{}),shortcut:"⌘C",onClick:()=>navigator.clipboard?.writeText(l)}),s.push({label:i.cut,icon:/* @__PURE__ */A(P,{}),shortcut:"⌘X",onClick:()=>{navigator.clipboard?.writeText(l),r("")}})),s.push({label:i.paste,icon:/* @__PURE__ */A(C,{}),shortcut:"⌘V",onClick:()=>{navigator.clipboard?.readText().then(e=>{e&&r(e)}).catch(()=>e.onPasteRefused())}});const a=[s,n.value?[{label:c.selectAll,shortcut:"⌘A",onClick:()=>{n.focus(),n.select()}}]:[]].filter(e=>e.length>0),d={label:"—",onClick:()=>{}};return a.flatMap((e,n)=>n?[d,...e]:e)}function F(e){return e.shiftKey}function U(e,t){const[o,l]=y(null),r=k(()=>l(null),[]);n(null!==o,r);const i=b(e);i.current=e;const c=k(e=>{const n=i.current,t=n.keys;if(!t)return;const o=E(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;g(()=>{if(!s)return;const e=e=>c(e);return s.addEventListener("keydown",e),()=>s.removeEventListener("keydown",e)},[s,c]),m(t,"keydown",c);const u=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]);m(t,"contextmenu",n=>{if(F(n)||!t)return;const o=n.target?.closest?.("[data-puck-component]")??null,r=o?.getAttribute("data-puck-component"),i=r?e.locate(r):null;n.preventDefault();const c=h(t.frame,n.clientX,n.clientY),s=t.frame;l(i?{kind:"node",...c,...i,owner:s}:{kind:"empty",...c,owner:s})}),m(t,"mousedown",r),m(t,"scroll",r,{on:"window"});return{onEditorContextMenu:u,menu:o?/* @__PURE__ */A(Q,{host:e,target:o,onClose:r}):null,closeMenu:r}}function Q({host:e,target:n,onClose:t}){const o="node"===n.kind?V(e,n):"input"===n.kind?N(e,n.el):X(e);return 0===o.length?null:/* @__PURE__ */A(v,{at:{x:n.x,y:n.y},owner:n.owner??null,onClose:t,"aria-label":i(o),items:r(o)})}export{K as EASEL_NODE_CLIPBOARD,D as ancestorChain,M as nodeClipboardOf,S as nodeClipboardRules,V as nodeMenuItems,E as nodeShortcut,X as pageMenuItems,B as pastePlace,R as runNodeShortcut,N as textMenuItems,T as useNodeClipboard,U as useNodeContextMenu};
@@ -1,2 +1,2 @@
1
- import{ScreenPartsProvider as t}from"./chunk-PAOZMXEI.js";import{useEaselHost as e}from"./chunk-MQA7OFRA.js";import{createEasel as r,EaselProvider as o}from"./chunk-EFHV56BO.js";import{useState as n,useEffect as s}from"react";import{jsx as a}from"react/jsx-runtime";function i({config:i,data:c,onChange:m,permissions:p,parts:f,children:u}){const[d]=n(()=>r({config:i,data:c,permissions:p}));s(()=>{d.setConfig(i)},[d,i]),s(()=>{if(!m)return;let t=d.getState().appState.data,e=!1;return d.subscribe(()=>{const r=d.getState().appState.data;r!==t&&(t=r,(e||r!==d.loaded)&&(e=!0,m(r)))})},[d,m]),s(()=>{p&&d.setPermissions(p)},[d,p]);const h=e();/* @__PURE__ */
1
+ import{ScreenPartsProvider as t}from"./chunk-NA3GMA43.js";import{useEaselHost as e}from"./chunk-MQA7OFRA.js";import{createEasel as r,EaselProvider as o}from"./chunk-7L3NKHEC.js";import{useState as n,useEffect as s}from"react";import{jsx as a}from"react/jsx-runtime";function i({config:i,data:c,onChange:m,permissions:p,parts:f,children:u}){const[d]=n(()=>r({config:i,data:c,permissions:p}));s(()=>{d.setConfig(i)},[d,i]),s(()=>{if(!m)return;let t=d.getState().appState.data,e=!1;return d.subscribe(()=>{const r=d.getState().appState.data;r!==t&&(t=r,(e||r!==d.loaded)&&(e=!0,m(r)))})},[d,m]),s(()=>{p&&d.setPermissions(p)},[d,p]);const h=e();/* @__PURE__ */
2
2
  return a(o,{easel:d,hotkeys:h.ownsDocument,children:/* @__PURE__ */a(t,{parts:f,children:u})})}export{i as ScreenStoreProvider};
@@ -1,15 +1,15 @@
1
- import{DEFAULT_CANVAS_WORDS as e}from"./chunk-TBY3DFKS.js";import{useResolvedFields as t}from"./chunk-IWCKVZHS.js";import{toItemSelector as n,fromItemSelector as o,useNodeOps as r,parentStep as i,clickPickPart as l,clickPick as s}from"./chunk-BSHIQIZC.js";import{selectionBox as a,placeWindow as c,offsetOrigin as d,colorRunOf as u,ColorWindow as p,startCanvasTyping as f,textMap as h}from"./chunk-23VM4PMV.js";import{DEFAULT_COPY_WORDS as m}from"./chunk-KRL3IUV3.js";import{useWords as g}from"./chunk-MFIRYGHW.js";import{find as v,ROOT_ID as y,getList as w,remove as b,parseZoneKey as k,move as S,duplicate as C,replaceNode as I,createNode as D,insert as E,normalizeData as x,createResolveCache as O,resolveNodeData as A,ROOT_SLOT as M}from"./chunk-K7BTCBWD.js";import{topLevelSlotKeys as z,fieldsFrom as R,drawnBlockCount as V,defaultsFrom as B}from"./chunk-L55YIXDC.js";import{setCanvasNonce as L,CANVAS_TYPABLE_EVENT as P,isTypingTarget as $,frameRectToHost as j,CANVAS_TYPING_EVENT as N,drawnBox as K}from"./chunk-QIDRJH3S.js";import{queryAllCopies as Z}from"./chunk-LF3FUSCQ.js";import{createContext as F,useEffect as H,useContext as T,useRef as W,useSyncExternalStore as Y,useState as q,useMemo as U,useCallback as Q,useLayoutEffect as X}from"react";import{jsx as G,jsxs as J,Fragment as _}from"react/jsx-runtime";import{createPortal as ee}from"react-dom";import{registerModalEscapeInterceptor as te,FloatingBar as ne,TextToolbar as oe,LinkPicker as re}from"efficient-shell/ui";function ie(e){return!["setData","setUi","set"].includes(e.type)}var le=(e,t,n,o)=>{const r=w(e,t,k(n));return r?.[o]??null},se=(e,t,n,o,r)=>{const i=le(e,t,n,o);if(!i)throw new Error(`${r}: nothing at ${n}[${o}]`);return i};function ae(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 ce(e,t,n){return n?"node"===n.kind?v(e,t,n.id)?n:null:n.parentId===y?w(e,t,n)?n:null:v(e,t,n.parentId)&&w(e,t,n)?n:null:null}function de(e,t,n,r=!1){const{itemSelector:i,selectedSlot:l,...s}=n;let a=e.selection;var c;return"itemSelector"in n&&(a=o(e.data,t,i??null)),"selectedSlot"in n&&(l?a=(c=l)?{kind:"slot",parentId:c.parentId,slot:c.slot}:null:"slot"===a?.kind&&(a=null)),{...e,selection:a,ui:r?s:{...e.ui,...s}}}function ue(e,t,n){const o=pe(e,t,n);if(o===e)return e;const r=ce(o.data,n,o.selection);return r===o.selection?o:{...o,selection:r}}function pe(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 de(e,n,"function"==typeof t.ui?t.ui(ae(e,n)):t.ui);case"set":{const r={data:o,ui:ae(e,n)},i="function"==typeof t.state?t.state(r):t.state;let l=i.data?{...e,data:i.data}:e;return i.ui&&(l=de(l,n,i.ui,!0)),l}case"insert":{const r={...k(t.destinationZone),index:t.destinationIndex},i=D(n,t.componentType,{},t.id?{id:t.id}:{});return{...e,data:E(o,n,r,i)}}case"replace":{const r=se(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:I(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=se(o,n,t.sourceZone,t.sourceIndex,"duplicate"),i=C(o,n,r.props.id),l=le(i,n,t.sourceZone,t.sourceIndex+1);return{...e,data:i,selection:l?{kind:"node",id:l.props.id}:e.selection}}case"reorder":return pe(e,{...t,type:"move",sourceZone:t.destinationZone},n);case"move":{if(t.sourceZone===t.destinationZone&&t.sourceIndex===t.destinationIndex)return e;const r=le(o,n,t.sourceZone,t.sourceIndex);if(!r)return e;const i={...k(t.destinationZone),index:t.destinationIndex};return{...e,data:S(o,n,r.props.id,i)}}case"remove":{const r=se(o,n,t.zone,t.index,"remove");return{...e,data:b(o,n,r.props.id)}}default:return e}}var fe={drag:!0,duplicate:!0,delete:!0,edit:!0,insert:!0},he={leftSideBarVisible:!0,rightSideBarVisible:!0,arrayState:{},componentList:{},isDragging:!1,previewMode:"edit",viewports:{current:{width:360,height:"auto"},options:[],controlsVisible:!0},field:{focus:null}},me=0,ge=()=>`history-${me+=1}`;function ve(e){let t=e.config;const r=e.now??(()=>Date.now()),i=e.historyCoalesceMs??250;let l=e.permissions??{};const s=x(e.data,t);let a=s,c={data:s,selection:null,ui:{...he}};if(e.ui){const{itemSelector:n,selectedSlot:r,...i}=e.ui;c={data:s,selection:r?{kind:"slot",...r}:o(s,t,n??null),ui:{...he,...i}}}let d=[{core:c,at:-1/0,sealed:!0,id:ge()}],u=0;const p=e=>{const t=d[u],n=r();!e&&u===d.length-1&&u>0&&!t.sealed&&n-t.at<i?d=[...d.slice(0,u),{...t,core:c,at:n}]:(d=[...d.slice(0,u+1),{core:c,at:n,sealed:e,id:ge()}],u=d.length-1)},f=/* @__PURE__ */new Set;let h=null,m=null,g=0,y=null,b=!1;const k=()=>{for(const e of[...f])e()},S=()=>{d=[...d.slice(0,u),{...d[u],core:c},...d.slice(u+1)]},C=(t,n)=>{g>0?b=b||n:(n?p(!1):c!==t&&S(),c.data!==t.data&&e.onChange?.(c.data),c!==t&&k())},D=e=>{const n=c;if(c=ue(c,e,t),c===n)return;const o=e.recordHistory??ie(e);C(n,o&&c.data!==n.data)},E=t=>{0===g&&(y=c,b=!1),g+=1;try{t()}catch(e){throw g-=1,0===g&&y&&(c=y,y=null),e}if(g-=1,g>0||!y)return;const n=y;y=null,b&&c.data!==n.data?p(!0):c!==n&&S(),c.data!==n.data&&e.onChange?.(c.data),c!==n&&k()},M=e=>{const n=c,o=ce(c.data,t,e);var r,i;(r=o,i=c.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))||(c={...c,selection:o},C(n,!1))},z=t=>{const n=c;u=t,c=d[u].core,c.data!==n.data&&e.onChange?.(c.data),c!==n&&k()},R=()=>(e={})=>{const n=e.root?t.root?.permissions:t.components[e.item?.type??e.type??""]?.permissions;return{...fe,...l,...n}};let V=R();const B=O(),L={resolveCache:B,async resolveAll({trigger:e="load",metadata:n}={}){const o=c.data,r={type:"root",props:{...o.root.props??{}}},i=[...o.content,...Object.values(o.zones??{}).flat()],[l,...s]=await Promise.all([A(r,t,{cache:B,trigger:e,metadata:n}),...i.map(o=>A(o,t,{cache:B,trigger:e,metadata:n}))]);E(()=>{const n=c;let r=c.data;s.forEach((e,n)=>{if(!e.didChange)return;const l=i[n].props.id,s=v(r,t,l)?.node;s&&s===v(o,t,l)?.node&&(r=I(r,t,l,e.node))}),l.didChange&&r.root===o.root&&(r={...r,root:{...r.root,props:l.node.props,readOnly:l.node.readOnly??r.root.readOnly}}),r!==c.data&&("load"===e&&c.data===a&&(a=r),c={...c,data:r,selection:ce(r,t,c.selection)},C(n,!1))})},async resolveNode(e,{trigger:n="replace",metadata:o}={}){const r=v(c.data,t,e)?.node;if(!r)return!1;const i=await A(r,t,{cache:B,trigger:n,metadata:o});if(!i.didChange)return!1;let l=!1;return E(()=>{const n=c;if(v(c.data,t,e)?.node!==r)return;const o=I(c.data,t,e,i.node);o!==c.data&&(c={...c,data:o,selection:ce(o,t,c.selection)},C(n,!1),l=!0)}),l},get config(){return t},get loaded(){return a},getState(){if(h&&m===c)return h;const e=c,o={data:e.data,ui:ae(e,t)},r="node"===e.selection?.kind?v(e.data,t,e.selection.id)?.node??null:null;return h={appState:o,selection:e.selection,selectedItem:r,config:t,dispatch:D,history:{back:()=>L.undo(),forward:()=>L.redo(),hasPast:u>0,hasFuture:u<d.length-1,histories:d.map(e=>({id:e.id,state:{data:e.core.data,ui:ae(e.core,t)}})),index:u,setHistoryIndex:e=>{e>=0&&e<d.length&&e!==u&&z(e)}},getPermissions:V,getItemById:n=>v(e.data,t,n)?.node,getItemBySelector:n=>function(e,t,n){const[o,r]=(n.zone??"root:default-zone").split(/:(.*)/s);return w(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,h},subscribe:e=>(f.add(e),()=>{f.delete(e)}),dispatch:D,batch:E,group:()=>{const e=u,t=d[e].id;let n=!0;return{close:()=>{if(!n)return;if(n=!1,d[e]?.id!==t)return;if(u<=e+1)return void(u===e+1&&(d=[...d.slice(0,u),{...d[u],sealed:!0},...d.slice(u+1)]));const o=d[u];d=[...d.slice(0,e+1),{...o,sealed:!0},...d.slice(u+1)],u=e+1}}},select:e=>M(e?{kind:"node",id:e}:null),selectSlot:e=>M(e?{kind:"slot",parentId:e.parentId,slot:e.slot}:null),run(e){E(()=>{const n=c,o=void 0===e.select?c.selection:e.select;c={...c,data:e.data,selection:ce(e.data,t,o)},C(n,e.data!==n.data)})},load(e,n={}){const o=c,r=x(e,t);c={...c,data:r,selection:ce(r,t,n.selection??c.selection)},a=r,n.keepHistory||(d=[{core:c,at:-1/0,sealed:!0,id:ge()}],u=0),c!==o&&k()},undo(){u>0&&z(u-1)},redo(){u<d.length-1&&z(u+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,l)||(l=e,V=R(),h=null,k())},setConfig(e){e!==t&&(t=e,V=R(),h=null,k())}};return L}function ye(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&&$(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 we=F(null),be=F(!0);function ke({easel:e,hotkeys:t=!0,resolveOnMount:n=!0,children:o}){return H(()=>{n&&e.resolveAll()},[e,n]),H(()=>{if(t&&"undefined"!=typeof document)return ye(document,e)},[e,t]),/* @__PURE__ */G(we.Provider,{value:e,children:/* @__PURE__ */G(be.Provider,{value:t,children:o})})}function Se(){const e=T(we);if(!e)throw new Error("useEasel: no <EaselProvider> above this component");return e}function Ce(e){const t=Se(),n=W({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 Y(t.subscribe,o,o)}function Ie(){return function(e){return Ce(e)}}var De="data-puck-component",Ee="data-puck-dropzone",xe={},Oe="data-es-mirror",Ae="undefined"==typeof window?H:X;function Me(e,t,n){for(const e of Array.from(t.head.querySelectorAll(`[${Oe}]`)))e.remove();for(const o of Array.from(e.head.querySelectorAll('style, link[rel="stylesheet"]'))){const e=o.cloneNode(!0);e.setAttribute(Oe,""),n&&e.setAttribute("nonce",n),t.head.appendChild(e)}}function ze({children:t,id:n="preview-frame",title:o,className:r,style:i,mirrorStyles:l=!0,onDocument:s,height:a="auto",nonce:c}){const d=g("canvas",e),u=W(null),[p,f]=q(null);return Ae(()=>{const e=u.current,t=p?.ownerDocument.defaultView;if("auto"!==a||!e||!p||!t)return;const n=()=>{e.style.height=`${Math.ceil(p.getBoundingClientRect().height)}px`};n();const o=t.ResizeObserver,r=o?new o(n):null;return r?.observe(p),()=>r?.disconnect()},[p,a]),Ae(()=>{let e=u.current?.contentDocument;if(!e)return;"CSS1Compat"!==e.compatMode&&(e.open(),e.write("<!DOCTYPE html><html><head></head><body></body></html>"),e.close(),e=u.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"===a&&t.classList.add("es-frame-fill"),e.body.appendChild(t),L(e,c),f(t),s?.(e);let n=null;const o=u.current?.ownerDocument;if(l&&o){Me(o,e,c);const t=o.defaultView;t&&"MutationObserver"in t&&(n=new t.MutationObserver(()=>Me(o,e,c)),n.observe(o.head,{childList:!0,subtree:!0,characterData:!0}))}return()=>{n?.disconnect(),t.remove(),f(null),s?.(null)}},[]),/* @__PURE__ */G("iframe",{ref:u,id:n,title:o??d.frame,className:["es-canvas-frame","fill"===a?"is-fill":"",r??""].filter(Boolean).join(" "),style:i,children:p?ee(t,p):null})}var Re=F(null),Ve=F(xe),Be=[];function Le({parentId:e,slot:t,className:n,style:o,minEmptyHeight:r=128,minEmptyWidth:i=120}){const l=Se(),s=Ce(n=>w(n.appState.data,l.config,{parentId:e,slot:t})??Be),a=Ce(t=>"node"===t.selection?.kind&&t.selection.id===e&&e!==y),c=Ce(n=>"slot"===n.selection?.kind&&n.selection.parentId===e&&n.selection.slot===t),d=T(Re),u=["es-zone"];return s.length&&u.push("has-children"),e===y&&u.push("is-root"),(a||c)&&u.push("is-area-selected"),null!==d&&d===e&&e!==y&&u.push("is-hovering-area"),n&&u.push(n),/* @__PURE__ */G("div",{className:u.join(" "),[Ee]:`${e}:${t}`,style:{...o,"--min-empty-height":`${r}px`,"--min-empty-width":`${i}px`},children:s.map(e=>/* @__PURE__ */G(He,{node:e},e.props.id))})}function Pe(e,t,n,o){const r=U(()=>{const n={};for(const o of z(R(e)))n[o]=Object.assign(function(e={}){/* @__PURE__ */
2
- return G(Le,{parentId:t,slot:o,...e})},{blockCount:0});return n},[e,t]);for(const e of Object.keys(r))r[e].blockCount=V(n[e],o);return r}function $e(e){return U(()=>function({zone:t,...n}){/* @__PURE__ */
3
- return G(Le,{parentId:e,slot:t,...n})},[e])}var je=["top","bottom","zIndex"];function Ne(e,t,n){e.style[t]!==n&&(e.style[t]=n)}function Ke(e){const t=function(e){const t=e?.ownerDocument.defaultView?.getComputedStyle(e);if(!t||"sticky"!==t.position)return null;const n=e=>"auto"===e?"":e;return{top:n(t.top),bottom:n(t.bottom),zIndex:n(t.zIndex)}}(function(e){const t=e.ownerDocument.defaultView;let n=null;for(const o of Array.from(e.children))if("none"!==t?.getComputedStyle(o).display){if(n)return null;n=o}return n}(e));Ne(e,"position",t?"sticky":"relative");for(const n of je)Ne(e,n,t?.[n]??"");return!!t}var Ze="data-es-canvas-relative";function Fe(e){e.hasAttribute(Ze)&&("relative"===e.style.position&&(e.style.position=""),e.removeAttribute(Ze));const t=e.ownerDocument.defaultView?.getComputedStyle(e).position;return t&&"static"!==t?"sticky"===t:(e.style.position||(e.style.position="relative",e.setAttribute(Ze,"")),!1)}function He({node:e}){const t=Se().config,n=t.components[e.type],o=e.props.id,r=W(null),i=function(e,t){return U(()=>n=>{const o=t.current;o&&o!==n&&(o.removeAttribute(De),o.removeAttribute("data-puck-dnd")),t.current=n,n&&(n.setAttribute(De,e),n.setAttribute("data-puck-dnd",e),Fe(n))},[e,t])}(o,r),l=W(null),s=!!n?.inline;!function(e,t){const n=W(!1),o=W(()=>{});o.current=()=>{const o=e(),i=n.current;n.current=!!o&&t(o),i!==n.current&&r.current()};const r=W(()=>{});Ae(()=>o.current()),Ae(()=>{const t=e(),i=t?.ownerDocument.defaultView;if(!t||!i)return;const l=()=>o.current();i.addEventListener("resize",l);const s=i.ResizeObserver,a=s?new s(l):null;a?.observe(t);let c=null;return r.current=()=>{c?.disconnect(),c=null;const e=t.ownerDocument.documentElement;n.current&&e&&i.MutationObserver&&(c=new i.MutationObserver(l),c.observe(e,{attributes:!0}))},r.current(),()=>{i.removeEventListener("resize",l),a?.disconnect(),c?.disconnect(),r.current=()=>{}}},[])}(()=>s?r.current:l.current,e=>s?Fe(e):Ke(e));const a=T(Ve),c=Pe(n,o,e.props,t.components),d=$e(o);if(!n?.render)return null;const u=n.render,p={...B(n),...e.props,...c},f={renderDropZone:d,isEditing:!0,dragRef:n.inline?i:null,metadata:{...a,...n.metadata}};return n.inline?/* @__PURE__ */G(u,{...p,puck:f,editMode:!0}):
4
- /* @__PURE__ */G("div",{ref:l,[De]:o,"data-puck-dnd":o,style:{position:"relative"},children:/* @__PURE__ */G(u,{...p,puck:f,editMode:!0})})}function Te({metadata:e}){const t=Ce(e=>e.config),n=Ce(e=>e.appState.data.root).props??{},o=t.root?.render,r=Pe(t.root,y,n,t.components),i=$e(y),l=/* @__PURE__ */G(Le,{parentId:y,slot:M}),s=o?/* @__PURE__ */G(o,{id:"puck-root",...n,...r,puck:{renderDropZone:i,isEditing:!0,dragRef:null,metadata:e??{}},editMode:!0,children:l}):l;/* @__PURE__ */
5
- return G(Ve.Provider,{value:e??xe,children:s})}var We=F(void 0),Ye=F(void 0),qe=F(void 0);function Ue({element:e}){const t=W(null),n=Qe(t,e?()=>e:null,e);/* @__PURE__ */
6
- return G("div",{ref:t,"aria-hidden":"true",className:"es-canvas-outline is-hover is-hover-part",style:n?{position:"absolute",top:n.top,left:n.left,width:n.width,height:n.height}:{display:"none"}})}function Qe(e,t,n){return Ge(e,t?e=>{const n=t(e);return n?[n]:[]}:null,n)[0]??null}var Xe=[];function Ge(e,t,n){const[o,r]=q(Xe),i=W(t);return i.current=t,Ae(()=>{const t=e.current?.ownerDocument,n=t?.defaultView;if(!t||!n||!i.current)return void r(Xe);let o=0;const l=()=>{o=0;const n=e.current?.parentElement??null,l=(i.current?i.current(t):[]).map(e=>function(e,t){if(!e||!t)return null;const n=K(e),o=t.getBoundingClientRect();return{top:n.top-o.top,left:n.left-o.left,width:n.width,height:n.height}}(e,n)).filter(e=>null!==e);r(e=>{return(t=e)===(n=l)||t.length===n.length&&t.every((e,t)=>function(e,t){return e===t||!!e&&!!t&&e.top===t.top&&e.left===t.left&&e.width===t.width&&e.height===t.height}(e,n[t]))?e:l.length?l:Xe;var t,n})},s=()=>{o||(o=(n.requestAnimationFrame??(e=>n.setTimeout(e,16)))(l))};l();const a="MutationObserver"in n?new n.MutationObserver(s):null;a?.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),()=>{a?.disconnect(),c?.disconnect(),n.removeEventListener("resize",s),o&&(n.cancelAnimationFrame??n.clearTimeout)(o)}},[n]),o}function Je({id:e,kind:t,overlay:n}){const o=W(null),r=T(Ye),i=null!==e&&!0===r?.(e),l=Ge(o,e?t=>Z(t,`[${De}="${t.defaultView?.CSS?.escape?t.defaultView.CSS.escape(e):e}"]`):null,e),[s,...a]=l,c=`es-canvas-outline is-${t}${i?" is-shared":""}`,d=e=>({position:"absolute",top:e.top,left:e.left,width:e.width,height:e.height}),u=/* @__PURE__ */J(_,{children:[
7
- /* @__PURE__ */G("div",{ref:o,"aria-hidden":"true",className:c,style:s?d(s):{display:"none"}}),a.map((e,t)=>/* @__PURE__ */G("div",{"aria-hidden":"true",className:c,style:d(e)},t))]});return n&&e?/* @__PURE__ */G(n,{componentId:e,kind:t,children:u}):u}function _e(e,t,n){const o=h(e,n),r=o.text.length,i=e.ownerDocument;if(!t)return[r,r];let l=null;const s=i.caretPositionFromPoint?.(t.x,t.y);if(s&&e.contains(s.offsetNode))l=o.at(s.offsetNode,s.offset);else{const n=i.caretRangeFromPoint?.(t.x,t.y);n&&e.contains(n.startContainer)&&(l=o.at(n.startContainer,n.startOffset))}if(null===l)return[r,r];const a=o.text;let c=l,d=l;for(;c>0&&!/\s/.test(a[c-1]);)c-=1;for(;d<a.length&&!/\s/.test(a[d]);)d+=1;return[c,d]}function et({s:e,element:t,toolbar:n,label:o,keys:r}){const i=g("copy",m),l=e.pressed(),s=new Set(n.offered),f=n.colors&&n.colors.length>0?n.colors:null,h=W(null),[v,y]=q(!1),[w,b]=q(null),k=v||null!==w,S=()=>{e.hold(),y(!1),b({href:e.pressed().href})},C=()=>{y(!1),b(null),e.resume()};X(()=>{r.current={escape:()=>!!k&&(C(),!0),link:()=>!!s.has("link")&&(S(),!0)}}),X(()=>()=>{r.current=null},[r]);const I=W(C);I.current=C,H(()=>{if(v)return te(e=>{const t=h.current;return!!("Escape"===e.key&&t&&e.target instanceof Node&&t.contains(e.target))&&(I.current(),!0)},()=>h.current?.querySelector(".es-copy-colors"))},[v]),H(()=>{const n=h.current;if(!k||!n)return;const o=/* @__PURE__ */new Set([n.ownerDocument]),r=t();r&&o.add(r.ownerDocument);const i=o=>{const r=o.target;if(r&&n.contains(r))return;y(!1),b(null);const i=t();r&&i&&i.contains(r)?e.release():e.stop("outside")};for(const e of o)e.addEventListener("pointerdown",i,!0);return()=>{for(const e of o)e.removeEventListener("pointerdown",i,!0)}},[k,e,t]),X(()=>{const e=h.current,n=e?.querySelector(".rosh-tb-wrap > .es-copy-pop"),o=t();if(!(k&&e&&n&&o))return;const r=o.ownerDocument.defaultView?.getSelection()??null,i=r&&r.rangeCount>0&&o.contains(r.getRangeAt(0).startContainer)?r.getRangeAt(0):null,l=(i?a(i,o):null)??(()=>{const e=o.getBoundingClientRect();return{left:e.left,top:e.top,right:e.right,bottom:e.bottom}})(),s=o.ownerDocument.defaultView?.frameElement,u=s?j(s,{left:l.left,top:l.top,width:l.right-l.left,height:l.bottom-l.top}):{left:l.left,top:l.top,width:l.right-l.left,height:l.bottom-l.top},p=o.getBoundingClientRect(),f=s?j(s,{left:p.left,top:p.top,width:p.width,height:p.height}):{left:p.left,top:p.top,width:p.width,height:p.height},m=(e.closest("[data-floating-bar]")??e).getBoundingClientRect(),g={left:u.left,right:u.left+u.width,top:Math.min(u.top,f.top-6,m.top),bottom:Math.max(u.top+u.height,f.top+f.height+6,m.bottom)},v=e.ownerDocument.documentElement,y=(s??o.closest(".es-canvas")??o).getBoundingClientRect(),w={left:Math.max(0,y.left),top:Math.max(0,y.top),right:Math.min(v.clientWidth||y.right,y.right),bottom:Math.min(v.clientHeight||y.bottom,y.bottom)};if(w.right<=w.left||w.bottom<=w.top||0===n.offsetWidth)return;const b=c({anchor:g,size:{width:n.offsetWidth,height:n.offsetHeight},within:{left:y.left,top:y.top,right:y.right,bottom:y.bottom},clip:w,parent:d(n)});n.style.top=`${b.top}px`,n.style.left=`${b.left}px`,n.style.setProperty("--es-pop-point",`${b.point}px`),n.dataset.side=b.above?"above":"below"});const D=f?{run:u(l.color,f),open:v,onToggle:()=>{b(null),v?C():(e.hold(),y(!0))}}:void 0;/* @__PURE__ */
8
- return G(ne,{anchor:()=>{const e=t();if(!e)return null;const n=e.getBoundingClientRect(),o=e.ownerDocument.defaultView?.frameElement,r=o?j(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__ */G("div",{ref:h,children:/* @__PURE__ */G(oe,{layout:"row",offered:s,pressed:l.marks,onMark:t=>{"link"===t?S():e.press(t)},color:D,linkOpen:null!==w,list:{pressed:l.list,onList:t=>e.list(t)},alignment:n.alignment,letterCase:n.letterCase,last:n.lastTool?.({className:"rosh-tb-btn",disabled:!1,selected:l.selected,keepCaret:t=>{t.preventDefault(),e.hold()},insert:t=>e.insert(t)}),windows:/* @__PURE__ */J(_,{children:[v&&f?/* @__PURE__ */G(p,{colors:f,current:l.color,words:i.colors??m.colors,onPick:t=>e.color(t)}):null,w?
9
- /* @__PURE__ */G(re,{className:"es-copy-link es-copy-pop",value:w.href??"",onApply:t=>{b(null),e.link(t)},onRemove:null!==w.href?()=>{b(null),e.link(null)}:void 0,onCancel:C}):null]})})})})}function tt({element:e}){const t=W(null),n=Qe(t,()=>e(),e);/* @__PURE__ */
10
- return G("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 nt({frame:t=!0,className:n,style:o,metadata:r,mirrorStyles:a,onDocument:c,height:d,title:u,nonce:p,hotkeys:h,frameWrapper:m,overlay:v,children:y,typing:w,passThrough:b}){const k=Se(),S=T(We),C=b??S,I=T(be),D=g("canvas",e),E=h??I,[x,O]=q(void 0),A=Ce(e=>"node"===e.selection?.kind?e.selection.id:null),[M,z]=q(null),[R,V]=q(null),B=T(qe),[L,$]=q(null),j=W(null),[,K]=q(0),Z=W(w);Z.current=w;const F=W(null),Y=W(null),U=Ce(e=>e.appState.data);H(()=>{const e=Y.current?.ownerDocument,t=e?.defaultView?.CustomEvent;if(!e||!t)return;const n=A&&!L&&Z.current?.atSelection?.()?A:null;e.dispatchEvent(new t(P,{detail:{id:n}}))},[A,L,U]);const Q=e=>{const t=Y.current?.ownerDocument,n=t?.defaultView?.CustomEvent;t&&n&&t.dispatchEvent(new n(N,{detail:{typing:e}}))},X=(e,t)=>{j.current?.s.stop("stop");const n=e.element();if(!n)return!1;const o=k.group(),r=e.element,i=f({element:r,value:e.value,rules:e.rules,multiline:e.multiline,skip:e.skip,caret:_e(n,t,e.skip),write:e.write,remount:e.remount,onSelect:()=>K(e=>e+1),onEscape:()=>F.current?.escape()??!1,onLinkKey:()=>F.current?.link()??!1,end:e=>{o.close(),j.current?.element===r&&(j.current=null),$(null),Q(!1),Z.current?.onChange?.({typing:!1,why:e})}});if(!i)return o.close(),!1;const l=n.closest?.(`[${De}]`)?.getAttribute(De);return l&&k.select(l),j.current={s:i,element:r,target:e},$(()=>r),z(null),Q(!0),Z.current?.onChange?.({typing:!0,element:n}),!0};H(()=>()=>j.current?.s.stop("stop"),[]);const _=e=>{const t=j.current?.element();return Boolean(t&&t.contains(e))},ee=e=>{const t=e.closest?.(`[${De}]`)?.getAttribute(De);if(!t)return;const n=k.getState(),o="node"===n.selection?.kind?n.selection.id:null,r=B?.partAt(e,t)??null;if(r){const e=l(n.appState.data,k.config,t,r.id,o,B?.selected()??null,C);if(e)return{node:e.node,part:e.part?r:null}}return{node:s(n.appState.data,k.config,t,o,C)??t,part:null}},te=e=>{if("Enter"!==e.key||e.defaultPrevented||e.shiftKey||e.metaKey||e.ctrlKey||e.altKey)return;if(j.current)return;const t=e.target;if(t?.isContentEditable||t?.closest?.("input, textarea, select, button"))return;const n=Z.current?.atSelection?.();n&&X(n,null)&&e.preventDefault()},ne=/* @__PURE__ */J("div",{ref:Y,className:"es-canvas-content",style:{position:"relative"},onClick:e=>{const t=e.target;if(t.closest?.("a[href]")&&e.preventDefault(),j.current){if(_(t))return;j.current.s.stop("outside")}const n=t.ownerDocument?.getSelection?.();n&&n.rangeCount>0&&n.isCollapsed&&n.removeAllRanges();const o=ee(t);if(void 0!==o)return k.select(o.node),void(B&&(o.part?.id??null)!==B.selected()&&B.select(o.part?.id??null));t.hasAttribute?.(Ee)||(k.select(null),B?.selected()&&B.select(null))},onDoubleClick:e=>{const t=Z.current;if(!t||_(e.target))return;const n=t.at(e.target);n&&X(n,{x:e.clientX,y:e.clientY})&&e.preventDefault()},onKeyDown:e=>te(e),onMouseOver:e=>{if(j.current)return;const t=ee(e.target),n=t?.part&&t.part.id!==B?.selected()?t.part.element:null,o=t&&!t.part?t.node:null;o!==M&&z(o),n!==R&&V(n)},onMouseLeave:()=>{z(null),V(null)},children:[
11
- /* @__PURE__ */G(Re.Provider,{value:M,children:/* @__PURE__ */G(Te,{metadata:r})}),
1
+ import{DEFAULT_CANVAS_WORDS as e}from"./chunk-TBY3DFKS.js";import{useResolvedFields as t}from"./chunk-IWCKVZHS.js";import{toItemSelector as n,fromItemSelector as o,useNodeOps as r,parentStep as i,clickPickPart as l,clickPick as s}from"./chunk-BSHIQIZC.js";import{selectionBox as a,placeWindow as c,offsetOrigin as d,colorRunOf as u,ColorWindow as p,startCanvasTyping as f,textMap as h}from"./chunk-MZ5GSSZ3.js";import{DEFAULT_COPY_WORDS as m}from"./chunk-KRL3IUV3.js";import{useWords as g}from"./chunk-MFIRYGHW.js";import{find as v,ROOT_ID as y,getList as w,remove as b,parseZoneKey as k,move as S,duplicate as C,replaceNode as I,createNode as D,insert as E,normalizeData as x,createResolveCache as O,resolveNodeData as A,ROOT_SLOT as M}from"./chunk-K7BTCBWD.js";import{topLevelSlotKeys as z,fieldsFrom as R,drawnBlockCount as B,defaultsFrom as L}from"./chunk-L55YIXDC.js";import{setCanvasNonce as V,CANVAS_TYPABLE_EVENT as $,isTypingTarget as j,frameRectToHost as N,CANVAS_TYPING_EVENT as P,drawnBox as Z}from"./chunk-QIDRJH3S.js";import{queryAllCopies as K}from"./chunk-LF3FUSCQ.js";import{createContext as F,useEffect as H,useContext as T,useRef as W,useSyncExternalStore as Y,useState as q,useMemo as U,useCallback as Q,useLayoutEffect as G}from"react";import{jsx as X,jsxs as J,Fragment as _}from"react/jsx-runtime";import{createPortal as ee}from"react-dom";import{registerModalEscapeInterceptor as te,FloatingBar as ne,TextToolbar as oe,LinkPicker as re}from"efficient-shell/ui";function ie(e){return!["setData","setUi","set"].includes(e.type)}var le=(e,t,n,o)=>{const r=w(e,t,k(n));return r?.[o]??null},se=(e,t,n,o,r)=>{const i=le(e,t,n,o);if(!i)throw new Error(`${r}: nothing at ${n}[${o}]`);return i};function ae(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 ce(e,t,n){return n?"node"===n.kind?v(e,t,n.id)?n:null:n.parentId===y?w(e,t,n)?n:null:v(e,t,n.parentId)&&w(e,t,n)?n:null:null}function de(e,t,n,r=!1){const{itemSelector:i,selectedSlot:l,...s}=n;let a=e.selection;var c;return"itemSelector"in n&&(a=o(e.data,t,i??null)),"selectedSlot"in n&&(l?a=(c=l)?{kind:"slot",parentId:c.parentId,slot:c.slot}:null:"slot"===a?.kind&&(a=null)),{...e,selection:a,ui:r?s:{...e.ui,...s}}}function ue(e,t,n){const o=pe(e,t,n);if(o===e)return e;const r=ce(o.data,n,o.selection);return r===o.selection?o:{...o,selection:r}}function pe(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 de(e,n,"function"==typeof t.ui?t.ui(ae(e,n)):t.ui);case"set":{const r={data:o,ui:ae(e,n)},i="function"==typeof t.state?t.state(r):t.state;let l=i.data?{...e,data:i.data}:e;return i.ui&&(l=de(l,n,i.ui,!0)),l}case"insert":{const r={...k(t.destinationZone),index:t.destinationIndex},i=D(n,t.componentType,{},t.id?{id:t.id}:{});return{...e,data:E(o,n,r,i)}}case"replace":{const r=se(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:I(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=se(o,n,t.sourceZone,t.sourceIndex,"duplicate"),i=C(o,n,r.props.id),l=le(i,n,t.sourceZone,t.sourceIndex+1);return{...e,data:i,selection:l?{kind:"node",id:l.props.id}:e.selection}}case"reorder":return pe(e,{...t,type:"move",sourceZone:t.destinationZone},n);case"move":{if(t.sourceZone===t.destinationZone&&t.sourceIndex===t.destinationIndex)return e;const r=le(o,n,t.sourceZone,t.sourceIndex);if(!r)return e;const i={...k(t.destinationZone),index:t.destinationIndex};return{...e,data:S(o,n,r.props.id,i)}}case"remove":{const r=se(o,n,t.zone,t.index,"remove");return{...e,data:b(o,n,r.props.id)}}default:return e}}var fe={drag:!0,duplicate:!0,delete:!0,edit:!0,insert:!0},he={leftSideBarVisible:!0,rightSideBarVisible:!0,arrayState:{},componentList:{},isDragging:!1,previewMode:"edit",viewports:{current:{width:360,height:"auto"},options:[],controlsVisible:!0},field:{focus:null}},me=0,ge=()=>`history-${me+=1}`;function ve(e){let t=e.config;const r=e.now??(()=>Date.now()),i=e.historyCoalesceMs??250;let l=e.permissions??{};const s=x(e.data,t);let a=s,c={data:s,selection:null,ui:{...he}};if(e.ui){const{itemSelector:n,selectedSlot:r,...i}=e.ui;c={data:s,selection:r?{kind:"slot",...r}:o(s,t,n??null),ui:{...he,...i}}}let d=[{core:c,at:-1/0,sealed:!0,id:ge()}],u=0;const p=e=>{const t=d[u],n=r();!e&&u===d.length-1&&u>0&&!t.sealed&&n-t.at<i?d=[...d.slice(0,u),{...t,core:c,at:n}]:(d=[...d.slice(0,u+1),{core:c,at:n,sealed:e,id:ge()}],u=d.length-1)},f=/* @__PURE__ */new Set;let h=null,m=null,g=0,y=null,b=!1;const k=()=>{for(const e of[...f])e()},S=()=>{d=[...d.slice(0,u),{...d[u],core:c},...d.slice(u+1)]},C=(t,n)=>{g>0?b=b||n:(n?p(!1):c!==t&&S(),c.data!==t.data&&e.onChange?.(c.data),c!==t&&k())},D=e=>{const n=c;if(c=ue(c,e,t),c===n)return;const o=e.recordHistory??ie(e);C(n,o&&c.data!==n.data)},E=t=>{0===g&&(y=c,b=!1),g+=1;try{t()}catch(e){throw g-=1,0===g&&y&&(c=y,y=null),e}if(g-=1,g>0||!y)return;const n=y;y=null,b&&c.data!==n.data?p(!0):c!==n&&S(),c.data!==n.data&&e.onChange?.(c.data),c!==n&&k()},M=e=>{const n=c,o=ce(c.data,t,e);var r,i;(r=o,i=c.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))||(c={...c,selection:o},C(n,!1))},z=t=>{const n=c;u=t,c=d[u].core,c.data!==n.data&&e.onChange?.(c.data),c!==n&&k()},R=()=>(e={})=>{const n=e.root?t.root?.permissions:t.components[e.item?.type??e.type??""]?.permissions;return{...fe,...l,...n}};let B=R();const L=O(),V={resolveCache:L,async resolveAll({trigger:e="load",metadata:n}={}){const o=c.data,r={type:"root",props:{...o.root.props??{}}},i=[...o.content,...Object.values(o.zones??{}).flat()],[l,...s]=await Promise.all([A(r,t,{cache:L,trigger:e,metadata:n}),...i.map(o=>A(o,t,{cache:L,trigger:e,metadata:n}))]);E(()=>{const n=c;let r=c.data;s.forEach((e,n)=>{if(!e.didChange)return;const l=i[n].props.id,s=v(r,t,l)?.node;s&&s===v(o,t,l)?.node&&(r=I(r,t,l,e.node))}),l.didChange&&r.root===o.root&&(r={...r,root:{...r.root,props:l.node.props,readOnly:l.node.readOnly??r.root.readOnly}}),r!==c.data&&("load"===e&&c.data===a&&(a=r),c={...c,data:r,selection:ce(r,t,c.selection)},C(n,!1))})},async resolveNode(e,{trigger:n="replace",metadata:o}={}){const r=v(c.data,t,e)?.node;if(!r)return!1;const i=await A(r,t,{cache:L,trigger:n,metadata:o});if(!i.didChange)return!1;let l=!1;return E(()=>{const n=c;if(v(c.data,t,e)?.node!==r)return;const o=I(c.data,t,e,i.node);o!==c.data&&(c={...c,data:o,selection:ce(o,t,c.selection)},C(n,!1),l=!0)}),l},get config(){return t},get loaded(){return a},getState(){if(h&&m===c)return h;const e=c,o={data:e.data,ui:ae(e,t)},r="node"===e.selection?.kind?v(e.data,t,e.selection.id)?.node??null:null;return h={appState:o,selection:e.selection,selectedItem:r,config:t,dispatch:D,history:{back:()=>V.undo(),forward:()=>V.redo(),hasPast:u>0,hasFuture:u<d.length-1,histories:d.map(e=>({id:e.id,state:{data:e.core.data,ui:ae(e.core,t)}})),index:u,setHistoryIndex:e=>{e>=0&&e<d.length&&e!==u&&z(e)}},getPermissions:B,getItemById:n=>v(e.data,t,n)?.node,getItemBySelector:n=>function(e,t,n){const[o,r]=(n.zone??"root:default-zone").split(/:(.*)/s);return w(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,h},subscribe:e=>(f.add(e),()=>{f.delete(e)}),dispatch:D,batch:E,group:()=>{const e=u,t=d[e].id;let n=!0;return{close:()=>{if(!n)return;if(n=!1,d[e]?.id!==t)return;if(u<=e+1)return void(u===e+1&&(d=[...d.slice(0,u),{...d[u],sealed:!0},...d.slice(u+1)]));const o=d[u];d=[...d.slice(0,e+1),{...o,sealed:!0},...d.slice(u+1)],u=e+1}}},select:e=>M(e?{kind:"node",id:e}:null),selectSlot:e=>M(e?{kind:"slot",parentId:e.parentId,slot:e.slot}:null),run(e){E(()=>{const n=c,o=void 0===e.select?c.selection:e.select;c={...c,data:e.data,selection:ce(e.data,t,o)},C(n,e.data!==n.data)})},load(e,n={}){const o=c,r=x(e,t);c={...c,data:r,selection:ce(r,t,n.selection??c.selection)},a=r,n.keepHistory||(d=[{core:c,at:-1/0,sealed:!0,id:ge()}],u=0),c!==o&&k()},undo(){u>0&&z(u-1)},redo(){u<d.length-1&&z(u+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,l)||(l=e,B=R(),h=null,k())},setConfig(e){e!==t&&(t=e,B=R(),h=null,k())}};return V}function ye(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&&j(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 we=F(null),be=F(!0);function ke({easel:e,hotkeys:t=!0,resolveOnMount:n=!0,children:o}){return H(()=>{n&&e.resolveAll()},[e,n]),H(()=>{if(t&&"undefined"!=typeof document)return ye(document,e)},[e,t]),/* @__PURE__ */X(we.Provider,{value:e,children:/* @__PURE__ */X(be.Provider,{value:t,children:o})})}function Se(){const e=T(we);if(!e)throw new Error("useEasel: no <EaselProvider> above this component");return e}function Ce(e){const t=Se(),n=W({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 Y(t.subscribe,o,o)}function Ie(){return function(e){return Ce(e)}}var De="data-puck-component",Ee="data-puck-dropzone",xe={},Oe="data-es-mirror",Ae="undefined"==typeof window?H:G;function Me(e,t,n){for(const e of Array.from(t.head.querySelectorAll(`[${Oe}]`)))e.remove();for(const o of Array.from(e.head.querySelectorAll('style, link[rel="stylesheet"]'))){const e=o.cloneNode(!0);e.setAttribute(Oe,""),n&&e.setAttribute("nonce",n),t.head.appendChild(e)}}function ze({children:t,id:n="preview-frame",title:o,className:r,style:i,mirrorStyles:l=!0,onDocument:s,height:a="auto",nonce:c}){const d=g("canvas",e),u=W(null),[p,f]=q(null);return Ae(()=>{const e=u.current,t=p?.ownerDocument.defaultView;if("auto"!==a||!e||!p||!t)return;const n=()=>{e.style.height=`${Math.ceil(p.getBoundingClientRect().height)}px`};n();const o=t.ResizeObserver,r=o?new o(n):null;return r?.observe(p),()=>r?.disconnect()},[p,a]),Ae(()=>{let e=u.current?.contentDocument;if(!e)return;"CSS1Compat"!==e.compatMode&&(e.open(),e.write("<!DOCTYPE html><html><head></head><body></body></html>"),e.close(),e=u.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"===a&&t.classList.add("es-frame-fill"),e.body.appendChild(t),V(e,c),f(t),s?.(e);let n=null;const o=u.current?.ownerDocument;if(l&&o){Me(o,e,c);const t=o.defaultView;t&&"MutationObserver"in t&&(n=new t.MutationObserver(()=>Me(o,e,c)),n.observe(o.head,{childList:!0,subtree:!0,characterData:!0}))}return()=>{n?.disconnect(),t.remove(),f(null),s?.(null)}},[]),/* @__PURE__ */X("iframe",{ref:u,id:n,title:o??d.frame,className:["es-canvas-frame","fill"===a?"is-fill":"",r??""].filter(Boolean).join(" "),style:i,children:p?ee(t,p):null})}var Re=F(null),Be=F(xe),Le=[];function Ve({parentId:e,slot:t,className:n,style:o,minEmptyHeight:r=128,minEmptyWidth:i=120}){const l=Se(),s=Ce(n=>w(n.appState.data,l.config,{parentId:e,slot:t})??Le),a=Ce(t=>"node"===t.selection?.kind&&t.selection.id===e&&e!==y),c=Ce(n=>"slot"===n.selection?.kind&&n.selection.parentId===e&&n.selection.slot===t),d=T(Re),u=["es-zone"];return s.length&&u.push("has-children"),e===y&&u.push("is-root"),(a||c)&&u.push("is-area-selected"),null!==d&&d===e&&e!==y&&u.push("is-hovering-area"),n&&u.push(n),/* @__PURE__ */X("div",{className:u.join(" "),[Ee]:`${e}:${t}`,style:{...o,"--min-empty-height":`${r}px`,"--min-empty-width":`${i}px`},children:s.map(e=>/* @__PURE__ */X(He,{node:e},e.props.id))})}function $e(e,t,n,o){const r=U(()=>{const n={};for(const o of z(R(e)))n[o]=Object.assign(function(e={}){/* @__PURE__ */
2
+ return X(Ve,{parentId:t,slot:o,...e})},{blockCount:0});return n},[e,t]);for(const e of Object.keys(r))r[e].blockCount=B(n[e],o);return r}function je(e){return U(()=>function({zone:t,...n}){/* @__PURE__ */
3
+ return X(Ve,{parentId:e,slot:t,...n})},[e])}var Ne=["top","bottom","zIndex"];function Pe(e,t,n){e.style[t]!==n&&(e.style[t]=n)}function Ze(e){const t=function(e){const t=e?.ownerDocument.defaultView?.getComputedStyle(e);if(!t||"sticky"!==t.position)return null;const n=e=>"auto"===e?"":e;return{top:n(t.top),bottom:n(t.bottom),zIndex:n(t.zIndex)}}(function(e){const t=e.ownerDocument.defaultView;let n=null;for(const o of Array.from(e.children))if("none"!==t?.getComputedStyle(o).display){if(n)return null;n=o}return n}(e));Pe(e,"position",t?"sticky":"relative");for(const n of Ne)Pe(e,n,t?.[n]??"");return!!t}var Ke="data-es-canvas-relative";function Fe(e){e.hasAttribute(Ke)&&("relative"===e.style.position&&(e.style.position=""),e.removeAttribute(Ke));const t=e.ownerDocument.defaultView?.getComputedStyle(e).position;return t&&"static"!==t?"sticky"===t:(e.style.position||(e.style.position="relative",e.setAttribute(Ke,"")),!1)}function He({node:e}){const t=Se().config,n=t.components[e.type],o=e.props.id,r=W(null),i=function(e,t){return U(()=>n=>{const o=t.current;o&&o!==n&&(o.removeAttribute(De),o.removeAttribute("data-puck-dnd")),t.current=n,n&&(n.setAttribute(De,e),n.setAttribute("data-puck-dnd",e),Fe(n))},[e,t])}(o,r),l=W(null),s=!!n?.inline;!function(e,t){const n=W(!1),o=W(()=>{});o.current=()=>{const o=e(),i=n.current;n.current=!!o&&t(o),i!==n.current&&r.current()};const r=W(()=>{});Ae(()=>o.current()),Ae(()=>{const t=e(),i=t?.ownerDocument.defaultView;if(!t||!i)return;const l=()=>o.current();i.addEventListener("resize",l);const s=i.ResizeObserver,a=s?new s(l):null;a?.observe(t);let c=null;return r.current=()=>{c?.disconnect(),c=null;const e=t.ownerDocument.documentElement;n.current&&e&&i.MutationObserver&&(c=new i.MutationObserver(l),c.observe(e,{attributes:!0}))},r.current(),()=>{i.removeEventListener("resize",l),a?.disconnect(),c?.disconnect(),r.current=()=>{}}},[])}(()=>s?r.current:l.current,e=>s?Fe(e):Ze(e));const a=T(Be),c=$e(n,o,e.props,t.components),d=je(o);if(!n?.render)return null;const u=n.render,p={...L(n),...e.props,...c},f={renderDropZone:d,isEditing:!0,dragRef:n.inline?i:null,metadata:{...a,...n.metadata}};return n.inline?/* @__PURE__ */X(u,{...p,puck:f,editMode:!0}):
4
+ /* @__PURE__ */X("div",{ref:l,[De]:o,"data-puck-dnd":o,style:{position:"relative"},children:/* @__PURE__ */X(u,{...p,puck:f,editMode:!0})})}function Te({metadata:e}){const t=Ce(e=>e.config),n=Ce(e=>e.appState.data.root).props??{},o=t.root?.render,r=$e(t.root,y,n,t.components),i=je(y),l=/* @__PURE__ */X(Ve,{parentId:y,slot:M}),s=o?/* @__PURE__ */X(o,{id:"puck-root",...n,...r,puck:{renderDropZone:i,isEditing:!0,dragRef:null,metadata:e??{}},editMode:!0,children:l}):l;/* @__PURE__ */
5
+ return X(Be.Provider,{value:e??xe,children:s})}var We=F(void 0),Ye=F(void 0),qe=F(void 0);function Ue({element:e}){const t=W(null),n=Qe(t,e?()=>e:null,e);/* @__PURE__ */
6
+ return X("div",{ref:t,"aria-hidden":"true",className:"es-canvas-outline is-hover is-hover-part",style:n?{position:"absolute",top:n.top,left:n.left,width:n.width,height:n.height}:{display:"none"}})}function Qe(e,t,n){return Xe(e,t?e=>{const n=t(e);return n?[n]:[]}:null,n)[0]??null}var Ge=[];function Xe(e,t,n){const[o,r]=q(Ge),i=W(t);return i.current=t,Ae(()=>{const t=e.current?.ownerDocument,n=t?.defaultView;if(!t||!n||!i.current)return void r(Ge);let o=0;const l=()=>{o=0;const n=e.current?.parentElement??null,l=(i.current?i.current(t):[]).map(e=>function(e,t){if(!e||!t)return null;const n=Z(e),o=t.getBoundingClientRect();return{top:n.top-o.top,left:n.left-o.left,width:n.width,height:n.height}}(e,n)).filter(e=>null!==e);r(e=>{return(t=e)===(n=l)||t.length===n.length&&t.every((e,t)=>function(e,t){return e===t||!!e&&!!t&&e.top===t.top&&e.left===t.left&&e.width===t.width&&e.height===t.height}(e,n[t]))?e:l.length?l:Ge;var t,n})},s=()=>{o||(o=(n.requestAnimationFrame??(e=>n.setTimeout(e,16)))(l))};l();const a="MutationObserver"in n?new n.MutationObserver(s):null;a?.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),()=>{a?.disconnect(),c?.disconnect(),n.removeEventListener("resize",s),o&&(n.cancelAnimationFrame??n.clearTimeout)(o)}},[n]),o}function Je({id:e,kind:t,overlay:n}){const o=W(null),r=T(Ye),i=null!==e&&!0===r?.(e),l=Xe(o,e?t=>K(t,`[${De}="${t.defaultView?.CSS?.escape?t.defaultView.CSS.escape(e):e}"]`):null,e),[s,...a]=l,c=`es-canvas-outline is-${t}${i?" is-shared":""}`,d=e=>({position:"absolute",top:e.top,left:e.left,width:e.width,height:e.height}),u=/* @__PURE__ */J(_,{children:[
7
+ /* @__PURE__ */X("div",{ref:o,"aria-hidden":"true",className:c,style:s?d(s):{display:"none"}}),a.map((e,t)=>/* @__PURE__ */X("div",{"aria-hidden":"true",className:c,style:d(e)},t))]});return n&&e?/* @__PURE__ */X(n,{componentId:e,kind:t,children:u}):u}function _e(e,t,n){const o=h(e,n),r=o.text.length,i=e.ownerDocument;if(!t)return[r,r];let l=null;const s=i.caretPositionFromPoint?.(t.x,t.y);if(s&&e.contains(s.offsetNode))l=o.at(s.offsetNode,s.offset);else{const n=i.caretRangeFromPoint?.(t.x,t.y);n&&e.contains(n.startContainer)&&(l=o.at(n.startContainer,n.startOffset))}if(null===l)return[r,r];const a=o.text;let c=l,d=l;for(;c>0&&!/\s/.test(a[c-1]);)c-=1;for(;d<a.length&&!/\s/.test(a[d]);)d+=1;return[c,d]}function et({s:e,element:t,toolbar:n,label:o,keys:r}){const i=g("copy",m),l=e.pressed(),s=new Set(n.offered),f=n.colors&&n.colors.length>0?n.colors:null,h=W(null),[v,y]=q(!1),[w,b]=q(null),k=v||null!==w,S=()=>{e.hold(),y(!1),b({href:e.pressed().href})},C=()=>{y(!1),b(null),e.resume()};G(()=>{r.current={escape:()=>!!k&&(C(),!0),link:()=>!!s.has("link")&&(S(),!0)}}),G(()=>()=>{r.current=null},[r]);const I=W(C);I.current=C,H(()=>{if(v)return te(e=>{const t=h.current;return!!("Escape"===e.key&&t&&e.target instanceof Node&&t.contains(e.target))&&(I.current(),!0)},()=>h.current?.querySelector(".es-copy-colors"))},[v]),H(()=>{const n=h.current;if(!k||!n)return;const o=/* @__PURE__ */new Set([n.ownerDocument]),r=t();r&&o.add(r.ownerDocument);const i=o=>{const r=o.target;if(r&&n.contains(r))return;y(!1),b(null);const i=t();r&&i&&i.contains(r)?e.release():e.stop("outside")};for(const e of o)e.addEventListener("pointerdown",i,!0);return()=>{for(const e of o)e.removeEventListener("pointerdown",i,!0)}},[k,e,t]),G(()=>{const e=h.current,n=e?.querySelector(".rosh-tb-wrap > .es-copy-pop"),o=t();if(!(k&&e&&n&&o))return;const r=o.ownerDocument.defaultView?.getSelection()??null,i=r&&r.rangeCount>0&&o.contains(r.getRangeAt(0).startContainer)?r.getRangeAt(0):null,l=(i?a(i,o):null)??(()=>{const e=o.getBoundingClientRect();return{left:e.left,top:e.top,right:e.right,bottom:e.bottom}})(),s=o.ownerDocument.defaultView?.frameElement,u=s?N(s,{left:l.left,top:l.top,width:l.right-l.left,height:l.bottom-l.top}):{left:l.left,top:l.top,width:l.right-l.left,height:l.bottom-l.top},p=o.getBoundingClientRect(),f=s?N(s,{left:p.left,top:p.top,width:p.width,height:p.height}):{left:p.left,top:p.top,width:p.width,height:p.height},m=(e.closest("[data-floating-bar]")??e).getBoundingClientRect(),g={left:u.left,right:u.left+u.width,top:Math.min(u.top,f.top-6,m.top),bottom:Math.max(u.top+u.height,f.top+f.height+6,m.bottom)},v=e.ownerDocument.documentElement,y=(s??o.closest(".es-canvas")??o).getBoundingClientRect(),w={left:Math.max(0,y.left),top:Math.max(0,y.top),right:Math.min(v.clientWidth||y.right,y.right),bottom:Math.min(v.clientHeight||y.bottom,y.bottom)};if(w.right<=w.left||w.bottom<=w.top||0===n.offsetWidth)return;const b=c({anchor:g,size:{width:n.offsetWidth,height:n.offsetHeight},within:{left:y.left,top:y.top,right:y.right,bottom:y.bottom},clip:w,parent:d(n)});n.style.top=`${b.top}px`,n.style.left=`${b.left}px`,n.style.setProperty("--es-pop-point",`${b.point}px`),n.dataset.side=b.above?"above":"below"});const D=f?{run:u(l.color,f),open:v,onToggle:()=>{b(null),v?C():(e.hold(),y(!0))}}:void 0;/* @__PURE__ */
8
+ return X(ne,{anchor:()=>{const e=t();if(!e)return null;const n=e.getBoundingClientRect(),o=e.ownerDocument.defaultView?.frameElement,r=o?N(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__ */X("div",{ref:h,children:/* @__PURE__ */X(oe,{layout:"row",offered:s,pressed:l.marks,onMark:t=>{"link"===t?S():e.press(t)},color:D,linkOpen:null!==w,list:{pressed:l.list,onList:t=>e.list(t)},alignment:n.alignment,letterCase:n.letterCase,last:n.lastTool?.({className:"rosh-tb-btn",disabled:!1,selected:l.selected,keepCaret:t=>{t.preventDefault(),e.hold()},insert:t=>e.insert(t)}),windows:/* @__PURE__ */J(_,{children:[v&&f?/* @__PURE__ */X(p,{colors:f,current:l.color,words:i.colors??m.colors,onPick:t=>e.color(t)}):null,w?
9
+ /* @__PURE__ */X(re,{className:"es-copy-link es-copy-pop",value:w.href??"",onApply:t=>{b(null),e.link(t)},onRemove:null!==w.href?()=>{b(null),e.link(null)}:void 0,onCancel:C}):null]})})})})}function tt({element:e}){const t=W(null),n=Qe(t,()=>e(),e);/* @__PURE__ */
10
+ return X("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 nt({frame:t=!0,className:n,style:o,metadata:r,mirrorStyles:a,onDocument:c,height:d,title:u,nonce:p,hotkeys:h,frameWrapper:m,overlay:v,children:y,typing:w,passThrough:b}){const k=Se(),S=T(We),C=b??S,I=T(be),D=g("canvas",e),E=h??I,[x,O]=q(void 0),A=Ce(e=>"node"===e.selection?.kind?e.selection.id:null),[M,z]=q(null),[R,B]=q(null),L=T(qe),[V,j]=q(null),N=W(null),[,Z]=q(0),K=W(w);K.current=w;const F=W(null),Y=W(null),U=Ce(e=>e.appState.data);H(()=>{const e=Y.current?.ownerDocument,t=e?.defaultView?.CustomEvent;if(!e||!t)return;const n=A&&!V&&K.current?.atSelection?.()?A:null;e.dispatchEvent(new t($,{detail:{id:n}}))},[A,V,U]);const Q=e=>{const t=Y.current?.ownerDocument,n=t?.defaultView?.CustomEvent;t&&n&&t.dispatchEvent(new n(P,{detail:{typing:e}}))},G=(e,t)=>{N.current?.s.stop("stop");const n=e.element();if(!n)return!1;const o=k.group(),r=e.element,i=f({element:r,value:e.value,rules:e.rules,multiline:e.multiline,skip:e.skip,caret:_e(n,t,e.skip),write:e.write,remount:e.remount,onSelect:()=>Z(e=>e+1),onEscape:()=>F.current?.escape()??!1,onLinkKey:()=>F.current?.link()??!1,end:e=>{o.close(),N.current?.element===r&&(N.current=null),j(null),Q(!1),K.current?.onChange?.({typing:!1,why:e})}});if(!i)return o.close(),!1;const l=n.closest?.(`[${De}]`)?.getAttribute(De);return l&&k.select(l),N.current={s:i,element:r,target:e},j(()=>r),z(null),Q(!0),K.current?.onChange?.({typing:!0,element:n}),!0};H(()=>()=>N.current?.s.stop("stop"),[]);const _=e=>{const t=N.current?.element();return Boolean(t&&t.contains(e))},ee=e=>{const t=e.closest?.(`[${De}]`)?.getAttribute(De);if(!t)return;const n=k.getState(),o="node"===n.selection?.kind?n.selection.id:null,r=L?.partAt(e,t)??null;if(r){const e=l(n.appState.data,k.config,t,r.id,o,L?.selected()??null,C);if(e)return{node:e.node,part:e.part?r:null}}return{node:s(n.appState.data,k.config,t,o,C)??t,part:null}},te=e=>{if("Enter"!==e.key||e.defaultPrevented||e.shiftKey||e.metaKey||e.ctrlKey||e.altKey)return;if(N.current)return;const t=e.target;if(t?.isContentEditable||t?.closest?.("input, textarea, select, button"))return;const n=K.current?.atSelection?.();n&&G(n,null)&&e.preventDefault()},ne=/* @__PURE__ */J("div",{ref:Y,className:"es-canvas-content",style:{position:"relative"},onClick:e=>{const t=e.target;if(t.closest?.("a[href]")&&e.preventDefault(),N.current){if(_(t))return;N.current.s.stop("outside")}const n=t.ownerDocument?.getSelection?.();n&&n.rangeCount>0&&n.isCollapsed&&n.removeAllRanges();const o=ee(t);if(void 0!==o)return k.select(o.node),void(L&&(o.part?.id??null)!==L.selected()&&L.select(o.part?.id??null));t.hasAttribute?.(Ee)||(k.select(null),L?.selected()&&L.select(null))},onDoubleClick:e=>{const t=K.current;if(!t||_(e.target))return;const n=t.at(e.target);n&&G(n,{x:e.clientX,y:e.clientY})&&e.preventDefault()},onKeyDown:e=>te(e),onMouseOver:e=>{if(N.current)return;const t=ee(e.target),n=t?.part&&t.part.id!==L?.selected()?t.part.element:null,o=t&&!t.part?t.node:null;o!==M&&z(o),n!==R&&B(n)},onMouseLeave:()=>{z(null),B(null)},children:[
11
+ /* @__PURE__ */X(Re.Provider,{value:M,children:/* @__PURE__ */X(Te,{metadata:r})}),
12
12
  /* @__PURE__ */J("div",{className:"es-canvas-outlines",style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:[
13
- /* @__PURE__ */G(Je,{id:!L&&M&&M!==A?M:null,kind:"hover",overlay:v}),B?/* @__PURE__ */G(Ue,{element:L?null:R}):null,
14
- /* @__PURE__ */G(Je,{id:L?null:A,kind:"selected",overlay:v}),L?/* @__PURE__ */G(tt,{element:L}):null]}),y]}),oe=m?/* @__PURE__ */G(m,{document:x,children:ne}):ne;H(()=>{if(x&&E)return ye(x,k)},[x,E,k]),H(()=>{if(!x)return;const e=e=>{if("Enter"===e.key)return void te(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;if(B?.selected())return void B.select(null);const o=i(n.appState.data,k.config,n.selection);"node"===o?.kind&&k.select(o.id)};return x.addEventListener("keydown",e),()=>x.removeEventListener("keydown",e)},[x,k,B]);/* @__PURE__ */
15
- return J("div",{className:"es-canvas"+(n?` ${n}`:""),style:o,"data-puck-preview":"","data-es-typing":L?"":void 0,children:[L&&j.current?.target.toolbar?/* @__PURE__ */G(et,{s:j.current.s,element:j.current.element,toolbar:j.current.target.toolbar,label:D.textTools,keys:F}):null,t?/* @__PURE__ */G(ze,{mirrorStyles:a,onDocument:e=>{O(e??void 0),c?.(e)},height:d,title:u,nonce:p,children:oe}):/* @__PURE__ */G("div",{id:"preview-frame","data-puck-entry":"",children:oe})]})}function ot(e={}){const t=Se(),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 rt(){const e=Se(),n=Ce(e=>e.config),o=e.resolveCache,r=Ce(e=>e.selectedItem),i=Ce(e=>e.appState.data.root),l=r?r.props.id:"root",s=i.props??{},a=U(()=>r||{type:"root",props:s},[r,s]),c=r?n.components[r.type]:n.root,d=e.getState(),u=r?v(d.appState.data,n,l):null,p=u&&"root"!==u.place.parentId?u.place.parentId:null,f=p?d.getItemById(p)??null:null,{fields:h}=t({id:l,node:a,block:c,parent:f,appState:d.appState}),m=Ce(e=>!1===e.getPermissions(r?{item:r}:{root:!0}).edit),g=Q(t=>{(async()=>{const r=e.getState();if("root"!==l){const i=r.getItemById(l),s=r.getSelectorForId(l);if(!i||!s)return;const a={...i,props:{...i.props,...t}},{node:c}=await A(a,n,{cache:o,trigger:"replace"}),d=e.getState().getSelectorForId(l);if(!d)return;return void e.dispatch({type:"replace",destinationZone:d.zone??"root:default-zone",destinationIndex:d.index,data:c})}const i=r.appState.data.root.props??{},{node:s}=await A({type:"root",props:{...i,...t}},n,{cache:o,trigger:"replace"});e.dispatch({type:"replaceRoot",root:{props:s.props,readOnly:s.readOnly},recordHistory:!0})})()},[e,n,o,l]),y=Q((e,t)=>g({[e]:t}),[g]);return{id:l,node:a,fields:h,values:a.props,readOnly:m,onChange:y,onChangeMany:g}}export{ze as CanvasFrame,qe as CanvasPartsContext,We as CanvasPassThroughContext,Ye as CanvasSharedContext,he as DEFAULT_UI,nt as EaselCanvas,ke as EaselProvider,Te as EditDocument,ye as bindUndoKeys,ve as createEasel,Ie as createUseEasel,ie as recordsByDefault,ue as reduce,ae as uiView,Ce as useEasel,Se as useEaselApi,ot as useEaselNodeOps,rt as useSelectedFields,ce as validSelection};
13
+ /* @__PURE__ */X(Je,{id:!V&&M&&M!==A?M:null,kind:"hover",overlay:v}),L?/* @__PURE__ */X(Ue,{element:V?null:R}):null,
14
+ /* @__PURE__ */X(Je,{id:V?null:A,kind:"selected",overlay:v}),V?/* @__PURE__ */X(tt,{element:V}):null]}),y]}),oe=m?/* @__PURE__ */X(m,{document:x,children:ne}):ne;H(()=>{if(x&&E)return ye(x,k)},[x,E,k]),H(()=>{if(!x)return;const e=e=>{if("Enter"===e.key)return void te(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;if(L?.selected())return void L.select(null);const o=i(n.appState.data,k.config,n.selection);"node"===o?.kind&&k.select(o.id)};return x.addEventListener("keydown",e),()=>x.removeEventListener("keydown",e)},[x,k,L]);/* @__PURE__ */
15
+ return J("div",{className:"es-canvas"+(n?` ${n}`:""),style:o,"data-puck-preview":"","data-es-typing":V?"":void 0,children:[V&&N.current?.target.toolbar?/* @__PURE__ */X(et,{s:N.current.s,element:N.current.element,toolbar:N.current.target.toolbar,label:D.textTools,keys:F}):null,t?/* @__PURE__ */X(ze,{mirrorStyles:a,onDocument:e=>{O(e??void 0),c?.(e)},height:d,title:u,nonce:p,children:oe}):/* @__PURE__ */X("div",{id:"preview-frame","data-puck-entry":"",children:oe})]})}function ot(e={}){const t=Se(),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 rt(){const e=Se(),n=Ce(e=>e.config),o=e.resolveCache,r=Ce(e=>e.selectedItem),i=Ce(e=>e.appState.data.root),l=r?r.props.id:"root",s=i.props??{},a=U(()=>r||{type:"root",props:s},[r,s]),c=r?n.components[r.type]:n.root,d=e.getState(),u=r?v(d.appState.data,n,l):null,p=u&&"root"!==u.place.parentId?u.place.parentId:null,f=p?d.getItemById(p)??null:null,{fields:h}=t({id:l,node:a,block:c,parent:f,appState:d.appState}),m=Ce(e=>!1===e.getPermissions(r?{item:r}:{root:!0}).edit),g=Q(t=>{(async()=>{const r=e.getState();if("root"!==l){const i=r.getItemById(l),s=r.getSelectorForId(l);if(!i||!s)return;const a={...i,props:{...i.props,...t}},{node:c}=await A(a,n,{cache:o,trigger:"replace"}),d=e.getState().getSelectorForId(l);if(!d)return;return void e.dispatch({type:"replace",destinationZone:d.zone??"root:default-zone",destinationIndex:d.index,data:c})}const i=r.appState.data.root.props??{},{node:s}=await A({type:"root",props:{...i,...t}},n,{cache:o,trigger:"replace"});e.dispatch({type:"replaceRoot",root:{props:s.props,readOnly:s.readOnly},recordHistory:!0})})()},[e,n,o,l]),y=Q((e,t)=>g({[e]:t}),[g]);return{id:l,node:a,fields:h,values:a.props,readOnly:m,onChange:y,onChangeMany:g}}export{ze as CanvasFrame,qe as CanvasPartsContext,We as CanvasPassThroughContext,Ye as CanvasSharedContext,he as DEFAULT_UI,nt as EaselCanvas,ke as EaselProvider,Te as EditDocument,ye as bindUndoKeys,ve as createEasel,Ie as createUseEasel,ie as recordsByDefault,ue as reduce,ae as uiView,Ce as useEasel,Se as useEaselApi,ot as useEaselNodeOps,rt as useSelectedFields,ce as validSelection};