efficient-easel 23.0.0 → 23.1.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 (46) hide show
  1. package/README.md +7 -0
  2. package/dist/chunk-22I55W37.js +2 -0
  3. package/dist/chunk-2FYFAAAK.js +2 -0
  4. package/dist/chunk-6QSFJCJT.js +21 -0
  5. package/dist/chunk-DSKNJXB4.js +1 -0
  6. package/dist/{chunk-3P735WOM.js → chunk-HNV6HUSQ.js} +1 -1
  7. package/dist/chunk-JPCOBNYW.js +1 -0
  8. package/dist/{chunk-HLMQ34GP.js → chunk-JWOBAEBH.js} +1 -1
  9. package/dist/{chunk-FOOK54T2.js → chunk-LSTOOYG7.js} +1 -1
  10. package/dist/{chunk-FF54HWSE.js → chunk-NQ7NRYTK.js} +8 -8
  11. package/dist/{chunk-YHEYJKQL.js → chunk-T3LAGI43.js} +1 -1
  12. package/dist/chunk-TGSK5VII.js +5 -0
  13. package/dist/chunk-VBOSOH5M.js +16 -0
  14. package/dist/{chunk-XJ23ULBP.js → chunk-VHFLOHGQ.js} +1 -1
  15. package/dist/chunk-YCSZAP7T.js +1 -0
  16. package/dist/{chunk-VZUXOZGP.js → chunk-Z6V22QRZ.js} +30 -30
  17. package/dist/easel/easel.css +12 -9
  18. package/dist/easel/index.js +1 -1
  19. package/dist/fields/index.d.ts +35 -1
  20. package/dist/fields/index.js +1 -1
  21. package/dist/rowMarks-CO5TpfLY.d.ts +44 -0
  22. package/dist/screen/components/AddBlockRow.js +1 -1
  23. package/dist/screen/components/AddSidePanel.js +1 -1
  24. package/dist/screen/components/ScreenChrome.js +1 -1
  25. package/dist/screen/components/ScreenMount.d.ts +1 -1
  26. package/dist/screen/components/ScreenMount.js +1 -1
  27. package/dist/screen/components/ScreenStoreProvider.js +1 -1
  28. package/dist/screen/components/SectionScreenShell.js +17 -17
  29. package/dist/screen/components/usePartBridge.js +1 -1
  30. package/dist/screen/index.js +1 -1
  31. package/dist/screen/lib/document/device-fields.d.ts +7 -21
  32. package/dist/screen/lib/document/device-fields.js +1 -1
  33. package/dist/screen/lib/document/panel-no-control-mark.d.ts +3 -7
  34. package/dist/screen/lib/document/panel-no-control-mark.js +1 -1
  35. package/dist/screen/lib/document/style-clipboard.js +1 -1
  36. package/dist/screen/lib/document/use-section-ops.js +1 -1
  37. package/dist/screen/lib/key-scope.js +1 -1
  38. package/dist/screen/lib/screen-parts.js +1 -1
  39. package/package.json +2 -2
  40. package/dist/chunk-4YUC7B7E.js +0 -2
  41. package/dist/chunk-6F5GO337.js +0 -1
  42. package/dist/chunk-G3HAKQUF.js +0 -1
  43. package/dist/chunk-GXRS52JD.js +0 -5
  44. package/dist/chunk-INRERJU4.js +0 -2
  45. package/dist/chunk-KXTXYINN.js +0 -16
  46. package/dist/chunk-MXECWHRJ.js +0 -21
