efficient-easel 26.12.0 → 26.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/README.md +12 -0
  2. package/dist/{canvas-typing-DOBx8dD3.d.ts → canvas-typing--FlIZwbT.d.ts} +15 -1
  3. package/dist/chunk-3BQT7FC7.js +7 -0
  4. package/dist/{chunk-QVQ7764L.js → chunk-3YHGKDBV.js} +4 -4
  5. package/dist/{chunk-IVSPOIOU.js → chunk-3ZGOVNVH.js} +1 -1
  6. package/dist/chunk-5OYP3C2K.js +1 -0
  7. package/dist/{chunk-KWGABNNM.js → chunk-7U4HEUZM.js} +1 -1
  8. package/dist/{chunk-7GGNFLHT.js → chunk-BLE3U2GS.js} +1 -1
  9. package/dist/{chunk-Q3VAJMXS.js → chunk-C4TJN6GR.js} +1 -1
  10. package/dist/{chunk-BYONFJVQ.js → chunk-CPIWSFGR.js} +2 -2
  11. package/dist/{chunk-STQDOTHF.js → chunk-H4TUOPI7.js} +1 -1
  12. package/dist/chunk-K6TDOXHR.js +17 -0
  13. package/dist/chunk-L4DFCNDQ.js +5 -0
  14. package/dist/{chunk-I7NHUVP6.js → chunk-M4SOZEZR.js} +4 -4
  15. package/dist/{chunk-TOEJCZUO.js → chunk-MGEXTIZH.js} +1 -1
  16. package/dist/chunk-NUJEHA6A.js +19 -0
  17. package/dist/{chunk-CVS3RPO6.js → chunk-PG7G7ELT.js} +1 -1
  18. package/dist/chunk-RWGOCHH7.js +1 -0
  19. package/dist/{chunk-JYVQ62TL.js → chunk-U4TG43PD.js} +1 -1
  20. package/dist/chunk-VVHDUTAE.js +8 -0
  21. package/dist/chunk-Y2OWVL6W.js +64 -0
  22. package/dist/{chunk-P4XLNW3E.js → chunk-YMK3MZJK.js} +1 -1
  23. package/dist/copy/index.d.ts +2 -2
  24. package/dist/copy/index.js +29 -29
  25. package/dist/easel/index.d.ts +46 -8
  26. package/dist/easel/index.js +1 -1
  27. package/dist/screen/components/AddBlockRow.js +1 -1
  28. package/dist/screen/components/AddSidePanel.js +1 -1
  29. package/dist/screen/components/NodeContextMenu.js +1 -1
  30. package/dist/screen/components/PageEditGuardNotices.js +1 -1
  31. package/dist/screen/components/ScreenChrome.js +1 -1
  32. package/dist/screen/components/ScreenDocumentContext.js +1 -1
  33. package/dist/screen/components/ScreenMount.js +1 -1
  34. package/dist/screen/components/ScreenStoreProvider.js +1 -1
  35. package/dist/screen/components/SectionScreenShell.js +17 -17
  36. package/dist/screen/components/usePartBridge.js +1 -1
  37. package/dist/screen/index.js +1 -1
  38. package/dist/screen/lib/document/block-set-host.js +1 -1
  39. package/dist/screen/lib/document/block-size-fields.js +1 -1
  40. package/dist/screen/lib/document/box-fields.d.ts +13 -6
  41. package/dist/screen/lib/document/box-fields.js +1 -1
  42. package/dist/screen/lib/document/button-fields.js +1 -1
  43. package/dist/screen/lib/document/device-fields.js +1 -1
  44. package/dist/screen/lib/document/image-fields.d.ts +1 -2
  45. package/dist/screen/lib/document/image-fields.js +4 -4
  46. package/dist/screen/lib/document/shadow-fields.js +1 -1
  47. package/dist/screen/lib/document/style-clipboard.js +1 -1
  48. package/dist/screen/lib/document/style-fields.js +1 -1
  49. package/dist/screen/lib/document/use-section-ops.js +1 -1
  50. package/dist/screen/lib/key-scope.js +1 -1
  51. package/dist/screen/lib/screen-parts.js +1 -1
  52. package/dist/screen/words.d.ts +2 -0
  53. package/dist/screen/words.js +1 -1
  54. package/dist/strings/index.js +2 -2
  55. package/package.json +1 -1
  56. package/dist/chunk-4SYDN43N.js +0 -1
  57. package/dist/chunk-CQVSWONH.js +0 -1
  58. package/dist/chunk-EVYIDHCK.js +0 -19
  59. package/dist/chunk-HZSZT3BE.js +0 -7
  60. package/dist/chunk-UMRYCN7L.js +0 -16
  61. package/dist/chunk-UR7YBZJR.js +0 -5
  62. package/dist/chunk-W2UMJ7WO.js +0 -8
  63. package/dist/chunk-YQXHRQXH.js +0 -64
