efficient-easel 20.1.0 → 20.2.1
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.
- package/dist/chrome/chrome.css +2 -1
- package/dist/{chunk-PEDR7G3K.js → chunk-6FWAE2RN.js} +1 -1
- package/dist/{chunk-WBFLSCTI.js → chunk-7YVEYQDE.js} +3 -3
- package/dist/{chunk-ROPYFLNZ.js → chunk-EFHV56BO.js} +13 -13
- package/dist/{chunk-HBBXDGDD.js → chunk-I7BROL77.js} +1 -1
- package/dist/{chunk-H4JCMK36.js → chunk-JQXD3TDE.js} +1 -1
- package/dist/{chunk-5THLKXTH.js → chunk-L2Y3PF2R.js} +1 -1
- package/dist/{chunk-LDEEFLE3.js → chunk-LQV5FZTQ.js} +4 -4
- package/dist/chunk-MEHLY5Q4.js +1 -0
- package/dist/chunk-PAOZMXEI.js +5 -0
- package/dist/chunk-R5KEFI55.js +8 -0
- package/dist/{chunk-2E2SXDYQ.js → chunk-TNGOL65V.js} +1 -1
- package/dist/chunk-WEIE2FBC.js +1 -0
- package/dist/chunk-XJ2WXGFJ.js +65 -0
- package/dist/copy/index.js +13 -13
- package/dist/drag/index.js +1 -1
- package/dist/easel/index.js +1 -1
- package/dist/screen/components/AddBlockRow.js +1 -1
- package/dist/screen/components/AddSidePanel.js +1 -1
- package/dist/screen/components/MediaPopup.d.ts +5 -6
- package/dist/screen/components/NodeContextMenu.js +1 -1
- package/dist/screen/components/ScreenChrome.js +1 -1
- package/dist/screen/components/ScreenMount.js +1 -1
- package/dist/screen/components/ScreenStoreProvider.js +1 -1
- package/dist/screen/components/SectionScreenShell.js +15 -15
- package/dist/screen/components/usePartBridge.js +1 -1
- package/dist/screen/index.js +1 -1
- package/dist/screen/lib/key-scope.js +1 -1
- package/dist/screen/lib/puck/preview-dom.js +1 -1
- package/dist/screen/lib/puck/style-clipboard.js +1 -1
- package/dist/screen/lib/puck/use-section-ops.js +1 -1
- package/dist/screen/lib/screen-parts.d.ts +5 -0
- package/dist/screen/lib/screen-parts.js +1 -1
- package/dist/screen/screen.css +37 -0
- package/dist/strings/index.js +1 -1
- package/dist/text-styles/index.js +21 -21
- package/package.json +1 -1
- package/dist/chunk-47CD7ULN.js +0 -1
- package/dist/chunk-47PYYMFM.js +0 -8
- package/dist/chunk-LEZFSSQN.js +0 -5
- package/dist/chunk-PI6RFJR4.js +0 -1
- package/dist/chunk-RVZJ52EP.js +0 -63
package/dist/chrome/chrome.css
CHANGED
|
@@ -61,7 +61,8 @@
|
|
|
61
61
|
width: var(--es-left-w, 288px);
|
|
62
62
|
box-sizing: border-box;
|
|
63
63
|
height: 100%;
|
|
64
|
-
|
|
64
|
+
/* No hairline up through the bar since 2026-10-25 (owner): the bar draws no
|
|
65
|
+
vertical line; the panel below keeps its own edge. */
|
|
65
66
|
}
|
|
66
67
|
.es-cluster--rail {
|
|
67
68
|
/* `flex: none` IS THE WIDTH. The bar is a flex row, so `width` alone is only a
|
|
@@ -1 +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-23DYNW6S.js";import{styleMenuItems as o}from"./chunk-V7U33NF2.js";import{
|
|
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-23DYNW6S.js";import{styleMenuItems as o}from"./chunk-V7U33NF2.js";import{easelMenuEntries as l,menuLabel as r}from"./chunk-FIVU2COQ.js";import{createNodeClipboard as i,nodeMenuItems as c}from"./chunk-P5VYGWYO.js";import{DEFAULT_NODE_MENU_WORDS as s}from"./chunk-WK3AFPXY.js";import{zoneKey as u,ROOT_SLOT as a,ROOT_ID as d}from"./chunk-K7BTCBWD.js";import{isTypingTarget as p,useCanvasEvent as f,framePointToHost as m}from"./chunk-QIDRJH3S.js";import{ROOT_ZONE as h}from"./chunk-PLVEGYK6.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 l={zone:n.zone,index:n.index};for(;l;){const n=e.nodeAt(l.zone,l.index);if(!n||o.has(n.props.id))break;if(o.add(n.props.id),t.push({zone:l.zone,index:l.index,node:n,parentType:null}),l.zone===h)break;const r=l.zone.lastIndexOf(":");if(r<=0)break;l=e.locate(l.zone.slice(0,r))}for(let e=0;e<t.length-1;e+=1)t[e].parentType=t[e+1].node.type;return t}var K=i(),j=/* @__PURE__ */new WeakMap;function M(e){if(e.claimsPage)return K;const n=e.registry;if(!n)return e.cache("easel:node-clipboard",i);let t=j.get(n);return t||(t=i(),j.set(n,t)),t}function S(){return M(e())}function T(e,n,t){if(n===h){const{floor:n,cap:o}=e.sectionBand();return{parentId:d,slot:a,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 Y(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 I(e,n,t){const o=e.canPasteAt;if(!o)return u(n.from)===t.zone?T(e,t.zone,t.index+1):null;for(const l of D(e,t)){const t=T(e,l.zone,l.index+1);if(o(n,t))return t}return null}function R(e){if(e.defaultPrevented||e.altKey||e.shiftKey)return null;if(p(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 B(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=Y(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:I(e,s,t);return u?(e.nodeOps.paste(u),{done:"pasted",name:s.label}):(e.onPasteRefused(s),{done:"refused",name:s.label})}function E(e,n){const{zone:t,index:l}=n,r=e.nodeAt(t,l);if(!r)return[];const i=r.props.id,s=e.labelOf(r.type,t),u=Boolean(r.props._hidden),a=e.nodeOps,d=e.isPinned(r,t),p=e.isLocked(r),f=!d&&!p&&!e.duplicateBlocked(r),m=e.permits?.(r)??{duplicate:!0,delete:!0},y=Y(e,r,t),k=D(e,n),b=a.held,g=b&&!d?I(e,b,n):null,v=!e.readOnly,w=e.style?o({held:v?e.style.held():null,canCopy:e.style.canCopy(r,t),onCopy:()=>e.style?.copy(r,t),onPaste:()=>e.style?.paste(t,l,r),words:e.words?.styleClipboard}):[];return c({title:s,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)},l=n.zone===h?null:e.slotRung?.(n.zone)??null;return l?[o,{label:l.label,checked:!1,onClick:l.select}]:[o]})},actions:{duplicate:v&&f&&m.duplicate?()=>a.duplicate(i):void 0,...L(v&&!d,e=>a.canStep(i,e),e=>a.step(i,e)),copy:y.copy?()=>a.copy(i,s):void 0,cut:v&&y.cut?()=>a.cut(i,s):void 0,paste:v&&b&&g?{label:b.label,run:()=>a.paste(g)}:void 0,rename:v&&e.renamePropOf(r,t)?()=>e.beginRename(t,l):void 0,hide:!v||p||d?void 0:{hidden:u,run:()=>a.setProps(i,{_hidden:!u})},delete:v&&f&&m.delete?()=>a.remove(i):void 0},style:w,extras:e.menuRows?.(r,t,l)??void 0,pinnedLine:d?V(e).pinned:void 0})}function L(e,n,t){return e?{moveUp:n(-1)?()=>t(-1):null,moveDown:n(1)?()=>t(1):null}:{}}var V=e=>e.words?.screen??t.menu;function X(e){const n=V(e),o=!e.readOnly,l=[];o&&e.history.hasPast&&l.push({label:n.undo,icon:/* @__PURE__ */A(w,{}),shortcut:"⌘Z",onClick:e.history.back}),o&&e.history.hasFuture&&l.push({label:n.redo,icon:/* @__PURE__ */A(x,{}),shortcut:"⇧⌘Z",onClick:e.history.forward});const r=[],i=e.nodeOps.held,c=T(e,h,e.sectionBand().cap);if(o&&i&&(e.canPasteAt?e.canPasteAt(i,c):u(i.from)===h)){const n=c,t=e.words?.menu??s;r.push({label:t.pasteNamed({paste:t.paste,label:i.label}),icon:/* @__PURE__ */A(C,{}),shortcut:"⌘V",onClick:()=>e.nodeOps.paste(n)})}const a=[l,r,[{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),d={label:"—",onClick:()=>{}};return a.flatMap((e,n)=>n?[d,...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??s,c=V(e),u=[];l&&(u.push({label:i.copy,icon:/* @__PURE__ */A(P,{}),shortcut:"⌘C",onClick:()=>navigator.clipboard?.writeText(l)}),u.push({label:i.cut,icon:/* @__PURE__ */A(P,{}),shortcut:"⌘X",onClick:()=>{navigator.clipboard?.writeText(l),r("")}})),u.push({label:i.paste,icon:/* @__PURE__ */A(C,{}),shortcut:"⌘V",onClick:()=>{navigator.clipboard?.readText().then(e=>{e&&r(e)}).catch(()=>e.onPasteRefused())}});const a=[u,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=R(e);if(!o)return;const l=t.selected();if(!l)return;const r=B(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]),f(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]);f(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=m(t.frame,n.clientX,n.clientY),s=t.frame;l(i?{kind:"node",...c,...i,owner:s}:{kind:"empty",...c,owner:s})}),f(t,"mousedown",r),f(t,"scroll",r,{on:"window"});return{onEditorContextMenu:u,menu:o?/* @__PURE__ */A(W,{host:e,target:o,onClose:r}):null,closeMenu:r}}function W({host:e,target:n,onClose:t}){const o="node"===n.kind?E(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":r(o),items:l(o)})}export{K as EASEL_NODE_CLIPBOARD,D as ancestorChain,M as nodeClipboardOf,Y as nodeClipboardRules,E as nodeMenuItems,R as nodeShortcut,X as pageMenuItems,I as pastePlace,B as runNodeShortcut,N as textMenuItems,S as useNodeClipboard,U as useNodeContextMenu};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{clientOnly as r}from"./chunk-GXQCZJOP.js";import{ScreenChrome as n}from"./chunk-
|
|
1
|
+
import{clientOnly as r}from"./chunk-GXQCZJOP.js";import{ScreenChrome as n}from"./chunk-XJ2WXGFJ.js";import{ScreenStoreProvider as e}from"./chunk-JQXD3TDE.js";import{ScreenDocumentProvider as i,useScreenDocument as a}from"./chunk-276MBG5P.js";import{DEFAULT_SCREEN_WORDS as o}from"./chunk-23DYNW6S.js";import{documentPermissions as s}from"./chunk-THWO5YVZ.js";import{useWords as c}from"./chunk-MFIRYGHW.js";import{useMemo as t,useState as d,useRef as l,useEffect as m,useCallback as g}from"react";import{Dialog as h,Button as f}from"efficient-shell/ui";import{jsx as u,jsxs as p,Fragment as v}from"react/jsx-runtime";var k=r(e),C=r(n);function N({onCancel:r,onDiscard:n,onSave:e}){const i=c("screen",o).leave,[a,s]=d(!1),t=l(!0);m(()=>(t.current=!0,()=>{t.current=!1}),[]);const k=g(async()=>{s(!0);try{await e()}finally{t.current&&s(!1)}},[e]);/* @__PURE__ */
|
|
2
2
|
return u(h,{open:!0,role:"alertdialog",size:"sm",title:i.title,onClose:r,footer:/* @__PURE__ */p(v,{children:[
|
|
3
3
|
/* @__PURE__ */u(f,{variant:"secondary",onClick:r,children:i.cancel}),
|
|
4
4
|
/* @__PURE__ */u(f,{variant:"ghost-danger",onClick:n,children:i.discard}),
|
|
5
5
|
/* @__PURE__ */u(f,{variant:"primary",loading:a,onClick:()=>{k()},children:i.save})]}),children:i.body})}function j({target:r,addressing:n,onHostMessage:e,children:a}){/* @__PURE__ */
|
|
6
|
-
return u(i,{target:r,addressing:n,onHostMessage:e,children:a})}var y=(r,n)=>/* @__PURE__ */p(v,{children:[r,n]});function
|
|
7
|
-
/* @__PURE__ */u(k,{config:r,data:i,onChange:h,permissions:
|
|
6
|
+
return u(i,{target:r,addressing:n,onHostMessage:e,children:a})}var y=(r,n)=>/* @__PURE__ */p(v,{children:[r,n]});function D({config:r,parts:n,wrap:e=y}){const{data:i,error:d,redirecting:l,ready:m,readOnly:g,onChange:h,pendingNav:f,cancelPendingNav:p,discardAndNavigate:v,saveAndNavigate:j}=a(),D=t(()=>s(!g),[g]),G=c("screen",o);return l?/* @__PURE__ */u("div",{className:"sf-msg",children:G.loading}):d?/* @__PURE__ */u("div",{className:"sf-msg sf-msg--error",children:d}):m?i?e(
|
|
7
|
+
/* @__PURE__ */u(k,{config:r,data:i,onChange:h,permissions:D,parts:n,children:/* @__PURE__ */u(C,{})}),f&&/* @__PURE__ */u(N,{onCancel:p,onDiscard:v,onSave:j})):/* @__PURE__ */u("div",{className:"sf-msg",children:G.loading}):/* @__PURE__ */u("div",{className:"sf-msg",children:G.waitingForAuthorization})}export{D as DocumentScreen,j as ScreenMount};
|
|
@@ -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{setCanvasNonce as v,CANVAS_TYPABLE_EVENT as y,isTypingTarget as w,frameRectToHost as b,CANVAS_TYPING_EVENT as k,drawnBox as S}from"./chunk-QIDRJH3S.js";import{queryAllCopies as C}from"./chunk-LF3FUSCQ.js";import{find as I,ROOT_ID as D,getList as E,remove as x,parseZoneKey as O,move as A,duplicate as M,replaceNode as z,createNode as R,insert as V,normalizeData as B,createResolveCache as L,resolveNodeData as P,ROOT_SLOT as $}from"./chunk-K7BTCBWD.js";import{topLevelSlotKeys as j,fieldsFrom as N,drawnBlockCount as K,defaultsFrom as Z}from"./chunk-L55YIXDC.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=E(e,t,O(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?I(e,t,n.id)?n:null:n.parentId===D?E(e,t,n)?n:null:I(e,t,n.parentId)&&E(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={...O(t.destinationZone),index:t.destinationIndex},i=R(n,t.componentType,{},t.id?{id:t.id}:{});return{...e,data:V(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:z(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=M(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={...O(t.destinationZone),index:t.destinationIndex};return{...e,data:A(o,n,r.props.id,i)}}case"remove":{const r=se(o,n,t.zone,t.index,"remove");return{...e,data:x(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=B(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,v=null,y=!1;const w=()=>{for(const e of[...f])e()},b=()=>{d=[...d.slice(0,u),{...d[u],core:c},...d.slice(u+1)]},k=(t,n)=>{g>0?y=y||n:(n?p(!1):c!==t&&b(),c.data!==t.data&&e.onChange?.(c.data),c!==t&&w())},S=e=>{const n=c;if(c=ue(c,e,t),c===n)return;const o=e.recordHistory??ie(e);k(n,o&&c.data!==n.data)},C=t=>{0===g&&(v=c,y=!1),g+=1;try{t()}catch(e){throw g-=1,0===g&&v&&(c=v,v=null),e}if(g-=1,g>0||!v)return;const n=v;v=null,y&&c.data!==n.data?p(!0):c!==n&&b(),c.data!==n.data&&e.onChange?.(c.data),c!==n&&w()},D=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},k(n,!1))},x=t=>{const n=c;u=t,c=d[u].core,c.data!==n.data&&e.onChange?.(c.data),c!==n&&w()},O=()=>(e={})=>{const n=e.root?t.root?.permissions:t.components[e.item?.type??e.type??""]?.permissions;return{...fe,...l,...n}};let A=O();const M=L(),R={resolveCache:M,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([P(r,t,{cache:M,trigger:e,metadata:n}),...i.map(o=>P(o,t,{cache:M,trigger:e,metadata:n}))]);C(()=>{const n=c;let r=c.data;s.forEach((e,n)=>{if(!e.didChange)return;const l=i[n].props.id,s=I(r,t,l)?.node;s&&s===I(o,t,l)?.node&&(r=z(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)},k(n,!1))})},async resolveNode(e,{trigger:n="replace",metadata:o}={}){const r=I(c.data,t,e)?.node;if(!r)return!1;const i=await P(r,t,{cache:M,trigger:n,metadata:o});if(!i.didChange)return!1;let l=!1;return C(()=>{const n=c;if(I(c.data,t,e)?.node!==r)return;const o=z(c.data,t,e,i.node);o!==c.data&&(c={...c,data:o,selection:ce(o,t,c.selection)},k(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?I(e.data,t,e.selection.id)?.node??null:null;return h={appState:o,selection:e.selection,selectedItem:r,config:t,dispatch:S,history:{back:()=>R.undo(),forward:()=>R.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&&x(e)}},getPermissions:A,getItemById:n=>I(e.data,t,n)?.node,getItemBySelector:n=>function(e,t,n){const[o,r]=(n.zone??"root:default-zone").split(/:(.*)/s);return E(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:S,batch:C,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=>D(e?{kind:"node",id:e}:null),selectSlot:e=>D(e?{kind:"slot",parentId:e.parentId,slot:e.slot}:null),run(e){C(()=>{const n=c,o=void 0===e.select?c.selection:e.select;c={...c,data:e.data,selection:ce(e.data,t,o)},k(n,e.data!==n.data)})},load(e,n={}){const o=c,r=B(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&&w()},undo(){u>0&&x(u-1)},redo(){u<d.length-1&&x(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,A=O(),h=null,w())},setConfig(e){e!==t&&(t=e,A=O(),h=null,w())}};return R}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&&w(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),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__ */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=>E(n.appState.data,l.config,{parentId:e,slot:t})??Be),a=Ce(t=>"node"===t.selection?.kind&&t.selection.id===e&&e!==D),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===D&&u.push("is-root"),(a||c)&&u.push("is-area-selected"),null!==d&&d===e&&e!==D&&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 j(N(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=
|
|
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={...
|
|
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,
|
|
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
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=
|
|
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,
|
|
8
|
-
return G(ne,{anchor:()=>{const e=t();if(!e)return null;const n=e.getBoundingClientRect(),o=e.ownerDocument.defaultView?.frameElement,r=o?
|
|
9
|
-
/* @__PURE__ */G(re,{className:"es-copy-link es-copy-pop",value:w.href??"",onApply:t=>{
|
|
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:
|
|
11
|
-
/* @__PURE__ */G(Re.Provider,{value:
|
|
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})}),
|
|
12
12
|
/* @__PURE__ */J("div",{className:"es-canvas-outlines",style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:[
|
|
13
|
-
/* @__PURE__ */G(Je,{id
|
|
14
|
-
/* @__PURE__ */G(Je,{id
|
|
15
|
-
return J("div",{className:"es-canvas"+(n?` ${n}`:""),style:o,"data-puck-preview":"","data-es-typing"
|
|
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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useEaselHost as n}from"./chunk-MQA7OFRA.js";import{useEaselApi as e,bindUndoKeys as t}from"./chunk-
|
|
1
|
+
import{useEaselHost as n}from"./chunk-MQA7OFRA.js";import{useEaselApi as e,bindUndoKeys as t}from"./chunk-EFHV56BO.js";import{useState as r,useEffect as o,useRef as u}from"react";function c(e){const t=n(),[u,c]=r(null);return o(()=>c(e.current),[e]),t.ownsDocument?"undefined"==typeof document?null:document:u}function i(r,u){const i=n(),s=e(),f=c(r);o(()=>{if(!i.ownsDocument&&f)return t(f,s,{leaveTyping:!0})},[i,s,f]);const m=u?.document??null;o(()=>{if(!i.ownsDocument&&m)return t(m,s,{leaveTyping:!0})},[i,s,m])}function s(n){return n.ownsDocument?{}:{tabIndex:-1}}function f(n){return!n.altKey&&!n.shiftKey&&(!(!n.metaKey&&!n.ctrlKey)&&("s"===n.key||"S"===n.key||"KeyS"===n.code))}function m(n,e,t){const r=c(n),i=u(t);o(()=>{i.current=t}),o(()=>{if(!r)return;const n=n=>{f(n)&&(n.preventDefault(),i.current())};return r.addEventListener("keydown",n),()=>r.removeEventListener("keydown",n)},[r]);const s=e?.document??null;o(()=>{if(!s)return;const n=n=>{f(n)&&(n.preventDefault(),i.current())};return s.addEventListener("keydown",n),()=>s.removeEventListener("keydown",n)},[s])}export{s as editorRootFocus,f as isSaveShortcut,c as useEaselKeyTarget,m as useEaselSaveKey,i as useEaselUndoKeys};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{ScreenPartsProvider as t}from"./chunk-
|
|
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__ */
|
|
2
2
|
return a(o,{easel:d,hotkeys:h.ownsDocument,children:/* @__PURE__ */a(t,{parts:f,children:u})})}export{i as ScreenStoreProvider};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{blockRuns as e,offeredChoices as r}from"./chunk-M2Z775ZC.js";import{useScreenBlockLook as s}from"./chunk-
|
|
1
|
+
import{blockRuns as e,offeredChoices as r}from"./chunk-M2Z775ZC.js";import{useScreenBlockLook as s}from"./chunk-PAOZMXEI.js";import{DEFAULT_SCREEN_WORDS as t}from"./chunk-23DYNW6S.js";import{useWords as n}from"./chunk-MFIRYGHW.js";import{DropdownMenu as c}from"efficient-shell/ui";import{jsxs as i,Fragment as o,jsx as l}from"react/jsx-runtime";function p({choices:p,onPick:a}){const{Icon:m}=s(),u=n("screen",t),f=e(r(p)).flatMap(e=>[...e.group?[{type:"label",key:`group:${e.group}`,label:/* @__PURE__ */i(o,{children:[e.group," ",
|
|
2
2
|
/* @__PURE__ */l("span",{className:"sf-menugroup-count",children:e.items.length})]})}]:[],...e.items.map(e=>({key:e.type,label:e.label,icon:/* @__PURE__ */l("span",{className:"sf-chip",children:/* @__PURE__ */l(m,{type:e.type,size:13})}),onSelect:()=>a(e.type)}))]);/* @__PURE__ */
|
|
3
3
|
return l(c,{align:"start",triggerClassName:"sf-add-card",items:f,trigger:/* @__PURE__ */i(o,{children:[
|
|
4
4
|
/* @__PURE__ */l("span",{className:"sf-plus sf-plus--sm",children:"+"}),u.addBlockMenu]})})}export{p as AddBlockRow};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import{DEFAULT_DRAG_WORDS as e}from"./chunk-KAML3KQH.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{
|
|
1
|
+
import{DEFAULT_DRAG_WORDS as e}from"./chunk-KAML3KQH.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 x}from"./chunk-LF3FUSCQ.js";import{useRef as b,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}from"efficient-shell/ui";import{AddIcon as S,CloseIcon as $,SearchIcon as E}from"efficient-shell/icons/efficient";import{jsxs as L,jsx as j}from"react/jsx-runtime";function B({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
2
|
return L("div",{className:o,style:n,"data-index":r,children:[
|
|
3
3
|
/* @__PURE__ */j("span",{className:"es-canvas-insert-line","aria-hidden":"true"}),
|
|
4
|
-
/* @__PURE__ */j("span",{className:"es-canvas-insert-chip",children:/* @__PURE__ */j(z,{content:e,children:/* @__PURE__ */j(T,{variant:"ghost",size:"sm","aria-label":e,onClick:t,children:/* @__PURE__ */j(S,{})})})})]})}var K=(e,t,n)=>t>=e.left&&t<=e.left+e.width&&n>=e.top&&n<=e.top+e.height,O=e=>e.width*e.height;function I(e,t,n){return e.map((e,t)=>({s:e,at:t})).filter(({s:e})=>K(e.box,t,n)).sort((e,t)=>O(t.s.box)-O(e.s.box)||e.at-t.at).map(({s:e})=>e)}function q(e,t,n){return I(e,t,n).at(-1)??null}function H(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 X(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 Y(e,t,n,l,a=()=>!1,r=()=>!0){const o=e.filter(e=>K(e.box,t,n)).sort((e,t)=>O(e.box)-O(t.box));for(const e of o){const o=H(e,t,n),s={...e.list,index:o};if(a(s))return null;if(l(s))return{zone:e,to:s,line:X(e,o)};if(!r(s))return null}return null}function F(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)),x=Math.max(...m.map(e=>r?e.top+e.height:e.left+e.width)),b=r?{left:f,top:g,width:p,height:x-g}:{left:g,top:f,width:x-g,height:p};d.push({key:`${e.key}:+${a}`,place:{...e.list,index:a},box:b,axis:e.axis,label:t})}return d}function P(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 Q={nodes:[],zones:[]},R="data-puck-dropzone",Z="data-puck-component";function J(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 V(e,t){const{frame:n,document:l}=e,a=e=>
|
|
5
|
-
/* @__PURE__ */j(B,{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__ */j("button",{type:"button",className:["es-canvas-empty",e.addAlways?"is-always":"",G?.zoneKey===e.key?"is-over":""].filter(Boolean).join(" "),style:_(e.box),"data-node-id":e.list.parentId===
|
|
6
|
-
/* @__PURE__ */j("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__ */j(z,{className:"es-canvas-handle-tip",side:"top",content:!Z||
|
|
4
|
+
/* @__PURE__ */j("span",{className:"es-canvas-insert-chip",children:/* @__PURE__ */j(z,{content:e,children:/* @__PURE__ */j(T,{variant:"ghost",size:"sm","aria-label":e,onClick:t,children:/* @__PURE__ */j(S,{})})})})]})}var K=(e,t,n)=>t>=e.left&&t<=e.left+e.width&&n>=e.top&&n<=e.top+e.height,O=e=>e.width*e.height;function I(e,t,n){return e.map((e,t)=>({s:e,at:t})).filter(({s:e})=>K(e.box,t,n)).sort((e,t)=>O(t.s.box)-O(e.s.box)||e.at-t.at).map(({s:e})=>e)}function q(e,t,n){return I(e,t,n).at(-1)??null}function H(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 X(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 Y(e,t,n,l,a=()=>!1,r=()=>!0){const o=e.filter(e=>K(e.box,t,n)).sort((e,t)=>O(e.box)-O(t.box));for(const e of o){const o=H(e,t,n),s={...e.list,index:o};if(a(s))return null;if(l(s))return{zone:e,to:s,line:X(e,o)};if(!r(s))return null}return null}function F(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)),x=Math.max(...m.map(e=>r?e.top+e.height:e.left+e.width)),b=r?{left:f,top:g,width:p,height:x-g}:{left:g,top:f,width:x-g,height:p};d.push({key:`${e.key}:+${a}`,place:{...e.list,index:a},box:b,axis:e.axis,label:t})}return d}function P(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 Q={nodes:[],zones:[]},R="data-puck-dropzone",Z="data-puck-component";function J(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 V(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(`[${R}]`)){if(x(e))continue;const t=e.getAttribute(R)??"";let n;try{n=s(t)}catch{continue}const l=[...e.querySelectorAll(`[${Z}]`)].filter(t=>t.parentElement?.closest(`[${R}]`)===e&&!x(t)),i=l.map(a);o.push({key:t,list:n,box:a(e),axis:J(i,e),children:i}),l.forEach((e,t)=>{const l=e.getAttribute(Z);l&&r.push({id:l,place:{...n,index:t},box:i[t]})})}return{nodes:r,zones:o}}var W="data-es-empty-cell",U="data-puck-dropzone",G=140;var _=e=>({left:e.left,top:e.top,width:e.width,height:e.height});function ee(o){const{canvas:s,session:m,readOnly:x,words:D=e.canvas}=o,T=b(o);y(()=>{T.current=o});const C=b(null),S=c(s),[$,E]=v(0),K=w(()=>E(e=>e+1),[]),[O,q]=v(Q);y(()=>{const e=C.current;s&&e&&q((T.current.measure??V)(s,e))},[s,S,o.revision,$]);const H=o.model,X=k(()=>H(O),[H,O]),F=N(m.subscribe,m.shown,m.shown),P=o.choose,R=(e,t)=>{const n=I(X.sources,e,t);return 0===n.length?null:P?P(n):n[n.length-1]},[Z,J]=v(null),[G,ee]=v(null),[te,ne]=v(null),le=b(null),ae=()=>{le.current&&clearTimeout(le.current),le.current=null},re=()=>{ae(),le.current=setTimeout(()=>{m.get()||J(null)},140)};y(()=>ae,[]);const oe=b(null),se=d(s),ie=b(!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||x||F?null:O.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=R(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||K()});const he=b(null),fe=w(()=>{he.current?.(),he.current=null,ee(null),ne(null)},[]);y(()=>m.subscribe(()=>{m.get()?K():fe()}),[m,fe,K]),y(()=>fe,[fe]),("undefined"==typeof document?y:A)(()=>{if(m.get())return;const e=oe.current;J(t=>x||ie.current?null:e?R(e.x,e.y):t?X.sources.find(e=>e.key===t.key)??null:null)},[X,F,m,x,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=I(X.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=Y(X.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),ee(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 ee(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};ee(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,ee(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))}},xe={draggable:!x&&!!Z,onMouseEnter:ae,onMouseLeave:()=>!m.get()&&re(),onDragStart:e=>{if(Z&&!x){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&&!x&&T.current.onPick?.(Z.item)}},{seams:be=[]}=X,ye=X.zones.filter(e=>0===e.children.length),ve=!o.onZoneAdd||x||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(`[${U}]`))n.toggleAttribute(W,t.has(n.getAttribute(U)??""));return()=>{for(const t of e.querySelectorAll(`[${W}]`))t.removeAttribute(W)}},[s,we,O,S,$]),/* @__PURE__ */L("div",{ref:C,className:"es-canvas-layer",children:[F||!o.onSeamAdd||x||se?null:be.map(e=>
|
|
5
|
+
/* @__PURE__ */j(B,{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__ */j("button",{type:"button",className:["es-canvas-empty",e.addAlways?"is-always":"",G?.zoneKey===e.key?"is-over":""].filter(Boolean).join(" "),style:_(e.box),"data-node-id":e.list.parentId===i?void 0:e.list.parentId,onClick:()=>o.onZoneAdd?.({...e.list,index:0}),children:/* @__PURE__ */j("span",{className:"es-canvas-empty-add",children:D.addButton({label:e.addLabel??o.zoneAddLabel??D.addBlock})})},e.key)):null,F?/* @__PURE__ */j("div",{className:"es-canvas-catch",...ge}):null,te&&F?/* @__PURE__ */j("div",{className:"es-canvas-target",style:_(te.box),children:o.dropOn?.label?/* @__PURE__ */j("span",{className:"es-canvas-target-label",style:M(),children:o.dropOn.label(F.item,te)}):null}):null,G&&!ye.some(e=>e.key===G.zoneKey)?/* @__PURE__ */j("div",{className:`es-canvas-line is-${G.axis}`,style:_(G.line)}):null,ue?/* @__PURE__ */j("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__ */j("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__ */j(z,{className:"es-canvas-handle-tip",side:"top",content:!Z||x||F?null:Z.title??D.handle({label:Z.label}),children:/* @__PURE__ */L("div",{className:["es-canvas-handle",Z&&!x?"is-shown":"",F?"is-dragging":""].filter(Boolean).join(" "),...xe,children:[
|
|
7
7
|
/* @__PURE__ */j("span",{className:"es-canvas-grip","aria-hidden":"true",children:"⋮⋮"}),Z?.label]})})})]})}var te=e=>e.tiles.length>0&&e.tiles.every(e=>null!=e.cover);function ne({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(),x=p.trim().toLowerCase(),b=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:b[t],tiles:x?e.tiles.filter(e=>((e,t)=>e.label.toLowerCase().includes(t)||(e.keywords??[]).some(e=>e.toLowerCase().includes(t)))(e,x)):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
8
|
return L("div",{className:"es-add",children:[s?/* @__PURE__ */L("div",{className:"es-add-at",role:"status",children:[
|
|
9
9
|
/* @__PURE__ */j("span",{children:s.label}),o(u.stop,/* @__PURE__ */j("button",{type:"button",className:"es-add-at-clear","aria-label":u.stop,onClick:s.onClear,children:/* @__PURE__ */j($,{size:12,"aria-hidden":"true"})}))]}):null,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useSectionOps as o}from"./chunk-WEIE2FBC.js";import{SELECTION_MODE as e}from"./chunk-PAOZMXEI.js";import{useEasel as r}from"./chunk-EFHV56BO.js";import{usePreviewParts as t}from"./chunk-I54UCYOU.js";import{decodePartId as n,encodePartId as p}from"./chunk-IYT6NN2J.js";import{useCallback as d,useEffect as c}from"react";var s=o=>"part"===o.kind;function m({mode:m,setMode:i,onOpenPart:I}){const{getSelectorForId:a}=r(o=>o),u=o(),{setSelectedPartId:f,setSelectHandler:k}=t(),l=d(o=>{const r=n(o);if(!r)return;const{nodeId:t,propKey:p}=r;p?(i(o=>s(o)&&o.nodeId===t&&o.propKey===p?o:{kind:"part",nodeId:t,propKey:p}),I?.(t)):i(o=>"part"===o.kind?e:o)},[i,I]);c(()=>{k(l)},[k,l]);const h=s(m)?p(m.nodeId,m.propKey):null;c(()=>{f(h)},[h,f]);return{selectNode:d(o=>{i(()=>e);const r=a(o);r&&u.select(r)},[i,a,u]),openPartId:h}}export{m as usePartBridge};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{usePickFollowsSelection as n}from"./chunk-FHCKFOCD.js";import{EaselCanvas as e,useSelectedFields as t}from"./chunk-EFHV56BO.js";import{Inspector as r}from"./chunk-7LYKFL3Q.js";import{slotFieldsOf as i}from"./chunk-PLVEGYK6.js";import{createContext as o,useContext as u}from"react";import{DesktopIcon as l}from"efficient-shell/icons/efficient";import{jsx as s}from"react/jsx-runtime";var c={kind:"puck"};function f(n,e){const t=n,r=e,i=Object.keys(t);return i.length===Object.keys(r).length&&i.every(n=>Object.is(t[n],r[n]))}function a(n){const e=n;return"string"==typeof e.nodeId&&"string"==typeof e.slot}function d(n,e,t){const r=n.slotsOf?.(t);return r||i(e,t.type).map(n=>({slot:n,label:n,rung:!1}))}function p(n,e){return n.isFirst?n.isFirst(e):e.type===n.first}function m(n,e){return n.isLast?n.isLast(e):e.type===n.last}var k={},h=()=>k,v=()=>"",g=()=>null,y=()=>{},b={isLockedBlock:()=>!1,duplicateBlocked:()=>null,nestDepth:()=>0,newSectionNode:()=>null,canAddTo:()=>null,blockIsOffered:()=>!0},O={labelAtLevel:(n,e,t)=>t,descriptions:{},categoryLabel:()=>{},firstSection:null,blockRowName:(n,e)=>e(n.type),plainText:n=>n,Icon:()=>null,Thumbnail:()=>null,useProducts:()=>null},L={options:[{id:"desktop",label:"Desktop",icon:/* @__PURE__ */s(l,{})}],initial:"desktop",fluid:"desktop",widths:{desktop:2e3}},j={read:()=>"sections",write:()=>{},forSelection:(n,e)=>n?"sections":e},w={first:null,last:null,firstGroup:null,lastGroup:null,isSectionGroup:()=>!1,sectionGroupZone:()=>"",panelOf:()=>null};function C(){/* @__PURE__ */
|
|
2
|
+
return s(e,{height:"fill"})}function F(){const{id:n,fields:e,values:i,readOnly:o,onChange:u}=t();/* @__PURE__ */
|
|
3
|
+
return s("div",{className:"es-sidepanel es-sidepanel--right",children:/* @__PURE__ */s(r,{fields:e,values:i,onChange:u,readOnly:o,idPrefix:n})})}var S=o({});function D({parts:n,children:e}){/* @__PURE__ */
|
|
4
|
+
return s(S.Provider,{value:n,children:e})}function P(){return u(S)}function B(){return(P().useOwnerName??v)()}function G(){return(P().useDocumentLabel??g)()}function N(n,e,t,r){return(P().useBridges??h)(n,e,t,r)}function x(n){return(P().useStandaloneBridges??h)(n)}function I(n,e){(P().useDocumentPass??y)(n,e)}function K(){return P().blockRules??b}function H(){return P().blockLook??O}function T(){return P().devices??L}function V(){return P().leftView??j}function A(){return P().pinned??w}function E(){return P().saveSwitch??!0}function R(e){n(!0===P().pickFollowsSelection,e)}function Y(){return P().storageNamespace||void 0}function Q(){return P().styleClipboard??null}function Z(){return P().nodeKeys??!0}function q(){return P().notify??null}function z(){return P().Canvas??C}function J(){return P().CanvasHead??null}function M(){return P().canvasDrag??null}var U=o(null);function W({target:n,children:e}){/* @__PURE__ */
|
|
5
|
+
return s(U.Provider,{value:n,children:e})}function X(){return u(U)}function $(){return P().Inspector??F}export{c as SELECTION_MODE,W as ScreenCanvasTargetProvider,D as ScreenPartsProvider,p as isPinnedFirst,m as isPinnedLast,a as isSlotMode,f as sameInspectorMode,d as screenSlotsOf,H as useScreenBlockLook,K as useScreenBlockRules,N as useScreenBridges,M as useScreenCanvasDrag,z as useScreenCanvasFrame,J as useScreenCanvasHead,X as useScreenCanvasTarget,T as useScreenDevices,G as useScreenDocumentLabel,I as useScreenDocumentPass,$ as useScreenInspectorPanel,V as useScreenLeftView,Z as useScreenNodeKeys,q as useScreenNotify,B as useScreenOwnerName,P as useScreenParts,R as useScreenPickFollowsSelection,A as useScreenPinned,E as useScreenSaveSwitch,Y as useScreenStorageNamespace,Q as useScreenStyleClipboard,x as useStandaloneScreenBridges};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import{buildPaletteSections as e,pinnedSection as t,categoryLabel as n}from"./chunk-PA3PNTVV.js";import{blockTypesIn as o}from"./chunk-5ZBY24K7.js";import{sectionTemplatesOf as l}from"./chunk-BVN33R76.js";import{sharedSectionsOf as r}from"./chunk-43AEUUNQ.js";import{SidePanelHead as i,PanelModeExit as s}from"./chunk-SINAM2IT.js";import{blockRuns as c}from"./chunk-M2Z775ZC.js";import{useScreenBlockLook as a,useScreenBlockRules as d,useScreenPinned as p}from"./chunk-PAOZMXEI.js";import{useEaselSession as m}from"./chunk-O7Q4DDJT.js";import{DEFAULT_SCREEN_WORDS as f}from"./chunk-23DYNW6S.js";import{useEasel as u}from"./chunk-EFHV56BO.js";import{easelMenuEntries as y}from"./chunk-FIVU2COQ.js";import{useWords as h}from"./chunk-MFIRYGHW.js";import{AddPanel as k}from"./chunk-LQV5FZTQ.js";import{DEFAULT_DRAG_WORDS as g}from"./chunk-KAML3KQH.js";import{useState as b,useEffect as v,useMemo as j,useRef as w}from"react";import{SharedIcon as C,AddIcon as O}from"efficient-shell/icons/efficient";import{ContextMenu as T,toast as A,Dialog as E,Button as F}from"efficient-shell/ui";import{jsx as I,jsxs as M,Fragment as $}from"react/jsx-runtime";function x({name:e,pages:t,onDelete:n,onCancel:o}){const l=h("screen",f).shared,[r,i]=b(!1),s=w(null);/* @__PURE__ */
|
|
2
|
+
return I(E,{open:!0,role:"alertdialog",size:"sm",title:l.deleteTitle({name:e}),onClose:o,initialFocus:s,footer:/* @__PURE__ */M($,{children:[
|
|
3
|
+
/* @__PURE__ */I(F,{ref:s,variant:"secondary",onClick:o,children:l.cancel}),
|
|
4
|
+
/* @__PURE__ */I(F,{variant:"danger",loading:r,onClick:()=>{(async()=>{i(!0);try{await n()}finally{i(!1)}})()},children:l.deleteShared})]}),children:l.deleteMessage({count:t})})}var N=e=>`section:${e}`,B=e=>`block:${e}`,D=e=>`template:${e}`,L=e=>`shared:${e}`;function Q({at:w,placeBlocks:E,canTake:F,onPick:Q,itemFor:S,session:V,siteWide:H,onClose:P,onHide:Z,readOnly:z}){const W=u(e=>e.config),K=a(),{labelAtLevel:R,categoryLabel:U,firstSection:Y,Icon:_,Thumbnail:G}=K,{blockIsOffered:J,canAddTo:X}=d(),q=h("screen",f).add,ee=h("drag",g).add,te=m(),[ne,oe]=b([]);v(()=>{let e=!1;const t=e=>J(e,te);return l(te).list().then(n=>{if(e)return;const l=W.components;oe(n.filter(e=>e.node?.type&&l[e.node.type]&&o(e.node).every(t)))}).catch(()=>{}),()=>{e=!0}},[W,te]);const le=p().shared,re=h("screen",f).shared,[ie,se]=b([]),[ce,ae]=b(0);v(()=>{if(!le)return;let e=!1;const t=e=>J(e,te);return r(te).list().then(n=>{if(e)return;const l=W.components;se(n.filter(e=>e.node?.type&&l[e.node.type]&&o(e.node).every(t)))}).catch(()=>{}),()=>{e=!0}},[W,te,ce]);const[de,pe]=b(null),[me,fe]=b(null),ue=j(()=>e(W,K),[W]),ye=e=>R(e,"section",W.components[e]?.label??e),he=e=>({type:N(e.type),label:e.name,cover:/* @__PURE__ */I(G,{type:e.type}),title:e.desc?`${e.name} — ${e.desc}`:q.tile({name:e.name}),keywords:[e.alias??"",e.desc,e.type,e.catLabel].filter(Boolean)}),ke=e=>{const t=e.indexOf(":"),n=e.slice(0,t),o=e.slice(t+1);if("section"===n)return{kind:"section",type:o};if("block"===n)return{kind:"block",type:o};if("template"===n){const e=ne.find(e=>e.id===o);return e?{kind:"template",template:e}:null}if("shared"===n){const e=ie.find(e=>e.id===o);return e?{kind:"shared",section:e}:null}return null},ge=e=>/* @__PURE__ */I("span",{className:"es-add-glyph-cover",children:/* @__PURE__ */I(_,{type:e,size:26})}),be=j(()=>{const e=t(ue,Y),o=/* @__PURE__ */new Map,l=e=>{e.retired||o.has(e.type)||!J(e.type,te)||o.set(e.type,e)};for(const t of e?[e]:ue){const e=X(t.type)?.choices??[];e.forEach(l),e.forEach(e=>X(e.type,1)?.choices?.forEach(l))}E?.forEach(l);const r=new Set(ue.map(e=>e.type)),i=[...o.values()].filter(e=>!r.has(e.type)),s=e=>({type:B(e.type),label:e.label,cover:ge(e.type),title:q.tile({name:e.label}),keywords:[e.group??"",e.type].filter(Boolean)}),a=e=>o.has(e.type)?{...he(e),cover:ge(e.type)}:he(e),d=[];ie.length>0&&d.push({key:"shared",title:re.group,tiles:ie.map(e=>({type:L(e.id),label:e.title,cover:/* @__PURE__ */I(G,{type:e.node.type}),mark:/* @__PURE__ */I(C,{size:12}),title:re.onPages({count:e.used_on.length}),keywords:[ye(e.node.type),e.node.type]}))}),ne.length>0&&d.push({key:"templates",title:q.templates,tiles:ne.map(e=>({type:D(e.id),label:e.name,cover:/* @__PURE__ */I(G,{type:e.node.type}),keywords:[ye(e.node.type),e.node.type]}))});const p=i.filter(e=>!e.group);let m=!1;for(const t of Object.keys(W.categories??{})){const o=ue.filter(e=>e.cat===t);if(0===o.length)continue;const l=e&&o.some(t=>t.type===e.type)?e:null,r=(l?[l,...o.filter(e=>e.type!==l.type)]:o).map(a);l&&!m&&(r.splice(1,0,...p.map(s)),m=!0),d.push({key:`category:${t}`,title:n(W,t,U),tiles:r})}const f=d.find(e=>e.key?.startsWith("category:"));if(!m&&f&&p.length>0&&(f.tiles=[...f.tiles,...p.map(s)],m=!0),c(i.filter(e=>e.group||!m)).forEach((e,t)=>{d.push({key:`blocks:${t}`,title:e.group??"",tiles:e.items.map(s)})}),!F)return d;const u=d.map(e=>({...e,tiles:e.tiles.map(e=>{const t=ke(e.type),n=t?F(t):null;return n?{...e,disabled:!0,disabledReason:n}:e})})),y=e=>e.tiles.some(e=>!e.disabled);return[...u.filter(y),...u.filter(e=>!y(e))]},[ne,ie,re,ue,W,q,F,E,te]);/* @__PURE__ */
|
|
5
|
+
return M($,{children:[
|
|
6
|
+
/* @__PURE__ */I(i,{icon:/* @__PURE__ */I(O,{size:15}),title:q.title,context:q.contextAll,actions:/* @__PURE__ */I(s,{label:q.done,description:q.doneDescription,onClick:P}),onHide:Z}),
|
|
7
|
+
/* @__PURE__ */M("div",{className:"sf-addside sf-scroll",children:[
|
|
8
|
+
/* @__PURE__ */I(k,{groups:be,session:V,itemFor:e=>S(ke(e)??{kind:"section",type:e}),onInsert:Q?e=>{const t=ke(e);t&&Q(t)}:void 0,onTileMenu:(e,t)=>{const n=ke(e);return"shared"===n?.kind&&!z&&(pe({section:n.section,...t}),!0)},at:w,hint:q.hint,searchLabel:q.search,readOnly:z,words:ee}),H??null]}),de?/* @__PURE__ */I(T,{at:{x:de.x,y:de.y},owner:de.owner,onClose:()=>pe(null),"aria-label":de.section.title,items:y([{label:re.deleteShared,danger:!0,onClick:()=>{fe(de.section),pe(null)}}])}):null,me?/* @__PURE__ */I(x,{name:me.title,pages:me.used_on.length,onDelete:()=>(async e=>{try{await r(te).remove(e.id)}catch{return void A.error(re.deleteFailed)}fe(null),le?.removed?.(e),se(t=>t.filter(t=>t.id!==e.id)),ae(e=>e+1)})(me),onCancel:()=>fe(null)}):null]})}export{Q as AddSidePanel,B as blockKey,N as sectionKey,L as sharedKey,D as templateKey};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useScreenBlockRules as e}from"./chunk-PAOZMXEI.js";import{useEasel as t,useEaselApi as n}from"./chunk-EFHV56BO.js";import{newNodeId as o,ROOT_ZONE as r}from"./chunk-PLVEGYK6.js";import{useMemo as s}from"react";function i(i={}){const{dispatch:p}=t(e=>e),d=n(),c=!0===i.readOnly,a=e().resolveOnInsert,l=!0===(i.resolveOnInsert??a),m=!0===i.foldIntoHistory;return s(()=>{const e=m?e=>p({...e,recordHistory:!1}):p,t=(t,n,r)=>{const s=o(n);return c||e({type:"insert",componentType:n,destinationZone:t,destinationIndex:r,id:s}),s},n=e=>(l&&!c&&d.resolveNode(e,{trigger:"insert"}),e),s=(t,n,o)=>{c||e({type:"replace",destinationZone:t,destinationIndex:n,data:o})},i=(e,o,r)=>n(t(e,o,r));return{insertComponent:i,insertSection:(e,t)=>i(r,e,t),replaceComponent:s,seedChild:(e,o,r,i)=>{const p=t(e,r,o);s(e,o,{type:r,props:{id:p,...i}}),n(p)},insertNode:(e,o,r)=>{const i=t(e,r.type,o);return s(e,o,{type:r.type,props:{...r.props,id:i}}),n(i)},removeComponent:(t,n)=>{c||e({type:"remove",index:n,zone:t})},reorderComponent:(t,n,o)=>{c||e({type:"reorder",sourceIndex:n,destinationIndex:o,destinationZone:t})},duplicateComponent:(t,n)=>{c||e({type:"duplicate",sourceIndex:n,sourceZone:t})},select:e=>p({type:"setUi",ui:{itemSelector:e}}),setDocument:t=>{c||e({type:"setData",data:t})},commitDocument:(t,n)=>{c||(m?d.batch(()=>{e({type:"setData",data:t}),void 0!==n&&("slot"===n?.kind?d.selectSlot({parentId:n.parentId,slot:n.slot}):d.select(n?n.id:null))}):d.run({data:t,select:n}))}}},[p,c,l,d,m])}export{i as useSectionOps};
|