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
package/README.md CHANGED
@@ -1013,6 +1013,18 @@ const easel = createEasel<EaselConfig>({ config, data, onChange: (doc) => autosa
1013
1013
  `useSelectedFields().readOnly` or `useEasel((s) => s.getPermissions)`
1014
1014
  re-renders when the permissions change, and only then; the same permissions
1015
1015
  again tell nobody, so it is safe to call from an effect.
1016
+ - **One node's panel writes run in turn.** `onChange` and `onChangeMany` on
1017
+ `useSelectedFields()` wait for that node's resolver, and the writes made
1018
+ during the wait become the next write. `values` shows them at once.
1019
+ `onChangeMany` also takes a function of the latest props (`FieldsPatch`).
1020
+ A press that reads the document waits first: `useSettledAction(action)` (the
1021
+ writes and their render, one press at a time, busy meanwhile, then the latest
1022
+ render's press; `ScreenChrome` passes every main action and Save now through
1023
+ it, and a layer's own `barMain` must do the same), `useSettledPress()` or
1024
+ `writesSettled(easel)`. A resolver error loses its group. A
1025
+ write whose resolver does not answer in 60 seconds lands without the answer;
1026
+ `subscribeLateWrites(easel, listener)` tells the host (`ScreenChrome` shows a
1027
+ toast).
1016
1028
  - **A panel that edits the root beside a selection wraps its rows in
1017
1029
  `RootHostScope`.** A row that finds its node itself (`useSelectedHost`: a
1018
1030
  style row's `ValueAccess`, its sibling keys, the padding row, a phone twin)
@@ -147,7 +147,8 @@ interface CopyBoxFooter {
147
147
  /**
148
148
  * What a host needs to draw its OWN control in row 1's 9th cell of the final
149
149
  * toolbar ({@link CopyBoxProps.lastTool}) — the campaign designer's Insert
150
- * (merge tags), owner ruling 2026-10-07. The website editor passes nothing.
150
+ * (merge tags), owner ruling 2026-10-07, and the website editor's text style
151
+ * button (Lewis 2026-10-29, B).
151
152
  *
152
153
  * `className` makes it a cell that looks like its neighbours; `keepCaret` on
153
154
  * its mousedown keeps the caret and the selection in the box; `insert` writes
@@ -164,6 +165,11 @@ interface CopyBoxLastTool {
164
165
  }) => void;
165
166
  /** Put a literal string where the caret is, replacing any selection. */
166
167
  insert: (text: string) => void;
168
+ /** The one site text style every selected word wears; null with none selected. */
169
+ style: string | null;
170
+ /** Put a site text style on the selected words (`[words]{style=id}`), or
171
+ * take it off with null. Nothing selected changes nothing. */
172
+ applyStyle: (id: string | null) => void;
167
173
  }
168
174
  /**
169
175
  * The alignment strip, when the host has an alignment to offer.
@@ -381,6 +387,8 @@ interface CanvasTypingSession {
381
387
  /** The colour the selection wears (a theme colour's name or a hex, a
382
388
  * pending one included), or null: the colour window shows it. */
383
389
  color: string | null;
390
+ /** The one site text style every selected word wears; null with none selected. */
391
+ style: string | null;
384
392
  /** Whether the selected words wear a mark or a colour that Clear
385
393
  * formatting would take off (a link stays): the button shows only then. */
386
394
  clearable: boolean;
@@ -427,6 +435,12 @@ interface CanvasTypingSession {
427
435
  * window stays open, so the focus is not moved.
428
436
  */
429
437
  color: (color: string | null) => void;
438
+ /**
439
+ * A host tool's text style (`styleOver`): the site style `id` on the selected
440
+ * words, or null to take it off. One edit step. The tool's menu had focus, so
441
+ * the focus goes back to the words, as {@link insert} does.
442
+ */
443
+ textStyle: (id: string | null) => void;
430
444
  /**
431
445
  * Clear formatting (Lewis 2026-10-26): every mark and colour off the
432
446
  * selected words, back to the text's own style (`clearStyle`, which keeps a
@@ -0,0 +1,7 @@
1
+ import{STANDARD_MARKUP as t,writeMarkedLines as e,sameMarks as n,markedLines as r,spanFor as l,marksIn as o,toggleMark as i,styleIn as a,styleOver as s,listIn as c,setList as u,colorOver as d,unlinkAt as f,linkOver as h,colorIn as p,findLink as m,clearStyle as g,isSafeLinkHref as b}from"efficient-shell/markup";import{Tooltip as v,ColorSwatch as k,ColorPickerPanel as y,Button as x}from"efficient-shell/ui";import{jsxs as w,jsx as D}from"react/jsx-runtime";function M(t,e){return t&&t.start!==t.end?t:{start:0,end:e}}var N=/* @__PURE__ */new Set(["script","style","head","title","meta","link","template","noscript","svg","math","object","iframe"]),T=/* @__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 C(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(N.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=b(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=T.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=S(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 S(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 A="application/x-efficient-markup",E=/^([0-9]{1,3})\. $/;function B(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:E.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 R(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 L(t,e){const[n,r]=R(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 K(t,e){const[n,r]=R(t,e);let l=0;for(const t of n.chars){if(r===l)return t.at;l+=t.ch.length}return L(t,e)}function W(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 P(t,e,n){return[W(t,e),W(t,n)]}function j(t,e,n){return e===n?[L(t,e),L(t,e)]:[K(t,e),L(t,n)]}function V(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 q(t,o,i,a,s){const c=B(t,o),[u,d,f]=R(c,Math.min(i,a)),[h,p,m]=R(c,Math.max(i,a)),g=V(u,d),b=V(h,p),v=u.chars.slice(0,g),k=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:[...v,...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,...k]}}else l.chars.push(...k);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,B(l,o).lines))break}return{text:N,caret:Math.min(i,a)+T.length}}function F(t,e,n,r){const l=B(t,e),[o,,i]=R(l,n);return n!==r||!o.bullet&&null==o.number||""!==o.text?q(t,e,n,r,{text:"\n"}):I(t,e,i,!1,n)}function I(t,n,r,l,o){const i=B(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 O(t,n,r,l){const o=B(t,n),[i,a,s]=R(o,Math.min(r,l)),[c,u,d]=R(o,Math.max(r,l)),f=o.lines.slice(s,d+1).map(({bullet:t,number:e,chars:n},r)=>{const l=0===r?V(i,a):0,o=r===d-s?V(c,u):n.length;return{bullet:t,number:e,chars:n.slice(l,o)}});return e(f).text}function z(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 U(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:F(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=C({html:t.html??void 0,text:c},{doc:t.doc,multiline:r,rules:n});return{kind:"edit",edit:q(e,n,i,a,{markup:l}),range:s}}return r||(c=c.replace(/\s*\r?\n\s*/g," ")),{kind:"type",edit:q(e,n,i,a,{text:c,add:o?.add,drop:o?.drop,color:o?.color}),range:s}}if(l.startsWith("delete")){const t=B(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:I(e,n,c,!1,i),range:s};if(o?0===i:i===r.length)return null;o?i=z(r,i,-1):a=z(r,a,1)}return{kind:"type",edit:q(e,n,i,a,{text:""}),range:[i,a]}}return null}var $=1e3;function H(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 X=t=>t.preventDefault();function Y(t,e){if(t)return t.startsWith("#")?t:e?.find(e=>e.name===t)?.value}function Z({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 w("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__ */D("span",{className:"es-copy-pop-label",children:n.theme}),
4
+ /* @__PURE__ */D("div",{className:"es-copy-theme",role:"group","aria-label":n.theme,children:t.map(t=>/* @__PURE__ */D(v,{content:`${t.label} · ${t.value.toUpperCase()}`,children:/* @__PURE__ */D(k,{color:t.value,size:"sm",className:"es-copy-theme-swatch","data-color":t.name,"aria-label":t.label,selected:e===t.name,onMouseDown:X,onClick:()=>r(t.name)})},t.name))}),
5
+ /* @__PURE__ */D("span",{className:"es-copy-pop-label",children:n.any}),
6
+ /* @__PURE__ */D(y,{className:"es-copy-any",value:l??"",onChange:t=>{t!==e&&r(t)},label:n.title,dragWrites:"end"}),
7
+ /* @__PURE__ */D("div",{className:"es-copy-pop-foot",children:/* @__PURE__ */D(x,{variant:"ghost-danger",size:"sm","data-window-action":"remove",onMouseDown:X,onClick:()=>r(null),children:n.remove})})]})}var G={sup:"sub",sub:"sup"};function J(t){const{value:e,rules:n,start:r,end:l,style:a,pending:s}=t,c=G[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)}}function Q(t){if(null!==t.id&&a(t.value,t.start,t.end,t.rules)===t.id)return null;const e=s(t.value,t.start,t.end,t.id,t.rules);return e.text===t.value?null:e}var _=/^(block|list-item|flex|grid|table|flow-root)$/;function tt(t){const e=t.ownerDocument.defaultView;return!!e&&_.test(e.getComputedStyle(t).display)}function et(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=tt(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 nt(t){const e=t.element();if(!e)return null;let n=t.value;const r=t.rules;if(et(e,t.skip).text!==B(n,r).text)return null;const l=t.now??(()=>Date.now()),i=H();let s=e,b=!1,v=null,k=null,y=[t.caret[0],t.caret[1]],x=null,w=!1,D=!1;const N=()=>{D||t.onSelect?.()},T={contenteditable:e.getAttribute("contenteditable"),spellcheck:e.getAttribute("spellcheck")},S=()=>s.ownerDocument,E=()=>S().defaultView?.getSelection()??null,R=()=>{if(!k)return!0;at();const e=et(s,t.skip);if(e.text!==B(n,r).text)return!1;const[l,o]=k,[i,a]=e.dom(l),[c,u]=e.dom(o);return w||S().activeElement===s||s.focus({preventScroll:!0}),E()?.setBaseAndExtent(i,a,c,u),y=k,L=k,k=null,N(),!0};let L=null;const K=()=>{if(!L)return!1;const t=E(),e=t?.anchorNode??null;return!(e&&e.isConnected&&s.contains(e))||e===s&&0===t.anchorOffset&&(0!==L[0]||0!==L[1])},W=()=>{k=L,R()},V=()=>{R(),S().activeElement===s&&K()&&W();const e=E();if(!(e&&e.anchorNode&&e.focusNode&&s.contains(e.anchorNode)&&s.contains(e.focusNode)))return y;const n=et(s,t.skip),r=n.at(e.anchorNode,e.anchorOffset),l=n.at(e.focusNode,e.focusOffset);return y=r<=l?[r,l]:[l,r],y},F=t=>{const e=S().defaultView;t<=0||!e?L=null:e.requestAnimationFrame(()=>{b||k||(at(),S().activeElement===s?(K()&&(W(),N()),F(t-1)):L=null)})},I=(t,e)=>{k=[t,e];const n=t=>{if(b)return;if(R())return void F(3);const e=S().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),N()):I(e.caret,e.caret)},$=t=>j(B(n,r),t[0],t[1]),X=(t,e)=>{const l=M({start:t,end:e},n.length);return g(n,l.start,l.end,r)},Y=(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]=P(B(n,r),e.selectionStart,e.selectionEnd);I(a,s),N()},Z=t=>{if(b)return;const e=V(),[l,o]=$(e),i=J({value:n,rules:r,start:l,end:o,style:t,pending:x});if("pending"===i.kind)return x=i.pending,void N();Y(i.result,e)},G=e=>{n=e.text,t.write(n),I(e.start,e.end)},_=e=>{if(b)return;b=!0,st.removeEventListener("selectionchange",ct),it(s);const n=E();n&&n.rangeCount>0&&s.contains(n.anchorNode)&&s.contains(n.focusNode)&&n.removeAllRanges(),t.end(e)},tt=(t,e)=>{const l=V();!b&&l[0]!==l[1]&&t.clipboardData&&(t.preventDefault(),t.clipboardData.setData("text/plain",B(n,r).text.slice(l[0],l[1])),t.clipboardData.setData(A,O(n,r,l[0],l[1])),e&&z(q(n,r,l[0],l[1],{text:""}),l,"edit"))},nt=t=>t.preventDefault(),rt=()=>{t.remount?.()},lt=[["keydown",e=>{if(b||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,et(s,t.skip).text.length),void N();if("Enter"===e.key&&(!e.shiftKey||r))return e.preventDefault(),e.stopPropagation(),void _("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;_("escape")}}],["beforeinput",e=>{if(b)return;if("insertCompositionText"===e.inputType)return;e.preventDefault();const l=V(),o=et(s,t.skip),a="function"==typeof e.getTargetRanges?e.getTargetRanges()[0]:void 0,c=a&&!a.collapsed?[o.at(a.startContainer,a.startOffset),o.at(a.endContainer,a.endOffset)]:null,u=U({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:S(),sel:l,target:c,pending:x&&x.at===$(l)[0]?x:null});if(u){if("type"!==u.kind&&"edit"!==u.kind||(x=null),"history"===u.kind){const t={text:n,start:l[0],end:l[1]},e="undo"===u.dir?i.undo(t):i.redo(t);return void(e&&G(e))}"format"!==u.kind?z(u.edit,u.range,u.kind):Z(u.style)}}],["compositionstart",()=>{v=V()}],["compositionend",e=>{const o=v;if(v=null,!b&&o)if(e.data){const a=q(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),rt(),I(a.caret,a.caret)}else rt(),I(o[0],o[0])}],["paste",e=>{if(b)return;e.preventDefault();const l=V(),o=e.clipboardData,i=o?.getData(A)??"",a=i?t.multiline?i:i.replace(/\s*\r?\n\s*/g," "):C({html:o?.getData("text/html")??"",text:o?.getData("text/plain")??""},{doc:S(),multiline:t.multiline,rules:r});z(q(n,r,l[0],l[1],{markup:a}),l,"edit")}],["copy",t=>tt(t,!1)],["cut",t=>tt(t,!0)],["drop",nt],["dragstart",nt],["blur",e=>{if(b||null!==v||w)return;const n=e.target,r=n.ownerDocument.defaultView,l=()=>{b||(n.isConnected&&n===t.element()?w||n.ownerDocument.activeElement===n||_("blur"):I(y[0],y[1]))};r?.requestAnimationFrame?r.requestAnimationFrame(l):setTimeout(l,0)}],["focus",()=>{w=!1}]];function ot(t){t.setAttribute("contenteditable","true"),t.setAttribute("spellcheck","false"),t.setAttribute("data-es-typing","");for(const[e,n]of lt)t.addEventListener(e,n)}function it(t){for(const[e,n]of lt)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 at(){const e=t.element();e&&e!==s&&(it(s),s=e,ot(s))}const st=s.ownerDocument;function ct(){b||N()}return st.addEventListener("selectionchange",ct),ot(s),s.focus({preventScroll:!0}),I(t.caret[0],t.caret[1]),{get value(){return n},update(t){if(t===n)return;const e=B(t,r).text.length,[l,o]=V();n=t,i.reset(),I(Math.min(l,e),Math.min(o,e))},stop(t="stop"){_(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=x&&x.at===e?x:null;s[t]=!!r?.add.includes(t)||!r?.drop.includes(t)&&n}const u=x&&x.at===e&&void 0!==x.color?x:null;return{marks:s,list:c(n,e,l,r),selected:l>e,href:m(n,e,l)?.href??null,color:u?u.color??null:p(n,e,l,r),style:l>e?a(n,e,l,r):null,clearable:X(e,l).text!==n}},press:Z,insert(t){if(b)return;w=!1;const e=V(),[r,l]=$(e),o=r+t.length;Y({text:n.slice(0,r)+t+n.slice(l),selectionStart:o,selectionEnd:o},e),at(),s.focus({preventScroll:!0})},hold(){b||(V(),w=!0)},release(){w=!1},resume(){b||(w=!1,at(),s.focus({preventScroll:!0}),I(y[0],y[1]))},link(t){if(b)return;w=!1;const e=V(),[l,o]=$(e),i=null===t?f(n,l,o,r):h(n,l,o,t,r),a=i.text===n;Y(i,e),at(),s.focus({preventScroll:!0}),a&&I(e[0],e[1])},color(t){if(b)return;const e=V(),[l,o]=$(e);if(l===o){const e=x&&x.at===l?x:null;return x={add:e?.add??[],drop:e?.drop??[],color:t,at:l},void N()}Y(d(n,l,o,t,r),e)},textStyle(t){if(b)return;w=!1;const e=V(),[l,o]=$(e),i=Q({value:n,start:l,end:o,id:t,rules:r});i&&Y(i,e),at(),s.focus({preventScroll:!0}),i||I(e[0],e[1])},clear(){if(b)return;const t=V(),[e,n]=$(t);Y(X(e,n),t)},list(e){if(b||!t.multiline)return;const l=V(),[o,i]=$(l),a=c(n,o,i,r);Y(u(n,o,i,a===e?null:e,r),l)}}}var rt=(t,e,n)=>Math.min(Math.max(t,e),Math.max(e,n));function lt({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=rt(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=rt(h-5-s,10,e.width-10-10);return{top:f-l.top,left:s-l.left,above:d,point:p}}var ot=t=>({left:t.left,top:t.top,right:t.right,bottom:t.bottom});function it(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?ot(e):ot(n[0])}if(!e)return null;const r=e.getBoundingClientRect();return{left:r.left,top:r.top,right:r.left,bottom:r.bottom}}function at(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 st(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 ct(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{Z as ColorWindow,A as MARKUP_CLIPBOARD_TYPE,$ as TYPING_BURST_MS,M as clearRangeOf,Y as colorRunOf,H as createHistory,q as editVisible,J as markPress,O as markupOfRange,F as newLine,st as offsetOrigin,C as pasteToMarkup,lt as placeWindow,U as richInput,B as richLayout,it as selectionBox,j as selectionToSource,P as selectionToVisible,I as setBullet,nt as startCanvasTyping,Q as styleChange,et as textMap,ct as textRange,L as toSource,K as toSourceStart,W as toVisible,at as visibleArea};
@@ -1,7 +1,7 @@
1
- import{clientOnly as r}from"./chunk-GXQCZJOP.js";import{ScreenStoreProvider as n}from"./chunk-P4XLNW3E.js";import{ScreenChrome as e}from"./chunk-YQXHRQXH.js";import{ScreenDocumentProvider as i,useScreenDocument as a}from"./chunk-BYONFJVQ.js";import{DEFAULT_SCREEN_WORDS as o}from"./chunk-Q3VAJMXS.js";import{documentPermissions as s}from"./chunk-YYD257TD.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(n),N=r(e);function C({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{ScreenStoreProvider as n}from"./chunk-YMK3MZJK.js";import{ScreenChrome as e}from"./chunk-Y2OWVL6W.js";import{ScreenDocumentProvider as i,useScreenDocument as a}from"./chunk-CPIWSFGR.js";import{DEFAULT_SCREEN_WORDS as o}from"./chunk-C4TJN6GR.js";import{documentPermissions as s}from"./chunk-YYD257TD.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 C=r(n),k=r(e);function N({onCancel:r,onDiscard:n,onSave:e}){const i=c("screen",o).leave,[a,s]=d(!1),t=l(!0);m(()=>(t.current=!0,()=>{t.current=!1}),[]);const C=g(async()=>{s(!0);try{await e()}finally{t.current&&s(!1)}},[e]);/* @__PURE__ */
2
2
  return u(h,{open:!0,role:"alertdialog",size:"sm",title:i.title,onClose:r,footer:/* @__PURE__ */p(v,{children:[
3
3
  /* @__PURE__ */u(f,{variant:"secondary",onClick:r,children:i.cancel}),
4
4
  /* @__PURE__ */u(f,{variant:"ghost-danger",onClick:n,children:i.discard}),
5
- /* @__PURE__ */u(f,{variant:"primary",loading:a,onClick:()=>{k()},children:i.save})]}),children:i.body})}function j({target:r,addressing:n,onHostMessage:e,children:a}){/* @__PURE__ */
6
- return u(i,{target:r,addressing:n,onHostMessage:e,children:a})}var y=(r,n)=>/* @__PURE__ */p(v,{children:[r,n]});function H({config:r,parts:n,wrap:e=y}){const{data:i,error:d,redirecting:l,ready:m,readOnly:g,onChange:h,pendingNav:f,cancelPendingNav:p,discardAndNavigate:v,saveAndNavigate:j}=a(),H=t(()=>s(!g),[g]),Q=c("screen",o);return l?/* @__PURE__ */u("div",{className:"sf-msg",children:Q.loading}):d?/* @__PURE__ */u("div",{className:"sf-msg sf-msg--error",children:d}):m?i?e(
7
- /* @__PURE__ */u(k,{config:r,data:i,onChange:h,permissions:H,parts:n,children:/* @__PURE__ */u(N,{})}),f&&/* @__PURE__ */u(C,{onCancel:p,onDiscard:v,onSave:j})):/* @__PURE__ */u("div",{className:"sf-msg",children:Q.loading}):/* @__PURE__ */u("div",{className:"sf-msg",children:Q.waitingForAuthorization})}export{H as DocumentScreen,j as ScreenMount};
5
+ /* @__PURE__ */u(f,{variant:"primary",loading:a,onClick:()=>{C()},children:i.save})]}),children:i.body})}function j({target:r,addressing:n,onHostMessage:e,children:a}){/* @__PURE__ */
6
+ return u(i,{target:r,addressing:n,onHostMessage:e,children:a})}var y=(r,n)=>/* @__PURE__ */p(v,{children:[r,n]});function M({config:r,parts:n,wrap:e=y}){const{data:i,error:d,redirecting:l,ready:m,readOnly:g,onChange:h,pendingNav:f,cancelPendingNav:p,discardAndNavigate:v,saveAndNavigate:j}=a(),M=t(()=>s(!g),[g]),Y=c("screen",o);return l?/* @__PURE__ */u("div",{className:"sf-msg",children:Y.loading}):d?/* @__PURE__ */u("div",{className:"sf-msg sf-msg--error",children:d}):m?i?e(
7
+ /* @__PURE__ */u(C,{config:r,data:i,onChange:h,permissions:M,parts:n,children:/* @__PURE__ */u(k,{})}),f&&/* @__PURE__ */u(N,{onCancel:p,onDiscard:v,onSave:j})):/* @__PURE__ */u("div",{className:"sf-msg",children:Y.loading}):/* @__PURE__ */u("div",{className:"sf-msg",children:Y.waitingForAuthorization})}export{M as DocumentScreen,j as ScreenMount};
@@ -1 +1 @@
1
- import{useScreenBlockRules as e}from"./chunk-UR7YBZJR.js";import{newNodeId as t,ROOT_ZONE as n}from"./chunk-TCAAOYQY.js";import{useEasel as o,useEaselApi as r}from"./chunk-EVYIDHCK.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-L4DFCNDQ.js";import{newNodeId as t,ROOT_ZONE as n}from"./chunk-TCAAOYQY.js";import{useEasel as o,useEaselApi as r}from"./chunk-NUJEHA6A.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};
@@ -0,0 +1 @@
1
+ import{useSectionOps as o}from"./chunk-3ZGOVNVH.js";import{SELECTION_MODE as e}from"./chunk-L4DFCNDQ.js";import{decodePartId as r,encodePartId as t}from"./chunk-R4AUZVA3.js";import{useEasel as n}from"./chunk-NUJEHA6A.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:a}){const{getSelectorForId:u}=n(o=>o),f=o(),{setSelectedPartId:k,setSelectHandler:l}=p(),I=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}),a?.(n)):i(o=>"part"===o.kind?e:o)},[i,a]);c(()=>{l(I)},[l,I]);const h=s(m)?t(m.nodeId,m.propKey):null;c(()=>{k(h)},[h,k]);return{selectNode:d(o=>{i(()=>e);const r=u(o);r&&f.select(r)},[i,u,f]),openPartId:h}}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-UR7YBZJR.js";import{DEFAULT_SCREEN_WORDS as l}from"./chunk-Q3VAJMXS.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-L4DFCNDQ.js";import{DEFAULT_SCREEN_WORDS as l}from"./chunk-C4TJN6GR.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,2 +1,2 @@
1
- import{noControlField as e}from"./chunk-22I55W37.js";import{DEFAULT_SCREEN_WORDS as r}from"./chunk-Q3VAJMXS.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__ */
1
+ import{noControlField as e}from"./chunk-22I55W37.js";import{DEFAULT_SCREEN_WORDS as r}from"./chunk-C4TJN6GR.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
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};
@@ -1 +1 @@
1
- var e={title:"Add",contextAll:"Sections and blocks",done:"Done",doneDescription:"Close Add and go back",templates:"Your templates",tile:({name:e})=>`Add ${e}`,hint:"Drag onto the page.",search:"Search",onlySections:"Only sections go here",notInside:({name:e})=>`Cannot go inside ${e}`,addingTo:({name:e})=>`Adding to ${e}`,addingBefore:({name:e})=>`Adding before ${e}`,addingAtEnd:"Adding at the end of the page",addingHere:"Adding here"},a=e=>1===e?"1 page":`${e} pages`,t={group:"Shared sections",onPages:({count:e})=>`On ${a(e)}`,makeShared:"Make shared",makeSharedHint:"Use this section on other pages from Add. Change it once, and every page changes.",name:"Name",cancel:"Cancel",makeFailed:"Could not make it shared. Try again.",detach:"Detach from shared",removeFromPage:"Remove from this page",removed:({count:e})=>e>0?`Removed from this page · still on ${a(e)}`:"Removed from this page",deleteShared:"Delete shared section",deleteTitle:({name:e})=>`Delete “${e}”?`,deleteMessage:({count:e})=>0===e?"No page uses it. Nothing on the website changes.":1===e?"The page that uses it keeps its own copy. Nothing disappears from the website.":`The ${e} pages that use it each keep their own copy. Nothing disappears from the website.`,deleteFailed:"Could not delete it. Try again.",alreadyHere:"Already on this page"};var o={savedAgo:function({seconds:e}){const a=Math.max(0,Math.floor(e));if(a<1)return"Saved just now";if(a<60)return`Saved ${a} second${1===a?"":"s"} ago`;const t=Math.floor(a/60);if(t<60)return`Saved ${t} minute${1===t?"":"s"} ago`;const o=Math.floor(t/60);return`Saved ${o} hour${1===o?"":"s"} ago`},saved:"All changes saved",saving:"Saving",pending:"Changes not saved yet — saving in a moment",failedIn:({seconds:e})=>`Not saved — trying again in ${e} s`,failedSoon:"Not saved — trying again soon",offline:"You’re offline — we’ll save when you’re back",pausedHeld:"Auto-save is off — changes not saved",paused:"Auto-save is off",locked:({editing:e})=>`Not saving — ${e}`,blockedOffline:"You’re offline. Try again when you’re back online.",blockedFailed:"Your last changes are not saved yet. Try again when they are.",blockedConflict:"Your last save was refused. See the notice below."},n={blockCount:({count:e})=>`${e} ${1===e?"block":"blocks"}`,loading:"Loading",waitingForAuthorization:"Waiting for editor authorization",missingTemplatePage:"Couldn’t open a page in this template.",missingPage:({slug:e})=>`No page with slug "${e}".`,missingDocument:"Couldn’t open this document.",loadFailed:({cause:e})=>`Could not load the document — ${e}`,noun:"page",pageStyles:"This page",header:"Header",footer:"Footer",pageSections:"Page",templateSections:"Template",addSection:"Add section",addSectionHere:"Add section here",done:"Done",copied:({name:e})=>`Copied ${e}`,pasteRefused:({name:e})=>`${e} can’t be pasted here.`,add:e,shared:t,canvasAddBlock:"Add block",canvasReplaceImage:"Replace image",railMedia:"Media library",leftPanel:"Left panel",resizeLeftPanel:"Resize left panel",leave:{title:"Unsaved changes",body:"Your most recent edits haven’t finished saving yet. Save them before switching, or leave and discard them.",cancel:"Cancel",discard:"Discard & leave",save:"Save & leave",saving:"Saving"},bar:{undo:"Undo",redo:"Redo",refresh:"Reload the preview",refreshTip:"Reload the preview (keeps your place)",notSaving:"Not saving — see the notice below",retry:"Retry now",autoSaveOff:"Auto-save is off — click to turn it back on (saves your held edits)",autoSaveOn:"Auto-save is on — click to pause it",views:"Left panel views",saveOptions:"Save options",autoSave:"Auto-save",saveNow:"Save now"},saveStatus:o,menu:{undo:"Undo",redo:"Redo",collapseAll:"Collapse all layers",selectAll:"Select all",pinned:"Pinned — can’t be moved or deleted",clipboardRefused:"Your browser won’t let us read the clipboard — press ⌘V",itemAddAfter:"Add item after",itemMoveEarlier:"Move item earlier",itemMoveLater:"Move item later",itemDelete:"Delete item"},layers:"Layers",expandAll:"Expand all sections",collapseAll:"Collapse all sections",nothingToFold:"Nothing to fold on this page",rename:"Rename",deleteNamed:({name:e})=>`Delete ${e}`,hideNamed:({name:e})=>`Hide ${e}`,showNamed:({name:e})=>`Show ${e}`,addBlockHere:"Add block here",sectionFirst:({name:e})=>`“${e}” is already first`,sectionLast:({name:e})=>`“${e}” is already last`,sectionMoved:({name:e,n:a,total:t})=>`Moved “${e}” to position ${a} of ${t}`,sectionAdded:({name:e})=>`Added “${e}” section`,deleted:({name:e})=>`Deleted “${e}”`,resizeSettingsPanel:"Resize settings panel",sectionSettings:({name:e})=>`${e} settings`,headerSettings:"Header settings",addBlockMenu:"Add block",deviceNote:{tablet:"Tablet uses the desktop settings.",mobile:"Showing the phone settings for this section."}},s={focus:"Image focus",onDesktop:e=>`${e} on desktop`,pasteLink:"or paste an image URL",pasteName:"Image URL",template:"Templates don’t store images. This slot stays a placeholder. Each website picks its own after it’s created.",templateVideo:"Templates don’t store videos. This slot stays a placeholder. Each website picks its own after it’s created."};export{s as DEFAULT_IMAGE_ROW_WORDS,e as DEFAULT_SCREEN_ADD_WORDS,o as DEFAULT_SCREEN_SAVE_STATUS_WORDS,t as DEFAULT_SCREEN_SHARED_WORDS,n as DEFAULT_SCREEN_WORDS};
1
+ var e={title:"Add",contextAll:"Sections and blocks",done:"Done",doneDescription:"Close Add and go back",templates:"Your templates",tile:({name:e})=>`Add ${e}`,hint:"Drag onto the page.",search:"Search",onlySections:"Only sections go here",notInside:({name:e})=>`Cannot go inside ${e}`,addingTo:({name:e})=>`Adding to ${e}`,addingBefore:({name:e})=>`Adding before ${e}`,addingAtEnd:"Adding at the end of the page",addingHere:"Adding here"},a=e=>1===e?"1 page":`${e} pages`,t={group:"Shared sections",onPages:({count:e})=>`On ${a(e)}`,makeShared:"Make shared",makeSharedHint:"Use this section on other pages from Add. Change it once, and every page changes.",name:"Name",cancel:"Cancel",makeFailed:"Could not make it shared. Try again.",detach:"Detach from shared",removeFromPage:"Remove from this page",removed:({count:e})=>e>0?`Removed from this page · still on ${a(e)}`:"Removed from this page",deleteShared:"Delete shared section",deleteTitle:({name:e})=>`Delete “${e}”?`,deleteMessage:({count:e})=>0===e?"No page uses it. Nothing on the website changes.":1===e?"The page that uses it keeps its own copy. Nothing disappears from the website.":`The ${e} pages that use it each keep their own copy. Nothing disappears from the website.`,deleteFailed:"Could not delete it. Try again.",alreadyHere:"Already on this page"};var o={savedAgo:function({seconds:e}){const a=Math.max(0,Math.floor(e));if(a<1)return"Saved just now";if(a<60)return`Saved ${a} second${1===a?"":"s"} ago`;const t=Math.floor(a/60);if(t<60)return`Saved ${t} minute${1===t?"":"s"} ago`;const o=Math.floor(t/60);return`Saved ${o} hour${1===o?"":"s"} ago`},saved:"All changes saved",saving:"Saving",pending:"Changes not saved yet — saving in a moment",failedIn:({seconds:e})=>`Not saved — trying again in ${e} s`,failedSoon:"Not saved — trying again soon",offline:"You’re offline — we’ll save when you’re back",pausedHeld:"Auto-save is off — changes not saved",paused:"Auto-save is off",locked:({editing:e})=>`Not saving — ${e}`,blockedOffline:"You’re offline. Try again when you’re back online.",blockedFailed:"Your last changes are not saved yet. Try again when they are.",blockedConflict:"Your last save was refused. See the notice below."},n={blockCount:({count:e})=>`${e} ${1===e?"block":"blocks"}`,loading:"Loading",waitingForAuthorization:"Waiting for editor authorization",missingTemplatePage:"Couldn’t open a page in this template.",missingPage:({slug:e})=>`No page with slug "${e}".`,missingDocument:"Couldn’t open this document.",loadFailed:({cause:e})=>`Could not load the document — ${e}`,noun:"page",pageStyles:"This page",header:"Header",footer:"Footer",pageSections:"Page",templateSections:"Template",addSection:"Add section",addSectionHere:"Add section here",done:"Done",copied:({name:e})=>`Copied ${e}`,pasteRefused:({name:e})=>`${e} can’t be pasted here.`,writeLate:"That took too long. Your change is kept, but the last step did not finish.",add:e,shared:t,canvasAddBlock:"Add block",canvasReplaceImage:"Replace image",railMedia:"Media library",leftPanel:"Left panel",resizeLeftPanel:"Resize left panel",leave:{title:"Unsaved changes",body:"Your most recent edits haven’t finished saving yet. Save them before switching, or leave and discard them.",cancel:"Cancel",discard:"Discard & leave",save:"Save & leave",saving:"Saving"},bar:{undo:"Undo",redo:"Redo",refresh:"Reload the preview",refreshTip:"Reload the preview (keeps your place)",notSaving:"Not saving — see the notice below",retry:"Retry now",autoSaveOff:"Auto-save is off — click to turn it back on (saves your held edits)",autoSaveOn:"Auto-save is on — click to pause it",views:"Left panel views",saveOptions:"Save options",autoSave:"Auto-save",saveNow:"Save now"},saveStatus:o,menu:{undo:"Undo",redo:"Redo",collapseAll:"Collapse all layers",selectAll:"Select all",pinned:"Pinned — can’t be moved or deleted",clipboardRefused:"Your browser won’t let us read the clipboard — press ⌘V",itemAddAfter:"Add item after",itemMoveEarlier:"Move item earlier",itemMoveLater:"Move item later",itemDelete:"Delete item"},layers:"Layers",expandAll:"Expand all sections",collapseAll:"Collapse all sections",nothingToFold:"Nothing to fold on this page",rename:"Rename",deleteNamed:({name:e})=>`Delete ${e}`,hideNamed:({name:e})=>`Hide ${e}`,showNamed:({name:e})=>`Show ${e}`,addBlockHere:"Add block here",sectionFirst:({name:e})=>`“${e}” is already first`,sectionLast:({name:e})=>`“${e}” is already last`,sectionMoved:({name:e,n:a,total:t})=>`Moved “${e}” to position ${a} of ${t}`,sectionAdded:({name:e})=>`Added “${e}” section`,deleted:({name:e})=>`Deleted “${e}”`,resizeSettingsPanel:"Resize settings panel",sectionSettings:({name:e})=>`${e} settings`,headerSettings:"Header settings",addBlockMenu:"Add block",deviceNote:{tablet:"Tablet uses the desktop settings.",mobile:"Showing the phone settings for this section."}},s={focus:"Image focus",onDesktop:e=>`${e} on desktop`,pasteLink:"or paste an image URL",pasteName:"Image URL",template:"Templates don’t store images. This slot stays a placeholder. Each website picks its own after it’s created.",templateVideo:"Templates don’t store videos. This slot stays a placeholder. Each website picks its own after it’s created."};export{s as DEFAULT_IMAGE_ROW_WORDS,e as DEFAULT_SCREEN_ADD_WORDS,o as DEFAULT_SCREEN_SAVE_STATUS_WORDS,t as DEFAULT_SCREEN_SHARED_WORDS,n as DEFAULT_SCREEN_WORDS};
@@ -1,2 +1,2 @@
1
- import{routeSharedHostMessage as e}from"./chunk-QZJKWKGH.js";import{describeLoadFailure as r,hostLoadRefusal as n}from"./chunk-ERR437B5.js";import{editLockOf as t}from"./chunk-GR3XRILS.js";import{NO_DOCUMENT_ADDRESSING as o}from"./chunk-RLBXE4EU.js";import{saveStatusOf as u,resetForDocumentSwitch as a}from"./chunk-6ATIYLUL.js";import{isExpiredSession as s,readEaselFailure as i}from"./chunk-KO47WAWR.js";import{useAdminBridge as l}from"./chunk-NQW6XCAY.js";import{STATUS_UNREACHABLE as c}from"./chunk-KCOBHPN6.js";import{useEaselSession as d}from"./chunk-YM4UEGBV.js";import{backendOf as f,setSessionDocumentSite as m}from"./chunk-SNF5764Q.js";import{useEaselHost as k}from"./chunk-LX23TCTP.js";import{DEFAULT_SCREEN_WORDS as v}from"./chunk-Q3VAJMXS.js";import{useAutosave as g}from"./chunk-NDRZP6YR.js";import{canWriteDocument as p,newEaselClientId as h,reloadIfVersionMoved as y,openUnansweredClaim as w,FAIL_OPEN_RETRY_MS as b,CLAIM_FAIL_OPEN_MS as S,holderOf as I}from"./chunk-YYD257TD.js";import{useWords as P}from"./chunk-MFIRYGHW.js";import{createContext as j,useContext as R,useState as E,useMemo as A,useCallback as B,useEffect as T,useRef as C}from"react";import{jsx as H}from"react/jsx-runtime";var L={content:[],root:{},zones:{}};var D=j(null);function N(){const e=R(D);if(!e)throw new Error("useStorefrontDocument must be used within StorefrontDocumentProvider");return e}function O({target:j,addressing:R=o,onHostMessage:N,children:O}){const M=R,{homeSlug:Y,entryMayBounce:F,entryBounce:W,onSwitch:V,tellsHost:K,adapterFor:U,migrateRenamedProps:X,describeMissing:G,onLoadFailed:Q}=M,[x,J]=E(j),Z=k(),z=d(),_=A(()=>f(z),[z]),q=A(()=>t(z),[z]),$="template"===x.kind,ee="template"===x.kind?x.id:null,re="template"===x.kind?x.pageSlug??Y??"":"document"===x.kind?x.slug??"":x.slug,ne="page"===x.kind?x.siteId??null:null,te=z.blocks,oe=A(()=>U(x,_,te),[U,_,te,x.kind,"template"===x.kind?x.id:"document"===x.kind?x.record:x.siteId]),ue=oe.capabilities,ae=B(e=>z.documentHooks?.stored?.(e)??e,[z]);T(()=>{m(z,ne)},[z,ne]);const se=C(x);T(()=>{se.current=x},[x]);const{token:ie,tokenRef:le,capabilities:ce}=l({onMessage:r=>{if(N?.(r)||e(r))return;const n=r;if("storefront-editor:navigate"===n?.type){const e=r;e?.target&&Er(e.target)}}}),de=!z.usesBridgedToken||null!==ie,fe=oe.lock,me=Boolean(_.lock),[ke,ve]=E(null),[ge,pe]=E(null),[he,ye]=E(null),[we,be]=E(null),Se=P("screen",v),Ie=we?function(e,r){if(null!==e.sentence)return e.sentence;if(!e.missing)return r.loadFailed({cause:e.cause});switch(e.target.kind){case"template":return r.missingTemplatePage;case"document":return r.missingDocument;default:return r.missingPage({slug:e.slug})}}(we,Se):null,[Pe,je]=E(null),Re=C(null),Ee=C(null),[Ae,Be]=E(!1),Te=C(null),[Ce,He]=E(null),Le=C(null),[De,Ne]=E(null),[Oe,Me]=E(!1),Ye=C(null);T(()=>{Ye.current=De},[De]);const[Fe,We]=E(ue.hasEditLock?{kind:"checking"}:{kind:"editing"}),Ve=C(Fe);T(()=>{Ve.current=Fe},[Fe]);const Ke=C(()=>Promise.resolve(!1)),Ue=B(e=>{Ee.current=e,Be(!0)},[]),Xe=g({save:async({id:e,data:r})=>{if(p(Ve.current)){if(!await Ke.current(e,r)){if(!p(Ve.current))return void Ue({id:e,data:r});throw new Error("page save did not land")}}else Ue({id:e,data:r})},onFailure:(e,r)=>{0===r&&Z.send("storefront-editor:save-failed")}}),{state:Ge,push:Qe,flush:xe,pause:Je,resume:Ze,stop:ze,reset:_e,retryNow:qe,hasPending:$e}=Xe,er=C(Ge);T(()=>{er.current=Ge},[Ge]);const rr=u(Ge),nr=B(()=>{const e=Ee.current;e&&(Ee.current=null,Be(!1),Qe(e))},[Qe]),tr=C("");tr.current||(tr.current=h());const[or,ur]=E(0),ar=C(!1),[sr,ir]=E(F(j)),lr=C(!1);T(()=>{if(lr.current)return;lr.current=!0;const e=Z.address.search(),r=W(j,e);r?Z.address.load(r):F(j)&&ir(!1)},[j,Z]);const cr=Z.send;T(()=>{if(!de)return;let e=!1;const t=se.current,o=oe.resolve(re),u=z.documentHooks?.opening?.({slug:re,isTemplate:$,capabilities:ue});return o.then(async r=>{if(e)return;if(!r)return"page"===t.kind&&null!==Y&&re!==Y?void Z.address.load({kind:"page",slug:Y,siteId:ne??void 0}):(be({target:t,slug:re,missing:!0,sentence:G?.(t)??null}),void Q?.(t,null));const n=r.readOnlyReason?r.readOnlyReason:null;Re.current=n,je(n),ve(r.id),pe(r.kind??null),Le.current=r.version??null;const o=r.layout,a=o&&Object.keys(o).length?o:L,s=X(a),i=u?await u(s):s;e||ye(i)}).catch(o=>{e||(console.error("[storefront-editor] document load failed",o),be({target:t,slug:re,missing:!1,sentence:n(o,{slug:re},z),cause:r(o,z)}),Q?.(t,o))}),()=>{e=!0}},[de,ie,$,oe,re]);const dr=B(e=>new Promise(r=>{const n=Date.now(),t=setInterval(()=>{const o=le.current;o&&o!==e?(clearInterval(t),r(o)):Date.now()-n>6e3&&(clearInterval(t),r(null))},200)}),[]),fr=B(async e=>{const r=le.current;if(!r&&z.usesBridgedToken)return{ok:!1,error:new Error("no editor token")};try{return{ok:!0,value:await e(r??"")}}catch(n){if(s(n,z)){cr("storefront-editor:auth-expired");const n=r?await dr(r):null;if(n)try{return{ok:!0,value:await e(n)}}catch(e){return{ok:!1,error:e}}}return{ok:!1,error:n}}},[cr,dr,z]),mr=B(async e=>{const r=le.current?await fr(e):{ok:!1};return r.ok||cr("storefront-editor:save-failed"),r.ok},[cr,fr]),kr=B(async(e,r,n=!1)=>{if(null!==Re.current)return!1;if(!p(Ve.current))return!1;if(Ye.current)return!1;const t=await fr(()=>oe.saveLayout(e,r,Le.current,tr.current));if(t.ok)return Le.current=t.value.version??Le.current,Me(!1),!0;const o=q.readLockTaken(t.error);if(o){const e={kind:"takenover",holder:o};return Ve.current=e,We(e),!1}const u=q.readSaveConflict(t.error);if(u){if(u.savedByYou&&!n&&oe.rereadVersion){const n=await fr(()=>oe.rereadVersion(e));if(n.ok&&n.value)return Le.current=n.value,Ke.current(e,r,!0)}ze(),Ye.current=u,Ne(u)}return Me(i(t.error,z)?.status===c),!1},[oe,fr,ze,z]);T(()=>{Ke.current=kr},[kr]);const vr=B(e=>{if(null!==Re.current)return;if(cr("storefront-editor:dirty"),!ke)return;const r=ae(e);Te.current=r,p(Ve.current)?Qe({id:ke,data:r}):Ue({id:ke,data:r})},[ke,cr,Ue,Qe,ae]),gr=B(async()=>{p(Ve.current)&&nr();return await xe()&&null==Ee.current},[nr,xe]),pr=C(gr);T(()=>{pr.current=gr},[gr]);const hr=C(fr);T(()=>{hr.current=fr},[fr]);const yr=B(()=>{Z.address.reload()},[Z]),wr=C(()=>Promise.resolve(!1));T(()=>{wr.current=()=>{const e=oe.rereadVersion;return ke&&e?y({ours:Le.current,stored:async()=>{const r=await hr.current(()=>e(ke));return r.ok?r.value:null},hasPending:()=>null!=Ee.current||$e(),reload:yr}):Promise.resolve(!1)}},[oe,ke,$e,yr]);const br=null!==Pe;T(()=>{if(!fe||!ke||!de||br)return;let e=!1,r=null,n=null;const t=tr.current,o={claim:async e=>{const r=await hr.current(()=>fe.claim(ke,t,e));if(r.ok)return{heartbeat_seconds:r.value.heartbeatSeconds};throw r.error},cancelled:()=>e,currentAccess:()=>Ve.current,heldWrite:()=>({pending:null!=Ee.current||$e(),autoSaveEnabled:!er.current.paused,saveConflict:null!=Ye.current}),setAccess:e=>{Ve.current=e,We(e)},releaseHeldWrite:()=>{pr.current()},startHeartbeat:e=>{r&&clearInterval(r),r=setInterval(()=>{u(!1)},e)},stopHeartbeat:()=>{r&&(clearInterval(r),r=null)},reloadIfMoved:()=>{wr.current()}},u=q.makeClaimBeat(o),a=ar.current;return ar.current=!1,a||(We({kind:"checking"}),n=setTimeout(()=>{n=null,w(o)&&o.startHeartbeat(b)},S)),u(a).finally(()=>{n&&clearTimeout(n),n=null}),()=>{e=!0,n&&clearTimeout(n),r&&clearInterval(r),fe.release(ke,t).catch(()=>{})}},[ke,fe,de,ie,or,br]);const Sr=B(()=>{fe&&ke&&(ar.current=!0,ur(e=>e+1))},[ke,fe]),Ir=B(()=>{We(e=>{const r="blocked"===e.kind||"takenover"===e.kind?e.holder:null;return r?{kind:"readonly",holder:r}:e})},[]),Pr=B(()=>{er.current.paused?(p(Ve.current)&&nr(),Ze()):Je()},[nr,Je,Ze]),jr=B(()=>{qe()},[qe]),Rr=B(e=>{Te.current=null,a("template"!==e.kind&&me,{resetAutosave:()=>{_e(),Ee.current=null,Be(!1)},setVersion:e=>{Le.current=e},setSaveConflict:Ne,setAccess:We}),V(e),J(e),Re.current=null,je(null),ve(null),pe(null),ye(null),be(null),Z.address.show(e),"document"!==e.kind&&K(e)&&Z.send("storefront-editor:navigated",{target:e})},[_e,Z,me,V,K]),Er=B(e=>{if(function(e,r,n){if(e.kind!==r.kind)return!1;if("template"===e.kind){const t=r;return e.id===t.id&&(e.pageSlug??n)===(t.pageSlug??n)}if("document"===e.kind){const n=r;return e.record===n.record&&(e.slug??"")===(n.slug??"")}const t=r;return e.slug===t.slug&&e.siteId===t.siteId}(e,se.current,Y))return;const r=null!=Ee.current;if(!r&&!$e())return void Rr(e);const n=er.current;r||n.paused||n.failed||n.stopped?He(e):xe().then(r=>{r?Rr(e):He(e)})},[Rr,$e,xe,Y]),Ar=B(()=>He(null),[]),Br=B(()=>{He(e=>(e&&Rr(e),null))},[Rr]),Tr=B(async()=>{const e=Ce;if(!e)return;await gr()&&(He(null),Rr(e))},[Ce,gr,Rr]),Cr=B(async e=>{if(null!==Re.current)return;if(!ke)return;if(!p(Ve.current)||Ye.current)return;const r=ae(e);if(!await kr(ke,r))return void(Ye.current||cr("storefront-editor:save-failed"));const n=oe.publish;if(!ue.canPublish||!n)return void cr("storefront-editor:saved");const t=await fr(()=>n(ke,Le.current??void 0));if(!t.ok){const{error:e}=t;return void cr("storefront-editor:publish-failed",{reason:e instanceof Error&&e.message?e.message:null})}Le.current=t.value.version??Le.current,cr("storefront-editor:published")},[ke,oe,ue.canPublish,cr,kr,fr,ae]);/* @__PURE__ */
2
- return H(D.Provider,{value:{target:x,adapter:oe,capabilities:ue,templateId:ee,currentSlug:re,currentKind:ge,siteId:ne,ready:de,token:ie,tokenRef:le,notifyParent:cr,bridgeCapabilities:ce,runAuthed:mr,docId:ke,data:he,getLiveData:()=>Te.current??he,error:Ie,redirecting:sr,saveStatus:rr,saveState:Ge,autoSaveEnabled:!Ge.paused,autoSaveStoppedByConflict:Ge.stopped,hasUnsavedEdits:Ge.pending||Ae,toggleAutoSave:Pr,retrySave:jr,onChange:vr,flushSave:gr,onPublish:Cr,access:Fe,readOnly:null!==I(Fe)||null!==Pe||null!==De,readOnlyReason:Pe,takeOverEditing:Sr,viewReadOnly:Ir,saveConflict:De,saveUnreachable:Oe,reloadFromServer:yr,navigate:Er,pendingNav:Ce,cancelPendingNav:Ar,discardAndNavigate:Br,saveAndNavigate:Tr},children:O})}export{D as ScreenDocumentContext,O as ScreenDocumentProvider,N as useScreenDocument};
1
+ import{routeSharedHostMessage as e}from"./chunk-QZJKWKGH.js";import{describeLoadFailure as r,hostLoadRefusal as n}from"./chunk-ERR437B5.js";import{editLockOf as t}from"./chunk-GR3XRILS.js";import{NO_DOCUMENT_ADDRESSING as o}from"./chunk-RLBXE4EU.js";import{saveStatusOf as u,resetForDocumentSwitch as a}from"./chunk-6ATIYLUL.js";import{isExpiredSession as s,readEaselFailure as i}from"./chunk-KO47WAWR.js";import{useAdminBridge as l}from"./chunk-NQW6XCAY.js";import{STATUS_UNREACHABLE as c}from"./chunk-KCOBHPN6.js";import{useEaselSession as d}from"./chunk-YM4UEGBV.js";import{backendOf as f,setSessionDocumentSite as m}from"./chunk-SNF5764Q.js";import{useEaselHost as k}from"./chunk-LX23TCTP.js";import{DEFAULT_SCREEN_WORDS as v}from"./chunk-C4TJN6GR.js";import{useAutosave as g}from"./chunk-NDRZP6YR.js";import{canWriteDocument as p,newEaselClientId as h,reloadIfVersionMoved as y,openUnansweredClaim as w,FAIL_OPEN_RETRY_MS as b,CLAIM_FAIL_OPEN_MS as S,holderOf as I}from"./chunk-YYD257TD.js";import{useWords as P}from"./chunk-MFIRYGHW.js";import{createContext as j,useContext as R,useState as E,useMemo as T,useCallback as B,useEffect as C,useRef as A}from"react";import{jsx as H}from"react/jsx-runtime";var L={content:[],root:{},zones:{}};var N=j(null);function D(){const e=R(N);if(!e)throw new Error("useStorefrontDocument must be used within StorefrontDocumentProvider");return e}function O({target:j,addressing:R=o,onHostMessage:D,children:O}){const Y=R,{homeSlug:F,entryMayBounce:M,entryBounce:W,onSwitch:G,tellsHost:K,adapterFor:U,migrateRenamedProps:V,describeMissing:X,onLoadFailed:x}=Y,[Q,J]=E(j),Z=k(),z=d(),_=T(()=>f(z),[z]),q=T(()=>t(z),[z]),$="template"===Q.kind,ee="template"===Q.kind?Q.id:null,re="template"===Q.kind?Q.pageSlug??F??"":"document"===Q.kind?Q.slug??"":Q.slug,ne="page"===Q.kind?Q.siteId??null:null,te=z.blocks,oe=T(()=>U(Q,_,te),[U,_,te,Q.kind,"template"===Q.kind?Q.id:"document"===Q.kind?Q.record:Q.siteId]),ue=oe.capabilities,ae=B(e=>z.documentHooks?.stored?.(e)??e,[z]);C(()=>{m(z,ne)},[z,ne]);const se=A(Q);C(()=>{se.current=Q},[Q]);const{token:ie,tokenRef:le,capabilities:ce}=l({onMessage:r=>{if(D?.(r)||e(r))return;const n=r;if("storefront-editor:navigate"===n?.type){const e=r;e?.target&&Er(e.target)}}}),de=!z.usesBridgedToken||null!==ie,fe=oe.lock,me=Boolean(_.lock),[ke,ve]=E(null),[ge,pe]=E(null),[he,ye]=E(null),[we,be]=E(null),Se=P("screen",v),Ie=we?function(e,r){if(null!==e.sentence)return e.sentence;if(!e.missing)return r.loadFailed({cause:e.cause});switch(e.target.kind){case"template":return r.missingTemplatePage;case"document":return r.missingDocument;default:return r.missingPage({slug:e.slug})}}(we,Se):null,[Pe,je]=E(null),Re=A(null),Ee=A(null),[Te,Be]=E(!1),Ce=A(null),[Ae,He]=E(null),Le=A(null),[Ne,De]=E(null),[Oe,Ye]=E(!1),Fe=A(null);C(()=>{Fe.current=Ne},[Ne]);const[Me,We]=E(ue.hasEditLock?{kind:"checking"}:{kind:"editing"}),Ge=A(Me);C(()=>{Ge.current=Me},[Me]);const Ke=A(()=>Promise.resolve(!1)),Ue=B(e=>{Ee.current=e,Be(!0)},[]),Ve=g({save:async({id:e,data:r})=>{if(p(Ge.current)){if(!await Ke.current(e,r)){if(!p(Ge.current))return void Ue({id:e,data:r});throw new Error("page save did not land")}}else Ue({id:e,data:r})},onFailure:(e,r)=>{0===r&&Z.send("storefront-editor:save-failed")}}),{state:Xe,push:xe,flush:Qe,pause:Je,resume:Ze,stop:ze,reset:_e,retryNow:qe,hasPending:$e}=Ve,er=A(Xe);C(()=>{er.current=Xe},[Xe]);const rr=u(Xe),nr=B(()=>{const e=Ee.current;e&&(Ee.current=null,Be(!1),xe(e))},[xe]),tr=A("");tr.current||(tr.current=h());const[or,ur]=E(0),ar=A(!1),[sr,ir]=E(M(j)),lr=A(!1);C(()=>{if(lr.current)return;lr.current=!0;const e=Z.address.search(),r=W(j,e);r?Z.address.load(r):M(j)&&ir(!1)},[j,Z]);const cr=Z.send;C(()=>{if(!de)return;let e=!1;const t=se.current,o=oe.resolve(re),u=z.documentHooks?.opening?.({slug:re,isTemplate:$,capabilities:ue});return o.then(async r=>{if(e)return;if(!r)return"page"===t.kind&&null!==F&&re!==F?void Z.address.load({kind:"page",slug:F,siteId:ne??void 0}):(be({target:t,slug:re,missing:!0,sentence:X?.(t)??null}),void x?.(t,null));const n=r.readOnlyReason?r.readOnlyReason:null;Re.current=n,je(n),ve(r.id),pe(r.kind??null),Le.current=r.version??null;const o=r.layout,a=o&&Object.keys(o).length?o:L,s=V(a),i=u?await u(s):s;e||ye(i)}).catch(o=>{e||(console.error("[storefront-editor] document load failed",o),be({target:t,slug:re,missing:!1,sentence:n(o,{slug:re},z),cause:r(o,z)}),x?.(t,o))}),()=>{e=!0}},[de,ie,$,oe,re]);const dr=B(e=>new Promise(r=>{const n=Date.now(),t=setInterval(()=>{const o=le.current;o&&o!==e?(clearInterval(t),r(o)):Date.now()-n>6e3&&(clearInterval(t),r(null))},200)}),[]),fr=B(async e=>{const r=le.current;if(!r&&z.usesBridgedToken)return{ok:!1,error:new Error("no editor token")};try{return{ok:!0,value:await e(r??"")}}catch(n){if(s(n,z)){cr("storefront-editor:auth-expired");const n=r?await dr(r):null;if(n)try{return{ok:!0,value:await e(n)}}catch(e){return{ok:!1,error:e}}}return{ok:!1,error:n}}},[cr,dr,z]),mr=B(async e=>{const r=le.current?await fr(e):{ok:!1};return r.ok||cr("storefront-editor:save-failed"),r.ok},[cr,fr]),kr=B(async(e,r,n=!1)=>{if(null!==Re.current)return!1;if(!p(Ge.current))return!1;if(Fe.current)return!1;const t=await fr(()=>oe.saveLayout(e,r,Le.current,tr.current));if(t.ok)return Le.current=t.value.version??Le.current,Ye(!1),!0;const o=q.readLockTaken(t.error);if(o){const e={kind:"takenover",holder:o};return Ge.current=e,We(e),!1}const u=q.readSaveConflict(t.error);if(u){if(u.savedByYou&&!n&&oe.rereadVersion){const n=await fr(()=>oe.rereadVersion(e));if(n.ok&&n.value)return Le.current=n.value,Ke.current(e,r,!0)}ze(),Fe.current=u,De(u)}return Ye(i(t.error,z)?.status===c),!1},[oe,fr,ze,z]);C(()=>{Ke.current=kr},[kr]);const vr=B(e=>{if(null!==Re.current)return;if(cr("storefront-editor:dirty"),!ke)return;const r=ae(e);Ce.current=r,p(Ge.current)?xe({id:ke,data:r}):Ue({id:ke,data:r})},[ke,cr,Ue,xe,ae]),gr=B(async()=>{p(Ge.current)&&nr();return await Qe()&&null==Ee.current},[nr,Qe]),pr=A(gr);C(()=>{pr.current=gr},[gr]);const hr=A(fr);C(()=>{hr.current=fr},[fr]);const yr=B(()=>{Z.address.reload()},[Z]),wr=A(()=>Promise.resolve(!1));C(()=>{wr.current=()=>{const e=oe.rereadVersion;return ke&&e?y({ours:Le.current,stored:async()=>{const r=await hr.current(()=>e(ke));return r.ok?r.value:null},hasPending:()=>null!=Ee.current||$e(),reload:yr}):Promise.resolve(!1)}},[oe,ke,$e,yr]);const br=null!==Pe;C(()=>{if(!fe||!ke||!de||br)return;let e=!1,r=null,n=null;const t=tr.current,o={claim:async e=>{const r=await hr.current(()=>fe.claim(ke,t,e));if(r.ok)return{heartbeat_seconds:r.value.heartbeatSeconds};throw r.error},cancelled:()=>e,currentAccess:()=>Ge.current,heldWrite:()=>({pending:null!=Ee.current||$e(),autoSaveEnabled:!er.current.paused,saveConflict:null!=Fe.current}),setAccess:e=>{Ge.current=e,We(e)},releaseHeldWrite:()=>{pr.current()},startHeartbeat:e=>{r&&clearInterval(r),r=setInterval(()=>{u(!1)},e)},stopHeartbeat:()=>{r&&(clearInterval(r),r=null)},reloadIfMoved:()=>{wr.current()}},u=q.makeClaimBeat(o),a=ar.current;return ar.current=!1,a||(We({kind:"checking"}),n=setTimeout(()=>{n=null,w(o)&&o.startHeartbeat(b)},S)),u(a).finally(()=>{n&&clearTimeout(n),n=null}),()=>{e=!0,n&&clearTimeout(n),r&&clearInterval(r),fe.release(ke,t).catch(()=>{})}},[ke,fe,de,ie,or,br]);const Sr=B(()=>{fe&&ke&&(ar.current=!0,ur(e=>e+1))},[ke,fe]),Ir=B(()=>{We(e=>{const r="blocked"===e.kind||"takenover"===e.kind?e.holder:null;return r?{kind:"readonly",holder:r}:e})},[]),Pr=B(()=>{er.current.paused?(p(Ge.current)&&nr(),Ze()):Je()},[nr,Je,Ze]),jr=B(()=>{qe()},[qe]),Rr=B(e=>{Ce.current=null,a("template"!==e.kind&&me,{resetAutosave:()=>{_e(),Ee.current=null,Be(!1)},setVersion:e=>{Le.current=e},setSaveConflict:De,setAccess:We}),G(e),J(e),Re.current=null,je(null),ve(null),pe(null),ye(null),be(null),Z.address.show(e),"document"!==e.kind&&K(e)&&Z.send("storefront-editor:navigated",{target:e})},[_e,Z,me,G,K]),Er=B(e=>{if(function(e,r,n){if(e.kind!==r.kind)return!1;if("template"===e.kind){const t=r;return e.id===t.id&&(e.pageSlug??n)===(t.pageSlug??n)}if("document"===e.kind){const n=r;return e.record===n.record&&(e.slug??"")===(n.slug??"")}const t=r;return e.slug===t.slug&&e.siteId===t.siteId}(e,se.current,F))return;const r=null!=Ee.current;if(!r&&!$e())return void Rr(e);const n=er.current;r||n.paused||n.failed||n.stopped?He(e):Qe().then(r=>{r?Rr(e):He(e)})},[Rr,$e,Qe,F]),Tr=B(()=>He(null),[]),Br=B(()=>{He(e=>(e&&Rr(e),null))},[Rr]),Cr=B(async()=>{const e=Ae;if(!e)return;await gr()&&(He(null),Rr(e))},[Ae,gr,Rr]),Ar=B(async e=>{if(null!==Re.current)return;if(!ke)return;if(!p(Ge.current)||Fe.current)return;const r=ae(e);if(!await kr(ke,r))return void(Fe.current||cr("storefront-editor:save-failed"));const n=oe.publish;if(!ue.canPublish||!n)return void cr("storefront-editor:saved");const t=await fr(()=>n(ke,Le.current??void 0));if(!t.ok){const{error:e}=t;return void cr("storefront-editor:publish-failed",{reason:e instanceof Error&&e.message?e.message:null})}Le.current=t.value.version??Le.current,cr("storefront-editor:published")},[ke,oe,ue.canPublish,cr,kr,fr,ae]);/* @__PURE__ */
2
+ return H(N.Provider,{value:{target:Q,adapter:oe,capabilities:ue,templateId:ee,currentSlug:re,currentKind:ge,siteId:ne,ready:de,token:ie,tokenRef:le,notifyParent:cr,bridgeCapabilities:ce,runAuthed:mr,docId:ke,data:he,getLiveData:()=>Ce.current??he,error:Ie,redirecting:sr,saveStatus:rr,saveState:Xe,autoSaveEnabled:!Xe.paused,autoSaveStoppedByConflict:Xe.stopped,hasUnsavedEdits:Xe.pending||Te,toggleAutoSave:Pr,retrySave:jr,onChange:vr,flushSave:gr,onPublish:Ar,access:Me,readOnly:null!==I(Me)||null!==Pe||null!==Ne,readOnlyReason:Pe,takeOverEditing:Sr,viewReadOnly:Ir,saveConflict:Ne,saveUnreachable:Oe,reloadFromServer:yr,navigate:Er,pendingNav:Ae,cancelPendingNav:Tr,discardAndNavigate:Br,saveAndNavigate:Cr},children:O})}export{N as ScreenDocumentContext,O as ScreenDocumentProvider,D as useScreenDocument};
@@ -1 +1 @@
1
- import{useEaselSession as e}from"./chunk-YM4UEGBV.js";import{useHostEscape as n}from"./chunk-LX23TCTP.js";import{DEFAULT_SCREEN_WORDS as t}from"./chunk-Q3VAJMXS.js";import{styleMenuItems as o}from"./chunk-CWELHADJ.js";import{ROOT_ZONE as l}from"./chunk-TCAAOYQY.js";import{repeatCopyAt as r}from"./chunk-JQQFB7EZ.js";import{easelMenuEntries as i,menuLabel as c}from"./chunk-FIVU2COQ.js";import{createNodeClipboard as s,nodeMenuItems as a}from"./chunk-P5VYGWYO.js";import{DEFAULT_NODE_MENU_WORDS as u}from"./chunk-WK3AFPXY.js";import{useCanvasEvent as d}from"./chunk-TOKMFZPB.js";import{isTypingTarget as p,framePointToHost as f}from"./chunk-FR7EEKFF.js";import{zoneKey as m,ROOT_SLOT as y,ROOT_ID as h}from"./chunk-EUFDQ4KL.js";import{useState as k,useCallback as b,useRef as v,useEffect as x}from"react";import{ContextMenu as g}from"efficient-shell/ui";import{TrashIcon as w,AddIcon as C,MoveUpIcon as O,MoveDownIcon as z,UndoIcon as A,RedoIcon as P,PasteIcon as E,StylesIcon as j,LayersIcon as M,CopyIcon as D}from"efficient-shell/icons/efficient";import{jsx as K}from"react/jsx-runtime";function T(e,n){const t=[],o=/* @__PURE__ */new Set;let r={zone:n.zone,index:n.index};for(;r;){const n=e.nodeAt(r.zone,r.index);if(!n||o.has(n.props.id))break;if(o.add(n.props.id),t.push({zone:r.zone,index:r.index,node:n,parentType:null}),r.zone===l)break;const i=r.zone.lastIndexOf(":");if(i<=0)break;r=e.locate(r.zone.slice(0,i))}for(let e=0;e<t.length-1;e+=1)t[e].parentType=t[e+1].node.type;return t}var L=s(),I=/* @__PURE__ */new WeakMap;function S(e){if(e.claimsPage)return L;const n=e.registry;if(!n)return e.cache("easel:node-clipboard",s);let t=I.get(n);return t||(t=s(),I.set(n,t)),t}function Y(){return S(e())}function F(e,n,t){if(n===l){const{floor:n,cap:o}=e.sectionBand();return{parentId:h,slot:y,index:Math.min(Math.max(t,n),o)}}const o=n.lastIndexOf(":");return{parentId:n.slice(0,o),slot:n.slice(o+1),index:t}}function X(e,n,t){const o=e.isPinned(n,t),l=!o&&!e.isLocked(n)&&!e.duplicateBlocked(n),r=e.permits?.(n)??{duplicate:!0,delete:!0};return{copy:!o&&r.duplicate,cut:l&&r.duplicate&&r.delete,delete:l&&r.delete}}function B(e,n,t){const o=e.canPasteAt;if(!o)return m(n.from)===t.zone?F(e,t.zone,t.index+1):null;for(const l of T(e,t)){const t=F(e,l.zone,l.index+1);if(o(n,t))return t}return null}function R(e){if(e.defaultPrevented||e.altKey||e.shiftKey)return null;if(p(e.target))return null;const n=e.target,t=n&&"ownerDocument"in n?n.ownerDocument??n:null,o=t?.getSelection?.();if(o&&!o.isCollapsed&&o.toString().trim())return null;if(!e.metaKey&&!e.ctrlKey)return"Delete"===e.key?"delete":null;const l=e.code||(1===e.key.length?`Key${e.key.toUpperCase()}`:"");return"KeyC"===l?"copy":"KeyX"===l?"cut":"KeyV"===l?"paste":null}function V(e,n,t,o){const l=e.nodeAt(t.zone,t.index);if(!l)return null;const r=l.props.id,i=e.labelOf(l.type,t.zone),c=X(e,l,t.zone);if("copy"===n)return c.copy?(e.nodeOps.copy(r,i),{done:"copied",name:i}):null;if(o.readOnly)return null;if("cut"===n)return c.cut?(e.nodeOps.cut(r,i),{done:"cut",name:i}):null;if("delete"===n)return c.delete?(e.nodeOps.remove(r),{done:"deleted",name:i}):null;const s=o.held;if(!s)return null;const a=e.isPinned(l,t.zone)?null:B(e,s,t);return a?(e.nodeOps.paste(a),{done:"pasted",name:s.label}):(e.onPasteRefused(s),{done:"refused",name:s.label})}function Q(e,n){const{zone:t,index:r}=n,i=e.nodeAt(t,r);if(!i)return[];const c=i.props.id,s=e.labelOf(i.type,t),u=Boolean(i.props._hidden),d=e.nodeOps,p=e.isPinned(i,t),f=e.isLocked(i),m=!p&&!f&&!e.duplicateBlocked(i),y=e.permits?.(i)??{duplicate:!0,delete:!0},h=X(e,i,t),k=T(e,n),b=d.held,v=b&&!p?B(e,b,n):null,x=!e.readOnly,g=e.style?o({held:x?e.style.held():null,canCopy:e.style.canCopy(i,t),onCopy:()=>e.style?.copy(i,t),onPaste:()=>e.style?.paste(t,r,i),words:e.words?.styleClipboard}):[];return a({title:s,words:e.words?.menu,layer:{group:"pick",items:k.flatMap((n,t)=>{const o={label:e.rowNameOf(n.node,n.zone),checked:0===t,onClick:()=>e.selectAt(n.zone,n.index,n.node.props.id,n.parentType)},r=n.zone===l?null:e.slotRung?.(n.zone)??null;return r?[o,{label:r.label,checked:!1,onClick:r.select}]:[o]})},actions:{duplicate:x&&m&&y.duplicate?()=>d.duplicate(c):void 0,...W(x&&!p,e=>d.canStep(c,e),e=>d.step(c,e)),copy:h.copy?()=>d.copy(c,s):void 0,cut:x&&h.cut?()=>d.cut(c,s):void 0,paste:x&&b&&v?{label:b.label,run:()=>d.paste(v)}:void 0,rename:x&&e.renamePropOf(i,t)?()=>e.beginRename(t,r):void 0,hide:!x||f||p?void 0:{hidden:u,run:()=>d.setProps(c,{_hidden:!u})},delete:x&&m&&y.delete?()=>d.remove(c):void 0},style:g,extras:N(x?U(e,n.copy):null,e.menuRows?.(i,t,r)),pinnedLine:p?Z(e).pinned:void 0})}function U(e,n){const o=e.copyItem;if(!o||!n)return null;const l=Z(e),r=t.menu,i=e=>l[e]??r[e]??"",c={ownerId:n.ownerId,slot:n.slot,index:n.index,...n.outer?{outer:n.outer}:{}},s=e=>()=>o({...c,action:e});return{make:[{label:i("itemAddAfter"),icon:/* @__PURE__ */K(C,{}),onClick:s("addAfter")},{label:i("itemMoveEarlier"),icon:/* @__PURE__ */K(O,{}),onClick:s("moveEarlier"),disabled:n.index<=0},{label:i("itemMoveLater"),icon:/* @__PURE__ */K(z,{}),onClick:s("moveLater"),disabled:n.index>=n.count-1}],remove:[{label:i("itemDelete"),icon:/* @__PURE__ */K(w,{}),danger:!0,onClick:s("delete")}]}}function N(e,n){if(!e)return n??void 0;if(!n)return e;return Object.fromEntries(["pick","make","change","remove"].map(t=>[t,[...e[t]??[],...n[t]??[]]]).filter(([,e])=>e.length>0))}function W(e,n,t){return e?{moveUp:n(-1)?()=>t(-1):null,moveDown:n(1)?()=>t(1):null}:{}}var Z=e=>e.words?.screen??t.menu;function J(e){const n=Z(e),o=!e.readOnly,r=[];o&&e.history.hasPast&&r.push({label:n.undo,icon:/* @__PURE__ */K(A,{}),shortcut:"⌘Z",onClick:e.history.back}),o&&e.history.hasFuture&&r.push({label:n.redo,icon:/* @__PURE__ */K(P,{}),shortcut:"⇧⌘Z",onClick:e.history.forward});const i=[],c=e.nodeOps.held,s=F(e,l,e.sectionBand().cap);if(o&&c&&(e.canPasteAt?e.canPasteAt(c,s):m(c.from)===l)){const n=s,t=e.words?.menu??u;i.push({label:t.pasteNamed({paste:t.paste,label:c.label}),icon:/* @__PURE__ */K(E,{}),shortcut:"⌘V",onClick:()=>e.nodeOps.paste(n)})}const a=[r,i,[...e.openPageStyles?[{label:e.pageStylesLabel??t.pageStyles,icon:/* @__PURE__ */K(j,{}),onClick:e.openPageStyles}]:[],{label:n.collapseAll,icon:/* @__PURE__ */K(M,{}),onClick:e.collapseAll}]].filter(e=>e.length>0),d={label:"—",onClick:()=>{}};return a.flatMap((e,n)=>n?[d,...e]:e)}function G(e,n){const t=n.selectionStart??0,o=n.selectionEnd??0,l=n.value.slice(t,o),r=e=>{n.focus(),n.setRangeText(e,t,o,"end"),n.dispatchEvent(new Event("input",{bubbles:!0}))},i=e.words?.menu??u,c=Z(e),s=[];l&&(s.push({label:i.copy,icon:/* @__PURE__ */K(D,{}),shortcut:"⌘C",onClick:()=>navigator.clipboard?.writeText(l)}),s.push({label:i.cut,icon:/* @__PURE__ */K(D,{}),shortcut:"⌘X",onClick:()=>{navigator.clipboard?.writeText(l),r("")}})),s.push({label:i.paste,icon:/* @__PURE__ */K(E,{}),shortcut:"⌘V",onClick:()=>{navigator.clipboard?.readText().then(e=>{e&&r(e)}).catch(()=>e.onPasteRefused())}});const a=[s,n.value?[{label:c.selectAll,shortcut:"⌘A",onClick:()=>{n.focus(),n.select()}}]:[]].filter(e=>e.length>0),d={label:"—",onClick:()=>{}};return a.flatMap((e,n)=>n?[d,...e]:e)}function _(e){return e.shiftKey}function H(e,t){const[o,l]=k(null),i=b(()=>l(null),[]);n(null!==o,i);const c=v(e);c.current=e;const s=b(e=>{const n=c.current,t=n.keys;if(!t)return;const o=R(e);if(!o)return;const l=t.selected();if(!l)return;const r=V(n,o,l,{readOnly:t.readOnly,held:t.held()});r&&(e.preventDefault(),t.onDone?.(r))},[]),a=e.keys?.target??null;x(()=>{if(!a)return;const e=e=>s(e);return a.addEventListener("keydown",e),()=>a.removeEventListener("keydown",e)},[a,s]),d(t,"keydown",s);const u=b(n=>{if(_(n))return;const t=n.target;if(t?.closest?.("[data-slot-zone]"))return n.preventDefault(),void l(null);const o=function(e){const n=e?.closest?.("input, textarea");return n&&("INPUT"!==n.tagName||["text","search","url","email","tel","number",""].includes(n.type))?n:null}(t);if(o)return n.preventDefault(),void l({kind:"input",x:n.clientX,y:n.clientY,el:o,owner:t});const r=t?.closest?.("[data-node-id]")?.getAttribute("data-node-id"),i=r?e.locate(r):null;n.preventDefault(),l(i?{kind:"node",x:n.clientX,y:n.clientY,...i,owner:t}:{kind:"empty",x:n.clientX,y:n.clientY,owner:t})},[e]);d(t,"contextmenu",n=>{if(_(n)||!t)return;const o=n.target?.closest?.("[data-easel-block]")??null,i=o?.getAttribute("data-easel-block"),c=i?e.locate(i):null;n.preventDefault();const s=f(t.frame,n.clientX,n.clientY),a=t.frame,u=o?r(o):null;l(c?{kind:"node",...s,...c,copy:u,owner:a}:{kind:"empty",...s,owner:a})}),d(t,"mousedown",i),d(t,"scroll",i,{on:"window"});return{onEditorContextMenu:u,menu:o?/* @__PURE__ */K($,{host:e,target:o,onClose:i}):null,closeMenu:i}}function $({host:e,target:n,onClose:t}){const o="node"===n.kind?Q(e,n):"input"===n.kind?G(e,n.el):J(e);return 0===o.length?null:/* @__PURE__ */K(g,{at:{x:n.x,y:n.y},owner:n.owner??null,onClose:t,"aria-label":c(o),items:i(o)})}export{L as EASEL_NODE_CLIPBOARD,T as ancestorChain,S as nodeClipboardOf,X as nodeClipboardRules,Q as nodeMenuItems,R as nodeShortcut,J as pageMenuItems,B as pastePlace,V as runNodeShortcut,G as textMenuItems,Y as useNodeClipboard,H as useNodeContextMenu};
1
+ import{useEaselSession as e}from"./chunk-YM4UEGBV.js";import{useHostEscape as n}from"./chunk-LX23TCTP.js";import{DEFAULT_SCREEN_WORDS as t}from"./chunk-C4TJN6GR.js";import{styleMenuItems as o}from"./chunk-CWELHADJ.js";import{ROOT_ZONE as l}from"./chunk-TCAAOYQY.js";import{repeatCopyAt as r}from"./chunk-JQQFB7EZ.js";import{easelMenuEntries as i,menuLabel as c}from"./chunk-FIVU2COQ.js";import{createNodeClipboard as s,nodeMenuItems as a}from"./chunk-P5VYGWYO.js";import{DEFAULT_NODE_MENU_WORDS as u}from"./chunk-WK3AFPXY.js";import{useCanvasEvent as d}from"./chunk-TOKMFZPB.js";import{isTypingTarget as p,framePointToHost as f}from"./chunk-FR7EEKFF.js";import{zoneKey as m,ROOT_SLOT as y,ROOT_ID as h}from"./chunk-EUFDQ4KL.js";import{useState as k,useCallback as b,useRef as v,useEffect as x}from"react";import{ContextMenu as g}from"efficient-shell/ui";import{TrashIcon as C,AddIcon as w,MoveUpIcon as O,MoveDownIcon as z,UndoIcon as P,RedoIcon as A,PasteIcon as E,StylesIcon as j,LayersIcon as D,CopyIcon as K}from"efficient-shell/icons/efficient";import{jsx as M}from"react/jsx-runtime";function T(e,n){const t=[],o=/* @__PURE__ */new Set;let r={zone:n.zone,index:n.index};for(;r;){const n=e.nodeAt(r.zone,r.index);if(!n||o.has(n.props.id))break;if(o.add(n.props.id),t.push({zone:r.zone,index:r.index,node:n,parentType:null}),r.zone===l)break;const i=r.zone.lastIndexOf(":");if(i<=0)break;r=e.locate(r.zone.slice(0,i))}for(let e=0;e<t.length-1;e+=1)t[e].parentType=t[e+1].node.type;return t}var L=s(),I=/* @__PURE__ */new WeakMap;function Y(e){if(e.claimsPage)return L;const n=e.registry;if(!n)return e.cache("easel:node-clipboard",s);let t=I.get(n);return t||(t=s(),I.set(n,t)),t}function F(){return Y(e())}function S(e,n,t){if(n===l){const{floor:n,cap:o}=e.sectionBand();return{parentId:h,slot:y,index:Math.min(Math.max(t,n),o)}}const o=n.lastIndexOf(":");return{parentId:n.slice(0,o),slot:n.slice(o+1),index:t}}function B(e,n,t){const o=e.isPinned(n,t),l=!o&&!e.isLocked(n)&&!e.duplicateBlocked(n),r=e.permits?.(n)??{duplicate:!0,delete:!0};return{copy:!o&&r.duplicate,cut:l&&r.duplicate&&r.delete,delete:l&&r.delete}}function R(e,n,t){const o=e.canPasteAt;if(!o)return m(n.from)===t.zone?S(e,t.zone,t.index+1):null;for(const l of T(e,t)){const t=S(e,l.zone,l.index+1);if(o(n,t))return t}return null}function X(e){if(e.defaultPrevented||e.altKey||e.shiftKey)return null;if(p(e.target))return null;const n=e.target,t=n&&"ownerDocument"in n?n.ownerDocument??n:null,o=t?.getSelection?.();if(o&&!o.isCollapsed&&o.toString().trim())return null;if(!e.metaKey&&!e.ctrlKey)return"Delete"===e.key?"delete":null;const l=e.code||(1===e.key.length?`Key${e.key.toUpperCase()}`:"");return"KeyC"===l?"copy":"KeyX"===l?"cut":"KeyV"===l?"paste":null}function U(e,n,t,o){const l=e.nodeAt(t.zone,t.index);if(!l)return null;const r=l.props.id,i=e.labelOf(l.type,t.zone),c=B(e,l,t.zone);if("copy"===n)return c.copy?(e.nodeOps.copy(r,i),{done:"copied",name:i}):null;if(o.readOnly)return null;if("cut"===n)return c.cut?(e.nodeOps.cut(r,i),{done:"cut",name:i}):null;if("delete"===n)return c.delete?(e.nodeOps.remove(r),{done:"deleted",name:i}):null;const s=o.held;if(!s)return null;const a=e.isPinned(l,t.zone)?null:R(e,s,t);return a?(e.nodeOps.paste(a),{done:"pasted",name:s.label}):(e.onPasteRefused(s),{done:"refused",name:s.label})}function V(e,n){const{zone:t,index:r}=n,i=e.nodeAt(t,r);if(!i)return[];const c=i.props.id,s=e.labelOf(i.type,t),u=Boolean(i.props._hidden),d=e.nodeOps,p=e.isPinned(i,t),f=e.isLocked(i),m=!p&&!f&&!e.duplicateBlocked(i),y=e.permits?.(i)??{duplicate:!0,delete:!0},h=B(e,i,t),k=T(e,n),b=d.held,v=b&&!p?R(e,b,n):null,x=!e.readOnly,g=e.style?o({held:x?e.style.held():null,canCopy:e.style.canCopy(i,t),onCopy:()=>e.style?.copy(i,t),onPaste:()=>e.style?.paste(t,r,i),words:e.words?.styleClipboard}):[];return a({title:s,words:e.words?.menu,layer:{group:"pick",items:k.flatMap((n,t)=>{const o={label:e.rowNameOf(n.node,n.zone),checked:0===t,onClick:()=>e.selectAt(n.zone,n.index,n.node.props.id,n.parentType)},r=n.zone===l?null:e.slotRung?.(n.zone)??null;return r?[o,{label:r.label,checked:!1,onClick:r.select}]:[o]})},actions:{duplicate:x&&m&&y.duplicate?()=>d.duplicate(c):void 0,...W(x&&!p,e=>d.canStep(c,e),e=>d.step(c,e)),copy:h.copy?()=>d.copy(c,s):void 0,cut:x&&h.cut?()=>d.cut(c,s):void 0,paste:x&&b&&v?{label:b.label,run:()=>d.paste(v)}:void 0,rename:x&&e.renamePropOf(i,t)?()=>e.beginRename(t,r):void 0,hide:!x||f||p?void 0:{hidden:u,run:()=>d.setProps(c,{_hidden:!u})},delete:x&&m&&y.delete?()=>d.remove(c):void 0},style:g,extras:Q(x?N(e,n.copy):null,e.menuRows?.(i,t,r)),pinnedLine:p?Z(e).pinned:void 0})}function N(e,n){const o=e.copyItem;if(!o||!n)return null;const l=Z(e),r=t.menu,i=e=>l[e]??r[e]??"",c={ownerId:n.ownerId,slot:n.slot,index:n.index,...n.outer?{outer:n.outer}:{}},s=e=>()=>o({...c,action:e});return{make:[{label:i("itemAddAfter"),icon:/* @__PURE__ */M(w,{}),onClick:s("addAfter")},{label:i("itemMoveEarlier"),icon:/* @__PURE__ */M(O,{}),onClick:s("moveEarlier"),disabled:n.index<=0},{label:i("itemMoveLater"),icon:/* @__PURE__ */M(z,{}),onClick:s("moveLater"),disabled:n.index>=n.count-1}],remove:[{label:i("itemDelete"),icon:/* @__PURE__ */M(C,{}),danger:!0,onClick:s("delete")}]}}function Q(e,n){if(!e)return n??void 0;if(!n)return e;return Object.fromEntries(["pick","make","change","remove"].map(t=>[t,[...e[t]??[],...n[t]??[]]]).filter(([,e])=>e.length>0))}function W(e,n,t){return e?{moveUp:n(-1)?()=>t(-1):null,moveDown:n(1)?()=>t(1):null}:{}}var Z=e=>e.words?.screen??t.menu;function G(e){const n=Z(e),o=!e.readOnly,r=[];o&&e.history.hasPast&&r.push({label:n.undo,icon:/* @__PURE__ */M(P,{}),shortcut:"⌘Z",onClick:e.history.back}),o&&e.history.hasFuture&&r.push({label:n.redo,icon:/* @__PURE__ */M(A,{}),shortcut:"⇧⌘Z",onClick:e.history.forward});const i=[],c=e.nodeOps.held,s=S(e,l,e.sectionBand().cap);if(o&&c&&(e.canPasteAt?e.canPasteAt(c,s):m(c.from)===l)){const n=s,t=e.words?.menu??u;i.push({label:t.pasteNamed({paste:t.paste,label:c.label}),icon:/* @__PURE__ */M(E,{}),shortcut:"⌘V",onClick:()=>e.nodeOps.paste(n)})}const a=[r,i,[...e.openPageStyles?[{label:e.pageStylesLabel??t.pageStyles,icon:/* @__PURE__ */M(j,{}),onClick:e.openPageStyles}]:[],{label:n.collapseAll,icon:/* @__PURE__ */M(D,{}),onClick:e.collapseAll}]].filter(e=>e.length>0),d={label:"—",onClick:()=>{}};return a.flatMap((e,n)=>n?[d,...e]:e)}function J(e,n){const t=n.selectionStart??0,o=n.selectionEnd??0,l=n.value.slice(t,o),r=e=>{n.focus(),n.setRangeText(e,t,o,"end"),n.dispatchEvent(new Event("input",{bubbles:!0}))},i=e.words?.menu??u,c=Z(e),s=[];l&&(s.push({label:i.copy,icon:/* @__PURE__ */M(K,{}),shortcut:"⌘C",onClick:()=>navigator.clipboard?.writeText(l)}),s.push({label:i.cut,icon:/* @__PURE__ */M(K,{}),shortcut:"⌘X",onClick:()=>{navigator.clipboard?.writeText(l),r("")}})),s.push({label:i.paste,icon:/* @__PURE__ */M(E,{}),shortcut:"⌘V",onClick:()=>{navigator.clipboard?.readText().then(e=>{e&&r(e)}).catch(()=>e.onPasteRefused())}});const a=[s,n.value?[{label:c.selectAll,shortcut:"⌘A",onClick:()=>{n.focus(),n.select()}}]:[]].filter(e=>e.length>0),d={label:"—",onClick:()=>{}};return a.flatMap((e,n)=>n?[d,...e]:e)}function _(e){return e.shiftKey}function H(e,t){const[o,l]=k(null),i=b(()=>l(null),[]);n(null!==o,i);const c=v(e);c.current=e;const s=b(e=>{const n=c.current,t=n.keys;if(!t)return;const o=X(e);if(!o)return;const l=t.selected();if(!l)return;const r=U(n,o,l,{readOnly:t.readOnly,held:t.held()});r&&(e.preventDefault(),t.onDone?.(r))},[]),a=e.keys?.target??null;x(()=>{if(!a)return;const e=e=>s(e);return a.addEventListener("keydown",e),()=>a.removeEventListener("keydown",e)},[a,s]),d(t,"keydown",s);const u=b(n=>{if(_(n))return;const t=n.target;if(t?.closest?.("[data-slot-zone]"))return n.preventDefault(),void l(null);const o=function(e){const n=e?.closest?.("input, textarea");return n&&("INPUT"!==n.tagName||["text","search","url","email","tel","number",""].includes(n.type))?n:null}(t);if(o)return n.preventDefault(),void l({kind:"input",x:n.clientX,y:n.clientY,el:o,owner:t});const r=t?.closest?.("[data-node-id]")?.getAttribute("data-node-id"),i=r?e.locate(r):null;n.preventDefault(),l(i?{kind:"node",x:n.clientX,y:n.clientY,...i,owner:t}:{kind:"empty",x:n.clientX,y:n.clientY,owner:t})},[e]);d(t,"contextmenu",n=>{if(_(n)||!t)return;const o=n.target?.closest?.("[data-easel-block]")??null,i=o?.getAttribute("data-easel-block"),c=i?e.locate(i):null;n.preventDefault();const s=f(t.frame,n.clientX,n.clientY),a=t.frame,u=o?r(o):null;l(c?{kind:"node",...s,...c,copy:u,owner:a}:{kind:"empty",...s,owner:a})}),d(t,"mousedown",i),d(t,"scroll",i,{on:"window"});return{onEditorContextMenu:u,menu:o?/* @__PURE__ */M($,{host:e,target:o,onClose:i}):null,closeMenu:i}}function $({host:e,target:n,onClose:t}){const o="node"===n.kind?V(e,n):"input"===n.kind?J(e,n.el):G(e);return 0===o.length?null:/* @__PURE__ */M(g,{at:{x:n.x,y:n.y},owner:n.owner??null,onClose:t,"aria-label":c(o),items:i(o)})}export{L as EASEL_NODE_CLIPBOARD,T as ancestorChain,Y as nodeClipboardOf,B as nodeClipboardRules,V as nodeMenuItems,X as nodeShortcut,G as pageMenuItems,R as pastePlace,U as runNodeShortcut,J as textMenuItems,F as useNodeClipboard,H as useNodeContextMenu};
@@ -0,0 +1,17 @@
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-BLE3U2GS.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,useEasel as f}from"./chunk-NUJEHA6A.js";import{DEFAULT_PANEL_WORDS as b}from"./chunk-56ID6FKZ.js";import{SettingsSwitch as m}from"./chunk-OECWLNKJ.js";import{FieldSelect as h}from"./chunk-KFWNGPW3.js";import{SettingsField as v}from"./chunk-MIX7EGRG.js";import{SettingsSegmented as g}from"./chunk-DX3VILZ3.js";import{useWords as y}from"./chunk-MFIRYGHW.js";import{useState as k}from"react";import{AlignmentIcon as w,BoxJustifyIcon as x,WrapIcon as C,ArrowRightIcon as j,GapIcon as F,WidthIcon as L,PlacementIcon as O,NudgeIcon as E,DesktopIcon as S,BoxXEndIcon as P,BoxXCenterIcon as A,BoxXStartIcon as R,PaddingAllIcon as M,BoxYBetweenIcon as I,BoxYStretchIcon as K,BoxYEndIcon as W,BoxYCenterIcon as B,BoxYStartIcon as N,BoxXBetweenIcon as $,BoxXStretchIcon as G,BoxItemAlignmentIcon as T}from"efficient-shell/icons/efficient";import{textAlignOptions as V,AlignmentGrid as J,PositionInput as H,Slider as D}from"efficient-shell/ui";import{jsx as _,Fragment as z,jsxs as X}from"react/jsx-runtime";var Y=e=>e;function U(e,n){return e("{value} on desktop").replace("{value}",n)}var Z=()=>{};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 _(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__ */_(z,{})}}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 Ee(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 Se(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();return t=>{n&&n.onChangeMany(n=>{let l={};for(const[o,a]of t)l={...l,...e.write({...n,...l},o,a)};return l})}}var Ae={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 Me(e){return{...Ee(e),fieldKey:n=>`_${e}_${n}`}}function Ie({row:e,desktopKey:n,access:t,props:l}){const o=p(),a=o?.values?.[n],[i,r]=Se(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__ */_(Ie,{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 _(g,{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 Ne(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 _(v,{label:e(n),icon:/* @__PURE__ */_(O,{}),hint:a?.title?e(a.title):void 0,children:/* @__PURE__ */_(J,{label:e(n),value:t,points:i,onChange:l})})}function $e({say:e,label:n,value:t,onChange:l,pointsFor:o}){const{appState:a,selectedItem:i}=f(e=>e),r=i?.props?.id?String(i.props.id):void 0;return Ne(e,{label:n,value:t,onChange:l,points:o(a?.data,r)})}function Ge({say:e,o:n}){const t=p(),o=y("panel",b),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__ */_(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__ */_(l,{words:o,label:r,changed:s,detail:"0 px, 0 px",onReset:()=>u({x:null,y:null})});return null===n.label?/* @__PURE__ */X("div",{className:"sf-position-line",children:[c,d]}):/* @__PURE__ */_(v,{label:r,icon:/* @__PURE__ */_(E,{}),changed:s,action:d,children:c})}var Te={x:{start:/* @__PURE__ */_(R,{}),center:/* @__PURE__ */_(A,{}),end:/* @__PURE__ */_(P,{}),stretch:/* @__PURE__ */_(G,{}),between:/* @__PURE__ */_($,{})},y:{start:/* @__PURE__ */_(N,{}),center:/* @__PURE__ */_(B,{}),end:/* @__PURE__ */_(W,{}),stretch:/* @__PURE__ */_(K,{}),between:/* @__PURE__ */_(I,{})}},Ve=e=>"row"===e?"row":"column";function Je({say:e,kind:n,label:t,options:l,value:o,onChange:a,o:i}){const r=p(),s="justify"===n==("row"===(i.runs??Ve)(r?.values?.[i.directionKey??"direction"]))?"x":"y";return Be(e,{options:l.map(e=>({label:e.label,value:e.value,picture:Te[s][e.value]})),value:o,onChange:a,ariaLabel:t})}function He(e,n){const t=(e.useFallback??Z)(n);return Object.fromEntries(xe.map(n=>[n,t?.[n]??e.fallback[n]]))}function De({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 _(ze,{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 _e({say:e,o:n,props:t}){const l=He(n,t);/* @__PURE__ */
6
+ return _(ze,{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 ze({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]=k(()=>e(r,d)),m=y("panel",b),h=xe.map(e=>d[e]),g=`${1===new Set(h).size?h[0]:h.join(" / ")}px`;/* @__PURE__ */
7
+ return _(v,{label:o(a.label),icon:a.icon??/* @__PURE__ */_(M,{}),action:/* @__PURE__ */X(z,{children:[
8
+ /* @__PURE__ */_(t,{each:p,label:o("Each side"),onChange:f,disabled:u}),
9
+ /* @__PURE__ */_(l,{words:m,label:o(a.label),changed:xe.some(e=>"number"==typeof r[e]),detail:s?U(o,g):g,disabled:u,onReset:()=>c({top:null,right:null,bottom:null,left:null})})]}),children:/* @__PURE__ */_(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 Xe=e=>""===e||"px"===e?e:` ${e}`;function Ye({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__ */_(l,{label:e,changed:m,detail:f??u??(void 0===s?void 0:`${s}${Xe(r)}`),disabled:d,onReset:()=>t(void 0),...b?{words:b}:{}}):void 0;return{track:/* @__PURE__ */_("div",{className:"sf-slider",children:/* @__PURE__ */_(D,{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 Ue({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}=Ye({...a,label:n,value:r?t:i?null:a.min,hint:l,emptyLabel:o,clears:i});/* @__PURE__ */
10
+ return _(v,{label:e??n,action:u,children:s})}function Ze({draw:e,props:n,useMax:t,useHint:l}){return e(n,{max:(t??Z)(n),hint:(l??Z)(n)})}function qe(e=Y){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,g="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=Xe(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}=Ye({label:e(n),value:g?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?U(e,C):C});/* @__PURE__ */
11
+ return _(v,{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__ */_(Ze,{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 _(v,{label:e(n),icon:ne(o),action:/* @__PURE__ */_(l,{label:e(n),changed:p,detail:U(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 _(v,{label:e(n),icon:ne(o),action:"follows"in a&&s.followsLabel?/* @__PURE__ */_(l,{label:e(n),changed:null!=r&&""!==r,detail:void 0===b?void 0:U(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__ */_(S,{})}):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(V(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__ */_(w,{}),f(e),n,t?{followsLabel:t}:{}),e)}function g(e){const n={left:Te.x.start,center:Te.x.center,right:Te.x.end};return c(V((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__ */_(x,{}),g(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 _(v,{label:e(t),icon:ne(l),children:/* @__PURE__ */_(Je,{say:e,kind:n,label:t,options:c,value:p,onChange:s,o:i})})}}}function O(e={}){return k("justify","Justify",/* @__PURE__ */_(x,{}),ie,ie[0].value,e)}function E(e={}){return k("align","Item alignment",/* @__PURE__ */_(T,{}),re,"stretch",e)}function P(){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 _(v,{label:e(n),labelId:i,icon:/* @__PURE__ */_(C,{}),action:/* @__PURE__ */_(m,{checked:(r=t,!0===r||"wrap"===r),onChange:e=>l(e?ue[0].value:ue[1].value),ariaLabelledBy:i})});var r}}}function A({offered:e,fallback:n,resolve:t}){const l=t??(t=>e.some(e=>e.value===t)?t:n),o=s(ce,
16
+ /* @__PURE__ */_(j,{}),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 R({min:e,max:t,step:l,builtIn:o,resolve:a,action:i,mark:r}){const s=n("Gap",/* @__PURE__ */_(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 M(n,{fallback:t=me,pointsFor:l}={}){return{type:"custom",render:({value:o,onChange:a})=>{const i=ge(o,t);return l?/* @__PURE__ */_($e,{say:e,label:n,value:i,onChange:a,pointsFor:l}):Ne(e,{label:n,value:i,onChange:a,points:ve})}}}function I(n){return{[n.keys.x]:{type:"custom",render:()=>/* @__PURE__ */_(Ge,{say:e,o:n})},[n.keys.y]:{...a({type:"custom",render:()=>/* @__PURE__ */_(i,{})},"always"),reachedBy:n.keys.x}}}function K(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__ */_(_e,{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__ */_(De,{say:e,tier:n,o:l,props:t})};return r?o(n,t):t},d=()=>a({type:"custom",render:()=>/* @__PURE__ */_(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){const{note:s,phoneRest:u}="string"==typeof i?{note:i,phoneRest:void 0}:i??{};return{type:"custom",options:o,fallback:a,...s?{note:s}:{},...r({},{type:"select",label:n}),render:i=>{const{value:r,onChange:c,field:d}=i,p=d.options??o,f=d.fallback??a,b=p.some(e=>e.value===r),m="follows"in i,g=m?u?u(i.follows):i.follows:void 0,y=m?p.find(e=>e.value===g)??p.find(e=>e.value===f):void 0,k=b?r:y?.value??f,w=!0===i.readOnly;/* @__PURE__ */
17
+ return _(v,{label:e(n),icon:ne(t),action:m?/* @__PURE__ */_(l,{label:e(n),changed:null!=r&&""!==r,detail:y?U(e,e(y.label)):void 0,disabled:w,onReset:()=>c(void 0)}):void 0,children:/* @__PURE__ */_(h,{value:k,ariaLabel:e(n),readOnly:w,onChange:c,options:[...s?[{label:e(s),value:"\0note",disabled:!0}]:[],...p.map(n=>({label:e(n.label),value:n.value}))]})})}}},Segmented:t,segmented:s,boxJustifyField:O,boxAlignField:E,boxWrapField:P,directionField:A,gapField:R,placementField:M,PlacementGridView:function(n){return Ne(e,n)},positionFields:I,sidesPaddingFields:K,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,g,n)},BlockAlignmentStrip:function({opts:e={},value:n,onChange:l,ariaLabel:o,disabled:a=!1}){return t({options:g(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:M("Placement",e.placement),width:n("Width",/* @__PURE__ */_(L,{}),t.min,t.max,t.step,t.fallback,"%"),direction:A(o),gap:R(e.gap??pe),justify:O(i),align:E(i),wrap:P(),_gNudge:oe("Nudge"),...I({keys:e.nudge?.keys??{x:"nudgeX",y:"nudgeY"},min:-l,max:l,label:null}),...K(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,Ae as FLAT_ACCESS,ve as OPEN_PLACEMENT_POINTS,Re as PHONE_KEY_ACCESS,cn as PlacementGridView,Ce as SIDE_PAD_KEYS,nn as Segmented,Ue 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,Ee as objectAccess,U as onDesktopWords,Me 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,Se as useAccessValue};
@@ -0,0 +1,5 @@
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-NUJEHA6A.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={},O=()=>b,j=()=>"",C=()=>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},N={options:[{id:"desktop",label:"Desktop",icon:/* @__PURE__ */f(c,{})}],initial:"desktop",fluid:"desktop",widths:{desktop:2e3}},A={read:()=>"sections",write:()=>{},forSelection:(n,e)=>n?"sections":e},P={first:null,last:null,firstGroup:null,lastGroup:null,isSectionGroup:()=>!1,sectionGroupZone:()=>"",panelOf:()=>null};function B(){/* @__PURE__ */
2
+ return f(r,{height:"fill"})}function D(){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 I(){return s(F)}function x(){return(I().useOwnerName??j)()}function T(){return(I().useDocumentLabel??C)()}function E(n,e,t,r){return(I().useBridges??O)(n,e,t,r)}function Y(n){return(I().useStandaloneBridges??O)(n)}function H(n,e){(I().useDocumentPass??w)(n,e)}function M(){return I().blockRules??S}function Q(){return I().blockLook??L}function R(){return I().devices??N}function V(){return I().leftView??A}function W(){return I().pinned??P}function X(){return I().saveSwitch??!0}function J(e){n(!0===I().pickFollowsSelection,e)}function K(){return I().storageNamespace||void 0}function U(){return I().styleClipboard??null}function Z(){return I().nodeKeys??!0}function q(){return I().notify??null}function z(){return I().Canvas??B}function $(){return I().CanvasHead??null}function _(){return I().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 I().Inspector??D}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,Q as useScreenBlockLook,M as useScreenBlockRules,E as useScreenBridges,_ as useScreenCanvasDrag,z as useScreenCanvasFrame,$ as useScreenCanvasHead,tn as useScreenCanvasTarget,R as useScreenDevices,T as useScreenDocumentLabel,H as useScreenDocumentPass,rn as useScreenInspectorPanel,V as useScreenLeftView,Z as useScreenNodeKeys,q as useScreenNotify,x as useScreenOwnerName,I as useScreenParts,J as useScreenPickFollowsSelection,W as useScreenPinned,X as useScreenSaveSwitch,K as useScreenStorageNamespace,U as useScreenStyleClipboard,Y as useStandaloneScreenBridges};
@@ -1,4 +1,4 @@
1
- import{useAccessPatch as e,FLAT_ACCESS as o,onDesktopWords as r,useAccessValue as t}from"./chunk-UMRYCN7L.js";import{CornersInput as s,BorderInput as l,SettingsColour as n}from"./chunk-CLAADE4J.js";import{SettingsDefaultReset as i}from"./chunk-2T22IY3J.js";import{noControlField as c,NoControlMark as a}from"./chunk-22I55W37.js";import{normalizeCornerSides as d,CORNER_SIDES as u}from"./chunk-PLTTPHK5.js";import{DEFAULT_PANEL_WORDS as p,DEFAULT_COLOUR_ROW_WORDS as y}from"./chunk-56ID6FKZ.js";import{SettingsField as h}from"./chunk-MIX7EGRG.js";import{useWords as f}from"./chunk-MFIRYGHW.js";import{CornerIcon as m,BorderAllIcon as b}from"efficient-shell/icons/efficient";import{jsx as w}from"react/jsx-runtime";var g=e=>e;function v(e,o){const r=o.twinAccess;return r?{key:e.key,access:r,ownField:r.ownField}:e}function k(e,r){const s=!e.access||e.ownField?{value:r.value,onChange:r.onChange}:void 0;return t(e.access??o,e.key,s)}function F(e,r){return t(e.access??o,r??"")}function j(e){return{...c({type:"custom",render:()=>/* @__PURE__ */w(a,{})},"always"),reachedBy:e}}function C({o:t,say:s,props:l}){const i=f("colourRow",y),c=f("panel",p),a=t.useFollows(),d=t.usePresets?.(),u=t.opacity?.useUnset?.()??100,h=v(t,l),[m,b]=k(h,l),[g,j]=F(h,t.opacity?.key),C=e(h.access??o),B="string"==typeof m?m:"",O="number"==typeof g,A="follows"in l,R=(A&&"string"==typeof l.follows&&""!==l.follows?l.follows:void 0)??a,T=t.access||A?void 0:"";/* @__PURE__ */
2
- return w(n,{label:s(t.label),icon:t.icon,hint:t.hint,value:B,onChange:e=>b(""===e?T:e),inherited:R,presets:d,changed:""!==B||O,onReset:()=>{O&&t.opacity?C([[t.key,T],[t.opacity.key,void 0]]):b(T)},resetTo:A?r(s,R.toUpperCase()):t.resetTo?t.resetTo(a.toUpperCase()):a.toUpperCase(),...t.opacity?{opacity:O?g:u,onOpacityChange:e=>j(e)}:{},readOnly:l.readOnly,words:i,resetWords:c})}var B=20;function O({o:e,say:o,props:t}){const s=e.useFollows(),[n,c]=k(v(e,t),t),a=n&&"object"==typeof n?n:{},d="follows"in t,u=d&&t.follows&&"object"==typeof t.follows?t.follows:{},p="number"==typeof u.width?u.width:s.width,y="string"==typeof u.color&&""!==u.color?u.color:s.color,f=Object.keys(a).length>0,m={width:o("Border width"),sides:{top:o("Border top"),right:o("Border right"),bottom:o("Border bottom"),left:o("Border left")},style:o("Border style"),styles:{solid:o("Solid"),dashed:o("Dashed"),dotted:o("Dotted")},color:o("Border color"),unit:"px"};/* @__PURE__ */
3
- return w(h,{label:o("Border"),icon:/* @__PURE__ */w(b,{}),action:d?/* @__PURE__ */w(i,{label:o("Border"),changed:f,detail:r(o,`${p}px`),disabled:t.readOnly,onReset:()=>c(void 0)}):void 0,children:/* @__PURE__ */w(l,{label:o("Border"),value:a,each:!1,onChange:o=>c(function(e){const o=Object.fromEntries(Object.entries(e).filter(([,e])=>null!=e&&""!==e));return Object.keys(o).length?o:void 0}(e.styles?{width:o.width,color:o.color,style:o.style}:{width:o.width,color:o.color})),placeholder:{sides:{top:p,right:p,bottom:p,left:p},style:u.style??"solid",color:y},presets:[y],words:m,styles:e.styles??!1,max:20,readOnly:t.readOnly})})}var A=40,R=()=>null;function T({o:r,say:t,props:l}){const n=f("panel",p),c=r.useFollows(),[a,y]=k(r,l),[b,g]=F(r,r.sidesKey),v=e(r.access??o),j=r.access?void 0:null,C="number"==typeof a&&Number.isFinite(a)?a:null,B=d((r.useFollowsSides??R)())??[...u],O=d(b)??B,A=[{value:"tl",label:t("Top left")},{value:"tr",label:t("Top right")},{value:"bl",label:t("Bottom left")},{value:"br",label:t("Bottom right")}];/* @__PURE__ */
4
- return w(h,{label:t("Corners"),icon:/* @__PURE__ */w(m,{}),changed:null!==C||Array.isArray(b),action:/* @__PURE__ */w(i,{label:t("Corners"),changed:null!==C||Array.isArray(b),detail:`${c}px`,onReset:()=>Array.isArray(b)?v([[r.key,j],[r.sidesKey,j]]):y(j),words:n}),children:/* @__PURE__ */w(s,{label:t("Corners"),value:O,corners:A,onChange:e=>{const o=u.filter(o=>e.includes(o)),r=o.length===B.length&&o.every(e=>B.includes(e));g(r?j:o)},radius:C,onRadiusChange:e=>y(e??j),radiusMin:0,radiusMax:40,radiusStep:r.step??1,radiusPlaceholder:String(c),disabled:l.readOnly})})}function x(e=g){return{colourField:o=>({type:"custom",render:r=>/* @__PURE__ */w(C,{o:o,say:e,props:r})}),borderField:o=>({type:"custom",render:r=>/* @__PURE__ */w(O,{o:o,say:e,props:r})}),cornersField:o=>({type:"custom",render:r=>/* @__PURE__ */w(T,{o:o,say:e,props:r})})}}var{colourField:I,borderField:M,cornersField:U}=x();export{B as BORDER_WIDTH_MAX,A as CORNER_RADIUS_MAX,M as borderField,I as colourField,U as cornersField,j as keptByRow,x as styleFieldBuilders};
1
+ import{useAccessPatch as e,FLAT_ACCESS as o,onDesktopWords as r,useAccessValue as t}from"./chunk-K6TDOXHR.js";import{CornersInput as s,BorderInput as l,SettingsColour as n}from"./chunk-CLAADE4J.js";import{SettingsDefaultReset as i}from"./chunk-2T22IY3J.js";import{noControlField as c,NoControlMark as a}from"./chunk-22I55W37.js";import{normalizeCornerSides as d,CORNER_SIDES as u}from"./chunk-PLTTPHK5.js";import{DEFAULT_PANEL_WORDS as p,DEFAULT_COLOUR_ROW_WORDS as y}from"./chunk-56ID6FKZ.js";import{SettingsField as h}from"./chunk-MIX7EGRG.js";import{useWords as f}from"./chunk-MFIRYGHW.js";import{CornerIcon as m,BorderAllIcon as b}from"efficient-shell/icons/efficient";import{jsx as w}from"react/jsx-runtime";var g=e=>e;function v(e,o){const r=o.twinAccess;return r?{key:e.key,access:r,ownField:r.ownField}:e}function k(e,r){const s=!e.access||e.ownField?{value:r.value,onChange:r.onChange}:void 0;return t(e.access??o,e.key,s)}function F(e,r){return t(e.access??o,r??"")}function j(e){return{...c({type:"custom",render:()=>/* @__PURE__ */w(a,{})},"always"),reachedBy:e}}function C({o:t,say:s,props:l}){const i=f("colourRow",y),c=f("panel",p),a=t.useFollows(),d=t.usePresets?.(),u=t.opacity?.useUnset?.()??100,h=v(t,l),[m,b]=k(h,l),[g,j]=F(h,t.opacity?.key),C=e(h.access??o),B="string"==typeof m?m:"",O="number"==typeof g,A="follows"in l,T=(A&&"string"==typeof l.follows&&""!==l.follows?l.follows:void 0)??a,R=t.access||A?void 0:"";/* @__PURE__ */
2
+ return w(n,{label:s(t.label),icon:t.icon,hint:t.hint,value:B,onChange:e=>b(""===e?R:e),inherited:T,presets:d,changed:""!==B||O,onReset:()=>{O&&t.opacity?C([[t.key,R],[t.opacity.key,void 0]]):b(R)},resetTo:A?r(s,T.toUpperCase()):t.resetTo?t.resetTo(a.toUpperCase()):a.toUpperCase(),...t.opacity?{opacity:O?g:u,onOpacityChange:e=>j(e)}:{},readOnly:l.readOnly,words:i,resetWords:c})}var B=20;function O({o:e,say:o,props:t}){const s=e.useFollows(),[n,c]=k(v(e,t),t),a=n&&"object"==typeof n?n:{},d="follows"in t,u=d&&t.follows&&"object"==typeof t.follows?t.follows:{},p="number"==typeof u.width?u.width:s.width,y="string"==typeof u.color&&""!==u.color?u.color:s.color,f=Object.keys(a).length>0,m={width:o("Border width"),sides:{top:o("Border top"),right:o("Border right"),bottom:o("Border bottom"),left:o("Border left")},style:o("Border style"),styles:{solid:o("Solid"),dashed:o("Dashed"),dotted:o("Dotted")},color:o("Border color"),unit:"px"};/* @__PURE__ */
3
+ return w(h,{label:o("Border"),icon:/* @__PURE__ */w(b,{}),action:d?/* @__PURE__ */w(i,{label:o("Border"),changed:f,detail:r(o,`${p}px`),disabled:t.readOnly,onReset:()=>c(void 0)}):void 0,children:/* @__PURE__ */w(l,{label:o("Border"),value:a,each:!1,onChange:o=>c(function(e){const o=Object.fromEntries(Object.entries(e).filter(([,e])=>null!=e&&""!==e));return Object.keys(o).length?o:void 0}(e.styles?{width:o.width,color:o.color,style:o.style}:{width:o.width,color:o.color})),placeholder:{sides:{top:p,right:p,bottom:p,left:p},style:u.style??"solid",color:y},presets:[y],words:m,styles:e.styles??!1,max:20,readOnly:t.readOnly})})}var A=40,T=()=>null;function R({o:r,say:t,props:l}){const n=f("panel",p),c=r.useFollows(),[a,y]=k(r,l),[b,g]=F(r,r.sidesKey),v=e(r.access??o),j=r.access?void 0:null,C="number"==typeof a&&Number.isFinite(a)?a:null,B=d((r.useFollowsSides??T)())??[...u],O=d(b)??B,A=[{value:"tl",label:t("Top left")},{value:"tr",label:t("Top right")},{value:"bl",label:t("Bottom left")},{value:"br",label:t("Bottom right")}];/* @__PURE__ */
4
+ return w(h,{label:t("Corners"),icon:/* @__PURE__ */w(m,{}),changed:null!==C||Array.isArray(b),action:/* @__PURE__ */w(i,{label:t("Corners"),changed:null!==C||Array.isArray(b),detail:`${c}px`,onReset:()=>Array.isArray(b)?v([[r.key,j],[r.sidesKey,j]]):y(j),words:n}),children:/* @__PURE__ */w(s,{label:t("Corners"),value:O,corners:A,onChange:e=>{const o=u.filter(o=>e.includes(o)),r=o.length===B.length&&o.every(e=>B.includes(e));g(r?j:o)},radius:C,onRadiusChange:e=>y(e??j),radiusMin:0,radiusMax:40,radiusStep:r.step??1,radiusPlaceholder:String(c),disabled:l.readOnly})})}function x(e=g){return{colourField:o=>({type:"custom",render:r=>/* @__PURE__ */w(C,{o:o,say:e,props:r})}),borderField:o=>({type:"custom",render:r=>/* @__PURE__ */w(O,{o:o,say:e,props:r})}),cornersField:o=>({type:"custom",render:r=>/* @__PURE__ */w(R,{o:o,say:e,props:r})})}}var{colourField:D,borderField:I,cornersField:K}=x();export{B as BORDER_WIDTH_MAX,A as CORNER_RADIUS_MAX,I as borderField,D as colourField,K as cornersField,j as keptByRow,x as styleFieldBuilders};
@@ -1 +1 @@
1
- import{useScreenDocument as n}from"./chunk-BYONFJVQ.js";import{DEFAULT_SCREEN_WORDS as o}from"./chunk-Q3VAJMXS.js";import{EditNotice as r}from"./chunk-VBEVZZTV.js";import{useWords as e}from"./chunk-MFIRYGHW.js";import{jsx as i}from"react/jsx-runtime";function t(){const{capabilities:t,access:c,takeOverEditing:a,viewReadOnly:s,saveConflict:m,reloadFromServer:u}=n(),{noun:l}=e("screen",o);return t.hasEditGuard?/* @__PURE__ */i(r,{access:c,conflict:m,noun:l,onTakeOver:a,onViewReadOnly:s,onReload:u}):null}export{t as PageEditGuardNotices};
1
+ import{useScreenDocument as n}from"./chunk-CPIWSFGR.js";import{DEFAULT_SCREEN_WORDS as o}from"./chunk-C4TJN6GR.js";import{EditNotice as r}from"./chunk-VBEVZZTV.js";import{useWords as e}from"./chunk-MFIRYGHW.js";import{jsx as i}from"react/jsx-runtime";function t(){const{capabilities:t,access:c,takeOverEditing:a,viewReadOnly:s,saveConflict:m,reloadFromServer:u}=n(),{noun:l}=e("screen",o);return t.hasEditGuard?/* @__PURE__ */i(r,{access:c,conflict:m,noun:l,onTakeOver:a,onViewReadOnly:s,onReload:u}):null}export{t as PageEditGuardNotices};
@@ -0,0 +1,19 @@
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 y}from"./chunk-3BQT7FC7.js";import{DEFAULT_COPY_WORDS as v}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 A,frameRectToHost as D,drawnBox as M}from"./chunk-FR7EEKFF.js";import{queryAllCopies as O}from"./chunk-7UFKEX72.js";import{find as $,ROOT_ID as P,getList as j,remove as z,parseZoneKey as R,move as L,duplicate as B,replaceNode as N,createNode as V,insert as K,normalizeData as T,createResolveCache as F,slotsOf as Z,deepEqual as H,ROOT_SLOT as W,resolveNodeData as q}from"./chunk-EUFDQ4KL.js";import{topLevelSlotKeys as Q,fieldsFrom as Y,drawnBlockCount as U,defaultsFrom as X}from"./chunk-KXM6YRG2.js";import{createContext as G,useEffect as J,useContext as _,useRef as ee,useSyncExternalStore as te,useState as ne,useReducer as oe,useCallback as re,createElement as le,useMemo as ie,useLayoutEffect as se}from"react";import{jsx as ae,jsxs as ce,Fragment as ue}from"react/jsx-runtime";import{createPortal as de}from"react-dom";import{registerModalEscapeInterceptor as pe,FloatingBar as fe,TextToolbar as he,LinkPicker as me}from"efficient-shell/ui";function ge(e){return!["setData","setUi","set"].includes(e.type)}var ye=(e,t,n,o)=>{const r=j(e,t,R(n));return r?.[o]??null},ve=(e,t,n,o,r)=>{const l=ye(e,t,n,o);if(!l)throw new Error(`${r}: nothing at ${n}[${o}]`);return l};function we(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 be(e,t,n){return n?"node"===n.kind?$(e,t,n.id)?n:null:n.parentId===P?j(e,t,n)?n:null:$(e,t,n.parentId)&&j(e,t,n)?n:null:null}function ke(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 Se(e,t,n){const o=xe(e,t,n);if(o===e)return e;const r=be(o.data,n,o.selection);return r===o.selection?o:{...o,selection:r}}function xe(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 ke(e,n,"function"==typeof t.ui?t.ui(we(e,n)):t.ui);case"set":{const r={data:o,ui:we(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=ke(i,n,l.ui,!0)),i}case"insert":{const r={...R(t.destinationZone),index:t.destinationIndex},l=V(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:N(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=B(o,n,r.props.id),i=ye(l,n,t.sourceZone,t.sourceIndex+1);return{...e,data:l,selection:i?{kind:"node",id:i.props.id}:e.selection}}case"reorder":return xe(e,{...t,type:"move",sourceZone:t.destinationZone},n);case"move":{if(t.sourceZone===t.destinationZone&&t.sourceIndex===t.destinationIndex)return e;const r=ye(o,n,t.sourceZone,t.sourceIndex);if(!r)return e;const l={...R(t.destinationZone),index:t.destinationIndex};return{...e,data:L(o,n,r.props.id,l)}}case"remove":{const r=ve(o,n,t.zone,t.index,"remove");return{...e,data:z(o,n,r.props.id)}}default:return e}}var Ce={drag:!0,duplicate:!0,delete:!0,edit:!0,insert:!0},Ee={leftSideBarVisible:!0,rightSideBarVisible:!0,arrayState:{},componentList:{},isDragging:!1,previewMode:"edit",viewports:{current:{width:360,height:"auto"},options:[],controlsVisible:!0},field:{focus:null}},Ie=0,Ae=()=>`history-${Ie+=1}`;function De(e){let t=e.config;const n=e.now??(()=>Date.now()),o=e.historyCoalesceMs??250;let i=e.permissions??{};const s=T(e.data,t);let a=s,c={data:s,selection:null,ui:{...Ee}};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:{...Ee,...r}}}let u=[{core:c,at:-1/0,sealed:!0,id:Ae()}],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:Ae()}],d=u.length-1)},f=/* @__PURE__ */new Set;let h=null,m=null,g=0,y=null,v=!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?v=v||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=Se(c,e,t),c===n)return;const o=e.recordHistory??ge(e);k(n,o&&c.data!==n.data)},x=t=>{0===g&&(y=c,v=!1),g+=1;try{t()}catch(e){throw g-=1,0===g&&y&&(c=y,y=null),e}if(g-=1,g>0||!y)return;const n=y;y=null,v&&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=be(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{...Ce,...i,...n}};let A=I();const D=F(),M={resolveCache:D,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([q(r,t,{cache:D,trigger:e,metadata:n}),...l.map(o=>q(o,t,{cache:D,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=$(r,t,i)?.node;s&&s===$(o,t,i)?.node&&(r=N(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:be(r,t,c.selection)},k(n,!1))})},async resolveNode(e,{trigger:n="replace",metadata:o}={}){const r=$(c.data,t,e)?.node;if(!r)return!1;const l=await q(r,t,{cache:D,trigger:n,metadata:o});if(!l.didChange)return!1;let i=!1;return x(()=>{const n=c;if($(c.data,t,e)?.node!==r)return;const o=N(c.data,t,e,l.node);o!==c.data&&(c={...c,data:o,selection:be(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:we(e,t)},o="node"===e.selection?.kind?$(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:we(e.core,t)}})),index:d,setHistoryIndex:e=>{e>=0&&e<u.length&&e!==d&&E(e)}},getPermissions:A,getItemById:n=>$(e.data,t,n)?.node,getItemBySelector:n=>function(e,t,n){const[o,r]=(n.zone??"root:default-zone").split(/:(.*)/s);return j(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:be(e.data,t,o)},k(n,e.data!==n.data)})},load(e,n={}){const o=c,r=T(e,t);c={...c,data:r,selection:be(r,t,n.selection??c.selection)},a=r,n.keepHistory||(u=[{core:c,at:-1/0,sealed:!0,id:Ae()}],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,A=I(),h=null,w())},setConfig(e){e!==t&&(t=e,A=I(),h=null,w())}};return M}function Me(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 Oe=G(null),$e=G(!0);function Pe({easel:e,hotkeys:t=!0,resolveOnMount:n=!0,children:o}){return J(()=>{n&&e.resolveAll()},[e,n]),J(()=>{if(t&&"undefined"!=typeof document)return Me(document,e)},[e,t]),/* @__PURE__ */ae(Oe.Provider,{value:e,children:/* @__PURE__ */ae($e.Provider,{value:t,children:o})})}function je(){const e=_(Oe);if(!e)throw new Error("useEasel: no <EaselProvider> above this component");return e}function ze(e){const t=je(),n=ee({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 te(t.subscribe,o,o)}function Re(){return function(e){return ze(e)}}var Le=["--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"],Be="host-tokens";function Ne(e,t){const n=function(e){const t=e.ownerDocument.defaultView;if(!t)return"";const n=t.getComputedStyle(e),o=[];for(const e of Le){const t=n.getPropertyValue(e).trim();t&&o.push(`${e}: ${t};`)}return o.length?`:root { ${o.join(" ")} }`:""}(e);n?E(t,Be,n):I(t,Be)}var Ve="data-easel-block",Ke="data-easel-dropzone",Te={},Fe="data-es-mirror",Ze="undefined"==typeof window?J:se;function He(e,t,n){for(const e of Array.from(t.head.querySelectorAll(`[${Fe}]`)))e.remove();for(const o of Array.from(e.head.querySelectorAll('style, link[rel="stylesheet"]'))){const e=o.cloneNode(!0);e.setAttribute(Fe,""),n&&e.setAttribute("nonce",n),t.head.appendChild(e)}}function We({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=ee(null),[p,f]=ne(null);return Ze(()=>{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]),Ze(()=>{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){He(o,e,c);const t=o.defaultView;t&&"MutationObserver"in t&&(n=new t.MutationObserver(()=>He(o,e,c)),n.observe(o.head,{childList:!0,subtree:!0,characterData:!0}))}let r=null;const l=d.current;if(l&&o){Ne(l,e);const t=o.defaultView;if(t&&"MutationObserver"in t){r=new t.MutationObserver(()=>Ne(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__ */ae("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?de(e,p):null})}var qe=G(null),Qe=G(Te),Ye=[];function Ue({parentId:e,slot:t,className:n,style:o,minEmptyHeight:r=128,minEmptyWidth:l=120}){const i=je(),s=ze(n=>j(n.appState.data,i.config,{parentId:e,slot:t})??Ye),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=_(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__ */ae("div",{className:d.join(" "),[Ke]:`${e}:${t}`,style:{...o,"--min-empty-height":`${r}px`,"--min-empty-width":`${l}px`},children:s.map(e=>/* @__PURE__ */ae(ot,{node:e},e.props.id))})}function Xe(e,t,n,o){const r=ie(()=>{const n={};for(const o of Q(Y(e)))n[o]=Object.assign(function(e={}){/* @__PURE__ */
2
+ return ae(Ue,{parentId:t,slot:o,...e})},{blockCount:0});return n},[e,t]);for(const e of Object.keys(r))r[e].blockCount=U(n[e],o);return r}function Ge(e){return ie(()=>function({zone:t,...n}){/* @__PURE__ */
3
+ return ae(Ue,{parentId:e,slot:t,...n})},[e])}var Je=["top","bottom","zIndex"];function _e(e,t,n){e.style[t]!==n&&(e.style[t]=n)}function et(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));_e(e,"position",t?"sticky":"relative");for(const n of Je)_e(e,n,t?.[n]??"");return!!t}var tt="data-es-canvas-relative";function nt(e){e.hasAttribute(tt)&&("relative"===e.style.position&&(e.style.position=""),e.removeAttribute(tt));const t=e.ownerDocument.defaultView?.getComputedStyle(e).position;return t&&"static"!==t?"sticky"===t:(e.style.position||(e.style.position="relative",e.setAttribute(tt,"")),!1)}function ot({node:e}){const t=je().config,n=t.components[e.type],o=e.props.id,r=ee(null),l=function(e,t){return ie(()=>n=>{const o=t.current;o&&o!==n&&(o.removeAttribute(Ve),o.removeAttribute("data-easel-dnd")),t.current=n,n&&(n.setAttribute(Ve,e),n.setAttribute("data-easel-dnd",e),nt(n))},[e,t])}(o,r),i=ee(null),s=!!n?.inline;!function(e,t){const n=ee(!1),o=ee(()=>{});o.current=()=>{const o=e(),l=n.current;n.current=!!o&&t(o),l!==n.current&&r.current()};const r=ee(()=>{});Ze(()=>o.current()),Ze(()=>{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?nt(e):et(e));const a=_(Qe),c=Xe(n,o,e.props,t.components),u=Ge(o);if(!n?.render)return null;const d=n.render,p={...X(n),...e.props,...c},f={renderDropZone:u,isEditing:!0,dragRef:n.inline?l:null,metadata:{...a,...n.metadata}};return n.inline?/* @__PURE__ */ae(d,{...p,editor:f,editMode:!0}):
4
+ /* @__PURE__ */ae("div",{ref:i,[Ve]:o,"data-easel-dnd":o,style:{position:"relative"},children:/* @__PURE__ */ae(d,{...p,editor:f,editMode:!0})})}function rt({metadata:e}){const t=ze(e=>e.config),n=ze(e=>e.appState.data.root).props??{},o=t.root?.render,r=Xe(t.root,P,n,t.components),l=Ge(P),i=/* @__PURE__ */ae(Ue,{parentId:P,slot:W}),s=o?/* @__PURE__ */ae(o,{id:"page-root",...n,...r,editor:{renderDropZone:l,isEditing:!0,dragRef:null,metadata:e??{}},editMode:!0,children:i}):i;/* @__PURE__ */
5
+ return ae(Qe.Provider,{value:e??Te,children:s})}var lt=G(void 0),it=G(void 0);function st(e,t,n,o){const r=$(e,t,n);return!!r&&(Z(r.node,t).length>0||!1===o.whole)}var at=G(void 0),ct="data-es-chrome",ut=G(void 0);function dt(e){const t=e?.closest?.(`[${ct}]`)??null,n=t?.getAttribute(ct);return t&&n?{id:n,element:t}:null}function pt({element:e,clip:t=!1}){const n=ee(null),o=mt(n,e?()=>e:null,e),r=_(St);/* @__PURE__ */
6
+ return ae("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?kt(o,r):void 0}:{display:"none"}})}var ft={"--es-words-clear":`${A}px`};function ht({element:e,words:t=!1,clip:n=!1}){const o=ee(null),r=mt(o,e?()=>e:null,e),l=_(St);/* @__PURE__ */
7
+ return ae("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?kt(r,l):void 0,...ft}:{display:"none"}})}function mt(e,t,n){return yt(e,t?e=>{const n=t(e);return n?[n]:[]}:null,n)[0]??null}var gt=[];function yt(e,t,n){const[o,r]=ne(gt),l=ee(t);return l.current=t,Ze(()=>{const t=e.current?.ownerDocument,n=t?.defaultView;if(!t||!n||!l.current)return void r(gt);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:gt;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=A+2,wt=vt+2,bt=1;function kt(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-bt):t.left,e.left-wt)-e.left,s=Math.max(t.top<=e.top&&l>e.top?Math.min(t.top,e.top-bt):t.top,e.top-wt)-e.top,a=Math.min(r>=n&&t.left<n?Math.max(r,n+bt):r,n+wt)-e.left,c=Math.min(l>=o&&t.top<o?Math.max(l,o+bt):l,o+wt)-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${-wt} ${-wt}h${e.width+2*wt}v${e.height+2*wt}h${-(e.width+2*wt)}z`}${l.map(e=>`M${e.x} ${e.y}h${e.w}v${e.h}h${-e.w}z`).join("")}")`}var St=G([]);function xt({children:e}){const t=ee(null),n=_(ut),o=yt(t,n?e=>Array.from(e.querySelectorAll(`[${ct}]`)):null,n?1:0);/* @__PURE__ */
8
+ return ce("div",{className:"es-canvas-outlines",style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:[
9
+ /* @__PURE__ */ae("span",{ref:t,hidden:!0,"aria-hidden":"true"}),
10
+ /* @__PURE__ */ae(St.Provider,{value:o,children:e})]})}function Ct({id:e,kind:t,overlay:n}){const o=ee(null),r=_(it),l=null!==e&&!0===r?.(e),i=yt(o,e?t=>O(t,`[${Ve}="${t.defaultView?.CSS?.escape?t.defaultView.CSS.escape(e):e}"]`):null,e),[s,...a]=i,c=_(St),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:kt(e,c)}),p=/* @__PURE__ */ce(ue,{children:[
11
+ /* @__PURE__ */ae("div",{ref:o,"aria-hidden":"true",className:u,style:s?d(s):{display:"none"}}),a.map((e,t)=>/* @__PURE__ */ae("div",{"aria-hidden":"true",className:u,style:d(e)},t))]});return n&&e?/* @__PURE__ */ae(n,{componentId:e,kind:t,children:p}):p}function Et(e,n){return Array.from(e.querySelectorAll(`[${Ve}]`)).find(o=>o.getAttribute(Ve)===n&&t(o)?.wrapper===e)??null}function It(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 At({s:e,element:t,toolbar:n,label:o,keys:r}){const l=w("copy",v),i=e.pressed(),s=new Set(n.offered),a=n.colors&&n.colors.length>0?n.colors:null,c=ee(null),[m,g]=ne(!1),[y,b]=ne(null),k=m||null!==y,S=()=>{e.hold(),g(!1),b({href:e.pressed().href})},x=()=>{g(!1),b(null),e.resume()};se(()=>{r.current={escape:()=>!!k&&(x(),!0),link:()=>!!s.has("link")&&(S(),!0)}}),se(()=>()=>{r.current=null},[r]);const C=ee(x);C.current=x,J(()=>{if(m)return pe(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]),J(()=>{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]),se(()=>{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?D(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?D(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)},y=e.ownerDocument.documentElement,v=(s??o.closest(".es-canvas")??o).getBoundingClientRect(),w={left:Math.max(0,v.left),top:Math.max(0,v.top),right:Math.min(y.clientWidth||v.right,v.right),bottom:Math.min(y.clientHeight||v.bottom,v.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:v.left,top:v.top,right:v.right,bottom:v.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 ae(fe,{anchor:()=>{const e=t();if(!e)return null;const n=e.getBoundingClientRect(),o=e.ownerDocument.defaultView?.frameElement,r=o?D(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__ */ae("div",{ref:c,children:/* @__PURE__ */ae(he,{layout:"row",offered:s,pressed:i.marks,onMark:t=>{"link"===t?S():e.press(t)},color:E,linkOpen:null!==y,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),style:i.style,applyStyle:t=>e.textStyle(t)}),windows:/* @__PURE__ */ce(ue,{children:[m&&a?/* @__PURE__ */ae(h,{colors:a,current:i.color,words:l.colors??v.colors,onPick:t=>e.color(t)}):null,y?
13
+ /* @__PURE__ */ae(me,{className:"es-copy-link es-copy-pop",value:y.href??"",onApply:t=>{b(null),e.link(t)},onRemove:null!==y.href?()=>{b(null),e.link(null)}:void 0,onCancel:x}):null]})})})})}function Dt({element:e,which:t}){const n=ee(null),o=mt(n,()=>e(),t),r=_(St);/* @__PURE__ */
14
+ return ae("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:kt(o,r),...ft}:{display:"none"}})}function Mt({frame:o=!0,className:r,style:l,metadata:i,mirrorStyles:u,onDocument:d,height:p,title:f,nonce:h,hotkeys:v,frameWrapper:S,overlay:C,children:E,typing:I,passThrough:A}){const D=je(),M=_(lt),O=A??M,P=_($e),j=w("canvas",n),z=v??P,[R,L]=ne(void 0),B=ze(e=>"node"===e.selection?.kind?e.selection.id:null),[N,V]=ne(null),[K,T]=ne(null),F=_(at),H=_(ut),[W,q]=ne(null),[,Q]=oe(e=>e+1,0),[,Y]=oe(e=>e+1,0),U=e=>{F?.select(e),Y()},[X,G]=ne(null),te=ee(null),re=ee(null),[,le]=ne(0),ie=ee(I);ie.current=I;const se=ee(null),ue=ee(null),de=()=>{if(!B)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=$(D.getState().appState.data,D.config,B);return n&&0===Z(n.node,D.config).length?e:null},pe=ze(e=>e.appState.data),fe=F?.selected()??null;J(()=>{const e=ue.current?.ownerDocument,t=e?.defaultView?.CustomEvent;if(!e||!t)return;const n=B&&!X&&ie.current?.atSelection?.()?B:null,o=n?de():null;e.dispatchEvent(new t(b,{detail:o?{id:n,words:o}:{id:n}}))},[B,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)=>{te.current?.s.stop("stop");const n=e.element();if(!n)return!1;const o=ge(e,n),r=D.group(),l=e.element,i=m({element:l,value:o?.value??e.value,rules:e.rules,multiline:e.multiline,skip:e.skip,caret:It(n,t,e.skip),write:o?.write??e.write,remount:e.remount,onSelect:()=>le(e=>e+1),onEscape:()=>se.current?.escape()??!1,onLinkKey:()=>se.current?.link()??!1,end:e=>{r.close(),te.current?.element===l&&(te.current=null),G(null),he(!1),ie.current?.onChange?.({typing:!1,why:e})}});if(!i)return r.close(),!1;const s=n.closest?.(`[${Ve}]`)?.getAttribute(Ve);return s&&D.select(s),te.current={s:i,element:l,target:e},G(()=>l),V(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?.(`[${Ve}]`),i=l?.getAttribute(Ve);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??(y(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)}}};J(()=>()=>te.current?.s.stop("stop"),[]);const ye=e=>{const t=te.current?.element();return Boolean(t&&t.contains(e))},ve=(e,t)=>st(D.getState().appState.data,D.config,e,t),we=e=>{const t=e.closest?.(`[${Ve}]`)?.getAttribute(Ve);if(!t)return;const n=D.getState(),o="node"===n.selection?.kind?n.selection.id:null,r=F?.partAt(e,t)??null;if(r){const e=a(n.appState.data,D.config,t,r.id,o,F?.selected()??null,O);if(e)return{node:e.node,part:e.part?r:null}}return{node:c(n.appState.data,D.config,t,o,O)??t,part:null}},be=e=>{if("Enter"!==e.key||e.defaultPrevented||e.shiftKey||e.metaKey||e.ctrlKey||e.altKey)return;if(te.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!==B)return;const o=ue.current,r=o?e(o,n.copy):null,l=r?Et(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(`[${Ve}]`);if(!n||n.getAttribute(Ve)!==t.getAttribute(Ve))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&&Et(o.wrapper,n)?o.copy:null},xe=ue.current?.ownerDocument??null,Ce=F?.selected()&&xe&&B?F.selectedPart?.(xe)??null:null,Ee=Ce&&B&&ve(B,Ce)?Ce.element:null,Ie=H?.selected()??null,Ae=Ie&&xe?Array.from(xe.querySelectorAll(`[${ct}]`)).find(e=>e.getAttribute(ct)===Ie)??null:null,De=X?null:de(),Oe=/* @__PURE__ */ce("div",{ref:ue,className:"es-canvas-content",style:{position:"relative"},onClick:e=>{const t=e.target;if(t.closest?.("a[href]")&&e.preventDefault(),te.current){if(ye(t))return;te.current.s.stop("outside")}const n=t.ownerDocument?.getSelection?.();n&&n.rangeCount>0&&n.isCollapsed&&n.removeAllRanges();const o=H?dt(t):null;if(H&&o)return H.select(o.id),q(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 D.select(r.node),void(F&&(r.part?.id??null)!==F.selected()&&U(r.part?.id??null));t.hasAttribute?.(Ke)||(D.select(null),F?.selected()&&U(null))},onDoubleClick:e=>{const t=ie.current;if(!t||ye(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(te.current)return;const t=H?dt(e.target):null;if(t?.element!==W?.element&&q(t),t)return null!==N&&V(null),void(null!==K&&T(null));const n=we(e.target),o=!!n?.part&&ve(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!==N&&V(l),r?.id===K?.id&&r?.element===K?.element||T(r)},onMouseLeave:()=>{V(null),T(null),q(null)},children:[
15
+ /* @__PURE__ */ae(qe.Provider,{value:N,children:/* @__PURE__ */ae(rt,{metadata:i})}),
16
+ /* @__PURE__ */ce(xt,{children:[
17
+ /* @__PURE__ */ae(Ct,{id:!X&&N&&N!==B?N:null,kind:"hover",overlay:C}),F?/* @__PURE__ */ae(pt,{clip:!0,element:X||!K||K.id===F.selected()?null:K.element}):null,De||Ee?/* @__PURE__ */ae(ht,{clip:!0,element:X?null:De??Ee,words:null!==De}):null,H?/* @__PURE__ */ae(pt,{element:X||!W||W.element===Ae?null:W.element}):null,Ae?/* @__PURE__ */ae(ht,{element:X?null:Ae}):null,
18
+ /* @__PURE__ */ae(Ct,{id:X||Ee||De||Ae?null:B,kind:"selected",overlay:C}),X?/* @__PURE__ */ae(Dt,{element:()=>{const e=X?.()??null;return e?Ce&&x(Ce.element,e)?Ce.element:e:null},which:Ce?.element??X}):null]}),E]}),Pe=S?/* @__PURE__ */ae(S,{document:R,children:Oe}):Oe;J(()=>{if(R&&z)return Me(R,D)},[R,z,D]),J(()=>{if(!R)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=D.getState();if("node"!==n.selection?.kind)return;if(F?.selected())return void U(null);const o=s(n.appState.data,D.config,n.selection);"node"===o?.kind&&D.select(o.id)};return R.addEventListener("keydown",e),()=>R.removeEventListener("keydown",e)},[R,D,F]);/* @__PURE__ */
19
+ return ce("div",{className:"es-canvas"+(r?` ${r}`:""),style:l,"data-easel-preview":"","data-es-typing":X?"":void 0,children:[X&&te.current?.target.toolbar?/* @__PURE__ */ae(At,{s:te.current.s,element:te.current.element,toolbar:te.current.target.toolbar,label:j.textTools,keys:se}):null,o?/* @__PURE__ */ae(We,{mirrorStyles:u,onDocument:e=>{L(e??void 0),d?.(e)},height:p,title:f,nonce:h,children:Pe}):/* @__PURE__ */ae("div",{id:"preview-frame","data-easel-entry":"",children:Pe})]})}function Ot(e={}){const t=je(),n=ze(e=>e.appState.data);return i({...e,data:n,config:t.config,commit:(e,{select:n})=>t.run({data:e,select:n})})}var $t=/* @__PURE__ */new WeakMap,Pt=[];function jt(e){let t=$t.get(e);return t||(t={nodes:/* @__PURE__ */new Map,shown:/* @__PURE__ */new Map,listeners:/* @__PURE__ */new Set,lateListeners:/* @__PURE__ */new Set,settled:[]},$t.set(e,t)),t}function zt(e,t){const n=e.nodes.get(t),o=n?[...n.running,...n.next]:Pt;o.length?e.shown.set(t,o):e.shown.delete(t),e.listeners.forEach(e=>e())}function Rt(e,t,n,o){const r=jt(e),l=r.nodes.get(t);l?l.next=[...l.next,n]:r.nodes.set(t,{running:Pt,next:[n]}),zt(r,t),l||Promise.resolve().then(()=>Lt(r,t,o))}function Lt(e,t,n){const o=e.nodes.get(t);if(!o)return;if(!o.next.length)return e.nodes.delete(t),zt(e,t),void(e.nodes.size||e.settled.splice(0).forEach(e=>e()));const r=o.next;o.running=r,o.next=Pt;let l=!0;const i=()=>{l=!1,clearTimeout(a),o.running=Pt,zt(e,t)};let s=!1;const a=setTimeout(()=>{s=!0,i();try{n.landWithoutAnswer(r)&&(e.lateListeners.forEach(e=>e()),Promise.reject(new Error(`A write to ${t} landed without its resolver's answer after 60000 ms.`)))}catch(e){Promise.reject(e)}Lt(e,t,n)},6e4);n.run(r,{live:()=>l,landing:i}).catch(e=>{if(!s)throw e}).finally(()=>{s||(l&&i(),Lt(e,t,n))})}function Bt(e){const t=jt(e);return t.nodes.size?new Promise(e=>t.settled.push(e)):Promise.resolve()}function Nt(){const e=je(),t=ee([]),n=ee(!1),[o,r]=ne(!1),[,l]=oe(e=>e+1,0);J(()=>{t.current.splice(0).forEach(e=>e())});return{run:re(o=>{n.current||(n.current=!0,r(!0),Bt(e).then(()=>new Promise(e=>{t.current.push(e),l()})).then(()=>{n.current=!1,r(!1),o()}))},[e]),waiting:o}}function Vt(e){const t=Nt(),n=ee(e);return n.current=e,{...e,busy:!0===e.busy||t.waiting,onPress:()=>t.run(()=>n.current.onPress())}}function Kt(e,t){const{lateListeners:n}=jt(e);return n.add(t),()=>{n.delete(t)}}var Tt=e=>"object"==typeof e&&null!==e&&Object.getPrototypeOf(e)===Object.prototype;function Ft(e,t,n){if(t===e)return n;if(Array.isArray(e)&&Array.isArray(t)&&Array.isArray(n)){if(e.length!==n.length||e.some((e,t)=>n.includes(e)&&n[t]!==e))return t;const o=e.length===t.length&&1===t.filter((t,n)=>t!==e[n]).length;return t.map((t,r)=>{if(t===e[r])return n[r];const l=Tt(t)?e.indexOf(t):-1;return l>=0?n[l]:o?Ft(e[r],t,n[r]):t})}if(Tt(e)&&Tt(t)&&Tt(n)){const o={...n};for(const n of Object.keys(e))n in t||delete o[n];for(const r of Object.keys(t))o[r]=Ft(e[r],t[r],n[r]);return o}return t}function Zt(e,t){let n=null;for(const o of e){const e="function"==typeof o?o({...t,...n}):o;e&&(n={...n,...e})}return n}function Ht(e,t){if(!e.length)return t;try{return{...t,...Zt(e,t)}}catch{return t}}function Wt(){return Xt(ze(e=>e.selectedItem))}function qt(){const e=_(Qt);try{return function(e){const t=ze(e=>e.selectedItem);return Xt("root"===e?null:t)}(e)}catch{return null}}var Qt=G("selected");function Yt({children:e}){return le(Qt.Provider,{value:"root"},e)}function Ut(){return Xt(null)}function Xt(e){const t=je(),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=ie(()=>e||{type:"root",props:s},[e,s]),c=e?n.components[e.type]:n.root,u=t.getState(),d=e?$(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=re(e=>{Rt(t,i,e,{landWithoutAnswer:e=>{const n=t.getState();if("root"===i){const o=n.appState.data.root.props??{},r=Zt(e,o);return!!r&&(t.dispatch({type:"replaceRoot",root:{props:{...o,...r},readOnly:n.appState.data.root.readOnly},recordHistory:!0}),!0)}const o=n.getItemById(i),r=n.getSelectorForId(i);if(!o||!r)return!1;const l=Zt(e,o.props);return!!l&&(t.dispatch({type:"replace",destinationZone:r.zone??"root:default-zone",destinationIndex:r.index,data:{...o,props:{...o.props,...l}}}),!0)},run:async(e,{live:n,landing:o})=>{for(let l=1;;l+=1){const s=t.getState(),a={...r,lastChange:Object.create(r.lastChange)},c=()=>{o(),Object.assign(r.lastChange,a.lastChange)};if("root"!==i){const o=s.getItemById(i);if(!o)return;const r=Zt(e,o.props);if(!r)return;const u={...o,props:{...o.props,...r}},{node:d}=await q(u,t.config,{cache:a,trigger:"replace"});if(!n())return;const p=t.getState(),f=p.getSelectorForId(i);if(!f)return;if(p.getItemById(i)!==o&&l<5)continue;return c(),void t.dispatch({type:"replace",destinationZone:f.zone??"root:default-zone",destinationIndex:f.index,data:d})}const u=s.appState.data.root.props??{},d=Zt(e,u);if(!d)return;const{node:p}=await q({type:"root",props:{...u,...d}},t.config,{cache:a,trigger:"replace"});if(!n())return;if(!(t.getState().appState.data.root.props!==s.appState.data.root.props&&l<5))return c(),void t.dispatch({type:"replaceRoot",root:{props:p.props,readOnly:p.readOnly},recordHistory:!0})}}})},[t,r,i]),y=re(e=>{const{listeners:n}=jt(t);return n.add(e),()=>{n.delete(e)}},[t]),v=re(()=>jt(t).shown.get(i)??Pt,[t,i]),w=te(y,v,v),b=ie(()=>Ht(w,a.props),[w,a.props]),k=ee({id:i,values:b});k.current={id:i,values:b};const S=re((e,n)=>{const o=t.getState(),r=("root"===i?o.appState.data.root.props:o.getItemById(i)?.props)??{},l=Ht(jt(t).shown.get(i)??Pt,r),s=k.current,a=(s.id===i?s.values:l)[e];H(n,a)&&!H(l[e],a)?g({[e]:n}):g(t=>({[e]:Ft(a,n,t[e])}))},[t,i,g]);return{id:i,node:a,fields:h,values:b,readOnly:m,onChange:S,onChangeMany:g}}export{ct as CHROME_ATTR,ut as CanvasChromeContext,We as CanvasFrame,at as CanvasPartsContext,lt as CanvasPassThroughContext,it as CanvasSharedContext,Ee as DEFAULT_UI,Mt as EaselCanvas,Pe as EaselProvider,rt as EditDocument,Yt as RootHostScope,Me as bindUndoKeys,De as createEasel,Re as createUseEasel,st as partHasOwnBox,ge as recordsByDefault,Se as reduce,Kt as subscribeLateWrites,we as uiView,ze as useEasel,je as useEaselApi,Ot as useEaselNodeOps,Ut as useRootFields,Wt as useSelectedFields,qt as useSelectedHost,Vt as useSettledAction,Nt as useSettledPress,be as validSelection,Bt as writesSettled};