@@ -1 +0,0 @@
1
- import{useSectionOps as o}from"./chunk-IVSPOIOU.js";import{SELECTION_MODE as e}from"./chunk-UR7YBZJR.js";import{decodePartId as r,encodePartId as t}from"./chunk-R4AUZVA3.js";import{useEasel as n}from"./chunk-EVYIDHCK.js";import{usePreviewParts as p}from"./chunk-467WWV4I.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}=n(o=>o),u=o(),{setSelectedPartId:f,setSelectHandler:k}=p(),l=d(o=>{const t=r(o);if(!t)return;const{nodeId:n,propKey:p}=t;p?(i(o=>s(o)&&o.nodeId===n&&o.propKey===p?o:{kind:"part",nodeId:n,propKey:p}),I?.(n)):i(o=>"part"===o.kind?e:o)},[i,I]);c(()=>{k(l)},[k,l]);const h=s(m)?t(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};
@@ -1,19 +0,0 @@
1
- import{findCopy as e,repeatCopyWithWrapper as t}from"./chunk-JQQFB7EZ.js";import{DEFAULT_CANVAS_WORDS as n}from"./chunk-TBY3DFKS.js";import{useResolvedFields as o}from"./chunk-K53PQAMP.js";import{toItemSelector as r,fromItemSelector as l,useNodeOps as i,parentStep as s,clickPickPart as a,clickPick as c}from"./chunk-QTHQPJWA.js";import{selectionBox as u,placeWindow as d,offsetOrigin as p,colorRunOf as f,ColorWindow as h,startCanvasTyping as m,textMap as g,richLayout as v}from"./chunk-HZSZT3BE.js";import{DEFAULT_COPY_WORDS as y}from"./chunk-PMRN5Z3T.js";import{useWords as w}from"./chunk-MFIRYGHW.js";import{CANVAS_TYPABLE_EVENT as b,CANVAS_TYPING_EVENT as k}from"./chunk-TOKMFZPB.js";import{setCanvasNonce as S,related as x,isTypingTarget as C,upsertCanvasStyle as E,removeCanvasStyle as I,WORDS_CLEAR as D,frameRectToHost as A,drawnBox as M}from"./chunk-FR7EEKFF.js";import{queryAllCopies as $}from"./chunk-7UFKEX72.js";import{find as O,ROOT_ID as P,getList as z,remove as R,parseZoneKey as j,move as N,duplicate as V,replaceNode as L,createNode as B,insert as K,normalizeData as Z,createResolveCache as F,slotsOf as T,resolveNodeData as H,ROOT_SLOT as q}from"./chunk-EUFDQ4KL.js";import{topLevelSlotKeys as W,fieldsFrom as Q,drawnBlockCount as Y,defaultsFrom as U}from"./chunk-KXM6YRG2.js";import{createContext as X,useEffect as G,useContext as J,useRef as _,useSyncExternalStore as ee,useState as te,useReducer as ne,createElement as oe,useMemo as re,useCallback as le,useLayoutEffect as ie}from"react";import{jsx as se,jsxs as ae,Fragment as ce}from"react/jsx-runtime";import{createPortal as ue}from"react-dom";import{registerModalEscapeInterceptor as de,FloatingBar as pe,TextToolbar as fe,LinkPicker as he}from"efficient-shell/ui";function me(e){return!["setData","setUi","set"].includes(e.type)}var ge=(e,t,n,o)=>{const r=z(e,t,j(n));return r?.[o]??null},ve=(e,t,n,o,r)=>{const l=ge(e,t,n,o);if(!l)throw new Error(`${r}: nothing at ${n}[${o}]`);return l};function ye(e,t){const{selection:n}=e;return{...e.ui,itemSelector:r(e.data,t,n),selectedSlot:n&&"slot"===n.kind?{parentId:n.parentId,slot:n.slot}:null}}function we(e,t,n){return n?"node"===n.kind?O(e,t,n.id)?n:null:n.parentId===P?z(e,t,n)?n:null:O(e,t,n.parentId)&&z(e,t,n)?n:null:null}function be(e,t,n,o=!1){const{itemSelector:r,selectedSlot:i,...s}=n;let a=e.selection;var c;return"itemSelector"in n&&(a=l(e.data,t,r??null)),"selectedSlot"in n&&(i?a=(c=i)?{kind:"slot",parentId:c.parentId,slot:c.slot}:null:"slot"===a?.kind&&(a=null)),{...e,selection:a,ui:o?s:{...e.ui,...s}}}function ke(e,t,n){const o=Se(e,t,n);if(o===e)return e;const r=we(o.data,n,o.selection);return r===o.selection?o:{...o,selection:r}}function Se(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 be(e,n,"function"==typeof t.ui?t.ui(ye(e,n)):t.ui);case"set":{const r={data:o,ui:ye(e,n)},l="function"==typeof t.state?t.state(r):t.state;let i=l.data?{...e,data:l.data}:e;return l.ui&&(i=be(i,n,l.ui,!0)),i}case"insert":{const r={...j(t.destinationZone),index:t.destinationIndex},l=B(n,t.componentType,{},t.id?{id:t.id}:{});return{...e,data:K(o,n,r,l)}}case"replace":{const r=ve(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:L(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=ve(o,n,t.sourceZone,t.sourceIndex,"duplicate"),l=V(o,n,r.props.id),i=ge(l,n,t.sourceZone,t.sourceIndex+1);return{...e,data:l,selection:i?{kind:"node",id:i.props.id}:e.selection}}case"reorder":return Se(e,{...t,type:"move",sourceZone:t.destinationZone},n);case"move":{if(t.sourceZone===t.destinationZone&&t.sourceIndex===t.destinationIndex)return e;const r=ge(o,n,t.sourceZone,t.sourceIndex);if(!r)return e;const l={...j(t.destinationZone),index:t.destinationIndex};return{...e,data:N(o,n,r.props.id,l)}}case"remove":{const r=ve(o,n,t.zone,t.index,"remove");return{...e,data:R(o,n,r.props.id)}}default:return e}}var xe={drag:!0,duplicate:!0,delete:!0,edit:!0,insert:!0},Ce={leftSideBarVisible:!0,rightSideBarVisible:!0,arrayState:{},componentList:{},isDragging:!1,previewMode:"edit",viewports:{current:{width:360,height:"auto"},options:[],controlsVisible:!0},field:{focus:null}},Ee=0,Ie=()=>`history-${Ee+=1}`;function De(e){let t=e.config;const n=e.now??(()=>Date.now()),o=e.historyCoalesceMs??250;let i=e.permissions??{};const s=Z(e.data,t);let a=s,c={data:s,selection:null,ui:{...Ce}};if(e.ui){const{itemSelector:n,selectedSlot:o,...r}=e.ui;c={data:s,selection:o?{kind:"slot",...o}:l(s,t,n??null),ui:{...Ce,...r}}}let u=[{core:c,at:-1/0,sealed:!0,id:Ie()}],d=0;const p=e=>{const t=u[d],r=n();!e&&d===u.length-1&&d>0&&!t.sealed&&r-t.at<o?u=[...u.slice(0,d),{...t,core:c,at:r}]:(u=[...u.slice(0,d+1),{core:c,at:r,sealed:e,id:Ie()}],d=u.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=()=>{u=[...u.slice(0,d),{...u[d],core:c},...u.slice(d+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=ke(c,e,t),c===n)return;const o=e.recordHistory??me(e);k(n,o&&c.data!==n.data)},x=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()},C=e=>{const n=c,o=we(c.data,t,e);var r,l;(r=o,l=c.selection,r===l||r&&l&&r.kind===l.kind&&("node"===r.kind&&"node"===l.kind?r.id===l.id:"slot"===r.kind&&"slot"===l.kind&&r.parentId===l.parentId&&r.slot===l.slot))||(c={...c,selection:o},k(n,!1))},E=t=>{const n=c;d=t,c=u[d].core,c.data!==n.data&&e.onChange?.(c.data),c!==n&&w()},I=()=>(e={})=>{const n=e.root?t.root?.permissions:t.components[e.item?.type??e.type??""]?.permissions;return{...xe,...i,...n}};let D=I();const A=F(),M={resolveCache:A,async resolveAll({trigger:e="load",metadata:n}={}){const o=c.data,r={type:"root",props:{...o.root.props??{}}},l=[...o.content,...Object.values(o.zones??{}).flat()],[i,...s]=await Promise.all([H(r,t,{cache:A,trigger:e,metadata:n}),...l.map(o=>H(o,t,{cache:A,trigger:e,metadata:n}))]);x(()=>{const n=c;let r=c.data;s.forEach((e,n)=>{if(!e.didChange)return;const i=l[n].props.id,s=O(r,t,i)?.node;s&&s===O(o,t,i)?.node&&(r=L(r,t,i,e.node))}),i.didChange&&r.root===o.root&&(r={...r,root:{...r.root,props:i.node.props,readOnly:i.node.readOnly??r.root.readOnly}}),r!==c.data&&("load"===e&&c.data===a&&(a=r),c={...c,data:r,selection:we(r,t,c.selection)},k(n,!1))})},async resolveNode(e,{trigger:n="replace",metadata:o}={}){const r=O(c.data,t,e)?.node;if(!r)return!1;const l=await H(r,t,{cache:A,trigger:n,metadata:o});if(!l.didChange)return!1;let i=!1;return x(()=>{const n=c;if(O(c.data,t,e)?.node!==r)return;const o=L(c.data,t,e,l.node);o!==c.data&&(c={...c,data:o,selection:we(o,t,c.selection)},k(n,!1),i=!0)}),i},get config(){return t},get loaded(){return a},getState(){if(h&&m===c)return h;const e=c,n={data:e.data,ui:ye(e,t)},o="node"===e.selection?.kind?O(e.data,t,e.selection.id)?.node??null:null;return h={appState:n,selection:e.selection,selectedItem:o,config:t,dispatch:S,history:{back:()=>M.undo(),forward:()=>M.redo(),hasPast:d>0,hasFuture:d<u.length-1,histories:u.map(e=>({id:e.id,state:{data:e.core.data,ui:ye(e.core,t)}})),index:d,setHistoryIndex:e=>{e>=0&&e<u.length&&e!==d&&E(e)}},getPermissions:D,getItemById:n=>O(e.data,t,n)?.node,getItemBySelector:n=>function(e,t,n){const[o,r]=(n.zone??"root:default-zone").split(/:(.*)/s);return z(e,t,{parentId:o,slot:r})?.[n.index]}(e.data,t,n),getSelectorForId:n=>{const o=r(e.data,t,{kind:"node",id:n});return o?{index:o.index,zone:o.zone??"root:default-zone"}:void 0}},m=e,h},subscribe:e=>(f.add(e),()=>{f.delete(e)}),dispatch:S,batch:x,group:()=>{const e=d,t=u[e].id;let n=!0;return{close:()=>{if(!n)return;if(n=!1,u[e]?.id!==t)return;if(d<=e+1)return void(d===e+1&&(u=[...u.slice(0,d),{...u[d],sealed:!0},...u.slice(d+1)]));const o=u[d];u=[...u.slice(0,e+1),{...o,sealed:!0},...u.slice(d+1)],d=e+1}}},select:e=>C(e?{kind:"node",id:e}:null),selectSlot:e=>C(e?{kind:"slot",parentId:e.parentId,slot:e.slot}:null),run(e){x(()=>{const n=c,o=void 0===e.select?c.selection:e.select;c={...c,data:e.data,selection:we(e.data,t,o)},k(n,e.data!==n.data)})},load(e,n={}){const o=c,r=Z(e,t);c={...c,data:r,selection:we(r,t,n.selection??c.selection)},a=r,n.keepHistory||(u=[{core:c,at:-1/0,sealed:!0,id:Ie()}],d=0),c!==o&&w()},undo(){d>0&&E(d-1)},redo(){d<u.length-1&&E(d+1)},setPermissions(e){(function(e,t){if(e===t)return!0;const n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>e[n]===t[n])})(e,i)||(i=e,D=I(),h=null,w())},setConfig(e){e!==t&&(t=e,D=I(),h=null,w())}};return M}function Ae(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&&C(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 Me=X(null),$e=X(!0);function Oe({easel:e,hotkeys:t=!0,resolveOnMount:n=!0,children:o}){return G(()=>{n&&e.resolveAll()},[e,n]),G(()=>{if(t&&"undefined"!=typeof document)return Ae(document,e)},[e,t]),/* @__PURE__ */se(Me.Provider,{value:e,children:/* @__PURE__ */se($e.Provider,{value:t,children:o})})}function Pe(){const e=J(Me);if(!e)throw new Error("useEasel: no <EaselProvider> above this component");return e}function ze(e){const t=Pe(),n=_({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 l=e(o);return r.has&&Object.is(r.value,l)?(n.current={view:o,selector:e,value:r.value,has:!0},r.value):(n.current={view:o,selector:e,value:l,has:!0},l)};return ee(t.subscribe,o,o)}function Re(){return function(e){return ze(e)}}var je=["--es-accent","--es-accent-tint","--es-accent-tint-strong","--es-accent-line","--es-accent-text","--es-accent-ring","--es-accent-shadow","--es-on-accent","--status-success-solid","--elevation-panel"],Ne="host-tokens";function Ve(e,t){const n=function(e){const t=e.ownerDocument.defaultView;if(!t)return"";const n=t.getComputedStyle(e),o=[];for(const e of je){const t=n.getPropertyValue(e).trim();t&&o.push(`${e}: ${t};`)}return o.length?`:root { ${o.join(" ")} }`:""}(e);n?E(t,Ne,n):I(t,Ne)}var Le="data-easel-block",Be="data-easel-dropzone",Ke={},Ze="data-es-mirror",Fe="undefined"==typeof window?G:ie;function Te(e,t,n){for(const e of Array.from(t.head.querySelectorAll(`[${Ze}]`)))e.remove();for(const o of Array.from(e.head.querySelectorAll('style, link[rel="stylesheet"]'))){const e=o.cloneNode(!0);e.setAttribute(Ze,""),n&&e.setAttribute("nonce",n),t.head.appendChild(e)}}function He({children:e,id:t="preview-frame",title:o,className:r,style:l,mirrorStyles:i=!0,onDocument:s,height:a="auto",nonce:c}){const u=w("canvas",n),d=_(null),[p,f]=te(null);return Fe(()=>{const e=d.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]),Fe(()=>{let e=d.current?.contentDocument;if(!e)return;"CSS1Compat"!==e.compatMode&&(e.open(),e.write("<!DOCTYPE html><html><head></head><body></body></html>"),e.close(),e=d.current?.contentDocument??e),e.body||e.documentElement.appendChild(e.createElement("body")),e.body.style.margin="0";const t=e.createElement("div");t.setAttribute("data-easel-entry",""),t.id="frame-root","fill"===a&&t.classList.add("es-frame-fill"),e.body.appendChild(t),S(e,c),f(t),s?.(e);let n=null;const o=d.current?.ownerDocument;if(i&&o){Te(o,e,c);const t=o.defaultView;t&&"MutationObserver"in t&&(n=new t.MutationObserver(()=>Te(o,e,c)),n.observe(o.head,{childList:!0,subtree:!0,characterData:!0}))}let r=null;const l=d.current;if(l&&o){Ve(l,e);const t=o.defaultView;if(t&&"MutationObserver"in t){r=new t.MutationObserver(()=>Ve(l,e)),r.observe(o.head,{childList:!0,subtree:!0,characterData:!0});const n={attributes:!0,attributeFilter:["class","style","data-theme"]};for(const e of[o.documentElement,o.body,l.closest(".es-editor")])e&&r.observe(e,n)}}return()=>{n?.disconnect(),r?.disconnect(),t.remove(),f(null),s?.(null)}},[]),/* @__PURE__ */se("iframe",{ref:d,id:t,title:o??u.frame,className:["es-canvas-frame","fill"===a?"is-fill":"",r??""].filter(Boolean).join(" "),style:l,children:p?ue(e,p):null})}var qe=X(null),We=X(Ke),Qe=[];function Ye({parentId:e,slot:t,className:n,style:o,minEmptyHeight:r=128,minEmptyWidth:l=120}){const i=Pe(),s=ze(n=>z(n.appState.data,i.config,{parentId:e,slot:t})??Qe),a=ze(t=>"node"===t.selection?.kind&&t.selection.id===e&&e!==P),c=ze(n=>"slot"===n.selection?.kind&&n.selection.parentId===e&&n.selection.slot===t),u=J(qe),d=["es-zone"];return s.length&&d.push("has-children"),e===P&&d.push("is-root"),(a||c)&&d.push("is-area-selected"),null!==u&&u===e&&e!==P&&d.push("is-hovering-area"),n&&d.push(n),/* @__PURE__ */se("div",{className:d.join(" "),[Be]:`${e}:${t}`,style:{...o,"--min-empty-height":`${r}px`,"--min-empty-width":`${l}px`},children:s.map(e=>/* @__PURE__ */se(nt,{node:e},e.props.id))})}function Ue(e,t,n,o){const r=re(()=>{const n={};for(const o of W(Q(e)))n[o]=Object.assign(function(e={}){/* @__PURE__ */
2
- return se(Ye,{parentId:t,slot:o,...e})},{blockCount:0});return n},[e,t]);for(const e of Object.keys(r))r[e].blockCount=Y(n[e],o);return r}function Xe(e){return re(()=>function({zone:t,...n}){/* @__PURE__ */
3
- return se(Ye,{parentId:e,slot:t,...n})},[e])}var Ge=["top","bottom","zIndex"];function Je(e,t,n){e.style[t]!==n&&(e.style[t]=n)}function _e(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));Je(e,"position",t?"sticky":"relative");for(const n of Ge)Je(e,n,t?.[n]??"");return!!t}var et="data-es-canvas-relative";function tt(e){e.hasAttribute(et)&&("relative"===e.style.position&&(e.style.position=""),e.removeAttribute(et));const t=e.ownerDocument.defaultView?.getComputedStyle(e).position;return t&&"static"!==t?"sticky"===t:(e.style.position||(e.style.position="relative",e.setAttribute(et,"")),!1)}function nt({node:e}){const t=Pe().config,n=t.components[e.type],o=e.props.id,r=_(null),l=function(e,t){return re(()=>n=>{const o=t.current;o&&o!==n&&(o.removeAttribute(Le),o.removeAttribute("data-easel-dnd")),t.current=n,n&&(n.setAttribute(Le,e),n.setAttribute("data-easel-dnd",e),tt(n))},[e,t])}(o,r),i=_(null),s=!!n?.inline;!function(e,t){const n=_(!1),o=_(()=>{});o.current=()=>{const o=e(),l=n.current;n.current=!!o&&t(o),l!==n.current&&r.current()};const r=_(()=>{});Fe(()=>o.current()),Fe(()=>{const t=e(),l=t?.ownerDocument.defaultView;if(!t||!l)return;const i=()=>o.current();l.addEventListener("resize",i);const s=l.ResizeObserver,a=s?new s(i):null;a?.observe(t);let c=null;return r.current=()=>{c?.disconnect(),c=null;const e=t.ownerDocument.documentElement;n.current&&e&&l.MutationObserver&&(c=new l.MutationObserver(i),c.observe(e,{attributes:!0}))},r.current(),()=>{l.removeEventListener("resize",i),a?.disconnect(),c?.disconnect(),r.current=()=>{}}},[])}(()=>s?r.current:i.current,e=>s?tt(e):_e(e));const a=J(We),c=Ue(n,o,e.props,t.components),u=Xe(o);if(!n?.render)return null;const d=n.render,p={...U(n),...e.props,...c},f={renderDropZone:u,isEditing:!0,dragRef:n.inline?l:null,metadata:{...a,...n.metadata}};return n.inline?/* @__PURE__ */se(d,{...p,editor:f,editMode:!0}):
4
- /* @__PURE__ */se("div",{ref:i,[Le]:o,"data-easel-dnd":o,style:{position:"relative"},children:/* @__PURE__ */se(d,{...p,editor:f,editMode:!0})})}function ot({metadata:e}){const t=ze(e=>e.config),n=ze(e=>e.appState.data.root).props??{},o=t.root?.render,r=Ue(t.root,P,n,t.components),l=Xe(P),i=/* @__PURE__ */se(Ye,{parentId:P,slot:q}),s=o?/* @__PURE__ */se(o,{id:"page-root",...n,...r,editor:{renderDropZone:l,isEditing:!0,dragRef:null,metadata:e??{}},editMode:!0,children:i}):i;/* @__PURE__ */
5
- return se(We.Provider,{value:e??Ke,children:s})}var rt=X(void 0),lt=X(void 0);function it(e,t,n,o){const r=O(e,t,n);return!!r&&(T(r.node,t).length>0||!1===o.whole)}var st=X(void 0),at="data-es-chrome",ct=X(void 0);function ut(e){const t=e?.closest?.(`[${at}]`)??null,n=t?.getAttribute(at);return t&&n?{id:n,element:t}:null}function dt({element:e,clip:t=!1}){const n=_(null),o=ht(n,e?()=>e:null,e),r=J(kt);/* @__PURE__ */
6
- return se("div",{ref:n,"aria-hidden":"true",className:"es-canvas-outline is-hover is-hover-part",style:o?{position:"absolute",top:o.top,left:o.left,width:o.width,height:o.height,clipPath:t?bt(o,r):void 0}:{display:"none"}})}var pt={"--es-words-clear":`${D}px`};function ft({element:e,words:t=!1,clip:n=!1}){const o=_(null),r=ht(o,e?()=>e:null,e),l=J(kt);/* @__PURE__ */
7
- return se("div",{ref:o,"aria-hidden":"true",className:"es-canvas-outline is-selected is-selected-part"+(t?" is-words":""),style:r?{position:"absolute",top:r.top,left:r.left,width:r.width,height:r.height,clipPath:n?bt(r,l):void 0,...pt}:{display:"none"}})}function ht(e,t,n){return gt(e,t?e=>{const n=t(e);return n?[n]:[]}:null,n)[0]??null}var mt=[];function gt(e,t,n){const[o,r]=te(mt),l=_(t);return l.current=t,Fe(()=>{const t=e.current?.ownerDocument,n=t?.defaultView;if(!t||!n||!l.current)return void r(mt);let o=0;const i=()=>{o=0;const n=e.current?.parentElement??null,i=(l.current?l.current(t):[]).map(e=>function(e,t){if(!e||!t)return null;const n=M(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=i)||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:i.length?i:mt;var t,n})},s=()=>{o||(o=(n.requestAnimationFrame??(e=>n.setTimeout(e,16)))(i))};i();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),n.addEventListener("scroll",s,{capture:!0,passive:!0}),()=>{a?.disconnect(),c?.disconnect(),n.removeEventListener("resize",s),n.removeEventListener("scroll",s,{capture:!0}),o&&(n.cancelAnimationFrame??n.clearTimeout)(o)}},[n]),o}var vt=D+2,yt=vt+2,wt=1;function bt(e,t){const n=e.left+e.width,o=e.top+e.height,r=t.map(t=>{const r=t.left+t.width,l=t.top+t.height;if(!(r>e.left-vt&&t.left<n+vt&&l>e.top-vt&&t.top<o+vt))return null;const i=Math.max(t.left<=e.left&&r>e.left?Math.min(t.left,e.left-wt):t.left,e.left-yt)-e.left,s=Math.max(t.top<=e.top&&l>e.top?Math.min(t.top,e.top-wt):t.top,e.top-yt)-e.top,a=Math.min(r>=n&&t.left<n?Math.max(r,n+wt):r,n+yt)-e.left,c=Math.min(l>=o&&t.top<o?Math.max(l,o+wt):l,o+yt)-e.top;return a>i&&c>s?{x:i,y:s,w:a-i,h:c-s}:null}).filter(e=>null!==e);if(!r.length)return;const l=function(e){if(e.length<2)return e;const t=Array.from(new Set(e.flatMap(e=>[e.x,e.x+e.w]))).sort((e,t)=>e-t),n=Array.from(new Set(e.flatMap(e=>[e.y,e.y+e.h]))).sort((e,t)=>e-t),o=[];for(let r=0;r<n.length-1;r++){const l=o=>e.some(e=>e.x<=t[o]&&t[o+1]<=e.x+e.w&&e.y<=n[r]&&n[r+1]<=e.y+e.h);for(let e=0;e<t.length-1;e++){if(!l(e))continue;let i=e+1;for(;i<t.length-1&&l(i);)i++;const s={x:t[e],y:n[r],w:t[i]-t[e],h:n[r+1]-n[r]},a=o.find(e=>e.x===s.x&&e.w===s.w&&e.y+e.h===s.y);a?a.h+=s.h:o.push(s),e=i-1}}return o}(r);return`path(evenodd, "${`M${-yt} ${-yt}h${e.width+2*yt}v${e.height+2*yt}h${-(e.width+2*yt)}z`}${l.map(e=>`M${e.x} ${e.y}h${e.w}v${e.h}h${-e.w}z`).join("")}")`}var kt=X([]);function St({children:e}){const t=_(null),n=J(ct),o=gt(t,n?e=>Array.from(e.querySelectorAll(`[${at}]`)):null,n?1:0);/* @__PURE__ */
8
- return ae("div",{className:"es-canvas-outlines",style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:[
9
- /* @__PURE__ */se("span",{ref:t,hidden:!0,"aria-hidden":"true"}),
10
- /* @__PURE__ */se(kt.Provider,{value:o,children:e})]})}function xt({id:e,kind:t,overlay:n}){const o=_(null),r=J(lt),l=null!==e&&!0===r?.(e),i=gt(o,e?t=>$(t,`[${Le}="${t.defaultView?.CSS?.escape?t.defaultView.CSS.escape(e):e}"]`):null,e),[s,...a]=i,c=J(kt),u=`es-canvas-outline is-${t}${l?" is-shared":""}`,d=e=>({position:"absolute",top:e.top,left:e.left,width:e.width,height:e.height,clipPath:bt(e,c)}),p=/* @__PURE__ */ae(ce,{children:[
11
- /* @__PURE__ */se("div",{ref:o,"aria-hidden":"true",className:u,style:s?d(s):{display:"none"}}),a.map((e,t)=>/* @__PURE__ */se("div",{"aria-hidden":"true",className:u,style:d(e)},t))]});return n&&e?/* @__PURE__ */se(n,{componentId:e,kind:t,children:p}):p}function Ct(e,n){return Array.from(e.querySelectorAll(`[${Le}]`)).find(o=>o.getAttribute(Le)===n&&t(o)?.wrapper===e)??null}function Et(e,t,n){const o=g(e,n),r=o.text.length,l=e.ownerDocument;if(!t)return[r,r];let i=null;const s=l.caretPositionFromPoint?.(t.x,t.y);if(s&&e.contains(s.offsetNode))i=o.at(s.offsetNode,s.offset);else{const n=l.caretRangeFromPoint?.(t.x,t.y);n&&e.contains(n.startContainer)&&(i=o.at(n.startContainer,n.startOffset))}if(null===i)return[r,r];const a=o.text;let c=i,u=i;for(;c>0&&!/\s/.test(a[c-1]);)c-=1;for(;u<a.length&&!/\s/.test(a[u]);)u+=1;return[c,u]}function It({s:e,element:t,toolbar:n,label:o,keys:r}){const l=w("copy",y),i=e.pressed(),s=new Set(n.offered),a=n.colors&&n.colors.length>0?n.colors:null,c=_(null),[m,g]=te(!1),[v,b]=te(null),k=m||null!==v,S=()=>{e.hold(),g(!1),b({href:e.pressed().href})},x=()=>{g(!1),b(null),e.resume()};ie(()=>{r.current={escape:()=>!!k&&(x(),!0),link:()=>!!s.has("link")&&(S(),!0)}}),ie(()=>()=>{r.current=null},[r]);const C=_(x);C.current=x,G(()=>{if(m)return de(e=>{const t=c.current;return!!("Escape"===e.key&&t&&e.target instanceof Node&&t.contains(e.target))&&(C.current(),!0)},()=>c.current?.querySelector(".es-copy-colors"))},[m]),G(()=>{const n=c.current;if(!k||!n)return;const o=/* @__PURE__ */new Set([n.ownerDocument]),r=t();r&&o.add(r.ownerDocument);const l=o=>{const r=o.target;if(r&&n.contains(r))return;g(!1),b(null);const l=t();r&&l&&l.contains(r)?e.release():e.stop("outside")};for(const e of o)e.addEventListener("pointerdown",l,!0);return()=>{for(const e of o)e.removeEventListener("pointerdown",l,!0)}},[k,e,t]),ie(()=>{const e=c.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,l=r&&r.rangeCount>0&&o.contains(r.getRangeAt(0).startContainer)?r.getRangeAt(0):null,i=(l?u(l,o):null)??(()=>{const e=o.getBoundingClientRect();return{left:e.left,top:e.top,right:e.right,bottom:e.bottom}})(),s=o.ownerDocument.defaultView?.frameElement,a=s?A(s,{left:i.left,top:i.top,width:i.right-i.left,height:i.bottom-i.top}):{left:i.left,top:i.top,width:i.right-i.left,height:i.bottom-i.top},f=o.getBoundingClientRect(),h=s?A(s,{left:f.left,top:f.top,width:f.width,height:f.height}):{left:f.left,top:f.top,width:f.width,height:f.height},m=(e.closest("[data-floating-bar]")??e).getBoundingClientRect(),g={left:a.left,right:a.left+a.width,top:Math.min(a.top,h.top-6,m.top),bottom:Math.max(a.top+a.height,h.top+h.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=d({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:p(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 E=a?{run:f(i.color,a),open:m,onToggle:()=>{b(null),m?x():(e.hold(),g(!0))}}:void 0;/* @__PURE__ */
12
- return se(pe,{anchor:()=>{const e=t();if(!e)return null;const n=e.getBoundingClientRect(),o=e.ownerDocument.defaultView?.frameElement,r=o?A(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__ */se("div",{ref:c,children:/* @__PURE__ */se(fe,{layout:"row",offered:s,pressed:i.marks,onMark:t=>{"link"===t?S():e.press(t)},color:E,linkOpen:null!==v,list:{pressed:i.list,onList:t=>e.list(t)},clear:i.clearable?{onClear:()=>e.clear()}:void 0,alignment:n.alignment,letterCase:n.letterCase,last:n.lastTool?.({className:"rosh-tb-btn",disabled:!1,selected:i.selected,keepCaret:t=>{t.preventDefault(),e.hold()},insert:t=>e.insert(t)}),windows:/* @__PURE__ */ae(ce,{children:[m&&a?/* @__PURE__ */se(h,{colors:a,current:i.color,words:l.colors??y.colors,onPick:t=>e.color(t)}):null,v?
13
- /* @__PURE__ */se(he,{className:"es-copy-link es-copy-pop",value:v.href??"",onApply:t=>{b(null),e.link(t)},onRemove:null!==v.href?()=>{b(null),e.link(null)}:void 0,onCancel:x}):null]})})})})}function Dt({element:e,which:t}){const n=_(null),o=ht(n,()=>e(),t),r=J(kt);/* @__PURE__ */
14
- return se("div",{ref:n,"aria-hidden":"true",className:"es-canvas-outline is-typing",style:o?{position:"absolute",top:o.top,left:o.left,width:o.width,height:o.height,clipPath:bt(o,r),...pt}:{display:"none"}})}function At({frame:o=!0,className:r,style:l,metadata:i,mirrorStyles:u,onDocument:d,height:p,title:f,nonce:h,hotkeys:y,frameWrapper:S,overlay:C,children:E,typing:I,passThrough:D}){const A=Pe(),M=J(rt),$=D??M,P=J($e),z=w("canvas",n),R=y??P,[j,N]=te(void 0),V=ze(e=>"node"===e.selection?.kind?e.selection.id:null),[L,B]=te(null),[K,Z]=te(null),F=J(st),H=J(ct),[q,W]=te(null),[,Q]=ne(e=>e+1,0),[,Y]=ne(e=>e+1,0),U=e=>{F?.select(e),Y()},[X,ee]=te(null),oe=_(null),re=_(null),[,le]=te(0),ie=_(I);ie.current=I;const ce=_(null),ue=_(null),de=()=>{if(!V)return null;const e=ie.current?.atSelection?.()?.element()??null;if(!e)return null;const t=ue.current?.ownerDocument;if(F){const n=F.selected()&&t?F.selectedPart?.(t)??null:null;return n&&x(n.element,e)?n.element:null}const n=O(A.getState().appState.data,A.config,V);return n&&0===T(n.node,A.config).length?e:null},pe=ze(e=>e.appState.data),fe=F?.selected()??null;G(()=>{const e=ue.current?.ownerDocument,t=e?.defaultView?.CustomEvent;if(!e||!t)return;const n=V&&!X&&ie.current?.atSelection?.()?V:null,o=n?de():null;e.dispatchEvent(new t(b,{detail:o?{id:n,words:o}:{id:n}}))},[V,X,pe,fe]);const he=e=>{const t=ue.current?.ownerDocument,n=t?.defaultView?.CustomEvent;t&&n&&t.dispatchEvent(new n(k,{detail:{typing:e}}))},me=(e,t)=>{oe.current?.s.stop("stop");const n=e.element();if(!n)return!1;const o=ge(e,n),r=A.group(),l=e.element,i=m({element:l,value:o?.value??e.value,rules:e.rules,multiline:e.multiline,skip:e.skip,caret:Et(n,t,e.skip),write:o?.write??e.write,remount:e.remount,onSelect:()=>le(e=>e+1),onEscape:()=>ce.current?.escape()??!1,onLinkKey:()=>ce.current?.link()??!1,end:e=>{r.close(),oe.current?.element===l&&(oe.current=null),ee(null),he(!1),ie.current?.onChange?.({typing:!1,why:e})}});if(!i)return r.close(),!1;const s=n.closest?.(`[${Le}]`)?.getAttribute(Le);return s&&A.select(s),oe.current={s:i,element:l,target:e},ee(()=>l),B(null),he(!0),ie.current?.onChange?.({typing:!0,element:n}),!0},ge=(e,n)=>{const o=e.key;if(!o||!ie.current?.onCopyText)return null;const r=t(n),l=n.closest?.(`[${Le}]`),i=l?.getAttribute(Le);if(!r||!i||!r.wrapper.contains(l))return null;const{copy:s}=r,a=ie.current.copyValue?.({...s,nodeId:i,key:o}),c=g(n,e.skip).text,u=a??(v(e.value,e.rules).text===c?e.value:c),d={ownerId:s.ownerId,slot:s.slot,index:s.index,...s.outer?{outer:s.outer}:{},nodeId:i,key:o};return{value:u,write:t=>{const n=ie.current?.onCopyText;n&&!1!==n({...d,text:t})||e.write(t)}}};G(()=>()=>oe.current?.s.stop("stop"),[]);const ve=e=>{const t=oe.current?.element();return Boolean(t&&t.contains(e))},ye=(e,t)=>it(A.getState().appState.data,A.config,e,t),we=e=>{const t=e.closest?.(`[${Le}]`)?.getAttribute(Le);if(!t)return;const n=A.getState(),o="node"===n.selection?.kind?n.selection.id:null,r=F?.partAt(e,t)??null;if(r){const e=a(n.appState.data,A.config,t,r.id,o,F?.selected()??null,$);if(e)return{node:e.node,part:e.part?r:null}}return{node:c(n.appState.data,A.config,t,o,$)??t,part:null}},be=e=>{if("Enter"!==e.key||e.defaultPrevented||e.shiftKey||e.metaKey||e.ctrlKey||e.altKey)return;if(oe.current)return;const t=e.target;if(t?.isContentEditable||t?.closest?.("input, textarea, select, button"))return;const n=ke(),o=void 0===n?ie.current?.atSelection?.():n;o&&me(o,null)&&e.preventDefault()},ke=()=>{const t=ie.current,n=re.current;if(!t?.onCopyText||!n?.copy||n.node!==V)return;const o=ue.current,r=o?e(o,n.copy):null,l=r?Ct(r,n.node):null;if(!l)return null;const i=t.atSelection?.()??null,s=i?.element()??null;if(!i||!s)return null;if(l.contains(s))return i;const a=function(e,t){const n=e.closest(`[${Le}]`);if(!n||n.getAttribute(Le)!==t.getAttribute(Le))return null;const o=[];for(let t=e;t!==n;t=t.parentElement)o.unshift(Array.prototype.indexOf.call(t.parentElement.children,t));let r=t;for(const e of o)r=r?.children[e];return r&&r.tagName===e.tagName?r:null}(s,l);return a?t.at(a):null},Se=(e,n)=>{if(!ie.current?.onCopyText)return null;const o=t(e);return o&&Ct(o.wrapper,n)?o.copy:null},xe=ue.current?.ownerDocument??null,Ce=F?.selected()&&xe&&V?F.selectedPart?.(xe)??null:null,Ee=Ce&&V&&ye(V,Ce)?Ce.element:null,Ie=H?.selected()??null,De=Ie&&xe?Array.from(xe.querySelectorAll(`[${at}]`)).find(e=>e.getAttribute(at)===Ie)??null:null,Me=X?null:de(),Oe=/* @__PURE__ */ae("div",{ref:ue,className:"es-canvas-content",style:{position:"relative"},onClick:e=>{const t=e.target;if(t.closest?.("a[href]")&&e.preventDefault(),oe.current){if(ve(t))return;oe.current.s.stop("outside")}const n=t.ownerDocument?.getSelection?.();n&&n.rangeCount>0&&n.isCollapsed&&n.removeAllRanges();const o=H?ut(t):null;if(H&&o)return H.select(o.id),W(null),void Q();const r=we(t);if(re.current=void 0!==r?{node:r.node,copy:Se(t,r.node)}:null,void 0!==r)return A.select(r.node),void(F&&(r.part?.id??null)!==F.selected()&&U(r.part?.id??null));t.hasAttribute?.(Be)||(A.select(null),F?.selected()&&U(null))},onDoubleClick:e=>{const t=ie.current;if(!t||ve(e.target))return;const n=t.at(e.target);n&&me(n,{x:e.clientX,y:e.clientY})&&e.preventDefault()},onKeyDown:e=>be(e),onMouseOver:e=>{if(oe.current)return;const t=H?ut(e.target):null;if(t?.element!==q?.element&&W(t),t)return null!==L&&B(null),void(null!==K&&Z(null));const n=we(e.target),o=!!n?.part&&ye(n.node,n.part),r=n?.part&&o&&n.part.id!==F?.selected()?n.part:null,l=!n||n.part&&o?null:n.node;l!==L&&B(l),r?.id===K?.id&&r?.element===K?.element||Z(r)},onMouseLeave:()=>{B(null),Z(null),W(null)},children:[
15
- /* @__PURE__ */se(qe.Provider,{value:L,children:/* @__PURE__ */se(ot,{metadata:i})}),
16
- /* @__PURE__ */ae(St,{children:[
17
- /* @__PURE__ */se(xt,{id:!X&&L&&L!==V?L:null,kind:"hover",overlay:C}),F?/* @__PURE__ */se(dt,{clip:!0,element:X||!K||K.id===F.selected()?null:K.element}):null,Me||Ee?/* @__PURE__ */se(ft,{clip:!0,element:X?null:Me??Ee,words:null!==Me}):null,H?/* @__PURE__ */se(dt,{element:X||!q||q.element===De?null:q.element}):null,De?/* @__PURE__ */se(ft,{element:X?null:De}):null,
18
- /* @__PURE__ */se(xt,{id:X||Ee||Me||De?null:V,kind:"selected",overlay:C}),X?/* @__PURE__ */se(Dt,{element:()=>{const e=X?.()??null;return e?Ce&&x(Ce.element,e)?Ce.element:e:null},which:Ce?.element??X}):null]}),E]}),Re=S?/* @__PURE__ */se(S,{document:j,children:Oe}):Oe;G(()=>{if(j&&R)return Ae(j,A)},[j,R,A]),G(()=>{if(!j)return;const e=e=>{if("Enter"===e.key)return void be(e);if("Escape"!==e.key||e.defaultPrevented)return;const t=e.target;if(t?.isContentEditable||t?.closest?.("input, textarea, select"))return;const n=A.getState();if("node"!==n.selection?.kind)return;if(F?.selected())return void U(null);const o=s(n.appState.data,A.config,n.selection);"node"===o?.kind&&A.select(o.id)};return j.addEventListener("keydown",e),()=>j.removeEventListener("keydown",e)},[j,A,F]);/* @__PURE__ */
19
- return ae("div",{className:"es-canvas"+(r?` ${r}`:""),style:l,"data-easel-preview":"","data-es-typing":X?"":void 0,children:[X&&oe.current?.target.toolbar?/* @__PURE__ */se(It,{s:oe.current.s,element:oe.current.element,toolbar:oe.current.target.toolbar,label:z.textTools,keys:ce}):null,o?/* @__PURE__ */se(He,{mirrorStyles:u,onDocument:e=>{N(e??void 0),d?.(e)},height:p,title:f,nonce:h,children:Re}):/* @__PURE__ */se("div",{id:"preview-frame","data-easel-entry":"",children:Re})]})}function Mt(e={}){const t=Pe(),n=ze(e=>e.appState.data);return i({...e,data:n,config:t.config,commit:(e,{select:n})=>t.run({data:e,select:n})})}function $t(){return jt(ze(e=>e.selectedItem))}function Ot(){const e=J(Pt);try{return function(e){const t=ze(e=>e.selectedItem);return jt("root"===e?null:t)}(e)}catch{return null}}var Pt=X("selected");function zt({children:e}){return oe(Pt.Provider,{value:"root"},e)}function Rt(){return jt(null)}function jt(e){const t=Pe(),n=ze(e=>e.config),r=t.resolveCache,l=ze(e=>e.appState.data.root),i=e?e.props.id:"root",s=l.props??{},a=re(()=>e||{type:"root",props:s},[e,s]),c=e?n.components[e.type]:n.root,u=t.getState(),d=e?O(u.appState.data,n,i):null,p=d&&"root"!==d.place.parentId?d.place.parentId:null,f=p?u.getItemById(p)??null:null,{fields:h}=o({id:i,node:a,block:c,parent:f,appState:u.appState}),m=ze(t=>!1===t.getPermissions(e?{item:e}:{root:!0}).edit),g=le(e=>{(async()=>{const o=t.getState();if("root"!==i){const l=o.getItemById(i),s=o.getSelectorForId(i);if(!l||!s)return;const a={...l,props:{...l.props,...e}},{node:c}=await H(a,n,{cache:r,trigger:"replace"}),u=t.getState().getSelectorForId(i);if(!u)return;return void t.dispatch({type:"replace",destinationZone:u.zone??"root:default-zone",destinationIndex:u.index,data:c})}const l=o.appState.data.root.props??{},{node:s}=await H({type:"root",props:{...l,...e}},n,{cache:r,trigger:"replace"});t.dispatch({type:"replaceRoot",root:{props:s.props,readOnly:s.readOnly},recordHistory:!0})})()},[t,n,r,i]),v=le((e,t)=>g({[e]:t}),[g]);return{id:i,node:a,fields:h,values:a.props,readOnly:m,onChange:v,onChangeMany:g}}export{at as CHROME_ATTR,ct as CanvasChromeContext,He as CanvasFrame,st as CanvasPartsContext,rt as CanvasPassThroughContext,lt as CanvasSharedContext,Ce as DEFAULT_UI,At as EaselCanvas,Oe as EaselProvider,ot as EditDocument,zt as RootHostScope,Ae as bindUndoKeys,De as createEasel,Re as createUseEasel,it as partHasOwnBox,me as recordsByDefault,ke as reduce,ye as uiView,ze as useEasel,Pe as useEaselApi,Mt as useEaselNodeOps,Rt as useRootFields,$t as useSelectedFields,Ot as useSelectedHost,we as validSelection};
@@ -1,7 +0,0 @@
1
- import{STANDARD_MARKUP as t,writeMarkedLines as e,sameMarks as n,markedLines as r,spanFor as l,marksIn as o,toggleMark as i,listIn as a,setList as s,colorOver as c,unlinkAt as u,linkOver as d,colorIn as f,findLink as h,clearStyle as p,isSafeLinkHref as m}from"efficient-shell/markup";import{Tooltip as g,ColorSwatch as b,ColorPickerPanel as k,Button as v}from"efficient-shell/ui";import{jsxs as y,jsx as x}from"react/jsx-runtime";function w(t,e){return t&&t.start!==t.end?t:{start:0,end:e}}var D=/* @__PURE__ */new Set(["script","style","head","title","meta","link","template","noscript","svg","math","object","iframe"]),M=/* @__PURE__ */new Set(["p","div","li","ul","ol","dl","dt","dd","h1","h2","h3","h4","h5","h6","blockquote","pre","table","thead","tbody","tfoot","tr","section","article","header","footer","aside","nav","figure","figcaption","address","hr"]);function N(l,o){const i=o.rules??t,a=l.html&&""!==l.html.trim()?function(t,l,o){const i=l.createElement("template");i.innerHTML=t;const a=[[]],s=()=>a[a.length-1],c=()=>{const t=s();for(;t.length>0&&" "===t[t.length-1].ch;)t.pop();t.length>0&&a.push([])},u=(t,e,n,r)=>{if(3===t.nodeType){for(const l of t.textContent??""){const t=/\s/.test(l)?" ":l,o=s();" "===t&&(0===o.length&&a.length>1||" "===o[o.length-1]?.ch)||o.push({ch:t,bold:e,italic:n,href:r})}return}if(1!==t.nodeType&&11!==t.nodeType)return;const l=t,o=1===t.nodeType?l.localName:"";if(D.has(o))return;if("br"===o)return void a.push([]);let i=e,d=n,f=r;if("b"!==o&&"strong"!==o||(i=!0),"i"!==o&&"em"!==o||(d=!0),"a"===o){const t=(l.getAttribute("href")??"").trim();f=m(t)?t:null}const h=1===t.nodeType?l.style:null;if(h){const t=h.fontWeight;"bold"===t||"bolder"===t||Number(t)>=600?i=!0:("normal"===t||"lighter"===t||""!==t&&Number(t)<600)&&(i=!1),"italic"===h.fontStyle||"oblique"===h.fontStyle?d=!0:"normal"===h.fontStyle&&(d=!1)}const p=M.has(o);p&&c();for(const e of[...t.childNodes])u(e,i,d,f);p&&c()};u(i.content,!1,!1,null);for(;a.length>1&&0===a[a.length-1].length;)a.pop();return a.map(t=>function(t,l){const o=e=>t.map((n,r)=>n[e]&&(" "!==n.ch||Boolean(t[r-1]?.[e])&&Boolean(t[r+1]?.[e]))),i=[{bold:!0,italic:!0,links:!0},{bold:!0,italic:!1,links:!0},{bold:!1,italic:!1,links:!0},{bold:!1,italic:!1,links:!1}];for(const a of i){const i=T(t,a.bold?o("bold"):null,a.italic?o("italic"):null,a.links),s=e([i]).text;if(n([i],r(s,l)))return s}return t.map(t=>t.ch).join("")}(t,o))}(l.html,o.doc,i):(l.text??"").replace(/\r\n?/g,"\n").split("\n");return o.multiline?a.join("\n"):1===a.length?a[0]:a.map(t=>t.trim()).filter(t=>""!==t).join(" ")}function T(t,e,n,r){let o=0,i=null,a=null,s=null;return{bullet:!1,chars:t.map((t,c)=>{const u=r?t.href:null;return i=null===u?null:i&&i.href===u?i:l(++o,"link",u),a=e?.[c]?a??l(++o,"bold"):null,s=n?.[c]?s??l(++o,"italic"):null,{ch:t.ch,at:-1,marks:[i,a,s].filter(t=>null!==t)}})}}var C="application/x-efficient-markup",A=/^([0-9]{1,3})\. $/;function E(t,e){const n=t.split("\n"),l=r(t,e);let o=0,i=0;const a=l.map((t,e)=>{const r=!t.bullet&&null==t.number&&"- "===n[e],l=null!=t.number||t.bullet?null:A.exec(n[e]),a=t.bullet||r,s=l?l[1]:t.number??null,c=r||l?[]:t.chars,u=c.map(t=>t.ch).join(""),d=null!=s?s.length+2:a?2:0,f={bullet:a,number:s,chars:c,start:o,src:o+d,vis:i,text:u};return o+=n[e].length+1,i+=u.length+1,f});return{lines:a,text:a.map(t=>t.text).join("\n")}}function S(t,e){const{lines:n}=t;for(let t=0;t<n.length;t+=1){const r=n[t];if(e<=r.vis+r.text.length||t===n.length-1)return[r,Math.max(0,Math.min(e-r.vis,r.text.length)),t]}return[n[0],0,0]}function B(t,e){const[n,r]=S(t,e);if(0===r)return n.src;let l=0;for(const t of n.chars){if(r<=l+t.ch.length)return t.at+(r-l);l+=t.ch.length}return n.src}function R(t,e){const[n,r]=S(t,e);let l=0;for(const t of n.chars){if(r===l)return t.at;l+=t.ch.length}return B(t,e)}function L(t,e){const{lines:n}=t;let r=n[0];for(const t of n)e>=t.start&&(r=t);let l=0;for(const t of r.chars){if(!(e>=t.at+t.ch.length)){e>t.at&&(l+=e-t.at);break}l+=t.ch.length}return r.vis+l}function K(t,e,n){return[L(t,e),L(t,n)]}function W(t,e,n){return e===n?[B(t,e),B(t,e)]:[R(t,e),B(t,n)]}function P(t,e){let n=0;for(let r=0;r<t.chars.length;r+=1){if(n>=e)return r;n+=t.chars[r].ch.length}return t.chars.length}function j(t,o,i,a,s){const c=E(t,o),[u,d,f]=S(c,Math.min(i,a)),[h,p,m]=S(c,Math.max(i,a)),g=P(u,d),b=P(h,p),k=u.chars.slice(0,g),v=h.chars.slice(b),y=i!==a&&u.chars[g]&&(f!==m||g<b)?u.chars[g].marks:function(t,e){const n=t.chars[e-1],r=t.chars[e],l=(t,e)=>{const n=t.findIndex(t=>"link"===t.kind);return-1===n||e?t:t.slice(0,n)};if(n){const t=n.marks.find(t=>"link"===t.kind),e=Boolean(t&&r?.marks.some(e=>e.id===t.id));return l(n.marks,e)}return r?l(r.marks,!1):[]}(u,g);let x=(w=c.lines,Math.max(0,...w.flatMap(t=>t.chars.flatMap(t=>t.marks.map(t=>t.id))))+1);var w;const D=t=>{let e;if(void 0!==s.markup){const t=x;e=r(s.markup,o).map(e=>({bullet:e.bullet,number:e.number??null,chars:e.chars.map(e=>({...e,at:-1,marks:e.marks.map(e=>({...e,id:e.id+t}))}))}))}else{let n=u.number??null;e=(s.text??"").split("\n").map((e,r)=>(r>0&&null!=n&&(n=function(t){return String(Number(t)+1).padStart(t.length,"0")}(n)),{bullet:u.bullet,number:n,chars:[...e].map(e=>({ch:e,at:-1,marks:t??[]}))}))}const n=e.map(t=>t.chars.map(t=>t.ch).join("")).join("\n"),l={bullet:u.bullet,number:u.number??null,chars:[...k,...e[0].chars]},i=e.slice(1);if(i.length>0){const t=i[i.length-1];i[i.length-1]={...t,chars:[...t.chars,...v]}}else l.chars.push(...v);return{lines:[...c.lines.slice(0,f).map(({bullet:t,number:e,chars:n})=>({bullet:t,number:e,chars:n})),l,...i,...c.lines.slice(m+1).map(({bullet:t,number:e,chars:n})=>({bullet:t,number:e,chars:n}))],shown:n}},M=void 0!==s.markup?[null]:[(t=>{let e=t.filter(t=>!s.drop?.some(e=>t.kind===e||"highlight"===e&&"accent"===t.kind));for(const t of s.add??[]){if(e.some(e=>e.kind===t))continue;const n=l(x++,t);n&&(e=[...e,n])}if(void 0!==s.color){e=e.filter(t=>"color"!==t.kind);const t=null===s.color?null:l(x++,"color",s.color);t&&(e=[...e,t])}return e})(y),y,[]];let N="",T="";for(const t of M){const r=D(t),l=e(r.lines).text;if(N=l,T=r.shown,n(r.lines,E(l,o).lines))break}return{text:N,caret:Math.min(i,a)+T.length}}function V(t,e,n,r){const l=E(t,e),[o,,i]=S(l,n);return n!==r||!o.bullet&&null==o.number||""!==o.text?j(t,e,n,r,{text:"\n"}):q(t,e,i,!1,n)}function q(t,n,r,l,o){const i=E(t,n).lines.map(({bullet:t,number:e,chars:n},o)=>o===r?{bullet:l,number:null,chars:n}:{bullet:t,number:e,chars:n});return{text:e(i).text,caret:o}}function F(t,n,r,l){const o=E(t,n),[i,a,s]=S(o,Math.min(r,l)),[c,u,d]=S(o,Math.max(r,l)),f=o.lines.slice(s,d+1).map(({bullet:t,number:e,chars:n},r)=>{const l=0===r?P(i,a):0,o=r===d-s?P(c,u):n.length;return{bullet:t,number:e,chars:n.slice(l,o)}});return e(f).text}function I(t,e,n){if(n<0){const n=t.charCodeAt(e-1);return e-(n>=56320&&n<=57343&&e>=2?2:1)}const r=t.charCodeAt(e);return e+(r>=55296&&r<=56319?2:1)}function O(t){const{value:e,rules:n,multiline:r,inputType:l,pending:o}=t;let[i,a]=t.sel;t.target&&t.target[0]!==t.target[1]&&l.startsWith("delete")&&([i,a]=t.target);const s=[i,a];if("historyUndo"===l||"historyRedo"===l)return{kind:"history",dir:"historyUndo"===l?"undo":"redo"};if("formatBold"===l||"formatItalic"===l||"formatStrikeThrough"===l)return{kind:"format",style:"formatBold"===l?"bold":"formatItalic"===l?"italic":"strike"};if("insertParagraph"===l||"insertLineBreak"===l)return r?{kind:"edit",edit:V(e,n,i,a),range:s}:null;if(l.startsWith("insert")){if("insertTranspose"===l)return null;let c=t.data??"";if("insertFromDrop"===l||"insertFromPaste"===l){const l=N({html:t.html??void 0,text:c},{doc:t.doc,multiline:r,rules:n});return{kind:"edit",edit:j(e,n,i,a,{markup:l}),range:s}}return r||(c=c.replace(/\s*\r?\n\s*/g," ")),{kind:"type",edit:j(e,n,i,a,{text:c,add:o?.add,drop:o?.drop,color:o?.color}),range:s}}if(l.startsWith("delete")){const t=E(e,n),r=t.text;if(i===a){const o=l.includes("Backward"),c=t.lines.findIndex(t=>i>=t.vis&&i<=t.vis+t.text.length),u=t.lines[c];if(o&&u&&i===u.vis&&(u.bullet||null!=u.number))return{kind:"edit",edit:q(e,n,c,!1,i),range:s};if(o?0===i:i===r.length)return null;o?i=I(r,i,-1):a=I(r,a,1)}return{kind:"type",edit:j(e,n,i,a,{text:""}),range:[i,a]}}return null}var z=1e3;function U(t=200){let e=[],n=[],r=null,l=0;return{record(o,i,a){const s="type"===i&&"type"===r&&a-l<1e3;r=i,l=a,n=[],s||(e.push(o),e.length>t&&e.shift())},undo(t){const l=e.pop();return l?(n.push(t),r=null,l):null},redo(t){const l=n.pop();return l?(e.push(t),r=null,l):null},reset(){e=[],n=[],r=null}}}var $=t=>t.preventDefault();function H(t,e){if(t)return t.startsWith("#")?t:e?.find(e=>e.name===t)?.value}function X({colors:t,current:e,words:n,onPick:r}){const l=null===e?null:e.startsWith("#")?e.toLowerCase():t.find(t=>t.name===e)?.value.toLowerCase()??null;/* @__PURE__ */
2
- return y("div",{className:"es-copy-pop es-copy-colors",role:"dialog","aria-label":n.title,onMouseDown:t=>{"INPUT"!==t.target.tagName&&t.preventDefault()},children:[
3
- /* @__PURE__ */x("span",{className:"es-copy-pop-label",children:n.theme}),
4
- /* @__PURE__ */x("div",{className:"es-copy-theme",role:"group","aria-label":n.theme,children:t.map(t=>/* @__PURE__ */x(g,{content:`${t.label} · ${t.value.toUpperCase()}`,children:/* @__PURE__ */x(b,{color:t.value,size:"sm",className:"es-copy-theme-swatch","data-color":t.name,"aria-label":t.label,selected:e===t.name,onMouseDown:$,onClick:()=>r(t.name)})},t.name))}),
5
- /* @__PURE__ */x("span",{className:"es-copy-pop-label",children:n.any}),
6
- /* @__PURE__ */x(k,{className:"es-copy-any",value:l??"",onChange:t=>{t!==e&&r(t)},label:n.title,dragWrites:"end"}),
7
- /* @__PURE__ */x("div",{className:"es-copy-pop-foot",children:/* @__PURE__ */x(v,{variant:"ghost-danger",size:"sm","data-window-action":"remove",onMouseDown:$,onClick:()=>r(null),children:n.remove})})]})}var Y={sup:"sub",sub:"sup"};function Z(t){const{value:e,rules:n,start:r,end:l,style:a,pending:s}=t,c=Y[a];if(r===l){const t=o(e,r,l,n),i=s&&s.at===r?s:null,u=t.has(a),d=!!i?.add.includes(a)||!i?.drop.includes(a)&&u;let f=(i?.add??[]).filter(t=>t!==a),h=(i?.drop??[]).filter(t=>t!==a);return d&&u?h.push(a):d||u||f.push(a),!d&&c&&(f=f.filter(t=>t!==c),t.has(c)&&(h=[...h.filter(t=>t!==c),c])),{kind:"pending",pending:f.length||h.length||void 0!==i?.color?{add:f,drop:h,color:i?.color,at:r}:null}}let u=e,d=r,f=l;if(c&&!o(u,d,f,n).has(a)&&o(u,d,f,n).has(c)){const t=i(u,d,f,c,n);({text:u,selectionStart:d,selectionEnd:f}=t)}return{kind:"edit",result:i(u,d,f,a,n)}}var G=/^(block|list-item|flex|grid|table|flow-root)$/;function J(t){const e=t.ownerDocument.defaultView;return!!e&&G.test(e.getComputedStyle(t).display)}function Q(t,e){const n=[],r=/* @__PURE__ */new Map,l=/* @__PURE__ */new Map;let o="",i=!1;const a=()=>{i&&(o+="\n",i=!1)},s=t=>{for(const c of Array.from(t.childNodes)){if(3===c.nodeType){c.data.length>0&&a(),r.set(c,o.length),n.push({node:c,start:o.length,length:c.data.length}),o+=c.data,l.set(c,o.length);continue}if(1!==c.nodeType)continue;const t=c;if(e&&t.matches(e)){r.set(t,o.length),l.set(t,o.length);continue}if("BR"===t.tagName){a(),r.set(t,o.length),o+="\n",l.set(t,o.length);continue}const u=J(t);u&&((i||o.length>0&&!o.endsWith("\n"))&&(o+="\n"),i=!1),r.set(t,o.length);const d=o.length;s(t),u&&o.length===d&&!i&&n.push({node:t,start:d,length:0}),l.set(t,o.length),u&&(i=!0)}};r.set(t,0),s(t),l.set(t,o.length);return{text:o,at:(t,e)=>{if(3===t.nodeType)return(r.get(t)??0)+Math.min(e,t.data.length);const n=t.childNodes;return e<n.length?r.get(n[e])??l.get(t)??0:l.get(t)??o.length},dom:e=>{for(let t=0;t<n.length;t+=1){const r=n[t],l=r.start+r.length;if(e<r.start)return[r.node,0];if(e<l||e===l&&(t===n.length-1||n[t+1].start>e))return 3===r.node.nodeType?[r.node,e-r.start]:[r.node,0]}const r=n[n.length-1];return r?3===r.node.nodeType?[r.node,r.length]:[r.node,0]:[t,0]}}}function _(t){const e=t.element();if(!e)return null;let n=t.value;const r=t.rules;if(Q(e,t.skip).text!==E(n,r).text)return null;const l=t.now??(()=>Date.now()),i=U();let m=e,g=!1,b=null,k=null,v=[t.caret[0],t.caret[1]],y=null,x=!1,D=!1;const M=()=>{D||t.onSelect?.()},T={contenteditable:e.getAttribute("contenteditable"),spellcheck:e.getAttribute("spellcheck")},A=()=>m.ownerDocument,S=()=>A().defaultView?.getSelection()??null,B=()=>{if(!k)return!0;ot();const e=Q(m,t.skip);if(e.text!==E(n,r).text)return!1;const[l,o]=k,[i,a]=e.dom(l),[s,c]=e.dom(o);return x||A().activeElement===m||m.focus({preventScroll:!0}),S()?.setBaseAndExtent(i,a,s,c),v=k,R=k,k=null,M(),!0};let R=null;const L=()=>{if(!R)return!1;const t=S(),e=t?.anchorNode??null;return!(e&&e.isConnected&&m.contains(e))||e===m&&0===t.anchorOffset&&(0!==R[0]||0!==R[1])},P=()=>{k=R,B()},V=()=>{B(),A().activeElement===m&&L()&&P();const e=S();if(!(e&&e.anchorNode&&e.focusNode&&m.contains(e.anchorNode)&&m.contains(e.focusNode)))return v;const n=Q(m,t.skip),r=n.at(e.anchorNode,e.anchorOffset),l=n.at(e.focusNode,e.focusOffset);return v=r<=l?[r,l]:[l,r],v},q=t=>{const e=A().defaultView;t<=0||!e?R=null:e.requestAnimationFrame(()=>{g||k||(ot(),A().activeElement===m?(L()&&(P(),M()),q(t-1)):R=null)})},I=(t,e)=>{k=[t,e];const n=t=>{if(g)return;if(B())return void q(3);const e=A().defaultView;t>0&&e&&e.requestAnimationFrame(()=>n(t-1))};n(30)},z=(e,r,o)=>{e.text!==n?(i.record({text:n,start:r[0],end:r[1]},o,l()),n=e.text,t.write(n),I(e.caret,e.caret),M()):I(e.caret,e.caret)},$=t=>W(E(n,r),t[0],t[1]),H=(t,e)=>{const l=w({start:t,end:e},n.length);return p(n,l.start,l.end,r)},X=(e,o)=>{if(e.text===n)return;i.record({text:n,start:o[0],end:o[1]},"edit",l()),n=e.text,t.write(n);const[a,s]=K(E(n,r),e.selectionStart,e.selectionEnd);I(a,s),M()},Y=t=>{if(g)return;const e=V(),[l,o]=$(e),i=Z({value:n,rules:r,start:l,end:o,style:t,pending:y});if("pending"===i.kind)return y=i.pending,void M();X(i.result,e)},G=e=>{n=e.text,t.write(n),I(e.start,e.end)},J=e=>{if(g)return;g=!0,it.removeEventListener("selectionchange",at),lt(m);const n=S();n&&n.rangeCount>0&&m.contains(n.anchorNode)&&m.contains(n.focusNode)&&n.removeAllRanges(),t.end(e)},_=(t,e)=>{const l=V();!g&&l[0]!==l[1]&&t.clipboardData&&(t.preventDefault(),t.clipboardData.setData("text/plain",E(n,r).text.slice(l[0],l[1])),t.clipboardData.setData(C,F(n,r,l[0],l[1])),e&&z(j(n,r,l[0],l[1],{text:""}),l,"edit"))},tt=t=>t.preventDefault(),et=()=>{t.remount?.()},nt=[["keydown",e=>{if(g||e.isComposing)return;const r=e.metaKey||e.ctrlKey;if("Escape"!==e.key){if(r&&!e.altKey&&!e.shiftKey&&("k"===e.key||"K"===e.key)&&t.onLinkKey?.())return e.preventDefault(),void e.stopPropagation();if(r&&!e.altKey&&!e.shiftKey&&("KeyA"===e.code||"a"===e.key||"A"===e.key))return e.preventDefault(),e.stopPropagation(),I(0,Q(m,t.skip).text.length),void M();if("Enter"===e.key&&(!e.shiftKey||r))return e.preventDefault(),e.stopPropagation(),void J("enter");if(r&&("z"===e.key||"Z"===e.key||"y"===e.key)){e.preventDefault(),e.stopPropagation();const t=V(),r={text:n,start:t[0],end:t[1]},l="y"===e.key||e.shiftKey?i.redo(r):i.undo(r);l&&G(l)}}else{if(e.preventDefault(),e.stopPropagation(),t.onEscape?.())return;J("escape")}}],["beforeinput",e=>{if(g)return;if("insertCompositionText"===e.inputType)return;e.preventDefault();const l=V(),o=Q(m,t.skip),a="function"==typeof e.getTargetRanges?e.getTargetRanges()[0]:void 0,s=a&&!a.collapsed?[o.at(a.startContainer,a.startOffset),o.at(a.endContainer,a.endOffset)]:null,c=O({value:n,rules:r,multiline:t.multiline,inputType:e.inputType,data:e.data??e.dataTransfer?.getData("text/plain")??"",html:e.dataTransfer?.getData("text/html"),doc:A(),sel:l,target:s,pending:y&&y.at===$(l)[0]?y:null});if(c){if("type"!==c.kind&&"edit"!==c.kind||(y=null),"history"===c.kind){const t={text:n,start:l[0],end:l[1]},e="undo"===c.dir?i.undo(t):i.redo(t);return void(e&&G(e))}"format"!==c.kind?z(c.edit,c.range,c.kind):Y(c.style)}}],["compositionstart",()=>{b=V()}],["compositionend",e=>{const o=b;if(b=null,!g&&o)if(e.data){const a=j(n,r,o[0],o[1],{text:e.data});i.record({text:n,start:o[0],end:o[1]},"type",l()),n=a.text,t.write(n),et(),I(a.caret,a.caret)}else et(),I(o[0],o[0])}],["paste",e=>{if(g)return;e.preventDefault();const l=V(),o=e.clipboardData,i=o?.getData(C)??"",a=i?t.multiline?i:i.replace(/\s*\r?\n\s*/g," "):N({html:o?.getData("text/html")??"",text:o?.getData("text/plain")??""},{doc:A(),multiline:t.multiline,rules:r});z(j(n,r,l[0],l[1],{markup:a}),l,"edit")}],["copy",t=>_(t,!1)],["cut",t=>_(t,!0)],["drop",tt],["dragstart",tt],["blur",e=>{if(g||null!==b||x)return;const n=e.target,r=n.ownerDocument.defaultView,l=()=>{g||(n.isConnected&&n===t.element()?x||n.ownerDocument.activeElement===n||J("blur"):I(v[0],v[1]))};r?.requestAnimationFrame?r.requestAnimationFrame(l):setTimeout(l,0)}],["focus",()=>{x=!1}]];function rt(t){t.setAttribute("contenteditable","true"),t.setAttribute("spellcheck","false"),t.setAttribute("data-es-typing","");for(const[e,n]of nt)t.addEventListener(e,n)}function lt(t){for(const[e,n]of nt)t.removeEventListener(e,n);null===T.contenteditable?t.removeAttribute("contenteditable"):t.setAttribute("contenteditable",T.contenteditable),null===T.spellcheck?t.removeAttribute("spellcheck"):t.setAttribute("spellcheck",T.spellcheck),t.removeAttribute("data-es-typing")}function ot(){const e=t.element();e&&e!==m&&(lt(m),m=e,rt(m))}const it=m.ownerDocument;function at(){g||M()}return it.addEventListener("selectionchange",at),rt(m),m.focus({preventScroll:!0}),I(t.caret[0],t.caret[1]),{get value(){return n},update(t){if(t===n)return;const e=E(t,r).text.length,[l,o]=V();n=t,i.reset(),I(Math.min(l,e),Math.min(o,e))},stop(t="stop"){J(t)},pressed(){let t;D=!0;try{t=V()}finally{D=!1}const[e,l]=$(t),i=o(n,e,l,r),s={};for(const t of["bold","italic","underline","strike","sup","sub","link"]){const n=i.has(t),r=y&&y.at===e?y:null;s[t]=!!r?.add.includes(t)||!r?.drop.includes(t)&&n}const c=y&&y.at===e&&void 0!==y.color?y:null;return{marks:s,list:a(n,e,l,r),selected:l>e,href:h(n,e,l)?.href??null,color:c?c.color??null:f(n,e,l,r),clearable:H(e,l).text!==n}},press:Y,insert(t){if(g)return;x=!1;const e=V(),[r,l]=$(e),o=r+t.length;X({text:n.slice(0,r)+t+n.slice(l),selectionStart:o,selectionEnd:o},e),ot(),m.focus({preventScroll:!0})},hold(){g||(V(),x=!0)},release(){x=!1},resume(){g||(x=!1,ot(),m.focus({preventScroll:!0}),I(v[0],v[1]))},link(t){if(g)return;x=!1;const e=V(),[l,o]=$(e),i=null===t?u(n,l,o,r):d(n,l,o,t,r),a=i.text===n;X(i,e),ot(),m.focus({preventScroll:!0}),a&&I(e[0],e[1])},color(t){if(g)return;const e=V(),[l,o]=$(e);if(l===o){const e=y&&y.at===l?y:null;return y={add:e?.add??[],drop:e?.drop??[],color:t,at:l},void M()}X(c(n,l,o,t,r),e)},clear(){if(g)return;const t=V(),[e,n]=$(t);X(H(e,n),t)},list(e){if(g||!t.multiline)return;const l=V(),[o,i]=$(l),c=a(n,o,i,r);X(s(n,o,i,c===e?null:e,r),l)}}}var tt=(t,e,n)=>Math.min(Math.max(t,e),Math.max(e,n));function et({anchor:t,size:e,within:n,clip:r,parent:l,gap:o=8}){const i=Math.max(n.left,r.left),a=Math.min(n.right,r.right)-e.width,s=tt(t.left,i,a),c=r.bottom-(t.bottom+o),u=t.top-o-r.top,d=e.height>c&&(e.height<=u||u>c),f=d?t.top-o-e.height:t.bottom+o,h=t.left+Math.min((t.right-t.left)/2,10),p=tt(h-5-s,10,e.width-10-10);return{top:f-l.top,left:s-l.left,above:d,point:p}}var nt=t=>({left:t.left,top:t.top,right:t.right,bottom:t.bottom});function rt(t,e){const n=("function"==typeof t.getClientRects?[...t.getClientRects()]:[]).filter(t=>t.height>0);if(n.length>0){const e="function"==typeof t.getBoundingClientRect?t.getBoundingClientRect():n[0];return e.height>0?nt(e):nt(n[0])}if(!e)return null;const r=e.getBoundingClientRect();return{left:r.left,top:r.top,right:r.left,bottom:r.bottom}}function lt(t){const e=t.ownerDocument,n=e.documentElement,r={left:0,top:0,right:n.clientWidth,bottom:n.clientHeight},l=e.defaultView?.getComputedStyle.bind(e.defaultView);for(let o=t.parentElement;o&&o!==n&&o!==e.body;o=o.parentElement){const t=l?.(o);if(!t||"visible"===t.overflowX&&"visible"===t.overflowY)continue;const e=o.getBoundingClientRect();if(0===e.width&&0===e.height)continue;const n=e.left+o.clientLeft,i=e.top+o.clientTop;r.left=Math.max(r.left,n),r.top=Math.max(r.top,i),r.right=Math.min(r.right,n+(o.clientWidth||e.width)),r.bottom=Math.min(r.bottom,i+(o.clientHeight||e.height))}return r}function ot(t){const e=t.offsetParent??t.parentElement;if(!e)return{left:0,top:0};const n=e.getBoundingClientRect();return{left:n.left+e.clientLeft-e.scrollLeft,top:n.top+e.clientTop-e.scrollTop}}function it(t,e,n){const r=t.ownerDocument,l=r.createTreeWalker(t,4),o=t=>{let e=t,n=null;for(let t=l.nextNode();t;t=l.nextNode()){if(e<=t.data.length)return[t,e];e-=t.data.length,n=t}return n?[n,n.data.length]:null},i=o(e);l.currentNode=t;const a=o(n);if(!i||!a)return null;const s=r.createRange();return s.setStart(i[0],i[1]),s.setEnd(a[0],a[1]),s}export{X as ColorWindow,C as MARKUP_CLIPBOARD_TYPE,z as TYPING_BURST_MS,w as clearRangeOf,H as colorRunOf,U as createHistory,j as editVisible,Z as markPress,F as markupOfRange,V as newLine,ot as offsetOrigin,N as pasteToMarkup,et as placeWindow,O as richInput,E as richLayout,rt as selectionBox,W as selectionToSource,K as selectionToVisible,q as setBullet,_ as startCanvasTyping,Q as textMap,it as textRange,B as toSource,R as toSourceStart,L as toVisible,lt as visibleArea};
@@ -1,16 +0,0 @@
1
- import{sidesStartEach as e,SidesInput as n,SidesEachToggle as t}from"./chunk-CLAADE4J.js";import{SettingsDefaultReset as l}from"./chunk-2T22IY3J.js";import{deviceField as o}from"./chunk-7GGNFLHT.js";import{noControlField as a,NoControlMark as i}from"./chunk-22I55W37.js";import{describedAs as r}from"./chunk-LX23TCTP.js";import{withStyleKind as s}from"./chunk-CWELHADJ.js";import{phoneKey as u}from"./chunk-E52W3M5I.js";import{foldMetaOf as c,FOLD_FIELD_MARKER as d}from"./chunk-ANPOR6EY.js";import{useSelectedHost as p,useEaselApi as f,useEasel as b}from"./chunk-EVYIDHCK.js";import{DEFAULT_PANEL_WORDS as m}from"./chunk-56ID6FKZ.js";import{SettingsSwitch as h}from"./chunk-OECWLNKJ.js";import{FieldSelect as v}from"./chunk-KFWNGPW3.js";import{SettingsField as g}from"./chunk-MIX7EGRG.js";import{SettingsSegmented as y}from"./chunk-DX3VILZ3.js";import{useWords as k}from"./chunk-MFIRYGHW.js";import{useState as w}from"react";import{AlignmentIcon as x,BoxJustifyIcon as C,WrapIcon as j,GapIcon as F,WidthIcon as L,PlacementIcon as O,NudgeIcon as S,DesktopIcon as E,BoxXEndIcon as P,BoxXCenterIcon as I,BoxXStartIcon as R,PaddingAllIcon as A,BoxYBetweenIcon as M,BoxYStretchIcon as K,BoxYEndIcon as W,BoxYCenterIcon as B,BoxYStartIcon as G,BoxXBetweenIcon as N,BoxXStretchIcon as T,BoxItemAlignmentIcon as V}from"efficient-shell/icons/efficient";import{textAlignOptions as $,AlignmentGrid as D,PositionInput as H,Slider as J}from"efficient-shell/ui";import{jsx as Y,Fragment as _,jsxs as z}from"react/jsx-runtime";var X=e=>e;function Z(e,n){return e("{value} on desktop").replace("{value}",n)}var U=()=>{};function q(){return null}function Q(e){if(!e.trim())throw new Error("noGlyph() needs a reason naming the ruling that decided it.");/* @__PURE__ */
2
- return Y(q,{},e)}function ee(e){return e.type===q}function ne(e){return ee(e)?void 0:e}function te(e){for(const[n,t]of Object.entries(e))t&&"object"==typeof t&&!c(t)&&s(t,`section:${n}`);return e}function le(e,n){return{type:"custom",[d]:{label:e,level:n},marker:!0,fold:e,render:()=>/* @__PURE__ */Y(_,{})}}function oe(e){return le(e,2)}function ae(e){return le(e,1)}var ie=[{label:"Start",value:"start"},{label:"Center",value:"center"},{label:"Space between",value:"between"},{label:"End",value:"end"}],re=[{label:"Start",value:"start"},{label:"Center",value:"center"},{label:"End",value:"end"},{label:"Stretch",value:"stretch"}],se="Wrap",ue=[{label:"Wrap",value:"wrap"},{label:"No wrap",value:"nowrap"}],ce="Direction",de=[{label:"Stacked",value:"column"},{label:"One row",value:"row"}],pe={min:-32,max:64,step:2,builtIn:0},fe={min:30,max:100,step:5,fallback:60},be=["top-left","top-center","top-right","left","center","right","bottom-left","bottom-center","bottom-right"],me="bottom-left",he={"top-left":"Top left","top-center":"Top center","top-right":"Top right",left:"Left",center:"Center",right:"Right","bottom-left":"Bottom left","bottom-center":"Bottom center","bottom-right":"Bottom right"},ve=be.map(e=>({value:e,label:he[e]}));function ge(e,n=me){return be.includes(e)?e:n}var ye=40,ke=e=>"number"==typeof e?e:null;function we(e,n,t){const l={};for(const o of["x","y"])t[o]!==n[o]&&(l[e[o]]=t[o]??void 0);return l}var xe=["top","right","bottom","left"],Ce={top:"sectionPaddingTop",right:"sectionPaddingRight",bottom:"sectionPaddingBottom",left:"sectionPaddingLeft"},je=e=>"number"==typeof e?e:null;function Fe(e,n,t){const l={};for(const o of xe)t[o]!==n[o]&&(l[e[o]]=t[o]??void 0);return l}function Le(e){if("number"==typeof e)return{top:e,right:e,bottom:e,left:e};const n=e&&"object"==typeof e?e:{};return Object.fromEntries(xe.map(e=>[e,je(n[e])]))}function Oe(e){const n={};for(const t of xe)"number"==typeof e[t]&&(n[t]=e[t]);return Object.keys(n).length?n:void 0}function Se(e,n={}){const t=n=>{const t=n[e];return t&&"object"==typeof t?t:{}},l=e=>Object.hasOwn(n,e)?n[e]:e;return{read:(e,n)=>t(e)[l(n)],write:(n,o,a)=>{const i={...t(n)};return void 0===a?delete i[l(o)]:i[l(o)]=a,{[e]:Object.keys(i).length?i:void 0}}}}function Ee(e,n,t){const l=Pe(e),o=p();if(t)return[t.value,t.onChange];const a=o?.values??{};return[e.read(a,n),e=>l([[n,e]])]}function Pe(e){const n=p(),t=function(){try{return f()}catch{return null}}();return l=>{if(!n)return;const o=t?.getState(),a=(o?"root"===n.id?o.appState.data.root.props:o.getItemById(n.id)?.props:void 0)??n.values??{};let i={};for(const[n,t]of l)i={...i,...e.write({...a,...i},n,t)};n.onChangeMany(i)}}var Ie={read:(e,n)=>e[n],write:(e,n,t)=>({[n]:t})},Re={fieldKey:u,ownField:!0,read:(e,n)=>e[u(n)],write:(e,n,t)=>({[u(n)]:t})};function Ae(e){return{...Se(e),fieldKey:n=>`_${e}_${n}`}}function Me({row:e,desktopKey:n,access:t,props:l}){const o=p(),a=o?.values?.[n],[i,r]=Ee(t,n);return t.ownField?e.render({...l,follows:a,twinAccess:t}):e.render({...l,value:i,storedValue:i,follows:a,twinAccess:t,onChange:r})}function Ke(e,n,t=Re,l={}){const a=l.phoneRow??n,i={...a,render:n=>/* @__PURE__ */Y(Me,{row:a,desktopKey:e,access:t,props:n})};return{[e]:o("desktop",n),[t.fieldKey(e)]:o("mobile",i)}}var We=["left","center","right"];function Be(e,{options:n,value:t,onChange:l,ariaLabel:o,disabled:a=!1}){/* @__PURE__ */
3
- return Y(y,{options:n.map(n=>n.picture?{id:n.value,label:n.picture,title:e(n.title??n.label)}:{id:n.value,label:e(n.label),title:void 0===n.title?void 0:e(n.title)}),value:t,onChange:l,ariaLabel:e(o),disabled:a})}function Ge(e,{label:n,value:t,onChange:l,points:o}){const a=o.find(e=>e.disabled),i=o.map(n=>({...n,label:e(n.label),...n.title?{title:e(n.title)}:null}));/* @__PURE__ */
4
- return Y(g,{label:e(n),icon:/* @__PURE__ */Y(O,{}),hint:a?.title?e(a.title):void 0,children:/* @__PURE__ */Y(D,{label:e(n),value:t,points:i,onChange:l})})}function Ne({say:e,label:n,value:t,onChange:l,pointsFor:o}){const{appState:a,selectedItem:i}=b(e=>e),r=i?.props?.id?String(i.props.id):void 0;return Ge(e,{label:n,value:t,onChange:l,points:o(a?.data,r)})}function Te({say:e,o:n}){const t=p(),o=k("panel",m),a=t?.values??{},i={x:ke(a[n.keys.x]),y:ke(a[n.keys.y])},r=e(n.label??"Position"),s=Boolean(i.x||i.y),u=e=>{const l=we(n.keys,i,e);Object.keys(l).length&&t?.onChangeMany(l)},c=/* @__PURE__ */Y(H,{label:r,value:i,onChange:u,words:{x:e("Left and right"),y:e("Up and down"),unit:"px"},placeholder:{x:"0",y:"0"},min:n.min,max:n.max,step:n.step??1}),d=/* @__PURE__ */Y(l,{words:o,label:r,changed:s,detail:"0 px, 0 px",onReset:()=>u({x:null,y:null})});return null===n.label?/* @__PURE__ */z("div",{className:"sf-position-line",children:[c,d]}):/* @__PURE__ */Y(g,{label:r,icon:/* @__PURE__ */Y(S,{}),changed:s,action:d,children:c})}var Ve={x:{start:/* @__PURE__ */Y(R,{}),center:/* @__PURE__ */Y(I,{}),end:/* @__PURE__ */Y(P,{}),stretch:/* @__PURE__ */Y(T,{}),between:/* @__PURE__ */Y(N,{})},y:{start:/* @__PURE__ */Y(G,{}),center:/* @__PURE__ */Y(B,{}),end:/* @__PURE__ */Y(W,{}),stretch:/* @__PURE__ */Y(K,{}),between:/* @__PURE__ */Y(M,{})}},$e=e=>"row"===e?"row":"column";function De({say:e,kind:n,label:t,options:l,value:o,onChange:a,o:i}){const r=p(),s="justify"===n==("row"===(i.runs??$e)(r?.values?.[i.directionKey??"direction"]))?"x":"y";return Be(e,{options:l.map(e=>({label:e.label,value:e.value,picture:Ve[s][e.value]})),value:o,onChange:a,ariaLabel:t})}function He(e,n){const t=(e.useFallback??U)(n);return Object.fromEntries(xe.map(n=>[n,t?.[n]??e.fallback[n]]))}function Je({say:e,tier:n,o:t,props:l}){const o=He(t,l),a=p(),i=a?.values??{},r="mobile"===n?t.phoneKeys:t.keys,s=Object.fromEntries(xe.map(e=>[e,je(i[r[e]])])),u="mobile"===n?Object.fromEntries(xe.map(e=>[e,je(i[t.keys[e]])])):null;/* @__PURE__ */
5
- return Y(_e,{say:e,o:t,fallback:o,value:s,follows:u,readOnly:l.readOnly,onChange:e=>{const n=Fe(r,s,e);Object.keys(n).length&&a?.onChangeMany(n)}})}function Ye({say:e,o:n,props:t}){const l=He(n,t);/* @__PURE__ */
6
- return Y(_e,{say:e,o:n,fallback:l,value:Le(t.value),follows:"follows"in t?Le(t.follows):null,readOnly:t.readOnly,onChange:e=>t.onChange(Oe(e))})}function _e({say:o,o:a,fallback:i,value:r,follows:s,readOnly:u,onChange:c}){const d=Object.fromEntries(xe.map(e=>[e,String(s?.[e]??i[e])])),[p,f]=w(()=>e(r,d)),b=k("panel",m),h=xe.map(e=>d[e]),v=`${1===new Set(h).size?h[0]:h.join(" / ")}px`;/* @__PURE__ */
7
- return Y(g,{label:o(a.label),icon:a.icon??/* @__PURE__ */Y(A,{}),action:/* @__PURE__ */z(_,{children:[
8
- /* @__PURE__ */Y(t,{each:p,label:o("Each side"),onChange:f,disabled:u}),
9
- /* @__PURE__ */Y(l,{words:b,label:o(a.label),changed:xe.some(e=>"number"==typeof r[e]),detail:s?Z(o,v):v,disabled:u,onReset:()=>c({top:null,right:null,bottom:null,left:null})})]}),children:/* @__PURE__ */Y(n,{label:o(a.label),each:p,value:r,placeholder:d,min:a.min,max:a.max,step:a.step,readOnly:u,onChange:c,words:{sides:{top:o("Padding top"),right:o("Padding right"),bottom:o("Padding bottom"),left:o("Padding left")},vertical:o("Top and bottom"),horizontal:o("Left and right"),unit:"px"}})})}var ze=e=>""===e||"px"===e?e:` ${e}`;function Xe({label:e,value:n,onChange:t,min:o,max:a,step:i=1,unit:r="",hint:s,emptyLabel:u,inputMax:c,readOnly:d=!1,clears:p,detail:f,resetWords:b}){const m="number"==typeof n,h=p?/* @__PURE__ */Y(l,{label:e,changed:m,detail:f??u??(void 0===s?void 0:`${s}${ze(r)}`),disabled:d,onReset:()=>t(void 0),...b?{words:b}:{}}):void 0;return{track:/* @__PURE__ */Y("div",{className:"sf-slider",children:/* @__PURE__ */Y(J,{min:o,max:a,step:i,value:n,suffix:r||void 0,showInput:!0,label:e,disabled:d,...p&&void 0!==s?{placeholderValue:s}:{},...u?{emptyLabel:u}:{},...void 0!==c?{inputMax:c}:{},size:"sm",boxSize:"md",className:"sf-slider-track",onChange:e=>{null===e?p&&m&&t(void 0):e!==n&&t(e)}})}),reset:h}}function Ze({caption:e,label:n,value:t,hint:l,emptyLabel:o,...a}){const i=void 0!==l||void 0!==o,r="number"==typeof t,{track:s,reset:u}=Xe({...a,label:n,value:r?t:i?null:a.min,hint:l,emptyLabel:o,clears:i});/* @__PURE__ */
10
- return Y(g,{label:e??n,action:u,children:s})}function Ue({draw:e,props:n,useMax:t,useHint:l}){return e(n,{max:(t??U)(n),hint:(l??U)(n)})}function qe(e=X){function n(n,t,l,o,a,i,s="",u){const c="function"==typeof u?{action:u}:u??{},{action:d,clear:p}=c,f=(r,u)=>{const f="storedValue"in r?r.storedValue:r.value,b="follows"in r,m=b&&!1!==p?.phoneFollows,h=b||void 0!==p,v="number"==typeof r.value,y=void 0===p?i:u.hint??("function"==typeof p.hint?p.hint(r):p.hint)??i,k=m&&"number"==typeof r.follows?r.follows:y,w=ze(s),x=!p?.emptyLabel||m&&"number"==typeof r.follows?void 0:p.emptyLabel,C=x??`${k}${w}`,j="function"==typeof c.hint?c.hint(r):c.hint,{track:F,reset:L}=Xe({label:e(n),value:v?r.value:h?null:i,onChange:e=>r.onChange(e),min:l,max:u.max??o,step:a,unit:s,hint:h?k:void 0,emptyLabel:x,inputMax:c.inputMax,readOnly:!0===r.readOnly,clears:h,detail:m?Z(e,C):C});/* @__PURE__ */
11
- return Y(g,{label:e(n),icon:ne(t),hint:void 0===j?void 0:e(j),action:h?L:d?d(f,r.onChange):void 0,children:F})},b=c.useMax,m=p?.useHint;return{type:"custom",...r({},{type:"number",label:n}),render:b||m?e=>/* @__PURE__ */Y(Ue,{draw:f,props:e,useMax:b,useHint:m}):e=>f(e,{})}}function t(n){return Be(e,n)}function s(n,o,a,i,s={}){const u=a.map(e=>"string"==typeof e?{label:e,value:e}:e);return{type:"custom",...r({},{type:"radio",label:n,options:u.map(e=>({value:e.value,label:e.label}))}),render:a=>{const{value:r,onChange:c,field:d}=a,p=u.some(e=>e.value===r),f=!0===a.readOnly;if("follows"in a&&!u.some(e=>""===e.value)){const d=s.phoneRest?s.phoneRest(a.follows):a.follows,b=u.find(e=>e.value===d)??u.find(e=>e.value===i);/* @__PURE__ */
12
- return Y(g,{label:e(n),icon:ne(o),action:/* @__PURE__ */Y(l,{label:e(n),changed:p,detail:Z(e,e(b?.label??"")),disabled:f,onReset:()=>c(void 0)}),children:t({options:u,value:p?r:b?.value??i,onChange:c,ariaLabel:n,disabled:f})})}const b="follows"in a&&s.followsLabel?s.followsLabel(a.follows):void 0;/* @__PURE__ */
13
- return Y(g,{label:e(n),icon:ne(o),action:"follows"in a&&s.followsLabel?/* @__PURE__ */Y(l,{label:e(n),changed:null!=r&&""!==r,detail:void 0===b?void 0:Z(e,e(b)),disabled:f,onReset:()=>c(void 0)}):void 0,children:t({options:u,value:p?r:r||d?.currentValue||i,onChange:c,ariaLabel:n,disabled:f})})}}}function c(e,n){return n.phone?e.unshift({label:"Match desktop",value:"",picture:/* @__PURE__ */Y(E,{})}):n.inherit&&e.unshift({label:n.inherit,value:""}),e}function d(e,n){return n.inherit||n.phone?{...e,render:n=>e.render({...n,onChange:e=>n.onChange(""===e?void 0:e)})}:e}function p(e,n,t,l){if(l.access){const o=l.inherit?"":l.fallback??"left",a=t({...l,phone:!1}),i=e=>{const n="string"==typeof e&&""!==e&&a.some(n=>n.value===e)?e:o;return a.find(e=>e.value===n)?.label};return Ke(e,n(l,o),l.access,{phoneRow:n({...l,phone:!0},"",i)})}return{[e]:o("desktop",n(l)),[u(e)]:o("mobile",n({...l,phone:!0},""))}}function f(e){return c($(e.allow??We).map(e=>({label:e.label,value:e.value,picture:e.icon})),e)}function b(e,n=e.fallback??"left",t){return d(s(e.label??"Text alignment",/* @__PURE__ */Y(x,{}),f(e),n,t?{followsLabel:t}:{}),e)}function m(e){const n={left:Ve.x.start,center:Ve.x.center,right:Ve.x.end};return c($((e.allow??We).filter(e=>e in n)).map(e=>({label:e.label,value:e.value,picture:n[e.value]})),e)}function y(e,n=e.fallback??"left",t){return d(s(e.label??"Block alignment",/* @__PURE__ */Y(C,{}),m(e),n,t?{followsLabel:t}:{}),e)}function k(n,t,l,o,a,i){return{type:"custom",options:o,fallback:a,...r({},{type:"radio",label:t,options:o.map(e=>({value:e.value,label:e.label}))}),render:({value:r,onChange:s,field:u})=>{const c=u.options??o,d=u.fallback??a,p=c.some(e=>e.value===r)?r:d;/* @__PURE__ */
14
- return Y(g,{label:e(t),icon:ne(l),children:/* @__PURE__ */Y(De,{say:e,kind:n,label:t,options:c,value:p,onChange:s,o:i})})}}}function w(e={}){return k("justify","Justify",/* @__PURE__ */Y(C,{}),ie,ie[0].value,e)}function O(e={}){return k("align","Item alignment",/* @__PURE__ */Y(V,{}),re,"stretch",e)}function S(){const n=se;return{type:"custom",options:ue,fallback:ue[1].value,...r({},{type:"radio",label:n,options:ue.map(e=>({value:e.value,label:e.label}))}),render:({value:t,onChange:l,id:o,name:a})=>{const i=`${o??a??n}-label`;/* @__PURE__ */
15
- return Y(g,{label:e(n),labelId:i,icon:/* @__PURE__ */Y(j,{}),action:/* @__PURE__ */Y(h,{checked:(r=t,!0===r||"wrap"===r),onChange:e=>l(e?ue[0].value:ue[1].value),ariaLabelledBy:i})});var r}}}function P({offered:e,fallback:n,resolve:t}){const l=t??(t=>e.some(e=>e.value===t)?t:n),o=s(ce,Q("`Direction` names how a container’s children run — a MODIFIER, not a thing. doc/naming.md N10.1 gives the idea a dash in its Glyph column; the shell’s own `direction` meaning says the bare row is CORRECT and not an omission (SS seat, 2026-09-11)."),e.map(e=>({label:e.label,value:e.value})),l(void 0));return{type:"custom",render:e=>o.render({...e,value:l(e.value),onChange:n=>e.onChange(n)})}}function I({min:e,max:t,step:l,builtIn:o,resolve:a,action:i,mark:r}){const s=n("Gap",/* @__PURE__ */Y(F,{}),e,t,l,o,"px",i),u=a??(e=>"number"==typeof e?e:o);return{...r,type:"custom",render:e=>s.render({...e,value:u(e.value,e.field),storedValue:e.value,onChange:n=>e.onChange(n)})}}function R(n,{fallback:t=me,pointsFor:l}={}){return{type:"custom",render:({value:o,onChange:a})=>{const i=ge(o,t);return l?/* @__PURE__ */Y(Ne,{say:e,label:n,value:i,onChange:a,pointsFor:l}):Ge(e,{label:n,value:i,onChange:a,points:ve})}}}function A(n){return{[n.keys.x]:{type:"custom",render:()=>/* @__PURE__ */Y(Te,{say:e,o:n})},[n.keys.y]:{...a({type:"custom",render:()=>/* @__PURE__ */Y(i,{})},"always"),reachedBy:n.keys.x}}}function M(n={}){const t={...Ce,...n.keys},l={keys:t,phoneKeys:Object.fromEntries(xe.map(e=>[e,u(t[e])])),fallback:{top:0,right:0,bottom:0,left:0,...n.fallback},useFallback:n.useFallback,label:n.label??"Padding",icon:n.icon,min:n.min??0,max:n.max??200,step:n.step??4},r=!1!==n.phone,s=!1===n.group?{}:{_gSpacing:oe("Padding")};if(n.object){const t={type:"custom",render:n=>/* @__PURE__ */Y(Ye,{say:e,o:l,props:n})};return te({...s,...r?Ke(n.object.key,t,n.object.phone):{[n.object.key]:t}})}const c=n=>{const t={type:"custom",render:t=>/* @__PURE__ */Y(Je,{say:e,tier:n,o:l,props:t})};return r?o(n,t):t},d=()=>a({type:"custom",render:()=>/* @__PURE__ */Y(i,{})},"always"),p=xe.filter(e=>"top"!==e);return te({...s,[l.keys.top]:c("desktop"),...r?{[l.phoneKeys.top]:c("mobile")}:{},...Object.fromEntries(p.map(e=>[l.keys[e],{...d(),reachedBy:l.keys.top}])),...r?Object.fromEntries(p.map(e=>[l.phoneKeys[e],o("mobile",d())])):{}})}return{slider:n,select:function(n,t,o,a,i){return{type:"custom",options:o,fallback:a,...i?{note:i}:{},...r({},{type:"select",label:n}),render:r=>{const{value:s,onChange:u,field:c}=r,d=c.options??o,p=c.fallback??a,f=d.some(e=>e.value===s),b="follows"in r,m=b?d.find(e=>e.value===r.follows)??d.find(e=>e.value===p):void 0,h=f?s:m?.value??p,y=!0===r.readOnly;/* @__PURE__ */
16
- return Y(g,{label:e(n),icon:ne(t),action:b?/* @__PURE__ */Y(l,{label:e(n),changed:null!=s&&""!==s,detail:m?Z(e,e(m.label)):void 0,disabled:y,onReset:()=>u(void 0)}):void 0,children:/* @__PURE__ */Y(v,{value:h,ariaLabel:e(n),readOnly:y,onChange:u,options:[...i?[{label:e(i),value:"\0note",disabled:!0}]:[],...d.map(n=>({label:e(n.label),value:n.value}))]})})}}},Segmented:t,segmented:s,boxJustifyField:w,boxAlignField:O,boxWrapField:S,directionField:P,gapField:I,placementField:R,PlacementGridView:function(n){return Ge(e,n)},positionFields:A,sidesPaddingFields:M,alignmentField:function(e={},n=e.fallback??"left"){return b(e,n)},alignmentFields:function(e="align",n={}){return p(e,b,f,n)},AlignmentStrip:function({opts:e={},value:n,onChange:l,ariaLabel:o,disabled:a=!1}){return t({options:f(e),value:n,onChange:l,ariaLabel:o,disabled:a})},blockAlignmentField:function(e={},n=e.fallback??"left"){return y(e,n)},blockAlignmentFields:function(e="align",n={}){return p(e,y,m,n)},BlockAlignmentStrip:function({opts:e={},value:n,onChange:l,ariaLabel:o,disabled:a=!1}){return t({options:m(e),value:n,onChange:l,ariaLabel:o,disabled:a})},boxFieldSet:function(e={}){const t=e.width??fe,l=e.nudge?.limit??40,o=e.direction??{offered:de,fallback:"column"},a=o.resolve??(e=>o.offered.some(n=>n.value===e)?e:o.fallback),i={runs:e=>"row"===a(e)?"row":"column"};return{_gLayout:oe("Layout"),placement:R("Placement",e.placement),width:n("Width",/* @__PURE__ */Y(L,{}),t.min,t.max,t.step,t.fallback,"%"),direction:P(o),gap:I(e.gap??pe),justify:w(i),align:O(i),wrap:S(),_gNudge:oe("Nudge"),...A({keys:e.nudge?.keys??{x:"nudgeX",y:"nudgeY"},min:-l,max:l,label:null}),...M(e.padding)}}}}var{slider:Qe,select:en,Segmented:nn,segmented:tn,boxJustifyField:ln,boxAlignField:on,boxWrapField:an,directionField:rn,gapField:sn,placementField:un,PlacementGridView:cn,positionFields:dn,sidesPaddingFields:pn,alignmentField:fn,alignmentFields:bn,AlignmentStrip:mn,blockAlignmentField:hn,blockAlignmentFields:vn,BlockAlignmentStrip:gn,boxFieldSet:yn}=qe();export{he as ANCHOR_LABELS,mn as AlignmentStrip,re as BOX_ALIGN_POINTS,de as BOX_DIRECTIONS,ce as BOX_DIRECTION_LABEL,pe as BOX_GAP,ie as BOX_JUSTIFY_POINTS,ye as BOX_NUDGE_LIMIT,be as BOX_PLACEMENTS,me as BOX_PLACEMENT_DEFAULT,fe as BOX_WIDTH,se as BOX_WRAP_LABEL,ue as BOX_WRAP_POINTS,gn as BlockAlignmentStrip,Ie as FLAT_ACCESS,ve as OPEN_PLACEMENT_POINTS,Re as PHONE_KEY_ACCESS,cn as PlacementGridView,Ce as SIDE_PAD_KEYS,nn as Segmented,Ze as SliderControl,fn as alignmentField,bn as alignmentFields,hn as blockAlignmentField,vn as blockAlignmentFields,on as boxAlignField,qe as boxFieldBuilders,yn as boxFieldSet,ln as boxJustifyField,an as boxWrapField,rn as directionField,sn as gapField,oe as group,ne as iconOf,ee as isNoGlyph,Q as noGlyph,ge as normaliseBoxPlacement,Se as objectAccess,Z as onDesktopWords,Ae as phoneObjectAccess,Ke as phoneTwinFields,un as placementField,dn as positionFields,we as positionPatch,ae as section,tn as segmented,en as select,te as sharedStyleKinds,Le as sidesFromObject,pn as sidesPaddingFields,Fe as sidesPaddingPatch,Oe as sidesToObject,Qe as slider,Pe as useAccessPatch,Ee as useAccessValue};
@@ -1,5 +0,0 @@
1
- import{usePickFollowsSelection as n}from"./chunk-NCXYC7WI.js";import{slotFieldsOf as e,slotChildrenIn as t}from"./chunk-TCAAOYQY.js";import{EaselCanvas as r,useSelectedFields as o}from"./chunk-EVYIDHCK.js";import{Inspector as i}from"./chunk-WMC6FE3G.js";import{fieldIsShown as u}from"./chunk-BPXEFVSQ.js";import{createContext as l,useContext as s}from"react";import{DesktopIcon as c}from"efficient-shell/icons/efficient";import{jsx as f}from"react/jsx-runtime";var a={kind:"selection"};function d(n){return"selection"===n.kind}function p(n,e){if(d(n)&&d(e))return!0;const t=n,r=e,o=Object.keys(t);return o.length===Object.keys(r).length&&o.every(n=>Object.is(t[n],r[n]))}function m(n){const e=n;return"string"==typeof e.nodeId&&"string"==typeof e.slot}function k(n,t){const r=n.components?.[t.type]?.fields??{};return e(n,t.type).filter(n=>u(r[n],{values:t.props}))}function h(n,e){return k(n,e).flatMap(n=>t(e,n))}function v(n,e,t){const r=n.slotsOf?.(t);return r||k(e,t).map(n=>({slot:n,label:n,rung:!1}))}function y(n,e){return n.isFirst?n.isFirst(e):e.type===n.first}function g(n,e){return n.isLast?n.isLast(e):e.type===n.last}var b={},C=()=>b,O=()=>"",j=()=>null,w=()=>{},S={isLockedBlock:()=>!1,duplicateBlocked:()=>null,nestDepth:()=>0,newSectionNode:()=>null,canAddTo:()=>null,blockIsOffered:()=>!0},L={labelAtLevel:(n,e,t)=>t,descriptions:{},categoryLabel:()=>{},firstSection:null,blockRowName:(n,e)=>e(n.type),plainText:n=>n,Icon:()=>null,Thumbnail:()=>null,useProducts:()=>null},D={options:[{id:"desktop",label:"Desktop",icon:/* @__PURE__ */f(c,{})}],initial:"desktop",fluid:"desktop",widths:{desktop:2e3}},I={read:()=>"sections",write:()=>{},forSelection:(n,e)=>n?"sections":e},N={first:null,last:null,firstGroup:null,lastGroup:null,isSectionGroup:()=>!1,sectionGroupZone:()=>"",panelOf:()=>null};function P(){/* @__PURE__ */
2
- return f(r,{height:"fill"})}function B(){const{id:n,fields:e,values:t,readOnly:r,onChange:u}=o();/* @__PURE__ */
3
- return f("div",{className:"es-sidepanel es-sidepanel--right",children:/* @__PURE__ */f(i,{fields:e,values:t,onChange:u,readOnly:r,idPrefix:n})})}var F=l({});function G({parts:n,children:e}){/* @__PURE__ */
4
- return f(F.Provider,{value:n,children:e})}function x(){return s(F)}function A(){return(x().useOwnerName??O)()}function T(){return(x().useDocumentLabel??j)()}function Y(n,e,t,r){return(x().useBridges??C)(n,e,t,r)}function E(n){return(x().useStandaloneBridges??C)(n)}function V(n,e){(x().useDocumentPass??w)(n,e)}function H(){return x().blockRules??S}function K(){return x().blockLook??L}function M(){return x().devices??D}function Q(){return x().leftView??I}function R(){return x().pinned??N}function W(){return x().saveSwitch??!0}function X(e){n(!0===x().pickFollowsSelection,e)}function Z(){return x().storageNamespace||void 0}function q(){return x().styleClipboard??null}function z(){return x().nodeKeys??!0}function J(){return x().notify??null}function U(){return x().Canvas??P}function $(){return x().CanvasHead??null}function _(){return x().canvasDrag??null}var nn=l(null);function en({target:n,children:e}){/* @__PURE__ */
5
- return f(nn.Provider,{value:n,children:e})}function tn(){return s(nn)}function rn(){return x().Inspector??B}export{a as SELECTION_MODE,en as ScreenCanvasTargetProvider,G as ScreenPartsProvider,y as isPinnedFirst,g as isPinnedLast,d as isSelectionMode,m as isSlotMode,p as sameInspectorMode,v as screenSlotsOf,h as shownChildSlotsOf,k as shownSlotFieldsOf,K as useScreenBlockLook,H as useScreenBlockRules,Y as useScreenBridges,_ as useScreenCanvasDrag,U as useScreenCanvasFrame,$ as useScreenCanvasHead,tn as useScreenCanvasTarget,M as useScreenDevices,T as useScreenDocumentLabel,V as useScreenDocumentPass,rn as useScreenInspectorPanel,Q as useScreenLeftView,z as useScreenNodeKeys,J as useScreenNotify,A as useScreenOwnerName,x as useScreenParts,X as useScreenPickFollowsSelection,R as useScreenPinned,W as useScreenSaveSwitch,Z as useScreenStorageNamespace,q as useScreenStyleClipboard,E as useStandaloneScreenBridges};
@@ -1,8 +0,0 @@
1
- import{buildPaletteSections as e,pinnedSection as t,categoryLabel as n}from"./chunk-GDO4QJ4G.js";import{blockTypesIn as o}from"./chunk-IZGFJWH4.js";import{sectionTemplatesOf as r}from"./chunk-N7E6264U.js";import{sharedSectionsOf as l}from"./chunk-N3MJOHAG.js";import{SidePanelHead as i,PanelModeExit as s}from"./chunk-SBVIW3KJ.js";import{blockRuns as c}from"./chunk-RUQOIQWI.js";import{useScreenBlockLook as a,useScreenBlockRules as p,useScreenPinned as d}from"./chunk-UR7YBZJR.js";import{useEaselSession as m}from"./chunk-YM4UEGBV.js";import{DEFAULT_SCREEN_WORDS as f}from"./chunk-Q3VAJMXS.js";import{useEasel as u}from"./chunk-EVYIDHCK.js";import{easelMenuEntries as y}from"./chunk-FIVU2COQ.js";import{useWords as h}from"./chunk-MFIRYGHW.js";import{AddPanel as k}from"./chunk-SQTVXE5D.js";import{DEFAULT_DRAG_WORDS as g}from"./chunk-TQ5Y6S2X.js";import{useState as b,useEffect as v,useMemo as j,useRef as w}from"react";import{SharedIcon as C,AddIcon as I}from"efficient-shell/icons/efficient";import{ContextMenu as E,toast as O,Dialog as $,Button as S}from"efficient-shell/ui";import{jsx as x,jsxs as F,Fragment as M}from"react/jsx-runtime";function Q({name:e,pages:t,onDelete:n,onCancel:o}){const r=h("screen",f).shared,[l,i]=b(!1),s=w(null);/* @__PURE__ */
2
- return x($,{open:!0,role:"alertdialog",size:"sm",title:r.deleteTitle({name:e}),onClose:o,initialFocus:s,footer:/* @__PURE__ */F(M,{children:[
3
- /* @__PURE__ */x(S,{ref:s,variant:"secondary",onClick:o,children:r.cancel}),
4
- /* @__PURE__ */x(S,{variant:"danger",loading:l,onClick:()=>{(async()=>{i(!0);try{await n()}finally{i(!1)}})()},children:r.deleteShared})]}),children:r.deleteMessage({count:t})})}var T=e=>`section:${e}`,B=e=>`block:${e}`,D=e=>`template:${e}`,G=e=>`shared:${e}`,H=e=>`preset:${e}`;function J({at:w,placeBlocks:$,canTake:S,onPick:J,itemFor:V,session:W,siteWide:A,onClose:R,onHide:U,readOnly:Y}){const z=u(e=>e.config),L=a(),{labelAtLevel:N,categoryLabel:X,firstSection:K,Icon:P,Thumbnail:Z}=L,{blockIsOffered:_,canAddTo:q}=p(),ee=h("screen",f).add,te=h("drag",g).add,ne=m(),[oe,re]=b([]);v(()=>{let e=!1;const t=e=>_(e,ne);return r(ne).list().then(n=>{if(e)return;const r=z.components;re(n.filter(e=>e.node?.type&&r[e.node.type]&&o(e.node).every(t)))}).catch(()=>{}),()=>{e=!0}},[z,ne]);const le=d().shared,ie=h("screen",f).shared,[se,ce]=b([]),[ae,pe]=b(0);v(()=>{if(!le)return;let e=!1;const t=e=>_(e,ne);return l(ne).list().then(n=>{if(e)return;const r=z.components;ce(n.filter(e=>e.node?.type&&r[e.node.type]&&o(e.node).every(t)))}).catch(()=>{}),()=>{e=!0}},[z,ne,ae]);const[de,me]=b(null),[fe,ue]=b(null),ye=j(()=>e(z,L),[z]),he=e=>N(e,"section",z.components[e]?.label??e),ke=e=>({type:e.preset?H(e.preset.key):T(e.type),label:e.name,cover:/* @__PURE__ */x(Z,{type:e.type}),title:e.desc?`${e.name} — ${e.desc}`:ee.tile({name:e.name}),keywords:[e.alias??"",e.desc,e.type,e.catLabel].filter(Boolean)}),ge=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=oe.find(e=>e.id===o);return e?{kind:"template",template:e}:null}if("shared"===n){const e=se.find(e=>e.id===o);return e?{kind:"shared",section:e}:null}if("preset"===n){const e=ye.find(e=>e.preset?.key===o)?.preset;return e?{kind:"preset",preset:e}:null}return null},be=e=>/* @__PURE__ */x("span",{className:"es-add-glyph-cover",children:/* @__PURE__ */x(P,{type:e,size:26})}),ve=j(()=>{const e=t(ye,K),o=/* @__PURE__ */new Map,r=e=>{e.retired||o.has(e.type)||!_(e.type,ne)||o.set(e.type,e)};for(const t of e?[e]:ye.filter(e=>!e.preset)){const e=q(t.type)?.choices??[];e.forEach(r),e.forEach(e=>q(e.type,1)?.choices?.forEach(r))}$?.forEach(r);const l=new Set(ye.filter(e=>!e.preset).map(e=>e.type)),i=[...o.values()].filter(e=>!l.has(e.type)),s=e=>({type:B(e.type),label:e.label,cover:be(e.type),title:ee.tile({name:e.label}),keywords:[e.group??"",e.type].filter(Boolean)}),a=e=>!e.preset&&o.has(e.type)?{...ke(e),cover:be(e.type)}:ke(e),p=[];se.length>0&&p.push({key:"shared",title:ie.group,tiles:se.map(e=>({type:G(e.id),label:e.title,cover:/* @__PURE__ */x(Z,{type:e.node.type}),mark:/* @__PURE__ */x(C,{size:12}),title:ie.onPages({count:e.used_on.length}),keywords:[he(e.node.type),e.node.type]}))}),oe.length>0&&p.push({key:"templates",title:ee.templates,tiles:oe.map(e=>({type:D(e.id),label:e.name,cover:/* @__PURE__ */x(Z,{type:e.node.type}),keywords:[he(e.node.type),e.node.type]}))});const d=i.filter(e=>!e.group);let m=!1;for(const t of Object.keys(z.categories??{})){const o=ye.filter(e=>e.cat===t);if(0===o.length)continue;const r=e&&o.some(t=>t.type===e.type)?e:null,l=(r?[r,...o.filter(e=>e.type!==r.type)]:o).map(a);r&&!m&&(l.splice(1,0,...d.map(s)),m=!0),p.push({key:`category:${t}`,title:n(z,t,X),tiles:l})}const f=p.find(e=>e.key?.startsWith("category:"));if(!m&&f&&d.length>0&&(f.tiles=[...f.tiles,...d.map(s)],m=!0),c(i.filter(e=>e.group||!m)).forEach((e,t)=>{p.push({key:`blocks:${t}`,title:e.group??"",tiles:e.items.map(s)})}),!S)return p;const u=p.map(e=>({...e,tiles:e.tiles.map(e=>{const t=ge(e.type),n=t?S(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))]},[oe,se,ie,ye,z,ee,S,$,ne]);/* @__PURE__ */
5
- return F(M,{children:[
6
- /* @__PURE__ */x(i,{icon:/* @__PURE__ */x(I,{size:15}),title:ee.title,context:ee.contextAll,actions:/* @__PURE__ */x(s,{label:ee.done,description:ee.doneDescription,onClick:R}),onHide:U}),
7
- /* @__PURE__ */F("div",{className:"sf-addside sf-scroll",children:[
8
- /* @__PURE__ */x(k,{groups:ve,session:W,itemFor:e=>V(ge(e)??{kind:"section",type:e}),onInsert:J?e=>{const t=ge(e);t&&J(t)}:void 0,onTileMenu:(e,t)=>{const n=ge(e);return"shared"===n?.kind&&!Y&&(me({section:n.section,...t}),!0)},at:w,hint:ee.hint,searchLabel:ee.search,readOnly:Y,words:te}),A??null]}),de?/* @__PURE__ */x(E,{at:{x:de.x,y:de.y},owner:de.owner,onClose:()=>me(null),"aria-label":de.section.title,items:y([{label:ie.deleteShared,danger:!0,onClick:()=>{ue(de.section),me(null)}}])}):null,fe?/* @__PURE__ */x(Q,{name:fe.title,pages:fe.used_on.length,onDelete:()=>(async e=>{try{await l(ne).remove(e.id)}catch{return void O.error(ie.deleteFailed)}ue(null),le?.removed?.(e),ce(t=>t.filter(t=>t.id!==e.id)),pe(e=>e+1)})(fe),onCancel:()=>ue(null)}):null]})}export{J as AddSidePanel,B as blockKey,H as presetKey,T as sectionKey,G as sharedKey,D as templateKey};
@@ -1,64 +0,0 @@
1
- import{markedTreeNodeId as e,revealSelectedTreeRow as n,sameSelector as t}from"./chunk-UMBNBCL4.js";import{cloneNodeWithFreshIds as o}from"./chunk-OXZDSOZV.js";import{dedupeSlotChildren as r}from"./chunk-7OCEPOEJ.js";import{styleClipboardOf as i}from"./chunk-JYVQ62TL.js";import{scrollPreviewToSection as l,gotoPreviewSlide as s}from"./chunk-LUOY3A3Q.js";import{useEaselKeyTarget as d,useEaselUndoKeys as a,useEaselSaveKey as c,editorRootFocus as p}from"./chunk-CVS3RPO6.js";import{SlotChildActionsProvider as u}from"./chunk-KCBEE2MC.js";import{screenStorageKeys as f,DEFAULT_PANEL_W as h,clampPanelWidth as m}from"./chunk-6EDVZBUO.js";import{usePartBridge as g}from"./chunk-CQVSWONH.js";import{useSectionOps as y}from"./chunk-IVSPOIOU.js";import{PageEditGuardNotices as v}from"./chunk-TOEJCZUO.js";import{ScreenSaveIcon as b,ScreenMainButton as k}from"./chunk-PVBDKBJB.js";import{useBrowserOffline as S}from"./chunk-RKTF5XLP.js";import{useScreenDocument as w}from"./chunk-BYONFJVQ.js";import{requestMediaPick as x}from"./chunk-JIP5JNRB.js";import{AddChildRow as z}from"./chunk-5545A3PC.js";import{AddSidePanel as C}from"./chunk-W2UMJ7WO.js";import{keepsSharedSections as O,sharedSectionsOf as N}from"./chunk-N3MJOHAG.js";import{PanelHideButton as B,SidePanelHead as I,PanelShowStrip as P}from"./chunk-SBVIW3KJ.js";import{offeredChoices as T}from"./chunk-RUQOIQWI.js";import{useScreenSaveSwitch as $,useScreenNodeKeys as M,useScreenPinned as j,useScreenDocumentLabel as E,useScreenCanvasFrame as L,useScreenInspectorPanel as A,useScreenDevices as R,useScreenPickFollowsSelection as F,useScreenLeftView as D,SELECTION_MODE as V,isSelectionMode as W,sameInspectorMode as H,useScreenBridges as U,useScreenBlockRules as J,useScreenBlockLook as Y,useScreenStorageNamespace as X,useScreenNotify as Q,useScreenCanvasHead as K,isSlotMode as Z,useScreenStyleClipboard as G,useScreenDocumentPass as _,useScreenCanvasDrag as q,ScreenCanvasTargetProvider as ee,isPinnedFirst as ne,isPinnedLast as te,screenSlotsOf as oe,shownChildSlotsOf as re}from"./chunk-UR7YBZJR.js";import{MediaPopup as ie}from"./chunk-T2RINM7R.js";import{useMediaPanel as le,usePanelPick as se,useMediaBrowsing as de,useOpenMediaBrowse as ae,useMediaPlace as ce}from"./chunk-NCXYC7WI.js";import{useNodeClipboard as pe,useNodeContextMenu as ue}from"./chunk-STQDOTHF.js";import{useEaselSession as fe}from"./chunk-YM4UEGBV.js";import{useEaselHost as he,useHostEscape as me}from"./chunk-LX23TCTP.js";import{LayersIcon as ge,MediaIcon as ye}from"./chunk-XFYFKITX.js";import{DEFAULT_SCREEN_WORDS as ve}from"./chunk-Q3VAJMXS.js";import{heldStyle as be,styleShortcut as ke}from"./chunk-CWELHADJ.js";import{DEFAULT_STYLE_CLIPBOARD_WORDS as Se}from"./chunk-6WY6ZXJG.js";import{rootRowName as we,slotChildRowName as xe,slotChildRenameProp as ze,sectionRenameProp as Ce}from"./chunk-5NHQ452C.js";import{ROOT_ZONE as Oe,blockNodeActions as Ne,TREE_MAX_DEPTH as Be,childSlotsOf as Ie,slotFieldsOf as Pe,newNodeId as Te,slotChildrenIn as $e,nestsInTree as Me}from"./chunk-TCAAOYQY.js";import{useEasel as je,useEaselApi as Ee,CanvasPartsContext as Le,partHasOwnBox as Ae,CanvasPassThroughContext as Re,CanvasSharedContext as Fe}from"./chunk-EVYIDHCK.js";import{TreeRow as De,Subtree as Ve,LayersTree as We,TreeGroupLabel as He,TreeRowAction as Ue,TreeSeam as Je}from"./chunk-WHS6Y55E.js";import{DEFAULT_TREE_WORDS as Ye}from"./chunk-K56YDHYQ.js";import{DEFAULT_NODE_MENU_WORDS as Xe}from"./chunk-WK3AFPXY.js";import{toItemSelector as Qe,useNodeOps as Ke,clickPick as Ze}from"./chunk-QTHQPJWA.js";import{EaselTopBar as Ge,EaselIconButton as _e,TopBarCluster as qe,DeviceSwitch as en,InspectorIconButton as nn,PanelResizeHandle as tn,MAX_PANEL_W as on,MIN_PANEL_W_BY_SIDE as rn,panelWidthVars as ln}from"./chunk-VBEVZZTV.js";import{DEFAULT_NOTICE_WORDS as sn,DEFAULT_CHROME_WORDS as dn}from"./chunk-AJSDWWJW.js";import{holderOf as an,nameOrSomeone as cn}from"./chunk-YYD257TD.js";import{DEFAULT_LOCK_WORDS as pn}from"./chunk-RE4LP46F.js";import{useWords as un}from"./chunk-MFIRYGHW.js";import{insertSeams as fn,CanvasDragLayer as hn,CanvasInsert as mn}from"./chunk-SQTVXE5D.js";import{DEFAULT_DRAG_WORDS as gn}from"./chunk-TQ5Y6S2X.js";import{createDragSession as yn,useTreeDrag as vn,gapToMoveIndex as bn}from"./chunk-3XECMGXX.js";import{useCanvasFrame as kn,LIST_SELECTOR as Sn,BLOCK_SELECTOR as wn,useCanvasTyping as xn,useCanvasEvent as zn}from"./chunk-TOKMFZPB.js";import{nodeIdAt as Cn,frameRectToHost as On,BLOCK_ATTRIBUTE as Nn,drawnBox as Bn}from"./chunk-FR7EEKFF.js";import{queryMainCopy as In}from"./chunk-7UFKEX72.js";import{ROOT_ID as Pn,ROOT_SLOT as Tn,zoneKey as $n,parseZoneKey as Mn,find as jn,DataError as En}from"./chunk-EUFDQ4KL.js";import{useRef as Ln,useMemo as An,useState as Rn,useEffect as Fn,useCallback as Dn,useLayoutEffect as Vn,useContext as Wn,Fragment as Hn,useId as Un}from"react";import{ColoredBadge as Jn,Button as Yn,Tabs as Xn,toast as Qn,readMediaFileDrag as Kn,Tooltip as Zn,groupColors as Gn,Dialog as _n,FormField as qn,Input as et,MEDIA_FILE_DRAG_TYPE as nt}from"efficient-shell/ui";import{UndoIcon as tt,RedoIcon as ot,RefreshIcon as rt,AddIcon as it,TrashIcon as lt,EyeOffIcon as st,EyeIcon as dt,SharedIcon as at,DuplicateIcon as ct}from"efficient-shell/icons/efficient";import{jsx as pt,jsxs as ut,Fragment as ft}from"react/jsx-runtime";var ht="media-file";function mt({name:e,onMake:n,onCancel:t}){const o=un("screen",ve).shared,[r,i]=Rn(e),[l,s]=Rn(!1),d=Un(),a=Ln(null),c=async()=>{const e=r.trim();if(e&&!l){s(!0);try{await n(e)}finally{s(!1)}}};/* @__PURE__ */
2
- return pt(_n,{open:!0,size:"sm",title:o.makeShared,description:o.makeSharedHint,onClose:t,initialFocus:a,footer:/* @__PURE__ */ut(ft,{children:[
3
- /* @__PURE__ */pt(Yn,{variant:"secondary",onClick:t,children:o.cancel}),
4
- /* @__PURE__ */pt(Yn,{variant:"primary",loading:l,disabled:!r.trim(),onClick:()=>{c()},children:o.makeShared})]}),children:/* @__PURE__ */pt("form",{onSubmit:e=>{e.preventDefault(),c()},children:/* @__PURE__ */pt(qn,{label:o.name,htmlFor:d,children:/* @__PURE__ */pt(et,{id:d,ref:a,value:r,onChange:e=>i(e.target.value)})})})})}var gt=/* @__PURE__ */new WeakSet;function yt(e,n,t){const o=jn(e,n,t);if(!o)return null;const r=o.path.find(e=>"root"!==e.parentId);return r?r.parentId:t}function vt({canvas:e,tabs:n,onSelect:t}){const o=Ln(null),[r,i]=Rn({}),l=n.map(e=>`${e.id}:${e.below?1:e.above?2:0}`).join("|");return Vn(()=>{const t=e?.document,r=e?.window,l=e?.frame;if(!t||!r||!l||0===n.length)return void i({});let s=0;const d=()=>{s=0;const e=o.current;if(!e)return;const d=On(l,{left:0,top:0,width:r.innerWidth,height:r.innerHeight},e),a={};for(const o of n){const n=In(t,`[${Nn}="${r.CSS?.escape?r.CSS.escape(o.id):o.id}"]`),i=n?Bn(n):null;if(!i||0===i.height){a[o.id]=null;continue}const s=On(l,{left:i.left,top:i.top,width:i.width,height:i.height},e),c=s.top+s.height;if(c<d.top||s.top>d.top+d.height){a[o.id]=null;continue}const p=!0===o.above&&s.top-4>d.top,u=o.below?c+4:p?s.top-4:Math.max(s.top,d.top)+6;a[o.id]={left:Math.max(s.left,d.left)+(o.above?0:6),top:u,above:p}}i(a)},a=()=>{s||(s=r.requestAnimationFrame(d))};d(),r.addEventListener("scroll",a,!0),r.addEventListener("resize",a);const c=new r.MutationObserver(a);return c.observe(t.body,{childList:!0,subtree:!0,attributes:!0}),()=>{s&&r.cancelAnimationFrame(s),r.removeEventListener("scroll",a,!0),r.removeEventListener("resize",a),c.disconnect()}},[e,l]),/* @__PURE__ */pt("div",{ref:o,className:"es-band-tabs","aria-hidden":"true",children:n.map(e=>{const n=r[e.id];return n?/* @__PURE__ */pt("span",{className:"es-band-tab"+(n.above?" is-above":""),"data-band-tab":e.id,style:{left:n.left,top:n.top},onClick:n=>{n.stopPropagation(),t(e.id)},children:e.reach?
5
- /* @__PURE__ */pt(Zn,{content:e.reach,children:/* @__PURE__ */ut(Jn,{colorClass:Gn("success","solid"),size:"sm",children:[
6
- /* @__PURE__ */pt("span",{className:"es-band-tab-mark",children:/* @__PURE__ */pt(at,{size:12})}),e.label]})}):/* @__PURE__ */pt(Jn,{colorClass:Gn("info","solid"),size:"sm",children:e.label})},e.id):null})})}function bt({expand:e}){/* @__PURE__ */
7
- return pt("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.9,strokeLinecap:"round",strokeLinejoin:"round",children:/* @__PURE__ */ut(ft,e?{children:[
8
- /* @__PURE__ */pt("path",{d:"M8 9l4-4 4 4"}),
9
- /* @__PURE__ */pt("path",{d:"M8 15l4 4 4-4"})]}:{children:[
10
- /* @__PURE__ */pt("path",{d:"M8 4l4 4 4-4"}),
11
- /* @__PURE__ */pt("path",{d:"M8 20l4-4 4 4"}),
12
- /* @__PURE__ */pt("path",{d:"M5 12h14"})]})})}var kt=`${Sn}, ${wn}`;function St(e,n,t){const o=t-n;if(o<6)return null;if(o<24)return{top:Math.round((n+t)/2),height:Math.round(o)};return{top:Math.round(Math.min(Math.max(e,n+12),t-12))}}var wt="__rungs",xt=e=>"template"===e.kind?e.template.id:"shared"===e.kind?e.section.id:"preset"===e.kind?e.preset.key:e.type;var zt="screen:band",Ct={duplicate:!0,delete:!0},Ot=()=>null;function Nt(){const Sn=he(),On=Sn.panels?.Toolbar,Nn=(Sn.panels?.useRight??Ot)(),{target:Bn,docId:Un,capabilities:Zn,currentSlug:Gn,siteId:_n,onPublish:qn,saveState:et,saveConflict:at,retrySave:Nt,toggleAutoSave:Bt,flushSave:It,access:Pt,saveUnreachable:Tt=!1,readOnly:$t,readOnlyReason:Mt=null}=w(),jt=$(),Et=M(),{mediaEditing:Lt,hasEditGuard:At,hasPinnedChrome:Rt}=Zn,{appState:Ft,dispatch:Dt,history:Vt,selectedItem:Wt,getSelectorForId:Ht,config:Ut}=je(e=>e),Jt=j(),{first:Yt,firstGroup:Xt,lastGroup:Qt,isSectionGroup:Kt,sectionGroupZone:Zt,panelOf:Gt}=Jt,_t=Gt(Yt),qt=e=>ne(Jt,e),eo=e=>te(Jt,e),no="node"===Jt.firstRow,to=Jt.band??null,oo=un("screen",ve),ro=un("tree",Ye),io=un("drag",gn),lo=un("notice",sn),so=un("lock",pn),ao=un("menu",Xe),co=un("styleClipboard",Se),po=un("chrome",dn),uo=E()??`/${Gn}`,fo=L(),ho=A(),mo=y({readOnly:$t}),go=y({readOnly:$t,foldIntoHistory:!0}),yo=Ln(null),vo=Ee(),bo=An(()=>({...mo,select:e=>{yo.current=e,mo.select(e)},commitDocument:(e,n)=>{if(void 0!==n){const t=vo.config;yo.current=Qe(e,t,n)}mo.commitDocument(e,n)}}),[mo,vo]),ko=Ft.ui,So=ko.leftSideBarVisible,wo=ko.rightSideBarVisible,{options:xo,widths:zo,initial:Co,fluid:Oo,fit:No}=R(),[Bo,Io]=Rn(Co),Po=le(),To=Lt&&null!==Po;se(),de();const $o=ae();F(Wt?.props.id);const{read:Mo,write:jo,forSelection:Eo}=D(),[Lo,Ao]=Rn(Mo);Fn(()=>{jo(Lo)},[Lo]);const[Ro,Fo]=Rn(0),Do=Ln(null),Vo=Ln(null),Wo=kn(Vo,{readySelector:kt}),Ho=xn(Wo),Uo=d(Vo);a(Vo,Wo);const Jo=S(),Yo=an(Pt),Xo={state:et,offline:Jo||et.failed&&Tt,readOnlyReason:Mt,editing:Yo?lo.editing({name:cn(Yo.name,so),noun:oo.noun}):null,conflict:null!=at,notSaving:oo.bar.notSaving},Qo=()=>{$t||(et.failed?Nt():It())};c(Vo,Wo,Qo);const[Ko,Zo]=Rn(!1),Go=Ln(!1),[_o,qo]=Rn(null),[er,nr]=Rn([]),[tr,or]=Rn(V);W(tr);const rr=e(tr,Wt?.props.id),[ir,lr]=Rn(null);Fn(()=>{ir&&(n(),lr(null))},[ir]);const sr=Ln(Ht);sr.current=Ht;const dr=Dn((e,{scroll:n})=>{Ao(n=>Eo(e,n)),n&&lr(e);const t=[];let o=e;for(let e=0;e<4;e++){const e=sr.current(o)?.zone;if(!e||!e.includes(":"))break;const n=e.split(":")[0];t.push(n),t.push(e),o=n}0!==t.length&&Rr(e=>{if(t.every(n=>!e.has(n)))return e;const n=new Set(e);return t.forEach(e=>n.delete(e)),n})},[]),ar=Ln(null);Fn(()=>{const e=ar.current;ar.current=null;const n=null==Wt?.props.id?null:String(Wt.props.id);or(t=>e&&e.id===n?e.mode:"part"===t.kind&&"nodeId"in t&&t.nodeId===n?t:Gt(Wt?.type)??V);const o=Wt?.props.id,r=yo.current;if(yo.current=null,!o)return;const i=Ht(o);dr(String(o),{scroll:!t(r,i??null,Oe)})},[Wt?.props.id,dr]);const cr=Dn(e=>{or(n=>H(n,e)?n:e),Dt({type:"setUi",ui:{rightSideBarVisible:!0}})},[Dt]),pr=Ln(()=>{});pr.current=(e,n)=>{const t=e?Mi(e.zone??Oe)[e.index]?.props.id:null,o=null==t?null:String(t),r=null==Wt?.props.id?null:String(Wt.props.id);or(e=>H(e,n)?e:n),o!==r&&(ar.current={id:o,mode:n},bo.select(e))};const ur=Dn((e,n)=>pr.current(e,n),[]),fr={kind:tr.kind,mode:tr,open:cr,show:e=>or(e),reveal:()=>{wo||Dt({type:"setUi",ui:{rightSideBarVisible:!0}})},select:ur},hr=U(fr,{data:Ft.data,selected:Wt??null,zoneOf:e=>Ht(e)?.zone,readOnly:Boolean($t),select:e=>{or(V),bo.select({index:e})},replace:(e,n)=>bo.replaceComponent(Oe,e,n),scrollTo:e=>l(e)},{device:Bo,refreshes:Ro},{setView:Ao,reveal:()=>{So||Dt({type:"setUi",ui:{leftSideBarVisible:!0}})}}),mr=hr.resolveLeftView?hr.resolveLeftView(Lo):"sections",gr=J(),{isLockedBlock:yr,duplicateBlocked:vr,nestDepth:br,newSectionNode:kr,canAddTo:Sr,blockIsOffered:wr}=gr,xr=e=>({id:String(e.props.id??""),data:Ft?.data}),zr=Y(),{labelAtLevel:Cr,Icon:Or,useProducts:Nr}=zr,Br=zr.rowName?(e,n,t)=>zr.rowName(e,n,t):void 0,Ir=Dn(e=>{Dt({type:"setUi",ui:{rightSideBarVisible:!0}}),l(e),dr(e,{scroll:!0})},[Dt,dr]),{selectNode:Pr,openPartId:Tr}=g({mode:tr,setMode:or,onOpenPart:Ir}),[$r,Mr]=Rn(null);me(null!==$r,()=>Mr(null));const jr=f(X()),Er=jr.collapsed,Lr=jr.panelWidths,[Ar,Rr]=Rn(()=>{if("undefined"==typeof window)/* @__PURE__ */return new Set;try{const e=window.localStorage.getItem(Er);return new Set(e?JSON.parse(e):[])}catch{/* @__PURE__ */
13
- return new Set}});Fn(()=>{try{window.localStorage.setItem(Er,JSON.stringify([...Ar]))}catch{}},[Ar]);const[Fr,Dr]=Rn(()=>{if("undefined"==typeof window)return{...h};try{const e=window.localStorage.getItem(Lr);if(!e)return{...h};const n=JSON.parse(e);return{left:m(Number(n.left)||h.left,"left"),right:m(Number(n.right)||h.right,"right")}}catch{return{...h}}});Fn(()=>{const e=setTimeout(()=>{try{window.localStorage.setItem(Lr,JSON.stringify(Fr))}catch{}},300);return()=>clearTimeout(e)},[Fr]);const Vr=Dn((e,n)=>Dr(t=>{const o="function"==typeof n?n(t[e]):n;return t[e]===o?t:{...t,[e]:o}}),[]),Wr=Dn(e=>Vr("left",e),[Vr]),Hr=Dn(e=>Vr("right",e),[Vr]),Ur=e=>Ar.has(e),Jr=e=>Rr(n=>{const t=new Set(n);return t.has(e)?t.delete(e):t.add(e),t}),Yr=Ln(!1),Xr=Ln(null);Fn(()=>{if(Yr.current&&!Ko){const e=Xr.current,n=e&&e.isConnected&&!e.closest('[aria-hidden="true"]')?e:null;(n??Vo.current?.querySelector(`button[aria-label="${CSS.escape(oo.add.title)}"]`))?.focus(),Xr.current=null}Yr.current=Ko},[Ko]),Fn(()=>{if(!Ko||!Uo)return;const e=e=>{"Escape"===e.key&&ul()};return Uo.addEventListener("keydown",e),()=>Uo.removeEventListener("keydown",e)},[Ko,Uo]),me(Ko,()=>ul()),Fn(()=>{!So&&Ko&&(Zo(!1),qo(null),Go.current=!1)},[So]);const Qr=Q(),Kr=(e,n="success",t)=>{if(Qr)return void(t?Qr(e,"error"===n?"error":"info",t):Qr(e,"error"===n?"error":"info"));const o={sound:!1,action:t?.action,onClose:t?.onClose};"error"===n?Qn.error(e,{...o,duration:t?.duration??3200}):Qn.success(e,{...o,duration:t?.duration??1900})},Zr=Ln(null),[Gr,_r]=Rn(0),[qr,ei]=Rn(0),ni=K(),ti=Ln(null),oi=e=>Math.max(0,e.clientHeight-(ti.current?.offsetHeight??0));Fn(()=>{const e=Zr.current;if(!e)return;const n=()=>{_r(e.clientWidth),ei(oi(e))};n();const t=new ResizeObserver(n);return t.observe(e),ti.current&&t.observe(ti.current),()=>t.disconnect()},[]),Vn(()=>{Zr.current&&(_r(Zr.current.clientWidth),ei(oi(Zr.current)))},[Fr,So,wo]);const ri=Bo===Oo?Gr>0?Gr:zo[Oo]:zo[Bo],ii=Gr>0?Math.min(Gr/ri,"shrink"===No?1:2):1,li=ri*ii,si=Gr>0&&li>Gr+1,di={width:li,height:qr||"100%",flex:"none",position:"relative"},ai={width:ri,height:qr?qr/ii:"100%",maxHeight:"none",transform:1!==ii?`scale(${ii})`:void 0,transformOrigin:"top left"},ci=()=>Dt({type:"setUi",ui:{leftSideBarVisible:!So}}),pi=()=>Dt({type:"setUi",ui:{rightSideBarVisible:!wo}}),ui=e=>{Ko&&(Zo(!1),qo(null),Go.current=!1,So&&Lo===e)||(Ao(e),So||Dt({type:"setUi",ui:{leftSideBarVisible:!0}}))},fi=()=>{or(_t??V),wo||Dt({type:"setUi",ui:{rightSideBarVisible:!0}})},hi=Ft.data.content??[],mi=()=>{const e=hi.findIndex(qt),n=hi.findIndex(eo);return{floor:e>=0?e+1:0,cap:n>=0?n:hi.length}},gi=Ut,yi=gr.stripCopy,vi=e=>o(e,yi),bi=pe(),ki=Ke({data:Ft.data,config:gi,readOnly:Boolean($t),clipboard:bi,strip:yi?e=>yi(e):void 0,afterRemove:"none",stepBounds:(e,n)=>{if(e.parentId!==Pn||e.slot!==Tn)return{min:0,max:n-1};const{floor:t,cap:o}=mi();return{min:t,max:o-1}},commit:(e,{select:n})=>{void 0!==n&&or(V);const t=void 0===n||"node"===n?.kind?n:null;bo.commitDocument(e,t)}}),Si=fe(),[wi,xi]=Rn(null),zi=e=>{const n=hi.find(n=>String(n.props.id)===e),t=Jt.shared;n&&t&&ki.swap(e,t.detach(n))},Ci=e=>{const n=jn(Ft.data,Ut,e);if(!n)return!1;const t=$n(n.place),o=n.node,r=t===Oe?Pi(o):Ji(o),i=t===Oe?Jt.shared?.usedOn(o):null;return!!ki.remove(e)&&(Kr(i?oo.shared.removed({count:Math.max(0,i.length-1)}):oo.deleted({name:r}),"success",{duration:8e3,action:{label:oo.bar.undo,onClick:()=>{ki.restore(n.node,n.place)}}}),!0)},Oi={...ki,remove:Ci},Ni=e=>Cr(e,"block",Ut.components[e]?.label??e),Bi=Dn(e=>Ut.components[e]?.defaultProps??{},[Ut]),Ii=e=>Cr(e,"section",Ni(e)),Pi=e=>we({type:e.type,props:e.props??{}},Ii(e.type),Br),{nodeAddresses:Ti,zoneItems:$i}=An(()=>{const e=/* @__PURE__ */new Map,n=/* @__PURE__ */new Map,t=(o,r,i)=>{n.set(r,o),o.forEach((n,o)=>{const l=String(n.props?.id??"");if(l&&e.set(l,{zone:r,index:o}),i>=Be)return;const s=/* @__PURE__ */new Map;for(const{child:e,zone:t}of Ie(Ut,n))s.set(t,[...s.get(t)??[],e]);for(const[e,n]of s)t(n,e,i+1)})};return t(hi,Oe,0),{nodeAddresses:e,zoneItems:n}},[hi,Ut]),Mi=Dn(e=>$i.get(e)??[],[$i]),ji=e=>{const n=Ti.get(e);return n?Mi(n.zone)[n.index]:void 0},Ei=e=>oe(gr,Ut,e),Li=e=>{if(!gr.slotsOf||e===Oe)return null;const n=e.lastIndexOf(":");if(n<=0)return null;const t=ji(e.slice(0,n));if(!t)return null;const o=Ei(t).filter(e=>e.rung),r=o.findIndex(t=>t.slot===e.slice(n+1));return r<0?null:{node:t,slot:o[r],position:r}},Ai=(()=>{if(!Z(tr))return null;const e=`${tr.nodeId}:${tr.slot}`;return Li(e)?.slot.panel===tr.kind?e:null})(),Ri=Ln(null);Fn(()=>{const e=Ri.current;if(Ri.current=null,!Ai||!Z(tr))return;const n=tr.nodeId;dr(n,{scroll:e!==Ai}),Rr(e=>{if(!e.has(n))return e;const t=new Set(e);return t.delete(n),t})},[tr]);const Fi=e=>{const n=Ti.get(e);n&&(n.zone===Oe?il(n.index):$l(n.zone,n.index,e,ji(n.zone.slice(0,n.zone.lastIndexOf(":")))?.type??""))},Di=(e,n,t)=>{const o=String(e.props.id);if(!n.panel)return void Fi(o);const r={kind:n.panel,nodeId:o,slot:n.slot},i=`${o}:${n.slot}`;t&&Ai!==i&&(Ri.current=i),ur(null,r),wo||Dt({type:"setUi",ui:{rightSideBarVisible:!0}}),l(o)},Vi=(e,n,t)=>{const o=`${e}:${n}`;if(Rr(n=>{if(!n.has(o)&&!n.has(e))return n;const t=new Set(n);return t.delete(o),t.delete(e),t}),!t)return;Ai!==o&&(Ri.current=o);ur(null,{kind:t,nodeId:e,slot:n})},Wi=(e,n,t)=>{if($t||!gr.moveSlot)return;const o=ji(e),r=o?Ei(o).filter(e=>e.rung):[],i=r[n];if(!i)return;const l={parentId:e,slot:wt,index:n},s=bn(l,{...l,index:Math.min(Math.max(t,0),r.length)});if(s===n)return;const d=gr.moveSlot(e,n,s);"string"==typeof d&&Vi(e,d,i.panel)},Hi=Nr(),Ui=An(()=>{const e=/* @__PURE__ */new Map;for(const n of Hi??[])e.set(n.slug,n.name);return e},[Hi]),Ji=e=>xe(e,Ni,zr.plainText,e=>Ui.get(e),zr.rowName),Yi=(e,n)=>{const t=Ut.components[e.type]?.fields,o=n===Oe||rs(n)?"section":"block",r=n===Oe&&(qt(e)||eo(e)||Kt(e.type)),i="block"===o?ze(t):r?null:Ce(t);return zr.renamePropOf?zr.renamePropOf(e,o,i):i},Xi=(e,n,t,o)=>{if(!(!$t&&$r?.zone===e&&$r.index===n))return;const r=(t,o)=>{Mr(null),o&&((e,n,t)=>{const o=Mi(e)[n];if(!o)return;const r=Yi(o,e);r&&bo.replaceComponent(e,n,{...o,props:{...o.props,[r]:t.trim()}})})(e,n,t)};/* @__PURE__ */
14
- return pt("input",{className:"es-tree-rename",defaultValue:o,autoFocus:!0,"aria-label":oo.rename,onClick:e=>e.stopPropagation(),onBlur:e=>r(e.currentTarget.value,!0),onKeyDown:e=>{"Enter"===e.key?(e.preventDefault(),r(e.currentTarget.value,!0)):"Escape"===e.key&&(e.preventDefault(),r("",!1))}},t)},Qi=i(G(),co),Ki=Qi.scope({target:Bn,siteId:_n,docId:Un}),Zi=Ut,Gi=(e,n)=>n===Oe?Ii(e):Ni(e),_i=(e,n,t)=>{const o=Qi.plan(Ki,t,Gi(t.type,e),Zi);o&&(o.changed&&bo.replaceComponent(e,n,{...t,props:{...o.props,id:t.props.id}}),Kr(o.message))},qi=ue({nodesIn:Mi,nodeAt:(e,n)=>Mi(e)[n]??null,labelOf:(e,n)=>n===Oe?Ii(e):Ni(e),renamePropOf:Yi,beginRename:(e,n)=>Mr({zone:e,index:n}),history:{hasPast:Vt.hasPast,hasFuture:Vt.hasFuture,back:()=>Vt.back(),forward:()=>Vt.forward()},openPageStyles:hr.openPageStyles,pageStylesLabel:oo.pageStyles,words:{menu:ao,styleClipboard:co,screen:oo.menu},readOnly:Boolean($t),collapseAll:()=>Rr(new Set(Mi(Oe).map(e=>String(e.props.id)))),onPasteRefused:e=>Kr(e?oo.pasteRefused({name:e.label}):oo.menu.clipboardRefused,"error"),canPasteAt:(e,n)=>ss(e,n),copyItem:hr.onCopyItem,menuRows:(e,n,t)=>{const o=hr.menuRows?.(e,n,t)??null,r=((e,n)=>{const t=Jt.shared;if(!t||n!==Oe)return null;const o=t.usedOn(e);if(o){const n={pick:[{label:oo.shared.onPages({count:o.length}),onClick:()=>{},children:o.map(e=>({label:e.title,onClick:()=>t.openPage(e)}))}]};return $t||yr(e.type,e)?n:{...n,change:[{label:oo.shared.detach,onClick:()=>zi(e.props.id)}],remove:[{label:oo.shared.removeFromPage,danger:!0,onClick:()=>{Ci(e.props.id)}}]}}return $t||qt(e)||eo(e)||Kt(e.type)?null:O(Si)?{change:[{label:oo.shared.makeShared,onClick:()=>xi({id:e.props.id,name:Pi(e)})}]}:null})(e,n);if(!r)return o;return Object.fromEntries(["pick","make","change","remove"].map(e=>[e,[...o?.[e]??[],...r[e]??[]]]).filter(([,e])=>e.length>0))},isLocked:e=>yr(e.type,e),duplicateBlocked:e=>vr(Ft.data,e),permits:e=>{const n=Ne(Ut,e.type);return Jt.shared?.usedOn(e)?{...n,delete:!1}:n},nodeOps:Oi,isPinned:(e,n)=>n===Oe&&(qt(e)||eo(e)),sectionBand:mi,locate:e=>Ti.get(e)??null,rowNameOf:(e,n)=>n===Oe?Pi(e):Ji(e),selectAt:(e,n,t,o)=>{e===Oe?il(n):$l(e,n,t,o??"")},slotRung:e=>{const n=Li(e);return n?.slot.panel?{label:n.slot.label,select:()=>Di(n.node,n.slot,!1)}:null},style:{held:()=>be(Ki),canCopy:e=>Qi.rows(Zi,e).some(e=>!1!==e.counted),copy:(e,n)=>Qi.copy(Ki,e,Gi(e.type,n),Zi),paste:(e,n,t)=>_i(e,n,t)},keys:Et?{target:Uo,selected:()=>{const e=Ft.ui.itemSelector;return e?{zone:e.zone??Oe,index:e.index}:null},held:()=>bi.get(),readOnly:Boolean($t),onDone:({done:e,name:n})=>{"copied"===e&&Kr(oo.copied({name:n}))}}:void 0},Wo),el=Ln({copy:(e,n)=>{},paste:(e,n,t)=>{},at:()=>null,readOnly:!1});Fn(()=>{el.current={copy:(e,n)=>Qi.copy(Ki,e,Gi(e.type,n),Zi),paste:_i,at:()=>{const e=Ft.ui.itemSelector;if(!e)return null;const n=e.zone??Oe,t=Mi(n)[e.index];return t?{zone:n,index:e.index,node:t}:null},readOnly:Boolean($t)}});const nl=Dn(e=>{const n=ke(e);if(!n)return;const t=el.current,o=t.at();o&&(e.preventDefault(),"copy"===n?t.copy(o.node,o.zone):t.readOnly||t.paste(o.zone,o.index,o.node))},[]);Fn(()=>{if(!Uo)return;const e=e=>nl(e);return Uo.addEventListener("keydown",e),()=>Uo.removeEventListener("keydown",e)},[nl,Uo]),zn(Wo,"keydown",nl);const tl=hi.map(e=>e.props.id).join("|");Fn(()=>{const e=Wo?.document??null,n=Wo?.window??null;let t=0;const o=[],r=()=>{if(!e)return void nr(e=>e.length?[]:e);const n=hi.findIndex(eo),t=n>=0?n:hi.length,o=n=>{const t=hi[n]?.props?.id;return null==t?null:In(e,`[data-easel-block="${CSS.escape(String(t))}"]`)},r=e=>e?[...e.querySelectorAll(wn)].map(e=>e.getBoundingClientRect()).filter(e=>e.width>0||e.height>0):[],i=[];for(let e=hi.length>0&&!qt(hi[0])?0:1;e<=t;e++){const n=o(e),t=o(e-1),l=n?.getBoundingClientRect()??null,s=t?.getBoundingClientRect()??null;if(!l&&!s)continue;const d=St(l&&s?(s.bottom+l.top)/2:l?0===e?l.top+12:l.top:s.bottom,Math.max(0===e?0:-1/0,...r(t).map(e=>e.bottom)),Math.min(1/0,...r(n).map(e=>e.top)));d&&i.push({...d,index:e})}nr(e=>function(e,n){if(e.length!==n.length)return!1;for(let t=0;t<e.length;t++)if(e[t].top!==n[t].top||e[t].index!==n[t].index||e[t].height!==n[t].height)return!1;return!0}(e,i)?e:i)},i=()=>{cancelAnimationFrame(t),t=requestAnimationFrame(r)};if(!e||!n)return void r();n.addEventListener("scroll",i,{passive:!0});const l=new ResizeObserver(i);return l.observe(e.documentElement),r(),o.push(setTimeout(r,150),setTimeout(r,450)),()=>{cancelAnimationFrame(t),o.forEach(clearTimeout),n.removeEventListener("scroll",i),l.disconnect()}},[Wo,tl,Bo,ii,So,wo,Wt?.props.id]);const ol=Wo?.document??null,rl=Wo?.window??null;Fn(()=>{const e=Do.current;if(!e||!ol||!rl)return;const n=[],t=()=>{const n=In(ol,`[data-easel-block="${CSS.escape(e.id)}"]`);if(!n)return!1;const t=n.getBoundingClientRect().top-e.offset;return Math.abs(t)>1&&rl.scrollTo({left:rl.scrollX,top:rl.scrollY+t,behavior:"instant"}),!0};return Do.current=null,t()&&n.push(setTimeout(t,150),setTimeout(t,450)),()=>n.forEach(clearTimeout)},[ol,rl]);const il=e=>{or(V),bo.select({index:e}),hr.sectionPressed?.(hi[e]);const n=hi[e]?.props?.id;n&&l(n)},ll=e=>{const{floor:n,cap:t}=mi(),o=e=>Math.min(Math.max(n,e),t);if("number"==typeof e)return o(e);const r=Wt&&tr.kind!==_t?.kind?hi.findIndex(e=>e.props.id===Wt.props.id):-1;return o(r>=0?r+1:t)},sl=(e,n)=>{const{floor:t,cap:o}=mi(),r=Math.min(Math.max(n,t),o),i=e<r?r-1:r;return i===e?{moved:!1,dest:e}:(bo.reorderComponent(Oe,e,i),bo.select({index:i}),{moved:!0,dest:i})},dl=(e,n,t,o)=>{or(V),bo.select(o?{index:o.index,zone:o.zone}:{index:e}),l(n),Kr(oo.sectionAdded({name:t}))},al=(e,n)=>{const t=ll(n),o=kr(e,{nodeDefaults:Bi,newNodeId:Te,sectionLabel:Ii,blockIsOffered:wr}),r=o?bo.insertNode(Oe,t,o):bo.insertSection(e,t);return dl(t,r,Ii(e),o?((e,n,t)=>{if(e.type===t)return null;const o={at:null},r=(e,n,i)=>{const l=i.filter(n=>n===e.type).length;for(const{child:s,zone:d,index:a}of Ie(Ut,e)){if(s.type===t&&(!o.at||n>o.at.depth)){const r=Sr(e.type,l,d.slice(d.lastIndexOf(":")+1),xr(e)),i=r?.choices??(r?.spec?[{type:r.spec.childType,label:r.spec.childType}]:[]);null!==r&&"footer"!==r.source&&`${e.props.id}:${r.slot}`===d&&i.some(e=>e.type===t)&&(o.at={zone:d,index:a,depth:n})}r(s,n+1,[...i,e.type])}};return r({type:e.type,props:{...e.props,id:n}},1,[]),o.at?{zone:o.at.zone,index:o.at.index}:null})(o,r,e):null),t},cl=e=>pl(Oe,e),pl=(e,n)=>{Xr.current=document.activeElement??null,qo(null===n?null:{zone:e,index:n}),Zo(!0),So||(Go.current=!0,Dt({type:"setUi",ui:{leftSideBarVisible:!0}}))},ul=()=>{Zo(!1),qo(null),Go.current&&Dt({type:"setUi",ui:{leftSideBarVisible:!1}}),Go.current=!1},fl=(e,n)=>zr.rowName?n?qt(e)?zr.rowName(e,"section",oo.header):eo(e)?zr.rowName(e,"section",oo.footer):Kt(e.type)?zr.rowName(e,"section",Ni(e.type)):Pi(e):Ji(e):n?Ii(e.type):Ni(e.type),hl=e=>n=>{e()},ml=(e,n,t)=>{if($t)return null;const o=Mi(e)[n];return o&&!Ne(Ut,o.type).delete||o&&yr(o.type,o)?null:/* @__PURE__ */pt(Ue,{kind:"delete",label:e===Oe&&o&&Jt.shared?.usedOn(o)?oo.shared.removeFromPage:oo.deleteNamed({name:t}),onClick:()=>((e,n)=>{const t=Mi(e)[n]?.props?.id;null!=t&&Ci(String(t))})(e,n),children:/* @__PURE__ */pt(lt,{size:15})})},gl=e=>zr.rowPreview?.(e)||void 0,yl=e=>zr.rowMarks?.(e)??void 0,vl=(e,n,t)=>zr.rowActions?.(e,n,t)??null,bl=(e,n,t,o)=>{if($t)return null;if(yr(t.type,t))return null;const r=Boolean(t.props._hidden);/* @__PURE__ */
15
- return pt(Ue,{kind:"eye",label:r?oo.showNamed({name:o}):oo.hideNamed({name:o}),onClick:()=>Sl(e,n,t),children:/* @__PURE__ */pt(r?st:dt,{size:14,strokeWidth:1.8,strokeLinecap:void 0,strokeLinejoin:void 0})})},kl=e=>nd(Oe,e),Sl=(e,n,t)=>{bo.replaceComponent(e,n,{...t,props:{...t.props,_hidden:!t.props._hidden}})},wl=e=>Pe(Ut,e),xl=e=>Ie(Ut,e),zl=e=>gr.slotsOf?Ei(e).map(n=>({slot:n.slot,rung:n.rung?n:null,kids:$e(e,n.slot)})):[{slot:null,rung:null,kids:re(Ut,e)}],Cl=e=>gr.slotsOf?zl(e).flatMap(e=>e.kids):re(Ut,e),Ol=e=>Boolean(gr.slotsOf)&&Ei(e).some(e=>e.rung),Nl=(e,n,t)=>Sr(e.type,n,t??void 0,xr(e)),Bl=(e,n,t)=>{const o=Me(Ut,e.type,n)&&(t||Cl(e).length>0||Ol(e));return{collapsible:o,folded:o&&Ur(String(e.props.id))}},Il=(e,n,t)=>zl(e).flatMap(o=>{const r=o.rung?n+1:n,i=o.kids.flatMap(({child:e})=>Bl(e,r,t(e.type)).collapsible?[String(e.props.id),...Il(e,r+1,t)]:[]);return o.rung?[`${e.props.id}:${o.rung.slot}`,...i]:i}),Pl=e=>Cl(e).length>0||Ol(e)||Boolean(Sr(e.type)),Tl=e=>Boolean(Sr(e)),$l=(e,n,t,o)=>{if(or(V),Sr(o)?.spec?.slider){const t=e.split(":")[0];s(t,n),bo.select({index:n,zone:e}),l(t)}else bo.select({index:n,zone:e}),l(t)},Ml=(e,n,t,o,r)=>{const i=`${e}:${n}`;bo.insertComponent(i,t,o),Sr(r)?.spec?.slider?requestAnimationFrame(()=>{s(e,o),bo.select({index:o,zone:i})}):bo.select({index:o,zone:i})},jl=Ln(/* @__PURE__ */new Set);Fn(()=>{hi.forEach(e=>{const n=Sr(e.type)?.spec;if(!n)return;const t=e.props.id;if(jl.current.has(t))return;jl.current.add(t);if((Array.isArray(e.props[n.slot])?e.props[n.slot]:[]).length>0)return;if(n.skipSeed?.(e.props))return;const o=`${t}:${n.slot}`,r=n.legacy?.(e.props)??[];(r.length?r:n.seeds(Bi)).forEach((e,t)=>go.seedChild(o,t,n.childType,e))})},[hi,go,Bi]);const El=Ln(/* @__PURE__ */new Set);Fn(()=>{hi.forEach((e,n)=>{const t=e.props.id;if(El.current.has(t))return;const o=r(e,wl(e.type));El.current.add(t),o&&go.replaceComponent(Oe,n,{...e,props:o})})},[hi,go]),_(go,Ut);const Ll=hi.findIndex(eo),Al=Ll>=0?hi[Ll]:null,Rl=no?hi.findIndex(qt):-1,Fl=Rl>=0?hi[Rl]:null,Dl=Jt.groupTab,Vl=An(()=>Dl?e=>Kt(e.type):void 0,[Dl]),Wl=Boolean(Jt.groupBadge),Hl=Jt.sharedReach,Ul=e=>Hl?.(e)??void 0,Jl=An(()=>Hl?new Set(hi.filter(e=>Ul(e)).map(e=>String(e.props.id))):null,[hi,Hl]),Yl=An(()=>Jl?e=>Jl.has(e):void 0,[Jl]),Xl=Jt.first?Hl?.({type:Jt.first,props:{id:""}})??void 0:void 0,Ql=Jt.groupBadge?/* @__PURE__ */pt("span",{className:"es-tree-group-badge",children:/* @__PURE__ */pt(Jn,{tone:"info",size:"xs",children:Jt.groupBadge})}):void 0,Kl=hi.find(e=>e.type===Xt)??null,Zl=hi.find(e=>e.type===Qt)??null,Gl=Ll>=0?Ll:hi.length,_l=[];hi.forEach(e=>{eo(e)||(Pl(e)&&_l.push(String(e.props.id)),_l.push(...Il(e,1,Tl)))}),Al&&(_l.push(String(Al.props.id)),_l.push(...Il(Al,1,Tl)));const ql=_l.length>0&&_l.every(e=>Ar.has(e)),es=e=>{const n=zr.blockRowName(e,Ni);return zr.rowName?zr.rowName(e,"block",n):n},ns=(e,n,t,o)=>{const r=Mi(e)[t];if(!r)return;const i={...Mn(e),index:t},l={...Mn(n),index:Math.min(Math.max(o,0),Mi(n).length)},s=bn(i,l);if(e!==n||s!==t)try{ki.move(String(r.props.id),{...l,index:s})}catch(e){if(!(e instanceof En))throw e}},ts=e=>{const n=/* @__PURE__ */new Set,t=e=>{for(const{child:o,zone:r}of xl(e))n.add(r),t(o)};for(const t of wl(e.type))n.add(`${e.props.id}:${t}`);return t(e),n},os=e=>{let n=e.slice(0,e.indexOf(":"));for(let e=0;e<64;e++){const e=Ti.get(n);if(!e)return null;if(e.zone===Oe)return n;n=e.zone.slice(0,e.zone.indexOf(":"))}return null},rs=e=>{const n=e.slice(0,e.indexOf(":")),t=hi.find(e=>Kt(e.type)&&String(e.props.id)===n);return t&&Zt(n)===e?t:null},is=(e,n)=>{const t=rs(e);return!t||(!Jt.groupAccepts||Jt.groupAccepts(t.type,n,Mi(e).length))},ls=(e,n,t)=>{if(e.rung){const t=ji(e.rung.nodeId),o=t?Ei(t).filter(e=>e.rung).length:0;return n.parentId===e.rung.nodeId&&n.slot===wt&&n.index>=0&&n.index<=o}if(n.slot===wt)return!1;if(e.add)return cs(e.add,n);const o=$n(n);if(Kt(e.type))return!1;const r=rs(o),i=rs(e.zone);if(r||i)return!(!r||!i)&&(!(r!==i&&!is(o,e.type))&&(n.index>=0&&n.index<=Mi(o).length));if(e.zone===Oe||o===Oe){if(e.zone!==o)return!1;const{floor:t,cap:r}=mi();return n.index>=t&&n.index<=r}if(n.index<0||n.index>Mi(o).length)return!1;if(e.zone===o)return!0;const l=Al&&!Jt.lastIsOpen?String(Al.props.id):null;return(!l||os(e.zone)!==l&&os(o)!==l)&&((e,n,t,o)=>{if(e===n)return!0;const r=o??Mi(e)[t];if(!r)return!1;const i=n.split(":")[0],l=Ti.get(i),s=l?Mi(l.zone)[l.index]:void 0;if(!s)return!1;if(!o&&ts(r).has(n))return!1;const d=Sr(s.type,br(Ft?.data,s.type,i),n.slice(n.lastIndexOf(":")+1),xr(s));return!!d&&(!!(d.choices?d.choices.some(e=>e.type===r.type):d.spec?.childType===r.type)&&!d.spec?.addBlocked?.(Mi(n),r))})(e.zone,o,e.index,t)},ss=(e,n)=>{const t=$n(e.from),o=e.node;return t===$n(n)?is(t,o.type):ls({id:String(o.props?.id??""),zone:t,index:-1,type:o.type},n,o)},ds=e=>{const n=e.slice(0,e.indexOf(":")),t=Ti.get(n),o=t?Mi(t.zone)[t.index]:void 0;if(!t||!o)return null;const r=Sr(o.type,br(Ft?.data,o.type,n),e.slice(e.lastIndexOf(":")+1),xr(o));if(!r||`${n}:${r.slot}`!==e)return null;if("footer"===r.source)return null;const i=T(r.choices??(r.spec?[{type:r.spec.childType,label:Ni(r.spec.childType)}]:[])),l=Li(e);return{parent:o,parentId:n,target:r,choices:i,parentName:l?l.slot.label:fl(o,t.zone===Oe)}},as=(e,n)=>{if("section"!==e.kind)return e;const t=$n(n);return t===Oe||rs(t)?e:ds(t)?.choices.some(n=>n.type===e.type)?{kind:"block",type:e.type}:e},cs=(e,n)=>{const t=as(e,n),o=$n(n);if("shared"===t.kind){if(o!==Oe||!Jt.shared?.nodeOf(t.section))return!1;const{floor:e,cap:r}=mi();return n.index>=e&&n.index<=r}if("block"!==t.kind){if(rs(o)){if("preset"===t.kind)return!1;const e="section"===t.kind?t.type:t.template.node.type;return is(o,e)&&n.index>=0&&n.index<=Mi(o).length}if(o!==Oe)return!1;const{floor:e,cap:r}=mi();return n.index>=e&&n.index<=r}if(o===Oe)return!1;const r=ds(o);return!(!r||!r.choices.some(e=>e.type===t.type))&&!r.target.spec?.addBlocked?.(Mi(o))},ps=(e,n)=>{const t=as(e,n);if("block"!==t.kind&&rs($n(n)))return void((e,n,t)=>{const o="section"===e.kind?e.type:"template"===e.kind?e.template.node.type:null;if(o&&is(n,o)){if("section"===e.kind)bo.insertComponent(n,e.type,t);else{if("template"!==e.kind)return;bo.insertNode(n,t,vi(e.template.node))}or(V),bo.select({index:t,zone:n})}})(t,$n(n),n.index);if("section"===t.kind)return void al(t.type,n.index);if("template"===t.kind)return void((e,n,t)=>{const o=ll(t),r=bo.insertNode(Oe,o,n);dl(o,r,e)})(t.template.name,vi(t.template.node),n.index);if("preset"===t.kind)return void((e,n,t)=>{const o=n({nodeDefaults:Bi,newNodeId:Te,sectionLabel:Ii,blockIsOffered:wr});if(!o)return;const r=ll(t),i=bo.insertNode(Oe,r,o);dl(r,i,e)})(t.preset.label,t.preset.insert,n.index);if("shared"===t.kind){const e=Jt.shared?.nodeOf(t.section);if(!e)return;const o=ll(n.index);return void(ki.restore(e,{parentId:Pn,slot:Tn,index:o})&&dl(o,e.props.id,t.section.title))}const o=$n(n),r=ds(o);r&&(r.target.spec?Ml(r.parentId,r.target.slot,t.type,n.index,r.parent.type):((e,n,t)=>{bo.insertComponent(e,n,t),or(V),bo.select({index:t,zone:e})})(o,t.type,n.index))},us=(e,n)=>{e.media?function(e){const n=Zs();if(!n||!Xs)return;_s(n).then(n=>{n&&function(e,n){if(!Xs)return;const t=Xs.create(e,{nodeDefaults:Bi,newNodeId:Te,sectionLabel:Ii,blockIsOffered:wr}),o=$n(n);if(o===Oe){const e=ll(n.index),o=bo.insertNode(Oe,e,t);return void dl(e,o,Ii(t.type))}bo.insertNode(o,n.index,t),or(V),bo.select({index:n.index,zone:o})}(n,e)})}(n):e.rung?Wi(e.rung.nodeId,e.index,n.index):e.add?ps(e.add,n):e.zone===Oe?sl(e.index,n.index):ns(e.zone,$n(n),e.index,n.index)},[fs]=Rn(()=>yn()),hs=vn({keyOf:e=>e.id,readOnly:Boolean($t),session:fs,canDrop:ls,onDrop:us,onStep:(e,n)=>{e.rung?Wi(e.rung.nodeId,e.index,n<0?e.index-1:e.index+2):e.zone===Oe?((e,n)=>{const t=Ii(hi[e]?.type??""),o=sl(e,n<0?e-1:e+2);if(!o.moved)return void Kr(n<0?oo.sectionFirst({name:t}):oo.sectionLast({name:t}));const{floor:r,cap:i}=mi();Kr(oo.sectionMoved({name:t,n:o.dest-r+1,total:i-r}))})(e.index,n):ns(e.zone,e.zone,e.index,n<0?e.index-1:e.index+2)}}),ms=Dn(e=>{const{floor:n,cap:t}=mi(),o=[];for(const r of e.nodes){const e=$n(r.place),i=Mi(e)[r.place.index];if(!i||String(i.props.id)!==r.id)continue;if(qt(i)||eo(i)||yr(i.type,i))continue;if(Kt(i.type))continue;const l=Boolean(rs(e)),s=e===Oe||l;e===Oe&&t-n<2||o.push({key:r.id,item:{id:r.id,zone:e,index:r.place.index,type:i.type},box:r.box,label:s?Ii(i.type):Ji(i),from:r.place})}const r=e.zones.flatMap(e=>{const n=$n(e.list);if(n===Oe&&0===e.children.length)return[{...e,addLabel:oo.addSection,addAlways:!0}];const t=ds(n),o=t?.target.spec?.addLabel;return e.children.length>0||Boolean(t?.choices.length)||Boolean(rs(n))?[o?{...e,addLabel:o}:e]:[]}),i=r.flatMap(e=>{const n=$n(e.list),t=n===Oe||rs(n)?null:ds(n);return t?.choices.length?fn(e,t.target.spec?.addLabel??oo.addBlockHere):[]});return{sources:o,zones:r,seams:i}},[Ft.data]),gs=null==Wt?.props.id?null:String(Wt.props.id),ys=Wn(Le),vs=ys?.selected()&&Wo?.document&&gs?ys.selectedPart?.(Wo.document)??null:null,bs=vs&&gs&&Ae(Ft.data,Ut,gs,vs)?vs:null,ks=bs?.label?{element:bs.element,label:bs.label}:null,Ss=null!==bs,ws=Dn(e=>{const n=Ut,t=e=>!e.item.rung&&null!==jn(Ft.data,n,e.item.id),o=e[e.length-1];if(!t(o))return o;const r=n=>e.find(e=>t(e)&&e.item.id===n),i=r(gs);return i?Ss?null:i:r(Ze(Ft.data,n,o.item.id,gs,Vl))??o},[Ft.data,Ut,gs,Vl,Ss]),[xs,zs]=Rn(null),[Cs,Os]=Rn(null),Ns=zr.canvasTab,Bs=Boolean(Dl||Hl||Ns);zn(Wo,"mouseover",e=>{if(!Bs)return;const n=Cn(e.target),t=n?yt(Ft.data,Ut,n):null;t!==xs&&zs(t),Ns&&n!==Cs&&Os(n)}),zn(Wo,"mouseout",e=>{Bs&&!e.relatedTarget&&(zs(null),Os(null))});const Is=e=>qt(e)||eo(e)||Kt(e.type),Ps=e=>{const n=Kt(e.type)?Ni(e.type):qt(e)?oo.header:eo(e)?oo.footer:null;return null===n?Pi(e):zr.rowName?zr.rowName(e,"section",n):n},Ts=[];if(Bs){const e=gs?yt(Ft.data,Ut,gs):null;for(const n of/* @__PURE__ */new Set([e,xs])){const e=n?hi.find(e=>String(e.props.id)===n):void 0;if(!e)continue;const t=qt(e)||e.type===Xt,o=Ul(e);if(o){Ts.push({id:String(e.props.id),label:Ps(e),below:t,reach:o});continue}if(!Dl||!Is(e))continue;const r=Dl(e);r&&Ts.push({id:String(e.props.id),label:r,below:t})}for(const e of Ns?/* @__PURE__ */new Set([gs,Cs]):[]){const n=e?ji(e):void 0,t=n?Ns(n):null;t&&!Ts.some(n=>n.id===e)&&Ts.push({id:e,label:t,below:!1,above:!0})}}const $s=fe(),Ms=Ln(null);Fn(()=>{const e=Jt.changeNotice;if(!e)return;const n=JSON.stringify(hi.filter(Is)),t=Ms.current;if(Ms.current={doc:Un,bands:n,index:Vt.index},!t||t.doc!==Un||t.bands===n)return;Vt.hasPast&&Vt.index>=t.index&&!gt.has($s)&&(gt.add($s),Kr(e,"success",{action:{label:oo.bar.undo,onClick:()=>Vt.back()},duration:8e3}))},[hi]);const js=e=>{or(V),bo.select(e.zone===Oe?{index:e.index}:{index:e.index,zone:e.zone})},Es=q(),Ls=()=>({data:Ft.data,device:Bo,ops:bo,inspector:fr}),As=Es?.model,Rs=An(()=>As?e=>As(e,ms(e),Ls()):ms,[As,ms,Bo]),Fs=Es?.measure,Ds=Fs?(e,n)=>Fs(e,n,Ls()):void 0,Vs=Es?.canDrop,Ws=Vs?(e,n)=>Vs(e,n,ls,Ls()):ls,Hs=Es?.drop,Us=Hs?(e,n)=>Hs(e,n,us,Ls()):us,Js=Es?.pick,Ys=Js?e=>Js(e,js,Ls()):js,Xs=Es?.media??null,Qs=Ln(null),Ks=An(()=>Xs?{id:ht,zone:"",index:-1,type:Xs.adds.type,add:{kind:Xs.adds.kind,type:Xs.adds.type},media:!0}:null,[Xs]);Fn(()=>{if(!Ks||$t||"undefined"==typeof document)return;const e=e=>{(e=>Array.from(e.dataTransfer?.types??[]).includes(nt))(e)&&(Qs.current=null,fs.start({key:ht,item:Ks}))},n=e=>{fs.get()?.item.media&&(Qs.current=Kn(e.dataTransfer))},t=()=>{fs.get()?.item.media&&fs.end()};return document.addEventListener("dragstart",e),document.addEventListener("drop",n,!0),document.addEventListener("dragend",t,!0),()=>{document.removeEventListener("dragstart",e),document.removeEventListener("drop",n,!0),document.removeEventListener("dragend",t,!0)}},[Ks,$t,fs]);const Zs=()=>{const e=Qs.current;return Qs.current=null,e},Gs=ce(),_s=async e=>{if(!Gs)return e;const n=await Gs(e);return n?{...e,id:n.id,url:n.url}:null};const qs=(e,n)=>{if(!Xs)return;const t=jn(vo.getState().appState.data,gi,n);if(!t)return;const o=t.node;bo.replaceComponent($n(t.place),t.place.index,{...o,props:{...Xs.replace(o,e),id:o.props.id}})},ed=e=>{const n=$n(e),t=Li(n);t&&Di(t.node,t.slot,!1),pl(n,e.index)},nd=(e,n)=>/* @__PURE__ */pt(Je,{...$t?{}:hs.seam({place:{...Mn(e),index:n}})},`seam:${e}:${n}`),td={rowClick:hl,isCollapsed:Ur,toggleCollapse:Jr},od=e=>{const n=String(e.props.id),t=hi.findIndex(e=>String(e.props.id)===n),o=Zt(n),r=Mi(o),i=Ur(n),l=Ni(e.type),s=zr.rowName?zr.rowName(e,"section",l):l,d=e=>nd(o,e);/* @__PURE__ */
16
- return ut(ft,{children:[
17
- /* @__PURE__ */pt(De,{words:ro,icon:/* @__PURE__ */pt(Or,{type:e.type,size:13}),name:s,preview:gl(e),marks:yl(e),onSelect:()=>il(t),nameSlot:Xi(Oe,t,n,s),selected:rr===n,badge:Ul(e)?void 0:Ql,shared:Ul(e),actions:vl(e,Oe,t)??void 0,rowProps:{"data-node-id":n,onClick:hl(()=>il(t))},fold:{open:!i,label:"section",onToggle:()=>Jr(n)}}),!i&&/* @__PURE__ */ut(Ve,{children:[r.map((n,t)=>{const r=String(n.props.id),i=Pi(n),l=Pl(n),s=l&&Ur(r),a=()=>$l(o,t,r,e.type),{rowProps:c,...p}=hs.row({item:{id:r,zone:o,index:t,type:n.type},place:{...Mn(o),index:t}},{"data-node-id":r,onClick:hl(a)});/* @__PURE__ */
18
- return ut(Hn,{children:[d(t),
19
- /* @__PURE__ */pt(De,{words:ro,icon:/* @__PURE__ */pt(Or,{type:n.type,size:13}),name:i,preview:gl(n),marks:yl(n),onSelect:a,nameSlot:Xi(o,t,r,i),selected:rr===r,hidden:Boolean(n.props._hidden),...p,fold:l?{open:!s,label:"section",onToggle:()=>Jr(r)}:void 0,actions:/* @__PURE__ */ut(ft,{children:[ml(o,t,i),vl(n,o,t),bl(o,t,n,i)]}),rowProps:c}),l&&!s&&/* @__PURE__ */pt(Ve,{children:ld(n,2)})]},r)}),d(r.length)]})]})},rd=(e,n,t,o,r)=>{const i=String(e.props.id),l=`${i}:${n.slot}`,s=hs.dragging,d=!Ur(l)&&s?.rung?.nodeId!==i,a={...Mn(l),index:0},c=s&&!s.rung&&ls(s,a)?a:void 0,p=()=>Di(e,n,!0),{rowProps:u,...f}=hs.row({item:{id:`rung:${l}`,zone:`${i}:${wt}`,index:t,type:e.type,rung:{nodeId:i,slot:n.slot}},place:{parentId:i,slot:wt,index:t},into:c,canDrag:Boolean(gr.moveSlot)&&!1!==n.movable&&o>1},{"data-slot-zone":l,onClick:hl(p)}),h=$t?null:gr.slotActions?.(e,n.slot);/* @__PURE__ */
20
- return ut(Hn,{children:[n.heading,
21
- /* @__PURE__ */pt(De,{words:ro,icon:n.glyph??null,name:n.label,badge:n.badge,onSelect:p,selected:Ai===l,...f,dragHint:n.dragHint,fold:{open:d,label:n.label,onToggle:()=>Jr(l)},actions:h&&h.length>0?/* @__PURE__ */pt(ft,{children:h.map((t,o)=>/* @__PURE__ */pt(Ue,{kind:"delete"===t.kind?"delete":"plain",label:t.label,disabled:t.disabled,onClick:()=>((e,n,t)=>{if($t||t.disabled)return;const o=String(e.props.id),r=e=>{"string"==typeof e&&Vi(o,e,n.panel)},i=t.run();i&&"function"==typeof i.then?i.then(r):r(i)})(e,n,t),children:"delete"===t.kind?/* @__PURE__ */pt(lt,{size:15}):/* @__PURE__ */pt(ct,{size:15})},`${o}:${t.kind}`))}):void 0,rowProps:u}),d&&/* @__PURE__ */pt(Ve,{children:r})]},l)},id=(e,n)=>{const t=zl(e),o=t.filter(e=>e.rung).length;let r=0;/* @__PURE__ */
22
- return pt(ft,{children:t.map(t=>{const i=t.kids,l=t.rung?n+1:n,s=Nl(e,void 0,t.slot),d=s?`${e.props.id}:${s.slot}`:null,a=null===t.slot?null:`${e.props.id}:${t.slot}`,c=(e,n)=>nd(e,n),p=/* @__PURE__ */ut(ft,{children:[i.map(({child:n,zone:t,index:o})=>{const r=rr===String(n.props.id),{collapsible:i,folded:s}=Bl(n,l,Tl(n.type)),d=String(n.props.id),a=es(n),p=()=>$l(t,o,d,e.type),{rowProps:u,...f}=hs.row({item:{id:d,zone:t,index:o,type:n.type},place:{...Mn(t),index:o}},{"data-node-id":d,onClick:hl(p)});/* @__PURE__ */
23
- return ut(Hn,{children:[0===o&&c(t,0),
24
- /* @__PURE__ */pt(De,{words:ro,icon:/* @__PURE__ */pt(Or,{type:n.type,size:13}),name:a,preview:gl(n),marks:yl(n),onSelect:p,nameSlot:Xi(t,o,d,a),selected:r,hidden:Boolean(n.props._hidden),...f,fold:i?{open:!s,label:"group",onToggle:()=>Jr(d)}:void 0,actions:/* @__PURE__ */ut(ft,{children:[ml(t,o,a),vl(n,t,o),bl(t,o,n,a)]}),rowProps:u}),i&&!s&&/* @__PURE__ */pt(Ve,{children:id(n,l+1)}),c(t,o+1)]},String(n.props.id??`${t}-${o}`))}),null===a?d&&!i.some(e=>e.zone===d)?c(d,0):null:0!==i.length||!t.rung&&d!==a?null:c(a,0)]});return t.rung?rd(e,t.rung,r++,o,p):/* @__PURE__ */pt(Hn,{children:p},t.slot??"")})})},ld=(e,n)=>{const t=br(Ft?.data,e.type,String(e.props.id)),o=zl(e),r=o.filter(e=>e.rung).length;let i=0;/* @__PURE__ */
25
- return pt(ft,{children:o.map(o=>{const l=o.kids,s=o.rung?n+1:n,d=Nl(e,t,o.slot),a=d?.spec??null,c=a&&Array.isArray(e.props[a.slot])?e.props[a.slot]:[],p=d&&d.choices?{slot:d.slot,choices:d.choices}:null,u=String(e.props.id),f=a&&!a.fixed?`${u}:${a.slot}`:null,h=p?`${u}:${p.slot}`:null,m=(e,n)=>nd(e,n),g=null===o.slot?null:`${u}:${o.slot}`,y=Boolean(a&&!a.fixed&&(null===g||g===f)),v=/* @__PURE__ */ut(ft,{children:[l.map(({child:n,zone:t,index:o})=>{const r=rr===String(n.props.id),i=Ji(n),l=String(n.props.id),{collapsible:d,folded:a}=Bl(n,s,Tl(n.type)),c=wl(n.type),p=1===c.length?`${l}:${c[0]}`:null,u=p?{...Mn(p),index:Mi(p).length}:void 0,f=hs.dragging,h=u&&f&&ls(f,u)?u:void 0,g=()=>$l(t,o,l,e.type),{rowProps:y,...v}=hs.row({item:{id:l,zone:t,index:o,type:n.type},place:{...Mn(t),index:o},into:h,canDrag:!yr(n.type,n)},{"data-node-id":l,onClick:hl(g)});/* @__PURE__ */
26
- return ut(Hn,{children:[0===o&&m(t,0),
27
- /* @__PURE__ */pt(De,{words:ro,icon:/* @__PURE__ */pt(Or,{type:n.type,size:13}),name:i,preview:gl(n),marks:yl(n),onSelect:g,nameSlot:Xi(t,o,l,i),selected:r,hidden:Boolean(n.props._hidden),...v,fold:d?{open:!a,label:"group",onToggle:()=>Jr(l)}:void 0,actions:yr(n.type,n)?vl(n,t,o)??void 0:/* @__PURE__ */ut(ft,{children:[ml(t,o,i),vl(n,t,o),bl(t,o,n,i)]}),rowProps:y}),d&&!a&&/* @__PURE__ */pt(Ve,{children:ld(n,s+1)}),m(t,o+1)]},String(n.props.id??`${t}-${o}`))}),y&&a&&
28
- /* @__PURE__ */pt(z,{small:!0,label:a.addLabel,blocked:a.addBlocked?.(c)??null,onAdd:()=>Ml(e.props.id,a.slot,a.childType,c.length,e.type)}),null===g?h&&!l.some(e=>e.zone===h)?m(h,0):null:0!==l.length||(o.rung?y:g!==h)?null:m(g,0)]});return o.rung?rd(e,o.rung,i++,r,v):/* @__PURE__ */pt(Hn,{children:v},o.slot??"")})})},sd=Ko,dd=e=>"panel"in e?{id:e.id,label:e.label,icon:e.icon,active:So&&!sd&&mr===e.id,onSelect:()=>ui(e.id)}:e,ad=[...(hr.railLead??[]).map(dd),{id:"sections",label:oo.layers,icon:/* @__PURE__ */pt(ge,{}),active:So&&!sd&&"sections"===mr,onSelect:()=>ui("sections")},...(hr.railTrail??[]).map(dd)],cd=To?{onPress:$o}:Lt?{onPress:()=>{x(Sn,{accept:"image/*",title:po.mediaLibrary})}}:null,pd={value:ad.find(e=>!0===e.active)?.id??"",press:e=>{const n=ad.find(n=>n.id===e);n&&!n.disabled&&!0!==n.active&&n.onSelect?.()},items:ad.map(e=>({id:e.id,icon:e.icon,label:/* @__PURE__ */pt("span",{className:"sr-only",children:e.label}),tooltip:e.label,disabled:e.disabled}))},ud=[...hr.railLead??[],...hr.railTrail??[]].find(e=>"panel"in e&&e.id===mr),fd=Boolean(to?.foldable),hd=to?.label??(At?oo.pageSections:oo.templateSections),md=fd&&Ur(zt),gd=/* @__PURE__ */ut(ft,{children:[hi.map((e,n)=>{if(qt(e)||eo(e)||Kt(e.type))return null;const t=rr===String(e.props.id),o=Boolean(e.props._hidden);xl(e);const r=String(e.props.id),i=hr.hasOwnRows?.(e)??!1,l=Pl(e)||i,s=l&&Ur(r),d=wl(e.type),a=1===d.length?`${r}:${d[0]}`:null,c=a?{...Mn(a),index:Mi(a).length}:void 0,p=hs.dragging,u=c&&p&&ls(p,c)?c:void 0,{rowProps:f,...h}=hs.row({item:{id:r,zone:Oe,index:n,type:e.type},place:{...Mn(Oe),index:n},into:u,canDrag:!yr(e.type,e)},{"data-node-id":r,onClick:hl(()=>il(n))});/* @__PURE__ */
29
- return ut(Hn,{children:[n>0&&kl(n),
30
- /* @__PURE__ */pt(De,{words:ro,icon:/* @__PURE__ */pt(Or,{type:e.type,size:13}),name:Pi(e),preview:gl(e),marks:yl(e),shared:Ul(e),onSelect:()=>il(n),nameSlot:Xi(Oe,n,r,Pi(e)),selected:t,hidden:o,...h,fold:l?{open:!s,label:"section",onToggle:()=>Jr(r)}:void 0,actions:/* @__PURE__ */ut(ft,{children:[ml(Oe,n,Pi(e)),vl(e,Oe,n),bl(Oe,n,e,Pi(e))]}),rowProps:f}),Pl(e)&&!s&&/* @__PURE__ */ut(Ve,{children:[ld(e,1),hr.partRows?.(e,td)]}),i&&!s&&/* @__PURE__ */pt(Ve,{children:hr.ownRows?.(e,n,td)})]},String(e.props.id??n))}),Gl>0&&kl(Gl)]}),yd=(e,n,t)=>{const o=String(e.props.id),r=Cl(e).length>0||Ol(e)||Boolean(Sr(e.type)),i=r&&Ur(o),l="header"===t?oo.header:oo.footer,s=zr.rowName?zr.rowName(e,"section",l):l;/* @__PURE__ */
31
- return ut(ft,{children:[
32
- /* @__PURE__ */pt(De,{words:ro,icon:/* @__PURE__ */pt(Or,{type:t,size:13}),name:s,preview:gl(e),marks:yl(e),badge:Ul(e)?void 0:Ql,shared:Ul(e),onSelect:()=>il(n),nameSlot:Xi(Oe,n,o,s),selected:rr===String(e.props.id),fold:r?{open:!i,label:"section",onToggle:()=>Jr(o)}:void 0,actions:vl(e,Oe,n)??void 0,rowProps:{"data-node-id":o,onClick:hl(()=>il(n))}}),r&&!i&&/* @__PURE__ */pt(Ve,{children:id(e,1)})]})};return(hr.wrap??(e=>e))(
33
- /* @__PURE__ */pt(ee,{target:Wo,children:/* @__PURE__ */ut("div",{ref:Vo,className:"sf-editor es-editor",style:ln(Fr),onContextMenu:qi.onEditorContextMenu,...p(Sn),children:[
34
- /* @__PURE__ */ut(Ge,{children:[
35
- /* @__PURE__ */ut("div",{className:"es-cluster es-cluster--left",children:[cd?/* @__PURE__ */pt(Yn,{variant:"secondary",className:"es-barbtn",leftIcon:/* @__PURE__ */pt(ye,{}),onClick:cd.onPress,children:oo.railMedia}):null,
36
- /* @__PURE__ */pt(_e,{label:oo.bar.undo,disabled:Boolean($t)||!Vt.hasPast,onClick:()=>Vt.back(),children:/* @__PURE__ */pt(tt,{})}),
37
- /* @__PURE__ */pt(_e,{label:oo.bar.redo,disabled:Boolean($t)||!Vt.hasFuture,onClick:()=>Vt.forward(),children:/* @__PURE__ */pt(ot,{})})]}),
38
- /* @__PURE__ */ut(qe,{children:[
39
- /* @__PURE__ */pt(en,{devices:xo,value:Bo,onChange:Io}),
40
- /* @__PURE__ */pt(_e,{label:oo.bar.refresh,tip:oo.bar.refreshTip,onClick:()=>{Do.current=(()=>{const e=Wo?.document;if(!e)return null;const n=hi.findIndex(eo),t=n>=0?n:hi.length;let o=null;for(let n=0;n<t;n++){const t=hi[n]?.props?.id;if(null==t)continue;const r=In(e,`[data-easel-block="${CSS.escape(String(t))}"]`);if(!r)continue;const i=r.getBoundingClientRect().top;i<=4&&(null===o||i>o.offset)&&(o={id:String(t),offset:i})}if(!o){const e=Wt?.props?.id??hi[0]?.props?.id;null!=e&&(o={id:String(e),offset:0})}return o})(),Fo(e=>e+1)},children:/* @__PURE__ */pt(rt,{})}),hr.barView?.()]}),
41
- /* @__PURE__ */ut(qe,{kind:"right",style:{minWidth:300},children:[
42
- /* @__PURE__ */pt(b,{input:Xo,words:oo.saveStatus}),On?/* @__PURE__ */pt(On,{}):null,hr.barLead?.(),hr.barTrail?.(),hr.mainAction||!hr.barMain?/* @__PURE__ */pt(k,{input:Xo,action:hr.mainAction??{label:oo.done,onPress:()=>{qn(Ft.data)}},readOnly:Boolean($t),saveSwitch:jt,onToggleAutoSave:Bt,onSaveNow:Qo,bar:oo.bar,words:oo.saveStatus}):hr.barMain()]})]}),
43
- /* @__PURE__ */pt(v,{}),
44
- /* @__PURE__ */ut("div",{className:"sf-body",children:[So?/* @__PURE__ */ut(ft,{children:[
45
- /* @__PURE__ */ut("aside",{className:"es-sidepanel es-sidepanel--left sf-panel sf-panel--left","aria-label":oo.leftPanel,children:[
46
- /* @__PURE__ */ut("div",{className:"es-paneltabs es-paneltabs--with-hide",children:[
47
- /* @__PURE__ */pt(B,{side:"left",onHide:ci}),
48
- /* @__PURE__ */pt("span",{className:"es-paneltabs-divider","aria-hidden":"true"}),
49
- /* @__PURE__ */pt(Xn,{variant:"underline",block:!0,"aria-label":oo.bar.views,value:pd.value,onChange:pd.press,items:pd.items})]}),Ko?/* @__PURE__ */pt(C,{at:_o?{label:(e=>{const n=rs(e.zone);if(n)return oo.add.addingTo({name:zr.rowName?fl(n,!0):Ni(n.type)});if(e.zone===Oe){const n=hi[e.index];return n&&!eo(n)?oo.add.addingBefore({name:fl(n,!0)}):oo.add.addingAtEnd}const t=ds(e.zone);return t?oo.add.addingTo({name:t.parentName}):oo.add.addingHere})(_o),onClear:()=>qo(null)}:void 0,placeBlocks:_o&&_o.zone!==Oe?ds(_o.zone)?.choices:void 0,canTake:_o?e=>{if(!_o)return null;const n={...Mn(_o.zone),index:_o.index};if(cs(e,n))return null;if("shared"===e.kind&&_o.zone===Oe&&!Jt.shared?.nodeOf(e.section))return oo.shared.alreadyHere;const t=rs(_o.zone);if(t)return oo.add.notInside({name:fl(t,!0)});if(_o.zone===Oe)return oo.add.onlySections;const o=ds(_o.zone);return o?oo.add.notInside({name:o.parentName}):oo.add.onlySections}:void 0,onPick:_o?e=>{if(!_o)return;const n={...Mn(_o.zone),index:_o.index};cs(e,n)&&(ps(e,n),ul())}:void 0,itemFor:e=>({id:`new:${e.kind}:${xt(e)}`,zone:"",index:-1,type:"template"===e.kind?e.template.node.type:"shared"===e.kind?e.section.node.type:xt(e),add:e}),session:fs,siteWide:hr.addPanelRow?.(ul),onClose:ul,readOnly:Boolean($t)}):ud?ud.panel({onHide:ci,notify:Kr}):/* @__PURE__ */ut(ft,{children:[
50
- /* @__PURE__ */pt(I,{icon:/* @__PURE__ */pt(ge,{}),title:oo.layers,context:uo,actions:/* @__PURE__ */ut(ft,{children:[!$t&&/* @__PURE__ */pt(nn,{label:oo.add.title,onClick:()=>cl(null),children:/* @__PURE__ */pt(it,{size:15})}),
51
- /* @__PURE__ */pt(nn,{label:ql?oo.expandAll:oo.collapseAll,title:0===_l.length?oo.nothingToFold:void 0,disabled:0===_l.length,onClick:()=>Rr(e=>{const n=new Set(_l);return ql?new Set([...e].filter(e=>!n.has(e))):/* @__PURE__ */new Set([...e,..._l])}),children:/* @__PURE__ */pt(bt,{expand:ql})})]})}),
52
- /* @__PURE__ */ut(We,{className:"sf-tree sf-scroll",words:ro,children:[Kl&&/* @__PURE__ */ut(ft,{children:[!Wl&&/* @__PURE__ */pt(He,{children:oo.header}),od(Kl)]}),Rt&&!(Wl&&Kl)&&/* @__PURE__ */ut(ft,{children:[!Wl&&/* @__PURE__ */pt(He,{children:oo.header}),!no&&/* @__PURE__ */pt(De,{words:ro,icon:/* @__PURE__ */pt(Or,{type:"header",size:13}),name:oo.header,badge:Xl?void 0:Ql,shared:Xl,onSelect:fi,selected:tr.kind===_t?.kind,rowProps:{onClick:hl(fi)}})]}),Fl&&!(Wl&&Kl)&&yd(Fl,Rl,"header"),!fd&&/* @__PURE__ */pt(He,{children:hd}),fd?/* @__PURE__ */ut(ft,{children:[
53
- /* @__PURE__ */pt(De,{words:ro,icon:null,name:hd,fold:{open:!md,label:hd,onToggle:()=>Jr(zt)}}),!md&&/* @__PURE__ */pt(Ve,{children:gd})]}):gd,Rt&&!Wl&&/* @__PURE__ */pt(He,{children:oo.footer}),Al&&!(Wl&&Zl)&&yd(Al,Ll,"footer"),Zl&&od(Zl),hr.treeFoot?.()]})]})]}),
54
- /* @__PURE__ */pt(tn,{side:"left",width:Fr.left,min:rn.left,max:on,defaultWidth:h.left,label:oo.resizeLeftPanel,onResize:Wr})]}):/* @__PURE__ */pt(P,{side:"left",onShow:ci}),
55
- /* @__PURE__ */ut("div",{ref:Zr,className:"sf-center sf-scroll","data-sf-canvas-head":ni?"":void 0,style:{overflowX:si?"auto":"hidden",overflowY:"hidden"},children:[ni&&/* @__PURE__ */pt("div",{ref:ti,className:"sf-canvas-head",children:/* @__PURE__ */pt(ni,{device:Bo})}),
56
- /* @__PURE__ */ut("div",{className:"sf-frame-scaler",style:di,children:[
57
- /* @__PURE__ */pt("div",{className:"sf-frame "+(Bo===Oo?"":`sf-frame--${Bo}`),style:ai,children:/* @__PURE__ */ut("div",{className:"sf-preview-host",children:[
58
- /* @__PURE__ */pt(Re.Provider,{value:Vl,children:/* @__PURE__ */pt(Fe.Provider,{value:Yl,children:/* @__PURE__ */pt(fo,{},Ro)})}),
59
- /* @__PURE__ */pt(hn,{canvas:Wo,session:fs,model:Rs,measure:Ds,canDrop:Ws,onDrop:Us,choose:ws,tag:ks,onPick:Ys,dropOn:Xs?{accepts:(e,n)=>{if(!e.media||!Xs||n.item.rung)return!1;const t=jn(Ft.data,gi,n.item.id);return null!==t&&Xs.takes(t.node)},onDrop:(e,n)=>(e=>{const n=Zs();n&&Xs&&_s(n).then(n=>{n&&qs(n,e.item.id)})})(n),label:()=>oo.canvasReplaceImage}:void 0,onZoneAdd:ed,onSeamAdd:ed,zoneAddLabel:oo.canvasAddBlock,words:io.canvas,readOnly:Boolean($t),revision:Ft.data}),er.length>0&&!Ho&&/* @__PURE__ */pt("div",{className:"sf-preview-gaps",children:er.map(e=>
60
- /* @__PURE__ */pt(mn,{index:e.index,label:oo.addSectionHere,onInsert:()=>cl(e.index),className:void 0===e.height?"sf-preview-gap":"sf-preview-gap sf-preview-gap--tight",style:void 0===e.height?{top:e.top}:{top:e.top,height:e.height}},e.index))})]})}),Bs?/* @__PURE__ */pt(vt,{canvas:Wo,tabs:Ts,onSelect:Fi}):null]})]}),wo?/* @__PURE__ */ut(ft,{children:[Nn?
61
- /* @__PURE__ */pt("div",{className:"es-sidepanel es-sidepanel--right","data-es-host-panel":"",children:Nn}):/* @__PURE__ */pt(ft,{children:/* @__PURE__ */pt(u,{value:{selectChild:$l,addChild:Ml,childRowName:Ji,blockRowName:es},children:/* @__PURE__ */pt(ho,{mode:tr,onOpenWebsiteSettings:hr.openSettings??(()=>{}),onOpenSiteStyles:hr.openStyles,onOpenPageStyles:hr.openPageStyles,onSelectNode:Pr,onNotify:Kr,onHidePanel:pi,nodeActions:Wt?Ne(Ut,Wt.type):Ct})})}),
62
- /* @__PURE__ */pt(tn,{side:"right",width:Fr.right,min:rn.right,max:on,defaultWidth:h.right,label:oo.resizeSettingsPanel,onResize:Hr})]}):
63
- /* @__PURE__ */pt(P,{side:"right",onShow:pi})]}),qi.menu,
64
- /* @__PURE__ */pt(ie,{}),wi?/* @__PURE__ */pt(mt,{name:wi.name,onMake:e=>(async(e,n)=>{const t=hi.find(n=>String(n.props.id)===e),o=Jt.shared;if(!t||!o)return;let r;try{r=await N(Si).create(n,t)}catch{return void Kr(oo.shared.makeFailed,"error")}o.adopt(t,r),xi(null)})(wi.id,e),onCancel:()=>xi(null)}):null]})}))}export{Nt as ScreenChrome};