package/README.md CHANGED
@@ -1035,6 +1035,13 @@ const easel = createEasel<EaselConfig>({ config, data, onChange: (doc) => autosa
1035
1035
  character but letters, digits, `-` and `_` becomes `-u<hex>-`, so `" text"`
1036
1036
  is `<prefix>-fold--u20-text`); the key itself is unchanged for
1037
1037
  `closedFolds`, `onFold` and `data-fold`.
1038
+ - **In the phone view `planFields` plans only rows with a phone value.** When
1039
+ `showWhenContext.device` is `"mobile"`, a row that is not a `deviceField("mobile", …)`
1040
+ is not planned or drawn (it would write the desktop value). A heading mark, a
1041
+ slot and a field that draws no control anywhere stay; the `Inspector`'s `lead`
1042
+ is not drawn. `fieldShownInView(field, device)`
1043
+ is the one answer, exported from `efficient-easel/fields`. Desktop, tablet and
1044
+ no device: every row, as before.
1038
1045
  - **`planFields().rows` holds `slot` rows.** They draw nothing and are there so
1039
1046
  the slot's name has a bucket. Filter `row.field.type !== 'slot'` before
1040
1047
  drawing or counting rows of your own.
@@ -0,0 +1,2 @@
1
+ import{NO_CONTROL_FIELD as r}from"./chunk-YCSZAP7T.js";import{jsx as n}from"react/jsx-runtime";var t="data-sf-no-control";function o(){/* @__PURE__ */
2
+ return n("span",{[t]:"",hidden:!0})}function e(n,t){return{...n,[r]:t}}export{t as NO_CONTROL_ATTR,o as NoControlMark,e as noControlField};
@@ -0,0 +1,2 @@
1
+ import{noControlField as e}from"./chunk-22I55W37.js";import{DEFAULT_SCREEN_WORDS as r}from"./chunk-IYHO4XQX.js";import{deviceMetaOf as n,DEVICE_FIELD_MARKER as t}from"./chunk-YCSZAP7T.js";import{useWords as o}from"./chunk-MFIRYGHW.js";import{usePreviewDevice as i}from"./chunk-BSPCSC45.js";import{jsx as c}from"react/jsx-runtime";function u(e){return"mobile"===e?"mobile":"desktop"}var s={desktop:null,tablet:r.deviceNote.tablet,mobile:r.deviceNote.mobile},d="data-sf-device-hidden";function m(){/* @__PURE__ */
2
+ return c("span",{hidden:!0,[d]:""})}function f({tier:e,render:r,...n}){const t=i();return"each"===e?/* @__PURE__ */c(r,{...n,tier:u(t)}):u(t)===e?/* @__PURE__ */c(r,{...n}):/* @__PURE__ */c(m,{})}function l(e){return n(e)?.inner??e}function p(e,r){const n=r.render;return{...r,[t]:{tier:e,inner:r},render:r=>/* @__PURE__ */c(f,{tier:e,render:n,...r})}}function a(){const e=o("screen",r).deviceNote,n=i(),t="desktop"===n?null:e[n];return t?/* @__PURE__ */c("div",{className:"sf-device-scope",children:t}):/* @__PURE__ */c(m,{})}function h(){return e({type:"custom",render:()=>/* @__PURE__ */c(a,{})},"always")}export{d as DEVICE_HIDDEN_ATTR,s as DEVICE_NOTE,p as deviceField,h as deviceNote,u as shownTier,l as withoutDeviceGate};
@@ -0,0 +1,21 @@
1
+ import{fieldIsShown as e,shownFields as n}from"./chunk-BPXEFVSQ.js";import{noControlMetaOf as t,deviceMetaOf as l}from"./chunk-YCSZAP7T.js";import{TreeSeam as r}from"./chunk-WHS6Y55E.js";import{DEFAULT_TREE_WORDS as a}from"./chunk-K56YDHYQ.js";import{easelMenuEntries as o}from"./chunk-FIVU2COQ.js";import{SETTINGS_BUCKETS as i,SettingsGroup as s}from"./chunk-FM6JO4WF.js";import{DEFAULT_PANEL_WORDS as c}from"./chunk-KFV7N2DJ.js";import{FieldNumber as d}from"./chunk-Y2T3JX7K.js";import{FieldSelect as u}from"./chunk-KFWNGPW3.js";import{DEFAULT_FIELDS_WORDS as m}from"./chunk-JACEEVVF.js";import{SettingsField as h,SettingsSegmented as p}from"./chunk-S3DUFDQ6.js";import{useWords as f}from"./chunk-MFIRYGHW.js";import{useTreeDrag as b,gapToMoveIndex as g}from"./chunk-6NJHYXJM.js";import{withTip as v}from"./chunk-P2VEMZH5.js";import{Textarea as y,Input as k,ItemCount as x,SortableList as w,ListRow as C,ContextMenu as N,tabPanelId as O,Tabs as j,tabButtonId as S}from"efficient-shell/ui";export{LinkPicker}from"efficient-shell/ui";import{useRef as $,useState as D,useLayoutEffect as I,useId as F}from"react";import{jsx as P,jsxs as L}from"react/jsx-runtime";import{ChevronIcon as E,LockIcon as M,MoveUpIcon as T,MoveDownIcon as W,DuplicateIcon as z,TrashIcon as A}from"efficient-shell/icons/efficient";function R({id:e,value:n,onChange:t,placeholder:l,multiline:r=!1,rows:a=3,readOnly:o=!1,ariaLabel:i,ariaLabelledBy:s}){const c=n??"";return r?/* @__PURE__ */P(y,{id:e,size:"sm",className:"es-fin",value:c,rows:a,placeholder:l,readOnly:o,"aria-label":i,"aria-labelledby":s,onChange:e=>t(e.target.value)}):/* @__PURE__ */P(k,{id:e,size:"md",className:"es-fin",type:"text",value:c,placeholder:l,readOnly:o,"aria-label":i,"aria-labelledby":s,onChange:e=>t(e.target.value)})}function H(e,n,t){const l=e.slice();return l.splice(Math.max(0,Math.min(n,l.length)),0,t),l}function J(e,n,t){const l=e.slice(),[r]=l.splice(n,1);return l.splice(Math.max(0,Math.min(t,l.length)),0,r),l}function Y(e,n){return e.filter((e,t)=>t!==n)}function K(e){return null===e||"object"!=typeof e?e:JSON.parse(JSON.stringify(e))}var V='input, textarea, select, button, [contenteditable]:not([contenteditable="false"]), [tabindex]',B={parentId:"list",slot:"items"};function Q({label:e,icon:n,noun:t,items:l,onChange:i,newItem:s,summary:c,itemName:d,thumb:u,min:h=0,max:p,readOnly:y=!1,open:k,onOpen:O,renderItem:j,renderRow:S,canRemove:F,lockedReason:R,fixed:Q=!1,removeOnRow:X=!0,canDuplicate:Z,above:U,head:q=!0}){const G=f("fields",m).list,_=f("tree",a),ee=t??G.item,ne=!y&&!Q&&("number"!=typeof p||l.length<p),te=l.length<=h,le=e=>!!F&&!F(l[e],e),re=e=>!y&&!Q&&X&&!te&&!le(e),ae=e=>ne&&(!Z||Z(l[e],e)),oe=(e,n)=>d?d(e,n):G.itemName({noun:ee,n:n+1}),ie=$([]),se=$(null),[ce,de]=D(null),ue=$(null),[me,he]=D(null),[pe,fe]=D("");I(()=>{const e=se.current;if(!e)return;se.current=null;const n=ie.current[e.index]?.querySelectorAll(V)[e.nth]??ie.current[e.index];if(n?.focus(),n&&null!==e.start&&"setSelectionRange"in n)try{n.setSelectionRange(e.start,e.end)}catch{}});const be=(e,n)=>{if(n<0||n>=l.length||n===e)return;const t=ie.current[e],r=t?.ownerDocument.activeElement;if(t&&r&&t.contains(r)){const e=[...t.querySelectorAll(V)].indexOf(r),l=r;se.current={index:n,nth:e,start:"number"==typeof l.selectionStart?l.selectionStart:null,end:"number"==typeof l.selectionEnd?l.selectionEnd:null}}i(J(l,e,n));const a=function(e,n,t){return null===e?null:e===n?t:n<e&&t>=e?e-1:n>e&&t<=e?e+1:e}(k,e,n);a!==k&&O(a),fe(G.moved({n:n+1,total:l.length}))},ge=e=>{ne&&(i(H(l,e,s())),S?(se.current={index:e,nth:0,start:null,end:null},null!==k&&k>=e&&O(k+1)):O(e))},ve=e=>{re(e)&&(i(Y(l,e)),k===e?O(null):null!==k&&k>e&&O(k-1))},ye=b({keyOf:e=>String(e),canDrop:(e,n)=>n.parentId===B.parentId&&n.slot===B.slot,onDrop:(e,n)=>{const t=g({...B,index:e},n);t!==e&&be(e,t)},onStep:(e,n)=>be(e,e+n),canStep:(e,n)=>e+n>=0&&e+n<l.length,readOnly:y}),ke=e=>{const n=[];return e>0&&n.push({label:G.moveUp,icon:/* @__PURE__ */P(T,{size:14}),shortcut:"⌥↑",onClick:()=>be(e,e-1)}),e<l.length-1&&n.push({label:G.moveDown,icon:/* @__PURE__ */P(W,{size:14}),shortcut:"⌥↓",onClick:()=>be(e,e+1)}),ae(e)&&n.push({label:G.duplicate,icon:/* @__PURE__ */P(z,{size:14}),onClick:()=>(e=>{ae(e)&&(i(H(l,e+1,K(l[e]))),null!==k&&k>e&&O(k+1))})(e)}),re(e)&&n.push({label:G.delete,icon:/* @__PURE__ */P(A,{size:14}),danger:!0,onClick:()=>ve(e)}),n},xe=(e,n,t,l)=>{y||0===ke(e).length||he({index:e,x:n,y:t,owner:l})},we=e=>n=>{const t=l.slice();t[e]=n,i(t)};/* @__PURE__ */
2
+ return L("div",{className:"es-list",children:[q?/* @__PURE__ */L("div",{className:"es-list-head",children:[
3
+ /* @__PURE__ */L("span",{className:"es-list-label",children:[n?/* @__PURE__ */P("span",{className:"es-field-icon","aria-hidden":"true",children:n}):null,e]}),
4
+ /* @__PURE__ */P(x,{count:l.length,label:G.count({noun:ee,n:l.length}),showZero:!0})]}):null,U?/* @__PURE__ */P("div",{className:"es-list-above",children:U}):null,l.length?/* @__PURE__ */L(w,{"aria-label":e,spacing:"comfortable",className:"es-list-rows",rootProps:ye.rootProps(),children:[l.map((e,n)=>{const t=ye.row({item:n,place:{...B,index:n}}),l=t.draggable&&ce!==n,a=!S&&k===n,o=!y&&!Q&&X&&le(n),i=["es-list-row",S?"is-inline":"is-item",a?"is-open":"",l?"is-draggable":"",t.dragging?"is-dragging":"",t.drop?`is-drop-${t.drop}`:""].filter(Boolean).join(" ");return[n>0?/* @__PURE__ */P(r,{...ye.seam({place:{...B,index:n}}),onAdd:ne?()=>ge(n):void 0,label:G.addHere({noun:ee})},`seam-${n}`):null,
5
+ /* @__PURE__ */P(C,{className:i,flat:!!S,active:a,draggable:t.draggable,dragHint:_.dragHint,dragging:t.dragging,drop:"before"===t.drop||"after"===t.drop?t.drop:void 0,onMove:t.draggable?e=>be(n,"up"===e?n-1:n+1):void 0,rowRef:e=>{ie.current[n]=e},rowProps:{...t.rowProps,draggable:l||void 0,onPointerDown:e=>{const l=e.target.closest?.('input, textarea, select, [contenteditable]:not([contenteditable="false"])'),r=!!l&&l===l.ownerDocument.activeElement;e.currentTarget.draggable=t.draggable&&!r,ue.current=l&&!r?l:null,de(r?n:null)},onDragStart:e=>{const n=ue.current;ue.current=null,n&&n.ownerDocument.activeElement===n&&n.blur(),t.rowProps.onDragStart?.(e)},onContextMenu:e=>{y||(e.preventDefault(),e.stopPropagation(),xe(n,e.clientX,e.clientY,e.currentTarget))},onKeyDown:e=>{if("ContextMenu"===e.key||e.shiftKey&&"F10"===e.key){e.preventDefault();const t=e.currentTarget.ownerDocument,l=e=>e.preventDefault();t.addEventListener("contextmenu",l,{capture:!0,once:!0}),t.defaultView?.setTimeout(()=>t.removeEventListener("contextmenu",l,{capture:!0}),500);const r=e.currentTarget.getBoundingClientRect();return void xe(n,r.left+24,r.bottom,e.currentTarget)}t.rowProps.onKeyDown?.(e)}},actions:y||Q||!X?void 0:o?v(R?R(e,n):G.locked,/* @__PURE__ */P("span",{className:"es-list-lock",role:"img","aria-label":R?R(e,n):G.locked,children:/* @__PURE__ */P(M,{size:13})})):v(G.deleteItem({noun:ee}),/* @__PURE__ */P("button",{type:"button",className:"es-list-x","aria-label":G.deleteItem({noun:ee}),disabled:!re(n),onClick:()=>ve(n),children:"×"})),below:a?/* @__PURE__ */P("div",{className:"es-list-item",children:j(e,n,we(n))}):void 0,children:S?/* @__PURE__ */P("div",{className:"es-list-row-main",children:S(e,n,we(n))}):/* @__PURE__ */L("button",{type:"button",className:"es-list-open","aria-expanded":a,onClick:()=>O(a?null:n),children:[u?/* @__PURE__ */P("span",{className:"es-list-thumb","aria-hidden":"true",children:u(e,n)}):null,
6
+ /* @__PURE__ */P("span",{className:"es-list-row-name",children:oe(e,n)}),/* @__PURE__ */P("span",c?{className:"es-list-row-summary",children:c(e,n)}:{className:"es-list-row-summary"}),
7
+ /* @__PURE__ */P(E,{size:14,className:"es-list-chev","aria-hidden":"true"})]})},n)]}),
8
+ /* @__PURE__ */P(r,{...ye.seam({place:{...B,index:l.length}})})]}):null,y||Q?null:/* @__PURE__ */P("button",{type:"button",className:"es-list-add",disabled:!ne,onClick:()=>ge(l.length),children:G.add({noun:ee})}),
9
+ /* @__PURE__ */P("span",{className:"es-list-said","aria-live":"polite",children:pe}),me&&me.index<l.length?
10
+ /* @__PURE__ */P(N,{at:{x:me.x,y:me.y},owner:me.owner,onClose:()=>he(null),items:o(ke(me.index))}):null]})}var X=e=>e<6?e+1:6,Z=(e,n)=>"string"==typeof e.label&&e.label?e.label:n;function U({field:e,name:t,id:l,value:r,onChange:a,readOnly:o,context:i,showWhenContext:c,renderers:d,headingLevel:u=3}){const[m,h]=D(!0),p=r&&"object"==typeof r?r:{};/* @__PURE__ */
11
+ return P(s,{id:`${l}-group`,title:Z(e,t),open:m,onToggle:h,level:u,children:Object.entries(n(e.objectFields,{values:p,context:c})).map(([e,n])=>/* @__PURE__ */P(G,{field:n,name:`${t}.${e}`,id:`${l}-${e}`,value:p[e],onChange:n=>a({...p,[e]:n}),readOnly:o,context:i,showWhenContext:c,renderers:d,headingLevel:X(u)},e))})}function q({field:e,name:t,id:l,value:r,onChange:a,readOnly:o,context:i,showWhenContext:s,renderers:c,openItem:d,onOpenItem:u,headingLevel:m}){const[h,p]=D(null),f=u?d??null:h,b=u??p,g=Array.isArray(r)?r:[],v=e.getItemSummary;/* @__PURE__ */
12
+ return P(Q,{label:Z(e,t),icon:e.icon,noun:"string"==typeof e.noun?e.noun:void 0,items:g,onChange:a,newItem:()=>K({...e.defaultItemProps??{}}),summary:v?(e,n)=>v(e,n):void 0,min:e.min,max:e.max,readOnly:o,open:f,onOpen:b,renderItem:(r,a,d)=>Object.entries(n(e.arrayFields,{values:r,context:s})).map(([e,n])=>/* @__PURE__ */P(G,{field:n,name:`${t}[${a}].${e}`,id:`${l}-${a}-${e}`,value:r?.[e],onChange:n=>d({...r,[e]:n}),readOnly:o,context:i,showWhenContext:s,renderers:c,headingLevel:m},e))})}function G(e){const{field:n,name:t,id:l,value:r,onChange:a,readOnly:o,context:i,renderers:s}=e;if(!n||n.marker||!1===n.visible)return null;const c=s?.[n.type];if(c)return c({field:n,name:t,id:l,value:r,onChange:a,readOnly:o});switch(n.type){case"custom":{const e={...i,field:n,name:t,id:l,value:r,onChange:a,readOnly:o};return n.render(e)}case"text":case"textarea":/* @__PURE__ */
13
+ return P(h,{label:Z(n,t),htmlFor:l,icon:n.icon,hint:n.hint,children:/* @__PURE__ */P(R,{id:l,value:"string"==typeof r?r:null==r?"":String(r),onChange:a,placeholder:n.placeholder,multiline:"textarea"===n.type,readOnly:o})});case"number":/* @__PURE__ */
14
+ return P(h,{label:Z(n,t),htmlFor:l,icon:n.icon,hint:n.hint,children:/* @__PURE__ */P(d,{id:l,value:"number"==typeof r?r:void 0,onChange:a,min:n.min,max:n.max,step:n.step,placeholder:n.placeholder,readOnly:o})});case"select":{const e=`${l}-label`;/* @__PURE__ */
15
+ return P(h,{label:Z(n,t),labelId:e,htmlFor:l,icon:n.icon,hint:n.hint,children:/* @__PURE__ */P(u,{id:l,value:r,options:n.options,onChange:a,readOnly:o,ariaLabelledBy:e})})}case"radio":/* @__PURE__ */
16
+ return P(h,{label:Z(n,t),icon:n.icon,hint:n.hint,children:/* @__PURE__ */P(p,{ariaLabel:Z(n,t),value:r,options:n.options.map(e=>({id:e.value,label:e.label,icon:e.icon,disabled:e.disabled||o})),onChange:e=>{o||a(e)}})});case"object":/* @__PURE__ */
17
+ return P(U,{...e,field:n});case"array":/* @__PURE__ */
18
+ return P(q,{...e,field:n});case"slot":return null}}function _(e,n){if("mobile"!==n)return!0;const r=e;if(!r||r.marker||"slot"===r.type||"always"===t(e))return!0;const a=l(e)?.tier;return"mobile"===a||"each"===a}var ee={},ne=e=>i.includes(e);function te(n,t){let l,r=i[0];const a=[],o=/* @__PURE__ */new Set;for(const[i,s]of Object.entries(n))s&&(ne(s.bucket)&&((s.marker||s.bucket!==r)&&(l=void 0),r=s.bucket),s.marker&&"string"==typeof s.fold?l={key:i,title:s.fold}:s.marker&&!1===s.fold&&(l=void 0),s.marker||!1===s.visible||t&&!e(s,t)||t&&!_(s,t.context?.device)||(a.push(l?{name:i,field:s,bucket:r,fold:l}:{name:i,field:s,bucket:r}),"slot"!==s.type&&o.add(r)));return{rows:a,buckets:i.filter(e=>o.has(e))}}function le(e){return new Map(te(e).rows.map(e=>[e.name,e.bucket]))}function re(e){const n=[];for(const t of e){const e=n[n.length-1];e&&e.fold?.key===t.fold?.key?e.rows.push(t):n.push({fold:t.fold,rows:[t]})}return n}function ae({fields:e,values:n,onChange:t,readOnly:l=!1,context:r,showWhenContext:a,tab:o,onTab:i,tabs:d=!0,tabIcons:u,renderers:m,idPrefix:h,ariaLabel:p,lead:b,children:g,leadFold:v,closedFolds:y,onFold:k,headingLevel:x=3}){const w=f("panel",c),C=F(),N=h??`es-insp${C.replace(/:/g,"")}`,$=te(e,{values:n,context:a}),[I,E]=D(void 0),M=o??I,T=M&&$.buckets.includes(M)?M:$.buckets[0],[W,z]=D(null),A=W&&W.panel===N&&$.rows.some(e=>e.name===W.name)?W:null,R=d&&$.buckets.length>1,H=R&&T?O(N,T):`${N}-rows`,[J,Y]=D(()=>/* @__PURE__ */new Set),K=y??J,V=(e,n)=>{/* @__PURE__ */return P(s,{title:e.title,open:!K.has(e.key),onToggle:n=>((e,n)=>{void 0===y&&Y(t=>{const l=new Set(t);return n?l.delete(e):l.add(e),l}),k?.(e,n)})(e.key,n),id:`${N}-fold-${t=e.key,[...t].map(e=>/[A-Za-z0-9_-]/.test(e)?e:`-u${e.codePointAt(0).toString(16)}-`).join("")}`,level:x,children:n});var t},B=e=>R&&e!==T,Q=({name:e,field:o,bucket:i,fold:s})=>/* @__PURE__ */P("div",{className:"es-insp-row","data-field":e,"data-bucket":i,hidden:!!B(i)||void 0,children:/* @__PURE__ */P(G,{field:o,name:e,id:`${N}-${e}`,value:n[e],onChange:n=>t(e,n),readOnly:l,context:r,showWhenContext:a,renderers:m,openItem:A&&A.name===e?A.index:null,onOpenItem:n=>z(null===n?null:{panel:N,name:e,index:n}),headingLevel:s?X(x):x})},e);/* @__PURE__ */
19
+ return L("div",{className:"es-insp",children:[R?/* @__PURE__ */P("div",{className:"es-insp-tabs",children:/* @__PURE__ */P(j,{variant:"underline",block:!0,"aria-label":p??w.settings,idPrefix:N,value:T,onChange:e=>{const n=e;void 0===o&&E(n),i?.(n)},items:$.buckets.map(e=>{const n=w.buckets[e],t=u?.[e];return t?{id:e,icon:t,label:/* @__PURE__ */P("span",{className:"sr-only",children:n}),tooltip:n}:{id:e,label:n}})})}):null,
20
+ /* @__PURE__ */L("div",{className:"es-insp-rows",id:H,role:R?"tabpanel":void 0,"aria-labelledby":R&&T?S(N,T):void 0,children:[b&&_(ee,a?.device)?v?/* @__PURE__ */P("div",{className:"es-insp-band","data-fold":v.key,children:V(v,b)}):b:null,re($.rows).map((e,n)=>{if(!e.fold)return e.rows.map(Q);const t=e.rows[0].bucket,l=e.rows.every(e=>"slot"===e.field.type);/* @__PURE__ */
21
+ return P("div",{className:"es-insp-band","data-fold":e.fold.key,"data-bucket":t,hidden:!(!B(t)&&!l)||void 0,children:V(e.fold,e.rows.map(Q))},`fold-${e.fold.key}-${n}`)}),g]})]})}export{R as FieldText,ae as Inspector,G as InspectorField,Q as ListField,le as bucketsOf,K as copyItem,_ as fieldShownInView,H as insertAt,Z as labelOf,J as moveTo,te as planFields,Y as removeAt};
@@ -0,0 +1 @@
1
+ import{panelFieldsOf as t}from"./chunk-5XL2RXFU.js";import{withoutDeviceGate as o}from"./chunk-2FYFAAAK.js";import{DESIGN_GROUP_KEY as n,BUCKET_KEY as e}from"./chunk-3QB2ZQXK.js";import{STYLE_KIND as r,fieldKind as s,copyStyle as c,heldStyle as i,planPaste as p,pasteMessage as u}from"./chunk-V7U33NF2.js";import{ANCHOR_FIELD_KEYS as f,foldMetaOf as a,MEDIA_FIELD_MARKER as l,TEXT_FIELD_MARKER as m,LINK_FIELD_MARKER as h}from"./chunk-ANPOR6EY.js";import{deviceMetaOf as y}from"./chunk-YCSZAP7T.js";var j=/* @__PURE__ */new Set([n.Size,n.Design,n.Layout,n.Position]),w=new Set(Object.values(n)),b=new Set(Object.values(e)),S=new Set(f),k=/* @__PURE__ */new Set(["focal","imageFocal"]),A=[l,m,h];function g(t){return`site:${t??""}`}function v(t){if(!t||"object"!=typeof t)return null;const n=t,e=o(t)??t,c=n[r]??e[r];if("string"==typeof c)return c;const i=n.options??e.options;if(Array.isArray(i)){return`choice:${i.map(t=>String(t?.value)).sort().join("|")}`}return s(e)}function F(t){const n=t,e=o(t);return A.some(t=>t in n||e&&t in e)}function O(o,n){const r=t(o,n)??{},s=[];let c=!0,i=!1;for(const[t,o]of Object.entries(r))b.has(t)?(c=t===e.Design,i=!1):w.has(t)?c&&(i=j.has(t)):i&&o&&"object"==typeof o&&!t.startsWith("_")&&(a(o)||S.has(t)||k.has(t)||F(o)||"slot"!==o.type&&s.push({path:[t],kind:v(o),counted:"mobile"!==y(o)?.tier}));return s}function d(t,o,n,e,r){c({scope:n,type:e.type,label:r,rows:t(o,e),props:e.props})}function L(t,o,n,e,r,s){const c=i(n);if(!c)return null;const f=p(c,{type:e.type,rows:t(o,e),props:e.props});return{...f,message:u(f,c.sourceLabel,r,s)}}function P(t,o,n,e){d(O,t,o,n,e)}function X(t,o,n,e,r){return L(O,t,o,n,e,r)}var Y={scope:t=>g(t.siteId),rows:(t,o)=>O(t,o),copy:(t,o,n,e)=>P(e,t,o,n),plan:(t,o,n,e)=>X(e,t,o,n)};function D(t,o){if(!t&&!o)return Y;const n=t?.rows,e=n?(t,o)=>n(t,o):O;return{scope:t?.scope??Y.scope,rows:(t,o)=>e(t,o),copy:t?.copy??((t,o,n,r)=>d(e,r,t,o,n)),plan:t?.plan??((t,n,r,s)=>L(e,s,t,n,r,o))}}export{P as copyNodeStyle,O as nodeStyleRows,X as planNodePaste,v as shopFieldKind,g as siteStyleScope,D as styleClipboardOf};
@@ -1,4 +1,4 @@
1
- import{clientOnly as r}from"./chunk-GXQCZJOP.js";import{ScreenChrome as n}from"./chunk-VZUXOZGP.js";import{ScreenStoreProvider as e}from"./chunk-XJ23ULBP.js";import{ScreenDocumentProvider as i,useScreenDocument as a}from"./chunk-A6ZP5II4.js";import{DEFAULT_SCREEN_WORDS as o}from"./chunk-IYHO4XQX.js";import{documentPermissions as s}from"./chunk-THWO5YVZ.js";import{useWords as c}from"./chunk-MFIRYGHW.js";import{useMemo as t,useState as d,useRef as l,useEffect as m,useCallback as g}from"react";import{Dialog as h,Button as f}from"efficient-shell/ui";import{jsx as u,jsxs as p,Fragment as v}from"react/jsx-runtime";var k=r(e),C=r(n);function j({onCancel:r,onDiscard:n,onSave:e}){const i=c("screen",o).leave,[a,s]=d(!1),t=l(!0);m(()=>(t.current=!0,()=>{t.current=!1}),[]);const k=g(async()=>{s(!0);try{await e()}finally{t.current&&s(!1)}},[e]);/* @__PURE__ */
1
+ import{clientOnly as r}from"./chunk-GXQCZJOP.js";import{ScreenChrome as n}from"./chunk-Z6V22QRZ.js";import{ScreenStoreProvider as e}from"./chunk-VHFLOHGQ.js";import{ScreenDocumentProvider as i,useScreenDocument as a}from"./chunk-A6ZP5II4.js";import{DEFAULT_SCREEN_WORDS as o}from"./chunk-IYHO4XQX.js";import{documentPermissions as s}from"./chunk-THWO5YVZ.js";import{useWords as c}from"./chunk-MFIRYGHW.js";import{useMemo as t,useState as d,useRef as l,useEffect as m,useCallback as g}from"react";import{Dialog as h,Button as f}from"efficient-shell/ui";import{jsx as u,jsxs as p,Fragment as v}from"react/jsx-runtime";var k=r(e),C=r(n);function j({onCancel:r,onDiscard:n,onSave:e}){const i=c("screen",o).leave,[a,s]=d(!1),t=l(!0);m(()=>(t.current=!0,()=>{t.current=!1}),[]);const k=g(async()=>{s(!0);try{await e()}finally{t.current&&s(!1)}},[e]);/* @__PURE__ */
2
2
  return u(h,{open:!0,role:"alertdialog",size:"sm",title:i.title,onClose:r,footer:/* @__PURE__ */p(v,{children:[
3
3
  /* @__PURE__ */u(f,{variant:"secondary",onClick:r,children:i.cancel}),
4
4
  /* @__PURE__ */u(f,{variant:"ghost-danger",onClick:n,children:i.discard}),
@@ -0,0 +1 @@
1
+ import{useSectionOps as o}from"./chunk-LSTOOYG7.js";import{SELECTION_MODE as e}from"./chunk-TGSK5VII.js";import{decodePartId as r,encodePartId as t}from"./chunk-R4AUZVA3.js";import{useEasel as n}from"./chunk-VBOSOH5M.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 S=s(m)?t(m.nodeId,m.propKey):null;c(()=>{f(S)},[S,f]);return{selectNode:d(o=>{i(()=>e);const r=a(o);r&&u.select(r)},[i,a,u]),openPartId:S}}export{m as usePartBridge};
@@ -1,4 +1,4 @@
1
- import{blockRuns as e,offeredChoices as s}from"./chunk-RUQOIQWI.js";import{useScreenBlockLook as t}from"./chunk-GXRS52JD.js";import{DEFAULT_SCREEN_WORDS as l}from"./chunk-IYHO4XQX.js";import{useWords as r}from"./chunk-MFIRYGHW.js";import{ItemCount as n,DropdownMenu as c}from"efficient-shell/ui";import{jsxs as a,jsx as o,Fragment as i}from"react/jsx-runtime";function m({choices:m,onPick:p}){const{Icon:u}=t(),f=r("screen",l),h=e(s(m)).flatMap(e=>[...e.group?[{type:"label",key:`group:${e.group}`,label:/* @__PURE__ */a("span",{className:"flex w-full items-center gap-2",children:[
1
+ import{blockRuns as e,offeredChoices as s}from"./chunk-RUQOIQWI.js";import{useScreenBlockLook as t}from"./chunk-TGSK5VII.js";import{DEFAULT_SCREEN_WORDS as l}from"./chunk-IYHO4XQX.js";import{useWords as r}from"./chunk-MFIRYGHW.js";import{ItemCount as n,DropdownMenu as c}from"efficient-shell/ui";import{jsxs as a,jsx as o,Fragment as i}from"react/jsx-runtime";function m({choices:m,onPick:p}){const{Icon:u}=t(),f=r("screen",l),h=e(s(m)).flatMap(e=>[...e.group?[{type:"label",key:`group:${e.group}`,label:/* @__PURE__ */a("span",{className:"flex w-full items-center gap-2",children:[
2
2
  /* @__PURE__ */o("span",{children:e.group}),
3
3
  /* @__PURE__ */o(n,{count:e.items.length,label:f.blockCount({count:e.items.length}),className:"ml-auto"})]})}]:[],...e.items.map(e=>({key:e.type,label:e.label,icon:/* @__PURE__ */o("span",{className:"sf-chip",children:/* @__PURE__ */o(u,{type:e.type,size:13})}),onSelect:()=>p(e.type)}))]);/* @__PURE__ */
4
4
  return o(c,{align:"start",triggerClassName:"sf-add-card",items:h,trigger:/* @__PURE__ */a(i,{children:[
@@ -1 +1 @@
1
- import{useScreenBlockRules as e}from"./chunk-GXRS52JD.js";import{newNodeId as t,ROOT_ZONE as n}from"./chunk-TCAAOYQY.js";import{useEasel as o,useEaselApi as r}from"./chunk-KXTXYINN.js";import{useMemo as s}from"react";function i(i={}){const{dispatch:p}=o(e=>e),d=r(),c=!0===i.readOnly,a=e().resolveOnInsert,l=!0===(i.resolveOnInsert??a),m=!0===i.foldIntoHistory;return s(()=>{const e=m?e=>p({...e,recordHistory:!1}):p,o=(n,o,r)=>{const s=t(o);return c||e({type:"insert",componentType:o,destinationZone:n,destinationIndex:r,id:s}),s},r=e=>(l&&!c&&d.resolveNode(e,{trigger:"insert"}),e),s=(t,n,o)=>{c||e({type:"replace",destinationZone:t,destinationIndex:n,data:o})},i=(e,t,n)=>r(o(e,t,n));return{insertComponent:i,insertSection:(e,t)=>i(n,e,t),replaceComponent:s,seedChild:(e,t,n,i)=>{const p=o(e,n,t);s(e,t,{type:n,props:{id:p,...i}}),r(p)},insertNode:(e,t,n)=>{const i=o(e,n.type,t);return s(e,t,{type:n.type,props:{...n.props,id:i}}),r(i)},removeComponent:(t,n)=>{c||e({type:"remove",index:n,zone:t})},reorderComponent:(t,n,o)=>{c||e({type:"reorder",sourceIndex:n,destinationIndex:o,destinationZone:t})},duplicateComponent:(t,n)=>{c||e({type:"duplicate",sourceIndex:n,sourceZone:t})},select:e=>p({type:"setUi",ui:{itemSelector:e}}),setDocument:t=>{c||e({type:"setData",data:t})},commitDocument:(t,n)=>{c||(m?d.batch(()=>{e({type:"setData",data:t}),void 0!==n&&("slot"===n?.kind?d.selectSlot({parentId:n.parentId,slot:n.slot}):d.select(n?n.id:null))}):d.run({data:t,select:n}))}}},[p,c,l,d,m])}export{i as useSectionOps};
1
+ import{useScreenBlockRules as e}from"./chunk-TGSK5VII.js";import{newNodeId as t,ROOT_ZONE as n}from"./chunk-TCAAOYQY.js";import{useEasel as o,useEaselApi as r}from"./chunk-VBOSOH5M.js";import{useMemo as s}from"react";function i(i={}){const{dispatch:p}=o(e=>e),d=r(),c=!0===i.readOnly,a=e().resolveOnInsert,l=!0===(i.resolveOnInsert??a),m=!0===i.foldIntoHistory;return s(()=>{const e=m?e=>p({...e,recordHistory:!1}):p,o=(n,o,r)=>{const s=t(o);return c||e({type:"insert",componentType:o,destinationZone:n,destinationIndex:r,id:s}),s},r=e=>(l&&!c&&d.resolveNode(e,{trigger:"insert"}),e),s=(t,n,o)=>{c||e({type:"replace",destinationZone:t,destinationIndex:n,data:o})},i=(e,t,n)=>r(o(e,t,n));return{insertComponent:i,insertSection:(e,t)=>i(n,e,t),replaceComponent:s,seedChild:(e,t,n,i)=>{const p=o(e,n,t);s(e,t,{type:n,props:{id:p,...i}}),r(p)},insertNode:(e,t,n)=>{const i=o(e,n.type,t);return s(e,t,{type:n.type,props:{...n.props,id:i}}),r(i)},removeComponent:(t,n)=>{c||e({type:"remove",index:n,zone:t})},reorderComponent:(t,n,o)=>{c||e({type:"reorder",sourceIndex:n,destinationIndex:o,destinationZone:t})},duplicateComponent:(t,n)=>{c||e({type:"duplicate",sourceIndex:n,sourceZone:t})},select:e=>p({type:"setUi",ui:{itemSelector:e}}),setDocument:t=>{c||e({type:"setData",data:t})},commitDocument:(t,n)=>{c||(m?d.batch(()=>{e({type:"setData",data:t}),void 0!==n&&("slot"===n?.kind?d.selectSlot({parentId:n.parentId,slot:n.slot}):d.select(n?n.id:null))}):d.run({data:t,select:n}))}}},[p,c,l,d,m])}export{i as useSectionOps};
@@ -1,8 +1,8 @@
1
- import{buildPaletteSections as e,pinnedSection as t,categoryLabel as n}from"./chunk-VKPOH6MK.js";import{blockTypesIn as o}from"./chunk-IZGFJWH4.js";import{sectionTemplatesOf as l}from"./chunk-N7E6264U.js";import{sharedSectionsOf as r}from"./chunk-N3MJOHAG.js";import{SidePanelHead as i,PanelModeExit as s}from"./chunk-SINAM2IT.js";import{blockRuns as c}from"./chunk-RUQOIQWI.js";import{useScreenBlockLook as a,useScreenBlockRules as d,useScreenPinned as p}from"./chunk-GXRS52JD.js";import{useEaselSession as m}from"./chunk-YM4UEGBV.js";import{DEFAULT_SCREEN_WORDS as f}from"./chunk-IYHO4XQX.js";import{useEasel as u}from"./chunk-KXTXYINN.js";import{easelMenuEntries as y}from"./chunk-FIVU2COQ.js";import{useWords as h}from"./chunk-MFIRYGHW.js";import{AddPanel as k}from"./chunk-LN43DP2A.js";import{DEFAULT_DRAG_WORDS as g}from"./chunk-TQ5Y6S2X.js";import{useState as b,useEffect as v,useMemo as j,useRef as I}from"react";import{SharedIcon as w,AddIcon as C}from"efficient-shell/icons/efficient";import{ContextMenu as O,toast as M,Dialog as N,Button as T}from"efficient-shell/ui";import{jsx as $,jsxs as x,Fragment as E}from"react/jsx-runtime";function F({name:e,pages:t,onDelete:n,onCancel:o}){const l=h("screen",f).shared,[r,i]=b(!1),s=I(null);/* @__PURE__ */
2
- return $(N,{open:!0,role:"alertdialog",size:"sm",title:l.deleteTitle({name:e}),onClose:o,initialFocus:s,footer:/* @__PURE__ */x(E,{children:[
3
- /* @__PURE__ */$(T,{ref:s,variant:"secondary",onClick:o,children:l.cancel}),
4
- /* @__PURE__ */$(T,{variant:"danger",loading:r,onClick:()=>{(async()=>{i(!0);try{await n()}finally{i(!1)}})()},children:l.deleteShared})]}),children:l.deleteMessage({count:t})})}var H=e=>`section:${e}`,S=e=>`block:${e}`,A=e=>`template:${e}`,X=e=>`shared:${e}`;function D({at:I,placeBlocks:N,canTake:T,onPick:D,itemFor:G,session:L,siteWide:Q,onClose:W,onHide:Y,readOnly:z}){const B=u(e=>e.config),P=a(),{labelAtLevel:R,categoryLabel:U,firstSection:J,Icon:K,Thumbnail:V}=P,{blockIsOffered:_,canAddTo:Z}=d(),q=h("screen",f).add,ee=h("drag",g).add,te=m(),[ne,oe]=b([]);v(()=>{let e=!1;const t=e=>_(e,te);return l(te).list().then(n=>{if(e)return;const l=B.components;oe(n.filter(e=>e.node?.type&&l[e.node.type]&&o(e.node).every(t)))}).catch(()=>{}),()=>{e=!0}},[B,te]);const le=p().shared,re=h("screen",f).shared,[ie,se]=b([]),[ce,ae]=b(0);v(()=>{if(!le)return;let e=!1;const t=e=>_(e,te);return r(te).list().then(n=>{if(e)return;const l=B.components;se(n.filter(e=>e.node?.type&&l[e.node.type]&&o(e.node).every(t)))}).catch(()=>{}),()=>{e=!0}},[B,te,ce]);const[de,pe]=b(null),[me,fe]=b(null),ue=j(()=>e(B,P),[B]),ye=e=>R(e,"section",B.components[e]?.label??e),he=e=>({type:H(e.type),label:e.name,cover:/* @__PURE__ */$(V,{type:e.type}),title:e.desc?`${e.name} — ${e.desc}`:q.tile({name:e.name}),keywords:[e.alias??"",e.desc,e.type,e.catLabel].filter(Boolean)}),ke=e=>{const t=e.indexOf(":"),n=e.slice(0,t),o=e.slice(t+1);if("section"===n)return{kind:"section",type:o};if("block"===n)return{kind:"block",type:o};if("template"===n){const e=ne.find(e=>e.id===o);return e?{kind:"template",template:e}:null}if("shared"===n){const e=ie.find(e=>e.id===o);return e?{kind:"shared",section:e}:null}return null},ge=e=>/* @__PURE__ */$("span",{className:"es-add-glyph-cover",children:/* @__PURE__ */$(K,{type:e,size:26})}),be=j(()=>{const e=t(ue,J),o=/* @__PURE__ */new Map,l=e=>{e.retired||o.has(e.type)||!_(e.type,te)||o.set(e.type,e)};for(const t of e?[e]:ue){const e=Z(t.type)?.choices??[];e.forEach(l),e.forEach(e=>Z(e.type,1)?.choices?.forEach(l))}N?.forEach(l);const r=new Set(ue.map(e=>e.type)),i=[...o.values()].filter(e=>!r.has(e.type)),s=e=>({type:S(e.type),label:e.label,cover:ge(e.type),title:q.tile({name:e.label}),keywords:[e.group??"",e.type].filter(Boolean)}),a=e=>o.has(e.type)?{...he(e),cover:ge(e.type)}:he(e),d=[];ie.length>0&&d.push({key:"shared",title:re.group,tiles:ie.map(e=>({type:X(e.id),label:e.title,cover:/* @__PURE__ */$(V,{type:e.node.type}),mark:/* @__PURE__ */$(w,{size:12}),title:re.onPages({count:e.used_on.length}),keywords:[ye(e.node.type),e.node.type]}))}),ne.length>0&&d.push({key:"templates",title:q.templates,tiles:ne.map(e=>({type:A(e.id),label:e.name,cover:/* @__PURE__ */$(V,{type:e.node.type}),keywords:[ye(e.node.type),e.node.type]}))});const p=i.filter(e=>!e.group);let m=!1;for(const t of Object.keys(B.categories??{})){const o=ue.filter(e=>e.cat===t);if(0===o.length)continue;const l=e&&o.some(t=>t.type===e.type)?e:null,r=(l?[l,...o.filter(e=>e.type!==l.type)]:o).map(a);l&&!m&&(r.splice(1,0,...p.map(s)),m=!0),d.push({key:`category:${t}`,title:n(B,t,U),tiles:r})}const f=d.find(e=>e.key?.startsWith("category:"));if(!m&&f&&p.length>0&&(f.tiles=[...f.tiles,...p.map(s)],m=!0),c(i.filter(e=>e.group||!m)).forEach((e,t)=>{d.push({key:`blocks:${t}`,title:e.group??"",tiles:e.items.map(s)})}),!T)return d;const u=d.map(e=>({...e,tiles:e.tiles.map(e=>{const t=ke(e.type),n=t?T(t):null;return n?{...e,disabled:!0,disabledReason:n}:e})})),y=e=>e.tiles.some(e=>!e.disabled);return[...u.filter(y),...u.filter(e=>!y(e))]},[ne,ie,re,ue,B,q,T,N,te]);/* @__PURE__ */
5
- return x(E,{children:[
6
- /* @__PURE__ */$(i,{icon:/* @__PURE__ */$(C,{size:15}),title:q.title,context:q.contextAll,actions:/* @__PURE__ */$(s,{label:q.done,description:q.doneDescription,onClick:W}),onHide:Y}),
7
- /* @__PURE__ */x("div",{className:"sf-addside sf-scroll",children:[
8
- /* @__PURE__ */$(k,{groups:be,session:L,itemFor:e=>G(ke(e)??{kind:"section",type:e}),onInsert:D?e=>{const t=ke(e);t&&D(t)}:void 0,onTileMenu:(e,t)=>{const n=ke(e);return"shared"===n?.kind&&!z&&(pe({section:n.section,...t}),!0)},at:I,hint:q.hint,searchLabel:q.search,readOnly:z,words:ee}),Q??null]}),de?/* @__PURE__ */$(O,{at:{x:de.x,y:de.y},owner:de.owner,onClose:()=>pe(null),"aria-label":de.section.title,items:y([{label:re.deleteShared,danger:!0,onClick:()=>{fe(de.section),pe(null)}}])}):null,me?/* @__PURE__ */$(F,{name:me.title,pages:me.used_on.length,onDelete:()=>(async e=>{try{await r(te).remove(e.id)}catch{return void M.error(re.deleteFailed)}fe(null),le?.removed?.(e),se(t=>t.filter(t=>t.id!==e.id)),ae(e=>e+1)})(me),onCancel:()=>fe(null)}):null]})}export{D as AddSidePanel,S as blockKey,H as sectionKey,X as sharedKey,A as templateKey};
1
+ import{buildPaletteSections as e,pinnedSection as t,categoryLabel as n}from"./chunk-VKPOH6MK.js";import{blockTypesIn as o}from"./chunk-IZGFJWH4.js";import{sectionTemplatesOf as l}from"./chunk-N7E6264U.js";import{sharedSectionsOf as r}from"./chunk-N3MJOHAG.js";import{SidePanelHead as i,PanelModeExit as s}from"./chunk-SINAM2IT.js";import{blockRuns as c}from"./chunk-RUQOIQWI.js";import{useScreenBlockLook as a,useScreenBlockRules as d,useScreenPinned as p}from"./chunk-TGSK5VII.js";import{useEaselSession as m}from"./chunk-YM4UEGBV.js";import{DEFAULT_SCREEN_WORDS as f}from"./chunk-IYHO4XQX.js";import{useEasel as u}from"./chunk-VBOSOH5M.js";import{easelMenuEntries as y}from"./chunk-FIVU2COQ.js";import{useWords as h}from"./chunk-MFIRYGHW.js";import{AddPanel as k}from"./chunk-LN43DP2A.js";import{DEFAULT_DRAG_WORDS as g}from"./chunk-TQ5Y6S2X.js";import{useState as b,useEffect as v,useMemo as j,useRef as I}from"react";import{SharedIcon as O,AddIcon as w}from"efficient-shell/icons/efficient";import{ContextMenu as C,toast as M,Dialog as H,Button as S}from"efficient-shell/ui";import{jsx as T,jsxs as $,Fragment as x}from"react/jsx-runtime";function E({name:e,pages:t,onDelete:n,onCancel:o}){const l=h("screen",f).shared,[r,i]=b(!1),s=I(null);/* @__PURE__ */
2
+ return T(H,{open:!0,role:"alertdialog",size:"sm",title:l.deleteTitle({name:e}),onClose:o,initialFocus:s,footer:/* @__PURE__ */$(x,{children:[
3
+ /* @__PURE__ */T(S,{ref:s,variant:"secondary",onClick:o,children:l.cancel}),
4
+ /* @__PURE__ */T(S,{variant:"danger",loading:r,onClick:()=>{(async()=>{i(!0);try{await n()}finally{i(!1)}})()},children:l.deleteShared})]}),children:l.deleteMessage({count:t})})}var F=e=>`section:${e}`,A=e=>`block:${e}`,N=e=>`template:${e}`,B=e=>`shared:${e}`;function G({at:I,placeBlocks:H,canTake:S,onPick:G,itemFor:L,session:Q,siteWide:V,onClose:W,onHide:z,readOnly:D}){const P=u(e=>e.config),U=a(),{labelAtLevel:Y,categoryLabel:K,firstSection:R,Icon:X,Thumbnail:J}=U,{blockIsOffered:_,canAddTo:Z}=d(),q=h("screen",f).add,ee=h("drag",g).add,te=m(),[ne,oe]=b([]);v(()=>{let e=!1;const t=e=>_(e,te);return l(te).list().then(n=>{if(e)return;const l=P.components;oe(n.filter(e=>e.node?.type&&l[e.node.type]&&o(e.node).every(t)))}).catch(()=>{}),()=>{e=!0}},[P,te]);const le=p().shared,re=h("screen",f).shared,[ie,se]=b([]),[ce,ae]=b(0);v(()=>{if(!le)return;let e=!1;const t=e=>_(e,te);return r(te).list().then(n=>{if(e)return;const l=P.components;se(n.filter(e=>e.node?.type&&l[e.node.type]&&o(e.node).every(t)))}).catch(()=>{}),()=>{e=!0}},[P,te,ce]);const[de,pe]=b(null),[me,fe]=b(null),ue=j(()=>e(P,U),[P]),ye=e=>Y(e,"section",P.components[e]?.label??e),he=e=>({type:F(e.type),label:e.name,cover:/* @__PURE__ */T(J,{type:e.type}),title:e.desc?`${e.name} — ${e.desc}`:q.tile({name:e.name}),keywords:[e.alias??"",e.desc,e.type,e.catLabel].filter(Boolean)}),ke=e=>{const t=e.indexOf(":"),n=e.slice(0,t),o=e.slice(t+1);if("section"===n)return{kind:"section",type:o};if("block"===n)return{kind:"block",type:o};if("template"===n){const e=ne.find(e=>e.id===o);return e?{kind:"template",template:e}:null}if("shared"===n){const e=ie.find(e=>e.id===o);return e?{kind:"shared",section:e}:null}return null},ge=e=>/* @__PURE__ */T("span",{className:"es-add-glyph-cover",children:/* @__PURE__ */T(X,{type:e,size:26})}),be=j(()=>{const e=t(ue,R),o=/* @__PURE__ */new Map,l=e=>{e.retired||o.has(e.type)||!_(e.type,te)||o.set(e.type,e)};for(const t of e?[e]:ue){const e=Z(t.type)?.choices??[];e.forEach(l),e.forEach(e=>Z(e.type,1)?.choices?.forEach(l))}H?.forEach(l);const r=new Set(ue.map(e=>e.type)),i=[...o.values()].filter(e=>!r.has(e.type)),s=e=>({type:A(e.type),label:e.label,cover:ge(e.type),title:q.tile({name:e.label}),keywords:[e.group??"",e.type].filter(Boolean)}),a=e=>o.has(e.type)?{...he(e),cover:ge(e.type)}:he(e),d=[];ie.length>0&&d.push({key:"shared",title:re.group,tiles:ie.map(e=>({type:B(e.id),label:e.title,cover:/* @__PURE__ */T(J,{type:e.node.type}),mark:/* @__PURE__ */T(O,{size:12}),title:re.onPages({count:e.used_on.length}),keywords:[ye(e.node.type),e.node.type]}))}),ne.length>0&&d.push({key:"templates",title:q.templates,tiles:ne.map(e=>({type:N(e.id),label:e.name,cover:/* @__PURE__ */T(J,{type:e.node.type}),keywords:[ye(e.node.type),e.node.type]}))});const p=i.filter(e=>!e.group);let m=!1;for(const t of Object.keys(P.categories??{})){const o=ue.filter(e=>e.cat===t);if(0===o.length)continue;const l=e&&o.some(t=>t.type===e.type)?e:null,r=(l?[l,...o.filter(e=>e.type!==l.type)]:o).map(a);l&&!m&&(r.splice(1,0,...p.map(s)),m=!0),d.push({key:`category:${t}`,title:n(P,t,K),tiles:r})}const f=d.find(e=>e.key?.startsWith("category:"));if(!m&&f&&p.length>0&&(f.tiles=[...f.tiles,...p.map(s)],m=!0),c(i.filter(e=>e.group||!m)).forEach((e,t)=>{d.push({key:`blocks:${t}`,title:e.group??"",tiles:e.items.map(s)})}),!S)return d;const u=d.map(e=>({...e,tiles:e.tiles.map(e=>{const t=ke(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))]},[ne,ie,re,ue,P,q,S,H,te]);/* @__PURE__ */
5
+ return $(x,{children:[
6
+ /* @__PURE__ */T(i,{icon:/* @__PURE__ */T(w,{size:15}),title:q.title,context:q.contextAll,actions:/* @__PURE__ */T(s,{label:q.done,description:q.doneDescription,onClick:W}),onHide:z}),
7
+ /* @__PURE__ */$("div",{className:"sf-addside sf-scroll",children:[
8
+ /* @__PURE__ */T(k,{groups:be,session:Q,itemFor:e=>L(ke(e)??{kind:"section",type:e}),onInsert:G?e=>{const t=ke(e);t&&G(t)}:void 0,onTileMenu:(e,t)=>{const n=ke(e);return"shared"===n?.kind&&!D&&(pe({section:n.section,...t}),!0)},at:I,hint:q.hint,searchLabel:q.search,readOnly:D,words:ee}),V??null]}),de?/* @__PURE__ */T(C,{at:{x:de.x,y:de.y},owner:de.owner,onClose:()=>pe(null),"aria-label":de.section.title,items:y([{label:re.deleteShared,danger:!0,onClick:()=>{fe(de.section),pe(null)}}])}):null,me?/* @__PURE__ */T(E,{name:me.title,pages:me.used_on.length,onDelete:()=>(async e=>{try{await r(te).remove(e.id)}catch{return void M.error(re.deleteFailed)}fe(null),le?.removed?.(e),se(t=>t.filter(t=>t.id!==e.id)),ae(e=>e+1)})(me),onCancel:()=>fe(null)}):null]})}export{G as AddSidePanel,A as blockKey,F as sectionKey,B as sharedKey,N as templateKey};
@@ -1 +1 @@
1
- import{useEaselHost as n}from"./chunk-MQA7OFRA.js";import{useEaselApi as e,bindUndoKeys as t}from"./chunk-KXTXYINN.js";import{useState as r,useEffect as o,useRef as u}from"react";function c(e){const t=n(),[u,c]=r(null);return o(()=>c(e.current),[e]),t.ownsDocument?"undefined"==typeof document?null:document:u}function i(r,u){const i=n(),s=e(),f=c(r);o(()=>{if(!i.ownsDocument&&f)return t(f,s,{leaveTyping:!0})},[i,s,f]);const m=u?.document??null;o(()=>{if(!i.ownsDocument&&m)return t(m,s,{leaveTyping:!0})},[i,s,m])}function s(n){return n.ownsDocument?{}:{tabIndex:-1}}function f(n){return!n.altKey&&!n.shiftKey&&(!(!n.metaKey&&!n.ctrlKey)&&("s"===n.key||"S"===n.key||"KeyS"===n.code))}function m(n,e,t){const r=c(n),i=u(t);o(()=>{i.current=t}),o(()=>{if(!r)return;const n=n=>{f(n)&&(n.preventDefault(),i.current())};return r.addEventListener("keydown",n),()=>r.removeEventListener("keydown",n)},[r]);const s=e?.document??null;o(()=>{if(!s)return;const n=n=>{f(n)&&(n.preventDefault(),i.current())};return s.addEventListener("keydown",n),()=>s.removeEventListener("keydown",n)},[s])}export{s as editorRootFocus,f as isSaveShortcut,c as useEaselKeyTarget,m as useEaselSaveKey,i as useEaselUndoKeys};
1
+ import{useEaselHost as n}from"./chunk-MQA7OFRA.js";import{useEaselApi as e,bindUndoKeys as t}from"./chunk-VBOSOH5M.js";import{useState as r,useEffect as o,useRef as u}from"react";function c(e){const t=n(),[u,c]=r(null);return o(()=>c(e.current),[e]),t.ownsDocument?"undefined"==typeof document?null:document:u}function i(r,u){const i=n(),s=e(),f=c(r);o(()=>{if(!i.ownsDocument&&f)return t(f,s,{leaveTyping:!0})},[i,s,f]);const m=u?.document??null;o(()=>{if(!i.ownsDocument&&m)return t(m,s,{leaveTyping:!0})},[i,s,m])}function s(n){return n.ownsDocument?{}:{tabIndex:-1}}function f(n){return!n.altKey&&!n.shiftKey&&(!(!n.metaKey&&!n.ctrlKey)&&("s"===n.key||"S"===n.key||"KeyS"===n.code))}function m(n,e,t){const r=c(n),i=u(t);o(()=>{i.current=t}),o(()=>{if(!r)return;const n=n=>{f(n)&&(n.preventDefault(),i.current())};return r.addEventListener("keydown",n),()=>r.removeEventListener("keydown",n)},[r]);const s=e?.document??null;o(()=>{if(!s)return;const n=n=>{f(n)&&(n.preventDefault(),i.current())};return s.addEventListener("keydown",n),()=>s.removeEventListener("keydown",n)},[s])}export{s as editorRootFocus,f as isSaveShortcut,c as useEaselKeyTarget,m as useEaselSaveKey,i as useEaselUndoKeys};
@@ -0,0 +1,5 @@
1
+ import{usePickFollowsSelection as n}from"./chunk-FHCKFOCD.js";import{slotFieldsOf as e}from"./chunk-TCAAOYQY.js";import{EaselCanvas as t,useSelectedFields as r}from"./chunk-VBOSOH5M.js";import{Inspector as i}from"./chunk-6QSFJCJT.js";import{createContext as o,useContext as u}from"react";import{DesktopIcon as l}from"efficient-shell/icons/efficient";import{jsx as s}from"react/jsx-runtime";var c={kind:"selection"};function f(n){return"selection"===n.kind}function a(n,e){if(f(n)&&f(e))return!0;const t=n,r=e,i=Object.keys(t);return i.length===Object.keys(r).length&&i.every(n=>Object.is(t[n],r[n]))}function d(n){const e=n;return"string"==typeof e.nodeId&&"string"==typeof e.slot}function p(n,t,r){const i=n.slotsOf?.(r);return i||e(t,r.type).map(n=>({slot:n,label:n,rung:!1}))}function m(n,e){return n.isFirst?n.isFirst(e):e.type===n.first}function k(n,e){return n.isLast?n.isLast(e):e.type===n.last}var h={},v=()=>h,g=()=>"",y=()=>null,b=()=>{},O={isLockedBlock:()=>!1,duplicateBlocked:()=>null,nestDepth:()=>0,newSectionNode:()=>null,canAddTo:()=>null,blockIsOffered:()=>!0},C={labelAtLevel:(n,e,t)=>t,descriptions:{},categoryLabel:()=>{},firstSection:null,blockRowName:(n,e)=>e(n.type),plainText:n=>n,Icon:()=>null,Thumbnail:()=>null,useProducts:()=>null},S={options:[{id:"desktop",label:"Desktop",icon:/* @__PURE__ */s(l,{})}],initial:"desktop",fluid:"desktop",widths:{desktop:2e3}},j={read:()=>"sections",write:()=>{},forSelection:(n,e)=>n?"sections":e},w={first:null,last:null,firstGroup:null,lastGroup:null,isSectionGroup:()=>!1,sectionGroupZone:()=>"",panelOf:()=>null};function L(){/* @__PURE__ */
2
+ return s(t,{height:"fill"})}function D(){const{id:n,fields:e,values:t,readOnly:o,onChange:u}=r();/* @__PURE__ */
3
+ return s("div",{className:"es-sidepanel es-sidepanel--right",children:/* @__PURE__ */s(i,{fields:e,values:t,onChange:u,readOnly:o,idPrefix:n})})}var F=o({});function B({parts:n,children:e}){/* @__PURE__ */
4
+ return s(F.Provider,{value:n,children:e})}function N(){return u(F)}function P(){return(N().useOwnerName??g)()}function T(){return(N().useDocumentLabel??y)()}function x(n,e,t,r){return(N().useBridges??v)(n,e,t,r)}function A(n){return(N().useStandaloneBridges??v)(n)}function G(n,e){(N().useDocumentPass??b)(n,e)}function I(){return N().blockRules??O}function H(){return N().blockLook??C}function J(){return N().devices??S}function K(){return N().leftView??j}function Q(){return N().pinned??w}function R(){return N().saveSwitch??!0}function V(e){n(!0===N().pickFollowsSelection,e)}function Y(){return N().storageNamespace||void 0}function M(){return N().styleClipboard??null}function Z(){return N().nodeKeys??!0}function q(){return N().notify??null}function z(){return N().Canvas??L}function E(){return N().CanvasHead??null}function U(){return N().canvasDrag??null}var W=o(null);function X({target:n,children:e}){/* @__PURE__ */
5
+ return s(W.Provider,{value:n,children:e})}function $(){return u(W)}function _(){return N().Inspector??D}export{c as SELECTION_MODE,X as ScreenCanvasTargetProvider,B as ScreenPartsProvider,m as isPinnedFirst,k as isPinnedLast,f as isSelectionMode,d as isSlotMode,a as sameInspectorMode,p as screenSlotsOf,H as useScreenBlockLook,I as useScreenBlockRules,x as useScreenBridges,U as useScreenCanvasDrag,z as useScreenCanvasFrame,E as useScreenCanvasHead,$ as useScreenCanvasTarget,J as useScreenDevices,T as useScreenDocumentLabel,G as useScreenDocumentPass,_ as useScreenInspectorPanel,K as useScreenLeftView,Z as useScreenNodeKeys,q as useScreenNotify,P as useScreenOwnerName,N as useScreenParts,V as useScreenPickFollowsSelection,Q as useScreenPinned,R as useScreenSaveSwitch,Y as useScreenStorageNamespace,M as useScreenStyleClipboard,A as useStandaloneScreenBridges};
@@ -0,0 +1,16 @@
1
+ import{DEFAULT_CANVAS_WORDS as e}from"./chunk-TBY3DFKS.js";import{useResolvedFields as t}from"./chunk-AGWKB77Q.js";import{toItemSelector as n,fromItemSelector as o,useNodeOps as r,parentStep as i,clickPickPart as l,clickPick as s}from"./chunk-RPMSET77.js";import{selectionBox as a,placeWindow as c,offsetOrigin as d,colorRunOf as u,ColorWindow as p,startCanvasTyping as f,textMap as h}from"./chunk-HZSZT3BE.js";import{DEFAULT_COPY_WORDS as m}from"./chunk-KRL3IUV3.js";import{useWords as g}from"./chunk-MFIRYGHW.js";import{setCanvasNonce as v,CANVAS_TYPABLE_EVENT as y,related as w,isTypingTarget as b,upsertCanvasStyle as k,removeCanvasStyle as S,WORDS_CLEAR as C,frameRectToHost as I,CANVAS_TYPING_EVENT as D,drawnBox as E}from"./chunk-YU3WHLGI.js";import{queryAllCopies as x}from"./chunk-LF3FUSCQ.js";import{find as O,ROOT_ID as M,getList as A,remove as R,parseZoneKey as z,move as P,duplicate as $,replaceNode as V,createNode as L,insert as j,normalizeData as N,createResolveCache as B,slotsOf as K,resolveNodeData as Z,ROOT_SLOT as F}from"./chunk-TGZCD6IP.js";import{topLevelSlotKeys as T,fieldsFrom as H,drawnBlockCount as W,defaultsFrom as Y}from"./chunk-KXM6YRG2.js";import{createContext as U,useEffect as q,useContext as G,useRef as Q,useSyncExternalStore as X,useState as J,useReducer as _,useMemo as ee,useCallback as te,useLayoutEffect as ne}from"react";import{jsx as oe,jsxs as re,Fragment as ie}from"react/jsx-runtime";import{createPortal as le}from"react-dom";import{registerModalEscapeInterceptor as se,FloatingBar as ae,TextToolbar as ce,LinkPicker as de}from"efficient-shell/ui";function ue(e){return!["setData","setUi","set"].includes(e.type)}var pe=(e,t,n,o)=>{const r=A(e,t,z(n));return r?.[o]??null},fe=(e,t,n,o,r)=>{const i=pe(e,t,n,o);if(!i)throw new Error(`${r}: nothing at ${n}[${o}]`);return i};function he(e,t){const{selection:o}=e;return{...e.ui,itemSelector:n(e.data,t,o),selectedSlot:o&&"slot"===o.kind?{parentId:o.parentId,slot:o.slot}:null}}function me(e,t,n){return n?"node"===n.kind?O(e,t,n.id)?n:null:n.parentId===M?A(e,t,n)?n:null:O(e,t,n.parentId)&&A(e,t,n)?n:null:null}function ge(e,t,n,r=!1){const{itemSelector:i,selectedSlot:l,...s}=n;let a=e.selection;var c;return"itemSelector"in n&&(a=o(e.data,t,i??null)),"selectedSlot"in n&&(l?a=(c=l)?{kind:"slot",parentId:c.parentId,slot:c.slot}:null:"slot"===a?.kind&&(a=null)),{...e,selection:a,ui:r?s:{...e.ui,...s}}}function ve(e,t,n){const o=ye(e,t,n);if(o===e)return e;const r=me(o.data,n,o.selection);return r===o.selection?o:{...o,selection:r}}function ye(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 ge(e,n,"function"==typeof t.ui?t.ui(he(e,n)):t.ui);case"set":{const r={data:o,ui:he(e,n)},i="function"==typeof t.state?t.state(r):t.state;let l=i.data?{...e,data:i.data}:e;return i.ui&&(l=ge(l,n,i.ui,!0)),l}case"insert":{const r={...z(t.destinationZone),index:t.destinationIndex},i=L(n,t.componentType,{},t.id?{id:t.id}:{});return{...e,data:j(o,n,r,i)}}case"replace":{const r=fe(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:V(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=fe(o,n,t.sourceZone,t.sourceIndex,"duplicate"),i=$(o,n,r.props.id),l=pe(i,n,t.sourceZone,t.sourceIndex+1);return{...e,data:i,selection:l?{kind:"node",id:l.props.id}:e.selection}}case"reorder":return ye(e,{...t,type:"move",sourceZone:t.destinationZone},n);case"move":{if(t.sourceZone===t.destinationZone&&t.sourceIndex===t.destinationIndex)return e;const r=pe(o,n,t.sourceZone,t.sourceIndex);if(!r)return e;const i={...z(t.destinationZone),index:t.destinationIndex};return{...e,data:P(o,n,r.props.id,i)}}case"remove":{const r=fe(o,n,t.zone,t.index,"remove");return{...e,data:R(o,n,r.props.id)}}default:return e}}var we={drag:!0,duplicate:!0,delete:!0,edit:!0,insert:!0},be={leftSideBarVisible:!0,rightSideBarVisible:!0,arrayState:{},componentList:{},isDragging:!1,previewMode:"edit",viewports:{current:{width:360,height:"auto"},options:[],controlsVisible:!0},field:{focus:null}},ke=0,Se=()=>`history-${ke+=1}`;function Ce(e){let t=e.config;const r=e.now??(()=>Date.now()),i=e.historyCoalesceMs??250;let l=e.permissions??{};const s=N(e.data,t);let a=s,c={data:s,selection:null,ui:{...be}};if(e.ui){const{itemSelector:n,selectedSlot:r,...i}=e.ui;c={data:s,selection:r?{kind:"slot",...r}:o(s,t,n??null),ui:{...be,...i}}}let d=[{core:c,at:-1/0,sealed:!0,id:Se()}],u=0;const p=e=>{const t=d[u],n=r();!e&&u===d.length-1&&u>0&&!t.sealed&&n-t.at<i?d=[...d.slice(0,u),{...t,core:c,at:n}]:(d=[...d.slice(0,u+1),{core:c,at:n,sealed:e,id:Se()}],u=d.length-1)},f=/* @__PURE__ */new Set;let h=null,m=null,g=0,v=null,y=!1;const w=()=>{for(const e of[...f])e()},b=()=>{d=[...d.slice(0,u),{...d[u],core:c},...d.slice(u+1)]},k=(t,n)=>{g>0?y=y||n:(n?p(!1):c!==t&&b(),c.data!==t.data&&e.onChange?.(c.data),c!==t&&w())},S=e=>{const n=c;if(c=ve(c,e,t),c===n)return;const o=e.recordHistory??ue(e);k(n,o&&c.data!==n.data)},C=t=>{0===g&&(v=c,y=!1),g+=1;try{t()}catch(e){throw g-=1,0===g&&v&&(c=v,v=null),e}if(g-=1,g>0||!v)return;const n=v;v=null,y&&c.data!==n.data?p(!0):c!==n&&b(),c.data!==n.data&&e.onChange?.(c.data),c!==n&&w()},I=e=>{const n=c,o=me(c.data,t,e);var r,i;(r=o,i=c.selection,r===i||r&&i&&r.kind===i.kind&&("node"===r.kind&&"node"===i.kind?r.id===i.id:"slot"===r.kind&&"slot"===i.kind&&r.parentId===i.parentId&&r.slot===i.slot))||(c={...c,selection:o},k(n,!1))},D=t=>{const n=c;u=t,c=d[u].core,c.data!==n.data&&e.onChange?.(c.data),c!==n&&w()},E=()=>(e={})=>{const n=e.root?t.root?.permissions:t.components[e.item?.type??e.type??""]?.permissions;return{...we,...l,...n}};let x=E();const M=B(),R={resolveCache:M,async resolveAll({trigger:e="load",metadata:n}={}){const o=c.data,r={type:"root",props:{...o.root.props??{}}},i=[...o.content,...Object.values(o.zones??{}).flat()],[l,...s]=await Promise.all([Z(r,t,{cache:M,trigger:e,metadata:n}),...i.map(o=>Z(o,t,{cache:M,trigger:e,metadata:n}))]);C(()=>{const n=c;let r=c.data;s.forEach((e,n)=>{if(!e.didChange)return;const l=i[n].props.id,s=O(r,t,l)?.node;s&&s===O(o,t,l)?.node&&(r=V(r,t,l,e.node))}),l.didChange&&r.root===o.root&&(r={...r,root:{...r.root,props:l.node.props,readOnly:l.node.readOnly??r.root.readOnly}}),r!==c.data&&("load"===e&&c.data===a&&(a=r),c={...c,data:r,selection:me(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 i=await Z(r,t,{cache:M,trigger:n,metadata:o});if(!i.didChange)return!1;let l=!1;return C(()=>{const n=c;if(O(c.data,t,e)?.node!==r)return;const o=V(c.data,t,e,i.node);o!==c.data&&(c={...c,data:o,selection:me(o,t,c.selection)},k(n,!1),l=!0)}),l},get config(){return t},get loaded(){return a},getState(){if(h&&m===c)return h;const e=c,o={data:e.data,ui:he(e,t)},r="node"===e.selection?.kind?O(e.data,t,e.selection.id)?.node??null:null;return h={appState:o,selection:e.selection,selectedItem:r,config:t,dispatch:S,history:{back:()=>R.undo(),forward:()=>R.redo(),hasPast:u>0,hasFuture:u<d.length-1,histories:d.map(e=>({id:e.id,state:{data:e.core.data,ui:he(e.core,t)}})),index:u,setHistoryIndex:e=>{e>=0&&e<d.length&&e!==u&&D(e)}},getPermissions:x,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 A(e,t,{parentId:o,slot:r})?.[n.index]}(e.data,t,n),getSelectorForId:o=>{const r=n(e.data,t,{kind:"node",id:o});return r?{index:r.index,zone:r.zone??"root:default-zone"}:void 0}},m=e,h},subscribe:e=>(f.add(e),()=>{f.delete(e)}),dispatch:S,batch:C,group:()=>{const e=u,t=d[e].id;let n=!0;return{close:()=>{if(!n)return;if(n=!1,d[e]?.id!==t)return;if(u<=e+1)return void(u===e+1&&(d=[...d.slice(0,u),{...d[u],sealed:!0},...d.slice(u+1)]));const o=d[u];d=[...d.slice(0,e+1),{...o,sealed:!0},...d.slice(u+1)],u=e+1}}},select:e=>I(e?{kind:"node",id:e}:null),selectSlot:e=>I(e?{kind:"slot",parentId:e.parentId,slot:e.slot}:null),run(e){C(()=>{const n=c,o=void 0===e.select?c.selection:e.select;c={...c,data:e.data,selection:me(e.data,t,o)},k(n,e.data!==n.data)})},load(e,n={}){const o=c,r=N(e,t);c={...c,data:r,selection:me(r,t,n.selection??c.selection)},a=r,n.keepHistory||(d=[{core:c,at:-1/0,sealed:!0,id:Se()}],u=0),c!==o&&w()},undo(){u>0&&D(u-1)},redo(){u<d.length-1&&D(u+1)},setPermissions(e){(function(e,t){if(e===t)return!0;const n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>e[n]===t[n])})(e,l)||(l=e,x=E(),h=null,w())},setConfig(e){e!==t&&(t=e,x=E(),h=null,w())}};return R}function Ie(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&&b(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 De=U(null),Ee=U(!0);function xe({easel:e,hotkeys:t=!0,resolveOnMount:n=!0,children:o}){return q(()=>{n&&e.resolveAll()},[e,n]),q(()=>{if(t&&"undefined"!=typeof document)return Ie(document,e)},[e,t]),/* @__PURE__ */oe(De.Provider,{value:e,children:/* @__PURE__ */oe(Ee.Provider,{value:t,children:o})})}function Oe(){const e=G(De);if(!e)throw new Error("useEasel: no <EaselProvider> above this component");return e}function Me(e){const t=Oe(),n=Q({view:null,selector:null,value:void 0,has:!1}),o=()=>{const o=t.getState(),r=n.current;if(r.has&&r.view===o&&r.selector===e)return r.value;const i=e(o);return r.has&&Object.is(r.value,i)?(n.current={view:o,selector:e,value:r.value,has:!0},r.value):(n.current={view:o,selector:e,value:i,has:!0},i)};return X(t.subscribe,o,o)}function Ae(){return function(e){return Me(e)}}var Re=["--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"],ze="host-tokens";function Pe(e,t){const n=function(e){const t=e.ownerDocument.defaultView;if(!t)return"";const n=t.getComputedStyle(e),o=[];for(const e of Re){const t=n.getPropertyValue(e).trim();t&&o.push(`${e}: ${t};`)}return o.length?`:root { ${o.join(" ")} }`:""}(e);n?k(t,ze,n):S(t,ze)}var $e="data-easel-block",Ve="data-easel-dropzone",Le={},je="data-es-mirror",Ne="undefined"==typeof window?q:ne;function Be(e,t,n){for(const e of Array.from(t.head.querySelectorAll(`[${je}]`)))e.remove();for(const o of Array.from(e.head.querySelectorAll('style, link[rel="stylesheet"]'))){const e=o.cloneNode(!0);e.setAttribute(je,""),n&&e.setAttribute("nonce",n),t.head.appendChild(e)}}function Ke({children:t,id:n="preview-frame",title:o,className:r,style:i,mirrorStyles:l=!0,onDocument:s,height:a="auto",nonce:c}){const d=g("canvas",e),u=Q(null),[p,f]=J(null);return Ne(()=>{const e=u.current,t=p?.ownerDocument.defaultView;if("auto"!==a||!e||!p||!t)return;const n=()=>{e.style.height=`${Math.ceil(p.getBoundingClientRect().height)}px`};n();const o=t.ResizeObserver,r=o?new o(n):null;return r?.observe(p),()=>r?.disconnect()},[p,a]),Ne(()=>{let e=u.current?.contentDocument;if(!e)return;"CSS1Compat"!==e.compatMode&&(e.open(),e.write("<!DOCTYPE html><html><head></head><body></body></html>"),e.close(),e=u.current?.contentDocument??e),e.body||e.documentElement.appendChild(e.createElement("body")),e.body.style.margin="0";const t=e.createElement("div");t.setAttribute("data-easel-entry",""),t.id="frame-root","fill"===a&&t.classList.add("es-frame-fill"),e.body.appendChild(t),v(e,c),f(t),s?.(e);let n=null;const o=u.current?.ownerDocument;if(l&&o){Be(o,e,c);const t=o.defaultView;t&&"MutationObserver"in t&&(n=new t.MutationObserver(()=>Be(o,e,c)),n.observe(o.head,{childList:!0,subtree:!0,characterData:!0}))}let r=null;const i=u.current;if(i&&o){Pe(i,e);const t=o.defaultView;if(t&&"MutationObserver"in t){r=new t.MutationObserver(()=>Pe(i,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,i.closest(".es-editor")])e&&r.observe(e,n)}}return()=>{n?.disconnect(),r?.disconnect(),t.remove(),f(null),s?.(null)}},[]),/* @__PURE__ */oe("iframe",{ref:u,id:n,title:o??d.frame,className:["es-canvas-frame","fill"===a?"is-fill":"",r??""].filter(Boolean).join(" "),style:i,children:p?le(t,p):null})}var Ze=U(null),Fe=U(Le),Te=[];function He({parentId:e,slot:t,className:n,style:o,minEmptyHeight:r=128,minEmptyWidth:i=120}){const l=Oe(),s=Me(n=>A(n.appState.data,l.config,{parentId:e,slot:t})??Te),a=Me(t=>"node"===t.selection?.kind&&t.selection.id===e&&e!==M),c=Me(n=>"slot"===n.selection?.kind&&n.selection.parentId===e&&n.selection.slot===t),d=G(Ze),u=["es-zone"];return s.length&&u.push("has-children"),e===M&&u.push("is-root"),(a||c)&&u.push("is-area-selected"),null!==d&&d===e&&e!==M&&u.push("is-hovering-area"),n&&u.push(n),/* @__PURE__ */oe("div",{className:u.join(" "),[Ve]:`${e}:${t}`,style:{...o,"--min-empty-height":`${r}px`,"--min-empty-width":`${i}px`},children:s.map(e=>/* @__PURE__ */oe(Je,{node:e},e.props.id))})}function We(e,t,n,o){const r=ee(()=>{const n={};for(const o of T(H(e)))n[o]=Object.assign(function(e={}){/* @__PURE__ */
2
+ return oe(He,{parentId:t,slot:o,...e})},{blockCount:0});return n},[e,t]);for(const e of Object.keys(r))r[e].blockCount=W(n[e],o);return r}function Ye(e){return ee(()=>function({zone:t,...n}){/* @__PURE__ */
3
+ return oe(He,{parentId:e,slot:t,...n})},[e])}var Ue=["top","bottom","zIndex"];function qe(e,t,n){e.style[t]!==n&&(e.style[t]=n)}function Ge(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));qe(e,"position",t?"sticky":"relative");for(const n of Ue)qe(e,n,t?.[n]??"");return!!t}var Qe="data-es-canvas-relative";function Xe(e){e.hasAttribute(Qe)&&("relative"===e.style.position&&(e.style.position=""),e.removeAttribute(Qe));const t=e.ownerDocument.defaultView?.getComputedStyle(e).position;return t&&"static"!==t?"sticky"===t:(e.style.position||(e.style.position="relative",e.setAttribute(Qe,"")),!1)}function Je({node:e}){const t=Oe().config,n=t.components[e.type],o=e.props.id,r=Q(null),i=function(e,t){return ee(()=>n=>{const o=t.current;o&&o!==n&&(o.removeAttribute($e),o.removeAttribute("data-easel-dnd")),t.current=n,n&&(n.setAttribute($e,e),n.setAttribute("data-easel-dnd",e),Xe(n))},[e,t])}(o,r),l=Q(null),s=!!n?.inline;!function(e,t){const n=Q(!1),o=Q(()=>{});o.current=()=>{const o=e(),i=n.current;n.current=!!o&&t(o),i!==n.current&&r.current()};const r=Q(()=>{});Ne(()=>o.current()),Ne(()=>{const t=e(),i=t?.ownerDocument.defaultView;if(!t||!i)return;const l=()=>o.current();i.addEventListener("resize",l);const s=i.ResizeObserver,a=s?new s(l):null;a?.observe(t);let c=null;return r.current=()=>{c?.disconnect(),c=null;const e=t.ownerDocument.documentElement;n.current&&e&&i.MutationObserver&&(c=new i.MutationObserver(l),c.observe(e,{attributes:!0}))},r.current(),()=>{i.removeEventListener("resize",l),a?.disconnect(),c?.disconnect(),r.current=()=>{}}},[])}(()=>s?r.current:l.current,e=>s?Xe(e):Ge(e));const a=G(Fe),c=We(n,o,e.props,t.components),d=Ye(o);if(!n?.render)return null;const u=n.render,p={...Y(n),...e.props,...c},f={renderDropZone:d,isEditing:!0,dragRef:n.inline?i:null,metadata:{...a,...n.metadata}};return n.inline?/* @__PURE__ */oe(u,{...p,editor:f,editMode:!0}):
4
+ /* @__PURE__ */oe("div",{ref:l,[$e]:o,"data-easel-dnd":o,style:{position:"relative"},children:/* @__PURE__ */oe(u,{...p,editor:f,editMode:!0})})}function _e({metadata:e}){const t=Me(e=>e.config),n=Me(e=>e.appState.data.root).props??{},o=t.root?.render,r=We(t.root,M,n,t.components),i=Ye(M),l=/* @__PURE__ */oe(He,{parentId:M,slot:F}),s=o?/* @__PURE__ */oe(o,{id:"page-root",...n,...r,editor:{renderDropZone:i,isEditing:!0,dragRef:null,metadata:e??{}},editMode:!0,children:l}):l;/* @__PURE__ */
5
+ return oe(Fe.Provider,{value:e??Le,children:s})}var et=U(void 0),tt=U(void 0);function nt(e,t,n,o){const r=O(e,t,n);return!!r&&(K(r.node,t).length>0||!1===o.whole)}var ot=U(void 0);function rt({element:e}){const t=Q(null),n=st(t,e?()=>e:null,e);/* @__PURE__ */
6
+ return oe("div",{ref:t,"aria-hidden":"true",className:"es-canvas-outline is-hover is-hover-part",style:n?{position:"absolute",top:n.top,left:n.left,width:n.width,height:n.height}:{display:"none"}})}var it={"--es-words-clear":`${C}px`};function lt({element:e,words:t=!1}){const n=Q(null),o=st(n,e?()=>e:null,e);/* @__PURE__ */
7
+ return oe("div",{ref:n,"aria-hidden":"true",className:"es-canvas-outline is-selected is-selected-part"+(t?" is-words":""),style:o?{position:"absolute",top:o.top,left:o.left,width:o.width,height:o.height,...it}:{display:"none"}})}function st(e,t,n){return ct(e,t?e=>{const n=t(e);return n?[n]:[]}:null,n)[0]??null}var at=[];function ct(e,t,n){const[o,r]=J(at),i=Q(t);return i.current=t,Ne(()=>{const t=e.current?.ownerDocument,n=t?.defaultView;if(!t||!n||!i.current)return void r(at);let o=0;const l=()=>{o=0;const n=e.current?.parentElement??null,l=(i.current?i.current(t):[]).map(e=>function(e,t){if(!e||!t)return null;const n=E(e),o=t.getBoundingClientRect();return{top:n.top-o.top,left:n.left-o.left,width:n.width,height:n.height}}(e,n)).filter(e=>null!==e);r(e=>{return(t=e)===(n=l)||t.length===n.length&&t.every((e,t)=>function(e,t){return e===t||!!e&&!!t&&e.top===t.top&&e.left===t.left&&e.width===t.width&&e.height===t.height}(e,n[t]))?e:l.length?l:at;var t,n})},s=()=>{o||(o=(n.requestAnimationFrame??(e=>n.setTimeout(e,16)))(l))};l();const a="MutationObserver"in n?new n.MutationObserver(s):null;a?.observe(t.body,{childList:!0,subtree:!0,attributes:!0,characterData:!0});const c="ResizeObserver"in n?new n.ResizeObserver(s):null;return c?.observe(t.documentElement),n.addEventListener("resize",s),()=>{a?.disconnect(),c?.disconnect(),n.removeEventListener("resize",s),o&&(n.cancelAnimationFrame??n.clearTimeout)(o)}},[n]),o}function dt({id:e,kind:t,overlay:n}){const o=Q(null),r=G(tt),i=null!==e&&!0===r?.(e),l=ct(o,e?t=>x(t,`[${$e}="${t.defaultView?.CSS?.escape?t.defaultView.CSS.escape(e):e}"]`):null,e),[s,...a]=l,c=`es-canvas-outline is-${t}${i?" is-shared":""}`,d=e=>({position:"absolute",top:e.top,left:e.left,width:e.width,height:e.height}),u=/* @__PURE__ */re(ie,{children:[
8
+ /* @__PURE__ */oe("div",{ref:o,"aria-hidden":"true",className:c,style:s?d(s):{display:"none"}}),a.map((e,t)=>/* @__PURE__ */oe("div",{"aria-hidden":"true",className:c,style:d(e)},t))]});return n&&e?/* @__PURE__ */oe(n,{componentId:e,kind:t,children:u}):u}function ut(e,t,n){const o=h(e,n),r=o.text.length,i=e.ownerDocument;if(!t)return[r,r];let l=null;const s=i.caretPositionFromPoint?.(t.x,t.y);if(s&&e.contains(s.offsetNode))l=o.at(s.offsetNode,s.offset);else{const n=i.caretRangeFromPoint?.(t.x,t.y);n&&e.contains(n.startContainer)&&(l=o.at(n.startContainer,n.startOffset))}if(null===l)return[r,r];const a=o.text;let c=l,d=l;for(;c>0&&!/\s/.test(a[c-1]);)c-=1;for(;d<a.length&&!/\s/.test(a[d]);)d+=1;return[c,d]}function pt({s:e,element:t,toolbar:n,label:o,keys:r}){const i=g("copy",m),l=e.pressed(),s=new Set(n.offered),f=n.colors&&n.colors.length>0?n.colors:null,h=Q(null),[v,y]=J(!1),[w,b]=J(null),k=v||null!==w,S=()=>{e.hold(),y(!1),b({href:e.pressed().href})},C=()=>{y(!1),b(null),e.resume()};ne(()=>{r.current={escape:()=>!!k&&(C(),!0),link:()=>!!s.has("link")&&(S(),!0)}}),ne(()=>()=>{r.current=null},[r]);const D=Q(C);D.current=C,q(()=>{if(v)return se(e=>{const t=h.current;return!!("Escape"===e.key&&t&&e.target instanceof Node&&t.contains(e.target))&&(D.current(),!0)},()=>h.current?.querySelector(".es-copy-colors"))},[v]),q(()=>{const n=h.current;if(!k||!n)return;const o=/* @__PURE__ */new Set([n.ownerDocument]),r=t();r&&o.add(r.ownerDocument);const i=o=>{const r=o.target;if(r&&n.contains(r))return;y(!1),b(null);const i=t();r&&i&&i.contains(r)?e.release():e.stop("outside")};for(const e of o)e.addEventListener("pointerdown",i,!0);return()=>{for(const e of o)e.removeEventListener("pointerdown",i,!0)}},[k,e,t]),ne(()=>{const e=h.current,n=e?.querySelector(".rosh-tb-wrap > .es-copy-pop"),o=t();if(!(k&&e&&n&&o))return;const r=o.ownerDocument.defaultView?.getSelection()??null,i=r&&r.rangeCount>0&&o.contains(r.getRangeAt(0).startContainer)?r.getRangeAt(0):null,l=(i?a(i,o):null)??(()=>{const e=o.getBoundingClientRect();return{left:e.left,top:e.top,right:e.right,bottom:e.bottom}})(),s=o.ownerDocument.defaultView?.frameElement,u=s?I(s,{left:l.left,top:l.top,width:l.right-l.left,height:l.bottom-l.top}):{left:l.left,top:l.top,width:l.right-l.left,height:l.bottom-l.top},p=o.getBoundingClientRect(),f=s?I(s,{left:p.left,top:p.top,width:p.width,height:p.height}):{left:p.left,top:p.top,width:p.width,height:p.height},m=(e.closest("[data-floating-bar]")??e).getBoundingClientRect(),g={left:u.left,right:u.left+u.width,top:Math.min(u.top,f.top-6,m.top),bottom:Math.max(u.top+u.height,f.top+f.height+6,m.bottom)},v=e.ownerDocument.documentElement,y=(s??o.closest(".es-canvas")??o).getBoundingClientRect(),w={left:Math.max(0,y.left),top:Math.max(0,y.top),right:Math.min(v.clientWidth||y.right,y.right),bottom:Math.min(v.clientHeight||y.bottom,y.bottom)};if(w.right<=w.left||w.bottom<=w.top||0===n.offsetWidth)return;const b=c({anchor:g,size:{width:n.offsetWidth,height:n.offsetHeight},within:{left:y.left,top:y.top,right:y.right,bottom:y.bottom},clip:w,parent:d(n)});n.style.top=`${b.top}px`,n.style.left=`${b.left}px`,n.style.setProperty("--es-pop-point",`${b.point}px`),n.dataset.side=b.above?"above":"below"});const E=f?{run:u(l.color,f),open:v,onToggle:()=>{b(null),v?C():(e.hold(),y(!0))}}:void 0;/* @__PURE__ */
9
+ return oe(ae,{anchor:()=>{const e=t();if(!e)return null;const n=e.getBoundingClientRect(),o=e.ownerDocument.defaultView?.frameElement,r=o?I(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__ */oe("div",{ref:h,children:/* @__PURE__ */oe(ce,{layout:"row",offered:s,pressed:l.marks,onMark:t=>{"link"===t?S():e.press(t)},color:E,linkOpen:null!==w,list:{pressed:l.list,onList:t=>e.list(t)},clear:l.clearable?{onClear:()=>e.clear()}:void 0,alignment:n.alignment,letterCase:n.letterCase,last:n.lastTool?.({className:"rosh-tb-btn",disabled:!1,selected:l.selected,keepCaret:t=>{t.preventDefault(),e.hold()},insert:t=>e.insert(t)}),windows:/* @__PURE__ */re(ie,{children:[v&&f?/* @__PURE__ */oe(p,{colors:f,current:l.color,words:i.colors??m.colors,onPick:t=>e.color(t)}):null,w?
10
+ /* @__PURE__ */oe(de,{className:"es-copy-link es-copy-pop",value:w.href??"",onApply:t=>{b(null),e.link(t)},onRemove:null!==w.href?()=>{b(null),e.link(null)}:void 0,onCancel:C}):null]})})})})}function ft({element:e,which:t}){const n=Q(null),o=st(n,()=>e(),t);/* @__PURE__ */
11
+ return oe("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,...it}:{display:"none"}})}function ht({frame:t=!0,className:n,style:o,metadata:r,mirrorStyles:a,onDocument:c,height:d,title:u,nonce:p,hotkeys:h,frameWrapper:m,overlay:v,children:b,typing:k,passThrough:S}){const C=Oe(),I=G(et),E=S??I,x=G(Ee),M=g("canvas",e),A=h??x,[R,z]=J(void 0),P=Me(e=>"node"===e.selection?.kind?e.selection.id:null),[$,V]=J(null),[L,j]=J(null),N=G(ot),[,B]=_(e=>e+1,0),Z=e=>{N?.select(e),B()},[F,T]=J(null),H=Q(null),[,W]=J(0),Y=Q(k);Y.current=k;const U=Q(null),X=Q(null),ee=()=>{if(!P)return null;const e=Y.current?.atSelection?.()?.element()??null;if(!e)return null;const t=X.current?.ownerDocument;if(N){const n=N.selected()&&t?N.selectedPart?.(t)??null:null;return n&&w(n.element,e)?n.element:null}const n=O(C.getState().appState.data,C.config,P);return n&&0===K(n.node,C.config).length?e:null},te=Me(e=>e.appState.data),ne=N?.selected()??null;q(()=>{const e=X.current?.ownerDocument,t=e?.defaultView?.CustomEvent;if(!e||!t)return;const n=P&&!F&&Y.current?.atSelection?.()?P:null,o=n?ee():null;e.dispatchEvent(new t(y,{detail:o?{id:n,words:o}:{id:n}}))},[P,F,te,ne]);const ie=e=>{const t=X.current?.ownerDocument,n=t?.defaultView?.CustomEvent;t&&n&&t.dispatchEvent(new n(D,{detail:{typing:e}}))},le=(e,t)=>{H.current?.s.stop("stop");const n=e.element();if(!n)return!1;const o=C.group(),r=e.element,i=f({element:r,value:e.value,rules:e.rules,multiline:e.multiline,skip:e.skip,caret:ut(n,t,e.skip),write:e.write,remount:e.remount,onSelect:()=>W(e=>e+1),onEscape:()=>U.current?.escape()??!1,onLinkKey:()=>U.current?.link()??!1,end:e=>{o.close(),H.current?.element===r&&(H.current=null),T(null),ie(!1),Y.current?.onChange?.({typing:!1,why:e})}});if(!i)return o.close(),!1;const l=n.closest?.(`[${$e}]`)?.getAttribute($e);return l&&C.select(l),H.current={s:i,element:r,target:e},T(()=>r),V(null),ie(!0),Y.current?.onChange?.({typing:!0,element:n}),!0};q(()=>()=>H.current?.s.stop("stop"),[]);const se=e=>{const t=H.current?.element();return Boolean(t&&t.contains(e))},ae=(e,t)=>nt(C.getState().appState.data,C.config,e,t),ce=e=>{const t=e.closest?.(`[${$e}]`)?.getAttribute($e);if(!t)return;const n=C.getState(),o="node"===n.selection?.kind?n.selection.id:null,r=N?.partAt(e,t)??null;if(r){const e=l(n.appState.data,C.config,t,r.id,o,N?.selected()??null,E);if(e)return{node:e.node,part:e.part?r:null}}return{node:s(n.appState.data,C.config,t,o,E)??t,part:null}},de=e=>{if("Enter"!==e.key||e.defaultPrevented||e.shiftKey||e.metaKey||e.ctrlKey||e.altKey)return;if(H.current)return;const t=e.target;if(t?.isContentEditable||t?.closest?.("input, textarea, select, button"))return;const n=Y.current?.atSelection?.();n&&le(n,null)&&e.preventDefault()},ue=X.current?.ownerDocument??null,pe=N?.selected()&&ue&&P?N.selectedPart?.(ue)??null:null,fe=pe&&P&&ae(P,pe)?pe.element:null,he=F?null:ee(),me=/* @__PURE__ */re("div",{ref:X,className:"es-canvas-content",style:{position:"relative"},onClick:e=>{const t=e.target;if(t.closest?.("a[href]")&&e.preventDefault(),H.current){if(se(t))return;H.current.s.stop("outside")}const n=t.ownerDocument?.getSelection?.();n&&n.rangeCount>0&&n.isCollapsed&&n.removeAllRanges();const o=ce(t);if(void 0!==o)return C.select(o.node),void(N&&(o.part?.id??null)!==N.selected()&&Z(o.part?.id??null));t.hasAttribute?.(Ve)||(C.select(null),N?.selected()&&Z(null))},onDoubleClick:e=>{const t=Y.current;if(!t||se(e.target))return;const n=t.at(e.target);n&&le(n,{x:e.clientX,y:e.clientY})&&e.preventDefault()},onKeyDown:e=>de(e),onMouseOver:e=>{if(H.current)return;const t=ce(e.target),n=!!t?.part&&ae(t.node,t.part),o=t?.part&&n&&t.part.id!==N?.selected()?t.part:null,r=!t||t.part&&n?null:t.node;r!==$&&V(r),o?.id===L?.id&&o?.element===L?.element||j(o)},onMouseLeave:()=>{V(null),j(null)},children:[
12
+ /* @__PURE__ */oe(Ze.Provider,{value:$,children:/* @__PURE__ */oe(_e,{metadata:r})}),
13
+ /* @__PURE__ */re("div",{className:"es-canvas-outlines",style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:[
14
+ /* @__PURE__ */oe(dt,{id:!F&&$&&$!==P?$:null,kind:"hover",overlay:v}),N?/* @__PURE__ */oe(rt,{element:F||!L||L.id===N.selected()?null:L.element}):null,he||fe?/* @__PURE__ */oe(lt,{element:F?null:he??fe,words:null!==he}):null,
15
+ /* @__PURE__ */oe(dt,{id:F||fe||he?null:P,kind:"selected",overlay:v}),F?/* @__PURE__ */oe(ft,{element:()=>{const e=F?.()??null;return e?pe&&w(pe.element,e)?pe.element:e:null},which:pe?.element??F}):null]}),b]}),ge=m?/* @__PURE__ */oe(m,{document:R,children:me}):me;q(()=>{if(R&&A)return Ie(R,C)},[R,A,C]),q(()=>{if(!R)return;const e=e=>{if("Enter"===e.key)return void de(e);if("Escape"!==e.key||e.defaultPrevented)return;const t=e.target;if(t?.isContentEditable||t?.closest?.("input, textarea, select"))return;const n=C.getState();if("node"!==n.selection?.kind)return;if(N?.selected())return void Z(null);const o=i(n.appState.data,C.config,n.selection);"node"===o?.kind&&C.select(o.id)};return R.addEventListener("keydown",e),()=>R.removeEventListener("keydown",e)},[R,C,N]);/* @__PURE__ */
16
+ return re("div",{className:"es-canvas"+(n?` ${n}`:""),style:o,"data-easel-preview":"","data-es-typing":F?"":void 0,children:[F&&H.current?.target.toolbar?/* @__PURE__ */oe(pt,{s:H.current.s,element:H.current.element,toolbar:H.current.target.toolbar,label:M.textTools,keys:U}):null,t?/* @__PURE__ */oe(Ke,{mirrorStyles:a,onDocument:e=>{z(e??void 0),c?.(e)},height:d,title:u,nonce:p,children:ge}):/* @__PURE__ */oe("div",{id:"preview-frame","data-easel-entry":"",children:ge})]})}function mt(e={}){const t=Oe(),n=Me(e=>e.appState.data);return r({...e,data:n,config:t.config,commit:(e,{select:n})=>t.run({data:e,select:n})})}function gt(){return yt(Me(e=>e.selectedItem))}function vt(){return yt(null)}function yt(e){const n=Oe(),o=Me(e=>e.config),r=n.resolveCache,i=Me(e=>e.appState.data.root),l=e?e.props.id:"root",s=i.props??{},a=ee(()=>e||{type:"root",props:s},[e,s]),c=e?o.components[e.type]:o.root,d=n.getState(),u=e?O(d.appState.data,o,l):null,p=u&&"root"!==u.place.parentId?u.place.parentId:null,f=p?d.getItemById(p)??null:null,{fields:h}=t({id:l,node:a,block:c,parent:f,appState:d.appState}),m=Me(t=>!1===t.getPermissions(e?{item:e}:{root:!0}).edit),g=te(e=>{(async()=>{const t=n.getState();if("root"!==l){const i=t.getItemById(l),s=t.getSelectorForId(l);if(!i||!s)return;const a={...i,props:{...i.props,...e}},{node:c}=await Z(a,o,{cache:r,trigger:"replace"}),d=n.getState().getSelectorForId(l);if(!d)return;return void n.dispatch({type:"replace",destinationZone:d.zone??"root:default-zone",destinationIndex:d.index,data:c})}const i=t.appState.data.root.props??{},{node:s}=await Z({type:"root",props:{...i,...e}},o,{cache:r,trigger:"replace"});n.dispatch({type:"replaceRoot",root:{props:s.props,readOnly:s.readOnly},recordHistory:!0})})()},[n,o,r,l]),v=te((e,t)=>g({[e]:t}),[g]);return{id:l,node:a,fields:h,values:a.props,readOnly:m,onChange:v,onChangeMany:g}}export{Ke as CanvasFrame,ot as CanvasPartsContext,et as CanvasPassThroughContext,tt as CanvasSharedContext,be as DEFAULT_UI,ht as EaselCanvas,xe as EaselProvider,_e as EditDocument,Ie as bindUndoKeys,Ce as createEasel,Ae as createUseEasel,nt as partHasOwnBox,ue as recordsByDefault,ve as reduce,he as uiView,Me as useEasel,Oe as useEaselApi,mt as useEaselNodeOps,vt as useRootFields,gt as useSelectedFields,me as validSelection};
@@ -1,2 +1,2 @@
1
- import{ScreenPartsProvider as t}from"./chunk-GXRS52JD.js";import{useEaselHost as e}from"./chunk-MQA7OFRA.js";import{createEasel as r,EaselProvider as o}from"./chunk-KXTXYINN.js";import{useState as n,useEffect as s}from"react";import{jsx as a}from"react/jsx-runtime";function i({config:i,data:c,onChange:m,permissions:p,parts:f,children:u}){const[d]=n(()=>r({config:i,data:c,permissions:p}));s(()=>{d.setConfig(i)},[d,i]),s(()=>{if(!m)return;let t=d.getState().appState.data,e=!1;return d.subscribe(()=>{const r=d.getState().appState.data;r!==t&&(t=r,(e||r!==d.loaded)&&(e=!0,m(r)))})},[d,m]),s(()=>{p&&d.setPermissions(p)},[d,p]);const h=e();/* @__PURE__ */
1
+ import{ScreenPartsProvider as t}from"./chunk-TGSK5VII.js";import{useEaselHost as e}from"./chunk-MQA7OFRA.js";import{createEasel as r,EaselProvider as o}from"./chunk-VBOSOH5M.js";import{useState as n,useEffect as s}from"react";import{jsx as a}from"react/jsx-runtime";function i({config:i,data:c,onChange:m,permissions:p,parts:f,children:u}){const[d]=n(()=>r({config:i,data:c,permissions:p}));s(()=>{d.setConfig(i)},[d,i]),s(()=>{if(!m)return;let t=d.getState().appState.data,e=!1;return d.subscribe(()=>{const r=d.getState().appState.data;r!==t&&(t=r,(e||r!==d.loaded)&&(e=!0,m(r)))})},[d,m]),s(()=>{p&&d.setPermissions(p)},[d,p]);const h=e();/* @__PURE__ */
2
2
  return a(o,{easel:d,hotkeys:h.ownsDocument,children:/* @__PURE__ */a(t,{parts:f,children:u})})}export{i as ScreenStoreProvider};
@@ -0,0 +1 @@
1
+ var n="__device";function o(o){const r=o?.[n];return r??null}var r="__noControl";function t(n){const o=n?.[r];return o??null}export{n as DEVICE_FIELD_MARKER,r as NO_CONTROL_FIELD,o as deviceMetaOf,t as noControlMetaOf};